silgi 0.8.23 → 0.8.25
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/_chunks/index.mjs +1 -1
- package/dist/cli/prepare.mjs +59 -6
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1049,6 +1049,7 @@ function createDependencyGraph(modules) {
|
|
|
1049
1049
|
if (key) {
|
|
1050
1050
|
graph.set(key, /* @__PURE__ */ new Set());
|
|
1051
1051
|
inDegree.set(key, 0);
|
|
1052
|
+
logger$1.debug(`Module registered: ${key}`);
|
|
1052
1053
|
}
|
|
1053
1054
|
});
|
|
1054
1055
|
modules.forEach((module) => {
|
|
@@ -1056,13 +1057,18 @@ function createDependencyGraph(modules) {
|
|
|
1056
1057
|
if (!key)
|
|
1057
1058
|
return;
|
|
1058
1059
|
const beforeDeps = module.meta?.beforeDependencies || [];
|
|
1060
|
+
const afterDeps = module.meta?.afterDependencies || [];
|
|
1061
|
+
logger$1.debug(`Module ${key}:`);
|
|
1062
|
+
if (beforeDeps.length)
|
|
1063
|
+
logger$1.debug(` beforeDeps: ${beforeDeps.join(", ")}`);
|
|
1064
|
+
if (afterDeps.length)
|
|
1065
|
+
logger$1.debug(` afterDeps: ${afterDeps.join(", ")}`);
|
|
1059
1066
|
beforeDeps.forEach((dep) => {
|
|
1060
1067
|
if (graph.has(dep)) {
|
|
1061
1068
|
graph.get(dep)?.add(key);
|
|
1062
1069
|
inDegree.set(key, (inDegree.get(key) || 0) + 1);
|
|
1063
1070
|
}
|
|
1064
1071
|
});
|
|
1065
|
-
const afterDeps = module.meta?.afterDependencies || [];
|
|
1066
1072
|
afterDeps.forEach((dep) => {
|
|
1067
1073
|
if (graph.has(key)) {
|
|
1068
1074
|
graph.get(key)?.add(dep);
|
|
@@ -1072,25 +1078,72 @@ function createDependencyGraph(modules) {
|
|
|
1072
1078
|
});
|
|
1073
1079
|
return { graph, inDegree };
|
|
1074
1080
|
}
|
|
1081
|
+
function findCyclicDependencies(graph) {
|
|
1082
|
+
const visited = /* @__PURE__ */ new Map();
|
|
1083
|
+
const cycles = [];
|
|
1084
|
+
const path = [];
|
|
1085
|
+
function visit(node) {
|
|
1086
|
+
if (visited.has(node)) {
|
|
1087
|
+
if (visited.get(node) === false) {
|
|
1088
|
+
const cycleStart = path.indexOf(node);
|
|
1089
|
+
if (cycleStart !== -1) {
|
|
1090
|
+
cycles.push([...path.slice(cycleStart), node]);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
visited.set(node, false);
|
|
1096
|
+
path.push(node);
|
|
1097
|
+
for (const neighbor of graph.get(node) || []) {
|
|
1098
|
+
visit(neighbor);
|
|
1099
|
+
}
|
|
1100
|
+
path.pop();
|
|
1101
|
+
visited.set(node, true);
|
|
1102
|
+
}
|
|
1103
|
+
for (const node of graph.keys()) {
|
|
1104
|
+
if (!visited.has(node)) {
|
|
1105
|
+
visit(node);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return cycles;
|
|
1109
|
+
}
|
|
1075
1110
|
function topologicalSort(graphData) {
|
|
1076
1111
|
const { graph, inDegree } = graphData;
|
|
1077
1112
|
const order = [];
|
|
1078
1113
|
const queue = [];
|
|
1114
|
+
logger$1.debug("\nDependency Analysis:");
|
|
1115
|
+
logger$1.debug("Initial in-degrees:", Object.fromEntries(inDegree));
|
|
1079
1116
|
for (const [node, degree] of inDegree.entries()) {
|
|
1080
|
-
if (degree === 0)
|
|
1117
|
+
if (degree === 0) {
|
|
1081
1118
|
queue.push(node);
|
|
1119
|
+
logger$1.debug(`Starting with zero-dependency module: ${node}`);
|
|
1120
|
+
}
|
|
1082
1121
|
}
|
|
1083
1122
|
while (queue.length > 0) {
|
|
1084
1123
|
const node = queue.shift();
|
|
1085
1124
|
order.push(node);
|
|
1125
|
+
logger$1.debug(`Processing module: ${node}`);
|
|
1086
1126
|
for (const neighbor of graph.get(node) || []) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1127
|
+
const newDegree = (inDegree.get(neighbor) || 0) - 1;
|
|
1128
|
+
inDegree.set(neighbor, newDegree);
|
|
1129
|
+
logger$1.debug(` Reduced in-degree of ${neighbor} to ${newDegree}`);
|
|
1130
|
+
if (newDegree === 0) {
|
|
1089
1131
|
queue.push(neighbor);
|
|
1132
|
+
logger$1.debug(` Added ${neighbor} to processing queue`);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (order.length !== graph.size) {
|
|
1137
|
+
const cycles = findCyclicDependencies(graph);
|
|
1138
|
+
if (cycles.length > 0) {
|
|
1139
|
+
const cycleStr = cycles.map((cycle) => ` ${cycle.join(" -> ")}`).join("\n");
|
|
1140
|
+
throw new Error(`Circular dependencies detected:
|
|
1141
|
+
${cycleStr}`);
|
|
1142
|
+
} else {
|
|
1143
|
+
throw new Error("Unable to resolve dependencies - possible circular reference");
|
|
1090
1144
|
}
|
|
1091
1145
|
}
|
|
1092
|
-
|
|
1093
|
-
throw new Error("Circular dependency detected");
|
|
1146
|
+
logger$1.debug("\nFinal module order:", order.join(" -> "));
|
|
1094
1147
|
return order;
|
|
1095
1148
|
}
|
|
1096
1149
|
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED