@ttsc/graph 0.16.4 → 0.16.6

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 (115) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +24 -53
  3. package/lib/TtscGraphApplication.js +59 -0
  4. package/lib/TtscGraphApplication.js.map +1 -0
  5. package/lib/index.js +31 -108
  6. package/lib/index.js.map +1 -1
  7. package/lib/model/TtscGraphMemory.js +185 -0
  8. package/lib/model/TtscGraphMemory.js.map +1 -0
  9. package/lib/model/loadGraph.js +418 -0
  10. package/lib/model/loadGraph.js.map +1 -0
  11. package/lib/reduce.js +101 -0
  12. package/lib/reduce.js.map +1 -0
  13. package/lib/resolveGraphBinary.js +42 -0
  14. package/lib/resolveGraphBinary.js.map +1 -0
  15. package/lib/server/accessAliases.js +53 -0
  16. package/lib/server/accessAliases.js.map +1 -0
  17. package/lib/server/createServer.js +1726 -0
  18. package/lib/server/createServer.js.map +1 -0
  19. package/lib/server/instructions.js +80 -0
  20. package/lib/server/instructions.js.map +1 -0
  21. package/lib/server/resolveHandle.js +25 -0
  22. package/lib/server/resolveHandle.js.map +1 -0
  23. package/lib/server/runDetails.js +413 -0
  24. package/lib/server/runDetails.js.map +1 -0
  25. package/lib/server/runEntrypoints.js +211 -0
  26. package/lib/server/runEntrypoints.js.map +1 -0
  27. package/lib/server/runLookup.js +234 -0
  28. package/lib/server/runLookup.js.map +1 -0
  29. package/lib/server/runOverview.js +160 -0
  30. package/lib/server/runOverview.js.map +1 -0
  31. package/lib/server/runTrace.js +314 -0
  32. package/lib/server/runTrace.js.map +1 -0
  33. package/lib/server/startServer.js +21 -0
  34. package/lib/server/startServer.js.map +1 -0
  35. package/lib/structures/ITtscGraphApplication.js +3 -0
  36. package/lib/structures/ITtscGraphApplication.js.map +1 -0
  37. package/lib/structures/ITtscGraphDecorator.js +3 -0
  38. package/lib/structures/ITtscGraphDecorator.js.map +1 -0
  39. package/lib/structures/ITtscGraphDetails.js +3 -0
  40. package/lib/structures/ITtscGraphDetails.js.map +1 -0
  41. package/lib/structures/ITtscGraphDiagnostic.js +3 -0
  42. package/lib/structures/ITtscGraphDiagnostic.js.map +1 -0
  43. package/lib/structures/ITtscGraphDump.js +3 -0
  44. package/lib/structures/ITtscGraphDump.js.map +1 -0
  45. package/lib/structures/ITtscGraphEdge.js +3 -0
  46. package/lib/structures/ITtscGraphEdge.js.map +1 -0
  47. package/lib/structures/ITtscGraphEntrypoints.js +3 -0
  48. package/lib/structures/ITtscGraphEntrypoints.js.map +1 -0
  49. package/lib/structures/ITtscGraphEscape.js +3 -0
  50. package/lib/structures/ITtscGraphEscape.js.map +1 -0
  51. package/lib/structures/ITtscGraphEvidence.js +3 -0
  52. package/lib/structures/ITtscGraphEvidence.js.map +1 -0
  53. package/lib/structures/ITtscGraphLookup.js +3 -0
  54. package/lib/structures/ITtscGraphLookup.js.map +1 -0
  55. package/lib/structures/ITtscGraphNode.js +3 -0
  56. package/lib/structures/ITtscGraphNode.js.map +1 -0
  57. package/lib/structures/ITtscGraphOverview.js +3 -0
  58. package/lib/structures/ITtscGraphOverview.js.map +1 -0
  59. package/lib/structures/ITtscGraphTrace.js +3 -0
  60. package/lib/structures/ITtscGraphTrace.js.map +1 -0
  61. package/lib/structures/TtscGraphEdgeKind.js +3 -0
  62. package/lib/structures/TtscGraphEdgeKind.js.map +1 -0
  63. package/lib/structures/TtscGraphNodeKind.js +3 -0
  64. package/lib/structures/TtscGraphNodeKind.js.map +1 -0
  65. package/lib/structures/TtscGraphNodeModifier.js +3 -0
  66. package/lib/structures/TtscGraphNodeModifier.js.map +1 -0
  67. package/lib/structures/index.js +38 -0
  68. package/lib/structures/index.js.map +1 -0
  69. package/lib/view.js +140 -0
  70. package/lib/view.js.map +1 -0
  71. package/lib/viewer/index.html +123 -0
  72. package/lib/viewer/viewer.js +4610 -0
  73. package/package.json +17 -4
  74. package/src/TtscGraphApplication.ts +64 -0
  75. package/src/index.ts +40 -126
  76. package/src/model/TtscGraphMemory.ts +204 -0
  77. package/src/model/loadGraph.ts +85 -0
  78. package/src/reduce.ts +165 -0
  79. package/src/resolveGraphBinary.ts +40 -0
  80. package/src/server/accessAliases.ts +55 -0
  81. package/src/server/createServer.ts +101 -0
  82. package/src/server/instructions.ts +76 -0
  83. package/src/server/resolveHandle.ts +34 -0
  84. package/src/server/runDetails.ts +469 -0
  85. package/src/server/runEntrypoints.ts +256 -0
  86. package/src/server/runLookup.ts +257 -0
  87. package/src/server/runOverview.ts +166 -0
  88. package/src/server/runTrace.ts +359 -0
  89. package/src/server/startServer.ts +25 -0
  90. package/src/structures/ITtscGraphApplication.ts +116 -0
  91. package/src/structures/ITtscGraphDecorator.ts +31 -0
  92. package/src/structures/ITtscGraphDetails.ts +134 -0
  93. package/src/structures/ITtscGraphDiagnostic.ts +34 -0
  94. package/src/structures/ITtscGraphDump.ts +35 -0
  95. package/src/structures/ITtscGraphEdge.ts +24 -0
  96. package/src/structures/ITtscGraphEntrypoints.ts +118 -0
  97. package/src/structures/ITtscGraphEscape.ts +39 -0
  98. package/src/structures/ITtscGraphEvidence.ts +26 -0
  99. package/src/structures/ITtscGraphLookup.ts +61 -0
  100. package/src/structures/ITtscGraphNode.ts +70 -0
  101. package/src/structures/ITtscGraphOverview.ts +87 -0
  102. package/src/structures/ITtscGraphTrace.ts +140 -0
  103. package/src/structures/TtscGraphEdgeKind.ts +23 -0
  104. package/src/structures/TtscGraphNodeKind.ts +26 -0
  105. package/src/structures/TtscGraphNodeModifier.ts +19 -0
  106. package/src/structures/index.ts +22 -0
  107. package/src/view.ts +155 -0
  108. package/src/viewer/index.html +123 -0
  109. package/src/viewer/main.ts +209 -0
  110. package/lib/bin.d.ts +0 -2
  111. package/lib/diagnostics.d.ts +0 -23
  112. package/lib/diagnostics.js +0 -84
  113. package/lib/diagnostics.js.map +0 -1
  114. package/lib/index.d.ts +0 -29
  115. package/src/diagnostics.ts +0 -93
@@ -1,93 +0,0 @@
1
- import fs from "node:fs";
2
- import { createRequire } from "node:module";
3
-
4
- /**
5
- * Background worker that computes the project's plugin diagnostics and writes
6
- * them where the ttscgraph server reads them.
7
- *
8
- * The graph binary runs only the TypeScript semantic pass. Everything a plugin
9
- * adds — `@ttsc/lint` rule violations and transform-plugin (typia, nestia, …)
10
- * findings — comes from `ttsc`'s own check, which runs whatever plugins the
11
- * project configured. This worker invokes that check through the public
12
- * `TtscCompiler`, so nothing here is specific to any plugin: it forwards
13
- * whatever diagnostics ttsc produces.
14
- *
15
- * A native plugin reports its findings with a string `code` (tsc uses numeric
16
- * codes), so the string-coded diagnostics are exactly the plugin/lint set the
17
- * graph does not already have. They are serialized with code 0 and the rule
18
- * folded into the message, the shape ttscgraph's injected-diagnostics provider
19
- * consumes.
20
- *
21
- * Every failure is swallowed: a missing `ttsc`, a go toolchain that cannot
22
- * build a plugin, a project that does not compile — any of these simply leaves
23
- * no file, and the graph shows its tsc diagnostics alone. The worker must never
24
- * be able to break the server it feeds.
25
- */
26
- export function runDiagnosticsWorker(
27
- argv: readonly string[] = process.argv.slice(2),
28
- ): void {
29
- const [cwd, tsconfig, outPath] = argv;
30
- if (!cwd || !outPath) {
31
- return;
32
- }
33
- try {
34
- const ttscPackageJson = require.resolve("ttsc/package.json", {
35
- paths: [cwd],
36
- });
37
- const fromProject = createRequire(ttscPackageJson);
38
- const { TtscCompiler } = fromProject("ttsc") as {
39
- TtscCompiler: new (context: {
40
- cwd: string;
41
- tsconfig?: string;
42
- }) => { compile: () => unknown };
43
- };
44
-
45
- const result = new TtscCompiler({
46
- cwd,
47
- tsconfig: tsconfig || undefined,
48
- }).compile();
49
-
50
- const raw: ReadonlyArray<Record<string, unknown>> =
51
- result &&
52
- typeof result === "object" &&
53
- Array.isArray((result as { diagnostics?: unknown }).diagnostics)
54
- ? ((result as { diagnostics: Record<string, unknown>[] }).diagnostics)
55
- : [];
56
-
57
- const out = raw
58
- .filter(
59
- (d) =>
60
- typeof d.file === "string" &&
61
- (typeof d.line === "number" || typeof d.start === "number"),
62
- )
63
- .map((d) => ({
64
- file: d.file as string,
65
- // A byte offset when the structured lane gives one; otherwise null and
66
- // the server attributes by line. @ttsc/lint and transform plugins reach
67
- // the result through ttsc's text banner, which carries a line but no
68
- // offset.
69
- start: typeof d.start === "number" ? (d.start as number) : null,
70
- line: typeof d.line === "number" ? (d.line as number) : 1,
71
- column: typeof d.character === "number" ? (d.character as number) : 1,
72
- // tsc diagnostics use numeric codes; @ttsc/lint and native plugins hash
73
- // their rule to a code >= 9000. A rare string id is marked non-tsc (the
74
- // server then drops the "TS" prefix); the rule name travels in the
75
- // message regardless.
76
- code: typeof d.code === "number" ? (d.code as number) : 9000,
77
- message: String(d.messageText ?? ""),
78
- }));
79
-
80
- // Atomic publish: write to a sibling temp file and rename, so the server
81
- // never reads a half-written file (a partial read would drop every finding
82
- // for that query).
83
- const tmp = `${outPath}.${process.pid}.tmp`;
84
- fs.writeFileSync(tmp, JSON.stringify(out));
85
- fs.renameSync(tmp, outPath);
86
- } catch {
87
- // Resilient by contract: no file means the graph shows tsc-only diagnostics.
88
- }
89
- }
90
-
91
- if (require.main === module) {
92
- runDiagnosticsWorker();
93
- }