@yalehwang/archguard 0.1.6 β†’ 0.1.8

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.
Files changed (215) hide show
  1. package/README.md +90 -58
  2. package/dist/cli/analyze/normalize-to-diagrams.d.ts +5 -0
  3. package/dist/cli/analyze/normalize-to-diagrams.d.ts.map +1 -0
  4. package/dist/cli/analyze/normalize-to-diagrams.js +94 -0
  5. package/dist/cli/analyze/normalize-to-diagrams.js.map +1 -0
  6. package/dist/cli/analyze/run-analysis.d.ts +20 -0
  7. package/dist/cli/analyze/run-analysis.d.ts.map +1 -0
  8. package/dist/cli/analyze/run-analysis.js +150 -0
  9. package/dist/cli/analyze/run-analysis.js.map +1 -0
  10. package/dist/cli/cache/arch-json-disk-cache.d.ts.map +1 -1
  11. package/dist/cli/cache/arch-json-disk-cache.js +2 -1
  12. package/dist/cli/cache/arch-json-disk-cache.js.map +1 -1
  13. package/dist/cli/cache/diagram-manifest.d.ts +13 -0
  14. package/dist/cli/cache/diagram-manifest.d.ts.map +1 -0
  15. package/dist/cli/cache/diagram-manifest.js +60 -0
  16. package/dist/cli/cache/diagram-manifest.js.map +1 -0
  17. package/dist/cli/cache/render-hash-cache.d.ts +13 -0
  18. package/dist/cli/cache/render-hash-cache.d.ts.map +1 -0
  19. package/dist/cli/cache/render-hash-cache.js +39 -0
  20. package/dist/cli/cache/render-hash-cache.js.map +1 -0
  21. package/dist/cli/commands/analyze.d.ts +1 -4
  22. package/dist/cli/commands/analyze.d.ts.map +1 -1
  23. package/dist/cli/commands/analyze.js +26 -143
  24. package/dist/cli/commands/analyze.js.map +1 -1
  25. package/dist/cli/commands/cache.d.ts.map +1 -1
  26. package/dist/cli/commands/cache.js +7 -0
  27. package/dist/cli/commands/cache.js.map +1 -1
  28. package/dist/cli/commands/mcp.d.ts +3 -0
  29. package/dist/cli/commands/mcp.d.ts.map +1 -0
  30. package/dist/cli/commands/mcp.js +17 -0
  31. package/dist/cli/commands/mcp.js.map +1 -0
  32. package/dist/cli/commands/query.d.ts +3 -0
  33. package/dist/cli/commands/query.d.ts.map +1 -0
  34. package/dist/cli/commands/query.js +227 -0
  35. package/dist/cli/commands/query.js.map +1 -0
  36. package/dist/cli/index.d.ts.map +1 -1
  37. package/dist/cli/index.js +4 -0
  38. package/dist/cli/index.js.map +1 -1
  39. package/dist/cli/mcp/analyze-tool.d.ts +6 -0
  40. package/dist/cli/mcp/analyze-tool.d.ts.map +1 -0
  41. package/dist/cli/mcp/analyze-tool.js +112 -0
  42. package/dist/cli/mcp/analyze-tool.js.map +1 -0
  43. package/dist/cli/mcp/mcp-server.d.ts +6 -0
  44. package/dist/cli/mcp/mcp-server.d.ts.map +1 -0
  45. package/dist/cli/mcp/mcp-server.js +165 -0
  46. package/dist/cli/mcp/mcp-server.js.map +1 -0
  47. package/dist/cli/processors/arch-json-provider.d.ts +38 -0
  48. package/dist/cli/processors/arch-json-provider.d.ts.map +1 -0
  49. package/dist/cli/processors/arch-json-provider.js +295 -0
  50. package/dist/cli/processors/arch-json-provider.js.map +1 -0
  51. package/dist/cli/processors/diagram-output-router.d.ts +26 -0
  52. package/dist/cli/processors/diagram-output-router.d.ts.map +1 -0
  53. package/dist/cli/processors/diagram-output-router.js +235 -0
  54. package/dist/cli/processors/diagram-output-router.js.map +1 -0
  55. package/dist/cli/processors/diagram-processor.d.ts +11 -22
  56. package/dist/cli/processors/diagram-processor.d.ts.map +1 -1
  57. package/dist/cli/processors/diagram-processor.js +37 -455
  58. package/dist/cli/processors/diagram-processor.js.map +1 -1
  59. package/dist/cli/progress.d.ts +22 -1
  60. package/dist/cli/progress.d.ts.map +1 -1
  61. package/dist/cli/progress.js +24 -0
  62. package/dist/cli/progress.js.map +1 -1
  63. package/dist/cli/query/arch-index-builder.d.ts +4 -0
  64. package/dist/cli/query/arch-index-builder.d.ts.map +1 -0
  65. package/dist/cli/query/arch-index-builder.js +126 -0
  66. package/dist/cli/query/arch-index-builder.js.map +1 -0
  67. package/dist/cli/query/arch-index.d.ts +17 -0
  68. package/dist/cli/query/arch-index.d.ts.map +1 -0
  69. package/dist/cli/query/arch-index.js +2 -0
  70. package/dist/cli/query/arch-index.js.map +1 -0
  71. package/dist/cli/query/engine-loader.d.ts +7 -0
  72. package/dist/cli/query/engine-loader.d.ts.map +1 -0
  73. package/dist/cli/query/engine-loader.js +98 -0
  74. package/dist/cli/query/engine-loader.js.map +1 -0
  75. package/dist/cli/query/query-artifacts.d.ts +7 -0
  76. package/dist/cli/query/query-artifacts.d.ts.map +1 -0
  77. package/dist/cli/query/query-artifacts.js +78 -0
  78. package/dist/cli/query/query-artifacts.js.map +1 -0
  79. package/dist/cli/query/query-engine.d.ts +49 -0
  80. package/dist/cli/query/query-engine.d.ts.map +1 -0
  81. package/dist/cli/query/query-engine.js +137 -0
  82. package/dist/cli/query/query-engine.js.map +1 -0
  83. package/dist/cli/query/query-manifest.d.ts +24 -0
  84. package/dist/cli/query/query-manifest.d.ts.map +1 -0
  85. package/dist/cli/query/query-manifest.js +2 -0
  86. package/dist/cli/query/query-manifest.js.map +1 -0
  87. package/dist/cli/utils/canonicalize-arch-json.d.ts +3 -0
  88. package/dist/cli/utils/canonicalize-arch-json.d.ts.map +1 -0
  89. package/dist/cli/utils/canonicalize-arch-json.js +81 -0
  90. package/dist/cli/utils/canonicalize-arch-json.js.map +1 -0
  91. package/dist/cli/utils/diagram-index-generator.d.ts.map +1 -1
  92. package/dist/cli/utils/diagram-index-generator.js +0 -5
  93. package/dist/cli/utils/diagram-index-generator.js.map +1 -1
  94. package/dist/cli/utils/project-structure-detector.d.ts.map +1 -1
  95. package/dist/cli/utils/project-structure-detector.js +0 -10
  96. package/dist/cli/utils/project-structure-detector.js.map +1 -1
  97. package/dist/mermaid/renderer.d.ts.map +1 -1
  98. package/dist/mermaid/renderer.js +34 -0
  99. package/dist/mermaid/renderer.js.map +1 -1
  100. package/dist/plugins/golang/atlas/index.d.ts.map +1 -1
  101. package/dist/plugins/golang/atlas/index.js +3 -1
  102. package/dist/plugins/golang/atlas/index.js.map +1 -1
  103. package/dist/plugins/golang/atlas/types.d.ts +1 -0
  104. package/dist/plugins/golang/atlas/types.d.ts.map +1 -1
  105. package/dist/plugins/golang/index.d.ts.map +1 -1
  106. package/dist/plugins/golang/index.js +15 -6
  107. package/dist/plugins/golang/index.js.map +1 -1
  108. package/dist/plugins/golang/source-scope.d.ts +7 -0
  109. package/dist/plugins/golang/source-scope.d.ts.map +1 -0
  110. package/dist/plugins/golang/source-scope.js +83 -0
  111. package/dist/plugins/golang/source-scope.js.map +1 -0
  112. package/node_modules/node-addon-api/LICENSE.md +9 -0
  113. package/node_modules/node-addon-api/README.md +95 -0
  114. package/node_modules/node-addon-api/common.gypi +21 -0
  115. package/node_modules/node-addon-api/except.gypi +25 -0
  116. package/node_modules/node-addon-api/index.js +14 -0
  117. package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  118. package/node_modules/node-addon-api/napi-inl.h +7033 -0
  119. package/node_modules/node-addon-api/napi.h +3309 -0
  120. package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
  121. package/node_modules/node-addon-api/node_api.gyp +9 -0
  122. package/node_modules/node-addon-api/noexcept.gypi +26 -0
  123. package/node_modules/node-addon-api/nothing.c +0 -0
  124. package/node_modules/node-addon-api/package-support.json +21 -0
  125. package/node_modules/node-addon-api/package.json +480 -0
  126. package/node_modules/node-addon-api/tools/README.md +73 -0
  127. package/node_modules/node-addon-api/tools/check-napi.js +99 -0
  128. package/node_modules/node-addon-api/tools/clang-format.js +71 -0
  129. package/node_modules/node-addon-api/tools/conversion.js +301 -0
  130. package/node_modules/node-gyp-build/LICENSE +21 -0
  131. package/node_modules/node-gyp-build/README.md +58 -0
  132. package/node_modules/node-gyp-build/SECURITY.md +5 -0
  133. package/node_modules/node-gyp-build/bin.js +84 -0
  134. package/node_modules/node-gyp-build/build-test.js +19 -0
  135. package/node_modules/node-gyp-build/index.js +6 -0
  136. package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
  137. package/node_modules/node-gyp-build/optional.js +7 -0
  138. package/node_modules/node-gyp-build/package.json +43 -0
  139. package/node_modules/tree-sitter/LICENSE +21 -0
  140. package/node_modules/tree-sitter/README.md +128 -0
  141. package/node_modules/tree-sitter/binding.gyp +80 -0
  142. package/node_modules/tree-sitter/index.js +916 -0
  143. package/node_modules/tree-sitter/package.json +76 -0
  144. package/node_modules/tree-sitter/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  145. package/node_modules/tree-sitter/src/addon_data.h +47 -0
  146. package/node_modules/tree-sitter/src/binding.cc +35 -0
  147. package/node_modules/tree-sitter/src/conversions.cc +140 -0
  148. package/node_modules/tree-sitter/src/conversions.h +22 -0
  149. package/node_modules/tree-sitter/src/language.cc +106 -0
  150. package/node_modules/tree-sitter/src/language.h +17 -0
  151. package/node_modules/tree-sitter/src/logger.cc +70 -0
  152. package/node_modules/tree-sitter/src/logger.h +19 -0
  153. package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
  154. package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
  155. package/node_modules/tree-sitter/src/node.cc +1088 -0
  156. package/node_modules/tree-sitter/src/node.h +30 -0
  157. package/node_modules/tree-sitter/src/parser.cc +306 -0
  158. package/node_modules/tree-sitter/src/parser.h +35 -0
  159. package/node_modules/tree-sitter/src/query.cc +397 -0
  160. package/node_modules/tree-sitter/src/query.h +40 -0
  161. package/node_modules/tree-sitter/src/tree.cc +316 -0
  162. package/node_modules/tree-sitter/src/tree.h +45 -0
  163. package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
  164. package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
  165. package/node_modules/tree-sitter/tree-sitter.d.ts +1042 -0
  166. package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1478 -0
  167. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
  168. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
  169. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +291 -0
  170. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
  171. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
  172. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
  173. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +523 -0
  174. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
  175. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
  176. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +293 -0
  177. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +293 -0
  178. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
  179. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +483 -0
  180. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +54 -0
  181. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +12 -0
  182. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +875 -0
  183. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2293 -0
  184. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +286 -0
  185. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +48 -0
  186. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/portable/endian.h +239 -0
  187. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4350 -0
  188. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
  189. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
  190. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +911 -0
  191. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
  192. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1034 -0
  193. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +399 -0
  194. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +170 -0
  195. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
  196. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +717 -0
  197. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
  198. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/ts_assert.h +11 -0
  199. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
  200. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
  201. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
  202. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
  203. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
  204. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
  205. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
  206. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
  207. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
  208. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +75 -0
  209. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +24 -0
  210. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +113 -0
  211. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1314 -0
  212. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1935 -0
  213. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
  214. package/package.json +9 -2
  215. package/scripts/postinstall-tree-sitter.mjs +28 -0
@@ -1,12 +1,15 @@
1
1
  import type { ParseCache } from '../../parser/parse-cache.js';
2
2
  import type { DiagramConfig, GlobalConfig } from '../../types/config.js';
3
- import type { ArchJSON, ArchJSONMetrics } from '../../types/index.js';
4
- import type { ProgressReporter } from '../progress.js';
3
+ import type { ArchJSONMetrics } from '../../types/index.js';
4
+ import type { QuerySourceGroup } from '../query/query-manifest.js';
5
+ import type { ProgressReporterLike } from '../progress.js';
5
6
  import type { PluginRegistry } from '../../core/plugin-registry.js';
7
+ export { deriveSubModuleArchJSON } from './arch-json-provider.js';
8
+ export type InternalQueryScope = QuerySourceGroup;
6
9
  export interface DiagramProcessorOptions {
7
10
  diagrams: DiagramConfig[];
8
11
  globalConfig: GlobalConfig;
9
- progress: ProgressReporter;
12
+ progress: ProgressReporterLike;
10
13
  parseCache?: ParseCache;
11
14
  registry?: PluginRegistry;
12
15
  }
@@ -27,36 +30,22 @@ export interface DiagramResult {
27
30
  error?: string;
28
31
  metrics?: ArchJSONMetrics;
29
32
  }
30
- export declare function deriveSubModuleArchJSON(parent: ArchJSON, subPath: string, workspaceRoot?: string): ArchJSON;
31
33
  export declare class DiagramProcessor {
32
34
  private diagrams;
33
35
  private globalConfig;
34
36
  private progress;
35
- private fileDiscovery;
36
37
  private aggregator;
37
38
  private metricsCalculator;
38
39
  private parallelProgress?;
39
- private parseCache?;
40
- private registry?;
41
- private archJsonDiskCache;
40
+ private readonly provider;
41
+ private readonly router;
42
42
  constructor(options: DiagramProcessorOptions);
43
43
  processAll(): Promise<DiagramResult[]>;
44
44
  private groupDiagramsBySource;
45
- private hashSources;
46
- private cacheArchJson;
47
- private registerDeferred;
48
- private findParentCoverage;
49
- private archJsonCache;
50
- private archJsonPathIndex;
51
- private archJsonDeferred;
45
+ private queryScopes;
46
+ private registerQueryScope;
47
+ getQuerySourceGroups(): InternalQueryScope[];
52
48
  private processSourceGroup;
53
49
  private processDiagramWithArchJSON;
54
- private parseGoProject;
55
- private parseCppProject;
56
- private parseTsProject;
57
- private generateOutput;
58
- private generateAtlasOutput;
59
- private generateTsModuleGraphOutput;
60
- private generateCppPackageOutput;
61
50
  }
62
51
  //# sourceMappingURL=diagram-processor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagram-processor.d.ts","sourceRoot":"","sources":["../../../src/cli/processors/diagram-processor.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAA6B,MAAM,mBAAmB,CAAC;AAChG,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAYhE,MAAM,WAAW,uBAAuB;IAEtC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAE1B,YAAY,EAAE,YAAY,CAAC;IAE3B,QAAQ,EAAE,gBAAgB,CAAC;IAM3B,UAAU,CAAC,EAAE,UAAU,CAAC;IAMxB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAKD,MAAM,WAAW,aAAa;IAE5B,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,OAAO,CAAC;IAEjB,KAAK,CAAC,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IAEF,KAAK,CAAC,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,KAAK,CAAC,EAAE,MAAM,CAAC;IAMf,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAcD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GACrB,QAAQ,CAmGV;AAmBD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,gBAAgB,CAAC,CAA2B;IACpD,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,OAAO,EAAE,uBAAuB;IA6BtC,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IA6E5C,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,kBAAkB;IA+B1B,OAAO,CAAC,aAAa,CAA+B;IAGpD,OAAO,CAAC,iBAAiB,CAA6B;IAOtD,OAAO,CAAC,gBAAgB,CAAwE;YASlF,kBAAkB;YAsNlB,0BAA0B;YAmH1B,cAAc;YAwBd,eAAe;YA6Bf,cAAc;YA0Bd,cAAc;YA4Dd,mBAAmB;YA8GnB,2BAA2B;YAgE3B,wBAAwB;CAmDvC"}
1
+ {"version":3,"file":"diagram-processor.d.ts","sourceRoot":"","sources":["../../../src/cli/processors/diagram-processor.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAMlE,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAKlD,MAAM,WAAW,uBAAuB;IAEtC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAE1B,YAAY,EAAE,YAAY,CAAC;IAE3B,QAAQ,EAAE,oBAAoB,CAAC;IAM/B,UAAU,CAAC,EAAE,UAAU,CAAC;IAMxB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAKD,MAAM,WAAW,aAAa;IAE5B,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,OAAO,CAAC;IAEjB,KAAK,CAAC,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IAEF,KAAK,CAAC,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,KAAK,CAAC,EAAE,MAAM,CAAC;IAMf,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAmBD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,gBAAgB,CAAC,CAA2B;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;gBAEjC,OAAO,EAAE,uBAAuB;IA6BtC,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IA6E5C,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,WAAW,CAAyC;IAO5D,OAAO,CAAC,kBAAkB;IAiBnB,oBAAoB,IAAI,kBAAkB,EAAE;YAYrC,kBAAkB;YAiClB,0BAA0B;CAwGzC"}
@@ -1,91 +1,23 @@
1
- import { FileDiscoveryService } from '../utils/file-discovery-service.js';
2
- import { ParallelParser } from '../../parser/parallel-parser.js';
3
1
  import { ArchJSONAggregator } from '../../parser/archjson-aggregator.js';
4
2
  import { MetricsCalculator } from '../../parser/metrics-calculator.js';
5
3
  import { OutputPathResolver } from '../utils/output-path-resolver.js';
6
- import { MermaidDiagramGenerator } from '../../mermaid/diagram-generator.js';
7
4
  import { ParallelProgressReporter } from '../progress/parallel-progress.js';
8
5
  import { MermaidRenderWorkerPool } from '../../mermaid/render-worker-pool.js';
9
- import { ArchJsonDiskCache } from '../cache/arch-json-disk-cache.js';
10
- import fs from 'fs-extra';
6
+ import { ArchJsonProvider, hashSources } from './arch-json-provider.js';
7
+ import { DiagramOutputRouter } from './diagram-output-router.js';
11
8
  import pMap from 'p-map';
12
9
  import os from 'os';
13
- import { createHash } from 'crypto';
14
10
  import path from 'path';
15
- export function deriveSubModuleArchJSON(parent, subPath, workspaceRoot) {
16
- const normSub = subPath.replace(/\\/g, '/').replace(/\/$/, '');
17
- let relSub = null;
18
- if (workspaceRoot) {
19
- const normRoot = workspaceRoot.replace(/\\/g, '/').replace(/\/$/, '');
20
- if (normSub.startsWith(normRoot + '/')) {
21
- relSub = normSub.slice(normRoot.length + 1);
22
- }
23
- else if (normSub === normRoot) {
24
- relSub = '';
25
- }
26
- }
27
- const entities = parent.entities.filter((e) => {
28
- let fp = (e.filePath ?? '').replace(/\\/g, '/');
29
- if (!fp && e.name && e.id.endsWith('.' + e.name)) {
30
- fp = e.id.slice(0, e.id.length - e.name.length - 1).replace(/\\/g, '/');
31
- }
32
- if (e.sourceLocation?.file && (!fp || (!fp.includes('/') && !fp.includes('.')))) {
33
- fp = e.sourceLocation.file.replace(/\\/g, '/');
34
- }
35
- if (!fp)
36
- return false;
37
- if (fp.startsWith(normSub + '/') || fp === normSub)
38
- return true;
39
- if (relSub !== null) {
40
- if (relSub === '')
41
- return true;
42
- if (fp.startsWith(relSub + '/') || fp === relSub)
43
- return true;
44
- }
45
- return false;
46
- });
47
- const ids = new Set(entities.map((e) => e.id));
48
- const outgoingRelations = (parent.relations ?? []).filter((r) => ids.has(r.source));
49
- const crossModuleTargetIds = new Set(outgoingRelations.filter((r) => !ids.has(r.target)).map((r) => r.target));
50
- const stubEntities = parent.entities
51
- .filter((e) => crossModuleTargetIds.has(e.id))
52
- .map((e) => ({ ...e, members: [] }));
53
- const allModuleEntities = [...entities, ...stubEntities];
54
- const relations = outgoingRelations;
55
- let extensions = parent.extensions;
56
- const mg = parent.extensions?.tsAnalysis?.moduleGraph;
57
- if (mg) {
58
- const parts = normSub.split('/').filter(Boolean);
59
- const relPrefix = parts.length >= 2 ? parts.slice(-2).join('/') : (parts[parts.length - 1] ?? normSub);
60
- const filteredNodes = mg.nodes.filter((n) => n.id === relPrefix || n.id.startsWith(relPrefix + '/'));
61
- const filteredNodeIds = new Set(filteredNodes.map((n) => n.id));
62
- const filteredEdges = mg.edges.filter((e) => filteredNodeIds.has(e.from) && filteredNodeIds.has(e.to));
63
- const filteredCycles = (mg.cycles ?? []).filter((c) => c.modules.every((m) => filteredNodeIds.has(m)));
64
- extensions = {
65
- ...parent.extensions,
66
- tsAnalysis: {
67
- ...parent.extensions.tsAnalysis,
68
- moduleGraph: {
69
- nodes: filteredNodes,
70
- edges: filteredEdges,
71
- cycles: filteredCycles,
72
- },
73
- },
74
- };
75
- }
76
- return { ...parent, entities: allModuleEntities, relations, extensions };
77
- }
11
+ export { deriveSubModuleArchJSON } from './arch-json-provider.js';
78
12
  export class DiagramProcessor {
79
13
  diagrams;
80
14
  globalConfig;
81
15
  progress;
82
- fileDiscovery;
83
16
  aggregator;
84
17
  metricsCalculator;
85
18
  parallelProgress;
86
- parseCache;
87
- registry;
88
- archJsonDiskCache;
19
+ provider;
20
+ router;
89
21
  constructor(options) {
90
22
  if (options.diagrams.length === 0) {
91
23
  throw new Error('At least one diagram configuration is required');
@@ -93,14 +25,14 @@ export class DiagramProcessor {
93
25
  this.diagrams = options.diagrams;
94
26
  this.globalConfig = options.globalConfig;
95
27
  this.progress = options.progress;
96
- this.fileDiscovery = new FileDiscoveryService();
97
28
  this.aggregator = new ArchJSONAggregator();
98
29
  this.metricsCalculator = new MetricsCalculator();
99
- this.parseCache = options.parseCache;
100
- this.registry = options.registry;
101
- const diskCacheRoot = this.globalConfig.cache?.dir ?? path.join('.archguard', 'cache');
102
- const diskCacheDir = path.join(diskCacheRoot, 'archjson');
103
- this.archJsonDiskCache = new ArchJsonDiskCache(diskCacheDir);
30
+ this.provider = new ArchJsonProvider({
31
+ globalConfig: options.globalConfig,
32
+ parseCache: options.parseCache,
33
+ registry: options.registry,
34
+ });
35
+ this.router = new DiagramOutputRouter(options.globalConfig, options.progress);
104
36
  }
105
37
  async processAll() {
106
38
  const concurrency = this.globalConfig.concurrency || os.cpus().length;
@@ -136,7 +68,7 @@ export class DiagramProcessor {
136
68
  }, { concurrency: Math.min(concurrency, sourceGroups.size) });
137
69
  const results = groupResults.flat();
138
70
  if (process.env.ArchGuardDebug === 'true') {
139
- console.debug(`πŸ“Š Cache stats: ${this.archJsonCache.size} entries`);
71
+ console.debug(`πŸ“Š Cache stats: ${this.provider.cacheSize()} entries`);
140
72
  }
141
73
  return results;
142
74
  }
@@ -150,7 +82,7 @@ export class DiagramProcessor {
150
82
  groupDiagramsBySource() {
151
83
  const sourceGroups = new Map();
152
84
  for (const diagram of this.diagrams) {
153
- const key = this.hashSources(diagram.sources);
85
+ const key = hashSources(diagram.sources);
154
86
  if (!sourceGroups.has(key)) {
155
87
  sourceGroups.set(key, []);
156
88
  }
@@ -158,173 +90,37 @@ export class DiagramProcessor {
158
90
  }
159
91
  return sourceGroups;
160
92
  }
161
- hashSources(sources) {
162
- const normalized = sources
163
- .map((s) => s.replace(/\\/g, '/'))
164
- .sort()
165
- .join('|');
166
- return createHash('sha256').update(normalized).digest('hex').slice(0, 8);
167
- }
168
- cacheArchJson(sources, archJson) {
169
- const key = this.hashSources(sources);
170
- this.archJsonCache.set(key, archJson);
171
- for (const s of sources) {
172
- this.archJsonPathIndex.set(s.replace(/\\/g, '/'), key);
173
- }
174
- }
175
- registerDeferred(sources, parsePromise) {
176
- const key = this.hashSources(sources);
177
- const withCaching = parsePromise.then((result) => {
178
- this.cacheArchJson(sources, result);
179
- this.archJsonDeferred.delete(key);
180
- return result;
93
+ queryScopes = new Map();
94
+ registerQueryScope(sources, archJson, kind) {
95
+ if (!archJson.entities || archJson.entities.length === 0)
96
+ return;
97
+ const key = hashSources(sources);
98
+ if (this.queryScopes.has(key))
99
+ return;
100
+ const normalizedSources = sources.map((s) => path.resolve(s));
101
+ this.queryScopes.set(key, {
102
+ key,
103
+ sources: normalizedSources,
104
+ archJson,
105
+ kind,
181
106
  });
182
- this.archJsonDeferred.set(key, { promise: withCaching, sources });
183
- return withCaching;
184
107
  }
185
- findParentCoverage(sources) {
186
- const normSources = sources.map((s) => s.replace(/\\/g, '/'));
187
- for (const [indexedPath] of this.archJsonPathIndex) {
188
- if (normSources.every((s) => s.startsWith(indexedPath + '/') || s === indexedPath)) {
189
- return { deferred: null, normParentPath: indexedPath };
190
- }
191
- }
192
- for (const [, { promise, sources: parentSources }] of this.archJsonDeferred) {
193
- const normParentSources = parentSources.map((ps) => ps.replace(/\\/g, '/'));
194
- const matchedParent = normParentSources.find((ps) => normSources.every((s) => s.startsWith(ps + '/') || s === ps));
195
- if (matchedParent) {
196
- return { deferred: promise, normParentPath: matchedParent };
197
- }
198
- }
199
- return { deferred: null, normParentPath: null };
108
+ getQuerySourceGroups() {
109
+ return Array.from(this.queryScopes.values());
200
110
  }
201
- archJsonCache = new Map();
202
- archJsonPathIndex = new Map();
203
- archJsonDeferred = new Map();
204
- async processSourceGroup(sourceKey, diagrams, pool = null) {
205
- if (!this.parallelProgress && diagrams.length === 1) {
206
- this.progress.start(`Processing diagram: ${diagrams[0].name}`);
207
- }
111
+ async processSourceGroup(_sourceKey, diagrams, pool = null) {
208
112
  try {
209
- const firstDiagram = diagrams[0];
210
- if (firstDiagram.language === 'go') {
211
- const rawArchJSON = await this.registerDeferred(firstDiagram.sources, this.parseGoProject(firstDiagram));
212
- const results = await pMap(diagrams, async (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
213
- return results;
214
- }
215
- if (firstDiagram.language === 'cpp') {
216
- const { deferred, normParentPath } = this.findParentCoverage(firstDiagram.sources);
217
- let rawArchJSON;
218
- if (deferred) {
219
- const parentArchJSON = await deferred;
220
- rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, firstDiagram.sources[0], normParentPath ?? undefined);
221
- }
222
- else if (normParentPath) {
223
- const parentCacheKey = this.archJsonPathIndex.get(normParentPath);
224
- const parentArchJSON = this.archJsonCache.get(parentCacheKey);
225
- rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, firstDiagram.sources[0], normParentPath);
226
- }
227
- else {
228
- rawArchJSON = await this.registerDeferred(firstDiagram.sources, this.parseCppProject(firstDiagram));
229
- }
230
- const results = await pMap(diagrams, async (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
231
- return results;
232
- }
233
113
  const needsModuleGraph = diagrams.some((d) => d.level === 'package');
234
- if (needsModuleGraph && (!firstDiagram.language || firstDiagram.language === 'typescript')) {
235
- const tsFiles = await this.fileDiscovery.discoverFiles({
236
- sources: firstDiagram.sources,
237
- exclude: firstDiagram.exclude || this.globalConfig.exclude,
238
- skipMissing: false,
239
- });
240
- const diskCacheEnabled = this.globalConfig.cache?.enabled !== false;
241
- const diskKey = diskCacheEnabled && tsFiles.length > 0
242
- ? await this.archJsonDiskCache.computeKey(tsFiles)
243
- : null;
244
- let cachedArchJSON = null;
245
- if (diskKey) {
246
- cachedArchJSON = await this.archJsonDiskCache.get(diskKey);
247
- if (cachedArchJSON && process.env.ArchGuardDebug === 'true') {
248
- console.debug(`πŸ’Ύ Disk cache hit for ts-morph path: ${firstDiagram.sources.join(', ')}`);
249
- }
250
- }
251
- const rawArchJSON = cachedArchJSON
252
- ? cachedArchJSON
253
- : await this.registerDeferred(firstDiagram.sources, this.parseTsProject(firstDiagram).then(async (result) => {
254
- if (diskKey)
255
- await this.archJsonDiskCache.set(diskKey, result);
256
- return result;
257
- }));
258
- const results = await pMap(diagrams, async (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
259
- return results;
260
- }
261
- const files = await this.fileDiscovery.discoverFiles({
262
- sources: diagrams[0].sources,
263
- exclude: diagrams[0].exclude || this.globalConfig.exclude,
264
- skipMissing: false,
114
+ const firstDiagram = diagrams[0];
115
+ const { archJson: rawArchJSON, kind } = await this.provider.get(firstDiagram, {
116
+ needsModuleGraph,
265
117
  });
266
- if (files.length === 0) {
267
- throw new Error(`No TypeScript files found in sources: ${diagrams[0].sources.join(', ')}`);
268
- }
269
- let rawArchJSON = this.archJsonCache.get(sourceKey);
270
- if (!rawArchJSON) {
271
- const { deferred, normParentPath } = this.findParentCoverage(diagrams[0].sources);
272
- if (deferred) {
273
- const parentArchJSON = await deferred;
274
- rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, diagrams[0].sources[0], normParentPath ?? undefined);
275
- if (process.env.ArchGuardDebug === 'true') {
276
- console.debug(`πŸ”— Awaited parent and derived ArchJSON for ${diagrams[0].sources.join(', ')} from ${normParentPath}`);
277
- }
278
- }
279
- else if (normParentPath) {
280
- const parentCacheKey = this.archJsonPathIndex.get(normParentPath);
281
- const parentArchJSON = this.archJsonCache.get(parentCacheKey);
282
- rawArchJSON = deriveSubModuleArchJSON(parentArchJSON, diagrams[0].sources[0], normParentPath);
283
- if (process.env.ArchGuardDebug === 'true') {
284
- console.debug(`πŸ”— Derived ArchJSON for ${diagrams[0].sources.join(', ')} from ${normParentPath}`);
285
- }
286
- }
287
- else {
288
- if (process.env.ArchGuardDebug === 'true') {
289
- console.debug(`πŸ” Cache miss for ${sourceKey}: ${diagrams[0].sources.join(', ')}`);
290
- }
291
- const diskCacheEnabled2 = this.globalConfig.cache?.enabled !== false;
292
- const diskKey = diskCacheEnabled2 ? await this.archJsonDiskCache.computeKey(files) : null;
293
- const diskCached = diskKey ? await this.archJsonDiskCache.get(diskKey) : null;
294
- if (diskCached) {
295
- rawArchJSON = diskCached;
296
- if (process.env.ArchGuardDebug === 'true') {
297
- console.debug(`πŸ’Ύ Disk cache hit for ParallelParser path: ${diagrams[0].sources.join(', ')}`);
298
- }
299
- }
300
- else {
301
- const parser = new ParallelParser({
302
- concurrency: this.globalConfig.concurrency,
303
- continueOnError: true,
304
- parseCache: this.parseCache,
305
- });
306
- rawArchJSON = await parser.parseFiles(files);
307
- if (diskKey)
308
- await this.archJsonDiskCache.set(diskKey, rawArchJSON);
309
- }
310
- this.cacheArchJson(diagrams[0].sources, rawArchJSON);
311
- }
312
- }
313
- else if (process.env.ArchGuardDebug === 'true') {
314
- console.debug(`πŸ“¦ Cache hit for ${sourceKey}: ${diagrams[0].sources.join(', ')}`);
315
- }
316
- const results = await pMap(diagrams, async (diagram) => {
317
- return await this.processDiagramWithArchJSON(diagram, rawArchJSON, pool);
318
- }, { concurrency: this.globalConfig.concurrency || os.cpus().length });
319
- return results;
118
+ this.registerQueryScope(firstDiagram.sources, rawArchJSON, kind);
119
+ return await pMap(diagrams, (diagram) => this.processDiagramWithArchJSON(diagram, rawArchJSON, pool), { concurrency: this.globalConfig.concurrency || os.cpus().length });
320
120
  }
321
121
  catch (error) {
322
122
  const errorMessage = error instanceof Error ? error.message : String(error);
323
- return diagrams.map((diagram) => ({
324
- name: diagram.name,
325
- success: false,
326
- error: errorMessage,
327
- }));
123
+ return diagrams.map((diagram) => ({ name: diagram.name, success: false, error: errorMessage }));
328
124
  }
329
125
  }
330
126
  async processDiagramWithArchJSON(diagram, rawArchJSON, pool = null) {
@@ -351,8 +147,8 @@ export class DiagramProcessor {
351
147
  }
352
148
  const format = diagram.format || this.globalConfig.format;
353
149
  const computedMetrics = this.metricsCalculator.calculate(aggregatedJSON, diagram.level);
354
- const outputJSON = format === 'json' ? { ...aggregatedJSON, metrics: computedMetrics } : aggregatedJSON;
355
- await this.generateOutput(outputJSON, paths, format, diagram.level, diagram, pool);
150
+ const outputJSON = { ...aggregatedJSON, metrics: computedMetrics };
151
+ await this.router.route(outputJSON, paths, diagram, pool);
356
152
  if (this.parallelProgress) {
357
153
  this.parallelProgress.update(diagram.name, 90, 'Finalizing');
358
154
  }
@@ -401,219 +197,5 @@ export class DiagramProcessor {
401
197
  };
402
198
  }
403
199
  }
404
- async parseGoProject(diagram) {
405
- const workspaceRoot = path.resolve(diagram.sources[0]);
406
- const registryPlugin = this.registry?.getByName('golang');
407
- const plugin = registryPlugin ??
408
- (await (async () => {
409
- const { GoAtlasPlugin } = await import('../../plugins/golang/atlas/index.js');
410
- return new GoAtlasPlugin();
411
- })());
412
- await plugin.initialize({ workspaceRoot });
413
- return plugin.parseProject(workspaceRoot, {
414
- workspaceRoot,
415
- excludePatterns: diagram.exclude ?? this.globalConfig.exclude ?? [],
416
- languageSpecific: diagram.languageSpecific,
417
- });
418
- }
419
- async parseCppProject(diagram) {
420
- const workspaceRoot = path.resolve(diagram.sources[0]);
421
- const registryPlugin = this.registry?.getByName('cpp');
422
- const plugin = registryPlugin ??
423
- (await (async () => {
424
- const { CppPlugin } = await import('../../plugins/cpp/index.js');
425
- return new CppPlugin();
426
- })());
427
- await plugin.initialize({ workspaceRoot });
428
- return plugin.parseProject(workspaceRoot, {
429
- workspaceRoot,
430
- excludePatterns: diagram.exclude ?? this.globalConfig.exclude ?? [],
431
- });
432
- }
433
- async parseTsProject(diagram) {
434
- const workspaceRoot = path.resolve(diagram.sources[0]);
435
- const registryPlugin = this.registry?.getByName('typescript');
436
- const plugin = registryPlugin ??
437
- (await (async () => {
438
- const { TypeScriptPlugin } = await import('../../plugins/typescript/index.js');
439
- return new TypeScriptPlugin();
440
- })());
441
- await plugin.initialize({ workspaceRoot });
442
- return plugin.parseProject(workspaceRoot, {
443
- workspaceRoot,
444
- excludePatterns: diagram.exclude ?? this.globalConfig.exclude ?? [],
445
- });
446
- }
447
- async generateOutput(archJSON, paths, format, level, diagram, pool = null) {
448
- switch (format) {
449
- case 'json':
450
- await fs.writeJson(paths.paths.json, archJSON, { spaces: 2 });
451
- break;
452
- case 'mermaid':
453
- if (archJSON.extensions?.goAtlas) {
454
- await this.generateAtlasOutput(archJSON, paths, diagram, pool);
455
- }
456
- else if (level === 'package' && archJSON.extensions?.tsAnalysis?.moduleGraph) {
457
- await this.generateTsModuleGraphOutput(archJSON, paths, diagram, pool);
458
- }
459
- else if (level === 'package' && archJSON.language === 'cpp') {
460
- await this.generateCppPackageOutput(archJSON, paths, pool);
461
- }
462
- else {
463
- const mermaidGenerator = new MermaidDiagramGenerator(this.globalConfig, this.progress);
464
- await mermaidGenerator.generateAndRender(archJSON, {
465
- outputDir: paths.paths.mmd.replace(/\/[^/]+$/, ''),
466
- baseName: paths.paths.mmd.replace(/^.*\/([^/]+)\.mmd$/, '$1'),
467
- paths: paths.paths,
468
- }, level, diagram);
469
- }
470
- break;
471
- default:
472
- const exhaustiveCheck = format;
473
- throw new Error(`Unsupported format: ${exhaustiveCheck}`);
474
- }
475
- }
476
- async generateAtlasOutput(archJSON, paths, diagram, pool = null) {
477
- const { AtlasRenderer } = await import('../../plugins/golang/atlas/renderers/atlas-renderer.js');
478
- const { IsomorphicMermaidRenderer, inlineEdgeStyles } = await import('../../mermaid/renderer.js');
479
- const atlas = archJSON.extensions.goAtlas;
480
- const renderer = new AtlasRenderer();
481
- const requestedLayers = diagram.languageSpecific?.atlas?.layers ?? ['package', 'capability', 'goroutine', 'flow'];
482
- const availableLayers = requestedLayers.filter((layer) => atlas.layers[layer]);
483
- const basePath = paths.paths.mmd.replace(/\.mmd$/, '');
484
- const rendererOptions = {};
485
- if (this.globalConfig.mermaid?.theme) {
486
- rendererOptions.theme =
487
- typeof this.globalConfig.mermaid.theme === 'string'
488
- ? { name: this.globalConfig.mermaid.theme }
489
- : this.globalConfig.mermaid.theme;
490
- }
491
- if (this.globalConfig.mermaid?.transparentBackground) {
492
- rendererOptions.backgroundColor = 'transparent';
493
- }
494
- const mermaidRenderer = new IsomorphicMermaidRenderer(rendererOptions);
495
- console.log('\nπŸ—ΊοΈ Generating Go Architecture Atlas...');
496
- await Promise.all(availableLayers.map(async (layer) => {
497
- const result = await renderer.render(atlas, layer, 'mermaid');
498
- const layerPaths = {
499
- mmd: `${basePath}-${layer}.mmd`,
500
- svg: `${basePath}-${layer}.svg`,
501
- png: `${basePath}-${layer}.png`,
502
- };
503
- await fs.ensureDir(path.dirname(layerPaths.mmd));
504
- await fs.writeFile(layerPaths.mmd, result.content, 'utf-8');
505
- let svg;
506
- if (pool) {
507
- const poolResult = await pool.render({ mermaidCode: result.content });
508
- if (!poolResult.success) {
509
- console.warn(` Worker render failed: ${poolResult.error} β€” falling back to main thread`);
510
- svg = await mermaidRenderer.renderSVG(result.content);
511
- }
512
- else {
513
- svg = poolResult.svg;
514
- }
515
- }
516
- else {
517
- svg = await mermaidRenderer.renderSVG(result.content);
518
- }
519
- const processedSvg = typeof inlineEdgeStyles === 'function' ? inlineEdgeStyles(svg) : svg;
520
- let pngFailed = false;
521
- await Promise.all([
522
- fs.writeFile(layerPaths.svg, processedSvg, 'utf-8'),
523
- mermaidRenderer.convertSVGToPNG(processedSvg, layerPaths.png).catch((err) => {
524
- const msg = err instanceof Error ? err.message : String(err);
525
- console.warn(` ⚠️ ${layer} PNG skipped (${msg}) β€” MMD + SVG saved`);
526
- pngFailed = true;
527
- }),
528
- ]);
529
- console.log(` βœ… ${layer}: ${layerPaths.mmd}${pngFailed ? ' (no PNG)' : ''}`);
530
- }));
531
- const atlasJsonPath = `${basePath}-atlas.json`;
532
- await fs.writeJson(atlasJsonPath, atlas, { spaces: 2 });
533
- console.log(` πŸ“Š Atlas JSON: ${atlasJsonPath}`);
534
- console.log(`\n✨ Atlas layers: ${availableLayers.join(', ')}`);
535
- }
536
- async generateTsModuleGraphOutput(archJSON, paths, _diagram, pool = null) {
537
- const { renderTsModuleGraph } = await import('../../mermaid/ts-module-graph-renderer.js');
538
- const { IsomorphicMermaidRenderer, inlineEdgeStyles } = await import('../../mermaid/renderer.js');
539
- const moduleGraph = archJSON.extensions.tsAnalysis.moduleGraph;
540
- const mmdContent = renderTsModuleGraph(moduleGraph);
541
- const rendererOptions = {};
542
- if (this.globalConfig.mermaid?.theme) {
543
- rendererOptions.theme =
544
- typeof this.globalConfig.mermaid.theme === 'string'
545
- ? { name: this.globalConfig.mermaid.theme }
546
- : this.globalConfig.mermaid.theme;
547
- }
548
- if (this.globalConfig.mermaid?.transparentBackground) {
549
- rendererOptions.backgroundColor = 'transparent';
550
- }
551
- const mermaidRenderer = new IsomorphicMermaidRenderer(rendererOptions);
552
- await fs.ensureDir(path.dirname(paths.paths.mmd));
553
- await fs.writeFile(paths.paths.mmd, mmdContent, 'utf-8');
554
- let svg;
555
- if (pool) {
556
- const poolResult = await pool.render({ mermaidCode: mmdContent });
557
- if (!poolResult.success) {
558
- console.warn(` Worker render failed: ${poolResult.error} β€” falling back to main thread`);
559
- svg = await mermaidRenderer.renderSVG(mmdContent);
560
- }
561
- else {
562
- svg = poolResult.svg;
563
- }
564
- }
565
- else {
566
- svg = await mermaidRenderer.renderSVG(mmdContent);
567
- }
568
- const processedSvg = typeof inlineEdgeStyles === 'function' ? inlineEdgeStyles(svg) : svg;
569
- await Promise.all([
570
- fs.writeFile(paths.paths.svg, processedSvg, 'utf-8'),
571
- mermaidRenderer.convertSVGToPNG(processedSvg, paths.paths.png).catch((err) => {
572
- const msg = err instanceof Error ? err.message : String(err);
573
- console.warn(` TS module graph PNG skipped (${msg}) β€” MMD + SVG saved`);
574
- }),
575
- ]);
576
- }
577
- async generateCppPackageOutput(archJSON, paths, pool = null) {
578
- const { CppPackageFlowchartGenerator } = await import('../../mermaid/cpp-package-flowchart-generator.js');
579
- const { IsomorphicMermaidRenderer, inlineEdgeStyles } = await import('../../mermaid/renderer.js');
580
- const generator = new CppPackageFlowchartGenerator();
581
- const mmdContent = generator.generate(archJSON);
582
- const rendererOptions = {};
583
- if (this.globalConfig.mermaid?.theme) {
584
- rendererOptions.theme =
585
- typeof this.globalConfig.mermaid.theme === 'string'
586
- ? { name: this.globalConfig.mermaid.theme }
587
- : this.globalConfig.mermaid.theme;
588
- }
589
- if (this.globalConfig.mermaid?.transparentBackground) {
590
- rendererOptions.backgroundColor = 'transparent';
591
- }
592
- const mermaidRenderer = new IsomorphicMermaidRenderer(rendererOptions);
593
- await fs.ensureDir(path.dirname(paths.paths.mmd));
594
- await fs.writeFile(paths.paths.mmd, mmdContent, 'utf-8');
595
- let svg;
596
- if (pool) {
597
- const poolResult = await pool.render({ mermaidCode: mmdContent });
598
- if (!poolResult.success) {
599
- console.warn(` Worker render failed: ${poolResult.error} β€” falling back to main thread`);
600
- svg = await mermaidRenderer.renderSVG(mmdContent);
601
- }
602
- else {
603
- svg = poolResult.svg;
604
- }
605
- }
606
- else {
607
- svg = await mermaidRenderer.renderSVG(mmdContent);
608
- }
609
- const processedSvg = typeof inlineEdgeStyles === 'function' ? inlineEdgeStyles(svg) : svg;
610
- await Promise.all([
611
- fs.writeFile(paths.paths.svg, processedSvg, 'utf-8'),
612
- mermaidRenderer.convertSVGToPNG(processedSvg, paths.paths.png).catch((err) => {
613
- const msg = err instanceof Error ? err.message : String(err);
614
- console.warn(` C++ package graph PNG skipped (${msg}) β€” MMD + SVG saved`);
615
- }),
616
- ]);
617
- }
618
200
  }
619
201
  //# sourceMappingURL=diagram-processor.js.map