@delance/builder 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![npm](https://img.shields.io/npm/v/%40delance%2Fbuilder.svg)][npm]
2
2
  [![license](https://img.shields.io/npm/l/%40delance%2Fbuilder.svg)][license]
3
3
  [![builds.sr.ht status](https://builds.sr.ht/~self/delance-builder.svg)][builds]
4
- ![maintenance](https://img.shields.io/maintenance/yes/2024.svg)
4
+ ![maintenance](https://img.shields.io/maintenance/yes/2025.svg)
5
5
 
6
6
  @delance/builder
7
7
  ================
package/dist/index.js CHANGED
@@ -1,5 +1,21 @@
1
1
  import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
3
19
  var __export = (target, all) => {
4
20
  for (var name in all)
5
21
  __defProp(target, name, {
@@ -11,10 +27,22 @@ var __export = (target, all) => {
11
27
  };
12
28
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
13
29
 
30
+ // babel-import:@babel/generator
31
+ var require_generator = __commonJS((exports, module) => {
32
+ var m = __require("@babel/generator/lib/index.js");
33
+ module.exports = m.default ?? m;
34
+ });
35
+
36
+ // babel-import:@babel/traverse
37
+ var require_traverse = __commonJS((exports, module) => {
38
+ var m = __require("@babel/traverse/lib/index.js");
39
+ module.exports = m.default ?? m;
40
+ });
41
+
14
42
  // utils/ast.ts
15
- import babelGenerate from "@babel/generator";
43
+ var import_generator = __toESM(require_generator(), 1);
44
+ var import_traverse = __toESM(require_traverse(), 1);
16
45
  import { parse as babelParse } from "@babel/parser";
17
- import traverse, { visitors } from "@babel/traverse";
18
46
  import debug from "debug";
19
47
  var logger = debug("delance:transforms");
20
48
  function parse(code) {
@@ -24,7 +52,7 @@ function parse(code) {
24
52
  });
25
53
  }
26
54
  function generate(ast) {
27
- return babelGenerate(ast, { jsescOption: { minimal: true, quotes: "single" } }).code;
55
+ return import_generator.default(ast, { jsescOption: { minimal: true, quotes: "single" } }).code;
28
56
  }
29
57
  function applyTransform(ast, transform, options, noScopeOverride) {
30
58
  logger(`${transform.name}: started`);
@@ -33,7 +61,7 @@ function applyTransform(ast, transform, options, noScopeOverride) {
33
61
  if (transform.visitor) {
34
62
  const visitor = transform.visitor(options);
35
63
  visitor.noScope = noScopeOverride ?? !transform.scope;
36
- traverse(ast, visitor, undefined, state);
64
+ import_traverse.default(ast, visitor, undefined, state);
37
65
  }
38
66
  logger(`${transform.name}: finished with ${state.changes} changes`);
39
67
  return state;
@@ -53,10 +81,10 @@ function getPropName(node) {
53
81
  }
54
82
  }
55
83
  // webcrack/ast-utils/generator.js
56
- import babelGenerate2 from "@babel/generator";
84
+ var import_generator2 = __toESM(require_generator(), 1);
57
85
  var defaultOptions = { jsescOption: { minimal: true } };
58
86
  function generate2(ast, options = defaultOptions) {
59
- return babelGenerate2(ast, options).code;
87
+ return import_generator2.default(ast, options).code;
60
88
  }
61
89
  function codePreview(node) {
62
90
  const code = generate2(node, {
@@ -70,13 +98,13 @@ function codePreview(node) {
70
98
  return code;
71
99
  }
72
100
  // webcrack/ast-utils/inline.js
73
- import traverse3 from "@babel/traverse";
101
+ var import_traverse3 = __toESM(require_traverse(), 1);
74
102
  import * as t14 from "@babel/types";
75
103
 
76
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anyExpression.js
104
+ // node_modules/@codemod/matchers/dist/matchers/anyExpression.js
77
105
  import * as t2 from "@babel/types";
78
106
 
79
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/Matcher.js
107
+ // node_modules/@codemod/matchers/dist/matchers/Matcher.js
80
108
  class Matcher {
81
109
  match(value, keys = []) {
82
110
  return this.matchValue(value, keys);
@@ -86,7 +114,7 @@ class Matcher {
86
114
  }
87
115
  }
88
116
 
89
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anyExpression.js
117
+ // node_modules/@codemod/matchers/dist/matchers/anyExpression.js
90
118
  class AnyExpressionMatcher extends Matcher {
91
119
  matchValue(value) {
92
120
  return t2.isNode(value) && t2.isExpression(value);
@@ -95,7 +123,7 @@ class AnyExpressionMatcher extends Matcher {
95
123
  function anyExpression() {
96
124
  return new AnyExpressionMatcher;
97
125
  }
98
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/utils/distributeAcrossSlices.js
126
+ // node_modules/@codemod/matchers/dist/utils/distributeAcrossSlices.js
99
127
  function* distributeAcrossSlices(slices, available) {
100
128
  if (slices.length === 0) {
101
129
  yield [];
@@ -115,7 +143,7 @@ function* distributeAcrossSlices(slices, available) {
115
143
  }
116
144
  }
117
145
 
118
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anything.js
146
+ // node_modules/@codemod/matchers/dist/matchers/anything.js
119
147
  class AnythingMatcher extends Matcher {
120
148
  matchValue(value) {
121
149
  return true;
@@ -125,7 +153,7 @@ function anything() {
125
153
  return new AnythingMatcher;
126
154
  }
127
155
 
128
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/slice.js
156
+ // node_modules/@codemod/matchers/dist/matchers/slice.js
129
157
  class SliceMatcher extends Matcher {
130
158
  min;
131
159
  max;
@@ -164,7 +192,7 @@ function slice(optionsOrLength, matcherOrUndefined) {
164
192
  return new SliceMatcher(min, max, matcher);
165
193
  }
166
194
 
167
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anyList.js
195
+ // node_modules/@codemod/matchers/dist/matchers/anyList.js
168
196
  class AnyListMatcher extends Matcher {
169
197
  matchers;
170
198
  sliceMatchers = [];
@@ -221,11 +249,11 @@ class AnyListMatcher extends Matcher {
221
249
  function anyList(...elements) {
222
250
  return new AnyListMatcher(elements);
223
251
  }
224
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anyNode.js
252
+ // node_modules/@codemod/matchers/dist/matchers/anyNode.js
225
253
  import * as t3 from "@babel/types";
226
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anyStatement.js
254
+ // node_modules/@codemod/matchers/dist/matchers/anyStatement.js
227
255
  import * as t4 from "@babel/types";
228
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/anyString.js
256
+ // node_modules/@codemod/matchers/dist/matchers/anyString.js
229
257
  class StringMatcher extends Matcher {
230
258
  matchValue(value) {
231
259
  return typeof value === "string" || value instanceof String;
@@ -234,7 +262,7 @@ class StringMatcher extends Matcher {
234
262
  function anyString() {
235
263
  return new StringMatcher;
236
264
  }
237
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/arrayOf.js
265
+ // node_modules/@codemod/matchers/dist/matchers/arrayOf.js
238
266
  class ArrayOfMatcher extends Matcher {
239
267
  elementMatcher;
240
268
  constructor(elementMatcher) {
@@ -256,7 +284,7 @@ class ArrayOfMatcher extends Matcher {
256
284
  function arrayOf(elementMatcher) {
257
285
  return new ArrayOfMatcher(elementMatcher);
258
286
  }
259
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/capture.js
287
+ // node_modules/@codemod/matchers/dist/matchers/capture.js
260
288
  class CapturedMatcher extends Matcher {
261
289
  matcher;
262
290
  _current;
@@ -287,7 +315,7 @@ class CapturedMatcher extends Matcher {
287
315
  function capture(matcher) {
288
316
  return new CapturedMatcher(matcher);
289
317
  }
290
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/containerOf.js
318
+ // node_modules/@codemod/matchers/dist/matchers/containerOf.js
291
319
  import * as t5 from "@babel/types";
292
320
  class ContainerOfMatcher extends CapturedMatcher {
293
321
  containedMatcher;
@@ -321,18 +349,18 @@ class ContainerOfMatcher extends CapturedMatcher {
321
349
  function containerOf(containedMatcher) {
322
350
  return new ContainerOfMatcher(containedMatcher);
323
351
  }
324
- // node_modules/.pnpm/@codemod-esm+utils@1.1.1/node_modules/@codemod-esm/utils/dist/index.js
352
+ // node_modules/@codemod-esm/utils/dist/index.js
325
353
  import * as Babel from "@babel/core";
326
354
  import * as t10 from "@babel/types";
327
355
 
328
- // node_modules/.pnpm/@codemod-esm+utils@1.1.1/node_modules/@codemod-esm/utils/dist/builders.js
329
- import traverse2 from "@babel/traverse";
356
+ // node_modules/@codemod-esm/utils/dist/builders.js
357
+ var import_traverse2 = __toESM(require_traverse(), 1);
330
358
  import * as t6 from "@babel/types";
331
359
 
332
- // node_modules/.pnpm/@codemod-esm+parser@1.4.2/node_modules/@codemod-esm/parser/dist/index.js
360
+ // node_modules/@codemod-esm/parser/dist/index.js
333
361
  import { parse as babelParse2 } from "@babel/parser";
334
362
 
335
- // node_modules/.pnpm/@codemod-esm+parser@1.4.2/node_modules/@codemod-esm/parser/dist/options.js
363
+ // node_modules/@codemod-esm/parser/dist/options.js
336
364
  var DefaultParserPlugins = new Set([
337
365
  "asyncGenerators",
338
366
  "bigInt",
@@ -362,13 +390,13 @@ var DefaultParserPlugins = new Set([
362
390
  ["pipelineOperator", { proposal: "minimal" }],
363
391
  ["recordAndTuple", { syntaxType: "hash" }]
364
392
  ]);
365
- // node_modules/.pnpm/@codemod-esm+utils@1.1.1/node_modules/@codemod-esm/utils/dist/js.js
393
+ // node_modules/@codemod-esm/utils/dist/js.js
366
394
  import * as t8 from "@babel/types";
367
395
 
368
- // node_modules/.pnpm/@codemod-esm+utils@1.1.1/node_modules/@codemod-esm/utils/dist/NodeTypes.js
396
+ // node_modules/@codemod-esm/utils/dist/NodeTypes.js
369
397
  import * as t7 from "@babel/types";
370
398
  var { BUILDER_KEYS, NODE_FIELDS } = t7;
371
- // node_modules/.pnpm/@codemod-esm+utils@1.1.1/node_modules/@codemod-esm/utils/dist/nodesEquivalent.js
399
+ // node_modules/@codemod-esm/utils/dist/nodesEquivalent.js
372
400
  import * as t9 from "@babel/types";
373
401
  function nodesEquivalent(a, b) {
374
402
  if (a === b) {
@@ -414,7 +442,7 @@ function nodesEquivalent(a, b) {
414
442
  }
415
443
  return true;
416
444
  }
417
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/fromCapture.js
445
+ // node_modules/@codemod/matchers/dist/matchers/fromCapture.js
418
446
  class FromCaptureMatcher extends Matcher {
419
447
  capturedMatcher;
420
448
  constructor(capturedMatcher) {
@@ -431,10 +459,10 @@ class FromCaptureMatcher extends Matcher {
431
459
  function fromCapture(capturedMatcher) {
432
460
  return new FromCaptureMatcher(capturedMatcher);
433
461
  }
434
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/function.js
462
+ // node_modules/@codemod/matchers/dist/matchers/function.js
435
463
  import * as t11 from "@babel/types";
436
464
 
437
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/tupleOf.js
465
+ // node_modules/@codemod/matchers/dist/matchers/tupleOf.js
438
466
  class TupleOfMatcher extends Matcher {
439
467
  matchers;
440
468
  constructor(...matchers) {
@@ -461,7 +489,39 @@ class TupleOfMatcher extends Matcher {
461
489
  function tupleOf(...matchers) {
462
490
  return new TupleOfMatcher(...matchers);
463
491
  }
464
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/generated.js
492
+
493
+ // node_modules/@codemod/matchers/dist/matchers/function.js
494
+ class FunctionMatcher extends Matcher {
495
+ params;
496
+ body;
497
+ constructor(params, body) {
498
+ super();
499
+ this.params = params;
500
+ this.body = body;
501
+ }
502
+ matchValue(value, keys) {
503
+ if (!t11.isNode(value) || !t11.isFunction(value)) {
504
+ return false;
505
+ }
506
+ if (this.params) {
507
+ if (Array.isArray(this.params)) {
508
+ if (!tupleOf(...this.params).matchValue(value.params, [...keys, "params"])) {
509
+ return false;
510
+ }
511
+ } else if (!this.params.matchValue(value.params, [...keys, "params"])) {
512
+ return false;
513
+ }
514
+ }
515
+ if (this.body && !this.body.matchValue(value.body, [...keys, "body"])) {
516
+ return false;
517
+ }
518
+ return true;
519
+ }
520
+ }
521
+ function Function(params, body) {
522
+ return new FunctionMatcher(params, body);
523
+ }
524
+ // node_modules/@codemod/matchers/dist/matchers/generated.js
465
525
  import * as t12 from "@babel/types";
466
526
  class ArrayExpressionMatcher extends Matcher {
467
527
  elements;
@@ -754,6 +814,30 @@ class CallExpressionMatcher extends Matcher {
754
814
  function callExpression(callee, _arguments) {
755
815
  return new CallExpressionMatcher(callee, _arguments);
756
816
  }
817
+ class ClassBodyMatcher extends Matcher {
818
+ body;
819
+ constructor(body) {
820
+ super();
821
+ this.body = body;
822
+ }
823
+ matchValue(node, keys) {
824
+ if (!t12.isNode(node) || !t12.isClassBody(node)) {
825
+ return false;
826
+ }
827
+ if (typeof this.body === "undefined") {
828
+ } else if (Array.isArray(this.body)) {
829
+ if (!tupleOf(...this.body).matchValue(node.body, [...keys, "body"])) {
830
+ return false;
831
+ }
832
+ } else if (!this.body.matchValue(node.body, [...keys, "body"])) {
833
+ return false;
834
+ }
835
+ return true;
836
+ }
837
+ }
838
+ function classBody(body) {
839
+ return new ClassBodyMatcher(body);
840
+ }
757
841
  class ClassMethodMatcher extends Matcher {
758
842
  kind;
759
843
  key;
@@ -981,6 +1065,32 @@ class ContinueStatementMatcher extends Matcher {
981
1065
  function continueStatement(label) {
982
1066
  return new ContinueStatementMatcher(label);
983
1067
  }
1068
+ class DoWhileStatementMatcher extends Matcher {
1069
+ test;
1070
+ body;
1071
+ constructor(test, body) {
1072
+ super();
1073
+ this.test = test;
1074
+ this.body = body;
1075
+ }
1076
+ matchValue(node, keys) {
1077
+ if (!t12.isNode(node) || !t12.isDoWhileStatement(node)) {
1078
+ return false;
1079
+ }
1080
+ if (typeof this.test === "undefined") {
1081
+ } else if (!this.test.matchValue(node.test, [...keys, "test"])) {
1082
+ return false;
1083
+ }
1084
+ if (typeof this.body === "undefined") {
1085
+ } else if (!this.body.matchValue(node.body, [...keys, "body"])) {
1086
+ return false;
1087
+ }
1088
+ return true;
1089
+ }
1090
+ }
1091
+ function doWhileStatement(test, body) {
1092
+ return new DoWhileStatementMatcher(test, body);
1093
+ }
984
1094
  class ExpressionStatementMatcher extends Matcher {
985
1095
  expression;
986
1096
  constructor(expression) {
@@ -1033,6 +1143,50 @@ class ForInStatementMatcher extends Matcher {
1033
1143
  function forInStatement(left, right, body) {
1034
1144
  return new ForInStatementMatcher(left, right, body);
1035
1145
  }
1146
+
1147
+ class ForOfStatementMatcher extends Matcher {
1148
+ left;
1149
+ right;
1150
+ body;
1151
+ _await;
1152
+ constructor(left, right, body, _await) {
1153
+ super();
1154
+ this.left = left;
1155
+ this.right = right;
1156
+ this.body = body;
1157
+ this._await = _await;
1158
+ }
1159
+ matchValue(node, keys) {
1160
+ if (!t12.isNode(node) || !t12.isForOfStatement(node)) {
1161
+ return false;
1162
+ }
1163
+ if (typeof this.left === "undefined") {
1164
+ } else if (!this.left.matchValue(node.left, [...keys, "left"])) {
1165
+ return false;
1166
+ }
1167
+ if (typeof this.right === "undefined") {
1168
+ } else if (!this.right.matchValue(node.right, [...keys, "right"])) {
1169
+ return false;
1170
+ }
1171
+ if (typeof this.body === "undefined") {
1172
+ } else if (!this.body.matchValue(node.body, [...keys, "body"])) {
1173
+ return false;
1174
+ }
1175
+ if (typeof this._await === "undefined") {
1176
+ } else if (typeof this._await === "boolean") {
1177
+ if (this._await !== node.await) {
1178
+ return false;
1179
+ }
1180
+ } else if (!this._await.matchValue(node.await, [...keys, "await"])) {
1181
+ return false;
1182
+ }
1183
+ return true;
1184
+ }
1185
+ }
1186
+ function forOfStatement(left, right, body, _await) {
1187
+ return new ForOfStatementMatcher(left, right, body, _await);
1188
+ }
1189
+
1036
1190
  class ForStatementMatcher extends Matcher {
1037
1191
  init;
1038
1192
  test;
@@ -2107,7 +2261,7 @@ class WhileStatementMatcher extends Matcher {
2107
2261
  function whileStatement(test, body) {
2108
2262
  return new WhileStatementMatcher(test, body);
2109
2263
  }
2110
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/or.js
2264
+ // node_modules/@codemod/matchers/dist/matchers/or.js
2111
2265
  class OrMatcher extends Matcher {
2112
2266
  matchersOrValues;
2113
2267
  constructor(...matchersOrValues) {
@@ -2130,7 +2284,7 @@ class OrMatcher extends Matcher {
2130
2284
  function or(...matchersOrValues) {
2131
2285
  return new OrMatcher(...matchersOrValues);
2132
2286
  }
2133
- // node_modules/.pnpm/@codemod-esm+matchers@1.7.1/node_modules/@codemod-esm/matchers/dist/matchers/predicate.js
2287
+ // node_modules/@codemod/matchers/dist/matchers/predicate.js
2134
2288
  class PredicateMatcher extends Matcher {
2135
2289
  predicate;
2136
2290
  constructor(predicate) {
@@ -2266,7 +2420,7 @@ function inlineFunction(fn, caller) {
2266
2420
  }
2267
2421
  const returnedValue = fn.body.body[0].argument;
2268
2422
  const clone = t14.cloneNode(returnedValue, true);
2269
- traverse3(clone, {
2423
+ import_traverse3.default(clone, {
2270
2424
  Identifier(path) {
2271
2425
  const paramIndex = fn.params.findIndex((p) => p.name === path.node.name);
2272
2426
  if (paramIndex !== -1) {
@@ -2343,7 +2497,7 @@ function inlineVariableAliases(binding, targetName = binding.identifier.name) {
2343
2497
  return state;
2344
2498
  }
2345
2499
  // webcrack/ast-utils/rename.js
2346
- import traverse4 from "@babel/traverse";
2500
+ var import_traverse4 = __toESM(require_traverse(), 1);
2347
2501
  import * as t15 from "@babel/types";
2348
2502
  function renameFast(binding, newName) {
2349
2503
  binding.referencePaths.forEach((ref) => {
@@ -2376,7 +2530,7 @@ function renameFast(binding, newName) {
2376
2530
  }
2377
2531
  }
2378
2532
  } else if (ref.isFor() || patternMatcher.match(ref.node)) {
2379
- traverse4(ref.node, {
2533
+ import_traverse4.default(ref.node, {
2380
2534
  Identifier(path) {
2381
2535
  if (path.scope !== ref.scope)
2382
2536
  return path.skip();
@@ -2397,7 +2551,7 @@ function renameFast(binding, newName) {
2397
2551
  binding.identifier.name = newName;
2398
2552
  }
2399
2553
  // webcrack/ast-utils/transform.js
2400
- import traverse5, { visitors as visitors2 } from "@babel/traverse";
2554
+ var import_traverse5 = __toESM(require_traverse(), 1);
2401
2555
  import debug2 from "debug";
2402
2556
  var logger2 = debug2("webcrack:transforms");
2403
2557
  async function applyTransformAsync(ast, transform, options) {
@@ -2405,7 +2559,7 @@ async function applyTransformAsync(ast, transform, options) {
2405
2559
  const state = { changes: 0 };
2406
2560
  await transform.run?.(ast, state, options);
2407
2561
  if (transform.visitor)
2408
- traverse5(ast, transform.visitor(options), undefined, state);
2562
+ import_traverse5.default(ast, transform.visitor(options), undefined, state);
2409
2563
  logger2(`${transform.name}: finished with ${state.changes} changes`);
2410
2564
  return state;
2411
2565
  }
@@ -2416,7 +2570,7 @@ function applyTransform2(ast, transform, options) {
2416
2570
  if (transform.visitor) {
2417
2571
  const visitor = transform.visitor(options);
2418
2572
  visitor.noScope = !transform.scope;
2419
- traverse5(ast, visitor, undefined, state);
2573
+ import_traverse5.default(ast, visitor, undefined, state);
2420
2574
  }
2421
2575
  logger2(`${transform.name}: finished with ${state.changes} changes`);
2422
2576
  return state;
@@ -2432,9 +2586,9 @@ function applyTransforms(ast, transforms, options = {}) {
2432
2586
  }
2433
2587
  const traverseOptions = transforms.flatMap((t16) => t16.visitor?.() ?? []);
2434
2588
  if (traverseOptions.length > 0) {
2435
- const visitor = visitors2.merge(traverseOptions);
2589
+ const visitor = import_traverse5.visitors.merge(traverseOptions);
2436
2590
  visitor.noScope = options.noScope || transforms.every((t16) => !t16.scope);
2437
- traverse5(ast, visitor, undefined, state);
2591
+ import_traverse5.default(ast, visitor, undefined, state);
2438
2592
  }
2439
2593
  if (options.log)
2440
2594
  logger2(`${name}: finished with ${state.changes} changes`);
@@ -2446,7 +2600,7 @@ function mergeTransforms(options) {
2446
2600
  tags: options.tags,
2447
2601
  scope: options.transforms.some((t16) => t16.scope),
2448
2602
  visitor() {
2449
- return visitors2.merge(options.transforms.flatMap((t16) => t16.visitor?.() ?? []));
2603
+ return import_traverse5.visitors.merge(options.transforms.flatMap((t16) => t16.visitor?.() ?? []));
2450
2604
  }
2451
2605
  };
2452
2606
  }
@@ -2875,7 +3029,7 @@ var antifeature_default = {
2875
3029
  };
2876
3030
 
2877
3031
  // transform/delance/stringaes.ts
2878
- import traverse6 from "@babel/traverse";
3032
+ var import_traverse6 = __toESM(require_traverse(), 1);
2879
3033
  import * as t23 from "@babel/types";
2880
3034
 
2881
3035
  // utils/crypto.ts
@@ -2926,7 +3080,7 @@ var stringaes_default = {
2926
3080
  name: "string-aes",
2927
3081
  tags: ["safe"],
2928
3082
  run(ast2) {
2929
- traverse6(ast2, {
3083
+ import_traverse6.default(ast2, {
2930
3084
  CallExpression: {
2931
3085
  exit($) {
2932
3086
  if (newSalt || !scrypt2.match($.node)) {
@@ -3824,7 +3978,7 @@ var inline_object_props_default = {
3824
3978
  };
3825
3979
 
3826
3980
  // webcrack/deobfuscate/string-array.js
3827
- import traverse7 from "@babel/traverse";
3981
+ var import_traverse7 = __toESM(require_traverse(), 1);
3828
3982
  function findStringArray(ast2) {
3829
3983
  let result2;
3830
3984
  const functionName = capture(anyString());
@@ -3842,7 +3996,7 @@ function findStringArray(ast2) {
3842
3996
  expressionStatement(functionAssignment),
3843
3997
  returnStatement(callExpression(identifier(functionName)))
3844
3998
  ])));
3845
- traverse7(ast2, {
3999
+ import_traverse7.default(ast2, {
3846
4000
  FunctionDeclaration(path) {
3847
4001
  if (matcher2.match(path.node)) {
3848
4002
  const length = arrayExpression2.current.elements.length;
@@ -3981,7 +4135,7 @@ var merge_object_assignments_default = {
3981
4135
  sibling.remove();
3982
4136
  binding.dereference();
3983
4137
  binding.referencePaths.shift();
3984
- if (binding.references === 1 && inlineableObject.match(object.current)) {
4138
+ if (binding.references === 1 && inlineableObject.match(object.current) && !isRepeatedCallReference(binding, binding.referencePaths[0])) {
3985
4139
  binding.referencePaths[0].replaceWith(object.current);
3986
4140
  path.remove();
3987
4141
  this.changes++;
@@ -3995,6 +4149,12 @@ var merge_object_assignments_default = {
3995
4149
  function hasCircularReference(node, binding) {
3996
4150
  return binding.referencePaths.some((path) => path.find((p2) => p2.node === node)) || containerOf(callExpression()).match(node);
3997
4151
  }
4152
+ var repeatedCallMatcher = or(forStatement(), forOfStatement(), forInStatement(), whileStatement(), doWhileStatement(), Function(), objectMethod(), classBody());
4153
+ function isRepeatedCallReference(binding, reference) {
4154
+ const block = binding.scope.getBlockParent().path;
4155
+ const repeatable = findParent(reference, repeatedCallMatcher);
4156
+ return repeatable?.isDescendant(block);
4157
+ }
3998
4158
  var inlineableObject = predicate((node) => or(safeLiteral, arrayExpression(arrayOf(inlineableObject)), objectExpression(arrayOf(constObjectProperty(inlineableObject)))).match(node));
3999
4159
 
4000
4160
  // webcrack/deobfuscate/self-defending.js
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@delance/builder",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.3",
5
5
  "description": "A spear to the Python language server built with black magic",
6
6
  "author": "mochaaP <npm@mochaa.ws>",
7
7
  "license": "0BSD",
@@ -20,45 +20,47 @@
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
23
- "peerDependencies": {
24
- "debug": "^4"
23
+ "scripts": {
24
+ "build": "bun build.ts",
25
+ "build:minify": "bun run build --minify --entry-naming [dir]/[name].min.[ext]",
26
+ "build:webcrack": "tsc -p ./tsconfig.webcrack.json || :",
27
+ "check": "tsc; bun run lint",
28
+ "lint": "eslint .",
29
+ "lint:fix": "eslint . --fix",
30
+ "prebuild": "bun run build:webcrack",
31
+ "prepare": "bun run build",
32
+ "prepublishOnly": "rm -rf dist",
33
+ "start": "bun cli.ts"
25
34
  },
26
- "dependencies": {
35
+ "peerDependencies": {
27
36
  "@babel/code-frame": "^7.26.2",
28
- "@babel/core": "^7.26.0",
29
- "@babel/generator": "^7.26.3",
30
37
  "@babel/helper-validator-identifier": "^7.25.9",
31
- "@babel/parser": "^7.26.3",
38
+ "debug": "^4.4.0"
39
+ },
40
+ "dependencies": {
41
+ "@babel/core": "^7.26.7",
42
+ "@babel/generator": "^7.26.5",
43
+ "@babel/parser": "^7.26.7",
32
44
  "@babel/template": "^7.25.9",
33
- "@babel/traverse": "^7.26.4",
34
- "@babel/types": "^7.26.3",
35
- "quickjs-emscripten": "^0.29.2"
45
+ "@babel/traverse": "^7.26.7",
46
+ "@babel/types": "^7.26.7",
47
+ "quickjs-emscripten": "^0.31.0"
36
48
  },
37
49
  "devDependencies": {
38
50
  "@codemod/core": "npm:@codemod-esm/core@^2.2.1",
39
51
  "@codemod/matchers": "npm:@codemod-esm/matchers@^1.7.1",
40
52
  "@codemod/parser": "npm:@codemod-esm/parser@^1.4.2",
41
53
  "@codemod/utils": "npm:@codemod-esm/utils@^1.1.1",
42
- "@mochaa/eslintrc": "^0.1.8",
54
+ "@mochaa/eslintrc": "^0.1.12",
43
55
  "@types/babel__core": "^7.20.5",
44
56
  "@types/babel__generator": "^7.6.8",
45
57
  "@types/babel__helper-validator-identifier": "^7.15.2",
46
58
  "@types/babel__template": "^7.4.4",
47
59
  "@types/babel__traverse": "^7.20.6",
48
- "@types/bun": "^1.1.14",
60
+ "@types/bun": "^1.2.2",
49
61
  "@types/debug": "^4.1.12",
50
- "bun": "^1.1.38",
51
- "eslint": "^9.16.0",
52
- "rimraf": "^6.0.1",
53
- "typescript": "^5.7.2",
62
+ "eslint": "^9.19.0",
63
+ "typescript": "^5.7.3",
54
64
  "webcrack": "github:j4k0xb/webcrack"
55
- },
56
- "scripts": {
57
- "build": "bun build index.ts cli.ts --target=node --splitting -e=isolated-vm -e=quickjs-emscripten -e=@babel -e=debug --outdir=dist",
58
- "build:minify": "pnpm run build --minify --entry-naming [dir]/[name].min.[ext]",
59
- "build:webcrack": "tsc -p ./tsconfig.webcrack.json",
60
- "lint": "eslint .",
61
- "lint:fix": "eslint . --fix",
62
- "start": "bun cli.ts"
63
65
  }
64
- }
66
+ }
package/types.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type * as t from '@babel/types';
2
-
3
- export default function (code: string): Promise<string>;
4
- export function transform(ast: t.Node): Promise<t.Node>;