import { isDid, isNsid, Nsid } from "@atcute/lexicons/syntax"; import { A, useNavigate, useParams } from "@solidjs/router"; import { createEffect, createSignal, ErrorBoundary, For, Show } from "solid-js"; import { resolveLexiconAuthority } from "../utils/api"; import { ATURI_RE } from "../utils/types/at-uri"; import { hideMedia } from "../views/settings"; import { pds } from "./navbar"; import Tooltip from "./tooltip"; import VideoPlayer from "./video-player"; interface AtBlob { $type: string; ref: { $link: string }; mimeType: string; } const JSONString = ({ data, isType }: { data: string; isType?: boolean }) => { const navigate = useNavigate(); const isURL = URL.canParse ?? ((url, base) => { try { new URL(url, base); return true; } catch { return false; } }); const handleClick = async (lex: string) => { try { const [nsid, anchor] = lex.split("#"); const authority = await resolveLexiconAuthority(nsid as Nsid); const hash = anchor ? `#schema:${anchor}` : "#schema"; navigate(`/at://${authority}/com.atproto.lexicon.schema/${nsid}${hash}`); } catch (err) { console.error("Failed to resolve lexicon authority:", err); } }; return ( " {(part) => ( <> {ATURI_RE.test(part) ? {part} : isDid(part) ? {part} : isNsid(part.split("#")[0]) && isType ? : ( isURL(part) && ["http:", "https:", "web+at:"].includes(new URL(part).protocol) && part.split("\n").length === 1 ) ? {part} : part} )} " ); }; const JSONNumber = ({ data }: { data: number }) => { return {data}; }; const JSONBoolean = ({ data }: { data: boolean }) => { return {data ? "true" : "false"}; }; const JSONNull = () => { return null; }; const JSONObject = ({ data, repo }: { data: { [x: string]: JSONType }; repo: string }) => { const params = useParams(); const [hide, setHide] = createSignal( localStorage.hideMedia === "true" || params.rkey === undefined, ); createEffect(() => { if (hideMedia()) setHide(hideMedia()); }); const Obj = ({ key, value }: { key: string; value: JSONType }) => { const [show, setShow] = createSignal(true); return ( ); }; const rawObj = ( {([key, value]) => } ); const blob: AtBlob = data as any; if (blob.$type === "blob") { return ( <> Failed to load video}> {rawObj} ); } return rawObj; }; const JSONArray = ({ data, repo }: { data: JSONType[]; repo: string }) => { return ( {(value, index) => ( )} ); }; export const JSONValue = (props: { data: JSONType; repo: string; isType?: boolean }) => { const data = props.data; if (typeof data === "string") return ; if (typeof data === "number") return ; if (typeof data === "boolean") return ; if (data === null) return ; if (Array.isArray(data)) return ; return ; }; export type JSONType = string | number | boolean | null | { [x: string]: JSONType } | JSONType[];