poe-code 14.0.49 → 14.0.50
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/index.js +128 -87
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-bash/dist/browser.js +45 -17
- package/packages/safe-bash/dist/browser.js.map +2 -2
- package/packages/safe-bash/dist/shell/runtime.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/runtime.js +51 -20
- package/packages/safe-bash/dist/shell/runtime.js.map +1 -1
- package/packages/safe-js/dist/chunks/{chunk-FV3SMFMZ.js → chunk-7AIY5C3F.js} +118 -88
- package/packages/safe-js/dist/chunks/{chunk-FV3SMFMZ.js.map → chunk-7AIY5C3F.js.map} +3 -3
- package/packages/safe-js/dist/chunks/{chunk-FO4UY5ZE.js → chunk-MQU3AETK.js} +2 -2
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/data-checkpoint.d.ts +3 -0
- package/packages/safe-js/dist/interp/data-checkpoint.js +18 -0
- package/packages/safe-js/dist/interp/globals/collections.d.ts +1 -1
- package/packages/safe-js/dist/interp/globals/collections.js +101 -76
- package/packages/safe-js/dist/interp/globals/object-array.js +2 -18
- package/packages/safe-js/dist/interp/methods/map.js +7 -2
- package/packages/safe-js/dist/interp/methods/set.js +7 -2
- /package/packages/safe-js/dist/chunks/{chunk-FO4UY5ZE.js.map → chunk-MQU3AETK.js.map} +0 -0
|
@@ -24528,7 +24528,11 @@ function getMapMember(target, property, options) {
|
|
|
24528
24528
|
}
|
|
24529
24529
|
return createSandboxClosure({
|
|
24530
24530
|
sandbox: true,
|
|
24531
|
-
call: (args, context) =>
|
|
24531
|
+
call: (args, context) => {
|
|
24532
|
+
const receiver = context?.thisValue;
|
|
24533
|
+
if (!isSandboxMap(receiver)) throw new TypeError(`Map#${property} requires a Map receiver.`);
|
|
24534
|
+
return callMapMethod(receiver, property, args, options, context?.stack ?? []);
|
|
24535
|
+
},
|
|
24532
24536
|
name: property
|
|
24533
24537
|
});
|
|
24534
24538
|
}
|
|
@@ -25130,7 +25134,11 @@ function getSetMember(target, property, options) {
|
|
|
25130
25134
|
}
|
|
25131
25135
|
return createSandboxClosure({
|
|
25132
25136
|
sandbox: true,
|
|
25133
|
-
call: (args, context) =>
|
|
25137
|
+
call: (args, context) => {
|
|
25138
|
+
const receiver = context?.thisValue;
|
|
25139
|
+
if (!isSandboxSet(receiver)) throw new TypeError(`Set#${property} requires a Set receiver.`);
|
|
25140
|
+
return callSetMethod(receiver, property, args, options, context?.stack ?? []);
|
|
25141
|
+
},
|
|
25134
25142
|
name: property
|
|
25135
25143
|
});
|
|
25136
25144
|
}
|
|
@@ -25362,6 +25370,20 @@ function typeTag(value) {
|
|
|
25362
25370
|
return "Object";
|
|
25363
25371
|
}
|
|
25364
25372
|
|
|
25373
|
+
// packages/safe-js/src/interp/data-checkpoint.ts
|
|
25374
|
+
function createDataCheckpoint(budget, context) {
|
|
25375
|
+
let estimatedDataSize = 0;
|
|
25376
|
+
return (value, growth = 0, force = false) => {
|
|
25377
|
+
const limit = budget.limits.dataSize;
|
|
25378
|
+
if (limit === void 0) return;
|
|
25379
|
+
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
25380
|
+
if (!force && estimatedDataSize <= limit) return;
|
|
25381
|
+
if (context?.reconcileData !== void 0) context.reconcileData(value);
|
|
25382
|
+
else reconcileCompiledValues(budget, [value], context?.compilation);
|
|
25383
|
+
estimatedDataSize = budget.currentDataSize;
|
|
25384
|
+
};
|
|
25385
|
+
}
|
|
25386
|
+
|
|
25365
25387
|
// packages/safe-js/src/interp/globals/collections.ts
|
|
25366
25388
|
var mapConstructors = /* @__PURE__ */ new WeakSet();
|
|
25367
25389
|
var setConstructors = /* @__PURE__ */ new WeakSet();
|
|
@@ -25371,12 +25393,27 @@ function createCollectionGlobals(options) {
|
|
|
25371
25393
|
call: () => {
|
|
25372
25394
|
throw new TypeError("Constructor Map requires 'new'.");
|
|
25373
25395
|
},
|
|
25374
|
-
construct: ([source]) => {
|
|
25375
|
-
const
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
|
|
25379
|
-
|
|
25396
|
+
construct: ([source], context) => {
|
|
25397
|
+
const map = createSandboxMap([]);
|
|
25398
|
+
let key;
|
|
25399
|
+
let value;
|
|
25400
|
+
return populateCollection(source, map, {
|
|
25401
|
+
name: "Map",
|
|
25402
|
+
budget: options.budget,
|
|
25403
|
+
context,
|
|
25404
|
+
retainedValues: () => [key, value],
|
|
25405
|
+
append: (entry) => {
|
|
25406
|
+
if (typeof entry !== "object" || entry === null) throw new TypeError("Map constructor requires entry objects.");
|
|
25407
|
+
key = context?.getProperty !== void 0 ? context.getProperty(entry, 0) : getSandboxDataProperty(entry, 0, options.budget);
|
|
25408
|
+
value = context?.getProperty !== void 0 ? context.getProperty(entry, 1) : getSandboxDataProperty(entry, 1, options.budget);
|
|
25409
|
+
const added = map.entries.has(key) ? 0 : 1;
|
|
25410
|
+
const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([key, value]));
|
|
25411
|
+
options.budget.allocateCollectionEntries(map.entries.size + added);
|
|
25412
|
+
map.entries.set(key, value);
|
|
25413
|
+
key = value = void 0;
|
|
25414
|
+
return growth;
|
|
25415
|
+
}
|
|
25416
|
+
});
|
|
25380
25417
|
},
|
|
25381
25418
|
name: "Map"
|
|
25382
25419
|
});
|
|
@@ -25385,12 +25422,20 @@ function createCollectionGlobals(options) {
|
|
|
25385
25422
|
call: () => {
|
|
25386
25423
|
throw new TypeError("Constructor Set requires 'new'.");
|
|
25387
25424
|
},
|
|
25388
|
-
construct: ([source]) => {
|
|
25389
|
-
const
|
|
25390
|
-
|
|
25391
|
-
|
|
25392
|
-
|
|
25393
|
-
|
|
25425
|
+
construct: ([source], context) => {
|
|
25426
|
+
const set = createSandboxSet([]);
|
|
25427
|
+
return populateCollection(source, set, {
|
|
25428
|
+
name: "Set",
|
|
25429
|
+
budget: options.budget,
|
|
25430
|
+
context,
|
|
25431
|
+
append: (value) => {
|
|
25432
|
+
const added = set.values.has(value) ? 0 : 1;
|
|
25433
|
+
const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([value]));
|
|
25434
|
+
options.budget.allocateCollectionEntries(set.values.size + added);
|
|
25435
|
+
set.values.add(value);
|
|
25436
|
+
return growth;
|
|
25437
|
+
}
|
|
25438
|
+
});
|
|
25394
25439
|
},
|
|
25395
25440
|
name: "Set"
|
|
25396
25441
|
});
|
|
@@ -25404,71 +25449,68 @@ function isSandboxMapConstructor(value) {
|
|
|
25404
25449
|
function isSandboxSetConstructor(value) {
|
|
25405
25450
|
return typeof value === "object" && value !== null && setConstructors.has(value);
|
|
25406
25451
|
}
|
|
25407
|
-
function
|
|
25408
|
-
|
|
25409
|
-
|
|
25410
|
-
}
|
|
25411
|
-
if (isSandboxMap(source)) {
|
|
25412
|
-
return [...source.entries];
|
|
25413
|
-
}
|
|
25414
|
-
if (Array.isArray(source)) {
|
|
25415
|
-
return validateMapEntries(source);
|
|
25416
|
-
}
|
|
25452
|
+
function populateCollection(source, collection, { name, budget, context, append, retainedValues }) {
|
|
25453
|
+
budget.allocateCollectionEntries(0);
|
|
25454
|
+
if (source === void 0 || source === null) return collection;
|
|
25417
25455
|
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
|
-
|
|
25456
|
+
if (iterator === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
25457
|
+
let entry;
|
|
25458
|
+
let failure;
|
|
25459
|
+
const retained = {};
|
|
25460
|
+
budget.setRetainedValues(retained, () => [source, collection, entry, failure, ...retainedValues?.() ?? []]);
|
|
25461
|
+
const checkData = createDataCheckpoint(budget, context);
|
|
25462
|
+
const closeOnThrow = (error) => {
|
|
25463
|
+
failure = isCapturedException(error) ? error.reason : error;
|
|
25464
|
+
const rethrow = (closeError) => {
|
|
25465
|
+
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
25466
|
+
throw error;
|
|
25467
|
+
};
|
|
25468
|
+
try {
|
|
25469
|
+
const closing = iterator.return?.();
|
|
25470
|
+
if (iterator.generator) return Promise.resolve(closing).then(() => {
|
|
25471
|
+
throw error;
|
|
25472
|
+
}, rethrow);
|
|
25473
|
+
} catch (closeError) {
|
|
25474
|
+
return rethrow(closeError);
|
|
25436
25475
|
}
|
|
25437
|
-
|
|
25438
|
-
}
|
|
25439
|
-
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25449
|
-
|
|
25450
|
-
|
|
25451
|
-
return
|
|
25476
|
+
throw error;
|
|
25477
|
+
};
|
|
25478
|
+
const consume = (result) => {
|
|
25479
|
+
if (typeof result !== "object" || result === null) throw new TypeError("Iterator result must be an object.");
|
|
25480
|
+
if (result.done) return true;
|
|
25481
|
+
entry = result.value;
|
|
25482
|
+
try {
|
|
25483
|
+
budget.visitNode();
|
|
25484
|
+
const growth = append(entry);
|
|
25485
|
+
entry = void 0;
|
|
25486
|
+
checkData(collection, growth);
|
|
25487
|
+
} catch (error) {
|
|
25488
|
+
return closeOnThrow(error);
|
|
25489
|
+
}
|
|
25490
|
+
return false;
|
|
25491
|
+
};
|
|
25492
|
+
if (iterator.generator) {
|
|
25493
|
+
return (async () => {
|
|
25494
|
+
try {
|
|
25495
|
+
checkData(collection, 0, true);
|
|
25496
|
+
while (!await consume(await iterator.next())) {
|
|
25497
|
+
}
|
|
25498
|
+
checkData(collection, 0, true);
|
|
25499
|
+
return collection;
|
|
25500
|
+
} finally {
|
|
25501
|
+
budget.setRetainedValues(retained, void 0);
|
|
25502
|
+
}
|
|
25503
|
+
})();
|
|
25452
25504
|
}
|
|
25453
|
-
|
|
25454
|
-
|
|
25455
|
-
|
|
25456
|
-
|
|
25457
|
-
|
|
25458
|
-
|
|
25459
|
-
|
|
25460
|
-
|
|
25505
|
+
try {
|
|
25506
|
+
checkData(collection, 0, true);
|
|
25507
|
+
while (!consume(iterator.next())) {
|
|
25508
|
+
}
|
|
25509
|
+
checkData(collection, 0, true);
|
|
25510
|
+
return collection;
|
|
25511
|
+
} finally {
|
|
25512
|
+
budget.setRetainedValues(retained, void 0);
|
|
25461
25513
|
}
|
|
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
25514
|
}
|
|
25473
25515
|
|
|
25474
25516
|
// packages/safe-js/src/interp/globals/float32array.ts
|
|
@@ -30836,18 +30878,6 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
30836
30878
|
budget.setRetainedValues(retained, void 0);
|
|
30837
30879
|
}
|
|
30838
30880
|
}
|
|
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
30881
|
function createArrayFromConstructorArgs(args, budget) {
|
|
30852
30882
|
if (args.length !== 1) {
|
|
30853
30883
|
return budgetSandboxValue2(Reflect.apply(Array, Array, [...args]), budget);
|
|
@@ -33023,4 +33053,4 @@ export {
|
|
|
33023
33053
|
FileSnapshotBackend,
|
|
33024
33054
|
run
|
|
33025
33055
|
};
|
|
33026
|
-
//# sourceMappingURL=chunk-
|
|
33056
|
+
//# sourceMappingURL=chunk-7AIY5C3F.js.map
|