poe-code 4.0.58 → 4.0.59
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/cli/program.js +2 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +486 -439
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/graph-depth.js +4 -0
- package/packages/safejs/dist/interp/arguments.d.ts +10 -0
- package/packages/safejs/dist/interp/arguments.js +44 -0
- package/packages/safejs/dist/interp/async.js +3 -1
- package/packages/safejs/dist/interp/values.d.ts +1 -1
- package/packages/safejs/dist/interp/values.js +27 -2
- package/packages/safejs/dist/lint/index.js +0 -2
- package/packages/safejs/dist/lint/rules/AS-async-not-needed.d.ts +1 -1
- package/packages/safejs/dist/lint/rules/AS-async-not-needed.js +15 -3
- package/packages/safejs/dist/lint/rules/AS-await-non-promise.js +10 -0
- package/packages/safejs/dist/lint/rules/AS-destructure-null-default.js +9 -0
- package/packages/safejs/dist/lint/rules/AS-export-import-meta.js +17 -0
- package/packages/safejs/dist/lint/rules/AS-floating-promise.js +23 -2
- package/packages/safejs/dist/lint/rules/AS-frontmatter-field-unused.js +9 -0
- package/packages/safejs/dist/lint/rules/AS-jsdoc-type.js +10 -0
- package/packages/safejs/dist/lint/rules/AS-large-literal.js +9 -0
- package/packages/safejs/dist/lint/rules/AS-missing-async.d.ts +1 -1
- package/packages/safejs/dist/lint/rules/AS-missing-async.js +9 -1
- package/packages/safejs/dist/lint/rules/AS-mutating-frozen.js +9 -0
- package/packages/safejs/dist/lint/rules/AS-needless-template.js +9 -0
- package/packages/safejs/dist/lint/rules/AS-shadow-global.js +12 -0
- package/packages/safejs/dist/lint/rules/AS-unbounded-loop.js +9 -0
- package/packages/safejs/dist/lint/rules/AS-unreachable.js +9 -1
- package/packages/safejs/dist/lint/rules/AS-unused-import.js +22 -0
- package/packages/safejs/dist/lint/rules/AS001.js +0 -6
- package/packages/safejs/dist/lint/rules/AS003.js +22 -0
- package/packages/safejs/dist/lint/rules/AS006-007.js +19 -0
- package/packages/safejs/dist/lint/rules/AS008.js +9 -0
- package/packages/safejs/dist/lint/rules/AS009.js +9 -0
- package/packages/safejs/dist/lint/rules/AS010.js +9 -0
- package/packages/safejs/dist/lint/rules/AS011.js +9 -0
- package/packages/safejs/dist/lint/rules/AS015.js +9 -0
- package/packages/safejs/dist/parse/parser.d.ts +1 -0
- package/packages/safejs/dist/snapshot/arguments.d.ts +17 -0
- package/packages/safejs/dist/snapshot/arguments.js +34 -0
- package/packages/safejs/dist/snapshot/dump-format.js +15 -3
- package/packages/safejs/dist/snapshot/restore.js +27 -1
- package/packages/safejs/dist/snapshot/serialize.d.ts +2 -1
- package/packages/safejs/dist/snapshot/serialize.js +20 -10
- package/packages/safejs/dist/snapshot/validation.js +50 -1
- package/packages/safejs/dist/lint/rules/AS012.d.ts +0 -13
- package/packages/safejs/dist/lint/rules/AS012.js +0 -384
package/dist/index.js
CHANGED
|
@@ -124066,11 +124066,6 @@ var init_AS001 = __esm({
|
|
|
124066
124066
|
pendingClassBody = true;
|
|
124067
124067
|
}
|
|
124068
124068
|
}
|
|
124069
|
-
if (token.value === "function" && nextSignificantChar === "*") {
|
|
124070
|
-
const generatorStart = this.positionWithinSource(this.skipTriviaFrom(this.index));
|
|
124071
|
-
const generatorEnd = this.positionWithinSource(this.skipTriviaFrom(this.index) + 1);
|
|
124072
|
-
this.report("generator", generatorStart, generatorEnd);
|
|
124073
|
-
}
|
|
124074
124069
|
}
|
|
124075
124070
|
const isStatementBrace = token.type === "punctuator" && token.value === "{" && canStartStatement;
|
|
124076
124071
|
if (token.type === "punctuator" && token.value === "{") {
|
|
@@ -124116,7 +124111,6 @@ var init_AS001 = __esm({
|
|
|
124116
124111
|
switch (token.value) {
|
|
124117
124112
|
case "class":
|
|
124118
124113
|
case "eval":
|
|
124119
|
-
case "function":
|
|
124120
124114
|
case "Function":
|
|
124121
124115
|
case "switch":
|
|
124122
124116
|
case "this":
|
|
@@ -124532,6 +124526,9 @@ var init_AS003 = __esm({
|
|
|
124532
124526
|
}
|
|
124533
124527
|
visitStatement(node) {
|
|
124534
124528
|
switch (node.type) {
|
|
124529
|
+
case "FunctionDeclaration":
|
|
124530
|
+
this.visitArrowFunction(node);
|
|
124531
|
+
return;
|
|
124535
124532
|
case "BlockStatement":
|
|
124536
124533
|
this.visitBlock(node);
|
|
124537
124534
|
return;
|
|
@@ -124663,9 +124660,15 @@ var init_AS003 = __esm({
|
|
|
124663
124660
|
}
|
|
124664
124661
|
visitExpression(node) {
|
|
124665
124662
|
switch (node.type) {
|
|
124663
|
+
case "YieldExpression":
|
|
124664
|
+
if (node.argument !== void 0) {
|
|
124665
|
+
this.visitExpression(node.argument);
|
|
124666
|
+
}
|
|
124667
|
+
return;
|
|
124666
124668
|
case "Identifier":
|
|
124667
124669
|
this.visitIdentifier(node);
|
|
124668
124670
|
return;
|
|
124671
|
+
case "FunctionExpression":
|
|
124669
124672
|
case "ArrowFunctionExpression":
|
|
124670
124673
|
this.visitArrowFunction(node);
|
|
124671
124674
|
return;
|
|
@@ -124935,6 +124938,10 @@ var init_AS003 = __esm({
|
|
|
124935
124938
|
bindings.push(...this.collectImportBindings(statement));
|
|
124936
124939
|
continue;
|
|
124937
124940
|
}
|
|
124941
|
+
if (statement.type === "FunctionDeclaration") {
|
|
124942
|
+
bindings.push({ kind: "let", name: statement.id.name });
|
|
124943
|
+
continue;
|
|
124944
|
+
}
|
|
124938
124945
|
if (statement.type === "VariableDeclaration") {
|
|
124939
124946
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
124940
124947
|
continue;
|
|
@@ -124948,6 +124955,9 @@ var init_AS003 = __esm({
|
|
|
124948
124955
|
collectBlockBindings(body) {
|
|
124949
124956
|
const bindings = [];
|
|
124950
124957
|
for (const statement of body) {
|
|
124958
|
+
if (statement.type === "FunctionDeclaration") {
|
|
124959
|
+
bindings.push({ kind: "let", name: statement.id.name });
|
|
124960
|
+
}
|
|
124951
124961
|
if (statement.type === "VariableDeclaration") {
|
|
124952
124962
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
124953
124963
|
}
|
|
@@ -124956,6 +124966,12 @@ var init_AS003 = __esm({
|
|
|
124956
124966
|
}
|
|
124957
124967
|
collectParameterBindings(node) {
|
|
124958
124968
|
const bindings = [];
|
|
124969
|
+
if (node.type !== "ArrowFunctionExpression") {
|
|
124970
|
+
bindings.push({ kind: "let", name: "arguments" });
|
|
124971
|
+
if (node.type === "FunctionExpression" && node.id !== void 0) {
|
|
124972
|
+
bindings.push({ kind: "const", name: node.id.name });
|
|
124973
|
+
}
|
|
124974
|
+
}
|
|
124959
124975
|
for (const parameter of node.params) {
|
|
124960
124976
|
this.collectBindingNamesFromElement(parameter, "param", bindings);
|
|
124961
124977
|
}
|
|
@@ -125239,6 +125255,9 @@ var init_AS006_007 = __esm({
|
|
|
125239
125255
|
}
|
|
125240
125256
|
visitStatement(node) {
|
|
125241
125257
|
switch (node.type) {
|
|
125258
|
+
case "FunctionDeclaration":
|
|
125259
|
+
this.visitArrowFunction(node);
|
|
125260
|
+
return;
|
|
125242
125261
|
case "ExportNamedDeclaration":
|
|
125243
125262
|
this.visitVariableDeclaration(node.declaration);
|
|
125244
125263
|
return;
|
|
@@ -125370,9 +125389,15 @@ var init_AS006_007 = __esm({
|
|
|
125370
125389
|
}
|
|
125371
125390
|
visitExpression(node) {
|
|
125372
125391
|
switch (node.type) {
|
|
125392
|
+
case "YieldExpression":
|
|
125393
|
+
if (node.argument !== void 0) {
|
|
125394
|
+
this.visitExpression(node.argument);
|
|
125395
|
+
}
|
|
125396
|
+
return;
|
|
125373
125397
|
case "Identifier":
|
|
125374
125398
|
this.markRead(node);
|
|
125375
125399
|
return;
|
|
125400
|
+
case "FunctionExpression":
|
|
125376
125401
|
case "ArrowFunctionExpression":
|
|
125377
125402
|
this.visitArrowFunction(node);
|
|
125378
125403
|
return;
|
|
@@ -125646,6 +125671,10 @@ var init_AS006_007 = __esm({
|
|
|
125646
125671
|
bindings.push(...this.collectImportBindings(statement));
|
|
125647
125672
|
continue;
|
|
125648
125673
|
}
|
|
125674
|
+
if (statement.type === "FunctionDeclaration") {
|
|
125675
|
+
bindings.push(this.createBinding(statement.id, "let"));
|
|
125676
|
+
continue;
|
|
125677
|
+
}
|
|
125649
125678
|
if (statement.type === "VariableDeclaration") {
|
|
125650
125679
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
125651
125680
|
continue;
|
|
@@ -125659,6 +125688,9 @@ var init_AS006_007 = __esm({
|
|
|
125659
125688
|
collectBlockBindings(body) {
|
|
125660
125689
|
const bindings = [];
|
|
125661
125690
|
for (const statement of body) {
|
|
125691
|
+
if (statement.type === "FunctionDeclaration") {
|
|
125692
|
+
bindings.push(this.createBinding(statement.id, "let"));
|
|
125693
|
+
}
|
|
125662
125694
|
if (statement.type === "VariableDeclaration") {
|
|
125663
125695
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
125664
125696
|
}
|
|
@@ -125667,6 +125699,9 @@ var init_AS006_007 = __esm({
|
|
|
125667
125699
|
}
|
|
125668
125700
|
collectParameterBindings(node) {
|
|
125669
125701
|
const bindings = [];
|
|
125702
|
+
if (node.type === "FunctionExpression" && node.id !== void 0) {
|
|
125703
|
+
bindings.push(this.createBinding(node.id, "param"));
|
|
125704
|
+
}
|
|
125670
125705
|
for (const parameter of node.params) {
|
|
125671
125706
|
this.collectBindingNamesFromElement(parameter, "param", bindings);
|
|
125672
125707
|
}
|
|
@@ -125841,6 +125876,9 @@ var init_AS008 = __esm({
|
|
|
125841
125876
|
}
|
|
125842
125877
|
visitStatement(node) {
|
|
125843
125878
|
switch (node.type) {
|
|
125879
|
+
case "FunctionDeclaration":
|
|
125880
|
+
this.visitArrowFunction(node);
|
|
125881
|
+
return;
|
|
125844
125882
|
case "BlockStatement":
|
|
125845
125883
|
this.withNestedScope(() => {
|
|
125846
125884
|
this.visitBlock(node);
|
|
@@ -125957,6 +125995,12 @@ var init_AS008 = __esm({
|
|
|
125957
125995
|
}
|
|
125958
125996
|
visitExpression(node) {
|
|
125959
125997
|
switch (node.type) {
|
|
125998
|
+
case "YieldExpression":
|
|
125999
|
+
if (node.argument !== void 0) {
|
|
126000
|
+
this.visitExpression(node.argument);
|
|
126001
|
+
}
|
|
126002
|
+
return;
|
|
126003
|
+
case "FunctionExpression":
|
|
125960
126004
|
case "ArrowFunctionExpression":
|
|
125961
126005
|
this.visitArrowFunction(node);
|
|
125962
126006
|
return;
|
|
@@ -126227,6 +126271,9 @@ var init_AS009 = __esm({
|
|
|
126227
126271
|
}
|
|
126228
126272
|
visitStatement(node) {
|
|
126229
126273
|
switch (node.type) {
|
|
126274
|
+
case "FunctionDeclaration":
|
|
126275
|
+
this.visitArrowFunction(node);
|
|
126276
|
+
return;
|
|
126230
126277
|
case "BlockStatement":
|
|
126231
126278
|
this.visitBlockStatement(node.body);
|
|
126232
126279
|
return;
|
|
@@ -126354,6 +126401,12 @@ var init_AS009 = __esm({
|
|
|
126354
126401
|
}
|
|
126355
126402
|
visitExpression(node) {
|
|
126356
126403
|
switch (node.type) {
|
|
126404
|
+
case "YieldExpression":
|
|
126405
|
+
if (node.argument !== void 0) {
|
|
126406
|
+
this.visitExpression(node.argument);
|
|
126407
|
+
}
|
|
126408
|
+
return;
|
|
126409
|
+
case "FunctionExpression":
|
|
126357
126410
|
case "ArrowFunctionExpression":
|
|
126358
126411
|
this.visitArrowFunction(node);
|
|
126359
126412
|
return;
|
|
@@ -126713,6 +126766,9 @@ var init_AS010 = __esm({
|
|
|
126713
126766
|
}
|
|
126714
126767
|
visitStatement(node) {
|
|
126715
126768
|
switch (node.type) {
|
|
126769
|
+
case "FunctionDeclaration":
|
|
126770
|
+
this.visitArrowFunction(node);
|
|
126771
|
+
return;
|
|
126716
126772
|
case "BlockStatement":
|
|
126717
126773
|
this.visitBlock(node);
|
|
126718
126774
|
return;
|
|
@@ -126845,9 +126901,15 @@ var init_AS010 = __esm({
|
|
|
126845
126901
|
}
|
|
126846
126902
|
visitExpression(node) {
|
|
126847
126903
|
switch (node.type) {
|
|
126904
|
+
case "YieldExpression":
|
|
126905
|
+
if (node.argument !== void 0) {
|
|
126906
|
+
this.visitExpression(node.argument);
|
|
126907
|
+
}
|
|
126908
|
+
return;
|
|
126848
126909
|
case "Identifier":
|
|
126849
126910
|
this.markRead(node);
|
|
126850
126911
|
return;
|
|
126912
|
+
case "FunctionExpression":
|
|
126851
126913
|
case "ArrowFunctionExpression":
|
|
126852
126914
|
this.visitArrowFunction(node);
|
|
126853
126915
|
return;
|
|
@@ -127353,6 +127415,9 @@ var init_AS011 = __esm({
|
|
|
127353
127415
|
}
|
|
127354
127416
|
visitStatement(node) {
|
|
127355
127417
|
switch (node.type) {
|
|
127418
|
+
case "FunctionDeclaration":
|
|
127419
|
+
this.visitArrowFunction(node);
|
|
127420
|
+
return;
|
|
127356
127421
|
case "BlockStatement":
|
|
127357
127422
|
for (const statement of node.body) {
|
|
127358
127423
|
this.visitStatement(statement);
|
|
@@ -127468,6 +127533,12 @@ var init_AS011 = __esm({
|
|
|
127468
127533
|
}
|
|
127469
127534
|
visitExpression(node) {
|
|
127470
127535
|
switch (node.type) {
|
|
127536
|
+
case "YieldExpression":
|
|
127537
|
+
if (node.argument !== void 0) {
|
|
127538
|
+
this.visitExpression(node.argument);
|
|
127539
|
+
}
|
|
127540
|
+
return;
|
|
127541
|
+
case "FunctionExpression":
|
|
127471
127542
|
case "ArrowFunctionExpression":
|
|
127472
127543
|
this.visitArrowFunction(node);
|
|
127473
127544
|
return;
|
|
@@ -127588,399 +127659,7 @@ var init_AS011 = __esm({
|
|
|
127588
127659
|
this.visitExpression(expression);
|
|
127589
127660
|
}
|
|
127590
127661
|
}
|
|
127591
|
-
visitAssignmentTarget(node) {
|
|
127592
|
-
switch (node.type) {
|
|
127593
|
-
case "Identifier":
|
|
127594
|
-
case "MetaProperty":
|
|
127595
|
-
return;
|
|
127596
|
-
case "MemberExpression":
|
|
127597
|
-
this.visitMemberExpression(node);
|
|
127598
|
-
return;
|
|
127599
|
-
case "AssignmentPattern":
|
|
127600
|
-
this.visitAssignmentTarget(node.left);
|
|
127601
|
-
this.visitExpression(node.right);
|
|
127602
|
-
return;
|
|
127603
|
-
case "RestElement":
|
|
127604
|
-
this.visitAssignmentTarget(node.argument);
|
|
127605
|
-
return;
|
|
127606
|
-
case "ArrayPattern":
|
|
127607
|
-
for (const element of node.elements) {
|
|
127608
|
-
if (element !== null) {
|
|
127609
|
-
this.visitAssignmentTarget(element);
|
|
127610
|
-
}
|
|
127611
|
-
}
|
|
127612
|
-
return;
|
|
127613
|
-
case "ObjectPattern":
|
|
127614
|
-
for (const property of node.properties) {
|
|
127615
|
-
if (property.type === "RestElement") {
|
|
127616
|
-
this.visitAssignmentTarget(property.argument);
|
|
127617
|
-
continue;
|
|
127618
|
-
}
|
|
127619
|
-
if (property.computed) {
|
|
127620
|
-
this.visitExpression(property.key);
|
|
127621
|
-
}
|
|
127622
|
-
this.visitAssignmentTarget(property.value);
|
|
127623
|
-
}
|
|
127624
|
-
return;
|
|
127625
|
-
}
|
|
127626
|
-
}
|
|
127627
|
-
visitBindingTarget(node) {
|
|
127628
|
-
switch (node.type) {
|
|
127629
|
-
case "AssignmentPattern":
|
|
127630
|
-
this.visitBindingTarget(node.left);
|
|
127631
|
-
this.visitExpression(node.right);
|
|
127632
|
-
return;
|
|
127633
|
-
case "RestElement":
|
|
127634
|
-
this.visitBindingTarget(node.argument);
|
|
127635
|
-
return;
|
|
127636
|
-
default:
|
|
127637
|
-
this.visitAssignmentTarget(node);
|
|
127638
|
-
return;
|
|
127639
|
-
}
|
|
127640
|
-
}
|
|
127641
|
-
isForbiddenMemberProperty(node) {
|
|
127642
|
-
if (!node.computed) {
|
|
127643
|
-
return node.property.type === "Identifier" && FORBIDDEN_PROPERTY_NAMES.has(node.property.name);
|
|
127644
|
-
}
|
|
127645
|
-
return node.property.type === "StringLiteral" && FORBIDDEN_PROPERTY_NAMES.has(node.property.value);
|
|
127646
|
-
}
|
|
127647
|
-
report(span) {
|
|
127648
|
-
this.diagnostics.push({
|
|
127649
|
-
code: "AS011",
|
|
127650
|
-
severity: "error",
|
|
127651
|
-
message: MESSAGE3,
|
|
127652
|
-
filename: this.filename,
|
|
127653
|
-
line: span.start.line,
|
|
127654
|
-
column: span.start.column,
|
|
127655
|
-
span
|
|
127656
|
-
});
|
|
127657
|
-
}
|
|
127658
|
-
};
|
|
127659
|
-
}
|
|
127660
|
-
});
|
|
127661
|
-
|
|
127662
|
-
// packages/safejs/src/lint/rules/AS012.ts
|
|
127663
|
-
function AS012(source, options = {}) {
|
|
127664
|
-
return new AS012Scanner(options.filename ?? "<input>").scan(source);
|
|
127665
|
-
}
|
|
127666
|
-
function getMemberPropertyName(node) {
|
|
127667
|
-
if (node.type !== "MemberExpression") {
|
|
127668
|
-
return void 0;
|
|
127669
|
-
}
|
|
127670
|
-
if (!node.computed && node.property.type === "Identifier") {
|
|
127671
|
-
return node.property.name;
|
|
127672
|
-
}
|
|
127673
|
-
if (node.computed && node.property.type === "StringLiteral") {
|
|
127674
|
-
return node.property.value;
|
|
127675
|
-
}
|
|
127676
|
-
return void 0;
|
|
127677
|
-
}
|
|
127678
|
-
function isSupportedSortComparator(node) {
|
|
127679
|
-
return node.type === "ArrowFunctionExpression" && !node.async && isNumberReturningArrow(node);
|
|
127680
|
-
}
|
|
127681
|
-
function isNumberReturningArrow(node) {
|
|
127682
|
-
if (node.body.type === "BlockStatement") {
|
|
127683
|
-
return false;
|
|
127684
|
-
}
|
|
127685
|
-
return isClearlyNumberExpression(node.body);
|
|
127686
|
-
}
|
|
127687
|
-
function isClearlyNumberExpression(node) {
|
|
127688
|
-
switch (node.type) {
|
|
127689
|
-
case "NumericLiteral":
|
|
127690
|
-
return true;
|
|
127691
|
-
case "RegexLiteral":
|
|
127692
|
-
return false;
|
|
127693
|
-
case "UnaryExpression":
|
|
127694
|
-
return (node.operator === "+" || node.operator === "-" || node.operator === "~") && isClearlyNumberExpression(node.argument);
|
|
127695
|
-
case "BinaryExpression":
|
|
127696
|
-
return NUMBER_RETURNING_BINARY_OPERATORS.has(node.operator);
|
|
127697
|
-
case "ConditionalExpression":
|
|
127698
|
-
return isClearlyNumberExpression(node.consequent) && isClearlyNumberExpression(node.alternate);
|
|
127699
|
-
case "CallExpression":
|
|
127700
|
-
return isLocaleCompareCall(node);
|
|
127701
|
-
default:
|
|
127702
|
-
return false;
|
|
127703
|
-
}
|
|
127704
|
-
}
|
|
127705
|
-
function isLocaleCompareCall(node) {
|
|
127706
|
-
return getMemberPropertyName(node.callee) === "localeCompare";
|
|
127707
|
-
}
|
|
127708
|
-
var SORT_MESSAGE, NUMBER_RETURNING_BINARY_OPERATORS, AS012Scanner;
|
|
127709
|
-
var init_AS012 = __esm({
|
|
127710
|
-
"packages/safejs/src/lint/rules/AS012.ts"() {
|
|
127711
|
-
"use strict";
|
|
127712
|
-
init_parser3();
|
|
127713
|
-
SORT_MESSAGE = "Array#sort only supports comparators that are arrows returning a number.";
|
|
127714
|
-
NUMBER_RETURNING_BINARY_OPERATORS = /* @__PURE__ */ new Set([
|
|
127715
|
-
"%",
|
|
127716
|
-
"*",
|
|
127717
|
-
"**",
|
|
127718
|
-
"-",
|
|
127719
|
-
"/",
|
|
127720
|
-
"<<",
|
|
127721
|
-
">>",
|
|
127722
|
-
">>>",
|
|
127723
|
-
"&",
|
|
127724
|
-
"^",
|
|
127725
|
-
"|"
|
|
127726
|
-
]);
|
|
127727
|
-
AS012Scanner = class {
|
|
127728
|
-
constructor(filename) {
|
|
127729
|
-
this.filename = filename;
|
|
127730
|
-
}
|
|
127731
|
-
filename;
|
|
127732
|
-
diagnostics = [];
|
|
127733
|
-
scan(source) {
|
|
127734
|
-
this.visitModule(parseModule(source, this.filename));
|
|
127735
|
-
return this.diagnostics;
|
|
127736
|
-
}
|
|
127737
|
-
visitModule(node) {
|
|
127738
|
-
for (const statement of node.body) {
|
|
127739
|
-
this.visitStatement(statement);
|
|
127740
|
-
}
|
|
127741
|
-
}
|
|
127742
|
-
visitStatement(node) {
|
|
127743
|
-
switch (node.type) {
|
|
127744
|
-
case "BlockStatement":
|
|
127745
|
-
for (const statement of node.body) {
|
|
127746
|
-
this.visitStatement(statement);
|
|
127747
|
-
}
|
|
127748
|
-
return;
|
|
127749
|
-
case "ExpressionStatement":
|
|
127750
|
-
this.visitExpression(node.expression);
|
|
127751
|
-
return;
|
|
127752
|
-
case "IfStatement":
|
|
127753
|
-
this.visitIfStatement(node);
|
|
127754
|
-
return;
|
|
127755
|
-
case "ForStatement":
|
|
127756
|
-
this.visitForStatement(node);
|
|
127757
|
-
return;
|
|
127758
|
-
case "ForInStatement":
|
|
127759
|
-
case "ForOfStatement":
|
|
127760
|
-
this.visitForOfStatement(node);
|
|
127761
|
-
return;
|
|
127762
|
-
case "WhileStatement":
|
|
127763
|
-
case "DoWhileStatement":
|
|
127764
|
-
this.visitWhileStatement(node);
|
|
127765
|
-
return;
|
|
127766
|
-
case "TryStatement":
|
|
127767
|
-
this.visitTryStatement(node);
|
|
127768
|
-
return;
|
|
127769
|
-
case "VariableDeclaration":
|
|
127770
|
-
this.visitVariableDeclaration(node);
|
|
127771
|
-
return;
|
|
127772
|
-
case "ReturnStatement":
|
|
127773
|
-
this.visitReturnStatement(node);
|
|
127774
|
-
return;
|
|
127775
|
-
case "ThrowStatement":
|
|
127776
|
-
this.visitThrowStatement(node);
|
|
127777
|
-
return;
|
|
127778
|
-
case "ExportNamedDeclaration":
|
|
127779
|
-
this.visitVariableDeclaration(node.declaration);
|
|
127780
|
-
return;
|
|
127781
|
-
case "ExportDefaultDeclaration":
|
|
127782
|
-
this.visitExpression(node.declaration);
|
|
127783
|
-
return;
|
|
127784
|
-
case "ImportDeclaration":
|
|
127785
|
-
case "BreakStatement":
|
|
127786
|
-
case "ContinueStatement":
|
|
127787
|
-
return;
|
|
127788
|
-
}
|
|
127789
|
-
}
|
|
127790
|
-
visitIfStatement(node) {
|
|
127791
|
-
this.visitExpression(node.test);
|
|
127792
|
-
this.visitStatement(node.consequent);
|
|
127793
|
-
if (node.alternate !== void 0) {
|
|
127794
|
-
this.visitStatement(node.alternate);
|
|
127795
|
-
}
|
|
127796
|
-
}
|
|
127797
|
-
visitForStatement(node) {
|
|
127798
|
-
if (node.init !== void 0) {
|
|
127799
|
-
if (node.init.type === "VariableDeclaration") {
|
|
127800
|
-
this.visitVariableDeclaration(node.init);
|
|
127801
|
-
} else {
|
|
127802
|
-
this.visitExpression(node.init);
|
|
127803
|
-
}
|
|
127804
|
-
}
|
|
127805
|
-
if (node.test !== void 0) {
|
|
127806
|
-
this.visitExpression(node.test);
|
|
127807
|
-
}
|
|
127808
|
-
if (node.update !== void 0) {
|
|
127809
|
-
this.visitExpression(node.update);
|
|
127810
|
-
}
|
|
127811
|
-
this.visitStatement(node.body);
|
|
127812
|
-
}
|
|
127813
|
-
visitForOfStatement(node) {
|
|
127814
|
-
if (node.left.type === "VariableDeclaration") {
|
|
127815
|
-
this.visitVariableDeclaration(node.left);
|
|
127816
|
-
} else {
|
|
127817
|
-
this.visitPattern(node.left);
|
|
127818
|
-
}
|
|
127819
|
-
this.visitExpression(node.right);
|
|
127820
|
-
this.visitStatement(node.body);
|
|
127821
|
-
}
|
|
127822
|
-
visitWhileStatement(node) {
|
|
127823
|
-
this.visitExpression(node.test);
|
|
127824
|
-
this.visitStatement(node.body);
|
|
127825
|
-
}
|
|
127826
|
-
visitTryStatement(node) {
|
|
127827
|
-
this.visitStatement(node.block);
|
|
127828
|
-
if (node.handler !== void 0) {
|
|
127829
|
-
this.visitCatchClause(node.handler);
|
|
127830
|
-
}
|
|
127831
|
-
if (node.finalizer !== void 0) {
|
|
127832
|
-
this.visitStatement(node.finalizer);
|
|
127833
|
-
}
|
|
127834
|
-
}
|
|
127835
|
-
visitCatchClause(node) {
|
|
127836
|
-
if (node.param !== void 0) {
|
|
127837
|
-
this.visitPattern(node.param);
|
|
127838
|
-
}
|
|
127839
|
-
this.visitStatement(node.body);
|
|
127840
|
-
}
|
|
127841
|
-
visitVariableDeclaration(node) {
|
|
127842
|
-
for (const declarator of node.declarations) {
|
|
127843
|
-
this.visitVariableDeclarator(declarator);
|
|
127844
|
-
}
|
|
127845
|
-
}
|
|
127846
|
-
visitVariableDeclarator(node) {
|
|
127847
|
-
this.visitPattern(node.id);
|
|
127848
|
-
if (node.init !== void 0) {
|
|
127849
|
-
this.visitExpression(node.init);
|
|
127850
|
-
}
|
|
127851
|
-
}
|
|
127852
|
-
visitReturnStatement(node) {
|
|
127853
|
-
if (node.argument !== void 0) {
|
|
127854
|
-
this.visitExpression(node.argument);
|
|
127855
|
-
}
|
|
127856
|
-
}
|
|
127857
|
-
visitThrowStatement(node) {
|
|
127858
|
-
this.visitExpression(node.argument);
|
|
127859
|
-
}
|
|
127860
|
-
visitExpression(node) {
|
|
127861
|
-
switch (node.type) {
|
|
127862
|
-
case "ArrowFunctionExpression":
|
|
127863
|
-
this.visitArrowFunction(node);
|
|
127864
|
-
return;
|
|
127865
|
-
case "AwaitExpression":
|
|
127866
|
-
this.visitExpression(node.argument);
|
|
127867
|
-
return;
|
|
127868
|
-
case "ArrayExpression":
|
|
127869
|
-
this.visitArrayExpression(node);
|
|
127870
|
-
return;
|
|
127871
|
-
case "ObjectExpression":
|
|
127872
|
-
this.visitObjectExpression(node);
|
|
127873
|
-
return;
|
|
127874
|
-
case "UnaryExpression":
|
|
127875
|
-
this.visitUnaryExpression(node);
|
|
127876
|
-
return;
|
|
127877
|
-
case "BinaryExpression":
|
|
127878
|
-
case "LogicalExpression":
|
|
127879
|
-
this.visitBinaryLikeExpression(node);
|
|
127880
|
-
return;
|
|
127881
|
-
case "ConditionalExpression":
|
|
127882
|
-
this.visitConditionalExpression(node);
|
|
127883
|
-
return;
|
|
127884
|
-
case "MemberExpression":
|
|
127885
|
-
this.visitMemberExpression(node);
|
|
127886
|
-
return;
|
|
127887
|
-
case "AssignmentExpression":
|
|
127888
|
-
this.visitAssignmentExpression(node);
|
|
127889
|
-
return;
|
|
127890
|
-
case "CallExpression":
|
|
127891
|
-
this.visitCallExpression(node);
|
|
127892
|
-
return;
|
|
127893
|
-
case "TemplateLiteral":
|
|
127894
|
-
this.visitTemplateLiteral(node);
|
|
127895
|
-
return;
|
|
127896
|
-
case "Identifier":
|
|
127897
|
-
case "BooleanLiteral":
|
|
127898
|
-
case "NullLiteral":
|
|
127899
|
-
case "NumericLiteral":
|
|
127900
|
-
case "RegexLiteral":
|
|
127901
|
-
case "StringLiteral":
|
|
127902
|
-
case "UndefinedLiteral":
|
|
127903
|
-
return;
|
|
127904
|
-
}
|
|
127905
|
-
}
|
|
127906
|
-
visitArrowFunction(node) {
|
|
127907
|
-
for (const parameter of node.params) {
|
|
127908
|
-
this.visitPattern(parameter);
|
|
127909
|
-
}
|
|
127910
|
-
if (node.body.type === "BlockStatement") {
|
|
127911
|
-
for (const statement of node.body.body) {
|
|
127912
|
-
this.visitStatement(statement);
|
|
127913
|
-
}
|
|
127914
|
-
return;
|
|
127915
|
-
}
|
|
127916
|
-
this.visitExpression(node.body);
|
|
127917
|
-
}
|
|
127918
|
-
visitArrayExpression(node) {
|
|
127919
|
-
for (const element of node.elements) {
|
|
127920
|
-
if (element.type === "SpreadElement") {
|
|
127921
|
-
this.visitExpression(element.argument);
|
|
127922
|
-
continue;
|
|
127923
|
-
}
|
|
127924
|
-
this.visitExpression(element);
|
|
127925
|
-
}
|
|
127926
|
-
}
|
|
127927
|
-
visitObjectExpression(node) {
|
|
127928
|
-
for (const property of node.properties) {
|
|
127929
|
-
if (property.type === "SpreadElement") {
|
|
127930
|
-
this.visitExpression(property.argument);
|
|
127931
|
-
continue;
|
|
127932
|
-
}
|
|
127933
|
-
this.visitProperty(property);
|
|
127934
|
-
}
|
|
127935
|
-
}
|
|
127936
|
-
visitProperty(node) {
|
|
127937
|
-
if (node.computed) {
|
|
127938
|
-
this.visitExpression(node.key);
|
|
127939
|
-
}
|
|
127940
|
-
this.visitExpression(node.value);
|
|
127941
|
-
}
|
|
127942
|
-
visitUnaryExpression(node) {
|
|
127943
|
-
this.visitExpression(node.argument);
|
|
127944
|
-
}
|
|
127945
|
-
visitBinaryLikeExpression(node) {
|
|
127946
|
-
this.visitExpression(node.left);
|
|
127947
|
-
this.visitExpression(node.right);
|
|
127948
|
-
}
|
|
127949
|
-
visitConditionalExpression(node) {
|
|
127950
|
-
this.visitExpression(node.test);
|
|
127951
|
-
this.visitExpression(node.consequent);
|
|
127952
|
-
this.visitExpression(node.alternate);
|
|
127953
|
-
}
|
|
127954
|
-
visitMemberExpression(node) {
|
|
127955
|
-
this.visitExpression(node.object);
|
|
127956
|
-
if (node.computed) {
|
|
127957
|
-
this.visitExpression(node.property);
|
|
127958
|
-
}
|
|
127959
|
-
}
|
|
127960
|
-
visitAssignmentExpression(node) {
|
|
127961
|
-
this.visitPattern(node.left);
|
|
127962
|
-
this.visitExpression(node.right);
|
|
127963
|
-
}
|
|
127964
|
-
visitCallExpression(node) {
|
|
127965
|
-
this.visitExpression(node.callee);
|
|
127966
|
-
this.reportUnsupportedMethodArgs(node);
|
|
127967
|
-
for (const argument of node.arguments) {
|
|
127968
|
-
this.visitCallArgument(argument);
|
|
127969
|
-
}
|
|
127970
|
-
}
|
|
127971
|
-
visitCallArgument(node) {
|
|
127972
|
-
if (node.type === "SpreadElement") {
|
|
127973
|
-
this.visitExpression(node.argument);
|
|
127974
|
-
return;
|
|
127975
|
-
}
|
|
127976
|
-
this.visitExpression(node);
|
|
127977
|
-
}
|
|
127978
|
-
visitTemplateLiteral(node) {
|
|
127979
|
-
for (const expression of node.expressions) {
|
|
127980
|
-
this.visitExpression(expression);
|
|
127981
|
-
}
|
|
127982
|
-
}
|
|
127983
|
-
visitPattern(node) {
|
|
127662
|
+
visitAssignmentTarget(node) {
|
|
127984
127663
|
switch (node.type) {
|
|
127985
127664
|
case "Identifier":
|
|
127986
127665
|
case "MetaProperty":
|
|
@@ -127988,56 +127667,59 @@ var init_AS012 = __esm({
|
|
|
127988
127667
|
case "MemberExpression":
|
|
127989
127668
|
this.visitMemberExpression(node);
|
|
127990
127669
|
return;
|
|
127670
|
+
case "AssignmentPattern":
|
|
127671
|
+
this.visitAssignmentTarget(node.left);
|
|
127672
|
+
this.visitExpression(node.right);
|
|
127673
|
+
return;
|
|
127674
|
+
case "RestElement":
|
|
127675
|
+
this.visitAssignmentTarget(node.argument);
|
|
127676
|
+
return;
|
|
127991
127677
|
case "ArrayPattern":
|
|
127992
127678
|
for (const element of node.elements) {
|
|
127993
|
-
if (element
|
|
127994
|
-
|
|
127679
|
+
if (element !== null) {
|
|
127680
|
+
this.visitAssignmentTarget(element);
|
|
127995
127681
|
}
|
|
127996
|
-
this.visitPattern(element);
|
|
127997
127682
|
}
|
|
127998
127683
|
return;
|
|
127999
127684
|
case "ObjectPattern":
|
|
128000
127685
|
for (const property of node.properties) {
|
|
128001
127686
|
if (property.type === "RestElement") {
|
|
128002
|
-
this.
|
|
127687
|
+
this.visitAssignmentTarget(property.argument);
|
|
128003
127688
|
continue;
|
|
128004
127689
|
}
|
|
128005
127690
|
if (property.computed) {
|
|
128006
127691
|
this.visitExpression(property.key);
|
|
128007
127692
|
}
|
|
128008
|
-
this.
|
|
127693
|
+
this.visitAssignmentTarget(property.value);
|
|
128009
127694
|
}
|
|
128010
127695
|
return;
|
|
127696
|
+
}
|
|
127697
|
+
}
|
|
127698
|
+
visitBindingTarget(node) {
|
|
127699
|
+
switch (node.type) {
|
|
128011
127700
|
case "AssignmentPattern":
|
|
128012
|
-
this.
|
|
127701
|
+
this.visitBindingTarget(node.left);
|
|
128013
127702
|
this.visitExpression(node.right);
|
|
128014
127703
|
return;
|
|
128015
127704
|
case "RestElement":
|
|
128016
|
-
this.
|
|
127705
|
+
this.visitBindingTarget(node.argument);
|
|
127706
|
+
return;
|
|
127707
|
+
default:
|
|
127708
|
+
this.visitAssignmentTarget(node);
|
|
128017
127709
|
return;
|
|
128018
127710
|
}
|
|
128019
127711
|
}
|
|
128020
|
-
|
|
128021
|
-
|
|
128022
|
-
|
|
128023
|
-
return;
|
|
128024
|
-
}
|
|
128025
|
-
if (methodName !== "sort") {
|
|
128026
|
-
return;
|
|
128027
|
-
}
|
|
128028
|
-
const comparator = node.arguments[0];
|
|
128029
|
-
if (comparator === void 0 || comparator.type === "SpreadElement") {
|
|
128030
|
-
return;
|
|
128031
|
-
}
|
|
128032
|
-
if (!isSupportedSortComparator(comparator)) {
|
|
128033
|
-
this.report(comparator.span, SORT_MESSAGE);
|
|
127712
|
+
isForbiddenMemberProperty(node) {
|
|
127713
|
+
if (!node.computed) {
|
|
127714
|
+
return node.property.type === "Identifier" && FORBIDDEN_PROPERTY_NAMES.has(node.property.name);
|
|
128034
127715
|
}
|
|
127716
|
+
return node.property.type === "StringLiteral" && FORBIDDEN_PROPERTY_NAMES.has(node.property.value);
|
|
128035
127717
|
}
|
|
128036
|
-
report(span
|
|
127718
|
+
report(span) {
|
|
128037
127719
|
this.diagnostics.push({
|
|
128038
|
-
code: "
|
|
127720
|
+
code: "AS011",
|
|
128039
127721
|
severity: "error",
|
|
128040
|
-
message:
|
|
127722
|
+
message: MESSAGE3,
|
|
128041
127723
|
filename: this.filename,
|
|
128042
127724
|
line: span.start.line,
|
|
128043
127725
|
column: span.start.column,
|
|
@@ -128176,6 +127858,9 @@ var init_AS015 = __esm({
|
|
|
128176
127858
|
}
|
|
128177
127859
|
visitStatement(node) {
|
|
128178
127860
|
switch (node.type) {
|
|
127861
|
+
case "FunctionDeclaration":
|
|
127862
|
+
this.visitArrowFunction(node);
|
|
127863
|
+
return;
|
|
128179
127864
|
case "BlockStatement":
|
|
128180
127865
|
for (const statement of node.body) {
|
|
128181
127866
|
this.visitStatement(statement);
|
|
@@ -128292,6 +127977,12 @@ var init_AS015 = __esm({
|
|
|
128292
127977
|
}
|
|
128293
127978
|
visitExpression(node) {
|
|
128294
127979
|
switch (node.type) {
|
|
127980
|
+
case "YieldExpression":
|
|
127981
|
+
if (node.argument !== void 0) {
|
|
127982
|
+
this.visitExpression(node.argument);
|
|
127983
|
+
}
|
|
127984
|
+
return;
|
|
127985
|
+
case "FunctionExpression":
|
|
128295
127986
|
case "ArrowFunctionExpression":
|
|
128296
127987
|
this.visitArrowFunction(node);
|
|
128297
127988
|
return;
|
|
@@ -128634,7 +128325,7 @@ var init_AS_async_not_needed = __esm({
|
|
|
128634
128325
|
"packages/safejs/src/lint/rules/AS-async-not-needed.ts"() {
|
|
128635
128326
|
"use strict";
|
|
128636
128327
|
init_parser3();
|
|
128637
|
-
AS_ASYNC_NOT_NEEDED_MESSAGE = "Async
|
|
128328
|
+
AS_ASYNC_NOT_NEEDED_MESSAGE = "Async functions without await should remove the async keyword.";
|
|
128638
128329
|
ASAsyncNotNeededScanner = class {
|
|
128639
128330
|
constructor(source, filename) {
|
|
128640
128331
|
this.source = source;
|
|
@@ -128654,6 +128345,9 @@ var init_AS_async_not_needed = __esm({
|
|
|
128654
128345
|
}
|
|
128655
128346
|
visitStatement(node) {
|
|
128656
128347
|
switch (node.type) {
|
|
128348
|
+
case "FunctionDeclaration":
|
|
128349
|
+
this.visitFunctionExpression(node);
|
|
128350
|
+
return;
|
|
128657
128351
|
case "BlockStatement":
|
|
128658
128352
|
this.visitBlockStatement(node);
|
|
128659
128353
|
return;
|
|
@@ -128694,6 +128388,10 @@ var init_AS_async_not_needed = __esm({
|
|
|
128694
128388
|
this.visitArrowFunction(node.declaration, true);
|
|
128695
128389
|
return;
|
|
128696
128390
|
}
|
|
128391
|
+
if (node.declaration.type === "FunctionExpression") {
|
|
128392
|
+
this.visitFunctionExpression(node.declaration, true);
|
|
128393
|
+
return;
|
|
128394
|
+
}
|
|
128697
128395
|
this.visitExpression(node.declaration);
|
|
128698
128396
|
return;
|
|
128699
128397
|
case "ImportDeclaration":
|
|
@@ -128779,6 +128477,11 @@ var init_AS_async_not_needed = __esm({
|
|
|
128779
128477
|
}
|
|
128780
128478
|
visitExpression(node) {
|
|
128781
128479
|
switch (node.type) {
|
|
128480
|
+
case "YieldExpression":
|
|
128481
|
+
if (node.argument !== void 0) {
|
|
128482
|
+
this.visitExpression(node.argument);
|
|
128483
|
+
}
|
|
128484
|
+
return;
|
|
128782
128485
|
case "ArrowFunctionExpression":
|
|
128783
128486
|
this.visitArrowFunction(node, false);
|
|
128784
128487
|
return;
|
|
@@ -128843,8 +128546,8 @@ var init_AS_async_not_needed = __esm({
|
|
|
128843
128546
|
}
|
|
128844
128547
|
this.visitExpression(node.body);
|
|
128845
128548
|
}
|
|
128846
|
-
visitFunctionExpression(node) {
|
|
128847
|
-
if (node.async && !bodyContainsAwait(node.body)) {
|
|
128549
|
+
visitFunctionExpression(node, isDefaultExport = false) {
|
|
128550
|
+
if (node.async && !isDefaultExport && !bodyContainsAwait(node.body)) {
|
|
128848
128551
|
this.report(createAsyncKeywordSpan(node.span));
|
|
128849
128552
|
}
|
|
128850
128553
|
for (const param of node.params) {
|
|
@@ -129000,6 +128703,7 @@ function AS_AWAIT_NON_PROMISE(source, options = {}) {
|
|
|
129000
128703
|
}
|
|
129001
128704
|
function isKnownNonPromiseExpression(node) {
|
|
129002
128705
|
switch (node.type) {
|
|
128706
|
+
case "FunctionExpression":
|
|
129003
128707
|
case "ArrowFunctionExpression":
|
|
129004
128708
|
case "ArrayExpression":
|
|
129005
128709
|
case "BinaryExpression":
|
|
@@ -129037,6 +128741,9 @@ var init_AS_await_non_promise = __esm({
|
|
|
129037
128741
|
}
|
|
129038
128742
|
visitStatement(node) {
|
|
129039
128743
|
switch (node.type) {
|
|
128744
|
+
case "FunctionDeclaration":
|
|
128745
|
+
this.visitArrowFunction(node);
|
|
128746
|
+
return;
|
|
129040
128747
|
case "BlockStatement":
|
|
129041
128748
|
this.visitBlockStatement(node);
|
|
129042
128749
|
return;
|
|
@@ -129152,6 +128859,12 @@ var init_AS_await_non_promise = __esm({
|
|
|
129152
128859
|
}
|
|
129153
128860
|
visitExpression(node) {
|
|
129154
128861
|
switch (node.type) {
|
|
128862
|
+
case "YieldExpression":
|
|
128863
|
+
if (node.argument !== void 0) {
|
|
128864
|
+
this.visitExpression(node.argument);
|
|
128865
|
+
}
|
|
128866
|
+
return;
|
|
128867
|
+
case "FunctionExpression":
|
|
129155
128868
|
case "ArrowFunctionExpression":
|
|
129156
128869
|
this.visitArrowFunction(node);
|
|
129157
128870
|
return;
|
|
@@ -129359,6 +129072,9 @@ var init_AS_destructure_null_default = __esm({
|
|
|
129359
129072
|
}
|
|
129360
129073
|
visitStatement(node) {
|
|
129361
129074
|
switch (node.type) {
|
|
129075
|
+
case "FunctionDeclaration":
|
|
129076
|
+
this.visitArrowFunction(node);
|
|
129077
|
+
return;
|
|
129362
129078
|
case "BlockStatement":
|
|
129363
129079
|
this.visitBlockStatement(node);
|
|
129364
129080
|
return;
|
|
@@ -129480,6 +129196,12 @@ var init_AS_destructure_null_default = __esm({
|
|
|
129480
129196
|
}
|
|
129481
129197
|
visitExpression(node) {
|
|
129482
129198
|
switch (node.type) {
|
|
129199
|
+
case "YieldExpression":
|
|
129200
|
+
if (node.argument !== void 0) {
|
|
129201
|
+
this.visitExpression(node.argument);
|
|
129202
|
+
}
|
|
129203
|
+
return;
|
|
129204
|
+
case "FunctionExpression":
|
|
129483
129205
|
case "ArrowFunctionExpression":
|
|
129484
129206
|
this.visitArrowFunction(node);
|
|
129485
129207
|
return;
|
|
@@ -129838,6 +129560,12 @@ var init_AS_export_import_meta = __esm({
|
|
|
129838
129560
|
}
|
|
129839
129561
|
visitStatement(node) {
|
|
129840
129562
|
switch (node.type) {
|
|
129563
|
+
case "FunctionDeclaration":
|
|
129564
|
+
for (const param of node.params) {
|
|
129565
|
+
this.visitAssignmentTarget(param);
|
|
129566
|
+
}
|
|
129567
|
+
this.visitStatement(node.body);
|
|
129568
|
+
return;
|
|
129841
129569
|
case "ExportNamedDeclaration":
|
|
129842
129570
|
this.visitExportNamedDeclaration(node.declaration);
|
|
129843
129571
|
return;
|
|
@@ -129990,7 +129718,15 @@ var init_AS_export_import_meta = __esm({
|
|
|
129990
129718
|
}
|
|
129991
129719
|
visitExpression(node) {
|
|
129992
129720
|
switch (node.type) {
|
|
129721
|
+
case "YieldExpression":
|
|
129722
|
+
if (node.argument !== void 0) {
|
|
129723
|
+
this.visitExpression(node.argument);
|
|
129724
|
+
}
|
|
129725
|
+
return;
|
|
129993
129726
|
case "ArrowFunctionExpression":
|
|
129727
|
+
for (const param of node.params) {
|
|
129728
|
+
this.visitAssignmentTarget(param);
|
|
129729
|
+
}
|
|
129994
129730
|
if (node.body.type === "BlockStatement") {
|
|
129995
129731
|
this.visitStatement(node.body);
|
|
129996
129732
|
} else {
|
|
@@ -129998,6 +129734,9 @@ var init_AS_export_import_meta = __esm({
|
|
|
129998
129734
|
}
|
|
129999
129735
|
return;
|
|
130000
129736
|
case "FunctionExpression":
|
|
129737
|
+
for (const param of node.params) {
|
|
129738
|
+
this.visitAssignmentTarget(param);
|
|
129739
|
+
}
|
|
130001
129740
|
this.visitStatement(node.body);
|
|
130002
129741
|
return;
|
|
130003
129742
|
case "AwaitExpression":
|
|
@@ -130194,6 +129933,9 @@ var init_AS_floating_promise = __esm({
|
|
|
130194
129933
|
}
|
|
130195
129934
|
visitStatement(node) {
|
|
130196
129935
|
switch (node.type) {
|
|
129936
|
+
case "FunctionDeclaration":
|
|
129937
|
+
this.visitArrowFunction(node);
|
|
129938
|
+
return;
|
|
130197
129939
|
case "BlockStatement":
|
|
130198
129940
|
this.visitBlockStatement(node);
|
|
130199
129941
|
return;
|
|
@@ -130324,6 +130066,12 @@ var init_AS_floating_promise = __esm({
|
|
|
130324
130066
|
}
|
|
130325
130067
|
visitExpression(node) {
|
|
130326
130068
|
switch (node.type) {
|
|
130069
|
+
case "YieldExpression":
|
|
130070
|
+
if (node.argument !== void 0) {
|
|
130071
|
+
this.visitExpression(node.argument);
|
|
130072
|
+
}
|
|
130073
|
+
return;
|
|
130074
|
+
case "FunctionExpression":
|
|
130327
130075
|
case "ArrowFunctionExpression":
|
|
130328
130076
|
this.visitArrowFunction(node);
|
|
130329
130077
|
return;
|
|
@@ -130532,6 +130280,7 @@ var init_AS_floating_promise = __esm({
|
|
|
130532
130280
|
this.reportUnhandledLikelyPromiseStatementExpression(node.alternate);
|
|
130533
130281
|
return;
|
|
130534
130282
|
case "CallExpression":
|
|
130283
|
+
case "FunctionExpression":
|
|
130535
130284
|
case "ArrowFunctionExpression":
|
|
130536
130285
|
case "AwaitExpression":
|
|
130537
130286
|
case "ArrayExpression":
|
|
@@ -130630,6 +130379,11 @@ var init_AS_floating_promise = __esm({
|
|
|
130630
130379
|
}
|
|
130631
130380
|
collectBlockBindings(statements) {
|
|
130632
130381
|
return statements.flatMap((statement) => {
|
|
130382
|
+
if (statement.type === "FunctionDeclaration") {
|
|
130383
|
+
return [
|
|
130384
|
+
{ async: statement.async && !statement.generator, kind: "local", name: statement.id.name }
|
|
130385
|
+
];
|
|
130386
|
+
}
|
|
130633
130387
|
if (statement.type === "VariableDeclaration") {
|
|
130634
130388
|
return this.collectDeclarationBindings(statement);
|
|
130635
130389
|
}
|
|
@@ -130642,7 +130396,7 @@ var init_AS_floating_promise = __esm({
|
|
|
130642
130396
|
collectDeclarationBindings(node) {
|
|
130643
130397
|
return node.declarations.flatMap(
|
|
130644
130398
|
(declarator) => this.collectDeclaratorBindings(declarator).map((name) => ({
|
|
130645
|
-
async: declarator.init?.type === "ArrowFunctionExpression" && declarator.init.async,
|
|
130399
|
+
async: (declarator.init?.type === "ArrowFunctionExpression" || declarator.init?.type === "FunctionExpression" && !declarator.init.generator) && declarator.init.async,
|
|
130646
130400
|
kind: "local",
|
|
130647
130401
|
name
|
|
130648
130402
|
}))
|
|
@@ -130652,13 +130406,17 @@ var init_AS_floating_promise = __esm({
|
|
|
130652
130406
|
return this.collectPatternBindingNames(node.id);
|
|
130653
130407
|
}
|
|
130654
130408
|
collectArrowFunctionBindings(node) {
|
|
130655
|
-
|
|
130409
|
+
const bindings = node.params.flatMap(
|
|
130656
130410
|
(param) => this.collectParameterBindingNames(param).map((name) => ({
|
|
130657
130411
|
async: false,
|
|
130658
130412
|
kind: "local",
|
|
130659
130413
|
name
|
|
130660
130414
|
}))
|
|
130661
130415
|
);
|
|
130416
|
+
if (node.type === "FunctionExpression" && node.id !== void 0) {
|
|
130417
|
+
bindings.unshift({ async: node.async && !node.generator, kind: "local", name: node.id.name });
|
|
130418
|
+
}
|
|
130419
|
+
return bindings;
|
|
130662
130420
|
}
|
|
130663
130421
|
collectPatternBindings(node) {
|
|
130664
130422
|
return this.collectPatternBindingNames(node).map((name) => ({
|
|
@@ -130807,6 +130565,9 @@ var init_AS_frontmatter_field_unused = __esm({
|
|
|
130807
130565
|
}
|
|
130808
130566
|
visitStatement(node) {
|
|
130809
130567
|
switch (node.type) {
|
|
130568
|
+
case "FunctionDeclaration":
|
|
130569
|
+
this.visitArrowFunction(node);
|
|
130570
|
+
return;
|
|
130810
130571
|
case "BlockStatement":
|
|
130811
130572
|
this.visitBlockStatement(node);
|
|
130812
130573
|
return;
|
|
@@ -130929,6 +130690,12 @@ var init_AS_frontmatter_field_unused = __esm({
|
|
|
130929
130690
|
}
|
|
130930
130691
|
visitExpression(node) {
|
|
130931
130692
|
switch (node.type) {
|
|
130693
|
+
case "YieldExpression":
|
|
130694
|
+
if (node.argument !== void 0) {
|
|
130695
|
+
this.visitExpression(node.argument);
|
|
130696
|
+
}
|
|
130697
|
+
return;
|
|
130698
|
+
case "FunctionExpression":
|
|
130932
130699
|
case "ArrowFunctionExpression":
|
|
130933
130700
|
this.visitArrowFunction(node);
|
|
130934
130701
|
return;
|
|
@@ -131517,6 +131284,7 @@ function inferExpressionKind(expression) {
|
|
|
131517
131284
|
return "boolean";
|
|
131518
131285
|
}
|
|
131519
131286
|
return void 0;
|
|
131287
|
+
case "FunctionExpression":
|
|
131520
131288
|
case "ArrowFunctionExpression":
|
|
131521
131289
|
case "AssignmentExpression":
|
|
131522
131290
|
case "AwaitExpression":
|
|
@@ -131635,6 +131403,9 @@ var init_AS_jsdoc_type = __esm({
|
|
|
131635
131403
|
}
|
|
131636
131404
|
visitStatement(node) {
|
|
131637
131405
|
switch (node.type) {
|
|
131406
|
+
case "FunctionDeclaration":
|
|
131407
|
+
this.visitArrowFunction(node);
|
|
131408
|
+
return;
|
|
131638
131409
|
case "BlockStatement":
|
|
131639
131410
|
this.visitBlockStatement(node);
|
|
131640
131411
|
return;
|
|
@@ -131781,6 +131552,12 @@ var init_AS_jsdoc_type = __esm({
|
|
|
131781
131552
|
}
|
|
131782
131553
|
visitExpression(node) {
|
|
131783
131554
|
switch (node.type) {
|
|
131555
|
+
case "YieldExpression":
|
|
131556
|
+
if (node.argument !== void 0) {
|
|
131557
|
+
this.visitExpression(node.argument);
|
|
131558
|
+
}
|
|
131559
|
+
return;
|
|
131560
|
+
case "FunctionExpression":
|
|
131784
131561
|
case "ArrowFunctionExpression":
|
|
131785
131562
|
this.visitArrowFunction(node);
|
|
131786
131563
|
return;
|
|
@@ -132035,6 +131812,9 @@ var init_AS_large_literal = __esm({
|
|
|
132035
131812
|
}
|
|
132036
131813
|
visitStatement(node) {
|
|
132037
131814
|
switch (node.type) {
|
|
131815
|
+
case "FunctionDeclaration":
|
|
131816
|
+
this.visitArrowFunction(node);
|
|
131817
|
+
return;
|
|
132038
131818
|
case "BlockStatement":
|
|
132039
131819
|
this.visitBlockStatement(node);
|
|
132040
131820
|
return;
|
|
@@ -132153,6 +131933,12 @@ var init_AS_large_literal = __esm({
|
|
|
132153
131933
|
}
|
|
132154
131934
|
visitExpression(node) {
|
|
132155
131935
|
switch (node.type) {
|
|
131936
|
+
case "YieldExpression":
|
|
131937
|
+
if (node.argument !== void 0) {
|
|
131938
|
+
this.visitExpression(node.argument);
|
|
131939
|
+
}
|
|
131940
|
+
return;
|
|
131941
|
+
case "FunctionExpression":
|
|
132156
131942
|
case "ArrowFunctionExpression":
|
|
132157
131943
|
this.visitArrowFunction(node);
|
|
132158
131944
|
return;
|
|
@@ -132531,7 +132317,7 @@ var init_AS_missing_async = __esm({
|
|
|
132531
132317
|
"packages/safejs/src/lint/rules/AS-missing-async.ts"() {
|
|
132532
132318
|
"use strict";
|
|
132533
132319
|
init_parser3();
|
|
132534
|
-
AS_MISSING_ASYNC_MESSAGE = "
|
|
132320
|
+
AS_MISSING_ASYNC_MESSAGE = "Functions that contain await must be marked async.";
|
|
132535
132321
|
ASMissingAsyncScanner = class {
|
|
132536
132322
|
constructor(filename) {
|
|
132537
132323
|
this.filename = filename;
|
|
@@ -132549,6 +132335,9 @@ var init_AS_missing_async = __esm({
|
|
|
132549
132335
|
}
|
|
132550
132336
|
visitStatement(node) {
|
|
132551
132337
|
switch (node.type) {
|
|
132338
|
+
case "FunctionDeclaration":
|
|
132339
|
+
this.visitFunctionExpression(node);
|
|
132340
|
+
return;
|
|
132552
132341
|
case "BlockStatement":
|
|
132553
132342
|
this.visitBlockStatement(node);
|
|
132554
132343
|
return;
|
|
@@ -132668,6 +132457,11 @@ var init_AS_missing_async = __esm({
|
|
|
132668
132457
|
}
|
|
132669
132458
|
visitExpression(node) {
|
|
132670
132459
|
switch (node.type) {
|
|
132460
|
+
case "YieldExpression":
|
|
132461
|
+
if (node.argument !== void 0) {
|
|
132462
|
+
this.visitExpression(node.argument);
|
|
132463
|
+
}
|
|
132464
|
+
return;
|
|
132671
132465
|
case "ArrowFunctionExpression":
|
|
132672
132466
|
this.visitArrowFunction(node);
|
|
132673
132467
|
return;
|
|
@@ -132955,6 +132749,9 @@ var init_AS_mutating_frozen = __esm({
|
|
|
132955
132749
|
}
|
|
132956
132750
|
visitStatement(node) {
|
|
132957
132751
|
switch (node.type) {
|
|
132752
|
+
case "FunctionDeclaration":
|
|
132753
|
+
this.visitArrowFunction(node);
|
|
132754
|
+
return;
|
|
132958
132755
|
case "BlockStatement":
|
|
132959
132756
|
this.visitBlockStatement(node);
|
|
132960
132757
|
return;
|
|
@@ -133095,6 +132892,12 @@ var init_AS_mutating_frozen = __esm({
|
|
|
133095
132892
|
}
|
|
133096
132893
|
visitExpression(node) {
|
|
133097
132894
|
switch (node.type) {
|
|
132895
|
+
case "YieldExpression":
|
|
132896
|
+
if (node.argument !== void 0) {
|
|
132897
|
+
this.visitExpression(node.argument);
|
|
132898
|
+
}
|
|
132899
|
+
return;
|
|
132900
|
+
case "FunctionExpression":
|
|
133098
132901
|
case "ArrowFunctionExpression":
|
|
133099
132902
|
this.visitArrowFunction(node);
|
|
133100
132903
|
return;
|
|
@@ -133450,6 +133253,9 @@ var init_AS_needless_template = __esm({
|
|
|
133450
133253
|
}
|
|
133451
133254
|
visitStatement(node) {
|
|
133452
133255
|
switch (node.type) {
|
|
133256
|
+
case "FunctionDeclaration":
|
|
133257
|
+
this.visitArrowFunction(node);
|
|
133258
|
+
return;
|
|
133453
133259
|
case "BlockStatement":
|
|
133454
133260
|
this.visitBlockStatement(node);
|
|
133455
133261
|
return;
|
|
@@ -133571,6 +133377,12 @@ var init_AS_needless_template = __esm({
|
|
|
133571
133377
|
}
|
|
133572
133378
|
visitExpression(node) {
|
|
133573
133379
|
switch (node.type) {
|
|
133380
|
+
case "YieldExpression":
|
|
133381
|
+
if (node.argument !== void 0) {
|
|
133382
|
+
this.visitExpression(node.argument);
|
|
133383
|
+
}
|
|
133384
|
+
return;
|
|
133385
|
+
case "FunctionExpression":
|
|
133574
133386
|
case "ArrowFunctionExpression":
|
|
133575
133387
|
this.visitArrowFunction(node);
|
|
133576
133388
|
return;
|
|
@@ -133814,6 +133626,9 @@ var init_AS_shadow_global = __esm({
|
|
|
133814
133626
|
}
|
|
133815
133627
|
visitStatement(node) {
|
|
133816
133628
|
switch (node.type) {
|
|
133629
|
+
case "FunctionDeclaration":
|
|
133630
|
+
this.visitArrowFunctionExpression(node);
|
|
133631
|
+
return;
|
|
133817
133632
|
case "BlockStatement":
|
|
133818
133633
|
this.visitBlockStatement(node);
|
|
133819
133634
|
return;
|
|
@@ -133935,6 +133750,12 @@ var init_AS_shadow_global = __esm({
|
|
|
133935
133750
|
}
|
|
133936
133751
|
visitExpression(node) {
|
|
133937
133752
|
switch (node.type) {
|
|
133753
|
+
case "YieldExpression":
|
|
133754
|
+
if (node.argument !== void 0) {
|
|
133755
|
+
this.visitExpression(node.argument);
|
|
133756
|
+
}
|
|
133757
|
+
return;
|
|
133758
|
+
case "FunctionExpression":
|
|
133938
133759
|
case "ArrowFunctionExpression":
|
|
133939
133760
|
this.visitArrowFunctionExpression(node);
|
|
133940
133761
|
return;
|
|
@@ -133986,6 +133807,9 @@ var init_AS_shadow_global = __esm({
|
|
|
133986
133807
|
}
|
|
133987
133808
|
}
|
|
133988
133809
|
visitArrowFunctionExpression(node) {
|
|
133810
|
+
if (node.type !== "ArrowFunctionExpression" && node.id !== void 0) {
|
|
133811
|
+
this.reportIfGlobalShadow(node.id);
|
|
133812
|
+
}
|
|
133989
133813
|
for (const parameter of node.params) {
|
|
133990
133814
|
this.visitBindingElement(parameter);
|
|
133991
133815
|
}
|
|
@@ -134262,6 +134086,9 @@ var init_AS_unbounded_loop = __esm({
|
|
|
134262
134086
|
}
|
|
134263
134087
|
visitStatement(node) {
|
|
134264
134088
|
switch (node.type) {
|
|
134089
|
+
case "FunctionDeclaration":
|
|
134090
|
+
this.visitArrowFunction(node);
|
|
134091
|
+
return;
|
|
134265
134092
|
case "BlockStatement":
|
|
134266
134093
|
this.visitBlockStatement(node);
|
|
134267
134094
|
return;
|
|
@@ -134397,6 +134224,12 @@ var init_AS_unbounded_loop = __esm({
|
|
|
134397
134224
|
}
|
|
134398
134225
|
visitExpression(node) {
|
|
134399
134226
|
switch (node.type) {
|
|
134227
|
+
case "YieldExpression":
|
|
134228
|
+
if (node.argument !== void 0) {
|
|
134229
|
+
this.visitExpression(node.argument);
|
|
134230
|
+
}
|
|
134231
|
+
return;
|
|
134232
|
+
case "FunctionExpression":
|
|
134400
134233
|
case "ArrowFunctionExpression":
|
|
134401
134234
|
this.visitArrowFunction(node);
|
|
134402
134235
|
return;
|
|
@@ -134584,6 +134417,9 @@ var init_AS_unreachable = __esm({
|
|
|
134584
134417
|
}
|
|
134585
134418
|
visitStatement(node) {
|
|
134586
134419
|
switch (node.type) {
|
|
134420
|
+
case "FunctionDeclaration":
|
|
134421
|
+
this.visitArrowFunction(node);
|
|
134422
|
+
return false;
|
|
134587
134423
|
case "BlockStatement":
|
|
134588
134424
|
return this.visitBlock(node);
|
|
134589
134425
|
case "ExpressionStatement":
|
|
@@ -134628,7 +134464,6 @@ var init_AS_unreachable = __esm({
|
|
|
134628
134464
|
this.visitExpression(node.declaration);
|
|
134629
134465
|
return false;
|
|
134630
134466
|
case "ImportDeclaration":
|
|
134631
|
-
case "FunctionDeclaration":
|
|
134632
134467
|
case "EmptyStatement":
|
|
134633
134468
|
return false;
|
|
134634
134469
|
}
|
|
@@ -134708,6 +134543,12 @@ var init_AS_unreachable = __esm({
|
|
|
134708
134543
|
}
|
|
134709
134544
|
visitExpression(node) {
|
|
134710
134545
|
switch (node.type) {
|
|
134546
|
+
case "YieldExpression":
|
|
134547
|
+
if (node.argument !== void 0) {
|
|
134548
|
+
this.visitExpression(node.argument);
|
|
134549
|
+
}
|
|
134550
|
+
return;
|
|
134551
|
+
case "FunctionExpression":
|
|
134711
134552
|
case "ArrowFunctionExpression":
|
|
134712
134553
|
this.visitArrowFunction(node);
|
|
134713
134554
|
return;
|
|
@@ -134973,6 +134814,9 @@ var init_AS_unused_import = __esm({
|
|
|
134973
134814
|
}
|
|
134974
134815
|
visitStatement(node) {
|
|
134975
134816
|
switch (node.type) {
|
|
134817
|
+
case "FunctionDeclaration":
|
|
134818
|
+
this.visitArrowFunction(node);
|
|
134819
|
+
return;
|
|
134976
134820
|
case "ExportNamedDeclaration":
|
|
134977
134821
|
this.visitVariableDeclaration(node.declaration);
|
|
134978
134822
|
return;
|
|
@@ -135098,9 +134942,15 @@ var init_AS_unused_import = __esm({
|
|
|
135098
134942
|
}
|
|
135099
134943
|
visitExpression(node) {
|
|
135100
134944
|
switch (node.type) {
|
|
134945
|
+
case "YieldExpression":
|
|
134946
|
+
if (node.argument !== void 0) {
|
|
134947
|
+
this.visitExpression(node.argument);
|
|
134948
|
+
}
|
|
134949
|
+
return;
|
|
135101
134950
|
case "Identifier":
|
|
135102
134951
|
this.markRead(node);
|
|
135103
134952
|
return;
|
|
134953
|
+
case "FunctionExpression":
|
|
135104
134954
|
case "ArrowFunctionExpression":
|
|
135105
134955
|
this.visitArrowFunction(node);
|
|
135106
134956
|
return;
|
|
@@ -135333,6 +135183,10 @@ var init_AS_unused_import = __esm({
|
|
|
135333
135183
|
bindings.push(...this.collectImportBindings(statement));
|
|
135334
135184
|
continue;
|
|
135335
135185
|
}
|
|
135186
|
+
if (statement.type === "FunctionDeclaration") {
|
|
135187
|
+
bindings.push({ kind: "let", name: statement.id.name });
|
|
135188
|
+
continue;
|
|
135189
|
+
}
|
|
135336
135190
|
if (statement.type === "VariableDeclaration") {
|
|
135337
135191
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
135338
135192
|
continue;
|
|
@@ -135346,6 +135200,9 @@ var init_AS_unused_import = __esm({
|
|
|
135346
135200
|
collectBlockBindings(body) {
|
|
135347
135201
|
const bindings = [];
|
|
135348
135202
|
for (const statement of body) {
|
|
135203
|
+
if (statement.type === "FunctionDeclaration") {
|
|
135204
|
+
bindings.push({ kind: "let", name: statement.id.name });
|
|
135205
|
+
}
|
|
135349
135206
|
if (statement.type === "VariableDeclaration") {
|
|
135350
135207
|
bindings.push(...this.collectDeclarationBindings(statement));
|
|
135351
135208
|
}
|
|
@@ -135354,6 +135211,12 @@ var init_AS_unused_import = __esm({
|
|
|
135354
135211
|
}
|
|
135355
135212
|
collectParameterBindings(node) {
|
|
135356
135213
|
const bindings = [];
|
|
135214
|
+
if (node.type !== "ArrowFunctionExpression") {
|
|
135215
|
+
bindings.push({ kind: "param", name: "arguments" });
|
|
135216
|
+
if (node.type === "FunctionExpression" && node.id !== void 0) {
|
|
135217
|
+
bindings.push({ kind: "param", name: node.id.name });
|
|
135218
|
+
}
|
|
135219
|
+
}
|
|
135357
135220
|
for (const parameter of node.params) {
|
|
135358
135221
|
this.collectBindingNamesFromElement(parameter, "param", bindings);
|
|
135359
135222
|
}
|
|
@@ -135772,7 +135635,6 @@ var init_lint3 = __esm({
|
|
|
135772
135635
|
init_AS009();
|
|
135773
135636
|
init_AS010();
|
|
135774
135637
|
init_AS011();
|
|
135775
|
-
init_AS012();
|
|
135776
135638
|
init_AS013();
|
|
135777
135639
|
init_AS015();
|
|
135778
135640
|
init_AS_async_not_needed();
|
|
@@ -135805,7 +135667,6 @@ var init_lint3 = __esm({
|
|
|
135805
135667
|
AS009,
|
|
135806
135668
|
AS010,
|
|
135807
135669
|
AS011,
|
|
135808
|
-
AS012,
|
|
135809
135670
|
AS013,
|
|
135810
135671
|
AS015,
|
|
135811
135672
|
AS_IMPORT_CYCLE,
|
|
@@ -136193,6 +136054,57 @@ var init_budget2 = __esm({
|
|
|
136193
136054
|
}
|
|
136194
136055
|
});
|
|
136195
136056
|
|
|
136057
|
+
// packages/safejs/src/interp/arguments.ts
|
|
136058
|
+
function createSandboxArguments(values) {
|
|
136059
|
+
const result = /* @__PURE__ */ (function() {
|
|
136060
|
+
return arguments;
|
|
136061
|
+
})();
|
|
136062
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
136063
|
+
result[index] = values[index];
|
|
136064
|
+
}
|
|
136065
|
+
result.length = values.length;
|
|
136066
|
+
Object.defineProperty(result, sandboxArgumentsBrand, { value: true });
|
|
136067
|
+
return result;
|
|
136068
|
+
}
|
|
136069
|
+
function isSandboxArguments(value) {
|
|
136070
|
+
return typeof value === "object" && value !== null && Object.hasOwn(value, sandboxArgumentsBrand);
|
|
136071
|
+
}
|
|
136072
|
+
function getSandboxArgumentEntries(value) {
|
|
136073
|
+
return Object.entries(Object.getOwnPropertyDescriptors(value)).flatMap(
|
|
136074
|
+
([key3, descriptor]) => "value" in descriptor ? [[key3, descriptor.value]] : []
|
|
136075
|
+
);
|
|
136076
|
+
}
|
|
136077
|
+
function copySandboxArgumentProperties(source, target, copyValue) {
|
|
136078
|
+
const names = Object.getOwnPropertyNames(source);
|
|
136079
|
+
if (!names.includes("length") || names.indexOf("length") > names.indexOf("callee")) {
|
|
136080
|
+
Reflect.deleteProperty(target, "length");
|
|
136081
|
+
}
|
|
136082
|
+
for (const [key3, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(source))) {
|
|
136083
|
+
if (!("value" in descriptor)) {
|
|
136084
|
+
if (key3 !== "callee") throw new TypeError(`Cannot copy arguments accessor '${key3}'.`);
|
|
136085
|
+
continue;
|
|
136086
|
+
}
|
|
136087
|
+
Object.defineProperty(target, key3, { ...descriptor, value: copyValue(descriptor.value, key3) });
|
|
136088
|
+
}
|
|
136089
|
+
const iterator = Object.getOwnPropertyDescriptor(source, Symbol.iterator);
|
|
136090
|
+
if (iterator === void 0) {
|
|
136091
|
+
Reflect.deleteProperty(target, Symbol.iterator);
|
|
136092
|
+
} else {
|
|
136093
|
+
if (iterator.value !== Array.prototype.values) {
|
|
136094
|
+
throw new TypeError("Cannot copy a replaced arguments iterator.");
|
|
136095
|
+
}
|
|
136096
|
+
Object.defineProperty(target, Symbol.iterator, iterator);
|
|
136097
|
+
}
|
|
136098
|
+
if (!Object.isExtensible(source)) Object.preventExtensions(target);
|
|
136099
|
+
}
|
|
136100
|
+
var sandboxArgumentsBrand;
|
|
136101
|
+
var init_arguments = __esm({
|
|
136102
|
+
"packages/safejs/src/interp/arguments.ts"() {
|
|
136103
|
+
"use strict";
|
|
136104
|
+
sandboxArgumentsBrand = /* @__PURE__ */ Symbol("SandboxArguments");
|
|
136105
|
+
}
|
|
136106
|
+
});
|
|
136107
|
+
|
|
136196
136108
|
// packages/safejs/src/graph-depth.ts
|
|
136197
136109
|
function assertSandboxDataDepth(depth) {
|
|
136198
136110
|
if (depth > MAX_DATA_DEPTH) {
|
|
@@ -136235,6 +136147,9 @@ function walkGraphDepth(root, rootPath, assertDepth) {
|
|
|
136235
136147
|
}
|
|
136236
136148
|
}
|
|
136237
136149
|
function graphEntries(value) {
|
|
136150
|
+
if (isSandboxArguments(value)) {
|
|
136151
|
+
return getSandboxArgumentEntries(value).map(([key3, entry]) => [`.${key3}`, entry]);
|
|
136152
|
+
}
|
|
136238
136153
|
if (Array.isArray(value)) return value.map((entry, index) => [`[${index}]`, entry]);
|
|
136239
136154
|
if (value instanceof Map) {
|
|
136240
136155
|
return [...value.entries()].flatMap(([key3, entry], index) => [
|
|
@@ -136259,6 +136174,7 @@ var init_graph_depth = __esm({
|
|
|
136259
136174
|
"use strict";
|
|
136260
136175
|
init_shape();
|
|
136261
136176
|
init_budget2();
|
|
136177
|
+
init_arguments();
|
|
136262
136178
|
MAX_DATA_DEPTH = 1024;
|
|
136263
136179
|
SnapshotBudgetError = class extends Error {
|
|
136264
136180
|
code = "budgetExceeded";
|
|
@@ -136278,6 +136194,44 @@ var init_graph_depth = __esm({
|
|
|
136278
136194
|
}
|
|
136279
136195
|
});
|
|
136280
136196
|
|
|
136197
|
+
// packages/safejs/src/snapshot/arguments.ts
|
|
136198
|
+
function serializeArguments(value, serializeValue) {
|
|
136199
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
136200
|
+
for (const [key3, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
136201
|
+
if (!("value" in descriptor)) {
|
|
136202
|
+
if (key3 !== "callee") throw new TypeError(`Cannot snapshot arguments accessor '${key3}'.`);
|
|
136203
|
+
continue;
|
|
136204
|
+
}
|
|
136205
|
+
properties[key3] = {
|
|
136206
|
+
value: serializeValue(descriptor.value, key3),
|
|
136207
|
+
configurable: descriptor.configurable === true,
|
|
136208
|
+
enumerable: descriptor.enumerable === true,
|
|
136209
|
+
writable: descriptor.writable === true
|
|
136210
|
+
};
|
|
136211
|
+
}
|
|
136212
|
+
const iterator = Object.getOwnPropertyDescriptor(value, Symbol.iterator);
|
|
136213
|
+
if (iterator !== void 0 && iterator.value !== Array.prototype.values) {
|
|
136214
|
+
throw new TypeError("Cannot snapshot a replaced arguments iterator.");
|
|
136215
|
+
}
|
|
136216
|
+
const names = Object.getOwnPropertyNames(value);
|
|
136217
|
+
return {
|
|
136218
|
+
kind: "arguments",
|
|
136219
|
+
extensible: Object.isExtensible(value),
|
|
136220
|
+
lengthBeforeCallee: names.includes("length") && names.indexOf("length") < names.indexOf("callee"),
|
|
136221
|
+
iterator: iterator === void 0 ? null : {
|
|
136222
|
+
configurable: iterator.configurable === true,
|
|
136223
|
+
enumerable: iterator.enumerable === true,
|
|
136224
|
+
writable: iterator.writable === true
|
|
136225
|
+
},
|
|
136226
|
+
properties
|
|
136227
|
+
};
|
|
136228
|
+
}
|
|
136229
|
+
var init_arguments2 = __esm({
|
|
136230
|
+
"packages/safejs/src/snapshot/arguments.ts"() {
|
|
136231
|
+
"use strict";
|
|
136232
|
+
}
|
|
136233
|
+
});
|
|
136234
|
+
|
|
136281
136235
|
// packages/safejs/src/snapshot/dump-format.ts
|
|
136282
136236
|
function serializeSafeJSSnapshot(snapshot2) {
|
|
136283
136237
|
for (const [key3, value] of getEnumerableDataEntries(snapshot2)) {
|
|
@@ -136350,7 +136304,12 @@ function serializeHeapReference(value, path189, state) {
|
|
|
136350
136304
|
}
|
|
136351
136305
|
if (!state.serializedHeapIds.has(id)) {
|
|
136352
136306
|
state.serializedHeapIds.add(id);
|
|
136353
|
-
if (
|
|
136307
|
+
if (isSandboxArguments(value)) {
|
|
136308
|
+
state.heap[String(id)] = serializeArguments(value, (entry, key3) => {
|
|
136309
|
+
const serialized = serializeDumpValue(entry, `${path189}.${key3}`, state);
|
|
136310
|
+
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
136311
|
+
});
|
|
136312
|
+
} else if (Array.isArray(value)) {
|
|
136354
136313
|
state.heap[String(id)] = {
|
|
136355
136314
|
kind: "array",
|
|
136356
136315
|
items: serializeArrayItems(value, path189, state)
|
|
@@ -136389,7 +136348,7 @@ function indexHeapContainers(snapshot2) {
|
|
|
136389
136348
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
136390
136349
|
let nextId = 1;
|
|
136391
136350
|
for (const [value, stat36] of stats2.entries()) {
|
|
136392
|
-
if (stat36.count > 1 || stat36.cyclic) {
|
|
136351
|
+
if (stat36.count > 1 || stat36.cyclic || isSandboxArguments(value)) {
|
|
136393
136352
|
heapIds.set(value, nextId);
|
|
136394
136353
|
nextId += 1;
|
|
136395
136354
|
}
|
|
@@ -136422,7 +136381,7 @@ function collectContainerStats(value, stats2, ancestors) {
|
|
|
136422
136381
|
}
|
|
136423
136382
|
stat36.expanded = true;
|
|
136424
136383
|
ancestors.add(value);
|
|
136425
|
-
const entries = Array.isArray(value) ? getArrayDataItems(value) : getEnumerableDataValues(value);
|
|
136384
|
+
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : Array.isArray(value) ? getArrayDataItems(value) : getEnumerableDataValues(value);
|
|
136426
136385
|
for (const entry of entries) {
|
|
136427
136386
|
collectContainerStats(entry, stats2, ancestors);
|
|
136428
136387
|
}
|
|
@@ -136464,6 +136423,8 @@ var init_dump_format = __esm({
|
|
|
136464
136423
|
"packages/safejs/src/snapshot/dump-format.ts"() {
|
|
136465
136424
|
"use strict";
|
|
136466
136425
|
init_graph_depth();
|
|
136426
|
+
init_arguments();
|
|
136427
|
+
init_arguments2();
|
|
136467
136428
|
DUMP_FORMAT_VERSION = 1;
|
|
136468
136429
|
SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
|
|
136469
136430
|
}
|
|
@@ -136497,6 +136458,10 @@ function validateDumpHeap(root, state) {
|
|
|
136497
136458
|
const id = parseHeapId(key3, path189);
|
|
136498
136459
|
addUnique2(heapIds, id, path189);
|
|
136499
136460
|
const entry = requireRecord3(value, path189);
|
|
136461
|
+
if (entry.kind === "arguments") {
|
|
136462
|
+
validateArgumentsProperties(entry, path189);
|
|
136463
|
+
continue;
|
|
136464
|
+
}
|
|
136500
136465
|
if (entry.kind === "array") {
|
|
136501
136466
|
requireArray(entry.items, `${path189}.items`, state);
|
|
136502
136467
|
continue;
|
|
@@ -136601,6 +136566,7 @@ function validateTaggedValue(record, path189, state) {
|
|
|
136601
136566
|
requireSafeInteger(record.lastIndex, `${path189}.lastIndex`, 0);
|
|
136602
136567
|
return;
|
|
136603
136568
|
case "array":
|
|
136569
|
+
case "arguments":
|
|
136604
136570
|
case "object":
|
|
136605
136571
|
case "map":
|
|
136606
136572
|
case "set":
|
|
@@ -136641,6 +136607,55 @@ function validateGeneratorShape(record, path189, state) {
|
|
|
136641
136607
|
}
|
|
136642
136608
|
});
|
|
136643
136609
|
}
|
|
136610
|
+
function validateArgumentsProperties(record, path189) {
|
|
136611
|
+
if (typeof record.extensible !== "boolean") {
|
|
136612
|
+
fail2("invalidType", `${path189}.extensible`, "expected boolean");
|
|
136613
|
+
}
|
|
136614
|
+
if (typeof record.lengthBeforeCallee !== "boolean") {
|
|
136615
|
+
fail2("invalidType", `${path189}.lengthBeforeCallee`, "expected boolean");
|
|
136616
|
+
}
|
|
136617
|
+
const properties = requireRecord3(record.properties, `${path189}.properties`);
|
|
136618
|
+
if (record.iterator !== null) {
|
|
136619
|
+
const iterator = requireRecord3(record.iterator, `${path189}.iterator`);
|
|
136620
|
+
for (const key3 of Object.keys(iterator)) {
|
|
136621
|
+
if (!["configurable", "enumerable", "writable"].includes(key3)) {
|
|
136622
|
+
fail2(
|
|
136623
|
+
"invalidValue",
|
|
136624
|
+
`${path189}.iterator${formatKey(key3)}`,
|
|
136625
|
+
"unknown iterator descriptor field"
|
|
136626
|
+
);
|
|
136627
|
+
}
|
|
136628
|
+
}
|
|
136629
|
+
for (const flag of ["configurable", "enumerable", "writable"]) {
|
|
136630
|
+
if (typeof iterator[flag] !== "boolean")
|
|
136631
|
+
fail2("invalidType", `${path189}.iterator.${flag}`, "expected boolean");
|
|
136632
|
+
}
|
|
136633
|
+
}
|
|
136634
|
+
if (record.lengthBeforeCallee && !Object.hasOwn(properties, "length")) {
|
|
136635
|
+
fail2("invalidValue", `${path189}.properties`, "initial length property is required");
|
|
136636
|
+
}
|
|
136637
|
+
for (const [key3, value] of Object.entries(properties)) {
|
|
136638
|
+
const propertyPath = `${path189}.properties${formatKey(key3)}`;
|
|
136639
|
+
if (key3 === "callee")
|
|
136640
|
+
fail2("invalidValue", propertyPath, "strict callee accessor cannot be replaced");
|
|
136641
|
+
const descriptor = requireRecord3(value, propertyPath);
|
|
136642
|
+
for (const field of Object.keys(descriptor)) {
|
|
136643
|
+
if (!["value", "configurable", "enumerable", "writable"].includes(field)) {
|
|
136644
|
+
fail2(
|
|
136645
|
+
"invalidValue",
|
|
136646
|
+
`${propertyPath}${formatKey(field)}`,
|
|
136647
|
+
"unknown property descriptor field"
|
|
136648
|
+
);
|
|
136649
|
+
}
|
|
136650
|
+
}
|
|
136651
|
+
if (!Object.hasOwn(descriptor, "value"))
|
|
136652
|
+
fail2("invalidValue", propertyPath, "property value is required");
|
|
136653
|
+
for (const flag of ["configurable", "enumerable", "writable"]) {
|
|
136654
|
+
if (typeof descriptor[flag] !== "boolean")
|
|
136655
|
+
fail2("invalidType", `${propertyPath}.${flag}`, "expected boolean");
|
|
136656
|
+
}
|
|
136657
|
+
}
|
|
136658
|
+
}
|
|
136644
136659
|
function validateGenericValue(value, path189, depth, state) {
|
|
136645
136660
|
if (depth > state.limits.maxDepth)
|
|
136646
136661
|
fail2("budgetExceeded", path189, `exceeds nesting limit ${state.limits.maxDepth}`);
|
|
@@ -136752,6 +136767,7 @@ var init_validation = __esm({
|
|
|
136752
136767
|
DEFAULT_MAX_STRING_LENGTH = 1e6;
|
|
136753
136768
|
DEFAULT_MAX_DATA_SIZE = 16e6;
|
|
136754
136769
|
TAGGED_VALUE_KINDS = /* @__PURE__ */ new Set([
|
|
136770
|
+
"arguments",
|
|
136755
136771
|
"array",
|
|
136756
136772
|
"fn",
|
|
136757
136773
|
"generator",
|
|
@@ -137214,7 +137230,7 @@ function measureSandboxData(values) {
|
|
|
137214
137230
|
usage += value.source.length + value.flags.length;
|
|
137215
137231
|
return;
|
|
137216
137232
|
}
|
|
137217
|
-
const entries = Object.entries(value);
|
|
137233
|
+
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value) : Object.entries(value);
|
|
137218
137234
|
usage += entries.length;
|
|
137219
137235
|
for (const [key3, entry] of entries) {
|
|
137220
137236
|
usage += key3.length;
|
|
@@ -137331,6 +137347,18 @@ function copyToSandbox(value, state, path189 = "<root>", cloneSandboxCollections
|
|
|
137331
137347
|
}
|
|
137332
137348
|
return copy;
|
|
137333
137349
|
}
|
|
137350
|
+
if (isSandboxArguments(value)) {
|
|
137351
|
+
const existing = state.seen.get(value);
|
|
137352
|
+
if (existing !== void 0) return existing;
|
|
137353
|
+
const copy = createSandboxArguments([]);
|
|
137354
|
+
state.seen.set(value, copy);
|
|
137355
|
+
copySandboxArgumentProperties(
|
|
137356
|
+
value,
|
|
137357
|
+
copy,
|
|
137358
|
+
(entry, key3) => copyToSandbox(entry, state, joinPath(path189, key3), cloneSandboxCollections, depth + 1)
|
|
137359
|
+
);
|
|
137360
|
+
return copy;
|
|
137361
|
+
}
|
|
137334
137362
|
if (isPlainObject10(value)) {
|
|
137335
137363
|
const existing = state.seen.get(value);
|
|
137336
137364
|
if (existing !== void 0) {
|
|
@@ -137433,6 +137461,18 @@ function copyFromSandbox(value, state, path189 = "<root>", options, depth = 0) {
|
|
|
137433
137461
|
}
|
|
137434
137462
|
return copy;
|
|
137435
137463
|
}
|
|
137464
|
+
if (isSandboxArguments(value)) {
|
|
137465
|
+
const existing = state.seen.get(value);
|
|
137466
|
+
if (existing !== void 0) return existing;
|
|
137467
|
+
const copy = createSandboxArguments([]);
|
|
137468
|
+
state.seen.set(value, copy);
|
|
137469
|
+
copySandboxArgumentProperties(
|
|
137470
|
+
value,
|
|
137471
|
+
copy,
|
|
137472
|
+
(entry, key3) => copyFromSandbox(entry, state, joinPath(path189, key3), options, depth + 1)
|
|
137473
|
+
);
|
|
137474
|
+
return copy;
|
|
137475
|
+
}
|
|
137436
137476
|
if (isPlainObject10(value)) {
|
|
137437
137477
|
const existing = state.seen.get(value);
|
|
137438
137478
|
if (existing !== void 0) {
|
|
@@ -137503,7 +137543,8 @@ function allocateSandboxValue(value, budget, seen) {
|
|
|
137503
137543
|
return;
|
|
137504
137544
|
}
|
|
137505
137545
|
seen.add(value);
|
|
137506
|
-
|
|
137546
|
+
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : Object.values(value);
|
|
137547
|
+
for (const entry of entries) {
|
|
137507
137548
|
allocateSandboxValue(entry, budget, seen);
|
|
137508
137549
|
}
|
|
137509
137550
|
}
|
|
@@ -137598,6 +137639,8 @@ var init_values = __esm({
|
|
|
137598
137639
|
init_promise_tracker();
|
|
137599
137640
|
init_parse5();
|
|
137600
137641
|
init_graph_depth();
|
|
137642
|
+
init_arguments();
|
|
137643
|
+
init_arguments();
|
|
137601
137644
|
sandboxClosureBrand = /* @__PURE__ */ Symbol("SandboxClosure");
|
|
137602
137645
|
sandboxGeneratorBrand = /* @__PURE__ */ Symbol("SandboxGenerator");
|
|
137603
137646
|
sandboxMapBrand = /* @__PURE__ */ Symbol("SandboxMap");
|
|
@@ -140400,6 +140443,8 @@ async function createClosureScope(node, args, thisValue, context, evaluateNode3)
|
|
|
140400
140443
|
const scope = context.scope.child({}, { functionBoundary: true });
|
|
140401
140444
|
if (node.type !== "ArrowFunctionExpression") {
|
|
140402
140445
|
scope.declare("this", "const", thisValue);
|
|
140446
|
+
context.budget.allocateArrayLength(args.length);
|
|
140447
|
+
scope.declare("arguments", "let", createSandboxArguments(args));
|
|
140403
140448
|
}
|
|
140404
140449
|
await bindParameters(node.params, args, scope, context, evaluateNode3);
|
|
140405
140450
|
hoistVarDeclarations(node.body, scope);
|
|
@@ -145910,6 +145955,7 @@ var init_serialize = __esm({
|
|
|
145910
145955
|
"use strict";
|
|
145911
145956
|
init_hash();
|
|
145912
145957
|
init_graph_depth();
|
|
145958
|
+
init_arguments2();
|
|
145913
145959
|
init_values();
|
|
145914
145960
|
UnsnapshotableValueError = class extends Error {
|
|
145915
145961
|
path;
|
|
@@ -152180,7 +152226,7 @@ var init_package2 = __esm({
|
|
|
152180
152226
|
"package.json"() {
|
|
152181
152227
|
package_default2 = {
|
|
152182
152228
|
name: "poe-code",
|
|
152183
|
-
version: "4.0.
|
|
152229
|
+
version: "4.0.59",
|
|
152184
152230
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
152185
152231
|
license: "MIT",
|
|
152186
152232
|
type: "module",
|
|
@@ -152655,7 +152701,8 @@ function formatHelpText(input) {
|
|
|
152655
152701
|
`${text.muted("Run")} ${text.usageCommand(input.helpCommand)} ${text.muted("for command options.")}`,
|
|
152656
152702
|
"",
|
|
152657
152703
|
`${text.muted("Learn more about Poe:")} ${text.link("https://poe.com/api")}`,
|
|
152658
|
-
`${text.muted("GitHub:")} ${text.link("https://github.com/poe-platform/poe-code")}
|
|
152704
|
+
`${text.muted("GitHub:")} ${text.link("https://github.com/poe-platform/poe-code")}`,
|
|
152705
|
+
""
|
|
152659
152706
|
].join("\n");
|
|
152660
152707
|
}
|
|
152661
152708
|
function formatSubcommandHelp(cmd, helper) {
|