@delance/builder 0.3.1 → 0.3.4
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/README.md +1 -1
- package/dist/index.js +199 -38
- package/package.json +28 -28
- package/types.d.ts +0 -4
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[][npm]
|
|
2
2
|
[][license]
|
|
3
3
|
[][builds]
|
|
4
|
-

|
|
5
5
|
|
|
6
6
|
@delance/builder
|
|
7
7
|
================
|
package/dist/index.js
CHANGED
|
@@ -27,13 +27,13 @@ var __export = (target, all) => {
|
|
|
27
27
|
};
|
|
28
28
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
29
29
|
|
|
30
|
-
//
|
|
30
|
+
// babel-import:@babel/generator
|
|
31
31
|
var require_generator = __commonJS((exports, module) => {
|
|
32
32
|
var m = __require("@babel/generator/lib/index.js");
|
|
33
33
|
module.exports = m.default ?? m;
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// babel-import:@babel/traverse
|
|
37
37
|
var require_traverse = __commonJS((exports, module) => {
|
|
38
38
|
var m = __require("@babel/traverse/lib/index.js");
|
|
39
39
|
module.exports = m.default ?? m;
|
|
@@ -101,10 +101,10 @@ function codePreview(node) {
|
|
|
101
101
|
var import_traverse3 = __toESM(require_traverse(), 1);
|
|
102
102
|
import * as t14 from "@babel/types";
|
|
103
103
|
|
|
104
|
-
// node_modules
|
|
104
|
+
// node_modules/@codemod/matchers/dist/matchers/anyExpression.js
|
|
105
105
|
import * as t2 from "@babel/types";
|
|
106
106
|
|
|
107
|
-
// node_modules
|
|
107
|
+
// node_modules/@codemod/matchers/dist/matchers/Matcher.js
|
|
108
108
|
class Matcher {
|
|
109
109
|
match(value, keys = []) {
|
|
110
110
|
return this.matchValue(value, keys);
|
|
@@ -114,7 +114,7 @@ class Matcher {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
// node_modules
|
|
117
|
+
// node_modules/@codemod/matchers/dist/matchers/anyExpression.js
|
|
118
118
|
class AnyExpressionMatcher extends Matcher {
|
|
119
119
|
matchValue(value) {
|
|
120
120
|
return t2.isNode(value) && t2.isExpression(value);
|
|
@@ -123,7 +123,7 @@ class AnyExpressionMatcher extends Matcher {
|
|
|
123
123
|
function anyExpression() {
|
|
124
124
|
return new AnyExpressionMatcher;
|
|
125
125
|
}
|
|
126
|
-
// node_modules
|
|
126
|
+
// node_modules/@codemod/matchers/dist/utils/distributeAcrossSlices.js
|
|
127
127
|
function* distributeAcrossSlices(slices, available) {
|
|
128
128
|
if (slices.length === 0) {
|
|
129
129
|
yield [];
|
|
@@ -143,7 +143,7 @@ function* distributeAcrossSlices(slices, available) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// node_modules
|
|
146
|
+
// node_modules/@codemod/matchers/dist/matchers/anything.js
|
|
147
147
|
class AnythingMatcher extends Matcher {
|
|
148
148
|
matchValue(value) {
|
|
149
149
|
return true;
|
|
@@ -153,7 +153,7 @@ function anything() {
|
|
|
153
153
|
return new AnythingMatcher;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
// node_modules
|
|
156
|
+
// node_modules/@codemod/matchers/dist/matchers/slice.js
|
|
157
157
|
class SliceMatcher extends Matcher {
|
|
158
158
|
min;
|
|
159
159
|
max;
|
|
@@ -192,7 +192,7 @@ function slice(optionsOrLength, matcherOrUndefined) {
|
|
|
192
192
|
return new SliceMatcher(min, max, matcher);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
// node_modules
|
|
195
|
+
// node_modules/@codemod/matchers/dist/matchers/anyList.js
|
|
196
196
|
class AnyListMatcher extends Matcher {
|
|
197
197
|
matchers;
|
|
198
198
|
sliceMatchers = [];
|
|
@@ -249,11 +249,11 @@ class AnyListMatcher extends Matcher {
|
|
|
249
249
|
function anyList(...elements) {
|
|
250
250
|
return new AnyListMatcher(elements);
|
|
251
251
|
}
|
|
252
|
-
// node_modules
|
|
252
|
+
// node_modules/@codemod/matchers/dist/matchers/anyNode.js
|
|
253
253
|
import * as t3 from "@babel/types";
|
|
254
|
-
// node_modules
|
|
254
|
+
// node_modules/@codemod/matchers/dist/matchers/anyStatement.js
|
|
255
255
|
import * as t4 from "@babel/types";
|
|
256
|
-
// node_modules
|
|
256
|
+
// node_modules/@codemod/matchers/dist/matchers/anyString.js
|
|
257
257
|
class StringMatcher extends Matcher {
|
|
258
258
|
matchValue(value) {
|
|
259
259
|
return typeof value === "string" || value instanceof String;
|
|
@@ -262,7 +262,7 @@ class StringMatcher extends Matcher {
|
|
|
262
262
|
function anyString() {
|
|
263
263
|
return new StringMatcher;
|
|
264
264
|
}
|
|
265
|
-
// node_modules
|
|
265
|
+
// node_modules/@codemod/matchers/dist/matchers/arrayOf.js
|
|
266
266
|
class ArrayOfMatcher extends Matcher {
|
|
267
267
|
elementMatcher;
|
|
268
268
|
constructor(elementMatcher) {
|
|
@@ -284,7 +284,7 @@ class ArrayOfMatcher extends Matcher {
|
|
|
284
284
|
function arrayOf(elementMatcher) {
|
|
285
285
|
return new ArrayOfMatcher(elementMatcher);
|
|
286
286
|
}
|
|
287
|
-
// node_modules
|
|
287
|
+
// node_modules/@codemod/matchers/dist/matchers/capture.js
|
|
288
288
|
class CapturedMatcher extends Matcher {
|
|
289
289
|
matcher;
|
|
290
290
|
_current;
|
|
@@ -315,7 +315,7 @@ class CapturedMatcher extends Matcher {
|
|
|
315
315
|
function capture(matcher) {
|
|
316
316
|
return new CapturedMatcher(matcher);
|
|
317
317
|
}
|
|
318
|
-
// node_modules
|
|
318
|
+
// node_modules/@codemod/matchers/dist/matchers/containerOf.js
|
|
319
319
|
import * as t5 from "@babel/types";
|
|
320
320
|
class ContainerOfMatcher extends CapturedMatcher {
|
|
321
321
|
containedMatcher;
|
|
@@ -349,18 +349,18 @@ class ContainerOfMatcher extends CapturedMatcher {
|
|
|
349
349
|
function containerOf(containedMatcher) {
|
|
350
350
|
return new ContainerOfMatcher(containedMatcher);
|
|
351
351
|
}
|
|
352
|
-
// node_modules
|
|
352
|
+
// node_modules/@codemod-esm/utils/dist/index.js
|
|
353
353
|
import * as Babel from "@babel/core";
|
|
354
354
|
import * as t10 from "@babel/types";
|
|
355
355
|
|
|
356
|
-
// node_modules
|
|
356
|
+
// node_modules/@codemod-esm/utils/dist/builders.js
|
|
357
357
|
var import_traverse2 = __toESM(require_traverse(), 1);
|
|
358
358
|
import * as t6 from "@babel/types";
|
|
359
359
|
|
|
360
|
-
// node_modules
|
|
360
|
+
// node_modules/@codemod-esm/parser/dist/index.js
|
|
361
361
|
import { parse as babelParse2 } from "@babel/parser";
|
|
362
362
|
|
|
363
|
-
// node_modules
|
|
363
|
+
// node_modules/@codemod-esm/parser/dist/options.js
|
|
364
364
|
var DefaultParserPlugins = new Set([
|
|
365
365
|
"asyncGenerators",
|
|
366
366
|
"bigInt",
|
|
@@ -390,13 +390,13 @@ var DefaultParserPlugins = new Set([
|
|
|
390
390
|
["pipelineOperator", { proposal: "minimal" }],
|
|
391
391
|
["recordAndTuple", { syntaxType: "hash" }]
|
|
392
392
|
]);
|
|
393
|
-
// node_modules
|
|
393
|
+
// node_modules/@codemod-esm/utils/dist/js.js
|
|
394
394
|
import * as t8 from "@babel/types";
|
|
395
395
|
|
|
396
|
-
// node_modules
|
|
396
|
+
// node_modules/@codemod-esm/utils/dist/NodeTypes.js
|
|
397
397
|
import * as t7 from "@babel/types";
|
|
398
398
|
var { BUILDER_KEYS, NODE_FIELDS } = t7;
|
|
399
|
-
// node_modules
|
|
399
|
+
// node_modules/@codemod-esm/utils/dist/nodesEquivalent.js
|
|
400
400
|
import * as t9 from "@babel/types";
|
|
401
401
|
function nodesEquivalent(a, b) {
|
|
402
402
|
if (a === b) {
|
|
@@ -442,7 +442,7 @@ function nodesEquivalent(a, b) {
|
|
|
442
442
|
}
|
|
443
443
|
return true;
|
|
444
444
|
}
|
|
445
|
-
// node_modules
|
|
445
|
+
// node_modules/@codemod/matchers/dist/matchers/fromCapture.js
|
|
446
446
|
class FromCaptureMatcher extends Matcher {
|
|
447
447
|
capturedMatcher;
|
|
448
448
|
constructor(capturedMatcher) {
|
|
@@ -459,10 +459,10 @@ class FromCaptureMatcher extends Matcher {
|
|
|
459
459
|
function fromCapture(capturedMatcher) {
|
|
460
460
|
return new FromCaptureMatcher(capturedMatcher);
|
|
461
461
|
}
|
|
462
|
-
// node_modules
|
|
462
|
+
// node_modules/@codemod/matchers/dist/matchers/function.js
|
|
463
463
|
import * as t11 from "@babel/types";
|
|
464
464
|
|
|
465
|
-
// node_modules
|
|
465
|
+
// node_modules/@codemod/matchers/dist/matchers/tupleOf.js
|
|
466
466
|
class TupleOfMatcher extends Matcher {
|
|
467
467
|
matchers;
|
|
468
468
|
constructor(...matchers) {
|
|
@@ -489,7 +489,39 @@ class TupleOfMatcher extends Matcher {
|
|
|
489
489
|
function tupleOf(...matchers) {
|
|
490
490
|
return new TupleOfMatcher(...matchers);
|
|
491
491
|
}
|
|
492
|
-
|
|
492
|
+
|
|
493
|
+
// node_modules/@codemod/matchers/dist/matchers/function.js
|
|
494
|
+
class FunctionMatcher extends Matcher {
|
|
495
|
+
params;
|
|
496
|
+
body;
|
|
497
|
+
constructor(params, body) {
|
|
498
|
+
super();
|
|
499
|
+
this.params = params;
|
|
500
|
+
this.body = body;
|
|
501
|
+
}
|
|
502
|
+
matchValue(value, keys) {
|
|
503
|
+
if (!t11.isNode(value) || !t11.isFunction(value)) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
if (this.params) {
|
|
507
|
+
if (Array.isArray(this.params)) {
|
|
508
|
+
if (!tupleOf(...this.params).matchValue(value.params, [...keys, "params"])) {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
} else if (!this.params.matchValue(value.params, [...keys, "params"])) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (this.body && !this.body.matchValue(value.body, [...keys, "body"])) {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
return true;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function Function(params, body) {
|
|
522
|
+
return new FunctionMatcher(params, body);
|
|
523
|
+
}
|
|
524
|
+
// node_modules/@codemod/matchers/dist/matchers/generated.js
|
|
493
525
|
import * as t12 from "@babel/types";
|
|
494
526
|
class ArrayExpressionMatcher extends Matcher {
|
|
495
527
|
elements;
|
|
@@ -782,6 +814,30 @@ class CallExpressionMatcher extends Matcher {
|
|
|
782
814
|
function callExpression(callee, _arguments) {
|
|
783
815
|
return new CallExpressionMatcher(callee, _arguments);
|
|
784
816
|
}
|
|
817
|
+
class ClassBodyMatcher extends Matcher {
|
|
818
|
+
body;
|
|
819
|
+
constructor(body) {
|
|
820
|
+
super();
|
|
821
|
+
this.body = body;
|
|
822
|
+
}
|
|
823
|
+
matchValue(node, keys) {
|
|
824
|
+
if (!t12.isNode(node) || !t12.isClassBody(node)) {
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
if (typeof this.body === "undefined") {
|
|
828
|
+
} else if (Array.isArray(this.body)) {
|
|
829
|
+
if (!tupleOf(...this.body).matchValue(node.body, [...keys, "body"])) {
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
833
|
+
return false;
|
|
834
|
+
}
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function classBody(body) {
|
|
839
|
+
return new ClassBodyMatcher(body);
|
|
840
|
+
}
|
|
785
841
|
class ClassMethodMatcher extends Matcher {
|
|
786
842
|
kind;
|
|
787
843
|
key;
|
|
@@ -1009,6 +1065,32 @@ class ContinueStatementMatcher extends Matcher {
|
|
|
1009
1065
|
function continueStatement(label) {
|
|
1010
1066
|
return new ContinueStatementMatcher(label);
|
|
1011
1067
|
}
|
|
1068
|
+
class DoWhileStatementMatcher extends Matcher {
|
|
1069
|
+
test;
|
|
1070
|
+
body;
|
|
1071
|
+
constructor(test, body) {
|
|
1072
|
+
super();
|
|
1073
|
+
this.test = test;
|
|
1074
|
+
this.body = body;
|
|
1075
|
+
}
|
|
1076
|
+
matchValue(node, keys) {
|
|
1077
|
+
if (!t12.isNode(node) || !t12.isDoWhileStatement(node)) {
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
1080
|
+
if (typeof this.test === "undefined") {
|
|
1081
|
+
} else if (!this.test.matchValue(node.test, [...keys, "test"])) {
|
|
1082
|
+
return false;
|
|
1083
|
+
}
|
|
1084
|
+
if (typeof this.body === "undefined") {
|
|
1085
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1088
|
+
return true;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function doWhileStatement(test, body) {
|
|
1092
|
+
return new DoWhileStatementMatcher(test, body);
|
|
1093
|
+
}
|
|
1012
1094
|
class ExpressionStatementMatcher extends Matcher {
|
|
1013
1095
|
expression;
|
|
1014
1096
|
constructor(expression) {
|
|
@@ -1061,6 +1143,50 @@ class ForInStatementMatcher extends Matcher {
|
|
|
1061
1143
|
function forInStatement(left, right, body) {
|
|
1062
1144
|
return new ForInStatementMatcher(left, right, body);
|
|
1063
1145
|
}
|
|
1146
|
+
|
|
1147
|
+
class ForOfStatementMatcher extends Matcher {
|
|
1148
|
+
left;
|
|
1149
|
+
right;
|
|
1150
|
+
body;
|
|
1151
|
+
_await;
|
|
1152
|
+
constructor(left, right, body, _await) {
|
|
1153
|
+
super();
|
|
1154
|
+
this.left = left;
|
|
1155
|
+
this.right = right;
|
|
1156
|
+
this.body = body;
|
|
1157
|
+
this._await = _await;
|
|
1158
|
+
}
|
|
1159
|
+
matchValue(node, keys) {
|
|
1160
|
+
if (!t12.isNode(node) || !t12.isForOfStatement(node)) {
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1163
|
+
if (typeof this.left === "undefined") {
|
|
1164
|
+
} else if (!this.left.matchValue(node.left, [...keys, "left"])) {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
if (typeof this.right === "undefined") {
|
|
1168
|
+
} else if (!this.right.matchValue(node.right, [...keys, "right"])) {
|
|
1169
|
+
return false;
|
|
1170
|
+
}
|
|
1171
|
+
if (typeof this.body === "undefined") {
|
|
1172
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1173
|
+
return false;
|
|
1174
|
+
}
|
|
1175
|
+
if (typeof this._await === "undefined") {
|
|
1176
|
+
} else if (typeof this._await === "boolean") {
|
|
1177
|
+
if (this._await !== node.await) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
} else if (!this._await.matchValue(node.await, [...keys, "await"])) {
|
|
1181
|
+
return false;
|
|
1182
|
+
}
|
|
1183
|
+
return true;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
function forOfStatement(left, right, body, _await) {
|
|
1187
|
+
return new ForOfStatementMatcher(left, right, body, _await);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1064
1190
|
class ForStatementMatcher extends Matcher {
|
|
1065
1191
|
init;
|
|
1066
1192
|
test;
|
|
@@ -2135,7 +2261,7 @@ class WhileStatementMatcher extends Matcher {
|
|
|
2135
2261
|
function whileStatement(test, body) {
|
|
2136
2262
|
return new WhileStatementMatcher(test, body);
|
|
2137
2263
|
}
|
|
2138
|
-
// node_modules
|
|
2264
|
+
// node_modules/@codemod/matchers/dist/matchers/or.js
|
|
2139
2265
|
class OrMatcher extends Matcher {
|
|
2140
2266
|
matchersOrValues;
|
|
2141
2267
|
constructor(...matchersOrValues) {
|
|
@@ -2158,7 +2284,7 @@ class OrMatcher extends Matcher {
|
|
|
2158
2284
|
function or(...matchersOrValues) {
|
|
2159
2285
|
return new OrMatcher(...matchersOrValues);
|
|
2160
2286
|
}
|
|
2161
|
-
// node_modules
|
|
2287
|
+
// node_modules/@codemod/matchers/dist/matchers/predicate.js
|
|
2162
2288
|
class PredicateMatcher extends Matcher {
|
|
2163
2289
|
predicate;
|
|
2164
2290
|
constructor(predicate) {
|
|
@@ -2210,7 +2336,8 @@ function isReadonlyObject(binding, memberAccess) {
|
|
|
2210
2336
|
if (!binding.constant && binding.constantViolations[0] !== binding.path)
|
|
2211
2337
|
return false;
|
|
2212
2338
|
function isPatternAssignment(member) {
|
|
2213
|
-
|
|
2339
|
+
const { parentPath } = member;
|
|
2340
|
+
return parentPath?.isArrayPattern() || parentPath?.parentPath?.isObjectPattern() && (parentPath.isObjectProperty({ value: member.node }) || parentPath.isRestElement()) || parentPath?.isAssignmentPattern({ left: member.node });
|
|
2214
2341
|
}
|
|
2215
2342
|
return binding.referencePaths.every((path) => memberAccess.match(path.parent) && !path.parentPath?.parentPath?.isAssignmentExpression({
|
|
2216
2343
|
left: path.parent
|
|
@@ -2225,6 +2352,34 @@ function isTemporaryVariable(binding, references, kind = "var") {
|
|
|
2225
2352
|
return binding !== undefined && binding.references === references && binding.constantViolations.length === 1 && (kind === "var" ? binding.path.isVariableDeclarator() && binding.path.node.init === null : binding.path.listKey === "params" && binding.path.isIdentifier());
|
|
2226
2353
|
}
|
|
2227
2354
|
|
|
2355
|
+
class AnySubListMatcher extends Matcher {
|
|
2356
|
+
matchers;
|
|
2357
|
+
constructor(matchers2) {
|
|
2358
|
+
super();
|
|
2359
|
+
this.matchers = matchers2;
|
|
2360
|
+
}
|
|
2361
|
+
matchValue(array, keys) {
|
|
2362
|
+
if (!Array.isArray(array))
|
|
2363
|
+
return false;
|
|
2364
|
+
if (this.matchers.length === 0 && array.length === 0)
|
|
2365
|
+
return true;
|
|
2366
|
+
let j = 0;
|
|
2367
|
+
for (let i = 0;i < array.length; i++) {
|
|
2368
|
+
const matches = this.matchers[j].matchValue(array[i], [...keys, i]);
|
|
2369
|
+
if (matches) {
|
|
2370
|
+
j++;
|
|
2371
|
+
if (j === this.matchers.length) {
|
|
2372
|
+
return true;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
return false;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
function anySubList(...elements) {
|
|
2380
|
+
return new AnySubListMatcher(elements);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2228
2383
|
// webcrack/ast-utils/inline.js
|
|
2229
2384
|
function inlineVariable(binding, value = anyExpression(), unsafeAssignments = false) {
|
|
2230
2385
|
const varDeclarator = binding.path.node;
|
|
@@ -2287,7 +2442,7 @@ function inlineObjectProperties(binding, property = objectProperty()) {
|
|
|
2287
2442
|
});
|
|
2288
2443
|
binding.path.remove();
|
|
2289
2444
|
}
|
|
2290
|
-
function
|
|
2445
|
+
function inlineFunctionCall(fn, caller) {
|
|
2291
2446
|
if (t14.isRestElement(fn.params[1])) {
|
|
2292
2447
|
caller.replaceWith(t14.callExpression(caller.node.arguments[0], caller.node.arguments.slice(1)));
|
|
2293
2448
|
return;
|
|
@@ -2298,7 +2453,7 @@ function inlineFunction(fn, caller) {
|
|
|
2298
2453
|
Identifier(path) {
|
|
2299
2454
|
const paramIndex = fn.params.findIndex((p) => p.name === path.node.name);
|
|
2300
2455
|
if (paramIndex !== -1) {
|
|
2301
|
-
path.replaceWith(caller.node.arguments[paramIndex]);
|
|
2456
|
+
path.replaceWith(caller.node.arguments[paramIndex] ?? t14.unaryExpression("void", t14.numericLiteral(0)));
|
|
2302
2457
|
path.skip();
|
|
2303
2458
|
}
|
|
2304
2459
|
},
|
|
@@ -2328,7 +2483,7 @@ function inlineFunctionAliases(binding) {
|
|
|
2328
2483
|
refs.push(...fnRefs);
|
|
2329
2484
|
const callRefs = fnRefs.filter((ref2) => t14.isCallExpression(ref2.parent) && t14.isIdentifier(ref2.parent.callee, { name: fnName.current })).map((ref2) => ref2.parentPath);
|
|
2330
2485
|
for (const callRef of callRefs) {
|
|
2331
|
-
|
|
2486
|
+
inlineFunctionCall(fn.node, callRef);
|
|
2332
2487
|
state.changes++;
|
|
2333
2488
|
}
|
|
2334
2489
|
fn.remove();
|
|
@@ -3549,7 +3704,7 @@ var control_flow_object_default = {
|
|
|
3549
3704
|
if (t27.isStringLiteral(value)) {
|
|
3550
3705
|
memberPath.replaceWith(value);
|
|
3551
3706
|
} else {
|
|
3552
|
-
|
|
3707
|
+
inlineFunctionCall(value, memberPath.parentPath);
|
|
3553
3708
|
}
|
|
3554
3709
|
changes++;
|
|
3555
3710
|
});
|
|
@@ -3611,7 +3766,7 @@ var control_flow_object_default = {
|
|
|
3611
3766
|
if (t27.isStringLiteral(value)) {
|
|
3612
3767
|
path.replaceWith(value);
|
|
3613
3768
|
} else if (path.parentPath.isCallExpression()) {
|
|
3614
|
-
|
|
3769
|
+
inlineFunctionCall(value, path.parentPath);
|
|
3615
3770
|
} else {
|
|
3616
3771
|
path.replaceWith(value);
|
|
3617
3772
|
}
|
|
@@ -3758,9 +3913,9 @@ function findDecoders(stringArray) {
|
|
|
3758
3913
|
const decoders = [];
|
|
3759
3914
|
const functionName = capture(anyString());
|
|
3760
3915
|
const arrayIdentifier = capture(identifier());
|
|
3761
|
-
const matcher2 = functionDeclaration(identifier(functionName), anything(), blockStatement(
|
|
3916
|
+
const matcher2 = functionDeclaration(identifier(functionName), anything(), blockStatement(anySubList(variableDeclaration(undefined, [
|
|
3762
3917
|
variableDeclarator(arrayIdentifier, callExpression(identifier(stringArray.name)))
|
|
3763
|
-
]),
|
|
3918
|
+
]), containerOf(memberExpression(fromCapture(arrayIdentifier), undefined, true)))));
|
|
3764
3919
|
for (const ref of stringArray.references) {
|
|
3765
3920
|
const decoderFn = findParent(ref, matcher2);
|
|
3766
3921
|
if (decoderFn) {
|
|
@@ -4009,7 +4164,7 @@ var merge_object_assignments_default = {
|
|
|
4009
4164
|
sibling.remove();
|
|
4010
4165
|
binding.dereference();
|
|
4011
4166
|
binding.referencePaths.shift();
|
|
4012
|
-
if (binding.references === 1 && inlineableObject.match(object.current)) {
|
|
4167
|
+
if (binding.references === 1 && inlineableObject.match(object.current) && !isRepeatedCallReference(binding, binding.referencePaths[0])) {
|
|
4013
4168
|
binding.referencePaths[0].replaceWith(object.current);
|
|
4014
4169
|
path.remove();
|
|
4015
4170
|
this.changes++;
|
|
@@ -4023,6 +4178,12 @@ var merge_object_assignments_default = {
|
|
|
4023
4178
|
function hasCircularReference(node, binding) {
|
|
4024
4179
|
return binding.referencePaths.some((path) => path.find((p2) => p2.node === node)) || containerOf(callExpression()).match(node);
|
|
4025
4180
|
}
|
|
4181
|
+
var repeatedCallMatcher = or(forStatement(), forOfStatement(), forInStatement(), whileStatement(), doWhileStatement(), Function(), objectMethod(), classBody());
|
|
4182
|
+
function isRepeatedCallReference(binding, reference) {
|
|
4183
|
+
const block = binding.scope.getBlockParent().path;
|
|
4184
|
+
const repeatable = findParent(reference, repeatedCallMatcher);
|
|
4185
|
+
return repeatable?.isDescendant(block);
|
|
4186
|
+
}
|
|
4026
4187
|
var inlineableObject = predicate((node) => or(safeLiteral, arrayExpression(arrayOf(inlineableObject)), objectExpression(arrayOf(constObjectProperty(inlineableObject)))).match(node));
|
|
4027
4188
|
|
|
4028
4189
|
// webcrack/deobfuscate/self-defending.js
|
|
@@ -4192,7 +4353,7 @@ var computed_properties_default = {
|
|
|
4192
4353
|
name: "computed-properties",
|
|
4193
4354
|
tags: ["safe"],
|
|
4194
4355
|
visitor() {
|
|
4195
|
-
const stringMatcher = capture(stringLiteral(predicate(
|
|
4356
|
+
const stringMatcher = capture(stringLiteral(predicate(isIdentifierName)));
|
|
4196
4357
|
const propertyMatcher = or(memberExpression(anything(), stringMatcher, true), optionalMemberExpression(anything(), stringMatcher, true));
|
|
4197
4358
|
const keyMatcher = or(objectProperty(stringMatcher), classProperty(stringMatcher), objectMethod(undefined, stringMatcher), classMethod(undefined, stringMatcher));
|
|
4198
4359
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delance/builder",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"description": "A spear to the Python language server built with black magic",
|
|
6
6
|
"author": "mochaaP <npm@mochaa.ws>",
|
|
7
7
|
"license": "0BSD",
|
|
@@ -20,47 +20,47 @@
|
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "bun build.ts",
|
|
25
|
+
"build:minify": "bun run build --minify --entry-naming [dir]/[name].min.[ext]",
|
|
26
|
+
"build:webcrack": "tsc -p ./tsconfig.webcrack.json || :",
|
|
27
|
+
"check": "tsc; bun run lint",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"prebuild": "bun run build:webcrack",
|
|
31
|
+
"prepare": "bun run build",
|
|
32
|
+
"prepublishOnly": "rm -rf dist",
|
|
33
|
+
"start": "bun cli.ts"
|
|
25
34
|
},
|
|
26
|
-
"
|
|
35
|
+
"peerDependencies": {
|
|
27
36
|
"@babel/code-frame": "^7.26.2",
|
|
28
|
-
"@babel/core": "^7.26.0",
|
|
29
|
-
"@babel/generator": "^7.26.3",
|
|
30
37
|
"@babel/helper-validator-identifier": "^7.25.9",
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@babel/
|
|
35
|
-
"
|
|
38
|
+
"debug": "^4.4.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@babel/core": "^7.26.9",
|
|
42
|
+
"@babel/generator": "^7.26.9",
|
|
43
|
+
"@babel/parser": "^7.26.9",
|
|
44
|
+
"@babel/template": "^7.26.9",
|
|
45
|
+
"@babel/traverse": "^7.26.9",
|
|
46
|
+
"@babel/types": "^7.26.9",
|
|
47
|
+
"quickjs-emscripten": "^0.31.0"
|
|
36
48
|
},
|
|
37
49
|
"devDependencies": {
|
|
38
50
|
"@codemod/core": "npm:@codemod-esm/core@^2.2.1",
|
|
39
51
|
"@codemod/matchers": "npm:@codemod-esm/matchers@^1.7.1",
|
|
40
52
|
"@codemod/parser": "npm:@codemod-esm/parser@^1.4.2",
|
|
41
53
|
"@codemod/utils": "npm:@codemod-esm/utils@^1.1.1",
|
|
42
|
-
"@mochaa/eslintrc": "^0.1.
|
|
54
|
+
"@mochaa/eslintrc": "^0.1.12",
|
|
43
55
|
"@types/babel__core": "^7.20.5",
|
|
44
56
|
"@types/babel__generator": "^7.6.8",
|
|
45
57
|
"@types/babel__helper-validator-identifier": "^7.15.2",
|
|
46
58
|
"@types/babel__template": "^7.4.4",
|
|
47
59
|
"@types/babel__traverse": "^7.20.6",
|
|
48
|
-
"@types/bun": "^1.
|
|
60
|
+
"@types/bun": "^1.2.4",
|
|
49
61
|
"@types/debug": "^4.1.12",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"rimraf": "^6.0.1",
|
|
53
|
-
"typescript": "^5.7.2",
|
|
62
|
+
"eslint": "^9.21.0",
|
|
63
|
+
"typescript": "^5.8.2",
|
|
54
64
|
"webcrack": "github:j4k0xb/webcrack"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "bun build.ts",
|
|
58
|
-
"build:minify": "pnpm run build --minify --entry-naming [dir]/[name].min.[ext]",
|
|
59
|
-
"build:webcrack": "tsc -p ./tsconfig.webcrack.json",
|
|
60
|
-
"check": "tsc; pnpm run lint",
|
|
61
|
-
"lint": "eslint .",
|
|
62
|
-
"lint:fix": "eslint . --fix",
|
|
63
|
-
"prebuild": "pnpm run build:webcrack",
|
|
64
|
-
"start": "bun cli.ts"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
package/types.d.ts
DELETED