@ttsc/graph 0.19.2 → 0.20.0

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 (92) hide show
  1. package/lib/TtscGraphApplication.js +5 -1
  2. package/lib/TtscGraphApplication.js.map +1 -1
  3. package/lib/bin.js +15 -3
  4. package/lib/bin.js.map +1 -1
  5. package/lib/index.d.ts +13 -2
  6. package/lib/index.js +25 -30
  7. package/lib/index.js.map +1 -1
  8. package/lib/launcherArgs.d.ts +24 -0
  9. package/lib/launcherArgs.js +136 -0
  10. package/lib/launcherArgs.js.map +1 -0
  11. package/lib/model/TtscGraphMemory.d.ts +9 -5
  12. package/lib/model/TtscGraphMemory.js +35 -58
  13. package/lib/model/TtscGraphMemory.js.map +1 -1
  14. package/lib/model/TtscGraphNodeId.d.ts +17 -0
  15. package/lib/model/TtscGraphNodeId.js +69 -0
  16. package/lib/model/TtscGraphNodeId.js.map +1 -0
  17. package/lib/model/TtscGraphSession.d.ts +23 -7
  18. package/lib/model/TtscGraphSession.js +423 -171
  19. package/lib/model/TtscGraphSession.js.map +1 -1
  20. package/lib/model/TtscGraphSourceReader.d.ts +27 -0
  21. package/lib/model/TtscGraphSourceReader.js +97 -0
  22. package/lib/model/TtscGraphSourceReader.js.map +1 -0
  23. package/lib/model/loadGraph.d.ts +14 -0
  24. package/lib/model/loadGraph.js +256 -143
  25. package/lib/model/loadGraph.js.map +1 -1
  26. package/lib/reduce.d.ts +4 -1
  27. package/lib/reduce.js +112 -29
  28. package/lib/reduce.js.map +1 -1
  29. package/lib/resolveGraphBinary.d.ts +9 -3
  30. package/lib/resolveGraphBinary.js +9 -3
  31. package/lib/resolveGraphBinary.js.map +1 -1
  32. package/lib/server/createServer.js +22 -11
  33. package/lib/server/createServer.js.map +1 -1
  34. package/lib/server/pathPolicy.d.ts +6 -0
  35. package/lib/server/pathPolicy.js +10 -1
  36. package/lib/server/pathPolicy.js.map +1 -1
  37. package/lib/server/resolveHandle.js +22 -18
  38. package/lib/server/resolveHandle.js.map +1 -1
  39. package/lib/server/resultAudit.d.ts +56 -14
  40. package/lib/server/resultAudit.js +90 -24
  41. package/lib/server/resultAudit.js.map +1 -1
  42. package/lib/server/resultNext.d.ts +5 -0
  43. package/lib/server/resultNext.js.map +1 -1
  44. package/lib/server/runDetails.d.ts +9 -2
  45. package/lib/server/runDetails.js +132 -157
  46. package/lib/server/runDetails.js.map +1 -1
  47. package/lib/server/runEntrypoints.js +1 -1
  48. package/lib/server/runEntrypoints.js.map +1 -1
  49. package/lib/server/runLookup.js +1 -1
  50. package/lib/server/runLookup.js.map +1 -1
  51. package/lib/server/runTour.js +113 -30
  52. package/lib/server/runTour.js.map +1 -1
  53. package/lib/server/runTrace.d.ts +22 -0
  54. package/lib/server/runTrace.js +293 -63
  55. package/lib/server/runTrace.js.map +1 -1
  56. package/lib/structures/ITtscGraphApplication.d.ts +8 -7
  57. package/lib/structures/ITtscGraphDetails.d.ts +18 -8
  58. package/lib/structures/ITtscGraphDump.d.ts +13 -13
  59. package/lib/structures/ITtscGraphNode.d.ts +71 -0
  60. package/lib/structures/ITtscGraphTour.d.ts +1 -1
  61. package/lib/structures/ITtscGraphTrace.d.ts +1 -1
  62. package/lib/view.js +18 -28
  63. package/lib/view.js.map +1 -1
  64. package/package.json +7 -4
  65. package/src/TtscGraphApplication.ts +8 -1
  66. package/src/bin.ts +13 -3
  67. package/src/index.ts +35 -27
  68. package/src/launcherArgs.ts +168 -0
  69. package/src/model/TtscGraphMemory.ts +34 -60
  70. package/src/model/TtscGraphNodeId.ts +77 -0
  71. package/src/model/TtscGraphSession.ts +253 -53
  72. package/src/model/TtscGraphSourceReader.ts +117 -0
  73. package/src/model/loadGraph.ts +6 -1
  74. package/src/reduce.ts +136 -31
  75. package/src/resolveGraphBinary.ts +9 -3
  76. package/src/server/createServer.ts +12 -2
  77. package/src/server/pathPolicy.ts +10 -1
  78. package/src/server/resolveHandle.ts +21 -22
  79. package/src/server/resultAudit.ts +93 -23
  80. package/src/server/resultNext.ts +6 -0
  81. package/src/server/runDetails.ts +134 -165
  82. package/src/server/runEntrypoints.ts +1 -1
  83. package/src/server/runLookup.ts +1 -1
  84. package/src/server/runTour.ts +133 -39
  85. package/src/server/runTrace.ts +401 -65
  86. package/src/structures/ITtscGraphApplication.ts +8 -7
  87. package/src/structures/ITtscGraphDetails.ts +18 -8
  88. package/src/structures/ITtscGraphDump.ts +13 -13
  89. package/src/structures/ITtscGraphNode.ts +80 -0
  90. package/src/structures/ITtscGraphTour.ts +1 -1
  91. package/src/structures/ITtscGraphTrace.ts +1 -1
  92. package/src/view.ts +25 -23
@@ -13,19 +13,19 @@ import { ITtscGraphSpan } from "./ITtscGraphSpan";
13
13
  * warm model while project inputs stay unchanged; the bundled 3D viewer reduces
14
14
  * the same dump.
15
15
  *
16
- * `project` is absolute. Every other path is relative to it — `tsconfig`, and
17
- * the `file` fields on nodes, edges, diagnostics, and the provenance manifest.
18
- *
19
- * Two kinds of path fall outside the project and so cannot be relative to it: a
20
- * dependency keeps its `node_modules/`-relative tail, which is what makes a
21
- * dependency leaf readable, and anything else the compiler loaded keeps the
22
- * identity the compiler gave it a virtual lib stays `bundled:///…`.
16
+ * `project` is the producer-local absolute locator. Every identity-bearing path
17
+ * uses one schema-v6 coordinate relative to it: project files are ordinary
18
+ * relative paths; same-filesystem siblings use `../` segments; package files
19
+ * keep their full resolution context (including version/peer-store segments);
20
+ * and a virtual compiler source stays `bundled:///…`. Raw absolute identities
21
+ * are never emitted. A source on another drive or UNC share makes the producer
22
+ * fail unless a future contract supplies a logical root for it.
23
23
  */
24
24
  export interface ITtscGraphDump {
25
25
  /** Absolute path of the project root the graph was built for. */
26
26
  project: string;
27
27
 
28
- /** The tsconfig the program was loaded from, relative to `project`. */
28
+ /** The tsconfig the program was loaded from, in the dump's path vocabulary. */
29
29
  tsconfig: string;
30
30
 
31
31
  /** Evidence about the one program that produced everything below. */
@@ -143,16 +143,16 @@ export namespace ITtscGraphDump {
143
143
 
144
144
  /** A root file attributed to the config that named it. */
145
145
  export interface IRootFile {
146
- /** The tsconfig that named this root, project-relative. */
146
+ /** The tsconfig that named this root, in the dump's path vocabulary. */
147
147
  config: string;
148
148
 
149
- /** The root file, project-relative. */
149
+ /** The root file, in the dump's path vocabulary. */
150
150
  file: string;
151
151
  }
152
152
 
153
153
  /** A file and the hex-encoded SHA-256 of its on-disk bytes. */
154
154
  export interface IFileDigest {
155
- /** Project-relative. */
155
+ /** In the dump's path vocabulary. */
156
156
  file: string;
157
157
 
158
158
  /** Hex-encoded SHA-256. */
@@ -169,7 +169,7 @@ export namespace ITtscGraphDump {
169
169
  * on every build.
170
170
  */
171
171
  export interface ISourceDigest {
172
- /** Project-relative. */
172
+ /** In the dump's path vocabulary. */
173
173
  file: string;
174
174
 
175
175
  /**
@@ -199,7 +199,7 @@ export namespace ITtscGraphDump {
199
199
 
200
200
  /** One compiler diagnostic from the generation that produced the facts. */
201
201
  export interface IDiagnostic {
202
- /** Project-relative. */
202
+ /** In the dump's path vocabulary. */
203
203
  file: string;
204
204
 
205
205
  /** 1-based line. */
@@ -63,12 +63,63 @@ export interface ITtscGraphNode {
63
63
  /** Declaration modifiers, when the declaration pass recorded any. */
64
64
  modifiers?: TtscGraphNodeModifier[];
65
65
 
66
+ /**
67
+ * The complete value set of a type alias or enum whose declared type the
68
+ * checker resolved to literals, each in TypeScript source form (`"a"`, `1`,
69
+ * `true`, `null`).
70
+ *
71
+ * Present only when every constituent is enumerable, so the list is the whole
72
+ * type and never a sample of it: `type T = Kind | string` admits values no
73
+ * list can name and carries none. It is resolved from the type, not read off
74
+ * the declaration, so indirection (`type I = Kind | 'f'`) is followed and the
75
+ * answer does not depend on how the declaration is wrapped.
76
+ */
77
+ literals?: string[];
78
+
79
+ /**
80
+ * What an enum declares, in checker order: the name a caller writes and the
81
+ * value it carries. Absent on every other kind.
82
+ *
83
+ * `literals` says which values the enum admits, which is what a serializer
84
+ * asks. The code says `Colors.Red`, so the names are the other half, and
85
+ * without them a caller that had already named the enum still had to open the
86
+ * file to learn what to type. The members are not nodes — `Colors.Red` is a
87
+ * string a grep finds exactly — so this fills in the node the graph already
88
+ * holds instead of minting one per member.
89
+ */
90
+ enumMembers?: ITtscGraphNode.IEnumMember[];
91
+
92
+ /**
93
+ * Direct, statically named members when this variable is initialized with an
94
+ * object literal, in declaration order.
95
+ *
96
+ * The native builder takes identity from the compiler AST and renders the
97
+ * compact signature from the same Program-owned source snapshot. A spread or
98
+ * dynamic computed name has no declaration name it can report soundly, so it
99
+ * contributes no fabricated member.
100
+ */
101
+ objectMembers?: ITtscGraphNode.IObjectMember[];
102
+
66
103
  /**
67
104
  * Decorators written on this declaration, in source order: raw facts
68
105
  * (`@Controller`, `@Get`) a consumer interprets without re-parsing source.
69
106
  */
70
107
  decorators?: ITtscGraphDecorator[];
71
108
 
109
+ /**
110
+ * The declaration head, cut by the producer where the compiler says the body
111
+ * opens.
112
+ *
113
+ * Absent when the producer could not bound the head, in which case a consumer
114
+ * falls back to reading the declaration span. That fallback is a line scan,
115
+ * and a physical line is not a declaration boundary: it leaks implementation
116
+ * text when a declaration shares its line with its body, and it stops early
117
+ * when the head itself contains a brace — a type-literal parameter, an object
118
+ * return type, a destructured parameter. Prefer this field wherever it is
119
+ * present.
120
+ */
121
+ signature?: string;
122
+
72
123
  /** The declaration span, for display and signatures. */
73
124
  evidence?: ITtscGraphEvidence;
74
125
 
@@ -78,3 +129,32 @@ export interface ITtscGraphNode {
78
129
  */
79
130
  implementation?: ITtscGraphEvidence;
80
131
  }
132
+ export namespace ITtscGraphNode {
133
+ /** One member of an enum: the name a caller writes and the value it carries. */
134
+ export interface IEnumMember {
135
+ /** The member's own name, unqualified (`Red` on `Colors.Red`). */
136
+ name: string;
137
+
138
+ /**
139
+ * The value it carries, in TypeScript source form (`"red"`, `1`). Absent
140
+ * for a computed member the checker could not fold to a constant; the name
141
+ * still stands.
142
+ */
143
+ value?: string;
144
+ }
145
+
146
+ /** One direct, statically named member of an object-literal variable. */
147
+ export interface IObjectMember {
148
+ /** The source-visible static property name. */
149
+ name: string;
150
+
151
+ /** Whether the declaration is a data property or callable/accessor member. */
152
+ kind: "property" | "method";
153
+
154
+ /** 1-based declaration line in the node's file, when source was available. */
155
+ line?: number;
156
+
157
+ /** Compact declaration outline rendered from the compiler source snapshot. */
158
+ signature?: string;
159
+ }
160
+ }
@@ -66,7 +66,7 @@ export namespace ITtscGraphTour {
66
66
  * Central entrypoints to seed the tour. Raise only when the question names
67
67
  * several public paths that must all appear in one answer.
68
68
  *
69
- * @default 4
69
+ * @default 5
70
70
  */
71
71
  limit?: number;
72
72
 
@@ -17,7 +17,7 @@ export interface ITtscGraphTrace {
17
17
  /** Unique nodes reached (excluding the start), each with its depth and roles. */
18
18
  reached: ITtscGraphTrace.INode[];
19
19
 
20
- /** True when the trace hit its node or depth cap; the returned flow stands. */
20
+ /** In an open trace, true when a bound omitted an eligible node or hop. */
21
21
  truncated: boolean;
22
22
 
23
23
  /** The resolved `to` target, when a path was requested. */
package/src/view.ts CHANGED
@@ -3,6 +3,12 @@ import fs from "node:fs";
3
3
  import http from "node:http";
4
4
  import path from "node:path";
5
5
 
6
+ import {
7
+ nonNegativeIntegerOption,
8
+ parseLauncherOptions,
9
+ positiveIntegerOption,
10
+ projectOptions,
11
+ } from "./launcherArgs";
6
12
  import { ensureExecutable } from "./nativeExecutable";
7
13
  import { type RawDump, reduce } from "./reduce";
8
14
  import { resolveGraphBinary } from "./resolveGraphBinary";
@@ -16,30 +22,26 @@ interface ViewOptions {
16
22
  }
17
23
 
18
24
  function parseViewArgs(argv: readonly string[]): ViewOptions {
19
- const opts: ViewOptions = {
20
- cwd: process.cwd(),
21
- tsconfig: "tsconfig.json",
22
- port: 0,
23
- open: true,
24
- maxNodes: 1200,
25
+ const values = parseLauncherOptions(argv, [
26
+ { key: "cwd", flags: ["--cwd"], kind: "value" },
27
+ { key: "tsconfig", flags: ["--tsconfig", "-p"], kind: "value" },
28
+ { key: "port", flags: ["--port"], kind: "value" },
29
+ { key: "open", flags: ["--no-open"], kind: "flag" },
30
+ { key: "max_nodes", flags: ["--max-nodes"], kind: "value" },
31
+ ]);
32
+ const project = projectOptions(values);
33
+ return {
34
+ ...project,
35
+ port:
36
+ values.has("port") === true
37
+ ? nonNegativeIntegerOption(values, "port", 65_535)
38
+ : 0,
39
+ open: values.get("open") !== true,
40
+ maxNodes:
41
+ values.has("max_nodes") === true
42
+ ? positiveIntegerOption(values, "max_nodes", Number.MAX_SAFE_INTEGER)
43
+ : 1200,
25
44
  };
26
- for (let i = 0; i < argv.length; i++) {
27
- const arg = argv[i]!;
28
- if (arg === "--cwd") opts.cwd = argv[++i] ?? opts.cwd;
29
- else if (arg.startsWith("--cwd=")) opts.cwd = arg.slice("--cwd=".length);
30
- else if (arg === "--tsconfig" || arg === "-p")
31
- opts.tsconfig = argv[++i] ?? opts.tsconfig;
32
- else if (arg.startsWith("--tsconfig="))
33
- opts.tsconfig = arg.slice("--tsconfig=".length);
34
- else if (arg === "--port") opts.port = Number(argv[++i]);
35
- else if (arg.startsWith("--port="))
36
- opts.port = Number(arg.slice("--port=".length));
37
- else if (arg === "--no-open") opts.open = false;
38
- else if (arg === "--max-nodes") opts.maxNodes = Number(argv[++i]);
39
- else if (arg.startsWith("--max-nodes="))
40
- opts.maxNodes = Number(arg.slice("--max-nodes=".length));
41
- }
42
- return opts;
43
45
  }
44
46
 
45
47
  /**