@artblocks/abx-sdk 0.1.0-alpha.10 → 0.1.0-alpha.11
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.
- package/dist/deps.d.ts +84 -5
- package/dist/deps.d.ts.map +1 -1
- package/dist/deps.js +179 -6
- package/dist/deps.js.map +1 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -1
- package/dist/gateways.d.ts +32 -0
- package/dist/gateways.d.ts.map +1 -0
- package/dist/gateways.js +53 -0
- package/dist/gateways.js.map +1 -0
- package/dist/generator-document.d.ts +57 -0
- package/dist/generator-document.d.ts.map +1 -0
- package/dist/generator-document.js +123 -0
- package/dist/generator-document.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mime.d.ts +11 -0
- package/dist/mime.d.ts.map +1 -0
- package/dist/mime.js +40 -0
- package/dist/mime.js.map +1 -0
- package/dist/node.d.ts +7 -10
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +11 -0
- package/dist/node.js.map +1 -1
- package/dist/reconstruct.d.ts +22 -5
- package/dist/reconstruct.d.ts.map +1 -1
- package/dist/reconstruct.js +40 -11
- package/dist/reconstruct.js.map +1 -1
- package/dist/util.d.ts +15 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +17 -0
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/dist/deps.d.ts
CHANGED
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Also speaks the AB-compatible registry READ interface (`IDependencyRegistryV0`,
|
|
14
14
|
* specs/protocol/dependency-registry.md): `getDependencyDetails(bytes32)` is the
|
|
15
|
-
* load-bearing read behind the CLI's best-effort selection-time check
|
|
15
|
+
* load-bearing read behind the CLI's best-effort selection-time check, and
|
|
16
|
+
* `getDependencyScript(bytes32, index)` is the resolver's own read for on-chain bytes (see the
|
|
17
|
+
* "resolver's registry-aware serving lane" section below — hoisted from
|
|
18
|
+
* `@artblocks/abx-token-api` in the abx-services integrator ask, because it shares this exact
|
|
19
|
+
* vocabulary end to end).
|
|
16
20
|
*/
|
|
17
|
-
import { type Address, type Hex } from 'viem';
|
|
21
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
22
|
+
import type { DependencyInfo, ProjectState } from './types.js';
|
|
18
23
|
/** `IAbxDependencies.Resolution` — index-aligned with the Solidity enum. */
|
|
19
24
|
export declare const DEP_RESOLUTION: {
|
|
20
25
|
readonly registry: 0;
|
|
@@ -40,9 +45,16 @@ export declare function parseDependencyRef(input: string): ParsedDependencyRef;
|
|
|
40
45
|
/** The reverse read: an evented `(resolution, bytes32)` back to its human form (the twin of
|
|
41
46
|
* the reconstruction fold's decode — registry ⇒ the tag, onchain ⇒ the address). */
|
|
42
47
|
export declare function decodeDependencyRef(resolution: DepResolution, ref: Hex): string;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The load-bearing reads of AB's `IDependencyRegistryV0` — the exact upstream signatures (any
|
|
50
|
+
* registry ABX consumers read from speaks this shape; see the dependency-registry spec).
|
|
51
|
+
* `getDependencyDetails` backs both the CLI's best-effort selection-time check and the
|
|
52
|
+
* resolver's own resolution; `getDependencyScript` is the resolver-only per-chunk read for a
|
|
53
|
+
* dep whose bytes live on chain. (Merging this hoist: token-api's `DEPENDENCY_REGISTRY_ABI` and
|
|
54
|
+
* this module's prior `dependencyRegistryReadAbi` declared the identical `getDependencyDetails`
|
|
55
|
+
* entry twice — one array now backs both callers.)
|
|
56
|
+
*/
|
|
57
|
+
export declare const DEPENDENCY_REGISTRY_ABI: readonly [{
|
|
46
58
|
readonly type: "function";
|
|
47
59
|
readonly name: "getDependencyDetails";
|
|
48
60
|
readonly stateMutability: "view";
|
|
@@ -78,6 +90,20 @@ export declare const dependencyRegistryReadAbi: readonly [{
|
|
|
78
90
|
readonly name: "scriptCount";
|
|
79
91
|
readonly type: "uint24";
|
|
80
92
|
}];
|
|
93
|
+
}, {
|
|
94
|
+
readonly type: "function";
|
|
95
|
+
readonly name: "getDependencyScript";
|
|
96
|
+
readonly stateMutability: "view";
|
|
97
|
+
readonly inputs: readonly [{
|
|
98
|
+
readonly name: "dependencyNameAndVersion";
|
|
99
|
+
readonly type: "bytes32";
|
|
100
|
+
}, {
|
|
101
|
+
readonly name: "index";
|
|
102
|
+
readonly type: "uint256";
|
|
103
|
+
}];
|
|
104
|
+
readonly outputs: readonly [{
|
|
105
|
+
readonly type: "string";
|
|
106
|
+
}];
|
|
81
107
|
}];
|
|
82
108
|
/** What the selection-time check cares about from a registry record. */
|
|
83
109
|
export interface RegistryDependencyDetails {
|
|
@@ -144,4 +170,57 @@ export declare function checkRegistryDeps(client: DependencyReadClient, registry
|
|
|
144
170
|
checks: DepCheck[];
|
|
145
171
|
rpcOk: boolean;
|
|
146
172
|
}>;
|
|
173
|
+
/** What a registry ref resolved to: on-chain bytes (decompressed, inline-ready JS) or a CDN URL. */
|
|
174
|
+
export type RegistryResolution = {
|
|
175
|
+
kind: 'onchain';
|
|
176
|
+
script: string;
|
|
177
|
+
} | {
|
|
178
|
+
kind: 'cdn';
|
|
179
|
+
url: string;
|
|
180
|
+
};
|
|
181
|
+
export interface RegistryResolveOptions {
|
|
182
|
+
/** Decompress gzip bytes — required only when the resolved dependency is on-chain bytes
|
|
183
|
+
* (`availableOnChain` with `scriptCount > 0`); a CDN-resolved or unresolved dep never needs
|
|
184
|
+
* it. Omitting it in that case throws {@link InflateRequiredError} naming the fix. */
|
|
185
|
+
inflate?: (bytes: Uint8Array) => Uint8Array;
|
|
186
|
+
}
|
|
187
|
+
/** Reset the in-process registry-resolution cache — for tests. */
|
|
188
|
+
export declare function resetRegistryDependencyCache(): void;
|
|
189
|
+
/** The collection's registry pointer, if set to a real address (zero/undefined ⇒ none). */
|
|
190
|
+
export declare function activeRegistry(state: ProjectState): Address | null;
|
|
191
|
+
/**
|
|
192
|
+
* Resolve one `name@version` ref through the collection's registry. Returns the resolution
|
|
193
|
+
* (or null when the registry couldn't answer — caller falls back to the built-in map) plus
|
|
194
|
+
* whether it was served from cache. Never throws for a resolution failure; a fresh one logs ONE
|
|
195
|
+
* warn (the negative cache rate-limits it) naming the dep and why. DOES throw
|
|
196
|
+
* {@link InflateRequiredError} when the resolution needs decompression and `opts.inflate` is
|
|
197
|
+
* absent — that is a caller-configuration bug, not a resolution outcome.
|
|
198
|
+
*/
|
|
199
|
+
export declare function resolveRegistryDep(client: PublicClient, registry: Address, dep: DependencyInfo, opts?: RegistryResolveOptions): Promise<{
|
|
200
|
+
resolution: RegistryResolution | null;
|
|
201
|
+
cached: boolean;
|
|
202
|
+
error?: string;
|
|
203
|
+
}>;
|
|
204
|
+
/**
|
|
205
|
+
* Resolve a `name@version` registry ref to a CDN URL — the built-in reference convention,
|
|
206
|
+
* the LAST-resort rung of the resolution order (the soft registry pointer stays
|
|
207
|
+
* non-validating). Known runtimes get their real dist paths; anything else is best-effort npm.
|
|
208
|
+
*/
|
|
209
|
+
export declare function registryDepUrl(ref: string): string | null;
|
|
210
|
+
/**
|
|
211
|
+
* The ordered dependency `<script>` tags for the generator document, each dep resolved per
|
|
212
|
+
* the Consumers table: registry on-chain bytes → registry preferredCDN → built-in map;
|
|
213
|
+
* `onchain`-resolution refs read their SSTORE2 data contract directly (never a registry).
|
|
214
|
+
* Never throws for a resolution failure — an unresolvable dep is skipped (after the warn) and
|
|
215
|
+
* the document assembles. DOES propagate {@link InflateRequiredError} (see
|
|
216
|
+
* {@link resolveRegistryDep}) — a missing `inflate` is a host wiring bug, not a bad dep.
|
|
217
|
+
*/
|
|
218
|
+
export declare function dependencyScriptTags(client: PublicClient, state: ProjectState, opts?: RegistryResolveOptions): Promise<string[]>;
|
|
219
|
+
/** The spec's URL-carried tokenData size budget: gateway front-ends commonly cap request lines
|
|
220
|
+
* near 8KB. Applies to URL-carried `?abx=` payloads (a resolver's directory-mode 302 fallback);
|
|
221
|
+
* inline document serving is unaffected. Hoisted alongside the rest of this lane — the
|
|
222
|
+
* budget-tracking/observability surface built on it (`checkUrlBudget`, `urlBudgetStatus`) stays
|
|
223
|
+
* resolver-local (token-api/src/deps.ts), since it's a serving-observability concern rather than
|
|
224
|
+
* a resolution rule. */
|
|
225
|
+
export declare const URL_BUDGET_BYTES = 8192;
|
|
147
226
|
//# sourceMappingURL=deps.d.ts.map
|
package/dist/deps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAiD,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAC,MAAM,MAAM,CAAC;AAO/G,OAAO,KAAK,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAE7D,4EAA4E;AAC5E,eAAO,MAAM,cAAc;;;CAAqC,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEjF,oGAAoG;AACpG,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,aAAa,CAAC;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD;;sFAEsF;AACtF,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,GAAG,CAahE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAOrE;AAED;qFACqF;AACrF,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,aAAa,EAAE,GAA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G,MAAM,GAAG,IAAI,CAazD;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,YAAY,EACnB,IAAI,GAAE,sBAA2B,GAChC,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BnB;AAED;;;;;yBAKyB;AACzB,eAAO,MAAM,gBAAgB,OAAO,CAAC"}
|
package/dist/deps.js
CHANGED
|
@@ -12,12 +12,19 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Also speaks the AB-compatible registry READ interface (`IDependencyRegistryV0`,
|
|
14
14
|
* specs/protocol/dependency-registry.md): `getDependencyDetails(bytes32)` is the
|
|
15
|
-
* load-bearing read behind the CLI's best-effort selection-time check
|
|
15
|
+
* load-bearing read behind the CLI's best-effort selection-time check, and
|
|
16
|
+
* `getDependencyScript(bytes32, index)` is the resolver's own read for on-chain bytes (see the
|
|
17
|
+
* "resolver's registry-aware serving lane" section below — hoisted from
|
|
18
|
+
* `@artblocks/abx-token-api` in the abx-services integrator ask, because it shares this exact
|
|
19
|
+
* vocabulary end to end).
|
|
16
20
|
*/
|
|
17
|
-
import { encodeFunctionData, padHex, toHex } from 'viem';
|
|
21
|
+
import { encodeFunctionData, hexToString, padHex, toHex } from 'viem';
|
|
18
22
|
import { decodeTag } from './spine.js';
|
|
19
23
|
import { seriesCodeAbi } from './abi/index.js';
|
|
20
24
|
import { resolveDependencyRegistry } from './deployments.js';
|
|
25
|
+
import { escapeInlineScript } from './generator-document.js';
|
|
26
|
+
import { base64ToBytes } from './util.js';
|
|
27
|
+
import { InflateRequiredError } from './errors.js';
|
|
21
28
|
/** `IAbxDependencies.Resolution` — index-aligned with the Solidity enum. */
|
|
22
29
|
export const DEP_RESOLUTION = { registry: 0, onchain: 1 };
|
|
23
30
|
// Printable non-space ASCII — what a readable bytes32 tag can carry unambiguously
|
|
@@ -59,9 +66,16 @@ export function decodeDependencyRef(resolution, ref) {
|
|
|
59
66
|
return resolution === DEP_RESOLUTION.onchain ? '0x' + ref.slice(2, 42) : decodeTag(ref);
|
|
60
67
|
}
|
|
61
68
|
// ── the AB-compatible registry read (IDependencyRegistryV0) ───────────────────
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The load-bearing reads of AB's `IDependencyRegistryV0` — the exact upstream signatures (any
|
|
71
|
+
* registry ABX consumers read from speaks this shape; see the dependency-registry spec).
|
|
72
|
+
* `getDependencyDetails` backs both the CLI's best-effort selection-time check and the
|
|
73
|
+
* resolver's own resolution; `getDependencyScript` is the resolver-only per-chunk read for a
|
|
74
|
+
* dep whose bytes live on chain. (Merging this hoist: token-api's `DEPENDENCY_REGISTRY_ABI` and
|
|
75
|
+
* this module's prior `dependencyRegistryReadAbi` declared the identical `getDependencyDetails`
|
|
76
|
+
* entry twice — one array now backs both callers.)
|
|
77
|
+
*/
|
|
78
|
+
export const DEPENDENCY_REGISTRY_ABI = [
|
|
65
79
|
{
|
|
66
80
|
type: 'function',
|
|
67
81
|
name: 'getDependencyDetails',
|
|
@@ -79,6 +93,16 @@ export const dependencyRegistryReadAbi = [
|
|
|
79
93
|
{ name: 'scriptCount', type: 'uint24' },
|
|
80
94
|
],
|
|
81
95
|
},
|
|
96
|
+
{
|
|
97
|
+
type: 'function',
|
|
98
|
+
name: 'getDependencyScript',
|
|
99
|
+
stateMutability: 'view',
|
|
100
|
+
inputs: [
|
|
101
|
+
{ name: 'dependencyNameAndVersion', type: 'bytes32' },
|
|
102
|
+
{ name: 'index', type: 'uint256' },
|
|
103
|
+
],
|
|
104
|
+
outputs: [{ type: 'string' }],
|
|
105
|
+
},
|
|
82
106
|
];
|
|
83
107
|
/**
|
|
84
108
|
* Read one dependency's registry record. Returns `null` when the registry doesn't know the
|
|
@@ -92,7 +116,7 @@ export const dependencyRegistryReadAbi = [
|
|
|
92
116
|
export async function readRegistryDependency(client, registry, ref) {
|
|
93
117
|
const out = (await client.readContract({
|
|
94
118
|
address: registry,
|
|
95
|
-
abi:
|
|
119
|
+
abi: DEPENDENCY_REGISTRY_ABI,
|
|
96
120
|
functionName: 'getDependencyDetails',
|
|
97
121
|
args: [ref],
|
|
98
122
|
}));
|
|
@@ -169,4 +193,153 @@ export async function checkRegistryDeps(client, registry, deps) {
|
|
|
169
193
|
}
|
|
170
194
|
return { checks, rpcOk };
|
|
171
195
|
}
|
|
196
|
+
// Resolved registry entries are effectively immutable (admin-gated writes), so an in-process
|
|
197
|
+
// cache is safe; the TTL only guards admin updates. Failures negative-cache briefly so a dead
|
|
198
|
+
// registry doesn't cost an eth_call (and a warn) per request.
|
|
199
|
+
const REGISTRY_CACHE_TTL_MS = 60 * 60 * 1000; // 1h
|
|
200
|
+
const REGISTRY_NEGATIVE_TTL_MS = 60 * 1000; // 1min
|
|
201
|
+
const registryCache = new Map();
|
|
202
|
+
/** Reset the in-process registry-resolution cache — for tests. */
|
|
203
|
+
export function resetRegistryDependencyCache() {
|
|
204
|
+
registryCache.clear();
|
|
205
|
+
}
|
|
206
|
+
/** The collection's registry pointer, if set to a real address (zero/undefined ⇒ none). */
|
|
207
|
+
export function activeRegistry(state) {
|
|
208
|
+
const registry = state.dependencies?.registry ?? null;
|
|
209
|
+
if (!registry || /^0x0{40}$/i.test(registry))
|
|
210
|
+
return null;
|
|
211
|
+
return registry;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Resolve one `name@version` ref through the collection's registry. Returns the resolution
|
|
215
|
+
* (or null when the registry couldn't answer — caller falls back to the built-in map) plus
|
|
216
|
+
* whether it was served from cache. Never throws for a resolution failure; a fresh one logs ONE
|
|
217
|
+
* warn (the negative cache rate-limits it) naming the dep and why. DOES throw
|
|
218
|
+
* {@link InflateRequiredError} when the resolution needs decompression and `opts.inflate` is
|
|
219
|
+
* absent — that is a caller-configuration bug, not a resolution outcome.
|
|
220
|
+
*/
|
|
221
|
+
export async function resolveRegistryDep(client, registry, dep, opts = {}) {
|
|
222
|
+
const key = `${registry.toLowerCase()}|${dep.refDecoded}`;
|
|
223
|
+
const hit = registryCache.get(key);
|
|
224
|
+
if (hit && hit.expiresAt > Date.now()) {
|
|
225
|
+
return { resolution: hit.value, cached: true, error: hit.error };
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
// nameAndVersion rides as readable-ASCII bytes32 — the raw evented ref, right-padded.
|
|
229
|
+
const ref = padHex(dep.ref, { size: 32, dir: 'right' });
|
|
230
|
+
const details = (await client.readContract({
|
|
231
|
+
address: registry,
|
|
232
|
+
abi: DEPENDENCY_REGISTRY_ABI,
|
|
233
|
+
functionName: 'getDependencyDetails',
|
|
234
|
+
args: [ref],
|
|
235
|
+
}));
|
|
236
|
+
const [nameAndVersion, , preferredCDN, , , , , availableOnChain, scriptCount] = details;
|
|
237
|
+
if (availableOnChain && scriptCount > 0) {
|
|
238
|
+
// Per-chunk reads; the concatenated chunk strings form one base64(gzip(script)) stream.
|
|
239
|
+
const chunks = (await Promise.all(Array.from({ length: Number(scriptCount) }, (_, i) => client.readContract({
|
|
240
|
+
address: registry,
|
|
241
|
+
abi: DEPENDENCY_REGISTRY_ABI,
|
|
242
|
+
functionName: 'getDependencyScript',
|
|
243
|
+
args: [ref, BigInt(i)],
|
|
244
|
+
}))));
|
|
245
|
+
if (!opts.inflate)
|
|
246
|
+
throw new InflateRequiredError();
|
|
247
|
+
const gz = base64ToBytes(chunks.join(''));
|
|
248
|
+
const script = new TextDecoder().decode(opts.inflate(gz));
|
|
249
|
+
const value = { kind: 'onchain', script };
|
|
250
|
+
registryCache.set(key, { value, expiresAt: Date.now() + REGISTRY_CACHE_TTL_MS });
|
|
251
|
+
return { resolution: value, cached: false };
|
|
252
|
+
}
|
|
253
|
+
if (preferredCDN) {
|
|
254
|
+
const value = { kind: 'cdn', url: preferredCDN };
|
|
255
|
+
registryCache.set(key, { value, expiresAt: Date.now() + REGISTRY_CACHE_TTL_MS });
|
|
256
|
+
return { resolution: value, cached: false };
|
|
257
|
+
}
|
|
258
|
+
// An empty struct back means the entry simply isn't registered.
|
|
259
|
+
const why = nameAndVersion
|
|
260
|
+
? 'registered but has neither on-chain bytes nor a preferredCDN'
|
|
261
|
+
: 'not registered in the registry';
|
|
262
|
+
return failRegistryResolution(key, dep, registry, why);
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
// A missing inflate is a host-configuration bug, not a resolution outcome — surface it
|
|
266
|
+
// rather than mis-reporting it as "registry read failed" and quietly falling back.
|
|
267
|
+
if (err instanceof InflateRequiredError)
|
|
268
|
+
throw err;
|
|
269
|
+
return failRegistryResolution(key, dep, registry, `registry read failed: ${err.message}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/** Negative-cache a failed resolution + one warn (per negative-TTL window). Never throws. */
|
|
273
|
+
function failRegistryResolution(key, dep, registry, why) {
|
|
274
|
+
registryCache.set(key, { value: null, error: why, expiresAt: Date.now() + REGISTRY_NEGATIVE_TTL_MS });
|
|
275
|
+
console.warn(`[deps] registry resolution failed for ${dep.refDecoded} via ${registry}: ${why} — falling back to the built-in CDN map`);
|
|
276
|
+
return { resolution: null, cached: false, error: why };
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Resolve a `name@version` registry ref to a CDN URL — the built-in reference convention,
|
|
280
|
+
* the LAST-resort rung of the resolution order (the soft registry pointer stays
|
|
281
|
+
* non-validating). Known runtimes get their real dist paths; anything else is best-effort npm.
|
|
282
|
+
*/
|
|
283
|
+
export function registryDepUrl(ref) {
|
|
284
|
+
const at = ref.lastIndexOf('@');
|
|
285
|
+
if (at <= 0)
|
|
286
|
+
return null;
|
|
287
|
+
const name = ref.slice(0, at);
|
|
288
|
+
const version = ref.slice(at + 1);
|
|
289
|
+
const known = {
|
|
290
|
+
p5js: `https://cdn.jsdelivr.net/npm/p5@${version}/lib/p5.min.js`,
|
|
291
|
+
p5: `https://cdn.jsdelivr.net/npm/p5@${version}/lib/p5.min.js`,
|
|
292
|
+
threejs: `https://cdn.jsdelivr.net/npm/three@${version}/build/three.min.js`,
|
|
293
|
+
three: `https://cdn.jsdelivr.net/npm/three@${version}/build/three.min.js`,
|
|
294
|
+
tonejs: `https://cdn.jsdelivr.net/npm/tone@${version}/build/Tone.js`,
|
|
295
|
+
};
|
|
296
|
+
return known[name] ?? `https://cdn.jsdelivr.net/npm/${name}@${version}`;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The ordered dependency `<script>` tags for the generator document, each dep resolved per
|
|
300
|
+
* the Consumers table: registry on-chain bytes → registry preferredCDN → built-in map;
|
|
301
|
+
* `onchain`-resolution refs read their SSTORE2 data contract directly (never a registry).
|
|
302
|
+
* Never throws for a resolution failure — an unresolvable dep is skipped (after the warn) and
|
|
303
|
+
* the document assembles. DOES propagate {@link InflateRequiredError} (see
|
|
304
|
+
* {@link resolveRegistryDep}) — a missing `inflate` is a host wiring bug, not a bad dep.
|
|
305
|
+
*/
|
|
306
|
+
export async function dependencyScriptTags(client, state, opts = {}) {
|
|
307
|
+
const registry = activeRegistry(state);
|
|
308
|
+
const tags = [];
|
|
309
|
+
for (const dep of state.dependencies?.list ?? []) {
|
|
310
|
+
if (dep.resolution === 'registry') {
|
|
311
|
+
if (registry) {
|
|
312
|
+
const { resolution } = await resolveRegistryDep(client, registry, dep, opts);
|
|
313
|
+
if (resolution?.kind === 'onchain') {
|
|
314
|
+
tags.push(`<script>${escapeInlineScript(resolution.script)}</script>`);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (resolution?.kind === 'cdn') {
|
|
318
|
+
tags.push(`<script src="${resolution.url}"></script>`);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
// fell through — resolveRegistryDep already warned; last resort below
|
|
322
|
+
}
|
|
323
|
+
const url = registryDepUrl(dep.refDecoded);
|
|
324
|
+
if (url)
|
|
325
|
+
tags.push(`<script src="${url}"></script>`);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
// on-chain dep: an SSTORE2 data contract holding the JS (code = 0x00 ‖ content). No
|
|
329
|
+
// inflate needed here — raw bytecode, never gzip'd — so this branch never touches `opts`.
|
|
330
|
+
const bytecode = await client.getCode({ address: dep.refDecoded });
|
|
331
|
+
if (bytecode && bytecode.length > 4) {
|
|
332
|
+
tags.push(`<script>${escapeInlineScript(hexToString(('0x' + bytecode.slice(4))))}</script>`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return tags;
|
|
337
|
+
}
|
|
338
|
+
/** The spec's URL-carried tokenData size budget: gateway front-ends commonly cap request lines
|
|
339
|
+
* near 8KB. Applies to URL-carried `?abx=` payloads (a resolver's directory-mode 302 fallback);
|
|
340
|
+
* inline document serving is unaffected. Hoisted alongside the rest of this lane — the
|
|
341
|
+
* budget-tracking/observability surface built on it (`checkUrlBudget`, `urlBudgetStatus`) stays
|
|
342
|
+
* resolver-local (token-api/src/deps.ts), since it's a serving-observability concern rather than
|
|
343
|
+
* a resolution rule. */
|
|
344
|
+
export const URL_BUDGET_BYTES = 8192;
|
|
172
345
|
//# sourceMappingURL=deps.js.map
|
package/dist/deps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAC,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAyB,MAAM,MAAM,CAAC;AAC/E,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,yBAAyB,EAAC,MAAM,kBAAkB,CAAC;AAE3D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,EAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAU,CAAC;AAUjE,kFAAkF;AAClF,oFAAoF;AACpF,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC;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YAC1F,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAC,OAAO,EAAE,GAAG,CAAC,UAAqB,EAAC,CAAC,CAAC;YAC5E,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,IAAI,CAAC,WAAW,kBAAkB,CAAC,WAAW,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,WAAW,CAAC,CAAC;YACtG,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;yBAKyB;AACzB,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -42,6 +42,17 @@ export declare class GasEstimateBelowFloorError extends AbxSdkError {
|
|
|
42
42
|
export declare class MissingSigningKeyError extends AbxSdkError {
|
|
43
43
|
constructor();
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* A registry-resolved dependency's on-chain bytes are gzip'd, and no `inflate` was supplied to
|
|
47
|
+
* decompress them (`resolveRegistryDep`/`dependencyScriptTags`, deps.ts). SDK core carries no
|
|
48
|
+
* `node:zlib` — it has to stay reachable from a browser bundle (see `test/browser-bundle.test.ts`)
|
|
49
|
+
* — so decompression is an injected function rather than a direct call. Thrown instead of letting
|
|
50
|
+
* the caller either crash on `opts.inflate(...)` being undefined or silently serve a broken
|
|
51
|
+
* document; names the exact fix instead of a generic "cannot read properties of undefined".
|
|
52
|
+
*/
|
|
53
|
+
export declare class InflateRequiredError extends AbxSdkError {
|
|
54
|
+
constructor();
|
|
55
|
+
}
|
|
45
56
|
/** The five bootstrap-or-refuse trust anchors / singletons `ensureFactory` & co. (anchors.ts)
|
|
46
57
|
* resolve. */
|
|
47
58
|
export type AnchorKind = 'factory' | 'series-factory' | 'series-code-factory' | 'renderer' | 'seed-source';
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,GAAG,EAAC,MAAM,MAAM,CAAC;AAEvC;;;;;;;GAOG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;gBACT,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG;CAMpC;AAED;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBACX,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAW5C;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;;CAQtD;AAED;eACe;AACf,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,gBAAgB,GAAG,qBAAqB,GAAG,UAAU,GAAG,aAAa,CAAC;AAE3G;;;;;;;;GAQG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBACf,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,GAAG,eAAe,GAAG,gBAAgB,EAAE,OAAO,CAAC,EAAE,OAAO;CAO1G"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,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|
|
65
|
+
* A registry-resolved dependency's on-chain bytes are gzip'd, and no `inflate` was supplied to
|
|
66
|
+
* decompress them (`resolveRegistryDep`/`dependencyScriptTags`, deps.ts). SDK core carries no
|
|
67
|
+
* `node:zlib` — it has to stay reachable from a browser bundle (see `test/browser-bundle.test.ts`)
|
|
68
|
+
* — so decompression is an injected function rather than a direct call. Thrown instead of letting
|
|
69
|
+
* the caller either crash on `opts.inflate(...)` being undefined or silently serve a broken
|
|
70
|
+
* document; names the exact fix instead of a generic "cannot read properties of undefined".
|
|
71
|
+
*/
|
|
72
|
+
export class InflateRequiredError extends AbxSdkError {
|
|
73
|
+
constructor() {
|
|
74
|
+
super("A registry-resolved dependency's on-chain bytes are gzip-compressed, but no `inflate` was " +
|
|
75
|
+
'provided to decompress them. On a Node host, pass `nodeInflate` from `@artblocks/abx-sdk/node` ' +
|
|
76
|
+
"(e.g. `dependencyScriptTags(client, state, {inflate: nodeInflate})`). In a browser, pass a " +
|
|
77
|
+
'DecompressionStream-based implementation — SDK core carries no `node:zlib` so it never assumes one.');
|
|
78
|
+
this.name = 'InflateRequiredError';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
64
81
|
/**
|
|
65
82
|
* A trust anchor {@link AnchorKind} that `ensureFactory`/`ensureSeriesFactory`/
|
|
66
83
|
* `ensureSeriesCodeFactory` (anchors.ts) could not resolve to a usable address, with
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,WAAW;IACrC,EAAE,CAAS;IACX,MAAM,CAAM;IACrB,YAAY,E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qB,SAAQ,WAAW;IACnD;QACE,KAAK,CACH,4FAA4F;YAC1F,iGAAiG;YACjG,6FAA6F;YAC7F,qGAAqG,CACxG,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAMD;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAuB,SAAQ,WAAW;IAC5C,MAAM,CAAa;IACnB,MAAM,CAAiD;IACvD,OAAO,CAAW;IAC3B,YAAY,MAAkB,EAAE,MAAsD,EAAE,OAAiB;QACvG,KAAK,CAAC,GAAG,MAAM,8BAA8B,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACxF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** The locator's network, which decides which gateways can be asked about it. `http` locators
|
|
2
|
+
* carry their own base (they are already an absolute URL) and resolve to `''` here — a caller
|
|
3
|
+
* returns them verbatim before consulting a gateway. */
|
|
4
|
+
export type LocatorNetwork = 'arweave' | 'ipfs' | 'http';
|
|
5
|
+
/** Resolved gateway overrides for the two content-addressed networks — the shape both
|
|
6
|
+
* {@link resolveGatewayBase} and {@link gatewayConfigFromEnv} speak. */
|
|
7
|
+
export interface GatewayOverrides {
|
|
8
|
+
ipfs?: string;
|
|
9
|
+
arweave?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The gateway BASE for a locator network, given already-resolved `overrides` — PURE, no env
|
|
13
|
+
* read. Defaults to the generic public gateways (`ipfs.io` / `arweave.net`) when `overrides`
|
|
14
|
+
* doesn't name one; any other `network` (e.g. `http`, which carries its own base) resolves to
|
|
15
|
+
* `''`. Callers that want override → env → default precedence compose this with
|
|
16
|
+
* {@link gatewayConfigFromEnv} themselves (see `@artblocks/abx-storage`'s `resolveGatewayBase`
|
|
17
|
+
* for the reference compose) — kept separate so a host with its own config source never has this
|
|
18
|
+
* function reach into `process.env` on its behalf.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveGatewayBase(network: 'ipfs' | 'arweave' | string, overrides?: GatewayOverrides): string;
|
|
21
|
+
/**
|
|
22
|
+
* The ONLY env-reading piece of this module: `ABX_IPFS_GATEWAY` / `ABX_ARWEAVE_GATEWAY`, read via
|
|
23
|
+
* {@link readEnv} (safe where `process` doesn't exist). Exported separately from
|
|
24
|
+
* {@link resolveGatewayBase} so a host with its own gateway configuration (a database row, a
|
|
25
|
+
* remote config service) never has to touch `process.env` through this package at all — it just
|
|
26
|
+
* never calls this function and passes its own overrides straight to the pure resolver instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare function gatewayConfigFromEnv(): GatewayOverrides;
|
|
29
|
+
/** Build the URL that asks `gateway` for `id`. A locator that is already an absolute URL is asked
|
|
30
|
+
* verbatim — rewriting someone's URL would answer a question they didn't ask. */
|
|
31
|
+
export declare function gatewayUrlFor(network: LocatorNetwork, id: string, gateway: string): string;
|
|
32
|
+
//# sourceMappingURL=gateways.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateways.d.ts","sourceRoot":"","sources":["../src/gateways.ts"],"names":[],"mappings":"AAWA;;yDAEyD;AACzD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD;yEACyE;AACzE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAI7G;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAOvD;AAED;kFACkF;AAClF,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAK1F"}
|
package/dist/gateways.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway resolution for content-addressed locators (`ipfs://…`, `ar://…`) — hoisted from
|
|
3
|
+
* `@artblocks/abx-storage` (the abx-services integrator ask), split into a PURE resolver and a
|
|
4
|
+
* separate env-reading piece so a host with its own gateway config never has to touch
|
|
5
|
+
* `process.env` through this module at all, and so this stays reachable from a browser bundle
|
|
6
|
+
* (see `test/browser-bundle.test.ts` — no `process.env` read outside {@link gatewayConfigFromEnv},
|
|
7
|
+
* which itself goes through {@link readEnv} and degrades to "no override" rather than throwing
|
|
8
|
+
* where `process` doesn't exist).
|
|
9
|
+
*/
|
|
10
|
+
import { readEnv } from './util.js';
|
|
11
|
+
/**
|
|
12
|
+
* The gateway BASE for a locator network, given already-resolved `overrides` — PURE, no env
|
|
13
|
+
* read. Defaults to the generic public gateways (`ipfs.io` / `arweave.net`) when `overrides`
|
|
14
|
+
* doesn't name one; any other `network` (e.g. `http`, which carries its own base) resolves to
|
|
15
|
+
* `''`. Callers that want override → env → default precedence compose this with
|
|
16
|
+
* {@link gatewayConfigFromEnv} themselves (see `@artblocks/abx-storage`'s `resolveGatewayBase`
|
|
17
|
+
* for the reference compose) — kept separate so a host with its own config source never has this
|
|
18
|
+
* function reach into `process.env` on its behalf.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveGatewayBase(network, overrides) {
|
|
21
|
+
if (network === 'ipfs')
|
|
22
|
+
return overrides?.ipfs || 'https://ipfs.io';
|
|
23
|
+
if (network === 'arweave')
|
|
24
|
+
return overrides?.arweave || 'https://arweave.net';
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The ONLY env-reading piece of this module: `ABX_IPFS_GATEWAY` / `ABX_ARWEAVE_GATEWAY`, read via
|
|
29
|
+
* {@link readEnv} (safe where `process` doesn't exist). Exported separately from
|
|
30
|
+
* {@link resolveGatewayBase} so a host with its own gateway configuration (a database row, a
|
|
31
|
+
* remote config service) never has to touch `process.env` through this package at all — it just
|
|
32
|
+
* never calls this function and passes its own overrides straight to the pure resolver instead.
|
|
33
|
+
*/
|
|
34
|
+
export function gatewayConfigFromEnv() {
|
|
35
|
+
const ipfs = readEnv('ABX_IPFS_GATEWAY');
|
|
36
|
+
const arweave = readEnv('ABX_ARWEAVE_GATEWAY');
|
|
37
|
+
const out = {};
|
|
38
|
+
if (ipfs)
|
|
39
|
+
out.ipfs = ipfs;
|
|
40
|
+
if (arweave)
|
|
41
|
+
out.arweave = arweave;
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/** Build the URL that asks `gateway` for `id`. A locator that is already an absolute URL is asked
|
|
45
|
+
* verbatim — rewriting someone's URL would answer a question they didn't ask. */
|
|
46
|
+
export function gatewayUrlFor(network, id, gateway) {
|
|
47
|
+
if (/^https?:\/\//i.test(id))
|
|
48
|
+
return id;
|
|
49
|
+
const base = gateway.replace(/\/+$/, '');
|
|
50
|
+
// A path suffix (a directory manifest entry, e.g. `<txid>/index.html`) rides along untouched.
|
|
51
|
+
return network === 'ipfs' ? `${base}/ipfs/${id}` : `${base}/${id}`;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=gateways.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateways.js","sourceRoot":"","sources":["../src/gateways.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAclC;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAoC,EAAE,SAA4B;IACnG,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,SAAS,EAAE,IAAI,IAAI,iBAAiB,CAAC;IACpE,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,EAAE,OAAO,IAAI,qBAAqB,CAAC;IAC9E,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC/C,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,IAAI,IAAI;QAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;IAC1B,IAAI,OAAO;QAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACnC,OAAO,GAAG,CAAC;AACb,CAAC;AAED;kFACkF;AAClF,MAAM,UAAU,aAAa,CAAC,OAAuB,EAAE,EAAU,EAAE,OAAe;IAChF,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzC,8FAA8F;IAC9F,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The generator-document family — the template-mode runtime companion, the inline-safety
|
|
3
|
+
* escapes, and the pure document-shape builders. Hoisted from `@artblocks/abx-token-api`
|
|
4
|
+
* (the abx-services integrator ask): every piece here is a pure string operation with no chain
|
|
5
|
+
* access and no Node dependency, so it belongs in the neutral layer a resolver, a CLI preview,
|
|
6
|
+
* and any third-party provider all consume identically — one definition of the runtime surface
|
|
7
|
+
* and the document shape, so none of them can quietly drift from what the others emit.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* `abx.js` — the runtime companion (the hl-gen.js analog), served at `/abx.js` and
|
|
11
|
+
* inlined into template-mode documents. Convention, not protocol: a directory build
|
|
12
|
+
* includes it; the generator injects the same surface.
|
|
13
|
+
*
|
|
14
|
+
* tokenData resolution order (the durability chain): the injected `window.abxTokenData`
|
|
15
|
+
* global (template mode) → the `?abx=` query param (base64url canonical JSON — the
|
|
16
|
+
* live-view route) → the `?chainId&contract&tokenId` coordinate floor (a build opened
|
|
17
|
+
* bare from a gateway still knows which token it is; full param reads from RPC are the
|
|
18
|
+
* render-node's job, not this shim's).
|
|
19
|
+
*/
|
|
20
|
+
export declare const ABX_JS = "(function () {\n var abx = (window.abx = window.abx || {});\n function fromQuery() {\n try {\n var q = new URLSearchParams(location.search);\n var packed = q.get('abx');\n if (packed) {\n var b64 = packed.replace(/-/g, '+').replace(/_/g, '/');\n return JSON.parse(new TextDecoder().decode(Uint8Array.from(atob(b64), function (c) { return c.charCodeAt(0); })));\n }\n // coordinate floor: enough for a deterministic piece opened bare from a gateway\n if (q.get('contract') && q.get('tokenId')) {\n return {\n chainId: Number(q.get('chainId') || 1),\n contractAddress: String(q.get('contract')).toLowerCase(),\n tokenId: String(q.get('tokenId')),\n };\n }\n } catch (e) {}\n return null;\n }\n abx.tokenData = window.abxTokenData || fromQuery();\n abx.__traits = null;\n abx.__done = false;\n /** The script reports its computed traits (script-defined features; captured at render). */\n abx.traits = function (t) {\n abx.__traits = t;\n try { document.dispatchEvent(new CustomEvent('abx:traits', {detail: t})); } catch (e) {}\n return t;\n };\n /** Output-complete \u2014 the capture point for the render effect. Optional (timeout fallback). */\n abx.done = function () {\n abx.__done = true;\n try { document.dispatchEvent(new CustomEvent('abx:done')); } catch (e) {}\n };\n})();\n";
|
|
21
|
+
/**
|
|
22
|
+
* Inline-document safety — the one HTML parsing rule that matters when embedding
|
|
23
|
+
* content inside <script> elements: the parser ends the element at the first
|
|
24
|
+
* `</script`, regardless of JS string/comment context. Two content shapes, two
|
|
25
|
+
* semantics-preserving escapes:
|
|
26
|
+
*
|
|
27
|
+
* - JS source (libraries, artist scripts): `</script` → `<\/script`. In valid JS the
|
|
28
|
+
* sequence can only occur inside a string, template, regex, or comment — contexts
|
|
29
|
+
* where `\/` is identical to `/` — so the transform never changes behavior.
|
|
30
|
+
* - JSON (the injected `window.abxTokenData`): every `<` → `\u003c`. `<` only occurs
|
|
31
|
+
* inside JSON strings (never in the syntax), and `\u003c` parses to the same
|
|
32
|
+
* character — the canonical (hashed) serialization is untouched; only the delivery
|
|
33
|
+
* form differs.
|
|
34
|
+
*/
|
|
35
|
+
/** JS source safe to inline inside a <script> element. */
|
|
36
|
+
export declare function escapeInlineScript(src: string): string;
|
|
37
|
+
/** A JSON payload safe to inline inside a <script> element (parse-identical). */
|
|
38
|
+
export declare function escapeInlineJson(json: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Inject `window.abxTokenData` (and, when the document doesn't already carry one, a
|
|
41
|
+
* `<base href="{code root}/">` so relative asset paths keep riding the gateway) at the
|
|
42
|
+
* very top of `<head>` — before any build script can execute; abx.js resolves the global
|
|
43
|
+
* first. String-level and deliberately robust rather than a full HTML parse: no `<head>`
|
|
44
|
+
* → inject right after `<html …>`; neither → prepend. First `<base>` wins in HTML, so an
|
|
45
|
+
* existing one is never doubled.
|
|
46
|
+
*/
|
|
47
|
+
export declare function injectTokenDataIntoHtml(html: string, tokenDataJson: string, codeRoot: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* The template-mode document shape, pure — no chain access, so a caller that already has a
|
|
50
|
+
* script + dep tags in hand (the resolver's own chain-fetched assembly; `abx preview`'s offline
|
|
51
|
+
* studio, local-file + CDN-resolved) can build the byte-identical document. Exported for exactly
|
|
52
|
+
* that reason: **one** definition of the shape, so a caller can never quietly drift from what the
|
|
53
|
+
* generator actually serves — the failure mode a hand-maintained duplicate (with a "keep these in
|
|
54
|
+
* sync" comment and nothing enforcing it) invites.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildGeneratorDocument(script: string, tokenDataJson: string, depTags: string[]): string;
|
|
57
|
+
//# sourceMappingURL=generator-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator-document.d.ts","sourceRoot":"","sources":["../src/generator-document.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,o4CAoClB,CAAC;AAEF;;;;;;;;;;;;;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;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAcrG;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAYvG"}
|