@poe-platform/safe-js 0.1.161 → 0.1.163
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-AR5OJ6OJ.js → chunk-AW3IBVVD.js} +472 -800
- package/dist/safe-js/chunks/chunk-AW3IBVVD.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-F2N5FBBV.js → chunk-ZXBZUJHU.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/patterns.d.ts +3 -2
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-AR5OJ6OJ.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-F2N5FBBV.js.map → chunk-ZXBZUJHU.js.map} +0 -0
|
@@ -9070,221 +9070,6 @@ async function withRunResources(signal, execute) {
|
|
|
9070
9070
|
return result;
|
|
9071
9071
|
}
|
|
9072
9072
|
|
|
9073
|
-
// packages/safe-js/src/interp/patterns.ts
|
|
9074
|
-
async function bindPattern(pattern, value, target, scope, context) {
|
|
9075
|
-
switch (pattern.type) {
|
|
9076
|
-
case "Identifier":
|
|
9077
|
-
bindIdentifier(pattern, value, target, scope);
|
|
9078
|
-
return { ok: true };
|
|
9079
|
-
case "MemberExpression":
|
|
9080
|
-
if ("kind" in target) {
|
|
9081
|
-
throw new TypeError("Destructuring declarations cannot bind to member expressions.");
|
|
9082
|
-
}
|
|
9083
|
-
return bindMemberExpression(pattern, value, scope, context);
|
|
9084
|
-
case "AssignmentPattern":
|
|
9085
|
-
return bindAssignmentPattern(pattern, value, target, scope, context);
|
|
9086
|
-
case "ArrayPattern":
|
|
9087
|
-
return bindArrayPattern(pattern, value, target, scope, context);
|
|
9088
|
-
case "ObjectPattern":
|
|
9089
|
-
return bindObjectPattern(pattern, value, target, scope, context);
|
|
9090
|
-
case "RestElement":
|
|
9091
|
-
return bindPattern(pattern.argument, value, target, scope, context);
|
|
9092
|
-
}
|
|
9093
|
-
}
|
|
9094
|
-
function bindIdentifier(pattern, value, target, scope) {
|
|
9095
|
-
if ("assign" in target || target.kind === "var" && target.initialize !== true) {
|
|
9096
|
-
if ("assign" in target) {
|
|
9097
|
-
const binding = scope.lookup(pattern.name);
|
|
9098
|
-
if (!binding.found) {
|
|
9099
|
-
throw new ReferenceError(`Cannot assign to undeclared binding '${pattern.name}'.`);
|
|
9100
|
-
}
|
|
9101
|
-
if (binding.kind === "const") {
|
|
9102
|
-
throw new TypeError(`Cannot assign to const '${pattern.name}'`);
|
|
9103
|
-
}
|
|
9104
|
-
}
|
|
9105
|
-
scope.assign(pattern.name, value);
|
|
9106
|
-
return;
|
|
9107
|
-
}
|
|
9108
|
-
scope.declare(pattern.name, target.kind, value);
|
|
9109
|
-
}
|
|
9110
|
-
async function bindAssignmentPattern(pattern, value, target, scope, context) {
|
|
9111
|
-
if (value !== void 0) {
|
|
9112
|
-
return bindPattern(pattern.left, value, target, scope, context);
|
|
9113
|
-
}
|
|
9114
|
-
const defaultValue = await context.evaluate(
|
|
9115
|
-
pattern.right,
|
|
9116
|
-
pattern.left.type === "Identifier" ? pattern.left.name : void 0
|
|
9117
|
-
);
|
|
9118
|
-
if (defaultValue.kind !== "normal") {
|
|
9119
|
-
return { ok: false, result: defaultValue };
|
|
9120
|
-
}
|
|
9121
|
-
return bindPattern(pattern.left, defaultValue.value, target, scope, context);
|
|
9122
|
-
}
|
|
9123
|
-
async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
9124
|
-
const iterator = isSandboxCollectionIterator(value) ? value : void 0;
|
|
9125
|
-
const values = iterator === void 0 ? getArrayPatternValues(value) : void 0;
|
|
9126
|
-
let cursor = 0;
|
|
9127
|
-
let done = false;
|
|
9128
|
-
const next = async () => {
|
|
9129
|
-
if (iterator !== void 0) return nextCollectionIterator(iterator, context.budget);
|
|
9130
|
-
if (done || cursor >= values.length) {
|
|
9131
|
-
done = true;
|
|
9132
|
-
return { done: true, value: void 0 };
|
|
9133
|
-
}
|
|
9134
|
-
return { done: false, value: await context.getProperty(values, cursor++) };
|
|
9135
|
-
};
|
|
9136
|
-
for (let index = 0; index < pattern.elements.length; index += 1) {
|
|
9137
|
-
const element = pattern.elements[index];
|
|
9138
|
-
if (element === null) {
|
|
9139
|
-
await next();
|
|
9140
|
-
continue;
|
|
9141
|
-
}
|
|
9142
|
-
let elementValue;
|
|
9143
|
-
if (element.type === "RestElement") {
|
|
9144
|
-
const rest = [];
|
|
9145
|
-
for (let entry = await next(); !entry.done; entry = await next()) {
|
|
9146
|
-
context.budget?.allocateArrayLength(rest.length + 1);
|
|
9147
|
-
rest.push(entry.value);
|
|
9148
|
-
}
|
|
9149
|
-
elementValue = rest;
|
|
9150
|
-
} else {
|
|
9151
|
-
elementValue = (await next()).value;
|
|
9152
|
-
}
|
|
9153
|
-
const binding = await bindPattern(element, elementValue, target, scope, context);
|
|
9154
|
-
if (!binding.ok) {
|
|
9155
|
-
return binding;
|
|
9156
|
-
}
|
|
9157
|
-
}
|
|
9158
|
-
return { ok: true };
|
|
9159
|
-
}
|
|
9160
|
-
async function bindObjectPattern(pattern, value, target, scope, context) {
|
|
9161
|
-
if (typeof value !== "object" || value === null) {
|
|
9162
|
-
throw new TypeError("Object destructuring declarations require a non-null object value.");
|
|
9163
|
-
}
|
|
9164
|
-
const excludedKeys = /* @__PURE__ */ new Set();
|
|
9165
|
-
for (const property of pattern.properties) {
|
|
9166
|
-
if (property.type === "RestElement") {
|
|
9167
|
-
const binding2 = await bindPattern(
|
|
9168
|
-
property,
|
|
9169
|
-
await copyObjectRestValue(value, excludedKeys, context),
|
|
9170
|
-
target,
|
|
9171
|
-
scope,
|
|
9172
|
-
context
|
|
9173
|
-
);
|
|
9174
|
-
if (!binding2.ok) {
|
|
9175
|
-
return binding2;
|
|
9176
|
-
}
|
|
9177
|
-
continue;
|
|
9178
|
-
}
|
|
9179
|
-
const key = await evaluatePatternKey(property, context);
|
|
9180
|
-
if (!key.ok) {
|
|
9181
|
-
return key;
|
|
9182
|
-
}
|
|
9183
|
-
excludedKeys.add(typeof key.value === "symbol" ? key.value : String(key.value));
|
|
9184
|
-
const binding = await bindPattern(
|
|
9185
|
-
property.value,
|
|
9186
|
-
await context.getProperty(value, key.value),
|
|
9187
|
-
target,
|
|
9188
|
-
scope,
|
|
9189
|
-
context
|
|
9190
|
-
);
|
|
9191
|
-
if (!binding.ok) {
|
|
9192
|
-
return binding;
|
|
9193
|
-
}
|
|
9194
|
-
}
|
|
9195
|
-
return { ok: true };
|
|
9196
|
-
}
|
|
9197
|
-
async function bindMemberExpression(pattern, value, scope, context) {
|
|
9198
|
-
const object = await context.evaluate(pattern.object);
|
|
9199
|
-
if (object.kind !== "normal") {
|
|
9200
|
-
return { ok: false, result: object };
|
|
9201
|
-
}
|
|
9202
|
-
const property = pattern.computed ? await context.evaluate(pattern.property) : { kind: "normal", value: getStaticPropertyName(pattern.property) };
|
|
9203
|
-
if (property.kind !== "normal") {
|
|
9204
|
-
return { ok: false, result: property };
|
|
9205
|
-
}
|
|
9206
|
-
if (object.value === null || object.value === void 0) {
|
|
9207
|
-
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
9208
|
-
}
|
|
9209
|
-
if (!isIndexableValue(object.value)) {
|
|
9210
|
-
throw new TypeError("Assignment expressions require a sandbox object property.");
|
|
9211
|
-
}
|
|
9212
|
-
await context.setProperty(object.value, await context.toPropertyKey(property.value), value);
|
|
9213
|
-
return { ok: true };
|
|
9214
|
-
}
|
|
9215
|
-
async function evaluatePatternKey(property, context) {
|
|
9216
|
-
return property.computed ? evaluateProperty(property.key, context) : { ok: true, value: getStaticPropertyName(property.key) };
|
|
9217
|
-
}
|
|
9218
|
-
async function evaluateProperty(property, context) {
|
|
9219
|
-
const result = await context.evaluate(property);
|
|
9220
|
-
if (result.kind !== "normal") {
|
|
9221
|
-
return { ok: false, result };
|
|
9222
|
-
}
|
|
9223
|
-
return { ok: true, value: await context.toPropertyKey(result.value) };
|
|
9224
|
-
}
|
|
9225
|
-
function getStaticPropertyName(property) {
|
|
9226
|
-
if (property.type === "Identifier") {
|
|
9227
|
-
return property.name;
|
|
9228
|
-
}
|
|
9229
|
-
if (property.type === "StringLiteral" || property.type === "NumericLiteral") {
|
|
9230
|
-
return property.value;
|
|
9231
|
-
}
|
|
9232
|
-
throw new TypeError(`Unsupported static property node '${property.type}'.`);
|
|
9233
|
-
}
|
|
9234
|
-
function getArrayPatternValues(value) {
|
|
9235
|
-
if (Array.isArray(value)) {
|
|
9236
|
-
return value;
|
|
9237
|
-
}
|
|
9238
|
-
if (typeof value === "string") {
|
|
9239
|
-
return Array.from(value);
|
|
9240
|
-
}
|
|
9241
|
-
if (isSandboxMap(value)) {
|
|
9242
|
-
return Array.from(value.entries, ([key, entry]) => [key, entry]);
|
|
9243
|
-
}
|
|
9244
|
-
if (isSandboxSet(value)) {
|
|
9245
|
-
return [...value.values];
|
|
9246
|
-
}
|
|
9247
|
-
if (isIterableValue(value)) {
|
|
9248
|
-
throw new TypeError(
|
|
9249
|
-
`Array destructuring declarations support only arrays and strings; received ${describeRuntimeValue(value)}.`
|
|
9250
|
-
);
|
|
9251
|
-
}
|
|
9252
|
-
throw new TypeError("Array destructuring declarations require an array or string iterable.");
|
|
9253
|
-
}
|
|
9254
|
-
function isIterableValue(value) {
|
|
9255
|
-
return typeof value === "object" && value !== null && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
9256
|
-
}
|
|
9257
|
-
function describeRuntimeValue(value) {
|
|
9258
|
-
if (value === null) return "null";
|
|
9259
|
-
if (value === void 0) return "undefined";
|
|
9260
|
-
if (typeof value === "object") return value.constructor?.name ?? "Object";
|
|
9261
|
-
return typeof value;
|
|
9262
|
-
}
|
|
9263
|
-
async function copyObjectRestValue(value, excludedKeys, context) {
|
|
9264
|
-
const rest = /* @__PURE__ */ Object.create(null);
|
|
9265
|
-
const release = context.budget === void 0 ? () => void 0 : retainValues(context.budget, () => [value, rest]);
|
|
9266
|
-
try {
|
|
9267
|
-
for (const key of ownEnumerableSandboxKeys(value, true)) {
|
|
9268
|
-
if (excludedKeys.has(key) || !hasOwnSandboxProperty(value, key, true)) continue;
|
|
9269
|
-
defineProperty(rest, key, await context.getProperty(value, key));
|
|
9270
|
-
}
|
|
9271
|
-
return rest;
|
|
9272
|
-
} finally {
|
|
9273
|
-
release();
|
|
9274
|
-
}
|
|
9275
|
-
}
|
|
9276
|
-
function isIndexableValue(value) {
|
|
9277
|
-
return typeof value === "object" && value !== null;
|
|
9278
|
-
}
|
|
9279
|
-
function defineProperty(target, key, value) {
|
|
9280
|
-
Object.defineProperty(target, key, {
|
|
9281
|
-
configurable: true,
|
|
9282
|
-
enumerable: true,
|
|
9283
|
-
value,
|
|
9284
|
-
writable: true
|
|
9285
|
-
});
|
|
9286
|
-
}
|
|
9287
|
-
|
|
9288
9073
|
// packages/safe-js/src/interp/jobs.ts
|
|
9289
9074
|
import { AsyncLocalStorage as AsyncLocalStorage4 } from "node:async_hooks";
|
|
9290
9075
|
var activeJob = new AsyncLocalStorage4();
|
|
@@ -9377,31 +9162,6 @@ async function suspendJob(pending) {
|
|
|
9377
9162
|
}
|
|
9378
9163
|
}
|
|
9379
9164
|
|
|
9380
|
-
// packages/safe-js/src/interp/var-hoist.ts
|
|
9381
|
-
function hoistVarDeclarations(node, scope) {
|
|
9382
|
-
for (const declaration of hoistedVarDeclarations([node])) {
|
|
9383
|
-
for (const declarator of declaration.declarations) {
|
|
9384
|
-
for (const identifier of boundIdentifiers(declarator.id)) {
|
|
9385
|
-
scope.declareVar(identifier.name);
|
|
9386
|
-
}
|
|
9387
|
-
}
|
|
9388
|
-
}
|
|
9389
|
-
}
|
|
9390
|
-
|
|
9391
|
-
// packages/safe-js/src/interp/data-checkpoint.ts
|
|
9392
|
-
function createDataCheckpoint(budget, context) {
|
|
9393
|
-
let estimatedDataSize = 0;
|
|
9394
|
-
return (value, growth = 0, force = false) => {
|
|
9395
|
-
const limit = budget.limits.dataSize;
|
|
9396
|
-
if (limit === void 0) return;
|
|
9397
|
-
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
9398
|
-
if (!force && estimatedDataSize <= limit) return;
|
|
9399
|
-
if (context?.reconcileData !== void 0) context.reconcileData(value);
|
|
9400
|
-
else reconcileCompiledValues(budget, [value], context?.compilation);
|
|
9401
|
-
estimatedDataSize = budget.currentDataSize;
|
|
9402
|
-
};
|
|
9403
|
-
}
|
|
9404
|
-
|
|
9405
9165
|
// packages/safe-js/src/interp/iteration.ts
|
|
9406
9166
|
async function acquireSandboxIterator(value, budget, context, asyncProtocol = false, signal) {
|
|
9407
9167
|
const key = asyncProtocol ? Symbol.asyncIterator : Symbol.iterator;
|
|
@@ -9715,33 +9475,276 @@ function syncIterator(iterator) {
|
|
|
9715
9475
|
};
|
|
9716
9476
|
}
|
|
9717
9477
|
|
|
9718
|
-
// packages/safe-js/src/interp/
|
|
9719
|
-
function
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9478
|
+
// packages/safe-js/src/interp/patterns.ts
|
|
9479
|
+
async function bindPattern(pattern, value, target, scope, context) {
|
|
9480
|
+
switch (pattern.type) {
|
|
9481
|
+
case "Identifier":
|
|
9482
|
+
bindIdentifier(pattern, value, target, scope);
|
|
9483
|
+
return { ok: true };
|
|
9484
|
+
case "MemberExpression":
|
|
9485
|
+
if ("kind" in target) {
|
|
9486
|
+
throw new TypeError("Destructuring declarations cannot bind to member expressions.");
|
|
9487
|
+
}
|
|
9488
|
+
return bindMemberExpression(pattern, value, scope, context);
|
|
9489
|
+
case "AssignmentPattern":
|
|
9490
|
+
return bindAssignmentPattern(pattern, value, target, scope, context);
|
|
9491
|
+
case "ArrayPattern":
|
|
9492
|
+
return bindArrayPattern(pattern, value, target, scope, context);
|
|
9493
|
+
case "ObjectPattern":
|
|
9494
|
+
return bindObjectPattern(pattern, value, target, scope, context);
|
|
9495
|
+
case "RestElement":
|
|
9496
|
+
return bindPattern(pattern.argument, value, target, scope, context);
|
|
9497
|
+
}
|
|
9498
|
+
}
|
|
9499
|
+
function bindIdentifier(pattern, value, target, scope) {
|
|
9500
|
+
if ("assign" in target || target.kind === "var" && target.initialize !== true) {
|
|
9501
|
+
if ("assign" in target) {
|
|
9502
|
+
const binding = scope.lookup(pattern.name);
|
|
9503
|
+
if (!binding.found) {
|
|
9504
|
+
throw new ReferenceError(`Cannot assign to undeclared binding '${pattern.name}'.`);
|
|
9505
|
+
}
|
|
9506
|
+
if (binding.kind === "const") {
|
|
9507
|
+
throw new TypeError(`Cannot assign to const '${pattern.name}'`);
|
|
9508
|
+
}
|
|
9509
|
+
}
|
|
9510
|
+
scope.assign(pattern.name, value);
|
|
9511
|
+
return;
|
|
9512
|
+
}
|
|
9513
|
+
scope.declare(pattern.name, target.kind, value);
|
|
9514
|
+
}
|
|
9515
|
+
async function bindAssignmentPattern(pattern, value, target, scope, context) {
|
|
9516
|
+
if (value !== void 0) {
|
|
9517
|
+
return bindPattern(pattern.left, value, target, scope, context);
|
|
9518
|
+
}
|
|
9519
|
+
const defaultValue = await context.evaluate(
|
|
9520
|
+
pattern.right,
|
|
9521
|
+
pattern.left.type === "Identifier" ? pattern.left.name : void 0
|
|
9522
|
+
);
|
|
9523
|
+
if (defaultValue.kind !== "normal") {
|
|
9524
|
+
return { ok: false, result: defaultValue };
|
|
9525
|
+
}
|
|
9526
|
+
return bindPattern(pattern.left, defaultValue.value, target, scope, context);
|
|
9527
|
+
}
|
|
9528
|
+
async function bindArrayPattern(pattern, value, target, scope, context) {
|
|
9529
|
+
const budget = context.budget ?? new Budget();
|
|
9530
|
+
const iterator = await acquireSandboxIterator(
|
|
9531
|
+
value,
|
|
9532
|
+
budget,
|
|
9533
|
+
context.callContext ?? {
|
|
9534
|
+
stack: [],
|
|
9535
|
+
thisValue: void 0,
|
|
9536
|
+
getProperty: context.getProperty
|
|
9537
|
+
}
|
|
9538
|
+
);
|
|
9539
|
+
if (iterator === void 0) throw new TypeError("Array destructuring requires an iterable.");
|
|
9540
|
+
let done = false;
|
|
9541
|
+
const next = async (readValue = true) => {
|
|
9542
|
+
if (done) return { value: void 0 };
|
|
9543
|
+
try {
|
|
9544
|
+
const result = await iterator.next();
|
|
9545
|
+
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
9546
|
+
throw new TypeError("Iterator result must be an object.");
|
|
9547
|
+
done = Boolean((await readIteratorResult(iterator, result, "done")).value);
|
|
9548
|
+
return done || !readValue ? { value: void 0 } : await readIteratorResult(iterator, result, "value");
|
|
9549
|
+
} catch (error) {
|
|
9550
|
+
done = true;
|
|
9551
|
+
throw error;
|
|
9552
|
+
}
|
|
9553
|
+
};
|
|
9554
|
+
let retained;
|
|
9555
|
+
const release = retainValues(budget, () => [value, iterator.retainedValue, retained]);
|
|
9556
|
+
try {
|
|
9557
|
+
for (let index = 0; index < pattern.elements.length; index += 1) {
|
|
9558
|
+
const element = pattern.elements[index];
|
|
9559
|
+
if (element === null) {
|
|
9560
|
+
await next(false);
|
|
9561
|
+
continue;
|
|
9562
|
+
}
|
|
9563
|
+
let elementValue;
|
|
9564
|
+
if (element.type === "RestElement") {
|
|
9565
|
+
const rest = [];
|
|
9566
|
+
retained = rest;
|
|
9567
|
+
for (let entry = await next(); !done; entry = await next()) {
|
|
9568
|
+
budget.allocateArrayLength(rest.length + 1);
|
|
9569
|
+
rest.push(entry.value);
|
|
9570
|
+
}
|
|
9571
|
+
elementValue = rest;
|
|
9572
|
+
} else {
|
|
9573
|
+
elementValue = (await next()).value;
|
|
9574
|
+
}
|
|
9575
|
+
retained = elementValue;
|
|
9576
|
+
const binding = await bindPattern(element, elementValue, target, scope, context);
|
|
9577
|
+
if (!binding.ok) {
|
|
9578
|
+
if (!done) {
|
|
9579
|
+
done = true;
|
|
9580
|
+
await closeIterator(iterator, binding.result.kind === "throw");
|
|
9581
|
+
}
|
|
9582
|
+
return binding;
|
|
9583
|
+
}
|
|
9584
|
+
}
|
|
9585
|
+
if (!done) {
|
|
9586
|
+
done = true;
|
|
9587
|
+
await closeIterator(iterator);
|
|
9588
|
+
}
|
|
9589
|
+
return { ok: true };
|
|
9590
|
+
} catch (error) {
|
|
9591
|
+
if (!done && !isFatalSandboxError(error)) await closeIterator(iterator, true);
|
|
9592
|
+
throw error;
|
|
9593
|
+
} finally {
|
|
9594
|
+
release();
|
|
9595
|
+
}
|
|
9596
|
+
}
|
|
9597
|
+
async function bindObjectPattern(pattern, value, target, scope, context) {
|
|
9598
|
+
if (typeof value !== "object" || value === null) {
|
|
9599
|
+
throw new TypeError("Object destructuring declarations require a non-null object value.");
|
|
9600
|
+
}
|
|
9601
|
+
const excludedKeys = /* @__PURE__ */ new Set();
|
|
9602
|
+
for (const property of pattern.properties) {
|
|
9603
|
+
if (property.type === "RestElement") {
|
|
9604
|
+
const binding2 = await bindPattern(
|
|
9605
|
+
property,
|
|
9606
|
+
await copyObjectRestValue(value, excludedKeys, context),
|
|
9607
|
+
target,
|
|
9608
|
+
scope,
|
|
9609
|
+
context
|
|
9610
|
+
);
|
|
9611
|
+
if (!binding2.ok) {
|
|
9612
|
+
return binding2;
|
|
9613
|
+
}
|
|
9614
|
+
continue;
|
|
9615
|
+
}
|
|
9616
|
+
const key = await evaluatePatternKey(property, context);
|
|
9617
|
+
if (!key.ok) {
|
|
9618
|
+
return key;
|
|
9619
|
+
}
|
|
9620
|
+
excludedKeys.add(typeof key.value === "symbol" ? key.value : String(key.value));
|
|
9621
|
+
const binding = await bindPattern(
|
|
9622
|
+
property.value,
|
|
9623
|
+
await context.getProperty(value, key.value),
|
|
9624
|
+
target,
|
|
9625
|
+
scope,
|
|
9626
|
+
context
|
|
9627
|
+
);
|
|
9628
|
+
if (!binding.ok) {
|
|
9629
|
+
return binding;
|
|
9630
|
+
}
|
|
9631
|
+
}
|
|
9632
|
+
return { ok: true };
|
|
9633
|
+
}
|
|
9634
|
+
async function bindMemberExpression(pattern, value, scope, context) {
|
|
9635
|
+
const object = await context.evaluate(pattern.object);
|
|
9636
|
+
if (object.kind !== "normal") {
|
|
9637
|
+
return { ok: false, result: object };
|
|
9638
|
+
}
|
|
9639
|
+
const property = pattern.computed ? await context.evaluate(pattern.property) : { kind: "normal", value: getStaticPropertyName(pattern.property) };
|
|
9640
|
+
if (property.kind !== "normal") {
|
|
9641
|
+
return { ok: false, result: property };
|
|
9642
|
+
}
|
|
9643
|
+
if (object.value === null || object.value === void 0) {
|
|
9644
|
+
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
9645
|
+
}
|
|
9646
|
+
if (!isIndexableValue(object.value)) {
|
|
9647
|
+
throw new TypeError("Assignment expressions require a sandbox object property.");
|
|
9648
|
+
}
|
|
9649
|
+
await context.setProperty(object.value, await context.toPropertyKey(property.value), value);
|
|
9650
|
+
return { ok: true };
|
|
9651
|
+
}
|
|
9652
|
+
async function evaluatePatternKey(property, context) {
|
|
9653
|
+
return property.computed ? evaluateProperty(property.key, context) : { ok: true, value: getStaticPropertyName(property.key) };
|
|
9654
|
+
}
|
|
9655
|
+
async function evaluateProperty(property, context) {
|
|
9656
|
+
const result = await context.evaluate(property);
|
|
9657
|
+
if (result.kind !== "normal") {
|
|
9658
|
+
return { ok: false, result };
|
|
9659
|
+
}
|
|
9660
|
+
return { ok: true, value: await context.toPropertyKey(result.value) };
|
|
9661
|
+
}
|
|
9662
|
+
function getStaticPropertyName(property) {
|
|
9663
|
+
if (property.type === "Identifier") {
|
|
9664
|
+
return property.name;
|
|
9665
|
+
}
|
|
9666
|
+
if (property.type === "StringLiteral" || property.type === "NumericLiteral") {
|
|
9667
|
+
return property.value;
|
|
9668
|
+
}
|
|
9669
|
+
throw new TypeError(`Unsupported static property node '${property.type}'.`);
|
|
9670
|
+
}
|
|
9671
|
+
async function copyObjectRestValue(value, excludedKeys, context) {
|
|
9672
|
+
const rest = /* @__PURE__ */ Object.create(null);
|
|
9673
|
+
const release = context.budget === void 0 ? () => void 0 : retainValues(context.budget, () => [value, rest]);
|
|
9674
|
+
try {
|
|
9675
|
+
for (const key of ownEnumerableSandboxKeys(value, true)) {
|
|
9676
|
+
if (excludedKeys.has(key) || !hasOwnSandboxProperty(value, key, true)) continue;
|
|
9677
|
+
defineProperty(rest, key, await context.getProperty(value, key));
|
|
9678
|
+
}
|
|
9679
|
+
return rest;
|
|
9680
|
+
} finally {
|
|
9681
|
+
release();
|
|
9682
|
+
}
|
|
9683
|
+
}
|
|
9684
|
+
function isIndexableValue(value) {
|
|
9685
|
+
return typeof value === "object" && value !== null;
|
|
9686
|
+
}
|
|
9687
|
+
function defineProperty(target, key, value) {
|
|
9688
|
+
Object.defineProperty(target, key, {
|
|
9689
|
+
configurable: true,
|
|
9690
|
+
enumerable: true,
|
|
9691
|
+
value,
|
|
9692
|
+
writable: true
|
|
9693
|
+
});
|
|
9694
|
+
}
|
|
9695
|
+
|
|
9696
|
+
// packages/safe-js/src/interp/var-hoist.ts
|
|
9697
|
+
function hoistVarDeclarations(node, scope) {
|
|
9698
|
+
for (const declaration of hoistedVarDeclarations([node])) {
|
|
9699
|
+
for (const declarator of declaration.declarations) {
|
|
9700
|
+
for (const identifier of boundIdentifiers(declarator.id)) {
|
|
9701
|
+
scope.declareVar(identifier.name);
|
|
9702
|
+
}
|
|
9703
|
+
}
|
|
9704
|
+
}
|
|
9705
|
+
}
|
|
9706
|
+
|
|
9707
|
+
// packages/safe-js/src/interp/data-checkpoint.ts
|
|
9708
|
+
function createDataCheckpoint(budget, context) {
|
|
9709
|
+
let estimatedDataSize = 0;
|
|
9710
|
+
return (value, growth = 0, force = false) => {
|
|
9711
|
+
const limit = budget.limits.dataSize;
|
|
9712
|
+
if (limit === void 0) return;
|
|
9713
|
+
estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
|
|
9714
|
+
if (!force && estimatedDataSize <= limit) return;
|
|
9715
|
+
if (context?.reconcileData !== void 0) context.reconcileData(value);
|
|
9716
|
+
else reconcileCompiledValues(budget, [value], context?.compilation);
|
|
9717
|
+
estimatedDataSize = budget.currentDataSize;
|
|
9718
|
+
};
|
|
9719
|
+
}
|
|
9720
|
+
|
|
9721
|
+
// packages/safe-js/src/interp/globals/numeric-parsers.ts
|
|
9722
|
+
function createNumericParsers(budget) {
|
|
9723
|
+
return {
|
|
9724
|
+
parseInt: createSandboxClosure({
|
|
9725
|
+
sandbox: true,
|
|
9726
|
+
name: "parseInt",
|
|
9727
|
+
call: ([value, radix], context) => {
|
|
9728
|
+
const parse2 = (text2) => {
|
|
9729
|
+
const release = retainValues(budget, () => [text2]);
|
|
9730
|
+
let convertedRadix;
|
|
9731
|
+
try {
|
|
9732
|
+
convertedRadix = sandboxNumber(radix, budget, context);
|
|
9733
|
+
} catch (error) {
|
|
9734
|
+
release();
|
|
9735
|
+
throw error;
|
|
9736
|
+
}
|
|
9737
|
+
if (typeof convertedRadix === "number") {
|
|
9738
|
+
try {
|
|
9739
|
+
return globalThis.parseInt(text2, convertedRadix);
|
|
9740
|
+
} finally {
|
|
9741
|
+
release();
|
|
9742
|
+
}
|
|
9743
|
+
}
|
|
9744
|
+
return convertedRadix.then((number) => globalThis.parseInt(text2, number)).finally(release);
|
|
9745
|
+
};
|
|
9746
|
+
const text = sandboxString(value, budget, context);
|
|
9747
|
+
return typeof text === "string" ? parse2(text) : text.then(parse2);
|
|
9745
9748
|
}
|
|
9746
9749
|
}),
|
|
9747
9750
|
parseFloat: createSandboxClosure({
|
|
@@ -15492,6 +15495,7 @@ function createPatternContext(context, scope = context.scope, evaluate = evaluat
|
|
|
15492
15495
|
const evaluationContext = { ...context, scope };
|
|
15493
15496
|
return {
|
|
15494
15497
|
budget: context.budget,
|
|
15498
|
+
callContext: createCoercionContext(evaluationContext),
|
|
15495
15499
|
evaluate: (node, inferredName) => evaluate(node, { ...evaluationContext, inferredName }),
|
|
15496
15500
|
toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(evaluationContext)),
|
|
15497
15501
|
getProperty: (value, key) => getPropertyValue(value, key, evaluationContext),
|
|
@@ -18641,7 +18645,18 @@ function createObjectGlobal(methods, budget) {
|
|
|
18641
18645
|
sandbox: true,
|
|
18642
18646
|
name: "toString",
|
|
18643
18647
|
length: 0,
|
|
18644
|
-
call: (_args, context) =>
|
|
18648
|
+
call: (_args, context) => {
|
|
18649
|
+
const receiver = context?.thisValue;
|
|
18650
|
+
if (receiver === void 0 || receiver === null)
|
|
18651
|
+
return budget.allocateString(`[object ${typeTag(receiver)}]`);
|
|
18652
|
+
const object = construct([receiver]);
|
|
18653
|
+
const descriptor = isGuestHostObject(object) ? void 0 : getSandboxPropertyDescriptor(object, Symbol.toStringTag, budget);
|
|
18654
|
+
const fallback = typeTag(object, descriptor !== void 0 || hasExplicitSandboxPrototype(object));
|
|
18655
|
+
const finish = (tag2) => budget.allocateString(`[object ${typeof tag2 === "string" ? tag2 : fallback}]`);
|
|
18656
|
+
if (descriptor === void 0) return finish(void 0);
|
|
18657
|
+
const tag = readPropertyDescriptor(descriptor, object, context, true);
|
|
18658
|
+
return tag instanceof Promise ? tag.then(finish) : finish(tag);
|
|
18659
|
+
}
|
|
18645
18660
|
}),
|
|
18646
18661
|
valueOf: createSandboxClosure({
|
|
18647
18662
|
sandbox: true,
|
|
@@ -18716,14 +18731,16 @@ function hasOwnSandboxProperty(value, key, enumerable) {
|
|
|
18716
18731
|
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
18717
18732
|
return descriptor !== void 0 && (!enumerable || descriptor.enumerable === true);
|
|
18718
18733
|
}
|
|
18719
|
-
function typeTag(value) {
|
|
18734
|
+
function typeTag(value, builtinOnly = false) {
|
|
18720
18735
|
if (isSandboxBox(value)) value = boxedValue(value);
|
|
18721
18736
|
if (value === void 0) return "Undefined";
|
|
18722
18737
|
if (value === null) return "Null";
|
|
18723
18738
|
if (typeof value === "string") return "String";
|
|
18724
18739
|
if (typeof value === "number") return "Number";
|
|
18725
18740
|
if (typeof value === "boolean") return "Boolean";
|
|
18741
|
+
if (isSandboxArguments(value)) return "Arguments";
|
|
18726
18742
|
if (isSandboxClosure(value)) {
|
|
18743
|
+
if (builtinOnly) return "Function";
|
|
18727
18744
|
while (value.boundTarget !== void 0) value = value.boundTarget;
|
|
18728
18745
|
return value.generator ? "GeneratorFunction" : value.async ? "AsyncFunction" : "Function";
|
|
18729
18746
|
}
|
|
@@ -18731,6 +18748,7 @@ function typeTag(value) {
|
|
|
18731
18748
|
if (isSandboxDate(value)) return "Date";
|
|
18732
18749
|
if (isSandboxErrorConstructorInstance(value, "Error")) return "Error";
|
|
18733
18750
|
if (isSandboxRegex(value)) return "RegExp";
|
|
18751
|
+
if (builtinOnly) return "Object";
|
|
18734
18752
|
if (isSandboxMap(value)) return "Map";
|
|
18735
18753
|
if (isSandboxSet(value)) return "Set";
|
|
18736
18754
|
if (isSandboxCollectionIterator(value)) return collectionIteratorState(value).collectionKind === "map" ? "Map Iterator" : "Set Iterator";
|
|
@@ -25161,584 +25179,239 @@ var AS010Scanner = class {
|
|
|
25161
25179
|
return true;
|
|
25162
25180
|
}
|
|
25163
25181
|
}
|
|
25164
|
-
return false;
|
|
25165
|
-
}
|
|
25166
|
-
resolveCandidate(name) {
|
|
25167
|
-
for (let index = this.scopes.length - 1; index >= 0; index -= 1) {
|
|
25168
|
-
const entry = this.scopes[index]?.get(name);
|
|
25169
|
-
if (entry === void 0) {
|
|
25170
|
-
continue;
|
|
25171
|
-
}
|
|
25172
|
-
return typeof entry === "object" && entry.kind === "candidate" ? entry : void 0;
|
|
25173
|
-
}
|
|
25174
|
-
return void 0;
|
|
25175
|
-
}
|
|
25176
|
-
collectModuleBindings(body) {
|
|
25177
|
-
const scope = /* @__PURE__ */ new Map();
|
|
25178
|
-
for (const statement of body) {
|
|
25179
|
-
if (statement.type === "ImportDeclaration") {
|
|
25180
|
-
this.mergeScope(scope, this.collectImportBindings(statement));
|
|
25181
|
-
continue;
|
|
25182
|
-
}
|
|
25183
|
-
if (statement.type === "VariableDeclaration") {
|
|
25184
|
-
this.mergeScope(scope, this.collectDeclarationBindings(statement));
|
|
25185
|
-
continue;
|
|
25186
|
-
}
|
|
25187
|
-
if (statement.type === "ExportNamedDeclaration") {
|
|
25188
|
-
this.mergeScope(scope, this.collectDeclarationBindings(statement.declaration));
|
|
25189
|
-
}
|
|
25190
|
-
}
|
|
25191
|
-
return scope;
|
|
25192
|
-
}
|
|
25193
|
-
collectCandidates(body, scope) {
|
|
25194
|
-
for (const statement of body) {
|
|
25195
|
-
if (statement.type !== "VariableDeclaration" || statement.kind !== "let") {
|
|
25196
|
-
continue;
|
|
25197
|
-
}
|
|
25198
|
-
for (const declarator of statement.declarations) {
|
|
25199
|
-
if (declarator.id.type !== "Identifier") {
|
|
25200
|
-
continue;
|
|
25201
|
-
}
|
|
25202
|
-
const hostCall = this.findHostCall(declarator.init);
|
|
25203
|
-
if (hostCall === void 0 || !this.isHostCall(hostCall)) {
|
|
25204
|
-
continue;
|
|
25205
|
-
}
|
|
25206
|
-
const candidate = {
|
|
25207
|
-
kind: "candidate",
|
|
25208
|
-
name: declarator.id.name,
|
|
25209
|
-
reads: 0,
|
|
25210
|
-
reassignments: 0,
|
|
25211
|
-
span: declarator.id.span
|
|
25212
|
-
};
|
|
25213
|
-
this.candidates.push(candidate);
|
|
25214
|
-
scope.set(candidate.name, candidate);
|
|
25215
|
-
}
|
|
25216
|
-
}
|
|
25217
|
-
}
|
|
25218
|
-
collectBlockBindings(body) {
|
|
25219
|
-
const scope = /* @__PURE__ */ new Map();
|
|
25220
|
-
for (const statement of body) {
|
|
25221
|
-
if (statement.type === "VariableDeclaration") {
|
|
25222
|
-
this.mergeScope(scope, this.collectDeclarationBindings(statement));
|
|
25223
|
-
}
|
|
25224
|
-
}
|
|
25225
|
-
return scope;
|
|
25226
|
-
}
|
|
25227
|
-
collectParameterBindings(node) {
|
|
25228
|
-
const scope = /* @__PURE__ */ new Map();
|
|
25229
|
-
for (const parameter of node.params) {
|
|
25230
|
-
this.collectBindingNamesFromElement(parameter, scope);
|
|
25231
|
-
}
|
|
25232
|
-
return scope;
|
|
25233
|
-
}
|
|
25234
|
-
collectDeclarationBindings(node) {
|
|
25235
|
-
const scope = /* @__PURE__ */ new Map();
|
|
25236
|
-
for (const declarator of node.declarations) {
|
|
25237
|
-
this.collectBindingNamesFromPattern(declarator.id, scope);
|
|
25238
|
-
}
|
|
25239
|
-
return scope;
|
|
25240
|
-
}
|
|
25241
|
-
collectCatchBindings(node) {
|
|
25242
|
-
const scope = /* @__PURE__ */ new Map();
|
|
25243
|
-
if (node.param !== void 0) {
|
|
25244
|
-
this.collectBindingNamesFromPattern(node.param, scope);
|
|
25245
|
-
}
|
|
25246
|
-
return scope;
|
|
25247
|
-
}
|
|
25248
|
-
collectImportBindings(node) {
|
|
25249
|
-
const scope = /* @__PURE__ */ new Map();
|
|
25250
|
-
for (const specifier of node.specifiers) {
|
|
25251
|
-
scope.set(specifier.local.name, this.getImportBindingKind(specifier));
|
|
25252
|
-
}
|
|
25253
|
-
return scope;
|
|
25254
|
-
}
|
|
25255
|
-
getImportBindingKind(specifier) {
|
|
25256
|
-
return specifier.type === "ImportNamespaceSpecifier" ? "namespace" : "import";
|
|
25257
|
-
}
|
|
25258
|
-
collectBindingNamesFromElement(node, scope) {
|
|
25259
|
-
switch (node.type) {
|
|
25260
|
-
case "AssignmentPattern":
|
|
25261
|
-
this.collectBindingNamesFromPattern(node.left, scope);
|
|
25262
|
-
return;
|
|
25263
|
-
case "RestElement":
|
|
25264
|
-
this.collectBindingNamesFromPattern(node.argument, scope);
|
|
25265
|
-
return;
|
|
25266
|
-
default:
|
|
25267
|
-
this.collectBindingNamesFromPattern(node, scope);
|
|
25268
|
-
return;
|
|
25269
|
-
}
|
|
25270
|
-
}
|
|
25271
|
-
collectBindingNamesFromPattern(node, scope) {
|
|
25272
|
-
switch (node.type) {
|
|
25273
|
-
case "Identifier":
|
|
25274
|
-
scope.set(node.name, "local");
|
|
25275
|
-
return;
|
|
25276
|
-
case "MemberExpression":
|
|
25277
|
-
return;
|
|
25278
|
-
case "ArrayPattern":
|
|
25279
|
-
for (const element of node.elements) {
|
|
25280
|
-
if (element !== null) {
|
|
25281
|
-
this.collectBindingNamesFromElement(element, scope);
|
|
25282
|
-
}
|
|
25283
|
-
}
|
|
25284
|
-
return;
|
|
25285
|
-
case "ObjectPattern":
|
|
25286
|
-
for (const property of node.properties) {
|
|
25287
|
-
if (property.type === "RestElement") {
|
|
25288
|
-
this.collectBindingNamesFromPattern(property.argument, scope);
|
|
25289
|
-
continue;
|
|
25290
|
-
}
|
|
25291
|
-
this.collectBindingNamesFromElement(property.value, scope);
|
|
25292
|
-
}
|
|
25293
|
-
return;
|
|
25294
|
-
}
|
|
25295
|
-
}
|
|
25296
|
-
collectPatternBindingNames(node) {
|
|
25297
|
-
const names = [];
|
|
25298
|
-
this.collectBindingNames(node, names);
|
|
25299
|
-
return names;
|
|
25300
|
-
}
|
|
25301
|
-
collectBindingNames(node, names) {
|
|
25302
|
-
switch (node.type) {
|
|
25303
|
-
case "AssignmentPattern":
|
|
25304
|
-
this.collectBindingNames(node.left, names);
|
|
25305
|
-
return;
|
|
25306
|
-
case "RestElement":
|
|
25307
|
-
this.collectBindingNames(node.argument, names);
|
|
25308
|
-
return;
|
|
25309
|
-
case "Identifier":
|
|
25310
|
-
names.push(node.name);
|
|
25311
|
-
return;
|
|
25312
|
-
case "MemberExpression":
|
|
25313
|
-
return;
|
|
25314
|
-
case "ArrayPattern":
|
|
25315
|
-
for (const element of node.elements) {
|
|
25316
|
-
if (element !== null) {
|
|
25317
|
-
this.collectBindingNames(element, names);
|
|
25318
|
-
}
|
|
25319
|
-
}
|
|
25320
|
-
return;
|
|
25321
|
-
case "ObjectPattern":
|
|
25322
|
-
for (const property of node.properties) {
|
|
25323
|
-
this.collectBindingNames(
|
|
25324
|
-
property.type === "RestElement" ? property.argument : property.value,
|
|
25325
|
-
names
|
|
25326
|
-
);
|
|
25327
|
-
}
|
|
25328
|
-
return;
|
|
25329
|
-
}
|
|
25330
|
-
}
|
|
25331
|
-
resolveCandidates(names) {
|
|
25332
|
-
return names.flatMap((name) => {
|
|
25333
|
-
const candidate = this.resolveCandidate(name);
|
|
25334
|
-
return candidate === void 0 ? [] : [candidate];
|
|
25335
|
-
});
|
|
25336
|
-
}
|
|
25337
|
-
withIgnoredReads(candidates, visit) {
|
|
25338
|
-
if (candidates.length === 0) {
|
|
25339
|
-
visit();
|
|
25340
|
-
return;
|
|
25341
|
-
}
|
|
25342
|
-
this.ignoredReads.push(new Set(candidates));
|
|
25343
|
-
try {
|
|
25344
|
-
visit();
|
|
25345
|
-
} finally {
|
|
25346
|
-
this.ignoredReads.pop();
|
|
25347
|
-
}
|
|
25348
|
-
}
|
|
25349
|
-
withScope(scope, visit) {
|
|
25350
|
-
this.scopes.push(scope);
|
|
25351
|
-
try {
|
|
25352
|
-
visit();
|
|
25353
|
-
} finally {
|
|
25354
|
-
this.scopes.pop();
|
|
25355
|
-
}
|
|
25356
|
-
}
|
|
25357
|
-
mergeScope(target, source) {
|
|
25358
|
-
for (const [name, binding] of source) {
|
|
25359
|
-
target.set(name, binding);
|
|
25360
|
-
}
|
|
25361
|
-
}
|
|
25362
|
-
findHostCall(node) {
|
|
25363
|
-
if (node === void 0) {
|
|
25364
|
-
return void 0;
|
|
25365
|
-
}
|
|
25366
|
-
if (node.type === "CallExpression") {
|
|
25367
|
-
return node;
|
|
25368
|
-
}
|
|
25369
|
-
if (node.type === "AwaitExpression" && node.argument.type === "CallExpression") {
|
|
25370
|
-
return node.argument;
|
|
25371
|
-
}
|
|
25372
|
-
return void 0;
|
|
25373
|
-
}
|
|
25374
|
-
isHostCall(node) {
|
|
25375
|
-
const root = this.findRootIdentifier(node.callee);
|
|
25376
|
-
if (root === void 0) {
|
|
25377
|
-
return false;
|
|
25378
|
-
}
|
|
25379
|
-
for (let index = this.scopes.length - 1; index >= 0; index -= 1) {
|
|
25380
|
-
const binding = this.scopes[index]?.get(root.name);
|
|
25381
|
-
if (binding === void 0) {
|
|
25382
|
-
continue;
|
|
25383
|
-
}
|
|
25384
|
-
return binding === "import" || binding === "namespace";
|
|
25385
|
-
}
|
|
25386
|
-
return false;
|
|
25387
|
-
}
|
|
25388
|
-
findRootIdentifier(node) {
|
|
25389
|
-
switch (node.type) {
|
|
25390
|
-
case "Identifier":
|
|
25391
|
-
return node;
|
|
25392
|
-
case "MemberExpression":
|
|
25393
|
-
return this.findRootIdentifier(node.object);
|
|
25394
|
-
default:
|
|
25395
|
-
return void 0;
|
|
25396
|
-
}
|
|
25397
|
-
}
|
|
25398
|
-
};
|
|
25399
|
-
|
|
25400
|
-
// packages/safe-js/src/lint/rules/AS011.ts
|
|
25401
|
-
var FORBIDDEN_PROPERTY_NAMES = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
25402
|
-
var MESSAGE2 = "Property access to '__proto__', 'prototype', and 'constructor' is not allowed.";
|
|
25403
|
-
function AS011(source, options = {}) {
|
|
25404
|
-
return new AS011Scanner(options.filename ?? "<input>").scan(source);
|
|
25405
|
-
}
|
|
25406
|
-
var AS011Scanner = class {
|
|
25407
|
-
constructor(filename) {
|
|
25408
|
-
this.filename = filename;
|
|
25409
|
-
}
|
|
25410
|
-
filename;
|
|
25411
|
-
diagnostics = [];
|
|
25412
|
-
scan(source) {
|
|
25413
|
-
this.visitModule(parseModule(source, this.filename));
|
|
25414
|
-
return this.diagnostics;
|
|
25415
|
-
}
|
|
25416
|
-
visitModule(node) {
|
|
25417
|
-
for (const statement of node.body) {
|
|
25418
|
-
this.visitStatement(statement);
|
|
25419
|
-
}
|
|
25420
|
-
}
|
|
25421
|
-
visitStatement(node) {
|
|
25422
|
-
if (node.type === "ClassDeclaration") {
|
|
25423
|
-
visitClassElements(node, (expression) => this.visitExpression(expression), (statement) => this.visitStatement(statement));
|
|
25424
|
-
return;
|
|
25425
|
-
}
|
|
25426
|
-
switch (node.type) {
|
|
25427
|
-
case "FunctionDeclaration":
|
|
25428
|
-
this.visitArrowFunction(node);
|
|
25429
|
-
return;
|
|
25430
|
-
case "BlockStatement":
|
|
25431
|
-
for (const statement of node.body) {
|
|
25432
|
-
this.visitStatement(statement);
|
|
25433
|
-
}
|
|
25434
|
-
return;
|
|
25435
|
-
case "ExpressionStatement":
|
|
25436
|
-
this.visitExpression(node.expression);
|
|
25437
|
-
return;
|
|
25438
|
-
case "IfStatement":
|
|
25439
|
-
this.visitIfStatement(node);
|
|
25440
|
-
return;
|
|
25441
|
-
case "ForStatement":
|
|
25442
|
-
this.visitForStatement(node);
|
|
25443
|
-
return;
|
|
25444
|
-
case "ForInStatement":
|
|
25445
|
-
case "ForOfStatement":
|
|
25446
|
-
this.visitForOfStatement(node);
|
|
25447
|
-
return;
|
|
25448
|
-
case "WhileStatement":
|
|
25449
|
-
case "DoWhileStatement":
|
|
25450
|
-
this.visitExpression(node.test);
|
|
25451
|
-
this.visitStatement(node.body);
|
|
25452
|
-
return;
|
|
25453
|
-
case "TryStatement":
|
|
25454
|
-
this.visitTryStatement(node);
|
|
25455
|
-
return;
|
|
25456
|
-
case "VariableDeclaration":
|
|
25457
|
-
this.visitVariableDeclaration(node);
|
|
25458
|
-
return;
|
|
25459
|
-
case "ReturnStatement":
|
|
25460
|
-
this.visitReturnStatement(node);
|
|
25461
|
-
return;
|
|
25462
|
-
case "ThrowStatement":
|
|
25463
|
-
this.visitThrowStatement(node);
|
|
25464
|
-
return;
|
|
25465
|
-
case "ExportNamedDeclaration":
|
|
25466
|
-
this.visitVariableDeclaration(node.declaration);
|
|
25467
|
-
return;
|
|
25468
|
-
case "ExportDefaultDeclaration":
|
|
25469
|
-
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
25470
|
-
else this.visitExpression(node.declaration);
|
|
25471
|
-
return;
|
|
25472
|
-
case "ImportDeclaration":
|
|
25473
|
-
case "BreakStatement":
|
|
25474
|
-
case "ContinueStatement":
|
|
25475
|
-
return;
|
|
25476
|
-
}
|
|
25477
|
-
}
|
|
25478
|
-
visitIfStatement(node) {
|
|
25479
|
-
this.visitExpression(node.test);
|
|
25480
|
-
this.visitStatement(node.consequent);
|
|
25481
|
-
if (node.alternate !== void 0) {
|
|
25482
|
-
this.visitStatement(node.alternate);
|
|
25483
|
-
}
|
|
25484
|
-
}
|
|
25485
|
-
visitForStatement(node) {
|
|
25486
|
-
if (node.init !== void 0) {
|
|
25487
|
-
if (node.init.type === "VariableDeclaration") {
|
|
25488
|
-
this.visitVariableDeclaration(node.init);
|
|
25489
|
-
} else {
|
|
25490
|
-
this.visitExpression(node.init);
|
|
25491
|
-
}
|
|
25492
|
-
}
|
|
25493
|
-
if (node.test !== void 0) {
|
|
25494
|
-
this.visitExpression(node.test);
|
|
25495
|
-
}
|
|
25496
|
-
if (node.update !== void 0) {
|
|
25497
|
-
this.visitExpression(node.update);
|
|
25498
|
-
}
|
|
25499
|
-
this.visitStatement(node.body);
|
|
25500
|
-
}
|
|
25501
|
-
visitForOfStatement(node) {
|
|
25502
|
-
if (node.left.type === "VariableDeclaration") {
|
|
25503
|
-
this.visitVariableDeclaration(node.left);
|
|
25504
|
-
} else {
|
|
25505
|
-
this.visitAssignmentTarget(node.left);
|
|
25506
|
-
}
|
|
25507
|
-
this.visitExpression(node.right);
|
|
25508
|
-
this.visitStatement(node.body);
|
|
25509
|
-
}
|
|
25510
|
-
visitTryStatement(node) {
|
|
25511
|
-
this.visitStatement(node.block);
|
|
25512
|
-
if (node.handler !== void 0) {
|
|
25513
|
-
this.visitCatchClause(node.handler);
|
|
25514
|
-
}
|
|
25515
|
-
if (node.finalizer !== void 0) {
|
|
25516
|
-
this.visitStatement(node.finalizer);
|
|
25517
|
-
}
|
|
25518
|
-
}
|
|
25519
|
-
visitCatchClause(node) {
|
|
25520
|
-
if (node.param !== void 0) {
|
|
25521
|
-
this.visitAssignmentTarget(node.param);
|
|
25522
|
-
}
|
|
25523
|
-
this.visitStatement(node.body);
|
|
25524
|
-
}
|
|
25525
|
-
visitVariableDeclaration(node) {
|
|
25526
|
-
for (const declarator of node.declarations) {
|
|
25527
|
-
this.visitVariableDeclarator(declarator);
|
|
25528
|
-
}
|
|
25529
|
-
}
|
|
25530
|
-
visitVariableDeclarator(node) {
|
|
25531
|
-
this.visitBindingTarget(node.id);
|
|
25532
|
-
if (node.init !== void 0) {
|
|
25533
|
-
this.visitExpression(node.init);
|
|
25534
|
-
}
|
|
25535
|
-
}
|
|
25536
|
-
visitReturnStatement(node) {
|
|
25537
|
-
if (node.argument !== void 0) {
|
|
25538
|
-
this.visitExpression(node.argument);
|
|
25539
|
-
}
|
|
25540
|
-
}
|
|
25541
|
-
visitThrowStatement(node) {
|
|
25542
|
-
this.visitExpression(node.argument);
|
|
25543
|
-
}
|
|
25544
|
-
visitExpression(node) {
|
|
25545
|
-
if (node.type === "ClassExpression") {
|
|
25546
|
-
visitClassElements(node, (expression) => this.visitExpression(expression), (statement) => this.visitStatement(statement));
|
|
25547
|
-
return;
|
|
25548
|
-
}
|
|
25549
|
-
switch (node.type) {
|
|
25550
|
-
case "YieldExpression":
|
|
25551
|
-
if (node.argument !== void 0) {
|
|
25552
|
-
this.visitExpression(node.argument);
|
|
25553
|
-
}
|
|
25554
|
-
return;
|
|
25555
|
-
case "FunctionExpression":
|
|
25556
|
-
case "ArrowFunctionExpression":
|
|
25557
|
-
this.visitArrowFunction(node);
|
|
25558
|
-
return;
|
|
25559
|
-
case "AwaitExpression":
|
|
25560
|
-
this.visitExpression(node.argument);
|
|
25561
|
-
return;
|
|
25562
|
-
case "ArrayExpression":
|
|
25563
|
-
this.visitArrayExpression(node);
|
|
25564
|
-
return;
|
|
25565
|
-
case "ObjectExpression":
|
|
25566
|
-
this.visitObjectExpression(node);
|
|
25567
|
-
return;
|
|
25568
|
-
case "UnaryExpression":
|
|
25569
|
-
this.visitUnaryExpression(node);
|
|
25570
|
-
return;
|
|
25571
|
-
case "BinaryExpression":
|
|
25572
|
-
case "LogicalExpression":
|
|
25573
|
-
this.visitBinaryLikeExpression(node);
|
|
25574
|
-
return;
|
|
25575
|
-
case "ConditionalExpression":
|
|
25576
|
-
this.visitConditionalExpression(node);
|
|
25577
|
-
return;
|
|
25578
|
-
case "MemberExpression":
|
|
25579
|
-
this.visitMemberExpression(node);
|
|
25580
|
-
return;
|
|
25581
|
-
case "AssignmentExpression":
|
|
25582
|
-
this.visitAssignmentExpression(node);
|
|
25583
|
-
return;
|
|
25584
|
-
case "CallExpression":
|
|
25585
|
-
this.visitCallExpression(node);
|
|
25586
|
-
return;
|
|
25587
|
-
case "TemplateLiteral":
|
|
25588
|
-
this.visitTemplateLiteral(node);
|
|
25589
|
-
return;
|
|
25590
|
-
case "Identifier":
|
|
25591
|
-
case "BooleanLiteral":
|
|
25592
|
-
case "NullLiteral":
|
|
25593
|
-
case "NumericLiteral":
|
|
25594
|
-
case "StringLiteral":
|
|
25595
|
-
case "UndefinedLiteral":
|
|
25596
|
-
return;
|
|
25597
|
-
}
|
|
25598
|
-
}
|
|
25599
|
-
visitArrowFunction(node) {
|
|
25600
|
-
for (const parameter of node.params) {
|
|
25601
|
-
this.visitBindingTarget(parameter);
|
|
25602
|
-
}
|
|
25603
|
-
if (node.body.type === "BlockStatement") {
|
|
25604
|
-
for (const statement of node.body.body) {
|
|
25605
|
-
this.visitStatement(statement);
|
|
25182
|
+
return false;
|
|
25183
|
+
}
|
|
25184
|
+
resolveCandidate(name) {
|
|
25185
|
+
for (let index = this.scopes.length - 1; index >= 0; index -= 1) {
|
|
25186
|
+
const entry = this.scopes[index]?.get(name);
|
|
25187
|
+
if (entry === void 0) {
|
|
25188
|
+
continue;
|
|
25606
25189
|
}
|
|
25607
|
-
return;
|
|
25190
|
+
return typeof entry === "object" && entry.kind === "candidate" ? entry : void 0;
|
|
25608
25191
|
}
|
|
25609
|
-
|
|
25192
|
+
return void 0;
|
|
25610
25193
|
}
|
|
25611
|
-
|
|
25612
|
-
|
|
25613
|
-
|
|
25194
|
+
collectModuleBindings(body) {
|
|
25195
|
+
const scope = /* @__PURE__ */ new Map();
|
|
25196
|
+
for (const statement of body) {
|
|
25197
|
+
if (statement.type === "ImportDeclaration") {
|
|
25198
|
+
this.mergeScope(scope, this.collectImportBindings(statement));
|
|
25614
25199
|
continue;
|
|
25615
25200
|
}
|
|
25616
|
-
if (
|
|
25617
|
-
this.
|
|
25201
|
+
if (statement.type === "VariableDeclaration") {
|
|
25202
|
+
this.mergeScope(scope, this.collectDeclarationBindings(statement));
|
|
25618
25203
|
continue;
|
|
25619
25204
|
}
|
|
25620
|
-
|
|
25205
|
+
if (statement.type === "ExportNamedDeclaration") {
|
|
25206
|
+
this.mergeScope(scope, this.collectDeclarationBindings(statement.declaration));
|
|
25207
|
+
}
|
|
25621
25208
|
}
|
|
25209
|
+
return scope;
|
|
25622
25210
|
}
|
|
25623
|
-
|
|
25624
|
-
for (const
|
|
25625
|
-
if (
|
|
25626
|
-
this.visitExpression(property.argument);
|
|
25211
|
+
collectCandidates(body, scope) {
|
|
25212
|
+
for (const statement of body) {
|
|
25213
|
+
if (statement.type !== "VariableDeclaration" || statement.kind !== "let") {
|
|
25627
25214
|
continue;
|
|
25628
25215
|
}
|
|
25629
|
-
|
|
25216
|
+
for (const declarator of statement.declarations) {
|
|
25217
|
+
if (declarator.id.type !== "Identifier") {
|
|
25218
|
+
continue;
|
|
25219
|
+
}
|
|
25220
|
+
const hostCall = this.findHostCall(declarator.init);
|
|
25221
|
+
if (hostCall === void 0 || !this.isHostCall(hostCall)) {
|
|
25222
|
+
continue;
|
|
25223
|
+
}
|
|
25224
|
+
const candidate = {
|
|
25225
|
+
kind: "candidate",
|
|
25226
|
+
name: declarator.id.name,
|
|
25227
|
+
reads: 0,
|
|
25228
|
+
reassignments: 0,
|
|
25229
|
+
span: declarator.id.span
|
|
25230
|
+
};
|
|
25231
|
+
this.candidates.push(candidate);
|
|
25232
|
+
scope.set(candidate.name, candidate);
|
|
25233
|
+
}
|
|
25630
25234
|
}
|
|
25631
25235
|
}
|
|
25632
|
-
|
|
25633
|
-
|
|
25634
|
-
|
|
25236
|
+
collectBlockBindings(body) {
|
|
25237
|
+
const scope = /* @__PURE__ */ new Map();
|
|
25238
|
+
for (const statement of body) {
|
|
25239
|
+
if (statement.type === "VariableDeclaration") {
|
|
25240
|
+
this.mergeScope(scope, this.collectDeclarationBindings(statement));
|
|
25241
|
+
}
|
|
25635
25242
|
}
|
|
25636
|
-
|
|
25637
|
-
}
|
|
25638
|
-
visitUnaryExpression(node) {
|
|
25639
|
-
this.visitExpression(node.argument);
|
|
25640
|
-
}
|
|
25641
|
-
visitBinaryLikeExpression(node) {
|
|
25642
|
-
this.visitExpression(node.left);
|
|
25643
|
-
this.visitExpression(node.right);
|
|
25243
|
+
return scope;
|
|
25644
25244
|
}
|
|
25645
|
-
|
|
25646
|
-
|
|
25647
|
-
|
|
25648
|
-
|
|
25245
|
+
collectParameterBindings(node) {
|
|
25246
|
+
const scope = /* @__PURE__ */ new Map();
|
|
25247
|
+
for (const parameter of node.params) {
|
|
25248
|
+
this.collectBindingNamesFromElement(parameter, scope);
|
|
25249
|
+
}
|
|
25250
|
+
return scope;
|
|
25649
25251
|
}
|
|
25650
|
-
|
|
25651
|
-
|
|
25652
|
-
|
|
25653
|
-
this.
|
|
25252
|
+
collectDeclarationBindings(node) {
|
|
25253
|
+
const scope = /* @__PURE__ */ new Map();
|
|
25254
|
+
for (const declarator of node.declarations) {
|
|
25255
|
+
this.collectBindingNamesFromPattern(declarator.id, scope);
|
|
25654
25256
|
}
|
|
25655
|
-
|
|
25257
|
+
return scope;
|
|
25656
25258
|
}
|
|
25657
|
-
|
|
25658
|
-
|
|
25659
|
-
|
|
25259
|
+
collectCatchBindings(node) {
|
|
25260
|
+
const scope = /* @__PURE__ */ new Map();
|
|
25261
|
+
if (node.param !== void 0) {
|
|
25262
|
+
this.collectBindingNamesFromPattern(node.param, scope);
|
|
25263
|
+
}
|
|
25264
|
+
return scope;
|
|
25660
25265
|
}
|
|
25661
|
-
|
|
25662
|
-
|
|
25663
|
-
for (const
|
|
25664
|
-
|
|
25665
|
-
this.visitExpression(argument.argument);
|
|
25666
|
-
continue;
|
|
25667
|
-
}
|
|
25668
|
-
this.visitExpression(argument);
|
|
25266
|
+
collectImportBindings(node) {
|
|
25267
|
+
const scope = /* @__PURE__ */ new Map();
|
|
25268
|
+
for (const specifier of node.specifiers) {
|
|
25269
|
+
scope.set(specifier.local.name, this.getImportBindingKind(specifier));
|
|
25669
25270
|
}
|
|
25271
|
+
return scope;
|
|
25670
25272
|
}
|
|
25671
|
-
|
|
25672
|
-
|
|
25673
|
-
|
|
25273
|
+
getImportBindingKind(specifier) {
|
|
25274
|
+
return specifier.type === "ImportNamespaceSpecifier" ? "namespace" : "import";
|
|
25275
|
+
}
|
|
25276
|
+
collectBindingNamesFromElement(node, scope) {
|
|
25277
|
+
switch (node.type) {
|
|
25278
|
+
case "AssignmentPattern":
|
|
25279
|
+
this.collectBindingNamesFromPattern(node.left, scope);
|
|
25280
|
+
return;
|
|
25281
|
+
case "RestElement":
|
|
25282
|
+
this.collectBindingNamesFromPattern(node.argument, scope);
|
|
25283
|
+
return;
|
|
25284
|
+
default:
|
|
25285
|
+
this.collectBindingNamesFromPattern(node, scope);
|
|
25286
|
+
return;
|
|
25674
25287
|
}
|
|
25675
25288
|
}
|
|
25676
|
-
|
|
25289
|
+
collectBindingNamesFromPattern(node, scope) {
|
|
25677
25290
|
switch (node.type) {
|
|
25678
25291
|
case "Identifier":
|
|
25679
|
-
|
|
25292
|
+
scope.set(node.name, "local");
|
|
25680
25293
|
return;
|
|
25681
25294
|
case "MemberExpression":
|
|
25682
|
-
this.visitMemberExpression(node);
|
|
25683
|
-
return;
|
|
25684
|
-
case "AssignmentPattern":
|
|
25685
|
-
this.visitAssignmentTarget(node.left);
|
|
25686
|
-
this.visitExpression(node.right);
|
|
25687
|
-
return;
|
|
25688
|
-
case "RestElement":
|
|
25689
|
-
this.visitAssignmentTarget(node.argument);
|
|
25690
25295
|
return;
|
|
25691
25296
|
case "ArrayPattern":
|
|
25692
25297
|
for (const element of node.elements) {
|
|
25693
25298
|
if (element !== null) {
|
|
25694
|
-
this.
|
|
25299
|
+
this.collectBindingNamesFromElement(element, scope);
|
|
25695
25300
|
}
|
|
25696
25301
|
}
|
|
25697
25302
|
return;
|
|
25698
25303
|
case "ObjectPattern":
|
|
25699
25304
|
for (const property of node.properties) {
|
|
25700
25305
|
if (property.type === "RestElement") {
|
|
25701
|
-
this.
|
|
25306
|
+
this.collectBindingNamesFromPattern(property.argument, scope);
|
|
25702
25307
|
continue;
|
|
25703
25308
|
}
|
|
25704
|
-
|
|
25705
|
-
this.visitExpression(property.key);
|
|
25706
|
-
}
|
|
25707
|
-
this.visitAssignmentTarget(property.value);
|
|
25309
|
+
this.collectBindingNamesFromElement(property.value, scope);
|
|
25708
25310
|
}
|
|
25709
25311
|
return;
|
|
25710
25312
|
}
|
|
25711
25313
|
}
|
|
25712
|
-
|
|
25314
|
+
collectPatternBindingNames(node) {
|
|
25315
|
+
const names = [];
|
|
25316
|
+
this.collectBindingNames(node, names);
|
|
25317
|
+
return names;
|
|
25318
|
+
}
|
|
25319
|
+
collectBindingNames(node, names) {
|
|
25713
25320
|
switch (node.type) {
|
|
25714
25321
|
case "AssignmentPattern":
|
|
25715
|
-
this.
|
|
25716
|
-
this.visitExpression(node.right);
|
|
25322
|
+
this.collectBindingNames(node.left, names);
|
|
25717
25323
|
return;
|
|
25718
25324
|
case "RestElement":
|
|
25719
|
-
this.
|
|
25325
|
+
this.collectBindingNames(node.argument, names);
|
|
25720
25326
|
return;
|
|
25721
|
-
|
|
25722
|
-
|
|
25327
|
+
case "Identifier":
|
|
25328
|
+
names.push(node.name);
|
|
25329
|
+
return;
|
|
25330
|
+
case "MemberExpression":
|
|
25331
|
+
return;
|
|
25332
|
+
case "ArrayPattern":
|
|
25333
|
+
for (const element of node.elements) {
|
|
25334
|
+
if (element !== null) {
|
|
25335
|
+
this.collectBindingNames(element, names);
|
|
25336
|
+
}
|
|
25337
|
+
}
|
|
25338
|
+
return;
|
|
25339
|
+
case "ObjectPattern":
|
|
25340
|
+
for (const property of node.properties) {
|
|
25341
|
+
this.collectBindingNames(
|
|
25342
|
+
property.type === "RestElement" ? property.argument : property.value,
|
|
25343
|
+
names
|
|
25344
|
+
);
|
|
25345
|
+
}
|
|
25723
25346
|
return;
|
|
25724
25347
|
}
|
|
25725
25348
|
}
|
|
25726
|
-
|
|
25727
|
-
|
|
25728
|
-
|
|
25349
|
+
resolveCandidates(names) {
|
|
25350
|
+
return names.flatMap((name) => {
|
|
25351
|
+
const candidate = this.resolveCandidate(name);
|
|
25352
|
+
return candidate === void 0 ? [] : [candidate];
|
|
25353
|
+
});
|
|
25354
|
+
}
|
|
25355
|
+
withIgnoredReads(candidates, visit) {
|
|
25356
|
+
if (candidates.length === 0) {
|
|
25357
|
+
visit();
|
|
25358
|
+
return;
|
|
25359
|
+
}
|
|
25360
|
+
this.ignoredReads.push(new Set(candidates));
|
|
25361
|
+
try {
|
|
25362
|
+
visit();
|
|
25363
|
+
} finally {
|
|
25364
|
+
this.ignoredReads.pop();
|
|
25365
|
+
}
|
|
25366
|
+
}
|
|
25367
|
+
withScope(scope, visit) {
|
|
25368
|
+
this.scopes.push(scope);
|
|
25369
|
+
try {
|
|
25370
|
+
visit();
|
|
25371
|
+
} finally {
|
|
25372
|
+
this.scopes.pop();
|
|
25729
25373
|
}
|
|
25730
|
-
return node.property.type === "StringLiteral" && FORBIDDEN_PROPERTY_NAMES.has(node.property.value);
|
|
25731
25374
|
}
|
|
25732
|
-
|
|
25733
|
-
|
|
25734
|
-
|
|
25735
|
-
|
|
25736
|
-
|
|
25737
|
-
|
|
25738
|
-
|
|
25739
|
-
|
|
25740
|
-
|
|
25741
|
-
|
|
25375
|
+
mergeScope(target, source) {
|
|
25376
|
+
for (const [name, binding] of source) {
|
|
25377
|
+
target.set(name, binding);
|
|
25378
|
+
}
|
|
25379
|
+
}
|
|
25380
|
+
findHostCall(node) {
|
|
25381
|
+
if (node === void 0) {
|
|
25382
|
+
return void 0;
|
|
25383
|
+
}
|
|
25384
|
+
if (node.type === "CallExpression") {
|
|
25385
|
+
return node;
|
|
25386
|
+
}
|
|
25387
|
+
if (node.type === "AwaitExpression" && node.argument.type === "CallExpression") {
|
|
25388
|
+
return node.argument;
|
|
25389
|
+
}
|
|
25390
|
+
return void 0;
|
|
25391
|
+
}
|
|
25392
|
+
isHostCall(node) {
|
|
25393
|
+
const root = this.findRootIdentifier(node.callee);
|
|
25394
|
+
if (root === void 0) {
|
|
25395
|
+
return false;
|
|
25396
|
+
}
|
|
25397
|
+
for (let index = this.scopes.length - 1; index >= 0; index -= 1) {
|
|
25398
|
+
const binding = this.scopes[index]?.get(root.name);
|
|
25399
|
+
if (binding === void 0) {
|
|
25400
|
+
continue;
|
|
25401
|
+
}
|
|
25402
|
+
return binding === "import" || binding === "namespace";
|
|
25403
|
+
}
|
|
25404
|
+
return false;
|
|
25405
|
+
}
|
|
25406
|
+
findRootIdentifier(node) {
|
|
25407
|
+
switch (node.type) {
|
|
25408
|
+
case "Identifier":
|
|
25409
|
+
return node;
|
|
25410
|
+
case "MemberExpression":
|
|
25411
|
+
return this.findRootIdentifier(node.object);
|
|
25412
|
+
default:
|
|
25413
|
+
return void 0;
|
|
25414
|
+
}
|
|
25742
25415
|
}
|
|
25743
25416
|
};
|
|
25744
25417
|
|
|
@@ -26714,7 +26387,7 @@ function patternTargetContainsAwait(node) {
|
|
|
26714
26387
|
}
|
|
26715
26388
|
|
|
26716
26389
|
// packages/safe-js/src/lint/rules/AS-destructure-null-default.ts
|
|
26717
|
-
var
|
|
26390
|
+
var MESSAGE2 = "Destructuring default values only apply to undefined, not null.";
|
|
26718
26391
|
var HINT = "Handle null explicitly before destructuring or use ?? after binding.";
|
|
26719
26392
|
function AS_DESTRUCTURE_NULL_DEFAULT(source, options = {}) {
|
|
26720
26393
|
return new ASDestructureNullDefaultScanner(options.filename ?? "<input>").scan(source);
|
|
@@ -27118,7 +26791,7 @@ var ASDestructureNullDefaultScanner = class {
|
|
|
27118
26791
|
this.diagnostics.push({
|
|
27119
26792
|
code: "AS-DESTRUCTURE-NULL-DEFAULT",
|
|
27120
26793
|
severity: "warning",
|
|
27121
|
-
message:
|
|
26794
|
+
message: MESSAGE2,
|
|
27122
26795
|
filename: this.filename,
|
|
27123
26796
|
line: span.start.line,
|
|
27124
26797
|
column: span.start.column,
|
|
@@ -31734,7 +31407,7 @@ var ASShadowGlobalScanner = class {
|
|
|
31734
31407
|
};
|
|
31735
31408
|
|
|
31736
31409
|
// packages/safe-js/src/lint/rules/AS-unbounded-loop.ts
|
|
31737
|
-
var
|
|
31410
|
+
var MESSAGE3 = "Unbounded loop or generator source has no static exit with break, return, or throw.";
|
|
31738
31411
|
function AS_UNBOUNDED_LOOP(source, options = {}) {
|
|
31739
31412
|
return new ASUnboundedLoopScanner(options.filename ?? "<input>").scan(source);
|
|
31740
31413
|
}
|
|
@@ -32044,7 +31717,7 @@ var ASUnboundedLoopScanner = class {
|
|
|
32044
31717
|
this.diagnostics.push({
|
|
32045
31718
|
code: "AS-UNBOUNDED-LOOP",
|
|
32046
31719
|
severity: "warning",
|
|
32047
|
-
message:
|
|
31720
|
+
message: MESSAGE3,
|
|
32048
31721
|
filename: this.filename,
|
|
32049
31722
|
line: node.span.start.line,
|
|
32050
31723
|
column: node.span.start.column,
|
|
@@ -33050,7 +32723,6 @@ var RULES = [
|
|
|
33050
32723
|
AS_MISSING_ASYNC,
|
|
33051
32724
|
AS009,
|
|
33052
32725
|
AS010,
|
|
33053
|
-
AS011,
|
|
33054
32726
|
AS013,
|
|
33055
32727
|
AS015,
|
|
33056
32728
|
AS_IMPORT_CYCLE,
|
|
@@ -36214,4 +35886,4 @@ export {
|
|
|
36214
35886
|
FileSnapshotBackend,
|
|
36215
35887
|
run
|
|
36216
35888
|
};
|
|
36217
|
-
//# sourceMappingURL=chunk-
|
|
35889
|
+
//# sourceMappingURL=chunk-AW3IBVVD.js.map
|