@delance/builder 0.3.3 → 0.3.5

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.
Files changed (3) hide show
  1. package/dist/index.js +66 -37
  2. package/package.json +26 -27
  3. package/types.d.ts +4 -0
package/dist/index.js CHANGED
@@ -101,10 +101,10 @@ function codePreview(node) {
101
101
  var import_traverse3 = __toESM(require_traverse(), 1);
102
102
  import * as t14 from "@babel/types";
103
103
 
104
- // node_modules/@codemod/matchers/dist/matchers/anyExpression.js
104
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anyExpression.js
105
105
  import * as t2 from "@babel/types";
106
106
 
107
- // node_modules/@codemod/matchers/dist/matchers/Matcher.js
107
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/Matcher.js
108
108
  class Matcher {
109
109
  match(value, keys = []) {
110
110
  return this.matchValue(value, keys);
@@ -114,7 +114,7 @@ class Matcher {
114
114
  }
115
115
  }
116
116
 
117
- // node_modules/@codemod/matchers/dist/matchers/anyExpression.js
117
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anyExpression.js
118
118
  class AnyExpressionMatcher extends Matcher {
119
119
  matchValue(value) {
120
120
  return t2.isNode(value) && t2.isExpression(value);
@@ -123,7 +123,7 @@ class AnyExpressionMatcher extends Matcher {
123
123
  function anyExpression() {
124
124
  return new AnyExpressionMatcher;
125
125
  }
126
- // node_modules/@codemod/matchers/dist/utils/distributeAcrossSlices.js
126
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/utils/distributeAcrossSlices.js
127
127
  function* distributeAcrossSlices(slices, available) {
128
128
  if (slices.length === 0) {
129
129
  yield [];
@@ -143,7 +143,7 @@ function* distributeAcrossSlices(slices, available) {
143
143
  }
144
144
  }
145
145
 
146
- // node_modules/@codemod/matchers/dist/matchers/anything.js
146
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anything.js
147
147
  class AnythingMatcher extends Matcher {
148
148
  matchValue(value) {
149
149
  return true;
@@ -153,7 +153,7 @@ function anything() {
153
153
  return new AnythingMatcher;
154
154
  }
155
155
 
156
- // node_modules/@codemod/matchers/dist/matchers/slice.js
156
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/slice.js
157
157
  class SliceMatcher extends Matcher {
158
158
  min;
159
159
  max;
@@ -192,7 +192,7 @@ function slice(optionsOrLength, matcherOrUndefined) {
192
192
  return new SliceMatcher(min, max, matcher);
193
193
  }
194
194
 
195
- // node_modules/@codemod/matchers/dist/matchers/anyList.js
195
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anyList.js
196
196
  class AnyListMatcher extends Matcher {
197
197
  matchers;
198
198
  sliceMatchers = [];
@@ -249,11 +249,11 @@ class AnyListMatcher extends Matcher {
249
249
  function anyList(...elements) {
250
250
  return new AnyListMatcher(elements);
251
251
  }
252
- // node_modules/@codemod/matchers/dist/matchers/anyNode.js
252
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anyNode.js
253
253
  import * as t3 from "@babel/types";
254
- // node_modules/@codemod/matchers/dist/matchers/anyStatement.js
254
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anyStatement.js
255
255
  import * as t4 from "@babel/types";
256
- // node_modules/@codemod/matchers/dist/matchers/anyString.js
256
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/anyString.js
257
257
  class StringMatcher extends Matcher {
258
258
  matchValue(value) {
259
259
  return typeof value === "string" || value instanceof String;
@@ -262,7 +262,7 @@ class StringMatcher extends Matcher {
262
262
  function anyString() {
263
263
  return new StringMatcher;
264
264
  }
265
- // node_modules/@codemod/matchers/dist/matchers/arrayOf.js
265
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/arrayOf.js
266
266
  class ArrayOfMatcher extends Matcher {
267
267
  elementMatcher;
268
268
  constructor(elementMatcher) {
@@ -284,7 +284,7 @@ class ArrayOfMatcher extends Matcher {
284
284
  function arrayOf(elementMatcher) {
285
285
  return new ArrayOfMatcher(elementMatcher);
286
286
  }
287
- // node_modules/@codemod/matchers/dist/matchers/capture.js
287
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/capture.js
288
288
  class CapturedMatcher extends Matcher {
289
289
  matcher;
290
290
  _current;
@@ -315,7 +315,7 @@ class CapturedMatcher extends Matcher {
315
315
  function capture(matcher) {
316
316
  return new CapturedMatcher(matcher);
317
317
  }
318
- // node_modules/@codemod/matchers/dist/matchers/containerOf.js
318
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/containerOf.js
319
319
  import * as t5 from "@babel/types";
320
320
  class ContainerOfMatcher extends CapturedMatcher {
321
321
  containedMatcher;
@@ -349,18 +349,18 @@ class ContainerOfMatcher extends CapturedMatcher {
349
349
  function containerOf(containedMatcher) {
350
350
  return new ContainerOfMatcher(containedMatcher);
351
351
  }
352
- // node_modules/@codemod-esm/utils/dist/index.js
352
+ // node_modules/.pnpm/@codemod-esm+utils@1.1.2/node_modules/@codemod-esm/utils/dist/index.js
353
353
  import * as Babel from "@babel/core";
354
354
  import * as t10 from "@babel/types";
355
355
 
356
- // node_modules/@codemod-esm/utils/dist/builders.js
356
+ // node_modules/.pnpm/@codemod-esm+utils@1.1.2/node_modules/@codemod-esm/utils/dist/builders.js
357
357
  var import_traverse2 = __toESM(require_traverse(), 1);
358
358
  import * as t6 from "@babel/types";
359
359
 
360
- // node_modules/@codemod-esm/parser/dist/index.js
360
+ // node_modules/.pnpm/@codemod-esm+parser@1.4.3/node_modules/@codemod-esm/parser/dist/index.js
361
361
  import { parse as babelParse2 } from "@babel/parser";
362
362
 
363
- // node_modules/@codemod-esm/parser/dist/options.js
363
+ // node_modules/.pnpm/@codemod-esm+parser@1.4.3/node_modules/@codemod-esm/parser/dist/options.js
364
364
  var DefaultParserPlugins = new Set([
365
365
  "asyncGenerators",
366
366
  "bigInt",
@@ -390,13 +390,13 @@ var DefaultParserPlugins = new Set([
390
390
  ["pipelineOperator", { proposal: "minimal" }],
391
391
  ["recordAndTuple", { syntaxType: "hash" }]
392
392
  ]);
393
- // node_modules/@codemod-esm/utils/dist/js.js
393
+ // node_modules/.pnpm/@codemod-esm+utils@1.1.2/node_modules/@codemod-esm/utils/dist/js.js
394
394
  import * as t8 from "@babel/types";
395
395
 
396
- // node_modules/@codemod-esm/utils/dist/NodeTypes.js
396
+ // node_modules/.pnpm/@codemod-esm+utils@1.1.2/node_modules/@codemod-esm/utils/dist/NodeTypes.js
397
397
  import * as t7 from "@babel/types";
398
398
  var { BUILDER_KEYS, NODE_FIELDS } = t7;
399
- // node_modules/@codemod-esm/utils/dist/nodesEquivalent.js
399
+ // node_modules/.pnpm/@codemod-esm+utils@1.1.2/node_modules/@codemod-esm/utils/dist/nodesEquivalent.js
400
400
  import * as t9 from "@babel/types";
401
401
  function nodesEquivalent(a, b) {
402
402
  if (a === b) {
@@ -442,7 +442,7 @@ function nodesEquivalent(a, b) {
442
442
  }
443
443
  return true;
444
444
  }
445
- // node_modules/@codemod/matchers/dist/matchers/fromCapture.js
445
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/fromCapture.js
446
446
  class FromCaptureMatcher extends Matcher {
447
447
  capturedMatcher;
448
448
  constructor(capturedMatcher) {
@@ -459,10 +459,10 @@ class FromCaptureMatcher extends Matcher {
459
459
  function fromCapture(capturedMatcher) {
460
460
  return new FromCaptureMatcher(capturedMatcher);
461
461
  }
462
- // node_modules/@codemod/matchers/dist/matchers/function.js
462
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/function.js
463
463
  import * as t11 from "@babel/types";
464
464
 
465
- // node_modules/@codemod/matchers/dist/matchers/tupleOf.js
465
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/tupleOf.js
466
466
  class TupleOfMatcher extends Matcher {
467
467
  matchers;
468
468
  constructor(...matchers) {
@@ -490,7 +490,7 @@ function tupleOf(...matchers) {
490
490
  return new TupleOfMatcher(...matchers);
491
491
  }
492
492
 
493
- // node_modules/@codemod/matchers/dist/matchers/function.js
493
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/function.js
494
494
  class FunctionMatcher extends Matcher {
495
495
  params;
496
496
  body;
@@ -521,7 +521,7 @@ class FunctionMatcher extends Matcher {
521
521
  function Function(params, body) {
522
522
  return new FunctionMatcher(params, body);
523
523
  }
524
- // node_modules/@codemod/matchers/dist/matchers/generated.js
524
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/generated.js
525
525
  import * as t12 from "@babel/types";
526
526
  class ArrayExpressionMatcher extends Matcher {
527
527
  elements;
@@ -2261,7 +2261,7 @@ class WhileStatementMatcher extends Matcher {
2261
2261
  function whileStatement(test, body) {
2262
2262
  return new WhileStatementMatcher(test, body);
2263
2263
  }
2264
- // node_modules/@codemod/matchers/dist/matchers/or.js
2264
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/or.js
2265
2265
  class OrMatcher extends Matcher {
2266
2266
  matchersOrValues;
2267
2267
  constructor(...matchersOrValues) {
@@ -2284,7 +2284,7 @@ class OrMatcher extends Matcher {
2284
2284
  function or(...matchersOrValues) {
2285
2285
  return new OrMatcher(...matchersOrValues);
2286
2286
  }
2287
- // node_modules/@codemod/matchers/dist/matchers/predicate.js
2287
+ // node_modules/.pnpm/@codemod-esm+matchers@1.7.2/node_modules/@codemod-esm/matchers/dist/matchers/predicate.js
2288
2288
  class PredicateMatcher extends Matcher {
2289
2289
  predicate;
2290
2290
  constructor(predicate) {
@@ -2336,7 +2336,8 @@ function isReadonlyObject(binding, memberAccess) {
2336
2336
  if (!binding.constant && binding.constantViolations[0] !== binding.path)
2337
2337
  return false;
2338
2338
  function isPatternAssignment(member) {
2339
- return member.parentPath?.isArrayPattern() || member.parentPath?.isAssignmentPattern() || member.parentPath?.parentPath?.isObjectPattern() || member.parentPath?.isAssignmentPattern();
2339
+ const { parentPath } = member;
2340
+ return parentPath?.isArrayPattern() || parentPath?.parentPath?.isObjectPattern() && (parentPath.isObjectProperty({ value: member.node }) || parentPath.isRestElement()) || parentPath?.isAssignmentPattern({ left: member.node });
2340
2341
  }
2341
2342
  return binding.referencePaths.every((path) => memberAccess.match(path.parent) && !path.parentPath?.parentPath?.isAssignmentExpression({
2342
2343
  left: path.parent
@@ -2351,6 +2352,34 @@ function isTemporaryVariable(binding, references, kind = "var") {
2351
2352
  return binding !== undefined && binding.references === references && binding.constantViolations.length === 1 && (kind === "var" ? binding.path.isVariableDeclarator() && binding.path.node.init === null : binding.path.listKey === "params" && binding.path.isIdentifier());
2352
2353
  }
2353
2354
 
2355
+ class AnySubListMatcher extends Matcher {
2356
+ matchers;
2357
+ constructor(matchers2) {
2358
+ super();
2359
+ this.matchers = matchers2;
2360
+ }
2361
+ matchValue(array, keys) {
2362
+ if (!Array.isArray(array))
2363
+ return false;
2364
+ if (this.matchers.length === 0 && array.length === 0)
2365
+ return true;
2366
+ let j = 0;
2367
+ for (let i = 0;i < array.length; i++) {
2368
+ const matches = this.matchers[j].matchValue(array[i], [...keys, i]);
2369
+ if (matches) {
2370
+ j++;
2371
+ if (j === this.matchers.length) {
2372
+ return true;
2373
+ }
2374
+ }
2375
+ }
2376
+ return false;
2377
+ }
2378
+ }
2379
+ function anySubList(...elements) {
2380
+ return new AnySubListMatcher(elements);
2381
+ }
2382
+
2354
2383
  // webcrack/ast-utils/inline.js
2355
2384
  function inlineVariable(binding, value = anyExpression(), unsafeAssignments = false) {
2356
2385
  const varDeclarator = binding.path.node;
@@ -2413,7 +2442,7 @@ function inlineObjectProperties(binding, property = objectProperty()) {
2413
2442
  });
2414
2443
  binding.path.remove();
2415
2444
  }
2416
- function inlineFunction(fn, caller) {
2445
+ function inlineFunctionCall(fn, caller) {
2417
2446
  if (t14.isRestElement(fn.params[1])) {
2418
2447
  caller.replaceWith(t14.callExpression(caller.node.arguments[0], caller.node.arguments.slice(1)));
2419
2448
  return;
@@ -2424,7 +2453,7 @@ function inlineFunction(fn, caller) {
2424
2453
  Identifier(path) {
2425
2454
  const paramIndex = fn.params.findIndex((p) => p.name === path.node.name);
2426
2455
  if (paramIndex !== -1) {
2427
- path.replaceWith(caller.node.arguments[paramIndex]);
2456
+ path.replaceWith(caller.node.arguments[paramIndex] ?? t14.unaryExpression("void", t14.numericLiteral(0)));
2428
2457
  path.skip();
2429
2458
  }
2430
2459
  },
@@ -2454,7 +2483,7 @@ function inlineFunctionAliases(binding) {
2454
2483
  refs.push(...fnRefs);
2455
2484
  const callRefs = fnRefs.filter((ref2) => t14.isCallExpression(ref2.parent) && t14.isIdentifier(ref2.parent.callee, { name: fnName.current })).map((ref2) => ref2.parentPath);
2456
2485
  for (const callRef of callRefs) {
2457
- inlineFunction(fn.node, callRef);
2486
+ inlineFunctionCall(fn.node, callRef);
2458
2487
  state.changes++;
2459
2488
  }
2460
2489
  fn.remove();
@@ -3675,7 +3704,7 @@ var control_flow_object_default = {
3675
3704
  if (t27.isStringLiteral(value)) {
3676
3705
  memberPath.replaceWith(value);
3677
3706
  } else {
3678
- inlineFunction(value, memberPath.parentPath);
3707
+ inlineFunctionCall(value, memberPath.parentPath);
3679
3708
  }
3680
3709
  changes++;
3681
3710
  });
@@ -3737,7 +3766,7 @@ var control_flow_object_default = {
3737
3766
  if (t27.isStringLiteral(value)) {
3738
3767
  path.replaceWith(value);
3739
3768
  } else if (path.parentPath.isCallExpression()) {
3740
- inlineFunction(value, path.parentPath);
3769
+ inlineFunctionCall(value, path.parentPath);
3741
3770
  } else {
3742
3771
  path.replaceWith(value);
3743
3772
  }
@@ -3884,9 +3913,9 @@ function findDecoders(stringArray) {
3884
3913
  const decoders = [];
3885
3914
  const functionName = capture(anyString());
3886
3915
  const arrayIdentifier = capture(identifier());
3887
- const matcher2 = functionDeclaration(identifier(functionName), anything(), blockStatement(anyList(variableDeclaration(undefined, [
3916
+ const matcher2 = functionDeclaration(identifier(functionName), anything(), blockStatement(anySubList(variableDeclaration(undefined, [
3888
3917
  variableDeclarator(arrayIdentifier, callExpression(identifier(stringArray.name)))
3889
- ]), zeroOrMore(), containerOf(memberExpression(fromCapture(arrayIdentifier), undefined, true)), zeroOrMore())));
3918
+ ]), containerOf(memberExpression(fromCapture(arrayIdentifier), undefined, true)))));
3890
3919
  for (const ref of stringArray.references) {
3891
3920
  const decoderFn = findParent(ref, matcher2);
3892
3921
  if (decoderFn) {
@@ -4324,7 +4353,7 @@ var computed_properties_default = {
4324
4353
  name: "computed-properties",
4325
4354
  tags: ["safe"],
4326
4355
  visitor() {
4327
- const stringMatcher = capture(stringLiteral(predicate((value) => isIdentifierName(value))));
4356
+ const stringMatcher = capture(stringLiteral(predicate(isIdentifierName)));
4328
4357
  const propertyMatcher = or(memberExpression(anything(), stringMatcher, true), optionalMemberExpression(anything(), stringMatcher, true));
4329
4358
  const keyMatcher = or(objectProperty(stringMatcher), classProperty(stringMatcher), objectMethod(undefined, stringMatcher), classMethod(undefined, stringMatcher));
4330
4359
  return {
@@ -4985,7 +5014,7 @@ async function transform5(ast2) {
4985
5014
  const quickjs = await getQuickJS();
4986
5015
  await applyTransformAsync(ast2, deobfuscate_default, async (code) => quickjs.evalCode(code, {
4987
5016
  shouldInterrupt: shouldInterruptAfterDeadline(Date.now() + 2000),
4988
- memoryLimitBytes: 2 * 1024 * 1024
5017
+ memoryLimitBytes: 4 * 1024 * 1024
4989
5018
  }));
4990
5019
  applyTransform2(ast2, unminify_default);
4991
5020
  applyTransform2(ast2, merge_object_assignments_default);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@delance/builder",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.3.5",
5
5
  "description": "A spear to the Python language server built with black magic",
6
6
  "author": "mochaaP <npm@mochaa.ws>",
7
7
  "license": "0BSD",
@@ -20,47 +20,46 @@
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
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"
34
- },
35
23
  "peerDependencies": {
36
24
  "@babel/code-frame": "^7.26.2",
37
25
  "@babel/helper-validator-identifier": "^7.25.9",
38
26
  "debug": "^4.4.0"
39
27
  },
40
28
  "dependencies": {
41
- "@babel/core": "^7.26.7",
42
- "@babel/generator": "^7.26.5",
43
- "@babel/parser": "^7.26.7",
44
- "@babel/template": "^7.25.9",
45
- "@babel/traverse": "^7.26.7",
46
- "@babel/types": "^7.26.7",
29
+ "@babel/core": "^7.26.9",
30
+ "@babel/generator": "^7.26.9",
31
+ "@babel/parser": "^7.26.9",
32
+ "@babel/template": "^7.26.9",
33
+ "@babel/traverse": "^7.26.9",
34
+ "@babel/types": "^7.26.9",
47
35
  "quickjs-emscripten": "^0.31.0"
48
36
  },
49
37
  "devDependencies": {
50
- "@codemod/core": "npm:@codemod-esm/core@^2.2.1",
51
- "@codemod/matchers": "npm:@codemod-esm/matchers@^1.7.1",
52
- "@codemod/parser": "npm:@codemod-esm/parser@^1.4.2",
53
- "@codemod/utils": "npm:@codemod-esm/utils@^1.1.1",
38
+ "@codemod/core": "npm:@codemod-esm/core@^2.2.2",
39
+ "@codemod/matchers": "npm:@codemod-esm/matchers@^1.7.2",
40
+ "@codemod/parser": "npm:@codemod-esm/parser@^1.4.3",
41
+ "@codemod/utils": "npm:@codemod-esm/utils@^1.1.2",
54
42
  "@mochaa/eslintrc": "^0.1.12",
55
43
  "@types/babel__core": "^7.20.5",
56
44
  "@types/babel__generator": "^7.6.8",
57
45
  "@types/babel__helper-validator-identifier": "^7.15.2",
58
46
  "@types/babel__template": "^7.4.4",
59
47
  "@types/babel__traverse": "^7.20.6",
60
- "@types/bun": "^1.2.2",
48
+ "@types/bun": "^1.2.4",
61
49
  "@types/debug": "^4.1.12",
62
- "eslint": "^9.19.0",
63
- "typescript": "^5.7.3",
50
+ "bun": "^1.2.4",
51
+ "eslint": "^9.21.0",
52
+ "typescript": "^5.8.2",
64
53
  "webcrack": "github:j4k0xb/webcrack"
54
+ },
55
+ "scripts": {
56
+ "build": "bun build.ts",
57
+ "build:minify": "bun run build --minify --entry-naming [dir]/[name].min.[ext]",
58
+ "build:webcrack": "tsc -p ./tsconfig.webcrack.json || :",
59
+ "check": "tsc; bun run lint",
60
+ "lint": "eslint .",
61
+ "lint:fix": "eslint . --fix",
62
+ "prebuild": "bun run build:webcrack",
63
+ "start": "bun cli.ts"
65
64
  }
66
- }
65
+ }
package/types.d.ts ADDED
@@ -0,0 +1,4 @@
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>;