@poe-platform/safe-js 0.1.391 → 0.1.392
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/safe-js/chunks/{chunk-MT4D4J5E.js → chunk-GYLSKXNZ.js} +375 -51
- package/dist/safe-js/chunks/chunk-GYLSKXNZ.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-2H5CQNFL.js → chunk-VN2F4GHQ.js} +2 -2
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/generator-expression-state.d.ts +3 -0
- package/dist/safe-js/interp/patterns.d.ts +2 -0
- package/dist/safe-js/interp/private-state.d.ts +18 -0
- package/dist/safe-js/interp/scope.d.ts +5 -0
- package/dist/safe-js/parse/function-source.d.ts +1 -1
- package/dist/safe-js/parse/parser.d.ts +5 -1
- package/dist/safe-js/parse/tokenizer.d.ts +1 -1
- package/dist/safe-js/snapshot/array-buffer.d.ts +1 -1
- package/dist/safe-js/snapshot/data-view.d.ts +1 -1
- package/dist/safe-js/snapshot/guest-heap.d.ts +31 -0
- package/dist/safe-js/snapshot/typed-array.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-MT4D4J5E.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-2H5CQNFL.js.map → chunk-VN2F4GHQ.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-GYLSKXNZ.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-VN2F4GHQ.js.map
|
package/dist/safe-js/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-VN2F4GHQ.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-GYLSKXNZ.js";
|
|
38
38
|
import "./chunks/chunk-4YIDX44G.js";
|
|
39
39
|
|
|
40
40
|
// packages/safe-js/src/cli.ts
|
package/dist/safe-js/core.js
CHANGED
package/dist/safe-js/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runWithSpawnUsageAccumulator,
|
|
27
27
|
splitFrontmatter,
|
|
28
28
|
supportsSpawnMode
|
|
29
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-VN2F4GHQ.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-GYLSKXNZ.js";
|
|
54
54
|
import "./chunks/chunk-4YIDX44G.js";
|
|
55
55
|
|
|
56
56
|
// packages/safe-js/src/parse.ts
|
|
@@ -29,6 +29,7 @@ export type GeneratorExpressionState<T = SandboxValue, S = Scope, I = SandboxIte
|
|
|
29
29
|
current: T;
|
|
30
30
|
referenceObject?: T;
|
|
31
31
|
referenceKey?: T;
|
|
32
|
+
privateName?: string;
|
|
32
33
|
} | {
|
|
33
34
|
kind: "array-pattern";
|
|
34
35
|
phase: "reference" | "binding";
|
|
@@ -38,6 +39,7 @@ export type GeneratorExpressionState<T = SandboxValue, S = Scope, I = SandboxIte
|
|
|
38
39
|
iterator: I;
|
|
39
40
|
referenceObject?: T;
|
|
40
41
|
referenceKey?: T;
|
|
42
|
+
privateName?: string;
|
|
41
43
|
} | {
|
|
42
44
|
kind: "for-of-array";
|
|
43
45
|
phase: "left" | "body";
|
|
@@ -83,6 +85,7 @@ export type GeneratorExpressionState<T = SandboxValue, S = Scope, I = SandboxIte
|
|
|
83
85
|
current: T;
|
|
84
86
|
key?: T;
|
|
85
87
|
superReceiver?: T;
|
|
88
|
+
privateName?: string;
|
|
86
89
|
} | {
|
|
87
90
|
kind: "template";
|
|
88
91
|
prefix: string;
|
|
@@ -8,6 +8,7 @@ type Pattern = VariableDeclarator["id"] | AssignmentPattern | MemberExpression |
|
|
|
8
8
|
export type AssignmentReference = {
|
|
9
9
|
object: SandboxValue;
|
|
10
10
|
key: PropertyKey;
|
|
11
|
+
privateName?: string;
|
|
11
12
|
};
|
|
12
13
|
export type PatternTarget = {
|
|
13
14
|
kind: VariableDeclarationKind;
|
|
@@ -31,6 +32,7 @@ export type PatternContext = {
|
|
|
31
32
|
toPropertyKey(value: SandboxValue): string | symbol | Promise<string | symbol>;
|
|
32
33
|
getProperty(value: SandboxValue, key: PropertyKey): SandboxValue | Promise<SandboxValue>;
|
|
33
34
|
setProperty(target: SandboxValue, key: PropertyKey, value: SandboxValue): void | Promise<void>;
|
|
35
|
+
setPrivateProperty?(target: SandboxValue, name: string, value: SandboxValue): void | Promise<void>;
|
|
34
36
|
};
|
|
35
37
|
export type BindPatternResult = {
|
|
36
38
|
ok: true;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SandboxClosure, SandboxValue } from "./values.js";
|
|
2
|
+
export type PrivateName = {
|
|
3
|
+
readonly description: string;
|
|
4
|
+
};
|
|
5
|
+
export type PrivateElement = {
|
|
6
|
+
kind: "field";
|
|
7
|
+
value: SandboxValue;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "method";
|
|
10
|
+
value: SandboxClosure;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "accessor";
|
|
13
|
+
get?: SandboxClosure;
|
|
14
|
+
set?: SandboxClosure;
|
|
15
|
+
};
|
|
16
|
+
export declare const privateElements: WeakMap<object, Map<PrivateName, PrivateElement>>;
|
|
17
|
+
export declare function findPrivateElement(receiver: SandboxValue, name: PrivateName): PrivateElement | undefined;
|
|
18
|
+
export declare function addPrivateElement(receiver: SandboxValue, name: PrivateName, element: PrivateElement): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { VariableDeclarationKind } from "../parse.js";
|
|
2
|
+
import type { PrivateName } from "./private-state.js";
|
|
2
3
|
import type { InterpreterSnapshot, InterpreterValue } from "./interpreter.js";
|
|
3
4
|
type ScopeLookupResult = {
|
|
4
5
|
found: true;
|
|
@@ -12,6 +13,7 @@ type ScopeOptions = {
|
|
|
12
13
|
chargeData?: boolean;
|
|
13
14
|
};
|
|
14
15
|
export type ScopeFrame = {
|
|
16
|
+
privateNames?: Array<[string, PrivateName]>;
|
|
15
17
|
parent?: Scope;
|
|
16
18
|
importMeta?: InterpreterValue;
|
|
17
19
|
functionBoundary: boolean;
|
|
@@ -32,8 +34,11 @@ export declare class Scope {
|
|
|
32
34
|
private readonly parent?;
|
|
33
35
|
private importMeta?;
|
|
34
36
|
private readonly options;
|
|
37
|
+
privateNames?: Map<string, PrivateName>;
|
|
35
38
|
constructor(bindings?: Record<string, InterpreterValue>, parent?: Scope | undefined, importMeta?: InterpreterValue, options?: ScopeOptions, restoredBindings?: Record<string, InterpreterValue>);
|
|
36
39
|
child(bindings?: Record<string, InterpreterValue>, options?: ScopeOptions): Scope;
|
|
40
|
+
declarePrivateName(description: string): PrivateName;
|
|
41
|
+
resolvePrivateName(description: string): PrivateName;
|
|
37
42
|
consumeRestoredBinding(name: string): {
|
|
38
43
|
found: true;
|
|
39
44
|
value: InterpreterValue;
|
|
@@ -19,6 +19,10 @@ export type Identifier = BaseNode & {
|
|
|
19
19
|
type: "Identifier";
|
|
20
20
|
name: string;
|
|
21
21
|
};
|
|
22
|
+
export type PrivateIdentifier = BaseNode & {
|
|
23
|
+
type: "PrivateIdentifier";
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
22
26
|
export type ThisExpression = BaseNode & {
|
|
23
27
|
type: "ThisExpression";
|
|
24
28
|
};
|
|
@@ -397,7 +401,7 @@ export type ArrowFunctionExpression = BaseNode & {
|
|
|
397
401
|
params: Array<AssignmentPattern | ArrayPattern | Identifier | ObjectPattern | RestElement>;
|
|
398
402
|
};
|
|
399
403
|
export type FunctionNode = ArrowFunctionExpression | FunctionDeclaration | FunctionExpression;
|
|
400
|
-
export type Expression = ArrowFunctionExpression | AssignmentExpression | ArrayExpression | AwaitExpression | BinaryExpression | BooleanLiteral | CallExpression | ConditionalExpression | ClassExpression | FunctionExpression | Identifier | LogicalExpression | MemberExpression | MetaProperty | NewExpression | NewTargetExpression | NullLiteral | NumericLiteral | BigIntLiteral | ObjectExpression | RegexLiteral | SequenceExpression | StringLiteral | SuperExpression | TaggedTemplateExpression | TemplateLiteral | ThisExpression | UnaryExpression | UpdateExpression | UndefinedLiteral | YieldExpression;
|
|
404
|
+
export type Expression = ArrowFunctionExpression | AssignmentExpression | ArrayExpression | AwaitExpression | BinaryExpression | BooleanLiteral | CallExpression | ConditionalExpression | ClassExpression | FunctionExpression | Identifier | PrivateIdentifier | LogicalExpression | MemberExpression | MetaProperty | NewExpression | NewTargetExpression | NullLiteral | NumericLiteral | BigIntLiteral | ObjectExpression | RegexLiteral | SequenceExpression | StringLiteral | SuperExpression | TaggedTemplateExpression | TemplateLiteral | ThisExpression | UnaryExpression | UpdateExpression | UndefinedLiteral | YieldExpression;
|
|
401
405
|
export type ParseResult = Expression | Statement;
|
|
402
406
|
export declare function parse(source: string, filename?: string, owner?: CompileOwner): ParseResult;
|
|
403
407
|
export declare function parseModule(source: string, filename?: string, owner?: CompileOwner): Module;
|
|
@@ -4,7 +4,7 @@ export type Position = {
|
|
|
4
4
|
column: number;
|
|
5
5
|
offset: number;
|
|
6
6
|
};
|
|
7
|
-
export type TokenType = "identifier" | "keyword" | "numeric" | "regex" | "string" | "template" | "punctuator" | "eof";
|
|
7
|
+
export type TokenType = "identifier" | "private-identifier" | "keyword" | "numeric" | "regex" | "string" | "template" | "punctuator" | "eof";
|
|
8
8
|
export type Token = {
|
|
9
9
|
type: TokenType;
|
|
10
10
|
value: string;
|
|
@@ -3,6 +3,7 @@ import { type CollectionIterationMethod } from "../interp/collection-iterator.js
|
|
|
3
3
|
import { type IteratorHelperState } from "../interp/iterator-helper.js";
|
|
4
4
|
import { type ScopeFrame } from "../interp/scope.js";
|
|
5
5
|
import { type PropertyDescriptorData } from "./property-descriptors.js";
|
|
6
|
+
import { type PrivateName, type PrivateElement } from "../interp/private-state.js";
|
|
6
7
|
import type { CompletionResult } from "../interp/exceptions.js";
|
|
7
8
|
import type { GeneratorExpressionState } from "../interp/generator-expression-state.js";
|
|
8
9
|
import { type IteratorSnapshot } from "../interp/iteration.js";
|
|
@@ -14,8 +15,32 @@ export type GeneratorFinallyCompletion<T> = Omit<CompletionResult, "value" | "no
|
|
|
14
15
|
export type GuestObjectState<T> = {
|
|
15
16
|
properties: PropertyDescriptorData<T>;
|
|
16
17
|
prototype?: T;
|
|
18
|
+
privateElements?: PrivateElementData<T>[];
|
|
17
19
|
};
|
|
20
|
+
export type PrivateElementData<T> = {
|
|
21
|
+
name: T;
|
|
22
|
+
} & ({
|
|
23
|
+
kind: "field" | "method";
|
|
24
|
+
value: T;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "accessor";
|
|
27
|
+
get: T;
|
|
28
|
+
set: T;
|
|
29
|
+
});
|
|
18
30
|
export type GuestHeapNode<T> = {
|
|
31
|
+
kind: "guest-regex";
|
|
32
|
+
source: string;
|
|
33
|
+
flags: string;
|
|
34
|
+
state: GuestObjectState<T>;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "guest-boxed";
|
|
37
|
+
value: T;
|
|
38
|
+
state: GuestObjectState<T>;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "guest-date";
|
|
41
|
+
value: T;
|
|
42
|
+
state: GuestObjectState<T>;
|
|
43
|
+
} | {
|
|
19
44
|
kind: "iterator-helper";
|
|
20
45
|
method: IteratorHelperState["method"];
|
|
21
46
|
status: "start" | "yield" | "done";
|
|
@@ -82,18 +107,22 @@ export type GuestHeapNode<T> = {
|
|
|
82
107
|
fields: Array<{
|
|
83
108
|
index: number;
|
|
84
109
|
key: T;
|
|
110
|
+
privateName?: T;
|
|
85
111
|
}>;
|
|
112
|
+
privateMethods?: PrivateElementData<T>[];
|
|
86
113
|
state: GuestObjectState<T>;
|
|
87
114
|
} | {
|
|
88
115
|
kind: "map";
|
|
89
116
|
entries: Array<[T, T]>;
|
|
90
117
|
propertyState?: PropertyDescriptorData<T>;
|
|
91
118
|
prototype?: T;
|
|
119
|
+
privateElements?: PrivateElementData<T>[];
|
|
92
120
|
} | {
|
|
93
121
|
kind: "set";
|
|
94
122
|
values: T[];
|
|
95
123
|
propertyState?: PropertyDescriptorData<T>;
|
|
96
124
|
prototype?: T;
|
|
125
|
+
privateElements?: PrivateElementData<T>[];
|
|
97
126
|
} | {
|
|
98
127
|
kind: "raw-json";
|
|
99
128
|
text: string;
|
|
@@ -147,6 +176,7 @@ export type GuestHeapNode<T> = {
|
|
|
147
176
|
importMeta: T;
|
|
148
177
|
functionBoundary: boolean;
|
|
149
178
|
chargeData: boolean;
|
|
179
|
+
privateNames?: Array<[string, T]>;
|
|
150
180
|
bindings: Array<[string, number]>;
|
|
151
181
|
cells: Array<{
|
|
152
182
|
kind: ScopeFrame["cells"][number]["kind"];
|
|
@@ -159,3 +189,4 @@ export type GuestHeapNode<T> = {
|
|
|
159
189
|
restoredBindings?: Array<[string, T]>;
|
|
160
190
|
};
|
|
161
191
|
export declare function captureGuestHeapNode<T>(value: object, encode: (value: unknown) => T): GuestHeapNode<T> | undefined;
|
|
192
|
+
export declare function capturePrivateElements<T>(elements: Map<PrivateName, PrivateElement>, encode: (value: unknown) => T): PrivateElementData<T>[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { numericTypedArrayConstructors, type NumericTypedArray } from "../interp/typed-array.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type GuestObjectState } from "./guest-heap.js";
|
|
3
3
|
import type { Budget } from "../interp/budget.js";
|
|
4
4
|
export declare function captureTypedArrayState<T>(value: NumericTypedArray, encode: (value: unknown) => T): GuestObjectState<T>;
|
|
5
5
|
export declare function restoreTypedArrayProperties<T>(value: NumericTypedArray, state: GuestObjectState<T>, 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.
|
|
3
|
+
"version": "0.1.392",
|
|
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.
|
|
61
|
+
"@poe-platform/safe-fs": "0.1.392",
|
|
62
62
|
"@petamoriken/float16": "^3.9.3",
|
|
63
63
|
"yaml": "^2.8.2",
|
|
64
64
|
"jose": "^6.1.3",
|