@delance/builder 0.2.1 → 0.2.2
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/index.js +2642 -595
- package/dist/index.js.map +101 -9
- package/package.json +40 -12
package/dist/index.js
CHANGED
|
@@ -12,10 +12,10 @@ var __export = (target, all) => {
|
|
|
12
12
|
// transform/webcrack/index.ts
|
|
13
13
|
import {getQuickJS, shouldInterruptAfterDeadline} from "quickjs-emscripten";
|
|
14
14
|
|
|
15
|
-
// node_modules/webcrack/src/deobfuscate/index.ts
|
|
15
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/deobfuscate/index.ts
|
|
16
16
|
import debug3 from "debug";
|
|
17
17
|
|
|
18
|
-
// node_modules/webcrack/src/ast-utils/ast.ts
|
|
18
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/ast.ts
|
|
19
19
|
import * as t from "@babel/types";
|
|
20
20
|
function getPropName(node) {
|
|
21
21
|
if (t.isIdentifier(node)) {
|
|
@@ -28,7 +28,7 @@ function getPropName(node) {
|
|
|
28
28
|
return node.value.toString();
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
// node_modules/webcrack/src/ast-utils/generator.ts
|
|
31
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/generator.ts
|
|
32
32
|
import babelGenerate from "@babel/generator";
|
|
33
33
|
function generate(ast, options = defaultOptions) {
|
|
34
34
|
return babelGenerate(ast, options).code;
|
|
@@ -45,37 +45,2125 @@ function codePreview(node) {
|
|
|
45
45
|
return code;
|
|
46
46
|
}
|
|
47
47
|
var defaultOptions = { jsescOption: { minimal: true } };
|
|
48
|
-
// node_modules/webcrack/src/ast-utils/inline.ts
|
|
49
|
-
import
|
|
48
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/inline.ts
|
|
49
|
+
import traverse4 from "@babel/traverse";
|
|
50
|
+
import * as t13 from "@babel/types";
|
|
51
|
+
|
|
52
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anyExpression.ts
|
|
53
|
+
import * as t2 from "@babel/types";
|
|
54
|
+
|
|
55
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/Matcher.ts
|
|
56
|
+
class Matcher {
|
|
57
|
+
match(value, keys = []) {
|
|
58
|
+
return this.matchValue(value, keys);
|
|
59
|
+
}
|
|
60
|
+
matchValue(value, keys) {
|
|
61
|
+
throw new Error(`${this.constructor.name}#matchValue is not implemented`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anyExpression.ts
|
|
66
|
+
function anyExpression() {
|
|
67
|
+
return new AnyExpressionMatcher;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class AnyExpressionMatcher extends Matcher {
|
|
71
|
+
constructor() {
|
|
72
|
+
super(...arguments);
|
|
73
|
+
}
|
|
74
|
+
matchValue(value) {
|
|
75
|
+
return t2.isNode(value) && t2.isExpression(value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/utils/distributeAcrossSlices.ts
|
|
79
|
+
function* distributeAcrossSlices(slices, available) {
|
|
80
|
+
if (slices.length === 0) {
|
|
81
|
+
yield [];
|
|
82
|
+
} else if (slices.length === 1) {
|
|
83
|
+
const spacer = slices[0];
|
|
84
|
+
if (spacer.min <= available && available <= spacer.max) {
|
|
85
|
+
yield [available];
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
const last = slices[slices.length - 1];
|
|
89
|
+
for (let allocateToLast = last.min;allocateToLast <= last.max && allocateToLast <= available; allocateToLast++) {
|
|
90
|
+
const allButLast = slices.slice(0, -1);
|
|
91
|
+
for (const allButLastAllocations of distributeAcrossSlices(allButLast, available - allocateToLast)) {
|
|
92
|
+
yield [...allButLastAllocations, allocateToLast];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anything.ts
|
|
99
|
+
function anything() {
|
|
100
|
+
return new AnythingMatcher;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class AnythingMatcher extends Matcher {
|
|
104
|
+
constructor() {
|
|
105
|
+
super(...arguments);
|
|
106
|
+
}
|
|
107
|
+
matchValue(value) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/slice.ts
|
|
113
|
+
function zeroOrMore(matcher = anything()) {
|
|
114
|
+
return new SliceMatcher(0, Infinity, matcher);
|
|
115
|
+
}
|
|
116
|
+
function oneOrMore(matcher = anything()) {
|
|
117
|
+
return new SliceMatcher(1, Infinity, matcher);
|
|
118
|
+
}
|
|
119
|
+
function slice(optionsOrLength, matcherOrUndefined) {
|
|
120
|
+
let min;
|
|
121
|
+
let max;
|
|
122
|
+
let matcher;
|
|
123
|
+
if (typeof optionsOrLength === "number") {
|
|
124
|
+
min = optionsOrLength;
|
|
125
|
+
max = optionsOrLength;
|
|
126
|
+
matcher = matcherOrUndefined ?? anything();
|
|
127
|
+
} else if (typeof optionsOrLength === "object" && typeof matcherOrUndefined === "undefined") {
|
|
128
|
+
min = optionsOrLength.min ?? 0;
|
|
129
|
+
max = optionsOrLength.max ?? Infinity;
|
|
130
|
+
matcher = optionsOrLength.matcher ?? anything();
|
|
131
|
+
} else {
|
|
132
|
+
throw new Error("Invalid arguments");
|
|
133
|
+
}
|
|
134
|
+
return new SliceMatcher(min, max, matcher);
|
|
135
|
+
}
|
|
136
|
+
class SliceMatcher extends Matcher {
|
|
137
|
+
min;
|
|
138
|
+
max;
|
|
139
|
+
matcher;
|
|
140
|
+
constructor(min, max, matcher) {
|
|
141
|
+
super();
|
|
142
|
+
this.min = min;
|
|
143
|
+
this.max = max;
|
|
144
|
+
this.matcher = matcher;
|
|
145
|
+
}
|
|
146
|
+
matchValue(value, keys) {
|
|
147
|
+
return this.matcher.matchValue(value, keys);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anyList.ts
|
|
152
|
+
function anyList(...elements) {
|
|
153
|
+
return new AnyListMatcher(elements);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
class AnyListMatcher extends Matcher {
|
|
157
|
+
matchers;
|
|
158
|
+
sliceMatchers = [];
|
|
159
|
+
constructor(matchers) {
|
|
160
|
+
super();
|
|
161
|
+
this.matchers = matchers;
|
|
162
|
+
for (const matcher of matchers) {
|
|
163
|
+
if (matcher instanceof SliceMatcher) {
|
|
164
|
+
this.sliceMatchers.push(matcher);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
matchValue(array, keys) {
|
|
169
|
+
if (!Array.isArray(array)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
if (this.matchers.length === 0 && array.length === 0) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
const spacerAllocations = distributeAcrossSlices(this.sliceMatchers, array.length - this.matchers.length + this.sliceMatchers.length);
|
|
176
|
+
for (const allocations of spacerAllocations) {
|
|
177
|
+
const valuesToMatch = array.slice();
|
|
178
|
+
let matchedAll = true;
|
|
179
|
+
let key = 0;
|
|
180
|
+
for (const matcher of this.matchers) {
|
|
181
|
+
if (matcher instanceof SliceMatcher) {
|
|
182
|
+
let sliceValueCount = allocations.shift() || 0;
|
|
183
|
+
while (sliceValueCount > 0) {
|
|
184
|
+
const valueToMatch = valuesToMatch.shift();
|
|
185
|
+
if (!matcher.matchValue(valueToMatch, [...keys, key])) {
|
|
186
|
+
matchedAll = false;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
sliceValueCount--;
|
|
190
|
+
key++;
|
|
191
|
+
}
|
|
192
|
+
} else if (!matcher.matchValue(valuesToMatch.shift(), [...keys, key])) {
|
|
193
|
+
matchedAll = false;
|
|
194
|
+
break;
|
|
195
|
+
} else {
|
|
196
|
+
key++;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (matchedAll) {
|
|
200
|
+
if (valuesToMatch.length > 0) {
|
|
201
|
+
throw new Error(`expected to consume all elements to match but ${valuesToMatch.length} remain!`);
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anyNode.ts
|
|
50
210
|
import * as t3 from "@babel/types";
|
|
51
|
-
|
|
211
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anyStatement.ts
|
|
212
|
+
import * as t4 from "@babel/types";
|
|
213
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/anyString.ts
|
|
214
|
+
function anyString() {
|
|
215
|
+
return new StringMatcher;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class StringMatcher extends Matcher {
|
|
219
|
+
constructor() {
|
|
220
|
+
super(...arguments);
|
|
221
|
+
}
|
|
222
|
+
matchValue(value) {
|
|
223
|
+
return typeof value === "string" || value instanceof String;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/arrayOf.ts
|
|
227
|
+
function arrayOf(elementMatcher) {
|
|
228
|
+
return new ArrayOfMatcher(elementMatcher);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
class ArrayOfMatcher extends Matcher {
|
|
232
|
+
elementMatcher;
|
|
233
|
+
constructor(elementMatcher) {
|
|
234
|
+
super();
|
|
235
|
+
this.elementMatcher = elementMatcher;
|
|
236
|
+
}
|
|
237
|
+
matchValue(value, keys) {
|
|
238
|
+
if (!Array.isArray(value)) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
for (const [i, element] of value.entries()) {
|
|
242
|
+
if (!this.elementMatcher.matchValue(element, [...keys, i])) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/capture.ts
|
|
250
|
+
function capture(matcher) {
|
|
251
|
+
return new CapturedMatcher(matcher);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
class CapturedMatcher extends Matcher {
|
|
255
|
+
matcher;
|
|
256
|
+
_current;
|
|
257
|
+
_currentKeys;
|
|
258
|
+
constructor(matcher = anything()) {
|
|
259
|
+
super();
|
|
260
|
+
this.matcher = matcher;
|
|
261
|
+
}
|
|
262
|
+
get current() {
|
|
263
|
+
return this._current;
|
|
264
|
+
}
|
|
265
|
+
get currentKeys() {
|
|
266
|
+
return this._currentKeys;
|
|
267
|
+
}
|
|
268
|
+
matchValue(value, keys) {
|
|
269
|
+
if (this.matcher.matchValue(value, keys)) {
|
|
270
|
+
this.capture(value, keys);
|
|
271
|
+
return true;
|
|
272
|
+
} else {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
capture(value, keys) {
|
|
277
|
+
this._current = value;
|
|
278
|
+
this._currentKeys = keys;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/containerOf.ts
|
|
282
|
+
import * as t5 from "@babel/types";
|
|
283
|
+
function containerOf(containedMatcher) {
|
|
284
|
+
return new ContainerOfMatcher(containedMatcher);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
class ContainerOfMatcher extends CapturedMatcher {
|
|
288
|
+
containedMatcher;
|
|
289
|
+
constructor(containedMatcher) {
|
|
290
|
+
super();
|
|
291
|
+
this.containedMatcher = containedMatcher;
|
|
292
|
+
}
|
|
293
|
+
matchValue(value, keys) {
|
|
294
|
+
if (!t5.isNode(value)) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
if (this.containedMatcher.matchValue(value, keys)) {
|
|
298
|
+
this.capture(value, keys);
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
for (const key in value) {
|
|
302
|
+
const valueAtKey = value[key];
|
|
303
|
+
if (Array.isArray(valueAtKey)) {
|
|
304
|
+
for (const [i, element] of valueAtKey.entries()) {
|
|
305
|
+
if (this.matchValue(element, [...keys, key, i])) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} else if (this.matchValue(valueAtKey, [...keys, key])) {
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/@codemod/utils/src/index.ts
|
|
317
|
+
import * as Babel from "@babel/core";
|
|
318
|
+
import * as t9 from "@babel/types";
|
|
319
|
+
|
|
320
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@utils&commit=f7526b4223cf97415_tmdrjyefmlkz7xjmrqotqhciwe/node_modules/@codemod/utils/src/NodeTypes.ts
|
|
321
|
+
import * as t6 from "@babel/types";
|
|
322
|
+
var { BUILDER_KEYS, NODE_FIELDS } = t6;
|
|
323
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@utils&commit=f7526b4223cf97415_tmdrjyefmlkz7xjmrqotqhciwe/node_modules/@codemod/utils/src/builders.ts
|
|
324
|
+
import traverse2 from "@babel/traverse";
|
|
325
|
+
import * as t7 from "@babel/types";
|
|
326
|
+
|
|
327
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/@codemod/parser/src/index.ts
|
|
328
|
+
import {
|
|
329
|
+
parse as babelParse
|
|
330
|
+
} from "@babel/parser";
|
|
331
|
+
|
|
332
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@parser&commit=f7526b4223cf9741_hxm5tbv23uosukgwpiwqxr6wbu/node_modules/@codemod/parser/src/options.ts
|
|
333
|
+
var DefaultParserPlugins = new Set([
|
|
334
|
+
"asyncGenerators",
|
|
335
|
+
"bigInt",
|
|
336
|
+
"classPrivateMethods",
|
|
337
|
+
"classPrivateProperties",
|
|
338
|
+
"classProperties",
|
|
339
|
+
"doExpressions",
|
|
340
|
+
"dynamicImport",
|
|
341
|
+
"exportDefaultFrom",
|
|
342
|
+
"exportNamespaceFrom",
|
|
343
|
+
"functionBind",
|
|
344
|
+
"functionSent",
|
|
345
|
+
"importAssertions",
|
|
346
|
+
"importMeta",
|
|
347
|
+
"jsx",
|
|
348
|
+
"logicalAssignment",
|
|
349
|
+
"nullishCoalescingOperator",
|
|
350
|
+
"numericSeparator",
|
|
351
|
+
"objectRestSpread",
|
|
352
|
+
"optionalCatchBinding",
|
|
353
|
+
"optionalChaining",
|
|
354
|
+
"partialApplication",
|
|
355
|
+
"throwExpressions",
|
|
356
|
+
"topLevelAwait",
|
|
357
|
+
["decorators", { decoratorsBeforeExport: true }],
|
|
358
|
+
"decorators-legacy",
|
|
359
|
+
["pipelineOperator", { proposal: "minimal" }],
|
|
360
|
+
["recordAndTuple", { syntaxType: "hash" }]
|
|
361
|
+
]);
|
|
362
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@utils&commit=f7526b4223cf97415_tmdrjyefmlkz7xjmrqotqhciwe/node_modules/@codemod/utils/src/nodesEquivalent.ts
|
|
363
|
+
import * as t8 from "@babel/types";
|
|
364
|
+
function nodesEquivalent(a, b) {
|
|
365
|
+
if (a === b) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
if (a.type !== b.type) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
const fields = NODE_FIELDS[a.type];
|
|
372
|
+
const aProps = a;
|
|
373
|
+
const bProps = b;
|
|
374
|
+
for (const [k, field] of Object.entries(fields)) {
|
|
375
|
+
const key = k;
|
|
376
|
+
if (field.optional && aProps[key] == null && bProps[key] == null) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
const aVal = aProps[key];
|
|
380
|
+
const bVal = bProps[key];
|
|
381
|
+
if (aVal === bVal) {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (aVal == null || bVal == null) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
if (Array.isArray(aVal) && Array.isArray(bVal)) {
|
|
388
|
+
if (aVal.length !== bVal.length) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
for (let i = 0;i < aVal.length; i++) {
|
|
392
|
+
if (!nodesEquivalent(aVal[i], bVal[i])) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (t8.isNode(aVal) && t8.isNode(bVal)) {
|
|
399
|
+
if (!nodesEquivalent(aVal, bVal)) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/fromCapture.ts
|
|
409
|
+
function fromCapture(capturedMatcher) {
|
|
410
|
+
return new FromCaptureMatcher(capturedMatcher);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
class FromCaptureMatcher extends Matcher {
|
|
414
|
+
capturedMatcher;
|
|
415
|
+
constructor(capturedMatcher) {
|
|
416
|
+
super();
|
|
417
|
+
this.capturedMatcher = capturedMatcher;
|
|
418
|
+
}
|
|
419
|
+
matchValue(value) {
|
|
420
|
+
if (t9.isNode(this.capturedMatcher.current) && t9.isNode(value)) {
|
|
421
|
+
return nodesEquivalent(this.capturedMatcher.current, value);
|
|
422
|
+
}
|
|
423
|
+
return this.capturedMatcher.current === value;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/function.ts
|
|
427
|
+
import * as t10 from "@babel/types";
|
|
428
|
+
|
|
429
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/tupleOf.ts
|
|
430
|
+
function tupleOf(...matchers) {
|
|
431
|
+
return new TupleOfMatcher(...matchers);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
class TupleOfMatcher extends Matcher {
|
|
435
|
+
matchers;
|
|
436
|
+
constructor(...matchers) {
|
|
437
|
+
super();
|
|
438
|
+
this.matchers = matchers;
|
|
439
|
+
}
|
|
440
|
+
matchValue(value, keys) {
|
|
441
|
+
if (!Array.isArray(value)) {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
if (value.length !== this.matchers.length) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
for (let i = 0;i < this.matchers.length; i++) {
|
|
448
|
+
const matcher = this.matchers[i];
|
|
449
|
+
const element = value[i];
|
|
450
|
+
if (!matcher.matchValue(element, [...keys, i])) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/generated.ts
|
|
458
|
+
import * as t11 from "@babel/types";
|
|
459
|
+
function arrayExpression(elements) {
|
|
460
|
+
return new ArrayExpressionMatcher(elements);
|
|
461
|
+
}
|
|
462
|
+
function arrayPattern(elements) {
|
|
463
|
+
return new ArrayPatternMatcher(elements);
|
|
464
|
+
}
|
|
465
|
+
function arrowFunctionExpression(params, body, async) {
|
|
466
|
+
return new ArrowFunctionExpressionMatcher(params, body, async);
|
|
467
|
+
}
|
|
468
|
+
function assignmentExpression(operator, left, right) {
|
|
469
|
+
return new AssignmentExpressionMatcher(operator, left, right);
|
|
470
|
+
}
|
|
471
|
+
function binaryExpression(operator, left, right) {
|
|
472
|
+
return new BinaryExpressionMatcher(operator, left, right);
|
|
473
|
+
}
|
|
474
|
+
function blockStatement(body, directives) {
|
|
475
|
+
return new BlockStatementMatcher(body, directives);
|
|
476
|
+
}
|
|
477
|
+
function booleanLiteral(value) {
|
|
478
|
+
return new BooleanLiteralMatcher(value);
|
|
479
|
+
}
|
|
480
|
+
function breakStatement(label) {
|
|
481
|
+
return new BreakStatementMatcher(label);
|
|
482
|
+
}
|
|
483
|
+
function callExpression(callee, _arguments) {
|
|
484
|
+
return new CallExpressionMatcher(callee, _arguments);
|
|
485
|
+
}
|
|
486
|
+
function classMethod(kind, key, params, body, computed, _static, generator2, async) {
|
|
487
|
+
return new ClassMethodMatcher(kind, key, params, body, computed, _static, generator2, async);
|
|
488
|
+
}
|
|
489
|
+
function classProperty(key, value, typeAnnotation, decorators, computed, _static) {
|
|
490
|
+
return new ClassPropertyMatcher(key, value, typeAnnotation, decorators, computed, _static);
|
|
491
|
+
}
|
|
492
|
+
function conditionalExpression(test, consequent, alternate) {
|
|
493
|
+
return new ConditionalExpressionMatcher(test, consequent, alternate);
|
|
494
|
+
}
|
|
495
|
+
function continueStatement(label) {
|
|
496
|
+
return new ContinueStatementMatcher(label);
|
|
497
|
+
}
|
|
498
|
+
function expressionStatement(expression) {
|
|
499
|
+
return new ExpressionStatementMatcher(expression);
|
|
500
|
+
}
|
|
501
|
+
function forInStatement(left, right, body) {
|
|
502
|
+
return new ForInStatementMatcher(left, right, body);
|
|
503
|
+
}
|
|
504
|
+
function forStatement(init, test, update, body) {
|
|
505
|
+
return new ForStatementMatcher(init, test, update, body);
|
|
506
|
+
}
|
|
507
|
+
function functionDeclaration(id, params, body, generator2, async) {
|
|
508
|
+
return new FunctionDeclarationMatcher(id, params, body, generator2, async);
|
|
509
|
+
}
|
|
510
|
+
function functionExpression(id, params, body, generator2, async) {
|
|
511
|
+
return new FunctionExpressionMatcher(id, params, body, generator2, async);
|
|
512
|
+
}
|
|
513
|
+
function identifier(name) {
|
|
514
|
+
return new IdentifierMatcher(name);
|
|
515
|
+
}
|
|
516
|
+
function ifStatement(test, consequent, alternate) {
|
|
517
|
+
return new IfStatementMatcher(test, consequent, alternate);
|
|
518
|
+
}
|
|
519
|
+
function logicalExpression(operator, left, right) {
|
|
520
|
+
return new LogicalExpressionMatcher(operator, left, right);
|
|
521
|
+
}
|
|
522
|
+
function memberExpression(object, property, computed, optional) {
|
|
523
|
+
return new MemberExpressionMatcher(object, property, computed, optional);
|
|
524
|
+
}
|
|
525
|
+
function nullLiteral() {
|
|
526
|
+
return new NullLiteralMatcher;
|
|
527
|
+
}
|
|
528
|
+
function numericLiteral(value) {
|
|
529
|
+
return new NumericLiteralMatcher(value);
|
|
530
|
+
}
|
|
531
|
+
function objectExpression(properties) {
|
|
532
|
+
return new ObjectExpressionMatcher(properties);
|
|
533
|
+
}
|
|
534
|
+
function objectMethod(kind, key, params, body, computed, generator2, async) {
|
|
535
|
+
return new ObjectMethodMatcher(kind, key, params, body, computed, generator2, async);
|
|
536
|
+
}
|
|
537
|
+
function objectPattern(properties) {
|
|
538
|
+
return new ObjectPatternMatcher(properties);
|
|
539
|
+
}
|
|
540
|
+
function objectProperty(key, value, computed, shorthand, decorators) {
|
|
541
|
+
return new ObjectPropertyMatcher(key, value, computed, shorthand, decorators);
|
|
542
|
+
}
|
|
543
|
+
function optionalMemberExpression(object, property, computed, optional) {
|
|
544
|
+
return new OptionalMemberExpressionMatcher(object, property, computed, optional);
|
|
545
|
+
}
|
|
546
|
+
function restElement(argument) {
|
|
547
|
+
return new RestElementMatcher(argument);
|
|
548
|
+
}
|
|
549
|
+
function returnStatement(argument) {
|
|
550
|
+
return new ReturnStatementMatcher(argument);
|
|
551
|
+
}
|
|
552
|
+
function sequenceExpression(expressions) {
|
|
553
|
+
return new SequenceExpressionMatcher(expressions);
|
|
554
|
+
}
|
|
555
|
+
function spreadElement(argument) {
|
|
556
|
+
return new SpreadElementMatcher(argument);
|
|
557
|
+
}
|
|
558
|
+
function stringLiteral(value) {
|
|
559
|
+
return new StringLiteralMatcher(value);
|
|
560
|
+
}
|
|
561
|
+
function switchCase(test, consequent) {
|
|
562
|
+
return new SwitchCaseMatcher(test, consequent);
|
|
563
|
+
}
|
|
564
|
+
function switchStatement(discriminant, cases) {
|
|
565
|
+
return new SwitchStatementMatcher(discriminant, cases);
|
|
566
|
+
}
|
|
567
|
+
function templateLiteral(quasis, expressions) {
|
|
568
|
+
return new TemplateLiteralMatcher(quasis, expressions);
|
|
569
|
+
}
|
|
570
|
+
function thisExpression() {
|
|
571
|
+
return new ThisExpressionMatcher;
|
|
572
|
+
}
|
|
573
|
+
function tryStatement(block, handler, finalizer) {
|
|
574
|
+
return new TryStatementMatcher(block, handler, finalizer);
|
|
575
|
+
}
|
|
576
|
+
function unaryExpression(operator, argument, prefix) {
|
|
577
|
+
return new UnaryExpressionMatcher(operator, argument, prefix);
|
|
578
|
+
}
|
|
579
|
+
function updateExpression(operator, argument, prefix) {
|
|
580
|
+
return new UpdateExpressionMatcher(operator, argument, prefix);
|
|
581
|
+
}
|
|
582
|
+
function variableDeclaration(kind, declarations) {
|
|
583
|
+
return new VariableDeclarationMatcher(kind, declarations);
|
|
584
|
+
}
|
|
585
|
+
function variableDeclarator(id, init) {
|
|
586
|
+
return new VariableDeclaratorMatcher(id, init);
|
|
587
|
+
}
|
|
588
|
+
function whileStatement(test, body) {
|
|
589
|
+
return new WhileStatementMatcher(test, body);
|
|
590
|
+
}
|
|
591
|
+
class ArrayExpressionMatcher extends Matcher {
|
|
592
|
+
elements;
|
|
593
|
+
constructor(elements) {
|
|
594
|
+
super();
|
|
595
|
+
this.elements = elements;
|
|
596
|
+
}
|
|
597
|
+
matchValue(node, keys) {
|
|
598
|
+
if (!t11.isNode(node) || !t11.isArrayExpression(node)) {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
if (typeof this.elements === "undefined") {
|
|
602
|
+
} else if (Array.isArray(this.elements)) {
|
|
603
|
+
if (!tupleOf(...this.elements).matchValue(node.elements, [
|
|
604
|
+
...keys,
|
|
605
|
+
"elements"
|
|
606
|
+
])) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
} else if (!this.elements.matchValue(node.elements, [...keys, "elements"])) {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
class ArrayPatternMatcher extends Matcher {
|
|
617
|
+
elements;
|
|
618
|
+
constructor(elements) {
|
|
619
|
+
super();
|
|
620
|
+
this.elements = elements;
|
|
621
|
+
}
|
|
622
|
+
matchValue(node, keys) {
|
|
623
|
+
if (!t11.isNode(node) || !t11.isArrayPattern(node)) {
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
if (typeof this.elements === "undefined") {
|
|
627
|
+
} else if (Array.isArray(this.elements)) {
|
|
628
|
+
if (!tupleOf(...this.elements).matchValue(node.elements, [
|
|
629
|
+
...keys,
|
|
630
|
+
"elements"
|
|
631
|
+
])) {
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
} else if (!this.elements.matchValue(node.elements, [...keys, "elements"])) {
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
return true;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
class ArrowFunctionExpressionMatcher extends Matcher {
|
|
641
|
+
params;
|
|
642
|
+
body;
|
|
643
|
+
async;
|
|
644
|
+
constructor(params, body, async) {
|
|
645
|
+
super();
|
|
646
|
+
this.params = params;
|
|
647
|
+
this.body = body;
|
|
648
|
+
this.async = async;
|
|
649
|
+
}
|
|
650
|
+
matchValue(node, keys) {
|
|
651
|
+
if (!t11.isNode(node) || !t11.isArrowFunctionExpression(node)) {
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
if (typeof this.params === "undefined") {
|
|
655
|
+
} else if (Array.isArray(this.params)) {
|
|
656
|
+
if (!tupleOf(...this.params).matchValue(node.params, [
|
|
657
|
+
...keys,
|
|
658
|
+
"params"
|
|
659
|
+
])) {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
} else if (!this.params.matchValue(node.params, [...keys, "params"])) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
if (typeof this.body === "undefined") {
|
|
666
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
if (typeof this.async === "undefined") {
|
|
670
|
+
} else if (typeof this.async === "boolean") {
|
|
671
|
+
if (this.async !== node.async) {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
} else if (!this.async.matchValue(node.async, [...keys, "async"])) {
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
class AssignmentExpressionMatcher extends Matcher {
|
|
682
|
+
operator;
|
|
683
|
+
left;
|
|
684
|
+
right;
|
|
685
|
+
constructor(operator, left, right) {
|
|
686
|
+
super();
|
|
687
|
+
this.operator = operator;
|
|
688
|
+
this.left = left;
|
|
689
|
+
this.right = right;
|
|
690
|
+
}
|
|
691
|
+
matchValue(node, keys) {
|
|
692
|
+
if (!t11.isNode(node) || !t11.isAssignmentExpression(node)) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
if (typeof this.operator === "undefined") {
|
|
696
|
+
} else if (typeof this.operator === "string") {
|
|
697
|
+
if (this.operator !== node.operator) {
|
|
698
|
+
return false;
|
|
699
|
+
}
|
|
700
|
+
} else if (!this.operator.matchValue(node.operator, [...keys, "operator"])) {
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
if (typeof this.left === "undefined") {
|
|
704
|
+
} else if (!this.left.matchValue(node.left, [...keys, "left"])) {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
if (typeof this.right === "undefined") {
|
|
708
|
+
} else if (!this.right.matchValue(node.right, [...keys, "right"])) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
return true;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
class BinaryExpressionMatcher extends Matcher {
|
|
715
|
+
operator;
|
|
716
|
+
left;
|
|
717
|
+
right;
|
|
718
|
+
constructor(operator, left, right) {
|
|
719
|
+
super();
|
|
720
|
+
this.operator = operator;
|
|
721
|
+
this.left = left;
|
|
722
|
+
this.right = right;
|
|
723
|
+
}
|
|
724
|
+
matchValue(node, keys) {
|
|
725
|
+
if (!t11.isNode(node) || !t11.isBinaryExpression(node)) {
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
if (typeof this.operator === "undefined") {
|
|
729
|
+
} else if (typeof this.operator === "string") {
|
|
730
|
+
if (this.operator !== node.operator) {
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
} else if (!this.operator.matchValue(node.operator, [...keys, "operator"])) {
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
if (typeof this.left === "undefined") {
|
|
737
|
+
} else if (!this.left.matchValue(node.left, [...keys, "left"])) {
|
|
738
|
+
return false;
|
|
739
|
+
}
|
|
740
|
+
if (typeof this.right === "undefined") {
|
|
741
|
+
} else if (!this.right.matchValue(node.right, [...keys, "right"])) {
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
class BlockStatementMatcher extends Matcher {
|
|
748
|
+
body;
|
|
749
|
+
directives;
|
|
750
|
+
constructor(body, directives) {
|
|
751
|
+
super();
|
|
752
|
+
this.body = body;
|
|
753
|
+
this.directives = directives;
|
|
754
|
+
}
|
|
755
|
+
matchValue(node, keys) {
|
|
756
|
+
if (!t11.isNode(node) || !t11.isBlockStatement(node)) {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
if (typeof this.body === "undefined") {
|
|
760
|
+
} else if (Array.isArray(this.body)) {
|
|
761
|
+
if (!tupleOf(...this.body).matchValue(node.body, [...keys, "body"])) {
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
if (typeof this.directives === "undefined") {
|
|
768
|
+
} else if (Array.isArray(this.directives)) {
|
|
769
|
+
if (!tupleOf(...this.directives).matchValue(node.directives, [
|
|
770
|
+
...keys,
|
|
771
|
+
"directives"
|
|
772
|
+
])) {
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
} else if (!this.directives.matchValue(node.directives, [...keys, "directives"])) {
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
return true;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
class BooleanLiteralMatcher extends Matcher {
|
|
783
|
+
value;
|
|
784
|
+
constructor(value) {
|
|
785
|
+
super();
|
|
786
|
+
this.value = value;
|
|
787
|
+
}
|
|
788
|
+
matchValue(node, keys) {
|
|
789
|
+
if (!t11.isNode(node) || !t11.isBooleanLiteral(node)) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
if (typeof this.value === "undefined") {
|
|
793
|
+
} else if (typeof this.value === "boolean") {
|
|
794
|
+
if (this.value !== node.value) {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
} else if (!this.value.matchValue(node.value, [...keys, "value"])) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
return true;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
class BreakStatementMatcher extends Matcher {
|
|
804
|
+
label;
|
|
805
|
+
constructor(label) {
|
|
806
|
+
super();
|
|
807
|
+
this.label = label;
|
|
808
|
+
}
|
|
809
|
+
matchValue(node, keys) {
|
|
810
|
+
if (!t11.isNode(node) || !t11.isBreakStatement(node)) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
if (typeof this.label === "undefined") {
|
|
814
|
+
} else if (this.label === null) {
|
|
815
|
+
if (node.label !== null) {
|
|
816
|
+
return false;
|
|
817
|
+
}
|
|
818
|
+
} else if (!this.label.matchValue(node.label, [...keys, "label"])) {
|
|
819
|
+
return false;
|
|
820
|
+
}
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
class CallExpressionMatcher extends Matcher {
|
|
826
|
+
callee;
|
|
827
|
+
_arguments;
|
|
828
|
+
constructor(callee, _arguments) {
|
|
829
|
+
super();
|
|
830
|
+
this.callee = callee;
|
|
831
|
+
this._arguments = _arguments;
|
|
832
|
+
}
|
|
833
|
+
matchValue(node, keys) {
|
|
834
|
+
if (!t11.isNode(node) || !t11.isCallExpression(node)) {
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
if (typeof this.callee === "undefined") {
|
|
838
|
+
} else if (!this.callee.matchValue(node.callee, [...keys, "callee"])) {
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
if (typeof this._arguments === "undefined") {
|
|
842
|
+
} else if (Array.isArray(this._arguments)) {
|
|
843
|
+
if (!tupleOf(...this._arguments).matchValue(node.arguments, [
|
|
844
|
+
...keys,
|
|
845
|
+
"arguments"
|
|
846
|
+
])) {
|
|
847
|
+
return false;
|
|
848
|
+
}
|
|
849
|
+
} else if (!this._arguments.matchValue(node.arguments, [...keys, "arguments"])) {
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
return true;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
class ClassMethodMatcher extends Matcher {
|
|
856
|
+
kind;
|
|
857
|
+
key;
|
|
858
|
+
params;
|
|
859
|
+
body;
|
|
860
|
+
computed;
|
|
861
|
+
_static;
|
|
862
|
+
generator2;
|
|
863
|
+
async;
|
|
864
|
+
constructor(kind, key, params, body, computed, _static, generator2, async) {
|
|
865
|
+
super();
|
|
866
|
+
this.kind = kind;
|
|
867
|
+
this.key = key;
|
|
868
|
+
this.params = params;
|
|
869
|
+
this.body = body;
|
|
870
|
+
this.computed = computed;
|
|
871
|
+
this._static = _static;
|
|
872
|
+
this.generator = generator2;
|
|
873
|
+
this.async = async;
|
|
874
|
+
}
|
|
875
|
+
matchValue(node, keys) {
|
|
876
|
+
if (!t11.isNode(node) || !t11.isClassMethod(node)) {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
if (typeof this.kind === "undefined") {
|
|
880
|
+
} else if (typeof this.kind === "string") {
|
|
881
|
+
if (this.kind !== node.kind) {
|
|
882
|
+
return false;
|
|
883
|
+
}
|
|
884
|
+
} else if (!this.kind.matchValue(node.kind, [...keys, "kind"])) {
|
|
885
|
+
return false;
|
|
886
|
+
}
|
|
887
|
+
if (typeof this.key === "undefined") {
|
|
888
|
+
} else if (!this.key.matchValue(node.key, [...keys, "key"])) {
|
|
889
|
+
return false;
|
|
890
|
+
}
|
|
891
|
+
if (typeof this.params === "undefined") {
|
|
892
|
+
} else if (Array.isArray(this.params)) {
|
|
893
|
+
if (!tupleOf(...this.params).matchValue(node.params, [
|
|
894
|
+
...keys,
|
|
895
|
+
"params"
|
|
896
|
+
])) {
|
|
897
|
+
return false;
|
|
898
|
+
}
|
|
899
|
+
} else if (!this.params.matchValue(node.params, [...keys, "params"])) {
|
|
900
|
+
return false;
|
|
901
|
+
}
|
|
902
|
+
if (typeof this.body === "undefined") {
|
|
903
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
if (typeof this.computed === "undefined") {
|
|
907
|
+
} else if (typeof this.computed === "boolean") {
|
|
908
|
+
if (this.computed !== node.computed) {
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
} else if (!this.computed.matchValue(node.computed, [...keys, "computed"])) {
|
|
912
|
+
return false;
|
|
913
|
+
}
|
|
914
|
+
if (typeof this._static === "undefined") {
|
|
915
|
+
} else if (typeof this._static === "boolean") {
|
|
916
|
+
if (this._static !== node.static) {
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
919
|
+
} else if (!this._static.matchValue(node.static, [...keys, "static"])) {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
if (typeof this.generator === "undefined") {
|
|
923
|
+
} else if (typeof this.generator === "boolean") {
|
|
924
|
+
if (this.generator !== node.generator) {
|
|
925
|
+
return false;
|
|
926
|
+
}
|
|
927
|
+
} else if (!this.generator.matchValue(node.generator, [...keys, "generator"])) {
|
|
928
|
+
return false;
|
|
929
|
+
}
|
|
930
|
+
if (typeof this.async === "undefined") {
|
|
931
|
+
} else if (typeof this.async === "boolean") {
|
|
932
|
+
if (this.async !== node.async) {
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
} else if (!this.async.matchValue(node.async, [...keys, "async"])) {
|
|
936
|
+
return false;
|
|
937
|
+
}
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
class ClassPropertyMatcher extends Matcher {
|
|
942
|
+
key;
|
|
943
|
+
value;
|
|
944
|
+
typeAnnotation;
|
|
945
|
+
decorators;
|
|
946
|
+
computed;
|
|
947
|
+
_static;
|
|
948
|
+
constructor(key, value, typeAnnotation, decorators, computed, _static) {
|
|
949
|
+
super();
|
|
950
|
+
this.key = key;
|
|
951
|
+
this.value = value;
|
|
952
|
+
this.typeAnnotation = typeAnnotation;
|
|
953
|
+
this.decorators = decorators;
|
|
954
|
+
this.computed = computed;
|
|
955
|
+
this._static = _static;
|
|
956
|
+
}
|
|
957
|
+
matchValue(node, keys) {
|
|
958
|
+
if (!t11.isNode(node) || !t11.isClassProperty(node)) {
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
if (typeof this.key === "undefined") {
|
|
962
|
+
} else if (!this.key.matchValue(node.key, [...keys, "key"])) {
|
|
963
|
+
return false;
|
|
964
|
+
}
|
|
965
|
+
if (typeof this.value === "undefined") {
|
|
966
|
+
} else if (this.value === null) {
|
|
967
|
+
if (node.value !== null) {
|
|
968
|
+
return false;
|
|
969
|
+
}
|
|
970
|
+
} else if (!this.value.matchValue(node.value, [...keys, "value"])) {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
if (typeof this.typeAnnotation === "undefined") {
|
|
974
|
+
} else if (this.typeAnnotation === null) {
|
|
975
|
+
if (node.typeAnnotation !== null) {
|
|
976
|
+
return false;
|
|
977
|
+
}
|
|
978
|
+
} else if (!this.typeAnnotation.matchValue(node.typeAnnotation, [
|
|
979
|
+
...keys,
|
|
980
|
+
"typeAnnotation"
|
|
981
|
+
])) {
|
|
982
|
+
return false;
|
|
983
|
+
}
|
|
984
|
+
if (typeof this.decorators === "undefined") {
|
|
985
|
+
} else if (this.decorators === null) {
|
|
986
|
+
if (node.decorators !== null) {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
} else if (Array.isArray(this.decorators)) {
|
|
990
|
+
if (!tupleOf(...this.decorators).matchValue(node.decorators, [
|
|
991
|
+
...keys,
|
|
992
|
+
"decorators"
|
|
993
|
+
])) {
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
} else if (!this.decorators.matchValue(node.decorators, [...keys, "decorators"])) {
|
|
997
|
+
return false;
|
|
998
|
+
}
|
|
999
|
+
if (typeof this.computed === "undefined") {
|
|
1000
|
+
} else if (typeof this.computed === "boolean") {
|
|
1001
|
+
if (this.computed !== node.computed) {
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
1004
|
+
} else if (!this.computed.matchValue(node.computed, [...keys, "computed"])) {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof this._static === "undefined") {
|
|
1008
|
+
} else if (typeof this._static === "boolean") {
|
|
1009
|
+
if (this._static !== node.static) {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
} else if (!this._static.matchValue(node.static, [...keys, "static"])) {
|
|
1013
|
+
return false;
|
|
1014
|
+
}
|
|
1015
|
+
return true;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
class ConditionalExpressionMatcher extends Matcher {
|
|
1020
|
+
test;
|
|
1021
|
+
consequent;
|
|
1022
|
+
alternate;
|
|
1023
|
+
constructor(test, consequent, alternate) {
|
|
1024
|
+
super();
|
|
1025
|
+
this.test = test;
|
|
1026
|
+
this.consequent = consequent;
|
|
1027
|
+
this.alternate = alternate;
|
|
1028
|
+
}
|
|
1029
|
+
matchValue(node, keys) {
|
|
1030
|
+
if (!t11.isNode(node) || !t11.isConditionalExpression(node)) {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
if (typeof this.test === "undefined") {
|
|
1034
|
+
} else if (!this.test.matchValue(node.test, [...keys, "test"])) {
|
|
1035
|
+
return false;
|
|
1036
|
+
}
|
|
1037
|
+
if (typeof this.consequent === "undefined") {
|
|
1038
|
+
} else if (!this.consequent.matchValue(node.consequent, [...keys, "consequent"])) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
if (typeof this.alternate === "undefined") {
|
|
1042
|
+
} else if (!this.alternate.matchValue(node.alternate, [...keys, "alternate"])) {
|
|
1043
|
+
return false;
|
|
1044
|
+
}
|
|
1045
|
+
return true;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
class ContinueStatementMatcher extends Matcher {
|
|
1050
|
+
label;
|
|
1051
|
+
constructor(label) {
|
|
1052
|
+
super();
|
|
1053
|
+
this.label = label;
|
|
1054
|
+
}
|
|
1055
|
+
matchValue(node, keys) {
|
|
1056
|
+
if (!t11.isNode(node) || !t11.isContinueStatement(node)) {
|
|
1057
|
+
return false;
|
|
1058
|
+
}
|
|
1059
|
+
if (typeof this.label === "undefined") {
|
|
1060
|
+
} else if (this.label === null) {
|
|
1061
|
+
if (node.label !== null) {
|
|
1062
|
+
return false;
|
|
1063
|
+
}
|
|
1064
|
+
} else if (!this.label.matchValue(node.label, [...keys, "label"])) {
|
|
1065
|
+
return false;
|
|
1066
|
+
}
|
|
1067
|
+
return true;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
class ExpressionStatementMatcher extends Matcher {
|
|
1071
|
+
expression;
|
|
1072
|
+
constructor(expression) {
|
|
1073
|
+
super();
|
|
1074
|
+
this.expression = expression;
|
|
1075
|
+
}
|
|
1076
|
+
matchValue(node, keys) {
|
|
1077
|
+
if (!t11.isNode(node) || !t11.isExpressionStatement(node)) {
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
1080
|
+
if (typeof this.expression === "undefined") {
|
|
1081
|
+
} else if (!this.expression.matchValue(node.expression, [...keys, "expression"])) {
|
|
1082
|
+
return false;
|
|
1083
|
+
}
|
|
1084
|
+
return true;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
class ForInStatementMatcher extends Matcher {
|
|
1088
|
+
left;
|
|
1089
|
+
right;
|
|
1090
|
+
body;
|
|
1091
|
+
constructor(left, right, body) {
|
|
1092
|
+
super();
|
|
1093
|
+
this.left = left;
|
|
1094
|
+
this.right = right;
|
|
1095
|
+
this.body = body;
|
|
1096
|
+
}
|
|
1097
|
+
matchValue(node, keys) {
|
|
1098
|
+
if (!t11.isNode(node) || !t11.isForInStatement(node)) {
|
|
1099
|
+
return false;
|
|
1100
|
+
}
|
|
1101
|
+
if (typeof this.left === "undefined") {
|
|
1102
|
+
} else if (!this.left.matchValue(node.left, [...keys, "left"])) {
|
|
1103
|
+
return false;
|
|
1104
|
+
}
|
|
1105
|
+
if (typeof this.right === "undefined") {
|
|
1106
|
+
} else if (!this.right.matchValue(node.right, [...keys, "right"])) {
|
|
1107
|
+
return false;
|
|
1108
|
+
}
|
|
1109
|
+
if (typeof this.body === "undefined") {
|
|
1110
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1111
|
+
return false;
|
|
1112
|
+
}
|
|
1113
|
+
return true;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
class ForStatementMatcher extends Matcher {
|
|
1117
|
+
init;
|
|
1118
|
+
test;
|
|
1119
|
+
update;
|
|
1120
|
+
body;
|
|
1121
|
+
constructor(init, test, update, body) {
|
|
1122
|
+
super();
|
|
1123
|
+
this.init = init;
|
|
1124
|
+
this.test = test;
|
|
1125
|
+
this.update = update;
|
|
1126
|
+
this.body = body;
|
|
1127
|
+
}
|
|
1128
|
+
matchValue(node, keys) {
|
|
1129
|
+
if (!t11.isNode(node) || !t11.isForStatement(node)) {
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
if (typeof this.init === "undefined") {
|
|
1133
|
+
} else if (this.init === null) {
|
|
1134
|
+
if (node.init !== null) {
|
|
1135
|
+
return false;
|
|
1136
|
+
}
|
|
1137
|
+
} else if (!this.init.matchValue(node.init, [...keys, "init"])) {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
if (typeof this.test === "undefined") {
|
|
1141
|
+
} else if (this.test === null) {
|
|
1142
|
+
if (node.test !== null) {
|
|
1143
|
+
return false;
|
|
1144
|
+
}
|
|
1145
|
+
} else if (!this.test.matchValue(node.test, [...keys, "test"])) {
|
|
1146
|
+
return false;
|
|
1147
|
+
}
|
|
1148
|
+
if (typeof this.update === "undefined") {
|
|
1149
|
+
} else if (this.update === null) {
|
|
1150
|
+
if (node.update !== null) {
|
|
1151
|
+
return false;
|
|
1152
|
+
}
|
|
1153
|
+
} else if (!this.update.matchValue(node.update, [...keys, "update"])) {
|
|
1154
|
+
return false;
|
|
1155
|
+
}
|
|
1156
|
+
if (typeof this.body === "undefined") {
|
|
1157
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
return true;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
class FunctionDeclarationMatcher extends Matcher {
|
|
1165
|
+
id;
|
|
1166
|
+
params;
|
|
1167
|
+
body;
|
|
1168
|
+
generator2;
|
|
1169
|
+
async;
|
|
1170
|
+
constructor(id, params, body, generator2, async) {
|
|
1171
|
+
super();
|
|
1172
|
+
this.id = id;
|
|
1173
|
+
this.params = params;
|
|
1174
|
+
this.body = body;
|
|
1175
|
+
this.generator = generator2;
|
|
1176
|
+
this.async = async;
|
|
1177
|
+
}
|
|
1178
|
+
matchValue(node, keys) {
|
|
1179
|
+
if (!t11.isNode(node) || !t11.isFunctionDeclaration(node)) {
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
if (typeof this.id === "undefined") {
|
|
1183
|
+
} else if (this.id === null) {
|
|
1184
|
+
if (node.id !== null) {
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
} else if (!this.id.matchValue(node.id, [...keys, "id"])) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
if (typeof this.params === "undefined") {
|
|
1191
|
+
} else if (Array.isArray(this.params)) {
|
|
1192
|
+
if (!tupleOf(...this.params).matchValue(node.params, [
|
|
1193
|
+
...keys,
|
|
1194
|
+
"params"
|
|
1195
|
+
])) {
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
} else if (!this.params.matchValue(node.params, [...keys, "params"])) {
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
if (typeof this.body === "undefined") {
|
|
1202
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1203
|
+
return false;
|
|
1204
|
+
}
|
|
1205
|
+
if (typeof this.generator === "undefined") {
|
|
1206
|
+
} else if (typeof this.generator === "boolean") {
|
|
1207
|
+
if (this.generator !== node.generator) {
|
|
1208
|
+
return false;
|
|
1209
|
+
}
|
|
1210
|
+
} else if (!this.generator.matchValue(node.generator, [...keys, "generator"])) {
|
|
1211
|
+
return false;
|
|
1212
|
+
}
|
|
1213
|
+
if (typeof this.async === "undefined") {
|
|
1214
|
+
} else if (typeof this.async === "boolean") {
|
|
1215
|
+
if (this.async !== node.async) {
|
|
1216
|
+
return false;
|
|
1217
|
+
}
|
|
1218
|
+
} else if (!this.async.matchValue(node.async, [...keys, "async"])) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
return true;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
class FunctionExpressionMatcher extends Matcher {
|
|
1226
|
+
id;
|
|
1227
|
+
params;
|
|
1228
|
+
body;
|
|
1229
|
+
generator2;
|
|
1230
|
+
async;
|
|
1231
|
+
constructor(id, params, body, generator2, async) {
|
|
1232
|
+
super();
|
|
1233
|
+
this.id = id;
|
|
1234
|
+
this.params = params;
|
|
1235
|
+
this.body = body;
|
|
1236
|
+
this.generator = generator2;
|
|
1237
|
+
this.async = async;
|
|
1238
|
+
}
|
|
1239
|
+
matchValue(node, keys) {
|
|
1240
|
+
if (!t11.isNode(node) || !t11.isFunctionExpression(node)) {
|
|
1241
|
+
return false;
|
|
1242
|
+
}
|
|
1243
|
+
if (typeof this.id === "undefined") {
|
|
1244
|
+
} else if (this.id === null) {
|
|
1245
|
+
if (node.id !== null) {
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
} else if (!this.id.matchValue(node.id, [...keys, "id"])) {
|
|
1249
|
+
return false;
|
|
1250
|
+
}
|
|
1251
|
+
if (typeof this.params === "undefined") {
|
|
1252
|
+
} else if (Array.isArray(this.params)) {
|
|
1253
|
+
if (!tupleOf(...this.params).matchValue(node.params, [
|
|
1254
|
+
...keys,
|
|
1255
|
+
"params"
|
|
1256
|
+
])) {
|
|
1257
|
+
return false;
|
|
1258
|
+
}
|
|
1259
|
+
} else if (!this.params.matchValue(node.params, [...keys, "params"])) {
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
if (typeof this.body === "undefined") {
|
|
1263
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
if (typeof this.generator === "undefined") {
|
|
1267
|
+
} else if (typeof this.generator === "boolean") {
|
|
1268
|
+
if (this.generator !== node.generator) {
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
} else if (!this.generator.matchValue(node.generator, [...keys, "generator"])) {
|
|
1272
|
+
return false;
|
|
1273
|
+
}
|
|
1274
|
+
if (typeof this.async === "undefined") {
|
|
1275
|
+
} else if (typeof this.async === "boolean") {
|
|
1276
|
+
if (this.async !== node.async) {
|
|
1277
|
+
return false;
|
|
1278
|
+
}
|
|
1279
|
+
} else if (!this.async.matchValue(node.async, [...keys, "async"])) {
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
return true;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
class IdentifierMatcher extends Matcher {
|
|
1286
|
+
name;
|
|
1287
|
+
constructor(name) {
|
|
1288
|
+
super();
|
|
1289
|
+
this.name = name;
|
|
1290
|
+
}
|
|
1291
|
+
matchValue(node, keys) {
|
|
1292
|
+
if (!t11.isNode(node) || !t11.isIdentifier(node)) {
|
|
1293
|
+
return false;
|
|
1294
|
+
}
|
|
1295
|
+
if (typeof this.name === "undefined") {
|
|
1296
|
+
} else if (typeof this.name === "string") {
|
|
1297
|
+
if (this.name !== node.name) {
|
|
1298
|
+
return false;
|
|
1299
|
+
}
|
|
1300
|
+
} else if (!this.name.matchValue(node.name, [...keys, "name"])) {
|
|
1301
|
+
return false;
|
|
1302
|
+
}
|
|
1303
|
+
return true;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
class IfStatementMatcher extends Matcher {
|
|
1308
|
+
test;
|
|
1309
|
+
consequent;
|
|
1310
|
+
alternate;
|
|
1311
|
+
constructor(test, consequent, alternate) {
|
|
1312
|
+
super();
|
|
1313
|
+
this.test = test;
|
|
1314
|
+
this.consequent = consequent;
|
|
1315
|
+
this.alternate = alternate;
|
|
1316
|
+
}
|
|
1317
|
+
matchValue(node, keys) {
|
|
1318
|
+
if (!t11.isNode(node) || !t11.isIfStatement(node)) {
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
if (typeof this.test === "undefined") {
|
|
1322
|
+
} else if (!this.test.matchValue(node.test, [...keys, "test"])) {
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1325
|
+
if (typeof this.consequent === "undefined") {
|
|
1326
|
+
} else if (!this.consequent.matchValue(node.consequent, [...keys, "consequent"])) {
|
|
1327
|
+
return false;
|
|
1328
|
+
}
|
|
1329
|
+
if (typeof this.alternate === "undefined") {
|
|
1330
|
+
} else if (this.alternate === null) {
|
|
1331
|
+
if (node.alternate !== null) {
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
} else if (!this.alternate.matchValue(node.alternate, [...keys, "alternate"])) {
|
|
1335
|
+
return false;
|
|
1336
|
+
}
|
|
1337
|
+
return true;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
class LogicalExpressionMatcher extends Matcher {
|
|
1341
|
+
operator;
|
|
1342
|
+
left;
|
|
1343
|
+
right;
|
|
1344
|
+
constructor(operator, left, right) {
|
|
1345
|
+
super();
|
|
1346
|
+
this.operator = operator;
|
|
1347
|
+
this.left = left;
|
|
1348
|
+
this.right = right;
|
|
1349
|
+
}
|
|
1350
|
+
matchValue(node, keys) {
|
|
1351
|
+
if (!t11.isNode(node) || !t11.isLogicalExpression(node)) {
|
|
1352
|
+
return false;
|
|
1353
|
+
}
|
|
1354
|
+
if (typeof this.operator === "undefined") {
|
|
1355
|
+
} else if (typeof this.operator === "string") {
|
|
1356
|
+
if (this.operator !== node.operator) {
|
|
1357
|
+
return false;
|
|
1358
|
+
}
|
|
1359
|
+
} else if (!this.operator.matchValue(node.operator, [...keys, "operator"])) {
|
|
1360
|
+
return false;
|
|
1361
|
+
}
|
|
1362
|
+
if (typeof this.left === "undefined") {
|
|
1363
|
+
} else if (!this.left.matchValue(node.left, [...keys, "left"])) {
|
|
1364
|
+
return false;
|
|
1365
|
+
}
|
|
1366
|
+
if (typeof this.right === "undefined") {
|
|
1367
|
+
} else if (!this.right.matchValue(node.right, [...keys, "right"])) {
|
|
1368
|
+
return false;
|
|
1369
|
+
}
|
|
1370
|
+
return true;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
class MemberExpressionMatcher extends Matcher {
|
|
1375
|
+
object;
|
|
1376
|
+
property;
|
|
1377
|
+
computed;
|
|
1378
|
+
optional;
|
|
1379
|
+
constructor(object, property, computed, optional) {
|
|
1380
|
+
super();
|
|
1381
|
+
this.object = object;
|
|
1382
|
+
this.property = property;
|
|
1383
|
+
this.computed = computed;
|
|
1384
|
+
this.optional = optional;
|
|
1385
|
+
}
|
|
1386
|
+
matchValue(node, keys) {
|
|
1387
|
+
if (!t11.isNode(node) || !t11.isMemberExpression(node)) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
if (typeof this.object === "undefined") {
|
|
1391
|
+
} else if (!this.object.matchValue(node.object, [...keys, "object"])) {
|
|
1392
|
+
return false;
|
|
1393
|
+
}
|
|
1394
|
+
if (typeof this.property === "undefined") {
|
|
1395
|
+
} else if (!this.property.matchValue(node.property, [...keys, "property"])) {
|
|
1396
|
+
return false;
|
|
1397
|
+
}
|
|
1398
|
+
if (typeof this.computed === "undefined") {
|
|
1399
|
+
} else if (typeof this.computed === "boolean") {
|
|
1400
|
+
if (this.computed !== node.computed) {
|
|
1401
|
+
return false;
|
|
1402
|
+
}
|
|
1403
|
+
} else if (!this.computed.matchValue(node.computed, [...keys, "computed"])) {
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
if (typeof this.optional === "undefined") {
|
|
1407
|
+
} else if (typeof this.optional === "boolean") {
|
|
1408
|
+
if (this.optional !== node.optional) {
|
|
1409
|
+
return false;
|
|
1410
|
+
}
|
|
1411
|
+
} else if (this.optional === null) {
|
|
1412
|
+
if (node.optional !== null) {
|
|
1413
|
+
return false;
|
|
1414
|
+
}
|
|
1415
|
+
} else if (!this.optional.matchValue(node.optional, [...keys, "optional"])) {
|
|
1416
|
+
return false;
|
|
1417
|
+
}
|
|
1418
|
+
return true;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
class NullLiteralMatcher extends Matcher {
|
|
1422
|
+
constructor() {
|
|
1423
|
+
super();
|
|
1424
|
+
}
|
|
1425
|
+
matchValue(node, keys) {
|
|
1426
|
+
if (!t11.isNode(node) || !t11.isNullLiteral(node)) {
|
|
1427
|
+
return false;
|
|
1428
|
+
}
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
class NumericLiteralMatcher extends Matcher {
|
|
1433
|
+
value;
|
|
1434
|
+
constructor(value) {
|
|
1435
|
+
super();
|
|
1436
|
+
this.value = value;
|
|
1437
|
+
}
|
|
1438
|
+
matchValue(node, keys) {
|
|
1439
|
+
if (!t11.isNode(node) || !t11.isNumericLiteral(node)) {
|
|
1440
|
+
return false;
|
|
1441
|
+
}
|
|
1442
|
+
if (typeof this.value === "undefined") {
|
|
1443
|
+
} else if (typeof this.value === "number") {
|
|
1444
|
+
if (this.value !== node.value) {
|
|
1445
|
+
return false;
|
|
1446
|
+
}
|
|
1447
|
+
} else if (!this.value.matchValue(node.value, [...keys, "value"])) {
|
|
1448
|
+
return false;
|
|
1449
|
+
}
|
|
1450
|
+
return true;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
class ObjectExpressionMatcher extends Matcher {
|
|
1455
|
+
properties;
|
|
1456
|
+
constructor(properties) {
|
|
1457
|
+
super();
|
|
1458
|
+
this.properties = properties;
|
|
1459
|
+
}
|
|
1460
|
+
matchValue(node, keys) {
|
|
1461
|
+
if (!t11.isNode(node) || !t11.isObjectExpression(node)) {
|
|
1462
|
+
return false;
|
|
1463
|
+
}
|
|
1464
|
+
if (typeof this.properties === "undefined") {
|
|
1465
|
+
} else if (Array.isArray(this.properties)) {
|
|
1466
|
+
if (!tupleOf(...this.properties).matchValue(node.properties, [
|
|
1467
|
+
...keys,
|
|
1468
|
+
"properties"
|
|
1469
|
+
])) {
|
|
1470
|
+
return false;
|
|
1471
|
+
}
|
|
1472
|
+
} else if (!this.properties.matchValue(node.properties, [...keys, "properties"])) {
|
|
1473
|
+
return false;
|
|
1474
|
+
}
|
|
1475
|
+
return true;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
class ObjectMethodMatcher extends Matcher {
|
|
1480
|
+
kind;
|
|
1481
|
+
key;
|
|
1482
|
+
params;
|
|
1483
|
+
body;
|
|
1484
|
+
computed;
|
|
1485
|
+
generator2;
|
|
1486
|
+
async;
|
|
1487
|
+
constructor(kind, key, params, body, computed, generator2, async) {
|
|
1488
|
+
super();
|
|
1489
|
+
this.kind = kind;
|
|
1490
|
+
this.key = key;
|
|
1491
|
+
this.params = params;
|
|
1492
|
+
this.body = body;
|
|
1493
|
+
this.computed = computed;
|
|
1494
|
+
this.generator = generator2;
|
|
1495
|
+
this.async = async;
|
|
1496
|
+
}
|
|
1497
|
+
matchValue(node, keys) {
|
|
1498
|
+
if (!t11.isNode(node) || !t11.isObjectMethod(node)) {
|
|
1499
|
+
return false;
|
|
1500
|
+
}
|
|
1501
|
+
if (typeof this.kind === "undefined") {
|
|
1502
|
+
} else if (typeof this.kind === "string") {
|
|
1503
|
+
if (this.kind !== node.kind) {
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
} else if (!this.kind.matchValue(node.kind, [...keys, "kind"])) {
|
|
1507
|
+
return false;
|
|
1508
|
+
}
|
|
1509
|
+
if (typeof this.key === "undefined") {
|
|
1510
|
+
} else if (!this.key.matchValue(node.key, [...keys, "key"])) {
|
|
1511
|
+
return false;
|
|
1512
|
+
}
|
|
1513
|
+
if (typeof this.params === "undefined") {
|
|
1514
|
+
} else if (Array.isArray(this.params)) {
|
|
1515
|
+
if (!tupleOf(...this.params).matchValue(node.params, [
|
|
1516
|
+
...keys,
|
|
1517
|
+
"params"
|
|
1518
|
+
])) {
|
|
1519
|
+
return false;
|
|
1520
|
+
}
|
|
1521
|
+
} else if (!this.params.matchValue(node.params, [...keys, "params"])) {
|
|
1522
|
+
return false;
|
|
1523
|
+
}
|
|
1524
|
+
if (typeof this.body === "undefined") {
|
|
1525
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
1526
|
+
return false;
|
|
1527
|
+
}
|
|
1528
|
+
if (typeof this.computed === "undefined") {
|
|
1529
|
+
} else if (typeof this.computed === "boolean") {
|
|
1530
|
+
if (this.computed !== node.computed) {
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
} else if (!this.computed.matchValue(node.computed, [...keys, "computed"])) {
|
|
1534
|
+
return false;
|
|
1535
|
+
}
|
|
1536
|
+
if (typeof this.generator === "undefined") {
|
|
1537
|
+
} else if (typeof this.generator === "boolean") {
|
|
1538
|
+
if (this.generator !== node.generator) {
|
|
1539
|
+
return false;
|
|
1540
|
+
}
|
|
1541
|
+
} else if (!this.generator.matchValue(node.generator, [...keys, "generator"])) {
|
|
1542
|
+
return false;
|
|
1543
|
+
}
|
|
1544
|
+
if (typeof this.async === "undefined") {
|
|
1545
|
+
} else if (typeof this.async === "boolean") {
|
|
1546
|
+
if (this.async !== node.async) {
|
|
1547
|
+
return false;
|
|
1548
|
+
}
|
|
1549
|
+
} else if (!this.async.matchValue(node.async, [...keys, "async"])) {
|
|
1550
|
+
return false;
|
|
1551
|
+
}
|
|
1552
|
+
return true;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
52
1555
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1556
|
+
class ObjectPatternMatcher extends Matcher {
|
|
1557
|
+
properties;
|
|
1558
|
+
constructor(properties) {
|
|
1559
|
+
super();
|
|
1560
|
+
this.properties = properties;
|
|
1561
|
+
}
|
|
1562
|
+
matchValue(node, keys) {
|
|
1563
|
+
if (!t11.isNode(node) || !t11.isObjectPattern(node)) {
|
|
1564
|
+
return false;
|
|
1565
|
+
}
|
|
1566
|
+
if (typeof this.properties === "undefined") {
|
|
1567
|
+
} else if (Array.isArray(this.properties)) {
|
|
1568
|
+
if (!tupleOf(...this.properties).matchValue(node.properties, [
|
|
1569
|
+
...keys,
|
|
1570
|
+
"properties"
|
|
1571
|
+
])) {
|
|
1572
|
+
return false;
|
|
1573
|
+
}
|
|
1574
|
+
} else if (!this.properties.matchValue(node.properties, [...keys, "properties"])) {
|
|
1575
|
+
return false;
|
|
1576
|
+
}
|
|
1577
|
+
return true;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
class ObjectPropertyMatcher extends Matcher {
|
|
1582
|
+
key;
|
|
1583
|
+
value;
|
|
1584
|
+
computed;
|
|
1585
|
+
shorthand;
|
|
1586
|
+
decorators;
|
|
1587
|
+
constructor(key, value, computed, shorthand, decorators) {
|
|
1588
|
+
super();
|
|
1589
|
+
this.key = key;
|
|
1590
|
+
this.value = value;
|
|
1591
|
+
this.computed = computed;
|
|
1592
|
+
this.shorthand = shorthand;
|
|
1593
|
+
this.decorators = decorators;
|
|
1594
|
+
}
|
|
1595
|
+
matchValue(node, keys) {
|
|
1596
|
+
if (!t11.isNode(node) || !t11.isObjectProperty(node)) {
|
|
1597
|
+
return false;
|
|
1598
|
+
}
|
|
1599
|
+
if (typeof this.key === "undefined") {
|
|
1600
|
+
} else if (!this.key.matchValue(node.key, [...keys, "key"])) {
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
if (typeof this.value === "undefined") {
|
|
1604
|
+
} else if (!this.value.matchValue(node.value, [...keys, "value"])) {
|
|
1605
|
+
return false;
|
|
1606
|
+
}
|
|
1607
|
+
if (typeof this.computed === "undefined") {
|
|
1608
|
+
} else if (typeof this.computed === "boolean") {
|
|
1609
|
+
if (this.computed !== node.computed) {
|
|
1610
|
+
return false;
|
|
1611
|
+
}
|
|
1612
|
+
} else if (!this.computed.matchValue(node.computed, [...keys, "computed"])) {
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
if (typeof this.shorthand === "undefined") {
|
|
1616
|
+
} else if (typeof this.shorthand === "boolean") {
|
|
1617
|
+
if (this.shorthand !== node.shorthand) {
|
|
1618
|
+
return false;
|
|
1619
|
+
}
|
|
1620
|
+
} else if (!this.shorthand.matchValue(node.shorthand, [...keys, "shorthand"])) {
|
|
1621
|
+
return false;
|
|
1622
|
+
}
|
|
1623
|
+
if (typeof this.decorators === "undefined") {
|
|
1624
|
+
} else if (this.decorators === null) {
|
|
1625
|
+
if (node.decorators !== null) {
|
|
1626
|
+
return false;
|
|
1627
|
+
}
|
|
1628
|
+
} else if (Array.isArray(this.decorators)) {
|
|
1629
|
+
if (!tupleOf(...this.decorators).matchValue(node.decorators, [
|
|
1630
|
+
...keys,
|
|
1631
|
+
"decorators"
|
|
1632
|
+
])) {
|
|
1633
|
+
return false;
|
|
1634
|
+
}
|
|
1635
|
+
} else if (!this.decorators.matchValue(node.decorators, [...keys, "decorators"])) {
|
|
1636
|
+
return false;
|
|
1637
|
+
}
|
|
1638
|
+
return true;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
class OptionalMemberExpressionMatcher extends Matcher {
|
|
1642
|
+
object;
|
|
1643
|
+
property;
|
|
1644
|
+
computed;
|
|
1645
|
+
optional;
|
|
1646
|
+
constructor(object, property, computed, optional) {
|
|
1647
|
+
super();
|
|
1648
|
+
this.object = object;
|
|
1649
|
+
this.property = property;
|
|
1650
|
+
this.computed = computed;
|
|
1651
|
+
this.optional = optional;
|
|
1652
|
+
}
|
|
1653
|
+
matchValue(node, keys) {
|
|
1654
|
+
if (!t11.isNode(node) || !t11.isOptionalMemberExpression(node)) {
|
|
1655
|
+
return false;
|
|
1656
|
+
}
|
|
1657
|
+
if (typeof this.object === "undefined") {
|
|
1658
|
+
} else if (!this.object.matchValue(node.object, [...keys, "object"])) {
|
|
1659
|
+
return false;
|
|
1660
|
+
}
|
|
1661
|
+
if (typeof this.property === "undefined") {
|
|
1662
|
+
} else if (!this.property.matchValue(node.property, [...keys, "property"])) {
|
|
1663
|
+
return false;
|
|
1664
|
+
}
|
|
1665
|
+
if (typeof this.computed === "undefined") {
|
|
1666
|
+
} else if (typeof this.computed === "boolean") {
|
|
1667
|
+
if (this.computed !== node.computed) {
|
|
1668
|
+
return false;
|
|
1669
|
+
}
|
|
1670
|
+
} else if (!this.computed.matchValue(node.computed, [...keys, "computed"])) {
|
|
1671
|
+
return false;
|
|
1672
|
+
}
|
|
1673
|
+
if (typeof this.optional === "undefined") {
|
|
1674
|
+
} else if (typeof this.optional === "boolean") {
|
|
1675
|
+
if (this.optional !== node.optional) {
|
|
1676
|
+
return false;
|
|
1677
|
+
}
|
|
1678
|
+
} else if (!this.optional.matchValue(node.optional, [...keys, "optional"])) {
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
return true;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
class RestElementMatcher extends Matcher {
|
|
1685
|
+
argument;
|
|
1686
|
+
constructor(argument) {
|
|
1687
|
+
super();
|
|
1688
|
+
this.argument = argument;
|
|
1689
|
+
}
|
|
1690
|
+
matchValue(node, keys) {
|
|
1691
|
+
if (!t11.isNode(node) || !t11.isRestElement(node)) {
|
|
1692
|
+
return false;
|
|
1693
|
+
}
|
|
1694
|
+
if (typeof this.argument === "undefined") {
|
|
1695
|
+
} else if (!this.argument.matchValue(node.argument, [...keys, "argument"])) {
|
|
1696
|
+
return false;
|
|
1697
|
+
}
|
|
1698
|
+
return true;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
class ReturnStatementMatcher extends Matcher {
|
|
1703
|
+
argument;
|
|
1704
|
+
constructor(argument) {
|
|
1705
|
+
super();
|
|
1706
|
+
this.argument = argument;
|
|
1707
|
+
}
|
|
1708
|
+
matchValue(node, keys) {
|
|
1709
|
+
if (!t11.isNode(node) || !t11.isReturnStatement(node)) {
|
|
1710
|
+
return false;
|
|
1711
|
+
}
|
|
1712
|
+
if (typeof this.argument === "undefined") {
|
|
1713
|
+
} else if (this.argument === null) {
|
|
1714
|
+
if (node.argument !== null) {
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
1717
|
+
} else if (!this.argument.matchValue(node.argument, [...keys, "argument"])) {
|
|
1718
|
+
return false;
|
|
1719
|
+
}
|
|
1720
|
+
return true;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
class SequenceExpressionMatcher extends Matcher {
|
|
1725
|
+
expressions;
|
|
1726
|
+
constructor(expressions) {
|
|
1727
|
+
super();
|
|
1728
|
+
this.expressions = expressions;
|
|
1729
|
+
}
|
|
1730
|
+
matchValue(node, keys) {
|
|
1731
|
+
if (!t11.isNode(node) || !t11.isSequenceExpression(node)) {
|
|
1732
|
+
return false;
|
|
1733
|
+
}
|
|
1734
|
+
if (typeof this.expressions === "undefined") {
|
|
1735
|
+
} else if (Array.isArray(this.expressions)) {
|
|
1736
|
+
if (!tupleOf(...this.expressions).matchValue(node.expressions, [
|
|
1737
|
+
...keys,
|
|
1738
|
+
"expressions"
|
|
1739
|
+
])) {
|
|
1740
|
+
return false;
|
|
1741
|
+
}
|
|
1742
|
+
} else if (!this.expressions.matchValue(node.expressions, [...keys, "expressions"])) {
|
|
1743
|
+
return false;
|
|
1744
|
+
}
|
|
1745
|
+
return true;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
class SpreadElementMatcher extends Matcher {
|
|
1750
|
+
argument;
|
|
1751
|
+
constructor(argument) {
|
|
1752
|
+
super();
|
|
1753
|
+
this.argument = argument;
|
|
1754
|
+
}
|
|
1755
|
+
matchValue(node, keys) {
|
|
1756
|
+
if (!t11.isNode(node) || !t11.isSpreadElement(node)) {
|
|
1757
|
+
return false;
|
|
1758
|
+
}
|
|
1759
|
+
if (typeof this.argument === "undefined") {
|
|
1760
|
+
} else if (!this.argument.matchValue(node.argument, [...keys, "argument"])) {
|
|
1761
|
+
return false;
|
|
1762
|
+
}
|
|
1763
|
+
return true;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
class StringLiteralMatcher extends Matcher {
|
|
1767
|
+
value;
|
|
1768
|
+
constructor(value) {
|
|
1769
|
+
super();
|
|
1770
|
+
this.value = value;
|
|
1771
|
+
}
|
|
1772
|
+
matchValue(node, keys) {
|
|
1773
|
+
if (!t11.isNode(node) || !t11.isStringLiteral(node)) {
|
|
1774
|
+
return false;
|
|
1775
|
+
}
|
|
1776
|
+
if (typeof this.value === "undefined") {
|
|
1777
|
+
} else if (typeof this.value === "string") {
|
|
1778
|
+
if (this.value !== node.value) {
|
|
1779
|
+
return false;
|
|
1780
|
+
}
|
|
1781
|
+
} else if (!this.value.matchValue(node.value, [...keys, "value"])) {
|
|
1782
|
+
return false;
|
|
1783
|
+
}
|
|
1784
|
+
return true;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
class SwitchCaseMatcher extends Matcher {
|
|
1788
|
+
test;
|
|
1789
|
+
consequent;
|
|
1790
|
+
constructor(test, consequent) {
|
|
1791
|
+
super();
|
|
1792
|
+
this.test = test;
|
|
1793
|
+
this.consequent = consequent;
|
|
1794
|
+
}
|
|
1795
|
+
matchValue(node, keys) {
|
|
1796
|
+
if (!t11.isNode(node) || !t11.isSwitchCase(node)) {
|
|
1797
|
+
return false;
|
|
1798
|
+
}
|
|
1799
|
+
if (typeof this.test === "undefined") {
|
|
1800
|
+
} else if (this.test === null) {
|
|
1801
|
+
if (node.test !== null) {
|
|
1802
|
+
return false;
|
|
1803
|
+
}
|
|
1804
|
+
} else if (!this.test.matchValue(node.test, [...keys, "test"])) {
|
|
1805
|
+
return false;
|
|
1806
|
+
}
|
|
1807
|
+
if (typeof this.consequent === "undefined") {
|
|
1808
|
+
} else if (Array.isArray(this.consequent)) {
|
|
1809
|
+
if (!tupleOf(...this.consequent).matchValue(node.consequent, [
|
|
1810
|
+
...keys,
|
|
1811
|
+
"consequent"
|
|
1812
|
+
])) {
|
|
1813
|
+
return false;
|
|
1814
|
+
}
|
|
1815
|
+
} else if (!this.consequent.matchValue(node.consequent, [...keys, "consequent"])) {
|
|
1816
|
+
return false;
|
|
1817
|
+
}
|
|
1818
|
+
return true;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
class SwitchStatementMatcher extends Matcher {
|
|
1823
|
+
discriminant;
|
|
1824
|
+
cases;
|
|
1825
|
+
constructor(discriminant, cases) {
|
|
1826
|
+
super();
|
|
1827
|
+
this.discriminant = discriminant;
|
|
1828
|
+
this.cases = cases;
|
|
1829
|
+
}
|
|
1830
|
+
matchValue(node, keys) {
|
|
1831
|
+
if (!t11.isNode(node) || !t11.isSwitchStatement(node)) {
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
if (typeof this.discriminant === "undefined") {
|
|
1835
|
+
} else if (!this.discriminant.matchValue(node.discriminant, [
|
|
1836
|
+
...keys,
|
|
1837
|
+
"discriminant"
|
|
1838
|
+
])) {
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
if (typeof this.cases === "undefined") {
|
|
1842
|
+
} else if (Array.isArray(this.cases)) {
|
|
1843
|
+
if (!tupleOf(...this.cases).matchValue(node.cases, [
|
|
1844
|
+
...keys,
|
|
1845
|
+
"cases"
|
|
1846
|
+
])) {
|
|
1847
|
+
return false;
|
|
1848
|
+
}
|
|
1849
|
+
} else if (!this.cases.matchValue(node.cases, [...keys, "cases"])) {
|
|
1850
|
+
return false;
|
|
1851
|
+
}
|
|
1852
|
+
return true;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
class TemplateLiteralMatcher extends Matcher {
|
|
1856
|
+
quasis;
|
|
1857
|
+
expressions;
|
|
1858
|
+
constructor(quasis, expressions) {
|
|
1859
|
+
super();
|
|
1860
|
+
this.quasis = quasis;
|
|
1861
|
+
this.expressions = expressions;
|
|
1862
|
+
}
|
|
1863
|
+
matchValue(node, keys) {
|
|
1864
|
+
if (!t11.isNode(node) || !t11.isTemplateLiteral(node)) {
|
|
1865
|
+
return false;
|
|
1866
|
+
}
|
|
1867
|
+
if (typeof this.quasis === "undefined") {
|
|
1868
|
+
} else if (Array.isArray(this.quasis)) {
|
|
1869
|
+
if (!tupleOf(...this.quasis).matchValue(node.quasis, [
|
|
1870
|
+
...keys,
|
|
1871
|
+
"quasis"
|
|
1872
|
+
])) {
|
|
1873
|
+
return false;
|
|
1874
|
+
}
|
|
1875
|
+
} else if (!this.quasis.matchValue(node.quasis, [...keys, "quasis"])) {
|
|
1876
|
+
return false;
|
|
1877
|
+
}
|
|
1878
|
+
if (typeof this.expressions === "undefined") {
|
|
1879
|
+
} else if (Array.isArray(this.expressions)) {
|
|
1880
|
+
if (!tupleOf(...this.expressions).matchValue(node.expressions, [
|
|
1881
|
+
...keys,
|
|
1882
|
+
"expressions"
|
|
1883
|
+
])) {
|
|
1884
|
+
return false;
|
|
1885
|
+
}
|
|
1886
|
+
} else if (!this.expressions.matchValue(node.expressions, [...keys, "expressions"])) {
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
return true;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
class ThisExpressionMatcher extends Matcher {
|
|
1894
|
+
constructor() {
|
|
1895
|
+
super();
|
|
1896
|
+
}
|
|
1897
|
+
matchValue(node, keys) {
|
|
1898
|
+
if (!t11.isNode(node) || !t11.isThisExpression(node)) {
|
|
1899
|
+
return false;
|
|
1900
|
+
}
|
|
1901
|
+
return true;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
class TryStatementMatcher extends Matcher {
|
|
1905
|
+
block;
|
|
1906
|
+
handler;
|
|
1907
|
+
finalizer;
|
|
1908
|
+
constructor(block, handler, finalizer) {
|
|
1909
|
+
super();
|
|
1910
|
+
this.block = block;
|
|
1911
|
+
this.handler = handler;
|
|
1912
|
+
this.finalizer = finalizer;
|
|
1913
|
+
}
|
|
1914
|
+
matchValue(node, keys) {
|
|
1915
|
+
if (!t11.isNode(node) || !t11.isTryStatement(node)) {
|
|
1916
|
+
return false;
|
|
1917
|
+
}
|
|
1918
|
+
if (typeof this.block === "undefined") {
|
|
1919
|
+
} else if (!this.block.matchValue(node.block, [...keys, "block"])) {
|
|
1920
|
+
return false;
|
|
1921
|
+
}
|
|
1922
|
+
if (typeof this.handler === "undefined") {
|
|
1923
|
+
} else if (this.handler === null) {
|
|
1924
|
+
if (node.handler !== null) {
|
|
1925
|
+
return false;
|
|
1926
|
+
}
|
|
1927
|
+
} else if (!this.handler.matchValue(node.handler, [...keys, "handler"])) {
|
|
1928
|
+
return false;
|
|
1929
|
+
}
|
|
1930
|
+
if (typeof this.finalizer === "undefined") {
|
|
1931
|
+
} else if (this.finalizer === null) {
|
|
1932
|
+
if (node.finalizer !== null) {
|
|
1933
|
+
return false;
|
|
1934
|
+
}
|
|
1935
|
+
} else if (!this.finalizer.matchValue(node.finalizer, [...keys, "finalizer"])) {
|
|
1936
|
+
return false;
|
|
1937
|
+
}
|
|
1938
|
+
return true;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
class UnaryExpressionMatcher extends Matcher {
|
|
1942
|
+
operator;
|
|
1943
|
+
argument;
|
|
1944
|
+
prefix;
|
|
1945
|
+
constructor(operator, argument, prefix) {
|
|
1946
|
+
super();
|
|
1947
|
+
this.operator = operator;
|
|
1948
|
+
this.argument = argument;
|
|
1949
|
+
this.prefix = prefix;
|
|
1950
|
+
}
|
|
1951
|
+
matchValue(node, keys) {
|
|
1952
|
+
if (!t11.isNode(node) || !t11.isUnaryExpression(node)) {
|
|
1953
|
+
return false;
|
|
1954
|
+
}
|
|
1955
|
+
if (typeof this.operator === "undefined") {
|
|
1956
|
+
} else if (typeof this.operator === "string") {
|
|
1957
|
+
if (this.operator !== node.operator) {
|
|
1958
|
+
return false;
|
|
1959
|
+
}
|
|
1960
|
+
} else if (!this.operator.matchValue(node.operator, [...keys, "operator"])) {
|
|
1961
|
+
return false;
|
|
1962
|
+
}
|
|
1963
|
+
if (typeof this.argument === "undefined") {
|
|
1964
|
+
} else if (!this.argument.matchValue(node.argument, [...keys, "argument"])) {
|
|
1965
|
+
return false;
|
|
1966
|
+
}
|
|
1967
|
+
if (typeof this.prefix === "undefined") {
|
|
1968
|
+
} else if (typeof this.prefix === "boolean") {
|
|
1969
|
+
if (this.prefix !== node.prefix) {
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
} else if (!this.prefix.matchValue(node.prefix, [...keys, "prefix"])) {
|
|
1973
|
+
return false;
|
|
1974
|
+
}
|
|
1975
|
+
return true;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
class UpdateExpressionMatcher extends Matcher {
|
|
1979
|
+
operator;
|
|
1980
|
+
argument;
|
|
1981
|
+
prefix;
|
|
1982
|
+
constructor(operator, argument, prefix) {
|
|
1983
|
+
super();
|
|
1984
|
+
this.operator = operator;
|
|
1985
|
+
this.argument = argument;
|
|
1986
|
+
this.prefix = prefix;
|
|
1987
|
+
}
|
|
1988
|
+
matchValue(node, keys) {
|
|
1989
|
+
if (!t11.isNode(node) || !t11.isUpdateExpression(node)) {
|
|
1990
|
+
return false;
|
|
1991
|
+
}
|
|
1992
|
+
if (typeof this.operator === "undefined") {
|
|
1993
|
+
} else if (typeof this.operator === "string") {
|
|
1994
|
+
if (this.operator !== node.operator) {
|
|
1995
|
+
return false;
|
|
1996
|
+
}
|
|
1997
|
+
} else if (!this.operator.matchValue(node.operator, [...keys, "operator"])) {
|
|
1998
|
+
return false;
|
|
1999
|
+
}
|
|
2000
|
+
if (typeof this.argument === "undefined") {
|
|
2001
|
+
} else if (!this.argument.matchValue(node.argument, [...keys, "argument"])) {
|
|
2002
|
+
return false;
|
|
2003
|
+
}
|
|
2004
|
+
if (typeof this.prefix === "undefined") {
|
|
2005
|
+
} else if (typeof this.prefix === "boolean") {
|
|
2006
|
+
if (this.prefix !== node.prefix) {
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
2009
|
+
} else if (!this.prefix.matchValue(node.prefix, [...keys, "prefix"])) {
|
|
2010
|
+
return false;
|
|
2011
|
+
}
|
|
2012
|
+
return true;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
class VariableDeclarationMatcher extends Matcher {
|
|
2016
|
+
kind;
|
|
2017
|
+
declarations;
|
|
2018
|
+
constructor(kind, declarations) {
|
|
2019
|
+
super();
|
|
2020
|
+
this.kind = kind;
|
|
2021
|
+
this.declarations = declarations;
|
|
2022
|
+
}
|
|
2023
|
+
matchValue(node, keys) {
|
|
2024
|
+
if (!t11.isNode(node) || !t11.isVariableDeclaration(node)) {
|
|
2025
|
+
return false;
|
|
2026
|
+
}
|
|
2027
|
+
if (typeof this.kind === "undefined") {
|
|
2028
|
+
} else if (typeof this.kind === "string") {
|
|
2029
|
+
if (this.kind !== node.kind) {
|
|
2030
|
+
return false;
|
|
2031
|
+
}
|
|
2032
|
+
} else if (!this.kind.matchValue(node.kind, [...keys, "kind"])) {
|
|
2033
|
+
return false;
|
|
2034
|
+
}
|
|
2035
|
+
if (typeof this.declarations === "undefined") {
|
|
2036
|
+
} else if (Array.isArray(this.declarations)) {
|
|
2037
|
+
if (!tupleOf(...this.declarations).matchValue(node.declarations, [
|
|
2038
|
+
...keys,
|
|
2039
|
+
"declarations"
|
|
2040
|
+
])) {
|
|
2041
|
+
return false;
|
|
2042
|
+
}
|
|
2043
|
+
} else if (!this.declarations.matchValue(node.declarations, [
|
|
2044
|
+
...keys,
|
|
2045
|
+
"declarations"
|
|
2046
|
+
])) {
|
|
2047
|
+
return false;
|
|
2048
|
+
}
|
|
2049
|
+
return true;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
class VariableDeclaratorMatcher extends Matcher {
|
|
2054
|
+
id;
|
|
2055
|
+
init;
|
|
2056
|
+
constructor(id, init) {
|
|
2057
|
+
super();
|
|
2058
|
+
this.id = id;
|
|
2059
|
+
this.init = init;
|
|
2060
|
+
}
|
|
2061
|
+
matchValue(node, keys) {
|
|
2062
|
+
if (!t11.isNode(node) || !t11.isVariableDeclarator(node)) {
|
|
2063
|
+
return false;
|
|
2064
|
+
}
|
|
2065
|
+
if (typeof this.id === "undefined") {
|
|
2066
|
+
} else if (!this.id.matchValue(node.id, [...keys, "id"])) {
|
|
2067
|
+
return false;
|
|
2068
|
+
}
|
|
2069
|
+
if (typeof this.init === "undefined") {
|
|
2070
|
+
} else if (this.init === null) {
|
|
2071
|
+
if (node.init !== null) {
|
|
2072
|
+
return false;
|
|
2073
|
+
}
|
|
2074
|
+
} else if (!this.init.matchValue(node.init, [...keys, "init"])) {
|
|
2075
|
+
return false;
|
|
2076
|
+
}
|
|
2077
|
+
return true;
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
class WhileStatementMatcher extends Matcher {
|
|
2081
|
+
test;
|
|
2082
|
+
body;
|
|
2083
|
+
constructor(test, body) {
|
|
2084
|
+
super();
|
|
2085
|
+
this.test = test;
|
|
2086
|
+
this.body = body;
|
|
2087
|
+
}
|
|
2088
|
+
matchValue(node, keys) {
|
|
2089
|
+
if (!t11.isNode(node) || !t11.isWhileStatement(node)) {
|
|
2090
|
+
return false;
|
|
2091
|
+
}
|
|
2092
|
+
if (typeof this.test === "undefined") {
|
|
2093
|
+
} else if (!this.test.matchValue(node.test, [...keys, "test"])) {
|
|
2094
|
+
return false;
|
|
2095
|
+
}
|
|
2096
|
+
if (typeof this.body === "undefined") {
|
|
2097
|
+
} else if (!this.body.matchValue(node.body, [...keys, "body"])) {
|
|
2098
|
+
return false;
|
|
2099
|
+
}
|
|
2100
|
+
return true;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/or.ts
|
|
2104
|
+
function or(...matchersOrValues) {
|
|
2105
|
+
return new OrMatcher(...matchersOrValues);
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
class OrMatcher extends Matcher {
|
|
2109
|
+
matchersOrValues;
|
|
2110
|
+
constructor(...matchersOrValues) {
|
|
2111
|
+
super();
|
|
2112
|
+
this.matchersOrValues = matchersOrValues;
|
|
2113
|
+
}
|
|
2114
|
+
matchValue(value, keys) {
|
|
2115
|
+
for (const matcherOrValue of this.matchersOrValues) {
|
|
2116
|
+
if (matcherOrValue instanceof Matcher) {
|
|
2117
|
+
if (matcherOrValue.matchValue(value, keys)) {
|
|
2118
|
+
return true;
|
|
2119
|
+
}
|
|
2120
|
+
} else if (matcherOrValue === value) {
|
|
2121
|
+
return true;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
return false;
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=codemod-js+codemod+packages@matchers&commit=f7526b4223cf97_sq4rt2xlb3cg2qja5fg2vnnn4u/node_modules/@codemod/matchers/src/matchers/predicate.ts
|
|
2128
|
+
function predicate(predicate2) {
|
|
2129
|
+
return new PredicateMatcher(predicate2);
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
class PredicateMatcher extends Matcher {
|
|
2133
|
+
predicate2;
|
|
2134
|
+
constructor(predicate2) {
|
|
2135
|
+
super();
|
|
2136
|
+
this.predicate = predicate2;
|
|
2137
|
+
}
|
|
2138
|
+
matchValue(value) {
|
|
2139
|
+
return this.predicate(value);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/matcher.ts
|
|
2143
|
+
import * as t12 from "@babel/types";
|
|
56
2144
|
function infiniteLoop(body) {
|
|
57
|
-
return
|
|
2145
|
+
return or(forStatement(undefined, null, undefined, body), forStatement(undefined, truthyMatcher, undefined, body), whileStatement(truthyMatcher, body));
|
|
58
2146
|
}
|
|
59
2147
|
function constKey(name) {
|
|
60
|
-
return
|
|
2148
|
+
return or(identifier(name), stringLiteral(name));
|
|
61
2149
|
}
|
|
62
2150
|
function constObjectProperty(value) {
|
|
63
|
-
return
|
|
2151
|
+
return or(objectProperty(identifier(), value, false), objectProperty(or(stringLiteral(), numericLiteral()), value));
|
|
64
2152
|
}
|
|
65
2153
|
function matchIife(body) {
|
|
66
|
-
return
|
|
2154
|
+
return callExpression(functionExpression(null, [], body ? blockStatement(body) : undefined), []);
|
|
67
2155
|
}
|
|
68
2156
|
function constMemberExpression(object, property) {
|
|
69
2157
|
if (typeof object === "string")
|
|
70
|
-
object =
|
|
71
|
-
return
|
|
2158
|
+
object = identifier(object);
|
|
2159
|
+
return or(memberExpression(object, identifier(property), false), memberExpression(object, stringLiteral(property), true));
|
|
72
2160
|
}
|
|
73
|
-
function findParent(path,
|
|
74
|
-
return path.findParent((path2) =>
|
|
2161
|
+
function findParent(path, matcher) {
|
|
2162
|
+
return path.findParent((path2) => matcher.match(path2.node));
|
|
75
2163
|
}
|
|
76
2164
|
function createFunctionMatcher(params, body) {
|
|
77
|
-
const captures = Array.from({ length: params }, () =>
|
|
78
|
-
return
|
|
2165
|
+
const captures = Array.from({ length: params }, () => capture(anyString()));
|
|
2166
|
+
return functionExpression(undefined, captures.map(identifier), blockStatement(body(...captures.map((c) => identifier(fromCapture(c))))));
|
|
79
2167
|
}
|
|
80
2168
|
function isReadonlyObject(binding, memberAccess) {
|
|
81
2169
|
if (!binding.constant && binding.constantViolations[0] !== binding.path)
|
|
@@ -95,18 +2183,18 @@ function isReadonlyObject(binding, memberAccess) {
|
|
|
95
2183
|
function isTemporaryVariable(binding, references, kind = "var") {
|
|
96
2184
|
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());
|
|
97
2185
|
}
|
|
98
|
-
var
|
|
2186
|
+
var safeLiteral = predicate((node) => t12.isLiteral(node) && (!t12.isTemplateLiteral(node) || node.expressions.length === 0));
|
|
99
2187
|
var iife = matchIife();
|
|
100
2188
|
var emptyIife = matchIife([]);
|
|
101
|
-
var trueMatcher =
|
|
102
|
-
var falseMatcher =
|
|
103
|
-
var truthyMatcher =
|
|
2189
|
+
var trueMatcher = or(booleanLiteral(true), unaryExpression("!", numericLiteral(0)), unaryExpression("!", unaryExpression("!", numericLiteral(1))), unaryExpression("!", unaryExpression("!", arrayExpression([]))));
|
|
2190
|
+
var falseMatcher = or(booleanLiteral(false), unaryExpression("!", arrayExpression([])));
|
|
2191
|
+
var truthyMatcher = or(trueMatcher, arrayExpression([]));
|
|
104
2192
|
|
|
105
|
-
// node_modules/webcrack/src/ast-utils/inline.ts
|
|
106
|
-
function inlineVariable(binding, value =
|
|
2193
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/inline.ts
|
|
2194
|
+
function inlineVariable(binding, value = anyExpression(), unsafeAssignments = false) {
|
|
107
2195
|
const varDeclarator = binding.path.node;
|
|
108
|
-
const varMatcher =
|
|
109
|
-
const assignmentMatcher =
|
|
2196
|
+
const varMatcher = variableDeclarator(identifier(binding.identifier.name), value);
|
|
2197
|
+
const assignmentMatcher = assignmentExpression("=", identifier(binding.identifier.name), value);
|
|
110
2198
|
if (binding.constant && varMatcher.match(varDeclarator)) {
|
|
111
2199
|
binding.referencePaths.forEach((ref) => {
|
|
112
2200
|
ref.replaceWith(varDeclarator.init);
|
|
@@ -130,10 +2218,10 @@ function inlineArrayElements(array, references) {
|
|
|
130
2218
|
memberPath.replaceWith(replacement);
|
|
131
2219
|
}
|
|
132
2220
|
}
|
|
133
|
-
function inlineObjectProperties(binding, property =
|
|
2221
|
+
function inlineObjectProperties(binding, property = objectProperty()) {
|
|
134
2222
|
const varDeclarator = binding.path.node;
|
|
135
|
-
const objectProperties =
|
|
136
|
-
const varMatcher =
|
|
2223
|
+
const objectProperties = capture(arrayOf(property));
|
|
2224
|
+
const varMatcher = variableDeclarator(identifier(binding.identifier.name), objectExpression(objectProperties));
|
|
137
2225
|
if (!varMatcher.match(varDeclarator))
|
|
138
2226
|
return;
|
|
139
2227
|
const propertyMap = new Map(objectProperties.current.map((p) => [getPropName(p.key), p.value]));
|
|
@@ -152,13 +2240,13 @@ function inlineObjectProperties(binding, property = m2.objectProperty()) {
|
|
|
152
2240
|
binding.path.remove();
|
|
153
2241
|
}
|
|
154
2242
|
function inlineFunction(fn, caller) {
|
|
155
|
-
if (
|
|
156
|
-
caller.replaceWith(
|
|
2243
|
+
if (t13.isRestElement(fn.params[1])) {
|
|
2244
|
+
caller.replaceWith(t13.callExpression(caller.node.arguments[0], caller.node.arguments.slice(1)));
|
|
157
2245
|
return;
|
|
158
2246
|
}
|
|
159
2247
|
const returnedValue = fn.body.body[0].argument;
|
|
160
|
-
const clone =
|
|
161
|
-
|
|
2248
|
+
const clone = t13.cloneNode(returnedValue, true);
|
|
2249
|
+
traverse4(clone, {
|
|
162
2250
|
Identifier(path) {
|
|
163
2251
|
const paramIndex = fn.params.findIndex((p) => p.name === path.node.name);
|
|
164
2252
|
if (paramIndex !== -1) {
|
|
@@ -174,11 +2262,11 @@ function inlineFunctionAliases(binding) {
|
|
|
174
2262
|
const state = { changes: 0 };
|
|
175
2263
|
const refs = [...binding.referencePaths];
|
|
176
2264
|
for (const ref of refs) {
|
|
177
|
-
const fn = findParent(ref,
|
|
178
|
-
const fnName =
|
|
179
|
-
const returnedCall =
|
|
180
|
-
const
|
|
181
|
-
if (fn &&
|
|
2265
|
+
const fn = findParent(ref, functionDeclaration());
|
|
2266
|
+
const fnName = capture(anyString());
|
|
2267
|
+
const returnedCall = capture(callExpression(identifier(binding.identifier.name), anyList(slice({ min: 2 }))));
|
|
2268
|
+
const matcher2 = functionDeclaration(identifier(fnName), anyList(slice({ min: 2 })), blockStatement([returnStatement(returnedCall)]));
|
|
2269
|
+
if (fn && matcher2.match(fn.node)) {
|
|
182
2270
|
const paramUsedInDecodeCall = fn.node.params.some((param) => {
|
|
183
2271
|
const binding2 = fn.scope.getBinding(param.name);
|
|
184
2272
|
return binding2?.referencePaths.some((ref2) => ref2.findParent((p) => p.node === returnedCall.current));
|
|
@@ -190,7 +2278,7 @@ function inlineFunctionAliases(binding) {
|
|
|
190
2278
|
continue;
|
|
191
2279
|
const fnRefs = fnBinding.referencePaths;
|
|
192
2280
|
refs.push(...fnRefs);
|
|
193
|
-
const callRefs = fnRefs.filter((ref2) =>
|
|
2281
|
+
const callRefs = fnRefs.filter((ref2) => t13.isCallExpression(ref2.parent) && t13.isIdentifier(ref2.parent.callee, { name: fnName.current })).map((ref2) => ref2.parentPath);
|
|
194
2282
|
for (const callRef of callRefs) {
|
|
195
2283
|
inlineFunction(fn.node, callRef);
|
|
196
2284
|
state.changes++;
|
|
@@ -205,10 +2293,10 @@ function inlineFunctionAliases(binding) {
|
|
|
205
2293
|
function inlineVariableAliases(binding, targetName = binding.identifier.name) {
|
|
206
2294
|
const state = { changes: 0 };
|
|
207
2295
|
const refs = [...binding.referencePaths];
|
|
208
|
-
const varName =
|
|
209
|
-
const
|
|
2296
|
+
const varName = capture(anyString());
|
|
2297
|
+
const matcher2 = or(variableDeclarator(identifier(varName), identifier(binding.identifier.name)), assignmentExpression("=", identifier(varName), identifier(binding.identifier.name)));
|
|
210
2298
|
for (const ref of refs) {
|
|
211
|
-
if (
|
|
2299
|
+
if (matcher2.match(ref.parent)) {
|
|
212
2300
|
const varScope = ref.scope;
|
|
213
2301
|
const varBinding = varScope.getBinding(varName.current);
|
|
214
2302
|
if (!varBinding)
|
|
@@ -216,7 +2304,7 @@ function inlineVariableAliases(binding, targetName = binding.identifier.name) {
|
|
|
216
2304
|
state.changes += inlineVariableAliases(varBinding, targetName).changes;
|
|
217
2305
|
if (ref.parentPath?.isAssignmentExpression()) {
|
|
218
2306
|
varBinding.path.remove();
|
|
219
|
-
if (
|
|
2307
|
+
if (t13.isExpressionStatement(ref.parentPath.parent)) {
|
|
220
2308
|
ref.parentPath.remove();
|
|
221
2309
|
} else {
|
|
222
2310
|
ref.parentPath.replaceWith(ref.parentPath.node.right);
|
|
@@ -226,16 +2314,15 @@ function inlineVariableAliases(binding, targetName = binding.identifier.name) {
|
|
|
226
2314
|
}
|
|
227
2315
|
state.changes++;
|
|
228
2316
|
} else {
|
|
229
|
-
ref.replaceWith(
|
|
2317
|
+
ref.replaceWith(t13.identifier(targetName));
|
|
230
2318
|
state.changes++;
|
|
231
2319
|
}
|
|
232
2320
|
}
|
|
233
2321
|
return state;
|
|
234
2322
|
}
|
|
235
|
-
// node_modules/webcrack/src/ast-utils/rename.ts
|
|
236
|
-
import
|
|
237
|
-
import * as
|
|
238
|
-
import * as m3 from "@codemod/matchers";
|
|
2323
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/rename.ts
|
|
2324
|
+
import traverse6 from "@babel/traverse";
|
|
2325
|
+
import * as t14 from "@babel/types";
|
|
239
2326
|
function renameFast(binding, newName) {
|
|
240
2327
|
binding.referencePaths.forEach((ref) => {
|
|
241
2328
|
if (!ref.isIdentifier()) {
|
|
@@ -245,18 +2332,18 @@ function renameFast(binding, newName) {
|
|
|
245
2332
|
ref.scope.rename(newName);
|
|
246
2333
|
ref.node.name = newName;
|
|
247
2334
|
});
|
|
248
|
-
const patternMatcher =
|
|
2335
|
+
const patternMatcher = assignmentExpression("=", or(arrayPattern(), objectPattern()));
|
|
249
2336
|
binding.constantViolations.forEach((ref) => {
|
|
250
2337
|
if (ref.scope.hasBinding(newName))
|
|
251
2338
|
ref.scope.rename(newName);
|
|
252
|
-
if (ref.isAssignmentExpression() &&
|
|
2339
|
+
if (ref.isAssignmentExpression() && t14.isIdentifier(ref.node.left)) {
|
|
253
2340
|
ref.node.left.name = newName;
|
|
254
|
-
} else if (ref.isUpdateExpression() &&
|
|
2341
|
+
} else if (ref.isUpdateExpression() && t14.isIdentifier(ref.node.argument)) {
|
|
255
2342
|
ref.node.argument.name = newName;
|
|
256
|
-
} else if (ref.isVariableDeclarator() &&
|
|
2343
|
+
} else if (ref.isVariableDeclarator() && t14.isIdentifier(ref.node.id)) {
|
|
257
2344
|
ref.node.id.name = newName;
|
|
258
2345
|
} else if (ref.isFor() || patternMatcher.match(ref.node)) {
|
|
259
|
-
|
|
2346
|
+
traverse6(ref.node, {
|
|
260
2347
|
Identifier(path) {
|
|
261
2348
|
if (path.scope !== ref.scope)
|
|
262
2349
|
return path.skip();
|
|
@@ -274,78 +2361,77 @@ function renameFast(binding, newName) {
|
|
|
274
2361
|
binding.scope.bindings[newName] = binding;
|
|
275
2362
|
binding.identifier.name = newName;
|
|
276
2363
|
}
|
|
277
|
-
// node_modules/webcrack/src/ast-utils/transform.ts
|
|
278
|
-
import
|
|
2364
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/ast-utils/transform.ts
|
|
2365
|
+
import traverse8, {
|
|
279
2366
|
visitors
|
|
280
2367
|
} from "@babel/traverse";
|
|
281
2368
|
import debug from "debug";
|
|
282
|
-
async function applyTransformAsync(ast, transform,
|
|
2369
|
+
async function applyTransformAsync(ast, transform, options2) {
|
|
283
2370
|
logger(`${transform.name}: started`);
|
|
284
2371
|
const state = { changes: 0 };
|
|
285
|
-
await transform.run?.(ast, state,
|
|
2372
|
+
await transform.run?.(ast, state, options2);
|
|
286
2373
|
if (transform.visitor)
|
|
287
|
-
|
|
2374
|
+
traverse8(ast, transform.visitor(options2), undefined, state);
|
|
288
2375
|
logger(`${transform.name}: finished with ${state.changes} changes`);
|
|
289
2376
|
return state;
|
|
290
2377
|
}
|
|
291
|
-
function applyTransform(ast, transform,
|
|
2378
|
+
function applyTransform(ast, transform, options2, noScopeOverride) {
|
|
292
2379
|
logger(`${transform.name}: started`);
|
|
293
2380
|
const state = { changes: 0 };
|
|
294
|
-
transform.run?.(ast, state,
|
|
2381
|
+
transform.run?.(ast, state, options2);
|
|
295
2382
|
if (transform.visitor) {
|
|
296
|
-
const visitor = transform.visitor(
|
|
2383
|
+
const visitor = transform.visitor(options2);
|
|
297
2384
|
visitor.noScope = noScopeOverride || !transform.scope;
|
|
298
|
-
|
|
2385
|
+
traverse8(ast, visitor, undefined, state);
|
|
299
2386
|
}
|
|
300
2387
|
logger(`${transform.name}: finished with ${state.changes} changes`);
|
|
301
2388
|
return state;
|
|
302
2389
|
}
|
|
303
|
-
function applyTransforms(ast, transforms,
|
|
304
|
-
|
|
305
|
-
const name =
|
|
306
|
-
if (
|
|
2390
|
+
function applyTransforms(ast, transforms, options2 = {}) {
|
|
2391
|
+
options2.log ??= true;
|
|
2392
|
+
const name = options2.name ?? transforms.map((t15) => t15.name).join(", ");
|
|
2393
|
+
if (options2.log)
|
|
307
2394
|
logger(`${name}: started`);
|
|
308
2395
|
const state = { changes: 0 };
|
|
309
2396
|
for (const transform of transforms) {
|
|
310
2397
|
transform.run?.(ast, state);
|
|
311
2398
|
}
|
|
312
|
-
const traverseOptions = transforms.flatMap((
|
|
2399
|
+
const traverseOptions = transforms.flatMap((t15) => t15.visitor?.() ?? []);
|
|
313
2400
|
if (traverseOptions.length > 0) {
|
|
314
2401
|
const visitor = visitors.merge(traverseOptions);
|
|
315
|
-
visitor.noScope =
|
|
316
|
-
|
|
2402
|
+
visitor.noScope = options2.noScope || transforms.every((t15) => !t15.scope);
|
|
2403
|
+
traverse8(ast, visitor, undefined, state);
|
|
317
2404
|
}
|
|
318
|
-
if (
|
|
2405
|
+
if (options2.log)
|
|
319
2406
|
logger(`${name}: finished with ${state.changes} changes`);
|
|
320
2407
|
return state;
|
|
321
2408
|
}
|
|
322
|
-
function mergeTransforms(
|
|
2409
|
+
function mergeTransforms(options2) {
|
|
323
2410
|
return {
|
|
324
|
-
name:
|
|
325
|
-
tags:
|
|
326
|
-
scope:
|
|
2411
|
+
name: options2.name,
|
|
2412
|
+
tags: options2.tags,
|
|
2413
|
+
scope: options2.transforms.some((t15) => t15.scope),
|
|
327
2414
|
visitor() {
|
|
328
|
-
return visitors.merge(
|
|
2415
|
+
return visitors.merge(options2.transforms.flatMap((t15) => t15.visitor?.() ?? []));
|
|
329
2416
|
}
|
|
330
2417
|
};
|
|
331
2418
|
}
|
|
332
2419
|
var logger = debug("webcrack:transforms");
|
|
333
|
-
// node_modules/webcrack/src/unminify/transforms/merge-strings.ts
|
|
334
|
-
import * as
|
|
335
|
-
import * as m4 from "@codemod/matchers";
|
|
2420
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/merge-strings.ts
|
|
2421
|
+
import * as t15 from "@babel/types";
|
|
336
2422
|
var merge_strings_default = {
|
|
337
2423
|
name: "merge-strings",
|
|
338
2424
|
tags: ["safe"],
|
|
339
2425
|
visitor() {
|
|
340
|
-
const left =
|
|
341
|
-
const right =
|
|
342
|
-
const
|
|
343
|
-
const nestedMatcher =
|
|
2426
|
+
const left = capture(stringLiteral(anyString()));
|
|
2427
|
+
const right = capture(stringLiteral(anyString()));
|
|
2428
|
+
const matcher3 = binaryExpression("+", left, right);
|
|
2429
|
+
const nestedMatcher = binaryExpression("+", binaryExpression("+", anything(), left), right);
|
|
344
2430
|
return {
|
|
345
2431
|
BinaryExpression: {
|
|
346
2432
|
exit(path) {
|
|
347
|
-
if (
|
|
348
|
-
path.replaceWith(
|
|
2433
|
+
if (matcher3.match(path.node)) {
|
|
2434
|
+
path.replaceWith(t15.stringLiteral(left.current.value + right.current.value));
|
|
349
2435
|
this.changes++;
|
|
350
2436
|
}
|
|
351
2437
|
}
|
|
@@ -363,65 +2449,62 @@ var merge_strings_default = {
|
|
|
363
2449
|
}
|
|
364
2450
|
};
|
|
365
2451
|
|
|
366
|
-
// node_modules/webcrack/src/deobfuscate/array-rotator.ts
|
|
367
|
-
import * as m5 from "@codemod/matchers";
|
|
368
|
-
import {callExpression as callExpression5} from "@codemod/matchers";
|
|
2452
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/array-rotator.ts
|
|
369
2453
|
function findArrayRotator(stringArray) {
|
|
370
|
-
const arrayIdentifier =
|
|
371
|
-
const pushShift =
|
|
372
|
-
|
|
2454
|
+
const arrayIdentifier = capture(identifier());
|
|
2455
|
+
const pushShift = callExpression(constMemberExpression(arrayIdentifier, "push"), [
|
|
2456
|
+
callExpression(constMemberExpression(fromCapture(arrayIdentifier), "shift"))
|
|
373
2457
|
]);
|
|
374
|
-
const callMatcher =
|
|
375
|
-
return
|
|
376
|
-
|
|
2458
|
+
const callMatcher = callExpression(functionExpression(null, anything(), blockStatement(anyList(zeroOrMore(), infiniteLoop(predicate((node) => {
|
|
2459
|
+
return containerOf(callExpression(identifier("parseInt"))).match(node) && blockStatement([
|
|
2460
|
+
tryStatement(containerOf(pushShift), containerOf(pushShift))
|
|
377
2461
|
]).match(node);
|
|
378
2462
|
}))))));
|
|
379
|
-
const
|
|
2463
|
+
const matcher3 = expressionStatement(or(callMatcher, unaryExpression("!", callMatcher)));
|
|
380
2464
|
for (const ref of stringArray.references) {
|
|
381
|
-
const rotator = findParent(ref,
|
|
2465
|
+
const rotator = findParent(ref, matcher3);
|
|
382
2466
|
if (rotator) {
|
|
383
2467
|
return rotator;
|
|
384
2468
|
}
|
|
385
2469
|
}
|
|
386
2470
|
}
|
|
387
2471
|
|
|
388
|
-
// node_modules/webcrack/src/deobfuscate/control-flow-object.ts
|
|
389
|
-
import * as
|
|
390
|
-
import * as m6 from "@codemod/matchers";
|
|
2472
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/control-flow-object.ts
|
|
2473
|
+
import * as t16 from "@babel/types";
|
|
391
2474
|
var control_flow_object_default = {
|
|
392
2475
|
name: "control-flow-object",
|
|
393
2476
|
tags: ["safe"],
|
|
394
2477
|
scope: true,
|
|
395
2478
|
visitor() {
|
|
396
|
-
const varId =
|
|
397
|
-
const propertyName =
|
|
2479
|
+
const varId = capture(identifier());
|
|
2480
|
+
const propertyName = predicate((name) => /^[a-z]{5}$/i.test(name));
|
|
398
2481
|
const propertyKey = constKey(propertyName);
|
|
399
|
-
const propertyValue =
|
|
400
|
-
|
|
401
|
-
]),
|
|
402
|
-
return
|
|
403
|
-
|
|
2482
|
+
const propertyValue = or(stringLiteral(), createFunctionMatcher(2, (left, right) => [
|
|
2483
|
+
returnStatement(or(binaryExpression(undefined, left, right), logicalExpression(undefined, left, right), binaryExpression(undefined, right, left), logicalExpression(undefined, right, left)))
|
|
2484
|
+
]), predicate((node) => {
|
|
2485
|
+
return t16.isFunctionExpression(node) && createFunctionMatcher(node.params.length, (...params) => [
|
|
2486
|
+
returnStatement(callExpression(params[0], params.slice(1)))
|
|
404
2487
|
]).match(node);
|
|
405
2488
|
}), (() => {
|
|
406
|
-
const fnName =
|
|
407
|
-
const restName =
|
|
408
|
-
return
|
|
409
|
-
|
|
410
|
-
|
|
2489
|
+
const fnName = capture(identifier());
|
|
2490
|
+
const restName = capture(identifier());
|
|
2491
|
+
return functionExpression(undefined, [fnName, restElement(restName)], blockStatement([
|
|
2492
|
+
returnStatement(callExpression(fromCapture(fnName), [
|
|
2493
|
+
spreadElement(fromCapture(restName))
|
|
411
2494
|
]))
|
|
412
2495
|
]));
|
|
413
2496
|
})());
|
|
414
|
-
const objectProperties =
|
|
415
|
-
const aliasId =
|
|
416
|
-
const aliasVar =
|
|
417
|
-
|
|
2497
|
+
const objectProperties = capture(arrayOf(objectProperty(propertyKey, propertyValue)));
|
|
2498
|
+
const aliasId = capture(identifier());
|
|
2499
|
+
const aliasVar = variableDeclaration(anything(), [
|
|
2500
|
+
variableDeclarator(aliasId, fromCapture(varId))
|
|
418
2501
|
]);
|
|
419
|
-
const assignedKey =
|
|
420
|
-
const assignedValue =
|
|
421
|
-
const assignment =
|
|
422
|
-
const looseAssignment =
|
|
423
|
-
const memberAccess = constMemberExpression(
|
|
424
|
-
const varMatcher =
|
|
2502
|
+
const assignedKey = capture(propertyName);
|
|
2503
|
+
const assignedValue = capture(propertyValue);
|
|
2504
|
+
const assignment = expressionStatement(assignmentExpression("=", constMemberExpression(fromCapture(varId), assignedKey), assignedValue));
|
|
2505
|
+
const looseAssignment = expressionStatement(assignmentExpression("=", constMemberExpression(fromCapture(varId), assignedKey)));
|
|
2506
|
+
const memberAccess = constMemberExpression(or(fromCapture(varId), fromCapture(aliasId)), propertyName);
|
|
2507
|
+
const varMatcher = variableDeclarator(varId, capture(objectExpression(objectProperties)));
|
|
425
2508
|
function isConstantBinding(binding) {
|
|
426
2509
|
return binding.constant || binding.constantViolations[0] === binding.path;
|
|
427
2510
|
}
|
|
@@ -448,7 +2531,7 @@ var control_flow_object_default = {
|
|
|
448
2531
|
const memberPath = ref.parentPath;
|
|
449
2532
|
const propName = getPropName(memberPath.node.property);
|
|
450
2533
|
const value = props.get(propName);
|
|
451
|
-
if (
|
|
2534
|
+
if (t16.isStringLiteral(value)) {
|
|
452
2535
|
memberPath.replaceWith(value);
|
|
453
2536
|
} else {
|
|
454
2537
|
inlineFunction(value, memberPath.parentPath);
|
|
@@ -456,7 +2539,7 @@ var control_flow_object_default = {
|
|
|
456
2539
|
changes++;
|
|
457
2540
|
});
|
|
458
2541
|
oldRefs.forEach((ref) => {
|
|
459
|
-
const varDeclarator = findParent(ref,
|
|
2542
|
+
const varDeclarator = findParent(ref, variableDeclarator());
|
|
460
2543
|
if (varDeclarator)
|
|
461
2544
|
changes += transform2(varDeclarator);
|
|
462
2545
|
});
|
|
@@ -475,7 +2558,7 @@ var control_flow_object_default = {
|
|
|
475
2558
|
applyTransform(statement, merge_strings_default);
|
|
476
2559
|
}
|
|
477
2560
|
if (assignment.match(statement)) {
|
|
478
|
-
properties.push(
|
|
2561
|
+
properties.push(t16.objectProperty(t16.identifier(assignedKey.current), assignedValue.current));
|
|
479
2562
|
} else {
|
|
480
2563
|
break;
|
|
481
2564
|
}
|
|
@@ -506,31 +2589,30 @@ var control_flow_object_default = {
|
|
|
506
2589
|
}
|
|
507
2590
|
};
|
|
508
2591
|
|
|
509
|
-
// node_modules/webcrack/src/deobfuscate/control-flow-switch.ts
|
|
510
|
-
import * as
|
|
511
|
-
import * as m7 from "@codemod/matchers";
|
|
2592
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/control-flow-switch.ts
|
|
2593
|
+
import * as t17 from "@babel/types";
|
|
512
2594
|
var control_flow_switch_default = {
|
|
513
2595
|
name: "control-flow-switch",
|
|
514
2596
|
tags: ["safe"],
|
|
515
2597
|
visitor() {
|
|
516
|
-
const sequenceName =
|
|
517
|
-
const sequenceString =
|
|
518
|
-
const iterator =
|
|
519
|
-
const cases =
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
]),
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
])),
|
|
2598
|
+
const sequenceName = capture(identifier());
|
|
2599
|
+
const sequenceString = capture(predicate((s) => /^\d+(\|\d+)*$/.test(s)));
|
|
2600
|
+
const iterator = capture(identifier());
|
|
2601
|
+
const cases = capture(arrayOf(switchCase(stringLiteral(predicate((s) => /^\d+$/.test(s))), anyList(zeroOrMore(), or(continueStatement(), returnStatement())))));
|
|
2602
|
+
const matcher3 = blockStatement(anyList(variableDeclaration(undefined, [
|
|
2603
|
+
variableDeclarator(sequenceName, callExpression(constMemberExpression(stringLiteral(sequenceString), "split"), [stringLiteral("|")]))
|
|
2604
|
+
]), variableDeclaration(undefined, [variableDeclarator(iterator)]), infiniteLoop(blockStatement([
|
|
2605
|
+
switchStatement(memberExpression(fromCapture(sequenceName), updateExpression("++", fromCapture(iterator)), true), cases),
|
|
2606
|
+
breakStatement()
|
|
2607
|
+
])), zeroOrMore()));
|
|
526
2608
|
return {
|
|
527
2609
|
BlockStatement: {
|
|
528
2610
|
exit(path) {
|
|
529
|
-
if (!
|
|
2611
|
+
if (!matcher3.match(path.node))
|
|
530
2612
|
return;
|
|
531
2613
|
const caseStatements = new Map(cases.current.map((c) => [
|
|
532
2614
|
c.test.value,
|
|
533
|
-
|
|
2615
|
+
t17.isContinueStatement(c.consequent.at(-1)) ? c.consequent.slice(0, -1) : c.consequent
|
|
534
2616
|
]));
|
|
535
2617
|
const sequence = sequenceString.current.split("|");
|
|
536
2618
|
const newStatements = sequence.flatMap((s) => caseStatements.get(s));
|
|
@@ -542,11 +2624,10 @@ var control_flow_switch_default = {
|
|
|
542
2624
|
}
|
|
543
2625
|
};
|
|
544
2626
|
|
|
545
|
-
// node_modules/webcrack/src/deobfuscate/dead-code.ts
|
|
546
|
-
import * as
|
|
547
|
-
import * as m8 from "@codemod/matchers";
|
|
2627
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/dead-code.ts
|
|
2628
|
+
import * as t18 from "@babel/types";
|
|
548
2629
|
var replace = function(path, node) {
|
|
549
|
-
if (
|
|
2630
|
+
if (t18.isBlockStatement(node)) {
|
|
550
2631
|
path.replaceWithMultiple(node.body);
|
|
551
2632
|
} else {
|
|
552
2633
|
path.replaceWith(node);
|
|
@@ -557,8 +2638,8 @@ var dead_code_default = {
|
|
|
557
2638
|
tags: ["unsafe"],
|
|
558
2639
|
scope: true,
|
|
559
2640
|
visitor() {
|
|
560
|
-
const stringComparison =
|
|
561
|
-
const testMatcher =
|
|
2641
|
+
const stringComparison = binaryExpression(or("===", "==", "!==", "!="), stringLiteral(), stringLiteral());
|
|
2642
|
+
const testMatcher = or(stringComparison, unaryExpression("!", stringComparison));
|
|
562
2643
|
return {
|
|
563
2644
|
"IfStatement|ConditionalExpression": {
|
|
564
2645
|
exit(_path) {
|
|
@@ -591,18 +2672,17 @@ var dead_code_default = {
|
|
|
591
2672
|
}
|
|
592
2673
|
};
|
|
593
2674
|
|
|
594
|
-
// node_modules/webcrack/src/deobfuscate/decoder.ts
|
|
2675
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/decoder.ts
|
|
595
2676
|
import {expression} from "@babel/template";
|
|
596
|
-
import * as m9 from "@codemod/matchers";
|
|
597
2677
|
function findDecoders(stringArray) {
|
|
598
2678
|
const decoders = [];
|
|
599
|
-
const functionName =
|
|
600
|
-
const arrayIdentifier =
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
]),
|
|
2679
|
+
const functionName = capture(anyString());
|
|
2680
|
+
const arrayIdentifier = capture(identifier());
|
|
2681
|
+
const matcher3 = functionDeclaration(identifier(functionName), anything(), blockStatement(anyList(variableDeclaration(undefined, [
|
|
2682
|
+
variableDeclarator(arrayIdentifier, callExpression(identifier(stringArray.name)))
|
|
2683
|
+
]), zeroOrMore(), containerOf(memberExpression(fromCapture(arrayIdentifier), undefined, true)), zeroOrMore())));
|
|
604
2684
|
for (const ref of stringArray.references) {
|
|
605
|
-
const decoderFn = findParent(ref,
|
|
2685
|
+
const decoderFn = findParent(ref, matcher3);
|
|
606
2686
|
if (decoderFn) {
|
|
607
2687
|
const oldName = functionName.current;
|
|
608
2688
|
const newName = `__DECODE_${decoders.length}__`;
|
|
@@ -623,11 +2703,11 @@ class Decoder {
|
|
|
623
2703
|
}
|
|
624
2704
|
collectCalls() {
|
|
625
2705
|
const calls = [];
|
|
626
|
-
const literalArgument =
|
|
627
|
-
const literalCall =
|
|
628
|
-
const expressionCall =
|
|
629
|
-
const conditional =
|
|
630
|
-
const conditionalCall =
|
|
2706
|
+
const literalArgument = or(binaryExpression(anything(), predicate((node) => literalArgument.match(node)), predicate((node) => literalArgument.match(node))), unaryExpression("-", predicate((node) => literalArgument.match(node))), numericLiteral(), stringLiteral());
|
|
2707
|
+
const literalCall = callExpression(identifier(this.name), arrayOf(literalArgument));
|
|
2708
|
+
const expressionCall = callExpression(identifier(this.name), arrayOf(anyExpression()));
|
|
2709
|
+
const conditional = capture(conditionalExpression());
|
|
2710
|
+
const conditionalCall = callExpression(identifier(this.name), [
|
|
631
2711
|
conditional
|
|
632
2712
|
]);
|
|
633
2713
|
const buildExtractedConditional = expression`TEST ? CALLEE(CONSEQUENT) : CALLEE(ALTERNATE)`;
|
|
@@ -661,21 +2741,21 @@ class Decoder {
|
|
|
661
2741
|
}
|
|
662
2742
|
}
|
|
663
2743
|
|
|
664
|
-
// node_modules/webcrack/src/deobfuscate/inline-decoded-strings.ts
|
|
665
|
-
import * as
|
|
2744
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/inline-decoded-strings.ts
|
|
2745
|
+
import * as t19 from "@babel/types";
|
|
666
2746
|
var inline_decoded_strings_default = {
|
|
667
2747
|
name: "inline-decoded-strings",
|
|
668
2748
|
tags: ["unsafe"],
|
|
669
2749
|
scope: true,
|
|
670
|
-
async run(ast2, state,
|
|
671
|
-
if (!
|
|
2750
|
+
async run(ast2, state, options2) {
|
|
2751
|
+
if (!options2)
|
|
672
2752
|
return;
|
|
673
|
-
const calls =
|
|
674
|
-
const decodedValues = await
|
|
2753
|
+
const calls = options2.vm.decoders.flatMap((decoder) => decoder.collectCalls());
|
|
2754
|
+
const decodedValues = await options2.vm.decode(calls);
|
|
675
2755
|
for (let i = 0;i < calls.length; i++) {
|
|
676
2756
|
const call = calls[i];
|
|
677
2757
|
const value = decodedValues[i];
|
|
678
|
-
call.replaceWith(
|
|
2758
|
+
call.replaceWith(t19.valueToNode(value));
|
|
679
2759
|
if (typeof value !== "string")
|
|
680
2760
|
call.addComment("leading", "webcrack:decode_error");
|
|
681
2761
|
}
|
|
@@ -683,7 +2763,7 @@ var inline_decoded_strings_default = {
|
|
|
683
2763
|
}
|
|
684
2764
|
};
|
|
685
2765
|
|
|
686
|
-
// node_modules/webcrack/src/deobfuscate/inline-decoder-wrappers.ts
|
|
2766
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/inline-decoder-wrappers.ts
|
|
687
2767
|
var inline_decoder_wrappers_default = {
|
|
688
2768
|
name: "inline-decoder-wrappers",
|
|
689
2769
|
tags: ["unsafe"],
|
|
@@ -700,19 +2780,18 @@ var inline_decoder_wrappers_default = {
|
|
|
700
2780
|
}
|
|
701
2781
|
};
|
|
702
2782
|
|
|
703
|
-
// node_modules/webcrack/src/deobfuscate/inline-object-props.ts
|
|
704
|
-
import * as m10 from "@codemod/matchers";
|
|
2783
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/inline-object-props.ts
|
|
705
2784
|
var inline_object_props_default = {
|
|
706
2785
|
name: "inline-object-props",
|
|
707
2786
|
tags: ["safe"],
|
|
708
2787
|
scope: true,
|
|
709
2788
|
visitor() {
|
|
710
|
-
const varId =
|
|
711
|
-
const propertyName =
|
|
2789
|
+
const varId = capture(identifier());
|
|
2790
|
+
const propertyName = predicate((name) => /^[\w]+$/i.test(name));
|
|
712
2791
|
const propertyKey = constKey(propertyName);
|
|
713
|
-
const objectProperties =
|
|
714
|
-
const memberAccess = constMemberExpression(
|
|
715
|
-
const varMatcher =
|
|
2792
|
+
const objectProperties = capture(arrayOf(objectProperty(propertyKey, or(stringLiteral(), numericLiteral()))));
|
|
2793
|
+
const memberAccess = constMemberExpression(fromCapture(varId), propertyName);
|
|
2794
|
+
const varMatcher = variableDeclarator(varId, objectExpression(objectProperties));
|
|
716
2795
|
return {
|
|
717
2796
|
VariableDeclarator(path) {
|
|
718
2797
|
if (!varMatcher.match(path.node))
|
|
@@ -722,36 +2801,35 @@ var inline_object_props_default = {
|
|
|
722
2801
|
const binding = path.scope.getBinding(varId.current.name);
|
|
723
2802
|
if (!binding || !isReadonlyObject(binding, memberAccess))
|
|
724
2803
|
return;
|
|
725
|
-
inlineObjectProperties(binding,
|
|
2804
|
+
inlineObjectProperties(binding, objectProperty(propertyKey, or(stringLiteral(), numericLiteral())));
|
|
726
2805
|
}
|
|
727
2806
|
};
|
|
728
2807
|
}
|
|
729
2808
|
};
|
|
730
2809
|
|
|
731
|
-
// node_modules/webcrack/src/deobfuscate/string-array.ts
|
|
732
|
-
import
|
|
733
|
-
import * as m11 from "@codemod/matchers";
|
|
2810
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/string-array.ts
|
|
2811
|
+
import traverse10 from "@babel/traverse";
|
|
734
2812
|
function findStringArray(ast2) {
|
|
735
2813
|
let result;
|
|
736
|
-
const functionName =
|
|
737
|
-
const arrayIdentifier =
|
|
738
|
-
const
|
|
739
|
-
const functionAssignment =
|
|
740
|
-
const
|
|
741
|
-
|
|
2814
|
+
const functionName = capture(anyString());
|
|
2815
|
+
const arrayIdentifier = capture(identifier());
|
|
2816
|
+
const arrayExpression2 = capture(arrayExpression(arrayOf(stringLiteral())));
|
|
2817
|
+
const functionAssignment = assignmentExpression("=", identifier(fromCapture(functionName)), functionExpression(undefined, [], blockStatement([returnStatement(fromCapture(arrayIdentifier))])));
|
|
2818
|
+
const variableDeclaration2 = variableDeclaration(undefined, [
|
|
2819
|
+
variableDeclarator(arrayIdentifier, arrayExpression2)
|
|
742
2820
|
]);
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
]),
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
2821
|
+
const matcher3 = functionDeclaration(identifier(functionName), [], or(blockStatement([
|
|
2822
|
+
variableDeclaration2,
|
|
2823
|
+
returnStatement(callExpression(functionAssignment))
|
|
2824
|
+
]), blockStatement([
|
|
2825
|
+
variableDeclaration2,
|
|
2826
|
+
expressionStatement(functionAssignment),
|
|
2827
|
+
returnStatement(callExpression(identifier(functionName)))
|
|
750
2828
|
])));
|
|
751
|
-
|
|
2829
|
+
traverse10(ast2, {
|
|
752
2830
|
FunctionDeclaration(path) {
|
|
753
|
-
if (
|
|
754
|
-
const length =
|
|
2831
|
+
if (matcher3.match(path.node)) {
|
|
2832
|
+
const length = arrayExpression2.current.elements.length;
|
|
755
2833
|
const name = functionName.current;
|
|
756
2834
|
const binding = path.scope.getBinding(name);
|
|
757
2835
|
renameFast(binding, "__STRING_ARRAY__");
|
|
@@ -765,21 +2843,21 @@ function findStringArray(ast2) {
|
|
|
765
2843
|
}
|
|
766
2844
|
},
|
|
767
2845
|
VariableDeclaration(path) {
|
|
768
|
-
if (!
|
|
2846
|
+
if (!variableDeclaration2.match(path.node))
|
|
769
2847
|
return;
|
|
770
|
-
const length =
|
|
2848
|
+
const length = arrayExpression2.current.elements.length;
|
|
771
2849
|
const binding = path.scope.getBinding(arrayIdentifier.current.name);
|
|
772
|
-
const memberAccess =
|
|
2850
|
+
const memberAccess = memberExpression(fromCapture(arrayIdentifier), numericLiteral(predicate((value) => value < length)));
|
|
773
2851
|
if (!isReadonlyObject(binding, memberAccess))
|
|
774
2852
|
return;
|
|
775
|
-
inlineArrayElements(
|
|
2853
|
+
inlineArrayElements(arrayExpression2.current, binding.referencePaths);
|
|
776
2854
|
path.remove();
|
|
777
2855
|
}
|
|
778
2856
|
});
|
|
779
2857
|
return result;
|
|
780
2858
|
}
|
|
781
2859
|
|
|
782
|
-
// node_modules/webcrack/src/deobfuscate/vm.ts
|
|
2860
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/deobfuscate/vm.ts
|
|
783
2861
|
import debug2 from "debug";
|
|
784
2862
|
class VMDecoder {
|
|
785
2863
|
decoders;
|
|
@@ -815,7 +2893,7 @@ class VMDecoder {
|
|
|
815
2893
|
}
|
|
816
2894
|
}
|
|
817
2895
|
|
|
818
|
-
// node_modules/webcrack/src/deobfuscate/index.ts
|
|
2896
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/deobfuscate/index.ts
|
|
819
2897
|
var deobfuscate_default = {
|
|
820
2898
|
name: "deobfuscate",
|
|
821
2899
|
tags: ["unsafe"],
|
|
@@ -846,23 +2924,22 @@ var deobfuscate_default = {
|
|
|
846
2924
|
}
|
|
847
2925
|
};
|
|
848
2926
|
|
|
849
|
-
// node_modules/webcrack/src/deobfuscate/var-functions.ts
|
|
850
|
-
import * as
|
|
851
|
-
import * as m12 from "@codemod/matchers";
|
|
2927
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/deobfuscate/var-functions.ts
|
|
2928
|
+
import * as t20 from "@babel/types";
|
|
852
2929
|
var var_functions_default = {
|
|
853
2930
|
name: "var-functions",
|
|
854
2931
|
tags: ["unsafe"],
|
|
855
2932
|
visitor() {
|
|
856
|
-
const name =
|
|
857
|
-
const fn =
|
|
858
|
-
const
|
|
859
|
-
|
|
2933
|
+
const name = capture(identifier());
|
|
2934
|
+
const fn = capture(functionExpression(null));
|
|
2935
|
+
const matcher3 = variableDeclaration("var", [
|
|
2936
|
+
variableDeclarator(name, fn)
|
|
860
2937
|
]);
|
|
861
2938
|
return {
|
|
862
2939
|
VariableDeclaration: {
|
|
863
2940
|
exit(path) {
|
|
864
|
-
if (
|
|
865
|
-
path.replaceWith(
|
|
2941
|
+
if (matcher3.match(path.node) && path.key !== "init") {
|
|
2942
|
+
path.replaceWith(t20.functionDeclaration(name.current, fn.current.params, fn.current.body, fn.current.generator, fn.current.async));
|
|
866
2943
|
}
|
|
867
2944
|
}
|
|
868
2945
|
}
|
|
@@ -870,26 +2947,25 @@ var var_functions_default = {
|
|
|
870
2947
|
}
|
|
871
2948
|
};
|
|
872
2949
|
|
|
873
|
-
// node_modules/webcrack/src/deobfuscate/merge-object-assignments.ts
|
|
874
|
-
import * as
|
|
875
|
-
import * as m13 from "@codemod/matchers";
|
|
2950
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/deobfuscate/merge-object-assignments.ts
|
|
2951
|
+
import * as t21 from "@babel/types";
|
|
876
2952
|
var hasCircularReference = function(node, binding) {
|
|
877
|
-
return binding.referencePaths.some((path) => path.find((p) => p.node === node)) ||
|
|
2953
|
+
return binding.referencePaths.some((path) => path.find((p) => p.node === node)) || containerOf(callExpression()).match(node);
|
|
878
2954
|
};
|
|
879
2955
|
var merge_object_assignments_default = {
|
|
880
2956
|
name: "merge-object-assignments",
|
|
881
2957
|
tags: ["safe"],
|
|
882
2958
|
scope: true,
|
|
883
2959
|
visitor: () => {
|
|
884
|
-
const id =
|
|
885
|
-
const object =
|
|
886
|
-
const varMatcher =
|
|
887
|
-
|
|
2960
|
+
const id = capture(identifier());
|
|
2961
|
+
const object = capture(objectExpression([]));
|
|
2962
|
+
const varMatcher = variableDeclaration(undefined, [
|
|
2963
|
+
variableDeclarator(id, object)
|
|
888
2964
|
]);
|
|
889
|
-
const key =
|
|
890
|
-
const computed =
|
|
891
|
-
const value =
|
|
892
|
-
const assignmentMatcher =
|
|
2965
|
+
const key = capture(anyExpression());
|
|
2966
|
+
const computed = capture(anything());
|
|
2967
|
+
const value = capture(anyExpression());
|
|
2968
|
+
const assignmentMatcher = expressionStatement(assignmentExpression("=", memberExpression(fromCapture(id), key, computed), value));
|
|
893
2969
|
return {
|
|
894
2970
|
Program(path) {
|
|
895
2971
|
path.scope.crawl();
|
|
@@ -906,7 +2982,7 @@ var merge_object_assignments_default = {
|
|
|
906
2982
|
if (!assignmentMatcher.match(sibling.node) || hasCircularReference(value.current, binding))
|
|
907
2983
|
return;
|
|
908
2984
|
const isComputed = computed.current && key.current.type !== "NumericLiteral" && key.current.type !== "StringLiteral";
|
|
909
|
-
object.current.properties.push(
|
|
2985
|
+
object.current.properties.push(t21.objectProperty(key.current, value.current, isComputed));
|
|
910
2986
|
sibling.remove();
|
|
911
2987
|
binding.dereference();
|
|
912
2988
|
binding.referencePaths.shift();
|
|
@@ -921,9 +2997,9 @@ var merge_object_assignments_default = {
|
|
|
921
2997
|
};
|
|
922
2998
|
}
|
|
923
2999
|
};
|
|
924
|
-
var inlineableObject =
|
|
3000
|
+
var inlineableObject = predicate((node) => or(safeLiteral, arrayExpression(arrayOf(inlineableObject)), objectExpression(arrayOf(constObjectProperty(inlineableObject)))).match(node));
|
|
925
3001
|
|
|
926
|
-
// node_modules/webcrack/src/unminify/transforms/index.ts
|
|
3002
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/unminify/transforms/index.ts
|
|
927
3003
|
var exports_transforms = {};
|
|
928
3004
|
__export(exports_transforms, {
|
|
929
3005
|
yoda: () => {
|
|
@@ -1023,37 +3099,37 @@ __export(exports_transforms, {
|
|
|
1023
3099
|
}
|
|
1024
3100
|
});
|
|
1025
3101
|
|
|
1026
|
-
// node_modules/webcrack/src/unminify/transforms/block-statements.ts
|
|
1027
|
-
import * as
|
|
3102
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/block-statements.ts
|
|
3103
|
+
import * as t22 from "@babel/types";
|
|
1028
3104
|
var block_statements_default = {
|
|
1029
3105
|
name: "block-statements",
|
|
1030
3106
|
tags: ["safe"],
|
|
1031
3107
|
visitor: () => ({
|
|
1032
3108
|
IfStatement: {
|
|
1033
3109
|
exit(path) {
|
|
1034
|
-
if (!
|
|
1035
|
-
path.node.consequent =
|
|
3110
|
+
if (!t22.isBlockStatement(path.node.consequent) && !t22.isEmptyStatement(path.node.consequent)) {
|
|
3111
|
+
path.node.consequent = t22.blockStatement([path.node.consequent]);
|
|
1036
3112
|
this.changes++;
|
|
1037
3113
|
}
|
|
1038
|
-
if (path.node.alternate && !
|
|
1039
|
-
path.node.alternate =
|
|
3114
|
+
if (path.node.alternate && !t22.isBlockStatement(path.node.alternate)) {
|
|
3115
|
+
path.node.alternate = t22.blockStatement([path.node.alternate]);
|
|
1040
3116
|
this.changes++;
|
|
1041
3117
|
}
|
|
1042
3118
|
}
|
|
1043
3119
|
},
|
|
1044
3120
|
Loop: {
|
|
1045
3121
|
exit(path) {
|
|
1046
|
-
if (!
|
|
1047
|
-
path.node.body =
|
|
3122
|
+
if (!t22.isBlockStatement(path.node.body) && !t22.isEmptyStatement(path.node.body)) {
|
|
3123
|
+
path.node.body = t22.blockStatement([path.node.body]);
|
|
1048
3124
|
this.changes++;
|
|
1049
3125
|
}
|
|
1050
3126
|
}
|
|
1051
3127
|
},
|
|
1052
3128
|
ArrowFunctionExpression: {
|
|
1053
3129
|
exit(path) {
|
|
1054
|
-
if (
|
|
1055
|
-
path.node.body =
|
|
1056
|
-
|
|
3130
|
+
if (t22.isSequenceExpression(path.node.body)) {
|
|
3131
|
+
path.node.body = t22.blockStatement([
|
|
3132
|
+
t22.returnStatement(path.node.body)
|
|
1057
3133
|
]);
|
|
1058
3134
|
this.changes++;
|
|
1059
3135
|
}
|
|
@@ -1061,24 +3137,23 @@ var block_statements_default = {
|
|
|
1061
3137
|
}
|
|
1062
3138
|
})
|
|
1063
3139
|
};
|
|
1064
|
-
// node_modules/webcrack/src/unminify/transforms/computed-properties.ts
|
|
3140
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/computed-properties.ts
|
|
1065
3141
|
import {isIdentifierName} from "@babel/helper-validator-identifier";
|
|
1066
|
-
import * as
|
|
1067
|
-
import * as m14 from "@codemod/matchers";
|
|
3142
|
+
import * as t23 from "@babel/types";
|
|
1068
3143
|
var computed_properties_default = {
|
|
1069
3144
|
name: "computed-properties",
|
|
1070
3145
|
tags: ["safe"],
|
|
1071
3146
|
visitor() {
|
|
1072
|
-
const stringMatcher =
|
|
1073
|
-
const propertyMatcher =
|
|
1074
|
-
const keyMatcher =
|
|
3147
|
+
const stringMatcher = capture(stringLiteral(predicate((value) => isIdentifierName(value))));
|
|
3148
|
+
const propertyMatcher = or(memberExpression(anything(), stringMatcher, true), optionalMemberExpression(anything(), stringMatcher, true));
|
|
3149
|
+
const keyMatcher = or(objectProperty(stringMatcher), classProperty(stringMatcher), objectMethod(undefined, stringMatcher), classMethod(undefined, stringMatcher));
|
|
1075
3150
|
return {
|
|
1076
3151
|
"MemberExpression|OptionalMemberExpression": {
|
|
1077
3152
|
exit(path) {
|
|
1078
3153
|
if (!propertyMatcher.match(path.node))
|
|
1079
3154
|
return;
|
|
1080
3155
|
path.node.computed = false;
|
|
1081
|
-
path.node.property =
|
|
3156
|
+
path.node.property = t23.identifier(stringMatcher.current.value);
|
|
1082
3157
|
this.changes++;
|
|
1083
3158
|
}
|
|
1084
3159
|
},
|
|
@@ -1089,15 +3164,15 @@ var computed_properties_default = {
|
|
|
1089
3164
|
if (path.type === "ClassMethod" && stringMatcher.current.value === "constructor" || path.type === "ObjectProperty" && stringMatcher.current.value === "__proto__")
|
|
1090
3165
|
return;
|
|
1091
3166
|
path.node.computed = false;
|
|
1092
|
-
path.node.key =
|
|
3167
|
+
path.node.key = t23.identifier(stringMatcher.current.value);
|
|
1093
3168
|
this.changes++;
|
|
1094
3169
|
}
|
|
1095
3170
|
}
|
|
1096
3171
|
};
|
|
1097
3172
|
}
|
|
1098
3173
|
};
|
|
1099
|
-
// node_modules/webcrack/src/unminify/transforms/for-to-while.ts
|
|
1100
|
-
import * as
|
|
3174
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/for-to-while.ts
|
|
3175
|
+
import * as t24 from "@babel/types";
|
|
1101
3176
|
var for_to_while_default = {
|
|
1102
3177
|
name: "for-to-while",
|
|
1103
3178
|
tags: ["safe"],
|
|
@@ -1108,33 +3183,32 @@ var for_to_while_default = {
|
|
|
1108
3183
|
const { test, body, init, update } = path.node;
|
|
1109
3184
|
if (init || update)
|
|
1110
3185
|
return;
|
|
1111
|
-
path.replaceWith(test ?
|
|
3186
|
+
path.replaceWith(test ? t24.whileStatement(test, body) : t24.whileStatement(t24.booleanLiteral(true), body));
|
|
1112
3187
|
this.changes++;
|
|
1113
3188
|
}
|
|
1114
3189
|
}
|
|
1115
3190
|
};
|
|
1116
3191
|
}
|
|
1117
3192
|
};
|
|
1118
|
-
// node_modules/webcrack/src/unminify/transforms/infinity.ts
|
|
1119
|
-
import * as
|
|
1120
|
-
import * as m15 from "@codemod/matchers";
|
|
3193
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/infinity.ts
|
|
3194
|
+
import * as t25 from "@babel/types";
|
|
1121
3195
|
var infinity_default = {
|
|
1122
3196
|
name: "infinity",
|
|
1123
3197
|
tags: ["safe"],
|
|
1124
3198
|
scope: true,
|
|
1125
3199
|
visitor: () => {
|
|
1126
|
-
const infinityMatcher =
|
|
1127
|
-
const negativeInfinityMatcher =
|
|
3200
|
+
const infinityMatcher = binaryExpression("/", numericLiteral(1), numericLiteral(0));
|
|
3201
|
+
const negativeInfinityMatcher = binaryExpression("/", unaryExpression("-", numericLiteral(1)), numericLiteral(0));
|
|
1128
3202
|
return {
|
|
1129
3203
|
BinaryExpression: {
|
|
1130
3204
|
exit(path) {
|
|
1131
3205
|
if (path.scope.hasBinding("Infinity", { noGlobals: true }))
|
|
1132
3206
|
return;
|
|
1133
3207
|
if (infinityMatcher.match(path.node)) {
|
|
1134
|
-
path.replaceWith(
|
|
3208
|
+
path.replaceWith(t25.identifier("Infinity"));
|
|
1135
3209
|
this.changes++;
|
|
1136
3210
|
} else if (negativeInfinityMatcher.match(path.node)) {
|
|
1137
|
-
path.replaceWith(
|
|
3211
|
+
path.replaceWith(t25.unaryExpression("-", t25.identifier("Infinity")));
|
|
1138
3212
|
this.changes++;
|
|
1139
3213
|
}
|
|
1140
3214
|
}
|
|
@@ -1142,9 +3216,8 @@ var infinity_default = {
|
|
|
1142
3216
|
};
|
|
1143
3217
|
}
|
|
1144
3218
|
};
|
|
1145
|
-
// node_modules/webcrack/src/unminify/transforms/invert-boolean-logic.ts
|
|
1146
|
-
import * as
|
|
1147
|
-
import * as m16 from "@codemod/matchers";
|
|
3219
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/invert-boolean-logic.ts
|
|
3220
|
+
import * as t26 from "@babel/types";
|
|
1148
3221
|
var INVERTED_BINARY_OPERATORS = {
|
|
1149
3222
|
"==": "!=",
|
|
1150
3223
|
"===": "!==",
|
|
@@ -1163,25 +3236,25 @@ var invert_boolean_logic_default = {
|
|
|
1163
3236
|
name: "invert-boolean-logic",
|
|
1164
3237
|
tags: ["safe"],
|
|
1165
3238
|
visitor: () => {
|
|
1166
|
-
const
|
|
1167
|
-
const logicalMatcher =
|
|
1168
|
-
const
|
|
1169
|
-
const binaryMatcher =
|
|
3239
|
+
const logicalExpression2 = logicalExpression(or(...Object.values(INVERTED_LOGICAL_OPERATORS)));
|
|
3240
|
+
const logicalMatcher = unaryExpression("!", logicalExpression2);
|
|
3241
|
+
const binaryExpression2 = capture(binaryExpression(or(...Object.values(INVERTED_BINARY_OPERATORS))));
|
|
3242
|
+
const binaryMatcher = unaryExpression("!", binaryExpression2);
|
|
1170
3243
|
return {
|
|
1171
3244
|
UnaryExpression: {
|
|
1172
3245
|
exit(path) {
|
|
1173
3246
|
const { argument } = path.node;
|
|
1174
3247
|
if (binaryMatcher.match(path.node)) {
|
|
1175
|
-
|
|
1176
|
-
path.replaceWith(
|
|
3248
|
+
binaryExpression2.current.operator = INVERTED_BINARY_OPERATORS[binaryExpression2.current.operator];
|
|
3249
|
+
path.replaceWith(binaryExpression2.current);
|
|
1177
3250
|
this.changes++;
|
|
1178
3251
|
} else if (logicalMatcher.match(path.node)) {
|
|
1179
3252
|
let current = argument;
|
|
1180
|
-
while (
|
|
3253
|
+
while (logicalExpression2.match(current)) {
|
|
1181
3254
|
current.operator = INVERTED_LOGICAL_OPERATORS[current.operator];
|
|
1182
|
-
current.right =
|
|
1183
|
-
if (!
|
|
1184
|
-
current.left =
|
|
3255
|
+
current.right = t26.unaryExpression("!", current.right);
|
|
3256
|
+
if (!logicalExpression2.match(current.left)) {
|
|
3257
|
+
current.left = t26.unaryExpression("!", current.left);
|
|
1185
3258
|
}
|
|
1186
3259
|
current = current.left;
|
|
1187
3260
|
}
|
|
@@ -1193,22 +3266,21 @@ var invert_boolean_logic_default = {
|
|
|
1193
3266
|
};
|
|
1194
3267
|
}
|
|
1195
3268
|
};
|
|
1196
|
-
// node_modules/webcrack/src/unminify/transforms/json-parse.ts
|
|
3269
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/json-parse.ts
|
|
1197
3270
|
import {parseExpression} from "@babel/parser";
|
|
1198
|
-
import * as m17 from "@codemod/matchers";
|
|
1199
3271
|
var json_parse_default = {
|
|
1200
3272
|
name: "json-parse",
|
|
1201
3273
|
tags: ["safe"],
|
|
1202
3274
|
scope: true,
|
|
1203
3275
|
visitor: () => {
|
|
1204
|
-
const string =
|
|
1205
|
-
const
|
|
1206
|
-
|
|
3276
|
+
const string = capture(anyString());
|
|
3277
|
+
const matcher3 = callExpression(constMemberExpression("JSON", "parse"), [
|
|
3278
|
+
stringLiteral(string)
|
|
1207
3279
|
]);
|
|
1208
3280
|
return {
|
|
1209
3281
|
CallExpression: {
|
|
1210
3282
|
exit(path) {
|
|
1211
|
-
if (
|
|
3283
|
+
if (matcher3.match(path.node) && !path.scope.hasBinding("JSON", { noGlobals: true })) {
|
|
1212
3284
|
try {
|
|
1213
3285
|
JSON.parse(string.current);
|
|
1214
3286
|
const parsed = parseExpression(string.current);
|
|
@@ -1222,15 +3294,14 @@ var json_parse_default = {
|
|
|
1222
3294
|
};
|
|
1223
3295
|
}
|
|
1224
3296
|
};
|
|
1225
|
-
// node_modules/webcrack/src/unminify/transforms/logical-to-if.ts
|
|
3297
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/logical-to-if.ts
|
|
1226
3298
|
import {statement} from "@babel/template";
|
|
1227
|
-
import * as m18 from "@codemod/matchers";
|
|
1228
3299
|
var logical_to_if_default = {
|
|
1229
3300
|
name: "logical-to-if",
|
|
1230
3301
|
tags: ["safe"],
|
|
1231
3302
|
visitor: () => {
|
|
1232
|
-
const andMatcher =
|
|
1233
|
-
const orMatcher =
|
|
3303
|
+
const andMatcher = expressionStatement(logicalExpression("&&"));
|
|
3304
|
+
const orMatcher = expressionStatement(logicalExpression("||"));
|
|
1234
3305
|
const buildIf = statement`if (TEST) { BODY; }`;
|
|
1235
3306
|
const buildIfNot = statement`if (!TEST) { BODY; }`;
|
|
1236
3307
|
return {
|
|
@@ -1255,18 +3326,17 @@ var logical_to_if_default = {
|
|
|
1255
3326
|
};
|
|
1256
3327
|
}
|
|
1257
3328
|
};
|
|
1258
|
-
// node_modules/webcrack/src/unminify/transforms/merge-else-if.ts
|
|
1259
|
-
import * as m19 from "@codemod/matchers";
|
|
3329
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/merge-else-if.ts
|
|
1260
3330
|
var merge_else_if_default = {
|
|
1261
3331
|
name: "merge-else-if",
|
|
1262
3332
|
tags: ["safe"],
|
|
1263
3333
|
visitor() {
|
|
1264
|
-
const nestedIf =
|
|
1265
|
-
const
|
|
3334
|
+
const nestedIf = capture(ifStatement());
|
|
3335
|
+
const matcher3 = ifStatement(anything(), anything(), blockStatement([nestedIf]));
|
|
1266
3336
|
return {
|
|
1267
3337
|
IfStatement: {
|
|
1268
3338
|
exit(path) {
|
|
1269
|
-
if (
|
|
3339
|
+
if (matcher3.match(path.node)) {
|
|
1270
3340
|
path.node.alternate = nestedIf.current;
|
|
1271
3341
|
this.changes++;
|
|
1272
3342
|
}
|
|
@@ -1275,22 +3345,21 @@ var merge_else_if_default = {
|
|
|
1275
3345
|
};
|
|
1276
3346
|
}
|
|
1277
3347
|
};
|
|
1278
|
-
// node_modules/webcrack/src/unminify/transforms/number-expressions.ts
|
|
1279
|
-
import * as
|
|
1280
|
-
import * as m20 from "@codemod/matchers";
|
|
3348
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/number-expressions.ts
|
|
3349
|
+
import * as t27 from "@babel/types";
|
|
1281
3350
|
var number_expressions_default = {
|
|
1282
3351
|
name: "number-expressions",
|
|
1283
3352
|
tags: ["safe"],
|
|
1284
3353
|
visitor: () => ({
|
|
1285
3354
|
"BinaryExpression|UnaryExpression": {
|
|
1286
3355
|
exit(path) {
|
|
1287
|
-
if (
|
|
3356
|
+
if (matcher3.match(path.node)) {
|
|
1288
3357
|
const evaluated = path.evaluate();
|
|
1289
3358
|
if (evaluated.confident) {
|
|
1290
3359
|
if (path.node.type === "BinaryExpression" && path.node.operator === "/" && !Number.isInteger(evaluated.value)) {
|
|
1291
3360
|
return;
|
|
1292
3361
|
}
|
|
1293
|
-
path.replaceWith(
|
|
3362
|
+
path.replaceWith(t27.valueToNode(evaluated.value));
|
|
1294
3363
|
path.skip();
|
|
1295
3364
|
this.changes++;
|
|
1296
3365
|
}
|
|
@@ -1299,8 +3368,8 @@ var number_expressions_default = {
|
|
|
1299
3368
|
}
|
|
1300
3369
|
})
|
|
1301
3370
|
};
|
|
1302
|
-
var
|
|
1303
|
-
// node_modules/webcrack/src/unminify/transforms/raw-literals.ts
|
|
3371
|
+
var matcher3 = or(binaryExpression(or("+", "-", "*", "/"), predicate((node) => matcher3.match(node)), predicate((node) => matcher3.match(node))), binaryExpression("-", or(stringLiteral(), predicate((node) => matcher3.match(node))), or(stringLiteral(), predicate((node) => matcher3.match(node)))), unaryExpression("-", or(stringLiteral(), predicate((node) => matcher3.match(node)))), numericLiteral());
|
|
3372
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/raw-literals.ts
|
|
1304
3373
|
var raw_literals_default = {
|
|
1305
3374
|
name: "raw-literals",
|
|
1306
3375
|
tags: ["safe"],
|
|
@@ -1319,26 +3388,25 @@ var raw_literals_default = {
|
|
|
1319
3388
|
}
|
|
1320
3389
|
})
|
|
1321
3390
|
};
|
|
1322
|
-
// node_modules/webcrack/src/unminify/transforms/sequence.ts
|
|
1323
|
-
import * as
|
|
1324
|
-
import * as m21 from "@codemod/matchers";
|
|
3391
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/sequence.ts
|
|
3392
|
+
import * as t28 from "@babel/types";
|
|
1325
3393
|
var sequence_default = {
|
|
1326
3394
|
name: "sequence",
|
|
1327
3395
|
tags: ["safe"],
|
|
1328
3396
|
visitor() {
|
|
1329
|
-
const assignmentVariable =
|
|
1330
|
-
const assignedSequence =
|
|
1331
|
-
const assignmentMatcher =
|
|
3397
|
+
const assignmentVariable = or(identifier(), memberExpression(identifier(), identifier()));
|
|
3398
|
+
const assignedSequence = capture(sequenceExpression());
|
|
3399
|
+
const assignmentMatcher = expressionStatement(assignmentExpression(or("=", "+=", "-=", "*=", "/=", "%=", "**=", "<<=", ">>=", ">>>=", "|=", "^=", "&="), assignmentVariable, assignedSequence));
|
|
1332
3400
|
return {
|
|
1333
3401
|
ExpressionStatement: {
|
|
1334
3402
|
exit(path) {
|
|
1335
|
-
if (
|
|
1336
|
-
const statements = path.node.expression.expressions.map((expr) =>
|
|
3403
|
+
if (t28.isSequenceExpression(path.node.expression)) {
|
|
3404
|
+
const statements = path.node.expression.expressions.map((expr) => t28.expressionStatement(expr));
|
|
1337
3405
|
path.replaceWithMultiple(statements);
|
|
1338
3406
|
this.changes++;
|
|
1339
3407
|
} else if (assignmentMatcher.match(path.node)) {
|
|
1340
3408
|
const value = assignedSequence.current.expressions.pop();
|
|
1341
|
-
const statements = assignedSequence.current.expressions.map((expr) =>
|
|
3409
|
+
const statements = assignedSequence.current.expressions.map((expr) => t28.expressionStatement(expr));
|
|
1342
3410
|
path.get("expression.right").replaceWith(value);
|
|
1343
3411
|
path.insertBefore(statements);
|
|
1344
3412
|
this.changes++;
|
|
@@ -1347,10 +3415,10 @@ var sequence_default = {
|
|
|
1347
3415
|
},
|
|
1348
3416
|
ReturnStatement: {
|
|
1349
3417
|
exit(path) {
|
|
1350
|
-
if (
|
|
3418
|
+
if (t28.isSequenceExpression(path.node.argument)) {
|
|
1351
3419
|
const expressions = path.node.argument.expressions;
|
|
1352
3420
|
path.node.argument = expressions.pop();
|
|
1353
|
-
const statements = expressions.map((expr) =>
|
|
3421
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1354
3422
|
path.insertBefore(statements);
|
|
1355
3423
|
this.changes++;
|
|
1356
3424
|
}
|
|
@@ -1358,10 +3426,10 @@ var sequence_default = {
|
|
|
1358
3426
|
},
|
|
1359
3427
|
IfStatement: {
|
|
1360
3428
|
exit(path) {
|
|
1361
|
-
if (
|
|
3429
|
+
if (t28.isSequenceExpression(path.node.test)) {
|
|
1362
3430
|
const expressions = path.node.test.expressions;
|
|
1363
3431
|
path.node.test = expressions.pop();
|
|
1364
|
-
const statements = expressions.map((expr) =>
|
|
3432
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1365
3433
|
path.insertBefore(statements);
|
|
1366
3434
|
this.changes++;
|
|
1367
3435
|
}
|
|
@@ -1369,10 +3437,10 @@ var sequence_default = {
|
|
|
1369
3437
|
},
|
|
1370
3438
|
SwitchStatement: {
|
|
1371
3439
|
exit(path) {
|
|
1372
|
-
if (
|
|
3440
|
+
if (t28.isSequenceExpression(path.node.discriminant)) {
|
|
1373
3441
|
const expressions = path.node.discriminant.expressions;
|
|
1374
3442
|
path.node.discriminant = expressions.pop();
|
|
1375
|
-
const statements = expressions.map((expr) =>
|
|
3443
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1376
3444
|
path.insertBefore(statements);
|
|
1377
3445
|
this.changes++;
|
|
1378
3446
|
}
|
|
@@ -1380,10 +3448,10 @@ var sequence_default = {
|
|
|
1380
3448
|
},
|
|
1381
3449
|
ThrowStatement: {
|
|
1382
3450
|
exit(path) {
|
|
1383
|
-
if (
|
|
3451
|
+
if (t28.isSequenceExpression(path.node.argument)) {
|
|
1384
3452
|
const expressions = path.node.argument.expressions;
|
|
1385
3453
|
path.node.argument = expressions.pop();
|
|
1386
|
-
const statements = expressions.map((expr) =>
|
|
3454
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1387
3455
|
path.insertBefore(statements);
|
|
1388
3456
|
this.changes++;
|
|
1389
3457
|
}
|
|
@@ -1391,12 +3459,12 @@ var sequence_default = {
|
|
|
1391
3459
|
},
|
|
1392
3460
|
ForInStatement: {
|
|
1393
3461
|
exit(path) {
|
|
1394
|
-
const sequence =
|
|
1395
|
-
const
|
|
1396
|
-
if (
|
|
3462
|
+
const sequence = capture(sequenceExpression());
|
|
3463
|
+
const matcher4 = forInStatement(anything(), sequence);
|
|
3464
|
+
if (matcher4.match(path.node)) {
|
|
1397
3465
|
const expressions = sequence.current.expressions;
|
|
1398
3466
|
path.node.right = expressions.pop();
|
|
1399
|
-
const statements = expressions.map((expr) =>
|
|
3467
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1400
3468
|
path.insertBefore(statements);
|
|
1401
3469
|
this.changes++;
|
|
1402
3470
|
}
|
|
@@ -1404,27 +3472,27 @@ var sequence_default = {
|
|
|
1404
3472
|
},
|
|
1405
3473
|
ForStatement: {
|
|
1406
3474
|
exit(path) {
|
|
1407
|
-
if (
|
|
1408
|
-
const statements = path.node.init.expressions.map((expr) =>
|
|
3475
|
+
if (t28.isSequenceExpression(path.node.init)) {
|
|
3476
|
+
const statements = path.node.init.expressions.map((expr) => t28.expressionStatement(expr));
|
|
1409
3477
|
path.insertBefore(statements);
|
|
1410
3478
|
path.node.init = null;
|
|
1411
3479
|
this.changes++;
|
|
1412
3480
|
}
|
|
1413
|
-
if (
|
|
3481
|
+
if (t28.isSequenceExpression(path.node.update) && path.node.body.type === "EmptyStatement") {
|
|
1414
3482
|
const expressions = path.node.update.expressions;
|
|
1415
3483
|
path.node.update = expressions.pop();
|
|
1416
|
-
const statements = expressions.map((expr) =>
|
|
1417
|
-
path.node.body =
|
|
3484
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
3485
|
+
path.node.body = t28.blockStatement(statements);
|
|
1418
3486
|
this.changes++;
|
|
1419
3487
|
}
|
|
1420
3488
|
}
|
|
1421
3489
|
},
|
|
1422
3490
|
WhileStatement: {
|
|
1423
3491
|
exit(path) {
|
|
1424
|
-
if (
|
|
3492
|
+
if (t28.isSequenceExpression(path.node.test)) {
|
|
1425
3493
|
const expressions = path.node.test.expressions;
|
|
1426
3494
|
path.node.test = expressions.pop();
|
|
1427
|
-
const statements = expressions.map((expr) =>
|
|
3495
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1428
3496
|
path.insertBefore(statements);
|
|
1429
3497
|
this.changes++;
|
|
1430
3498
|
}
|
|
@@ -1432,14 +3500,14 @@ var sequence_default = {
|
|
|
1432
3500
|
},
|
|
1433
3501
|
VariableDeclaration: {
|
|
1434
3502
|
exit(path) {
|
|
1435
|
-
const sequence =
|
|
1436
|
-
const
|
|
1437
|
-
|
|
3503
|
+
const sequence = capture(sequenceExpression());
|
|
3504
|
+
const matcher4 = variableDeclaration(undefined, [
|
|
3505
|
+
variableDeclarator(undefined, sequence)
|
|
1438
3506
|
]);
|
|
1439
|
-
if (
|
|
3507
|
+
if (matcher4.match(path.node)) {
|
|
1440
3508
|
const expressions = sequence.current.expressions;
|
|
1441
3509
|
path.node.declarations[0].init = expressions.pop();
|
|
1442
|
-
const statements = expressions.map((expr) =>
|
|
3510
|
+
const statements = expressions.map((expr) => t28.expressionStatement(expr));
|
|
1443
3511
|
if (path.parentPath.isForStatement() && path.key === "init") {
|
|
1444
3512
|
path.parentPath.insertBefore(statements);
|
|
1445
3513
|
} else {
|
|
@@ -1452,8 +3520,8 @@ var sequence_default = {
|
|
|
1452
3520
|
};
|
|
1453
3521
|
}
|
|
1454
3522
|
};
|
|
1455
|
-
// node_modules/webcrack/src/unminify/transforms/split-variable-declarations.ts
|
|
1456
|
-
import * as
|
|
3523
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/split-variable-declarations.ts
|
|
3524
|
+
import * as t29 from "@babel/types";
|
|
1457
3525
|
var split_variable_declarations_default = {
|
|
1458
3526
|
name: "split-variable-declarations",
|
|
1459
3527
|
tags: ["safe"],
|
|
@@ -1462,9 +3530,9 @@ var split_variable_declarations_default = {
|
|
|
1462
3530
|
exit(path) {
|
|
1463
3531
|
if (path.node.declarations.length > 1 && path.key !== "init") {
|
|
1464
3532
|
if (path.parentPath.isExportNamedDeclaration()) {
|
|
1465
|
-
path.parentPath.replaceWithMultiple(path.node.declarations.map((declaration) =>
|
|
3533
|
+
path.parentPath.replaceWithMultiple(path.node.declarations.map((declaration) => t29.exportNamedDeclaration(t29.variableDeclaration(path.node.kind, [declaration]))));
|
|
1466
3534
|
} else {
|
|
1467
|
-
path.replaceWithMultiple(path.node.declarations.map((declaration) =>
|
|
3535
|
+
path.replaceWithMultiple(path.node.declarations.map((declaration) => t29.variableDeclaration(path.node.kind, [declaration])));
|
|
1468
3536
|
}
|
|
1469
3537
|
this.changes++;
|
|
1470
3538
|
}
|
|
@@ -1472,17 +3540,16 @@ var split_variable_declarations_default = {
|
|
|
1472
3540
|
}
|
|
1473
3541
|
})
|
|
1474
3542
|
};
|
|
1475
|
-
// node_modules/webcrack/src/unminify/transforms/ternary-to-if.ts
|
|
3543
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/ternary-to-if.ts
|
|
1476
3544
|
import {statement as statement2} from "@babel/template";
|
|
1477
|
-
import * as m22 from "@codemod/matchers";
|
|
1478
3545
|
var ternary_to_if_default = {
|
|
1479
3546
|
name: "ternary-to-if",
|
|
1480
3547
|
tags: ["safe"],
|
|
1481
3548
|
visitor() {
|
|
1482
|
-
const test =
|
|
1483
|
-
const consequent =
|
|
1484
|
-
const alternate =
|
|
1485
|
-
const conditional =
|
|
3549
|
+
const test = capture(anyExpression());
|
|
3550
|
+
const consequent = capture(anyExpression());
|
|
3551
|
+
const alternate = capture(anyExpression());
|
|
3552
|
+
const conditional = conditionalExpression(test, consequent, alternate);
|
|
1486
3553
|
const buildIf = statement2`if (TEST) { CONSEQUENT; } else { ALTERNATE; }`;
|
|
1487
3554
|
const buildIfReturn = statement2`if (TEST) { return CONSEQUENT; } else { return ALTERNATE; }`;
|
|
1488
3555
|
return {
|
|
@@ -1513,9 +3580,8 @@ var ternary_to_if_default = {
|
|
|
1513
3580
|
};
|
|
1514
3581
|
}
|
|
1515
3582
|
};
|
|
1516
|
-
// node_modules/webcrack/src/unminify/transforms/typeof-undefined.ts
|
|
1517
|
-
import * as
|
|
1518
|
-
import * as m23 from "@codemod/matchers";
|
|
3583
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/typeof-undefined.ts
|
|
3584
|
+
import * as t30 from "@babel/types";
|
|
1519
3585
|
var OPERATOR_MAP = {
|
|
1520
3586
|
">": "===",
|
|
1521
3587
|
"<": "!=="
|
|
@@ -1524,35 +3590,34 @@ var typeof_undefined_default = {
|
|
|
1524
3590
|
name: "typeof-undefined",
|
|
1525
3591
|
tags: ["safe"],
|
|
1526
3592
|
visitor() {
|
|
1527
|
-
const operator =
|
|
1528
|
-
const argument =
|
|
1529
|
-
const
|
|
3593
|
+
const operator = capture(or(">", "<"));
|
|
3594
|
+
const argument = capture(anyExpression());
|
|
3595
|
+
const matcher4 = binaryExpression(operator, unaryExpression("typeof", argument), stringLiteral("u"));
|
|
1530
3596
|
return {
|
|
1531
3597
|
BinaryExpression: {
|
|
1532
3598
|
exit(path) {
|
|
1533
|
-
if (!
|
|
3599
|
+
if (!matcher4.match(path.node))
|
|
1534
3600
|
return;
|
|
1535
|
-
path.replaceWith(
|
|
3601
|
+
path.replaceWith(t30.binaryExpression(OPERATOR_MAP[operator.current], t30.unaryExpression("typeof", argument.current), t30.stringLiteral("undefined")));
|
|
1536
3602
|
this.changes++;
|
|
1537
3603
|
}
|
|
1538
3604
|
}
|
|
1539
3605
|
};
|
|
1540
3606
|
}
|
|
1541
3607
|
};
|
|
1542
|
-
// node_modules/webcrack/src/unminify/transforms/unary-expressions.ts
|
|
1543
|
-
import * as
|
|
1544
|
-
import * as m24 from "@codemod/matchers";
|
|
3608
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/unary-expressions.ts
|
|
3609
|
+
import * as t31 from "@babel/types";
|
|
1545
3610
|
var unary_expressions_default = {
|
|
1546
3611
|
name: "unary-expressions",
|
|
1547
3612
|
tags: ["safe"],
|
|
1548
3613
|
visitor() {
|
|
1549
|
-
const argument =
|
|
1550
|
-
const
|
|
1551
|
-
const returnVoid =
|
|
3614
|
+
const argument = capture(anyExpression());
|
|
3615
|
+
const matcher4 = expressionStatement(unaryExpression(or("void", "!", "typeof"), argument));
|
|
3616
|
+
const returnVoid = returnStatement(unaryExpression("void", argument));
|
|
1552
3617
|
return {
|
|
1553
3618
|
ExpressionStatement: {
|
|
1554
3619
|
exit(path) {
|
|
1555
|
-
if (!
|
|
3620
|
+
if (!matcher4.match(path.node))
|
|
1556
3621
|
return;
|
|
1557
3622
|
path.replaceWith(argument.current);
|
|
1558
3623
|
this.changes++;
|
|
@@ -1563,47 +3628,45 @@ var unary_expressions_default = {
|
|
|
1563
3628
|
if (!returnVoid.match(path.node))
|
|
1564
3629
|
return;
|
|
1565
3630
|
path.replaceWith(argument.current);
|
|
1566
|
-
path.insertAfter(
|
|
3631
|
+
path.insertAfter(t31.returnStatement());
|
|
1567
3632
|
this.changes++;
|
|
1568
3633
|
}
|
|
1569
3634
|
}
|
|
1570
3635
|
};
|
|
1571
3636
|
}
|
|
1572
3637
|
};
|
|
1573
|
-
// node_modules/webcrack/src/unminify/transforms/unminify-booleans.ts
|
|
1574
|
-
import * as
|
|
1575
|
-
import * as m25 from "@codemod/matchers";
|
|
3638
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/unminify-booleans.ts
|
|
3639
|
+
import * as t32 from "@babel/types";
|
|
1576
3640
|
var unminify_booleans_default = {
|
|
1577
3641
|
name: "unminify-booleans",
|
|
1578
3642
|
tags: ["safe"],
|
|
1579
3643
|
visitor: () => ({
|
|
1580
3644
|
UnaryExpression(path) {
|
|
1581
3645
|
if (trueMatcher2.match(path.node)) {
|
|
1582
|
-
path.replaceWith(
|
|
3646
|
+
path.replaceWith(t32.booleanLiteral(true));
|
|
1583
3647
|
this.changes++;
|
|
1584
3648
|
} else if (falseMatcher2.match(path.node)) {
|
|
1585
|
-
path.replaceWith(
|
|
3649
|
+
path.replaceWith(t32.booleanLiteral(false));
|
|
1586
3650
|
this.changes++;
|
|
1587
3651
|
}
|
|
1588
3652
|
}
|
|
1589
3653
|
})
|
|
1590
3654
|
};
|
|
1591
|
-
var trueMatcher2 =
|
|
1592
|
-
var falseMatcher2 =
|
|
1593
|
-
// node_modules/webcrack/src/unminify/transforms/void-to-undefined.ts
|
|
1594
|
-
import * as
|
|
1595
|
-
import * as m26 from "@codemod/matchers";
|
|
3655
|
+
var trueMatcher2 = or(unaryExpression("!", numericLiteral(0)), unaryExpression("!", unaryExpression("!", numericLiteral(1))), unaryExpression("!", unaryExpression("!", arrayExpression([]))));
|
|
3656
|
+
var falseMatcher2 = or(unaryExpression("!", numericLiteral(1)), unaryExpression("!", arrayExpression([])));
|
|
3657
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/void-to-undefined.ts
|
|
3658
|
+
import * as t33 from "@babel/types";
|
|
1596
3659
|
var void_to_undefined_default = {
|
|
1597
3660
|
name: "void-to-undefined",
|
|
1598
3661
|
tags: ["safe"],
|
|
1599
3662
|
scope: true,
|
|
1600
3663
|
visitor: () => {
|
|
1601
|
-
const
|
|
3664
|
+
const matcher4 = unaryExpression("void", numericLiteral(0));
|
|
1602
3665
|
return {
|
|
1603
3666
|
UnaryExpression: {
|
|
1604
3667
|
exit(path) {
|
|
1605
|
-
if (
|
|
1606
|
-
path.replaceWith(
|
|
3668
|
+
if (matcher4.match(path.node) && !path.scope.hasBinding("undefined", { noGlobals: true })) {
|
|
3669
|
+
path.replaceWith(t33.identifier("undefined"));
|
|
1607
3670
|
this.changes++;
|
|
1608
3671
|
}
|
|
1609
3672
|
}
|
|
@@ -1611,9 +3674,8 @@ var void_to_undefined_default = {
|
|
|
1611
3674
|
};
|
|
1612
3675
|
}
|
|
1613
3676
|
};
|
|
1614
|
-
// node_modules/webcrack/src/unminify/transforms/yoda.ts
|
|
1615
|
-
import * as
|
|
1616
|
-
import * as m27 from "@codemod/matchers";
|
|
3677
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/unminify/transforms/yoda.ts
|
|
3678
|
+
import * as t34 from "@babel/types";
|
|
1617
3679
|
var FLIPPED_OPERATORS = {
|
|
1618
3680
|
"==": "==",
|
|
1619
3681
|
"===": "===",
|
|
@@ -1632,12 +3694,12 @@ var yoda_default = {
|
|
|
1632
3694
|
name: "yoda",
|
|
1633
3695
|
tags: ["safe"],
|
|
1634
3696
|
visitor: () => {
|
|
1635
|
-
const
|
|
3697
|
+
const matcher4 = binaryExpression(or(...Object.values(FLIPPED_OPERATORS)), or(stringLiteral(), numericLiteral(), unaryExpression("-", or(numericLiteral(), identifier("Infinity"))), booleanLiteral(), nullLiteral(), identifier("undefined"), identifier("NaN"), identifier("Infinity")), predicate((node) => !t34.isLiteral(node)));
|
|
1636
3698
|
return {
|
|
1637
3699
|
BinaryExpression: {
|
|
1638
3700
|
exit(path) {
|
|
1639
|
-
if (
|
|
1640
|
-
path.replaceWith(
|
|
3701
|
+
if (matcher4.match(path.node)) {
|
|
3702
|
+
path.replaceWith(t34.binaryExpression(FLIPPED_OPERATORS[path.node.operator], path.node.right, path.node.left));
|
|
1641
3703
|
this.changes++;
|
|
1642
3704
|
}
|
|
1643
3705
|
}
|
|
@@ -1645,7 +3707,7 @@ var yoda_default = {
|
|
|
1645
3707
|
};
|
|
1646
3708
|
}
|
|
1647
3709
|
};
|
|
1648
|
-
// node_modules/webcrack/src/unminify/index.ts
|
|
3710
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/unminify/index.ts
|
|
1649
3711
|
var unminify_default = mergeTransforms({
|
|
1650
3712
|
name: "unminify",
|
|
1651
3713
|
tags: ["safe"],
|
|
@@ -1668,23 +3730,20 @@ async function transform2(ast2) {
|
|
|
1668
3730
|
}
|
|
1669
3731
|
|
|
1670
3732
|
// transform/esmodule/module-helper.ts
|
|
1671
|
-
import * as
|
|
1672
|
-
import * as m34 from "@codemod/matchers";
|
|
3733
|
+
import * as t35 from "@babel/types";
|
|
1673
3734
|
|
|
1674
3735
|
// utils/matchers/chunk.ts
|
|
1675
|
-
import * as m28 from "@codemod/matchers";
|
|
1676
3736
|
function chunk(id) {
|
|
1677
|
-
return
|
|
3737
|
+
return objectProperty(numericLiteral(id), or(functionExpr([]), functionExpr([mod]), functionExpr([mod, exp]), functionExpr([mod, exp, req])));
|
|
1678
3738
|
}
|
|
1679
|
-
var mod =
|
|
1680
|
-
var exp =
|
|
1681
|
-
var req =
|
|
1682
|
-
var functionExpr = (args) =>
|
|
1683
|
-
var chunks =
|
|
3739
|
+
var mod = capture(identifier());
|
|
3740
|
+
var exp = capture(identifier());
|
|
3741
|
+
var req = capture(identifier());
|
|
3742
|
+
var functionExpr = (args) => or(functionExpression(null, args, blockStatement(), false, false), arrowFunctionExpression(args, blockStatement(), false));
|
|
3743
|
+
var chunks = objectExpression(anyList(oneOrMore(chunk())));
|
|
1684
3744
|
var chunk_default = chunk();
|
|
1685
3745
|
|
|
1686
3746
|
// utils/matchers/createBinding.ts
|
|
1687
|
-
import * as m29 from "@codemod/matchers";
|
|
1688
3747
|
import tmpl from "@babel/template";
|
|
1689
3748
|
var __createBinding = tmpl.expression.ast`
|
|
1690
3749
|
(this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -1699,50 +3758,49 @@ var __createBinding = tmpl.expression.ast`
|
|
|
1699
3758
|
o[k2] = m[k];
|
|
1700
3759
|
}))
|
|
1701
3760
|
`;
|
|
1702
|
-
var obj =
|
|
1703
|
-
var mod2 =
|
|
1704
|
-
var k =
|
|
1705
|
-
var k2 =
|
|
1706
|
-
var desc =
|
|
1707
|
-
var descObj =
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
3761
|
+
var obj = capture(identifier());
|
|
3762
|
+
var mod2 = capture(identifier());
|
|
3763
|
+
var k = capture(identifier());
|
|
3764
|
+
var k2 = capture(identifier());
|
|
3765
|
+
var desc = capture(identifier());
|
|
3766
|
+
var descObj = objectExpression([
|
|
3767
|
+
objectProperty(identifier("enumerable"), booleanLiteral(true)),
|
|
3768
|
+
objectProperty(identifier("get"), functionExpression(null, [], blockStatement([
|
|
3769
|
+
returnStatement(memberExpression(fromCapture(mod2), fromCapture(k), true))
|
|
1711
3770
|
])))
|
|
1712
3771
|
]);
|
|
1713
|
-
var cond =
|
|
1714
|
-
var createBinding_default =
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
3772
|
+
var cond = conditionalExpression(binaryExpression("in", stringLiteral("get"), fromCapture(desc)), unaryExpression("!", memberExpression(fromCapture(mod2), identifier("__esModule"), false)), logicalExpression("||", memberExpression(fromCapture(desc), identifier("writable"), false), memberExpression(fromCapture(desc), identifier("configurable"), false)));
|
|
3773
|
+
var createBinding_default = variableDeclaration("var", [
|
|
3774
|
+
variableDeclarator(identifier(), logicalExpression("||", logicalExpression("&&", thisExpression(), memberExpression(thisExpression(), identifier("__createBinding"))), conditionalExpression(memberExpression(identifier("Object"), identifier("create")), functionExpression(null, [obj, mod2, k, k2], or(blockStatement([
|
|
3775
|
+
ifStatement(binaryExpression("===", k2, identifier("undefined")), containerOf(expressionStatement(assignmentExpression("=", fromCapture(k2), fromCapture(k)))), null),
|
|
3776
|
+
variableDeclaration("var", [
|
|
3777
|
+
variableDeclarator(desc, callExpression(memberExpression(identifier("Object"), identifier("getOwnPropertyDescriptor"), false), [
|
|
3778
|
+
fromCapture(mod2),
|
|
3779
|
+
fromCapture(k)
|
|
1721
3780
|
]))
|
|
1722
3781
|
]),
|
|
1723
|
-
|
|
1724
|
-
|
|
3782
|
+
ifStatement(logicalExpression("||", unaryExpression("!", fromCapture(desc), true), or(cond, unaryExpression("!", unaryExpression("!", cond, true), true))), blockStatement([
|
|
3783
|
+
expressionStatement(assignmentExpression("=", fromCapture(desc), descObj))
|
|
1725
3784
|
]), null),
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
3785
|
+
expressionStatement(callExpression(memberExpression(identifier("Object"), identifier("defineProperty"), false), [
|
|
3786
|
+
fromCapture(obj),
|
|
3787
|
+
fromCapture(k2),
|
|
3788
|
+
fromCapture(desc)
|
|
1730
3789
|
]))
|
|
1731
|
-
]),
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
3790
|
+
]), blockStatement([
|
|
3791
|
+
ifStatement(binaryExpression("===", k2, identifier("undefined")), containerOf(expressionStatement(assignmentExpression("=", fromCapture(k2), fromCapture(k)))), null),
|
|
3792
|
+
expressionStatement(callExpression(memberExpression(identifier("Object"), identifier("defineProperty"), false), [
|
|
3793
|
+
fromCapture(obj),
|
|
3794
|
+
fromCapture(k2),
|
|
1736
3795
|
descObj
|
|
1737
3796
|
]))
|
|
1738
|
-
]))),
|
|
1739
|
-
|
|
1740
|
-
|
|
3797
|
+
]))), functionExpression(null, [obj, mod2, k, k2], blockStatement([
|
|
3798
|
+
ifStatement(binaryExpression("===", k2, identifier("undefined")), containerOf(expressionStatement(assignmentExpression("=", fromCapture(k2), fromCapture(k)))), null),
|
|
3799
|
+
expressionStatement(assignmentExpression("=", memberExpression(fromCapture(obj), fromCapture(k2), true), memberExpression(fromCapture(mod2), fromCapture(k), true)))
|
|
1741
3800
|
])))))
|
|
1742
3801
|
]);
|
|
1743
3802
|
|
|
1744
3803
|
// utils/matchers/setModuleDefault.ts
|
|
1745
|
-
import * as m30 from "@codemod/matchers";
|
|
1746
3804
|
import tmpl2 from "@babel/template";
|
|
1747
3805
|
var __setModuleDefault = tmpl2.expression.ast`
|
|
1748
3806
|
(this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
@@ -1751,42 +3809,41 @@ var __setModuleDefault = tmpl2.expression.ast`
|
|
|
1751
3809
|
o["default"] = v;
|
|
1752
3810
|
})
|
|
1753
3811
|
`;
|
|
1754
|
-
var leftParamObj =
|
|
1755
|
-
var leftParamVal =
|
|
1756
|
-
var leftObjIdentifier =
|
|
1757
|
-
var leftObj =
|
|
1758
|
-
|
|
1759
|
-
|
|
3812
|
+
var leftParamObj = capture(identifier());
|
|
3813
|
+
var leftParamVal = capture(identifier());
|
|
3814
|
+
var leftObjIdentifier = capture(identifier());
|
|
3815
|
+
var leftObj = objectExpression([
|
|
3816
|
+
objectProperty(identifier("enumerable"), booleanLiteral(true)),
|
|
3817
|
+
objectProperty(identifier("value"), leftParamVal)
|
|
1760
3818
|
]);
|
|
1761
|
-
var rightParamObj =
|
|
1762
|
-
var rightParamVal =
|
|
1763
|
-
var setModuleDefault_default =
|
|
1764
|
-
|
|
3819
|
+
var rightParamObj = capture(identifier());
|
|
3820
|
+
var rightParamVal = capture(identifier());
|
|
3821
|
+
var setModuleDefault_default = variableDeclaration("var", [
|
|
3822
|
+
variableDeclarator(identifier(), logicalExpression("||", logicalExpression("&&", thisExpression(), memberExpression(thisExpression(), identifier("__setModuleDefault"))), conditionalExpression(memberExpression(identifier("Object"), identifier("create")), functionExpression(null, [
|
|
1765
3823
|
leftParamObj,
|
|
1766
3824
|
leftParamVal
|
|
1767
|
-
],
|
|
1768
|
-
|
|
1769
|
-
|
|
3825
|
+
], or(blockStatement([
|
|
3826
|
+
variableDeclaration("const", [variableDeclarator(leftObjIdentifier, leftObj)]),
|
|
3827
|
+
expressionStatement(callExpression(memberExpression(identifier("Object"), identifier("defineProperty")), [
|
|
1770
3828
|
leftParamObj,
|
|
1771
|
-
|
|
3829
|
+
stringLiteral("default"),
|
|
1772
3830
|
leftObjIdentifier
|
|
1773
3831
|
]))
|
|
1774
|
-
]),
|
|
1775
|
-
|
|
3832
|
+
]), blockStatement([
|
|
3833
|
+
expressionStatement(callExpression(memberExpression(identifier("Object"), identifier("defineProperty")), [
|
|
1776
3834
|
leftParamObj,
|
|
1777
|
-
|
|
3835
|
+
stringLiteral("default"),
|
|
1778
3836
|
leftObj
|
|
1779
3837
|
]))
|
|
1780
|
-
])), false, false),
|
|
3838
|
+
])), false, false), functionExpression(null, [
|
|
1781
3839
|
rightParamObj,
|
|
1782
3840
|
rightParamVal
|
|
1783
|
-
],
|
|
1784
|
-
|
|
3841
|
+
], blockStatement([
|
|
3842
|
+
expressionStatement(assignmentExpression("=", memberExpression(rightParamObj, identifier("default")), rightParamVal))
|
|
1785
3843
|
])))))
|
|
1786
3844
|
]);
|
|
1787
3845
|
|
|
1788
3846
|
// utils/matchers/importStar.ts
|
|
1789
|
-
import * as m31 from "@codemod/matchers";
|
|
1790
3847
|
import tmpl3 from "@babel/template";
|
|
1791
3848
|
var __importStar = tmpl3.expression.ast`
|
|
1792
3849
|
(this && this.__importStar) || function (mod) {
|
|
@@ -1797,82 +3854,80 @@ var __importStar = tmpl3.expression.ast`
|
|
|
1797
3854
|
return result;
|
|
1798
3855
|
}
|
|
1799
3856
|
`;
|
|
1800
|
-
var mod3 =
|
|
1801
|
-
var k3 =
|
|
1802
|
-
var result =
|
|
1803
|
-
var importStar_default =
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
3857
|
+
var mod3 = capture(identifier());
|
|
3858
|
+
var k3 = capture(identifier());
|
|
3859
|
+
var result = capture(identifier());
|
|
3860
|
+
var importStar_default = variableDeclaration("var", [
|
|
3861
|
+
variableDeclarator(identifier(), logicalExpression("||", logicalExpression("&&", thisExpression(), memberExpression(thisExpression(), identifier("__importStar"), false)), functionExpression(null, [mod3], or(blockStatement([
|
|
3862
|
+
ifStatement(logicalExpression("&&", fromCapture(mod3), memberExpression(fromCapture(mod3), identifier("__esModule"))), containerOf(returnStatement(fromCapture(mod3))), null),
|
|
3863
|
+
variableDeclaration("var", [
|
|
3864
|
+
variableDeclarator(result, objectExpression([]))
|
|
1808
3865
|
]),
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
]),
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
])),
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
3866
|
+
ifStatement(binaryExpression("!=", fromCapture(mod3), nullLiteral()), containerOf(forInStatement(variableDeclaration("var", [
|
|
3867
|
+
variableDeclarator(k3, null)
|
|
3868
|
+
]), fromCapture(mod3), containerOf(ifStatement(logicalExpression("&&", binaryExpression("!==", fromCapture(k3), stringLiteral("default")), callExpression(memberExpression(memberExpression(memberExpression(identifier("Object"), identifier("prototype"), false), identifier("hasOwnProperty"), false), identifier("call"), false), [
|
|
3869
|
+
fromCapture(mod3),
|
|
3870
|
+
fromCapture(k3)
|
|
3871
|
+
])), containerOf(callExpression(identifier(), [
|
|
3872
|
+
fromCapture(result),
|
|
3873
|
+
fromCapture(mod3),
|
|
3874
|
+
fromCapture(k3)
|
|
1818
3875
|
])))))), null),
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
3876
|
+
expressionStatement(callExpression(identifier(), [
|
|
3877
|
+
fromCapture(result),
|
|
3878
|
+
fromCapture(mod3)
|
|
1822
3879
|
])),
|
|
1823
|
-
|
|
3880
|
+
returnStatement(fromCapture(result))
|
|
1824
3881
|
])))))
|
|
1825
3882
|
]);
|
|
1826
3883
|
|
|
1827
3884
|
// utils/matchers/importDefault.ts
|
|
1828
|
-
import * as m32 from "@codemod/matchers";
|
|
1829
3885
|
import tmpl4 from "@babel/template";
|
|
1830
3886
|
var __importDefault = tmpl4.expression.ast`
|
|
1831
3887
|
(this && this.__importDefault) || function (mod) {
|
|
1832
3888
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1833
3889
|
}
|
|
1834
3890
|
`;
|
|
1835
|
-
var mod4 =
|
|
1836
|
-
var isEsm =
|
|
1837
|
-
var importDefault_default =
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
]))),
|
|
1842
|
-
|
|
3891
|
+
var mod4 = capture(identifier());
|
|
3892
|
+
var isEsm = logicalExpression("&&", fromCapture(mod4), memberExpression(fromCapture(mod4), identifier("__esModule"), false));
|
|
3893
|
+
var importDefault_default = variableDeclaration("var", [
|
|
3894
|
+
variableDeclarator(identifier(), logicalExpression("||", logicalExpression("&&", thisExpression(), memberExpression(thisExpression(), identifier("__importDefault"))), functionExpression(null, [mod4], blockStatement([
|
|
3895
|
+
or(returnStatement(conditionalExpression(isEsm, fromCapture(mod4), objectExpression([
|
|
3896
|
+
objectProperty(stringLiteral("default"), fromCapture(mod4), false)
|
|
3897
|
+
]))), ifStatement(isEsm, containerOf(returnStatement(fromCapture(mod4))), containerOf(returnStatement(objectExpression([
|
|
3898
|
+
objectProperty(identifier("default"), fromCapture(mod4), false)
|
|
1843
3899
|
])))))
|
|
1844
3900
|
]))))
|
|
1845
3901
|
]);
|
|
1846
3902
|
|
|
1847
3903
|
// utils/matchers/exportStar.ts
|
|
1848
|
-
import * as m33 from "@codemod/matchers";
|
|
1849
3904
|
import tmpl5 from "@babel/template";
|
|
1850
3905
|
var __exportStar = tmpl5.expression.ast`
|
|
1851
3906
|
(this && this.__exportStar) || function(m, exports) {
|
|
1852
3907
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1853
3908
|
}
|
|
1854
3909
|
`;
|
|
1855
|
-
var mod5 =
|
|
1856
|
-
var exp2 =
|
|
1857
|
-
var p =
|
|
1858
|
-
var exportStar_default =
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
]),
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
]), true)),
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
3910
|
+
var mod5 = capture(identifier());
|
|
3911
|
+
var exp2 = capture(identifier());
|
|
3912
|
+
var p = capture(identifier());
|
|
3913
|
+
var exportStar_default = variableDeclaration("var", [
|
|
3914
|
+
variableDeclarator(identifier(), logicalExpression("||", logicalExpression("&&", thisExpression(), memberExpression(thisExpression(), identifier("__exportStar"), false)), functionExpression(null, [mod5, exp2], blockStatement([
|
|
3915
|
+
forInStatement(variableDeclaration("var", [
|
|
3916
|
+
variableDeclarator(p)
|
|
3917
|
+
]), fromCapture(mod5), containerOf(ifStatement(logicalExpression("&&", binaryExpression("!==", fromCapture(p), stringLiteral("default")), unaryExpression("!", callExpression(memberExpression(memberExpression(memberExpression(identifier("Object"), identifier("prototype"), false), identifier("hasOwnProperty"), false), identifier("call"), false), [
|
|
3918
|
+
fromCapture(exp2),
|
|
3919
|
+
fromCapture(p)
|
|
3920
|
+
]), true)), containerOf(expressionStatement(callExpression(identifier(), [
|
|
3921
|
+
fromCapture(exp2),
|
|
3922
|
+
fromCapture(mod5),
|
|
3923
|
+
fromCapture(p)
|
|
1869
3924
|
]))))))
|
|
1870
3925
|
]))))
|
|
1871
3926
|
]);
|
|
1872
3927
|
|
|
1873
3928
|
// transform/esmodule/module-helper.ts
|
|
1874
|
-
var preExport =
|
|
1875
|
-
var undefinedExpr =
|
|
3929
|
+
var preExport = assignmentExpression("=", memberExpression(identifier("exports"), identifier(), false), identifier("undefined"));
|
|
3930
|
+
var undefinedExpr = expressionStatement(identifier("undefined"));
|
|
1876
3931
|
var module_helper_default = {
|
|
1877
3932
|
name: "module-helper",
|
|
1878
3933
|
tags: ["safe"],
|
|
@@ -1918,19 +3973,19 @@ var module_helper_default = {
|
|
|
1918
3973
|
if (!$id.isIdentifier()) {
|
|
1919
3974
|
return;
|
|
1920
3975
|
}
|
|
1921
|
-
if (importStar_default.match(
|
|
3976
|
+
if (importStar_default.match(t35.cloneNode(p2.node))) {
|
|
1922
3977
|
$id.scope.rename($id.node.name, "__importStar");
|
|
1923
3978
|
$decl.get("init").replaceWith(__importStar);
|
|
1924
|
-
} else if (setModuleDefault_default.match(
|
|
3979
|
+
} else if (setModuleDefault_default.match(t35.cloneNode(p2.node))) {
|
|
1925
3980
|
$id.scope.rename($id.node.name, "__setModuleDefault");
|
|
1926
3981
|
$decl.get("init").replaceWith(__setModuleDefault);
|
|
1927
|
-
} else if (importDefault_default.match(
|
|
3982
|
+
} else if (importDefault_default.match(t35.cloneNode(p2.node))) {
|
|
1928
3983
|
$id.scope.rename($id.node.name, "__importDefault");
|
|
1929
3984
|
$decl.get("init").replaceWith(__importDefault);
|
|
1930
|
-
} else if (createBinding_default.match(
|
|
3985
|
+
} else if (createBinding_default.match(t35.cloneNode(p2.node))) {
|
|
1931
3986
|
$id.scope.rename($id.node.name, "__createBinding");
|
|
1932
3987
|
$decl.get("init").replaceWith(__createBinding);
|
|
1933
|
-
} else if (exportStar_default.match(
|
|
3988
|
+
} else if (exportStar_default.match(t35.cloneNode(p2.node))) {
|
|
1934
3989
|
$id.scope.rename($id.node.name, "__exportStar");
|
|
1935
3990
|
$decl.get("init").replaceWith(__exportStar);
|
|
1936
3991
|
} else {
|
|
@@ -1947,7 +4002,7 @@ var module_helper_default = {
|
|
|
1947
4002
|
};
|
|
1948
4003
|
|
|
1949
4004
|
// transform/esmodule/indirect-call.ts
|
|
1950
|
-
import * as
|
|
4005
|
+
import * as t36 from "@babel/types";
|
|
1951
4006
|
var indirect_call_default = {
|
|
1952
4007
|
name: "indirect-call",
|
|
1953
4008
|
tags: ["unsafe"],
|
|
@@ -1955,16 +4010,16 @@ var indirect_call_default = {
|
|
|
1955
4010
|
CallExpression: {
|
|
1956
4011
|
exit($) {
|
|
1957
4012
|
const { callee, arguments: args } = $.node;
|
|
1958
|
-
if (!
|
|
4013
|
+
if (!t36.isSequenceExpression(callee)) {
|
|
1959
4014
|
return;
|
|
1960
4015
|
}
|
|
1961
4016
|
const exprs = [...callee.expressions];
|
|
1962
4017
|
const func = exprs.pop();
|
|
1963
|
-
if (!
|
|
4018
|
+
if (!t36.isMemberExpression(func)) {
|
|
1964
4019
|
return;
|
|
1965
4020
|
}
|
|
1966
|
-
if (exprs.every((expr) =>
|
|
1967
|
-
$.replaceWith(
|
|
4021
|
+
if (exprs.every((expr) => t36.isPureish(expr))) {
|
|
4022
|
+
$.replaceWith(t36.callExpression(func, args));
|
|
1968
4023
|
this.changes++;
|
|
1969
4024
|
}
|
|
1970
4025
|
}
|
|
@@ -1973,12 +4028,12 @@ var indirect_call_default = {
|
|
|
1973
4028
|
};
|
|
1974
4029
|
|
|
1975
4030
|
// utils/ast.ts
|
|
1976
|
-
import {parse as
|
|
4031
|
+
import {parse as babelParse2} from "@babel/parser";
|
|
1977
4032
|
import babelGenerate2 from "@babel/generator";
|
|
1978
4033
|
import debug4 from "debug";
|
|
1979
|
-
import
|
|
1980
|
-
function
|
|
1981
|
-
return
|
|
4034
|
+
import traverse12, {visitors as visitors2} from "@babel/traverse";
|
|
4035
|
+
function parse2(code) {
|
|
4036
|
+
return babelParse2(code, {
|
|
1982
4037
|
sourceType: "script",
|
|
1983
4038
|
allowReturnOutsideFunction: true
|
|
1984
4039
|
});
|
|
@@ -1986,14 +4041,14 @@ function parse(code) {
|
|
|
1986
4041
|
function generate2(ast2) {
|
|
1987
4042
|
return babelGenerate2(ast2, { jsescOption: { minimal: true, quotes: "single" } }).code;
|
|
1988
4043
|
}
|
|
1989
|
-
function applyTransform2(ast2, transform3,
|
|
4044
|
+
function applyTransform2(ast2, transform3, options2, noScopeOverride) {
|
|
1990
4045
|
logger2(`${transform3.name}: started`);
|
|
1991
4046
|
const state = { changes: 0 };
|
|
1992
|
-
transform3.run?.(ast2, state,
|
|
4047
|
+
transform3.run?.(ast2, state, options2);
|
|
1993
4048
|
if (transform3.visitor) {
|
|
1994
|
-
const visitor = transform3.visitor(
|
|
4049
|
+
const visitor = transform3.visitor(options2);
|
|
1995
4050
|
visitor.noScope = noScopeOverride ?? !transform3.scope;
|
|
1996
|
-
|
|
4051
|
+
traverse12(ast2, visitor, undefined, state);
|
|
1997
4052
|
}
|
|
1998
4053
|
logger2(`${transform3.name}: finished with ${state.changes} changes`);
|
|
1999
4054
|
return state;
|
|
@@ -2008,8 +4063,7 @@ function transform3(ast2) {
|
|
|
2008
4063
|
}
|
|
2009
4064
|
|
|
2010
4065
|
// transform/syntactic/template-literal.ts
|
|
2011
|
-
import * as
|
|
2012
|
-
import * as m35 from "@codemod/matchers";
|
|
4066
|
+
import * as t37 from "@babel/types";
|
|
2013
4067
|
var escape = function(string) {
|
|
2014
4068
|
return string.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("$", "\\$").replaceAll("\t", "\\t").replaceAll("\r", "\\r").replaceAll("\0", "\\0");
|
|
2015
4069
|
};
|
|
@@ -2017,7 +4071,7 @@ var template_literal_default = {
|
|
|
2017
4071
|
name: "template-literal",
|
|
2018
4072
|
tags: ["safe"],
|
|
2019
4073
|
visitor() {
|
|
2020
|
-
const concatExpr =
|
|
4074
|
+
const concatExpr = binaryExpression("+", or(stringLiteral(), templateLiteral()), anyExpression());
|
|
2021
4075
|
return {
|
|
2022
4076
|
BinaryExpression: {
|
|
2023
4077
|
exit($) {
|
|
@@ -2032,10 +4086,10 @@ var template_literal_default = {
|
|
|
2032
4086
|
if (!last) {
|
|
2033
4087
|
throw new Error("Unexpected empty template literal");
|
|
2034
4088
|
}
|
|
2035
|
-
$left.node.quasis.push(
|
|
4089
|
+
$left.node.quasis.push(t37.templateElement({
|
|
2036
4090
|
raw: last.value.raw + $right.node.quasis[0].value.raw
|
|
2037
4091
|
}, false), ...$right.node.quasis.slice(1));
|
|
2038
|
-
$.replaceWith(
|
|
4092
|
+
$.replaceWith(t37.templateLiteral([
|
|
2039
4093
|
...$left.node.quasis
|
|
2040
4094
|
], [
|
|
2041
4095
|
...$left.node.expressions,
|
|
@@ -2046,17 +4100,17 @@ var template_literal_default = {
|
|
|
2046
4100
|
if (!last) {
|
|
2047
4101
|
throw new Error("Unexpected empty template literal");
|
|
2048
4102
|
}
|
|
2049
|
-
$left.node.quasis.push(
|
|
4103
|
+
$left.node.quasis.push(t37.templateElement({
|
|
2050
4104
|
raw: escape(last.value.raw + $right.node.value)
|
|
2051
4105
|
}, true));
|
|
2052
4106
|
$.replaceWith($left.node);
|
|
2053
4107
|
} else {
|
|
2054
|
-
$.replaceWith(
|
|
4108
|
+
$.replaceWith(t37.templateLiteral([
|
|
2055
4109
|
...$left.node.quasis.map((element) => {
|
|
2056
4110
|
element.tail = false;
|
|
2057
4111
|
return element;
|
|
2058
4112
|
}),
|
|
2059
|
-
|
|
4113
|
+
t37.templateElement({ raw: "" }, true)
|
|
2060
4114
|
], [
|
|
2061
4115
|
...$left.node.expressions,
|
|
2062
4116
|
$right.node
|
|
@@ -2070,9 +4124,9 @@ var template_literal_default = {
|
|
|
2070
4124
|
if ($right.isCallExpression() && $right.get("callee").isFunctionExpression()) {
|
|
2071
4125
|
return;
|
|
2072
4126
|
}
|
|
2073
|
-
$.replaceWith(
|
|
2074
|
-
|
|
2075
|
-
|
|
4127
|
+
$.replaceWith(t37.templateLiteral([
|
|
4128
|
+
t37.templateElement({ raw: escape($left.node.value) }, false),
|
|
4129
|
+
t37.templateElement({ raw: "" }, true)
|
|
2076
4130
|
], [
|
|
2077
4131
|
$right.node
|
|
2078
4132
|
]));
|
|
@@ -2091,7 +4145,7 @@ function transform4(ast2) {
|
|
|
2091
4145
|
return ast2;
|
|
2092
4146
|
}
|
|
2093
4147
|
|
|
2094
|
-
// node_modules/webcrack/src/transpile/transforms/index.ts
|
|
4148
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/transpile/transforms/index.ts
|
|
2095
4149
|
var exports_transforms2 = {};
|
|
2096
4150
|
__export(exports_transforms2, {
|
|
2097
4151
|
templateLiterals: () => {
|
|
@@ -2121,31 +4175,30 @@ __export(exports_transforms2, {
|
|
|
2121
4175
|
}
|
|
2122
4176
|
});
|
|
2123
4177
|
|
|
2124
|
-
// node_modules/webcrack/src/transpile/transforms/logical-assignments.ts
|
|
2125
|
-
import * as
|
|
2126
|
-
import * as m36 from "@codemod/matchers";
|
|
4178
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/transpile/transforms/logical-assignments.ts
|
|
4179
|
+
import * as t38 from "@babel/types";
|
|
2127
4180
|
var logical_assignments_default = {
|
|
2128
4181
|
name: "logical-assignments",
|
|
2129
4182
|
tags: ["safe"],
|
|
2130
4183
|
scope: true,
|
|
2131
4184
|
visitor() {
|
|
2132
|
-
const operator =
|
|
2133
|
-
const left =
|
|
2134
|
-
const right =
|
|
2135
|
-
const idMatcher =
|
|
2136
|
-
const object =
|
|
2137
|
-
const property =
|
|
2138
|
-
const tmpVar =
|
|
2139
|
-
const member =
|
|
2140
|
-
const memberMatcher =
|
|
2141
|
-
const computedMemberMatcher =
|
|
2142
|
-
const tmpVar2 =
|
|
2143
|
-
const multiComputedMemberMatcher =
|
|
4185
|
+
const operator = capture(or("||", "&&"));
|
|
4186
|
+
const left = capture(or(identifier(), memberExpression()));
|
|
4187
|
+
const right = capture(anyExpression());
|
|
4188
|
+
const idMatcher = logicalExpression(operator, left, assignmentExpression("=", fromCapture(left), right));
|
|
4189
|
+
const object = capture(anyExpression());
|
|
4190
|
+
const property = capture(anyExpression());
|
|
4191
|
+
const tmpVar = capture(identifier());
|
|
4192
|
+
const member = capture(memberExpression(fromCapture(tmpVar), fromCapture(property)));
|
|
4193
|
+
const memberMatcher = logicalExpression(operator, memberExpression(assignmentExpression("=", tmpVar, object), property), assignmentExpression("=", member, right));
|
|
4194
|
+
const computedMemberMatcher = logicalExpression(operator, memberExpression(object, assignmentExpression("=", tmpVar, property), true), assignmentExpression("=", memberExpression(fromCapture(object), fromCapture(tmpVar), true), right));
|
|
4195
|
+
const tmpVar2 = capture(identifier());
|
|
4196
|
+
const multiComputedMemberMatcher = logicalExpression(operator, memberExpression(assignmentExpression("=", tmpVar, object), assignmentExpression("=", tmpVar2, property), true), assignmentExpression("=", memberExpression(fromCapture(tmpVar), fromCapture(tmpVar2), true), right));
|
|
2144
4197
|
return {
|
|
2145
4198
|
LogicalExpression: {
|
|
2146
4199
|
exit(path) {
|
|
2147
4200
|
if (idMatcher.match(path.node)) {
|
|
2148
|
-
path.replaceWith(
|
|
4201
|
+
path.replaceWith(t38.assignmentExpression(operator.current + "=", left.current, right.current));
|
|
2149
4202
|
this.changes++;
|
|
2150
4203
|
} else if (memberMatcher.match(path.node)) {
|
|
2151
4204
|
const binding = path.scope.getBinding(tmpVar.current.name);
|
|
@@ -2153,14 +4206,14 @@ var logical_assignments_default = {
|
|
|
2153
4206
|
return;
|
|
2154
4207
|
binding.path.remove();
|
|
2155
4208
|
member.current.object = object.current;
|
|
2156
|
-
path.replaceWith(
|
|
4209
|
+
path.replaceWith(t38.assignmentExpression(operator.current + "=", member.current, right.current));
|
|
2157
4210
|
this.changes++;
|
|
2158
4211
|
} else if (computedMemberMatcher.match(path.node)) {
|
|
2159
4212
|
const binding = path.scope.getBinding(tmpVar.current.name);
|
|
2160
4213
|
if (!isTemporaryVariable(binding, 1))
|
|
2161
4214
|
return;
|
|
2162
4215
|
binding.path.remove();
|
|
2163
|
-
path.replaceWith(
|
|
4216
|
+
path.replaceWith(t38.assignmentExpression(operator.current + "=", t38.memberExpression(object.current, property.current, true), right.current));
|
|
2164
4217
|
this.changes++;
|
|
2165
4218
|
} else if (multiComputedMemberMatcher.match(path.node)) {
|
|
2166
4219
|
const binding = path.scope.getBinding(tmpVar.current.name);
|
|
@@ -2169,7 +4222,7 @@ var logical_assignments_default = {
|
|
|
2169
4222
|
return;
|
|
2170
4223
|
binding.path.remove();
|
|
2171
4224
|
binding2.path.remove();
|
|
2172
|
-
path.replaceWith(
|
|
4225
|
+
path.replaceWith(t38.assignmentExpression(operator.current + "=", t38.memberExpression(object.current, property.current, true), right.current));
|
|
2173
4226
|
this.changes++;
|
|
2174
4227
|
}
|
|
2175
4228
|
}
|
|
@@ -2177,32 +4230,31 @@ var logical_assignments_default = {
|
|
|
2177
4230
|
};
|
|
2178
4231
|
}
|
|
2179
4232
|
};
|
|
2180
|
-
// node_modules/webcrack/src/transpile/transforms/nullish-coalescing.ts
|
|
2181
|
-
import * as
|
|
2182
|
-
import * as m37 from "@codemod/matchers";
|
|
4233
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/transpile/transforms/nullish-coalescing.ts
|
|
4234
|
+
import * as t39 from "@babel/types";
|
|
2183
4235
|
var nullish_coalescing_default = {
|
|
2184
4236
|
name: "nullish-coalescing",
|
|
2185
4237
|
tags: ["safe"],
|
|
2186
4238
|
scope: true,
|
|
2187
4239
|
visitor() {
|
|
2188
|
-
const tmpVar =
|
|
2189
|
-
const left =
|
|
2190
|
-
const right =
|
|
2191
|
-
const idMatcher =
|
|
2192
|
-
const idLooseMatcher =
|
|
2193
|
-
const simpleIdMatcher =
|
|
2194
|
-
const iifeMatcher =
|
|
4240
|
+
const tmpVar = capture(identifier());
|
|
4241
|
+
const left = capture(anyExpression());
|
|
4242
|
+
const right = capture(anyExpression());
|
|
4243
|
+
const idMatcher = conditionalExpression(logicalExpression("&&", binaryExpression("!==", assignmentExpression("=", tmpVar, left), nullLiteral()), binaryExpression("!==", fromCapture(tmpVar), identifier("undefined"))), fromCapture(tmpVar), right);
|
|
4244
|
+
const idLooseMatcher = conditionalExpression(binaryExpression("!=", assignmentExpression("=", tmpVar, left), nullLiteral()), fromCapture(tmpVar), right);
|
|
4245
|
+
const simpleIdMatcher = conditionalExpression(or(logicalExpression("&&", binaryExpression("!==", left, nullLiteral()), binaryExpression("!==", fromCapture(left), identifier("undefined"))), binaryExpression("!=", left, nullLiteral())), fromCapture(left), right);
|
|
4246
|
+
const iifeMatcher = callExpression(arrowFunctionExpression([fromCapture(tmpVar)], anyExpression(), false), []);
|
|
2195
4247
|
return {
|
|
2196
4248
|
ConditionalExpression: {
|
|
2197
4249
|
exit(path) {
|
|
2198
4250
|
if (idMatcher.match(path.node)) {
|
|
2199
4251
|
const binding = path.scope.getBinding(tmpVar.current.name);
|
|
2200
4252
|
if (iifeMatcher.match(path.parentPath.parent) && isTemporaryVariable(binding, 2, "param")) {
|
|
2201
|
-
path.parentPath.parentPath.replaceWith(
|
|
4253
|
+
path.parentPath.parentPath.replaceWith(t39.logicalExpression("??", left.current, right.current));
|
|
2202
4254
|
this.changes++;
|
|
2203
4255
|
} else if (isTemporaryVariable(binding, 2, "var")) {
|
|
2204
4256
|
binding.path.remove();
|
|
2205
|
-
path.replaceWith(
|
|
4257
|
+
path.replaceWith(t39.logicalExpression("??", left.current, right.current));
|
|
2206
4258
|
this.changes++;
|
|
2207
4259
|
}
|
|
2208
4260
|
} else if (idLooseMatcher.match(path.node)) {
|
|
@@ -2210,10 +4262,10 @@ var nullish_coalescing_default = {
|
|
|
2210
4262
|
if (!isTemporaryVariable(binding, 1))
|
|
2211
4263
|
return;
|
|
2212
4264
|
binding.path.remove();
|
|
2213
|
-
path.replaceWith(
|
|
4265
|
+
path.replaceWith(t39.logicalExpression("??", left.current, right.current));
|
|
2214
4266
|
this.changes++;
|
|
2215
4267
|
} else if (simpleIdMatcher.match(path.node)) {
|
|
2216
|
-
path.replaceWith(
|
|
4268
|
+
path.replaceWith(t39.logicalExpression("??", left.current, right.current));
|
|
2217
4269
|
this.changes++;
|
|
2218
4270
|
}
|
|
2219
4271
|
}
|
|
@@ -2221,22 +4273,21 @@ var nullish_coalescing_default = {
|
|
|
2221
4273
|
};
|
|
2222
4274
|
}
|
|
2223
4275
|
};
|
|
2224
|
-
// node_modules/webcrack/src/transpile/transforms/nullish-coalescing-assignment.ts
|
|
2225
|
-
import * as
|
|
2226
|
-
import * as m38 from "@codemod/matchers";
|
|
4276
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/transpile/transforms/nullish-coalescing-assignment.ts
|
|
4277
|
+
import * as t40 from "@babel/types";
|
|
2227
4278
|
var nullish_coalescing_assignment_default = {
|
|
2228
4279
|
name: "nullish-coalescing-assignment",
|
|
2229
4280
|
tags: ["safe"],
|
|
2230
4281
|
scope: true,
|
|
2231
4282
|
visitor() {
|
|
2232
|
-
const tmpVar =
|
|
2233
|
-
const leftId =
|
|
2234
|
-
const property =
|
|
2235
|
-
const right =
|
|
2236
|
-
const computed =
|
|
2237
|
-
const memberMatcher =
|
|
2238
|
-
const left =
|
|
2239
|
-
const simpleMatcher =
|
|
4283
|
+
const tmpVar = capture(identifier());
|
|
4284
|
+
const leftId = capture(identifier());
|
|
4285
|
+
const property = capture(identifier());
|
|
4286
|
+
const right = capture(anyExpression());
|
|
4287
|
+
const computed = capture(anything());
|
|
4288
|
+
const memberMatcher = logicalExpression("??", memberExpression(assignmentExpression("=", tmpVar, leftId), property, computed), assignmentExpression("=", memberExpression(fromCapture(tmpVar), fromCapture(property), computed), right));
|
|
4289
|
+
const left = capture(or(identifier(), memberExpression()));
|
|
4290
|
+
const simpleMatcher = logicalExpression("??", left, assignmentExpression("=", fromCapture(left), right));
|
|
2240
4291
|
return {
|
|
2241
4292
|
LogicalExpression: {
|
|
2242
4293
|
exit(path) {
|
|
@@ -2245,10 +4296,10 @@ var nullish_coalescing_assignment_default = {
|
|
|
2245
4296
|
if (!isTemporaryVariable(binding, 1))
|
|
2246
4297
|
return;
|
|
2247
4298
|
binding.path.remove();
|
|
2248
|
-
path.replaceWith(
|
|
4299
|
+
path.replaceWith(t40.assignmentExpression("??=", t40.memberExpression(leftId.current, property.current, computed.current), right.current));
|
|
2249
4300
|
this.changes++;
|
|
2250
4301
|
} else if (simpleMatcher.match(path.node)) {
|
|
2251
|
-
path.replaceWith(
|
|
4302
|
+
path.replaceWith(t40.assignmentExpression("??=", left.current, right.current));
|
|
2252
4303
|
this.changes++;
|
|
2253
4304
|
}
|
|
2254
4305
|
}
|
|
@@ -2256,26 +4307,25 @@ var nullish_coalescing_assignment_default = {
|
|
|
2256
4307
|
};
|
|
2257
4308
|
}
|
|
2258
4309
|
};
|
|
2259
|
-
// node_modules/webcrack/src/transpile/transforms/optional-chaining.ts
|
|
2260
|
-
import * as
|
|
2261
|
-
import * as m39 from "@codemod/matchers";
|
|
4310
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/transpile/transforms/optional-chaining.ts
|
|
4311
|
+
import * as t41 from "@babel/types";
|
|
2262
4312
|
var optional_chaining_default = {
|
|
2263
4313
|
name: "optional-chaining",
|
|
2264
4314
|
tags: ["safe"],
|
|
2265
4315
|
scope: true,
|
|
2266
4316
|
visitor() {
|
|
2267
|
-
const object =
|
|
2268
|
-
const member =
|
|
2269
|
-
const simpleMatcher =
|
|
2270
|
-
const tmpVar =
|
|
2271
|
-
const tmpMember =
|
|
2272
|
-
const tmpMatcher =
|
|
4317
|
+
const object = capture(anyExpression());
|
|
4318
|
+
const member = capture(memberExpression(fromCapture(object)));
|
|
4319
|
+
const simpleMatcher = conditionalExpression(logicalExpression("||", binaryExpression("===", object, nullLiteral()), binaryExpression("===", fromCapture(object), identifier("undefined"))), identifier("undefined"), member);
|
|
4320
|
+
const tmpVar = capture(identifier());
|
|
4321
|
+
const tmpMember = capture(memberExpression(fromCapture(tmpVar)));
|
|
4322
|
+
const tmpMatcher = conditionalExpression(logicalExpression("||", binaryExpression("===", assignmentExpression("=", tmpVar, object), nullLiteral()), binaryExpression("===", fromCapture(tmpVar), identifier("undefined"))), identifier("undefined"), tmpMember);
|
|
2273
4323
|
return {
|
|
2274
4324
|
ConditionalExpression: {
|
|
2275
4325
|
exit(path) {
|
|
2276
4326
|
if (simpleMatcher.match(path.node)) {
|
|
2277
4327
|
member.current.optional = true;
|
|
2278
|
-
path.replaceWith(
|
|
4328
|
+
path.replaceWith(t41.optionalMemberExpression(object.current, member.current.property, member.current.computed, true));
|
|
2279
4329
|
this.changes++;
|
|
2280
4330
|
} else if (tmpMatcher.match(path.node)) {
|
|
2281
4331
|
const binding = path.scope.getBinding(tmpVar.current.name);
|
|
@@ -2283,7 +4333,7 @@ var optional_chaining_default = {
|
|
|
2283
4333
|
return;
|
|
2284
4334
|
binding.path.remove();
|
|
2285
4335
|
tmpMember.current.optional = true;
|
|
2286
|
-
path.replaceWith(
|
|
4336
|
+
path.replaceWith(t41.optionalMemberExpression(object.current, tmpMember.current.property, tmpMember.current.computed, true));
|
|
2287
4337
|
this.changes++;
|
|
2288
4338
|
}
|
|
2289
4339
|
}
|
|
@@ -2291,9 +4341,8 @@ var optional_chaining_default = {
|
|
|
2291
4341
|
};
|
|
2292
4342
|
}
|
|
2293
4343
|
};
|
|
2294
|
-
// node_modules/webcrack/src/transpile/transforms/template-literals.ts
|
|
2295
|
-
import * as
|
|
2296
|
-
import * as m40 from "@codemod/matchers";
|
|
4344
|
+
// node_modules/.pnpm/@gitpkg.vercel.app+api+pkg.tgz+url=j4k0xb+webcrack+packages@webcrack&commit=fdf21377287e6b492_5xocjcmxikr6zrul2rffoywegy/node_modules/webcrack/src/transpile/transforms/template-literals.ts
|
|
4345
|
+
import * as t42 from "@babel/types";
|
|
2297
4346
|
var escape2 = function(str) {
|
|
2298
4347
|
return str.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$").replace(/\t/g, "\\t").replace(/\r/g, "\\r");
|
|
2299
4348
|
};
|
|
@@ -2309,7 +4358,7 @@ var push = function(template9, value) {
|
|
|
2309
4358
|
template9.quasis.push(...value.quasis.slice(1));
|
|
2310
4359
|
} else {
|
|
2311
4360
|
template9.expressions.push(value);
|
|
2312
|
-
template9.quasis.push(
|
|
4361
|
+
template9.quasis.push(t42.templateElement({ raw: "" }));
|
|
2313
4362
|
}
|
|
2314
4363
|
};
|
|
2315
4364
|
var unshift = function(template9, value) {
|
|
@@ -2323,24 +4372,24 @@ var unshift = function(template9, value) {
|
|
|
2323
4372
|
template9.quasis.unshift(...value.quasis.slice(0, -1));
|
|
2324
4373
|
} else {
|
|
2325
4374
|
template9.expressions.unshift(value);
|
|
2326
|
-
template9.quasis.unshift(
|
|
4375
|
+
template9.quasis.unshift(t42.templateElement({ raw: "" }));
|
|
2327
4376
|
}
|
|
2328
4377
|
};
|
|
2329
4378
|
var template_literals_default = {
|
|
2330
4379
|
name: "template-literals",
|
|
2331
4380
|
tags: ["unsafe"],
|
|
2332
4381
|
visitor() {
|
|
2333
|
-
const concatMatcher =
|
|
4382
|
+
const concatMatcher = or(callExpression(constMemberExpression(or(stringLiteral(), predicate((node) => concatMatcher.match(node))), "concat"), arrayOf(anyExpression())));
|
|
2334
4383
|
return {
|
|
2335
4384
|
BinaryExpression: {
|
|
2336
4385
|
exit(path) {
|
|
2337
4386
|
if (path.node.operator !== "+")
|
|
2338
4387
|
return;
|
|
2339
|
-
if (
|
|
4388
|
+
if (t42.isTemplateLiteral(path.node.left)) {
|
|
2340
4389
|
push(path.node.left, path.node.right);
|
|
2341
4390
|
path.replaceWith(path.node.left);
|
|
2342
4391
|
this.changes++;
|
|
2343
|
-
} else if (
|
|
4392
|
+
} else if (t42.isTemplateLiteral(path.node.right) && t42.isExpression(path.node.left)) {
|
|
2344
4393
|
unshift(path.node.right, path.node.left);
|
|
2345
4394
|
path.replaceWith(path.node.right);
|
|
2346
4395
|
this.changes++;
|
|
@@ -2350,7 +4399,7 @@ var template_literals_default = {
|
|
|
2350
4399
|
CallExpression: {
|
|
2351
4400
|
exit(path) {
|
|
2352
4401
|
if (concatMatcher.match(path.node) && !concatMatcher.match(path.parentPath.parent)) {
|
|
2353
|
-
const template9 =
|
|
4402
|
+
const template9 = t42.templateLiteral([t42.templateElement({ raw: "" })], []);
|
|
2354
4403
|
let current = path.node;
|
|
2355
4404
|
while (current.type === "CallExpression") {
|
|
2356
4405
|
for (const arg of current.arguments.reverse()) {
|
|
@@ -2367,7 +4416,7 @@ var template_literals_default = {
|
|
|
2367
4416
|
};
|
|
2368
4417
|
}
|
|
2369
4418
|
};
|
|
2370
|
-
// node_modules/webcrack/src/transpile/index.ts
|
|
4419
|
+
// /home/mochaa/ghq/git.sr.ht/~self/delance-builder/node_modules/webcrack/src/transpile/index.ts
|
|
2371
4420
|
var transpile_default = mergeTransforms({
|
|
2372
4421
|
name: "transpile",
|
|
2373
4422
|
tags: ["safe"],
|
|
@@ -2375,9 +4424,8 @@ var transpile_default = mergeTransforms({
|
|
|
2375
4424
|
});
|
|
2376
4425
|
|
|
2377
4426
|
// transform/delance/stringaes.ts
|
|
2378
|
-
import
|
|
2379
|
-
import * as
|
|
2380
|
-
import * as t33 from "@babel/types";
|
|
4427
|
+
import traverse14 from "@babel/traverse";
|
|
4428
|
+
import * as t43 from "@babel/types";
|
|
2381
4429
|
|
|
2382
4430
|
// utils/crypto.ts
|
|
2383
4431
|
import crypto from "node:crypto";
|
|
@@ -2390,9 +4438,9 @@ function lic(x = _lic) {
|
|
|
2390
4438
|
_lic = x;
|
|
2391
4439
|
return _lic;
|
|
2392
4440
|
}
|
|
2393
|
-
function decrypt(
|
|
4441
|
+
function decrypt(m) {
|
|
2394
4442
|
const c = crypto.createDecipheriv("aes-192-cbc", scrypt(), iv());
|
|
2395
|
-
let a = c.update(
|
|
4443
|
+
let a = c.update(m, "hex", "utf8");
|
|
2396
4444
|
a += c.final("utf8");
|
|
2397
4445
|
return a;
|
|
2398
4446
|
}
|
|
@@ -2415,19 +4463,19 @@ var scrypt = () => crypto.scryptSync(lic(), salt(), 24);
|
|
|
2415
4463
|
var iv = () => Buffer.from(salt());
|
|
2416
4464
|
|
|
2417
4465
|
// transform/delance/stringaes.ts
|
|
2418
|
-
var scrypt2 =
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
4466
|
+
var scrypt2 = callExpression(memberExpression(identifier(), identifier("scryptSync"), false), [
|
|
4467
|
+
memberExpression(identifier(), identifier("licenseErrorText"), false),
|
|
4468
|
+
identifier(),
|
|
4469
|
+
numericLiteral(24)
|
|
2422
4470
|
]);
|
|
2423
|
-
var licenseText =
|
|
4471
|
+
var licenseText = assignmentExpression("=", memberExpression(identifier(), identifier("licenseErrorText")), callExpression(memberExpression(arrayExpression(anyList(oneOrMore(stringLiteral()))), identifier("join"), false), [stringLiteral(" ")]));
|
|
2424
4472
|
var newSalt;
|
|
2425
4473
|
var newKey;
|
|
2426
4474
|
var stringaes_default = {
|
|
2427
4475
|
name: "string-aes",
|
|
2428
4476
|
tags: ["safe"],
|
|
2429
4477
|
run(ast2) {
|
|
2430
|
-
|
|
4478
|
+
traverse14(ast2, {
|
|
2431
4479
|
CallExpression: {
|
|
2432
4480
|
exit($) {
|
|
2433
4481
|
if (newSalt || !scrypt2.match($.node)) {
|
|
@@ -2467,7 +4515,7 @@ var stringaes_default = {
|
|
|
2467
4515
|
}
|
|
2468
4516
|
},
|
|
2469
4517
|
visitor() {
|
|
2470
|
-
const encryptedString =
|
|
4518
|
+
const encryptedString = callExpression(memberExpression(identifier(), identifier("decrypt"), false), [stringLiteral()]);
|
|
2471
4519
|
return {
|
|
2472
4520
|
CallExpression: {
|
|
2473
4521
|
exit($) {
|
|
@@ -2480,7 +4528,7 @@ var stringaes_default = {
|
|
|
2480
4528
|
$id.assertIdentifier();
|
|
2481
4529
|
const $string = $.get("arguments")[0];
|
|
2482
4530
|
$string.assertStringLiteral();
|
|
2483
|
-
$.replaceWith(
|
|
4531
|
+
$.replaceWith(t43.stringLiteral(decrypt($string.node.value)));
|
|
2484
4532
|
this.changes++;
|
|
2485
4533
|
}
|
|
2486
4534
|
}
|
|
@@ -2489,13 +4537,12 @@ var stringaes_default = {
|
|
|
2489
4537
|
};
|
|
2490
4538
|
|
|
2491
4539
|
// transform/delance/antifeature.ts
|
|
2492
|
-
import * as
|
|
2493
|
-
import * as m42 from "@codemod/matchers";
|
|
4540
|
+
import * as t44 from "@babel/types";
|
|
2494
4541
|
import tmpl6 from "@babel/template";
|
|
2495
|
-
var entry =
|
|
2496
|
-
var main =
|
|
2497
|
-
var verifyClient =
|
|
2498
|
-
var vsda =
|
|
4542
|
+
var entry = capture(numericLiteral());
|
|
4543
|
+
var main = callExpression(memberExpression(callExpression(identifier("require"), [entry]), identifier("main"), false), [booleanLiteral(true)]);
|
|
4544
|
+
var verifyClient = assignmentExpression("=", memberExpression(identifier("exports"), identifier("verifyClient")), functionExpression(null, [identifier()]));
|
|
4545
|
+
var vsda = ifStatement(containerOf(stringLiteral("vsda")));
|
|
2499
4546
|
var antifeature_default = {
|
|
2500
4547
|
name: "anti-feature",
|
|
2501
4548
|
tags: ["unsafe"],
|
|
@@ -2505,7 +4552,7 @@ var antifeature_default = {
|
|
|
2505
4552
|
if (!main.match($.node)) {
|
|
2506
4553
|
return;
|
|
2507
4554
|
}
|
|
2508
|
-
|
|
4555
|
+
t44.assertNumericLiteral(entry.current);
|
|
2509
4556
|
const _target = $.find((p2) => chunk_default.match(p2.node));
|
|
2510
4557
|
if (!_target) {
|
|
2511
4558
|
throw new Error("Could not find module chunk");
|
|
@@ -2565,7 +4612,7 @@ async function transform6(ast2) {
|
|
|
2565
4612
|
|
|
2566
4613
|
// index.ts
|
|
2567
4614
|
async function delance_builder_default(code) {
|
|
2568
|
-
return generate2(await transform6(
|
|
4615
|
+
return generate2(await transform6(parse2(code)));
|
|
2569
4616
|
}
|
|
2570
4617
|
export {
|
|
2571
4618
|
transform6 as transform,
|
|
@@ -2574,4 +4621,4 @@ export {
|
|
|
2574
4621
|
|
|
2575
4622
|
export { delance_builder_default };
|
|
2576
4623
|
|
|
2577
|
-
//# debugId=
|
|
4624
|
+
//# debugId=B200542A89D7F19764756e2164756e21
|