silgi 0.8.7 → 0.8.9

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.
@@ -1,4 +1,4 @@
1
- const version = "0.8.7";
1
+ const version = "0.8.9";
2
2
  const packageJson = {
3
3
  version: version};
4
4
 
@@ -1036,60 +1036,54 @@ async function scanModules$1(silgi) {
1036
1036
  const moduleMap = new Map(
1037
1037
  silgi.scanModules.map((m) => [m.meta?.configKey, m])
1038
1038
  );
1039
- const graph = createDependencyGraph(silgi.scanModules);
1040
- const sortedKeys = topologicalSort(graph);
1039
+ const graphData = createDependencyGraph(silgi.scanModules);
1040
+ const sortedKeys = topologicalSort(graphData);
1041
1041
  const modules = sortedKeys.map((key) => moduleMap.get(key)).filter((module) => Boolean(module));
1042
1042
  silgi.scanModules = modules;
1043
1043
  }
1044
1044
  function createDependencyGraph(modules) {
1045
1045
  const graph = /* @__PURE__ */ new Map();
1046
+ const inDegree = /* @__PURE__ */ new Map();
1046
1047
  modules.forEach((module) => {
1047
1048
  const key = module.meta?.configKey;
1048
1049
  if (key) {
1049
1050
  graph.set(key, /* @__PURE__ */ new Set());
1051
+ inDegree.set(key, 0);
1050
1052
  }
1051
1053
  });
1052
1054
  modules.forEach((module) => {
1053
1055
  const key = module.meta?.configKey;
1054
1056
  const deps = module.meta?.dependencies || [];
1055
1057
  if (key && deps.length > 0) {
1056
- const modulesDeps = graph.get(key) || /* @__PURE__ */ new Set();
1057
1058
  deps.forEach((dep) => {
1058
1059
  if (graph.has(dep)) {
1059
- modulesDeps.add(dep);
1060
+ graph.get(dep)?.add(key);
1061
+ inDegree.set(key, (inDegree.get(key) || 0) + 1);
1060
1062
  }
1061
1063
  });
1062
- graph.set(key, modulesDeps);
1063
1064
  }
1064
1065
  });
1065
- return graph;
1066
+ return { graph, inDegree };
1066
1067
  }
1067
- function topologicalSort(graph) {
1068
- const visited = /* @__PURE__ */ new Set();
1069
- const temp = /* @__PURE__ */ new Set();
1068
+ function topologicalSort(graphData) {
1069
+ const { graph, inDegree } = graphData;
1070
1070
  const order = [];
1071
- function visit(node) {
1072
- if (temp.has(node))
1073
- throw new Error(`Circular dependency detected: ${node}`);
1074
- if (visited.has(node))
1075
- return;
1076
- temp.add(node);
1077
- const deps = graph.get(node) || /* @__PURE__ */ new Set();
1078
- for (const dep of deps) {
1079
- visit(dep);
1080
- }
1081
- temp.delete(node);
1082
- visited.add(node);
1083
- order.unshift(node);
1071
+ const queue = [];
1072
+ for (const [node, degree] of inDegree.entries()) {
1073
+ if (degree === 0)
1074
+ queue.push(node);
1084
1075
  }
1085
- for (const [node, deps] of graph.entries()) {
1086
- if (deps.size === 0 && !visited.has(node))
1087
- visit(node);
1088
- }
1089
- for (const node of graph.keys()) {
1090
- if (!visited.has(node))
1091
- visit(node);
1076
+ while (queue.length > 0) {
1077
+ const node = queue.shift();
1078
+ order.push(node);
1079
+ for (const neighbor of graph.get(node) || []) {
1080
+ inDegree.set(neighbor, (inDegree.get(neighbor) || 0) - 1);
1081
+ if (inDegree.get(neighbor) === 0)
1082
+ queue.push(neighbor);
1083
+ }
1092
1084
  }
1085
+ if (order.length !== graph.size)
1086
+ throw new Error("Circular dependency detected");
1093
1087
  return order;
1094
1088
  }
1095
1089
 
@@ -1,3 +1,3 @@
1
- const version = "0.8.7";
1
+ const version = "0.8.9";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "0.8.7";
1
+ const version = "0.8.9";
2
2
 
3
3
  export { version };
@@ -740,7 +740,7 @@ interface SilgiCLIOptions extends PresetOptions {
740
740
  /**
741
741
  * Silgi input config (silgi.config)
742
742
  */
743
- interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, DeepPartial<SilgiModuleOptions> {
743
+ interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, Partial<SilgiModuleOptions> {
744
744
  preset?: PresetNameInput;
745
745
  extends?: string | string[] | SilgiPreset;
746
746
  compatibilityDate?: CompatibilityDateSpec;
@@ -740,7 +740,7 @@ interface SilgiCLIOptions extends PresetOptions {
740
740
  /**
741
741
  * Silgi input config (silgi.config)
742
742
  */
743
- interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, DeepPartial<SilgiModuleOptions> {
743
+ interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, Partial<SilgiModuleOptions> {
744
744
  preset?: PresetNameInput;
745
745
  extends?: string | string[] | SilgiPreset;
746
746
  compatibilityDate?: CompatibilityDateSpec;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.8.7",
4
+ "version": "0.8.9",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {