@poe-platform/safe-js 0.1.439 → 0.1.441
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-XCJLWZP7.js → chunk-TIAM72UI.js} +51 -17
- package/dist/safe-js/chunks/{chunk-XCJLWZP7.js.map → chunk-TIAM72UI.js.map} +3 -3
- package/dist/safe-js/chunks/{chunk-O6PAZGEO.js → chunk-XHHDLB42.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/scope.d.ts +1 -0
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-O6PAZGEO.js.map → chunk-XHHDLB42.js.map} +0 -0
|
@@ -7626,6 +7626,9 @@ function serializedDateTime(value) {
|
|
|
7626
7626
|
return Number.isNaN(time) ? null : time;
|
|
7627
7627
|
}
|
|
7628
7628
|
|
|
7629
|
+
// packages/safe-js/src/interp/scope-data-roots.ts
|
|
7630
|
+
var scopeDataRoots = /* @__PURE__ */ new WeakMap();
|
|
7631
|
+
|
|
7629
7632
|
// packages/safe-js/src/error/native-suppressed-error.ts
|
|
7630
7633
|
function SuppressedError(error, suppressed, message) {
|
|
7631
7634
|
const prototype = new.target?.prototype;
|
|
@@ -9477,6 +9480,27 @@ var Scope = class _Scope {
|
|
|
9477
9480
|
}
|
|
9478
9481
|
return values;
|
|
9479
9482
|
}
|
|
9483
|
+
retainedDataRoots() {
|
|
9484
|
+
const values = this.parent?.retainedDataRoots() ?? [];
|
|
9485
|
+
if (this.moduleEnvironment !== void 0) values.push(...Object.values(this.moduleEnvironment.namespaces));
|
|
9486
|
+
if (this.resourceState !== void 0) values.push(this.resourceState);
|
|
9487
|
+
if (this.options.chargeData !== false) {
|
|
9488
|
+
if (this.importMeta !== void 0) values.push(this.importMeta);
|
|
9489
|
+
if (this.privateNames !== void 0) values.push(...this.privateNames.values());
|
|
9490
|
+
}
|
|
9491
|
+
const bindings = this.options.chargeData === false ? this.#replacedBindings : this.#bindings.values();
|
|
9492
|
+
for (const binding of bindings) {
|
|
9493
|
+
const value = binding.value;
|
|
9494
|
+
if (value === uninitialized || value == null || typeof value === "number" || typeof value === "boolean") continue;
|
|
9495
|
+
if (binding.accounting === void 0 || !Object.is(binding.accounting.value, value)) {
|
|
9496
|
+
const root = Object.freeze({});
|
|
9497
|
+
scopeDataRoots.set(root, { value });
|
|
9498
|
+
binding.accounting = { value, root };
|
|
9499
|
+
}
|
|
9500
|
+
values.push(binding.accounting.root);
|
|
9501
|
+
}
|
|
9502
|
+
return values;
|
|
9503
|
+
}
|
|
9480
9504
|
declare(name, kind, value) {
|
|
9481
9505
|
const existing = this.#bindings.get(name);
|
|
9482
9506
|
if (existing !== void 0 && existing.value !== uninitialized) {
|
|
@@ -9485,7 +9509,7 @@ var Scope = class _Scope {
|
|
|
9485
9509
|
if (existing !== void 0 && existing.kind !== kind) {
|
|
9486
9510
|
throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
|
|
9487
9511
|
}
|
|
9488
|
-
if (existing !== void 0) existing
|
|
9512
|
+
if (existing !== void 0) writeBindingValue(existing, value);
|
|
9489
9513
|
else this.#bindings.set(name, { kind, value });
|
|
9490
9514
|
}
|
|
9491
9515
|
declareAlias(name, target) {
|
|
@@ -9548,7 +9572,7 @@ var Scope = class _Scope {
|
|
|
9548
9572
|
if (binding.kind === "const") {
|
|
9549
9573
|
throw new TypeError(`Cannot assign to const binding '${name}'.`);
|
|
9550
9574
|
}
|
|
9551
|
-
binding
|
|
9575
|
+
writeBindingValue(binding, value);
|
|
9552
9576
|
scope.trackReplacement(name, binding);
|
|
9553
9577
|
}
|
|
9554
9578
|
lookup(name) {
|
|
@@ -9671,7 +9695,7 @@ var Scope = class _Scope {
|
|
|
9671
9695
|
}
|
|
9672
9696
|
const targetBinding = targetScope.#bindings.get(name);
|
|
9673
9697
|
targetBinding.kind = sourceBinding.kind;
|
|
9674
|
-
targetBinding
|
|
9698
|
+
writeBindingValue(targetBinding, sourceBinding.value);
|
|
9675
9699
|
}
|
|
9676
9700
|
}
|
|
9677
9701
|
resolveScope(name) {
|
|
@@ -9702,6 +9726,10 @@ var Scope = class _Scope {
|
|
|
9702
9726
|
};
|
|
9703
9727
|
}
|
|
9704
9728
|
};
|
|
9729
|
+
function writeBindingValue(binding, value) {
|
|
9730
|
+
if (!Object.is(binding.value, value)) binding.accounting = void 0;
|
|
9731
|
+
binding.value = value;
|
|
9732
|
+
}
|
|
9705
9733
|
function defineSnapshotBinding(target, name, value) {
|
|
9706
9734
|
Object.defineProperty(target, name, {
|
|
9707
9735
|
configurable: true,
|
|
@@ -16287,7 +16315,7 @@ async function evaluateNode(node, context) {
|
|
|
16287
16315
|
function reconcileDataBudget(budget, stats, scope, transient, compilation, parent) {
|
|
16288
16316
|
reconcileCompiledValues(
|
|
16289
16317
|
budget,
|
|
16290
|
-
[...scope.
|
|
16318
|
+
[...scope.retainedDataRoots(), transient],
|
|
16291
16319
|
compilation,
|
|
16292
16320
|
parent,
|
|
16293
16321
|
[transient]
|
|
@@ -21024,7 +21052,7 @@ function createClassConstructor(node, context, evaluateNode2, fields2) {
|
|
|
21024
21052
|
length: constructorElement === void 0 ? 0 : getFunctionLength(constructorElement.value.params),
|
|
21025
21053
|
sourceRange: functionSources.get(node),
|
|
21026
21054
|
retainedValues: () => {
|
|
21027
|
-
const values = [...scope.
|
|
21055
|
+
const values = [...scope.retainedDataRoots(), ...fields2.flatMap((field) => field.privateName === void 0 ? [field.key] : [field.key, field.privateName])];
|
|
21028
21056
|
for (const [name, element] of classOrigins.get(constructor)?.privateMethods ?? []) {
|
|
21029
21057
|
values.push(name);
|
|
21030
21058
|
if (element.kind === "accessor") values.push(element.get, element.set);
|
|
@@ -29514,6 +29542,12 @@ function measureSandboxData(values, options = {}) {
|
|
|
29514
29542
|
}
|
|
29515
29543
|
if (typeof value !== "object" || value === null) return;
|
|
29516
29544
|
if (seen.has(value)) return;
|
|
29545
|
+
const bindingRoot = scopeDataRoots.get(value);
|
|
29546
|
+
if (bindingRoot !== void 0) {
|
|
29547
|
+
seen.add(value);
|
|
29548
|
+
visit(bindingRoot.value, depth);
|
|
29549
|
+
return;
|
|
29550
|
+
}
|
|
29517
29551
|
assertSandboxDataDepth(depth);
|
|
29518
29552
|
seen.add(value);
|
|
29519
29553
|
usage += 1;
|
|
@@ -32623,7 +32657,7 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
32623
32657
|
...node.type === "FunctionDeclaration" || node.type === "FunctionExpression" ? node.id === void 0 ? { name: context.inferredName } : { name: node.id.name } : { name: context.inferredName },
|
|
32624
32658
|
...construct === void 0 ? {} : { construct },
|
|
32625
32659
|
retainedValues: () => {
|
|
32626
|
-
const values = [...context.scope.
|
|
32660
|
+
const values = [...context.scope.retainedDataRoots(), context.functionEnvironment?.homeObject, context.functionEnvironment?.newTarget];
|
|
32627
32661
|
if (constructionState !== void 0) {
|
|
32628
32662
|
values.push(
|
|
32629
32663
|
constructionState.constructor,
|
|
@@ -32631,7 +32665,7 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
32631
32665
|
constructionState.prototype,
|
|
32632
32666
|
constructionState.thisValue
|
|
32633
32667
|
);
|
|
32634
|
-
if (constructionState.thisScope !== void 0) values.push(...constructionState.thisScope.
|
|
32668
|
+
if (constructionState.thisScope !== void 0) values.push(...constructionState.thisScope.retainedDataRoots());
|
|
32635
32669
|
}
|
|
32636
32670
|
return values;
|
|
32637
32671
|
},
|
|
@@ -32679,7 +32713,7 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
32679
32713
|
}
|
|
32680
32714
|
});
|
|
32681
32715
|
const value = "hasValue" in result && result.hasValue ? result.value : void 0;
|
|
32682
|
-
reconcileCompiledValues(context.budget, [...scope.
|
|
32716
|
+
reconcileCompiledValues(context.budget, [...scope.retainedDataRoots(), value], compilation, parent, [value]);
|
|
32683
32717
|
if (result.kind === "error") throw result.error;
|
|
32684
32718
|
if (result.kind === "throw") throw result.value;
|
|
32685
32719
|
return value;
|
|
@@ -32737,7 +32771,7 @@ function createGeneratorClosure(node, context, evaluateNode2, initializePrototyp
|
|
|
32737
32771
|
sandbox: true,
|
|
32738
32772
|
length: getFunctionLength(node.params),
|
|
32739
32773
|
...node.id === void 0 ? { name: context.inferredName } : { name: node.id.name },
|
|
32740
|
-
retainedValues: () => [...context.scope.
|
|
32774
|
+
retainedValues: () => [...context.scope.retainedDataRoots(), context.functionEnvironment?.homeObject, context.functionEnvironment?.newTarget],
|
|
32741
32775
|
call: async (args, callContext) => {
|
|
32742
32776
|
const candidate = prototypes2 === void 0 ? void 0 : getGuestFunctionProperty(closure, "prototype");
|
|
32743
32777
|
const prototype = typeof candidate === "object" && candidate !== null ? candidate : prototypes2?.instancePrototype;
|
|
@@ -32906,7 +32940,7 @@ async function executeClosure(node, args, thisValue, context, evaluateNode2) {
|
|
|
32906
32940
|
const value = "hasValue" in result && result.hasValue ? result.value : void 0;
|
|
32907
32941
|
reconcileCompiledValues(
|
|
32908
32942
|
context.budget,
|
|
32909
|
-
[...scope.
|
|
32943
|
+
[...scope.retainedDataRoots(), value],
|
|
32910
32944
|
compilation,
|
|
32911
32945
|
parent,
|
|
32912
32946
|
[value]
|
|
@@ -45661,7 +45695,7 @@ var RealmState = class {
|
|
|
45661
45695
|
}
|
|
45662
45696
|
if (captured.length > 0)
|
|
45663
45697
|
this.budget.reconcileDataUsage(
|
|
45664
|
-
measureSandboxData([...this.scope?.
|
|
45698
|
+
measureSandboxData([...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()])
|
|
45665
45699
|
);
|
|
45666
45700
|
return { args: values, rollback };
|
|
45667
45701
|
} catch (error) {
|
|
@@ -45677,7 +45711,7 @@ var RealmState = class {
|
|
|
45677
45711
|
if (this.active === void 0)
|
|
45678
45712
|
reconcileCompiledValues(
|
|
45679
45713
|
this.budget,
|
|
45680
|
-
[...this.scope?.
|
|
45714
|
+
[...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()],
|
|
45681
45715
|
this.compilation
|
|
45682
45716
|
);
|
|
45683
45717
|
};
|
|
@@ -45860,7 +45894,7 @@ var RealmState = class {
|
|
|
45860
45894
|
});
|
|
45861
45895
|
try {
|
|
45862
45896
|
this.budget.reconcileDataUsage(
|
|
45863
|
-
measureSandboxData([...this.scope?.
|
|
45897
|
+
measureSandboxData([...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()])
|
|
45864
45898
|
);
|
|
45865
45899
|
} catch (error) {
|
|
45866
45900
|
this.poison(error);
|
|
@@ -45875,7 +45909,7 @@ var RealmState = class {
|
|
|
45875
45909
|
if (this.active === void 0)
|
|
45876
45910
|
reconcileCompiledValues(
|
|
45877
45911
|
this.budget,
|
|
45878
|
-
[...this.scope?.
|
|
45912
|
+
[...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()],
|
|
45879
45913
|
this.compilation
|
|
45880
45914
|
);
|
|
45881
45915
|
};
|
|
@@ -45949,7 +45983,7 @@ var RealmState = class {
|
|
|
45949
45983
|
if (!this.closed && this.active === void 0)
|
|
45950
45984
|
reconcileCompiledValues(
|
|
45951
45985
|
this.budget,
|
|
45952
|
-
[...this.scope?.
|
|
45986
|
+
[...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()],
|
|
45953
45987
|
this.compilation
|
|
45954
45988
|
);
|
|
45955
45989
|
}
|
|
@@ -46151,7 +46185,7 @@ var RealmState = class {
|
|
|
46151
46185
|
if (!this.closed)
|
|
46152
46186
|
reconcileCompiledValues(
|
|
46153
46187
|
this.budget,
|
|
46154
|
-
[...this.scope?.
|
|
46188
|
+
[...this.scope?.retainedDataRoots() ?? [], ...this.retainedRoots()],
|
|
46155
46189
|
this.compilation
|
|
46156
46190
|
);
|
|
46157
46191
|
return result;
|
|
@@ -47559,4 +47593,4 @@ export {
|
|
|
47559
47593
|
FileSnapshotBackend,
|
|
47560
47594
|
run
|
|
47561
47595
|
};
|
|
47562
|
-
//# sourceMappingURL=chunk-
|
|
47596
|
+
//# sourceMappingURL=chunk-TIAM72UI.js.map
|