@delance/builder 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -9
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
3916
|
+
const matcher2 = functionDeclaration(identifier(functionName), anything(), blockStatement(anySubList(variableDeclaration(undefined, [
|
|
3888
3917
|
variableDeclarator(arrayIdentifier, callExpression(identifier(stringArray.name)))
|
|
3889
|
-
]),
|
|
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(
|
|
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 {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delance/builder",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"description": "A spear to the Python language server built with black magic",
|
|
6
6
|
"author": "mochaaP <npm@mochaa.ws>",
|
|
7
7
|
"license": "0BSD",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"debug": "^4.4.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@babel/core": "^7.26.
|
|
42
|
-
"@babel/generator": "^7.26.
|
|
43
|
-
"@babel/parser": "^7.26.
|
|
44
|
-
"@babel/template": "^7.
|
|
45
|
-
"@babel/traverse": "^7.26.
|
|
46
|
-
"@babel/types": "^7.26.
|
|
41
|
+
"@babel/core": "^7.26.9",
|
|
42
|
+
"@babel/generator": "^7.26.9",
|
|
43
|
+
"@babel/parser": "^7.26.9",
|
|
44
|
+
"@babel/template": "^7.26.9",
|
|
45
|
+
"@babel/traverse": "^7.26.9",
|
|
46
|
+
"@babel/types": "^7.26.9",
|
|
47
47
|
"quickjs-emscripten": "^0.31.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"@types/babel__helper-validator-identifier": "^7.15.2",
|
|
58
58
|
"@types/babel__template": "^7.4.4",
|
|
59
59
|
"@types/babel__traverse": "^7.20.6",
|
|
60
|
-
"@types/bun": "^1.2.
|
|
60
|
+
"@types/bun": "^1.2.4",
|
|
61
61
|
"@types/debug": "^4.1.12",
|
|
62
|
-
"eslint": "^9.
|
|
63
|
-
"typescript": "^5.
|
|
62
|
+
"eslint": "^9.21.0",
|
|
63
|
+
"typescript": "^5.8.2",
|
|
64
64
|
"webcrack": "github:j4k0xb/webcrack"
|
|
65
65
|
}
|
|
66
66
|
}
|