silgi 0.8.24 → 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 +41 -19
- 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);
|
|
@@ -1073,28 +1079,30 @@ function createDependencyGraph(modules) {
|
|
|
1073
1079
|
return { graph, inDegree };
|
|
1074
1080
|
}
|
|
1075
1081
|
function findCyclicDependencies(graph) {
|
|
1076
|
-
const visited = /* @__PURE__ */ new
|
|
1077
|
-
const recursionStack = /* @__PURE__ */ new Set();
|
|
1082
|
+
const visited = /* @__PURE__ */ new Map();
|
|
1078
1083
|
const cycles = [];
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
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
|
+
}
|
|
1083
1093
|
return;
|
|
1084
1094
|
}
|
|
1085
|
-
|
|
1086
|
-
return;
|
|
1087
|
-
visited.add(node);
|
|
1088
|
-
recursionStack.add(node);
|
|
1095
|
+
visited.set(node, false);
|
|
1089
1096
|
path.push(node);
|
|
1090
1097
|
for (const neighbor of graph.get(node) || []) {
|
|
1091
|
-
|
|
1098
|
+
visit(neighbor);
|
|
1092
1099
|
}
|
|
1093
|
-
|
|
1100
|
+
path.pop();
|
|
1101
|
+
visited.set(node, true);
|
|
1094
1102
|
}
|
|
1095
1103
|
for (const node of graph.keys()) {
|
|
1096
1104
|
if (!visited.has(node)) {
|
|
1097
|
-
|
|
1105
|
+
visit(node);
|
|
1098
1106
|
}
|
|
1099
1107
|
}
|
|
1100
1108
|
return cycles;
|
|
@@ -1103,25 +1111,39 @@ function topologicalSort(graphData) {
|
|
|
1103
1111
|
const { graph, inDegree } = graphData;
|
|
1104
1112
|
const order = [];
|
|
1105
1113
|
const queue = [];
|
|
1114
|
+
logger$1.debug("\nDependency Analysis:");
|
|
1115
|
+
logger$1.debug("Initial in-degrees:", Object.fromEntries(inDegree));
|
|
1106
1116
|
for (const [node, degree] of inDegree.entries()) {
|
|
1107
|
-
if (degree === 0)
|
|
1117
|
+
if (degree === 0) {
|
|
1108
1118
|
queue.push(node);
|
|
1119
|
+
logger$1.debug(`Starting with zero-dependency module: ${node}`);
|
|
1120
|
+
}
|
|
1109
1121
|
}
|
|
1110
1122
|
while (queue.length > 0) {
|
|
1111
1123
|
const node = queue.shift();
|
|
1112
1124
|
order.push(node);
|
|
1125
|
+
logger$1.debug(`Processing module: ${node}`);
|
|
1113
1126
|
for (const neighbor of graph.get(node) || []) {
|
|
1114
|
-
|
|
1115
|
-
|
|
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) {
|
|
1116
1131
|
queue.push(neighbor);
|
|
1132
|
+
logger$1.debug(` Added ${neighbor} to processing queue`);
|
|
1133
|
+
}
|
|
1117
1134
|
}
|
|
1118
1135
|
}
|
|
1119
1136
|
if (order.length !== graph.size) {
|
|
1120
1137
|
const cycles = findCyclicDependencies(graph);
|
|
1121
|
-
|
|
1122
|
-
|
|
1138
|
+
if (cycles.length > 0) {
|
|
1139
|
+
const cycleStr = cycles.map((cycle) => ` ${cycle.join(" -> ")}`).join("\n");
|
|
1140
|
+
throw new Error(`Circular dependencies detected:
|
|
1123
1141
|
${cycleStr}`);
|
|
1142
|
+
} else {
|
|
1143
|
+
throw new Error("Unable to resolve dependencies - possible circular reference");
|
|
1144
|
+
}
|
|
1124
1145
|
}
|
|
1146
|
+
logger$1.debug("\nFinal module order:", order.join(" -> "));
|
|
1125
1147
|
return order;
|
|
1126
1148
|
}
|
|
1127
1149
|
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED