vue-hook-optimizer 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +34 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -89
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -48,8 +48,8 @@ var require_virtual_types = __commonJS({
|
|
48
48
|
exports.Statement = Statement;
|
49
49
|
var Expression = ["Expression"];
|
50
50
|
exports.Expression = Expression;
|
51
|
-
var
|
52
|
-
exports.Scope =
|
51
|
+
var Scope3 = ["Scopable", "Pattern"];
|
52
|
+
exports.Scope = Scope3;
|
53
53
|
var Referenced = null;
|
54
54
|
exports.Referenced = Referenced;
|
55
55
|
var BlockScoped = null;
|
@@ -18062,7 +18062,7 @@ var require_scope = __commonJS({
|
|
18062
18062
|
}
|
18063
18063
|
};
|
18064
18064
|
var uid = 0;
|
18065
|
-
var
|
18065
|
+
var Scope3 = class _Scope {
|
18066
18066
|
constructor(path2) {
|
18067
18067
|
this.uid = void 0;
|
18068
18068
|
this.path = void 0;
|
@@ -18697,9 +18697,9 @@ var require_scope = __commonJS({
|
|
18697
18697
|
} while (scope = scope.parent);
|
18698
18698
|
}
|
18699
18699
|
};
|
18700
|
-
exports.default =
|
18701
|
-
|
18702
|
-
|
18700
|
+
exports.default = Scope3;
|
18701
|
+
Scope3.globals = Object.keys(_globals.builtin);
|
18702
|
+
Scope3.contextVariables = ["arguments", "undefined", "Infinity", "NaN"];
|
18703
18703
|
}
|
18704
18704
|
});
|
18705
18705
|
|
@@ -29011,7 +29011,7 @@ var require_lib9 = __commonJS({
|
|
29011
29011
|
var CLASS_ELEMENT_INSTANCE_GETTER2 = CLASS_ELEMENT_KIND_GETTER2;
|
29012
29012
|
var CLASS_ELEMENT_INSTANCE_SETTER2 = CLASS_ELEMENT_KIND_SETTER2;
|
29013
29013
|
var CLASS_ELEMENT_OTHER2 = 0;
|
29014
|
-
var
|
29014
|
+
var Scope3 = class {
|
29015
29015
|
constructor(flags) {
|
29016
29016
|
this.var = /* @__PURE__ */ new Set();
|
29017
29017
|
this.lexical = /* @__PURE__ */ new Set();
|
@@ -29067,7 +29067,7 @@ var require_lib9 = __commonJS({
|
|
29067
29067
|
return this.treatFunctionsAsVarInScope(this.currentScope());
|
29068
29068
|
}
|
29069
29069
|
createScope(flags) {
|
29070
|
-
return new
|
29070
|
+
return new Scope3(flags);
|
29071
29071
|
}
|
29072
29072
|
enter(flags) {
|
29073
29073
|
this.scopeStack.push(this.createScope(flags));
|
@@ -29162,7 +29162,7 @@ var require_lib9 = __commonJS({
|
|
29162
29162
|
}
|
29163
29163
|
}
|
29164
29164
|
};
|
29165
|
-
var FlowScope2 = class extends
|
29165
|
+
var FlowScope2 = class extends Scope3 {
|
29166
29166
|
constructor(...args) {
|
29167
29167
|
super(...args);
|
29168
29168
|
this.declareFunctions = /* @__PURE__ */ new Set();
|
@@ -34668,7 +34668,7 @@ var require_lib9 = __commonJS({
|
|
34668
34668
|
}
|
34669
34669
|
}
|
34670
34670
|
};
|
34671
|
-
var TypeScriptScope2 = class extends
|
34671
|
+
var TypeScriptScope2 = class extends Scope3 {
|
34672
34672
|
constructor(...args) {
|
34673
34673
|
super(...args);
|
34674
34674
|
this.types = /* @__PURE__ */ new Set();
|
@@ -86277,13 +86277,7 @@ var traverse2 = (
|
|
86277
86277
|
//@ts-ignore
|
86278
86278
|
import_traverse2.default.default?.default || import_traverse2.default.default || import_traverse2.default
|
86279
86279
|
);
|
86280
|
-
function
|
86281
|
-
const ast = parse_1$1(content, {
|
86282
|
-
sourceType: "module",
|
86283
|
-
plugins: [
|
86284
|
-
"typescript"
|
86285
|
-
]
|
86286
|
-
});
|
86280
|
+
function processSetup(ast, parentScope, parentPath) {
|
86287
86281
|
const graph = {
|
86288
86282
|
nodes: /* @__PURE__ */ new Set(),
|
86289
86283
|
edges: /* @__PURE__ */ new Map()
|
@@ -86296,7 +86290,7 @@ function analyze2(content) {
|
|
86296
86290
|
if (element?.type === "Identifier") {
|
86297
86291
|
const name = element.name;
|
86298
86292
|
const binding2 = path2.scope.getBinding(name);
|
86299
|
-
if (binding2 && path2.parent.type === "Program" && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
|
86293
|
+
if (binding2 && (path2.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path2.parent) && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
|
86300
86294
|
graph.nodes.add(name);
|
86301
86295
|
if (!graph.edges.get(name)) {
|
86302
86296
|
graph.edges.set(name, /* @__PURE__ */ new Set());
|
@@ -86310,7 +86304,7 @@ function analyze2(content) {
|
|
86310
86304
|
if (property.type === "ObjectProperty" && property.value.type === "Identifier") {
|
86311
86305
|
const name = property.value.name;
|
86312
86306
|
const binding2 = path2.scope.getBinding(name);
|
86313
|
-
if (binding2 && path2.parent.type === "Program" && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
|
86307
|
+
if (binding2 && (path2.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path2.parent) && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
|
86314
86308
|
graph.nodes.add(name);
|
86315
86309
|
if (!graph.edges.get(name)) {
|
86316
86310
|
graph.edges.set(name, /* @__PURE__ */ new Set());
|
@@ -86322,7 +86316,7 @@ function analyze2(content) {
|
|
86322
86316
|
if (declaration2.id?.type === "Identifier") {
|
86323
86317
|
const name = declaration2.id.name;
|
86324
86318
|
const binding2 = path2.scope.getBinding(name);
|
86325
|
-
if (binding2 && path2.parent.type === "Program" && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
|
86319
|
+
if (binding2 && (path2.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path2.parent) && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
|
86326
86320
|
graph.nodes.add(name);
|
86327
86321
|
if (!graph.edges.get(name)) {
|
86328
86322
|
graph.edges.set(name, /* @__PURE__ */ new Set());
|
@@ -86335,7 +86329,7 @@ function analyze2(content) {
|
|
86335
86329
|
const name = path2.node.id?.name;
|
86336
86330
|
if (name) {
|
86337
86331
|
const binding2 = path2.scope.getBinding(name);
|
86338
|
-
if (binding2 && path2.parent.type === "Program") {
|
86332
|
+
if (binding2 && (path2.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path2.parent)) {
|
86339
86333
|
graph.nodes.add(name);
|
86340
86334
|
if (!graph.edges.get(name)) {
|
86341
86335
|
graph.edges.set(name, /* @__PURE__ */ new Set());
|
@@ -86343,7 +86337,7 @@ function analyze2(content) {
|
|
86343
86337
|
}
|
86344
86338
|
}
|
86345
86339
|
}
|
86346
|
-
});
|
86340
|
+
}, parentScope, parentPath);
|
86347
86341
|
traverse2(ast, {
|
86348
86342
|
FunctionDeclaration(path2) {
|
86349
86343
|
const name = path2.node.id?.name;
|
@@ -86351,7 +86345,7 @@ function analyze2(content) {
|
|
86351
86345
|
path2.traverse({
|
86352
86346
|
Identifier(path1) {
|
86353
86347
|
const binding2 = path1.scope.getBinding(path1.node.name);
|
86354
|
-
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
|
86348
|
+
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
|
86355
86349
|
graph.edges.get(name)?.add(path1.node.name);
|
86356
86350
|
}
|
86357
86351
|
}
|
@@ -86368,7 +86362,7 @@ function analyze2(content) {
|
|
86368
86362
|
traverse2(path2.node.init, {
|
86369
86363
|
Identifier(path1) {
|
86370
86364
|
const binding2 = path1.scope.getBinding(path1.node.name);
|
86371
|
-
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
|
86365
|
+
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
|
86372
86366
|
graph.edges.get(name)?.add(path1.node.name);
|
86373
86367
|
}
|
86374
86368
|
}
|
@@ -86385,7 +86379,7 @@ function analyze2(content) {
|
|
86385
86379
|
traverse2(path2.node.init, {
|
86386
86380
|
Identifier(path1) {
|
86387
86381
|
const binding2 = path1.scope.getBinding(path1.node.name);
|
86388
|
-
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
|
86382
|
+
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
|
86389
86383
|
graph.edges.get(name)?.add(path1.node.name);
|
86390
86384
|
}
|
86391
86385
|
}
|
@@ -86404,7 +86398,7 @@ function analyze2(content) {
|
|
86404
86398
|
traverse2(path2.node.init, {
|
86405
86399
|
Identifier(path1) {
|
86406
86400
|
const binding2 = path1.scope.getBinding(path1.node.name);
|
86407
|
-
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
|
86401
|
+
if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
|
86408
86402
|
graph.edges.get(name)?.add(path1.node.name);
|
86409
86403
|
}
|
86410
86404
|
}
|
@@ -86413,9 +86407,18 @@ function analyze2(content) {
|
|
86413
86407
|
}
|
86414
86408
|
}
|
86415
86409
|
}
|
86416
|
-
});
|
86410
|
+
}, parentScope, parentPath);
|
86417
86411
|
return graph;
|
86418
86412
|
}
|
86413
|
+
function analyze2(content) {
|
86414
|
+
const ast = parse_1$1(content, {
|
86415
|
+
sourceType: "module",
|
86416
|
+
plugins: [
|
86417
|
+
"typescript"
|
86418
|
+
]
|
86419
|
+
});
|
86420
|
+
return processSetup(ast);
|
86421
|
+
}
|
86419
86422
|
|
86420
86423
|
// src/analyze/options.ts
|
86421
86424
|
var import_traverse3 = __toESM(require_lib13());
|
@@ -86476,68 +86479,10 @@ function analyze3(content) {
|
|
86476
86479
|
if (path2.node.declaration.type === "ObjectExpression" && path1.parent === path2.node.declaration || path2.node.declaration.type === "CallExpression" && path1.parent === path2.node.declaration.arguments[0]) {
|
86477
86480
|
if (path1.node.key.type === "Identifier" && path1.node.key.name === "setup") {
|
86478
86481
|
const setupNode = path1.node;
|
86479
|
-
const
|
86480
|
-
|
86481
|
-
|
86482
|
-
|
86483
|
-
path22.node.declarations.forEach((declaration2) => {
|
86484
|
-
if (declaration2.id?.type === "Identifier") {
|
86485
|
-
const name = declaration2.id.name;
|
86486
|
-
if (path22.parent == setupNode.body) {
|
86487
|
-
tempNodes.add(name);
|
86488
|
-
if (!tempEdges.get(name)) {
|
86489
|
-
tempEdges.set(name, /* @__PURE__ */ new Set());
|
86490
|
-
}
|
86491
|
-
}
|
86492
|
-
}
|
86493
|
-
});
|
86494
|
-
},
|
86495
|
-
FunctionDeclaration(path22) {
|
86496
|
-
const name = path22.node.id?.name;
|
86497
|
-
if (name) {
|
86498
|
-
if (path22.parent == setupNode.body) {
|
86499
|
-
tempNodes.add(name);
|
86500
|
-
if (!tempEdges.get(name)) {
|
86501
|
-
tempEdges.set(name, /* @__PURE__ */ new Set());
|
86502
|
-
}
|
86503
|
-
}
|
86504
|
-
}
|
86505
|
-
}
|
86506
|
-
}, path1.scope, path1);
|
86507
|
-
traverse3(setupNode, {
|
86508
|
-
FunctionDeclaration(path3) {
|
86509
|
-
const name = path3.node.id?.name;
|
86510
|
-
if (name && tempNodes.has(name)) {
|
86511
|
-
path3.traverse({
|
86512
|
-
Identifier(path4) {
|
86513
|
-
if (tempNodes.has(path4.node.name) && path4.node.name !== name) {
|
86514
|
-
tempEdges.get(name)?.add(path4.node.name);
|
86515
|
-
}
|
86516
|
-
}
|
86517
|
-
});
|
86518
|
-
}
|
86519
|
-
},
|
86520
|
-
VariableDeclarator(path3) {
|
86521
|
-
if (path3.node.init) {
|
86522
|
-
if ([
|
86523
|
-
"CallExpression",
|
86524
|
-
"ArrowFunctionExpression",
|
86525
|
-
"FunctionDeclaration"
|
86526
|
-
].includes(path3.node.init.type) && path3.node.id.type === "Identifier") {
|
86527
|
-
const name = path3.node.id?.name;
|
86528
|
-
if (name && tempNodes.has(name)) {
|
86529
|
-
path3.traverse({
|
86530
|
-
Identifier(path4) {
|
86531
|
-
if (tempNodes.has(path4.node.name) && path4.node.name !== name) {
|
86532
|
-
tempEdges.get(name)?.add(path4.node.name);
|
86533
|
-
}
|
86534
|
-
}
|
86535
|
-
});
|
86536
|
-
}
|
86537
|
-
}
|
86538
|
-
}
|
86539
|
-
}
|
86540
|
-
}, path1.scope, path1);
|
86482
|
+
const {
|
86483
|
+
nodes: tempNodes,
|
86484
|
+
edges: tempEdges
|
86485
|
+
} = processSetup(setupNode, path1.scope, setupNode);
|
86541
86486
|
traverse3(setupNode, {
|
86542
86487
|
ReturnStatement(path22) {
|
86543
86488
|
if (path22.node.argument?.type === "ObjectExpression") {
|