vue-hook-optimizer 0.0.10 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  [![NPM version](https://img.shields.io/npm/v/vue-hook-optimizer?color=a1b858&label=)](https://www.npmjs.com/package/vue-hook-optimizer)
2
+ <a href="https://marketplace.visualstudio.com/items?itemName=zcf0508.vue-hook-optimizer-ext" target="__blank"><img src="https://img.shields.io/visual-studio-marketplace/v/zcf0508.vue-hook-optimizer-ext.svg?color=eee&amp;label=VS%20Code%20Marketplace&logo=visual-studio-code" alt="Visual Studio Marketplace Version" /></a>
2
3
 
3
4
  [中文文档](./README_cn.md)
4
5
 
5
- This is a tool to analyze your `vue` code.
6
+ This is a tool to analyze your `vue` code. Viste [hook.huali.cafe](https://hook.huali.cafe) or try the vscode extension [vue-hook-optimizer-ext](https://marketplace.visualstudio.com/items?itemName=zcf0508.vue-hook-optimizer-ext).
6
7
 
7
8
  ## Install And Run Playground
8
9
 
@@ -21,11 +22,11 @@ Open the browser and visit `http://localhost:3000/`.
21
22
 
22
23
  1. paste your `vue` code into the editor
23
24
 
24
- Up to now, it only supports the code with `<script setup>` syntax block.If your code use `options api`, it's not working at the moment.
25
+ ~~Up to now, it only supports the code with `<script setup>` syntax block.If your code use `options api`, it's not working at the moment.~~
25
26
 
26
27
  2. click `Analyze` button
27
28
 
28
- The tool will analyze the `setup block` and `template block`, and show the relations between the variables and the methods. This is a simple demo.
29
+ The tool will analyze the code, and show the relations between the variables and the methods. This is a simple demo.
29
30
 
30
31
  ![demo](./images/demo1.png)
31
32
 
@@ -37,7 +38,7 @@ So I want to build a tool to help us analyze the code, and find the relations be
37
38
 
38
39
  ## Development Plan
39
40
 
40
- - [ ] add node type and more info
41
+ - [ ] add ~~node type~~ (has added `var` and `fun` types) and more info
41
42
  - [ ] provide some suggestions for optimization
42
43
  - [x] support `options api`
43
44
  - [x] [vscode extension](./packages/vscode)
package/dist/index.d.mts CHANGED
@@ -3,19 +3,51 @@ import * as vis_network from 'vis-network';
3
3
 
4
4
  declare function analyze$2(content: string): Set<string>;
5
5
 
6
+ declare enum NodeType {
7
+ var = "var",
8
+ fun = "fun"
9
+ }
10
+
6
11
  declare function analyze$1(content: string): {
7
- nodes: Set<string>;
8
- edges: Map<string, Set<string>>;
12
+ nodes: Set<{
13
+ label: string;
14
+ type: NodeType;
15
+ }>;
16
+ edges: Map<{
17
+ label: string;
18
+ type: NodeType;
19
+ }, Set<{
20
+ label: string;
21
+ type: NodeType;
22
+ }>>;
9
23
  };
10
24
 
11
25
  declare function analyze(content: string): {
12
- nodes: Set<string>;
13
- edges: Map<string, Set<string>>;
26
+ nodes: Set<{
27
+ label: string;
28
+ type: NodeType;
29
+ }>;
30
+ edges: Map<{
31
+ label: string;
32
+ type: NodeType;
33
+ }, Set<{
34
+ label: string;
35
+ type: NodeType;
36
+ }>>;
14
37
  };
15
38
 
16
39
  declare function getVisData(graph: {
17
- nodes: Set<string>;
18
- edges: Map<string, Set<string>>;
40
+ nodes: Set<{
41
+ label: string;
42
+ type: string;
43
+ }>;
44
+ edges: Map<{
45
+ label: string;
46
+ type: string;
47
+ }, Set<{
48
+ label: string;
49
+ type: string;
50
+ }>>;
19
51
  }, usedNodes: Set<string>): {
20
52
  nodes: vis_network.Node[];
21
53
  edges: vis_network.Edge[];
package/dist/index.d.ts CHANGED
@@ -3,19 +3,51 @@ import * as vis_network from 'vis-network';
3
3
 
4
4
  declare function analyze$2(content: string): Set<string>;
5
5
 
6
+ declare enum NodeType {
7
+ var = "var",
8
+ fun = "fun"
9
+ }
10
+
6
11
  declare function analyze$1(content: string): {
7
- nodes: Set<string>;
8
- edges: Map<string, Set<string>>;
12
+ nodes: Set<{
13
+ label: string;
14
+ type: NodeType;
15
+ }>;
16
+ edges: Map<{
17
+ label: string;
18
+ type: NodeType;
19
+ }, Set<{
20
+ label: string;
21
+ type: NodeType;
22
+ }>>;
9
23
  };
10
24
 
11
25
  declare function analyze(content: string): {
12
- nodes: Set<string>;
13
- edges: Map<string, Set<string>>;
26
+ nodes: Set<{
27
+ label: string;
28
+ type: NodeType;
29
+ }>;
30
+ edges: Map<{
31
+ label: string;
32
+ type: NodeType;
33
+ }, Set<{
34
+ label: string;
35
+ type: NodeType;
36
+ }>>;
14
37
  };
15
38
 
16
39
  declare function getVisData(graph: {
17
- nodes: Set<string>;
18
- edges: Map<string, Set<string>>;
40
+ nodes: Set<{
41
+ label: string;
42
+ type: string;
43
+ }>;
44
+ edges: Map<{
45
+ label: string;
46
+ type: string;
47
+ }, Set<{
48
+ label: string;
49
+ type: string;
50
+ }>>;
19
51
  }, usedNodes: Set<string>): {
20
52
  nodes: vis_network.Node[];
21
53
  edges: vis_network.Edge[];
package/dist/index.js CHANGED
@@ -86273,14 +86273,63 @@ function analyze(content) {
86273
86273
 
86274
86274
  // src/analyze/setupScript.ts
86275
86275
  var import_traverse2 = __toESM(require_lib13());
86276
+
86277
+ // src/analyze/utils.ts
86278
+ var NodeCollection = class {
86279
+ nodes = /* @__PURE__ */ new Map();
86280
+ addNode(label, node2, options = { isComputed: false }) {
86281
+ if (this.nodes.has(label)) {
86282
+ return;
86283
+ }
86284
+ if (!options.isComputed && (node2.type === "VariableDeclarator" && [
86285
+ "ArrowFunctionExpression",
86286
+ "FunctionDeclaration"
86287
+ ].includes(node2.init?.type || "") || node2.type === "FunctionDeclaration" || node2.type === "ObjectMethod")) {
86288
+ this.nodes.set(label, {
86289
+ label,
86290
+ type: "fun" /* fun */
86291
+ });
86292
+ } else {
86293
+ this.nodes.set(label, {
86294
+ label,
86295
+ type: "var" /* var */
86296
+ });
86297
+ }
86298
+ }
86299
+ addTypedNode(label, node2) {
86300
+ this.nodes.set(label, {
86301
+ label,
86302
+ type: node2.type
86303
+ });
86304
+ }
86305
+ map(graph) {
86306
+ const nodes = new Set(Array.from(graph.nodes).map((node2) => {
86307
+ return this.nodes.get(node2);
86308
+ }).filter((node2) => !!node2));
86309
+ const edges = new Map(Array.from(graph.edges).map(([from2, to]) => {
86310
+ return [this.nodes.get(from2), new Set(Array.from(to).map((node2) => {
86311
+ return this.nodes.get(node2);
86312
+ }).filter((node2) => !!node2))];
86313
+ }));
86314
+ return {
86315
+ nodes,
86316
+ edges
86317
+ };
86318
+ }
86319
+ };
86320
+
86321
+ // src/analyze/setupScript.ts
86276
86322
  var traverse2 = (
86277
86323
  //@ts-ignore
86278
86324
  import_traverse2.default.default?.default || import_traverse2.default.default || import_traverse2.default
86279
86325
  );
86280
- function processSetup(ast, parentScope, parentPath) {
86326
+ function processSetup(ast, parentScope, parentPath, _spread) {
86327
+ const spread = _spread || [];
86328
+ const nodeCollection = new NodeCollection();
86281
86329
  const graph = {
86282
86330
  nodes: /* @__PURE__ */ new Set(),
86283
- edges: /* @__PURE__ */ new Map()
86331
+ edges: /* @__PURE__ */ new Map(),
86332
+ spread: /* @__PURE__ */ new Map()
86284
86333
  };
86285
86334
  traverse2(ast, {
86286
86335
  VariableDeclaration(path2) {
@@ -86292,6 +86341,7 @@ function processSetup(ast, parentScope, parentPath) {
86292
86341
  const binding2 = path2.scope.getBinding(name);
86293
86342
  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))) {
86294
86343
  graph.nodes.add(name);
86344
+ nodeCollection.addNode(name, declaration2);
86295
86345
  if (!graph.edges.get(name)) {
86296
86346
  graph.edges.set(name, /* @__PURE__ */ new Set());
86297
86347
  }
@@ -86306,6 +86356,7 @@ function processSetup(ast, parentScope, parentPath) {
86306
86356
  const binding2 = path2.scope.getBinding(name);
86307
86357
  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))) {
86308
86358
  graph.nodes.add(name);
86359
+ nodeCollection.addNode(name, declaration2);
86309
86360
  if (!graph.edges.get(name)) {
86310
86361
  graph.edges.set(name, /* @__PURE__ */ new Set());
86311
86362
  }
@@ -86318,9 +86369,53 @@ function processSetup(ast, parentScope, parentPath) {
86318
86369
  const binding2 = path2.scope.getBinding(name);
86319
86370
  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))) {
86320
86371
  graph.nodes.add(name);
86372
+ nodeCollection.addNode(name, declaration2);
86321
86373
  if (!graph.edges.get(name)) {
86322
86374
  graph.edges.set(name, /* @__PURE__ */ new Set());
86323
86375
  }
86376
+ if (spread.includes(name)) {
86377
+ if (declaration2.init?.type === "ObjectExpression") {
86378
+ declaration2.init?.properties.forEach((prop) => {
86379
+ if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
86380
+ const keyName = prop.key.name;
86381
+ graph.nodes.add(keyName);
86382
+ nodeCollection.addNode(keyName, prop);
86383
+ if (!graph.edges.get(keyName)) {
86384
+ graph.edges.set(keyName, /* @__PURE__ */ new Set());
86385
+ }
86386
+ if (graph.spread.has(name)) {
86387
+ graph.spread.get(name)?.add(keyName);
86388
+ } else {
86389
+ graph.spread.set(name, /* @__PURE__ */ new Set([keyName]));
86390
+ }
86391
+ } else if (prop.type === "SpreadElement") {
86392
+ console.warn("not support spread in spread");
86393
+ }
86394
+ });
86395
+ }
86396
+ if (declaration2.init?.type === "CallExpression" && declaration2.init?.callee.type === "Identifier" && declaration2.init?.callee.name === "reactive") {
86397
+ const arg = declaration2.init?.arguments[0];
86398
+ if (arg.type === "ObjectExpression") {
86399
+ arg.properties.forEach((prop) => {
86400
+ if ((prop.type === "ObjectProperty" || prop.type === "ObjectMethod") && prop.key.type === "Identifier") {
86401
+ const keyName = prop.key.name;
86402
+ graph.nodes.add(keyName);
86403
+ nodeCollection.addNode(keyName, prop);
86404
+ if (!graph.edges.get(keyName)) {
86405
+ graph.edges.set(keyName, /* @__PURE__ */ new Set());
86406
+ }
86407
+ if (graph.spread.has(name)) {
86408
+ graph.spread.get(name)?.add(keyName);
86409
+ } else {
86410
+ graph.spread.set(name, /* @__PURE__ */ new Set([keyName]));
86411
+ }
86412
+ } else if (prop.type === "SpreadElement") {
86413
+ console.warn("not support spread in spread");
86414
+ }
86415
+ });
86416
+ }
86417
+ }
86418
+ }
86324
86419
  }
86325
86420
  }
86326
86421
  });
@@ -86331,6 +86426,7 @@ function processSetup(ast, parentScope, parentPath) {
86331
86426
  const binding2 = path2.scope.getBinding(name);
86332
86427
  if (binding2 && (path2.parent.type === "Program" || parentPath?.type === "ObjectMethod" && parentPath.body === path2.parent)) {
86333
86428
  graph.nodes.add(name);
86429
+ nodeCollection.addNode(name, path2.node);
86334
86430
  if (!graph.edges.get(name)) {
86335
86431
  graph.edges.set(name, /* @__PURE__ */ new Set());
86336
86432
  }
@@ -86348,6 +86444,14 @@ function processSetup(ast, parentScope, parentPath) {
86348
86444
  if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86349
86445
  graph.edges.get(name)?.add(path1.node.name);
86350
86446
  }
86447
+ },
86448
+ MemberExpression(path1) {
86449
+ if (path1.node.object.type === "Identifier" && spread.includes(path1.node.object.name)) {
86450
+ const binding2 = path1.scope.getBinding(path1.node.object.name);
86451
+ if (spread.includes(path1.node.object.name) && path1.node.property.type === "Identifier" && path1.node.property.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86452
+ graph.edges.get(name)?.add(path1.node.property.name);
86453
+ }
86454
+ }
86351
86455
  }
86352
86456
  });
86353
86457
  }
@@ -86365,6 +86469,14 @@ function processSetup(ast, parentScope, parentPath) {
86365
86469
  if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86366
86470
  graph.edges.get(name)?.add(path1.node.name);
86367
86471
  }
86472
+ },
86473
+ MemberExpression(path1) {
86474
+ if (path1.node.object.type === "Identifier" && spread.includes(path1.node.object.name)) {
86475
+ const binding2 = path1.scope.getBinding(path1.node.object.name);
86476
+ if (spread.includes(path1.node.object.name) && path1.node.property.type === "Identifier" && path1.node.property.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86477
+ graph.edges.get(name)?.add(path1.node.property.name);
86478
+ }
86479
+ }
86368
86480
  }
86369
86481
  }, path2.scope, path2);
86370
86482
  }
@@ -86382,6 +86494,14 @@ function processSetup(ast, parentScope, parentPath) {
86382
86494
  if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86383
86495
  graph.edges.get(name)?.add(path1.node.name);
86384
86496
  }
86497
+ },
86498
+ MemberExpression(path1) {
86499
+ if (path1.node.object.type === "Identifier" && spread.includes(path1.node.object.name)) {
86500
+ const binding2 = path1.scope.getBinding(path1.node.object.name);
86501
+ if (spread.includes(path1.node.object.name) && path1.node.property.type === "Identifier" && path1.node.property.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86502
+ graph.edges.get(name)?.add(path1.node.property.name);
86503
+ }
86504
+ }
86385
86505
  }
86386
86506
  }, path2.scope, path2);
86387
86507
  }
@@ -86401,14 +86521,44 @@ function processSetup(ast, parentScope, parentPath) {
86401
86521
  if (graph.nodes.has(path1.node.name) && path1.node.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86402
86522
  graph.edges.get(name)?.add(path1.node.name);
86403
86523
  }
86524
+ },
86525
+ MemberExpression(path1) {
86526
+ if (path1.node.object.type === "Identifier" && spread.includes(path1.node.object.name)) {
86527
+ const binding2 = path1.scope.getBinding(path1.node.object.name);
86528
+ if (spread.includes(path1.node.object.name) && path1.node.property.type === "Identifier" && path1.node.property.name !== name && (binding2?.scope.block.type === "Program" || parentScope === binding2?.scope)) {
86529
+ graph.edges.get(name)?.add(path1.node.property.name);
86530
+ }
86531
+ }
86404
86532
  }
86405
86533
  }, path2.scope, path2);
86406
86534
  }
86407
86535
  }
86408
86536
  }
86537
+ },
86538
+ ObjectMethod(path2) {
86539
+ if (path2.node.key.type === "Identifier" && graph.nodes.has(path2.node.key.name)) {
86540
+ const name = path2.node.key.name;
86541
+ path2.traverse({
86542
+ Identifier(path1) {
86543
+ if (graph.nodes.has(path1.node.name) && path1.node.name !== name) {
86544
+ graph.edges.get(name)?.add(path1.node.name);
86545
+ }
86546
+ },
86547
+ MemberExpression(path1) {
86548
+ if (path1.node.object.type === "Identifier" && spread.includes(path1.node.object.name)) {
86549
+ if (spread.includes(path1.node.object.name) && path1.node.property.type === "Identifier" && path1.node.property.name !== name) {
86550
+ graph.edges.get(name)?.add(path1.node.property.name);
86551
+ }
86552
+ }
86553
+ }
86554
+ });
86555
+ }
86409
86556
  }
86410
86557
  }, parentScope, parentPath);
86411
- return graph;
86558
+ return {
86559
+ graph,
86560
+ nodeCollection
86561
+ };
86412
86562
  }
86413
86563
  function analyze2(content) {
86414
86564
  const ast = parse_1$1(content, {
@@ -86417,7 +86567,8 @@ function analyze2(content) {
86417
86567
  "typescript"
86418
86568
  ]
86419
86569
  });
86420
- return processSetup(ast);
86570
+ const { graph, nodeCollection } = processSetup(ast);
86571
+ return nodeCollection.map(graph);
86421
86572
  }
86422
86573
 
86423
86574
  // src/analyze/options.ts
@@ -86433,6 +86584,7 @@ function analyze3(content) {
86433
86584
  "typescript"
86434
86585
  ]
86435
86586
  });
86587
+ const nodeCollection = new NodeCollection();
86436
86588
  const graph = {
86437
86589
  nodes: /* @__PURE__ */ new Set(),
86438
86590
  edges: /* @__PURE__ */ new Map()
@@ -86449,6 +86601,9 @@ function analyze3(content) {
86449
86601
  if (prop.key.type === "Identifier") {
86450
86602
  const name = prop.key.name;
86451
86603
  graph.nodes.add(name);
86604
+ nodeCollection.addNode(name, prop, {
86605
+ isComputed: true
86606
+ });
86452
86607
  if (!graph.edges.get(name)) {
86453
86608
  graph.edges.set(name, /* @__PURE__ */ new Set());
86454
86609
  }
@@ -86465,6 +86620,7 @@ function analyze3(content) {
86465
86620
  if (prop.key.type === "Identifier") {
86466
86621
  const name = prop.key.name;
86467
86622
  graph.nodes.add(name);
86623
+ nodeCollection.addNode(name, prop);
86468
86624
  if (!graph.edges.get(name)) {
86469
86625
  graph.edges.set(name, /* @__PURE__ */ new Set());
86470
86626
  }
@@ -86479,10 +86635,31 @@ function analyze3(content) {
86479
86635
  if (path2.node.declaration.type === "ObjectExpression" && path1.parent === path2.node.declaration || path2.node.declaration.type === "CallExpression" && path1.parent === path2.node.declaration.arguments[0]) {
86480
86636
  if (path1.node.key.type === "Identifier" && path1.node.key.name === "setup") {
86481
86637
  const setupNode = path1.node;
86638
+ const spread = [];
86639
+ traverse3(setupNode, {
86640
+ ReturnStatement(path22) {
86641
+ if (path22.node.argument?.type === "ObjectExpression") {
86642
+ const returnNode = path22.node.argument;
86643
+ traverse3(returnNode, {
86644
+ SpreadElement(path3) {
86645
+ if (path3.node.argument.type === "CallExpression" && path3.node.argument.callee.type === "Identifier" && path3.node.argument.callee.name === "toRefs" && path3.node.argument.arguments[0].type === "Identifier") {
86646
+ spread.push(path3.node.argument.arguments[0].name);
86647
+ } else if (path3.node.argument.type === "Identifier") {
86648
+ spread.push(path3.node.argument.name);
86649
+ }
86650
+ }
86651
+ }, path22.scope, path22);
86652
+ }
86653
+ }
86654
+ }, path1.scope, path1);
86482
86655
  const {
86483
- nodes: tempNodes,
86484
- edges: tempEdges
86485
- } = processSetup(setupNode, path1.scope, setupNode);
86656
+ graph: {
86657
+ nodes: tempNodes,
86658
+ edges: tempEdges,
86659
+ spread: tempSpread
86660
+ },
86661
+ nodeCollection: tempNodeCollection
86662
+ } = processSetup(setupNode, path1.scope, setupNode, spread);
86486
86663
  traverse3(setupNode, {
86487
86664
  ReturnStatement(path22) {
86488
86665
  if (path22.node.argument?.type === "ObjectExpression") {
@@ -86495,6 +86672,7 @@ function analyze3(content) {
86495
86672
  const valName = path3.node.value.type === "Identifier" ? path3.node.value.name : "";
86496
86673
  if (valName && tempNodes.has(valName)) {
86497
86674
  graph.nodes.add(name);
86675
+ nodeCollection.addTypedNode(name, tempNodeCollection.nodes.get(valName));
86498
86676
  if (!graph.edges.get(name)) {
86499
86677
  graph.edges.set(name, /* @__PURE__ */ new Set());
86500
86678
  tempEdges.get(valName)?.forEach((edge) => {
@@ -86504,6 +86682,31 @@ function analyze3(content) {
86504
86682
  }
86505
86683
  }
86506
86684
  }
86685
+ },
86686
+ SpreadElement(path3) {
86687
+ if (path3.node.argument.type === "CallExpression" && path3.node.argument.callee.type === "Identifier" && path3.node.argument.callee.name === "toRefs" && path3.node.argument.arguments[0].type === "Identifier" && tempSpread.get(path3.node.argument.arguments[0].name)) {
86688
+ tempSpread.get(path3.node.argument.arguments[0].name)?.forEach((name) => {
86689
+ graph.nodes.add(name);
86690
+ nodeCollection.addTypedNode(name, tempNodeCollection.nodes.get(name));
86691
+ if (!graph.edges.get(name)) {
86692
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86693
+ tempEdges.get(name)?.forEach((edge) => {
86694
+ graph.edges.get(name)?.add(edge);
86695
+ });
86696
+ }
86697
+ });
86698
+ } else if (path3.node.argument.type === "Identifier" && tempSpread.get(path3.node.argument.name)) {
86699
+ tempSpread.get(path3.node.argument.name)?.forEach((name) => {
86700
+ graph.nodes.add(name);
86701
+ nodeCollection.addTypedNode(name, tempNodeCollection.nodes.get(name));
86702
+ if (!graph.edges.get(name)) {
86703
+ graph.edges.set(name, /* @__PURE__ */ new Set());
86704
+ tempEdges.get(name)?.forEach((edge) => {
86705
+ graph.edges.get(name)?.add(edge);
86706
+ });
86707
+ }
86708
+ });
86709
+ }
86507
86710
  }
86508
86711
  }, path22.scope, path22);
86509
86712
  } else {
@@ -86523,6 +86726,7 @@ function analyze3(content) {
86523
86726
  if (prop.key.type === "Identifier") {
86524
86727
  const name = prop.key.name;
86525
86728
  graph.nodes.add(name);
86729
+ nodeCollection.addNode(name, prop);
86526
86730
  if (!graph.edges.get(name)) {
86527
86731
  graph.edges.set(name, /* @__PURE__ */ new Set());
86528
86732
  }
@@ -86601,7 +86805,7 @@ function analyze3(content) {
86601
86805
  }
86602
86806
  }
86603
86807
  });
86604
- return graph;
86808
+ return nodeCollection.map(graph);
86605
86809
  }
86606
86810
 
86607
86811
  // src/vis.ts
@@ -86610,16 +86814,19 @@ function getVisData(graph, usedNodes) {
86610
86814
  const edges = [];
86611
86815
  graph.nodes.forEach((node2) => {
86612
86816
  nodes.push({
86613
- id: node2,
86614
- label: node2,
86615
- group: usedNodes.has(node2) ? "used" : "normal"
86817
+ id: node2.label,
86818
+ label: node2.label,
86819
+ shape: node2.type === "var" ? "dot" : "diamond",
86820
+ group: usedNodes.has(node2.label) ? "used" : "normal"
86616
86821
  });
86617
86822
  });
86618
86823
  graph.edges.forEach((edge, key) => {
86619
86824
  edge.forEach((to) => {
86825
+ if (!to)
86826
+ return;
86620
86827
  edges.push({
86621
- from: key,
86622
- to,
86828
+ from: key.label,
86829
+ to: to.label,
86623
86830
  arrows: {
86624
86831
  to: {
86625
86832
  enabled: true,