poe-code 14.0.44 → 14.0.46
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 +96 -48
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-bash/dist/browser.js +72 -25
- package/packages/safe-bash/dist/browser.js.map +3 -3
- package/packages/safe-bash/dist/shell/parser.d.ts +3 -2
- package/packages/safe-bash/dist/shell/parser.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/parser.js +18 -21
- package/packages/safe-bash/dist/shell/parser.js.map +1 -1
- package/packages/safe-bash/dist/shell/runtime.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/runtime.js +14 -6
- package/packages/safe-bash/dist/shell/runtime.js.map +1 -1
- package/packages/safe-bash/dist/shell/shell.d.ts.map +1 -1
- package/packages/safe-bash/dist/shell/shell.js +4 -2
- package/packages/safe-bash/dist/shell/shell.js.map +1 -1
- package/packages/safe-bash/dist/shell/source-line-index.d.ts +10 -0
- package/packages/safe-bash/dist/shell/source-line-index.d.ts.map +1 -0
- package/packages/safe-bash/dist/shell/source-line-index.js +41 -0
- package/packages/safe-bash/dist/shell/source-line-index.js.map +1 -0
- package/packages/safe-js/dist/chunks/{chunk-2GJ635AB.js → chunk-WQY27BRL.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-JZXAWFPL.js → chunk-XC53RECY.js} +96 -49
- package/packages/safe-js/dist/chunks/chunk-XC53RECY.js.map +7 -0
- 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/budget.d.ts +1 -0
- package/packages/safe-js/dist/interp/budget.js +3 -0
- package/packages/safe-js/dist/interp/exceptions.d.ts +4 -0
- package/packages/safe-js/dist/interp/exceptions.js +68 -23
- package/packages/safe-js/dist/interp/interpreter.js +8 -30
- package/packages/safe-js/dist/interp/methods/function.js +5 -2
- package/packages/safe-js/dist/interp/patterns.js +2 -4
- package/packages/safe-js/dist/interp/values.d.ts +1 -1
- package/packages/safe-js/dist/interp/values.js +9 -4
- package/packages/safe-js/dist/chunks/chunk-JZXAWFPL.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-2GJ635AB.js.map → chunk-WQY27BRL.js.map} +0 -0
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-WQY27BRL.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-XC53RECY.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-WQY27BRL.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-XC53RECY.js";
|
|
54
54
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
55
55
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -34,6 +34,9 @@ export class SandboxError extends Error {
|
|
|
34
34
|
this.limit = input.limit;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
export function isFatalSandboxError(error) {
|
|
38
|
+
return (error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry"));
|
|
39
|
+
}
|
|
37
40
|
export class Budget {
|
|
38
41
|
deadline;
|
|
39
42
|
limits;
|
|
@@ -2,6 +2,7 @@ import type { BreakStatement, ContinueStatement, ParseResult, ThrowStatement, Tr
|
|
|
2
2
|
import { type SandboxErrorName, type ErrorSourceSpan } from "../error/shape.js";
|
|
3
3
|
import { type Budget } from "./budget.js";
|
|
4
4
|
import type { Scope } from "./scope.js";
|
|
5
|
+
import type { InterpreterError } from "./interpreter.js";
|
|
5
6
|
import { type SandboxObject, type SandboxValue } from "./values.js";
|
|
6
7
|
declare const capturedExceptionBrand: unique symbol;
|
|
7
8
|
export type { SandboxErrorName } from "../error/shape.js";
|
|
@@ -30,10 +31,13 @@ type ExceptionContext = {
|
|
|
30
31
|
callStack: readonly string[];
|
|
31
32
|
scope: Scope;
|
|
32
33
|
toPropertyKey?: (value: SandboxValue) => Promise<string>;
|
|
34
|
+
getProperty?: (value: SandboxValue, key: string | number) => SandboxValue;
|
|
33
35
|
};
|
|
34
36
|
type EvaluateExceptionNode<TContext, TError> = (node: ParseResult, context: TContext) => Promise<EvaluationResult<TError>>;
|
|
35
37
|
export declare function evaluateThrowStatement<TContext extends ExceptionContext, TError>(node: ThrowStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
|
|
36
38
|
export declare function evaluateTryStatement<TContext extends ExceptionContext, TError>(node: TryStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
|
|
39
|
+
export declare function createThrowCompletion(error: unknown, budget: Budget, stackFrames: readonly string[], span?: ErrorSourceSpan): CompletionResult;
|
|
40
|
+
export declare function isInterpreterError(value: unknown): value is InterpreterError;
|
|
37
41
|
export declare function createCapturedException(reason: unknown, stackFrames: readonly string[], sandbox?: boolean): CapturedException;
|
|
38
42
|
export declare function isCapturedException(value: unknown): value is CapturedException;
|
|
39
43
|
export declare function coerceThrownValue(reason: unknown, budget: Budget, stackFrames: readonly string[], span?: ErrorSourceSpan, sandbox?: boolean): SandboxValue;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { attachErrorSpan, attachWrappedErrorCause, describeThrownValue, formatErrorStack, readErrorCause, readErrorSpan, sandboxErrorNames, sandboxErrorTypes } from "../error/shape.js";
|
|
2
|
-
import { SandboxError } from "./budget.js";
|
|
2
|
+
import { isFatalSandboxError, SandboxError } from "./budget.js";
|
|
3
3
|
import { HostCallResumabilityError } from "./host-call.js";
|
|
4
4
|
import { withFatalPromiseCleanup } from "./promise-tracker.js";
|
|
5
|
-
import { deepCopyToSandbox } from "./values.js";
|
|
5
|
+
import { deepCopyToSandbox, ownEnumerableSandboxEntries } from "./values.js";
|
|
6
|
+
import { getSandboxDataProperty } from "./object-model.js";
|
|
6
7
|
import { toPropertyKey } from "./property-key.js";
|
|
7
8
|
const capturedExceptionBrand = Symbol("CapturedException");
|
|
8
9
|
export async function evaluateThrowStatement(node, context, evaluateNode) {
|
|
@@ -35,25 +36,70 @@ export async function evaluateTryStatement(node, context, evaluateNode) {
|
|
|
35
36
|
value: undefined
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let tryOrCatchResult = tryResult;
|
|
40
|
+
let catchFailure;
|
|
41
|
+
if (fatalBudgetError === undefined && tryResult.kind === "throw" && node.handler !== undefined) {
|
|
42
|
+
try {
|
|
43
|
+
tryOrCatchResult = await evaluateCatchClause(node.handler, tryResult.value, context, evaluateNode);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (isFatalSandboxError(error) || isInterpreterError(error) || error instanceof HostCallResumabilityError) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
catchFailure = createThrowCompletion(error, context.budget, context.callStack, node.span);
|
|
50
|
+
tryOrCatchResult = catchFailure;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
if (node.finalizer === undefined || tryOrCatchResult.kind === "error") {
|
|
42
54
|
return tryOrCatchResult;
|
|
43
55
|
}
|
|
44
56
|
const evaluateFinalizer = () => fatalBudgetError?.budget === "deadline"
|
|
45
57
|
? evaluateWithoutDeadlineChecks(context, () => evaluateBlockCompletion(node.finalizer, context, evaluateNode))
|
|
46
58
|
: evaluateBlockCompletion(node.finalizer, context, evaluateNode);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (fatalBudgetError !== undefined) {
|
|
51
|
-
throw fatalBudgetError;
|
|
59
|
+
if (catchFailure !== undefined) {
|
|
60
|
+
const value = catchFailure.value;
|
|
61
|
+
context.budget.setRetainedValues(catchFailure, () => [value]);
|
|
52
62
|
}
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
try {
|
|
64
|
+
const finalizerResult = await (fatalBudgetError === undefined
|
|
65
|
+
? evaluateFinalizer()
|
|
66
|
+
: withFatalPromiseCleanup(evaluateFinalizer));
|
|
67
|
+
if (fatalBudgetError !== undefined) {
|
|
68
|
+
throw fatalBudgetError;
|
|
69
|
+
}
|
|
70
|
+
if (finalizerResult.kind === "normal") {
|
|
71
|
+
return tryOrCatchResult;
|
|
72
|
+
}
|
|
73
|
+
return finalizerResult;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
if (catchFailure !== undefined)
|
|
77
|
+
context.budget.setRetainedValues(catchFailure, undefined);
|
|
55
78
|
}
|
|
56
|
-
|
|
79
|
+
}
|
|
80
|
+
export function createThrowCompletion(error, budget, stackFrames, span) {
|
|
81
|
+
const value = isCapturedException(error)
|
|
82
|
+
? coerceThrownValue(error.reason, budget, error.stackFrames, span, error.sandbox)
|
|
83
|
+
: coerceThrownValue(error, budget, stackFrames, span, true);
|
|
84
|
+
return {
|
|
85
|
+
kind: "throw",
|
|
86
|
+
hasValue: true,
|
|
87
|
+
span: readErrorSpan(value) ?? span,
|
|
88
|
+
stackFrames: isCapturedException(error) ? error.stackFrames : stackFrames,
|
|
89
|
+
value
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function isInterpreterError(value) {
|
|
93
|
+
return (typeof value === "object" &&
|
|
94
|
+
value !== null &&
|
|
95
|
+
hasOwnProperty(value, "code") &&
|
|
96
|
+
hasOwnProperty(value, "message") &&
|
|
97
|
+
hasOwnProperty(value, "nodeType") &&
|
|
98
|
+
hasOwnProperty(value, "span") &&
|
|
99
|
+
(value.code === "UNBOUND_IDENTIFIER" || value.code === "UNSUPPORTED_NODE"));
|
|
100
|
+
}
|
|
101
|
+
function hasOwnProperty(value, name) {
|
|
102
|
+
return Object.prototype.hasOwnProperty.call(value, name);
|
|
57
103
|
}
|
|
58
104
|
export function createCapturedException(reason, stackFrames, sandbox = false) {
|
|
59
105
|
return {
|
|
@@ -240,6 +286,9 @@ async function evaluateCatchClause(node, thrownValue, context, evaluateNode) {
|
|
|
240
286
|
scope
|
|
241
287
|
};
|
|
242
288
|
if (node.param !== undefined) {
|
|
289
|
+
for (const name of getPatternBindingNames(node.param)) {
|
|
290
|
+
scope.predeclare(name, "let");
|
|
291
|
+
}
|
|
243
292
|
const binding = await bindPattern(node.param, thrownValue, catchContext, evaluateNode);
|
|
244
293
|
if (!binding.ok) {
|
|
245
294
|
return binding.result;
|
|
@@ -351,8 +400,8 @@ async function bindArrayPattern(pattern, value, context, evaluateNode) {
|
|
|
351
400
|
return { ok: true };
|
|
352
401
|
}
|
|
353
402
|
async function bindObjectPattern(pattern, value, context, evaluateNode) {
|
|
354
|
-
if (
|
|
355
|
-
throw new TypeError("Object catch bindings require a non-
|
|
403
|
+
if (value === null || value === undefined) {
|
|
404
|
+
throw new TypeError("Object catch bindings require a non-nullish value.");
|
|
356
405
|
}
|
|
357
406
|
const excludedKeys = new Set();
|
|
358
407
|
for (const property of pattern.properties) {
|
|
@@ -369,7 +418,9 @@ async function bindObjectPattern(pattern, value, context, evaluateNode) {
|
|
|
369
418
|
return key;
|
|
370
419
|
}
|
|
371
420
|
excludedKeys.add(String(key.value));
|
|
372
|
-
const binding = await bindPattern(property.value,
|
|
421
|
+
const binding = await bindPattern(property.value, context.getProperty === undefined
|
|
422
|
+
? getSandboxDataProperty(value, key.value, context.budget)
|
|
423
|
+
: context.getProperty(value, key.value), context, evaluateNode);
|
|
373
424
|
if (!binding.ok) {
|
|
374
425
|
return binding;
|
|
375
426
|
}
|
|
@@ -406,15 +457,9 @@ function getStaticPropertyKey(property) {
|
|
|
406
457
|
throw new TypeError(`Unsupported catch binding property key '${property.type}'.`);
|
|
407
458
|
}
|
|
408
459
|
}
|
|
409
|
-
function getObjectPatternValue(value, key) {
|
|
410
|
-
return value[key];
|
|
411
|
-
}
|
|
412
460
|
function copyObjectRest(value, excludedKeys) {
|
|
413
461
|
const rest = Object.create(null);
|
|
414
|
-
for (const [key, entryValue] of
|
|
415
|
-
if (excludedKeys.has(key)) {
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
462
|
+
for (const [key, entryValue] of ownEnumerableSandboxEntries(value, excludedKeys)) {
|
|
418
463
|
rest[key] = entryValue;
|
|
419
464
|
}
|
|
420
465
|
return rest;
|
|
@@ -4,12 +4,12 @@ import { toPropertyKey } from "./property-key.js";
|
|
|
4
4
|
import { assertPromiseExecutionAllowed } from "./promise-tracker.js";
|
|
5
5
|
import { SandboxJobQueue, runAsyncPrefix, suspendJob } from "./jobs.js";
|
|
6
6
|
import { withCancellationSignal } from "./cancel.js";
|
|
7
|
-
import { attachErrorSpan, formatErrorStack,
|
|
7
|
+
import { attachErrorSpan, formatErrorStack, replaceErrorStack } from "../error/shape.js";
|
|
8
8
|
import { evaluateArrowFunctionExpression, evaluateFunctionExpression, evaluateAwaitExpression, emitResumeBreakpoint, createInterpretedClosure, normalizeClosureResult } from "./async.js";
|
|
9
9
|
import { HostCallResumabilityError } from "./host-call.js";
|
|
10
|
-
import { Budget, SandboxError } from "./budget.js";
|
|
10
|
+
import { Budget, isFatalSandboxError, SandboxError } from "./budget.js";
|
|
11
11
|
import { CompileScope, RegexCompileGuard } from "./regex/compile-guard.js";
|
|
12
|
-
import {
|
|
12
|
+
import { createCapturedException, createThrowCompletion, evaluateThrowStatement as evaluateThrowStatementResult, evaluateTryStatement as evaluateTryStatementResult, isCapturedException, isInterpreterError, surfaceThrownValue } from "./exceptions.js";
|
|
13
13
|
import { callArrayMethod, getArrayMember, isArrayMethodName } from "./methods/array.js";
|
|
14
14
|
import { getFunctionMember } from "./methods/function.js";
|
|
15
15
|
import { getGuestFunctionProperty, getSandboxPrototype, isGuestClosure, materializeFunctionProperties, setSandboxPrototype } from "./object-model.js";
|
|
@@ -222,17 +222,9 @@ async function evaluateNode(node, context) {
|
|
|
222
222
|
error
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
reconcileDataBudget(context.budget, context.stats, context.scope, exception, compilation, context.compilation);
|
|
229
|
-
return {
|
|
230
|
-
kind: "throw",
|
|
231
|
-
hasValue: true,
|
|
232
|
-
span: readErrorSpan(exception) ?? node.span,
|
|
233
|
-
stackFrames: isCapturedException(error) ? error.stackFrames : context.callStack,
|
|
234
|
-
value: exception
|
|
235
|
-
};
|
|
225
|
+
const completion = createThrowCompletion(error, context.budget, context.callStack, node.span);
|
|
226
|
+
reconcileDataBudget(context.budget, context.stats, context.scope, completion.value, compilation, context.compilation);
|
|
227
|
+
return completion;
|
|
236
228
|
}
|
|
237
229
|
finally {
|
|
238
230
|
compilation.dispose();
|
|
@@ -1537,7 +1529,8 @@ async function evaluateThrowStatement(node, context) {
|
|
|
1537
1529
|
async function evaluateTryStatement(node, context) {
|
|
1538
1530
|
return evaluateTryStatementResult(node, {
|
|
1539
1531
|
...context,
|
|
1540
|
-
toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(context))
|
|
1532
|
+
toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(context)),
|
|
1533
|
+
getProperty: (value, key) => getPropertyValue(value, key, context)
|
|
1541
1534
|
}, evaluateNode);
|
|
1542
1535
|
}
|
|
1543
1536
|
async function evaluateUnaryExpression(node, context) {
|
|
@@ -2666,18 +2659,6 @@ function defineSandboxProperty(target, key, value) {
|
|
|
2666
2659
|
writable: true
|
|
2667
2660
|
});
|
|
2668
2661
|
}
|
|
2669
|
-
function isInterpreterError(value) {
|
|
2670
|
-
return (typeof value === "object" &&
|
|
2671
|
-
value !== null &&
|
|
2672
|
-
hasOwnProperty(value, "code") &&
|
|
2673
|
-
hasOwnProperty(value, "message") &&
|
|
2674
|
-
hasOwnProperty(value, "nodeType") &&
|
|
2675
|
-
hasOwnProperty(value, "span") &&
|
|
2676
|
-
(value.code === "UNBOUND_IDENTIFIER" || value.code === "UNSUPPORTED_NODE"));
|
|
2677
|
-
}
|
|
2678
|
-
function hasOwnProperty(value, name) {
|
|
2679
|
-
return Object.prototype.hasOwnProperty.call(value, name);
|
|
2680
|
-
}
|
|
2681
2662
|
function wrapHostResult(result, stack, sandbox) {
|
|
2682
2663
|
if (!isPromiseLikeResult(result)) {
|
|
2683
2664
|
return result;
|
|
@@ -2689,9 +2670,6 @@ function wrapHostResult(result, stack, sandbox) {
|
|
|
2689
2670
|
function captureException(error, stack, sandbox) {
|
|
2690
2671
|
return isCapturedException(error) ? error : createCapturedException(error, stack, sandbox);
|
|
2691
2672
|
}
|
|
2692
|
-
function isFatalSandboxError(error) {
|
|
2693
|
-
return (error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry"));
|
|
2694
|
-
}
|
|
2695
2673
|
function isPromiseLikeResult(value) {
|
|
2696
2674
|
return typeof value === "object" && value !== null && "then" in value;
|
|
2697
2675
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSandboxClosure } from "../values.js";
|
|
1
|
+
import { createSandboxClosure, isSandboxClosure } from "../values.js";
|
|
2
2
|
import { getGuestFunctionProperty, isGuestClosure } from "../object-model.js";
|
|
3
3
|
const functionMethodNames = new Set(["apply", "bind", "call"]);
|
|
4
4
|
export function getFunctionMember(target, property, options) {
|
|
@@ -22,13 +22,16 @@ export function getFunctionMember(target, property, options) {
|
|
|
22
22
|
return createSandboxClosure({
|
|
23
23
|
sandbox: true,
|
|
24
24
|
name: `Function#${property}`,
|
|
25
|
-
call: (args, context) => callFunctionMethod(
|
|
25
|
+
call: (args, context) => callFunctionMethod(context?.thisValue, property, args, options, context?.stack ?? [])
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
function isFunctionMethodName(property) {
|
|
29
29
|
return typeof property === "string" && functionMethodNames.has(property);
|
|
30
30
|
}
|
|
31
31
|
function callFunctionMethod(target, methodName, args, options, stack) {
|
|
32
|
+
if (!isSandboxClosure(target)) {
|
|
33
|
+
throw new TypeError(`Function#${methodName} requires a callable receiver.`);
|
|
34
|
+
}
|
|
32
35
|
const thisValue = args[0];
|
|
33
36
|
if (methodName === "bind") {
|
|
34
37
|
const boundArgs = args.slice(1);
|
|
@@ -161,10 +161,8 @@ function describeRuntimeValue(value) {
|
|
|
161
161
|
}
|
|
162
162
|
function copyObjectRestValue(value, excludedKeys) {
|
|
163
163
|
const rest = Object.create(null);
|
|
164
|
-
for (const [key, entryValue] of ownEnumerableSandboxEntries(value)) {
|
|
165
|
-
|
|
166
|
-
defineProperty(rest, key, entryValue);
|
|
167
|
-
}
|
|
164
|
+
for (const [key, entryValue] of ownEnumerableSandboxEntries(value, excludedKeys)) {
|
|
165
|
+
defineProperty(rest, key, entryValue);
|
|
168
166
|
}
|
|
169
167
|
return rest;
|
|
170
168
|
}
|
|
@@ -104,7 +104,7 @@ export declare function createSandboxClosure(input: {
|
|
|
104
104
|
properties?: SandboxObject | ((closure: SandboxClosure) => SandboxObject);
|
|
105
105
|
retainedValues?: () => Iterable<SandboxValue>;
|
|
106
106
|
}): SandboxClosure;
|
|
107
|
-
export declare function ownEnumerableSandboxEntries(value: SandboxValue): Array<[string, SandboxValue]>;
|
|
107
|
+
export declare function ownEnumerableSandboxEntries(value: SandboxValue, excludedKeys?: ReadonlySet<string>): Array<[string, SandboxValue]>;
|
|
108
108
|
export declare function createSandboxPromise(promise: Promise<SandboxValue>, metadata?: {
|
|
109
109
|
trackReplay?: boolean;
|
|
110
110
|
synchronousPrefix?: Promise<void>;
|
|
@@ -73,10 +73,12 @@ export function createSandboxClosure(input) {
|
|
|
73
73
|
}
|
|
74
74
|
return Object.freeze(closure);
|
|
75
75
|
}
|
|
76
|
-
export function ownEnumerableSandboxEntries(value) {
|
|
76
|
+
export function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
77
77
|
if (isGuestHostObject(value)) {
|
|
78
78
|
const entries = [];
|
|
79
79
|
for (const key of getHostObjectKeys(value)) {
|
|
80
|
+
if (excludedKeys?.has(key))
|
|
81
|
+
continue;
|
|
80
82
|
if (hasHostObjectMember(value, key, true))
|
|
81
83
|
entries.push([key, getHostObjectMember(value, key)]);
|
|
82
84
|
}
|
|
@@ -84,11 +86,14 @@ export function ownEnumerableSandboxEntries(value) {
|
|
|
84
86
|
}
|
|
85
87
|
if (value === null || value === undefined)
|
|
86
88
|
throw new TypeError("Cannot convert undefined or null to object.");
|
|
89
|
+
let entries;
|
|
87
90
|
if (isGuestClosure(value))
|
|
88
|
-
|
|
89
|
-
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value))
|
|
91
|
+
entries = Object.entries(value.properties ?? {});
|
|
92
|
+
else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value))
|
|
90
93
|
return [];
|
|
91
|
-
|
|
94
|
+
else
|
|
95
|
+
entries = Object.entries(Object(value));
|
|
96
|
+
return excludedKeys === undefined ? entries : entries.filter(([key]) => !excludedKeys.has(key));
|
|
92
97
|
}
|
|
93
98
|
export function createSandboxPromise(promise, metadata = {}) {
|
|
94
99
|
const original = metadata.trackReplay === false
|