@artblocks/abx-token-api 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abxjs.d.ts +13 -0
  3. package/dist/abxjs.d.ts.map +1 -0
  4. package/dist/abxjs.js +49 -0
  5. package/dist/abxjs.js.map +1 -0
  6. package/dist/art.d.ts +26 -0
  7. package/dist/art.d.ts.map +1 -0
  8. package/dist/art.js +85 -0
  9. package/dist/art.js.map +1 -0
  10. package/dist/code.d.ts +73 -0
  11. package/dist/code.d.ts.map +1 -0
  12. package/dist/code.js +216 -0
  13. package/dist/code.js.map +1 -0
  14. package/dist/dashboard.d.ts +12 -0
  15. package/dist/dashboard.d.ts.map +1 -0
  16. package/dist/dashboard.js +231 -0
  17. package/dist/dashboard.js.map +1 -0
  18. package/dist/deps.d.ts +146 -0
  19. package/dist/deps.d.ts.map +1 -0
  20. package/dist/deps.js +297 -0
  21. package/dist/deps.js.map +1 -0
  22. package/dist/index.d.ts +15 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +15 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/inline.d.ts +19 -0
  27. package/dist/inline.d.ts.map +1 -0
  28. package/dist/inline.js +23 -0
  29. package/dist/inline.js.map +1 -0
  30. package/dist/metadata.d.ts +89 -0
  31. package/dist/metadata.d.ts.map +1 -0
  32. package/dist/metadata.js +673 -0
  33. package/dist/metadata.js.map +1 -0
  34. package/dist/resolve.d.ts +74 -0
  35. package/dist/resolve.d.ts.map +1 -0
  36. package/dist/resolve.js +107 -0
  37. package/dist/resolve.js.map +1 -0
  38. package/dist/server.d.ts +91 -0
  39. package/dist/server.d.ts.map +1 -0
  40. package/dist/server.js +940 -0
  41. package/dist/server.js.map +1 -0
  42. package/dist/watcher.d.ts +56 -0
  43. package/dist/watcher.d.ts.map +1 -0
  44. package/dist/watcher.js +179 -0
  45. package/dist/watcher.js.map +1 -0
  46. package/package.json +50 -0
package/dist/deps.js ADDED
@@ -0,0 +1,297 @@
1
+ import { gunzipSync } from 'node:zlib';
2
+ import { padHex } from 'viem';
3
+ import { codeField } from '@artblocks/abx-sdk';
4
+ import { escapeInlineScript } from './inline.js';
5
+ /**
6
+ * Registry-aware dependency resolution — the resolver's leg of the
7
+ * specs/protocol/dependency-registry.md "Consumers" table:
8
+ *
9
+ * the collection's registry pointer: `availableOnChain` → serve the bytes
10
+ * → else `preferredCDN` → else the built-in CDN map (last resort, warns)
11
+ *
12
+ * The read interface is AB's IDependencyRegistryV0 shape (a hard compatibility rule —
13
+ * any registry a collection points at speaks it). Script chunks are stored gzip'd THEN
14
+ * base64'd; the resolver concatenates the chunk strings, base64-decodes, and gunzips
15
+ * server-side so the document inlines plain JS. Resolution NEVER throws — the document
16
+ * must always assemble; every failure degrades to the built-in map with one warn.
17
+ *
18
+ * This module also owns the query-string size budget for URL-carried tokenData (~8KB
19
+ * request-line caps at gateway front-ends). It applies only to the directory 302 fallback
20
+ * — the primary inline-injection path carries tokenData inside the document. Over-budget
21
+ * redirects are still served IN FULL (never silently drop params), but warn loudly — once
22
+ * per project per process, then debug.
23
+ */
24
+ /** The IDependencyRegistryV0 reads the resolver speaks (exact AB signatures). */
25
+ export const DEPENDENCY_REGISTRY_ABI = [
26
+ {
27
+ type: 'function',
28
+ name: 'getDependencyDetails',
29
+ stateMutability: 'view',
30
+ inputs: [{ name: 'dependencyNameAndVersion', type: 'bytes32' }],
31
+ outputs: [
32
+ { name: 'nameAndVersion', type: 'string' },
33
+ { name: 'licenseType', type: 'string' },
34
+ { name: 'preferredCDN', type: 'string' },
35
+ { name: 'additionalCDNCount', type: 'uint24' },
36
+ { name: 'preferredRepository', type: 'string' },
37
+ { name: 'additionalRepositoryCount', type: 'uint24' },
38
+ { name: 'dependencyWebsite', type: 'string' },
39
+ { name: 'availableOnChain', type: 'bool' },
40
+ { name: 'scriptCount', type: 'uint24' },
41
+ ],
42
+ },
43
+ {
44
+ type: 'function',
45
+ name: 'getDependencyScript',
46
+ stateMutability: 'view',
47
+ inputs: [
48
+ { name: 'dependencyNameAndVersion', type: 'bytes32' },
49
+ { name: 'index', type: 'uint256' },
50
+ ],
51
+ outputs: [{ type: 'string' }],
52
+ },
53
+ ];
54
+ // Resolved registry entries are effectively immutable (admin-gated writes), so an in-process
55
+ // cache is safe; the TTL only guards admin updates. Failures negative-cache briefly so a dead
56
+ // registry doesn't cost an eth_call (and a warn) per request.
57
+ const CACHE_TTL_MS = 60 * 60 * 1000; // 1h
58
+ const NEGATIVE_TTL_MS = 60 * 1000; // 1min
59
+ const registryCache = new Map();
60
+ /** Reset all in-process dependency state (cache + budget flags + serve modes) — for tests. */
61
+ export function resetDependencyResolutionState() {
62
+ registryCache.clear();
63
+ budgetFlags.clear();
64
+ directoryServeModes.clear();
65
+ }
66
+ /** The collection's registry pointer, if set to a real address (zero/undefined ⇒ none). */
67
+ export function activeRegistry(state) {
68
+ const registry = state.dependencies?.registry ?? null;
69
+ if (!registry || /^0x0{40}$/i.test(registry))
70
+ return null;
71
+ return registry;
72
+ }
73
+ /**
74
+ * Resolve one `name@version` ref through the collection's registry. Returns the resolution
75
+ * (or null when the registry couldn't answer — caller falls back to the built-in map) plus
76
+ * whether it was served from cache. Never throws; a fresh failure logs ONE warn (the
77
+ * negative cache rate-limits it) naming the dep and why.
78
+ */
79
+ export async function resolveRegistryDep(client, registry, dep) {
80
+ const key = `${registry.toLowerCase()}|${dep.refDecoded}`;
81
+ const hit = registryCache.get(key);
82
+ if (hit && hit.expiresAt > Date.now()) {
83
+ return { resolution: hit.value, cached: true, error: hit.error };
84
+ }
85
+ try {
86
+ // nameAndVersion rides as readable-ASCII bytes32 — the raw evented ref, right-padded.
87
+ const ref = padHex(dep.ref, { size: 32, dir: 'right' });
88
+ const details = (await client.readContract({
89
+ address: registry,
90
+ abi: DEPENDENCY_REGISTRY_ABI,
91
+ functionName: 'getDependencyDetails',
92
+ args: [ref],
93
+ }));
94
+ const [nameAndVersion, , preferredCDN, , , , , availableOnChain, scriptCount] = details;
95
+ if (availableOnChain && scriptCount > 0) {
96
+ // Per-chunk reads; the concatenated chunk strings form one base64(gzip(script)) stream.
97
+ const chunks = (await Promise.all(Array.from({ length: Number(scriptCount) }, (_, i) => client.readContract({
98
+ address: registry,
99
+ abi: DEPENDENCY_REGISTRY_ABI,
100
+ functionName: 'getDependencyScript',
101
+ args: [ref, BigInt(i)],
102
+ }))));
103
+ const script = gunzipSync(Buffer.from(chunks.join(''), 'base64')).toString('utf8');
104
+ const value = { kind: 'onchain', script };
105
+ registryCache.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS });
106
+ return { resolution: value, cached: false };
107
+ }
108
+ if (preferredCDN) {
109
+ const value = { kind: 'cdn', url: preferredCDN };
110
+ registryCache.set(key, { value, expiresAt: Date.now() + CACHE_TTL_MS });
111
+ return { resolution: value, cached: false };
112
+ }
113
+ // An empty struct back means the entry simply isn't registered.
114
+ const why = nameAndVersion
115
+ ? 'registered but has neither on-chain bytes nor a preferredCDN'
116
+ : 'not registered in the registry';
117
+ return failResolution(key, dep, registry, why);
118
+ }
119
+ catch (err) {
120
+ return failResolution(key, dep, registry, `registry read failed: ${err.message}`);
121
+ }
122
+ }
123
+ /** Negative-cache a failed resolution + one warn (per negative-TTL window). Never throws. */
124
+ function failResolution(key, dep, registry, why) {
125
+ registryCache.set(key, { value: null, error: why, expiresAt: Date.now() + NEGATIVE_TTL_MS });
126
+ console.warn(`[deps] registry resolution failed for ${dep.refDecoded} via ${registry}: ${why} — falling back to the built-in CDN map`);
127
+ return { resolution: null, cached: false, error: why };
128
+ }
129
+ /**
130
+ * Resolve a `name@version` registry ref to a CDN URL — the built-in reference convention,
131
+ * the LAST-resort rung of the resolution order (the soft registry pointer stays
132
+ * non-validating). Known runtimes get their real dist paths; anything else is best-effort npm.
133
+ */
134
+ export function registryDepUrl(ref) {
135
+ const at = ref.lastIndexOf('@');
136
+ if (at <= 0)
137
+ return null;
138
+ const name = ref.slice(0, at);
139
+ const version = ref.slice(at + 1);
140
+ const known = {
141
+ p5js: `https://cdn.jsdelivr.net/npm/p5@${version}/lib/p5.min.js`,
142
+ p5: `https://cdn.jsdelivr.net/npm/p5@${version}/lib/p5.min.js`,
143
+ threejs: `https://cdn.jsdelivr.net/npm/three@${version}/build/three.min.js`,
144
+ three: `https://cdn.jsdelivr.net/npm/three@${version}/build/three.min.js`,
145
+ tonejs: `https://cdn.jsdelivr.net/npm/tone@${version}/build/Tone.js`,
146
+ };
147
+ return known[name] ?? `https://cdn.jsdelivr.net/npm/${name}@${version}`;
148
+ }
149
+ /**
150
+ * The ordered dependency `<script>` tags for the generator document, each dep resolved per
151
+ * the Consumers table: registry on-chain bytes → registry preferredCDN → built-in map;
152
+ * `onchain`-resolution refs read their SSTORE2 data contract directly (never a registry).
153
+ * Never throws — an unresolvable dep is skipped (after the warn) and the document assembles.
154
+ */
155
+ export async function dependencyScriptTags(client, state) {
156
+ const registry = activeRegistry(state);
157
+ const tags = [];
158
+ for (const dep of state.dependencies?.list ?? []) {
159
+ if (dep.resolution === 'registry') {
160
+ if (registry) {
161
+ const { resolution } = await resolveRegistryDep(client, registry, dep);
162
+ if (resolution?.kind === 'onchain') {
163
+ tags.push(`<script>${escapeInlineScript(resolution.script)}</script>`);
164
+ continue;
165
+ }
166
+ if (resolution?.kind === 'cdn') {
167
+ tags.push(`<script src="${resolution.url}"></script>`);
168
+ continue;
169
+ }
170
+ // fell through — resolveRegistryDep already warned; last resort below
171
+ }
172
+ const url = registryDepUrl(dep.refDecoded);
173
+ if (url)
174
+ tags.push(`<script src="${url}"></script>`);
175
+ }
176
+ else {
177
+ // on-chain dep: an SSTORE2 data contract holding the JS (code = 0x00 ‖ content)
178
+ const bytecode = await client.getCode({ address: dep.refDecoded });
179
+ if (bytecode && bytecode.length > 4) {
180
+ tags.push(`<script>${escapeInlineScript(Buffer.from(bytecode.slice(4), 'hex').toString('utf8'))}</script>`);
181
+ }
182
+ }
183
+ }
184
+ return tags;
185
+ }
186
+ // The last directory serve outcome per project (in-process): inline injection is the
187
+ // primary; a redirect only happens when the entry-document fetch failed. /api/deps reports it.
188
+ const directoryServeModes = new Map();
189
+ /** Record which directory serving path a live-view request actually took. */
190
+ export function recordDirectoryServe(address, mode) {
191
+ directoryServeModes.set(address.toLowerCase(), { mode, at: new Date().toISOString() });
192
+ }
193
+ // ── the query-string size budget (URL-carried tokenData lanes only) ──────────────
194
+ /** Gateway front-ends commonly cap request lines near 8KB — the spec's URL budget. It
195
+ * applies to URL-carried `?abx=` payloads (the 302 fallback); resolver inline serving
196
+ * injects tokenData into the document and is unaffected. */
197
+ export const URL_BUDGET_BYTES = 8192;
198
+ // Per-project over-budget observations (in-process). First breach warns loudly; repeats
199
+ // drop to debug so a hot token doesn't spam the log once the fact is known.
200
+ const budgetFlags = new Map();
201
+ /**
202
+ * Measure a URL-carried `?abx=` payload (the directory 302 fallback) against the ~8KB
203
+ * budget. The FULL URL is always served — params are never dropped — this only makes the
204
+ * breach visible: a loud structured warn on the first over-budget redirect per project per
205
+ * process, debug-level after. Inline-injection serving never routes through here.
206
+ */
207
+ export function checkUrlBudget(address, tokenId, redirectUrl) {
208
+ const bytes = Buffer.byteLength(redirectUrl, 'utf8');
209
+ if (bytes <= URL_BUDGET_BYTES)
210
+ return;
211
+ const key = address.toLowerCase();
212
+ const seen = budgetFlags.has(key);
213
+ budgetFlags.set(key, { bytes, tokenId, at: new Date().toISOString() });
214
+ const payload = JSON.stringify({
215
+ warn: 'url-budget-exceeded',
216
+ address,
217
+ tokenId,
218
+ bytes,
219
+ limit: URL_BUDGET_BYTES,
220
+ hint: 'exceeds the 8KB URL budget — template mode or locator params recommended; resolver inline serving unaffected',
221
+ });
222
+ if (seen)
223
+ console.debug(`[deps] ${payload}`);
224
+ else
225
+ console.warn(`[deps] ${payload}`);
226
+ }
227
+ /** The project's URL-budget status (directory projects) — surfaced by /api/deps. */
228
+ export function urlBudgetStatus(address) {
229
+ const flag = budgetFlags.get(address.toLowerCase());
230
+ if (!flag)
231
+ return { limit: URL_BUDGET_BYTES, exceeded: false };
232
+ return { limit: URL_BUDGET_BYTES, exceeded: true, lastBytes: flag.bytes, lastTokenId: flag.tokenId, lastAt: flag.at };
233
+ }
234
+ /**
235
+ * Per-dep resolution status for a project — a read-only dry run of the same resolution the
236
+ * generator document uses (and it shares the cache, so a status read warms serving). For
237
+ * directory projects the active serving path (inline-injection primary vs the ?abx= 302
238
+ * fallback) and the URL-budget flag ride along.
239
+ */
240
+ export async function depStatusReport(client, state) {
241
+ const registry = activeRegistry(state);
242
+ const deps = [];
243
+ for (const dep of state.dependencies?.list ?? []) {
244
+ if (dep.resolution === 'onchain') {
245
+ // an SSTORE2 data contract — resolvable iff code is actually there
246
+ let resolvedVia = 'unresolved';
247
+ try {
248
+ const bytecode = await client.getCode({ address: dep.refDecoded });
249
+ if (bytecode && bytecode.length > 4)
250
+ resolvedVia = 'inline-onchain';
251
+ }
252
+ catch {
253
+ // unreachable RPC reads as unresolved — this surface is observational, never throws
254
+ }
255
+ deps.push({ ref: dep.refDecoded, resolution: 'onchain', resolvedVia, registry: null, cached: false });
256
+ continue;
257
+ }
258
+ if (registry) {
259
+ const { resolution, cached } = await resolveRegistryDep(client, registry, dep);
260
+ if (resolution) {
261
+ deps.push({
262
+ ref: dep.refDecoded,
263
+ resolution: 'registry',
264
+ resolvedVia: resolution.kind === 'onchain' ? 'onchain-registry' : 'cdn-registry',
265
+ registry,
266
+ cached,
267
+ });
268
+ continue;
269
+ }
270
+ }
271
+ const url = registryDepUrl(dep.refDecoded);
272
+ deps.push({
273
+ ref: dep.refDecoded,
274
+ resolution: 'registry',
275
+ resolvedVia: url ? 'builtin-map' : 'unresolved',
276
+ registry,
277
+ cached: false,
278
+ });
279
+ }
280
+ const directory = !!codeField(state);
281
+ const serve = directoryServeModes.get(state.address.toLowerCase());
282
+ return {
283
+ address: state.address,
284
+ registry,
285
+ locked: state.dependencies?.locked ?? false,
286
+ deps,
287
+ ...(directory
288
+ ? {
289
+ // inline injection is the primary; a redirect only ever means the last serve's
290
+ // entry-document fetch failed. `at` is absent until a live view has been served.
291
+ directoryServing: { primary: 'inline-injection', active: serve?.mode ?? 'inline-injection', ...(serve ? { at: serve.at } : {}) },
292
+ urlBudget: urlBudgetStatus(state.address),
293
+ }
294
+ : {}),
295
+ };
296
+ }
297
+ //# sourceMappingURL=deps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAC,SAAS,EAA0E,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,sBAAsB;QAC5B,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAC,IAAI,EAAE,0BAA0B,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC;QAC7D,OAAO,EAAE;YACP,EAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAC;YACxC,EAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAC;YACrC,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAC;YACtC,EAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,QAAQ,EAAC;YAC5C,EAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,QAAQ,EAAC;YAC7C,EAAC,IAAI,EAAE,2BAA2B,EAAE,IAAI,EAAE,QAAQ,EAAC;YACnD,EAAC,IAAI,EAAE,mBAAmB,EAAE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gBAAgB,EAAE,EAAC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,IAAI,kBAAkB,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAC;gBAC5H,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC;aAC1C;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @artblocks/abx-token-api — Layer 3 reference token API + byte-custody server.
3
+ *
4
+ * Serves standard ERC-721 / ERC-7572 metadata, the token image, a JSON state
5
+ * API, and a demo dashboard — all from the reconstructed projection. The on-chain
6
+ * URIs point here, so this node is the resolver; switching nodes is a repoint.
7
+ */
8
+ export { createTokenApiServer, startTokenApiServer, resolveBaseUrl, resolveContent, verifyProject, DEFAULT_PORT, type ServerOptions, } from './server.js';
9
+ export { buildTokenMetadata, buildContractMetadata, tokenImageUrl, type DisplayMeta, type FieldProvenance } from './metadata.js';
10
+ export { currentRenderArtifact, injectTokenDataIntoHtml, liveViewEnabled } from './code.js';
11
+ export { depStatusReport, dependencyScriptTags, resolveRegistryDep, registryDepUrl, activeRegistry, urlBudgetStatus, URL_BUDGET_BYTES, DEPENDENCY_REGISTRY_ABI, type DepStatus, type DirectoryServeMode, type RegistryResolution, type ResolvedVia, } from './deps.js';
12
+ export { startChainWatcher, notifyEffects, watchIntervalMs, DEFAULT_WATCH_INTERVAL_MS, type WatcherOptions, type WatcherStatus } from './watcher.js';
13
+ export { generateArt, artContentHash, fallbackImageSvg, IMAGE_MEDIA_TYPE } from './art.js';
14
+ export { renderDashboard } from './dashboard.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAC,MAAM,eAAe,CAAC;AAC/H,OAAO,EAAC,qBAAqB,EAAE,uBAAuB,EAAE,eAAe,EAAC,MAAM,WAAW,CAAC;AAC1F,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,yBAAyB,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAC,MAAM,cAAc,CAAC;AACnJ,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzF,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @artblocks/abx-token-api — Layer 3 reference token API + byte-custody server.
3
+ *
4
+ * Serves standard ERC-721 / ERC-7572 metadata, the token image, a JSON state
5
+ * API, and a demo dashboard — all from the reconstructed projection. The on-chain
6
+ * URIs point here, so this node is the resolver; switching nodes is a repoint.
7
+ */
8
+ export { createTokenApiServer, startTokenApiServer, resolveBaseUrl, resolveContent, verifyProject, DEFAULT_PORT, } from './server.js';
9
+ export { buildTokenMetadata, buildContractMetadata, tokenImageUrl } from './metadata.js';
10
+ export { currentRenderArtifact, injectTokenDataIntoHtml, liveViewEnabled } from './code.js';
11
+ export { depStatusReport, dependencyScriptTags, resolveRegistryDep, registryDepUrl, activeRegistry, urlBudgetStatus, URL_BUDGET_BYTES, DEPENDENCY_REGISTRY_ABI, } from './deps.js';
12
+ export { startChainWatcher, notifyEffects, watchIntervalMs, DEFAULT_WATCH_INTERVAL_MS } from './watcher.js';
13
+ export { generateArt, artContentHash, fallbackImageSvg, IMAGE_MEDIA_TYPE } from './art.js';
14
+ export { renderDashboard } from './dashboard.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,GAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAyC,MAAM,eAAe,CAAC;AAC/H,OAAO,EAAC,qBAAqB,EAAE,uBAAuB,EAAE,eAAe,EAAC,MAAM,WAAW,CAAC;AAC1F,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,yBAAyB,EAA0C,MAAM,cAAc,CAAC;AACnJ,OAAO,EAAC,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzF,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inline-document safety — the one HTML parsing rule that matters when embedding
3
+ * content inside <script> elements: the parser ends the element at the first
4
+ * `</script`, regardless of JS string/comment context. Two content shapes, two
5
+ * semantics-preserving escapes:
6
+ *
7
+ * - JS source (libraries, artist scripts): `</script` → `<\/script`. In valid JS the
8
+ * sequence can only occur inside a string, template, regex, or comment — contexts
9
+ * where `\/` is identical to `/` — so the transform never changes behavior.
10
+ * - JSON (the injected `window.abxTokenData`): every `<` → `\u003c`. `<` only occurs
11
+ * inside JSON strings (never in the syntax), and `\u003c` parses to the same
12
+ * character — the canonical (hashed) serialization is untouched; only the delivery
13
+ * form differs.
14
+ */
15
+ /** JS source safe to inline inside a <script> element. */
16
+ export declare function escapeInlineScript(src: string): string;
17
+ /** A JSON payload safe to inline inside a <script> element (parse-identical). */
18
+ export declare function escapeInlineJson(json: string): string;
19
+ //# sourceMappingURL=inline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../src/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
package/dist/inline.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Inline-document safety — the one HTML parsing rule that matters when embedding
3
+ * content inside <script> elements: the parser ends the element at the first
4
+ * `</script`, regardless of JS string/comment context. Two content shapes, two
5
+ * semantics-preserving escapes:
6
+ *
7
+ * - JS source (libraries, artist scripts): `</script` → `<\/script`. In valid JS the
8
+ * sequence can only occur inside a string, template, regex, or comment — contexts
9
+ * where `\/` is identical to `/` — so the transform never changes behavior.
10
+ * - JSON (the injected `window.abxTokenData`): every `<` → `\u003c`. `<` only occurs
11
+ * inside JSON strings (never in the syntax), and `\u003c` parses to the same
12
+ * character — the canonical (hashed) serialization is untouched; only the delivery
13
+ * form differs.
14
+ */
15
+ /** JS source safe to inline inside a <script> element. */
16
+ export function escapeInlineScript(src) {
17
+ return src.replace(/<\/(script)/gi, '<\\/$1');
18
+ }
19
+ /** A JSON payload safe to inline inside a <script> element (parse-identical). */
20
+ export function escapeInlineJson(json) {
21
+ return json.replace(/</g, '\\u003c');
22
+ }
23
+ //# sourceMappingURL=inline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline.js","sourceRoot":"","sources":["../src/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,0DAA0D;AAC1D,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AAChD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { type MetadataField, type OpenSeaAttribute, type ProjectState, type PublicClient, type TokenState } from '@artblocks/abx-sdk';
2
+ import { type StorageBackend } from '@artblocks/abx-storage';
3
+ /**
4
+ * Standard, marketplace-facing metadata, built from the reconstructed projection by the
5
+ * protocol rule: each field has ONE active on-chain representation — if set, it wins;
6
+ * otherwise the off-chain operator value fills in; otherwise a default. Every served field
7
+ * gets an `abx_provenance` entry saying where it came from and whether the chain vouches for it.
8
+ */
9
+ export declare function tokenImageUrl(baseUrl: string, chainId: number, address: string, tokenId: string): string;
10
+ /** Operator-supplied off-chain display metadata (from the registration — survives re-index). */
11
+ export interface DisplayMeta {
12
+ description?: string;
13
+ externalUrl?: string;
14
+ /** Operator's OpenSea attributes, stitched UNDER any on-chain `attributes` (on-chain wins).
15
+ * Collection-scope (a 1/1's traits, or a Series' shared/fallback). */
16
+ attributes?: OpenSeaAttribute[];
17
+ /** Operator's PER-TOKEN off-chain attributes, keyed by tokenId string — a Series' editable traits.
18
+ * A token's entry wins over the collection-scope `attributes`; on-chain `attributes` wins over both. */
19
+ tokenAttributes?: Record<string, OpenSeaAttribute[]>;
20
+ /**
21
+ * Durable, gateway-agnostic locators for off-chain content, keyed by the field's on-chain
22
+ * `keccak256`/`sha256` hash (lowercased) → e.g. `ipfs://<cid>`. Bridged from the deployer's
23
+ * content index via the admin control plane, so a remote resolver can point the `image` at
24
+ * IPFS/Arweave directly — without holding the bytes or any storage credentials itself.
25
+ */
26
+ contentLocators?: Record<string, string>;
27
+ }
28
+ /**
29
+ * Per-field source transparency — emitted as `abx_provenance` in the served JSON.
30
+ *
31
+ * `status` replaces the old ambiguous `verifiedAgainstChain: boolean | null` (which conflated
32
+ * "the value IS on-chain, nothing to verify" with "an off-chain value we haven't checked"):
33
+ * - `on-chain` — the value lives on-chain (or is reconstructable from chain); nothing to verify.
34
+ * - `verified` — an off-chain value we re-hashed against its on-chain anchor — it matched.
35
+ * - `mismatch` — re-hashed against the anchor — it did NOT match (served bytes are wrong).
36
+ * - `anchored` — off-chain bytes with an on-chain hash anchor, not re-hashed at build time
37
+ * (anyone can verify any gateway's bytes against the anchor — `abx verify` / `/verify`).
38
+ * - `off-chain` — a plain off-chain operator value with no on-chain anchor. A benign by-design
39
+ * state (e.g. an operator-supplied description), NOT a failure — distinct from a
40
+ * hash check that didn't run (`anchored`) or didn't match (`mismatch`).
41
+ * - `n/a` — a placeholder/default; provenance doesn't apply.
42
+ */
43
+ export type ProvenanceStatus = 'on-chain' | 'verified' | 'mismatch' | 'anchored' | 'off-chain' | 'n/a';
44
+ export interface FieldProvenance {
45
+ field: string;
46
+ source: 'inline' | 'inline-gzip' | 'reader' | 'reader-gzip' | 'renderer' | 'keccak256' | 'sha256' | 'arweave' | 'ipfs' | 'url' | 'url-template' | 'off-chain' | 'fallback' | 'placeholder' | `effect:${string}` | 'live-view';
47
+ onChain: boolean;
48
+ status: ProvenanceStatus;
49
+ /** Integrity-anchor kind for off-chain bytes, e.g. `keccak256` — the on-chain hash you verify against. */
50
+ anchor?: 'keccak256' | 'sha256';
51
+ note: string;
52
+ }
53
+ /** One entry of the `artifacts` manifest (`specs/protocol/data-plane.md`) — exactly
54
+ * `{key, mimeType, uri}`, all required, nothing optional. */
55
+ export interface ArtifactEntry {
56
+ key: string;
57
+ mimeType: string;
58
+ uri: string;
59
+ }
60
+ /** The shape of a producer-registered effect-artifact row this module consumes (structurally
61
+ * `@artblocks/abx-indexer`'s EffectArtifactRow — kept structural so tests need no store). */
62
+ export interface PlaneArtifactRow {
63
+ key: string;
64
+ effectKey: string;
65
+ outputKey: string;
66
+ contentType: string | null;
67
+ locator: string | null;
68
+ }
69
+ /** The resolver's read surface over the effect-artifact registry — how the manifest enumerates
70
+ * the plane's effect source without learning any effect's internals. */
71
+ export interface PlaneAccess {
72
+ /** Every registered row for (project, token) — filtered here by current-inputsHash key match. */
73
+ list(address: string, tokenId: string): PlaneArtifactRow[];
74
+ /** One row by artifact key (the image seam's published-locator check). */
75
+ get(key: string): PlaneArtifactRow | null;
76
+ }
77
+ /**
78
+ * The declared-type ladder for a FIELD artifact (`data-plane.md → Declared type, never sniffed`):
79
+ * the representation is the declaration channel — `renderer` returns its contentType from chain;
80
+ * on-chain image bytes are SVG by the registry convention; custody bytes carry the type declared
81
+ * at upload; locator forms get a *labeled* extension-map fallback (never byte-sniffing). Unknown
82
+ * → `application/octet-stream`, never omitted (the complete-listing rule).
83
+ */
84
+ export declare function fieldMimeType(client: PublicClient, state: ProjectState, entry: MetadataField, field: string, tokenId: string, display: DisplayMeta, storage?: StorageBackend): Promise<string>;
85
+ /** ERC-721 metadata JSON for a token (the `tokenURI` target) + `abx_provenance` + `artifacts`. */
86
+ export declare function buildTokenMetadata(client: PublicClient, state: ProjectState, token: TokenState, baseUrl: string, chainId: number, display?: DisplayMeta, storage?: StorageBackend, plane?: PlaneAccess): Promise<Record<string, unknown>>;
87
+ /** ERC-7572 collection metadata JSON (the `contractURI` target) + `abx_provenance`. */
88
+ export declare function buildContractMetadata(client: PublicClient, state: ProjectState, baseUrl: string, chainId: number, display?: DisplayMeta, storage?: StorageBackend): Promise<Record<string, unknown>>;
89
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata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