poe-code 14.0.39 → 14.0.41
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 +238 -191
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-CSC4EXIV.js → chunk-5J6BX3HD.js} +225 -179
- package/packages/safe-js/dist/chunks/chunk-5J6BX3HD.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-QXSG4XRW.js → chunk-L4NMOY6O.js} +2 -2
- 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/async.d.ts +1 -0
- package/packages/safe-js/dist/interp/async.js +29 -26
- package/packages/safe-js/dist/interp/interpreter.d.ts +1 -0
- package/packages/safe-js/dist/interp/interpreter.js +51 -8
- package/packages/safe-js/dist/parse/parser.js +13 -17
- package/packages/safe-js/dist/snapshot/restore.js +20 -8
- package/packages/safe-js/dist/chunks/chunk-CSC4EXIV.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-QXSG4XRW.js.map → chunk-L4NMOY6O.js.map} +0 -0
package/package.json
CHANGED
|
@@ -3554,9 +3554,9 @@ var Parser = class {
|
|
|
3554
3554
|
};
|
|
3555
3555
|
}
|
|
3556
3556
|
const token = this.currentToken();
|
|
3557
|
-
if (token.type === "identifier") {
|
|
3557
|
+
if (token.type === "identifier" || token.type === "keyword") {
|
|
3558
3558
|
this.index += 1;
|
|
3559
|
-
const key =
|
|
3559
|
+
const key = createIdentifierName(token);
|
|
3560
3560
|
if (this.consumePunctuator(":") !== void 0) {
|
|
3561
3561
|
const value2 = this.parseBindingElement();
|
|
3562
3562
|
if (value2.type === "RestElement") {
|
|
@@ -3571,6 +3571,7 @@ var Parser = class {
|
|
|
3571
3571
|
span: createSpan2(key.span.start, value2.span.end)
|
|
3572
3572
|
};
|
|
3573
3573
|
}
|
|
3574
|
+
if (!isIdentifierLikeToken(token)) throw unexpectedTokenError(token);
|
|
3574
3575
|
let value = key;
|
|
3575
3576
|
if (this.consumePunctuator("=") !== void 0) {
|
|
3576
3577
|
const right = this.parseExpression().node;
|
|
@@ -3783,9 +3784,9 @@ var Parser = class {
|
|
|
3783
3784
|
};
|
|
3784
3785
|
}
|
|
3785
3786
|
const token = this.currentToken();
|
|
3786
|
-
if (token.type === "identifier") {
|
|
3787
|
+
if (token.type === "identifier" || token.type === "keyword") {
|
|
3787
3788
|
this.index += 1;
|
|
3788
|
-
const key =
|
|
3789
|
+
const key = createIdentifierName(token);
|
|
3789
3790
|
if (this.consumePunctuator(":") !== void 0) {
|
|
3790
3791
|
const value2 = this.parseAssignmentPatternElement();
|
|
3791
3792
|
if (value2.type === "RestElement") {
|
|
@@ -3800,6 +3801,7 @@ var Parser = class {
|
|
|
3800
3801
|
span: createSpan2(key.span.start, value2.span.end)
|
|
3801
3802
|
};
|
|
3802
3803
|
}
|
|
3804
|
+
if (!isIdentifierLikeToken(token)) throw unexpectedTokenError(token);
|
|
3803
3805
|
let value = key;
|
|
3804
3806
|
if (this.consumePunctuator("=") !== void 0) {
|
|
3805
3807
|
const right = this.parseAssignmentExpression().node;
|
|
@@ -4448,9 +4450,9 @@ var Parser = class {
|
|
|
4448
4450
|
};
|
|
4449
4451
|
}
|
|
4450
4452
|
const token = this.currentToken();
|
|
4451
|
-
if (
|
|
4453
|
+
if (token.type === "identifier" || token.type === "keyword") {
|
|
4452
4454
|
this.index += 1;
|
|
4453
|
-
const key =
|
|
4455
|
+
const key = createIdentifierName(token);
|
|
4454
4456
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === "(") {
|
|
4455
4457
|
const value2 = this.parseObjectMethod(asyncToken, key.span.start);
|
|
4456
4458
|
return {
|
|
@@ -4463,6 +4465,7 @@ var Parser = class {
|
|
|
4463
4465
|
};
|
|
4464
4466
|
}
|
|
4465
4467
|
if (this.consumePunctuator(":") === void 0) {
|
|
4468
|
+
if (!isIdentifierLikeToken(token)) throw unexpectedTokenError(token);
|
|
4466
4469
|
assertAllowedIdentifierReference(token);
|
|
4467
4470
|
return {
|
|
4468
4471
|
type: "Property",
|
|
@@ -5874,10 +5877,7 @@ function rebasePosition(position, base) {
|
|
|
5874
5877
|
};
|
|
5875
5878
|
}
|
|
5876
5879
|
function isLiteralPropertyKey(token) {
|
|
5877
|
-
|
|
5878
|
-
return true;
|
|
5879
|
-
}
|
|
5880
|
-
return token.type === "keyword" && (token.value === "true" || token.value === "false" || token.value === "null" || token.value === "undefined");
|
|
5880
|
+
return token.type === "numeric" || token.type === "string";
|
|
5881
5881
|
}
|
|
5882
5882
|
function isIdentifierLikeToken(token) {
|
|
5883
5883
|
return token.type === "identifier" || token.type === "keyword" && token.value === "async";
|
|
@@ -25081,6 +25081,134 @@ function isObjectLike(value) {
|
|
|
25081
25081
|
return typeof value === "object" && value !== null;
|
|
25082
25082
|
}
|
|
25083
25083
|
|
|
25084
|
+
// packages/safe-js/src/interp/globals/object.ts
|
|
25085
|
+
function createObjectGlobal(methods, budget) {
|
|
25086
|
+
const construct = ([value]) => {
|
|
25087
|
+
if (value === null || value === void 0) {
|
|
25088
|
+
budget.chargeDataUsage(1);
|
|
25089
|
+
return /* @__PURE__ */ Object.create(null);
|
|
25090
|
+
}
|
|
25091
|
+
if (typeof value !== "object") throw new TypeError("Object primitive boxing is not supported.");
|
|
25092
|
+
return value;
|
|
25093
|
+
};
|
|
25094
|
+
const constructor = createSandboxClosure({
|
|
25095
|
+
guest: true,
|
|
25096
|
+
sandbox: true,
|
|
25097
|
+
name: "Object",
|
|
25098
|
+
length: 1,
|
|
25099
|
+
call: construct,
|
|
25100
|
+
construct
|
|
25101
|
+
});
|
|
25102
|
+
const properties = materializeFunctionProperties(constructor);
|
|
25103
|
+
const prototype = properties.prototype;
|
|
25104
|
+
Object.defineProperty(properties, "prototype", { writable: false });
|
|
25105
|
+
for (const [name, method] of Object.entries(methods)) {
|
|
25106
|
+
Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
|
|
25107
|
+
}
|
|
25108
|
+
const prototypeMethods = {
|
|
25109
|
+
toString: createSandboxClosure({
|
|
25110
|
+
sandbox: true,
|
|
25111
|
+
name: "toString",
|
|
25112
|
+
length: 0,
|
|
25113
|
+
call: (_args, context) => budget.allocateString(`[object ${typeTag(context?.thisValue)}]`)
|
|
25114
|
+
}),
|
|
25115
|
+
valueOf: createSandboxClosure({
|
|
25116
|
+
sandbox: true,
|
|
25117
|
+
name: "valueOf",
|
|
25118
|
+
length: 0,
|
|
25119
|
+
call: (_args, context) => {
|
|
25120
|
+
const value = requireReceiver(context?.thisValue);
|
|
25121
|
+
if (typeof value !== "object")
|
|
25122
|
+
throw new TypeError("Object primitive boxing is not supported.");
|
|
25123
|
+
return value;
|
|
25124
|
+
}
|
|
25125
|
+
}),
|
|
25126
|
+
hasOwnProperty: createSandboxClosure({
|
|
25127
|
+
sandbox: true,
|
|
25128
|
+
name: "hasOwnProperty",
|
|
25129
|
+
length: 1,
|
|
25130
|
+
call: async ([key], context) => hasOwnSandboxProperty(
|
|
25131
|
+
requireReceiver(context?.thisValue),
|
|
25132
|
+
await sandboxString(key, budget, context),
|
|
25133
|
+
false
|
|
25134
|
+
)
|
|
25135
|
+
}),
|
|
25136
|
+
propertyIsEnumerable: createSandboxClosure({
|
|
25137
|
+
sandbox: true,
|
|
25138
|
+
name: "propertyIsEnumerable",
|
|
25139
|
+
length: 1,
|
|
25140
|
+
call: async ([key], context) => hasOwnSandboxProperty(
|
|
25141
|
+
requireReceiver(context?.thisValue),
|
|
25142
|
+
await sandboxString(key, budget, context),
|
|
25143
|
+
true
|
|
25144
|
+
)
|
|
25145
|
+
}),
|
|
25146
|
+
isPrototypeOf: createSandboxClosure({
|
|
25147
|
+
sandbox: true,
|
|
25148
|
+
name: "isPrototypeOf",
|
|
25149
|
+
length: 1,
|
|
25150
|
+
call: ([value], context) => {
|
|
25151
|
+
if (typeof value !== "object" || value === null) return false;
|
|
25152
|
+
const receiver = requireReceiver(context?.thisValue);
|
|
25153
|
+
let depth = 0;
|
|
25154
|
+
for (let current = getSandboxPrototype(value, budget); current !== null; current = getSandboxPrototype(current, budget)) {
|
|
25155
|
+
budget.visitNode();
|
|
25156
|
+
assertSandboxDataDepth(depth++);
|
|
25157
|
+
if (current === receiver) return true;
|
|
25158
|
+
}
|
|
25159
|
+
return false;
|
|
25160
|
+
}
|
|
25161
|
+
})
|
|
25162
|
+
};
|
|
25163
|
+
for (const [name, method] of Object.entries(prototypeMethods)) {
|
|
25164
|
+
Object.defineProperty(prototype, name, { value: method, writable: true, configurable: true });
|
|
25165
|
+
}
|
|
25166
|
+
markDescriptorObject(prototype);
|
|
25167
|
+
installObjectPrototype(budget, prototype, constructor);
|
|
25168
|
+
return constructor;
|
|
25169
|
+
}
|
|
25170
|
+
function requireReceiver(value) {
|
|
25171
|
+
if (value === null || value === void 0)
|
|
25172
|
+
throw new TypeError("Object method requires a non-null receiver.");
|
|
25173
|
+
return value;
|
|
25174
|
+
}
|
|
25175
|
+
function hasOwnSandboxProperty(value, key, enumerable) {
|
|
25176
|
+
requireReceiver(value);
|
|
25177
|
+
if (isGuestHostObject(value)) return hasHostObjectMember(value, key, enumerable);
|
|
25178
|
+
let properties;
|
|
25179
|
+
if (isGuestClosure(value)) properties = materializeFunctionProperties(value);
|
|
25180
|
+
else if (isSandboxClosure(value)) {
|
|
25181
|
+
if (key === "length" || key === "name") return !enumerable;
|
|
25182
|
+
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
25183
|
+
} else if (isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxGenerator(value))
|
|
25184
|
+
return false;
|
|
25185
|
+
else if (isSandboxRegex(value)) return key === "lastIndex" && !enumerable;
|
|
25186
|
+
else properties = Object(value);
|
|
25187
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
25188
|
+
return descriptor !== void 0 && (!enumerable || descriptor.enumerable === true);
|
|
25189
|
+
}
|
|
25190
|
+
function typeTag(value) {
|
|
25191
|
+
if (value === void 0) return "Undefined";
|
|
25192
|
+
if (value === null) return "Null";
|
|
25193
|
+
if (typeof value === "string") return "String";
|
|
25194
|
+
if (typeof value === "number") return "Number";
|
|
25195
|
+
if (typeof value === "boolean") return "Boolean";
|
|
25196
|
+
if (isSandboxClosure(value)) {
|
|
25197
|
+
while (value.boundTarget !== void 0) value = value.boundTarget;
|
|
25198
|
+
return value.generator ? "GeneratorFunction" : value.async ? "AsyncFunction" : "Function";
|
|
25199
|
+
}
|
|
25200
|
+
if (Array.isArray(value)) return "Array";
|
|
25201
|
+
if (isSandboxDate(value)) return "Date";
|
|
25202
|
+
if (isSandboxErrorConstructorInstance(value, "Error")) return "Error";
|
|
25203
|
+
if (isSandboxRegex(value)) return "RegExp";
|
|
25204
|
+
if (isSandboxMap(value)) return "Map";
|
|
25205
|
+
if (isSandboxSet(value)) return "Set";
|
|
25206
|
+
if (isSandboxPromise(value)) return "Promise";
|
|
25207
|
+
if (isSandboxGenerator(value)) return "Generator";
|
|
25208
|
+
if (isFloat32Array(value)) return "Float32Array";
|
|
25209
|
+
return "Object";
|
|
25210
|
+
}
|
|
25211
|
+
|
|
25084
25212
|
// packages/safe-js/src/interp/globals/collections.ts
|
|
25085
25213
|
var mapConstructors = /* @__PURE__ */ new WeakSet();
|
|
25086
25214
|
var setConstructors = /* @__PURE__ */ new WeakSet();
|
|
@@ -25712,6 +25840,7 @@ async function interpret(node, options = {}) {
|
|
|
25712
25840
|
budget,
|
|
25713
25841
|
callStack: [],
|
|
25714
25842
|
onYield: options.onYield,
|
|
25843
|
+
onSuspend: options.onSuspend,
|
|
25715
25844
|
captureReplayState: options.captureReplayState,
|
|
25716
25845
|
rootNode: node,
|
|
25717
25846
|
scope,
|
|
@@ -26083,11 +26212,14 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
26083
26212
|
if (right.kind !== "normal") {
|
|
26084
26213
|
return right;
|
|
26085
26214
|
}
|
|
26086
|
-
|
|
26087
|
-
|
|
26088
|
-
|
|
26089
|
-
|
|
26090
|
-
|
|
26215
|
+
let leftValue = left.value;
|
|
26216
|
+
if (node.operator === "in") {
|
|
26217
|
+
if (typeof right.value !== "object" || right.value === null) {
|
|
26218
|
+
throw new TypeError("Right-hand side of 'in' must be an object.");
|
|
26219
|
+
}
|
|
26220
|
+
leftValue = await toPropertyKey(leftValue, context);
|
|
26221
|
+
}
|
|
26222
|
+
const value = applyBinaryOperator(node, leftValue, right.value, context);
|
|
26091
26223
|
return {
|
|
26092
26224
|
kind: "normal",
|
|
26093
26225
|
hasValue: true,
|
|
@@ -27795,8 +27927,43 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
27795
27927
|
}
|
|
27796
27928
|
return false;
|
|
27797
27929
|
case "in":
|
|
27798
|
-
|
|
27930
|
+
return hasSandboxProperty(right, left, context);
|
|
27931
|
+
}
|
|
27932
|
+
}
|
|
27933
|
+
async function toPropertyKey(value, context) {
|
|
27934
|
+
if (isPlainSandboxObject(value) && !isSandboxDate(value) && !isFloat32Array(value) && !isSandboxGenerator(value) && !isGuestHostObject(value)) {
|
|
27935
|
+
for (const name of ["toString", "valueOf"]) {
|
|
27936
|
+
const method = getMemberValue(value, name, context);
|
|
27937
|
+
if (!isSandboxClosure(method)) continue;
|
|
27938
|
+
const primitive = await invokeSandboxClosure(method, [], context, context.callStack, void 0, value);
|
|
27939
|
+
if (primitive === null || typeof primitive !== "object") {
|
|
27940
|
+
return context.budget.allocateString(String(primitive));
|
|
27941
|
+
}
|
|
27942
|
+
}
|
|
27943
|
+
throw new TypeError("Cannot convert object to primitive value.");
|
|
27944
|
+
}
|
|
27945
|
+
return sandboxString(value, context.budget, {
|
|
27946
|
+
stack: context.callStack,
|
|
27947
|
+
thisValue: void 0,
|
|
27948
|
+
invokeClosure: (closure, args, thisValue) => invokeSandboxClosure(closure, args, context, context.callStack, void 0, thisValue)
|
|
27949
|
+
});
|
|
27950
|
+
}
|
|
27951
|
+
function hasSandboxProperty(value, key, context) {
|
|
27952
|
+
let current = value;
|
|
27953
|
+
let depth = 0;
|
|
27954
|
+
while (typeof current === "object" && current !== null) {
|
|
27955
|
+
if (isGuestHostObject(current)) return hasHostObjectMember(current, key);
|
|
27956
|
+
if (hasOwnSandboxProperty(current, key, false)) return true;
|
|
27957
|
+
if (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current)) {
|
|
27958
|
+
return getPropertyValue(current, key, context) !== void 0;
|
|
27959
|
+
}
|
|
27960
|
+
current = getSandboxPrototype(current, context.budget);
|
|
27961
|
+
if (current !== null) {
|
|
27962
|
+
context.budget.visitNode();
|
|
27963
|
+
assertSandboxDataDepth(++depth);
|
|
27964
|
+
}
|
|
27799
27965
|
}
|
|
27966
|
+
return false;
|
|
27800
27967
|
}
|
|
27801
27968
|
async function applyCompoundAssignmentOperator(operator, left, right, context) {
|
|
27802
27969
|
left = await toNumericPrimitive(left, context);
|
|
@@ -28393,44 +28560,51 @@ function createInterpretedClosure(node, context, evaluateNode2) {
|
|
|
28393
28560
|
};
|
|
28394
28561
|
if (!node.async)
|
|
28395
28562
|
return executeClosure(node, args, callContext?.thisValue, invocationContext, evaluateNode2);
|
|
28396
|
-
|
|
28397
|
-
|
|
28398
|
-
|
|
28399
|
-
|
|
28400
|
-
|
|
28401
|
-
|
|
28402
|
-
|
|
28403
|
-
|
|
28404
|
-
|
|
28405
|
-
|
|
28406
|
-
|
|
28407
|
-
{ ...invocationContext, onSuspend: completePrefix },
|
|
28408
|
-
evaluateNode2
|
|
28409
|
-
);
|
|
28410
|
-
resolve(
|
|
28411
|
-
isSandboxPromise(value) || getThenable(value) !== void 0 ? awaitSandboxValue(
|
|
28412
|
-
createSandboxPromise(resolveSandboxValue(value, { budget: context.budget }), {
|
|
28413
|
-
trackReplay: false
|
|
28414
|
-
}),
|
|
28415
|
-
context.signal,
|
|
28416
|
-
context.budget
|
|
28417
|
-
) : allocateProducedSandboxValue(value, context.budget)
|
|
28418
|
-
);
|
|
28419
|
-
} catch (error) {
|
|
28420
|
-
reject(error);
|
|
28421
|
-
} finally {
|
|
28422
|
-
completePrefix();
|
|
28423
|
-
}
|
|
28424
|
-
}).catch((error) => {
|
|
28425
|
-
reject(error);
|
|
28426
|
-
completePrefix();
|
|
28427
|
-
});
|
|
28428
|
-
});
|
|
28429
|
-
return createSandboxPromise(promise, { synchronousPrefix });
|
|
28563
|
+
return executeAsyncFunction(
|
|
28564
|
+
(onSuspend) => executeClosure(
|
|
28565
|
+
node,
|
|
28566
|
+
args,
|
|
28567
|
+
callContext?.thisValue,
|
|
28568
|
+
{ ...invocationContext, onSuspend },
|
|
28569
|
+
evaluateNode2
|
|
28570
|
+
),
|
|
28571
|
+
context.budget,
|
|
28572
|
+
context.signal
|
|
28573
|
+
);
|
|
28430
28574
|
}
|
|
28431
28575
|
});
|
|
28432
28576
|
return closure;
|
|
28433
28577
|
}
|
|
28578
|
+
function executeAsyncFunction(execute, budget, signal) {
|
|
28579
|
+
let completePrefix;
|
|
28580
|
+
const synchronousPrefix = new Promise((resolve) => {
|
|
28581
|
+
completePrefix = resolve;
|
|
28582
|
+
});
|
|
28583
|
+
const promise = new Promise((resolve, reject) => {
|
|
28584
|
+
runAsyncPrefix(async () => {
|
|
28585
|
+
try {
|
|
28586
|
+
const value = await execute(completePrefix);
|
|
28587
|
+
resolve(
|
|
28588
|
+
isSandboxPromise(value) || getThenable(value) !== void 0 ? awaitSandboxValue(
|
|
28589
|
+
createSandboxPromise(resolveSandboxValue(value, { budget }), {
|
|
28590
|
+
trackReplay: false
|
|
28591
|
+
}),
|
|
28592
|
+
signal,
|
|
28593
|
+
budget
|
|
28594
|
+
) : allocateProducedSandboxValue(value, budget)
|
|
28595
|
+
);
|
|
28596
|
+
} catch (error) {
|
|
28597
|
+
reject(error);
|
|
28598
|
+
} finally {
|
|
28599
|
+
completePrefix();
|
|
28600
|
+
}
|
|
28601
|
+
}).catch((error) => {
|
|
28602
|
+
reject(error);
|
|
28603
|
+
completePrefix();
|
|
28604
|
+
});
|
|
28605
|
+
});
|
|
28606
|
+
return createSandboxPromise(promise, { synchronousPrefix });
|
|
28607
|
+
}
|
|
28434
28608
|
function createGeneratorClosure(node, context, evaluateNode2) {
|
|
28435
28609
|
return createSandboxClosure({
|
|
28436
28610
|
guest: true,
|
|
@@ -30094,134 +30268,6 @@ function assertStructuredCloneable(value, seen) {
|
|
|
30094
30268
|
}
|
|
30095
30269
|
}
|
|
30096
30270
|
|
|
30097
|
-
// packages/safe-js/src/interp/globals/object.ts
|
|
30098
|
-
function createObjectGlobal(methods, budget) {
|
|
30099
|
-
const construct = ([value]) => {
|
|
30100
|
-
if (value === null || value === void 0) {
|
|
30101
|
-
budget.chargeDataUsage(1);
|
|
30102
|
-
return /* @__PURE__ */ Object.create(null);
|
|
30103
|
-
}
|
|
30104
|
-
if (typeof value !== "object") throw new TypeError("Object primitive boxing is not supported.");
|
|
30105
|
-
return value;
|
|
30106
|
-
};
|
|
30107
|
-
const constructor = createSandboxClosure({
|
|
30108
|
-
guest: true,
|
|
30109
|
-
sandbox: true,
|
|
30110
|
-
name: "Object",
|
|
30111
|
-
length: 1,
|
|
30112
|
-
call: construct,
|
|
30113
|
-
construct
|
|
30114
|
-
});
|
|
30115
|
-
const properties = materializeFunctionProperties(constructor);
|
|
30116
|
-
const prototype = properties.prototype;
|
|
30117
|
-
Object.defineProperty(properties, "prototype", { writable: false });
|
|
30118
|
-
for (const [name, method] of Object.entries(methods)) {
|
|
30119
|
-
Object.defineProperty(properties, name, { value: method, writable: true, configurable: true });
|
|
30120
|
-
}
|
|
30121
|
-
const prototypeMethods = {
|
|
30122
|
-
toString: createSandboxClosure({
|
|
30123
|
-
sandbox: true,
|
|
30124
|
-
name: "toString",
|
|
30125
|
-
length: 0,
|
|
30126
|
-
call: (_args, context) => budget.allocateString(`[object ${typeTag(context?.thisValue)}]`)
|
|
30127
|
-
}),
|
|
30128
|
-
valueOf: createSandboxClosure({
|
|
30129
|
-
sandbox: true,
|
|
30130
|
-
name: "valueOf",
|
|
30131
|
-
length: 0,
|
|
30132
|
-
call: (_args, context) => {
|
|
30133
|
-
const value = requireReceiver(context?.thisValue);
|
|
30134
|
-
if (typeof value !== "object")
|
|
30135
|
-
throw new TypeError("Object primitive boxing is not supported.");
|
|
30136
|
-
return value;
|
|
30137
|
-
}
|
|
30138
|
-
}),
|
|
30139
|
-
hasOwnProperty: createSandboxClosure({
|
|
30140
|
-
sandbox: true,
|
|
30141
|
-
name: "hasOwnProperty",
|
|
30142
|
-
length: 1,
|
|
30143
|
-
call: async ([key], context) => hasOwnSandboxProperty(
|
|
30144
|
-
requireReceiver(context?.thisValue),
|
|
30145
|
-
await sandboxString(key, budget, context),
|
|
30146
|
-
false
|
|
30147
|
-
)
|
|
30148
|
-
}),
|
|
30149
|
-
propertyIsEnumerable: createSandboxClosure({
|
|
30150
|
-
sandbox: true,
|
|
30151
|
-
name: "propertyIsEnumerable",
|
|
30152
|
-
length: 1,
|
|
30153
|
-
call: async ([key], context) => hasOwnSandboxProperty(
|
|
30154
|
-
requireReceiver(context?.thisValue),
|
|
30155
|
-
await sandboxString(key, budget, context),
|
|
30156
|
-
true
|
|
30157
|
-
)
|
|
30158
|
-
}),
|
|
30159
|
-
isPrototypeOf: createSandboxClosure({
|
|
30160
|
-
sandbox: true,
|
|
30161
|
-
name: "isPrototypeOf",
|
|
30162
|
-
length: 1,
|
|
30163
|
-
call: ([value], context) => {
|
|
30164
|
-
if (typeof value !== "object" || value === null) return false;
|
|
30165
|
-
const receiver = requireReceiver(context?.thisValue);
|
|
30166
|
-
let depth = 0;
|
|
30167
|
-
for (let current = getSandboxPrototype(value, budget); current !== null; current = getSandboxPrototype(current, budget)) {
|
|
30168
|
-
budget.visitNode();
|
|
30169
|
-
assertSandboxDataDepth(depth++);
|
|
30170
|
-
if (current === receiver) return true;
|
|
30171
|
-
}
|
|
30172
|
-
return false;
|
|
30173
|
-
}
|
|
30174
|
-
})
|
|
30175
|
-
};
|
|
30176
|
-
for (const [name, method] of Object.entries(prototypeMethods)) {
|
|
30177
|
-
Object.defineProperty(prototype, name, { value: method, writable: true, configurable: true });
|
|
30178
|
-
}
|
|
30179
|
-
markDescriptorObject(prototype);
|
|
30180
|
-
installObjectPrototype(budget, prototype, constructor);
|
|
30181
|
-
return constructor;
|
|
30182
|
-
}
|
|
30183
|
-
function requireReceiver(value) {
|
|
30184
|
-
if (value === null || value === void 0)
|
|
30185
|
-
throw new TypeError("Object method requires a non-null receiver.");
|
|
30186
|
-
return value;
|
|
30187
|
-
}
|
|
30188
|
-
function hasOwnSandboxProperty(value, key, enumerable) {
|
|
30189
|
-
requireReceiver(value);
|
|
30190
|
-
if (isGuestHostObject(value)) return hasHostObjectMember(value, key, enumerable);
|
|
30191
|
-
let properties;
|
|
30192
|
-
if (isGuestClosure(value)) properties = materializeFunctionProperties(value);
|
|
30193
|
-
else if (isSandboxClosure(value)) {
|
|
30194
|
-
if (key === "length" || key === "name") return !enumerable;
|
|
30195
|
-
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
30196
|
-
} else if (isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxGenerator(value))
|
|
30197
|
-
return false;
|
|
30198
|
-
else if (isSandboxRegex(value)) return key === "lastIndex" && !enumerable;
|
|
30199
|
-
else properties = Object(value);
|
|
30200
|
-
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
30201
|
-
return descriptor !== void 0 && (!enumerable || descriptor.enumerable === true);
|
|
30202
|
-
}
|
|
30203
|
-
function typeTag(value) {
|
|
30204
|
-
if (value === void 0) return "Undefined";
|
|
30205
|
-
if (value === null) return "Null";
|
|
30206
|
-
if (typeof value === "string") return "String";
|
|
30207
|
-
if (typeof value === "number") return "Number";
|
|
30208
|
-
if (typeof value === "boolean") return "Boolean";
|
|
30209
|
-
if (isSandboxClosure(value)) {
|
|
30210
|
-
while (value.boundTarget !== void 0) value = value.boundTarget;
|
|
30211
|
-
return value.generator ? "GeneratorFunction" : value.async ? "AsyncFunction" : "Function";
|
|
30212
|
-
}
|
|
30213
|
-
if (Array.isArray(value)) return "Array";
|
|
30214
|
-
if (isSandboxDate(value)) return "Date";
|
|
30215
|
-
if (isSandboxErrorConstructorInstance(value, "Error")) return "Error";
|
|
30216
|
-
if (isSandboxRegex(value)) return "RegExp";
|
|
30217
|
-
if (isSandboxMap(value)) return "Map";
|
|
30218
|
-
if (isSandboxSet(value)) return "Set";
|
|
30219
|
-
if (isSandboxPromise(value)) return "Promise";
|
|
30220
|
-
if (isSandboxGenerator(value)) return "Generator";
|
|
30221
|
-
if (isFloat32Array(value)) return "Float32Array";
|
|
30222
|
-
return "Object";
|
|
30223
|
-
}
|
|
30224
|
-
|
|
30225
30271
|
// packages/safe-js/src/interp/globals/object-array.ts
|
|
30226
30272
|
function createObjectArrayGlobals(options) {
|
|
30227
30273
|
return {
|
|
@@ -32772,4 +32818,4 @@ export {
|
|
|
32772
32818
|
FileSnapshotBackend,
|
|
32773
32819
|
run
|
|
32774
32820
|
};
|
|
32775
|
-
//# sourceMappingURL=chunk-
|
|
32821
|
+
//# sourceMappingURL=chunk-5J6BX3HD.js.map
|