@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.
- package/LICENSE +21 -21
- package/README.md +24 -53
- package/lib/TtscGraphApplication.js +59 -0
- package/lib/TtscGraphApplication.js.map +1 -0
- package/lib/index.js +31 -108
- package/lib/index.js.map +1 -1
- package/lib/model/TtscGraphMemory.js +185 -0
- package/lib/model/TtscGraphMemory.js.map +1 -0
- package/lib/model/loadGraph.js +418 -0
- package/lib/model/loadGraph.js.map +1 -0
- package/lib/reduce.js +101 -0
- package/lib/reduce.js.map +1 -0
- package/lib/resolveGraphBinary.js +42 -0
- package/lib/resolveGraphBinary.js.map +1 -0
- package/lib/server/accessAliases.js +53 -0
- package/lib/server/accessAliases.js.map +1 -0
- package/lib/server/createServer.js +1726 -0
- package/lib/server/createServer.js.map +1 -0
- package/lib/server/instructions.js +80 -0
- package/lib/server/instructions.js.map +1 -0
- package/lib/server/resolveHandle.js +25 -0
- package/lib/server/resolveHandle.js.map +1 -0
- package/lib/server/runDetails.js +413 -0
- package/lib/server/runDetails.js.map +1 -0
- package/lib/server/runEntrypoints.js +211 -0
- package/lib/server/runEntrypoints.js.map +1 -0
- package/lib/server/runLookup.js +234 -0
- package/lib/server/runLookup.js.map +1 -0
- package/lib/server/runOverview.js +160 -0
- package/lib/server/runOverview.js.map +1 -0
- package/lib/server/runTrace.js +314 -0
- package/lib/server/runTrace.js.map +1 -0
- package/lib/server/startServer.js +21 -0
- package/lib/server/startServer.js.map +1 -0
- package/lib/structures/ITtscGraphApplication.js +3 -0
- package/lib/structures/ITtscGraphApplication.js.map +1 -0
- package/lib/structures/ITtscGraphDecorator.js +3 -0
- package/lib/structures/ITtscGraphDecorator.js.map +1 -0
- package/lib/structures/ITtscGraphDetails.js +3 -0
- package/lib/structures/ITtscGraphDetails.js.map +1 -0
- package/lib/structures/ITtscGraphDiagnostic.js +3 -0
- package/lib/structures/ITtscGraphDiagnostic.js.map +1 -0
- package/lib/structures/ITtscGraphDump.js +3 -0
- package/lib/structures/ITtscGraphDump.js.map +1 -0
- package/lib/structures/ITtscGraphEdge.js +3 -0
- package/lib/structures/ITtscGraphEdge.js.map +1 -0
- package/lib/structures/ITtscGraphEntrypoints.js +3 -0
- package/lib/structures/ITtscGraphEntrypoints.js.map +1 -0
- package/lib/structures/ITtscGraphEscape.js +3 -0
- package/lib/structures/ITtscGraphEscape.js.map +1 -0
- package/lib/structures/ITtscGraphEvidence.js +3 -0
- package/lib/structures/ITtscGraphEvidence.js.map +1 -0
- package/lib/structures/ITtscGraphLookup.js +3 -0
- package/lib/structures/ITtscGraphLookup.js.map +1 -0
- package/lib/structures/ITtscGraphNode.js +3 -0
- package/lib/structures/ITtscGraphNode.js.map +1 -0
- package/lib/structures/ITtscGraphOverview.js +3 -0
- package/lib/structures/ITtscGraphOverview.js.map +1 -0
- package/lib/structures/ITtscGraphTrace.js +3 -0
- package/lib/structures/ITtscGraphTrace.js.map +1 -0
- package/lib/structures/TtscGraphEdgeKind.js +3 -0
- package/lib/structures/TtscGraphEdgeKind.js.map +1 -0
- package/lib/structures/TtscGraphNodeKind.js +3 -0
- package/lib/structures/TtscGraphNodeKind.js.map +1 -0
- package/lib/structures/TtscGraphNodeModifier.js +3 -0
- package/lib/structures/TtscGraphNodeModifier.js.map +1 -0
- package/lib/structures/index.js +38 -0
- package/lib/structures/index.js.map +1 -0
- package/lib/view.js +140 -0
- package/lib/view.js.map +1 -0
- package/lib/viewer/index.html +123 -0
- package/lib/viewer/viewer.js +4610 -0
- package/package.json +17 -4
- package/src/TtscGraphApplication.ts +64 -0
- package/src/index.ts +40 -126
- package/src/model/TtscGraphMemory.ts +204 -0
- package/src/model/loadGraph.ts +85 -0
- package/src/reduce.ts +165 -0
- package/src/resolveGraphBinary.ts +40 -0
- package/src/server/accessAliases.ts +55 -0
- package/src/server/createServer.ts +101 -0
- package/src/server/instructions.ts +76 -0
- package/src/server/resolveHandle.ts +34 -0
- package/src/server/runDetails.ts +469 -0
- package/src/server/runEntrypoints.ts +256 -0
- package/src/server/runLookup.ts +257 -0
- package/src/server/runOverview.ts +166 -0
- package/src/server/runTrace.ts +359 -0
- package/src/server/startServer.ts +25 -0
- package/src/structures/ITtscGraphApplication.ts +116 -0
- package/src/structures/ITtscGraphDecorator.ts +31 -0
- package/src/structures/ITtscGraphDetails.ts +134 -0
- package/src/structures/ITtscGraphDiagnostic.ts +34 -0
- package/src/structures/ITtscGraphDump.ts +35 -0
- package/src/structures/ITtscGraphEdge.ts +24 -0
- package/src/structures/ITtscGraphEntrypoints.ts +118 -0
- package/src/structures/ITtscGraphEscape.ts +39 -0
- package/src/structures/ITtscGraphEvidence.ts +26 -0
- package/src/structures/ITtscGraphLookup.ts +61 -0
- package/src/structures/ITtscGraphNode.ts +70 -0
- package/src/structures/ITtscGraphOverview.ts +87 -0
- package/src/structures/ITtscGraphTrace.ts +140 -0
- package/src/structures/TtscGraphEdgeKind.ts +23 -0
- package/src/structures/TtscGraphNodeKind.ts +26 -0
- package/src/structures/TtscGraphNodeModifier.ts +19 -0
- package/src/structures/index.ts +22 -0
- package/src/view.ts +155 -0
- package/src/viewer/index.html +123 -0
- package/src/viewer/main.ts +209 -0
- package/lib/bin.d.ts +0 -2
- package/lib/diagnostics.d.ts +0 -23
- package/lib/diagnostics.js +0 -84
- package/lib/diagnostics.js.map +0 -1
- package/lib/index.d.ts +0 -29
- package/src/diagnostics.ts +0 -93
package/src/diagnostics.ts
DELETED
|
@@ -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
|
-
}
|