@nodetool-ai/sandbox-runtime 0.0.0-stage → 0.8.9-bootstrap.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 +24 -2
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/host-access-gate.d.ts +24 -0
- package/dist/host-access-gate.d.ts.map +1 -0
- package/dist/host-access-gate.js +31 -0
- package/dist/host-access-gate.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +318 -0
- package/dist/index.js.map +1 -0
- package/dist/js-sandbox-worker/engine.d.ts +4 -0
- package/dist/js-sandbox-worker/engine.d.ts.map +1 -0
- package/dist/js-sandbox-worker/engine.js +82 -0
- package/dist/js-sandbox-worker/engine.js.map +1 -0
- package/dist/js-sandbox-worker/host.d.ts +136 -0
- package/dist/js-sandbox-worker/host.d.ts.map +1 -0
- package/dist/js-sandbox-worker/host.js +482 -0
- package/dist/js-sandbox-worker/host.js.map +1 -0
- package/dist/js-sandbox-worker/interpreter.d.ts +276 -0
- package/dist/js-sandbox-worker/interpreter.d.ts.map +1 -0
- package/dist/js-sandbox-worker/interpreter.js +1318 -0
- package/dist/js-sandbox-worker/interpreter.js.map +1 -0
- package/dist/js-sandbox-worker/protocol.d.ts +168 -0
- package/dist/js-sandbox-worker/protocol.d.ts.map +1 -0
- package/dist/js-sandbox-worker/protocol.js +217 -0
- package/dist/js-sandbox-worker/protocol.js.map +1 -0
- package/dist/js-sandbox-worker/worker-entry.d.ts +26 -0
- package/dist/js-sandbox-worker/worker-entry.d.ts.map +1 -0
- package/dist/js-sandbox-worker/worker-entry.js +308 -0
- package/dist/js-sandbox-worker/worker-entry.js.map +1 -0
- package/dist/limits.d.ts +77 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +56 -0
- package/dist/limits.js.map +1 -0
- package/dist/sandbox-bootstrap-modules.d.ts +54 -0
- package/dist/sandbox-bootstrap-modules.d.ts.map +1 -0
- package/dist/sandbox-bootstrap-modules.js +104 -0
- package/dist/sandbox-bootstrap-modules.js.map +1 -0
- package/dist/sandbox-bytes.d.ts +43 -0
- package/dist/sandbox-bytes.d.ts.map +1 -0
- package/dist/sandbox-bytes.js +61 -0
- package/dist/sandbox-bytes.js.map +1 -0
- package/dist/sandbox-canvas-api.d.ts +30 -0
- package/dist/sandbox-canvas-api.d.ts.map +1 -0
- package/dist/sandbox-canvas-api.js +81 -0
- package/dist/sandbox-canvas-api.js.map +1 -0
- package/dist/sandbox-constants.d.ts +5 -0
- package/dist/sandbox-constants.d.ts.map +1 -0
- package/dist/sandbox-constants.js +13 -0
- package/dist/sandbox-constants.js.map +1 -0
- package/dist/sandbox-json-transport.d.ts +107 -0
- package/dist/sandbox-json-transport.d.ts.map +1 -0
- package/dist/sandbox-json-transport.js +324 -0
- package/dist/sandbox-json-transport.js.map +1 -0
- package/dist/timeline-capture.d.ts +21 -0
- package/dist/timeline-capture.d.ts.map +1 -0
- package/dist/timeline-capture.js +564 -0
- package/dist/timeline-capture.js.map +1 -0
- package/dist/utils/type-guards.d.ts +26 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +44 -0
- package/dist/utils/type-guards.js.map +1 -0
- package/package.json +138 -4
- package/vendor/README.md +17 -0
- package/vendor/quickjs/LICENSE +21 -0
- package/vendor/quickjs/PROVENANCE.json +8 -0
- package/vendor/quickjs/adapter/fetch.d.ts +56 -0
- package/vendor/quickjs/adapter/fetch.js +140 -0
- package/vendor/quickjs/createTimeInterval.d.ts +9 -0
- package/vendor/quickjs/createTimeInterval.js +22 -0
- package/vendor/quickjs/createVirtualFileSystem.d.ts +13 -0
- package/vendor/quickjs/createVirtualFileSystem.js +191 -0
- package/vendor/quickjs/index.d.ts +77 -0
- package/vendor/quickjs/index.js +77 -0
- package/vendor/quickjs/loadAsyncQuickJs.d.ts +12 -0
- package/vendor/quickjs/loadAsyncQuickJs.js +66 -0
- package/vendor/quickjs/loadQuickJs.d.ts +12 -0
- package/vendor/quickjs/loadQuickJs.js +73 -0
- package/vendor/quickjs/modules/assert.d.ts +2 -0
- package/vendor/quickjs/modules/assert.js +47 -0
- package/vendor/quickjs/modules/buffer.d.ts +2 -0
- package/vendor/quickjs/modules/buffer.js +106 -0
- package/vendor/quickjs/modules/build/test-lib.js +2 -0
- package/vendor/quickjs/modules/events.d.ts +2 -0
- package/vendor/quickjs/modules/events.js +4 -0
- package/vendor/quickjs/modules/fs.d.ts +2 -0
- package/vendor/quickjs/modules/fs.js +76 -0
- package/vendor/quickjs/modules/fs_promises.d.ts +2 -0
- package/vendor/quickjs/modules/fs_promises.js +328 -0
- package/vendor/quickjs/modules/module.d.ts +2 -0
- package/vendor/quickjs/modules/module.js +33 -0
- package/vendor/quickjs/modules/nodeCompatibility/headers.d.ts +2 -0
- package/vendor/quickjs/modules/nodeCompatibility/headers.js +58 -0
- package/vendor/quickjs/modules/nodeCompatibility/request.d.ts +2 -0
- package/vendor/quickjs/modules/nodeCompatibility/request.js +5 -0
- package/vendor/quickjs/modules/nodeCompatibility/response.d.ts +2 -0
- package/vendor/quickjs/modules/nodeCompatibility/response.js +5 -0
- package/vendor/quickjs/modules/path.d.ts +2 -0
- package/vendor/quickjs/modules/path.js +504 -0
- package/vendor/quickjs/modules/process.d.ts +2 -0
- package/vendor/quickjs/modules/process.js +309 -0
- package/vendor/quickjs/modules/punycode.d.ts +2 -0
- package/vendor/quickjs/modules/punycode.js +443 -0
- package/vendor/quickjs/modules/querystring.d.ts +2 -0
- package/vendor/quickjs/modules/querystring.js +15 -0
- package/vendor/quickjs/modules/string_decoder.d.ts +2 -0
- package/vendor/quickjs/modules/string_decoder.js +223 -0
- package/vendor/quickjs/modules/timers.d.ts +2 -0
- package/vendor/quickjs/modules/timers.js +10 -0
- package/vendor/quickjs/modules/timers_promises.d.ts +2 -0
- package/vendor/quickjs/modules/timers_promises.js +40 -0
- package/vendor/quickjs/modules/url.d.ts +2 -0
- package/vendor/quickjs/modules/url.js +104 -0
- package/vendor/quickjs/modules/util.d.ts +2 -0
- package/vendor/quickjs/modules/util.js +233 -0
- package/vendor/quickjs/package.json +3 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.d.ts +4 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncEvalCodeFunction.js +76 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.d.ts +3 -0
- package/vendor/quickjs/sandbox/asyncVersion/createAsyncValidateCodeFunction.js +22 -0
- package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.d.ts +12 -0
- package/vendor/quickjs/sandbox/asyncVersion/executeAsyncSandboxFunction.js +9 -0
- package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.d.ts +4 -0
- package/vendor/quickjs/sandbox/asyncVersion/getAsyncModuleLoader.js +30 -0
- package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.d.ts +2 -0
- package/vendor/quickjs/sandbox/asyncVersion/modulePathNormalizerAsync.js +12 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.d.ts +3 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncNodeCompatibility.js +11 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.d.ts +4 -0
- package/vendor/quickjs/sandbox/asyncVersion/prepareAsyncSandbox.js +10 -0
- package/vendor/quickjs/sandbox/expose/expose.d.ts +3 -0
- package/vendor/quickjs/sandbox/expose/expose.js +155 -0
- package/vendor/quickjs/sandbox/expose/isES2015Class.d.ts +1 -0
- package/vendor/quickjs/sandbox/expose/isES2015Class.js +4 -0
- package/vendor/quickjs/sandbox/expose/isObject.d.ts +1 -0
- package/vendor/quickjs/sandbox/expose/isObject.js +4 -0
- package/vendor/quickjs/sandbox/expose/pendingHostPromises.d.ts +6 -0
- package/vendor/quickjs/sandbox/expose/pendingHostPromises.js +40 -0
- package/vendor/quickjs/sandbox/getMaxIntervalAmount.d.ts +8 -0
- package/vendor/quickjs/sandbox/getMaxIntervalAmount.js +12 -0
- package/vendor/quickjs/sandbox/getMaxTimeoutAmount.d.ts +8 -0
- package/vendor/quickjs/sandbox/getMaxTimeoutAmount.js +12 -0
- package/vendor/quickjs/sandbox/handleEvalError.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleEvalError.js +21 -0
- package/vendor/quickjs/sandbox/handleToNative/handleToNative.d.ts +9 -0
- package/vendor/quickjs/sandbox/handleToNative/handleToNative.js +153 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/index.d.ts +10 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/index.js +36 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeArrayBuffer.js +4 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeBuffer.js +16 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeDate.js +16 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeError.js +18 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeHeaders.js +17 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeMap.js +18 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeSet.js +16 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeURLSearchParams.js +17 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.d.ts +2 -0
- package/vendor/quickjs/sandbox/handleToNative/serializer/serializeUrl.js +17 -0
- package/vendor/quickjs/sandbox/helper.d.ts +2 -0
- package/vendor/quickjs/sandbox/helper.js +14 -0
- package/vendor/quickjs/sandbox/provide/provideConsole.d.ts +6 -0
- package/vendor/quickjs/sandbox/provide/provideConsole.js +53 -0
- package/vendor/quickjs/sandbox/provide/provideEnv.d.ts +3 -0
- package/vendor/quickjs/sandbox/provide/provideEnv.js +10 -0
- package/vendor/quickjs/sandbox/provide/provideFs.d.ts +4 -0
- package/vendor/quickjs/sandbox/provide/provideFs.js +159 -0
- package/vendor/quickjs/sandbox/provide/provideHttp.d.ts +9 -0
- package/vendor/quickjs/sandbox/provide/provideHttp.js +42 -0
- package/vendor/quickjs/sandbox/provide/provideTimingFunctions.d.ts +7 -0
- package/vendor/quickjs/sandbox/provide/provideTimingFunctions.js +119 -0
- package/vendor/quickjs/sandbox/setupFileSystem.d.ts +3 -0
- package/vendor/quickjs/sandbox/setupFileSystem.js +13 -0
- package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.d.ts +4 -0
- package/vendor/quickjs/sandbox/syncVersion/createEvalCodeFunction.js +76 -0
- package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.d.ts +3 -0
- package/vendor/quickjs/sandbox/syncVersion/createValidateCodeFunction.js +22 -0
- package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.d.ts +12 -0
- package/vendor/quickjs/sandbox/syncVersion/executeSandboxFunction.js +9 -0
- package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.d.ts +4 -0
- package/vendor/quickjs/sandbox/syncVersion/getModuleLoader.js +30 -0
- package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.d.ts +2 -0
- package/vendor/quickjs/sandbox/syncVersion/modulePathNormalizer.js +12 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.d.ts +3 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareNodeCompatibility.js +11 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.d.ts +4 -0
- package/vendor/quickjs/sandbox/syncVersion/prepareSandbox.js +10 -0
- package/vendor/quickjs/types/CodeFunctionInput.d.ts +12 -0
- package/vendor/quickjs/types/CodeFunctionInput.js +1 -0
- package/vendor/quickjs/types/ErrorResponse.d.ts +9 -0
- package/vendor/quickjs/types/ErrorResponse.js +1 -0
- package/vendor/quickjs/types/LoadQuickJsOptions.d.ts +3 -0
- package/vendor/quickjs/types/LoadQuickJsOptions.js +1 -0
- package/vendor/quickjs/types/OkResponse.d.ts +4 -0
- package/vendor/quickjs/types/OkResponse.js +1 -0
- package/vendor/quickjs/types/OkResponseCheck.d.ts +3 -0
- package/vendor/quickjs/types/OkResponseCheck.js +1 -0
- package/vendor/quickjs/types/Prettify.d.ts +3 -0
- package/vendor/quickjs/types/Prettify.js +1 -0
- package/vendor/quickjs/types/RuntimeOptions.d.ts +87 -0
- package/vendor/quickjs/types/RuntimeOptions.js +1 -0
- package/vendor/quickjs/types/SandboxEvalCode.d.ts +5 -0
- package/vendor/quickjs/types/SandboxEvalCode.js +1 -0
- package/vendor/quickjs/types/SandboxFunction.d.ts +16 -0
- package/vendor/quickjs/types/SandboxFunction.js +1 -0
- package/vendor/quickjs/types/SandboxOptions.d.ts +152 -0
- package/vendor/quickjs/types/SandboxOptions.js +1 -0
- package/vendor/quickjs/types/SandboxValidateCode.d.ts +9 -0
- package/vendor/quickjs/types/SandboxValidateCode.js +1 -0
- package/vendor/quickjs/types/Serializer.d.ts +2 -0
- package/vendor/quickjs/types/Serializer.js +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host→guest byte marshaling.
|
|
3
|
+
*
|
|
4
|
+
* Binary crosses the sandbox boundary asymmetrically. Guest→host is handled by
|
|
5
|
+
* the typed-array serializers, so a guest `Uint8Array` reaches a host function
|
|
6
|
+
* as a native one. Host→guest is not: a returned `Uint8Array` arrives in the
|
|
7
|
+
* guest as a numeric-keyed plain object. Anything producing bytes therefore
|
|
8
|
+
* returns a tagged base64 marker that the guest prelude rebuilds into a real
|
|
9
|
+
* `Uint8Array`.
|
|
10
|
+
*
|
|
11
|
+
* It lives in its own module because both the sandbox itself and the host
|
|
12
|
+
* module dispatcher marshal results, and the dispatcher is imported *by* the
|
|
13
|
+
* sandbox.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SANDBOX_SERIALIZE_MAX_DEPTH = 32;
|
|
16
|
+
/** Marker key carrying base64 bytes from host to guest. */
|
|
17
|
+
export declare const SANDBOX_BYTES_MARKER = "__nodetool_sandbox_bytes__";
|
|
18
|
+
/** The base64 alphabet, also inlined into the guest prelude's own codec. */
|
|
19
|
+
export declare const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
20
|
+
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
21
|
+
/** Base64 bytes tagged for the guest prelude to revive as a `Uint8Array`. */
|
|
22
|
+
export type GuestBytes = {
|
|
23
|
+
readonly [SANDBOX_BYTES_MARKER]: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* What a host bridge hands the guest: JSON-shaped data, with byte payloads
|
|
27
|
+
* carried as {@link GuestBytes} markers. Every host module export and every
|
|
28
|
+
* bridge return value satisfies this contract — a function, a class instance,
|
|
29
|
+
* or a live handle cannot cross the boundary.
|
|
30
|
+
*/
|
|
31
|
+
export type GuestValue = null | undefined | boolean | number | string | GuestBytes | readonly GuestValue[] | {
|
|
32
|
+
readonly [key: string]: GuestValue;
|
|
33
|
+
};
|
|
34
|
+
/** Tag bytes for the guest prelude to turn back into a real `Uint8Array`. */
|
|
35
|
+
export declare function toGuestBytes(bytes: Uint8Array): GuestBytes;
|
|
36
|
+
/**
|
|
37
|
+
* Same tagging, applied at any depth. A call that returns bytes inside a record
|
|
38
|
+
* (`image.decode`'s `{width, height, pixels}`, a zip's entry map) hands its
|
|
39
|
+
* result through this; the guest side pairs it with `__wrapDeep`, which revives
|
|
40
|
+
* every marker.
|
|
41
|
+
*/
|
|
42
|
+
export declare function toGuestBytesDeep(value: unknown, depth?: number): unknown;
|
|
43
|
+
//# sourceMappingURL=sandbox-bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-bytes.d.ts","sourceRoot":"","sources":["../src/sandbox-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,+BAA+B,CAAC;AAEjE,4EAA4E;AAC5E,eAAO,MAAM,eAAe,qEACwC,CAAC;AAErE,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAYtD;AAED,6EAA6E;AAC7E,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,IAAI,GACJ,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,SAAS,UAAU,EAAE,GACrB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC;AAE3C,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAcnE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host→guest byte marshaling.
|
|
3
|
+
*
|
|
4
|
+
* Binary crosses the sandbox boundary asymmetrically. Guest→host is handled by
|
|
5
|
+
* the typed-array serializers, so a guest `Uint8Array` reaches a host function
|
|
6
|
+
* as a native one. Host→guest is not: a returned `Uint8Array` arrives in the
|
|
7
|
+
* guest as a numeric-keyed plain object. Anything producing bytes therefore
|
|
8
|
+
* returns a tagged base64 marker that the guest prelude rebuilds into a real
|
|
9
|
+
* `Uint8Array`.
|
|
10
|
+
*
|
|
11
|
+
* It lives in its own module because both the sandbox itself and the host
|
|
12
|
+
* module dispatcher marshal results, and the dispatcher is imported *by* the
|
|
13
|
+
* sandbox.
|
|
14
|
+
*/
|
|
15
|
+
/** How deep the marshaler walks before it stops rewriting. */
|
|
16
|
+
import { isObjectLike } from "./utils/type-guards.js";
|
|
17
|
+
export const SANDBOX_SERIALIZE_MAX_DEPTH = 32;
|
|
18
|
+
/** Marker key carrying base64 bytes from host to guest. */
|
|
19
|
+
export const SANDBOX_BYTES_MARKER = "__nodetool_sandbox_bytes__";
|
|
20
|
+
/** The base64 alphabet, also inlined into the guest prelude's own codec. */
|
|
21
|
+
export const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
22
|
+
export function encodeBase64(bytes) {
|
|
23
|
+
let out = "";
|
|
24
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
25
|
+
const c = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);
|
|
26
|
+
out +=
|
|
27
|
+
BASE64_ALPHABET[(c >> 18) & 63] +
|
|
28
|
+
BASE64_ALPHABET[(c >> 12) & 63] +
|
|
29
|
+
(i + 1 < bytes.length ? BASE64_ALPHABET[(c >> 6) & 63] : "=") +
|
|
30
|
+
(i + 2 < bytes.length ? BASE64_ALPHABET[c & 63] : "=");
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/** Tag bytes for the guest prelude to turn back into a real `Uint8Array`. */
|
|
35
|
+
export function toGuestBytes(bytes) {
|
|
36
|
+
return { [SANDBOX_BYTES_MARKER]: encodeBase64(bytes) };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Same tagging, applied at any depth. A call that returns bytes inside a record
|
|
40
|
+
* (`image.decode`'s `{width, height, pixels}`, a zip's entry map) hands its
|
|
41
|
+
* result through this; the guest side pairs it with `__wrapDeep`, which revives
|
|
42
|
+
* every marker.
|
|
43
|
+
*/
|
|
44
|
+
export function toGuestBytesDeep(value, depth = 0) {
|
|
45
|
+
if (value instanceof Uint8Array)
|
|
46
|
+
return toGuestBytes(value);
|
|
47
|
+
if (depth >= SANDBOX_SERIALIZE_MAX_DEPTH)
|
|
48
|
+
return value;
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
return value.map((v) => toGuestBytesDeep(v, depth + 1));
|
|
51
|
+
}
|
|
52
|
+
if (isObjectLike(value)) {
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const [k, v] of Object.entries(value)) {
|
|
55
|
+
out[k] = toGuestBytesDeep(v, depth + 1);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sandbox-bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-bytes.js","sourceRoot":"","sources":["../src/sandbox-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8DAA8D;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAE9C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAEjE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,eAAe,GAC1B,kEAAkE,CAAC;AAErE,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,GACL,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,GAAG;YACD,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;gBAC/B,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;gBAC/B,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC7D,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAqBD,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,OAAO,EAAE,CAAC,oBAAoB,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IACxD,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5D,IAAI,KAAK,IAAI,2BAA2B;QAAE,OAAO,KAAK,CAAC;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YACtE,GAAG,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Canvas 2D surface the sandbox exposes, named in one place.
|
|
3
|
+
*
|
|
4
|
+
* Two sides read these lists and must agree: the guest-side recorder in the
|
|
5
|
+
* sandbox prelude, which builds a context object with exactly these members,
|
|
6
|
+
* and the host-side replay in `sandbox-media.ts`, which refuses any op naming
|
|
7
|
+
* something outside them. Splitting them out of the media engine keeps that
|
|
8
|
+
* engine — and the native canvas behind it — lazily loaded, since the prelude
|
|
9
|
+
* needs the names long before anything draws.
|
|
10
|
+
*/
|
|
11
|
+
/** Context properties a recorded draw list may set. */
|
|
12
|
+
export declare const CANVAS_PROPERTIES: readonly ["fillStyle", "strokeStyle", "lineWidth", "lineCap", "lineJoin", "miterLimit", "lineDashOffset", "globalAlpha", "globalCompositeOperation", "filter", "font", "textAlign", "textBaseline", "direction", "letterSpacing", "imageSmoothingEnabled", "imageSmoothingQuality", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY"];
|
|
13
|
+
/**
|
|
14
|
+
* Context methods a recorded draw list may call. `drawImage` is deliberately
|
|
15
|
+
* absent: it is the one call carrying binary, and both sides special-case it.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CANVAS_METHODS: readonly ["save", "restore", "translate", "rotate", "scale", "transform", "setTransform", "resetTransform", "beginPath", "closePath", "moveTo", "lineTo", "bezierCurveTo", "quadraticCurveTo", "arc", "arcTo", "ellipse", "rect", "roundRect", "fill", "stroke", "clip", "fillRect", "strokeRect", "clearRect", "fillText", "strokeText", "setLineDash"];
|
|
18
|
+
/** Gradient factories the recorder offers; each returns a gradient handle. */
|
|
19
|
+
export declare const CANVAS_GRADIENT_FACTORIES: {
|
|
20
|
+
readonly createLinearGradient: "linear";
|
|
21
|
+
readonly createRadialGradient: "radial";
|
|
22
|
+
readonly createConicGradient: "conic";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Marker key on a gradient handle. A gradient is a host object, so the guest
|
|
26
|
+
* holds a tag instead and the renderer swaps in the real one when the tag is
|
|
27
|
+
* assigned to `fillStyle` or `strokeStyle`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CANVAS_GRADIENT_MARKER = "__nodetool_canvas_gradient__";
|
|
30
|
+
//# sourceMappingURL=sandbox-canvas-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-canvas-api.d.ts","sourceRoot":"","sources":["../src/sandbox-canvas-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,YAC5B,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,0BAA0B,EAC1B,QAAQ,EACR,MAAM,EACN,WAAW,EACX,cAAc,EACd,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,eAAe,CACP,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc,YACzB,MAAM,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACR,OAAO,EACP,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,KAAK,EACL,OAAO,EACP,SAAS,EACT,MAAM,EACN,WAAW,EACX,MAAM,EACN,QAAQ,EACR,MAAM,EACN,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,CACL,CAAC;AAEX,8EAA8E;AAC9E,eAAO,MAAM,yBAAyB;aACpC,oBAAoB,EAAE,QAAQ;aAC9B,oBAAoB,EAAE,QAAQ;aAC9B,mBAAmB,EAAE,OAAO;CACpB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Canvas 2D surface the sandbox exposes, named in one place.
|
|
3
|
+
*
|
|
4
|
+
* Two sides read these lists and must agree: the guest-side recorder in the
|
|
5
|
+
* sandbox prelude, which builds a context object with exactly these members,
|
|
6
|
+
* and the host-side replay in `sandbox-media.ts`, which refuses any op naming
|
|
7
|
+
* something outside them. Splitting them out of the media engine keeps that
|
|
8
|
+
* engine — and the native canvas behind it — lazily loaded, since the prelude
|
|
9
|
+
* needs the names long before anything draws.
|
|
10
|
+
*/
|
|
11
|
+
/** Context properties a recorded draw list may set. */
|
|
12
|
+
export const CANVAS_PROPERTIES = [
|
|
13
|
+
"fillStyle",
|
|
14
|
+
"strokeStyle",
|
|
15
|
+
"lineWidth",
|
|
16
|
+
"lineCap",
|
|
17
|
+
"lineJoin",
|
|
18
|
+
"miterLimit",
|
|
19
|
+
"lineDashOffset",
|
|
20
|
+
"globalAlpha",
|
|
21
|
+
"globalCompositeOperation",
|
|
22
|
+
"filter",
|
|
23
|
+
"font",
|
|
24
|
+
"textAlign",
|
|
25
|
+
"textBaseline",
|
|
26
|
+
"direction",
|
|
27
|
+
"letterSpacing",
|
|
28
|
+
"imageSmoothingEnabled",
|
|
29
|
+
"imageSmoothingQuality",
|
|
30
|
+
"shadowColor",
|
|
31
|
+
"shadowBlur",
|
|
32
|
+
"shadowOffsetX",
|
|
33
|
+
"shadowOffsetY"
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Context methods a recorded draw list may call. `drawImage` is deliberately
|
|
37
|
+
* absent: it is the one call carrying binary, and both sides special-case it.
|
|
38
|
+
*/
|
|
39
|
+
export const CANVAS_METHODS = [
|
|
40
|
+
"save",
|
|
41
|
+
"restore",
|
|
42
|
+
"translate",
|
|
43
|
+
"rotate",
|
|
44
|
+
"scale",
|
|
45
|
+
"transform",
|
|
46
|
+
"setTransform",
|
|
47
|
+
"resetTransform",
|
|
48
|
+
"beginPath",
|
|
49
|
+
"closePath",
|
|
50
|
+
"moveTo",
|
|
51
|
+
"lineTo",
|
|
52
|
+
"bezierCurveTo",
|
|
53
|
+
"quadraticCurveTo",
|
|
54
|
+
"arc",
|
|
55
|
+
"arcTo",
|
|
56
|
+
"ellipse",
|
|
57
|
+
"rect",
|
|
58
|
+
"roundRect",
|
|
59
|
+
"fill",
|
|
60
|
+
"stroke",
|
|
61
|
+
"clip",
|
|
62
|
+
"fillRect",
|
|
63
|
+
"strokeRect",
|
|
64
|
+
"clearRect",
|
|
65
|
+
"fillText",
|
|
66
|
+
"strokeText",
|
|
67
|
+
"setLineDash"
|
|
68
|
+
];
|
|
69
|
+
/** Gradient factories the recorder offers; each returns a gradient handle. */
|
|
70
|
+
export const CANVAS_GRADIENT_FACTORIES = {
|
|
71
|
+
createLinearGradient: "linear",
|
|
72
|
+
createRadialGradient: "radial",
|
|
73
|
+
createConicGradient: "conic"
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Marker key on a gradient handle. A gradient is a host object, so the guest
|
|
77
|
+
* holds a tag instead and the renderer swaps in the real one when the tag is
|
|
78
|
+
* assigned to `fillStyle` or `strokeStyle`.
|
|
79
|
+
*/
|
|
80
|
+
export const CANVAS_GRADIENT_MARKER = "__nodetool_canvas_gradient__";
|
|
81
|
+
//# sourceMappingURL=sandbox-canvas-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-canvas-api.js","sourceRoot":"","sources":["../src/sandbox-canvas-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW;IACX,aAAa;IACb,WAAW;IACX,SAAS;IACT,UAAU;IACV,YAAY;IACZ,gBAAgB;IAChB,aAAa;IACb,0BAA0B;IAC1B,QAAQ;IACR,MAAM;IACN,WAAW;IACX,cAAc;IACd,WAAW;IACX,eAAe;IACf,uBAAuB;IACvB,uBAAuB;IACvB,aAAa;IACb,YAAY;IACZ,eAAe;IACf,eAAe;CACP,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,MAAM;IACN,SAAS;IACT,WAAW;IACX,QAAQ;IACR,OAAO;IACP,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,kBAAkB;IAClB,KAAK;IACL,OAAO;IACP,SAAS;IACT,MAAM;IACN,WAAW;IACX,MAAM;IACN,QAAQ;IACR,MAAM;IACN,UAAU;IACV,YAAY;IACZ,WAAW;IACX,UAAU;IACV,YAAY;IACZ,aAAa;CACL,CAAC;AAEX,8EAA8E;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,oBAAoB,EAAE,QAAQ;IAC9B,oBAAoB,EAAE,QAAQ;IAC9B,mBAAmB,EAAE,OAAO;CACpB,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Largest `crypto.getRandomValues` request the bridge will serve. */
|
|
2
|
+
export declare const MAX_RANDOM_BYTES = 65536;
|
|
3
|
+
/** Media member names, in the order the guest prelude re-wraps them. */
|
|
4
|
+
export declare const MEDIA_REF_MEMBERS: readonly ["bytes", "text", "info", "toDocument", "toImage", "toAudio", "toVideo"];
|
|
5
|
+
//# sourceMappingURL=sandbox-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-constants.d.ts","sourceRoot":"","sources":["../src/sandbox-constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,YAC5B,OAAO,EACP,MAAM,EACN,MAAM,EACN,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,CACD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Largest `crypto.getRandomValues` request the bridge will serve. */
|
|
2
|
+
export const MAX_RANDOM_BYTES = 65_536;
|
|
3
|
+
/** Media member names, in the order the guest prelude re-wraps them. */
|
|
4
|
+
export const MEDIA_REF_MEMBERS = [
|
|
5
|
+
"bytes",
|
|
6
|
+
"text",
|
|
7
|
+
"info",
|
|
8
|
+
"toDocument",
|
|
9
|
+
"toImage",
|
|
10
|
+
"toAudio",
|
|
11
|
+
"toVideo"
|
|
12
|
+
];
|
|
13
|
+
//# sourceMappingURL=sandbox-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-constants.js","sourceRoot":"","sources":["../src/sandbox-constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO;IACP,MAAM;IACN,MAAM;IACN,YAAY;IACZ,SAAS;IACT,SAAS;IACT,SAAS;CACD,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON transport for structured data across the QuickJS boundary.
|
|
3
|
+
*
|
|
4
|
+
* The wrapper marshals a value handle-by-handle: every object node costs four
|
|
5
|
+
* `evalCode` compilations inside the guest plus a `newFunction` allocation, and
|
|
6
|
+
* every property crosses as its own descriptor. Measured on this repo's engine
|
|
7
|
+
* that is ~150 µs per object node out of the guest and ~400 µs per object node
|
|
8
|
+
* into it — a Code node handed 5 000 rows spent 1.9 s reading them and another
|
|
9
|
+
* 0.8 s handing them back, before running a line of its own.
|
|
10
|
+
*
|
|
11
|
+
* Both directions carry JSON-shaped data, so the fast path is to move one
|
|
12
|
+
* string: the guest builds its answer with `JSON.stringify` and the host parses
|
|
13
|
+
* it, and the host encodes its globals here for the init prelude to parse.
|
|
14
|
+
* Measured on the same shapes, 20–25× either way.
|
|
15
|
+
*
|
|
16
|
+
* Two kinds of value would lose by that trade, and both ride *beside* the JSON
|
|
17
|
+
* in a sidecar the marshaler moves in one piece — a typed array (base64 inside
|
|
18
|
+
* the guest costs more than the marshal it replaces) and a string past
|
|
19
|
+
* {@link SIDECAR_STRING_THRESHOLD} (escaping a megabyte to unescape it again is
|
|
20
|
+
* two passes the primitive path never makes). A {@link JSON_SIDECAR_MARKER}
|
|
21
|
+
* holds its place by index.
|
|
22
|
+
*
|
|
23
|
+
* What JSON alone still cannot carry is carried by markers, so the round trip
|
|
24
|
+
* keeps the types the structured path preserved:
|
|
25
|
+
*
|
|
26
|
+
* - **dates** — an ISO string under {@link JSON_DATE_MARKER}, revived as a
|
|
27
|
+
* `Date`. A `state.lastRun` that survives a Code node's invocations stays a
|
|
28
|
+
* `Date` rather than degrading to a string on its first round trip.
|
|
29
|
+
* - **non-finite numbers** — `NaN` and the infinities under {@link
|
|
30
|
+
* JSON_NUMBER_MARKER}. `JSON.stringify` writes them as `null`.
|
|
31
|
+
* - **undefined** — {@link JSON_UNDEFINED_MARKER}, so a property whose value is
|
|
32
|
+
* `undefined` keeps its key. `JSON.stringify` drops it.
|
|
33
|
+
*
|
|
34
|
+
* Anything else — a function, a symbol, a bigint, a `Map`, a class instance —
|
|
35
|
+
* makes the encoder refuse that value, and its caller falls back to the
|
|
36
|
+
* wrapper's own marshaling, which is slow but total. The fast path never has to
|
|
37
|
+
* guess.
|
|
38
|
+
*
|
|
39
|
+
* A **cycle** is the one thing neither path carries: the wrapper's marshaler
|
|
40
|
+
* recurses until the runtime aborts with `list_empty(&rt->gc_obj_list)`, which
|
|
41
|
+
* kills the run with an assertion instead of an answer. So a cyclic global is
|
|
42
|
+
* refused by name, and a cyclic result becomes `String(value)` — the fallback
|
|
43
|
+
* `serializeResult` already documents for a value `JSON.stringify` rejects.
|
|
44
|
+
*
|
|
45
|
+
* Browser-safe: nothing here imports a Node builtin.
|
|
46
|
+
*/
|
|
47
|
+
/** Marker key carrying an ISO timestamp for a `Date`. */
|
|
48
|
+
export declare const JSON_DATE_MARKER = "__nodetool_sandbox_date__";
|
|
49
|
+
/** Marker key carrying `"NaN"`, `"Infinity"`, or `"-Infinity"`. */
|
|
50
|
+
export declare const JSON_NUMBER_MARKER = "__nodetool_sandbox_number__";
|
|
51
|
+
/** Marker key standing in for an `undefined` property value. */
|
|
52
|
+
export declare const JSON_UNDEFINED_MARKER = "__nodetool_sandbox_undefined__";
|
|
53
|
+
/** Marker key carrying an index into the payload's sidecar. */
|
|
54
|
+
export declare const JSON_SIDECAR_MARKER = "__nodetool_sandbox_side__";
|
|
55
|
+
/**
|
|
56
|
+
* Strings at least this long travel in the sidecar rather than inside the JSON.
|
|
57
|
+
* Below it the escape/unescape pass is noise next to the run's fixed cost; a
|
|
58
|
+
* megabyte of text is where it stops being.
|
|
59
|
+
*/
|
|
60
|
+
export declare const SIDECAR_STRING_THRESHOLD = 8192;
|
|
61
|
+
/** The global the guest parks its encoder on. */
|
|
62
|
+
export declare const GUEST_MARSHAL_GLOBAL = "__nodetool_marshal__";
|
|
63
|
+
/** The global carrying the host's encoded globals for the prelude to read. */
|
|
64
|
+
export declare const GUEST_GLOBALS_JSON_BINDING = "__nodetool_globals_json__";
|
|
65
|
+
/** The global carrying the sidecar those encoded globals index into. */
|
|
66
|
+
export declare const GUEST_GLOBALS_SIDECAR_BINDING = "__nodetool_globals_side__";
|
|
67
|
+
/** What one encoded batch of host globals hands the guest prelude. */
|
|
68
|
+
export interface HostRecordEncoding {
|
|
69
|
+
/** JSON for the guest to parse: `{name: value}` over the accepted entries. */
|
|
70
|
+
readonly json: string;
|
|
71
|
+
/** Values the JSON refers to by index, moved whole rather than escaped. */
|
|
72
|
+
readonly sidecar: readonly string[];
|
|
73
|
+
/** Entries no JSON representation covers. The caller marshals these itself. */
|
|
74
|
+
readonly skipped: readonly string[];
|
|
75
|
+
/** Entries that refer back to themselves. Neither path can carry these. */
|
|
76
|
+
readonly cyclic: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Encode a batch of named host values for the guest to `JSON.parse` and revive.
|
|
80
|
+
*
|
|
81
|
+
* One batch means one sidecar and one parse. An entry holding something JSON
|
|
82
|
+
* plus the markers cannot carry is reported in `skipped` instead of failing the
|
|
83
|
+
* batch, so one exotic global costs only itself; an entry that refers back to
|
|
84
|
+
* itself is reported in `cyclic`, which no path can carry.
|
|
85
|
+
*/
|
|
86
|
+
export declare function encodeHostRecord(values: Record<string, unknown>): HostRecordEncoding;
|
|
87
|
+
/**
|
|
88
|
+
* Decode what the guest's encoder produced: either a JSON string plus the
|
|
89
|
+
* sidecar its markers index, or a value the guest handed over as-is (a
|
|
90
|
+
* primitive, or something `JSON.stringify` refused) under `raw`.
|
|
91
|
+
*
|
|
92
|
+
* The guest owns this string, so a body that overwrites the encoder can hand
|
|
93
|
+
* back nonsense. That is not an escalation — the guest owned its own result
|
|
94
|
+
* either way — so a payload that will not parse decodes as `undefined` rather
|
|
95
|
+
* than failing the run.
|
|
96
|
+
*/
|
|
97
|
+
export declare function decodeGuestPayload(payload: unknown): unknown;
|
|
98
|
+
/**
|
|
99
|
+
* The guest half, spliced into the init prelude: the encoder the entry module
|
|
100
|
+
* and the sync extractor call, and the parse of whatever globals the host
|
|
101
|
+
* encoded.
|
|
102
|
+
*
|
|
103
|
+
* `__bytesMarker` and `fromBase64` are defined earlier in the prelude, so this
|
|
104
|
+
* source has to follow them.
|
|
105
|
+
*/
|
|
106
|
+
export declare const GUEST_JSON_TRANSPORT_SOURCE: string;
|
|
107
|
+
//# sourceMappingURL=sandbox-json-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-json-transport.d.ts","sourceRoot":"","sources":["../src/sandbox-json-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AASH,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAE5D,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,gCAAgC,CAAC;AAEhE,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,mCAAmC,CAAC;AAEtE,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAE3D,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AAEtE,wEAAwE;AACxE,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAwFzE,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,kBAAkB,CAkBpB;AA2BD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAgB5D;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,QA4EvC,CAAC"}
|