poe-code 12.0.5 → 12.0.6
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 -2
- package/dist/index.js +98 -17
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-RRSINVWT.js → chunk-KJSS53IH.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-XBRQ72W6.js → chunk-NDHGDM46.js} +89 -17
- package/packages/safejs/dist/chunks/{chunk-XBRQ72W6.js.map → chunk-NDHGDM46.js.map} +3 -3
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/methods/collection-callback.d.ts +7 -0
- package/packages/safejs/dist/interp/methods/collection-callback.js +68 -0
- package/packages/safejs/dist/interp/methods/map.js +18 -9
- package/packages/safejs/dist/interp/methods/set.js +17 -9
- /package/packages/safejs/dist/chunks/{chunk-RRSINVWT.js.map → chunk-KJSS53IH.js.map} +0 -0
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-NDHGDM46.js";
|
|
31
31
|
import {
|
|
32
32
|
FsError,
|
|
33
33
|
createFileSystem,
|
|
@@ -8181,4 +8181,4 @@ export {
|
|
|
8181
8181
|
parseMcpConfig,
|
|
8182
8182
|
makeMcpModule
|
|
8183
8183
|
};
|
|
8184
|
-
//# sourceMappingURL=chunk-
|
|
8184
|
+
//# sourceMappingURL=chunk-KJSS53IH.js.map
|
|
@@ -25137,6 +25137,67 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
25137
25137
|
return options.callClosure(target, applyArgs, stack, thisValue);
|
|
25138
25138
|
}
|
|
25139
25139
|
|
|
25140
|
+
// packages/safejs/src/interp/methods/collection-callback.ts
|
|
25141
|
+
var activeCallbacks = /* @__PURE__ */ new WeakMap();
|
|
25142
|
+
function enterKeyedCollectionCallback(target, keys, budget) {
|
|
25143
|
+
let state = activeCallbacks.get(target);
|
|
25144
|
+
if (state === void 0) {
|
|
25145
|
+
state = { cursors: /* @__PURE__ */ new Set(), leaveRunning: enterRunningState(target) };
|
|
25146
|
+
activeCallbacks.set(target, state);
|
|
25147
|
+
}
|
|
25148
|
+
const cursor = { budget, pending: /* @__PURE__ */ new Set() };
|
|
25149
|
+
state.cursors.add(cursor);
|
|
25150
|
+
const leave = () => {
|
|
25151
|
+
if (!state.cursors.delete(cursor)) return;
|
|
25152
|
+
cursor.pending.clear();
|
|
25153
|
+
budget.setRetainedDataUsage(cursor, 0);
|
|
25154
|
+
budget.setRetainedValues(cursor, void 0);
|
|
25155
|
+
if (state.cursors.size === 0) {
|
|
25156
|
+
activeCallbacks.delete(target);
|
|
25157
|
+
state.leaveRunning();
|
|
25158
|
+
}
|
|
25159
|
+
};
|
|
25160
|
+
try {
|
|
25161
|
+
budget.setRetainedDataUsage(cursor, 1);
|
|
25162
|
+
budget.setRetainedValues(cursor, () => cursor.pending);
|
|
25163
|
+
for (const key of keys) updatePendingKeys(cursor, "add", key);
|
|
25164
|
+
} catch (error) {
|
|
25165
|
+
leave();
|
|
25166
|
+
throw error;
|
|
25167
|
+
}
|
|
25168
|
+
return {
|
|
25169
|
+
next: () => {
|
|
25170
|
+
budget.visitNode();
|
|
25171
|
+
for (const key of cursor.pending) {
|
|
25172
|
+
cursor.pending.delete(key);
|
|
25173
|
+
budget.setRetainedDataUsage(cursor, 1 + cursor.pending.size);
|
|
25174
|
+
return { done: false, value: key };
|
|
25175
|
+
}
|
|
25176
|
+
return { done: true, value: void 0 };
|
|
25177
|
+
},
|
|
25178
|
+
leave
|
|
25179
|
+
};
|
|
25180
|
+
}
|
|
25181
|
+
function updateKeyedCollectionCallbacks(target, mutation, key) {
|
|
25182
|
+
const state = activeCallbacks.get(target);
|
|
25183
|
+
if (state === void 0) return;
|
|
25184
|
+
for (const cursor of state.cursors) updatePendingKeys(cursor, mutation, key);
|
|
25185
|
+
}
|
|
25186
|
+
function updatePendingKeys(cursor, mutation, key) {
|
|
25187
|
+
const { budget, pending } = cursor;
|
|
25188
|
+
budget.visitNode();
|
|
25189
|
+
if (mutation === "add") {
|
|
25190
|
+
const nextSize = pending.has(key) ? pending.size : pending.size + 1;
|
|
25191
|
+
budget.allocateCollectionEntries(nextSize);
|
|
25192
|
+
budget.setRetainedDataUsage(cursor, 1 + nextSize);
|
|
25193
|
+
pending.add(key);
|
|
25194
|
+
} else {
|
|
25195
|
+
if (mutation === "delete") pending.delete(key);
|
|
25196
|
+
else pending.clear();
|
|
25197
|
+
budget.setRetainedDataUsage(cursor, 1 + pending.size);
|
|
25198
|
+
}
|
|
25199
|
+
}
|
|
25200
|
+
|
|
25140
25201
|
// packages/safejs/src/interp/methods/map.ts
|
|
25141
25202
|
var mapMethodNames = /* @__PURE__ */ new Set([
|
|
25142
25203
|
"get",
|
|
@@ -25171,34 +25232,40 @@ async function callMapMethod(target, methodName, args, options, stack = []) {
|
|
|
25171
25232
|
return target.entries.get(args[0]);
|
|
25172
25233
|
case "set": {
|
|
25173
25234
|
assertCollectionMutable(target);
|
|
25174
|
-
const
|
|
25235
|
+
const exists = target.entries.has(args[0]);
|
|
25236
|
+
const nextSize = exists ? target.entries.size : target.entries.size + 1;
|
|
25175
25237
|
options.budget.allocateCollectionEntries(nextSize);
|
|
25238
|
+
if (!exists) updateKeyedCollectionCallbacks(target, "add", args[0]);
|
|
25176
25239
|
target.entries.set(args[0], args[1]);
|
|
25177
25240
|
return target;
|
|
25178
25241
|
}
|
|
25179
25242
|
case "has":
|
|
25180
25243
|
return target.entries.has(args[0]);
|
|
25181
|
-
case "delete":
|
|
25244
|
+
case "delete": {
|
|
25182
25245
|
assertCollectionMutable(target);
|
|
25183
|
-
|
|
25246
|
+
const deleted = target.entries.delete(args[0]);
|
|
25247
|
+
if (deleted) updateKeyedCollectionCallbacks(target, "delete", args[0]);
|
|
25248
|
+
return deleted;
|
|
25249
|
+
}
|
|
25184
25250
|
case "clear":
|
|
25185
25251
|
assertCollectionMutable(target);
|
|
25186
25252
|
target.entries.clear();
|
|
25253
|
+
updateKeyedCollectionCallbacks(target, "clear");
|
|
25187
25254
|
return void 0;
|
|
25188
25255
|
case "forEach": {
|
|
25189
25256
|
const callback = args[0];
|
|
25190
25257
|
if (!isSandboxClosure(callback)) {
|
|
25191
25258
|
throw new TypeError("Map.prototype.forEach requires a callback function.");
|
|
25192
25259
|
}
|
|
25193
|
-
const
|
|
25260
|
+
const cursor = enterKeyedCollectionCallback(target, target.entries.keys(), options.budget);
|
|
25194
25261
|
try {
|
|
25195
|
-
|
|
25196
|
-
|
|
25197
|
-
const
|
|
25262
|
+
for (let entry = cursor.next(); !entry.done; entry = cursor.next()) {
|
|
25263
|
+
const key = entry.value;
|
|
25264
|
+
const value = target.entries.get(key);
|
|
25198
25265
|
await options.callClosure(callback, [value, key, target], stack, args[1]);
|
|
25199
25266
|
}
|
|
25200
25267
|
} finally {
|
|
25201
|
-
|
|
25268
|
+
cursor.leave();
|
|
25202
25269
|
}
|
|
25203
25270
|
return void 0;
|
|
25204
25271
|
}
|
|
@@ -25978,34 +26045,39 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
|
|
|
25978
26045
|
switch (methodName) {
|
|
25979
26046
|
case "add": {
|
|
25980
26047
|
assertCollectionMutable(target);
|
|
25981
|
-
const
|
|
26048
|
+
const exists = target.values.has(args[0]);
|
|
26049
|
+
const nextSize = exists ? target.values.size : target.values.size + 1;
|
|
25982
26050
|
options.budget.allocateCollectionEntries(nextSize);
|
|
26051
|
+
if (!exists) updateKeyedCollectionCallbacks(target, "add", args[0]);
|
|
25983
26052
|
target.values.add(args[0]);
|
|
25984
26053
|
return target;
|
|
25985
26054
|
}
|
|
25986
26055
|
case "has":
|
|
25987
26056
|
return target.values.has(args[0]);
|
|
25988
|
-
case "delete":
|
|
26057
|
+
case "delete": {
|
|
25989
26058
|
assertCollectionMutable(target);
|
|
25990
|
-
|
|
26059
|
+
const deleted = target.values.delete(args[0]);
|
|
26060
|
+
if (deleted) updateKeyedCollectionCallbacks(target, "delete", args[0]);
|
|
26061
|
+
return deleted;
|
|
26062
|
+
}
|
|
25991
26063
|
case "clear":
|
|
25992
26064
|
assertCollectionMutable(target);
|
|
25993
26065
|
target.values.clear();
|
|
26066
|
+
updateKeyedCollectionCallbacks(target, "clear");
|
|
25994
26067
|
return void 0;
|
|
25995
26068
|
case "forEach": {
|
|
25996
26069
|
const callback = args[0];
|
|
25997
26070
|
if (!isSandboxClosure(callback)) {
|
|
25998
26071
|
throw new TypeError("Set.prototype.forEach requires a callback function.");
|
|
25999
26072
|
}
|
|
26000
|
-
const
|
|
26073
|
+
const cursor = enterKeyedCollectionCallback(target, target.values, options.budget);
|
|
26001
26074
|
try {
|
|
26002
|
-
|
|
26003
|
-
|
|
26004
|
-
const value = values[index];
|
|
26075
|
+
for (let entry = cursor.next(); !entry.done; entry = cursor.next()) {
|
|
26076
|
+
const value = entry.value;
|
|
26005
26077
|
await options.callClosure(callback, [value, value, target], stack, args[1]);
|
|
26006
26078
|
}
|
|
26007
26079
|
} finally {
|
|
26008
|
-
|
|
26080
|
+
cursor.leave();
|
|
26009
26081
|
}
|
|
26010
26082
|
return void 0;
|
|
26011
26083
|
}
|
|
@@ -29676,4 +29748,4 @@ export {
|
|
|
29676
29748
|
FileSnapshotBackend,
|
|
29677
29749
|
run
|
|
29678
29750
|
};
|
|
29679
|
-
//# sourceMappingURL=chunk-
|
|
29751
|
+
//# sourceMappingURL=chunk-NDHGDM46.js.map
|