@nimbus-sh/worker 0.8.0 → 0.10.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.
- package/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +24 -24
- package/dist/facets/cirrus-real.js +3 -3
- package/dist/facets/compose.d.ts +3 -0
- package/dist/facets/compose.d.ts.map +1 -1
- package/dist/facets/compose.js +10 -3
- package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
- package/dist/facets/esbuild-bundle-pool.js +3 -3
- package/dist/facets/esbuild-transform.d.ts +6 -2
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +8 -4
- package/dist/facets/manager.d.ts +54 -15
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +227 -144
- package/dist/facets/real-vite-hmr.d.ts +2 -0
- package/dist/facets/real-vite-hmr.d.ts.map +1 -1
- package/dist/facets/real-vite-hmr.js +3 -2
- package/dist/git/commands.d.ts +17 -1
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +73 -9
- package/dist/git/network-facet.d.ts +2 -0
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +10 -5
- package/dist/hosted/commands.d.ts.map +1 -1
- package/dist/hosted/commands.js +28 -39
- package/dist/hosted/runtime.d.ts +24 -2
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +70 -13
- package/dist/hosted/services.d.ts +14 -2
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +15 -2
- package/dist/loaders/generated-workers.d.ts +2 -2
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +4 -4
- package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
- package/dist/loaders/pre-bundle-preamble.js +13 -8
- package/dist/node-shims-artifact.generated.js +3 -3
- package/dist/npm/cache.d.ts +6 -1
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +8 -6
- package/dist/npm/install-batch-facet.d.ts +2 -0
- package/dist/npm/install-batch-facet.d.ts.map +1 -1
- package/dist/npm/install-batch-facet.js +29 -15
- package/dist/npm/installer.d.ts +8 -4
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +173 -113
- package/dist/npm/npx-install.d.ts +3 -1
- package/dist/npm/npx-install.d.ts.map +1 -1
- package/dist/npm/npx-install.js +4 -1
- package/dist/npm/placement.d.ts +16 -0
- package/dist/npm/placement.d.ts.map +1 -0
- package/dist/npm/placement.js +33 -0
- package/dist/npm/r2-cache.d.ts +10 -6
- package/dist/npm/r2-cache.d.ts.map +1 -1
- package/dist/npm/r2-cache.js +32 -16
- package/dist/npm/resolve-one-facet.d.ts +3 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +1 -0
- package/dist/npm/resolver.d.ts +11 -6
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +12 -3
- package/dist/runtime/bash-repl.d.ts +5 -3
- package/dist/runtime/bash-repl.d.ts.map +1 -1
- package/dist/runtime/bash-repl.js +8 -3
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +2 -10
- package/dist/runtime/esbuild-wasm-bytes.d.ts +25 -18
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +55 -30
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +0 -9
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +853 -181
- package/dist/runtime/python-repl.d.ts +4 -3
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +10 -39
- package/dist/runtime/ruby-repl.d.ts +3 -2
- package/dist/runtime/ruby-repl.d.ts.map +1 -1
- package/dist/runtime/ruby-repl.js +7 -6
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +5 -16
- package/dist/runtime/runtime-catalog.js +1 -1
- package/dist/runtime/wasi/preamble.d.ts +0 -22
- package/dist/runtime/wasi/preamble.d.ts.map +1 -1
- package/dist/runtime/wasi/preamble.js +160 -1445
- package/dist/runtime-catalog.generated.js +1 -1
- package/dist/session/hibernation.d.ts +45 -2
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +78 -1
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +1 -0
- package/dist/session/nimbus-session.d.ts +16 -23
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +25 -36
- package/dist/session/npm-install-port.d.ts.map +1 -1
- package/dist/session/npm-install-port.js +1 -0
- package/dist/session/port-capability.d.ts.map +1 -1
- package/dist/session/port-capability.js +11 -1
- package/dist/session/programmatic.js +2 -2
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +4 -2
- package/dist/session/rpc.d.ts +7 -44
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +17 -67
- package/dist/session/supervisor-op.d.ts +8 -3
- package/dist/session/supervisor-op.d.ts.map +1 -1
- package/dist/session/supervisor-op.js +10 -45
- package/dist/session/supervisor-rpc.d.ts +47 -22
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +64 -26
- package/dist/vfs/facet-resident-store.d.ts.map +1 -1
- package/dist/vfs/facet-resident-store.js +4 -2
- package/dist/workspace-host.d.ts +2 -1
- package/dist/workspace-host.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.js +3 -0
- package/package.json +30 -4
- package/public/_assets/esbuild-0.24.2.js +2380 -0
- package/public/_assets/runtime/{node-shims-8f8c64edd2a1f0f5.js → node-shims-7b4dd7a76d95d21e.js} +852 -180
- package/scripts/bundle-esbuild-wasm.mjs +55 -39
- package/scripts/bundle-facet-workers.mjs +45 -7
- package/scripts/bundle-runtime.mjs +35 -8
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placement paths: where a package lands, relative to the project's
|
|
3
|
+
* `node_modules` — `react` at root, `pkg-types/node_modules/confbox` nested
|
|
4
|
+
* under the dependent whose range root does not satisfy. Node walks
|
|
5
|
+
* `node_modules` upward from the importer, so a nested copy is found by its
|
|
6
|
+
* dependent (and what is beneath it) and by nobody else.
|
|
7
|
+
*/
|
|
8
|
+
const NM = '/node_modules/';
|
|
9
|
+
/** `name` under `parent`; `''` is the project itself. */
|
|
10
|
+
export function nestedPlacement(parent, name) {
|
|
11
|
+
return parent ? `${parent}${NM}${name}` : name;
|
|
12
|
+
}
|
|
13
|
+
/** The containing placement, `''` at root. */
|
|
14
|
+
export function parentPlacement(placement) {
|
|
15
|
+
const i = placement.lastIndexOf(NM);
|
|
16
|
+
return i < 0 ? '' : placement.slice(0, i);
|
|
17
|
+
}
|
|
18
|
+
/** The package name a placement holds. */
|
|
19
|
+
export function placementName(placement) {
|
|
20
|
+
const i = placement.lastIndexOf(NM);
|
|
21
|
+
return i < 0 ? placement : placement.slice(i + NM.length);
|
|
22
|
+
}
|
|
23
|
+
/** Placements Node's walk visits for `name` from inside `from`, nearest first, root last. */
|
|
24
|
+
export function visiblePlacements(from, name) {
|
|
25
|
+
const out = [];
|
|
26
|
+
let dir = from;
|
|
27
|
+
while (dir) {
|
|
28
|
+
out.push(`${dir}${NM}${name}`);
|
|
29
|
+
dir = parentPlacement(dir);
|
|
30
|
+
}
|
|
31
|
+
out.push(name);
|
|
32
|
+
return out;
|
|
33
|
+
}
|
package/dist/npm/r2-cache.d.ts
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
* stream directly from npm.
|
|
58
58
|
* - npm publish webhook -> cache invalidation.
|
|
59
59
|
*/
|
|
60
|
+
import { NPM_REGISTRY_ORIGIN, npmRegistryOrigin } from '@nimbus-sh/core/substrate/lifo/commands/system/npm.js';
|
|
60
61
|
import type { CacheTier, CacheKind } from '@nimbus-sh/core/_shared/cache-stats.js';
|
|
61
62
|
/**
|
|
62
63
|
* Per-call cache-stat event (cache metrics support). R2CacheClient
|
|
@@ -117,8 +118,9 @@ export declare const R2_CACHE_PREFIX = "v2";
|
|
|
117
118
|
* No data migration; existing R2 packument entries' customMetadata
|
|
118
119
|
* .expiresAt stamps remain valid against either TTL. */
|
|
119
120
|
export declare const PACKUMENT_TTL_MS: number;
|
|
121
|
+
export { NPM_REGISTRY_ORIGIN, npmRegistryOrigin };
|
|
120
122
|
/** The registry URL a packument is read from — also what `npm http` lines report. */
|
|
121
|
-
export declare function packumentUrl(name: string): string;
|
|
123
|
+
export declare function packumentUrl(name: string, registry?: string): string;
|
|
122
124
|
/** Cap on tarball bytes returned via this RPC. Workerd structured-clone
|
|
123
125
|
* cap is 32 MiB; we keep a comfortable margin to leave room for RPC
|
|
124
126
|
* framing + the call's own arg bytes. Tarballs above this size skip
|
|
@@ -171,7 +173,7 @@ type R2BucketLike = {
|
|
|
171
173
|
* encodeURIComponent on the name so '@scope/pkg' becomes a single path
|
|
172
174
|
* segment (R2 keys allow any UTF-8, but URL paths need encoding).
|
|
173
175
|
*/
|
|
174
|
-
export declare function packumentL2Url(name: string): string;
|
|
176
|
+
export declare function packumentL2Url(name: string, registry?: string): string;
|
|
175
177
|
/** L2 cache-key URL for a tarball content address. Hex + the SRI algo
|
|
176
178
|
* name are already URL-safe, so the R2 key doubles as the URL path. */
|
|
177
179
|
export declare function tarballL2Url(address: TarballAddress): string;
|
|
@@ -211,7 +213,7 @@ export declare function parseTarballAddress(integrity: string): TarballAddress |
|
|
|
211
213
|
*/
|
|
212
214
|
export declare function tarballKey(address: TarballAddress): string;
|
|
213
215
|
/** Compose the R2 object key for a packument. */
|
|
214
|
-
export declare function packumentKey(name: string): string;
|
|
216
|
+
export declare function packumentKey(name: string, registry?: string): string;
|
|
215
217
|
/**
|
|
216
218
|
* Per-instance counters surfaced for tests / probes. Read via
|
|
217
219
|
* `R2CacheClient.stats()`. Track at the FUNCTION boundary level so a
|
|
@@ -308,7 +310,7 @@ export declare class R2CacheClient {
|
|
|
308
310
|
* write back to L2 with a 5-min `Cache-Control: max-age=300`
|
|
309
311
|
* (matching the existing R2 customMetadata.expiresAt semantic).
|
|
310
312
|
*/
|
|
311
|
-
getPackument(name: string): Promise<CachedPackument | null>;
|
|
313
|
+
getPackument(name: string, registry?: string): Promise<CachedPackument | null>;
|
|
312
314
|
/**
|
|
313
315
|
* Resolve a packument through the whole stack: cache read, and on a
|
|
314
316
|
* miss (or an expired entry) the registry fetch plus the cache fill.
|
|
@@ -323,6 +325,8 @@ export declare class R2CacheClient {
|
|
|
323
325
|
* attacker would be choosing the address too. Here, the only bytes
|
|
324
326
|
* that reach `pc/<name>.json` are the ones registry.npmjs.org served
|
|
325
327
|
* for that exact name, one line below the fetch that produced them.
|
|
328
|
+
* Another registry (`options.registry`) fills and reads only its own
|
|
329
|
+
* namespace of the cache, so it can neither poison nor borrow those.
|
|
326
330
|
*
|
|
327
331
|
* `status` is set when the registry answered 4xx (no such package);
|
|
328
332
|
* `failure` when every attempt failed. Both leave `json` null.
|
|
@@ -330,6 +334,7 @@ export declare class R2CacheClient {
|
|
|
330
334
|
readThroughPackument(name: string, options?: {
|
|
331
335
|
retries?: number;
|
|
332
336
|
timeoutMs?: number;
|
|
337
|
+
registry?: string;
|
|
333
338
|
}): Promise<PackumentReadThrough>;
|
|
334
339
|
/**
|
|
335
340
|
* Write a packument JSON to R2 with a TTL stamp in customMetadata.
|
|
@@ -342,11 +347,10 @@ export declare class R2CacheClient {
|
|
|
342
347
|
* Returns true on success, false on failure (same best-effort posture
|
|
343
348
|
* as putTarball).
|
|
344
349
|
*/
|
|
345
|
-
putPackument(name: string, json: string): Promise<boolean>;
|
|
350
|
+
putPackument(name: string, json: string, registry?: string): Promise<boolean>;
|
|
346
351
|
/** Lightweight feature-detection for callers that want to log path. */
|
|
347
352
|
hasTarballBucket(): boolean;
|
|
348
353
|
/** Lightweight feature-detection for callers that want to log path. */
|
|
349
354
|
hasPackumentBucket(): boolean;
|
|
350
355
|
}
|
|
351
|
-
export {};
|
|
352
356
|
//# sourceMappingURL=r2-cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"r2-cache.d.ts","sourceRoot":"","sources":["../../src/npm/r2-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAE5D;;;;;;;;mBAQmB;AACnB,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDA6ByD;AACzD,eAAO,MAAM,gBAAgB,QAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"r2-cache.d.ts","sourceRoot":"","sources":["../../src/npm/r2-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC/G,OAAO,KAAK,EAAE,S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C,oBAAoB,CAAC;IA6DhC;;;;;;;;;;OAUG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAA4B,GAAG,OAAO,CAAC,OAAO,CAAC;IAexG,uEAAuE;IACvE,gBAAgB,IAAI,OAAO;IAI3B,uEAAuE;IACvE,kBAAkB,IAAI,OAAO;CAG9B"}
|
package/dist/npm/r2-cache.js
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
* stream directly from npm.
|
|
58
58
|
* - npm publish webhook -> cache invalidation.
|
|
59
59
|
*/
|
|
60
|
+
import { NPM_REGISTRY_ORIGIN, npmRegistryOrigin } from '@nimbus-sh/core/substrate/lifo/commands/system/npm.js';
|
|
60
61
|
/** Schema version baked into every cache key. Bump to invalidate
|
|
61
62
|
* everything atomically (e.g. if the storage shape changes or a bug
|
|
62
63
|
* poisoned a class of keys).
|
|
@@ -98,16 +99,28 @@ export const R2_CACHE_PREFIX = 'v2';
|
|
|
98
99
|
* No data migration; existing R2 packument entries' customMetadata
|
|
99
100
|
* .expiresAt stamps remain valid against either TTL. */
|
|
100
101
|
export const PACKUMENT_TTL_MS = 60 * 60_000;
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
// The origin rule lives with the command that reads NPM_REGISTRY; the cache
|
|
103
|
+
// keys by the same value.
|
|
104
|
+
export { NPM_REGISTRY_ORIGIN, npmRegistryOrigin };
|
|
103
105
|
/** Jittered backoff between packument fetch attempts. */
|
|
104
106
|
const PACKUMENT_BACKOFF_MS = [500, 1500, 4500];
|
|
105
107
|
/** The registry URL a packument is read from — also what `npm http` lines report. */
|
|
106
|
-
export function packumentUrl(name) {
|
|
108
|
+
export function packumentUrl(name, registry = NPM_REGISTRY_ORIGIN) {
|
|
107
109
|
const safeName = name.startsWith('@')
|
|
108
110
|
? '@' + encodeURIComponent(name.slice(1))
|
|
109
111
|
: encodeURIComponent(name);
|
|
110
|
-
return `${
|
|
112
|
+
return `${registry}/${safeName}`;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The cache path segment for a packument: `<name>.json` for the default
|
|
116
|
+
* registry (the keys warm caches already hold), and `<origin>/<name>.json`
|
|
117
|
+
* for any other, so a private registry never reads or fills the entries
|
|
118
|
+
* registry.npmjs.org served.
|
|
119
|
+
*/
|
|
120
|
+
function packumentCachePath(name, registry) {
|
|
121
|
+
return registry === NPM_REGISTRY_ORIGIN
|
|
122
|
+
? `${name}.json`
|
|
123
|
+
: `${encodeURIComponent(registry)}/${name}.json`;
|
|
111
124
|
}
|
|
112
125
|
/** Cap on tarball bytes returned via this RPC. Workerd structured-clone
|
|
113
126
|
* cap is 32 MiB; we keep a comfortable margin to leave room for RPC
|
|
@@ -136,8 +149,8 @@ const L2_KEY_HOST = 'https://nimbus-cache.invalid';
|
|
|
136
149
|
* encodeURIComponent on the name so '@scope/pkg' becomes a single path
|
|
137
150
|
* segment (R2 keys allow any UTF-8, but URL paths need encoding).
|
|
138
151
|
*/
|
|
139
|
-
export function packumentL2Url(name) {
|
|
140
|
-
return `${L2_KEY_HOST}/${R2_CACHE_PREFIX}/pc/${encodeURIComponent(name)}
|
|
152
|
+
export function packumentL2Url(name, registry = NPM_REGISTRY_ORIGIN) {
|
|
153
|
+
return `${L2_KEY_HOST}/${R2_CACHE_PREFIX}/pc/${encodeURIComponent(packumentCachePath(name, registry))}`;
|
|
141
154
|
}
|
|
142
155
|
/** L2 cache-key URL for a tarball content address. Hex + the SRI algo
|
|
143
156
|
* name are already URL-safe, so the R2 key doubles as the URL path. */
|
|
@@ -253,8 +266,8 @@ export function tarballKey(address) {
|
|
|
253
266
|
return `${R2_CACHE_PREFIX}/t/${address.algo}/${address.hex}.tgz`;
|
|
254
267
|
}
|
|
255
268
|
/** Compose the R2 object key for a packument. */
|
|
256
|
-
export function packumentKey(name) {
|
|
257
|
-
return `${R2_CACHE_PREFIX}/pc/${name}
|
|
269
|
+
export function packumentKey(name, registry = NPM_REGISTRY_ORIGIN) {
|
|
270
|
+
return `${R2_CACHE_PREFIX}/pc/${packumentCachePath(name, registry)}`;
|
|
258
271
|
}
|
|
259
272
|
/**
|
|
260
273
|
* R2-backed npm cache client. Wraps two R2 bindings (tarballs + packuments)
|
|
@@ -437,9 +450,9 @@ export class R2CacheClient {
|
|
|
437
450
|
* write back to L2 with a 5-min `Cache-Control: max-age=300`
|
|
438
451
|
* (matching the existing R2 customMetadata.expiresAt semantic).
|
|
439
452
|
*/
|
|
440
|
-
async getPackument(name) {
|
|
453
|
+
async getPackument(name, registry = NPM_REGISTRY_ORIGIN) {
|
|
441
454
|
// ── L2 fast path (per-colo) ───────────────────────────────────
|
|
442
|
-
const l2Key = new Request(packumentL2Url(name));
|
|
455
|
+
const l2Key = new Request(packumentL2Url(name, registry));
|
|
443
456
|
const l2Hit = await l2Get(l2Key);
|
|
444
457
|
if (l2Hit) {
|
|
445
458
|
this._l2HitsPackument++;
|
|
@@ -475,7 +488,7 @@ export class R2CacheClient {
|
|
|
475
488
|
return null;
|
|
476
489
|
}
|
|
477
490
|
this._l3GetsPackument++;
|
|
478
|
-
const obj = await this.packumentBucket.get(packumentKey(name));
|
|
491
|
+
const obj = await this.packumentBucket.get(packumentKey(name, registry));
|
|
479
492
|
if (!obj) {
|
|
480
493
|
this._recordMiss('L3', 'packument');
|
|
481
494
|
return null;
|
|
@@ -528,16 +541,19 @@ export class R2CacheClient {
|
|
|
528
541
|
* attacker would be choosing the address too. Here, the only bytes
|
|
529
542
|
* that reach `pc/<name>.json` are the ones registry.npmjs.org served
|
|
530
543
|
* for that exact name, one line below the fetch that produced them.
|
|
544
|
+
* Another registry (`options.registry`) fills and reads only its own
|
|
545
|
+
* namespace of the cache, so it can neither poison nor borrow those.
|
|
531
546
|
*
|
|
532
547
|
* `status` is set when the registry answered 4xx (no such package);
|
|
533
548
|
* `failure` when every attempt failed. Both leave `json` null.
|
|
534
549
|
*/
|
|
535
550
|
async readThroughPackument(name, options) {
|
|
536
|
-
const
|
|
551
|
+
const registry = options?.registry ?? NPM_REGISTRY_ORIGIN;
|
|
552
|
+
const cached = await this.getPackument(name, registry);
|
|
537
553
|
if (cached && !cached.expired && cached.json) {
|
|
538
554
|
return { json: cached.json, source: 'r2-cache' };
|
|
539
555
|
}
|
|
540
|
-
const url = packumentUrl(name);
|
|
556
|
+
const url = packumentUrl(name, registry);
|
|
541
557
|
const retries = Math.max(0, options?.retries ?? 3);
|
|
542
558
|
const timeoutMs = options?.timeoutMs ?? 15_000;
|
|
543
559
|
let lastErr;
|
|
@@ -566,7 +582,7 @@ export class R2CacheClient {
|
|
|
566
582
|
this._recordHit('L4', 'packument', json.length);
|
|
567
583
|
// Best-effort fill, awaited so a follow-up read in the same
|
|
568
584
|
// install sees it.
|
|
569
|
-
await this.putPackument(name, json);
|
|
585
|
+
await this.putPackument(name, json, registry);
|
|
570
586
|
return { json, source: 'network' };
|
|
571
587
|
}
|
|
572
588
|
if (resp.status >= 400 && resp.status < 500) {
|
|
@@ -605,12 +621,12 @@ export class R2CacheClient {
|
|
|
605
621
|
* Returns true on success, false on failure (same best-effort posture
|
|
606
622
|
* as putTarball).
|
|
607
623
|
*/
|
|
608
|
-
async putPackument(name, json) {
|
|
624
|
+
async putPackument(name, json, registry = NPM_REGISTRY_ORIGIN) {
|
|
609
625
|
if (!this.packumentBucket)
|
|
610
626
|
return false;
|
|
611
627
|
const expiresAt = Date.now() + PACKUMENT_TTL_MS;
|
|
612
628
|
try {
|
|
613
|
-
await this.packumentBucket.put(packumentKey(name), json, {
|
|
629
|
+
await this.packumentBucket.put(packumentKey(name, registry), json, {
|
|
614
630
|
httpMetadata: { contentType: 'application/json' },
|
|
615
631
|
customMetadata: { expiresAt: String(expiresAt) },
|
|
616
632
|
});
|
|
@@ -80,6 +80,8 @@ export interface ResolveOneSpec {
|
|
|
80
80
|
fetchTimeoutMs: number;
|
|
81
81
|
/** Retries for transient failures. Default 3. */
|
|
82
82
|
retries: number;
|
|
83
|
+
/** Registry origin the packument is read from (the install's `NPM_REGISTRY`). */
|
|
84
|
+
registry: string;
|
|
83
85
|
}
|
|
84
86
|
export interface ResolveOneResult {
|
|
85
87
|
/** Resolved package, or null if a registry policy filtered it out. */
|
|
@@ -201,6 +203,7 @@ export declare const resolveOnePackumentInFacet: (spec: ResolveOneSpec, env: {
|
|
|
201
203
|
getPackument: (name: string, options: {
|
|
202
204
|
retries: number;
|
|
203
205
|
timeoutMs: number;
|
|
206
|
+
registry: string;
|
|
204
207
|
}) => Promise<{
|
|
205
208
|
json: string | null;
|
|
206
209
|
source: "r2-cache" | "network";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-one-facet.d.ts","sourceRoot":"","sources":["../../src/npm/resolve-one-facet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AA4B/E;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC;+EAC2E;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-one-facet.d.ts","sourceRoot":"","sources":["../../src/npm/resolve-one-facet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,E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AC,EAAE,MAAM,CAAC;SAClB,CAAC,CAAC;KACJ,CAAC;CACH,KACA,OAAO,CAAC,gBAAgB,CAsW1B,CAAC"}
|
|
@@ -282,6 +282,7 @@ export const resolveOnePackumentInFacet = async function resolveOnePackumentInFa
|
|
|
282
282
|
const result = await __nimbusUseRpcResult(env.SUPERVISOR.getPackument(effName, {
|
|
283
283
|
retries: Math.max(0, spec.retries ?? 3),
|
|
284
284
|
timeoutMs: spec.fetchTimeoutMs ?? 15_000,
|
|
285
|
+
registry: spec.registry,
|
|
285
286
|
}), (r) => ({ json: r.json, source: r.source, events: r.events, status: r.status, failure: r.failure }));
|
|
286
287
|
packumentElapsedMs = Date.now() - packumentStart;
|
|
287
288
|
// Splice the supervisor's per-tier events into our accumulator.
|
package/dist/npm/resolver.d.ts
CHANGED
|
@@ -32,18 +32,23 @@ export interface ResolvedPackage {
|
|
|
32
32
|
export interface HoistPlan {
|
|
33
33
|
/** Root-level hoisted packages: name → ResolvedPackage. */
|
|
34
34
|
root: Map<string, ResolvedPackage>;
|
|
35
|
-
/**
|
|
36
|
-
* Packages that could not be hoisted due to version conflicts.
|
|
37
|
-
* Key: "parentName/childName", value: ResolvedPackage.
|
|
38
|
-
*/
|
|
35
|
+
/** Packages nested under a dependent root does not satisfy, by placement path (placement.ts). */
|
|
39
36
|
nested: Map<string, ResolvedPackage>;
|
|
40
37
|
}
|
|
38
|
+
/** One package at one placement: the unit diff, fetch and lockfile work in. */
|
|
39
|
+
export interface PackagePlacement {
|
|
40
|
+
/** Placement path relative to the project's `node_modules`. */
|
|
41
|
+
placement: string;
|
|
42
|
+
pkg: ResolvedPackage;
|
|
43
|
+
}
|
|
41
44
|
/**
|
|
42
45
|
* Serialize a resolved package into the registry-cache row shape. Facet task
|
|
43
46
|
* bodies keep inline literals of this shape because `fn.toString()` isolates
|
|
44
47
|
* cannot import supervisor modules.
|
|
45
48
|
*/
|
|
46
49
|
export declare function registryEntryFromResolved(pkg: ResolvedPackage): RegistryCacheEntry;
|
|
47
|
-
/**
|
|
48
|
-
export declare function computeHoistPlan(resolved: Map<string, ResolvedPackage>): HoistPlan;
|
|
50
|
+
/** The walk's placement decisions carried forward: first version per name at root, the rest nested. */
|
|
51
|
+
export declare function computeHoistPlan(resolved: Map<string, ResolvedPackage>, nested?: Map<string, ResolvedPackage>): HoistPlan;
|
|
52
|
+
/** Every placement in the plan, root first. */
|
|
53
|
+
export declare function hoistPlacements(plan: HoistPlan): PackagePlacement[];
|
|
49
54
|
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/npm/resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE7E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,8DAA8D;IAC9D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,sEAAsE;IACtE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,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,CAAC;IACnC,iGAAiG;IACjG,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACtC;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,eAAe,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,eAAe,GAAG,kBAAkB,CAgBlF;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACtC,MAAM,GAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAa,GAC/C,SAAS,CAKX;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,gBAAgB,EAAE,CAKnE"}
|
package/dist/npm/resolver.js
CHANGED
|
@@ -26,10 +26,19 @@ export function registryEntryFromResolved(pkg) {
|
|
|
26
26
|
fetchedAt: Date.now(),
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
export function computeHoistPlan(resolved) {
|
|
29
|
+
/** The walk's placement decisions carried forward: first version per name at root, the rest nested. */
|
|
30
|
+
export function computeHoistPlan(resolved, nested = new Map()) {
|
|
31
31
|
return {
|
|
32
32
|
root: new Map(resolved),
|
|
33
|
-
nested: new Map(),
|
|
33
|
+
nested: new Map(nested),
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
/** Every placement in the plan, root first. */
|
|
37
|
+
export function hoistPlacements(plan) {
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const [name, pkg] of plan.root)
|
|
40
|
+
out.push({ placement: name, pkg });
|
|
41
|
+
for (const [placement, pkg] of plan.nested)
|
|
42
|
+
out.push({ placement, pkg });
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { FacetManager } from '../facets/manager.js';
|
|
2
2
|
import type { WebSocketTerminal } from '../facets/ws-terminal.js';
|
|
3
|
-
import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
4
3
|
import type { Shell } from '@nimbus-sh/core/substrate/lifo/shell/Shell.js';
|
|
5
|
-
import type
|
|
4
|
+
import { type VfsCred, type RuntimeFsBridge, type NimbusFilesystemAuthority } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
6
5
|
import type { RuntimeManifest } from '@nimbus-sh/core/runtime/runtime-manifest.js';
|
|
7
6
|
export interface BashReplDeps {
|
|
8
7
|
facetMgr: FacetManager;
|
|
9
|
-
|
|
8
|
+
/** Owns the installed runtime blobs the session is instantiated from. */
|
|
9
|
+
authority: NimbusFilesystemAuthority;
|
|
10
10
|
terminal: WebSocketTerminal;
|
|
11
11
|
installRoot: string;
|
|
12
12
|
manifest: RuntimeManifest;
|
|
13
13
|
cred: VfsCred;
|
|
14
|
+
pid: number;
|
|
15
|
+
filesystem: RuntimeFsBridge;
|
|
14
16
|
env: Record<string, string>;
|
|
15
17
|
cwd: string;
|
|
16
18
|
shell?: Pick<Shell, 'env' | 'cwd' | 'takeQueuedInput'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/bash-repl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bash-repl.d.ts","sourceRoot":"","sources":["../../src/runtime/bash-repl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+CAA+C,CAAC;AAE3E,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAE1I,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAUnF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,yEAAyE;IACzE,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,eAAe,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,iBAAiB,CAAC,CAAC;CACxD;AA+LD,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { formatShellPrompt } from '@nimbus-sh/core/substrate/lifo/shell/Shell.js';
|
|
2
|
+
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
3
|
+
import { withHostFilesystem } from '@nimbus-sh/core/shell/execution-fs.js';
|
|
2
4
|
import { createBashFacetSession } from '@nimbus-sh/core/runtime/bash-runner.js';
|
|
3
5
|
import { facetHostForManager } from './facet-loader-host.js';
|
|
4
6
|
import { ReplSession, } from './repl-session.js';
|
|
@@ -82,9 +84,12 @@ class BashReplAdapter {
|
|
|
82
84
|
async ensureSession(signal) {
|
|
83
85
|
if (this.session)
|
|
84
86
|
return null;
|
|
85
|
-
this.session = await createBashFacetSession({
|
|
87
|
+
this.session = await withHostFilesystem(this.deps.authority, CRED_KERNEL, (artifacts) => createBashFacetSession({
|
|
86
88
|
facets: facetHostForManager(this.deps.facetMgr),
|
|
87
|
-
|
|
89
|
+
artifacts,
|
|
90
|
+
filesystem: this.deps.filesystem,
|
|
91
|
+
pid: this.deps.pid,
|
|
92
|
+
cred: this.deps.cred,
|
|
88
93
|
manifest: this.deps.manifest,
|
|
89
94
|
installRoot: this.deps.installRoot,
|
|
90
95
|
argv: ['bash', '--noediting', '-i'],
|
|
@@ -98,7 +103,7 @@ class BashReplAdapter {
|
|
|
98
103
|
stdinClosed: false,
|
|
99
104
|
stdinTty: true,
|
|
100
105
|
signal,
|
|
101
|
-
});
|
|
106
|
+
}));
|
|
102
107
|
const initial = this.session.initial;
|
|
103
108
|
if (initial.state !== 'need-input')
|
|
104
109
|
return this.consumeSlice(initial, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"cpython-resident.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-resident.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgDxE;AAeD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAgDjF"}
|
|
@@ -38,14 +38,6 @@ export function buildCPythonSocketProcessWorker(preamble) {
|
|
|
38
38
|
' if (supervisor) globalThis.__nimbusPySupervisor = supervisor;',
|
|
39
39
|
' __wasiAdoptSupervisor(supervisor);',
|
|
40
40
|
'}',
|
|
41
|
-
// A resident process answers between requests, and that is the only moment
|
|
42
|
-
// "durable while running" can be made true: by the time the caller holds a
|
|
43
|
-
// response, everything the request wrote has reached the VFS.
|
|
44
|
-
'async function __nimbusParkPy(value) {',
|
|
45
|
-
' await __wasiDrainPersist();',
|
|
46
|
-
' await __wasiRevalidateFS();',
|
|
47
|
-
' return value;',
|
|
48
|
-
'}',
|
|
49
41
|
'async function __nimbusStartPyProcess(args) {',
|
|
50
42
|
' const result = await globalThis.__cpythonStartProcess(args || {});',
|
|
51
43
|
' const ports = await globalThis.__cpythonListeningPorts();',
|
|
@@ -59,7 +51,7 @@ export function buildCPythonSocketProcessWorker(preamble) {
|
|
|
59
51
|
'export class NimbusProcess extends DurableObject {',
|
|
60
52
|
' async startProcess(args) {',
|
|
61
53
|
' __nimbusAdoptPySupervisor(this.env);',
|
|
62
|
-
' return
|
|
54
|
+
' return __nimbusStartPyProcess(args || {});',
|
|
63
55
|
' }',
|
|
64
56
|
' async fetch(request) {',
|
|
65
57
|
' __nimbusAdoptPySupervisor(this.env);',
|
|
@@ -70,7 +62,7 @@ export function buildCPythonSocketProcessWorker(preamble) {
|
|
|
70
62
|
' const hinted = Number(request.headers.get("X-Nimbus-Port") || 0);',
|
|
71
63
|
' const port = hinted || Array.from(globalThis.__nimbusVirtualSockets.listeners.keys())[0];',
|
|
72
64
|
' if (!port) return new Response("Nimbus Python process has no listening virtual socket", { status: 502 });',
|
|
73
|
-
' return
|
|
65
|
+
' return globalThis.__nimbusVirtualSockets.handleHttpRequest(port, request);',
|
|
74
66
|
' }',
|
|
75
67
|
'}',
|
|
76
68
|
].join('\n');
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* esbuild-wasm-bytes.ts — supervisor-side fetcher for the esbuild-wasm
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* esbuild-wasm-bytes.ts — supervisor-side fetcher for the two esbuild-wasm
|
|
3
|
+
* artifacts a transform facet is built from: the wasm binary and the JS
|
|
4
|
+
* adapter that drives it. Both live in the static-assets layer
|
|
5
|
+
* (env.ASSETS); this module hands them to the caller when needed.
|
|
5
6
|
*
|
|
6
7
|
* Cache strategy
|
|
7
8
|
* ──────────────
|
|
8
9
|
* - NO module-scope cache (would pin 16 MiB in supervisor heap; the
|
|
9
10
|
* reason this module exists, see Phase 2 A'.5 below).
|
|
10
11
|
* - L2 colo cache via `caches.default` (cache-and-scrub W-D): the bytes
|
|
11
|
-
* are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION
|
|
12
|
+
* are version-pinned by URL (`/_assets/esbuild-<ESBUILD_VERSION>.*`),
|
|
12
13
|
* so an `immutable` cache entry is correct. The Cache API holds its
|
|
13
14
|
* OWN reference outside the supervisor heap, so this does not
|
|
14
15
|
* re-introduce the residency that A'.5 removed.
|
|
@@ -28,6 +29,11 @@
|
|
|
28
29
|
* are stored OUTSIDE the supervisor heap (workerd manages them), so
|
|
29
30
|
* adding L2 wrap doesn't undo this.
|
|
30
31
|
*
|
|
32
|
+
* The JS adapter followed the wasm for the same reason at a smaller
|
|
33
|
+
* scale: the supervisor already imports esbuild-wasm's browser build as a
|
|
34
|
+
* module for its own transforms, so carrying the same 117 KiB again as a
|
|
35
|
+
* string literal for facets doubled it in the Worker bundle.
|
|
36
|
+
*
|
|
31
37
|
* Each call to `fetchEsbuildWasmBytes(env)` now does:
|
|
32
38
|
* - one `caches.default.match()` — sub-millisecond on hit
|
|
33
39
|
* - on miss: one env.ASSETS.fetch() + one cache write-back
|
|
@@ -39,16 +45,9 @@
|
|
|
39
45
|
* Cache lookup failure (any throw) → fall through to ASSETS.
|
|
40
46
|
* ASSETS fetch returning non-200 → throw (deploy bug, surface loudly).
|
|
41
47
|
* Digest mismatch on either tier → throw (the bytes are compiled as a wasm
|
|
42
|
-
* module, so they are verified against
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Path inside env.ASSETS where the esbuild-wasm binary lives.
|
|
46
|
-
* Versioned so a future esbuild-wasm bump produces a different asset
|
|
47
|
-
* name and forces a fresh fetch (no stale-cache risk). The matching
|
|
48
|
-
* file is staged at public/_assets/esbuild-<version>.wasm by
|
|
49
|
-
* scripts/bundle-esbuild-wasm.mjs at predeploy time.
|
|
48
|
+
* module or evaluated as facet code, so they are verified against the
|
|
49
|
+
* digest the generator recorded before returning).
|
|
50
50
|
*/
|
|
51
|
-
export declare const ESBUILD_WASM_ASSET_PATH = "/_assets/esbuild-0.24.2.wasm";
|
|
52
51
|
/**
|
|
53
52
|
* The minimal env shape this module needs. Defined narrowly so the
|
|
54
53
|
* caller can pass any env with an ASSETS Fetcher binding without
|
|
@@ -60,16 +59,18 @@ export interface EsbuildWasmFetchEnv {
|
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
61
|
/**
|
|
63
|
-
* Synthetic L2 cache
|
|
64
|
-
*
|
|
65
|
-
*
|
|
62
|
+
* Synthetic L2 cache keys for the esbuild-wasm assets, staged at
|
|
63
|
+
* public/_assets/esbuild-<version>.{wasm,js} by scripts/bundle-esbuild-wasm.mjs
|
|
64
|
+
* at predeploy time. Versioned via the asset paths so each esbuild upgrade
|
|
65
|
+
* lands fresh entries and old ones naturally evict on TTL.
|
|
66
66
|
*
|
|
67
67
|
* Exported so the test endpoint at /api/_test/cache/wasm/reset can
|
|
68
|
-
* purge the
|
|
68
|
+
* purge the entries between probe runs (otherwise wrangler dev's
|
|
69
69
|
* persistent caches.default.state preserves the L2 hit across sessions
|
|
70
70
|
* and the cold path is unobservable).
|
|
71
71
|
*/
|
|
72
|
-
export declare const ESBUILD_WASM_L2_KEY
|
|
72
|
+
export declare const ESBUILD_WASM_L2_KEY: string;
|
|
73
|
+
export declare const ESBUILD_JS_L2_KEY: string;
|
|
73
74
|
/**
|
|
74
75
|
* Fetch the esbuild-wasm bytes from the static-assets layer.
|
|
75
76
|
*
|
|
@@ -84,4 +85,10 @@ export declare const ESBUILD_WASM_L2_KEY = "https://nimbus-cache.invalid/_assets
|
|
|
84
85
|
* always the correct source of truth.
|
|
85
86
|
*/
|
|
86
87
|
export declare function fetchEsbuildWasmBytes(env: EsbuildWasmFetchEnv): Promise<ArrayBuffer>;
|
|
88
|
+
/**
|
|
89
|
+
* Fetch the esbuild-wasm JS adapter: the function body that, wrapped in
|
|
90
|
+
* `new Function(...)()`, returns the esbuild namespace. Facet sources
|
|
91
|
+
* splice it in verbatim, so it is verified like the wasm it drives.
|
|
92
|
+
*/
|
|
93
|
+
export declare function fetchEsbuildJsFnBody(env: EsbuildWasmFetchEnv): Promise<string>;
|
|
87
94
|
//# sourceMappingURL=esbuild-wasm-bytes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-wasm-bytes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"esbuild-wasm-bytes.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-wasm-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAWH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;CACpD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,QAA2D,CAAC;AAC5F,eAAO,MAAM,iBAAiB,QAAyD,CAAC;AA0BxF;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAEpF;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEpF"}
|