tangled
alpha
login
or
join now
danabra.mov
/
inlay
42
fork
atom
social components
inlay-proto.up.railway.app/
atproto
components
sdui
42
fork
atom
overview
issues
pulls
pipelines
cache lexicons
danabra.mov
6 days ago
de36f219
d3ae060e
+20
-5
3 changed files
expand all
collapse all
unified
split
proto
package.json
src
render.tsx
resolver.ts
+3
-2
proto/package.json
···
7
7
"start": "tsx --conditions source src/index.tsx"
8
8
},
9
9
"dependencies": {
10
10
+
"@atproto/lex-resolver": "^0.0.15",
11
11
+
"@atproto/syntax": "^0.3.0",
12
12
+
"@hono/node-server": "^1.19.9",
10
13
"@inlay/core": "*",
11
14
"@inlay/render": "*",
12
12
-
"@atproto/syntax": "^0.3.0",
13
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
24
-
return { resolver, validate: false };
24
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
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
6
+
7
7
+
const lexResolver = new LexResolver({});
5
8
6
9
type CacheTag = {
7
10
$type: string;
···
129
132
return value;
130
133
},
131
134
132
132
-
async resolveLexicon() {
133
133
-
return null;
135
135
+
async resolveLexicon(nsid) {
136
136
+
const key = `lexicon:${nsid}`;
137
137
+
const hit = await cacheGet(key);
138
138
+
if (hit !== undefined) return hit;
139
139
+
140
140
+
try {
141
141
+
const { lexicon } = await lexResolver.get(nsid);
142
142
+
await cacheSet(key, lexicon, { life: "hours" });
143
143
+
return lexicon;
144
144
+
} catch {
145
145
+
await cacheSet(key, null, { life: "hours" });
146
146
+
return null;
147
147
+
}
134
148
},
135
149
};
136
150
}