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
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-7AIY5C3F.js";
|
|
31
31
|
import {
|
|
32
32
|
createFileSystem,
|
|
33
33
|
createNodeFileSystemAdapterRegistry,
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-MQU3AETK.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-MQU3AETK.js";
|
|
26
26
|
import {
|
|
27
27
|
Budget,
|
|
28
28
|
SandboxError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
replaceErrorStack,
|
|
35
35
|
restore,
|
|
36
36
|
run
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-7AIY5C3F.js";
|
|
38
38
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
39
39
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
40
40
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runWithSpawnUsageAccumulator,
|
|
27
27
|
splitFrontmatter,
|
|
28
28
|
supportsSpawnMode
|
|
29
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-MQU3AETK.js";
|
|
30
30
|
import {
|
|
31
31
|
Budget,
|
|
32
32
|
FileSnapshotBackend,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
registerPendingHostCallPolicy,
|
|
51
51
|
restore,
|
|
52
52
|
run
|
|
53
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-7AIY5C3F.js";
|
|
54
54
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
55
55
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Budget } from "./budget.js";
|
|
2
|
+
import { type SandboxCallContext, type SandboxValue } from "./values.js";
|
|
3
|
+
export declare function createDataCheckpoint(budget: Budget, context?: SandboxCallContext): (value: SandboxValue, growth?: number, force?: boolean) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { reconcileCompiledValues } from "./values.js";
|
|
2
|
+
export function createDataCheckpoint(budget, context) {
|
|
3
|
+
let estimatedDataSize = 0;
|
|
4
|
+
return (value, growth = 0, force = false) => {
|
|
5
|
+
const limit = budget.limits.dataSize;
|
|
6
|
+
if (limit === undefined)
|
|
7
|
+
return;
|
|
8
|
+
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
9
|
+
// Bounded growth estimates defer exact scans until they could exceed the limit.
|
|
10
|
+
if (!force && estimatedDataSize <= limit)
|
|
11
|
+
return;
|
|
12
|
+
if (context?.reconcileData !== undefined)
|
|
13
|
+
context.reconcileData(value);
|
|
14
|
+
else
|
|
15
|
+
reconcileCompiledValues(budget, [value], context?.compilation);
|
|
16
|
+
estimatedDataSize = budget.currentDataSize;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { isFatalSandboxError } from "../budget.js";
|
|
2
|
+
import { createDataCheckpoint } from "../data-checkpoint.js";
|
|
3
|
+
import { isCapturedException } from "../exceptions.js";
|
|
1
4
|
import { getSandboxIterator } from "../iteration.js";
|
|
2
|
-
import {
|
|
5
|
+
import { getSandboxDataProperty } from "../object-model.js";
|
|
6
|
+
import { createSandboxClosure, createSandboxMap, createSandboxSet, measureSandboxData } from "../values.js";
|
|
3
7
|
const mapConstructors = new WeakSet();
|
|
4
8
|
const setConstructors = new WeakSet();
|
|
5
9
|
export function createCollectionGlobals(options) {
|
|
@@ -8,12 +12,27 @@ export function createCollectionGlobals(options) {
|
|
|
8
12
|
call: () => {
|
|
9
13
|
throw new TypeError("Constructor Map requires 'new'.");
|
|
10
14
|
},
|
|
11
|
-
construct: ([source]) => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
construct: ([source], context) => {
|
|
16
|
+
const map = createSandboxMap([]);
|
|
17
|
+
let key;
|
|
18
|
+
let value;
|
|
19
|
+
return populateCollection(source, map, {
|
|
20
|
+
name: "Map", budget: options.budget, context,
|
|
21
|
+
retainedValues: () => [key, value],
|
|
22
|
+
append: (entry) => {
|
|
23
|
+
if (typeof entry !== "object" || entry === null)
|
|
24
|
+
throw new TypeError("Map constructor requires entry objects.");
|
|
25
|
+
key = context?.getProperty !== undefined ? context.getProperty(entry, 0) : getSandboxDataProperty(entry, 0, options.budget);
|
|
26
|
+
value = context?.getProperty !== undefined ? context.getProperty(entry, 1) : getSandboxDataProperty(entry, 1, options.budget);
|
|
27
|
+
const added = map.entries.has(key) ? 0 : 1;
|
|
28
|
+
const growth = added +
|
|
29
|
+
(options.budget.limits.dataSize === undefined ? 0 : measureSandboxData([key, value]));
|
|
30
|
+
options.budget.allocateCollectionEntries(map.entries.size + added);
|
|
31
|
+
map.entries.set(key, value);
|
|
32
|
+
key = value = undefined;
|
|
33
|
+
return growth;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
17
36
|
},
|
|
18
37
|
name: "Map"
|
|
19
38
|
});
|
|
@@ -22,12 +41,19 @@ export function createCollectionGlobals(options) {
|
|
|
22
41
|
call: () => {
|
|
23
42
|
throw new TypeError("Constructor Set requires 'new'.");
|
|
24
43
|
},
|
|
25
|
-
construct: ([source]) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
construct: ([source], context) => {
|
|
45
|
+
const set = createSandboxSet([]);
|
|
46
|
+
return populateCollection(source, set, {
|
|
47
|
+
name: "Set", budget: options.budget, context,
|
|
48
|
+
append: (value) => {
|
|
49
|
+
const added = set.values.has(value) ? 0 : 1;
|
|
50
|
+
const growth = added +
|
|
51
|
+
(options.budget.limits.dataSize === undefined ? 0 : measureSandboxData([value]));
|
|
52
|
+
options.budget.allocateCollectionEntries(set.values.size + added);
|
|
53
|
+
set.values.add(value);
|
|
54
|
+
return growth;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
31
57
|
},
|
|
32
58
|
name: "Set"
|
|
33
59
|
});
|
|
@@ -41,73 +67,72 @@ export function isSandboxMapConstructor(value) {
|
|
|
41
67
|
export function isSandboxSetConstructor(value) {
|
|
42
68
|
return (typeof value === "object" && value !== null && setConstructors.has(value));
|
|
43
69
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (isSandboxMap(source)) {
|
|
49
|
-
return [...source.entries];
|
|
50
|
-
}
|
|
51
|
-
if (Array.isArray(source)) {
|
|
52
|
-
return validateMapEntries(source);
|
|
53
|
-
}
|
|
70
|
+
function populateCollection(source, collection, { name, budget, context, append, retainedValues }) {
|
|
71
|
+
budget.allocateCollectionEntries(0);
|
|
72
|
+
if (source === undefined || source === null)
|
|
73
|
+
return collection;
|
|
54
74
|
const iterator = getSandboxIterator(source);
|
|
55
|
-
if (iterator
|
|
56
|
-
throw new TypeError(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
if (iterator === undefined)
|
|
76
|
+
throw new TypeError(`${name} constructor requires an iterable.`);
|
|
77
|
+
let entry;
|
|
78
|
+
let failure;
|
|
79
|
+
const retained = {};
|
|
80
|
+
budget.setRetainedValues(retained, () => [source, collection, entry, failure, ...(retainedValues?.() ?? [])]);
|
|
81
|
+
const checkData = createDataCheckpoint(budget, context);
|
|
82
|
+
const closeOnThrow = (error) => {
|
|
83
|
+
failure = isCapturedException(error) ? error.reason : error;
|
|
84
|
+
const rethrow = (closeError) => {
|
|
85
|
+
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError))
|
|
86
|
+
throw closeError;
|
|
87
|
+
throw error;
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
const closing = iterator.return?.();
|
|
91
|
+
if (iterator.generator)
|
|
92
|
+
return Promise.resolve(closing).then(() => { throw error; }, rethrow);
|
|
93
|
+
}
|
|
94
|
+
catch (closeError) {
|
|
95
|
+
return rethrow(closeError);
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
};
|
|
99
|
+
const consume = (result) => {
|
|
100
|
+
if (typeof result !== "object" || result === null)
|
|
101
|
+
throw new TypeError("Iterator result must be an object.");
|
|
64
102
|
if (result.done)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!Array.isArray(entry)) {
|
|
73
|
-
throw new TypeError("Map constructor entries must be arrays.");
|
|
103
|
+
return true;
|
|
104
|
+
entry = result.value;
|
|
105
|
+
try {
|
|
106
|
+
budget.visitNode();
|
|
107
|
+
const growth = append(entry);
|
|
108
|
+
entry = undefined;
|
|
109
|
+
checkData(collection, growth);
|
|
74
110
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
111
|
+
catch (error) {
|
|
112
|
+
return closeOnThrow(error);
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
};
|
|
116
|
+
if (iterator.generator) {
|
|
117
|
+
return (async () => {
|
|
118
|
+
try {
|
|
119
|
+
checkData(collection, 0, true);
|
|
120
|
+
while (!(await consume(await iterator.next()))) { /* Consume each entry before advancing. */ }
|
|
121
|
+
checkData(collection, 0, true);
|
|
122
|
+
return collection;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
budget.setRetainedValues(retained, undefined);
|
|
126
|
+
}
|
|
127
|
+
})();
|
|
81
128
|
}
|
|
82
|
-
|
|
83
|
-
|
|
129
|
+
try {
|
|
130
|
+
checkData(collection, 0, true);
|
|
131
|
+
while (!consume(iterator.next())) { /* Synchronous inputs stay synchronous. */ }
|
|
132
|
+
checkData(collection, 0, true);
|
|
133
|
+
return collection;
|
|
84
134
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (Array.isArray(source))
|
|
88
|
-
return [...source];
|
|
89
|
-
const iterator = getSandboxIterator(source);
|
|
90
|
-
if (iterator?.generator === true) {
|
|
91
|
-
return collectSetValues(iterator);
|
|
135
|
+
finally {
|
|
136
|
+
budget.setRetainedValues(retained, undefined);
|
|
92
137
|
}
|
|
93
|
-
throw new TypeError("Set constructor argument must be an array, string, or Set.");
|
|
94
|
-
}
|
|
95
|
-
async function collectSetValues(iterator) {
|
|
96
|
-
const values = [];
|
|
97
|
-
while (true) {
|
|
98
|
-
const result = await iterator.next();
|
|
99
|
-
if (result.done)
|
|
100
|
-
break;
|
|
101
|
-
values.push(result.value);
|
|
102
|
-
}
|
|
103
|
-
return values;
|
|
104
|
-
}
|
|
105
|
-
function createBudgetedMap(entries, budget) {
|
|
106
|
-
const map = createSandboxMap(entries);
|
|
107
|
-
budget.allocateCollectionEntries(map.entries.size);
|
|
108
|
-
return map;
|
|
109
|
-
}
|
|
110
|
-
function createBudgetedSet(values, budget) {
|
|
111
|
-
budget.allocateCollectionEntries(new Set(values).size);
|
|
112
|
-
return createSandboxSet(values);
|
|
113
138
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isFatalSandboxError } from "../budget.js";
|
|
2
2
|
import { invokeBuiltinClosure } from "../builtin-call.js";
|
|
3
|
+
import { createDataCheckpoint } from "../data-checkpoint.js";
|
|
3
4
|
import { isCapturedException } from "../exceptions.js";
|
|
4
5
|
import { isSandboxDate } from "../date.js";
|
|
5
6
|
import { getDatePrototype } from "./date.js";
|
|
@@ -10,7 +11,7 @@ import { setSandboxProperty } from "../interpreter.js";
|
|
|
10
11
|
import { getSandboxIterator } from "../iteration.js";
|
|
11
12
|
import { sandboxNumber, sandboxString } from "../string-coercion.js";
|
|
12
13
|
import { getSandboxDataProperty, getSandboxPrototype, isGuestClosure, markDescriptorObject, materializeFunctionProperties, setSandboxPrototype } from "../object-model.js";
|
|
13
|
-
import { allocateProducedSandboxValue, createSandboxClosure, deepCopyToSandbox, defineOwnDataProperty, isSandboxClosure, isSandboxGenerator, isSandboxMap, isSandboxPromise, isSandboxRegex, isSandboxSet, measureSandboxData, ownEnumerableSandboxEntries as getOwnEnumerableEntries
|
|
14
|
+
import { allocateProducedSandboxValue, createSandboxClosure, deepCopyToSandbox, defineOwnDataProperty, isSandboxClosure, isSandboxGenerator, isSandboxMap, isSandboxPromise, isSandboxRegex, isSandboxSet, measureSandboxData, ownEnumerableSandboxEntries as getOwnEnumerableEntries } from "../values.js";
|
|
14
15
|
export function createObjectArrayGlobals(options) {
|
|
15
16
|
return {
|
|
16
17
|
Object: createObjectGlobal({
|
|
@@ -487,23 +488,6 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
487
488
|
budget.setRetainedValues(retained, undefined);
|
|
488
489
|
}
|
|
489
490
|
}
|
|
490
|
-
function createDataCheckpoint(budget, context) {
|
|
491
|
-
let estimatedDataSize = 0;
|
|
492
|
-
return (value, growth = 0, force = false) => {
|
|
493
|
-
const limit = budget.limits.dataSize;
|
|
494
|
-
if (limit === undefined)
|
|
495
|
-
return;
|
|
496
|
-
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
497
|
-
// Bounded growth estimates defer exact scans until they could exceed the limit.
|
|
498
|
-
if (!force && estimatedDataSize <= limit)
|
|
499
|
-
return;
|
|
500
|
-
if (context?.reconcileData !== undefined)
|
|
501
|
-
context.reconcileData(value);
|
|
502
|
-
else
|
|
503
|
-
reconcileCompiledValues(budget, [value], context?.compilation);
|
|
504
|
-
estimatedDataSize = budget.currentDataSize;
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
491
|
function createArrayFromConstructorArgs(args, budget) {
|
|
508
492
|
if (args.length !== 1) {
|
|
509
493
|
return budgetSandboxValue(Reflect.apply(Array, Array, [...args]), budget);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { allocateProducedSandboxValue, createSandboxClosure, isSandboxClosure } from "../values.js";
|
|
1
|
+
import { allocateProducedSandboxValue, createSandboxClosure, isSandboxClosure, isSandboxMap } from "../values.js";
|
|
2
2
|
import { assertCollectionMutable } from "../running-state.js";
|
|
3
3
|
import { enterKeyedCollectionCallback, updateKeyedCollectionCallbacks } from "./collection-callback.js";
|
|
4
4
|
const mapMethodNames = new Set([
|
|
@@ -24,7 +24,12 @@ export function getMapMember(target, property, options) {
|
|
|
24
24
|
}
|
|
25
25
|
return createSandboxClosure({
|
|
26
26
|
sandbox: true,
|
|
27
|
-
call: (args, context) =>
|
|
27
|
+
call: (args, context) => {
|
|
28
|
+
const receiver = context?.thisValue;
|
|
29
|
+
if (!isSandboxMap(receiver))
|
|
30
|
+
throw new TypeError(`Map#${property} requires a Map receiver.`);
|
|
31
|
+
return callMapMethod(receiver, property, args, options, context?.stack ?? []);
|
|
32
|
+
},
|
|
28
33
|
name: property
|
|
29
34
|
});
|
|
30
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { allocateProducedSandboxValue, createSandboxClosure, isSandboxClosure } from "../values.js";
|
|
1
|
+
import { allocateProducedSandboxValue, createSandboxClosure, isSandboxClosure, isSandboxSet } from "../values.js";
|
|
2
2
|
import { assertCollectionMutable } from "../running-state.js";
|
|
3
3
|
import { enterKeyedCollectionCallback, updateKeyedCollectionCallbacks } from "./collection-callback.js";
|
|
4
4
|
const setMethodNames = new Set([
|
|
@@ -23,7 +23,12 @@ export function getSetMember(target, property, options) {
|
|
|
23
23
|
}
|
|
24
24
|
return createSandboxClosure({
|
|
25
25
|
sandbox: true,
|
|
26
|
-
call: (args, context) =>
|
|
26
|
+
call: (args, context) => {
|
|
27
|
+
const receiver = context?.thisValue;
|
|
28
|
+
if (!isSandboxSet(receiver))
|
|
29
|
+
throw new TypeError(`Set#${property} requires a Set receiver.`);
|
|
30
|
+
return callSetMethod(receiver, property, args, options, context?.stack ?? []);
|
|
31
|
+
},
|
|
27
32
|
name: property
|
|
28
33
|
});
|
|
29
34
|
}
|
|
File without changes
|