poe-code 14.0.79 → 14.0.80

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.
Files changed (32) hide show
  1. package/dist/index.js +252 -100
  2. package/dist/index.js.map +4 -4
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-B3AL4KJ3.js → chunk-34G5WW2O.js} +2 -2
  6. package/packages/safe-js/dist/chunks/{chunk-BGSPSHLP.js → chunk-M4L3EZHL.js} +220 -93
  7. package/packages/safe-js/dist/chunks/chunk-M4L3EZHL.js.map +7 -0
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.js +1 -1
  10. package/packages/safe-js/dist/graph-depth.js +2 -1
  11. package/packages/safe-js/dist/index.js +2 -2
  12. package/packages/safe-js/dist/interp/generator-properties.d.ts +3 -0
  13. package/packages/safe-js/dist/interp/generator-properties.js +9 -0
  14. package/packages/safe-js/dist/interp/globals/function.d.ts +2 -0
  15. package/packages/safe-js/dist/interp/globals/function.js +24 -0
  16. package/packages/safe-js/dist/interp/globals/object-array.js +9 -6
  17. package/packages/safe-js/dist/interp/globals/object.js +2 -1
  18. package/packages/safe-js/dist/interp/globals.js +2 -0
  19. package/packages/safe-js/dist/interp/interpreter.js +13 -7
  20. package/packages/safe-js/dist/interp/iteration.js +37 -4
  21. package/packages/safe-js/dist/interp/methods/function.d.ts +4 -1
  22. package/packages/safe-js/dist/interp/methods/function.js +2 -2
  23. package/packages/safe-js/dist/interp/object-model.d.ts +1 -0
  24. package/packages/safe-js/dist/interp/object-model.js +67 -17
  25. package/packages/safe-js/dist/interp/string-coercion.js +3 -2
  26. package/packages/safe-js/dist/interp/values.js +21 -3
  27. package/packages/safe-js/dist/snapshot/guest-heap-validation.js +3 -1
  28. package/packages/safe-js/dist/snapshot/guest-heap.d.ts +1 -0
  29. package/packages/safe-js/dist/snapshot/guest-heap.js +4 -0
  30. package/packages/safe-js/dist/snapshot/restore.js +8 -0
  31. package/packages/safe-js/dist/chunks/chunk-BGSPSHLP.js.map +0 -7
  32. /package/packages/safe-js/dist/chunks/{chunk-B3AL4KJ3.js.map → chunk-34G5WW2O.js.map} +0 -0
@@ -1,5 +1,6 @@
1
1
  import { bindOtelSpan, getBoundOtelSpan } from "../observability/otel.js";
2
2
  import { internalSymbols } from "./internal-symbols.js";
3
+ import { getGeneratorProperties } from "./generator-properties.js";
3
4
  import { getRegexProperties, regexGuestProperties } from "./regexp-properties.js";
4
5
  import { getCollectionProperties, collectionGuestProperties, copyCollectionProperties } from "./collection-properties.js";
5
6
  export { getCollectionProperties } from "./collection-properties.js";
@@ -118,6 +119,8 @@ export function ownEnumerableSandboxEntries(value, excludedKeys) {
118
119
  entries = Object.entries(getRegexProperties(value));
119
120
  else if (isSandboxPromise(value))
120
121
  entries = Object.entries(getPromiseProperties(value));
122
+ else if (isSandboxGenerator(value))
123
+ entries = Object.entries(getGeneratorProperties(value));
121
124
  else if (isSandboxMap(value) || isSandboxSet(value))
122
125
  entries = Object.entries(getCollectionProperties(value));
123
126
  else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value))
@@ -137,15 +140,15 @@ export function ownSandboxSymbolKeys(value) {
137
140
  value = getRegexProperties(value);
138
141
  else if (isSandboxPromise(value))
139
142
  value = getPromiseProperties(value);
143
+ else if (isSandboxGenerator(value))
144
+ value = getGeneratorProperties(value);
140
145
  else if (isSandboxMap(value) || isSandboxSet(value))
141
146
  value = getCollectionProperties(value);
142
- else if (isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value))
143
- return [];
144
147
  return Object.getOwnPropertySymbols(Object(value)).filter(key => !internalSymbols.has(key));
145
148
  }
146
149
  export function ownEnumerableSandboxKeys(value, includeSymbols = false) {
147
150
  if (includeSymbols) {
148
- const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value)
151
+ const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value)
149
152
  : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : Object(value);
150
153
  return [...ownEnumerableSandboxKeys(value), ...ownSandboxSymbolKeys(value).filter(key => Object.getOwnPropertyDescriptor(properties, key)?.enumerable === true)];
151
154
  }
@@ -157,6 +160,8 @@ export function ownEnumerableSandboxKeys(value, includeSymbols = false) {
157
160
  return Object.keys(value.properties ?? {});
158
161
  if (isSandboxPromise(value))
159
162
  return Object.keys(getPromiseProperties(value));
163
+ if (isSandboxGenerator(value))
164
+ return Object.keys(getGeneratorProperties(value));
160
165
  if (isSandboxRegex(value))
161
166
  return Object.keys(getRegexProperties(value));
162
167
  if (isSandboxMap(value) || isSandboxSet(value))
@@ -213,6 +218,7 @@ export function createSandboxGenerator(channel, metadata = undefined) {
213
218
  enumerable: false,
214
219
  value: true
215
220
  });
221
+ getGeneratorProperties(generator);
216
222
  return generator;
217
223
  }
218
224
  export function createSandboxMap(entries = []) {
@@ -501,6 +507,18 @@ export function measureSandboxData(values, options = {}) {
501
507
  return;
502
508
  }
503
509
  if (isSandboxGenerator(value)) {
510
+ const descriptors = Object.getOwnPropertyDescriptors(getGeneratorProperties(value));
511
+ for (const key of Reflect.ownKeys(descriptors)) {
512
+ const descriptor = descriptors[key];
513
+ usage += typeof key === "string" ? key.length + 1 : 1;
514
+ if (typeof key === "symbol")
515
+ visit(key, depth + 1);
516
+ if ("value" in descriptor)
517
+ visit(descriptor.value, depth + 1);
518
+ else
519
+ for (const closure of retainedAccessorClosures(descriptor))
520
+ visit(closure, depth + 1);
521
+ }
504
522
  const snapshot = value.channel.snapshot();
505
523
  usage += snapshot.sent.length;
506
524
  for (const completion of snapshot.sent)
@@ -217,7 +217,9 @@ export function validateGuestHeapNode(raw, heap, maxArrayLength = 0xffffffff) {
217
217
  state(node.state);
218
218
  }
219
219
  else if (node.kind === "guest-generator") {
220
- fields(node, ["kind", "state", "astNodeId", "async", "scope", "closureScope", "sent"], ["suspendedScope", "yieldNodeId", "environment", "blockScopes", "finallyCompletions", "expressionStates"]);
220
+ fields(node, ["kind", "state", "astNodeId", "async", "scope", "closureScope", "sent"], ["suspendedScope", "yieldNodeId", "environment", "blockScopes", "finallyCompletions", "expressionStates", "objectState"]);
221
+ if (Object.hasOwn(node, "objectState"))
222
+ state(node.objectState);
221
223
  if (!["start", "running", "suspended", "done"].includes(String(node.state)) || typeof node.async !== "boolean" || integer(node.astNodeId) < 1)
222
224
  throw new TypeError("Invalid generator state.");
223
225
  reference(node.scope, ["scope-frame"]);
@@ -61,6 +61,7 @@ export type GuestHeapNode<T> = {
61
61
  homeObject?: T;
62
62
  newTarget?: T;
63
63
  };
64
+ objectState?: GuestObjectState<T>;
64
65
  } | {
65
66
  kind: "guest-object";
66
67
  state: GuestObjectState<T>;
@@ -1,4 +1,5 @@
1
1
  import { getClosureOrigin, getGeneratorOrigin } from "../interp/closure-origin.js";
2
+ import { getGeneratorProperties } from "../interp/generator-properties.js";
2
3
  import { getIntrinsicIdentity } from "../interp/intrinsics.js";
3
4
  import { getSandboxPrototype, hasExplicitSandboxPrototype, hasGuestObjectState, isGuestClosure, materializeFunctionProperties } from "../interp/object-model.js";
4
5
  import { isLiveCapability } from "../interp/host-capabilities.js";
@@ -65,6 +66,7 @@ export function captureGuestHeapNode(value, encode) {
65
66
  const channel = value.channel.snapshot();
66
67
  return {
67
68
  kind: "guest-generator", state: value.state, astNodeId: origin.node.nodeId, async: value.async === true,
69
+ objectState: captureObjectState(value, encode),
68
70
  scope: encode(origin.scope), closureScope: encode(origin.closureScope),
69
71
  ...(value.state !== "suspended" || origin.suspendedScope === undefined ? {} : { suspendedScope: encode(origin.suspendedScope) }),
70
72
  ...(value.state !== "suspended" || origin.blockScopes === undefined ? {} : {
@@ -164,6 +166,8 @@ export function captureGuestHeapNode(value, encode) {
164
166
  }
165
167
  function captureObjectState(value, encode) {
166
168
  let properties = value;
169
+ if (isSandboxGenerator(value))
170
+ properties = getGeneratorProperties(value);
167
171
  if (isSandboxClosure(value)) {
168
172
  properties = value.properties;
169
173
  if (isGuestClosure(value))
@@ -1,4 +1,5 @@
1
1
  import { Budget, SandboxError } from "../interp/budget.js";
2
+ import { getGeneratorProperties } from "../interp/generator-properties.js";
2
3
  import { restoreRegexProperties } from "./regexp-properties.js";
3
4
  import { classOrigins, createClassConstructor } from "../interp/classes.js";
4
5
  import { mapIteratorSnapshot } from "../interp/iteration.js";
@@ -521,6 +522,13 @@ function restoreHeapValue(id, state) {
521
522
  if (serialized.kind === "guest-generator") {
522
523
  const generator = restoreGuestGenerator(serialized, state);
523
524
  state.heapValueById.set(id, generator);
525
+ const objectState = serialized.objectState;
526
+ if (objectState !== undefined)
527
+ state.initializeIterators.push(() => {
528
+ if (objectState.prototype !== undefined)
529
+ setSandboxPrototype(generator, deserializeValue(objectState.prototype, state), state.budget);
530
+ restorePropertyDescriptors(getGeneratorProperties(generator), objectState.properties, entry => deserializeValue(entry, state));
531
+ });
524
532
  return generator;
525
533
  }
526
534
  if (serialized.kind === "intrinsic" || serialized.kind === "guest-function" || serialized.kind === "guest-class" || serialized.kind === "guest-object" || serialized.kind === "guest-array" || serialized.kind === "array-iterator") {