@poe-platform/safe-js 0.1.123 → 0.1.125
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-3JECZNKB.js → chunk-AHZ74NTE.js} +2 -2
- package/dist/safe-js/chunks/{chunk-N3CN2ACZ.js → chunk-D4YY44EF.js} +456 -413
- package/dist/safe-js/chunks/{chunk-N3CN2ACZ.js.map → chunk-D4YY44EF.js.map} +4 -4
- 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/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-3JECZNKB.js.map → chunk-AHZ74NTE.js.map} +0 -0
|
@@ -23880,6 +23880,44 @@ function hoistVarDeclarations(node, scope) {
|
|
|
23880
23880
|
}
|
|
23881
23881
|
}
|
|
23882
23882
|
|
|
23883
|
+
// packages/safe-js/src/interp/resources.ts
|
|
23884
|
+
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
23885
|
+
var runResources = new AsyncLocalStorage5();
|
|
23886
|
+
async function withRunResources(signal, execute) {
|
|
23887
|
+
const controller = new AbortController();
|
|
23888
|
+
const cancel = () => controller.abort(signal?.reason);
|
|
23889
|
+
const cleanups = /* @__PURE__ */ new Set();
|
|
23890
|
+
const resources = {
|
|
23891
|
+
signal: controller.signal,
|
|
23892
|
+
referenceReleases: /* @__PURE__ */ new Set(),
|
|
23893
|
+
add(close) {
|
|
23894
|
+
cleanups.add(close);
|
|
23895
|
+
}
|
|
23896
|
+
};
|
|
23897
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
23898
|
+
if (signal?.aborted) cancel();
|
|
23899
|
+
let result;
|
|
23900
|
+
let failure;
|
|
23901
|
+
let errors = [];
|
|
23902
|
+
try {
|
|
23903
|
+
result = await runResources.run(resources, execute);
|
|
23904
|
+
} catch (error) {
|
|
23905
|
+
failure = { reason: error };
|
|
23906
|
+
} finally {
|
|
23907
|
+
signal?.removeEventListener("abort", cancel);
|
|
23908
|
+
controller.abort(new Error("SafeJS run finished."));
|
|
23909
|
+
for (const release of resources.referenceReleases) release();
|
|
23910
|
+
resources.referenceReleases.clear();
|
|
23911
|
+
const outcomes = await Promise.allSettled(
|
|
23912
|
+
[...cleanups].map((close) => Promise.resolve().then(close))
|
|
23913
|
+
);
|
|
23914
|
+
errors = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
|
|
23915
|
+
}
|
|
23916
|
+
if (failure !== void 0) throw failure.reason;
|
|
23917
|
+
if (errors.length > 0) throw new AggregateError(errors, "SafeJS resource cleanup failed.");
|
|
23918
|
+
return result;
|
|
23919
|
+
}
|
|
23920
|
+
|
|
23883
23921
|
// packages/safe-js/src/interp/methods/array.ts
|
|
23884
23922
|
var arrayLikeSources = /* @__PURE__ */ new WeakMap();
|
|
23885
23923
|
var activeArrayCallbacks = /* @__PURE__ */ new WeakMap();
|
|
@@ -26557,89 +26595,110 @@ async function evaluateEmptyStatement(_node, _context) {
|
|
|
26557
26595
|
}
|
|
26558
26596
|
async function evaluateArrayExpression(node, context) {
|
|
26559
26597
|
const values = [];
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
26566
|
-
|
|
26567
|
-
const spreadValues = await evaluateSpreadElement(element, context);
|
|
26568
|
-
if (!spreadValues.ok) {
|
|
26569
|
-
return spreadValues.result;
|
|
26598
|
+
const release = retainValues(context.budget, () => [values]);
|
|
26599
|
+
try {
|
|
26600
|
+
for (const element of node.elements) {
|
|
26601
|
+
if (element.type === "UndefinedLiteral" && element.elision === true) {
|
|
26602
|
+
values.length += 1;
|
|
26603
|
+
context.budget.allocateArrayLength(values.length);
|
|
26604
|
+
continue;
|
|
26570
26605
|
}
|
|
26571
|
-
|
|
26606
|
+
if (element.type === "SpreadElement") {
|
|
26607
|
+
const spreadValues = await evaluateSpreadElement(element, context);
|
|
26608
|
+
if (!spreadValues.ok) {
|
|
26609
|
+
return spreadValues.result;
|
|
26610
|
+
}
|
|
26611
|
+
appendArrayValues2(values, spreadValues.value);
|
|
26612
|
+
context.budget.allocateArrayLength(values.length);
|
|
26613
|
+
continue;
|
|
26614
|
+
}
|
|
26615
|
+
const result = await evaluateNode(element, context);
|
|
26616
|
+
if (result.kind !== "normal") {
|
|
26617
|
+
return result;
|
|
26618
|
+
}
|
|
26619
|
+
values.push(result.value);
|
|
26572
26620
|
context.budget.allocateArrayLength(values.length);
|
|
26573
|
-
continue;
|
|
26574
26621
|
}
|
|
26575
|
-
|
|
26576
|
-
|
|
26577
|
-
|
|
26578
|
-
|
|
26579
|
-
|
|
26580
|
-
|
|
26622
|
+
return {
|
|
26623
|
+
kind: "normal",
|
|
26624
|
+
hasValue: true,
|
|
26625
|
+
value: values
|
|
26626
|
+
};
|
|
26627
|
+
} finally {
|
|
26628
|
+
release();
|
|
26581
26629
|
}
|
|
26582
|
-
return {
|
|
26583
|
-
kind: "normal",
|
|
26584
|
-
hasValue: true,
|
|
26585
|
-
value: values
|
|
26586
|
-
};
|
|
26587
26630
|
}
|
|
26588
26631
|
async function evaluateObjectExpression(node, context) {
|
|
26589
26632
|
const object = /* @__PURE__ */ Object.create(null);
|
|
26590
|
-
|
|
26591
|
-
|
|
26592
|
-
|
|
26593
|
-
if (
|
|
26594
|
-
|
|
26633
|
+
const release = retainValues(context.budget, () => [object]);
|
|
26634
|
+
try {
|
|
26635
|
+
for (const property of node.properties) {
|
|
26636
|
+
if (property.type === "SpreadElement") {
|
|
26637
|
+
const spreadEntries = await evaluateObjectSpread(property, context);
|
|
26638
|
+
if (!spreadEntries.ok) {
|
|
26639
|
+
return spreadEntries.result;
|
|
26640
|
+
}
|
|
26641
|
+
for (const [key2, value2] of spreadEntries.value) {
|
|
26642
|
+
defineSandboxProperty(object, key2, value2);
|
|
26643
|
+
}
|
|
26644
|
+
continue;
|
|
26595
26645
|
}
|
|
26596
|
-
|
|
26597
|
-
|
|
26646
|
+
const key = await evaluateObjectPropertyKey(property, context);
|
|
26647
|
+
if (!key.ok) {
|
|
26648
|
+
return key.result;
|
|
26598
26649
|
}
|
|
26599
|
-
|
|
26600
|
-
|
|
26601
|
-
|
|
26602
|
-
|
|
26603
|
-
|
|
26604
|
-
|
|
26605
|
-
const value = await evaluateNode(property.value, context);
|
|
26606
|
-
if (value.kind !== "normal") {
|
|
26607
|
-
return value;
|
|
26608
|
-
}
|
|
26609
|
-
if (isObjectPrototypeSetterProperty(property, key.value)) {
|
|
26610
|
-
if (value.value === null || typeof value.value === "object") {
|
|
26611
|
-
setSandboxPrototype(object, value.value, context.budget);
|
|
26650
|
+
const releaseKey = retainValues(context.budget, () => [key.value]);
|
|
26651
|
+
let value;
|
|
26652
|
+
try {
|
|
26653
|
+
value = await evaluateNode(property.value, context);
|
|
26654
|
+
} finally {
|
|
26655
|
+
releaseKey();
|
|
26612
26656
|
}
|
|
26613
|
-
|
|
26657
|
+
if (value.kind !== "normal") {
|
|
26658
|
+
return value;
|
|
26659
|
+
}
|
|
26660
|
+
if (isObjectPrototypeSetterProperty(property, key.value)) {
|
|
26661
|
+
if (value.value === null || typeof value.value === "object") {
|
|
26662
|
+
setSandboxPrototype(object, value.value, context.budget);
|
|
26663
|
+
}
|
|
26664
|
+
continue;
|
|
26665
|
+
}
|
|
26666
|
+
defineSandboxProperty(object, String(key.value), value.value);
|
|
26614
26667
|
}
|
|
26615
|
-
|
|
26668
|
+
return {
|
|
26669
|
+
kind: "normal",
|
|
26670
|
+
hasValue: true,
|
|
26671
|
+
value: object
|
|
26672
|
+
};
|
|
26673
|
+
} finally {
|
|
26674
|
+
release();
|
|
26616
26675
|
}
|
|
26617
|
-
return {
|
|
26618
|
-
kind: "normal",
|
|
26619
|
-
hasValue: true,
|
|
26620
|
-
value: object
|
|
26621
|
-
};
|
|
26622
26676
|
}
|
|
26623
26677
|
function isObjectPrototypeSetterProperty(property, key) {
|
|
26624
26678
|
return !property.computed && !property.shorthand && key === "__proto__";
|
|
26625
26679
|
}
|
|
26626
26680
|
async function evaluateTemplateLiteral(node, context) {
|
|
26627
26681
|
let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
|
|
26682
|
+
const release = retainValues(context.budget, () => [value]);
|
|
26683
|
+
try {
|
|
26684
|
+
for (let index = 0; index < node.expressions.length; index += 1) {
|
|
26685
|
+
const expression = await evaluateNode(node.expressions[index], context);
|
|
26686
|
+
if (expression.kind !== "normal") {
|
|
26687
|
+
return expression;
|
|
26688
|
+
}
|
|
26689
|
+
const expressionText = context.budget.allocateString(String(expression.value));
|
|
26690
|
+
value = context.budget.allocateString(value + expressionText);
|
|
26691
|
+
const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
|
|
26692
|
+
value = context.budget.allocateString(value + quasiText);
|
|
26632
26693
|
}
|
|
26633
|
-
|
|
26634
|
-
|
|
26635
|
-
|
|
26636
|
-
|
|
26694
|
+
return {
|
|
26695
|
+
kind: "normal",
|
|
26696
|
+
hasValue: true,
|
|
26697
|
+
value
|
|
26698
|
+
};
|
|
26699
|
+
} finally {
|
|
26700
|
+
release();
|
|
26637
26701
|
}
|
|
26638
|
-
return {
|
|
26639
|
-
kind: "normal",
|
|
26640
|
-
hasValue: true,
|
|
26641
|
-
value
|
|
26642
|
-
};
|
|
26643
26702
|
}
|
|
26644
26703
|
async function evaluateTaggedTemplateExpression(node, context) {
|
|
26645
26704
|
const tag = await evaluateNode(node.tag, context);
|
|
@@ -26666,20 +26725,25 @@ async function evaluateTaggedTemplateExpression(node, context) {
|
|
|
26666
26725
|
}
|
|
26667
26726
|
async function evaluateTemplateExpressionValues(node, context) {
|
|
26668
26727
|
const values = [];
|
|
26669
|
-
|
|
26670
|
-
|
|
26671
|
-
|
|
26672
|
-
|
|
26673
|
-
|
|
26674
|
-
|
|
26675
|
-
|
|
26728
|
+
const release = retainValues(context.budget, () => values);
|
|
26729
|
+
try {
|
|
26730
|
+
for (const expressionNode of node.expressions) {
|
|
26731
|
+
const expression = await evaluateNode(expressionNode, context);
|
|
26732
|
+
if (expression.kind !== "normal") {
|
|
26733
|
+
return {
|
|
26734
|
+
ok: false,
|
|
26735
|
+
result: expression
|
|
26736
|
+
};
|
|
26737
|
+
}
|
|
26738
|
+
values.push(expression.value);
|
|
26676
26739
|
}
|
|
26677
|
-
|
|
26740
|
+
return {
|
|
26741
|
+
ok: true,
|
|
26742
|
+
value: values
|
|
26743
|
+
};
|
|
26744
|
+
} finally {
|
|
26745
|
+
release();
|
|
26678
26746
|
}
|
|
26679
|
-
return {
|
|
26680
|
-
ok: true,
|
|
26681
|
-
value: values
|
|
26682
|
-
};
|
|
26683
26747
|
}
|
|
26684
26748
|
function createTaggedTemplateStrings(node, context) {
|
|
26685
26749
|
context.budget.allocateArrayLength(node.quasis.length);
|
|
@@ -26727,23 +26791,30 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
26727
26791
|
if (left.kind !== "normal") {
|
|
26728
26792
|
return left;
|
|
26729
26793
|
}
|
|
26730
|
-
|
|
26731
|
-
|
|
26732
|
-
|
|
26733
|
-
|
|
26734
|
-
|
|
26735
|
-
|
|
26736
|
-
|
|
26737
|
-
|
|
26794
|
+
let rightValue;
|
|
26795
|
+
const release = retainValues(context.budget, () => [left.value, rightValue]);
|
|
26796
|
+
try {
|
|
26797
|
+
const right = await evaluateNode(node.right, context);
|
|
26798
|
+
if (right.kind !== "normal") {
|
|
26799
|
+
return right;
|
|
26800
|
+
}
|
|
26801
|
+
rightValue = right.value;
|
|
26802
|
+
let leftValue = left.value;
|
|
26803
|
+
if (node.operator === "in") {
|
|
26804
|
+
if (typeof right.value !== "object" || right.value === null) {
|
|
26805
|
+
throw new TypeError("Right-hand side of 'in' must be an object.");
|
|
26806
|
+
}
|
|
26807
|
+
leftValue = await toPropertyKey(leftValue, context.budget, createCoercionContext(context));
|
|
26738
26808
|
}
|
|
26739
|
-
|
|
26809
|
+
const value = applyBinaryOperator(node, leftValue, right.value, context);
|
|
26810
|
+
return {
|
|
26811
|
+
kind: "normal",
|
|
26812
|
+
hasValue: true,
|
|
26813
|
+
value
|
|
26814
|
+
};
|
|
26815
|
+
} finally {
|
|
26816
|
+
release();
|
|
26740
26817
|
}
|
|
26741
|
-
const value = applyBinaryOperator(node, leftValue, right.value, context);
|
|
26742
|
-
return {
|
|
26743
|
-
kind: "normal",
|
|
26744
|
-
hasValue: true,
|
|
26745
|
-
value
|
|
26746
|
-
};
|
|
26747
26818
|
}
|
|
26748
26819
|
async function evaluateAssignmentExpression(node, context) {
|
|
26749
26820
|
if (node.left.type === "ArrayPattern" || node.left.type === "ObjectPattern") {
|
|
@@ -26816,61 +26887,64 @@ async function evaluateMemberAssignmentExpression(node, context) {
|
|
|
26816
26887
|
if (node.left.type !== "MemberExpression") {
|
|
26817
26888
|
throw new TypeError("Expected member assignment target.");
|
|
26818
26889
|
}
|
|
26819
|
-
|
|
26820
|
-
|
|
26821
|
-
return member;
|
|
26822
|
-
}
|
|
26823
|
-
if (member.kind === "completion") {
|
|
26824
|
-
return member.result;
|
|
26825
|
-
}
|
|
26826
|
-
if (member.kind === "nullish") {
|
|
26827
|
-
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
26828
|
-
}
|
|
26829
|
-
let property;
|
|
26830
|
-
let current = void 0;
|
|
26831
|
-
if (node.operator !== "=") {
|
|
26832
|
-
if (member.object === null || member.object === void 0) {
|
|
26890
|
+
return evaluateMemberAccess(node.left, context, async (member) => {
|
|
26891
|
+
if (member.kind === "nullish") {
|
|
26833
26892
|
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
26834
26893
|
}
|
|
26835
|
-
|
|
26836
|
-
current =
|
|
26837
|
-
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
|
|
26841
|
-
|
|
26842
|
-
|
|
26843
|
-
}
|
|
26844
|
-
|
|
26845
|
-
|
|
26846
|
-
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
}
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26855
|
-
|
|
26856
|
-
|
|
26857
|
-
}
|
|
26858
|
-
|
|
26859
|
-
|
|
26860
|
-
|
|
26861
|
-
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
26865
|
-
|
|
26866
|
-
|
|
26867
|
-
|
|
26868
|
-
|
|
26869
|
-
|
|
26870
|
-
|
|
26871
|
-
|
|
26872
|
-
|
|
26873
|
-
|
|
26894
|
+
let property;
|
|
26895
|
+
let current = void 0;
|
|
26896
|
+
if (node.operator !== "=") {
|
|
26897
|
+
if (member.object === null || member.object === void 0) {
|
|
26898
|
+
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
26899
|
+
}
|
|
26900
|
+
property = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
26901
|
+
current = getPropertyValue(member.object, property, context);
|
|
26902
|
+
}
|
|
26903
|
+
if (node.operator === "&&=" && !isTruthy(current)) {
|
|
26904
|
+
return {
|
|
26905
|
+
kind: "normal",
|
|
26906
|
+
hasValue: true,
|
|
26907
|
+
value: current
|
|
26908
|
+
};
|
|
26909
|
+
}
|
|
26910
|
+
if (node.operator === "||=" && isTruthy(current)) {
|
|
26911
|
+
return {
|
|
26912
|
+
kind: "normal",
|
|
26913
|
+
hasValue: true,
|
|
26914
|
+
value: current
|
|
26915
|
+
};
|
|
26916
|
+
}
|
|
26917
|
+
if (node.operator === "??=" && current !== null && current !== void 0) {
|
|
26918
|
+
return {
|
|
26919
|
+
kind: "normal",
|
|
26920
|
+
hasValue: true,
|
|
26921
|
+
value: current
|
|
26922
|
+
};
|
|
26923
|
+
}
|
|
26924
|
+
let operands = [current, property];
|
|
26925
|
+
const release = retainValues(context.budget, () => operands);
|
|
26926
|
+
try {
|
|
26927
|
+
const right = await evaluateNode(node.right, context);
|
|
26928
|
+
if (right.kind !== "normal") {
|
|
26929
|
+
return right;
|
|
26930
|
+
}
|
|
26931
|
+
operands.push(right.value);
|
|
26932
|
+
const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
|
|
26933
|
+
if (member.object === null || member.object === void 0) {
|
|
26934
|
+
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
26935
|
+
}
|
|
26936
|
+
operands = [value];
|
|
26937
|
+
property ??= await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
26938
|
+
setSandboxProperty(member.object, property, value, context.budget);
|
|
26939
|
+
return {
|
|
26940
|
+
kind: "normal",
|
|
26941
|
+
hasValue: true,
|
|
26942
|
+
value
|
|
26943
|
+
};
|
|
26944
|
+
} finally {
|
|
26945
|
+
release();
|
|
26946
|
+
}
|
|
26947
|
+
});
|
|
26874
26948
|
}
|
|
26875
26949
|
async function evaluateLogicalExpression(node, context) {
|
|
26876
26950
|
const left = await evaluateNode(node.left, context);
|
|
@@ -27849,33 +27923,28 @@ async function evaluateDeleteExpression(node, context) {
|
|
|
27849
27923
|
"Unary operator 'delete' requires a member target."
|
|
27850
27924
|
);
|
|
27851
27925
|
}
|
|
27852
|
-
|
|
27853
|
-
|
|
27854
|
-
|
|
27855
|
-
|
|
27856
|
-
|
|
27857
|
-
|
|
27858
|
-
|
|
27859
|
-
|
|
27860
|
-
|
|
27861
|
-
|
|
27862
|
-
kind: "normal",
|
|
27863
|
-
hasValue: true,
|
|
27864
|
-
value: true
|
|
27865
|
-
};
|
|
27926
|
+
return evaluateMemberAccess(node.argument, context, async (member) => {
|
|
27927
|
+
if (member.kind === "nullish" || member.object === null || member.object === void 0) {
|
|
27928
|
+
if (member.kind === "nullish") {
|
|
27929
|
+
return {
|
|
27930
|
+
kind: "normal",
|
|
27931
|
+
hasValue: true,
|
|
27932
|
+
value: true
|
|
27933
|
+
};
|
|
27934
|
+
}
|
|
27935
|
+
throw new TypeError("Cannot delete properties of null or undefined.");
|
|
27866
27936
|
}
|
|
27867
|
-
|
|
27868
|
-
|
|
27869
|
-
|
|
27870
|
-
|
|
27871
|
-
|
|
27872
|
-
|
|
27873
|
-
|
|
27874
|
-
|
|
27875
|
-
|
|
27876
|
-
|
|
27877
|
-
|
|
27878
|
-
};
|
|
27937
|
+
if (!isIndexableSandboxValue(member.object)) {
|
|
27938
|
+
throw new TypeError("Unary operator 'delete' requires a sandbox object property.");
|
|
27939
|
+
}
|
|
27940
|
+
const property = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
27941
|
+
const deleted = deleteSandboxProperty(member.object, property);
|
|
27942
|
+
return {
|
|
27943
|
+
kind: "normal",
|
|
27944
|
+
hasValue: true,
|
|
27945
|
+
value: deleted
|
|
27946
|
+
};
|
|
27947
|
+
});
|
|
27879
27948
|
}
|
|
27880
27949
|
async function evaluateUpdateExpression(node, context) {
|
|
27881
27950
|
if (node.argument.type === "Identifier") {
|
|
@@ -27911,41 +27980,35 @@ async function evaluateMemberUpdateExpression(node, context) {
|
|
|
27911
27980
|
if (node.argument.type !== "MemberExpression") {
|
|
27912
27981
|
throw new TypeError("Expected member update target.");
|
|
27913
27982
|
}
|
|
27914
|
-
|
|
27915
|
-
|
|
27916
|
-
|
|
27917
|
-
|
|
27918
|
-
|
|
27919
|
-
|
|
27920
|
-
|
|
27921
|
-
|
|
27922
|
-
|
|
27923
|
-
|
|
27924
|
-
|
|
27925
|
-
|
|
27926
|
-
|
|
27927
|
-
|
|
27928
|
-
|
|
27929
|
-
|
|
27930
|
-
return {
|
|
27931
|
-
kind: "normal",
|
|
27932
|
-
hasValue: true,
|
|
27933
|
-
value: node.prefix ? next : current
|
|
27934
|
-
};
|
|
27983
|
+
return evaluateMemberAccess(node.argument, context, async (member) => {
|
|
27984
|
+
if (member.kind === "nullish" || member.object === null || member.object === void 0) {
|
|
27985
|
+
throw new TypeError("Cannot update properties of null or undefined.");
|
|
27986
|
+
}
|
|
27987
|
+
const property = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
27988
|
+
const current = toNumber(
|
|
27989
|
+
await toNumericPrimitive(getPropertyValue(member.object, property, context), context)
|
|
27990
|
+
);
|
|
27991
|
+
const next = node.operator === "++" ? current + 1 : current - 1;
|
|
27992
|
+
setSandboxProperty(member.object, property, next, context.budget);
|
|
27993
|
+
return {
|
|
27994
|
+
kind: "normal",
|
|
27995
|
+
hasValue: true,
|
|
27996
|
+
value: node.prefix ? next : current
|
|
27997
|
+
};
|
|
27998
|
+
});
|
|
27935
27999
|
}
|
|
27936
28000
|
async function evaluateMemberExpression(node, context) {
|
|
27937
|
-
|
|
27938
|
-
|
|
27939
|
-
|
|
27940
|
-
|
|
27941
|
-
|
|
27942
|
-
|
|
27943
|
-
|
|
27944
|
-
|
|
27945
|
-
|
|
27946
|
-
|
|
27947
|
-
|
|
27948
|
-
};
|
|
28001
|
+
return evaluateMemberAccess(node, context, async (member) => {
|
|
28002
|
+
if (member.kind === "nullish" || member.object === null || member.object === void 0) {
|
|
28003
|
+
if (member.kind === "nullish") return { kind: "normal", hasValue: true, value: void 0 };
|
|
28004
|
+
throw new TypeError("Cannot read properties of null or undefined.");
|
|
28005
|
+
}
|
|
28006
|
+
return {
|
|
28007
|
+
kind: "normal",
|
|
28008
|
+
hasValue: true,
|
|
28009
|
+
value: getPropertyValue(member.object, await toPropertyKey(member.property, context.budget, createCoercionContext(context)), context)
|
|
28010
|
+
};
|
|
28011
|
+
});
|
|
27949
28012
|
}
|
|
27950
28013
|
function getPropertyValue(target, property, context) {
|
|
27951
28014
|
if (isGuestHostObject(target)) return getHostObjectMember(target, String(property));
|
|
@@ -28053,26 +28116,33 @@ function attachFatalSandboxErrorContext(error, node, stackFrames) {
|
|
|
28053
28116
|
attachErrorSpan(error, node.span);
|
|
28054
28117
|
replaceErrorStack(error, stackFrames);
|
|
28055
28118
|
}
|
|
28056
|
-
async function evaluateMemberAccess(node, context) {
|
|
28119
|
+
async function evaluateMemberAccess(node, context, consume) {
|
|
28057
28120
|
const object = await evaluateNode(node.object, context);
|
|
28058
|
-
if (object.kind !== "normal")
|
|
28059
|
-
return {
|
|
28060
|
-
kind: "completion",
|
|
28061
|
-
result: object
|
|
28062
|
-
};
|
|
28063
|
-
}
|
|
28121
|
+
if (object.kind !== "normal") return object;
|
|
28064
28122
|
if ((object.value === null || object.value === void 0) && node.optional) {
|
|
28065
|
-
return {
|
|
28066
|
-
kind: "nullish"
|
|
28067
|
-
};
|
|
28123
|
+
return consume({ kind: "nullish" });
|
|
28068
28124
|
}
|
|
28069
|
-
|
|
28070
|
-
|
|
28071
|
-
|
|
28072
|
-
kind: "
|
|
28073
|
-
|
|
28074
|
-
property
|
|
28125
|
+
let property;
|
|
28126
|
+
const release = retainValues(context.budget, () => [object.value, property]);
|
|
28127
|
+
try {
|
|
28128
|
+
const result = node.computed ? await evaluateNode(node.property, context) : { kind: "normal", value: getStaticPropertyName2(node.property) };
|
|
28129
|
+
if (result.kind !== "normal") return result;
|
|
28130
|
+
property = result.value;
|
|
28131
|
+
return await consume({ kind: "resolved", object: object.value, property });
|
|
28132
|
+
} finally {
|
|
28133
|
+
release();
|
|
28134
|
+
}
|
|
28135
|
+
}
|
|
28136
|
+
function retainValues(budget, values) {
|
|
28137
|
+
const retained = {};
|
|
28138
|
+
budget.setRetainedValues(retained, values);
|
|
28139
|
+
const pending = runResources.getStore()?.referenceReleases;
|
|
28140
|
+
const release = () => {
|
|
28141
|
+
budget.setRetainedValues(retained, void 0);
|
|
28142
|
+
pending?.delete(release);
|
|
28075
28143
|
};
|
|
28144
|
+
pending?.add(release);
|
|
28145
|
+
return release;
|
|
28076
28146
|
}
|
|
28077
28147
|
async function evaluateMemberProperty(node, context) {
|
|
28078
28148
|
const property = await evaluateNode(node, context);
|
|
@@ -28109,137 +28179,132 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
28109
28179
|
if (node.callee.type !== "MemberExpression") {
|
|
28110
28180
|
throw new TypeError("Expected member call expression.");
|
|
28111
28181
|
}
|
|
28112
|
-
|
|
28113
|
-
|
|
28114
|
-
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
|
|
28119
|
-
|
|
28120
|
-
|
|
28121
|
-
|
|
28122
|
-
kind: "normal",
|
|
28123
|
-
hasValue: true,
|
|
28124
|
-
value: void 0
|
|
28125
|
-
};
|
|
28182
|
+
return evaluateMemberAccess(node.callee, context, async (reference) => {
|
|
28183
|
+
if (reference.kind === "nullish" || reference.object === null || reference.object === void 0) {
|
|
28184
|
+
if (reference.kind === "nullish") {
|
|
28185
|
+
return {
|
|
28186
|
+
kind: "normal",
|
|
28187
|
+
hasValue: true,
|
|
28188
|
+
value: void 0
|
|
28189
|
+
};
|
|
28190
|
+
}
|
|
28191
|
+
throw new TypeError("Cannot read properties of null or undefined.");
|
|
28126
28192
|
}
|
|
28127
|
-
|
|
28128
|
-
|
|
28129
|
-
|
|
28130
|
-
|
|
28131
|
-
|
|
28132
|
-
|
|
28133
|
-
if (typeof member.object === "string" && isStringMethodName(member.property)) {
|
|
28134
|
-
return evaluateStringMethodCall(node, member.object, member.property, context);
|
|
28135
|
-
}
|
|
28136
|
-
if (typeof member.object === "number" && isNumberMethodName(member.property)) {
|
|
28137
|
-
return evaluateNumberMethodCall(node, member.object, member.property, context);
|
|
28138
|
-
}
|
|
28139
|
-
if (Array.isArray(member.object) && isArrayMethodName(member.property) && !Object.hasOwn(member.object, member.property)) {
|
|
28140
|
-
return evaluateArrayMethodCall(node, member.object, member.property, context);
|
|
28141
|
-
}
|
|
28142
|
-
if (isSandboxMap(member.object) && isMapMethodName(member.property)) {
|
|
28143
|
-
return evaluateMapMethodCall(node, member.object, member.property, context);
|
|
28144
|
-
}
|
|
28145
|
-
if (isSandboxSet(member.object) && isSetMethodName(member.property)) {
|
|
28146
|
-
return evaluateSetMethodCall(node, member.object, member.property, context);
|
|
28147
|
-
}
|
|
28148
|
-
if (typeof member.object === "string") {
|
|
28149
|
-
return evaluatePrimitiveMemberCall(
|
|
28150
|
-
node,
|
|
28151
|
-
"String",
|
|
28152
|
-
member.property,
|
|
28153
|
-
getStringMember(member.object, member.property, context.budget),
|
|
28154
|
-
context
|
|
28155
|
-
);
|
|
28156
|
-
}
|
|
28157
|
-
if (typeof member.object === "number") {
|
|
28158
|
-
return evaluatePrimitiveMemberCall(
|
|
28159
|
-
node,
|
|
28160
|
-
"Number",
|
|
28161
|
-
member.property,
|
|
28162
|
-
getNumberMember(member.property, context.budget),
|
|
28163
|
-
context
|
|
28164
|
-
);
|
|
28165
|
-
}
|
|
28166
|
-
if (Array.isArray(member.object) && !Object.hasOwn(member.object, member.property)) {
|
|
28167
|
-
return evaluatePrimitiveMemberCall(
|
|
28168
|
-
node,
|
|
28169
|
-
"Array",
|
|
28170
|
-
member.property,
|
|
28171
|
-
getArrayMemberValue(member.object, member.property, context),
|
|
28172
|
-
context
|
|
28173
|
-
);
|
|
28174
|
-
}
|
|
28175
|
-
if (isSandboxMap(member.object)) {
|
|
28176
|
-
return evaluatePrimitiveMemberCall(
|
|
28177
|
-
node,
|
|
28178
|
-
"Map",
|
|
28179
|
-
member.property,
|
|
28180
|
-
getMapMember(member.object, member.property, createMapMethodOptions(context)),
|
|
28181
|
-
context
|
|
28182
|
-
);
|
|
28183
|
-
}
|
|
28184
|
-
if (isSandboxDate(member.object)) {
|
|
28185
|
-
return evaluateResolvedCallExpression(node, getDateMember(member.property, context.budget, context.compilation?.owner), context, member.object);
|
|
28186
|
-
}
|
|
28187
|
-
if (isFloat32Array(member.object)) {
|
|
28188
|
-
return evaluateResolvedCallExpression(
|
|
28189
|
-
node,
|
|
28190
|
-
getFloat32Member(member.object, member.property, context.budget),
|
|
28191
|
-
context,
|
|
28192
|
-
member.object
|
|
28193
|
-
);
|
|
28194
|
-
}
|
|
28195
|
-
if (isSandboxSet(member.object)) {
|
|
28196
|
-
return evaluatePrimitiveMemberCall(
|
|
28197
|
-
node,
|
|
28198
|
-
"Set",
|
|
28199
|
-
member.property,
|
|
28200
|
-
getSetMember(member.object, member.property, createSetMethodOptions(context)),
|
|
28201
|
-
context
|
|
28202
|
-
);
|
|
28203
|
-
}
|
|
28204
|
-
if (isSandboxGenerator(member.object)) {
|
|
28205
|
-
const memberValue = getGeneratorMember(member.object, member.property, context.budget);
|
|
28206
|
-
if (memberValue === void 0) {
|
|
28207
|
-
throw new TypeError(`Generator#${String(member.property)} is not a supported method.`);
|
|
28193
|
+
const member = {
|
|
28194
|
+
...reference,
|
|
28195
|
+
property: await toPropertyKey(reference.property, context.budget, createCoercionContext(context))
|
|
28196
|
+
};
|
|
28197
|
+
if (typeof member.object === "string" && isStringMethodName(member.property)) {
|
|
28198
|
+
return evaluateStringMethodCall(node, member.object, member.property, context);
|
|
28208
28199
|
}
|
|
28209
|
-
|
|
28210
|
-
|
|
28211
|
-
|
|
28212
|
-
|
|
28213
|
-
|
|
28214
|
-
|
|
28200
|
+
if (typeof member.object === "number" && isNumberMethodName(member.property)) {
|
|
28201
|
+
return evaluateNumberMethodCall(node, member.object, member.property, context);
|
|
28202
|
+
}
|
|
28203
|
+
if (Array.isArray(member.object) && isArrayMethodName(member.property) && !Object.hasOwn(member.object, member.property)) {
|
|
28204
|
+
return evaluateArrayMethodCall(node, member.object, member.property, context);
|
|
28205
|
+
}
|
|
28206
|
+
if (isSandboxMap(member.object) && isMapMethodName(member.property)) {
|
|
28207
|
+
return evaluateMapMethodCall(node, member.object, member.property, context);
|
|
28208
|
+
}
|
|
28209
|
+
if (isSandboxSet(member.object) && isSetMethodName(member.property)) {
|
|
28210
|
+
return evaluateSetMethodCall(node, member.object, member.property, context);
|
|
28211
|
+
}
|
|
28212
|
+
if (typeof member.object === "string") {
|
|
28213
|
+
return evaluatePrimitiveMemberCall(
|
|
28214
|
+
node,
|
|
28215
|
+
"String",
|
|
28216
|
+
member.property,
|
|
28217
|
+
getStringMember(member.object, member.property, context.budget),
|
|
28218
|
+
context
|
|
28219
|
+
);
|
|
28220
|
+
}
|
|
28221
|
+
if (typeof member.object === "number") {
|
|
28222
|
+
return evaluatePrimitiveMemberCall(
|
|
28223
|
+
node,
|
|
28224
|
+
"Number",
|
|
28225
|
+
member.property,
|
|
28226
|
+
getNumberMember(member.property, context.budget),
|
|
28227
|
+
context
|
|
28228
|
+
);
|
|
28229
|
+
}
|
|
28230
|
+
if (Array.isArray(member.object) && !Object.hasOwn(member.object, member.property)) {
|
|
28231
|
+
return evaluatePrimitiveMemberCall(
|
|
28232
|
+
node,
|
|
28233
|
+
"Array",
|
|
28234
|
+
member.property,
|
|
28235
|
+
getArrayMemberValue(member.object, member.property, context),
|
|
28236
|
+
context
|
|
28237
|
+
);
|
|
28238
|
+
}
|
|
28239
|
+
if (isSandboxMap(member.object)) {
|
|
28240
|
+
return evaluatePrimitiveMemberCall(
|
|
28241
|
+
node,
|
|
28242
|
+
"Map",
|
|
28243
|
+
member.property,
|
|
28244
|
+
getMapMember(member.object, member.property, createMapMethodOptions(context)),
|
|
28245
|
+
context
|
|
28246
|
+
);
|
|
28247
|
+
}
|
|
28248
|
+
if (isSandboxDate(member.object)) {
|
|
28249
|
+
return evaluateResolvedCallExpression(node, getDateMember(member.property, context.budget, context.compilation?.owner), context, member.object);
|
|
28250
|
+
}
|
|
28251
|
+
if (isFloat32Array(member.object)) {
|
|
28252
|
+
return evaluateResolvedCallExpression(
|
|
28253
|
+
node,
|
|
28254
|
+
getFloat32Member(member.object, member.property, context.budget),
|
|
28255
|
+
context,
|
|
28256
|
+
member.object
|
|
28257
|
+
);
|
|
28258
|
+
}
|
|
28259
|
+
if (isSandboxSet(member.object)) {
|
|
28260
|
+
return evaluatePrimitiveMemberCall(
|
|
28261
|
+
node,
|
|
28262
|
+
"Set",
|
|
28263
|
+
member.property,
|
|
28264
|
+
getSetMember(member.object, member.property, createSetMethodOptions(context)),
|
|
28265
|
+
context
|
|
28266
|
+
);
|
|
28267
|
+
}
|
|
28268
|
+
if (isSandboxGenerator(member.object)) {
|
|
28269
|
+
const memberValue = getGeneratorMember(member.object, member.property, context.budget);
|
|
28270
|
+
if (memberValue === void 0) {
|
|
28271
|
+
throw new TypeError(`Generator#${String(member.property)} is not a supported method.`);
|
|
28272
|
+
}
|
|
28273
|
+
return evaluateResolvedCallExpression(node, memberValue, context, member.object);
|
|
28274
|
+
}
|
|
28275
|
+
if (isSandboxClosure(member.object)) {
|
|
28276
|
+
const memberValue = getClosureMemberValue(member.object, member.property, context);
|
|
28277
|
+
if (memberValue === void 0) {
|
|
28278
|
+
throw new TypeError(`Function#${String(member.property)} is not a supported method.`);
|
|
28279
|
+
}
|
|
28280
|
+
return evaluateResolvedCallExpression(node, memberValue, context, member.object);
|
|
28281
|
+
}
|
|
28282
|
+
if (isSandboxPromise(member.object)) {
|
|
28283
|
+
return evaluateResolvedCallExpression(
|
|
28284
|
+
node,
|
|
28285
|
+
getPromiseMember(member.property, context.budget),
|
|
28286
|
+
context,
|
|
28287
|
+
member.object
|
|
28288
|
+
);
|
|
28289
|
+
}
|
|
28290
|
+
if (isSandboxRegex(member.object) && isRegexMethodName(member.property)) {
|
|
28291
|
+
return evaluateResolvedCallExpression(
|
|
28292
|
+
node,
|
|
28293
|
+
getRegexMember(member.object, member.property, context.budget),
|
|
28294
|
+
context,
|
|
28295
|
+
member.object
|
|
28296
|
+
);
|
|
28297
|
+
}
|
|
28298
|
+
if (!isIndexableSandboxValue(member.object)) {
|
|
28299
|
+
throw new TypeError("Attempted to read a property from a non-object value.");
|
|
28215
28300
|
}
|
|
28216
|
-
return evaluateResolvedCallExpression(node, memberValue, context, member.object);
|
|
28217
|
-
}
|
|
28218
|
-
if (isSandboxPromise(member.object)) {
|
|
28219
|
-
return evaluateResolvedCallExpression(
|
|
28220
|
-
node,
|
|
28221
|
-
getPromiseMember(member.property, context.budget),
|
|
28222
|
-
context,
|
|
28223
|
-
member.object
|
|
28224
|
-
);
|
|
28225
|
-
}
|
|
28226
|
-
if (isSandboxRegex(member.object) && isRegexMethodName(member.property)) {
|
|
28227
28301
|
return evaluateResolvedCallExpression(
|
|
28228
28302
|
node,
|
|
28229
|
-
|
|
28303
|
+
getMemberValue(member.object, member.property, context),
|
|
28230
28304
|
context,
|
|
28231
28305
|
member.object
|
|
28232
28306
|
);
|
|
28233
|
-
}
|
|
28234
|
-
if (!isIndexableSandboxValue(member.object)) {
|
|
28235
|
-
throw new TypeError("Attempted to read a property from a non-object value.");
|
|
28236
|
-
}
|
|
28237
|
-
return evaluateResolvedCallExpression(
|
|
28238
|
-
node,
|
|
28239
|
-
getMemberValue(member.object, member.property, context),
|
|
28240
|
-
context,
|
|
28241
|
-
member.object
|
|
28242
|
-
);
|
|
28307
|
+
});
|
|
28243
28308
|
}
|
|
28244
28309
|
function evaluatePrimitiveMemberCall(node, receiverType, property, value, context) {
|
|
28245
28310
|
if (value === void 0) {
|
|
@@ -28874,30 +28939,35 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
28874
28939
|
}
|
|
28875
28940
|
async function evaluateCallArguments(args, context) {
|
|
28876
28941
|
const values = [];
|
|
28877
|
-
|
|
28878
|
-
|
|
28879
|
-
|
|
28880
|
-
if (
|
|
28881
|
-
|
|
28942
|
+
const release = retainValues(context.budget, () => values);
|
|
28943
|
+
try {
|
|
28944
|
+
for (const arg of args) {
|
|
28945
|
+
if (arg.type === "SpreadElement") {
|
|
28946
|
+
const spreadValues = await evaluateSpreadElement(arg, context);
|
|
28947
|
+
if (!spreadValues.ok) {
|
|
28948
|
+
return spreadValues;
|
|
28949
|
+
}
|
|
28950
|
+
appendArrayValues2(values, spreadValues.value);
|
|
28951
|
+
context.budget.allocateArrayLength(values.length);
|
|
28952
|
+
continue;
|
|
28953
|
+
}
|
|
28954
|
+
const result = await evaluateNode(arg, context);
|
|
28955
|
+
if (result.kind !== "normal") {
|
|
28956
|
+
return {
|
|
28957
|
+
ok: false,
|
|
28958
|
+
result
|
|
28959
|
+
};
|
|
28882
28960
|
}
|
|
28883
|
-
|
|
28961
|
+
values.push(result.value);
|
|
28884
28962
|
context.budget.allocateArrayLength(values.length);
|
|
28885
|
-
continue;
|
|
28886
|
-
}
|
|
28887
|
-
const result = await evaluateNode(arg, context);
|
|
28888
|
-
if (result.kind !== "normal") {
|
|
28889
|
-
return {
|
|
28890
|
-
ok: false,
|
|
28891
|
-
result
|
|
28892
|
-
};
|
|
28893
28963
|
}
|
|
28894
|
-
|
|
28895
|
-
|
|
28964
|
+
return {
|
|
28965
|
+
ok: true,
|
|
28966
|
+
value: values
|
|
28967
|
+
};
|
|
28968
|
+
} finally {
|
|
28969
|
+
release();
|
|
28896
28970
|
}
|
|
28897
|
-
return {
|
|
28898
|
-
ok: true,
|
|
28899
|
-
value: values
|
|
28900
|
-
};
|
|
28901
28971
|
}
|
|
28902
28972
|
async function evaluateSpreadElement(node, context) {
|
|
28903
28973
|
const value = await evaluateNode(node.argument, context);
|
|
@@ -28912,21 +28982,26 @@ async function evaluateSpreadElement(node, context) {
|
|
|
28912
28982
|
throw new TypeError("Spread arguments must evaluate to an iterable.");
|
|
28913
28983
|
}
|
|
28914
28984
|
const spreadValues = [];
|
|
28915
|
-
|
|
28916
|
-
|
|
28917
|
-
|
|
28918
|
-
|
|
28919
|
-
|
|
28920
|
-
|
|
28921
|
-
|
|
28985
|
+
const release = retainValues(context.budget, () => [value.value, ...spreadValues]);
|
|
28986
|
+
try {
|
|
28987
|
+
while (true) {
|
|
28988
|
+
const next = await iterator.next();
|
|
28989
|
+
if (typeof next !== "object" || next === null) {
|
|
28990
|
+
throw new TypeError("Iterator result must be an object.");
|
|
28991
|
+
}
|
|
28992
|
+
if (next.done === true) {
|
|
28993
|
+
break;
|
|
28994
|
+
}
|
|
28995
|
+
spreadValues.push(next.value);
|
|
28996
|
+
context.budget.allocateArrayLength(spreadValues.length);
|
|
28922
28997
|
}
|
|
28923
|
-
|
|
28924
|
-
|
|
28998
|
+
return {
|
|
28999
|
+
ok: true,
|
|
29000
|
+
value: spreadValues
|
|
29001
|
+
};
|
|
29002
|
+
} finally {
|
|
29003
|
+
release();
|
|
28925
29004
|
}
|
|
28926
|
-
return {
|
|
28927
|
-
ok: true,
|
|
28928
|
-
value: spreadValues
|
|
28929
|
-
};
|
|
28930
29005
|
}
|
|
28931
29006
|
async function evaluateObjectSpread(node, context) {
|
|
28932
29007
|
const value = await evaluateNode(node.argument, context);
|
|
@@ -31301,41 +31376,6 @@ function createBuiltinBindings(options) {
|
|
|
31301
31376
|
};
|
|
31302
31377
|
}
|
|
31303
31378
|
|
|
31304
|
-
// packages/safe-js/src/interp/resources.ts
|
|
31305
|
-
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
31306
|
-
var runResources = new AsyncLocalStorage5();
|
|
31307
|
-
async function withRunResources(signal, execute) {
|
|
31308
|
-
const controller = new AbortController();
|
|
31309
|
-
const cancel = () => controller.abort(signal?.reason);
|
|
31310
|
-
const cleanups = /* @__PURE__ */ new Set();
|
|
31311
|
-
const resources = {
|
|
31312
|
-
signal: controller.signal,
|
|
31313
|
-
add(close) {
|
|
31314
|
-
cleanups.add(close);
|
|
31315
|
-
}
|
|
31316
|
-
};
|
|
31317
|
-
signal?.addEventListener("abort", cancel, { once: true });
|
|
31318
|
-
if (signal?.aborted) cancel();
|
|
31319
|
-
let result;
|
|
31320
|
-
let failure;
|
|
31321
|
-
let errors = [];
|
|
31322
|
-
try {
|
|
31323
|
-
result = await runResources.run(resources, execute);
|
|
31324
|
-
} catch (error) {
|
|
31325
|
-
failure = { reason: error };
|
|
31326
|
-
} finally {
|
|
31327
|
-
signal?.removeEventListener("abort", cancel);
|
|
31328
|
-
controller.abort(new Error("SafeJS run finished."));
|
|
31329
|
-
const outcomes = await Promise.allSettled(
|
|
31330
|
-
[...cleanups].map((close) => Promise.resolve().then(close))
|
|
31331
|
-
);
|
|
31332
|
-
errors = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
|
|
31333
|
-
}
|
|
31334
|
-
if (failure !== void 0) throw failure.reason;
|
|
31335
|
-
if (errors.length > 0) throw new AggregateError(errors, "SafeJS resource cleanup failed.");
|
|
31336
|
-
return result;
|
|
31337
|
-
}
|
|
31338
|
-
|
|
31339
31379
|
// packages/safe-js/src/modules/registry.ts
|
|
31340
31380
|
function createUnknownModuleMessage2(moduleName, moduleNames) {
|
|
31341
31381
|
if (moduleNames.length === 0) {
|
|
@@ -31577,6 +31617,7 @@ var RealmState = class {
|
|
|
31577
31617
|
extensions;
|
|
31578
31618
|
consoleExtension;
|
|
31579
31619
|
cleanups = [];
|
|
31620
|
+
referenceReleases = /* @__PURE__ */ new Set();
|
|
31580
31621
|
callbacks = /* @__PURE__ */ new Map();
|
|
31581
31622
|
pendingCallbacks = /* @__PURE__ */ new Set();
|
|
31582
31623
|
callbackCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -31903,7 +31944,7 @@ var RealmState = class {
|
|
|
31903
31944
|
const pending = withSandboxPromiseRejectionTracker(
|
|
31904
31945
|
this.tracker,
|
|
31905
31946
|
() => runResources.run(
|
|
31906
|
-
{ signal: this.controller.signal, add: this.onCleanup },
|
|
31947
|
+
{ signal: this.controller.signal, referenceReleases: this.referenceReleases, add: this.onCleanup },
|
|
31907
31948
|
() => withCancellationSignal(
|
|
31908
31949
|
this.controller.signal,
|
|
31909
31950
|
() => active && this.phase.getStore()?.active ? runAsyncPrefix(invoke) : this.queue.run(invoke)
|
|
@@ -32098,7 +32139,7 @@ var RealmState = class {
|
|
|
32098
32139
|
() => withSandboxPromiseRejectionTracker(
|
|
32099
32140
|
this.tracker,
|
|
32100
32141
|
() => runResources.run(
|
|
32101
|
-
{ signal: this.controller.signal, add: this.onCleanup },
|
|
32142
|
+
{ signal: this.controller.signal, referenceReleases: this.referenceReleases, add: this.onCleanup },
|
|
32102
32143
|
() => withCancellationSignal(this.controller.signal, task)
|
|
32103
32144
|
)
|
|
32104
32145
|
)
|
|
@@ -32155,6 +32196,8 @@ var RealmState = class {
|
|
|
32155
32196
|
this.hostObjects.clear();
|
|
32156
32197
|
for (const reference of this.guestReferences.keys()) revokeGuestReference(reference, this);
|
|
32157
32198
|
this.guestReferences.clear();
|
|
32199
|
+
for (const release of this.referenceReleases) release();
|
|
32200
|
+
this.referenceReleases.clear();
|
|
32158
32201
|
this.budget.setRetainedValues(this, void 0);
|
|
32159
32202
|
releaseObjectPrototype(this.budget);
|
|
32160
32203
|
this.disposal = (async () => {
|
|
@@ -33408,9 +33451,9 @@ export {
|
|
|
33408
33451
|
validateSnapshotMigration,
|
|
33409
33452
|
restore,
|
|
33410
33453
|
lint,
|
|
33454
|
+
runResources,
|
|
33411
33455
|
declareHostOperation,
|
|
33412
33456
|
createSeededRandom,
|
|
33413
|
-
runResources,
|
|
33414
33457
|
createReplayableRandom,
|
|
33415
33458
|
createRealm,
|
|
33416
33459
|
dump,
|
|
@@ -33420,4 +33463,4 @@ export {
|
|
|
33420
33463
|
FileSnapshotBackend,
|
|
33421
33464
|
run
|
|
33422
33465
|
};
|
|
33423
|
-
//# sourceMappingURL=chunk-
|
|
33466
|
+
//# sourceMappingURL=chunk-D4YY44EF.js.map
|