@nodetool-ai/sandbox-runtime 0.0.0-stage → 0.8.9-beta.2
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,153 @@
|
|
|
1
|
+
import { Scope, } from 'quickjs-emscripten-core';
|
|
2
|
+
import { getHandle } from '../expose/expose.js';
|
|
3
|
+
import { call } from '../helper.js';
|
|
4
|
+
import { getSerializer } from './serializer/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Serialize data from guest to host
|
|
7
|
+
*
|
|
8
|
+
* @param ctx The sandbox context
|
|
9
|
+
* @param handle The QuickJS handle to serialize
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export const handleToNative = (ctx, handle, rootScope) => {
|
|
13
|
+
const ty = ctx.typeof(handle);
|
|
14
|
+
if (ty === 'undefined') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
if (ty === 'null') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (ty === 'number' || ty === 'string' || ty === 'boolean' || ty === 'bigint') {
|
|
21
|
+
return ctx.dump(handle);
|
|
22
|
+
}
|
|
23
|
+
if (ty === 'symbol') {
|
|
24
|
+
const desc = ctx.getString(ctx.getProp(handle, 'description'));
|
|
25
|
+
return Symbol(desc);
|
|
26
|
+
}
|
|
27
|
+
const asPromiseState = ctx.getPromiseState(handle);
|
|
28
|
+
if (asPromiseState.type && !asPromiseState.notAPromise) {
|
|
29
|
+
return ctx.resolvePromise(handle).then(val => {
|
|
30
|
+
if (val.error) {
|
|
31
|
+
const error = handleToNative(ctx, val.error, rootScope);
|
|
32
|
+
val.error.dispose();
|
|
33
|
+
return Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
const value = handleToNative(ctx, val.value, rootScope);
|
|
36
|
+
val.value.dispose();
|
|
37
|
+
return Promise.resolve(value);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// biome-ignore lint/complexity/noBannedTypes: ok here
|
|
41
|
+
const setProperties = (obj, h) => {
|
|
42
|
+
ctx
|
|
43
|
+
.newFunction('', (key, value) => {
|
|
44
|
+
const keyName = handleToNative(ctx, key, rootScope);
|
|
45
|
+
if (typeof keyName !== 'string' && typeof keyName !== 'number' && typeof keyName !== 'symbol')
|
|
46
|
+
return;
|
|
47
|
+
const desc = [
|
|
48
|
+
['value', true],
|
|
49
|
+
['get', true],
|
|
50
|
+
['set', true],
|
|
51
|
+
['configurable', false],
|
|
52
|
+
['enumerable', false],
|
|
53
|
+
['writable', false],
|
|
54
|
+
].reduce((desc, [key, unmarshable]) => {
|
|
55
|
+
const h = ctx.getProp(value, key);
|
|
56
|
+
const t = ctx.typeof(h);
|
|
57
|
+
if (t === 'undefined')
|
|
58
|
+
return desc;
|
|
59
|
+
if (!unmarshable && t === 'boolean') {
|
|
60
|
+
desc[key] = ctx.dump(h);
|
|
61
|
+
return desc;
|
|
62
|
+
}
|
|
63
|
+
desc[key] = handleToNative(ctx, h, rootScope);
|
|
64
|
+
h.dispose();
|
|
65
|
+
return desc;
|
|
66
|
+
}, {});
|
|
67
|
+
Object.defineProperty(obj, keyName, desc);
|
|
68
|
+
})
|
|
69
|
+
.consume(f => {
|
|
70
|
+
call(ctx, 'internal/serializer/setProperties.js', `(o, fn) => {
|
|
71
|
+
const descs = Object.getOwnPropertyDescriptors(o);
|
|
72
|
+
Object.entries(descs).forEach(([k, v]) => fn(k, v));
|
|
73
|
+
Object.getOwnPropertySymbols(descs).forEach(k => fn(k, descs[k]));
|
|
74
|
+
}`, undefined, h, f).dispose();
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
if (ty === 'function') {
|
|
78
|
+
if (!rootScope)
|
|
79
|
+
throw new Error('Missing root scope');
|
|
80
|
+
const cpHandle = rootScope.manage(handle.dup());
|
|
81
|
+
const f = function (...args) {
|
|
82
|
+
const scope = new Scope();
|
|
83
|
+
const thisHandle = getHandle(scope, ctx, '', this);
|
|
84
|
+
const argHandles = args.map(a => getHandle(scope, ctx, '', a));
|
|
85
|
+
if (new.target) {
|
|
86
|
+
const instance = handleToNative(ctx, call(ctx, 'internal/serializer/newClass.js', '(Cls, ...args) => new Cls(...args)', thisHandle, cpHandle, ...argHandles), rootScope);
|
|
87
|
+
Object.defineProperties(this, Object.getOwnPropertyDescriptors(instance));
|
|
88
|
+
scope.dispose();
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const resultHandle = scope.manage(ctx.unwrapResult(ctx.callFunction(cpHandle, thisHandle, ...argHandles)));
|
|
93
|
+
const res = handleToNative(ctx, resultHandle, rootScope);
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
scope.dispose();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
setProperties(f, handle);
|
|
101
|
+
return f;
|
|
102
|
+
}
|
|
103
|
+
if (ty === 'object') {
|
|
104
|
+
const isNull = call(ctx, 'internal/serializer/isNull.js', 'a => a === null', undefined, handle).consume(r => ctx.dump(r));
|
|
105
|
+
if (isNull)
|
|
106
|
+
return null;
|
|
107
|
+
// Check for Error instances
|
|
108
|
+
const errorType = call(ctx, 'internal/serializer/detectErrorType.js', `(o) => {
|
|
109
|
+
try {
|
|
110
|
+
const tag = Object.prototype.toString.call(o)
|
|
111
|
+
if (tag.startsWith('[object ') && tag.endsWith(']')) {
|
|
112
|
+
const type = tag.slice(8, -1)
|
|
113
|
+
if (type.endsWith('Error')) return type
|
|
114
|
+
}
|
|
115
|
+
} catch {}
|
|
116
|
+
if (typeof o?.name === 'string' && typeof o?.message === 'string') return 'Error'
|
|
117
|
+
return undefined
|
|
118
|
+
}`, undefined, handle).consume(r => ctx.dump(r));
|
|
119
|
+
if (typeof errorType === 'string') {
|
|
120
|
+
const s = getSerializer(errorType);
|
|
121
|
+
if (s) {
|
|
122
|
+
const ret = s(ctx, handle, rootScope);
|
|
123
|
+
if (ret) {
|
|
124
|
+
return ret;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const messageHandle = ctx.getProp(handle, 'message');
|
|
128
|
+
const stackHandle = ctx.getProp(handle, 'stack');
|
|
129
|
+
const message = ctx.dump(messageHandle) ?? '';
|
|
130
|
+
const stack = ctx.dump(stackHandle);
|
|
131
|
+
messageHandle.dispose();
|
|
132
|
+
stackHandle.dispose();
|
|
133
|
+
const e = new Error(message);
|
|
134
|
+
e.name = errorType;
|
|
135
|
+
if (typeof stack === 'string')
|
|
136
|
+
e.stack = stack;
|
|
137
|
+
return e;
|
|
138
|
+
}
|
|
139
|
+
const isArray = call(ctx, 'internal/serializer/isArray.js', 'Array.isArray', undefined, handle).consume(r => ctx.dump(r));
|
|
140
|
+
const obj = isArray ? [] : {};
|
|
141
|
+
const constructorName = call(ctx, 'internal/serializer/getConstructorName.js', `o => typeof o?.constructor?.name === 'string' ? o.constructor.name : undefined`, undefined, handle).consume(r => ctx.dump(r));
|
|
142
|
+
const serializer = getSerializer(constructorName);
|
|
143
|
+
if (serializer) {
|
|
144
|
+
const ret = serializer(ctx, handle, rootScope);
|
|
145
|
+
if (ret) {
|
|
146
|
+
return ret;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
setProperties(obj, handle);
|
|
150
|
+
return obj;
|
|
151
|
+
}
|
|
152
|
+
throw new TypeError(`Failed to serialize ${ty}`);
|
|
153
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Serializer } from '../../../types/Serializer.js';
|
|
2
|
+
export declare const serializer: Map<string, Serializer>;
|
|
3
|
+
/**
|
|
4
|
+
* Add a new Serializer
|
|
5
|
+
*/
|
|
6
|
+
export declare const addSerializer: (name: string, fn: Serializer) => Map<string, Serializer>;
|
|
7
|
+
/**
|
|
8
|
+
* Get a Serializer by constructor name
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSerializer: (name: string) => Serializer | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { serializeArrayBuffer } from './serializeArrayBuffer.js';
|
|
2
|
+
import { serializeBuffer } from './serializeBuffer.js';
|
|
3
|
+
import { serializeDate } from './serializeDate.js';
|
|
4
|
+
import { serializeError } from './serializeError.js';
|
|
5
|
+
import { serializeHeaders } from './serializeHeaders.js';
|
|
6
|
+
import { serializeMap } from './serializeMap.js';
|
|
7
|
+
import { serializeSet } from './serializeSet.js';
|
|
8
|
+
import { serializeURLSearchParams } from './serializeURLSearchParams.js';
|
|
9
|
+
import { serializeUrl } from './serializeUrl.js';
|
|
10
|
+
export const serializer = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Add a new Serializer
|
|
13
|
+
*/
|
|
14
|
+
export const addSerializer = (name, fn) => serializer.set(name, fn);
|
|
15
|
+
/**
|
|
16
|
+
* Get a Serializer by constructor name
|
|
17
|
+
*/
|
|
18
|
+
export const getSerializer = (name) => serializer.get(name);
|
|
19
|
+
addSerializer('Buffer', serializeBuffer);
|
|
20
|
+
addSerializer('ArrayBuffer', serializeArrayBuffer);
|
|
21
|
+
addSerializer('Map', serializeMap);
|
|
22
|
+
addSerializer('Set', serializeSet);
|
|
23
|
+
addSerializer('Date', serializeDate);
|
|
24
|
+
addSerializer('Headers', serializeHeaders);
|
|
25
|
+
addSerializer('URL', serializeUrl);
|
|
26
|
+
addSerializer('URLSearchParams', serializeURLSearchParams);
|
|
27
|
+
// Errors
|
|
28
|
+
addSerializer('AssertionError', serializeError);
|
|
29
|
+
addSerializer('Error', serializeError);
|
|
30
|
+
addSerializer('EvalError', serializeError);
|
|
31
|
+
addSerializer('RangeError', serializeError);
|
|
32
|
+
addSerializer('ReferenceError', serializeError);
|
|
33
|
+
addSerializer('SyntaxError', serializeError);
|
|
34
|
+
addSerializer('SystemError', serializeError);
|
|
35
|
+
addSerializer('TypeError', serializeError);
|
|
36
|
+
addSerializer('URIError', serializeError);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeBuffer = (ctx, handle, rootScope) => {
|
|
4
|
+
let b;
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', value => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
b = Buffer.from(v);
|
|
9
|
+
})
|
|
10
|
+
.consume(f => {
|
|
11
|
+
call(ctx, 'internal/serializer/serializeBuffer.js', `(b,fn) => {
|
|
12
|
+
fn(b.buffer)
|
|
13
|
+
}`, undefined, handle, f).dispose();
|
|
14
|
+
});
|
|
15
|
+
return b;
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeDate = (ctx, handle, rootScope) => {
|
|
4
|
+
const d = new Date();
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', value => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
d.setTime(v);
|
|
9
|
+
})
|
|
10
|
+
.consume(f => {
|
|
11
|
+
call(ctx, 'internal/serializer/serializeDate.js', `(d,fn) => {
|
|
12
|
+
fn(d.getTime())
|
|
13
|
+
}`, undefined, handle, f).dispose();
|
|
14
|
+
});
|
|
15
|
+
return d;
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeError = (ctx, handle, rootScope) => {
|
|
4
|
+
const d = new Error();
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('serializeError', (value, name) => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
const n = handleToNative(ctx, name, rootScope);
|
|
9
|
+
Object.defineProperties(d, v);
|
|
10
|
+
d.name = n;
|
|
11
|
+
})
|
|
12
|
+
.consume(f => {
|
|
13
|
+
call(ctx, 'internal/serializer/serializeError.js', `(d,fn) => {
|
|
14
|
+
fn(Object.getOwnPropertyDescriptors(d),d.name)
|
|
15
|
+
}`, undefined, handle, f).dispose();
|
|
16
|
+
});
|
|
17
|
+
return d;
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeHeaders = (ctx, handle, rootScope) => {
|
|
4
|
+
const h = new Headers();
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', (value, name) => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
const n = handleToNative(ctx, name, rootScope);
|
|
9
|
+
h.append(n, v);
|
|
10
|
+
})
|
|
11
|
+
.consume(f => {
|
|
12
|
+
call(ctx, 'internal/serializer/serializeHeaders.js', `(h, fn) => {
|
|
13
|
+
h.forEach(fn)
|
|
14
|
+
}`, undefined, handle, f).dispose();
|
|
15
|
+
});
|
|
16
|
+
return h;
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeMap = (ctx, handle, rootScope) => {
|
|
4
|
+
const m = new Map();
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', (key, value) => {
|
|
7
|
+
const k = handleToNative(ctx, key, rootScope);
|
|
8
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
9
|
+
m.set(k, v);
|
|
10
|
+
})
|
|
11
|
+
.consume(f => {
|
|
12
|
+
call(ctx, 'internal/serializer/serializeMap.js', `(m,fn) => {
|
|
13
|
+
for(const [key,value] of m.entries())
|
|
14
|
+
fn(key,value)
|
|
15
|
+
}`, undefined, handle, f).dispose();
|
|
16
|
+
});
|
|
17
|
+
return m;
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeSet = (ctx, handle, rootScope) => {
|
|
4
|
+
const s = new Set();
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', value => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
s.add(v);
|
|
9
|
+
})
|
|
10
|
+
.consume(f => {
|
|
11
|
+
call(ctx, 'internal/serializer/serializeSet.js', `(s,fn) => {
|
|
12
|
+
s.forEach(fn)
|
|
13
|
+
}`, undefined, handle, f).dispose();
|
|
14
|
+
});
|
|
15
|
+
return s;
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeURLSearchParams = (ctx, handle, rootScope) => {
|
|
4
|
+
const h = new URLSearchParams();
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', (value, name) => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
const n = handleToNative(ctx, name, rootScope);
|
|
9
|
+
h.append(n, v);
|
|
10
|
+
})
|
|
11
|
+
.consume(f => {
|
|
12
|
+
call(ctx, 'internal/serializer/serializeUrlSearchParams.js', `(h, fn) => {
|
|
13
|
+
h.forEach(fn)
|
|
14
|
+
}`, undefined, handle, f).dispose();
|
|
15
|
+
});
|
|
16
|
+
return h;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { call } from '../../helper.js';
|
|
2
|
+
import { handleToNative } from '../handleToNative.js';
|
|
3
|
+
export const serializeUrl = (ctx, handle, rootScope) => {
|
|
4
|
+
let d;
|
|
5
|
+
ctx
|
|
6
|
+
.newFunction('', value => {
|
|
7
|
+
const v = handleToNative(ctx, value, rootScope);
|
|
8
|
+
d = new URL(v);
|
|
9
|
+
})
|
|
10
|
+
.consume(f => {
|
|
11
|
+
call(ctx, 'internal/serializer/serializeUrl.js', `(d,fn) => {
|
|
12
|
+
fn(d.toJSON())
|
|
13
|
+
}`, undefined, handle, f).dispose();
|
|
14
|
+
});
|
|
15
|
+
return d;
|
|
16
|
+
};
|
|
17
|
+
URLSearchParams;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { QuickJSAsyncContext, QuickJSContext, QuickJSHandle } from 'quickjs-emscripten-core';
|
|
2
|
+
export declare const call: (ctx: QuickJSContext | QuickJSAsyncContext, fileName: string, code: string, that: QuickJSHandle | undefined, ...args: QuickJSHandle[]) => QuickJSHandle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const call = (ctx, fileName, code, that, ...args) => {
|
|
2
|
+
const fnHandle = ctx.unwrapResult(ctx.evalCode(code, fileName));
|
|
3
|
+
try {
|
|
4
|
+
const callHandle = ctx.unwrapResult(ctx.callFunction(fnHandle, that || ctx.undefined, ...args));
|
|
5
|
+
fnHandle.dispose();
|
|
6
|
+
return callHandle;
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
console.error(error);
|
|
10
|
+
const e = new Error(error.message ?? 'Function call failed in serialization');
|
|
11
|
+
e.cause = error;
|
|
12
|
+
throw e;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { QuickJSAsyncContext, QuickJSContext, Scope } from 'quickjs-emscripten-core';
|
|
2
|
+
import type { RuntimeOptions } from '../../types/RuntimeOptions.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provide all Node.js console methods
|
|
5
|
+
*/
|
|
6
|
+
export declare const provideConsole: (ctx: QuickJSContext | QuickJSAsyncContext, scope: Scope, options: RuntimeOptions) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { expose } from '../expose/expose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provide all Node.js console methods
|
|
4
|
+
*/
|
|
5
|
+
export const provideConsole = (ctx, scope, options) => {
|
|
6
|
+
const logger = {
|
|
7
|
+
log: (...params) => console.log(...params),
|
|
8
|
+
error: (...params) => console.error(...params),
|
|
9
|
+
warn: (...params) => console.warn(...params),
|
|
10
|
+
info: (...params) => console.info(...params),
|
|
11
|
+
debug: (...params) => console.debug(...params),
|
|
12
|
+
trace: (...params) => console.trace(...params),
|
|
13
|
+
assert: (...params) => console.assert(...params),
|
|
14
|
+
count: (...params) => console.count(...params),
|
|
15
|
+
countReset: (...params) => console.countReset(...params),
|
|
16
|
+
dir: (...params) => console.dir(...params),
|
|
17
|
+
dirxml: (...params) => console.dirxml(...params),
|
|
18
|
+
group: (...params) => console.group(...params),
|
|
19
|
+
groupCollapsed: (...params) => console.groupCollapsed(...params),
|
|
20
|
+
groupEnd: () => console.groupEnd(),
|
|
21
|
+
table: (...params) => console.table(...params),
|
|
22
|
+
time: (...params) => console.time(...params),
|
|
23
|
+
timeEnd: (...params) => console.timeEnd(...params),
|
|
24
|
+
timeLog: (...params) => console.timeLog(...params),
|
|
25
|
+
clear: () => {
|
|
26
|
+
throw new Error('console.clear is disabled for security reasons by default');
|
|
27
|
+
},
|
|
28
|
+
...options.console,
|
|
29
|
+
};
|
|
30
|
+
expose(ctx, scope, {
|
|
31
|
+
console: {
|
|
32
|
+
log: logger.log,
|
|
33
|
+
error: logger.error,
|
|
34
|
+
warn: logger.warn,
|
|
35
|
+
info: logger.info,
|
|
36
|
+
debug: logger.debug,
|
|
37
|
+
trace: logger.trace,
|
|
38
|
+
assert: logger.assert,
|
|
39
|
+
count: logger.count,
|
|
40
|
+
countReset: logger.countReset,
|
|
41
|
+
dir: logger.dir,
|
|
42
|
+
dirxml: logger.dirxml,
|
|
43
|
+
group: logger.group,
|
|
44
|
+
groupCollapsed: logger.groupCollapsed,
|
|
45
|
+
groupEnd: logger.groupEnd,
|
|
46
|
+
table: logger.table,
|
|
47
|
+
time: logger.time,
|
|
48
|
+
timeEnd: logger.timeEnd,
|
|
49
|
+
timeLog: logger.timeLog,
|
|
50
|
+
clear: logger.clear,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { QuickJSAsyncContext, QuickJSContext, Scope } from 'quickjs-emscripten-core';
|
|
2
|
+
import type { RuntimeOptions } from '../../types/RuntimeOptions.js';
|
|
3
|
+
export declare const provideEnv: (ctx: QuickJSContext | QuickJSAsyncContext, scope: Scope, options: RuntimeOptions) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IFs } from 'memfs';
|
|
2
|
+
import type { QuickJSAsyncContext, QuickJSContext, Scope } from 'quickjs-emscripten-core';
|
|
3
|
+
import type { RuntimeOptions } from '../../types/RuntimeOptions.js';
|
|
4
|
+
export declare const provideFs: (ctx: QuickJSContext | QuickJSAsyncContext, scope: Scope, runtimeOptions: RuntimeOptions, fs: IFs) => void;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { expose } from '../expose/expose.js';
|
|
2
|
+
export const provideFs = (ctx, scope, runtimeOptions, fs) => {
|
|
3
|
+
const disabledFn = (..._params) => {
|
|
4
|
+
throw new Error('File access is disabled');
|
|
5
|
+
};
|
|
6
|
+
const enabledFileSystem = {
|
|
7
|
+
access: (...params) => fs.access(...params),
|
|
8
|
+
accessSync: (...params) => fs.accessSync(...params),
|
|
9
|
+
appendFile: (...params) => fs.appendFile(...params),
|
|
10
|
+
appendFileSync: (...params) => fs.appendFileSync(...params),
|
|
11
|
+
chmod: (...params) => fs.chmod(...params),
|
|
12
|
+
chmodSync: (...params) => fs.chmodSync(...params),
|
|
13
|
+
chown: (...params) => fs.chown(...params),
|
|
14
|
+
chownSync: (...params) => fs.chownSync(...params),
|
|
15
|
+
close: (...params) => fs.close(...params),
|
|
16
|
+
closeSync: (...params) => fs.closeSync(...params),
|
|
17
|
+
copyFile: (...params) => fs.copyFile(...params),
|
|
18
|
+
copyFileSync: (...params) => fs.copyFileSync(...params),
|
|
19
|
+
createReadStream: (...params) => fs.createReadStream(...params),
|
|
20
|
+
createWriteStream: (...params) => fs.createWriteStream(...params),
|
|
21
|
+
exists: (...params) => fs.exists(...params),
|
|
22
|
+
existsSync: (...params) => fs.existsSync(...params),
|
|
23
|
+
fchmod: (...params) => fs.fchmod(...params),
|
|
24
|
+
fchmodSync: (...params) => fs.fchmodSync(...params),
|
|
25
|
+
fchown: (...params) => fs.fchown(...params),
|
|
26
|
+
fchownSync: (...params) => fs.fchownSync(...params),
|
|
27
|
+
fdatasync: (...params) => fs.fdatasync(...params),
|
|
28
|
+
fdatasyncSync: (...params) => fs.fdatasyncSync(...params),
|
|
29
|
+
fstat: (...params) => fs.fstat(...params),
|
|
30
|
+
fstatSync: (...params) => fs.fstatSync(...params),
|
|
31
|
+
fsync: (...params) => fs.fsync(...params),
|
|
32
|
+
fsyncSync: (...params) => fs.fsyncSync(...params),
|
|
33
|
+
ftruncate: (...params) => fs.ftruncate(...params),
|
|
34
|
+
ftruncateSync: (...params) => fs.ftruncateSync(...params),
|
|
35
|
+
futimes: (...params) => fs.futimes(...params),
|
|
36
|
+
futimesSync: (...params) => fs.futimesSync(...params),
|
|
37
|
+
lchmod: (...params) => fs.lchmod(...params),
|
|
38
|
+
lchmodSync: (...params) => fs.lchmodSync(...params),
|
|
39
|
+
lchown: (...params) => fs.lchown(...params),
|
|
40
|
+
lchownSync: (...params) => fs.lchownSync(...params),
|
|
41
|
+
link: (...params) => fs.link(...params),
|
|
42
|
+
linkSync: (...params) => fs.linkSync(...params),
|
|
43
|
+
lstat: (...params) => fs.lstat(...params),
|
|
44
|
+
lstatSync: (...params) => fs.lstatSync(...params),
|
|
45
|
+
mkdir: (...params) => fs.mkdir(...params),
|
|
46
|
+
mkdirSync: (...params) => fs.mkdirSync(...params),
|
|
47
|
+
mkdtemp: (...params) => fs.mkdtemp(...params),
|
|
48
|
+
mkdtempSync: (...params) => fs.mkdtempSync(...params),
|
|
49
|
+
open: (...params) => fs.open(...params),
|
|
50
|
+
openSync: (...params) => fs.openSync(...params),
|
|
51
|
+
readdir: (...params) => fs.readdir(...params),
|
|
52
|
+
readdirSync: (...params) => fs.readdirSync(...params),
|
|
53
|
+
read: (...params) => fs.read(...params),
|
|
54
|
+
readSync: (...params) => fs.readSync(...params),
|
|
55
|
+
readFile: (...params) => fs.readFile(...params),
|
|
56
|
+
readFileSync: (...params) => fs.readFileSync(...params).toString(),
|
|
57
|
+
readlink: (...params) => fs.readlink(...params),
|
|
58
|
+
readlinkSync: (...params) => fs.readlinkSync(...params),
|
|
59
|
+
realpath: (...params) => fs.realpath(...params),
|
|
60
|
+
realpathSync: (...params) => fs.realpathSync(...params),
|
|
61
|
+
rename: (...params) => fs.rename(...params),
|
|
62
|
+
renameSync: (...params) => fs.renameSync(...params),
|
|
63
|
+
rmdir: (...params) => fs.rmdir(...params),
|
|
64
|
+
rmdirSync: (...params) => fs.rmdirSync(...params),
|
|
65
|
+
stat: (...params) => fs.stat(...params),
|
|
66
|
+
statSync: (...params) => fs.statSync(...params),
|
|
67
|
+
symlink: (...params) => fs.symlink(...params),
|
|
68
|
+
symlinkSync: (...params) => fs.symlinkSync(...params),
|
|
69
|
+
truncate: (...params) => fs.truncate(...params),
|
|
70
|
+
truncateSync: (...params) => fs.truncateSync(...params),
|
|
71
|
+
unlink: (...params) => fs.unlink(...params),
|
|
72
|
+
unlinkSync: (...params) => fs.unlinkSync(...params),
|
|
73
|
+
utimes: (...params) => fs.utimes(...params),
|
|
74
|
+
utimesSync: (...params) => fs.utimesSync(...params),
|
|
75
|
+
write: (...params) => fs.write(...params),
|
|
76
|
+
writeSync: (...params) => fs.writeSync(...params),
|
|
77
|
+
writeFile: (...params) => fs.writeFile(...params),
|
|
78
|
+
writeFileSync: (...params) => {
|
|
79
|
+
fs.writeFileSync(...params);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
const disabledFileSystem = {
|
|
83
|
+
access: disabledFn,
|
|
84
|
+
accessSync: disabledFn,
|
|
85
|
+
appendFile: disabledFn,
|
|
86
|
+
appendFileSync: disabledFn,
|
|
87
|
+
chmod: disabledFn,
|
|
88
|
+
chmodSync: disabledFn,
|
|
89
|
+
chown: disabledFn,
|
|
90
|
+
chownSync: disabledFn,
|
|
91
|
+
close: disabledFn,
|
|
92
|
+
closeSync: disabledFn,
|
|
93
|
+
copyFile: disabledFn,
|
|
94
|
+
copyFileSync: disabledFn,
|
|
95
|
+
createReadStream: disabledFn,
|
|
96
|
+
createWriteStream: disabledFn,
|
|
97
|
+
exists: disabledFn,
|
|
98
|
+
existsSync: disabledFn,
|
|
99
|
+
fchmod: disabledFn,
|
|
100
|
+
fchmodSync: disabledFn,
|
|
101
|
+
fchown: disabledFn,
|
|
102
|
+
fchownSync: disabledFn,
|
|
103
|
+
fdatasync: disabledFn,
|
|
104
|
+
fdatasyncSync: disabledFn,
|
|
105
|
+
fstat: disabledFn,
|
|
106
|
+
fstatSync: disabledFn,
|
|
107
|
+
fsync: disabledFn,
|
|
108
|
+
fsyncSync: disabledFn,
|
|
109
|
+
ftruncate: disabledFn,
|
|
110
|
+
ftruncateSync: disabledFn,
|
|
111
|
+
futimes: disabledFn,
|
|
112
|
+
futimesSync: disabledFn,
|
|
113
|
+
lchmod: disabledFn,
|
|
114
|
+
lchmodSync: disabledFn,
|
|
115
|
+
lchown: disabledFn,
|
|
116
|
+
lchownSync: disabledFn,
|
|
117
|
+
link: disabledFn,
|
|
118
|
+
linkSync: disabledFn,
|
|
119
|
+
lstat: disabledFn,
|
|
120
|
+
lstatSync: disabledFn,
|
|
121
|
+
mkdir: disabledFn,
|
|
122
|
+
mkdirSync: disabledFn,
|
|
123
|
+
mkdtemp: disabledFn,
|
|
124
|
+
mkdtempSync: disabledFn,
|
|
125
|
+
open: disabledFn,
|
|
126
|
+
openSync: disabledFn,
|
|
127
|
+
readdir: disabledFn,
|
|
128
|
+
readdirSync: disabledFn,
|
|
129
|
+
read: disabledFn,
|
|
130
|
+
readSync: disabledFn,
|
|
131
|
+
readFile: disabledFn,
|
|
132
|
+
readFileSync: disabledFn,
|
|
133
|
+
readlink: disabledFn,
|
|
134
|
+
readlinkSync: disabledFn,
|
|
135
|
+
realpath: disabledFn,
|
|
136
|
+
realpathSync: disabledFn,
|
|
137
|
+
rename: disabledFn,
|
|
138
|
+
renameSync: disabledFn,
|
|
139
|
+
rmdir: disabledFn,
|
|
140
|
+
rmdirSync: disabledFn,
|
|
141
|
+
stat: disabledFn,
|
|
142
|
+
statSync: disabledFn,
|
|
143
|
+
symlink: disabledFn,
|
|
144
|
+
symlinkSync: disabledFn,
|
|
145
|
+
truncate: disabledFn,
|
|
146
|
+
truncateSync: disabledFn,
|
|
147
|
+
unlink: disabledFn,
|
|
148
|
+
unlinkSync: disabledFn,
|
|
149
|
+
utimes: disabledFn,
|
|
150
|
+
utimesSync: disabledFn,
|
|
151
|
+
write: disabledFn,
|
|
152
|
+
writeSync: disabledFn,
|
|
153
|
+
writeFile: disabledFn,
|
|
154
|
+
writeFileSync: disabledFn,
|
|
155
|
+
};
|
|
156
|
+
expose(ctx, scope, {
|
|
157
|
+
__fs: runtimeOptions.allowFs ? enabledFileSystem : disabledFileSystem,
|
|
158
|
+
});
|
|
159
|
+
};
|