@nimbus-sh/worker 0.3.0 → 0.5.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/README.md +46 -43
- package/dist/_shared/preview-host.d.ts +14 -1
- package/dist/_shared/preview-host.d.ts.map +1 -1
- package/dist/_shared/preview-host.js +28 -3
- package/dist/_shared/session-router.d.ts +43 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +59 -12
- package/dist/esbuild-wasm-bundle.generated.d.ts +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +1 -1
- package/dist/facets/cirrus-real.js +1 -1
- package/dist/facets/durable-images.d.ts +50 -0
- package/dist/facets/durable-images.d.ts.map +1 -0
- package/dist/facets/durable-images.js +75 -0
- package/dist/facets/durable-slots.d.ts +45 -0
- package/dist/facets/durable-slots.d.ts.map +1 -0
- package/dist/facets/durable-slots.js +94 -0
- package/dist/facets/esbuild-transform.d.ts +10 -0
- package/dist/facets/esbuild-transform.d.ts.map +1 -0
- package/dist/facets/esbuild-transform.js +36 -0
- package/dist/facets/manager.d.ts +167 -12
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +575 -113
- package/dist/facets/opencode-staging.d.ts.map +1 -1
- package/dist/facets/opencode-staging.js +3 -4
- package/dist/facets/real-vite-hmr.js +1 -1
- package/dist/facets/vite-dev-server.d.ts +4 -4
- package/dist/facets/vite-dev-server.js +5 -5
- package/dist/git/commands.d.ts +22 -0
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +431 -424
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +6 -5
- package/dist/git-bundle.generated.d.ts +2 -2
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/loaders/child-process/spawn-facet.js +1 -1
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -1
- package/dist/loaders/child-process/spawn-pool.js +2 -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 +3 -3
- package/dist/loaders/npm-resolve-preamble.d.ts +3 -3
- package/dist/loaders/npm-resolve-preamble.js +3 -3
- package/dist/loaders/pre-bundle-preamble.d.ts +5 -5
- package/dist/loaders/pre-bundle-preamble.js +6 -6
- package/dist/node-shims-artifact.generated.js +3 -3
- package/dist/npm/install-batch-facet.d.ts +1 -1
- package/dist/npm/install-batch-facet.js +1 -1
- package/dist/npm/installer.d.ts +6 -6
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +28 -27
- package/dist/npm/pre-bundle-facet.d.ts +2 -2
- package/dist/npm/pre-bundle-facet.js +5 -5
- package/dist/npm/r2-cache.d.ts +1 -1
- package/dist/npm/resolve-facet.d.ts +1 -1
- package/dist/npm/resolve-facet.js +1 -1
- package/dist/npm/resolve-one-facet.d.ts +5 -5
- package/dist/npm/resolve-one-facet.js +5 -5
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +61 -4
- package/dist/router/public-directory-do.d.ts +17 -0
- package/dist/router/public-directory-do.d.ts.map +1 -0
- package/dist/router/public-directory-do.js +16 -0
- package/dist/router/public-directory.d.ts +75 -0
- package/dist/router/public-directory.d.ts.map +1 -0
- package/dist/router/public-directory.js +115 -0
- package/dist/router/remote-api.d.ts +9 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +20 -3
- package/dist/runtime/bun-repl.d.ts +1 -1
- package/dist/runtime/bun-repl.js +3 -3
- package/dist/runtime/esbuild-wasm-bytes.js +1 -1
- package/dist/runtime/facet-loader-host.d.ts +2 -2
- package/dist/runtime/facet-loader-host.js +3 -3
- package/dist/runtime/node-repl.js +2 -2
- package/dist/runtime/node-shims-artifact.js +1 -1
- package/dist/runtime/node-shims.d.ts +4 -1
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +326 -7
- package/dist/runtime/opencode-artifact.js +1 -1
- package/dist/runtime/opentui-wasm-bytes.js +1 -1
- package/dist/runtime/python-repl.js +3 -3
- package/dist/runtime/ruby-repl.js +2 -2
- package/dist/runtime/sqlite-wasm-bytes.js +1 -1
- package/dist/session/agent.d.ts +11 -0
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/diag.js +1 -1
- package/dist/session/helpers.js +1 -1
- package/dist/session/hibernation.d.ts +8 -8
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +15 -15
- package/dist/session/init-phases.d.ts +19 -26
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +20 -43
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +24 -19
- package/dist/session/keys.d.ts +8 -0
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +12 -3
- package/dist/session/nimbus-session.d.ts +33 -19
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +78 -37
- package/dist/session/port-capability.d.ts +95 -8
- package/dist/session/port-capability.d.ts.map +1 -1
- package/dist/session/port-capability.js +165 -8
- package/dist/session/programmatic.d.ts +50 -4
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +112 -15
- package/dist/session/routes.d.ts +17 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +111 -43
- package/dist/session/rpc.d.ts +7 -7
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +34 -23
- package/dist/session/shell-socket.d.ts +76 -0
- package/dist/session/shell-socket.d.ts.map +1 -0
- package/dist/session/shell-socket.js +172 -0
- package/dist/session/start-real-vite.js +2 -2
- package/dist/session/supervisor-op.d.ts +5 -0
- package/dist/session/supervisor-op.d.ts.map +1 -0
- package/dist/session/supervisor-op.js +74 -0
- package/dist/session/supervisor-rpc.d.ts +6 -10
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +98 -79
- package/dist/session/ws.d.ts +1 -3
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +23 -7
- package/package.json +4 -3
- package/public/_assets/runtime/{node-shims-fea906843f6d594e.js → node-shims-9e1380d9ee430fcc.js} +320 -5
- package/public/s/index.html +101 -5
- package/scripts/bundle-esbuild-wasm.mjs +2 -2
- package/scripts/bundle-facet-workers.mjs +5 -7
- package/scripts/bundle-sqlite-wasm.mjs +1 -1
package/dist/npm/installer.js
CHANGED
|
@@ -27,21 +27,22 @@ import { packumentUrl } from './r2-cache.js';
|
|
|
27
27
|
import { npmAddedLine, npmHttpCacheLine, npmHttpFetchLine, npmTitleLine, } from './npm-log.js';
|
|
28
28
|
import { applySwaps, findRejects, lookupSwap, lookupReject, shouldSkipPackage, shouldWarnSkipTransitive, isOptionalNativeBinding, formatSwapNotice, RegistryRejectError, emitRegistryEvent, } from '../facets/wasm-swap-registry.js';
|
|
29
29
|
import { resolvePackageEntry } from '@nimbus-sh/core/_shared/exports-resolver.js';
|
|
30
|
-
import { encodeWriteBatchStream } from '@nimbus-sh/
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
30
|
+
import { encodeWriteBatchStream } from '@nimbus-sh/platform/w7-frame.js';
|
|
31
|
+
import { IsolatePool } from '@nimbus-sh/fabric/isolate-pool.js';
|
|
32
|
+
import { Fanout, IN_DO_THRESHOLD } from '@nimbus-sh/fabric/fanout.js';
|
|
33
33
|
import { TAR_STREAM_PREAMBLE, W7_FRAME_PREAMBLE } from '../loaders/generated-workers.js';
|
|
34
34
|
import { installPackagesInFacet, } from './install-batch-facet.js';
|
|
35
|
-
import { setInstallPhase, recordInstallFacetCounters, recordPreBundleSummary, recordR2RaceCounters,
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
35
|
+
import { setInstallPhase, recordInstallFacetCounters, recordPreBundleSummary, recordR2RaceCounters, readDiagCounters, } from '@nimbus-sh/platform/diag-counters.js';
|
|
36
|
+
import { recordCacheStatEvents } from '@nimbus-sh/core/_shared/cache-stats.js';
|
|
37
|
+
import { estimateSupervisorHeap } from '@nimbus-sh/platform/heap-estimate.js';
|
|
38
|
+
import { describeError } from '@nimbus-sh/platform/oom-classify.js';
|
|
38
39
|
import { resolveOnePackumentInFacet, } from './resolve-one-facet.js';
|
|
39
40
|
import { NPM_RESOLVE_PREAMBLE } from '../loaders/npm-resolve-preamble.js';
|
|
40
41
|
import { prebundleOne, buildSliceForSpecifierWithCap, externalsForSpecifier, } from './pre-bundle-facet.js';
|
|
41
42
|
import { PRE_BUNDLE_PREAMBLE } from '../loaders/pre-bundle-preamble.js';
|
|
42
43
|
import { fetchEsbuildWasmBytes } from '../runtime/esbuild-wasm-bytes.js';
|
|
43
|
-
import { CHUNK_SIZE, PRE_BUNDLE_CONCURRENCY, PRE_BUNDLE_SLICE_CAP_BYTES, SUPERVISOR_IN_FLIGHT_ALLOCATION_BUDGET_BYTES, } from '@nimbus-sh/
|
|
44
|
-
import { acquireSupervisorAllocation } from '@nimbus-sh/
|
|
44
|
+
import { CHUNK_SIZE, PRE_BUNDLE_CONCURRENCY, PRE_BUNDLE_SLICE_CAP_BYTES, SUPERVISOR_IN_FLIGHT_ALLOCATION_BUDGET_BYTES, } from '@nimbus-sh/platform/limits.js';
|
|
45
|
+
import { acquireSupervisorAllocation } from '@nimbus-sh/platform/heavy-alloc-coord.js';
|
|
45
46
|
import { countPackageFiles, BARREL_PKG_FILE_THRESHOLD, packageNameFromSpecifier } from '@nimbus-sh/core/runtime/barrel-detect.js';
|
|
46
47
|
import { scanNamedImports, namedImportSignature, buildSyntheticEntry, buildScopedSliceForSynthetic, syntheticEntryPath, } from '../runtime/barrel-synthesizer.js';
|
|
47
48
|
import { enc } from '@nimbus-sh/core/_shared/bytes.js';
|
|
@@ -146,7 +147,7 @@ export class NpmInstaller {
|
|
|
146
147
|
phases['lock-check'] = Date.now() - phaseStart;
|
|
147
148
|
// ── Phase 1: Resolve ──────────────────────────────────────────
|
|
148
149
|
// Frontier-coordinator path. Each BFS layer dispatches to
|
|
149
|
-
//
|
|
150
|
+
// Fanout.submitMany — width <5 in-DO (in-DO fanout),
|
|
150
151
|
// width ≥5 peer-DO (peer-DO fanout). Per-package task body is
|
|
151
152
|
// self-contained (resolveOnePackumentInFacet), supervisor builds
|
|
152
153
|
// layer N+1 from layer N's edges. Missing env.LOADER throws at
|
|
@@ -222,7 +223,7 @@ export class NpmInstaller {
|
|
|
222
223
|
setInstallPhase('fetch');
|
|
223
224
|
// Fetch + extract + write new packages.
|
|
224
225
|
//
|
|
225
|
-
// Single fetch path: one
|
|
226
|
+
// Single fetch path: one IsolatePool isolate (the batch facet)
|
|
226
227
|
// runs the entire install. The facet streams tarballs through gunzip+tar
|
|
227
228
|
// and coalesces package-owned paths into shared writeBatchStream waves;
|
|
228
229
|
// every owner awaits each wave it contributed to.
|
|
@@ -419,7 +420,7 @@ export class NpmInstaller {
|
|
|
419
420
|
/**
|
|
420
421
|
* F-2 frontier-coordinator path. Replaces the single-resolve-facet
|
|
421
422
|
* dispatch with a per-package fanout: each BFS layer becomes ONE
|
|
422
|
-
* `
|
|
423
|
+
* `Fanout.submitMany` call, layer N+1 builds from the
|
|
423
424
|
* resolved metadata of layer N.
|
|
424
425
|
*
|
|
425
426
|
* Topology auto-routes per layer:
|
|
@@ -486,7 +487,7 @@ export class NpmInstaller {
|
|
|
486
487
|
const RESOLVE_PEER_CAP = 8;
|
|
487
488
|
// F-2 fanout pool. One construction reused across every layer; the
|
|
488
489
|
// pool is stateless across submitMany calls.
|
|
489
|
-
const fanoutPool = new
|
|
490
|
+
const fanoutPool = new Fanout(this.env, this.ctx, {
|
|
490
491
|
tag: 'npm-resolve-fanout',
|
|
491
492
|
// 5 minutes per layer is generous; typical layers complete in
|
|
492
493
|
// 1-3 s. Per-task this gates each packument fetch + R2 race.
|
|
@@ -561,8 +562,8 @@ export class NpmInstaller {
|
|
|
561
562
|
};
|
|
562
563
|
return { key: name, args: taskSpec };
|
|
563
564
|
});
|
|
564
|
-
// Dispatch the layer.
|
|
565
|
-
// <5 → in-DO fanout in-DO (
|
|
565
|
+
// Dispatch the layer. Fanout routes:
|
|
566
|
+
// <5 → in-DO fanout in-DO (IsolatePool), concurrency = layer.length (capped at 4)
|
|
566
567
|
// ≥5 → peer-DO fanout peer-DO, N peers = min(layer.length, 32)
|
|
567
568
|
let results;
|
|
568
569
|
const layerT0 = Date.now();
|
|
@@ -769,12 +770,12 @@ export class NpmInstaller {
|
|
|
769
770
|
return { resolved, unresolved };
|
|
770
771
|
}
|
|
771
772
|
/**
|
|
772
|
-
* Batch install via two-tier fan-out (
|
|
773
|
+
* Batch install via two-tier fan-out (Fanout).
|
|
773
774
|
*
|
|
774
775
|
* Shard count is `min(specs.length, INSTALL_PEER_CAP)`, and the topology
|
|
775
776
|
* follows from it:
|
|
776
777
|
* shardCount < IN_DO_THRESHOLD (5) → in-DO fanout in-DO
|
|
777
|
-
* 1
|
|
778
|
+
* 1 IsolatePool with concurrency = shardCount, capped at
|
|
778
779
|
* 4 by V8 invariant. Each shard is one facet running its own
|
|
779
780
|
* installPackagesInFacet.
|
|
780
781
|
* shardCount >= IN_DO_THRESHOLD → peer-DO fanout peer-DO
|
|
@@ -786,7 +787,7 @@ export class NpmInstaller {
|
|
|
786
787
|
* `shard-${i}` task key deterministically (tests can predict
|
|
787
788
|
* placement).
|
|
788
789
|
*
|
|
789
|
-
* Pre-fix lineage: this site previously ran ONE
|
|
790
|
+
* Pre-fix lineage: this site previously ran ONE IsolatePool
|
|
790
791
|
* with concurrency=1, internal pLimit(3) — the explicit "collapses
|
|
791
792
|
* what was 4 concurrent dynamic workers (pool.map slots) into 1"
|
|
792
793
|
* Two-tier topology re-expands the fan-out without re-introducing
|
|
@@ -851,7 +852,7 @@ export class NpmInstaller {
|
|
|
851
852
|
// Peer shards dispatch in bounded phases and each phase is a barrier, so
|
|
852
853
|
// the phase profile is what distinguishes shard work from barrier count.
|
|
853
854
|
const phaseProfile = [];
|
|
854
|
-
const fanoutPool = new
|
|
855
|
+
const fanoutPool = new Fanout(this.env, this.ctx, {
|
|
855
856
|
tag: 'npm-install-batch',
|
|
856
857
|
// Whole-batch timeout. With per-shard parallelism of N=8 peer
|
|
857
858
|
// DOs each running pLimit(3), Mossaic-class 456 packages
|
|
@@ -869,7 +870,7 @@ export class NpmInstaller {
|
|
|
869
870
|
});
|
|
870
871
|
const tasks = nonEmptyShards.map((shardSpecs, shardIdx) => ({
|
|
871
872
|
// Stable-id router key. Same shardIdx → same peer DO across
|
|
872
|
-
// runs. Tests can predict placement via
|
|
873
|
+
// runs. Tests can predict placement via Fanout's
|
|
873
874
|
// `peerSiblingId(key, peerCount)` helper.
|
|
874
875
|
key: `shard-${shardIdx}`,
|
|
875
876
|
args: { packages: shardSpecs, concurrency: 3 },
|
|
@@ -974,7 +975,7 @@ export class NpmInstaller {
|
|
|
974
975
|
}
|
|
975
976
|
catch (e) {
|
|
976
977
|
// Final catch — preserved from the pre-fix shape so the error
|
|
977
|
-
// log line shape stays consistent.
|
|
978
|
+
// log line shape stays consistent. Fanout's internal
|
|
978
979
|
// pools dispose themselves at the end of each submitMany call,
|
|
979
980
|
// so no explicit dispose() is needed here.
|
|
980
981
|
// The earlier inner-catch already logged + threw; if we reach
|
|
@@ -1304,7 +1305,7 @@ export class NpmInstaller {
|
|
|
1304
1305
|
* JSX elements get rejected as "alien" — silent render failure.
|
|
1305
1306
|
*/
|
|
1306
1307
|
async prebundleUsedModules(projDir, installed) {
|
|
1307
|
-
// Pre-bundle now runs in
|
|
1308
|
+
// Pre-bundle now runs in IsolatePool isolates (src/pre-bundle-facet.ts);
|
|
1308
1309
|
// each facet ships its own bundled esbuild-wasm via the preamble. The
|
|
1309
1310
|
// supervisor's EsbuildService is no longer on the bundle path — it
|
|
1310
1311
|
// still serves the transform path (TS/JSX → JS) which is small and
|
|
@@ -1444,7 +1445,7 @@ export class NpmInstaller {
|
|
|
1444
1445
|
// C'.1 deterministic estimator. process.memoryUsage() returns 0
|
|
1445
1446
|
// for every field inside a Durable Object class context (only
|
|
1446
1447
|
// dynamic-worker isolates under nodejs_compat get the real
|
|
1447
|
-
// implementation — see
|
|
1448
|
+
// implementation — see @nimbus-sh/platform/diag-counters.js:4 and
|
|
1448
1449
|
// heap-estimate.ts:6). The previous "supervisor heap 0.0 MiB"
|
|
1449
1450
|
// line was actively misleading: it printed every time, regardless
|
|
1450
1451
|
// of what was actually in the heap, and could not be used to
|
|
@@ -1515,7 +1516,7 @@ export class NpmInstaller {
|
|
|
1515
1516
|
// (where it should live). No supervisor-side caching — see
|
|
1516
1517
|
// src/esbuild-wasm-bytes.ts for the full architectural rationale.
|
|
1517
1518
|
//
|
|
1518
|
-
// Bytes are shipped into each facet via
|
|
1519
|
+
// Bytes are shipped into each facet via IsolatePool's
|
|
1519
1520
|
// `wasmModules` option which workerd registers in the LOADER
|
|
1520
1521
|
// `modules` map as `{ wasm: ArrayBuffer }`. Workerd compiles at
|
|
1521
1522
|
// module-load (startup phase, where wasm code generation is
|
|
@@ -1562,12 +1563,12 @@ export class NpmInstaller {
|
|
|
1562
1563
|
if (wasmBytes.byteLength > maxRetainedWasmBytes) {
|
|
1563
1564
|
throw new RangeError(`pre-bundle wasm payload ${wasmBytes.byteLength} exceeds the ${maxRetainedWasmBytes}-byte retained budget`);
|
|
1564
1565
|
}
|
|
1565
|
-
//
|
|
1566
|
+
// IsolatePool keeps the constructor-time module bytes until
|
|
1566
1567
|
// dispose(), so retain their exact credit rather than treating
|
|
1567
1568
|
// construction as a handoff that immediately frees the ArrayBuffer.
|
|
1568
1569
|
setupAllocation.shrinkTo(wasmBytes.byteLength);
|
|
1569
1570
|
try {
|
|
1570
|
-
pool = new
|
|
1571
|
+
pool = new IsolatePool(this.env, this.ctx, {
|
|
1571
1572
|
concurrency: PRE_BUNDLE_CONCURRENCY,
|
|
1572
1573
|
timeoutMs: 60_000,
|
|
1573
1574
|
retries: 0,
|
|
@@ -1994,7 +1995,7 @@ export class NpmInstaller {
|
|
|
1994
1995
|
/**
|
|
1995
1996
|
* P5 (production reliability) — deterministic supervisor-heap estimate in MiB.
|
|
1996
1997
|
*
|
|
1997
|
-
* Routes through
|
|
1998
|
+
* Routes through @nimbus-sh/platform/heap-estimate.js which sums KNOWN
|
|
1998
1999
|
* supervisor heap allocation sources from runtime counters that
|
|
1999
2000
|
* ARE accurate inside a DO context (DiagCounters singleton +
|
|
2000
2001
|
* SqliteVFS.getStats()). This replaces a previous use of
|
|
@@ -2035,7 +2036,7 @@ export class NpmInstaller {
|
|
|
2035
2036
|
// process.memoryUsage() which returns 0 for every field inside a
|
|
2036
2037
|
// Durable Object class context (only dynamic-worker isolates under
|
|
2037
2038
|
// nodejs_compat get the real implementation — see
|
|
2038
|
-
//
|
|
2039
|
+
// @nimbus-sh/platform/diag-counters.js:4). The deterministic
|
|
2039
2040
|
// supervisor-heap estimator is the C'.1 replacement; see
|
|
2040
2041
|
// NpmInstaller._estimateSupervisorHeapMiB.
|
|
2041
2042
|
function parentOf(path) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pre-bundle-facet.ts —
|
|
2
|
+
* pre-bundle-facet.ts — IsolatePool entry for esbuild pre-bundling.
|
|
3
3
|
*
|
|
4
4
|
* Why this exists
|
|
5
5
|
* ───────────────
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* the previous isolate.
|
|
15
15
|
*
|
|
16
16
|
* The fix is to dispatch each per-specifier `esbuild.build` to a
|
|
17
|
-
*
|
|
17
|
+
* IsolatePool isolate. Each facet has its own 128 MB budget and
|
|
18
18
|
* stable-slot reuse keeps the warm-up cost amortized across the 8
|
|
19
19
|
* concurrent specs of a typical install. The install-batch facet uses
|
|
20
20
|
* the same isolate boundary for tarball extraction.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pre-bundle-facet.ts —
|
|
2
|
+
* pre-bundle-facet.ts — IsolatePool entry for esbuild pre-bundling.
|
|
3
3
|
*
|
|
4
4
|
* Why this exists
|
|
5
5
|
* ───────────────
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* the previous isolate.
|
|
15
15
|
*
|
|
16
16
|
* The fix is to dispatch each per-specifier `esbuild.build` to a
|
|
17
|
-
*
|
|
17
|
+
* IsolatePool isolate. Each facet has its own 128 MB budget and
|
|
18
18
|
* stable-slot reuse keeps the warm-up cost amortized across the 8
|
|
19
19
|
* concurrent specs of a typical install. The install-batch facet uses
|
|
20
20
|
* the same isolate boundary for tarball extraction.
|
|
@@ -181,7 +181,7 @@ export function externalsForSpecifier(specifier) {
|
|
|
181
181
|
}
|
|
182
182
|
// ── Facet function ──────────────────────────────────────────────────────
|
|
183
183
|
//
|
|
184
|
-
// `prebundleOne` runs inside a
|
|
184
|
+
// `prebundleOne` runs inside a IsolatePool isolate. cloudflare-parallel
|
|
185
185
|
// serialises it via fn.toString(); the helpers it references at module
|
|
186
186
|
// scope (ESBUILD_WASM_JS_FN_BODY, resolvePackageEntry) are NOT in the
|
|
187
187
|
// facet's lexical scope at runtime. Instead they're injected by the
|
|
@@ -250,7 +250,7 @@ export const prebundleOne = async function prebundleOne(spec, _env) {
|
|
|
250
250
|
// runs that at module-load time (where eval is permitted) and
|
|
251
251
|
// stashes the result on the module-scope const __NIMBUS_ESBUILD_NS.
|
|
252
252
|
//
|
|
253
|
-
// The WASM module is shipped into the facet via
|
|
253
|
+
// The WASM module is shipped into the facet via IsolatePool's
|
|
254
254
|
// `wasmModules` option, registered in the LOADER's modules map as
|
|
255
255
|
// { wasm: ArrayBuffer }. Workerd compiles it during the worker's
|
|
256
256
|
// module-load phase (eval permitted there), and the pool's
|
|
@@ -285,7 +285,7 @@ export const prebundleOne = async function prebundleOne(spec, _env) {
|
|
|
285
285
|
if (!initPromise) {
|
|
286
286
|
initPromise = (async () => {
|
|
287
287
|
// Read the WebAssembly.Module the pool registered. The key matches
|
|
288
|
-
// the name passed to
|
|
288
|
+
// the name passed to IsolatePool's `wasmModules` option (see
|
|
289
289
|
// src/npm-installer.ts:prebundleUsedModules dispatch site).
|
|
290
290
|
const wasmRegistry = globalThis.__NIMBUS_WASM;
|
|
291
291
|
const wasmModule = wasmRegistry && wasmRegistry['esbuild.wasm'];
|
package/dist/npm/r2-cache.d.ts
CHANGED
|
@@ -220,7 +220,7 @@ export declare function packumentKey(name: string): string;
|
|
|
220
220
|
* proving the L2 layer is functional even when local-dev wall-clock
|
|
221
221
|
* latency is too noisy to demonstrate 5×.
|
|
222
222
|
*
|
|
223
|
-
* Diag counters (
|
|
223
|
+
* Diag counters (@nimbus-sh/platform/diag-counters.js) bump for the
|
|
224
224
|
* SupervisorRPC layer (RPC-perspective hit/miss). These per-instance
|
|
225
225
|
* counters bump for the R2CacheClient call surface itself (L2 vs L3
|
|
226
226
|
* vs miss), independent of who's calling.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* resolve-facet.ts — shared wire types for the per-packument resolver facet.
|
|
3
3
|
*
|
|
4
|
-
* The npm resolver phase runs inside a
|
|
4
|
+
* The npm resolver phase runs inside a IsolatePool isolate so the
|
|
5
5
|
* supervisor DO heap stays flat while large packuments are decoded. The
|
|
6
6
|
* per-packument task body lives in resolve-one-facet.ts; this module holds
|
|
7
7
|
* the types exchanged between supervisor and facet over RPC.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* resolve-facet.ts — shared wire types for the per-packument resolver facet.
|
|
3
3
|
*
|
|
4
|
-
* The npm resolver phase runs inside a
|
|
4
|
+
* The npm resolver phase runs inside a IsolatePool isolate so the
|
|
5
5
|
* supervisor DO heap stays flat while large packuments are decoded. The
|
|
6
6
|
* per-packument task body lives in resolve-one-facet.ts; this module holds
|
|
7
7
|
* the types exchanged between supervisor and facet over RPC.
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* independent fanout tasks. This file is the per-task body: one packument
|
|
8
8
|
* fetch, one version pick, and edge extraction.
|
|
9
9
|
*
|
|
10
|
-
* Each task runs inside a Worker Loader isolate (
|
|
10
|
+
* Each task runs inside a Worker Loader isolate (Fanout routes
|
|
11
11
|
* automatically: <5 = in-DO, ≥5 = peer-DO). The isolate is short-lived;
|
|
12
12
|
* task body has its own ~128 MiB envelope. Parallelism = layer width
|
|
13
|
-
* (capped at 32 by
|
|
13
|
+
* (capped at 32 by Fanout's MAX_PEER_FANOUT).
|
|
14
14
|
*
|
|
15
15
|
* Stability invariants (cloudflare-parallel serialises via fn.toString)
|
|
16
16
|
* ───────────────────────────────────────────────────────────────────
|
|
@@ -180,13 +180,13 @@ export interface ResolveOneResult {
|
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Per-package fanout task body. Serialised via fn.toString() and
|
|
183
|
-
* dispatched by
|
|
183
|
+
* dispatched by Fanout.submitMany — see installer.ts
|
|
184
184
|
* resolveTreeViaFanout.
|
|
185
185
|
*
|
|
186
|
-
* Function signature MUST be `(spec, env)` so
|
|
186
|
+
* Function signature MUST be `(spec, env)` so Fanout's
|
|
187
187
|
* submitMany invocation `fn(item, env)` lines up.
|
|
188
188
|
*
|
|
189
|
-
* `env` is the loader-isolate env supplied by
|
|
189
|
+
* `env` is the loader-isolate env supplied by Fanout.
|
|
190
190
|
* `env.SUPERVISOR` is the supervisor-rpc binding (putRegistryEntries,
|
|
191
191
|
* getPackument).
|
|
192
192
|
*/
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* independent fanout tasks. This file is the per-task body: one packument
|
|
8
8
|
* fetch, one version pick, and edge extraction.
|
|
9
9
|
*
|
|
10
|
-
* Each task runs inside a Worker Loader isolate (
|
|
10
|
+
* Each task runs inside a Worker Loader isolate (Fanout routes
|
|
11
11
|
* automatically: <5 = in-DO, ≥5 = peer-DO). The isolate is short-lived;
|
|
12
12
|
* task body has its own ~128 MiB envelope. Parallelism = layer width
|
|
13
|
-
* (capped at 32 by
|
|
13
|
+
* (capped at 32 by Fanout's MAX_PEER_FANOUT).
|
|
14
14
|
*
|
|
15
15
|
* Stability invariants (cloudflare-parallel serialises via fn.toString)
|
|
16
16
|
* ───────────────────────────────────────────────────────────────────
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
*/
|
|
62
62
|
/**
|
|
63
63
|
* Per-package fanout task body. Serialised via fn.toString() and
|
|
64
|
-
* dispatched by
|
|
64
|
+
* dispatched by Fanout.submitMany — see installer.ts
|
|
65
65
|
* resolveTreeViaFanout.
|
|
66
66
|
*
|
|
67
|
-
* Function signature MUST be `(spec, env)` so
|
|
67
|
+
* Function signature MUST be `(spec, env)` so Fanout's
|
|
68
68
|
* submitMany invocation `fn(item, env)` lines up.
|
|
69
69
|
*
|
|
70
|
-
* `env` is the loader-isolate env supplied by
|
|
70
|
+
* `env` is the loader-isolate env supplied by Fanout.
|
|
71
71
|
* `env.SUPERVISOR` is the supervisor-rpc binding (putRegistryEntries,
|
|
72
72
|
* getPackument).
|
|
73
73
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAuCH,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AA+BzB,YAAY,EACV,YAAY,IAAI,eAAe,EAC/B,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,O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;;GAiCG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,aAAa,CAuUf"}
|
package/dist/router/index.js
CHANGED
|
@@ -33,11 +33,39 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { generateSessionId, isValidSessionId, } from '../_shared/session-id.js';
|
|
35
35
|
import { buildPreviewHost, isPreviewHostSafeSid, parsePreviewHost, readPreviewHostSuffix, } from '../_shared/preview-host.js';
|
|
36
|
-
import { parseSessionRoute, forwardToSession, renderInvalidSessionHtml, SESSION_ROUTE_PREFIX, LEGACY_PUBLIC_DO_SEGMENT, } from '../_shared/session-router.js';
|
|
36
|
+
import { parseSessionRoute, forwardToSession, renderInvalidSessionHtml, SESSION_ROUTE_PREFIX, LEGACY_PUBLIC_DO_SEGMENT, PREVIEW_CAPABILITY_HEADER, PUBLIC_BEARER_HEADER, } from '../_shared/session-router.js';
|
|
37
37
|
import { issueNimbusToken, verifyNimbusToken, verifyRequestToken, requireScopes, requireSessionPin, authErrorResponse, setNimbusTokenCookie, NIMBUS_TOKEN_QUERY, NimbusAuthError, NimbusBootstrapConsumedError, NimbusTokenClaimsError, DEFAULT_TOKEN_TTL_MS, ATTACH_BOOTSTRAP_TTL_MS, } from '../auth/index.js';
|
|
38
|
-
import {
|
|
38
|
+
import { adoptCtxExports } from '@nimbus-sh/fabric/composition.js';
|
|
39
39
|
import { handleNimbusRemoteApi, } from './remote-api.js';
|
|
40
40
|
import { parseAgentOAuthStateParam } from '../session/agent.js';
|
|
41
|
+
import { publicDirectoryStub } from './public-directory.js';
|
|
42
|
+
/**
|
|
43
|
+
* Positive directory resolutions, per isolate. A capability that resolved
|
|
44
|
+
* once keeps resolving — the row is deleted only when the port goes
|
|
45
|
+
* private, and a stale cache entry 404s honestly at the session's own
|
|
46
|
+
* visibility check anyway. Misses are never cached.
|
|
47
|
+
*/
|
|
48
|
+
const publicTenantCache = new Map();
|
|
49
|
+
/**
|
|
50
|
+
* The tenant segment a public capability URL forwards under. The directory
|
|
51
|
+
* is consulted first; a deployment without the binding falls back to the
|
|
52
|
+
* legacy-public DO name, which is where legacy-mode sessions already live.
|
|
53
|
+
*/
|
|
54
|
+
async function resolvePublicTenantSegment(capability, env) {
|
|
55
|
+
const cached = publicTenantCache.get(capability);
|
|
56
|
+
if (cached !== undefined)
|
|
57
|
+
return cached;
|
|
58
|
+
const stub = publicDirectoryStub(env);
|
|
59
|
+
if (stub === null)
|
|
60
|
+
return LEGACY_PUBLIC_DO_SEGMENT;
|
|
61
|
+
const entry = await stub.resolve(capability).catch(() => null);
|
|
62
|
+
if (entry === null) {
|
|
63
|
+
// An unresolvable capability 404s: no session DO is named for it.
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
publicTenantCache.set(capability, entry.tenantSegment);
|
|
67
|
+
return entry.tenantSegment;
|
|
68
|
+
}
|
|
41
69
|
/**
|
|
42
70
|
* Build a Nimbus default-export handler. The returned object is exactly
|
|
43
71
|
* what `export default` expects in a Workers entry module.
|
|
@@ -82,7 +110,7 @@ export function createNimbusHandler(options = {}) {
|
|
|
82
110
|
async function route(request, env, ctx) {
|
|
83
111
|
// Capture ctx.exports on first call (loopback bindings for facets).
|
|
84
112
|
if (ctx?.exports)
|
|
85
|
-
|
|
113
|
+
adoptCtxExports(ctx.exports);
|
|
86
114
|
const url = new URL(request.url);
|
|
87
115
|
const previewSuffix = readPreviewHostSuffix(env);
|
|
88
116
|
// ── <port>--<sid>.<suffix> — port preview ───────────────────────
|
|
@@ -102,6 +130,30 @@ export function createNimbusHandler(options = {}) {
|
|
|
102
130
|
},
|
|
103
131
|
});
|
|
104
132
|
}
|
|
133
|
+
if (preview.capability !== undefined) {
|
|
134
|
+
// The public capability form carries no attach token and never
|
|
135
|
+
// asks for one: the capability IS the bearer, so there is no
|
|
136
|
+
// session:attach exchange and no embedder credential to verify.
|
|
137
|
+
// The capability names the owning session through the public
|
|
138
|
+
// directory — a positive hit is cached for the life of this
|
|
139
|
+
// isolate, a miss 404s, and a deployment without the binding
|
|
140
|
+
// falls back to the legacy-public DO name.
|
|
141
|
+
const tenantSegment = await resolvePublicTenantSegment(preview.capability, env);
|
|
142
|
+
if (tenantSegment === null) {
|
|
143
|
+
return new Response('Not found', { status: 404 });
|
|
144
|
+
}
|
|
145
|
+
return forwardToSession(request, {
|
|
146
|
+
sessionId: preview.sid,
|
|
147
|
+
innerPath: `/port/${preview.port}${url.pathname === '/' ? '/' : url.pathname}`,
|
|
148
|
+
basePath: '',
|
|
149
|
+
}, env, {
|
|
150
|
+
tenantSegment,
|
|
151
|
+
extraHeaders: {
|
|
152
|
+
[PREVIEW_CAPABILITY_HEADER]: preview.capability,
|
|
153
|
+
[PUBLIC_BEARER_HEADER]: '1',
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
105
157
|
if (request.method === 'GET'
|
|
106
158
|
&& request.headers.get('Upgrade') !== 'websocket'
|
|
107
159
|
&& url.searchParams.get(NIMBUS_TOKEN_QUERY)
|
|
@@ -281,7 +333,12 @@ export function createNimbusHandler(options = {}) {
|
|
|
281
333
|
console.warn('[nimbus] onSessionStart hook threw synchronously:', e);
|
|
282
334
|
}
|
|
283
335
|
}
|
|
284
|
-
return forwardToSession(request, route, env, {
|
|
336
|
+
return forwardToSession(request, route, env, {
|
|
337
|
+
tenantSegment,
|
|
338
|
+
...(auth.verified?.claims.scopes !== undefined
|
|
339
|
+
? { callerScopes: auth.verified.claims.scopes }
|
|
340
|
+
: {}),
|
|
341
|
+
});
|
|
285
342
|
}
|
|
286
343
|
// ── Back-compat legacy root paths → landing page ────────────────
|
|
287
344
|
if (isLegacyRootPath(url.pathname)) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* public-directory-do.ts — the NimbusPublicDirectory Durable Object class.
|
|
3
|
+
*
|
|
4
|
+
* Lives apart from `public-directory.ts` so the session-side helpers and
|
|
5
|
+
* the router-side stub stay importable outside workerd — this file alone
|
|
6
|
+
* needs `cloudflare:workers` for `DurableObject`. The wrangler binding
|
|
7
|
+
* name and migration entry are `NimbusPublicDirectory`.
|
|
8
|
+
*/
|
|
9
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
10
|
+
import { type PublicDirectoryEntry } from './public-directory.js';
|
|
11
|
+
export declare class NimbusPublicDirectory extends DurableObject {
|
|
12
|
+
private store;
|
|
13
|
+
bind(capability: string, entry: PublicDirectoryEntry): Promise<void>;
|
|
14
|
+
unbind(capability: string): Promise<void>;
|
|
15
|
+
resolve(capability: string): Promise<PublicDirectoryEntry | null>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=public-directory-do.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-directory-do.d.ts","sourceRoot":"","sources":["../../src/router/public-directory-do.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,KAAK,CAAsC;IAEnD,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;IACpD,MAAM,CAAC,UAAU,EAAE,MAAM;IACzB,OAAO,CAAC,UAAU,EAAE,MAAM;CAC3B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* public-directory-do.ts — the NimbusPublicDirectory Durable Object class.
|
|
3
|
+
*
|
|
4
|
+
* Lives apart from `public-directory.ts` so the session-side helpers and
|
|
5
|
+
* the router-side stub stay importable outside workerd — this file alone
|
|
6
|
+
* needs `cloudflare:workers` for `DurableObject`. The wrangler binding
|
|
7
|
+
* name and migration entry are `NimbusPublicDirectory`.
|
|
8
|
+
*/
|
|
9
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
10
|
+
import { PublicDirectoryStore, } from './public-directory.js';
|
|
11
|
+
export class NimbusPublicDirectory extends DurableObject {
|
|
12
|
+
store = new PublicDirectoryStore(this.ctx);
|
|
13
|
+
bind(capability, entry) { return this.store.bind(capability, entry); }
|
|
14
|
+
unbind(capability) { return this.store.unbind(capability); }
|
|
15
|
+
resolve(capability) { return this.store.resolve(capability); }
|
|
16
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* public-directory.ts — capability → session routing for public preview hosts.
|
|
3
|
+
*
|
|
4
|
+
* The public capability host form `<cap>--<port>--<sid>.<suffix>` carries
|
|
5
|
+
* no session:attach credential, so the router has no verified tenant to
|
|
6
|
+
* name the session DO with. This singleton Durable Object is the one
|
|
7
|
+
* lookup that answers it: keyed by the unguessable 24-hex capability,
|
|
8
|
+
* it says which tenant segment + sid + port the capability belongs to.
|
|
9
|
+
* Rows are written by the session the moment a port goes public and are
|
|
10
|
+
* deleted on unexpose/clear/remove — there is no listing API, so the
|
|
11
|
+
* directory is never an enumeration surface.
|
|
12
|
+
*/
|
|
13
|
+
export interface PublicDirectoryEntry {
|
|
14
|
+
readonly tenantSegment: string;
|
|
15
|
+
readonly sid: string;
|
|
16
|
+
readonly port: number;
|
|
17
|
+
}
|
|
18
|
+
/** The DO body, usable with any `{ storage }` the tests hand it. */
|
|
19
|
+
export declare class PublicDirectoryStore {
|
|
20
|
+
private ctx;
|
|
21
|
+
constructor(ctx: {
|
|
22
|
+
storage: {
|
|
23
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
24
|
+
put(key: string, value: unknown): Promise<void>;
|
|
25
|
+
delete(key: string): Promise<unknown>;
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
bind(capability: string, entry: {
|
|
29
|
+
tenantSegment: string;
|
|
30
|
+
sid: string;
|
|
31
|
+
port: number;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
unbind(capability: string): Promise<void>;
|
|
34
|
+
resolve(capability: string): Promise<PublicDirectoryEntry | null>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The stub the router and the session share: one name, one binding, one
|
|
38
|
+
* instance. A missing binding on an enforce-mode deployment is loud at the
|
|
39
|
+
* caller — this helper returns null and the caller decides.
|
|
40
|
+
*/
|
|
41
|
+
export declare function publicDirectoryStub(env: unknown): {
|
|
42
|
+
bind(capability: string, entry: PublicDirectoryEntry): Promise<void>;
|
|
43
|
+
unbind(capability: string): Promise<void>;
|
|
44
|
+
resolve(capability: string): Promise<PublicDirectoryEntry | null>;
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Publish a public port's capability to the routing directory. A legacy-
|
|
48
|
+
* public deployment needs no directory — its DO name is already the one
|
|
49
|
+
* the public form resolves to — and is allowed to run without the binding.
|
|
50
|
+
* Anything else MUST bind, and a missing `NIMBUS_PUBLIC_DIRECTORY` binding
|
|
51
|
+
* on a non-legacy deployment is a loud error: the exposure would be half-
|
|
52
|
+
* public — stored as public, unroutable in practice.
|
|
53
|
+
*/
|
|
54
|
+
export declare function bindPublicPortCapability(host: {
|
|
55
|
+
env?: unknown;
|
|
56
|
+
ctx?: {
|
|
57
|
+
id?: {
|
|
58
|
+
name?: unknown;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
tenantSegment?: string;
|
|
62
|
+
sessionId?: string;
|
|
63
|
+
}, capability: string, port: number): Promise<void>;
|
|
64
|
+
/** Retire a public port's capability from the routing directory. */
|
|
65
|
+
export declare function unbindPublicPortCapability(host: {
|
|
66
|
+
env?: unknown;
|
|
67
|
+
ctx?: {
|
|
68
|
+
id?: {
|
|
69
|
+
name?: unknown;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
tenantSegment?: string;
|
|
73
|
+
sessionId?: string;
|
|
74
|
+
}, capability: string): Promise<void>;
|
|
75
|
+
//# sourceMappingURL=public-directory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-directory.d.ts","sourceRoot":"","sources":["../../src/router/public-directory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