vue-hook-optimizer 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -86886,6 +86886,15 @@ function noIndegreeFilter(graph) {
|
|
86886
86886
|
});
|
86887
86887
|
return nodes.filter((node2) => indegree.get(node2) === 0);
|
86888
86888
|
}
|
86889
|
+
function noOutdegreeFilter(graph) {
|
86890
|
+
const zeroOutdegreeNodes = [];
|
86891
|
+
for (let [node2, edges] of graph.entries()) {
|
86892
|
+
if (edges.size === 0) {
|
86893
|
+
zeroOutdegreeNodes.push(node2);
|
86894
|
+
}
|
86895
|
+
}
|
86896
|
+
return zeroOutdegreeNodes;
|
86897
|
+
}
|
86889
86898
|
function removeVariable(graph, targets) {
|
86890
86899
|
const newTarget = /* @__PURE__ */ new Set();
|
86891
86900
|
targets.forEach((target) => {
|
@@ -86911,6 +86920,64 @@ function onlyFunctions(graph) {
|
|
86911
86920
|
});
|
86912
86921
|
return result2;
|
86913
86922
|
}
|
86923
|
+
function findLinearPaths(graph) {
|
86924
|
+
let linearPaths = [];
|
86925
|
+
let visitedNodes = /* @__PURE__ */ new Set();
|
86926
|
+
for (let [node2, edges] of graph.entries()) {
|
86927
|
+
if (edges.size === 1 && !visitedNodes.has(node2)) {
|
86928
|
+
let path2 = [node2];
|
86929
|
+
let nextNode = Array.from(edges)[0];
|
86930
|
+
visitedNodes.add(node2);
|
86931
|
+
while (graph.get(nextNode)?.size === 1) {
|
86932
|
+
path2.push(nextNode);
|
86933
|
+
visitedNodes.add(nextNode);
|
86934
|
+
nextNode = Array.from(graph.get(nextNode))[0];
|
86935
|
+
}
|
86936
|
+
if (path2.length > 1) {
|
86937
|
+
linearPaths.push(path2);
|
86938
|
+
}
|
86939
|
+
}
|
86940
|
+
}
|
86941
|
+
return linearPaths;
|
86942
|
+
}
|
86943
|
+
function findArticulationPoints(graph) {
|
86944
|
+
const noIndegreeNodes = noIndegreeFilter(graph);
|
86945
|
+
let time = 0;
|
86946
|
+
const low = /* @__PURE__ */ new Map();
|
86947
|
+
const disc = /* @__PURE__ */ new Map();
|
86948
|
+
const parent = /* @__PURE__ */ new Map();
|
86949
|
+
const ap = /* @__PURE__ */ new Set();
|
86950
|
+
const visited = /* @__PURE__ */ new Set();
|
86951
|
+
function APUtil(graph2, node2) {
|
86952
|
+
let children = 0;
|
86953
|
+
disc.set(node2, time);
|
86954
|
+
low.set(node2, time);
|
86955
|
+
time++;
|
86956
|
+
visited.add(node2);
|
86957
|
+
for (let neighbor of graph2.get(node2) || []) {
|
86958
|
+
if (!visited.has(neighbor)) {
|
86959
|
+
children++;
|
86960
|
+
parent.set(neighbor, node2);
|
86961
|
+
APUtil(graph2, neighbor);
|
86962
|
+
low.set(node2, Math.min(low.get(node2), low.get(neighbor)));
|
86963
|
+
if (parent.get(node2) === null && children > 1) {
|
86964
|
+
ap.add(node2);
|
86965
|
+
}
|
86966
|
+
if (parent.get(node2) !== null && low.get(neighbor) >= disc.get(node2)) {
|
86967
|
+
ap.add(node2);
|
86968
|
+
}
|
86969
|
+
} else if (neighbor !== parent.get(node2)) {
|
86970
|
+
low.set(node2, Math.min(low.get(node2), disc.get(neighbor)));
|
86971
|
+
}
|
86972
|
+
}
|
86973
|
+
}
|
86974
|
+
for (let node2 of graph.keys()) {
|
86975
|
+
if (!visited.has(node2) && !noIndegreeNodes.includes(node2)) {
|
86976
|
+
APUtil(graph, node2);
|
86977
|
+
}
|
86978
|
+
}
|
86979
|
+
return ap;
|
86980
|
+
}
|
86914
86981
|
|
86915
86982
|
// src/suggest/utils.ts
|
86916
86983
|
function hasCycle(graph) {
|
@@ -86968,6 +87035,26 @@ function gen(graph, usedNodes) {
|
|
86968
87035
|
message: `There is a loop call in nodes [${nodes.length > 10 ? nodes.slice(0, 10).map((node2) => node2.label).join(",") + "...(" + nodes.length + ")" : nodes.map((node2) => node2.label).join(",")}], perhaps you can refactor it.`
|
86969
87036
|
});
|
86970
87037
|
}
|
87038
|
+
const paths = findLinearPaths(onlyFunctions(g));
|
87039
|
+
paths.forEach((path2) => {
|
87040
|
+
suggestions.push({
|
87041
|
+
type: "warning" /* warning */,
|
87042
|
+
message: `Nodes [${path2.length > 10 ? path2.slice(0, 10).map((node2) => node2.label).join(",") + "...(" + path2.length + ")" : path2.map((node2) => node2.label).join(",")}] are have function chain calls, perhaps you can refactor it.`
|
87043
|
+
});
|
87044
|
+
});
|
87045
|
+
if (g.size > 5) {
|
87046
|
+
const ap = findArticulationPoints(onlyFunctions(g));
|
87047
|
+
const noIndegreeNodes2 = noIndegreeFilter(g);
|
87048
|
+
ap.forEach((node2) => {
|
87049
|
+
if (!noIndegreeNodes2.includes(node2)) {
|
87050
|
+
suggestions.push({
|
87051
|
+
type: "info" /* info */,
|
87052
|
+
// eslint-disable-next-line max-len
|
87053
|
+
message: `Node [${node2.label}] is an articulation point, perhaps you need to pay special attention to this node.`
|
87054
|
+
});
|
87055
|
+
}
|
87056
|
+
});
|
87057
|
+
}
|
86971
87058
|
});
|
86972
87059
|
const noIndegreeNodes = noIndegreeFilter(graph.edges);
|
86973
87060
|
noIndegreeNodes.forEach((node2) => {
|
@@ -86978,6 +87065,15 @@ function gen(graph, usedNodes) {
|
|
86978
87065
|
});
|
86979
87066
|
}
|
86980
87067
|
});
|
87068
|
+
const noOutdegreeNodes = noOutdegreeFilter(graph.edges);
|
87069
|
+
noOutdegreeNodes.forEach((node2) => {
|
87070
|
+
if (!usedNodes.has(node2.label)) {
|
87071
|
+
suggestions.push({
|
87072
|
+
type: "info" /* info */,
|
87073
|
+
message: `Node [${node2.label}] is not used, perhaps you can remove it.`
|
87074
|
+
});
|
87075
|
+
}
|
87076
|
+
});
|
86981
87077
|
return suggestions;
|
86982
87078
|
}
|
86983
87079
|
|