vue-hook-optimizer 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +49 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -86285,14 +86285,14 @@ var NodeType = /* @__PURE__ */ ((NodeType3) => {
|
|
86285
86285
|
})(NodeType || {});
|
86286
86286
|
var NodeCollection = class {
|
86287
86287
|
nodes = /* @__PURE__ */ new Map();
|
86288
|
-
addNode(label, node2, options = { isComputed: false }) {
|
86288
|
+
addNode(label, node2, options = { isComputed: false, isMethod: false }) {
|
86289
86289
|
if (this.nodes.has(label)) {
|
86290
86290
|
return;
|
86291
86291
|
}
|
86292
86292
|
if (!options.isComputed && (node2.type === "VariableDeclarator" && [
|
86293
86293
|
"ArrowFunctionExpression",
|
86294
86294
|
"FunctionDeclaration"
|
86295
|
-
].includes(node2.init?.type || "") || node2.type === "FunctionDeclaration" || node2.type === "ObjectMethod")) {
|
86295
|
+
].includes(node2.init?.type || "") || node2.type === "FunctionDeclaration" || node2.type === "ObjectMethod") || options.isMethod) {
|
86296
86296
|
this.nodes.set(label, {
|
86297
86297
|
label,
|
86298
86298
|
type: "fun" /* fun */
|
@@ -86355,6 +86355,17 @@ function processSetup(ast, parentScope, parentPath, _spread) {
|
|
86355
86355
|
}
|
86356
86356
|
}
|
86357
86357
|
}
|
86358
|
+
if (element?.type === "RestElement" && element.argument.type === "Identifier") {
|
86359
|
+
const name = element.argument.name;
|
86360
|
+
const binding2 = path2.scope.getBinding(name);
|
86361
|
+
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))) {
|
86362
|
+
graph.nodes.add(name);
|
86363
|
+
nodeCollection.addNode(name, declaration2);
|
86364
|
+
if (!graph.edges.get(name)) {
|
86365
|
+
graph.edges.set(name, /* @__PURE__ */ new Set());
|
86366
|
+
}
|
86367
|
+
}
|
86368
|
+
}
|
86358
86369
|
});
|
86359
86370
|
}
|
86360
86371
|
if (declaration2.id.type === "ObjectPattern") {
|
@@ -86370,6 +86381,17 @@ function processSetup(ast, parentScope, parentPath, _spread) {
|
|
86370
86381
|
}
|
86371
86382
|
}
|
86372
86383
|
}
|
86384
|
+
if (property.type === "RestElement" && property.argument.type === "Identifier") {
|
86385
|
+
const name = property.argument.name;
|
86386
|
+
const binding2 = path2.scope.getBinding(name);
|
86387
|
+
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))) {
|
86388
|
+
graph.nodes.add(name);
|
86389
|
+
nodeCollection.addNode(name, declaration2);
|
86390
|
+
if (!graph.edges.get(name)) {
|
86391
|
+
graph.edges.set(name, /* @__PURE__ */ new Set());
|
86392
|
+
}
|
86393
|
+
}
|
86394
|
+
}
|
86373
86395
|
});
|
86374
86396
|
}
|
86375
86397
|
if (declaration2.id?.type === "Identifier") {
|
@@ -86601,6 +86623,29 @@ function analyze3(content) {
|
|
86601
86623
|
traverse3(node2, {
|
86602
86624
|
ObjectProperty(path1) {
|
86603
86625
|
if (path2.node.declaration.type === "ObjectExpression" && path1.parent === path2.node.declaration || path2.node.declaration.type === "CallExpression" && path1.parent === path2.node.declaration.arguments[0]) {
|
86626
|
+
if (path1.node.key.type === "Identifier" && path1.node.key.name === "data" && path1.node.value.type === "ArrowFunctionExpression") {
|
86627
|
+
const dataNode = path1.node.value;
|
86628
|
+
traverse3(dataNode, {
|
86629
|
+
ReturnStatement(path22) {
|
86630
|
+
if (path22.parent == dataNode.body) {
|
86631
|
+
if (path22.node.argument?.type === "ObjectExpression") {
|
86632
|
+
path22.node.argument.properties.forEach((prop) => {
|
86633
|
+
if (prop.type === "ObjectProperty") {
|
86634
|
+
if (prop.key.type === "Identifier") {
|
86635
|
+
const name = prop.key.name;
|
86636
|
+
graph.nodes.add(name);
|
86637
|
+
nodeCollection.addNode(name, prop);
|
86638
|
+
if (!graph.edges.get(name)) {
|
86639
|
+
graph.edges.set(name, /* @__PURE__ */ new Set());
|
86640
|
+
}
|
86641
|
+
}
|
86642
|
+
}
|
86643
|
+
});
|
86644
|
+
}
|
86645
|
+
}
|
86646
|
+
}
|
86647
|
+
}, path1.scope, path1);
|
86648
|
+
}
|
86604
86649
|
if (path1.node.key.type === "Identifier" && path1.node.key.name === "computed") {
|
86605
86650
|
const computedNode = path1.node;
|
86606
86651
|
if (computedNode.value.type === "ObjectExpression") {
|
@@ -86624,11 +86669,11 @@ function analyze3(content) {
|
|
86624
86669
|
const methodsNode = path1.node;
|
86625
86670
|
if (methodsNode.value.type === "ObjectExpression") {
|
86626
86671
|
methodsNode.value.properties.forEach((prop) => {
|
86627
|
-
if (prop.type === "ObjectMethod") {
|
86672
|
+
if (prop.type === "ObjectProperty" || prop.type === "ObjectMethod") {
|
86628
86673
|
if (prop.key.type === "Identifier") {
|
86629
86674
|
const name = prop.key.name;
|
86630
86675
|
graph.nodes.add(name);
|
86631
|
-
nodeCollection.addNode(name, prop);
|
86676
|
+
nodeCollection.addNode(name, prop, { isMethod: true });
|
86632
86677
|
if (!graph.edges.get(name)) {
|
86633
86678
|
graph.edges.set(name, /* @__PURE__ */ new Set());
|
86634
86679
|
}
|