vue-hook-optimizer 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -86281,6 +86281,34 @@ function analyze2(content) {
86281
86281
  traverse2(ast, {
86282
86282
  VariableDeclaration(path2) {
86283
86283
  path2.node.declarations.forEach((declaration2) => {
86284
+ if (declaration2.id.type === "ArrayPattern") {
86285
+ declaration2.id.elements.forEach((element) => {
86286
+ if (element?.type === "Identifier") {
86287
+ const name = element.name;
86288
+ const binding2 = path2.scope.getBinding(name);
86289
+ if (binding2 && path2.parent.type === "Program" && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
86290
+ graph.nodes.add(name);
86291
+ if (!graph.edges.get(name)) {
86292
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86293
+ }
86294
+ }
86295
+ }
86296
+ });
86297
+ }
86298
+ if (declaration2.id.type === "ObjectPattern") {
86299
+ declaration2.id.properties.forEach((property) => {
86300
+ if (property.type === "ObjectProperty" && property.value.type === "Identifier") {
86301
+ const name = property.value.name;
86302
+ const binding2 = path2.scope.getBinding(name);
86303
+ if (binding2 && path2.parent.type === "Program" && !(declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && ["defineProps", "defineEmits"].includes(declaration2.init?.callee.name))) {
86304
+ graph.nodes.add(name);
86305
+ if (!graph.edges.get(name)) {
86306
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86307
+ }
86308
+ }
86309
+ }
86310
+ });
86311
+ }
86284
86312
  if (declaration2.id?.type === "Identifier") {
86285
86313
  const name = declaration2.id.name;
86286
86314
  const binding2 = path2.scope.getBinding(name);
@@ -86311,9 +86339,10 @@ function analyze2(content) {
86311
86339
  const name = path2.node.id?.name;
86312
86340
  if (name && graph.nodes.has(name)) {
86313
86341
  path2.traverse({
86314
- Identifier(path3) {
86315
- if (graph.nodes.has(path3.node.name) && path3.node.name !== name) {
86316
- graph.edges.get(name)?.add(path3.node.name);
86342
+ Identifier(path1) {
86343
+ const binding2 = path1.scope.getBinding(path1.node.name);
86344
+ if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
86345
+ graph.edges.get(name)?.add(path1.node.name);
86317
86346
  }
86318
86347
  }
86319
86348
  });
@@ -86321,6 +86350,40 @@ function analyze2(content) {
86321
86350
  },
86322
86351
  VariableDeclarator(path2) {
86323
86352
  if (path2.node.init) {
86353
+ if (path2.node.id.type === "ArrayPattern") {
86354
+ path2.node.id.elements.forEach((element) => {
86355
+ if (element?.type === "Identifier") {
86356
+ const name = element.name;
86357
+ if (name && graph.nodes.has(name) && path2.node.init?.type === "CallExpression") {
86358
+ traverse2(path2.node.init, {
86359
+ Identifier(path1) {
86360
+ const binding2 = path1.scope.getBinding(path1.node.name);
86361
+ if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
86362
+ graph.edges.get(name)?.add(path1.node.name);
86363
+ }
86364
+ }
86365
+ }, path2.scope, path2);
86366
+ }
86367
+ }
86368
+ });
86369
+ }
86370
+ if (path2.node.id.type === "ObjectPattern") {
86371
+ path2.node.id.properties.forEach((property) => {
86372
+ if (property.type === "ObjectProperty" && property.value.type === "Identifier") {
86373
+ const name = property.value.name;
86374
+ if (name && graph.nodes.has(name) && path2.node.init) {
86375
+ traverse2(path2.node.init, {
86376
+ Identifier(path1) {
86377
+ const binding2 = path1.scope.getBinding(path1.node.name);
86378
+ if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
86379
+ graph.edges.get(name)?.add(path1.node.name);
86380
+ }
86381
+ }
86382
+ }, path2.scope, path2);
86383
+ }
86384
+ }
86385
+ });
86386
+ }
86324
86387
  if ([
86325
86388
  "CallExpression",
86326
86389
  "ArrowFunctionExpression",
@@ -86328,13 +86391,14 @@ function analyze2(content) {
86328
86391
  ].includes(path2.node.init.type) && path2.node.id.type === "Identifier") {
86329
86392
  const name = path2.node.id?.name;
86330
86393
  if (name && graph.nodes.has(name)) {
86331
- path2.traverse({
86332
- Identifier(path3) {
86333
- if (graph.nodes.has(path3.node.name) && path3.node.name !== name) {
86334
- graph.edges.get(name)?.add(path3.node.name);
86394
+ traverse2(path2.node.init, {
86395
+ Identifier(path1) {
86396
+ const binding2 = path1.scope.getBinding(path1.node.name);
86397
+ if (graph.nodes.has(path1.node.name) && path1.node.name !== name && binding2?.scope.block.type === "Program") {
86398
+ graph.edges.get(name)?.add(path1.node.name);
86335
86399
  }
86336
86400
  }
86337
- });
86401
+ }, path2.scope, path2);
86338
86402
  }
86339
86403
  }
86340
86404
  }
@@ -86579,7 +86643,6 @@ function analyze3(content) {
86579
86643
  process2(path2.node.declaration, path2);
86580
86644
  } else if (path2.node.declaration.type === "CallExpression" && path2.node.declaration.callee.type === "Identifier" && path2.node.declaration.callee.name === "defineComponent" && path2.node.declaration.arguments[0].type === "ObjectExpression") {
86581
86645
  process2(path2.node.declaration.arguments[0], path2);
86582
- console.log(graph);
86583
86646
  }
86584
86647
  }
86585
86648
  });