vue-hook-optimizer 0.0.57 → 0.0.58
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 +57 -11
 - package/dist/index.js.map +1 -1
 - package/dist/index.mjs +57 -11
 - package/dist/index.mjs.map +1 -1
 - package/package.json +2 -2
 
    
        package/dist/index.js
    CHANGED
    
    | 
         @@ -2022,23 +2022,69 @@ function noIndegreeFilter(graph) { 
     | 
|
| 
       2022 
2022 
     | 
    
         
             
            function findLinearPaths(graph) {
         
     | 
| 
       2023 
2023 
     | 
    
         
             
              const linearPaths = [];
         
     | 
| 
       2024 
2024 
     | 
    
         
             
              const visitedNodes = /* @__PURE__ */ new Set();
         
     | 
| 
      
 2025 
     | 
    
         
            +
              const nodeInDegrees = /* @__PURE__ */ new Map();
         
     | 
| 
       2025 
2026 
     | 
    
         
             
              for (const [node, edges] of graph.entries()) {
         
     | 
| 
       2026 
     | 
    
         
            -
                 
     | 
| 
       2027 
     | 
    
         
            -
                  const  
     | 
| 
       2028 
     | 
    
         
            -
                   
     | 
| 
       2029 
     | 
    
         
            -
             
     | 
| 
       2030 
     | 
    
         
            -
             
     | 
| 
       2031 
     | 
    
         
            -
             
     | 
| 
      
 2027 
     | 
    
         
            +
                for (const edge of edges) {
         
     | 
| 
      
 2028 
     | 
    
         
            +
                  const inDegree = nodeInDegrees.get(edge) || 0;
         
     | 
| 
      
 2029 
     | 
    
         
            +
                  nodeInDegrees.set(edge, inDegree + 1);
         
     | 
| 
      
 2030 
     | 
    
         
            +
                }
         
     | 
| 
      
 2031 
     | 
    
         
            +
              }
         
     | 
| 
      
 2032 
     | 
    
         
            +
              function dfs2(node, path) {
         
     | 
| 
      
 2033 
     | 
    
         
            +
                if (visitedNodes.has(node)) {
         
     | 
| 
      
 2034 
     | 
    
         
            +
                  return;
         
     | 
| 
      
 2035 
     | 
    
         
            +
                }
         
     | 
| 
      
 2036 
     | 
    
         
            +
                path.push(node);
         
     | 
| 
      
 2037 
     | 
    
         
            +
                visitedNodes.add(node);
         
     | 
| 
      
 2038 
     | 
    
         
            +
                const edges = graph.get(node) || /* @__PURE__ */ new Set();
         
     | 
| 
      
 2039 
     | 
    
         
            +
                if (edges.size === 0 || edges.size > 1) {
         
     | 
| 
      
 2040 
     | 
    
         
            +
                  if (path.length > 1) {
         
     | 
| 
      
 2041 
     | 
    
         
            +
                    addOrUpdatePath([...path]);
         
     | 
| 
      
 2042 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2043 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 2044 
     | 
    
         
            +
                  const nextNode = Array.from(edges)[0];
         
     | 
| 
      
 2045 
     | 
    
         
            +
                  const nextNodeInDegree = nodeInDegrees.get(nextNode) || 0;
         
     | 
| 
      
 2046 
     | 
    
         
            +
                  if (nextNodeInDegree === 1) {
         
     | 
| 
      
 2047 
     | 
    
         
            +
                    dfs2(nextNode, path);
         
     | 
| 
      
 2048 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2049 
     | 
    
         
            +
                }
         
     | 
| 
      
 2050 
     | 
    
         
            +
                path.pop();
         
     | 
| 
      
 2051 
     | 
    
         
            +
                visitedNodes.delete(node);
         
     | 
| 
      
 2052 
     | 
    
         
            +
              }
         
     | 
| 
      
 2053 
     | 
    
         
            +
              function addOrUpdatePath(newPath) {
         
     | 
| 
      
 2054 
     | 
    
         
            +
                let shouldAddNewPath = true;
         
     | 
| 
      
 2055 
     | 
    
         
            +
                for (let i = linearPaths.length - 1; i >= 0; i--) {
         
     | 
| 
      
 2056 
     | 
    
         
            +
                  const existingPath = linearPaths[i];
         
     | 
| 
      
 2057 
     | 
    
         
            +
                  if (isSubpath(existingPath, newPath)) {
         
     | 
| 
      
 2058 
     | 
    
         
            +
                    linearPaths.splice(i, 1);
         
     | 
| 
      
 2059 
     | 
    
         
            +
                  } else if (isSubpath(newPath, existingPath)) {
         
     | 
| 
      
 2060 
     | 
    
         
            +
                    shouldAddNewPath = false;
         
     | 
| 
      
 2061 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 2062 
     | 
    
         
            +
                  }
         
     | 
| 
      
 2063 
     | 
    
         
            +
                }
         
     | 
| 
      
 2064 
     | 
    
         
            +
                if (shouldAddNewPath && newPath.length > 2) {
         
     | 
| 
      
 2065 
     | 
    
         
            +
                  linearPaths.push(newPath);
         
     | 
| 
      
 2066 
     | 
    
         
            +
                }
         
     | 
| 
      
 2067 
     | 
    
         
            +
              }
         
     | 
| 
      
 2068 
     | 
    
         
            +
              function isSubpath(shortPath, longPath) {
         
     | 
| 
      
 2069 
     | 
    
         
            +
                if (shortPath.length >= longPath.length) {
         
     | 
| 
      
 2070 
     | 
    
         
            +
                  return false;
         
     | 
| 
      
 2071 
     | 
    
         
            +
                }
         
     | 
| 
      
 2072 
     | 
    
         
            +
                for (let i = 0; i <= longPath.length - shortPath.length; i++) {
         
     | 
| 
      
 2073 
     | 
    
         
            +
                  let isSub = true;
         
     | 
| 
      
 2074 
     | 
    
         
            +
                  for (let j = 0; j < shortPath.length; j++) {
         
     | 
| 
      
 2075 
     | 
    
         
            +
                    if (shortPath[j] !== longPath[i + j]) {
         
     | 
| 
      
 2076 
     | 
    
         
            +
                      isSub = false;
         
     | 
| 
       2032 
2077 
     | 
    
         
             
                      break;
         
     | 
| 
       2033 
2078 
     | 
    
         
             
                    }
         
     | 
| 
       2034 
     | 
    
         
            -
                    path.push(nextNode);
         
     | 
| 
       2035 
     | 
    
         
            -
                    visitedNodes.add(nextNode);
         
     | 
| 
       2036 
     | 
    
         
            -
                    nextNode = Array.from(graph.get(nextNode))[0];
         
     | 
| 
       2037 
2079 
     | 
    
         
             
                  }
         
     | 
| 
       2038 
     | 
    
         
            -
                  if ( 
     | 
| 
       2039 
     | 
    
         
            -
                     
     | 
| 
      
 2080 
     | 
    
         
            +
                  if (isSub) {
         
     | 
| 
      
 2081 
     | 
    
         
            +
                    return true;
         
     | 
| 
       2040 
2082 
     | 
    
         
             
                  }
         
     | 
| 
       2041 
2083 
     | 
    
         
             
                }
         
     | 
| 
      
 2084 
     | 
    
         
            +
                return false;
         
     | 
| 
      
 2085 
     | 
    
         
            +
              }
         
     | 
| 
      
 2086 
     | 
    
         
            +
              for (const node of graph.keys()) {
         
     | 
| 
      
 2087 
     | 
    
         
            +
                dfs2(node, []);
         
     | 
| 
       2042 
2088 
     | 
    
         
             
              }
         
     | 
| 
       2043 
2089 
     | 
    
         
             
              return linearPaths;
         
     | 
| 
       2044 
2090 
     | 
    
         
             
            }
         
     |