@poe-platform/safe-js 0.1.742 → 0.1.744
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 +4 -3
- package/dist/safe-js/chunks/{chunk-F6CV74HU.js → chunk-3NFTBEZR.js} +2 -3
- package/dist/safe-js/chunks/{chunk-LMS5SSTN.js → chunk-5WP5IRMP.js} +437 -388
- package/dist/safe-js/chunks/{chunk-47JWFV2B.js → chunk-6UP3B5TB.js} +7 -8
- package/dist/safe-js/chunks/{chunk-24Z6PSCN.js → chunk-6ZVFR4HR.js} +1 -2
- package/dist/safe-js/chunks/{chunk-J3CUCOMP.js → chunk-AB6ERQE5.js} +14798 -14210
- package/dist/safe-js/chunks/{chunk-4YIDX44G.js → chunk-CQ52GEHY.js} +0 -1
- package/dist/safe-js/chunks/chunk-DHGJSEFX.js +0 -0
- package/dist/safe-js/chunks/{chunk-GVKXZW53.js → chunk-DIG26TEI.js} +0 -1
- package/dist/safe-js/chunks/{chunk-JCVARKWT.js → chunk-DIMBVKHT.js} +6 -7
- package/dist/safe-js/chunks/{chunk-UQPYTZOZ.js → chunk-JCHJGIQA.js} +0 -1
- package/dist/safe-js/chunks/{chunk-IRYOK5BR.js → chunk-L265M6OS.js} +2 -3
- package/dist/safe-js/chunks/{chunk-3ITVV2R6.js → chunk-L3MIVH3T.js} +1 -2
- package/dist/safe-js/chunks/{chunk-AUVGHYM5.js → chunk-LRINZRJA.js} +2 -3
- package/dist/safe-js/chunks/{chunk-UIUJHTWG.js → chunk-MKY3MQUB.js} +3 -4
- package/dist/safe-js/chunks/{chunk-YDVEVDVT.js → chunk-MLJ4BKDX.js} +102 -20
- package/dist/safe-js/chunks/{chunk-YUQFFRUF.js → chunk-MMN3IESA.js} +1 -2
- package/dist/safe-js/chunks/{chunk-WEGFNME4.js → chunk-O3S3JVWS.js} +1 -2
- package/dist/safe-js/chunks/{chunk-2GVBG23M.js → chunk-ONWFPHUI.js} +0 -1
- package/dist/safe-js/chunks/chunk-OQYVEDRN.js +66 -0
- package/dist/safe-js/chunks/{chunk-EMH7CXQM.js → chunk-POEMWNHD.js} +1 -2
- package/dist/safe-js/chunks/{chunk-G6WTEIJJ.js → chunk-X3YCE3ZH.js} +1 -2
- package/dist/safe-js/chunks/{chunk-WWETRQCF.js → chunk-YYF5R6ML.js} +3 -4
- package/dist/safe-js/chunks/{cli-runtime-3SOHLG5M.js → cli-runtime-BGB24HNE.js} +19 -20
- package/dist/safe-js/chunks/{dump-CSLHITIE.js → dump-M7CMVXW7.js} +5 -6
- package/dist/safe-js/chunks/harness-4CPQ7WKS.js +10 -0
- package/dist/safe-js/chunks/mcp-7SNWIP5H.js +11 -0
- package/dist/safe-js/chunks/migration-file-CPBVNMLD.js +14 -0
- package/dist/safe-js/chunks/restore-FLH6OC5F.js +13 -0
- package/dist/safe-js/chunks/run-KFAD7GTT.js +19 -0
- package/dist/safe-js/chunks/runtime-modules-D6NO4KJW.js +10 -0
- package/dist/safe-js/chunks/source-files-BSDM22Y2.js +9 -0
- package/dist/safe-js/cli.js +5 -6
- package/dist/safe-js/core.d.ts +1 -1
- package/dist/safe-js/core.js +14 -15
- package/dist/safe-js/extensions.d.ts +17 -0
- package/dist/safe-js/index.d.ts +2 -2
- package/dist/safe-js/index.js +22 -23
- package/dist/safe-js/interp/arguments.d.ts +2 -0
- package/dist/safe-js/interp/collection-properties.d.ts +2 -0
- package/dist/safe-js/interp/data-copy.d.ts +2 -0
- package/dist/safe-js/interp/host-bridge.d.ts +5 -0
- package/dist/safe-js/interp/host-capabilities.d.ts +5 -0
- package/dist/safe-js/interp/internal-symbols.d.ts +1 -0
- package/dist/safe-js/interp/interpreter.d.ts +3 -1
- package/dist/safe-js/interp/regex/compile-guard.d.ts +6 -4
- package/dist/safe-js/interp/template-cache.d.ts +5 -0
- package/dist/safe-js/interp/values.d.ts +11 -0
- package/dist/safe-js/modules/fs.d.ts +4 -3
- package/dist/safe-js/modules/fs.js +8 -9
- package/dist/safe-js/platform/context.d.ts +14 -0
- package/dist/safe-js/platform/node.d.ts +16 -0
- package/dist/safe-js/platform/types.d.ts +18 -0
- package/dist/safe-js/platform/workerd.d.ts +21 -0
- package/dist/safe-js/restore.d.ts +1 -1
- package/dist/safe-js/snapshot/validation.d.ts +2 -1
- package/package.json +5 -5
- package/dist/safe-js/chunks/chunk-24Z6PSCN.js.map +0 -7
- package/dist/safe-js/chunks/chunk-2GVBG23M.js.map +0 -7
- package/dist/safe-js/chunks/chunk-3ITVV2R6.js.map +0 -7
- package/dist/safe-js/chunks/chunk-47JWFV2B.js.map +0 -7
- package/dist/safe-js/chunks/chunk-4YIDX44G.js.map +0 -7
- package/dist/safe-js/chunks/chunk-AUVGHYM5.js.map +0 -7
- package/dist/safe-js/chunks/chunk-EMH7CXQM.js.map +0 -7
- package/dist/safe-js/chunks/chunk-F6CV74HU.js.map +0 -7
- package/dist/safe-js/chunks/chunk-G6WTEIJJ.js.map +0 -7
- package/dist/safe-js/chunks/chunk-GVKXZW53.js.map +0 -7
- package/dist/safe-js/chunks/chunk-IRYOK5BR.js.map +0 -7
- package/dist/safe-js/chunks/chunk-J3CUCOMP.js.map +0 -7
- package/dist/safe-js/chunks/chunk-JCVARKWT.js.map +0 -7
- package/dist/safe-js/chunks/chunk-LMS5SSTN.js.map +0 -7
- package/dist/safe-js/chunks/chunk-U7ZNMTSQ.js +0 -1
- package/dist/safe-js/chunks/chunk-U7ZNMTSQ.js.map +0 -7
- package/dist/safe-js/chunks/chunk-UIUJHTWG.js.map +0 -7
- package/dist/safe-js/chunks/chunk-UQPYTZOZ.js.map +0 -7
- package/dist/safe-js/chunks/chunk-V72WS373.js +0 -128
- package/dist/safe-js/chunks/chunk-V72WS373.js.map +0 -7
- package/dist/safe-js/chunks/chunk-WEGFNME4.js.map +0 -7
- package/dist/safe-js/chunks/chunk-WWETRQCF.js.map +0 -7
- package/dist/safe-js/chunks/chunk-YDVEVDVT.js.map +0 -7
- package/dist/safe-js/chunks/chunk-YUQFFRUF.js.map +0 -7
- package/dist/safe-js/chunks/cli-runtime-3SOHLG5M.js.map +0 -7
- package/dist/safe-js/chunks/dump-CSLHITIE.js.map +0 -7
- package/dist/safe-js/chunks/harness-QKPVLVOT.js +0 -11
- package/dist/safe-js/chunks/harness-QKPVLVOT.js.map +0 -7
- package/dist/safe-js/chunks/mcp-A4YKQCIS.js +0 -12
- package/dist/safe-js/chunks/mcp-A4YKQCIS.js.map +0 -7
- package/dist/safe-js/chunks/migration-file-QCZTVXEU.js +0 -15
- package/dist/safe-js/chunks/migration-file-QCZTVXEU.js.map +0 -7
- package/dist/safe-js/chunks/restore-22OGYS6N.js +0 -14
- package/dist/safe-js/chunks/restore-22OGYS6N.js.map +0 -7
- package/dist/safe-js/chunks/run-EMFOFJ22.js +0 -20
- package/dist/safe-js/chunks/run-EMFOFJ22.js.map +0 -7
- package/dist/safe-js/chunks/runtime-modules-QCVDLUVF.js +0 -11
- package/dist/safe-js/chunks/runtime-modules-QCVDLUVF.js.map +0 -7
- package/dist/safe-js/chunks/source-files-L3SGK63Z.js +0 -10
- package/dist/safe-js/chunks/source-files-L3SGK63Z.js.map +0 -7
- package/dist/safe-js/cli.js.map +0 -7
- package/dist/safe-js/core.js.map +0 -7
- package/dist/safe-js/index.js.map +0 -7
- package/dist/safe-js/modules/fs.js.map +0 -7
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fsCodec
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DIG26TEI.js";
|
|
4
4
|
import {
|
|
5
5
|
getOwnErrorCode
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ONWFPHUI.js";
|
|
7
7
|
import {
|
|
8
8
|
declareBudgetedHostOperation,
|
|
9
9
|
declareHostOperation
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AB6ERQE5.js";
|
|
11
11
|
import {
|
|
12
12
|
basename,
|
|
13
13
|
dirname,
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
relative,
|
|
16
16
|
resolve,
|
|
17
17
|
sep
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MMN3IESA.js";
|
|
19
19
|
import {
|
|
20
20
|
accessDeniedSystemError,
|
|
21
21
|
constants,
|
|
22
22
|
hostFs,
|
|
23
23
|
hostPlatform,
|
|
24
24
|
inspect
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-JCHJGIQA.js";
|
|
26
26
|
|
|
27
27
|
// packages/safe-js/src/modules/fs.ts
|
|
28
28
|
import { createFsBridge } from "@poe-platform/safe-fs/core";
|
|
@@ -356,7 +356,7 @@ function makeFsModule(options = {}) {
|
|
|
356
356
|
COPYFILE_EXCL: constants.COPYFILE_EXCL
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
|
-
return
|
|
359
|
+
return Object.assign(module, { default: module, promises: module });
|
|
360
360
|
}
|
|
361
361
|
function assertSupportedPlatform() {
|
|
362
362
|
if (hostPlatform !== "win32") {
|
|
@@ -746,4 +746,3 @@ export {
|
|
|
746
746
|
FS_OPTION_SURFACE,
|
|
747
747
|
makeFsModule
|
|
748
748
|
};
|
|
749
|
-
//# sourceMappingURL=chunk-JCVARKWT.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SnapshotNotReadyError,
|
|
3
3
|
serializeSafeJSSnapshot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AB6ERQE5.js";
|
|
5
5
|
import {
|
|
6
6
|
SandboxError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5WP5IRMP.js";
|
|
8
8
|
|
|
9
9
|
// packages/safe-js/src/snapshot/dump.ts
|
|
10
10
|
var RUN_DUMP_CONTROLLER = /* @__PURE__ */ Symbol("SafeJS.run-dump-controller");
|
|
@@ -195,4 +195,3 @@ export {
|
|
|
195
195
|
dumpCurrent,
|
|
196
196
|
serializeRunSnapshot
|
|
197
197
|
};
|
|
198
|
-
//# sourceMappingURL=chunk-IRYOK5BR.js.map
|
|
@@ -3548,7 +3548,7 @@ var SubscriptionManager = class {
|
|
|
3548
3548
|
}
|
|
3549
3549
|
}
|
|
3550
3550
|
);
|
|
3551
|
-
const timer = setTimeout(() => {
|
|
3551
|
+
const timer = this.layer.requestTimeoutMs === Infinity ? void 0 : setTimeout(() => {
|
|
3552
3552
|
reject(new Error("MCP subscription acknowledgement timed out"));
|
|
3553
3553
|
cancel();
|
|
3554
3554
|
}, this.layer.requestTimeoutMs);
|
|
@@ -9829,4 +9829,3 @@ CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for
|
|
|
9829
9829
|
the full license text.
|
|
9830
9830
|
|
|
9831
9831
|
*/
|
|
9832
|
-
//# sourceMappingURL=chunk-3ITVV2R6.js.map
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
HostCallJournal,
|
|
3
3
|
decodeReplayData,
|
|
4
4
|
validateSnapshotData
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AB6ERQE5.js";
|
|
6
6
|
import {
|
|
7
7
|
CompileScope,
|
|
8
8
|
SandboxError,
|
|
9
9
|
functionSources,
|
|
10
10
|
parse,
|
|
11
11
|
parseModule
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5WP5IRMP.js";
|
|
13
13
|
|
|
14
14
|
// packages/safe-js/src/parse/hash.ts
|
|
15
15
|
var FNV_OFFSET_BASIS = 2166136261;
|
|
@@ -219,4 +219,3 @@ export {
|
|
|
219
219
|
validateMigrationReconciliation,
|
|
220
220
|
validateSnapshotMigration
|
|
221
221
|
};
|
|
222
|
-
//# sourceMappingURL=chunk-AUVGHYM5.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
addBrokenPipeListener,
|
|
3
3
|
createBrokenPipeState,
|
|
4
4
|
createSafeOutputStream
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-X3YCE3ZH.js";
|
|
6
6
|
import {
|
|
7
7
|
SandboxError,
|
|
8
8
|
activateOtelSpan,
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
safeRecordException,
|
|
15
15
|
safeStartSpan,
|
|
16
16
|
splitSourceLines
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5WP5IRMP.js";
|
|
18
18
|
import {
|
|
19
19
|
AsyncLocalStorage
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-JCHJGIQA.js";
|
|
21
21
|
|
|
22
22
|
// packages/safe-js/src/error/format.ts
|
|
23
23
|
var DEFAULT_MAX_MESSAGE_LENGTH = 1e4;
|
|
@@ -2850,4 +2850,3 @@ export {
|
|
|
2850
2850
|
makeLogModule,
|
|
2851
2851
|
makeMetricModule
|
|
2852
2852
|
};
|
|
2853
|
-
//# sourceMappingURL=chunk-UIUJHTWG.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fsCodec
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DIG26TEI.js";
|
|
4
4
|
import {
|
|
5
5
|
getOwnErrorCode,
|
|
6
6
|
hasOwnErrorCode
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ONWFPHUI.js";
|
|
8
8
|
import {
|
|
9
9
|
restore
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OQYVEDRN.js";
|
|
11
11
|
import {
|
|
12
12
|
hashParsedAst,
|
|
13
13
|
hashSource
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LRINZRJA.js";
|
|
15
15
|
import {
|
|
16
16
|
attachDumpController,
|
|
17
17
|
createDumpController
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-L265M6OS.js";
|
|
19
19
|
import {
|
|
20
20
|
DUMP_FORMAT_VERSION,
|
|
21
21
|
EXECUTION_SEMANTICS,
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
decodeReplayData,
|
|
52
52
|
deepCopyFromSandbox,
|
|
53
53
|
deepCopyToSandbox,
|
|
54
|
+
defaultDataMeasurementOptions,
|
|
54
55
|
denyGuestStringCompilation,
|
|
55
56
|
encodeReplayData,
|
|
56
57
|
enterRunningState,
|
|
@@ -60,6 +61,7 @@ import {
|
|
|
60
61
|
getRealmGlobalObject,
|
|
61
62
|
guestProxyStates,
|
|
62
63
|
hostObjectGuestRoot,
|
|
64
|
+
hostObjectPrototypeRoot,
|
|
63
65
|
inMemoryRunSnapshots,
|
|
64
66
|
interpret,
|
|
65
67
|
invokeBuiltinClosure,
|
|
@@ -95,6 +97,7 @@ import {
|
|
|
95
97
|
sandboxGetProperty,
|
|
96
98
|
schedulesHostCallbacks,
|
|
97
99
|
serializeSafeJSSnapshot,
|
|
100
|
+
setHostObjectPrototype,
|
|
98
101
|
setSandboxPrototype,
|
|
99
102
|
suspendJob,
|
|
100
103
|
validateSnapshotData,
|
|
@@ -102,8 +105,9 @@ import {
|
|
|
102
105
|
withRunResources,
|
|
103
106
|
withSandboxPromiseRejectionTracker,
|
|
104
107
|
wrapCallerInjectedBindings,
|
|
105
|
-
wrapCancelableBindings
|
|
106
|
-
|
|
108
|
+
wrapCancelableBindings,
|
|
109
|
+
wrapHostConstructor
|
|
110
|
+
} from "./chunk-AB6ERQE5.js";
|
|
107
111
|
import {
|
|
108
112
|
Budget,
|
|
109
113
|
CompileScope,
|
|
@@ -118,26 +122,48 @@ import {
|
|
|
118
122
|
parseSourceModule,
|
|
119
123
|
replaceErrorStack,
|
|
120
124
|
safeAddEvent
|
|
121
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-5WP5IRMP.js";
|
|
122
126
|
import {
|
|
123
127
|
dirname
|
|
124
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-MMN3IESA.js";
|
|
125
129
|
import {
|
|
126
130
|
AsyncLocalStorage,
|
|
127
131
|
createHostCallbackContext,
|
|
128
132
|
hostFs,
|
|
129
133
|
types
|
|
130
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-JCHJGIQA.js";
|
|
131
135
|
|
|
132
136
|
// packages/safe-js/src/modules/source-graph.ts
|
|
133
137
|
var ambiguous = /* @__PURE__ */ Symbol("ambiguous module export");
|
|
134
138
|
var sourceRecords = /* @__PURE__ */ new WeakSet();
|
|
139
|
+
var retainedRecordValues = Function.prototype.call.bind(Map.prototype.values);
|
|
140
|
+
var retainedRecordNext = Function.prototype.call.bind(
|
|
141
|
+
Object.getPrototypeOf((/* @__PURE__ */ new Map()).values()).next
|
|
142
|
+
);
|
|
143
|
+
var retainedArrayPrototype = Array.prototype;
|
|
144
|
+
var setRetainedArrayPrototype = Object.setPrototypeOf;
|
|
135
145
|
var SourceModuleGraph = class {
|
|
136
146
|
constructor(options) {
|
|
137
147
|
this.options = options;
|
|
138
148
|
this.jobs = options.jobs ?? new SandboxJobQueue();
|
|
139
149
|
attachSourceLoader(options.modules, this.import.bind(this), { preserveImmutableNamespaces: true });
|
|
140
|
-
options.budget?.setRetainedValues(this, () =>
|
|
150
|
+
options.budget?.setRetainedValues(this, () => {
|
|
151
|
+
const records = setRetainedArrayPrototype([], null);
|
|
152
|
+
const iterator = retainedRecordValues(this.records);
|
|
153
|
+
for (let next = retainedRecordNext(iterator); !next.done; next = retainedRecordNext(iterator))
|
|
154
|
+
records[records.length] = next.value;
|
|
155
|
+
const roots = setRetainedArrayPrototype([], null);
|
|
156
|
+
for (let index = 0; index < records.length; index++) {
|
|
157
|
+
const record = records[index];
|
|
158
|
+
roots[roots.length] = record.id;
|
|
159
|
+
roots[roots.length] = record.source;
|
|
160
|
+
const requests = record.parsed.requests;
|
|
161
|
+
for (let request = 0; request < requests.length; request++)
|
|
162
|
+
roots[roots.length] = requests[request];
|
|
163
|
+
for (const root of record.scope.retainedDataRoots()) roots[roots.length] = root;
|
|
164
|
+
}
|
|
165
|
+
return setRetainedArrayPrototype(roots, retainedArrayPrototype);
|
|
166
|
+
});
|
|
141
167
|
}
|
|
142
168
|
options;
|
|
143
169
|
stats = { nodeVisits: 0 };
|
|
@@ -607,7 +633,7 @@ function createReplayableRandom(options = {}) {
|
|
|
607
633
|
}
|
|
608
634
|
|
|
609
635
|
// packages/safe-js/src/realm.ts
|
|
610
|
-
var
|
|
636
|
+
var retainedArrayPrototype2 = Array.prototype;
|
|
611
637
|
var nativeRetainedArrayPrototype = Object.setPrototypeOf;
|
|
612
638
|
var nativeRetainedArrayAppend = Function.prototype.call.bind(Array.prototype.push);
|
|
613
639
|
var freezeSourceReference = Object.freeze;
|
|
@@ -785,11 +811,13 @@ var RealmState = class {
|
|
|
785
811
|
for (const object of this.hostObjects) {
|
|
786
812
|
const root = hostObjectGuestRoot(object);
|
|
787
813
|
if (root !== void 0) nativeRetainedArrayAppend(roots, root);
|
|
814
|
+
const prototype = hostObjectPrototypeRoot(object);
|
|
815
|
+
if (prototype !== void 0) nativeRetainedArrayAppend(roots, prototype);
|
|
788
816
|
}
|
|
789
817
|
for (const closure of this.callbacks.values()) nativeRetainedArrayAppend(roots, closure);
|
|
790
818
|
for (const pending of this.pendingCallbacks) nativeRetainedArrayAppend(roots, pending.closure);
|
|
791
819
|
for (const reference of this.guestReferences.values()) nativeRetainedArrayAppend(roots, reference);
|
|
792
|
-
return nativeRetainedArrayPrototype(roots,
|
|
820
|
+
return nativeRetainedArrayPrototype(roots, retainedArrayPrototype2);
|
|
793
821
|
};
|
|
794
822
|
captureArguments = (operation, args, copy) => {
|
|
795
823
|
const queued = schedulesHostCallbacks(operation);
|
|
@@ -844,15 +872,54 @@ var RealmState = class {
|
|
|
844
872
|
throw new TypeError(
|
|
845
873
|
"Live buffer references require a fixed, attached, plain ArrayBuffer without metadata."
|
|
846
874
|
);
|
|
847
|
-
let reference;
|
|
848
875
|
try {
|
|
849
876
|
this.budget.allocateArrayLength(arrayBufferLength(buffer));
|
|
877
|
+
return this.retainGuestValue(buffer);
|
|
878
|
+
} catch (error) {
|
|
879
|
+
if (error instanceof SandboxError) this.poison(error);
|
|
880
|
+
throw error;
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
createHostConstructor = (name, construct, options) => {
|
|
884
|
+
this.assertOpen();
|
|
885
|
+
if (typeof name !== "string" || name.length === 0 || name.length > 1024)
|
|
886
|
+
throw new TypeError("Host constructor names require 1 to 1024 code units.");
|
|
887
|
+
if (typeof construct !== "function" || types.isProxy(construct) || types.isAsyncFunction(construct) || types.isGeneratorFunction(construct))
|
|
888
|
+
throw new TypeError("Host constructors require a synchronous non-proxy callback.");
|
|
889
|
+
const definition = readDataRecord(options ?? {}, "Host constructor options");
|
|
890
|
+
if (Object.keys(definition).some((key) => !["parent", "hasInstance", "constants"].includes(key)))
|
|
891
|
+
throw new TypeError("Unknown host constructor option.");
|
|
892
|
+
const hasInstance = definition.hasInstance;
|
|
893
|
+
if (hasInstance !== void 0 && (typeof hasInstance !== "function" || types.isProxy(hasInstance) || types.isAsyncFunction(hasInstance) || types.isGeneratorFunction(hasInstance)))
|
|
894
|
+
throw new TypeError("Host instance checks require a synchronous non-proxy callback.");
|
|
895
|
+
const constants = readDataRecord(definition.constants ?? {}, "Host constructor constants");
|
|
896
|
+
for (const [key, value] of Object.entries(constants)) {
|
|
897
|
+
if (["prototype", "constructor", "name", "length"].includes(key) || typeof value !== "number" || !Number.isFinite(value))
|
|
898
|
+
throw new TypeError("Host constructor constants require unreserved names and finite numbers.");
|
|
899
|
+
}
|
|
900
|
+
const parent = definition.parent === void 0 ? void 0 : readGuestReference(definition.parent, this);
|
|
901
|
+
try {
|
|
902
|
+
this.budget.allocateString(name);
|
|
903
|
+
for (const key of Object.keys(constants)) this.budget.allocateString(key);
|
|
904
|
+
return this.retainGuestValue(wrapHostConstructor(name, construct, this.bridgeOptions(), {
|
|
905
|
+
parent,
|
|
906
|
+
hasInstance,
|
|
907
|
+
constants
|
|
908
|
+
}));
|
|
909
|
+
} catch (error) {
|
|
910
|
+
if (error instanceof SandboxError) this.poison(error);
|
|
911
|
+
throw error;
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
retainGuestValue(value) {
|
|
915
|
+
let reference;
|
|
916
|
+
try {
|
|
850
917
|
this.checkCollection(
|
|
851
918
|
this.guestReferences.size + 1,
|
|
852
919
|
this.limits.guestReferences,
|
|
853
920
|
"guest reference"
|
|
854
921
|
);
|
|
855
|
-
const root = [
|
|
922
|
+
const root = [value];
|
|
856
923
|
reference = createGuestReference(root, this, this.assertOpen);
|
|
857
924
|
this.guestReferences.set(reference, root);
|
|
858
925
|
this.budget.reconcileDataUsage(
|
|
@@ -871,7 +938,7 @@ var RealmState = class {
|
|
|
871
938
|
if (error instanceof SandboxError) this.poison(error);
|
|
872
939
|
throw error;
|
|
873
940
|
}
|
|
874
|
-
}
|
|
941
|
+
}
|
|
875
942
|
releaseGuestReference = (reference) => {
|
|
876
943
|
readGuestReference(reference, this);
|
|
877
944
|
revokeGuestReference(reference, this);
|
|
@@ -1075,6 +1142,20 @@ var RealmState = class {
|
|
|
1075
1142
|
}
|
|
1076
1143
|
return object;
|
|
1077
1144
|
};
|
|
1145
|
+
setHostObjectPrototype = (value, prototype, assertActive) => {
|
|
1146
|
+
this.assertOpen();
|
|
1147
|
+
try {
|
|
1148
|
+
setHostObjectPrototype(value, prototype, this, assertActive);
|
|
1149
|
+
reconcileCompiledValues(
|
|
1150
|
+
this.budget,
|
|
1151
|
+
[...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()],
|
|
1152
|
+
this.compilation
|
|
1153
|
+
);
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
if (error instanceof SandboxError) this.poison(error);
|
|
1156
|
+
throw error;
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1078
1159
|
wrapCallback = (closure, owned = false, queued = false) => {
|
|
1079
1160
|
this.assertOpen();
|
|
1080
1161
|
const cache = queued ? this.queuedCallbackCache : this.callbackCache;
|
|
@@ -1239,6 +1320,8 @@ var RealmState = class {
|
|
|
1239
1320
|
},
|
|
1240
1321
|
chargeWork: this.chargeWork,
|
|
1241
1322
|
createHostObject: this.createHostObject,
|
|
1323
|
+
setHostObjectPrototype: this.setHostObjectPrototype,
|
|
1324
|
+
createHostConstructor: this.createHostConstructor,
|
|
1242
1325
|
createArrayBufferReference: (buffer) => {
|
|
1243
1326
|
this.assertOpen();
|
|
1244
1327
|
if (!extension.manifest.capabilities?.includes("array-buffer:share"))
|
|
@@ -2236,7 +2319,7 @@ function run(source, options = {}) {
|
|
|
2236
2319
|
throw new TypeError("Source resolution requires sourceType: 'module'.");
|
|
2237
2320
|
if (options.sourceRoot !== void 0) {
|
|
2238
2321
|
if (options.sourceResolver !== void 0) throw new TypeError("Specify sourceRoot or sourceResolver, not both.");
|
|
2239
|
-
const { createRootedSourceResolver } = await import("./source-files-
|
|
2322
|
+
const { createRootedSourceResolver } = await import("./source-files-BSDM22Y2.js");
|
|
2240
2323
|
const { sourceRoot, ...resolved } = options;
|
|
2241
2324
|
const sourceResolver = await createRootedSourceResolver(sourceRoot);
|
|
2242
2325
|
return runWithExtensions(source, { ...resolved, filename: await sourceResolver.entryId(options.filename), sourceResolver }, jobs);
|
|
@@ -2410,7 +2493,7 @@ function run(source, options = {}) {
|
|
|
2410
2493
|
moduleOptions.prepareNamespace = (namespace, name) => {
|
|
2411
2494
|
const prepared = initialInputs.prepareNamespace(namespace, name);
|
|
2412
2495
|
const included = /* @__PURE__ */ new Set();
|
|
2413
|
-
const size = measureSandboxData([prepared], { ignoreClosureCaptures: true, compileTickets: included });
|
|
2496
|
+
const size = measureSandboxData([prepared], { ...defaultDataMeasurementOptions, ignoreClosureCaptures: true, compileTickets: included });
|
|
2414
2497
|
budget.reconcileCompileData(moduleInputSize + size, included, included, moduleInputOwner);
|
|
2415
2498
|
moduleInputSize += size;
|
|
2416
2499
|
return prepared;
|
|
@@ -2434,7 +2517,7 @@ function run(source, options = {}) {
|
|
|
2434
2517
|
...initialInputs.values.entryPointArgs ?? [],
|
|
2435
2518
|
initialInputs.values.importMeta
|
|
2436
2519
|
],
|
|
2437
|
-
{ ignoreClosureCaptures: true, compileTickets: inputTickets }
|
|
2520
|
+
{ ...defaultDataMeasurementOptions, ignoreClosureCaptures: true, compileTickets: inputTickets }
|
|
2438
2521
|
);
|
|
2439
2522
|
budget.reconcileCompileData(inputSize, inputTickets, inputTickets, initialInputs);
|
|
2440
2523
|
const entryPointArgs = initialInputs.values.entryPointArgs;
|
|
@@ -2839,4 +2922,3 @@ export {
|
|
|
2839
2922
|
UnhandledRejectionError,
|
|
2840
2923
|
run
|
|
2841
2924
|
};
|
|
2842
|
-
//# sourceMappingURL=chunk-YDVEVDVT.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostCwd
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JCHJGIQA.js";
|
|
4
4
|
|
|
5
5
|
// packages/safe-js/src/modules/paths.ts
|
|
6
6
|
import { basename, dirname, extname, isAbsolutePath, joinPath, relativePath, resolvePath } from "@poe-platform/safe-fs/core";
|
|
@@ -23,4 +23,3 @@ export {
|
|
|
23
23
|
relative,
|
|
24
24
|
paths_default
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-YUQFFRUF.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSandboxClosure
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AB6ERQE5.js";
|
|
4
4
|
|
|
5
5
|
// packages/safe-js/src/lint/runtime-modules.ts
|
|
6
6
|
var AsyncFunction = (async () => void 0).constructor;
|
|
@@ -34,4 +34,3 @@ function isAsyncRuntimeExport(value) {
|
|
|
34
34
|
export {
|
|
35
35
|
createLintModulesFromRuntimeRegistry
|
|
36
36
|
};
|
|
37
|
-
//# sourceMappingURL=chunk-WEGFNME4.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hashParsedAst,
|
|
3
|
+
hashSource,
|
|
4
|
+
validateSnapshotMigration
|
|
5
|
+
} from "./chunk-LRINZRJA.js";
|
|
6
|
+
import {
|
|
7
|
+
SnapshotValidationError,
|
|
8
|
+
assertSnapshotInactive,
|
|
9
|
+
inMemoryRunSnapshots,
|
|
10
|
+
serializeSafeJSSnapshot,
|
|
11
|
+
validateDumpEnvelope,
|
|
12
|
+
validateGuestHeapSource,
|
|
13
|
+
validateRuntimeSnapshotDescriptors
|
|
14
|
+
} from "./chunk-AB6ERQE5.js";
|
|
15
|
+
import {
|
|
16
|
+
SandboxError,
|
|
17
|
+
parseExecutableModule,
|
|
18
|
+
parseModule,
|
|
19
|
+
replaceErrorStack
|
|
20
|
+
} from "./chunk-5WP5IRMP.js";
|
|
21
|
+
|
|
22
|
+
// packages/safe-js/src/restore.ts
|
|
23
|
+
var SnapshotMismatchError = class extends Error {
|
|
24
|
+
actualHash;
|
|
25
|
+
expectedHash;
|
|
26
|
+
constructor(expectedHash, actualHash) {
|
|
27
|
+
super(
|
|
28
|
+
`source changed since snapshot was taken (hash ${expectedHash} expected, got ${actualHash}); pass --reset to discard`
|
|
29
|
+
);
|
|
30
|
+
this.name = "SnapshotMismatchError";
|
|
31
|
+
this.actualHash = actualHash;
|
|
32
|
+
this.expectedHash = expectedHash;
|
|
33
|
+
replaceErrorStack(this);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function restore(snapshot, options, owner) {
|
|
37
|
+
assertSnapshotInactive(snapshot);
|
|
38
|
+
try {
|
|
39
|
+
validateDumpEnvelope(snapshot, { resume: true });
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (!(error instanceof SnapshotValidationError) || error.code !== "invalidState" || error.path === "$.replayError" || !inMemoryRunSnapshots.has(snapshot)) throw error;
|
|
42
|
+
validateRuntimeSnapshotDescriptors(snapshot);
|
|
43
|
+
snapshot = JSON.parse(serializeSafeJSSnapshot(snapshot));
|
|
44
|
+
validateDumpEnvelope(snapshot, { resume: true });
|
|
45
|
+
}
|
|
46
|
+
validateSnapshotMigration(snapshot.migration, snapshot.sourceHash, owner);
|
|
47
|
+
const includeFunctionSource = snapshot.executionSemantics !== "jobs-v6" && snapshot.executionSemantics !== "jobs-v7";
|
|
48
|
+
const currentSourceHash = options.importSpecifiers === void 0 ? hashSource(options.source, owner, includeFunctionSource) : hashParsedAst(parseExecutableModule(options.source, "<input>", owner, options.importSpecifiers), includeFunctionSource);
|
|
49
|
+
if (snapshot.sourceHash !== currentSourceHash) {
|
|
50
|
+
throw new SnapshotMismatchError(snapshot.sourceHash, currentSourceHash);
|
|
51
|
+
}
|
|
52
|
+
if (snapshot.heap !== void 0 && typeof snapshot.heap === "object" && snapshot.heap !== null) {
|
|
53
|
+
try {
|
|
54
|
+
validateGuestHeapSource(snapshot.heap, options.importSpecifiers === void 0 ? parseModule(options.source, "<input>", owner) : parseExecutableModule(options.source, "<input>", owner, options.importSpecifiers), owner);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof SnapshotValidationError || error instanceof SandboxError) throw error;
|
|
57
|
+
throw new SnapshotValidationError("invalidValue", "$.heap", String(error));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return snapshot;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
SnapshotMismatchError,
|
|
65
|
+
restore
|
|
66
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
numericTypedArrayConstructors,
|
|
9
9
|
parseModule,
|
|
10
10
|
tokenize
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5WP5IRMP.js";
|
|
12
12
|
|
|
13
13
|
// packages/safe-js/src/lint/rules/AS001.ts
|
|
14
14
|
function AS001(source, options = {}) {
|
|
@@ -11177,4 +11177,3 @@ function hasOnlyRegexLiteralDiagnostics(diagnostics) {
|
|
|
11177
11177
|
export {
|
|
11178
11178
|
lint
|
|
11179
11179
|
};
|
|
11180
|
-
//# sourceMappingURL=chunk-EMH7CXQM.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hasOwnErrorCode
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ONWFPHUI.js";
|
|
4
4
|
|
|
5
5
|
// packages/safe-js/src/output-stream.ts
|
|
6
6
|
function createBrokenPipeState() {
|
|
@@ -57,4 +57,3 @@ export {
|
|
|
57
57
|
withBrokenPipeGuard,
|
|
58
58
|
addBrokenPipeListener
|
|
59
59
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-G6WTEIJJ.js.map
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
McpError,
|
|
3
3
|
connectMcpTransport,
|
|
4
4
|
normalizeMcpOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-L3MIVH3T.js";
|
|
6
6
|
import {
|
|
7
7
|
declareHostOperation,
|
|
8
8
|
runResources
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AB6ERQE5.js";
|
|
10
10
|
import {
|
|
11
11
|
hostErrorData
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5WP5IRMP.js";
|
|
13
13
|
|
|
14
14
|
// packages/safe-js/src/modules/mcp.ts
|
|
15
15
|
var DEFAULT_TOOL_BATCH_CONCURRENCY = 4;
|
|
@@ -402,4 +402,3 @@ function isPlainObjectRecord(value) {
|
|
|
402
402
|
export {
|
|
403
403
|
makeMcpModule
|
|
404
404
|
};
|
|
405
|
-
//# sourceMappingURL=chunk-WWETRQCF.js.map
|
|
@@ -12,45 +12,45 @@ import {
|
|
|
12
12
|
parseFsConfig,
|
|
13
13
|
resolveFsConfig,
|
|
14
14
|
splitFrontmatter
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MKY3MQUB.js";
|
|
16
16
|
import {
|
|
17
17
|
parseMcpConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-L3MIVH3T.js";
|
|
19
19
|
import {
|
|
20
20
|
lint
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-POEMWNHD.js";
|
|
22
22
|
import {
|
|
23
23
|
createBrokenPipeState,
|
|
24
24
|
createSafeOutputStream,
|
|
25
25
|
withBrokenPipeGuard
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-X3YCE3ZH.js";
|
|
27
27
|
import {
|
|
28
28
|
createRootedSourceResolver
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
29
|
+
} from "./chunk-3NFTBEZR.js";
|
|
30
|
+
import "./chunk-DHGJSEFX.js";
|
|
31
31
|
import {
|
|
32
32
|
fsCodec
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-DIG26TEI.js";
|
|
34
34
|
import {
|
|
35
35
|
hasOwnErrorCode
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ONWFPHUI.js";
|
|
37
37
|
import {
|
|
38
38
|
Budget,
|
|
39
39
|
SandboxError,
|
|
40
40
|
parseModule,
|
|
41
41
|
parseSourceModule,
|
|
42
42
|
replaceErrorStack
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-5WP5IRMP.js";
|
|
44
44
|
import {
|
|
45
45
|
dirname,
|
|
46
46
|
extname,
|
|
47
47
|
paths_default
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-MMN3IESA.js";
|
|
49
49
|
import {
|
|
50
50
|
formatWithOptions,
|
|
51
51
|
hostFs
|
|
52
|
-
} from "./chunk-
|
|
53
|
-
import "./chunk-
|
|
52
|
+
} from "./chunk-JCHJGIQA.js";
|
|
53
|
+
import "./chunk-CQ52GEHY.js";
|
|
54
54
|
|
|
55
55
|
// packages/safe-js/src/cli-runtime.ts
|
|
56
56
|
import { createFsBridge } from "@poe-platform/safe-fs/core";
|
|
@@ -72,7 +72,7 @@ async function runCli(argv, options, usage) {
|
|
|
72
72
|
async () => {
|
|
73
73
|
try {
|
|
74
74
|
if (argv[0] === "migrate") {
|
|
75
|
-
const { migrateSnapshotFile } = await import("./migration-file-
|
|
75
|
+
const { migrateSnapshotFile } = await import("./migration-file-CPBVNMLD.js");
|
|
76
76
|
const result = await migrateSnapshotFile({
|
|
77
77
|
...parseMigrationArgs(argv.slice(1)),
|
|
78
78
|
cwd: options.cwd ?? readCurrentWorkingDirectory(),
|
|
@@ -291,12 +291,12 @@ async function assertHarnessFile(input) {
|
|
|
291
291
|
}
|
|
292
292
|
async function runScriptFile(filepath, parsed, options) {
|
|
293
293
|
const [{ run }, { restore }, { dump, dumpCurrent }, { createLintModulesFromRuntimeRegistry }, { makeFsModule }, { makeMcpModule }] = await Promise.all([
|
|
294
|
-
import("./run-
|
|
295
|
-
import("./restore-
|
|
296
|
-
import("./dump-
|
|
297
|
-
import("./runtime-modules-
|
|
294
|
+
import("./run-KFAD7GTT.js"),
|
|
295
|
+
import("./restore-FLH6OC5F.js"),
|
|
296
|
+
import("./dump-M7CMVXW7.js"),
|
|
297
|
+
import("./runtime-modules-D6NO4KJW.js"),
|
|
298
298
|
import("../modules/fs.js"),
|
|
299
|
-
import("./mcp-
|
|
299
|
+
import("./mcp-7SNWIP5H.js")
|
|
300
300
|
]);
|
|
301
301
|
const loaded = loadExecutableSource(filepath, await options.readFile(filepath, "utf8"));
|
|
302
302
|
const meta = {
|
|
@@ -534,7 +534,7 @@ async function createRuntime(frontmatter, meta, options) {
|
|
|
534
534
|
};
|
|
535
535
|
}
|
|
536
536
|
const [{ makeHarnessModule }, { makeFsModule }] = await Promise.all([
|
|
537
|
-
import("./harness-
|
|
537
|
+
import("./harness-4CPQ7WKS.js"),
|
|
538
538
|
import("../modules/fs.js")
|
|
539
539
|
]);
|
|
540
540
|
const state = {
|
|
@@ -725,4 +725,3 @@ export {
|
|
|
725
725
|
exitCodeForError,
|
|
726
726
|
runCli
|
|
727
727
|
};
|
|
728
|
-
//# sourceMappingURL=cli-runtime-3SOHLG5M.js.map
|