social components inlay.at
atproto components sdui
86
fork

Configure Feed

Select the types of activity you want to include in your feed.

dedicated syntax for at uri decomposition

+24 -17
+22 -14
packages/@inlay/render/src/index.ts
··· 15 15 AtIdentifierString, 16 16 NsidString, 17 17 ensureValidNsid, 18 + ensureValidDid, 18 19 } from "@atproto/syntax"; 19 20 import { validateProps } from "./validate.js"; 20 21 ··· 212 213 return undefined; 213 214 } 214 215 if (typeof current === "string") { 215 - if (!current.startsWith("at://")) { 216 - return undefined; 216 + if (seg === "$did" || seg === "$collection" || seg === "$rkey") { 217 + if (!current.startsWith("at://")) { 218 + return undefined; 219 + } 220 + try { 221 + const parsed = new AtUri(current); 222 + if (seg === "$did") { 223 + ensureValidDid(parsed.host); 224 + current = parsed.host; 225 + } else if (seg === "$collection") { 226 + current = parsed.collection; 227 + } else if (seg === "$rkey") { 228 + current = parsed.rkey; 229 + } else { 230 + return undefined; 231 + } 232 + } catch { 233 + return undefined; 234 + } 235 + continue; 217 236 } 218 - try { 219 - const parsed = new AtUri(current); 220 - const uriParts: Record<string, string> = { 221 - did: parsed.host, 222 - collection: parsed.collection, 223 - rkey: parsed.rkey, 224 - }; 225 - current = uriParts[seg]; 226 - } catch { 227 - return undefined; 228 - } 229 - continue; 237 + return undefined; 230 238 } 231 239 if (typeof current !== "object") { 232 240 return undefined;
+2 -3
packages/@inlay/render/test/render.test.ts
··· 807 807 }); 808 808 809 809 it("skips record fetch when bindings only use props", async () => { 810 - // A Binding for ["props", "uri", "did"] is resolved via AT URI dotted 811 - // access on the props.uri string — no record fetch needed. 810 + // A Binding for ["props", "uri", "$did"] decomposes the AT-URI string. 812 811 const postCardComponent: ComponentRecord = { 813 812 $type: "at.inlay.component", 814 813 type: PostCard, 815 814 body: { 816 815 $type: "at.inlay.component#bodyTemplate", 817 816 node: serializeTree( 818 - $(Text, { value: $(Binding, { path: ["props", "uri", "did"] }) }) 817 + $(Text, { value: $(Binding, { path: ["props", "uri", "$did"] }) }) 819 818 ), 820 819 }, 821 820 imports: [HOST_PACK_URI],