@poe-platform/safe-js 0.1.157 → 0.1.159

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.
@@ -22,7 +22,7 @@ import {
22
22
  resolveFsConfig,
23
23
  splitFrontmatter,
24
24
  withBrokenPipeGuard
25
- } from "./chunks/chunk-C6UXDKOA.js";
25
+ } from "./chunks/chunk-7UAYAMV3.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-BTIHHHII.js";
37
+ } from "./chunks/chunk-PG6YTTQI.js";
38
38
  import "./chunks/chunk-4YIDX44G.js";
39
39
 
40
40
  // packages/safe-js/src/cli.ts
@@ -5,7 +5,7 @@ import {
5
5
  defineExtension,
6
6
  lint,
7
7
  run
8
- } from "./chunks/chunk-BTIHHHII.js";
8
+ } from "./chunks/chunk-PG6YTTQI.js";
9
9
  import "./chunks/chunk-4YIDX44G.js";
10
10
  export {
11
11
  Budget,
@@ -26,7 +26,7 @@ import {
26
26
  runWithSpawnUsageAccumulator,
27
27
  splitFrontmatter,
28
28
  supportsSpawnMode
29
- } from "./chunks/chunk-C6UXDKOA.js";
29
+ } from "./chunks/chunk-7UAYAMV3.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-BTIHHHII.js";
53
+ } from "./chunks/chunk-PG6YTTQI.js";
54
54
  import "./chunks/chunk-4YIDX44G.js";
55
55
 
56
56
  // packages/safe-js/src/parse.ts
@@ -30,8 +30,8 @@ type ExceptionContext = {
30
30
  budget: Budget;
31
31
  callStack: readonly string[];
32
32
  scope: Scope;
33
- toPropertyKey?: (value: SandboxValue) => Promise<string>;
34
- getProperty?: (value: SandboxValue, key: string | number) => SandboxValue | Promise<SandboxValue>;
33
+ toPropertyKey?: (value: SandboxValue) => string | symbol | Promise<string | symbol>;
34
+ getProperty?: (value: SandboxValue, key: PropertyKey) => SandboxValue | Promise<SandboxValue>;
35
35
  };
36
36
  type EvaluateExceptionNode<TContext, TError> = (node: ParseResult, context: TContext) => Promise<EvaluationResult<TError>>;
37
37
  export declare function evaluateThrowStatement<TContext extends ExceptionContext, TError>(node: ThrowStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
@@ -72,4 +72,4 @@ export declare function interpret(node: ParseResult, options?: InterpretOptions)
72
72
  export { Scope } from "./scope.js";
73
73
  declare function evaluateNode(node: ParseResult, context: EvaluationContext): Promise<EvaluationResult>;
74
74
  export declare function createPatternContext(context: AsyncEvaluationContext, scope?: Scope, evaluate?: typeof evaluateNode): PatternContext;
75
- export declare function setSandboxProperty(target: SandboxValue, property: string | number, value: SandboxValue, budget: Budget, checkInherited?: boolean, context?: SandboxCallContext): void | Promise<void>;
75
+ export declare function setSandboxProperty(target: SandboxValue, property: PropertyKey, value: SandboxValue, budget: Budget, checkInherited?: boolean, context?: SandboxCallContext): void | Promise<void>;
@@ -5,11 +5,19 @@ export type SandboxIterator = {
5
5
  readonly generator?: true;
6
6
  readonly asynchronous?: true;
7
7
  readonly retainedValue?: SandboxValue;
8
+ getOperation?(method: "next" | "return" | "throw"): Promise<SandboxIterator["next"] | undefined>;
9
+ readResultProperty?(result: IteratorResult<SandboxValue>, property: "done" | "value"): Promise<{
10
+ value: SandboxValue;
11
+ }>;
8
12
  snapshotIndex?(): number;
9
13
  next(value?: SandboxValue): IteratorResult<SandboxValue> | Promise<IteratorResult<SandboxValue>>;
10
14
  return?(value?: SandboxValue): IteratorResult<SandboxValue> | Promise<IteratorResult<SandboxValue>>;
11
15
  throw?(error?: SandboxValue): IteratorResult<SandboxValue> | Promise<IteratorResult<SandboxValue>>;
12
16
  };
17
+ export declare function acquireSandboxIterator(value: SandboxValue, budget: Budget, context: SandboxCallContext, asyncProtocol?: boolean, signal?: AbortSignal): Promise<SandboxIterator | undefined>;
18
+ export declare function readIteratorResult(iterator: SandboxIterator, result: IteratorResult<SandboxValue>, property: "done" | "value"): Promise<{
19
+ value: SandboxValue;
20
+ }>;
13
21
  export declare function getSandboxAsyncIterator(value: SandboxValue, budget: Budget, context?: SandboxCallContext, signal?: AbortSignal): SandboxIterator | undefined;
14
22
  export declare function closeIterator(iterator: SandboxIterator, preserveThrow?: boolean): Promise<void>;
15
23
  export declare function getSandboxIterator(value: SandboxValue, budget?: Budget, context?: SandboxCallContext): SandboxIterator | undefined;
@@ -13,9 +13,9 @@ export type PatternTarget = {
13
13
  export type PatternContext = {
14
14
  budget?: Budget;
15
15
  evaluate(node: ParseResult, inferredName?: string): Promise<AsyncEvaluationResult>;
16
- toPropertyKey(value: SandboxValue): Promise<string>;
17
- getProperty(value: SandboxValue, key: string | number): SandboxValue | Promise<SandboxValue>;
18
- setProperty(target: SandboxValue, key: string | number, value: SandboxValue): void | Promise<void>;
16
+ toPropertyKey(value: SandboxValue): string | symbol | Promise<string | symbol>;
17
+ getProperty(value: SandboxValue, key: PropertyKey): SandboxValue | Promise<SandboxValue>;
18
+ setProperty(target: SandboxValue, key: PropertyKey, value: SandboxValue): void | Promise<void>;
19
19
  };
20
20
  export type BindPatternResult = {
21
21
  ok: true;
@@ -13,10 +13,11 @@ declare const sandboxPromiseBrand: unique symbol;
13
13
  declare const sandboxRegexBrand: unique symbol;
14
14
  declare const sandboxRegexPattern: unique symbol;
15
15
  declare const sandboxRetainedValues: unique symbol;
16
- export type SandboxPrimitive = string | number | boolean | null | undefined;
16
+ export type SandboxPrimitive = string | number | boolean | symbol | null | undefined;
17
17
  export type SandboxValue = SandboxPrimitive | Date | Float32Array | SandboxObject | SandboxArray | SandboxClosure | SandboxGenerator | SandboxCollectionIterator | SandboxMap | SandboxSet | SandboxPromise | SandboxRegex;
18
18
  export type SandboxObject = {
19
19
  [key: string]: SandboxValue;
20
+ [key: symbol]: SandboxValue;
20
21
  };
21
22
  export type SandboxArray = SandboxValue[];
22
23
  export type SandboxMap = {
@@ -54,7 +55,7 @@ export type SandboxCallContext = {
54
55
  };
55
56
  readonly stack: readonly string[];
56
57
  readonly thisValue: SandboxValue;
57
- readonly getProperty?: (value: SandboxValue, property: string | number) => SandboxValue | Promise<SandboxValue>;
58
+ readonly getProperty?: (value: SandboxValue, property: PropertyKey) => SandboxValue | Promise<SandboxValue>;
58
59
  readonly reconcileData?: (value: SandboxValue) => void;
59
60
  readonly invokeClosure?: (closure: SandboxClosure, args: readonly SandboxValue[], thisValue: SandboxValue, construct?: boolean, newTarget?: SandboxClosure) => Promise<SandboxValue>;
60
61
  };
@@ -113,7 +114,9 @@ export declare function createSandboxClosure(input: {
113
114
  retainedValues?: () => Iterable<SandboxValue>;
114
115
  }): SandboxClosure;
115
116
  export declare function ownEnumerableSandboxEntries(value: SandboxValue, excludedKeys?: ReadonlySet<string>): Array<[string, SandboxValue]>;
117
+ export declare function ownSandboxSymbolKeys(value: SandboxValue): symbol[];
116
118
  export declare function ownEnumerableSandboxKeys(value: SandboxValue): string[];
119
+ export declare function ownEnumerableSandboxKeys(value: SandboxValue, includeSymbols: true): PropertyKey[];
117
120
  export declare function createSandboxPromise(promise: Promise<SandboxValue>, metadata?: {
118
121
  trackReplay?: boolean;
119
122
  synchronousPrefix?: Promise<void>;
@@ -149,5 +152,5 @@ export declare function measureSandboxData(values: Iterable<unknown>, options?:
149
152
  export declare function reconcileCompiledValues(budget: Budget, values: Iterable<unknown>, compilation?: CompileScope, parent?: CompileScope, escaping?: Iterable<unknown>): void;
150
153
  export declare function deepCopyFromSandbox(value: SandboxPromise, options?: CopyFromSandboxOptions): Promise<unknown>;
151
154
  export declare function deepCopyFromSandbox(value: SandboxValue, options?: CopyFromSandboxOptions): unknown;
152
- export declare function defineOwnDataProperty(target: object, key: string, value: unknown): void;
155
+ export declare function defineOwnDataProperty(target: object, key: PropertyKey, value: unknown): void;
153
156
  export declare function isArrayIndexKey(value: string): boolean;
@@ -1,3 +1,4 @@
1
+ import { type SerializedSymbol, type SerializedSymbolProperty } from "./symbols.js";
1
2
  import { type CollectionIterationMethod } from "../interp/collection-iterator.js";
2
3
  import { CompileScope } from "../interp/regex/compile-guard.js";
3
4
  import { type Float32Data } from "./float32array.js";
@@ -25,11 +26,12 @@ type Properties = Record<string, {
25
26
  enumerable: boolean;
26
27
  writable: boolean;
27
28
  }>;
28
- type DataNode = {
29
+ type DataNode = SerializedSymbol | {
29
30
  kind: "boxed";
30
31
  value: Atom;
31
32
  properties: Properties;
32
33
  extensible: boolean;
34
+ symbolEntries?: Array<SerializedSymbolProperty<Atom>>;
33
35
  } | {
34
36
  kind: "collection-iterator";
35
37
  collectionKind: "map" | "set";
@@ -42,6 +44,9 @@ type DataNode = {
42
44
  } | {
43
45
  kind: "date";
44
46
  time: number | null;
47
+ properties?: Properties;
48
+ symbolProperties?: Array<SerializedSymbolProperty<Atom>>;
49
+ extensible?: boolean;
45
50
  } | (Float32Data<Atom> & {
46
51
  properties: Properties;
47
52
  extensible: boolean;
@@ -52,6 +57,7 @@ type DataNode = {
52
57
  } | {
53
58
  kind: "array" | "object";
54
59
  properties: Properties;
60
+ symbolProperties?: Array<SerializedSymbolProperty<Atom>>;
55
61
  extensible: boolean;
56
62
  nullPrototype: boolean;
57
63
  errorType?: SandboxErrorName;
@@ -74,12 +80,15 @@ export type ReplayData = {
74
80
  root: Atom;
75
81
  nodes: DataNode[];
76
82
  };
83
+ export type ReplayPathSegment = string | {
84
+ symbol: number;
85
+ };
77
86
  export declare class MissingReplayCapabilityError extends TypeError {
78
87
  }
79
88
  export declare function encodeReplayData(value: SandboxValue, options?: {
80
- identifyCapability?: (value: SandboxClosure, path: readonly string[]) => string | undefined;
89
+ identifyCapability?: (value: SandboxClosure, path: readonly ReplayPathSegment[]) => string | undefined;
81
90
  captureCapabilityProperties?: boolean;
82
- identifyPromise?: (value: SandboxPromise, path: readonly string[]) => string | undefined;
91
+ identifyPromise?: (value: SandboxPromise, path: readonly ReplayPathSegment[]) => string | undefined;
83
92
  }): ReplayData;
84
93
  export declare function decodeReplayData(input: unknown, options?: {
85
94
  resolveCapability?: (id: string) => SandboxClosure | undefined;
@@ -0,0 +1,19 @@
1
+ export type SerializedSymbol = {
2
+ kind: "symbol";
3
+ description?: string;
4
+ wellKnown?: string;
5
+ };
6
+ export type SerializedSymbolProperty<T> = [T, {
7
+ value: T;
8
+ enumerable: boolean;
9
+ writable: boolean;
10
+ configurable: boolean;
11
+ }];
12
+ export declare function symbolData(value: symbol): SerializedSymbol;
13
+ export declare function serializeSymbol(value: symbol, heapIds: Map<object | symbol, number>, heap: Record<string, unknown>): {
14
+ kind: "ref";
15
+ id: number;
16
+ };
17
+ export declare function ownSerializableSymbolKeys(value: object): symbol[];
18
+ export declare function serializeSymbolProperties<T>(value: object, encode: (value: unknown) => T): Array<SerializedSymbolProperty<T>>;
19
+ export declare function restoreSymbolProperties<T>(target: object, entries: Array<SerializedSymbolProperty<T>> | undefined, decode: (value: T) => unknown): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-js",
3
- "version": "0.1.157",
3
+ "version": "0.1.159",
4
4
  "description": "Budgeted JavaScript interpreter with explicit host capabilities and resumable execution",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@poe-platform/safe-fs": "0.1.157",
61
+ "@poe-platform/safe-fs": "0.1.159",
62
62
  "yaml": "^2.8.2",
63
63
  "jose": "^6.1.3",
64
64
  "@types/node": "^25.2.2"