@nimbus-sh/worker 0.12.0 → 0.13.1
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-cli-artifact.generated.d.ts +1 -1
- package/dist/esbuild-cli-artifact.generated.js +4 -4
- package/dist/esbuild-wasm-bundle.generated.d.ts +11 -10
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +11 -10
- package/dist/facets/build-facet.d.ts +53 -0
- package/dist/facets/build-facet.d.ts.map +1 -0
- package/dist/facets/build-facet.js +346 -0
- package/dist/facets/cirrus-real.d.ts +3 -0
- package/dist/facets/cirrus-real.d.ts.map +1 -1
- package/dist/facets/cirrus-real.js +1 -2
- package/dist/facets/compose.d.ts +1 -0
- package/dist/facets/compose.d.ts.map +1 -1
- package/dist/facets/compose.js +3 -0
- package/dist/facets/data-plan.d.ts +14 -30
- package/dist/facets/data-plan.d.ts.map +1 -1
- package/dist/facets/data-plan.js +153 -13
- package/dist/facets/dev-stylesheet.d.ts +27 -0
- package/dist/facets/dev-stylesheet.d.ts.map +1 -0
- package/dist/facets/dev-stylesheet.js +65 -0
- package/dist/facets/esbuild-transform.d.ts +23 -18
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +63 -109
- package/dist/facets/manager.d.ts +49 -9
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +238 -69
- package/dist/facets/oxc-transform.d.ts +29 -0
- package/dist/facets/oxc-transform.d.ts.map +1 -0
- package/dist/facets/oxc-transform.js +198 -0
- package/dist/facets/prebundle-pool.d.ts +23 -0
- package/dist/facets/prebundle-pool.d.ts.map +1 -0
- package/dist/facets/prebundle-pool.js +55 -0
- package/dist/facets/process.d.ts +13 -6
- package/dist/facets/process.d.ts.map +1 -1
- package/dist/facets/process.js +37 -31
- package/dist/facets/transform-store.d.ts +4 -4
- package/dist/facets/transform-store.js +4 -4
- package/dist/facets/vite-dev-server.d.ts +89 -12
- package/dist/facets/vite-dev-server.d.ts.map +1 -1
- package/dist/facets/vite-dev-server.js +66 -43
- package/dist/hosted/commands.d.ts.map +1 -1
- package/dist/hosted/commands.js +20 -4
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +7 -2
- package/dist/hosted/services.d.ts +3 -3
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +102 -95
- package/dist/hosted/session.d.ts +1 -0
- package/dist/hosted/session.d.ts.map +1 -1
- package/dist/loaders/generated-workers.d.ts +3 -0
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +3 -0
- package/dist/napi-wasm-artifacts.generated.js +2 -2
- package/dist/node-shims-artifact.generated.d.ts +14 -1
- package/dist/node-shims-artifact.generated.d.ts.map +1 -1
- package/dist/node-shims-artifact.generated.js +23 -10
- package/dist/npm/bin-links.d.ts +7 -4
- package/dist/npm/bin-links.d.ts.map +1 -1
- package/dist/npm/bin-links.js +14 -55
- package/dist/npm/cache.d.ts +6 -0
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +26 -4
- package/dist/npm/installer.d.ts +1 -1
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +26 -52
- package/dist/npm/pre-bundle-facet.d.ts +15 -117
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
- package/dist/npm/pre-bundle-facet.js +13 -511
- package/dist/oxc-facet-artifact.generated.d.ts +18 -0
- package/dist/oxc-facet-artifact.generated.d.ts.map +1 -0
- package/dist/oxc-facet-artifact.generated.js +17 -0
- package/dist/oxc-wasm-artifact.generated.d.ts +20 -0
- package/dist/oxc-wasm-artifact.generated.d.ts.map +1 -0
- package/dist/oxc-wasm-artifact.generated.js +19 -0
- package/dist/rolldown-facet-artifact.generated.d.ts +18 -0
- package/dist/rolldown-facet-artifact.generated.d.ts.map +1 -0
- package/dist/rolldown-facet-artifact.generated.js +17 -0
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +9 -0
- package/dist/runtime/bash-repl.d.ts.map +1 -1
- package/dist/runtime/bash-repl.js +1 -4
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +1 -0
- package/dist/runtime/esbuild-wasm-bytes.d.ts +25 -23
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +30 -25
- package/dist/runtime/facet-loader-host.d.ts +5 -4
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +5 -4
- package/dist/runtime/node-runner.d.ts +2 -0
- package/dist/runtime/node-runner.d.ts.map +1 -1
- package/dist/runtime/node-runner.js +1 -0
- package/dist/runtime/node-shims-artifact.d.ts +8 -1
- package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
- package/dist/runtime/node-shims-artifact.js +32 -4
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +145 -109
- package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
- package/dist/runtime/opencode-facet-runner.js +6 -2
- package/dist/runtime/oxc-wasm-bytes.d.ts +19 -0
- package/dist/runtime/oxc-wasm-bytes.d.ts.map +1 -0
- package/dist/runtime/oxc-wasm-bytes.js +39 -0
- package/dist/runtime/package-manager.js +1 -1
- package/dist/runtime/process-logs-api.d.ts.map +1 -1
- package/dist/runtime/process-logs-api.js +2 -0
- package/dist/runtime/project-fs.d.ts +8 -1
- package/dist/runtime/project-fs.d.ts.map +1 -1
- package/dist/runtime/project-fs.js +15 -1
- package/dist/runtime/python-repl.d.ts +40 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +19 -11
- package/dist/runtime/ruby-repl.d.ts +38 -0
- package/dist/runtime/ruby-repl.d.ts.map +1 -1
- package/dist/runtime/ruby-repl.js +24 -5
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +2 -0
- package/dist/session/nimbus-session.d.ts +13 -8
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +11 -5
- package/dist/session/programmatic.d.ts +25 -30
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +65 -93
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +23 -7
- package/dist/session/rpc.d.ts +16 -6
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +53 -13
- package/dist/session/start-real-vite.d.ts +24 -9
- package/dist/session/start-real-vite.d.ts.map +1 -1
- package/dist/session/start-real-vite.js +40 -4
- package/dist/session/supervisor-op.d.ts +14 -0
- package/dist/session/supervisor-op.d.ts.map +1 -1
- package/dist/session/supervisor-op.js +49 -0
- package/dist/session/supervisor-rpc.d.ts +11 -0
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +18 -0
- package/dist/session/vite-command.d.ts.map +1 -1
- package/dist/session/vite-command.js +23 -19
- package/dist/session/ws-relay.d.ts.map +1 -1
- package/dist/session/ws-relay.js +13 -1
- package/dist/shell/npm-bin-entrypoints.d.ts +3 -1
- package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
- package/dist/shell/npm-bin-entrypoints.js +53 -25
- package/dist/vfs/facet-resident-store.d.ts.map +1 -1
- package/dist/vfs/facet-resident-store.js +11 -5
- package/dist/wrangler/nimbus-wrangler.d.ts +8 -0
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.js +54 -57
- package/package.json +7 -5
- package/public/_assets/esbuild-0.24.2.wasm +0 -0
- package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/napi-wasm-loader.mjs +4 -4
- package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/provenance.json +2 -2
- package/public/_assets/oxc/nimbus-oxc-1aa8c4c7057c6c28.provenance.json +72 -0
- package/public/_assets/oxc/nimbus-oxc-1aa8c4c7057c6c28.wasm +0 -0
- package/public/_assets/runtime/esbuild-cli-f13e6a112b03ac07.js +1143 -0
- package/public/_assets/runtime/js-interpreter-3c37c48024f0f651.js +23 -0
- package/public/_assets/runtime/js-interpreter-ops-2f4dfec6798e70fc.js +290 -0
- package/public/_assets/runtime/js-interpreter-primordials-e620a61b7e9800fa.js +1 -0
- package/public/_assets/runtime/{node-shims-f92f16c7d7c532e9.js → node-shims-e3adc4576da31e6e.js} +651 -103
- package/public/_assets/runtime/{esbuild-cli-b7aecffd4c6a36fe.js → oxc-facet-fd86fefcdf16bf9c.js} +217 -1047
- package/public/_assets/runtime/{resident-store-92386265e8b306dc.js → resident-store-009f39539ac989fc.js} +11 -5
- package/public/_assets/runtime/rolldown-facet-09983434e2dbe93e.js +15165 -0
- package/public/_assets/runtime/{vfs-write-ledger-d33ee0034446c3e0.js → vfs-write-ledger-9e9594591425a9b8.js} +4 -1
- package/scripts/acorn-primordials.mjs +637 -0
- package/scripts/bundle-esbuild-wasm.mjs +42 -50
- package/scripts/bundle-facet-workers.mjs +247 -18
- package/scripts/bundle-node-shims.mjs +29 -2
- package/scripts/bundle-oxc-wasm.mjs +105 -0
- package/scripts/interpreter-bundle.mjs +105 -0
- package/scripts/napi-wasm/build.mjs +4 -1
- package/scripts/napi-wasm/loader/napi-wasm-loader.ts +38 -3
- package/scripts/oxc-wasm/Cargo.lock +1246 -0
- package/scripts/oxc-wasm/Cargo.toml +30 -0
- package/scripts/oxc-wasm/build.mjs +249 -0
- package/scripts/oxc-wasm/examples/memory.rs +51 -0
- package/scripts/oxc-wasm/examples/transform.rs +20 -0
- package/scripts/oxc-wasm/inputs.mjs +32 -0
- package/scripts/oxc-wasm/rust-toolchain.toml +5 -0
- package/scripts/oxc-wasm/src/abi.rs +136 -0
- package/scripts/oxc-wasm/src/diagnostics.rs +49 -0
- package/scripts/oxc-wasm/src/helpers.rs +139 -0
- package/scripts/oxc-wasm/src/lib.rs +247 -0
- package/scripts/oxc-wasm/src/module.rs +978 -0
- package/scripts/oxc-wasm/src/names.rs +175 -0
- package/scripts/oxc-wasm/src/options.rs +154 -0
- package/scripts/parser-audit.mjs +492 -0
- package/scripts/rolldown-facet/entry.mjs +21 -0
- package/scripts/rolldown-facet/shims.mjs +64 -0
- package/dist/facets/esbuild-bundle-pool.d.ts +0 -43
- package/dist/facets/esbuild-bundle-pool.d.ts.map +0 -1
- package/dist/facets/esbuild-bundle-pool.js +0 -80
- package/dist/loaders/pre-bundle-preamble.d.ts +0 -44
- package/dist/loaders/pre-bundle-preamble.d.ts.map +0 -1
- package/dist/loaders/pre-bundle-preamble.js +0 -116
- package/dist/runtime/host-wasm.d.ts +0 -8
- package/dist/runtime/host-wasm.d.ts.map +0 -1
- package/dist/runtime/host-wasm.js +0 -33
- /package/public/_assets/napi-wasm/loader/{99efae93dd1dcc2b → ab7e57fe9e8750c2}/wasi-trampoline.wasm +0 -0
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* ESBUILD_CLI_BUILD_ID is a content-hash prefix, ESBUILD_CLI_SHA256 the
|
|
11
11
|
* digest every fetch is verified against.
|
|
12
12
|
*
|
|
13
|
-
* Size:
|
|
13
|
+
* Size: 36.44 KiB
|
|
14
14
|
*/
|
|
15
15
|
export declare const ESBUILD_CLI_ASSET_PATH: string;
|
|
16
16
|
export declare const ESBUILD_CLI_BUILD_ID: string;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* ESBUILD_CLI_BUILD_ID is a content-hash prefix, ESBUILD_CLI_SHA256 the
|
|
11
11
|
* digest every fetch is verified against.
|
|
12
12
|
*
|
|
13
|
-
* Size:
|
|
13
|
+
* Size: 36.44 KiB
|
|
14
14
|
*/
|
|
15
|
-
export const ESBUILD_CLI_ASSET_PATH = "/_assets/runtime/esbuild-cli-
|
|
16
|
-
export const ESBUILD_CLI_BUILD_ID = "
|
|
17
|
-
export const ESBUILD_CLI_SHA256 = "
|
|
15
|
+
export const ESBUILD_CLI_ASSET_PATH = "/_assets/runtime/esbuild-cli-f13e6a112b03ac07.js";
|
|
16
|
+
export const ESBUILD_CLI_BUILD_ID = "f13e6a112b03ac07";
|
|
17
|
+
export const ESBUILD_CLI_SHA256 = "f13e6a112b03ac0722a2e7b242ec8281e01bd01120f0d3abbc45d63e422470ab";
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* esbuild-wasm-bundle.generated.ts — AUTO-GENERATED by scripts/bundle-esbuild-wasm.mjs
|
|
3
3
|
* DO NOT EDIT.
|
|
4
4
|
*
|
|
5
|
-
* The esbuild-wasm 0.24.2 artifacts
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The esbuild-wasm 0.24.2 artifacts the esbuild facet runs: the wasm,
|
|
6
|
+
* public/_assets/esbuild-0.24.2.wasm, and the JS adapter,
|
|
7
|
+
* public/_assets/esbuild-0.24.2.js, both in the static-assets layer,
|
|
8
|
+
* fetched when the facet is loaded and verified by
|
|
9
|
+
* src/runtime/esbuild-wasm-bytes.ts. The host Worker bundles neither.
|
|
10
10
|
*
|
|
11
11
|
* The JS adapter is node_modules/esbuild-wasm/esm/browser.js with the
|
|
12
12
|
* trailing `export { ... }` rewritten to `return { ... };`, so that
|
|
@@ -37,11 +37,12 @@ export declare const ESBUILD_WASM_VERSION: string;
|
|
|
37
37
|
* check, which discovers asset paths by value in generated modules.
|
|
38
38
|
*/
|
|
39
39
|
export declare const ESBUILD_JS_ASSET_PATH: string;
|
|
40
|
-
/**
|
|
41
|
-
* Bytes of the esbuild.wasm the host bundles: what a facet carrying the
|
|
42
|
-
* host's compiled module counts toward the dynamic-worker code budget.
|
|
43
|
-
*/
|
|
44
|
-
export declare const ESBUILD_WASM_BYTES: number;
|
|
45
40
|
/** SHA-256 of the staged public/_assets/esbuild-0.24.2.js adapter, checked before it is evaluated. */
|
|
46
41
|
export declare const ESBUILD_JS_SHA256: string;
|
|
42
|
+
/** Where esbuild.wasm lives inside env.ASSETS, version-named like the adapter. */
|
|
43
|
+
export declare const ESBUILD_WASM_ASSET_PATH: string;
|
|
44
|
+
/** SHA-256 of the staged esbuild.wasm, checked before the facet compiles it. */
|
|
45
|
+
export declare const ESBUILD_WASM_SHA256: string;
|
|
46
|
+
/** Bytes of the staged esbuild.wasm: what the facet's module map counts toward the dynamic-worker code budget. */
|
|
47
|
+
export declare const ESBUILD_WASM_BYTES: number;
|
|
47
48
|
//# sourceMappingURL=esbuild-wasm-bundle.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-wasm-bundle.generated.d.ts","sourceRoot":"","sources":["../src/esbuild-wasm-bundle.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAiB,CAAC;AACrD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAqC,CAAC;AAC1E
|
|
1
|
+
{"version":3,"file":"esbuild-wasm-bundle.generated.d.ts","sourceRoot":"","sources":["../src/esbuild-wasm-bundle.generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAiB,CAAC;AACrD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAqC,CAAC;AAC1E,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,EAAE,MAA2E,CAAC;AAC5G,kFAAkF;AAClF,eAAO,MAAM,uBAAuB,EAAE,MAAuC,CAAC;AAC9E,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,EAAE,MAA2E,CAAC;AAC9G,kHAAkH;AAClH,eAAO,MAAM,kBAAkB,EAAE,MAAiB,CAAC"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* esbuild-wasm-bundle.generated.ts — AUTO-GENERATED by scripts/bundle-esbuild-wasm.mjs
|
|
3
3
|
* DO NOT EDIT.
|
|
4
4
|
*
|
|
5
|
-
* The esbuild-wasm 0.24.2 artifacts
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The esbuild-wasm 0.24.2 artifacts the esbuild facet runs: the wasm,
|
|
6
|
+
* public/_assets/esbuild-0.24.2.wasm, and the JS adapter,
|
|
7
|
+
* public/_assets/esbuild-0.24.2.js, both in the static-assets layer,
|
|
8
|
+
* fetched when the facet is loaded and verified by
|
|
9
|
+
* src/runtime/esbuild-wasm-bytes.ts. The host Worker bundles neither.
|
|
10
10
|
*
|
|
11
11
|
* The JS adapter is node_modules/esbuild-wasm/esm/browser.js with the
|
|
12
12
|
* trailing `export { ... }` rewritten to `return { ... };`, so that
|
|
@@ -37,10 +37,11 @@ export const ESBUILD_WASM_VERSION = "0.24.2";
|
|
|
37
37
|
* check, which discovers asset paths by value in generated modules.
|
|
38
38
|
*/
|
|
39
39
|
export const ESBUILD_JS_ASSET_PATH = "/_assets/esbuild-0.24.2.js";
|
|
40
|
-
/**
|
|
41
|
-
* Bytes of the esbuild.wasm the host bundles: what a facet carrying the
|
|
42
|
-
* host's compiled module counts toward the dynamic-worker code budget.
|
|
43
|
-
*/
|
|
44
|
-
export const ESBUILD_WASM_BYTES = 11907565;
|
|
45
40
|
/** SHA-256 of the staged public/_assets/esbuild-0.24.2.js adapter, checked before it is evaluated. */
|
|
46
41
|
export const ESBUILD_JS_SHA256 = "686b1cf18b0e47be54e74359a14daebb3cc2e2be1971ea57162242f60ca88266";
|
|
42
|
+
/** Where esbuild.wasm lives inside env.ASSETS, version-named like the adapter. */
|
|
43
|
+
export const ESBUILD_WASM_ASSET_PATH = "/_assets/esbuild-0.24.2.wasm";
|
|
44
|
+
/** SHA-256 of the staged esbuild.wasm, checked before the facet compiles it. */
|
|
45
|
+
export const ESBUILD_WASM_SHA256 = "e2b4b98297e04ef12981bafabf0a3c2d7c3c5cf6af603ef79d886deac3b5eeb3";
|
|
46
|
+
/** Bytes of the staged esbuild.wasm: what the facet's module map counts toward the dynamic-worker code budget. */
|
|
47
|
+
export const ESBUILD_WASM_BYTES = 11907565;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EsbuildBuildHost } from '@nimbus-sh/core/runtime/esbuild-service.js';
|
|
2
|
+
import type { WorkerCode } from '@nimbus-sh/fabric/vendor/types.js';
|
|
3
|
+
import { type StagedSourceEnv } from '../runtime/staged-source.js';
|
|
4
|
+
import type { PrebundleResult, PrebundleSpec } from '@nimbus-sh/core/runtime/prebundle-slice.js';
|
|
5
|
+
export declare const BUILD_FACET_WORKER_ID: string;
|
|
6
|
+
/** The staged parts of the build facet, each verified against its pinned digest. */
|
|
7
|
+
export interface BuildFacetParts {
|
|
8
|
+
loader: string;
|
|
9
|
+
trampoline: ArrayBuffer;
|
|
10
|
+
rolldown: ArrayBuffer;
|
|
11
|
+
runtime: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function fetchBuildFacetParts(env: StagedSourceEnv): Promise<BuildFacetParts>;
|
|
14
|
+
/** The build facet's Worker Loader module: the class that owns rolldown, and its staged parts. */
|
|
15
|
+
export declare function buildFacetWorkerCode(parts: BuildFacetParts): WorkerCode;
|
|
16
|
+
/**
|
|
17
|
+
* Loads the Durable Object's build facet ahead of its first build: the staged
|
|
18
|
+
* parts fetched and verified, the binding instantiated and rolldown's
|
|
19
|
+
* JavaScript evaluated, which a fresh session's first build would otherwise
|
|
20
|
+
* wait on (a 13 MiB binding), while `wrangler dev` reads its config. (A
|
|
21
|
+
* warm-up as `vite build` starts measured no gain: that build's first
|
|
22
|
+
* seconds go to resolving through the VFS plugin.) Best effort: a failed
|
|
23
|
+
* warm-up only drops the stub, as a failed call does.
|
|
24
|
+
*/
|
|
25
|
+
export declare function prewarmBuildFacet(ctx: DurableObjectState, env: unknown): void;
|
|
26
|
+
/**
|
|
27
|
+
* The build host a Durable Object's builds run on: its build facet, which runs
|
|
28
|
+
* rolldown. The plugin, and with it every file read, stays with the caller.
|
|
29
|
+
*
|
|
30
|
+
* A build whose binding died under it (`crashed`: a trap, or a module nested
|
|
31
|
+
* past the stack) retires that generation: the next build mints a fresh
|
|
32
|
+
* isolate. The build itself, and every other one that was in flight on that
|
|
33
|
+
* binding, goes to `fallback` (the esbuild facet in production), each logged;
|
|
34
|
+
* without one, its failure says what happened.
|
|
35
|
+
*/
|
|
36
|
+
export declare function rolldownBuildHost(ctx: DurableObjectState, env: unknown, fallback?: EsbuildBuildHost): EsbuildBuildHost;
|
|
37
|
+
/**
|
|
38
|
+
* Pre-bundles one npm specifier from its slice in the Durable Object's build
|
|
39
|
+
* facet (core runtime/prebundle-slice.ts on rolldown): the slice crosses
|
|
40
|
+
* once, with the call, and the bundle comes back. A failed pre-bundle is a
|
|
41
|
+
* result (`ok: false`), as is one whose binding died under it, which also
|
|
42
|
+
* retires that generation; a call that throws drops the stub, as a build's
|
|
43
|
+
* does.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildFacetPrebundler(ctx: DurableObjectState, env: unknown): (spec: PrebundleSpec) => Promise<PrebundleResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Loads the Durable Object's build facet and waits for it: the staged parts
|
|
48
|
+
* fetched and verified, the binding instantiated. What prewarmBuildFacet
|
|
49
|
+
* starts, for a caller that wants the load behind it before it allocates
|
|
50
|
+
* (a pre-bundle's slice). Rejects as the load does.
|
|
51
|
+
*/
|
|
52
|
+
export declare function loadBuildFacet(ctx: DurableObjectState, env: unknown): Promise<void>;
|
|
53
|
+
//# sourceMappingURL=build-facet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-facet.d.ts","sourceRoot":"","sources":["../../src/facets/build-facet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAIjB,MAAM,4CAA4C,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,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nimbus-sh/fabric/vendor/serialize.js';
|
|
4
|
+
import { ROLLDOWN_FACET_ASSET_PATH, ROLLDOWN_FACET_BUILD_ID, ROLLDOWN_FACET_SHA256 } from '../rolldown-facet-artifact.generated.js';
|
|
5
|
+
import { fetchStagedText } from '../runtime/staged-source.js';
|
|
6
|
+
import { NAPI_WASM_LOADER, NAPI_WASM_TRAMPOLINE, fetchStagedBindingAsset, stagedBinding, } from '../runtime/staged-bindings.js';
|
|
7
|
+
const ROLLDOWN = stagedBinding('rolldown');
|
|
8
|
+
/**
|
|
9
|
+
* The binding's linear memory past which the facet asks to be retired after
|
|
10
|
+
* a call. It starts at 5.4 MiB and grows to the largest graph built, and never
|
|
11
|
+
* shrinks; pre-bundles measured 17.6 MiB after react-dom/client, 27.9 after
|
|
12
|
+
* framer-motion, 53.8 after recharts and 60.5 after @mui/material (slices of
|
|
13
|
+
* up to 23 MiB). A binding past this leaves the next call's slice too little
|
|
14
|
+
* of the isolate's 128 MiB, so the next call starts a fresh isolate.
|
|
15
|
+
*/
|
|
16
|
+
const BUILD_BINDING_HIGH_WATER_BYTES = 64 * 1024 * 1024;
|
|
17
|
+
/**
|
|
18
|
+
* Everything of the build facet's module but its staged parts: the napi-rs
|
|
19
|
+
* wasm loader (scripts/napi-wasm/loader), the threadless rolldown binding and
|
|
20
|
+
* its wasi trampoline, and the facet's runtime (scripts/rolldown-facet: rolldown's
|
|
21
|
+
* JavaScript and core's esbuild-contract adapter, runtime/rolldown-build.ts).
|
|
22
|
+
* The binding is instantiated by the first build and kept: its linear memory
|
|
23
|
+
* starts at the binding's declared minimum and grows with the largest module
|
|
24
|
+
* graph built. Nothing here reads a file: every module comes from the
|
|
25
|
+
* caller's plugin, so the binding's WASI filesystem is the facet's own empty
|
|
26
|
+
* node:fs.
|
|
27
|
+
*
|
|
28
|
+
* A binding that dies (a trap, or the stack overflowing inside it: a module
|
|
29
|
+
* nested too deeply) holds promises that never settle. The loader says so
|
|
30
|
+
* (`onFatal`), and every build or pre-bundle on it, in flight or later, is
|
|
31
|
+
* answered at once with `crashed`; rolldown's JavaScript keeps the binding it
|
|
32
|
+
* imported, so only a fresh isolate (the host's next generation) builds again.
|
|
33
|
+
*/
|
|
34
|
+
const BUILD_FACET_BODY = [
|
|
35
|
+
// One load for every caller, overlapping ones included.
|
|
36
|
+
'let runtime = null;',
|
|
37
|
+
'let crashed = null;',
|
|
38
|
+
'const inFlight = new Set();',
|
|
39
|
+
'let memory = null;',
|
|
40
|
+
'function rolldownRuntime() {',
|
|
41
|
+
' if (runtime === null) {',
|
|
42
|
+
` memory = new WebAssembly.Memory({ initial: ${ROLLDOWN.memoryPages}, maximum: 65536 });`,
|
|
43
|
+
' globalThis.__nimbusRolldownBinding = createNapiWasmBinding({',
|
|
44
|
+
' fs, env: {}, writeStdout() {}, writeStderr() {},',
|
|
45
|
+
` binding: rolldownWasm, trampoline: trampolineWasm, memoryPages: ${ROLLDOWN.memoryPages}, memory, name: "rolldown",`,
|
|
46
|
+
' onFatal(error) {',
|
|
47
|
+
' crashed = { stackExhausted: error instanceof RangeError, message: String((error && error.message) || error) };',
|
|
48
|
+
' for (const answer of inFlight) answer();',
|
|
49
|
+
' inFlight.clear();',
|
|
50
|
+
' },',
|
|
51
|
+
' });',
|
|
52
|
+
// Dynamic: rolldown's JavaScript reads the binding as it evaluates, so it is imported once the binding exists.
|
|
53
|
+
' runtime = import("rolldown-runtime.js");',
|
|
54
|
+
' }',
|
|
55
|
+
' return runtime;',
|
|
56
|
+
'}',
|
|
57
|
+
'function crashText() {',
|
|
58
|
+
' return crashed.stackExhausted',
|
|
59
|
+
' ? "Nimbus\'s bundler ran out of stack: a module nests too deeply for it (" + crashed.message + ")"',
|
|
60
|
+
' : "Nimbus\'s bundler crashed: " + crashed.message;',
|
|
61
|
+
'}',
|
|
62
|
+
// One call on the binding, answered by `crashedAnswer()` if the binding is
|
|
63
|
+
// or becomes dead, and marked `retire` once the binding has outgrown its mark.
|
|
64
|
+
'async function onBinding(call, crashedAnswer) {',
|
|
65
|
+
' if (crashed) return crashedAnswer();',
|
|
66
|
+
' const loaded = await rolldownRuntime();',
|
|
67
|
+
' if (crashed) return crashedAnswer();',
|
|
68
|
+
' return new Promise((resolve, reject) => {',
|
|
69
|
+
' const answer = () => resolve(crashedAnswer());',
|
|
70
|
+
' inFlight.add(answer);',
|
|
71
|
+
` const outgrown = (value) => (memory.buffer.byteLength > ${BUILD_BINDING_HIGH_WATER_BYTES} ? { ...value, retire: true } : value);`,
|
|
72
|
+
' call(loaded).then((value) => resolve(outgrown(value)), reject).finally(() => inFlight.delete(answer));',
|
|
73
|
+
' });',
|
|
74
|
+
'}',
|
|
75
|
+
'export class BuildFacet extends DurableObject {',
|
|
76
|
+
' async warm() {',
|
|
77
|
+
' if (!crashed) await rolldownRuntime();',
|
|
78
|
+
' }',
|
|
79
|
+
' build(options, plugin) {',
|
|
80
|
+
' return onBinding((loaded) => loaded.build(options, plugin), () => ({',
|
|
81
|
+
' outputFiles: [], warnings: [], failure: "Build failed with 1 error:\\nerror: " + crashText(),',
|
|
82
|
+
' errors: [{ id: "", pluginName: "", text: crashText(), location: null, notes: [], detail: undefined }],',
|
|
83
|
+
' crashed,',
|
|
84
|
+
' }));',
|
|
85
|
+
' }',
|
|
86
|
+
' prebundle(spec) {',
|
|
87
|
+
' return onBinding((loaded) => loaded.prebundle(spec), () => ({',
|
|
88
|
+
' specifier: spec.specifier, ok: false, esmCode: "", errorText: crashText(), elapsed: 0, warnings: [], crashed,',
|
|
89
|
+
' }));',
|
|
90
|
+
' }',
|
|
91
|
+
'}',
|
|
92
|
+
].join('\n');
|
|
93
|
+
// The loader serves the code it cached under an id, so the id carries the code.
|
|
94
|
+
export const BUILD_FACET_WORKER_ID = [
|
|
95
|
+
'nimbus-build',
|
|
96
|
+
`rolldown-${ROLLDOWN.version}-${ROLLDOWN.wasm.sha256.slice(0, 16)}`,
|
|
97
|
+
NAPI_WASM_LOADER.sha256.slice(0, 16),
|
|
98
|
+
NAPI_WASM_TRAMPOLINE.sha256.slice(0, 16),
|
|
99
|
+
ROLLDOWN_FACET_BUILD_ID,
|
|
100
|
+
hashSource(BUILD_FACET_BODY),
|
|
101
|
+
].join(':');
|
|
102
|
+
export async function fetchBuildFacetParts(env) {
|
|
103
|
+
const [loader, trampoline, rolldown, runtime] = await Promise.all([
|
|
104
|
+
fetchStagedBindingAsset(env, NAPI_WASM_LOADER).then((bytes) => new TextDecoder().decode(bytes)),
|
|
105
|
+
fetchStagedBindingAsset(env, NAPI_WASM_TRAMPOLINE),
|
|
106
|
+
fetchStagedBindingAsset(env, ROLLDOWN.wasm),
|
|
107
|
+
fetchStagedText(env, {
|
|
108
|
+
path: ROLLDOWN_FACET_ASSET_PATH,
|
|
109
|
+
l2Key: `https://nimbus-cache.invalid${ROLLDOWN_FACET_ASSET_PATH}`,
|
|
110
|
+
sha256: ROLLDOWN_FACET_SHA256,
|
|
111
|
+
contentType: 'text/javascript; charset=utf-8',
|
|
112
|
+
poisonedCache: 'reject',
|
|
113
|
+
missingBinding: `Nimbus: the build facet requires an env.ASSETS binding (serves ${ROLLDOWN_FACET_ASSET_PATH})`,
|
|
114
|
+
fetchFailed: (res) => `build facet runtime asset fetch failed: ${res.status} ${res.statusText} for ${ROLLDOWN_FACET_ASSET_PATH} — deploy is missing the asset`,
|
|
115
|
+
integrityFailed: (digest, from) => `build facet runtime integrity check failed: expected ${ROLLDOWN_FACET_SHA256}, got ${digest} (${from}) for ` +
|
|
116
|
+
`${ROLLDOWN_FACET_ASSET_PATH} — the staged asset is corrupt or out of sync; rerun scripts/bundle-facet-workers.mjs and redeploy`,
|
|
117
|
+
}),
|
|
118
|
+
]);
|
|
119
|
+
return { loader, trampoline, rolldown, runtime };
|
|
120
|
+
}
|
|
121
|
+
/** The build facet's Worker Loader module: the class that owns rolldown, and its staged parts. */
|
|
122
|
+
export function buildFacetWorkerCode(parts) {
|
|
123
|
+
const source = [
|
|
124
|
+
'import { DurableObject } from "cloudflare:workers";',
|
|
125
|
+
'import * as fs from "node:fs";',
|
|
126
|
+
'import { createNapiWasmBinding } from "napi-wasm-loader.js";',
|
|
127
|
+
'import rolldownWasm from "rolldown.wasm";',
|
|
128
|
+
'import trampolineWasm from "trampoline.wasm";',
|
|
129
|
+
BUILD_FACET_BODY,
|
|
130
|
+
].join('\n');
|
|
131
|
+
return {
|
|
132
|
+
compatibilityDate: CF_COMPAT_DATE,
|
|
133
|
+
compatibilityFlags: [...GUEST_COMPAT_FLAGS],
|
|
134
|
+
mainModule: 'worker.js',
|
|
135
|
+
modules: {
|
|
136
|
+
'worker.js': source,
|
|
137
|
+
'napi-wasm-loader.js': parts.loader,
|
|
138
|
+
'rolldown-runtime.js': parts.runtime,
|
|
139
|
+
'rolldown.wasm': { wasm: parts.rolldown },
|
|
140
|
+
'trampoline.wasm': { wasm: parts.trampoline },
|
|
141
|
+
},
|
|
142
|
+
globalOutbound: null,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Which isolate of the build facet's code builds: a binding that died is
|
|
147
|
+
* left behind with its isolate, and every Durable Object this isolate hosts
|
|
148
|
+
* moves to the next generation's, whose loader id and facet name are new.
|
|
149
|
+
*/
|
|
150
|
+
let generation = 0;
|
|
151
|
+
const generationId = (n) => `${BUILD_FACET_WORKER_ID}:g${n}`;
|
|
152
|
+
async function buildFacet(ctx, env, id) {
|
|
153
|
+
const loader = Reflect.get(Object(env), 'LOADER');
|
|
154
|
+
if (!loader || typeof loader.get !== 'function')
|
|
155
|
+
throw new Error('Nimbus: env.LOADER unavailable for the build facet');
|
|
156
|
+
const assets = Reflect.get(Object(env), 'ASSETS');
|
|
157
|
+
if (!assets || typeof assets.fetch !== 'function')
|
|
158
|
+
throw new Error('Nimbus: env.ASSETS unavailable for the build facet');
|
|
159
|
+
const worker = await loader.get(id, async () => buildFacetWorkerCode(await fetchBuildFacetParts({ ASSETS: assets })));
|
|
160
|
+
const facetClass = worker.getDurableObjectClass('BuildFacet');
|
|
161
|
+
return ctx.facets.get(id, async () => ({ class: facetClass }));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* One stub per Durable Object: callers that overlap wait on one facet load.
|
|
165
|
+
* A load or call that failed drops the entry; the next caller mints a fresh one.
|
|
166
|
+
* An entry of a retired generation is dropped, and its facet aborted once
|
|
167
|
+
* the calls still on it are answered.
|
|
168
|
+
*/
|
|
169
|
+
const sharedFacets = new WeakMap();
|
|
170
|
+
function sharedBuildFacet(ctx, env) {
|
|
171
|
+
const current = sharedFacets.get(ctx);
|
|
172
|
+
if (current && current.generation === generation)
|
|
173
|
+
return current;
|
|
174
|
+
if (current)
|
|
175
|
+
retireFacet(ctx, current);
|
|
176
|
+
const minted = { generation, stub: buildFacet(ctx, env, generationId(generation)), calls: 0, retired: false, crashed: false };
|
|
177
|
+
sharedFacets.set(ctx, minted);
|
|
178
|
+
minted.stub.catch(() => forgetBuildFacet(ctx, minted));
|
|
179
|
+
return minted;
|
|
180
|
+
}
|
|
181
|
+
function forgetBuildFacet(ctx, facet) {
|
|
182
|
+
if (sharedFacets.get(ctx) === facet)
|
|
183
|
+
sharedFacets.delete(ctx);
|
|
184
|
+
}
|
|
185
|
+
function retireFacet(ctx, facet) {
|
|
186
|
+
forgetBuildFacet(ctx, facet);
|
|
187
|
+
// Once: every answer on an outgrown binding says to retire it.
|
|
188
|
+
if (facet.retired)
|
|
189
|
+
return;
|
|
190
|
+
facet.retired = true;
|
|
191
|
+
if (facet.calls === 0)
|
|
192
|
+
abortFacet(ctx, facet);
|
|
193
|
+
}
|
|
194
|
+
function abortFacet(ctx, facet) {
|
|
195
|
+
try {
|
|
196
|
+
ctx.facets.abort(generationId(facet.generation), new Error('Nimbus: the build facet was retired'));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// already gone
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A call on `facet` began: it is counted until it is answered, on the
|
|
204
|
+
* Durable Object's Dynamic Worker ledger under its generation's own worker
|
|
205
|
+
* id, since a retired generation's call and the next one's can be in flight
|
|
206
|
+
* at once as two workers.
|
|
207
|
+
*/
|
|
208
|
+
function beginCall(ctx, facet) {
|
|
209
|
+
const endFetch = beginLoaderFetch(ctx, generationId(facet.generation));
|
|
210
|
+
facet.calls++;
|
|
211
|
+
return () => {
|
|
212
|
+
endFetch();
|
|
213
|
+
facet.calls--;
|
|
214
|
+
if (facet.retired && facet.calls === 0)
|
|
215
|
+
abortFacet(ctx, facet);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Loads the Durable Object's build facet ahead of its first build: the staged
|
|
220
|
+
* parts fetched and verified, the binding instantiated and rolldown's
|
|
221
|
+
* JavaScript evaluated, which a fresh session's first build would otherwise
|
|
222
|
+
* wait on (a 13 MiB binding), while `wrangler dev` reads its config. (A
|
|
223
|
+
* warm-up as `vite build` starts measured no gain: that build's first
|
|
224
|
+
* seconds go to resolving through the VFS plugin.) Best effort: a failed
|
|
225
|
+
* warm-up only drops the stub, as a failed call does.
|
|
226
|
+
*/
|
|
227
|
+
export function prewarmBuildFacet(ctx, env) {
|
|
228
|
+
// loadBuildFacet keeps the stub call a direct call awaited by the frame
|
|
229
|
+
// that made it, as every facet call must (see beginLoaderFetch).
|
|
230
|
+
loadBuildFacet(ctx, env).catch(() => { });
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The build host a Durable Object's builds run on: its build facet, which runs
|
|
234
|
+
* rolldown. The plugin, and with it every file read, stays with the caller.
|
|
235
|
+
*
|
|
236
|
+
* A build whose binding died under it (`crashed`: a trap, or a module nested
|
|
237
|
+
* past the stack) retires that generation: the next build mints a fresh
|
|
238
|
+
* isolate. The build itself, and every other one that was in flight on that
|
|
239
|
+
* binding, goes to `fallback` (the esbuild facet in production), each logged;
|
|
240
|
+
* without one, its failure says what happened.
|
|
241
|
+
*/
|
|
242
|
+
export function rolldownBuildHost(ctx, env, fallback) {
|
|
243
|
+
return async (options, plugin) => {
|
|
244
|
+
const facet = sharedBuildFacet(ctx, env);
|
|
245
|
+
const endCall = beginCall(ctx, facet);
|
|
246
|
+
let outcome;
|
|
247
|
+
try {
|
|
248
|
+
outcome = await (await facet.stub).build(options, plugin);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
forgetBuildFacet(ctx, facet);
|
|
252
|
+
if (!facet.crashed)
|
|
253
|
+
throw error;
|
|
254
|
+
// The binding died under this build too, and its answer did not make it back.
|
|
255
|
+
outcome = { outputFiles: [], errors: [], warnings: [], crashed: { stackExhausted: false, message: error instanceof Error ? error.message : String(error) } };
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
endCall();
|
|
259
|
+
}
|
|
260
|
+
const { crashed, retire, ...built } = outcome;
|
|
261
|
+
if (retire)
|
|
262
|
+
retireGeneration(ctx, facet);
|
|
263
|
+
if (!crashed)
|
|
264
|
+
return built;
|
|
265
|
+
retireCrashed(ctx, facet);
|
|
266
|
+
const entries = Array.isArray(options.entryPoints) ? options.entryPoints.join(', ') : '<entries>';
|
|
267
|
+
console.warn(`[build-facet] rolldown's binding died building ${entries} (${crashed.message}); ${fallback ? 'building it with esbuild' : 'the build fails'}`);
|
|
268
|
+
if (fallback)
|
|
269
|
+
return fallback(options, plugin);
|
|
270
|
+
if (built.failure)
|
|
271
|
+
return built;
|
|
272
|
+
const text = `Nimbus's bundler crashed: ${crashed.message}`;
|
|
273
|
+
return { ...built, failure: `Build failed with 1 error:\nerror: ${text}`, errors: [{ id: '', pluginName: '', text, location: null, notes: [], detail: undefined }] };
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Leaves a dead binding's generation behind: the next call on any Durable
|
|
278
|
+
* Object mints the next. Its calls still in flight are answered (the facet
|
|
279
|
+
* answers each one, crashed) before the facet is aborted.
|
|
280
|
+
*/
|
|
281
|
+
function retireCrashed(ctx, facet) {
|
|
282
|
+
facet.crashed = true;
|
|
283
|
+
retireGeneration(ctx, facet);
|
|
284
|
+
}
|
|
285
|
+
/** Moves every Durable Object this isolate hosts past `facet`'s generation, and retires it. */
|
|
286
|
+
function retireGeneration(ctx, facet) {
|
|
287
|
+
if (facet.generation === generation)
|
|
288
|
+
generation++;
|
|
289
|
+
retireFacet(ctx, facet);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Pre-bundles one npm specifier from its slice in the Durable Object's build
|
|
293
|
+
* facet (core runtime/prebundle-slice.ts on rolldown): the slice crosses
|
|
294
|
+
* once, with the call, and the bundle comes back. A failed pre-bundle is a
|
|
295
|
+
* result (`ok: false`), as is one whose binding died under it, which also
|
|
296
|
+
* retires that generation; a call that throws drops the stub, as a build's
|
|
297
|
+
* does.
|
|
298
|
+
*/
|
|
299
|
+
export function buildFacetPrebundler(ctx, env) {
|
|
300
|
+
return async (spec) => {
|
|
301
|
+
const facet = sharedBuildFacet(ctx, env);
|
|
302
|
+
const endCall = beginCall(ctx, facet);
|
|
303
|
+
let result;
|
|
304
|
+
try {
|
|
305
|
+
result = await (await facet.stub).prebundle(spec);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
forgetBuildFacet(ctx, facet);
|
|
309
|
+
if (!facet.crashed)
|
|
310
|
+
throw error;
|
|
311
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
312
|
+
result = { specifier: spec.specifier, ok: false, esmCode: '', errorText: `Nimbus's bundler crashed: ${message}`, elapsed: 0, warnings: [], crashed: { stackExhausted: false, message } };
|
|
313
|
+
}
|
|
314
|
+
finally {
|
|
315
|
+
endCall();
|
|
316
|
+
}
|
|
317
|
+
const { crashed, retire, ...answer } = result;
|
|
318
|
+
if (retire)
|
|
319
|
+
retireGeneration(ctx, facet);
|
|
320
|
+
if (crashed) {
|
|
321
|
+
retireCrashed(ctx, facet);
|
|
322
|
+
console.warn(`[build-facet] rolldown's binding died pre-bundling ${spec.specifier} (${crashed.message})`);
|
|
323
|
+
}
|
|
324
|
+
return answer;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Loads the Durable Object's build facet and waits for it: the staged parts
|
|
329
|
+
* fetched and verified, the binding instantiated. What prewarmBuildFacet
|
|
330
|
+
* starts, for a caller that wants the load behind it before it allocates
|
|
331
|
+
* (a pre-bundle's slice). Rejects as the load does.
|
|
332
|
+
*/
|
|
333
|
+
export async function loadBuildFacet(ctx, env) {
|
|
334
|
+
const facet = sharedBuildFacet(ctx, env);
|
|
335
|
+
const endCall = beginCall(ctx, facet);
|
|
336
|
+
try {
|
|
337
|
+
await (await facet.stub).warm();
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
forgetBuildFacet(ctx, facet);
|
|
341
|
+
throw error;
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
endCall();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
*/
|
|
53
53
|
import { HmrBridge } from './real-vite-hmr.js';
|
|
54
54
|
import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
55
|
+
import type { VfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
55
56
|
import type { VfsEventEmitter } from '@nimbus-sh/core/vfs/events.js';
|
|
56
57
|
import type { ParsedViteConfig } from '@nimbus-sh/core/runtime/vite-config-parser.js';
|
|
57
58
|
/**
|
|
@@ -109,6 +110,8 @@ export declare class CirrusReal {
|
|
|
109
110
|
root: string;
|
|
110
111
|
basePath: string;
|
|
111
112
|
vfs: SqliteVFS;
|
|
113
|
+
/** Who the server reads its project as: the credential of the process it runs under. */
|
|
114
|
+
cred: VfsCred;
|
|
112
115
|
vfsEvents?: VfsEventEmitter | null;
|
|
113
116
|
userConfigBundle?: string | null;
|
|
114
117
|
extraSyntheticFiles?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cirrus-real.d.ts","sourceRoot":"","sources":["../../src/facets/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EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAItD;;;;OAIG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8C1E;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAsBzD"}
|
|
@@ -62,7 +62,6 @@ import { supervisorBindingProps, supervisorLoaderKey } from '@nimbus-sh/fabric/s
|
|
|
62
62
|
import { deleteFacetStorage } from '@nimbus-sh/fabric/workerd-facet-host.js';
|
|
63
63
|
import { buildFsSnapshot, generateFsShimModuleCode, generateFsPromisesShimModuleCode, generateSyntheticModuleCode, } from './real-vite-fs-shim.js';
|
|
64
64
|
import { HmrBridge, generateWsShimModuleCode, generateChokidarShimModuleCode, } from './real-vite-hmr.js';
|
|
65
|
-
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
66
65
|
import { stripLeadingSlashes } from '@nimbus-sh/core/vfs/path.js';
|
|
67
66
|
/**
|
|
68
67
|
* The real-vite facet needs Node's http client and server modules. At
|
|
@@ -587,7 +586,7 @@ export class CirrusReal {
|
|
|
587
586
|
this.port = opts.port;
|
|
588
587
|
this.root = opts.root;
|
|
589
588
|
this.basePath = opts.basePath;
|
|
590
|
-
this.vfs = opts.vfs.as(
|
|
589
|
+
this.vfs = opts.vfs.as(opts.cred);
|
|
591
590
|
this.vfsEvents = opts.vfsEvents || null;
|
|
592
591
|
this.userConfigBundle = opts.userConfigBundle || null;
|
|
593
592
|
this.extraSyntheticFiles = opts.extraSyntheticFiles || {};
|
package/dist/facets/compose.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/facets/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;A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SAAS,IAAI,OAAO,CAAC,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC,CAAC;QACtH;;;;;;;;WAQG;QACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;KAC/G,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,oBAAoB,CA+EhF"}
|
package/dist/facets/compose.js
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import { CRED_KERNEL } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
37
37
|
import { createPortCapability } from '@nimbus-sh/core/runtime/port-registry.js';
|
|
38
|
+
import { execIdField } from '@nimbus-sh/core/runtime/process-table.js';
|
|
38
39
|
import { FacetManager } from './manager.js';
|
|
39
40
|
import { processHostFor } from '../loaders/process-host.js';
|
|
40
41
|
import { resolveDurableWorkerImage } from './durable-images.js';
|
|
@@ -109,6 +110,8 @@ export function composeFacetManager(deps) {
|
|
|
109
110
|
pid: Number(entry.pid),
|
|
110
111
|
registeredAt: Number(entry.registeredAt),
|
|
111
112
|
capability: String(entry.capability),
|
|
113
|
+
// The listener's exec id, read from its process: the one place it lives.
|
|
114
|
+
...execIdField(deps.processes.get(entry.pid)),
|
|
112
115
|
}));
|
|
113
116
|
},
|
|
114
117
|
routeCapabilityPort(port, capability, request, innerPath) {
|