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.mjs CHANGED
@@ -86272,14 +86272,14 @@ var NodeType = /* @__PURE__ */ ((NodeType3) => {
86272
86272
  })(NodeType || {});
86273
86273
  var NodeCollection = class {
86274
86274
  nodes = /* @__PURE__ */ new Map();
86275
- addNode(label, node2, options = { isComputed: false }) {
86275
+ addNode(label, node2, options = { isComputed: false, isMethod: false }) {
86276
86276
  if (this.nodes.has(label)) {
86277
86277
  return;
86278
86278
  }
86279
86279
  if (!options.isComputed && (node2.type === "VariableDeclarator" && [
86280
86280
  "ArrowFunctionExpression",
86281
86281
  "FunctionDeclaration"
86282
- ].includes(node2.init?.type || "") || node2.type === "FunctionDeclaration" || node2.type === "ObjectMethod")) {
86282
+ ].includes(node2.init?.type || "") || node2.type === "FunctionDeclaration" || node2.type === "ObjectMethod") || options.isMethod) {
86283
86283
  this.nodes.set(label, {
86284
86284
  label,
86285
86285
  type: "fun" /* fun */
@@ -86342,6 +86342,17 @@ function processSetup(ast, parentScope, parentPath, _spread) {
86342
86342
  }
86343
86343
  }
86344
86344
  }
86345
+ if (element?.type === "RestElement" && element.argument.type === "Identifier") {
86346
+ const name = element.argument.name;
86347
+ const binding2 = path2.scope.getBinding(name);
86348
+ 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))) {
86349
+ graph.nodes.add(name);
86350
+ nodeCollection.addNode(name, declaration2);
86351
+ if (!graph.edges.get(name)) {
86352
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86353
+ }
86354
+ }
86355
+ }
86345
86356
  });
86346
86357
  }
86347
86358
  if (declaration2.id.type === "ObjectPattern") {
@@ -86357,6 +86368,17 @@ function processSetup(ast, parentScope, parentPath, _spread) {
86357
86368
  }
86358
86369
  }
86359
86370
  }
86371
+ if (property.type === "RestElement" && property.argument.type === "Identifier") {
86372
+ const name = property.argument.name;
86373
+ const binding2 = path2.scope.getBinding(name);
86374
+ 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))) {
86375
+ graph.nodes.add(name);
86376
+ nodeCollection.addNode(name, declaration2);
86377
+ if (!graph.edges.get(name)) {
86378
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86379
+ }
86380
+ }
86381
+ }
86360
86382
  });
86361
86383
  }
86362
86384
  if (declaration2.id?.type === "Identifier") {
@@ -86588,6 +86610,29 @@ function analyze3(content) {
86588
86610
  traverse3(node2, {
86589
86611
  ObjectProperty(path1) {
86590
86612
  if (path2.node.declaration.type === "ObjectExpression" && path1.parent === path2.node.declaration || path2.node.declaration.type === "CallExpression" && path1.parent === path2.node.declaration.arguments[0]) {
86613
+ if (path1.node.key.type === "Identifier" && path1.node.key.name === "data" && path1.node.value.type === "ArrowFunctionExpression") {
86614
+ const dataNode = path1.node.value;
86615
+ traverse3(dataNode, {
86616
+ ReturnStatement(path22) {
86617
+ if (path22.parent == dataNode.body) {
86618
+ if (path22.node.argument?.type === "ObjectExpression") {
86619
+ path22.node.argument.properties.forEach((prop) => {
86620
+ if (prop.type === "ObjectProperty") {
86621
+ if (prop.key.type === "Identifier") {
86622
+ const name = prop.key.name;
86623
+ graph.nodes.add(name);
86624
+ nodeCollection.addNode(name, prop);
86625
+ if (!graph.edges.get(name)) {
86626
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86627
+ }
86628
+ }
86629
+ }
86630
+ });
86631
+ }
86632
+ }
86633
+ }
86634
+ }, path1.scope, path1);
86635
+ }
86591
86636
  if (path1.node.key.type === "Identifier" && path1.node.key.name === "computed") {
86592
86637
  const computedNode = path1.node;
86593
86638
  if (computedNode.value.type === "ObjectExpression") {
@@ -86611,11 +86656,11 @@ function analyze3(content) {
86611
86656
  const methodsNode = path1.node;
86612
86657
  if (methodsNode.value.type === "ObjectExpression") {
86613
86658
  methodsNode.value.properties.forEach((prop) => {
86614
- if (prop.type === "ObjectMethod") {
86659
+ if (prop.type === "ObjectProperty" || prop.type === "ObjectMethod") {
86615
86660
  if (prop.key.type === "Identifier") {
86616
86661
  const name = prop.key.name;
86617
86662
  graph.nodes.add(name);
86618
- nodeCollection.addNode(name, prop);
86663
+ nodeCollection.addNode(name, prop, { isMethod: true });
86619
86664
  if (!graph.edges.get(name)) {
86620
86665
  graph.edges.set(name, /* @__PURE__ */ new Set());
86621
86666
  }