vue-hook-optimizer 0.0.58 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2024,6 +2024,9 @@ function findLinearPaths(graph) {
2024
2024
  const visitedNodes = /* @__PURE__ */ new Set();
2025
2025
  const nodeInDegrees = /* @__PURE__ */ new Map();
2026
2026
  for (const [node, edges] of graph.entries()) {
2027
+ if (!nodeInDegrees.has(node)) {
2028
+ nodeInDegrees.set(node, 0);
2029
+ }
2027
2030
  for (const edge of edges) {
2028
2031
  const inDegree = nodeInDegrees.get(edge) || 0;
2029
2032
  nodeInDegrees.set(edge, inDegree + 1);
@@ -2201,11 +2204,16 @@ function gen(graph, nodesUsedInTemplate, nodesUsedInStyle = /* @__PURE__ */ new
2201
2204
  }
2202
2205
  const paths = findLinearPaths(g);
2203
2206
  paths.forEach((path) => {
2204
- suggestions.push({
2205
- type: "warning" /* warning */,
2206
- message: `Nodes [${path.length > 10 ? `${path.slice(0, 10).map((node) => node.label).join(",")}...(${path.length})` : path.map((node) => node.label).join(",")}] are have function chain calls, perhaps you can refactor it.`,
2207
- nodeInfo: path
2208
- });
2207
+ const firstUsedNodeIndex = path.findIndex((node) => usedNodes.has(node.label));
2208
+ const reverseLastNotUsedNodeIndex = path.slice().reverse().findIndex((node) => !usedNodes.has(node.label));
2209
+ const lastNotUsedNodeIndex = reverseLastNotUsedNodeIndex !== -1 ? path.length - 1 - reverseLastNotUsedNodeIndex : -1;
2210
+ if (firstUsedNodeIndex > -1 && firstUsedNodeIndex < lastNotUsedNodeIndex) {
2211
+ suggestions.push({
2212
+ type: "warning" /* warning */,
2213
+ message: `Nodes [${path.length > 10 ? `${path.slice(0, 10).map((node) => node.label).join(",")}...(${path.length})` : path.map((node) => node.label).join(",")}] are have function chain calls, perhaps you can refactor it.`,
2214
+ nodeInfo: path
2215
+ });
2216
+ }
2209
2217
  });
2210
2218
  if (g.size > 5) {
2211
2219
  const ap = findArticulationPoints(g);