social components inlay-proto.up.railway.app/
atproto components sdui

cache lexicons

+20 -5
+3 -2
proto/package.json
··· 7 7 "start": "tsx --conditions source src/index.tsx" 8 8 }, 9 9 "dependencies": { 10 + "@atproto/lex-resolver": "^0.0.15", 11 + "@atproto/syntax": "^0.3.0", 12 + "@hono/node-server": "^1.19.9", 10 13 "@inlay/core": "*", 11 14 "@inlay/render": "*", 12 - "@atproto/syntax": "^0.3.0", 13 - "@hono/node-server": "^1.19.9", 14 15 "dotenv": "^16.5.0", 15 16 "hono": "^4.12.2", 16 17 "ioredis": "^5.6.0"
+1 -1
proto/src/render.tsx
··· 21 21 export type { RenderContext, JSXElement }; 22 22 23 23 export function createRenderOptions(resolver: Resolver): RenderOptions { 24 - return { resolver, validate: false }; 24 + return { resolver }; 25 25 } 26 26 27 27 export async function renderNode(
+16 -2
proto/src/resolver.ts
··· 1 1 import { AtUri } from "@atproto/syntax"; 2 + import { LexResolver } from "@atproto/lex-resolver"; 2 3 import { resolveDidToService } from "./resolve.ts"; 3 4 import { cacheGet, cacheSet } from "./cache.ts"; 4 5 import type { Resolver } from "@inlay/render"; 6 + 7 + const lexResolver = new LexResolver({}); 5 8 6 9 type CacheTag = { 7 10 $type: string; ··· 129 132 return value; 130 133 }, 131 134 132 - async resolveLexicon() { 133 - return null; 135 + async resolveLexicon(nsid) { 136 + const key = `lexicon:${nsid}`; 137 + const hit = await cacheGet(key); 138 + if (hit !== undefined) return hit; 139 + 140 + try { 141 + const { lexicon } = await lexResolver.get(nsid); 142 + await cacheSet(key, lexicon, { life: "hours" }); 143 + return lexicon; 144 + } catch { 145 + await cacheSet(key, null, { life: "hours" }); 146 + return null; 147 + } 134 148 }, 135 149 }; 136 150 }