@poe-platform/safe-js 0.1.734 → 0.1.735
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 +1 -1
- package/dist/safe-js/chunks/{chunk-MDIWQFYU.js → chunk-5X7TFA3E.js} +27 -6
- package/dist/safe-js/chunks/{chunk-MDIWQFYU.js.map → chunk-5X7TFA3E.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-WS2FJBH6.js → chunk-6G3J4CW7.js} +2 -2
- package/dist/safe-js/chunks/{chunk-K4T4EBED.js → chunk-7R3KDASZ.js} +2 -2
- package/dist/safe-js/chunks/{chunk-O4IDRXW7.js → chunk-JSXHEWUQ.js} +3 -3
- package/dist/safe-js/chunks/{chunk-P64CQIUA.js → chunk-MTQWXXXX.js} +2 -2
- package/dist/safe-js/chunks/{chunk-X3CKAZQ4.js → chunk-PPIYB46P.js} +2 -2
- package/dist/safe-js/chunks/{chunk-PSVV3IG2.js → chunk-SHVW6TCE.js} +2 -2
- package/dist/safe-js/chunks/{chunk-E4XLBT7R.js → chunk-U33B2YAT.js} +2 -2
- package/dist/safe-js/chunks/{chunk-GNEORAQI.js → chunk-VTIHUINQ.js} +21 -11
- package/dist/safe-js/chunks/chunk-VTIHUINQ.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-W4SWUHCQ.js → chunk-WGHFQSF5.js} +3 -3
- package/dist/safe-js/chunks/{cli-runtime-ZSOTNIVC.js → cli-runtime-ZUBPVST5.js} +8 -8
- package/dist/safe-js/chunks/{dump-RGRC3CG3.js → dump-YCUYBGSZ.js} +3 -3
- package/dist/safe-js/chunks/{harness-UMOMFXDT.js → harness-BSIQQFYL.js} +3 -3
- package/dist/safe-js/chunks/{mcp-2Z4XWHKW.js → mcp-JBFGRP6T.js} +3 -3
- package/dist/safe-js/chunks/{migration-file-KRXQYI3Q.js → migration-file-ISSKTEAS.js} +4 -4
- package/dist/safe-js/chunks/{restore-GEO7VN2R.js → restore-NHLS3LCF.js} +4 -4
- package/dist/safe-js/chunks/{run-ZSFX66RN.js → run-IBQKVJTY.js} +6 -6
- package/dist/safe-js/chunks/{runtime-modules-A3U2DKFL.js → runtime-modules-AFF6IQR2.js} +3 -3
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +5 -5
- package/dist/safe-js/index.js +10 -10
- package/dist/safe-js/interp/host-bridge.d.ts +3 -1
- package/dist/safe-js/modules/fs.js +2 -2
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-GNEORAQI.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-WS2FJBH6.js.map → chunk-6G3J4CW7.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-K4T4EBED.js.map → chunk-7R3KDASZ.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-O4IDRXW7.js.map → chunk-JSXHEWUQ.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-P64CQIUA.js.map → chunk-MTQWXXXX.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-X3CKAZQ4.js.map → chunk-PPIYB46P.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-PSVV3IG2.js.map → chunk-SHVW6TCE.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-E4XLBT7R.js.map → chunk-U33B2YAT.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-W4SWUHCQ.js.map → chunk-WGHFQSF5.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-ZSOTNIVC.js.map → cli-runtime-ZUBPVST5.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-RGRC3CG3.js.map → dump-YCUYBGSZ.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-UMOMFXDT.js.map → harness-BSIQQFYL.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-2Z4XWHKW.js.map → mcp-JBFGRP6T.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-KRXQYI3Q.js.map → migration-file-ISSKTEAS.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-GEO7VN2R.js.map → restore-NHLS3LCF.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-ZSFX66RN.js.map → run-IBQKVJTY.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-A3U2DKFL.js.map → runtime-modules-AFF6IQR2.js.map} +0 -0
package/README.md
CHANGED
|
@@ -566,7 +566,7 @@ functions can still be retained by custom Promise constructors.
|
|
|
566
566
|
- `restore(snapshot, { source })` validates state for compatible source; pass it as `run`'s `snapshot` option. It does not run the program.
|
|
567
567
|
- `new FileSnapshotBackend(path, { writeMaxAttempts?, writeRetryDelayMs? })` defaults to 3 write attempts and a 100 ms retry delay.
|
|
568
568
|
- `createReplayableRandom({ seed?, snapshot? })` supplies `next`, `seed`, `snapshot`, and `restore` for reproducible random sequences. Unseeded generators use Web Crypto entropy; unseeded `makeTimeModule().uuid()` uses `globalThis.crypto.randomUUID()`.
|
|
569
|
-
- `declareHostOperation(fn, policy, { onReplay?, awaitResult? })` declares `re-issue` or `read-side-effect` recovery policy. `registerPendingHostCallPolicy({ moduleId, operation, policy })` registers it by name. Only mark operations re-issuable when repeating them is acceptable; a declaration does not implement deduplication or external recovery. With `awaitResult: true`, an asynchronous host operation completes before the guest call returns its copied value or throws its error, without exposing a guest Promise. This is an explicit host capability; the host event loop still runs, and cancellation, value budgets, and host-call recovery still apply.
|
|
569
|
+
- `declareHostOperation(fn, policy, { onReplay?, awaitResult?, callbackScheduling? })` declares `re-issue` or `read-side-effect` recovery policy. `registerPendingHostCallPolicy({ moduleId, operation, policy })` registers it by name. Only mark operations re-issuable when repeating them is acceptable; a declaration does not implement deduplication or external recovery. With `awaitResult: true`, an asynchronous host operation completes before the guest call returns its copied value or throws its error, without exposing a guest Promise. This is an explicit host capability; the host event loop still runs, and cancellation, value budgets, and host-call recovery still apply. Use `callbackScheduling: "after-prefix"` for event-style APIs whose callbacks must wait for the current guest synchronous work to finish or explicitly await. Callbacks can then await other callbacks without blocking their admission. The default keeps inline callback behavior; `after-prefix` cannot be combined with `awaitResult: true`.
|
|
570
570
|
- `inspectSnapshotMigration(snapshot, { source })` inspects outstanding work. `migrateSnapshot(snapshot, { source, targetSource, state, reconciliation })` creates a continuation checkpoint. Reconciliation supplies `checkpointDigest`, `quiescent`, and `calls`; each call has `callId` and disposition `not-performed`, `fulfilled` with `value`, or `rejected` with `reason`.
|
|
571
571
|
- `migrateSnapshotFile(options)` accepts `snapshotPath`, `sourcePath`, `targetSourcePath`, `planPath`, `outputPath`, `inspect`, `dryRun`, and `cwd`. Inspect mode needs the checkpoint and original source; migration also needs the target, plan, and new output path. See [continuation migration](MIGRATION.md) before changing a checkpointed program.
|
|
572
572
|
|
|
@@ -21924,6 +21924,10 @@ var hostErrorMetadata = {
|
|
|
21924
21924
|
syscall: "string"
|
|
21925
21925
|
};
|
|
21926
21926
|
var awaitedHostOperations = /* @__PURE__ */ new WeakSet();
|
|
21927
|
+
var scheduledCallbackOperations = /* @__PURE__ */ new WeakSet();
|
|
21928
|
+
function schedulesHostCallbacks(operation) {
|
|
21929
|
+
return scheduledCallbackOperations.has(operation);
|
|
21930
|
+
}
|
|
21927
21931
|
var budgetedHostOperations = /* @__PURE__ */ new WeakMap();
|
|
21928
21932
|
function declareBudgetedHostOperation(operation, invoke) {
|
|
21929
21933
|
budgetedHostOperations.set(operation, invoke);
|
|
@@ -21931,7 +21935,11 @@ function declareBudgetedHostOperation(operation, invoke) {
|
|
|
21931
21935
|
var hostOperationPolicies = /* @__PURE__ */ new WeakMap();
|
|
21932
21936
|
var hostOperationReplayHandlers = /* @__PURE__ */ new WeakMap();
|
|
21933
21937
|
function declareHostOperation(operation, policy, options = {}) {
|
|
21938
|
+
if (options.callbackScheduling !== void 0 && options.callbackScheduling !== "after-prefix") throw new TypeError("Host callbackScheduling must be after-prefix.");
|
|
21939
|
+
if (options.callbackScheduling === "after-prefix" && options.awaitResult === true) throw new TypeError("Queued callbacks cannot be combined with awaitResult.");
|
|
21934
21940
|
hostOperationPolicies.set(operation, policy);
|
|
21941
|
+
if (options.callbackScheduling === "after-prefix") scheduledCallbackOperations.add(operation);
|
|
21942
|
+
else scheduledCallbackOperations.delete(operation);
|
|
21935
21943
|
if (options.awaitResult === true) awaitedHostOperations.add(operation);
|
|
21936
21944
|
else awaitedHostOperations.delete(operation);
|
|
21937
21945
|
if (options.onReplay !== void 0) hostOperationReplayHandlers.set(operation, options.onReplay);
|
|
@@ -21970,6 +21978,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
21970
21978
|
const bindingName = typeof nativeName === "string" && nativeName.length > 0 ? nativeName : name;
|
|
21971
21979
|
const callable = value;
|
|
21972
21980
|
const awaitResult = awaitedHostOperations.has(value) || options.realm?.awaitResult(callable) === true;
|
|
21981
|
+
if (awaitResult && schedulesHostCallbacks(callable)) throw new TypeError("Queued callbacks cannot be combined with awaitResult or nestedOperation.");
|
|
21973
21982
|
return createSandboxClosure({
|
|
21974
21983
|
...isAsyncFunction(callable) && !awaitResult ? { async: true } : {},
|
|
21975
21984
|
cancellationSignal: options.signal,
|
|
@@ -21981,6 +21990,7 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
21981
21990
|
if (options.signal?.aborted) throw readAbortReason2(options.signal);
|
|
21982
21991
|
const stackFrames = context?.stack ?? [];
|
|
21983
21992
|
const callbacks = {
|
|
21993
|
+
...schedulesHostCallbacks(callable) ? { schedule: captureJobScheduler() } : {},
|
|
21984
21994
|
journal: options.hostCalls,
|
|
21985
21995
|
entries: /* @__PURE__ */ new Map(),
|
|
21986
21996
|
hostFunctions: /* @__PURE__ */ new Map(),
|
|
@@ -22002,7 +22012,8 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
22002
22012
|
stackFrames,
|
|
22003
22013
|
options.budget,
|
|
22004
22014
|
operationLease.owner,
|
|
22005
|
-
callbacks
|
|
22015
|
+
callbacks,
|
|
22016
|
+
options.signal
|
|
22006
22017
|
))
|
|
22007
22018
|
});
|
|
22008
22019
|
const captured = options.realm?.captureArguments(callable, args, copyArguments);
|
|
@@ -22427,18 +22438,19 @@ function copyHostErrorMetadata(error, reason, budget, chargeBudget) {
|
|
|
22427
22438
|
resumeChecks?.();
|
|
22428
22439
|
}
|
|
22429
22440
|
}
|
|
22430
|
-
function wrapSandboxClosureForHost(closure, stackFrames, budget, compileOwner, callbacks) {
|
|
22441
|
+
function wrapSandboxClosureForHost(closure, stackFrames, budget, compileOwner, callbacks, signal) {
|
|
22431
22442
|
const existing = callbacks?.seen.get(closure);
|
|
22432
22443
|
if (existing !== void 0) return existing;
|
|
22433
22444
|
const id = (callbacks?.entries.size ?? 0) + 1;
|
|
22434
|
-
const
|
|
22445
|
+
const invokeNow = async (sandboxArgs, token, receiver) => {
|
|
22435
22446
|
const operation = budget.acquireCompileOwner(false, compileOwner);
|
|
22436
22447
|
const compilation = new CompileScope(operation.owner);
|
|
22437
22448
|
let leaveRunning;
|
|
22438
22449
|
let leaveCall;
|
|
22439
|
-
const wrapClosure = (nestedClosure) => wrapSandboxClosureForHost(nestedClosure, stackFrames, budget, compileOwner, callbacks);
|
|
22450
|
+
const wrapClosure = (nestedClosure) => wrapSandboxClosureForHost(nestedClosure, stackFrames, budget, compileOwner, callbacks, signal);
|
|
22440
22451
|
const onSharedBuffer = callbacks?.journal?.markSharedCallbackExport.bind(callbacks.journal);
|
|
22441
22452
|
try {
|
|
22453
|
+
signal?.throwIfAborted();
|
|
22442
22454
|
leaveRunning = enterRunningState(closure);
|
|
22443
22455
|
leaveCall = budget.enterCall();
|
|
22444
22456
|
let result;
|
|
@@ -22454,6 +22466,7 @@ function wrapSandboxClosureForHost(closure, stackFrames, budget, compileOwner, c
|
|
|
22454
22466
|
invokeClosure: (target, values, receiver2, construct, newTarget) => invokeBuiltinClosure(target, values, budget, callerContext, receiver2, construct, newTarget)
|
|
22455
22467
|
};
|
|
22456
22468
|
result = guestProxyStates.has(closure) ? await callGuestProxy(closure, sandboxArgs, budget, bridge, receiver) : closure.call(sandboxArgs, { compilation, stack: stackFrames, thisValue: receiver });
|
|
22469
|
+
if (callbacks?.schedule !== void 0) result = await result;
|
|
22457
22470
|
} catch (error) {
|
|
22458
22471
|
if (isSandboxLikeValue(error)) {
|
|
22459
22472
|
throw deepCopyFromSandbox(error, {
|
|
@@ -22464,11 +22477,17 @@ function wrapSandboxClosureForHost(closure, stackFrames, budget, compileOwner, c
|
|
|
22464
22477
|
}
|
|
22465
22478
|
throw error;
|
|
22466
22479
|
}
|
|
22467
|
-
|
|
22480
|
+
const settlement = deepCopyFromSandbox(normalizeClosureResult(result, budget), {
|
|
22468
22481
|
compilation,
|
|
22469
22482
|
wrapClosure,
|
|
22470
22483
|
onSharedBuffer
|
|
22471
22484
|
});
|
|
22485
|
+
if (callbacks?.schedule !== void 0) {
|
|
22486
|
+
void settlement.catch(() => void 0);
|
|
22487
|
+
if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) await result.synchronousPrefix;
|
|
22488
|
+
return await suspendJob(settlement);
|
|
22489
|
+
}
|
|
22490
|
+
return await settlement;
|
|
22472
22491
|
} catch (error) {
|
|
22473
22492
|
if (isFatalBridgeError(error)) promiseReplayContext.getStore()?.fail(error);
|
|
22474
22493
|
throw error;
|
|
@@ -22480,6 +22499,7 @@ function wrapSandboxClosureForHost(closure, stackFrames, budget, compileOwner, c
|
|
|
22480
22499
|
if (token !== void 0) promiseReplayContext.getStore()?.completeCallback(token);
|
|
22481
22500
|
}
|
|
22482
22501
|
};
|
|
22502
|
+
const invoke = callbacks?.schedule === void 0 ? invokeNow : (args, token, receiver) => callbacks.schedule(() => invokeNow(args, token, receiver));
|
|
22483
22503
|
const wrapped = async function(...args) {
|
|
22484
22504
|
const operation = budget.acquireCompileOwner(false, compileOwner);
|
|
22485
22505
|
try {
|
|
@@ -49202,6 +49222,7 @@ export {
|
|
|
49202
49222
|
createReplayEncodingContext,
|
|
49203
49223
|
encodeReplayData,
|
|
49204
49224
|
decodeReplayData,
|
|
49225
|
+
schedulesHostCallbacks,
|
|
49205
49226
|
declareBudgetedHostOperation,
|
|
49206
49227
|
declareHostOperation,
|
|
49207
49228
|
wrapCallerInjectedBindings,
|
|
@@ -49312,4 +49333,4 @@ authorization of the copyright holder.
|
|
|
49312
49333
|
SPDX-License-Identifier: Unicode-3.0
|
|
49313
49334
|
|
|
49314
49335
|
*/
|
|
49315
|
-
//# sourceMappingURL=chunk-
|
|
49336
|
+
//# sourceMappingURL=chunk-5X7TFA3E.js.map
|