@ttsc/graph 0.30.4 → 0.31.1

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 (292) hide show
  1. package/README.md +122 -30
  2. package/lib/CapturedProcessOutput.d.ts +47 -0
  3. package/lib/CapturedProcessOutput.js +3 -0
  4. package/lib/CapturedProcessOutput.js.map +1 -0
  5. package/lib/ILauncherOption.d.ts +22 -0
  6. package/lib/ILauncherOption.js +3 -0
  7. package/lib/ILauncherOption.js.map +1 -0
  8. package/lib/IProjectOptions.d.ts +18 -0
  9. package/lib/IProjectOptions.js +3 -0
  10. package/lib/IProjectOptions.js.map +1 -0
  11. package/lib/ParsedLauncherOptions.d.ts +13 -0
  12. package/lib/ParsedLauncherOptions.js +3 -0
  13. package/lib/ParsedLauncherOptions.js.map +1 -0
  14. package/lib/TtscGraphApplication.d.ts +38 -1
  15. package/lib/TtscGraphApplication.js +26 -1
  16. package/lib/TtscGraphApplication.js.map +1 -1
  17. package/lib/TtscGraphLauncherArguments.d.ts +115 -0
  18. package/lib/TtscGraphLauncherArguments.js +181 -0
  19. package/lib/TtscGraphLauncherArguments.js.map +1 -0
  20. package/lib/TtscGraphViewSnapshot.d.ts +35 -0
  21. package/lib/TtscGraphViewSnapshot.js +48 -0
  22. package/lib/TtscGraphViewSnapshot.js.map +1 -0
  23. package/lib/index.d.ts +9 -24
  24. package/lib/index.js +6 -128
  25. package/lib/index.js.map +1 -1
  26. package/lib/internal/GraphProcessTrace.d.ts +1 -0
  27. package/lib/internal/GraphProcessTrace.js +235 -0
  28. package/lib/internal/GraphProcessTrace.js.map +1 -0
  29. package/lib/launcherArgs.d.ts +75 -16
  30. package/lib/launcherArgs.js +77 -8
  31. package/lib/launcherArgs.js.map +1 -1
  32. package/lib/model/IArtifactDirectory.d.ts +26 -0
  33. package/lib/model/IArtifactDirectory.js +3 -0
  34. package/lib/model/IArtifactDirectory.js.map +1 -0
  35. package/lib/model/IArtifactInputs.d.ts +19 -0
  36. package/lib/model/IArtifactInputs.js +3 -0
  37. package/lib/model/IArtifactInputs.js.map +1 -0
  38. package/lib/model/IPublishedArtifacts.d.ts +76 -0
  39. package/lib/model/IPublishedArtifacts.js +3 -0
  40. package/lib/model/IPublishedArtifacts.js.map +1 -0
  41. package/lib/model/IPublishedArtifactsResident.d.ts +19 -0
  42. package/lib/model/IPublishedArtifactsResident.js +3 -0
  43. package/lib/model/IPublishedArtifactsResident.js.map +1 -0
  44. package/lib/model/ITtscLintDaemonTarget.d.ts +20 -0
  45. package/lib/model/ITtscLintDaemonTarget.js +3 -0
  46. package/lib/model/ITtscLintDaemonTarget.js.map +1 -0
  47. package/lib/model/TtscGraphLinePeer.d.ts +146 -0
  48. package/lib/model/TtscGraphLinePeer.js +213 -0
  49. package/lib/model/TtscGraphLinePeer.js.map +1 -0
  50. package/lib/model/TtscGraphMemory.d.ts +156 -16
  51. package/lib/model/TtscGraphMemory.js +228 -222
  52. package/lib/model/TtscGraphMemory.js.map +1 -1
  53. package/lib/model/TtscGraphNativeArguments.d.ts +40 -0
  54. package/lib/model/TtscGraphNativeArguments.js +64 -0
  55. package/lib/model/TtscGraphNativeArguments.js.map +1 -0
  56. package/lib/model/TtscGraphNodeId.d.ts +55 -3
  57. package/lib/model/TtscGraphNodeId.js +40 -2
  58. package/lib/model/TtscGraphNodeId.js.map +1 -1
  59. package/lib/model/TtscGraphProjection.d.ts +156 -0
  60. package/lib/model/TtscGraphProjection.js +390 -0
  61. package/lib/model/TtscGraphProjection.js.map +1 -0
  62. package/lib/model/TtscGraphProtocol.d.ts +28 -0
  63. package/lib/model/TtscGraphProtocol.js +928 -0
  64. package/lib/model/TtscGraphProtocol.js.map +1 -0
  65. package/lib/model/TtscGraphReadonly.d.ts +15 -0
  66. package/lib/model/TtscGraphReadonly.js +3 -0
  67. package/lib/model/TtscGraphReadonly.js.map +1 -0
  68. package/lib/model/TtscGraphRequestOptions.d.ts +16 -0
  69. package/lib/model/TtscGraphRequestOptions.js +3 -0
  70. package/lib/model/TtscGraphRequestOptions.js.map +1 -0
  71. package/lib/model/TtscGraphSession.d.ts +82 -36
  72. package/lib/model/TtscGraphSession.js +164 -1238
  73. package/lib/model/TtscGraphSession.js.map +1 -1
  74. package/lib/model/TtscGraphSessionOptions.d.ts +20 -0
  75. package/lib/model/TtscGraphSessionOptions.js +3 -0
  76. package/lib/model/TtscGraphSessionOptions.js.map +1 -0
  77. package/lib/model/TtscGraphSessionState.d.ts +187 -0
  78. package/lib/model/TtscGraphSessionState.js +417 -0
  79. package/lib/model/TtscGraphSessionState.js.map +1 -0
  80. package/lib/model/TtscGraphShardStore.d.ts +64 -3
  81. package/lib/model/TtscGraphShardStore.js +85 -15
  82. package/lib/model/TtscGraphShardStore.js.map +1 -1
  83. package/lib/model/TtscGraphSourceReader.d.ts +31 -8
  84. package/lib/model/TtscGraphSourceReader.js +37 -13
  85. package/lib/model/TtscGraphSourceReader.js.map +1 -1
  86. package/lib/model/TtscLintDaemon.d.ts +35 -17
  87. package/lib/model/TtscLintDaemon.js +39 -117
  88. package/lib/model/TtscLintDaemon.js.map +1 -1
  89. package/lib/model/TtscLintDaemonState.d.ts +69 -0
  90. package/lib/model/TtscLintDaemonState.js +166 -0
  91. package/lib/model/TtscLintDaemonState.js.map +1 -0
  92. package/lib/model/copyGraphRecords.d.ts +14 -0
  93. package/lib/model/copyGraphRecords.js +19 -0
  94. package/lib/model/copyGraphRecords.js.map +1 -0
  95. package/lib/model/copyGraphSnapshot.d.ts +17 -0
  96. package/lib/model/copyGraphSnapshot.js +33 -0
  97. package/lib/model/copyGraphSnapshot.js.map +1 -0
  98. package/lib/model/loadGraph.d.ts +19 -10
  99. package/lib/model/loadGraph.js +21 -12
  100. package/lib/model/loadGraph.js.map +1 -1
  101. package/lib/model/publishedArtifacts.d.ts +78 -97
  102. package/lib/model/publishedArtifacts.js +271 -85
  103. package/lib/model/publishedArtifacts.js.map +1 -1
  104. package/lib/nativeExecutable.d.ts +19 -8
  105. package/lib/nativeExecutable.js +75 -15
  106. package/lib/nativeExecutable.js.map +1 -1
  107. package/lib/reduce.d.ts +19 -45
  108. package/lib/reduce.js +19 -3
  109. package/lib/reduce.js.map +1 -1
  110. package/lib/resolveGraphBinary.d.ts +9 -0
  111. package/lib/resolveGraphBinary.js +11 -3
  112. package/lib/resolveGraphBinary.js.map +1 -1
  113. package/lib/runGraph.d.ts +21 -0
  114. package/lib/runGraph.js +83 -0
  115. package/lib/runGraph.js.map +1 -0
  116. package/lib/server/IResolvedGraphHandle.d.ts +22 -0
  117. package/lib/server/IResolvedGraphHandle.js +3 -0
  118. package/lib/server/IResolvedGraphHandle.js.map +1 -0
  119. package/lib/server/createServer.d.ts +14 -10
  120. package/lib/server/createServer.js +42 -39
  121. package/lib/server/createServer.js.map +1 -1
  122. package/lib/server/exportSurface.d.ts +23 -1
  123. package/lib/server/exportSurface.js +23 -1
  124. package/lib/server/exportSurface.js.map +1 -1
  125. package/lib/server/formatGraphFailure.d.ts +20 -0
  126. package/lib/server/formatGraphFailure.js +35 -0
  127. package/lib/server/formatGraphFailure.js.map +1 -0
  128. package/lib/server/pathPolicy.d.ts +70 -5
  129. package/lib/server/pathPolicy.js +66 -4
  130. package/lib/server/pathPolicy.js.map +1 -1
  131. package/lib/server/resolveHandle.d.ts +10 -5
  132. package/lib/server/resolveHandle.js +39 -7
  133. package/lib/server/resolveHandle.js.map +1 -1
  134. package/lib/server/resultAudit.d.ts +17 -14
  135. package/lib/server/resultAudit.js +56 -27
  136. package/lib/server/resultAudit.js.map +1 -1
  137. package/lib/server/resultNext.d.ts +26 -1
  138. package/lib/server/resultNext.js +14 -0
  139. package/lib/server/resultNext.js.map +1 -1
  140. package/lib/server/runDetails.d.ts +72 -15
  141. package/lib/server/runDetails.js +104 -69
  142. package/lib/server/runDetails.js.map +1 -1
  143. package/lib/server/runEntrypoints.d.ts +9 -0
  144. package/lib/server/runEntrypoints.js +9 -0
  145. package/lib/server/runEntrypoints.js.map +1 -1
  146. package/lib/server/runLookup.d.ts +13 -3
  147. package/lib/server/runLookup.js +19 -6
  148. package/lib/server/runLookup.js.map +1 -1
  149. package/lib/server/runOverview.d.ts +13 -4
  150. package/lib/server/runOverview.js +13 -4
  151. package/lib/server/runOverview.js.map +1 -1
  152. package/lib/server/runTour.d.ts +9 -0
  153. package/lib/server/runTour.js +33 -65
  154. package/lib/server/runTour.js.map +1 -1
  155. package/lib/server/runTrace.d.ts +25 -1
  156. package/lib/server/runTrace.js +133 -88
  157. package/lib/server/runTrace.js.map +1 -1
  158. package/lib/server/startServer.d.ts +16 -0
  159. package/lib/server/startServer.js +24 -1
  160. package/lib/server/startServer.js.map +1 -1
  161. package/lib/structures/ITtscGraphApplication.d.ts +95 -41
  162. package/lib/structures/ITtscGraphDecorator.d.ts +18 -0
  163. package/lib/structures/ITtscGraphDetails.d.ts +81 -6
  164. package/lib/structures/ITtscGraphDocTag.d.ts +17 -8
  165. package/lib/structures/ITtscGraphDump.d.ts +106 -8
  166. package/lib/structures/ITtscGraphEdge.d.ts +14 -2
  167. package/lib/structures/ITtscGraphEntrypoints.d.ts +81 -6
  168. package/lib/structures/ITtscGraphEscape.d.ts +24 -2
  169. package/lib/structures/ITtscGraphEvidence.d.ts +9 -0
  170. package/lib/structures/ITtscGraphLookup.d.ts +42 -9
  171. package/lib/structures/ITtscGraphNext.d.ts +12 -1
  172. package/lib/structures/ITtscGraphNode.d.ts +38 -11
  173. package/lib/structures/ITtscGraphOverview.d.ts +81 -6
  174. package/lib/structures/ITtscGraphSnapshot.d.ts +97 -2
  175. package/lib/structures/ITtscGraphSpan.d.ts +9 -0
  176. package/lib/structures/ITtscGraphTour.d.ts +83 -9
  177. package/lib/structures/ITtscGraphTrace.d.ts +99 -14
  178. package/lib/structures/RawDump.d.ts +22 -0
  179. package/lib/structures/RawDump.js +3 -0
  180. package/lib/structures/RawDump.js.map +1 -0
  181. package/lib/structures/RawEdge.d.ts +20 -0
  182. package/lib/structures/RawEdge.js +3 -0
  183. package/lib/structures/RawEdge.js.map +1 -0
  184. package/lib/structures/RawNode.d.ts +26 -0
  185. package/lib/structures/RawNode.js +3 -0
  186. package/lib/structures/RawNode.js.map +1 -0
  187. package/lib/structures/TtscGraphArtifactNodeKind.d.ts +9 -0
  188. package/lib/structures/TtscGraphArtifactNodeKind.js +9 -0
  189. package/lib/structures/TtscGraphArtifactNodeKind.js.map +1 -1
  190. package/lib/structures/TtscGraphDumpEdgeKind.d.ts +15 -1
  191. package/lib/structures/TtscGraphDumpNodeKind.d.ts +9 -0
  192. package/lib/structures/TtscGraphEdgeKind.d.ts +13 -4
  193. package/lib/structures/TtscGraphNodeKind.d.ts +9 -0
  194. package/lib/structures/TtscGraphNodeModifier.d.ts +9 -0
  195. package/lib/structures/ViewerLink.d.ts +20 -0
  196. package/lib/structures/ViewerLink.js +3 -0
  197. package/lib/structures/ViewerLink.js.map +1 -0
  198. package/lib/structures/ViewerNode.d.ts +24 -0
  199. package/lib/structures/ViewerNode.js +3 -0
  200. package/lib/structures/ViewerNode.js.map +1 -0
  201. package/lib/structures/ViewerPayload.d.ts +42 -0
  202. package/lib/structures/ViewerPayload.js +3 -0
  203. package/lib/structures/ViewerPayload.js.map +1 -0
  204. package/lib/view.d.ts +9 -0
  205. package/lib/view.js +203 -91
  206. package/lib/view.js.map +1 -1
  207. package/lib/viewer/viewer.js +1 -1
  208. package/package.json +8 -6
  209. package/src/CapturedProcessOutput.ts +50 -0
  210. package/src/ILauncherOption.ts +24 -0
  211. package/src/IProjectOptions.ts +19 -0
  212. package/src/ParsedLauncherOptions.ts +13 -0
  213. package/src/TtscGraphApplication.ts +38 -1
  214. package/src/TtscGraphLauncherArguments.ts +207 -0
  215. package/src/TtscGraphViewSnapshot.ts +46 -0
  216. package/src/index.ts +9 -160
  217. package/src/internal/GraphProcessTrace.ts +242 -0
  218. package/src/launcherArgs.ts +89 -23
  219. package/src/model/IArtifactDirectory.ts +27 -0
  220. package/src/model/IArtifactInputs.ts +21 -0
  221. package/src/model/IPublishedArtifacts.ts +81 -0
  222. package/src/model/IPublishedArtifactsResident.ts +24 -0
  223. package/src/model/ITtscLintDaemonTarget.ts +22 -0
  224. package/src/model/TtscGraphLinePeer.ts +318 -0
  225. package/src/model/TtscGraphMemory.ts +284 -246
  226. package/src/model/TtscGraphNativeArguments.ts +67 -0
  227. package/src/model/TtscGraphNodeId.ts +57 -3
  228. package/src/model/TtscGraphProjection.ts +473 -0
  229. package/src/model/TtscGraphProtocol.ts +90 -0
  230. package/src/model/TtscGraphReadonly.ts +17 -0
  231. package/src/model/TtscGraphRequestOptions.ts +16 -0
  232. package/src/model/TtscGraphSession.ts +196 -475
  233. package/src/model/TtscGraphSessionOptions.ts +22 -0
  234. package/src/model/TtscGraphSessionState.ts +558 -0
  235. package/src/model/TtscGraphShardStore.ts +99 -23
  236. package/src/model/TtscGraphSourceReader.ts +37 -15
  237. package/src/model/TtscLintDaemon.ts +55 -136
  238. package/src/model/TtscLintDaemonState.ts +174 -0
  239. package/src/model/copyGraphRecords.ts +17 -0
  240. package/src/model/copyGraphSnapshot.ts +30 -0
  241. package/src/model/loadGraph.ts +23 -12
  242. package/src/model/publishedArtifacts.ts +361 -182
  243. package/src/nativeExecutable.ts +93 -26
  244. package/src/reduce.ts +24 -51
  245. package/src/resolveGraphBinary.ts +13 -3
  246. package/src/runGraph.ts +90 -0
  247. package/src/server/IResolvedGraphHandle.ts +24 -0
  248. package/src/server/createServer.ts +16 -22
  249. package/src/server/exportSurface.ts +23 -1
  250. package/src/server/formatGraphFailure.ts +32 -0
  251. package/src/server/pathPolicy.ts +70 -5
  252. package/src/server/resolveHandle.ts +45 -14
  253. package/src/server/resultAudit.ts +58 -27
  254. package/src/server/resultNext.ts +26 -1
  255. package/src/server/runDetails.ts +138 -73
  256. package/src/server/runEntrypoints.ts +13 -1
  257. package/src/server/runLookup.ts +23 -7
  258. package/src/server/runOverview.ts +17 -5
  259. package/src/server/runTour.ts +44 -82
  260. package/src/server/runTrace.ts +175 -102
  261. package/src/server/startServer.ts +29 -1
  262. package/src/structures/ITtscGraphApplication.ts +95 -41
  263. package/src/structures/ITtscGraphDecorator.ts +18 -0
  264. package/src/structures/ITtscGraphDetails.ts +81 -6
  265. package/src/structures/ITtscGraphDocTag.ts +17 -8
  266. package/src/structures/ITtscGraphDump.ts +106 -8
  267. package/src/structures/ITtscGraphEdge.ts +14 -2
  268. package/src/structures/ITtscGraphEntrypoints.ts +81 -6
  269. package/src/structures/ITtscGraphEscape.ts +24 -2
  270. package/src/structures/ITtscGraphEvidence.ts +9 -0
  271. package/src/structures/ITtscGraphLookup.ts +42 -9
  272. package/src/structures/ITtscGraphNext.ts +12 -1
  273. package/src/structures/ITtscGraphNode.ts +38 -11
  274. package/src/structures/ITtscGraphOverview.ts +88 -6
  275. package/src/structures/ITtscGraphSnapshot.ts +117 -2
  276. package/src/structures/ITtscGraphSpan.ts +9 -0
  277. package/src/structures/ITtscGraphTour.ts +83 -9
  278. package/src/structures/ITtscGraphTrace.ts +100 -14
  279. package/src/structures/RawDump.ts +25 -0
  280. package/src/structures/RawEdge.ts +22 -0
  281. package/src/structures/RawNode.ts +31 -0
  282. package/src/structures/TtscGraphArtifactNodeKind.ts +9 -0
  283. package/src/structures/TtscGraphDumpEdgeKind.ts +15 -1
  284. package/src/structures/TtscGraphDumpNodeKind.ts +9 -0
  285. package/src/structures/TtscGraphEdgeKind.ts +13 -4
  286. package/src/structures/TtscGraphNodeKind.ts +9 -0
  287. package/src/structures/TtscGraphNodeModifier.ts +9 -0
  288. package/src/structures/ViewerLink.ts +22 -0
  289. package/src/structures/ViewerNode.ts +28 -0
  290. package/src/structures/ViewerPayload.ts +52 -0
  291. package/src/view.ts +208 -110
  292. package/src/viewer/legend.ts +119 -27
@@ -30,6 +30,15 @@ exports.TTSC_GRAPH_ARTIFACT_NODE_KINDS = [
30
30
  * {@link TtscGraphNodeId} assumes: a Prisma address carries no path because a
31
31
  * model name is unique across the schema folder, and an operation has no file
32
32
  * at all.
33
+ *
34
+ * @evidence contracts/common.md#principled-implementation Membership in the declared artifact-kind vocabulary distinguishes non-TypeScript addresses before symbol-id parsing.
35
+ * @evidence contracts/common.md#clear-and-simple-design The predicate shares the exported kind list instead of maintaining a second classification switch.
36
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The check concerns semantic kinds, not heuristics about address punctuation or fixture paths.
37
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain why artifact identities cannot use the TypeScript id parser.
38
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources returns a boolean and retains nothing.
39
+ * @evidenceExclude contracts/performance.md#efficient-algorithms one includes test over six constant kinds.
40
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work pure per-call work with no cache, so there is nothing to share or invalidate.
41
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation tests a kind name, which is not a path.
33
42
  */
34
43
  function isArtifactNodeKind(kind) {
35
44
  return exports.TTSC_GRAPH_ARTIFACT_NODE_KINDS.includes(kind);
@@ -1 +1 @@
1
- {"version":3,"file":"TtscGraphArtifactNodeKind.js","sourceRoot":"","sources":["../../src/structures/TtscGraphArtifactNodeKind.ts"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;GAUG;AACU,QAAA,8BAA8B,GAAG;IAC5C,mBAAmB;IACnB,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,mBAAmB;CAC4B,CAAC;AAElD;;;;;;;;;GASG;AACH,4BAAmC,IAAY;IAC7C,OAAQ,QAAA,8BAAoD,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC"}
1
+ {"version":3,"file":"TtscGraphArtifactNodeKind.js","sourceRoot":"","sources":["../../src/structures/TtscGraphArtifactNodeKind.ts"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;GAUG;AACU,QAAA,8BAA8B,GAAG;IAC5C,mBAAmB;IACnB,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,iBAAiB;IACjB,mBAAmB;CAC4B,CAAC;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACH,4BAAmC,IAAY;IAC7C,OAAQ,QAAA,8BAAoD,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9E,CAAC"}
@@ -1,2 +1,16 @@
1
- /** Relationship kinds the native Go dump producer can write. */
1
+ /**
2
+ * Relationship kinds the native Go dump producer can write.
3
+ *
4
+ * Memory-only containment and trace dispatch are absent because the native
5
+ * producer does not emit either relation.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation Literal variants describe only relationships emitted by the native wire producer.
8
+ * @evidence contracts/common.md#clear-and-simple-design A separate wire union keeps validation independent of memory-derived relation additions.
9
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Memory containment and inferred dispatch cannot be accepted as native compiler output.
10
+ * @evidence contracts/common.md#meaningful-documentation Native prose explains why the wire vocabulary excludes the two later-layer relationships.
11
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
12
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
13
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
14
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
15
+ */
2
16
  export type TtscGraphDumpEdgeKind = "exports" | "calls" | "accesses" | "instantiates" | "type_ref" | "doc_ref" | "extends" | "implements" | "overrides" | "renders";
@@ -6,5 +6,14 @@
6
6
  * that the type system holds nothing for — and their ids are the address a
7
7
  * citation writes rather than the `path#name:kind` grammar, which is why an id
8
8
  * is parsed only after its kind says it can be.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation Native declaration and published artifact variants match the wire producer vocabulary before memory refinement.
11
+ * @evidence contracts/common.md#clear-and-simple-design The wire union is separate from memory kinds so module replacement does not weaken native validation.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Artifact addresses are not coerced into TypeScript symbol-id grammar.
13
+ * @evidence contracts/common.md#meaningful-documentation Native documentation explains the artifact distinction and the gate required before parsing identities.
14
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
15
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
16
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
17
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
9
18
  */
10
19
  export type TtscGraphDumpNodeKind = "module" | "function" | "class" | "interface" | "type" | "enum" | "variable" | "method" | "markdown_document" | "markdown_section" | "prisma_model" | "prisma_column" | "prisma_relation" | "swagger_operation";
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Structural `exports` edges come from the native declaration pass, while the
5
5
  * TypeScript memory layer synthesizes `contains` ownership. Value and type
6
- * edges (`calls`, `accesses`, `instantiates`, `type_ref`,
7
- * `extends`, `implements`, `overrides`, `renders`) are resolved by the checker
8
- * — `renders` is a JSX component use. Decorators are facts on their target node,
9
- * not edges.
6
+ * edges (`calls`, `accesses`, `instantiates`, `type_ref`, `extends`,
7
+ * `implements`, `overrides`, `renders`) are resolved by the checker — `renders`
8
+ * is a JSX component use. Decorators are facts on their target node, not
9
+ * edges.
10
10
  *
11
11
  * `doc_ref` is a declaration's own documentation naming a symbol through an
12
12
  * inline link. The checker resolves that name and counts it as a use, so it is
@@ -21,5 +21,14 @@
21
21
  * implementation. It carries the implementation's declaration span, and a
22
22
  * traversal that follows what executes emits it in place of the dead end. It is
23
23
  * trace-only and never appears in a native dump.
24
+ *
25
+ * @evidence contracts/common.md#principled-implementation The union distinguishes compiler relationships, memory containment and trace-only dispatch, each with a separate semantic role.
26
+ * @evidence contracts/common.md#clear-and-simple-design One shared relation vocabulary keeps producers and projections aligned without a second generic relation taxonomy.
27
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Documentation links remain compiler uses; dispatch follows actual implementation relations rather than guessing runtime calls.
28
+ * @evidence contracts/common.md#meaningful-documentation Separate native paragraphs explain structural, documentation and dispatch relationships and their producer boundaries.
29
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
30
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
31
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
32
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
24
33
  */
25
34
  export type TtscGraphEdgeKind = "contains" | "exports" | "calls" | "accesses" | "instantiates" | "type_ref" | "doc_ref" | "extends" | "implements" | "overrides" | "dispatches" | "renders";
@@ -7,5 +7,14 @@
7
7
  * leaf keeps its real declaration kind and sets `external: true`.
8
8
  *
9
9
  * Used as the `kind` discriminant on {@link ITtscGraphNode}.
10
+ *
11
+ * @evidence contracts/common.md#principled-implementation Literal variants distinguish memory-layer declaration containers, refined members and published artifacts.
12
+ * @evidence contracts/common.md#clear-and-simple-design A single kind union is shared by node records instead of independent untyped classification strings.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Kinds express supported graph semantics, not fixture names or framework-specific categories.
14
+ * @evidence contracts/common.md#meaningful-documentation Native paragraphs explain native-to-memory refinement and external leaves before the tags.
15
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
16
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
17
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
18
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
10
19
  */
11
20
  export type TtscGraphNodeKind = "file" | "function" | "class" | "interface" | "type" | "enum" | "variable" | "method" | "property" | "markdown_document" | "markdown_section" | "prisma_model" | "prisma_column" | "prisma_relation" | "swagger_operation";
@@ -3,5 +3,14 @@
3
3
  * declaration pass records it. Used by projections that reason about visibility
4
4
  * and shape — e.g. a public-API overview filters on `export`, a class outline
5
5
  * separates `static` members.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation The literal union represents the declaration modifiers the native pass records, without assigning runtime behavior to absent modifiers.
8
+ * @evidence contracts/common.md#clear-and-simple-design Shared modifier values serve node presentation and projection decisions without separate visibility flags for each consumer.
9
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Visibility comes from compiler facts rather than naming conventions for private symbols.
10
+ * @evidence contracts/common.md#meaningful-documentation Native prose explains optional collection and the visibility/shape use cases.
11
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
12
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
13
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
14
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
6
15
  */
7
16
  export type TtscGraphNodeModifier = "export" | "default" | "declare" | "abstract" | "static" | "readonly" | "async" | "const" | "public" | "private" | "protected";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Viewer edge joining two retained display identities.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation Source and target use the node rewrite policy while kind groups native relationships into supported visual families.
5
+ * @evidence contracts/common.md#clear-and-simple-design The display relation carries only endpoints and color-family category.
6
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Unknown relationship kinds pass through rather than being relabeled as a known family.
7
+ * @evidence contracts/common.md#meaningful-documentation Native members describe rewritten endpoints and display-family kind.
8
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
9
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
10
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
11
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
12
+ */
13
+ export interface ViewerLink {
14
+ /** Retained source viewer node id. */
15
+ source: string;
16
+ /** Retained target viewer node id. */
17
+ target: string;
18
+ /** Grouped display family, or an unchanged unknown native kind. */
19
+ kind: string;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ViewerLink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewerLink.js","sourceRoot":"","sources":["../../src/structures/ViewerLink.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Connected viewer node with its degree in the final displayed subgraph.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation Rewritten identity and file coordinates remain paired; degree counts only final visible incident edges.
5
+ * @evidence contracts/common.md#clear-and-simple-design One compact display record omits native provenance and source spans unnecessary for drawing.
6
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Name is presentation, not a substitute identity that could merge distinct declarations.
7
+ * @evidence contracts/common.md#meaningful-documentation Native members identify display coordinates and final-subgraph degree.
8
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
9
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
10
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
11
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
12
+ */
13
+ export interface ViewerNode {
14
+ /** Identity rewritten with the same path policy as incident edges. */
15
+ id: string;
16
+ /** Producer declaration display name. */
17
+ name: string;
18
+ /** Node category used for viewer colors. */
19
+ kind: string;
20
+ /** Display path after optional legacy rerooting. */
21
+ file: string;
22
+ /** Incident edge count after final node selection. */
23
+ degree: number;
24
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ViewerNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewerNode.js","sourceRoot":"","sources":["../../src/structures/ViewerNode.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import { ViewerLink } from "./ViewerLink";
2
+ import { ViewerNode } from "./ViewerNode";
3
+ /**
4
+ * Reduced connected graph and the populations removed by its filters.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation Final nodes/links describe the drawn subgraph while counters retain raw totals and distinct boundary/cap omissions.
7
+ * @evidence contracts/common.md#clear-and-simple-design One payload carries drawing inputs and explanatory totals without preserving a second full raw graph.
8
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Selection losses are exposed as counters rather than hidden to imply the full project was drawn.
9
+ * @evidence contracts/common.md#meaningful-documentation Native member comments define each count's population and distinguish selected nodes from cap/boundary removals.
10
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources data shape only: it holds no handle, task or retained state.
11
+ * @evidenceExclude contracts/performance.md#efficient-algorithms data shape only: it contains no loop or algorithm.
12
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work data shape only: it computes nothing another request could share.
13
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation data shape only: it touches no file, path or process.
14
+ */
15
+ export interface ViewerPayload {
16
+ /** Display project label, empty when not supplied. */
17
+ project: string;
18
+ /** Input/output totals and disjoint removal categories. */
19
+ counts: {
20
+ /** Node count before viewer filtering. */
21
+ rawNodes: number;
22
+ /** Edge count before viewer filtering. */
23
+ rawEdges: number;
24
+ /** Connected nodes in the final payload. */
25
+ nodes: number;
26
+ /** Edges whose rewritten endpoints both survive. */
27
+ links: number;
28
+ /** External nodes omitted when boundary filtering is enabled. */
29
+ droppedExternal: number;
30
+ /** Nonexternal ignored nodes omitted when generated filtering is enabled. */
31
+ droppedIgnored: number;
32
+ /**
33
+ * Boundary-surviving nodes removed by the degree cap, before isolated-node
34
+ * removal.
35
+ */
36
+ droppedByCap: number;
37
+ };
38
+ /** Connected display nodes. */
39
+ nodes: ViewerNode[];
40
+ /** Directed display edges between retained nodes. */
41
+ links: ViewerLink[];
42
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ViewerPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewerPayload.js","sourceRoot":"","sources":["../../src/structures/ViewerPayload.ts"],"names":[],"mappings":""}
package/lib/view.d.ts CHANGED
@@ -3,5 +3,14 @@
3
3
  * self-contained 3D viewer on a localhost port, opening the browser. The native
4
4
  * binary produces the graph (the same `dump` the docs document); everything
5
5
  * else is local and offline. The process stays alive serving until Ctrl+C.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation Loopback binding must succeed before native preparation starts. Only a version-validated, reduced snapshot and bundled assets become ready; requests during preparation receive 503.
8
+ * @evidence contracts/common.md#clear-and-simple-design CLI parsing, native capture, reduction and loopback serving have explicit boundaries; browser opening is a best-effort convenience.
9
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Native failure remains a nonzero outcome and viewer absence remains an installation error rather than a fallback to fabricated graph data.
10
+ * @evidence contracts/common.md#meaningful-documentation Native prose explains offline operation, native producer responsibility and the process lifetime.
11
+ * @evidence contracts/portability.md#os-neutral-implementation Binary selection and Node paths/fs use native abstractions; browser opening isolates Windows start, macOS open and other-host xdg-open commands.
12
+ * @evidence contracts/performance.md#efficient-algorithms Native capture and reduction process the dump once; JSON and viewer assets are materialized once and reused by HTTP responses.
13
+ * @evidence contracts/performance.md#reuse-equivalent-work All requests to this one-shot viewer share the same reduced graph string and asset buffers; a new source snapshot requires another viewer invocation.
14
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Capture descriptors are disposed in finally. Signal cancellation cancels scheduled preparation or publication, drops the payload and closes owned sockets/server; bind failure releases signal listeners without starting native work. Synchronous native preparation cannot be interrupted by a queued JavaScript signal handler.
6
15
  */
7
16
  export declare function runView(argv: readonly string[]): number | void;
package/lib/view.js CHANGED
@@ -4,44 +4,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runView = runView;
7
- const node_child_process_1 = require("node:child_process");
8
7
  const node_fs_1 = __importDefault(require("node:fs"));
9
8
  const node_http_1 = __importDefault(require("node:http"));
10
9
  const node_path_1 = __importDefault(require("node:path"));
11
- const launcherArgs_1 = require("./launcherArgs");
12
- const loadGraph_1 = require("./model/loadGraph");
10
+ const TtscGraphLauncherArguments_1 = require("./TtscGraphLauncherArguments");
11
+ const TtscGraphViewSnapshot_1 = require("./TtscGraphViewSnapshot");
12
+ const GraphProcessTrace_1 = require("./internal/GraphProcessTrace");
13
13
  const publishedArtifacts_1 = require("./model/publishedArtifacts");
14
14
  const nativeExecutable_1 = require("./nativeExecutable");
15
15
  const reduce_1 = require("./reduce");
16
16
  const resolveGraphBinary_1 = require("./resolveGraphBinary");
17
- function parseViewArgs(argv) {
18
- const values = (0, launcherArgs_1.parseLauncherOptions)(argv, [
19
- { key: "cwd", flags: ["--cwd"], kind: "value" },
20
- { key: "tsconfig", flags: ["--tsconfig", "-p"], kind: "value" },
21
- { key: "port", flags: ["--port"], kind: "value" },
22
- { key: "open", flags: ["--no-open"], kind: "flag" },
23
- { key: "max_nodes", flags: ["--max-nodes"], kind: "value" },
24
- ]);
25
- const project = (0, launcherArgs_1.projectOptions)(values);
26
- return {
27
- ...project,
28
- port: values.has("port") === true
29
- ? (0, launcherArgs_1.nonNegativeIntegerOption)(values, "port", 65_535)
30
- : 0,
31
- open: values.get("open") !== true,
32
- maxNodes: values.has("max_nodes") === true
33
- ? (0, launcherArgs_1.positiveIntegerOption)(values, "max_nodes", Number.MAX_SAFE_INTEGER)
34
- : 1200,
35
- };
36
- }
37
17
  /**
38
18
  * `ttsc-graph view`: build the project's code graph, reduce it, and serve a
39
19
  * self-contained 3D viewer on a localhost port, opening the browser. The native
40
20
  * binary produces the graph (the same `dump` the docs document); everything
41
21
  * else is local and offline. The process stays alive serving until Ctrl+C.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation Loopback binding must succeed before native preparation starts. Only a version-validated, reduced snapshot and bundled assets become ready; requests during preparation receive 503.
24
+ * @evidence contracts/common.md#clear-and-simple-design CLI parsing, native capture, reduction and loopback serving have explicit boundaries; browser opening is a best-effort convenience.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Native failure remains a nonzero outcome and viewer absence remains an installation error rather than a fallback to fabricated graph data.
26
+ * @evidence contracts/common.md#meaningful-documentation Native prose explains offline operation, native producer responsibility and the process lifetime.
27
+ * @evidence contracts/portability.md#os-neutral-implementation Binary selection and Node paths/fs use native abstractions; browser opening isolates Windows start, macOS open and other-host xdg-open commands.
28
+ * @evidence contracts/performance.md#efficient-algorithms Native capture and reduction process the dump once; JSON and viewer assets are materialized once and reused by HTTP responses.
29
+ * @evidence contracts/performance.md#reuse-equivalent-work All requests to this one-shot viewer share the same reduced graph string and asset buffers; a new source snapshot requires another viewer invocation.
30
+ * @evidence contracts/performance.md#bound-retention-and-release-resources Capture descriptors are disposed in finally. Signal cancellation cancels scheduled preparation or publication, drops the payload and closes owned sockets/server; bind failure releases signal listeners without starting native work. Synchronous native preparation cannot be interrupted by a queued JavaScript signal handler.
42
31
  */
43
32
  function runView(argv) {
44
- const opts = parseViewArgs(argv);
33
+ const opts = TtscGraphLauncherArguments_1.TtscGraphLauncherArguments.view(argv);
45
34
  // Anchor binary resolution at the project selected by `--cwd`, so `view` from
46
35
  // an unrelated directory still finds the `ttsc` installed under the target.
47
36
  const binary = (0, resolveGraphBinary_1.resolveGraphBinary)(process.env, opts.cwd);
@@ -52,6 +41,170 @@ function runView(argv) {
52
41
  return 1;
53
42
  }
54
43
  (0, nativeExecutable_1.ensureExecutable)(binary);
44
+ let prepared;
45
+ let state = "binding";
46
+ let pending;
47
+ let closeRequested = false;
48
+ let endpoint = `127.0.0.1:${opts.port}`;
49
+ const connections = new Set();
50
+ const server = node_http_1.default.createServer((req, res) => {
51
+ if (state !== "ready" || prepared === undefined) {
52
+ res.writeHead(503, {
53
+ "content-type": "text/plain; charset=utf-8",
54
+ connection: "close",
55
+ });
56
+ res.end("The graph viewer is not ready.\n");
57
+ return;
58
+ }
59
+ const url = (req.url ?? "/").split("?")[0];
60
+ if (url === "/graph.json") {
61
+ res.writeHead(200, { "content-type": "application/json" });
62
+ res.end(prepared.graphJson);
63
+ }
64
+ else if (url === "/viewer.js") {
65
+ res.writeHead(200, {
66
+ "content-type": "application/javascript; charset=utf-8",
67
+ });
68
+ res.end(prepared.viewerJs);
69
+ }
70
+ else {
71
+ res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
72
+ res.end(prepared.indexHtml);
73
+ }
74
+ });
75
+ const releaseSignals = () => {
76
+ process.removeListener("SIGINT", interrupt);
77
+ process.removeListener("SIGTERM", terminate);
78
+ };
79
+ const reportCloseFailure = (error) => {
80
+ process.exitCode = 1;
81
+ process.stderr.write(`@ttsc/graph: could not close the 3D viewer at ${endpoint} (${error.message}).\n`);
82
+ };
83
+ const stop = () => {
84
+ if (state === "closed")
85
+ return;
86
+ state = "closing";
87
+ if (pending !== undefined) {
88
+ clearImmediate(pending);
89
+ pending = undefined;
90
+ }
91
+ prepared = undefined;
92
+ for (const connection of connections)
93
+ connection.destroy();
94
+ // If cancellation preceded the listening event, that event owns closure.
95
+ if (!server.listening || closeRequested)
96
+ return;
97
+ closeRequested = true;
98
+ try {
99
+ server.close((error) => {
100
+ if (error)
101
+ reportCloseFailure(error);
102
+ });
103
+ }
104
+ catch (error) {
105
+ reportCloseFailure(error instanceof Error ? error : new Error(String(error)));
106
+ }
107
+ };
108
+ const interrupt = () => {
109
+ process.exitCode = 130;
110
+ stop();
111
+ };
112
+ const terminate = () => {
113
+ process.exitCode = 143;
114
+ stop();
115
+ };
116
+ server.on("connection", (connection) => {
117
+ connections.add(connection);
118
+ connection.once("close", () => connections.delete(connection));
119
+ if (state === "closing" || state === "closed")
120
+ connection.destroy();
121
+ });
122
+ server.once("close", () => {
123
+ if (pending !== undefined) {
124
+ clearImmediate(pending);
125
+ pending = undefined;
126
+ }
127
+ state = "closed";
128
+ prepared = undefined;
129
+ releaseSignals();
130
+ });
131
+ server.on("error", (error) => {
132
+ const detail = typeof error.code === "string"
133
+ ? `${error.code}: ${error.message}`
134
+ : error.message;
135
+ process.stderr.write(`@ttsc/graph: could not serve the 3D viewer at ${endpoint} (${detail}).\n`);
136
+ process.exitCode = 1;
137
+ if (!server.listening && !closeRequested) {
138
+ state = "closed";
139
+ if (pending !== undefined) {
140
+ clearImmediate(pending);
141
+ pending = undefined;
142
+ }
143
+ prepared = undefined;
144
+ releaseSignals();
145
+ }
146
+ else
147
+ stop();
148
+ });
149
+ process.on("SIGINT", interrupt);
150
+ process.on("SIGTERM", terminate);
151
+ try {
152
+ server.listen(opts.port, "127.0.0.1", () => {
153
+ if (state === "closing") {
154
+ stop();
155
+ return;
156
+ }
157
+ if (state !== "binding")
158
+ return;
159
+ const address = server.address();
160
+ const port = typeof address === "object" && address ? address.port : opts.port;
161
+ endpoint = `127.0.0.1:${port}`;
162
+ state = "preparing";
163
+ pending = setImmediate(() => {
164
+ pending = undefined;
165
+ if (state !== "preparing")
166
+ return;
167
+ try {
168
+ const result = prepareView(opts, binary);
169
+ if (typeof result === "number") {
170
+ process.exitCode = result;
171
+ stop();
172
+ return;
173
+ }
174
+ // Yield after synchronous native preparation so queued cancellation
175
+ // and transport events are handled before publishing readiness.
176
+ pending = setImmediate(() => {
177
+ pending = undefined;
178
+ if (state !== "preparing")
179
+ return;
180
+ prepared = result;
181
+ state = "ready";
182
+ const counts = result.payload.counts;
183
+ const url = `http://${endpoint}/`;
184
+ process.stderr.write(`@ttsc/graph: ${counts.nodes.toLocaleString()} nodes / ${counts.links.toLocaleString()} edges` +
185
+ ` (from ${counts.rawNodes.toLocaleString()} / ${counts.rawEdges.toLocaleString()})\n`);
186
+ process.stderr.write(`@ttsc/graph: serving the 3D viewer at ${url}\n`);
187
+ process.stderr.write("@ttsc/graph: press Ctrl+C to stop.\n");
188
+ if (opts.open)
189
+ openBrowser(url);
190
+ });
191
+ }
192
+ catch (error) {
193
+ process.stderr.write(`@ttsc/graph: could not prepare the 3D viewer (${String(error)}).\n`);
194
+ process.exitCode = 1;
195
+ stop();
196
+ }
197
+ });
198
+ });
199
+ }
200
+ catch (error) {
201
+ state = "closed";
202
+ releaseSignals();
203
+ throw error;
204
+ }
205
+ }
206
+ /** Prepare one validated native snapshot and its bundled viewer assets. */
207
+ function prepareView(opts, binary) {
55
208
  process.stderr.write(`@ttsc/graph: building the graph for ${opts.cwd} (${opts.tsconfig})...\n`);
56
209
  // The dump goes to a file rather than a pipe, so no output ceiling applies.
57
210
  const capture = (0, nativeExecutable_1.captureProcessOutput)();
@@ -61,13 +214,13 @@ function runView(argv) {
61
214
  try {
62
215
  // The same artifacts the dump, the loader, and the resident session ask
63
216
  // for. Without this the viewer draws a different graph from the one every
64
- // other entry point answers with — and it already carries the colours for
217
+ // other entry point answers with, and it already carries the colours for
65
218
  // the nodes it would be missing.
66
219
  const artifacts = (0, publishedArtifacts_1.publishArtifacts)({
67
220
  cwd: opts.cwd,
68
221
  tsconfig: opts.tsconfig,
69
222
  });
70
- dump = (0, node_child_process_1.spawnSync)(binary, [
223
+ dump = GraphProcessTrace_1.GraphProcessTrace.spawnSync(binary, [
71
224
  "dump",
72
225
  "--cwd",
73
226
  opts.cwd,
@@ -89,21 +242,15 @@ function runView(argv) {
89
242
  return 1;
90
243
  }
91
244
  if (dump.status !== 0) {
92
- process.stderr.write(dump.stderr || "@ttsc/graph: dump failed\n");
245
+ process.stderr.write(dumpStderr || "@ttsc/graph: dump failed\n");
93
246
  return dump.status ?? 1;
94
247
  }
95
- let raw;
96
- try {
97
- raw = (0, loadGraph_1.parseDump)(dumpStdout);
248
+ const snapshot = TtscGraphViewSnapshot_1.TtscGraphViewSnapshot.decode(dumpStdout);
249
+ if (!snapshot.ok) {
250
+ process.stderr.write(snapshot.diagnostic);
251
+ return snapshot.code;
98
252
  }
99
- catch (error) {
100
- const message = error instanceof Error ? error.message : String(error);
101
- process.stderr.write(message.startsWith("@ttsc/graph:")
102
- ? `${message}\n`
103
- : `@ttsc/graph: could not validate the graph dump: ${message}\n`);
104
- return 1;
105
- }
106
- const payload = (0, reduce_1.reduce)(raw, { maxNodes: opts.maxNodes });
253
+ const payload = (0, reduce_1.reduce)(snapshot.raw, { maxNodes: opts.maxNodes });
107
254
  payload.project = node_path_1.default.basename(node_path_1.default.resolve(opts.cwd));
108
255
  const graphJson = JSON.stringify(payload);
109
256
  const viewerDir = node_path_1.default.join(__dirname, "viewer");
@@ -118,68 +265,33 @@ function runView(argv) {
118
265
  "Reinstall @ttsc/graph.\n");
119
266
  return 1;
120
267
  }
121
- const server = node_http_1.default.createServer((req, res) => {
122
- const url = (req.url ?? "/").split("?")[0];
123
- if (url === "/graph.json") {
124
- res.writeHead(200, { "content-type": "application/json" });
125
- res.end(graphJson);
126
- }
127
- else if (url === "/viewer.js") {
128
- res.writeHead(200, {
129
- "content-type": "application/javascript; charset=utf-8",
130
- });
131
- res.end(viewerJs);
132
- }
133
- else {
134
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
135
- res.end(indexHtml);
136
- }
137
- });
138
- let endpoint = `127.0.0.1:${opts.port}`;
139
- let failed = false;
140
- server.on("error", (error) => {
141
- if (failed)
142
- return;
143
- failed = true;
144
- const detail = typeof error.code === "string"
145
- ? `${error.code}: ${error.message}`
146
- : error.message;
147
- process.stderr.write(`@ttsc/graph: could not serve the 3D viewer at ${endpoint} (${detail}).\n`);
148
- process.exitCode = 1;
149
- if (server.listening) {
150
- server.close();
151
- server.closeAllConnections?.();
152
- }
153
- });
154
- server.listen(opts.port, "127.0.0.1", () => {
155
- if (failed)
156
- return;
157
- const address = server.address();
158
- const port = typeof address === "object" && address ? address.port : opts.port;
159
- endpoint = `127.0.0.1:${port}`;
160
- const url = `http://127.0.0.1:${port}/`;
161
- const counts = payload.counts;
162
- process.stderr.write(`@ttsc/graph: ${counts.nodes.toLocaleString()} nodes / ${counts.links.toLocaleString()} edges` +
163
- ` (from ${counts.rawNodes.toLocaleString()} / ${counts.rawEdges.toLocaleString()})\n`);
164
- process.stderr.write(`@ttsc/graph: serving the 3D viewer at ${url}\n`);
165
- process.stderr.write("@ttsc/graph: press Ctrl+C to stop.\n");
166
- if (opts.open)
167
- openBrowser(url);
168
- });
169
- // No return: the listening server keeps the process alive until Ctrl+C.
268
+ return { payload, graphJson, indexHtml, viewerJs };
170
269
  }
171
270
  /** Best-effort open the URL in the default browser; the URL is printed anyway. */
172
271
  function openBrowser(url) {
173
272
  try {
174
273
  if (process.platform === "win32")
175
- (0, node_child_process_1.spawn)("cmd", ["/c", "start", "", url], {
274
+ GraphProcessTrace_1.GraphProcessTrace.spawn("cmd", ["/c", "start", "", url], {
176
275
  stdio: "ignore",
177
276
  detached: true,
178
- }).unref();
277
+ windowsHide: true,
278
+ })
279
+ .on("error", () => undefined)
280
+ .unref();
179
281
  else if (process.platform === "darwin")
180
- (0, node_child_process_1.spawn)("open", [url], { stdio: "ignore", detached: true }).unref();
282
+ GraphProcessTrace_1.GraphProcessTrace.spawn("open", [url], {
283
+ stdio: "ignore",
284
+ detached: true,
285
+ })
286
+ .on("error", () => undefined)
287
+ .unref();
181
288
  else
182
- (0, node_child_process_1.spawn)("xdg-open", [url], { stdio: "ignore", detached: true }).unref();
289
+ GraphProcessTrace_1.GraphProcessTrace.spawn("xdg-open", [url], {
290
+ stdio: "ignore",
291
+ detached: true,
292
+ })
293
+ .on("error", () => undefined)
294
+ .unref();
183
295
  }
184
296
  catch {
185
297
  /* the URL is printed; opening is a convenience */