@poe-platform/safe-js 0.1.106 → 0.1.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-js/chunks/{chunk-OWVEZETW.js → chunk-FPFTLLMZ.js} +2 -2
- package/dist/safe-js/chunks/{chunk-FV3SMFMZ.js → chunk-OCJ6MUNL.js} +108 -86
- package/dist/safe-js/chunks/{chunk-FV3SMFMZ.js.map → chunk-OCJ6MUNL.js.map} +3 -3
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-OWVEZETW.js.map → chunk-FPFTLLMZ.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-OCJ6MUNL.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-FPFTLLMZ.js.map
|
|
@@ -25362,6 +25362,20 @@ function typeTag(value) {
|
|
|
25362
25362
|
return "Object";
|
|
25363
25363
|
}
|
|
25364
25364
|
|
|
25365
|
+
// packages/safe-js/src/interp/data-checkpoint.ts
|
|
25366
|
+
function createDataCheckpoint(budget, context) {
|
|
25367
|
+
let estimatedDataSize = 0;
|
|
25368
|
+
return (value, growth = 0, force = false) => {
|
|
25369
|
+
const limit = budget.limits.dataSize;
|
|
25370
|
+
if (limit === void 0) return;
|
|
25371
|
+
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
25372
|
+
if (!force && estimatedDataSize <= limit) return;
|
|
25373
|
+
if (context?.reconcileData !== void 0) context.reconcileData(value);
|
|
25374
|
+
else reconcileCompiledValues(budget, [value], context?.compilation);
|
|
25375
|
+
estimatedDataSize = budget.currentDataSize;
|
|
25376
|
+
};
|
|
25377
|
+
}
|
|
25378
|
+
|
|
25365
25379
|
// packages/safe-js/src/interp/globals/collections.ts
|
|
25366
25380
|
var mapConstructors = /* @__PURE__ */ new WeakSet();
|
|
25367
25381
|
var setConstructors = /* @__PURE__ */ new WeakSet();
|
|
@@ -25371,12 +25385,27 @@ function createCollectionGlobals(options) {
|
|
|
25371
25385
|
call: () => {
|
|
25372
25386
|
throw new TypeError("Constructor Map requires 'new'.");
|
|
25373
25387
|
},
|
|
25374
|
-
construct: ([source]) => {
|
|
25375
|
-
const
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25388
|
+
construct: ([source], context) => {
|
|
25389
|
+
const map = createSandboxMap([]);
|
|
25390
|
+
let key;
|
|
25391
|
+
let value;
|
|
25392
|
+
return populateCollection(source, map, {
|
|
25393
|
+
name: "Map",
|
|
25394
|
+
budget: options.budget,
|
|
25395
|
+
context,
|
|
25396
|
+
retainedValues: () => [key, value],
|
|
25397
|
+
append: (entry) => {
|
|
25398
|
+
if (typeof entry !== "object" || entry === null) throw new TypeError("Map constructor requires entry objects.");
|
|
25399
|
+
key = context?.getProperty !== void 0 ? context.getProperty(entry, 0) : getSandboxDataProperty(entry, 0, options.budget);
|
|
25400
|
+
value = context?.getProperty !== void 0 ? context.getProperty(entry, 1) : getSandboxDataProperty(entry, 1, options.budget);
|
|
25401
|
+
const added = map.entries.has(key) ? 0 : 1;
|
|
25402
|
+
const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([key, value]));
|
|
25403
|
+
options.budget.allocateCollectionEntries(map.entries.size + added);
|
|
25404
|
+
map.entries.set(key, value);
|
|
25405
|
+
key = value = void 0;
|
|
25406
|
+
return growth;
|
|
25407
|
+
}
|
|
25408
|
+
});
|
|
25380
25409
|
},
|
|
25381
25410
|
name: "Map"
|
|
25382
25411
|
});
|
|
@@ -25385,12 +25414,20 @@ function createCollectionGlobals(options) {
|
|
|
25385
25414
|
call: () => {
|
|
25386
25415
|
throw new TypeError("Constructor Set requires 'new'.");
|
|
25387
25416
|
},
|
|
25388
|
-
construct: ([source]) => {
|
|
25389
|
-
const
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25417
|
+
construct: ([source], context) => {
|
|
25418
|
+
const set = createSandboxSet([]);
|
|
25419
|
+
return populateCollection(source, set, {
|
|
25420
|
+
name: "Set",
|
|
25421
|
+
budget: options.budget,
|
|
25422
|
+
context,
|
|
25423
|
+
append: (value) => {
|
|
25424
|
+
const added = set.values.has(value) ? 0 : 1;
|
|
25425
|
+
const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([value]));
|
|
25426
|
+
options.budget.allocateCollectionEntries(set.values.size + added);
|
|
25427
|
+
set.values.add(value);
|
|
25428
|
+
return growth;
|
|
25429
|
+
}
|
|
25430
|
+
});
|
|
25394
25431
|
},
|
|
25395
25432
|
name: "Set"
|
|
25396
25433
|
});
|
|
@@ -25404,71 +25441,68 @@ function isSandboxMapConstructor(value) {
|
|
|
25404
25441
|
function isSandboxSetConstructor(value) {
|
|
25405
25442
|
return typeof value === "object" && value !== null && setConstructors.has(value);
|
|
25406
25443
|
}
|
|
25407
|
-
function
|
|
25408
|
-
|
|
25409
|
-
|
|
25410
|
-
}
|
|
25411
|
-
if (isSandboxMap(source)) {
|
|
25412
|
-
return [...source.entries];
|
|
25413
|
-
}
|
|
25414
|
-
if (Array.isArray(source)) {
|
|
25415
|
-
return validateMapEntries(source);
|
|
25416
|
-
}
|
|
25444
|
+
function populateCollection(source, collection, { name, budget, context, append, retainedValues }) {
|
|
25445
|
+
budget.allocateCollectionEntries(0);
|
|
25446
|
+
if (source === void 0 || source === null) return collection;
|
|
25417
25447
|
const iterator = getSandboxIterator(source);
|
|
25418
|
-
if (iterator
|
|
25419
|
-
|
|
25420
|
-
|
|
25421
|
-
|
|
25422
|
-
|
|
25423
|
-
|
|
25424
|
-
const
|
|
25425
|
-
|
|
25426
|
-
const
|
|
25427
|
-
|
|
25428
|
-
|
|
25429
|
-
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
25433
|
-
|
|
25434
|
-
|
|
25435
|
-
|
|
25448
|
+
if (iterator === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
25449
|
+
let entry;
|
|
25450
|
+
let failure;
|
|
25451
|
+
const retained = {};
|
|
25452
|
+
budget.setRetainedValues(retained, () => [source, collection, entry, failure, ...retainedValues?.() ?? []]);
|
|
25453
|
+
const checkData = createDataCheckpoint(budget, context);
|
|
25454
|
+
const closeOnThrow = (error) => {
|
|
25455
|
+
failure = isCapturedException(error) ? error.reason : error;
|
|
25456
|
+
const rethrow = (closeError) => {
|
|
25457
|
+
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
25458
|
+
throw error;
|
|
25459
|
+
};
|
|
25460
|
+
try {
|
|
25461
|
+
const closing = iterator.return?.();
|
|
25462
|
+
if (iterator.generator) return Promise.resolve(closing).then(() => {
|
|
25463
|
+
throw error;
|
|
25464
|
+
}, rethrow);
|
|
25465
|
+
} catch (closeError) {
|
|
25466
|
+
return rethrow(closeError);
|
|
25436
25467
|
}
|
|
25437
|
-
|
|
25438
|
-
}
|
|
25439
|
-
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25449
|
-
|
|
25450
|
-
|
|
25451
|
-
return
|
|
25468
|
+
throw error;
|
|
25469
|
+
};
|
|
25470
|
+
const consume = (result) => {
|
|
25471
|
+
if (typeof result !== "object" || result === null) throw new TypeError("Iterator result must be an object.");
|
|
25472
|
+
if (result.done) return true;
|
|
25473
|
+
entry = result.value;
|
|
25474
|
+
try {
|
|
25475
|
+
budget.visitNode();
|
|
25476
|
+
const growth = append(entry);
|
|
25477
|
+
entry = void 0;
|
|
25478
|
+
checkData(collection, growth);
|
|
25479
|
+
} catch (error) {
|
|
25480
|
+
return closeOnThrow(error);
|
|
25481
|
+
}
|
|
25482
|
+
return false;
|
|
25483
|
+
};
|
|
25484
|
+
if (iterator.generator) {
|
|
25485
|
+
return (async () => {
|
|
25486
|
+
try {
|
|
25487
|
+
checkData(collection, 0, true);
|
|
25488
|
+
while (!await consume(await iterator.next())) {
|
|
25489
|
+
}
|
|
25490
|
+
checkData(collection, 0, true);
|
|
25491
|
+
return collection;
|
|
25492
|
+
} finally {
|
|
25493
|
+
budget.setRetainedValues(retained, void 0);
|
|
25494
|
+
}
|
|
25495
|
+
})();
|
|
25452
25496
|
}
|
|
25453
|
-
|
|
25454
|
-
|
|
25455
|
-
|
|
25456
|
-
|
|
25457
|
-
|
|
25458
|
-
|
|
25459
|
-
|
|
25460
|
-
|
|
25497
|
+
try {
|
|
25498
|
+
checkData(collection, 0, true);
|
|
25499
|
+
while (!consume(iterator.next())) {
|
|
25500
|
+
}
|
|
25501
|
+
checkData(collection, 0, true);
|
|
25502
|
+
return collection;
|
|
25503
|
+
} finally {
|
|
25504
|
+
budget.setRetainedValues(retained, void 0);
|
|
25461
25505
|
}
|
|
25462
|
-
return values;
|
|
25463
|
-
}
|
|
25464
|
-
function createBudgetedMap(entries, budget) {
|
|
25465
|
-
const map = createSandboxMap(entries);
|
|
25466
|
-
budget.allocateCollectionEntries(map.entries.size);
|
|
25467
|
-
return map;
|
|
25468
|
-
}
|
|
25469
|
-
function createBudgetedSet(values, budget) {
|
|
25470
|
-
budget.allocateCollectionEntries(new Set(values).size);
|
|
25471
|
-
return createSandboxSet(values);
|
|
25472
25506
|
}
|
|
25473
25507
|
|
|
25474
25508
|
// packages/safe-js/src/interp/globals/float32array.ts
|
|
@@ -30836,18 +30870,6 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
30836
30870
|
budget.setRetainedValues(retained, void 0);
|
|
30837
30871
|
}
|
|
30838
30872
|
}
|
|
30839
|
-
function createDataCheckpoint(budget, context) {
|
|
30840
|
-
let estimatedDataSize = 0;
|
|
30841
|
-
return (value, growth = 0, force = false) => {
|
|
30842
|
-
const limit = budget.limits.dataSize;
|
|
30843
|
-
if (limit === void 0) return;
|
|
30844
|
-
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
30845
|
-
if (!force && estimatedDataSize <= limit) return;
|
|
30846
|
-
if (context?.reconcileData !== void 0) context.reconcileData(value);
|
|
30847
|
-
else reconcileCompiledValues(budget, [value], context?.compilation);
|
|
30848
|
-
estimatedDataSize = budget.currentDataSize;
|
|
30849
|
-
};
|
|
30850
|
-
}
|
|
30851
30873
|
function createArrayFromConstructorArgs(args, budget) {
|
|
30852
30874
|
if (args.length !== 1) {
|
|
30853
30875
|
return budgetSandboxValue2(Reflect.apply(Array, Array, [...args]), budget);
|
|
@@ -33023,4 +33045,4 @@ export {
|
|
|
33023
33045
|
FileSnapshotBackend,
|
|
33024
33046
|
run
|
|
33025
33047
|
};
|
|
33026
|
-
//# sourceMappingURL=chunk-
|
|
33048
|
+
//# sourceMappingURL=chunk-OCJ6MUNL.js.map
|