@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
@@ -0,0 +1,418 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.loadGraph = loadGraph;
40
+ const _a = __importStar(require("typia/lib/internal/_assertGuard"));
41
+ const node_child_process_1 = require("node:child_process");
42
+ const typia_1 = __importDefault(require("typia"));
43
+ const resolveGraphBinary_1 = require("../resolveGraphBinary");
44
+ const TtscGraphMemory_1 = require("./TtscGraphMemory");
45
+ // A full-project dump is the whole fact graph as one JSON document; a large
46
+ // monorepo runs to many megabytes, well past spawnSync's 1 MiB default, so the
47
+ // buffer is raised to a ceiling no real graph reaches.
48
+ const MAX_DUMP_BYTES = 1024 * 1024 * 1024;
49
+ /**
50
+ * Build the resident {@link TtscGraphMemory} for a project by running `ttscgraph
51
+ * dump` once and loading its JSON. This is the cold path behind the MCP tool
52
+ * calls: one type-check in Go produces the checker-resolved fact graph, then
53
+ * every later tool call is answered from the in-memory model.
54
+ *
55
+ * Throws when the binary cannot be resolved, the dump command fails, or its
56
+ * output is not a readable graph — the server surfaces the failure rather than
57
+ * answering from an empty graph.
58
+ */
59
+ function loadGraph(options = {}) {
60
+ const cwd = options.cwd ?? process.cwd();
61
+ const tsconfig = options.tsconfig ?? "tsconfig.json";
62
+ const binary = options.binary ?? (0, resolveGraphBinary_1.resolveGraphBinary)();
63
+ if (binary === null) {
64
+ throw new Error("@ttsc/graph: could not resolve the ttscgraph binary. " +
65
+ "Install `ttsc` so its platform package is present, " +
66
+ "or set TTSC_GRAPH_BINARY to an absolute path.");
67
+ }
68
+ const result = (0, node_child_process_1.spawnSync)(binary, ["dump", "--cwd", cwd, "--tsconfig", tsconfig], { encoding: "utf8", maxBuffer: MAX_DUMP_BYTES, windowsHide: true });
69
+ if (result.error) {
70
+ throw new Error(`@ttsc/graph: ttscgraph dump failed: ${result.error.message}`);
71
+ }
72
+ if (result.status !== 0) {
73
+ throw new Error(`@ttsc/graph: ttscgraph dump exited with ${result.status}: ${(result.stderr ?? "").trim()}`);
74
+ }
75
+ return TtscGraphMemory_1.TtscGraphMemory.from(parseDump(result.stdout));
76
+ }
77
+ /**
78
+ * Parse and validate `ttscgraph dump` output. typia asserts the full
79
+ * {@link ITtscGraphDump} shape so a malformed or stale dump fails loudly here
80
+ * rather than producing wrong answers downstream, and the schema version is
81
+ * checked so an incompatible producer is refused.
82
+ */
83
+ function parseDump(json) {
84
+ let value;
85
+ try {
86
+ value = JSON.parse(json);
87
+ }
88
+ catch (error) {
89
+ throw new Error(`@ttsc/graph: dump output is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
90
+ }
91
+ return (() => {
92
+ const _iv4 = new Set(["class", "enum", "external_symbol", "file", "function", "interface", "method", "module", "namespace", "package", "parameter", "property", "type", "variable"]);
93
+ const _iv6 = new Set(["abstract", "async", "const", "declare", "default", "export", "optional", "private", "protected", "public", "readonly", "static"]);
94
+ const _iv9 = new Set(["accesses", "calls", "contains", "decorates", "exports", "extends", "implements", "imports", "instantiates", "overrides", "renders", "tests", "type_ref"]);
95
+ const _av13 = new Set(["class", "enum", "external_symbol", "file", "function", "interface", "method", "module", "namespace", "package", "parameter", "property", "type", "variable"]);
96
+ const _av15 = new Set(["abstract", "async", "const", "declare", "default", "export", "optional", "private", "protected", "public", "readonly", "static"]);
97
+ const _av18 = new Set(["accesses", "calls", "contains", "decorates", "exports", "extends", "implements", "imports", "instantiates", "overrides", "renders", "tests", "type_ref"]);
98
+ const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.project || _a._assertGuard(_exceptionable, {
99
+ method: "typia.assert",
100
+ path: _path + ".project",
101
+ expected: "string",
102
+ value: input.project
103
+ }, _errorFactory)) && ("string" === typeof input.tsconfig || _a._assertGuard(_exceptionable, {
104
+ method: "typia.assert",
105
+ path: _path + ".tsconfig",
106
+ expected: "string",
107
+ value: input.tsconfig
108
+ }, _errorFactory)) && ((Array.isArray(input.nodes) || _a._assertGuard(_exceptionable, {
109
+ method: "typia.assert",
110
+ path: _path + ".nodes",
111
+ expected: "Array<ITtscGraphNode>",
112
+ value: input.nodes
113
+ }, _errorFactory)) && input.nodes.every((elem, _index10) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
114
+ method: "typia.assert",
115
+ path: _path + ".nodes[" + _index10 + "]",
116
+ expected: "ITtscGraphNode",
117
+ value: elem
118
+ }, _errorFactory)) && _ao1(elem, _path + ".nodes[" + _index10 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
119
+ method: "typia.assert",
120
+ path: _path + ".nodes[" + _index10 + "]",
121
+ expected: "ITtscGraphNode",
122
+ value: elem
123
+ }, _errorFactory)) || _a._assertGuard(_exceptionable, {
124
+ method: "typia.assert",
125
+ path: _path + ".nodes",
126
+ expected: "Array<ITtscGraphNode>",
127
+ value: input.nodes
128
+ }, _errorFactory)) && ((Array.isArray(input.edges) || _a._assertGuard(_exceptionable, {
129
+ method: "typia.assert",
130
+ path: _path + ".edges",
131
+ expected: "Array<ITtscGraphEdge>",
132
+ value: input.edges
133
+ }, _errorFactory)) && input.edges.every((elem, _index11) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
134
+ method: "typia.assert",
135
+ path: _path + ".edges[" + _index11 + "]",
136
+ expected: "ITtscGraphEdge",
137
+ value: elem
138
+ }, _errorFactory)) && _ao5(elem, _path + ".edges[" + _index11 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
139
+ method: "typia.assert",
140
+ path: _path + ".edges[" + _index11 + "]",
141
+ expected: "ITtscGraphEdge",
142
+ value: elem
143
+ }, _errorFactory)) || _a._assertGuard(_exceptionable, {
144
+ method: "typia.assert",
145
+ path: _path + ".edges",
146
+ expected: "Array<ITtscGraphEdge>",
147
+ value: input.edges
148
+ }, _errorFactory)) && (undefined === input.diagnostics || (Array.isArray(input.diagnostics) || _a._assertGuard(_exceptionable, {
149
+ method: "typia.assert",
150
+ path: _path + ".diagnostics",
151
+ expected: "(Array<ITtscGraphDiagnostic> | undefined)",
152
+ value: input.diagnostics
153
+ }, _errorFactory)) && input.diagnostics.every((elem, _index12) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
154
+ method: "typia.assert",
155
+ path: _path + ".diagnostics[" + _index12 + "]",
156
+ expected: "ITtscGraphDiagnostic",
157
+ value: elem
158
+ }, _errorFactory)) && _ao6(elem, _path + ".diagnostics[" + _index12 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
159
+ method: "typia.assert",
160
+ path: _path + ".diagnostics[" + _index12 + "]",
161
+ expected: "ITtscGraphDiagnostic",
162
+ value: elem
163
+ }, _errorFactory)) || _a._assertGuard(_exceptionable, {
164
+ method: "typia.assert",
165
+ path: _path + ".diagnostics",
166
+ expected: "(Array<ITtscGraphDiagnostic> | undefined)",
167
+ value: input.diagnostics
168
+ }, _errorFactory));
169
+ const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.id || _a._assertGuard(_exceptionable, {
170
+ method: "typia.assert",
171
+ path: _path + ".id",
172
+ expected: "string",
173
+ value: input.id
174
+ }, _errorFactory)) && (true === _av13.has(input.kind) || _a._assertGuard(_exceptionable, {
175
+ method: "typia.assert",
176
+ path: _path + ".kind",
177
+ expected: "(\"class\" | \"enum\" | \"external_symbol\" | \"file\" | \"function\" | \"interface\" | \"method\" | \"module\" | \"namespace\" | \"package\" | \"parameter\" | \"property\" | \"type\" | \"variable\")",
178
+ value: input.kind
179
+ }, _errorFactory)) && ("string" === typeof input.name || _a._assertGuard(_exceptionable, {
180
+ method: "typia.assert",
181
+ path: _path + ".name",
182
+ expected: "string",
183
+ value: input.name
184
+ }, _errorFactory)) && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName || _a._assertGuard(_exceptionable, {
185
+ method: "typia.assert",
186
+ path: _path + ".qualifiedName",
187
+ expected: "(string | undefined)",
188
+ value: input.qualifiedName
189
+ }, _errorFactory)) && ("string" === typeof input.file || _a._assertGuard(_exceptionable, {
190
+ method: "typia.assert",
191
+ path: _path + ".file",
192
+ expected: "string",
193
+ value: input.file
194
+ }, _errorFactory)) && ("boolean" === typeof input.external || _a._assertGuard(_exceptionable, {
195
+ method: "typia.assert",
196
+ path: _path + ".external",
197
+ expected: "boolean",
198
+ value: input.external
199
+ }, _errorFactory)) && (undefined === input.ignored || "boolean" === typeof input.ignored || _a._assertGuard(_exceptionable, {
200
+ method: "typia.assert",
201
+ path: _path + ".ignored",
202
+ expected: "(boolean | undefined)",
203
+ value: input.ignored
204
+ }, _errorFactory)) && (undefined === input.exported || "boolean" === typeof input.exported || _a._assertGuard(_exceptionable, {
205
+ method: "typia.assert",
206
+ path: _path + ".exported",
207
+ expected: "(boolean | undefined)",
208
+ value: input.exported
209
+ }, _errorFactory)) && (undefined === input.modifiers || (Array.isArray(input.modifiers) || _a._assertGuard(_exceptionable, {
210
+ method: "typia.assert",
211
+ path: _path + ".modifiers",
212
+ expected: "(Array<TtscGraphNodeModifier> | undefined)",
213
+ value: input.modifiers
214
+ }, _errorFactory)) && input.modifiers.every((elem, _index14) => true === _av15.has(elem) || _a._assertGuard(_exceptionable, {
215
+ method: "typia.assert",
216
+ path: _path + ".modifiers[" + _index14 + "]",
217
+ expected: "(\"abstract\" | \"async\" | \"const\" | \"declare\" | \"default\" | \"export\" | \"optional\" | \"private\" | \"protected\" | \"public\" | \"readonly\" | \"static\")",
218
+ value: elem
219
+ }, _errorFactory)) || _a._assertGuard(_exceptionable, {
220
+ method: "typia.assert",
221
+ path: _path + ".modifiers",
222
+ expected: "(Array<TtscGraphNodeModifier> | undefined)",
223
+ value: input.modifiers
224
+ }, _errorFactory)) && (undefined === input.decorators || (Array.isArray(input.decorators) || _a._assertGuard(_exceptionable, {
225
+ method: "typia.assert",
226
+ path: _path + ".decorators",
227
+ expected: "(Array<ITtscGraphDecorator> | undefined)",
228
+ value: input.decorators
229
+ }, _errorFactory)) && input.decorators.every((elem, _index16) => ("object" === typeof elem && null !== elem || _a._assertGuard(_exceptionable, {
230
+ method: "typia.assert",
231
+ path: _path + ".decorators[" + _index16 + "]",
232
+ expected: "ITtscGraphDecorator",
233
+ value: elem
234
+ }, _errorFactory)) && _ao2(elem, _path + ".decorators[" + _index16 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
235
+ method: "typia.assert",
236
+ path: _path + ".decorators[" + _index16 + "]",
237
+ expected: "ITtscGraphDecorator",
238
+ value: elem
239
+ }, _errorFactory)) || _a._assertGuard(_exceptionable, {
240
+ method: "typia.assert",
241
+ path: _path + ".decorators",
242
+ expected: "(Array<ITtscGraphDecorator> | undefined)",
243
+ value: input.decorators
244
+ }, _errorFactory)) && (undefined === input.evidence || ("object" === typeof input.evidence && null !== input.evidence || _a._assertGuard(_exceptionable, {
245
+ method: "typia.assert",
246
+ path: _path + ".evidence",
247
+ expected: "(ITtscGraphEvidence | undefined)",
248
+ value: input.evidence
249
+ }, _errorFactory)) && _ao4(input.evidence, _path + ".evidence", true && _exceptionable) || _a._assertGuard(_exceptionable, {
250
+ method: "typia.assert",
251
+ path: _path + ".evidence",
252
+ expected: "(ITtscGraphEvidence | undefined)",
253
+ value: input.evidence
254
+ }, _errorFactory)) && (undefined === input.implementation || ("object" === typeof input.implementation && null !== input.implementation || _a._assertGuard(_exceptionable, {
255
+ method: "typia.assert",
256
+ path: _path + ".implementation",
257
+ expected: "(ITtscGraphEvidence | undefined)",
258
+ value: input.implementation
259
+ }, _errorFactory)) && _ao4(input.implementation, _path + ".implementation", true && _exceptionable) || _a._assertGuard(_exceptionable, {
260
+ method: "typia.assert",
261
+ path: _path + ".implementation",
262
+ expected: "(ITtscGraphEvidence | undefined)",
263
+ value: input.implementation
264
+ }, _errorFactory));
265
+ const _ao2 = (input, _path, _exceptionable = true) => ("string" === typeof input.name || _a._assertGuard(_exceptionable, {
266
+ method: "typia.assert",
267
+ path: _path + ".name",
268
+ expected: "string",
269
+ value: input.name
270
+ }, _errorFactory)) && ((Array.isArray(input.arguments) || _a._assertGuard(_exceptionable, {
271
+ method: "typia.assert",
272
+ path: _path + ".arguments",
273
+ expected: "Array<ITtscGraphDecorator.IArgument>",
274
+ value: input.arguments
275
+ }, _errorFactory)) && input.arguments.every((elem, _index17) => ("object" === typeof elem && null !== elem && false === Array.isArray(elem) || _a._assertGuard(_exceptionable, {
276
+ method: "typia.assert",
277
+ path: _path + ".arguments[" + _index17 + "]",
278
+ expected: "ITtscGraphDecorator.IArgument",
279
+ value: elem
280
+ }, _errorFactory)) && _ao3(elem, _path + ".arguments[" + _index17 + "]", true && _exceptionable) || _a._assertGuard(_exceptionable, {
281
+ method: "typia.assert",
282
+ path: _path + ".arguments[" + _index17 + "]",
283
+ expected: "ITtscGraphDecorator.IArgument",
284
+ value: elem
285
+ }, _errorFactory)) || _a._assertGuard(_exceptionable, {
286
+ method: "typia.assert",
287
+ path: _path + ".arguments",
288
+ expected: "Array<ITtscGraphDecorator.IArgument>",
289
+ value: input.arguments
290
+ }, _errorFactory));
291
+ const _ao3 = (input, _path, _exceptionable = true) => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal || _a._assertGuard(_exceptionable, {
292
+ method: "typia.assert",
293
+ path: _path + ".literal",
294
+ expected: "(boolean | number | string | undefined)",
295
+ value: input.literal
296
+ }, _errorFactory);
297
+ const _ao4 = (input, _path, _exceptionable = true) => ("string" === typeof input.file || _a._assertGuard(_exceptionable, {
298
+ method: "typia.assert",
299
+ path: _path + ".file",
300
+ expected: "string",
301
+ value: input.file
302
+ }, _errorFactory)) && ("number" === typeof input.startLine || _a._assertGuard(_exceptionable, {
303
+ method: "typia.assert",
304
+ path: _path + ".startLine",
305
+ expected: "number",
306
+ value: input.startLine
307
+ }, _errorFactory)) && (undefined === input.startCol || "number" === typeof input.startCol || _a._assertGuard(_exceptionable, {
308
+ method: "typia.assert",
309
+ path: _path + ".startCol",
310
+ expected: "(number | undefined)",
311
+ value: input.startCol
312
+ }, _errorFactory)) && (undefined === input.endLine || "number" === typeof input.endLine || _a._assertGuard(_exceptionable, {
313
+ method: "typia.assert",
314
+ path: _path + ".endLine",
315
+ expected: "(number | undefined)",
316
+ value: input.endLine
317
+ }, _errorFactory)) && (undefined === input.endCol || "number" === typeof input.endCol || _a._assertGuard(_exceptionable, {
318
+ method: "typia.assert",
319
+ path: _path + ".endCol",
320
+ expected: "(number | undefined)",
321
+ value: input.endCol
322
+ }, _errorFactory));
323
+ const _ao5 = (input, _path, _exceptionable = true) => ("string" === typeof input.from || _a._assertGuard(_exceptionable, {
324
+ method: "typia.assert",
325
+ path: _path + ".from",
326
+ expected: "string",
327
+ value: input.from
328
+ }, _errorFactory)) && ("string" === typeof input.to || _a._assertGuard(_exceptionable, {
329
+ method: "typia.assert",
330
+ path: _path + ".to",
331
+ expected: "string",
332
+ value: input.to
333
+ }, _errorFactory)) && (true === _av18.has(input.kind) || _a._assertGuard(_exceptionable, {
334
+ method: "typia.assert",
335
+ path: _path + ".kind",
336
+ expected: "(\"accesses\" | \"calls\" | \"contains\" | \"decorates\" | \"exports\" | \"extends\" | \"implements\" | \"imports\" | \"instantiates\" | \"overrides\" | \"renders\" | \"tests\" | \"type_ref\")",
337
+ value: input.kind
338
+ }, _errorFactory)) && (undefined === input.evidence || ("object" === typeof input.evidence && null !== input.evidence || _a._assertGuard(_exceptionable, {
339
+ method: "typia.assert",
340
+ path: _path + ".evidence",
341
+ expected: "(ITtscGraphEvidence | undefined)",
342
+ value: input.evidence
343
+ }, _errorFactory)) && _ao4(input.evidence, _path + ".evidence", true && _exceptionable) || _a._assertGuard(_exceptionable, {
344
+ method: "typia.assert",
345
+ path: _path + ".evidence",
346
+ expected: "(ITtscGraphEvidence | undefined)",
347
+ value: input.evidence
348
+ }, _errorFactory));
349
+ const _ao6 = (input, _path, _exceptionable = true) => ("string" === typeof input.file || _a._assertGuard(_exceptionable, {
350
+ method: "typia.assert",
351
+ path: _path + ".file",
352
+ expected: "string",
353
+ value: input.file
354
+ }, _errorFactory)) && ("number" === typeof input.line || _a._assertGuard(_exceptionable, {
355
+ method: "typia.assert",
356
+ path: _path + ".line",
357
+ expected: "number",
358
+ value: input.line
359
+ }, _errorFactory)) && (undefined === input.column || "number" === typeof input.column || _a._assertGuard(_exceptionable, {
360
+ method: "typia.assert",
361
+ path: _path + ".column",
362
+ expected: "(number | undefined)",
363
+ value: input.column
364
+ }, _errorFactory)) && ("string" === typeof input.code || "number" === typeof input.code || _a._assertGuard(_exceptionable, {
365
+ method: "typia.assert",
366
+ path: _path + ".code",
367
+ expected: "(number | string)",
368
+ value: input.code
369
+ }, _errorFactory)) && ("string" === typeof input.message || _a._assertGuard(_exceptionable, {
370
+ method: "typia.assert",
371
+ path: _path + ".message",
372
+ expected: "string",
373
+ value: input.message
374
+ }, _errorFactory)) && (undefined === input.severity || "error" === input.severity || "hint" === input.severity || "info" === input.severity || "warning" === input.severity || _a._assertGuard(_exceptionable, {
375
+ method: "typia.assert",
376
+ path: _path + ".severity",
377
+ expected: "(\"error\" | \"hint\" | \"info\" | \"warning\" | undefined)",
378
+ value: input.severity
379
+ }, _errorFactory)) && (undefined === input.origin || "lint" === input.origin || "plugin" === input.origin || "tsc" === input.origin || _a._assertGuard(_exceptionable, {
380
+ method: "typia.assert",
381
+ path: _path + ".origin",
382
+ expected: "(\"lint\" | \"plugin\" | \"tsc\" | undefined)",
383
+ value: input.origin
384
+ }, _errorFactory)) && (undefined === input.node || "string" === typeof input.node || _a._assertGuard(_exceptionable, {
385
+ method: "typia.assert",
386
+ path: _path + ".node",
387
+ expected: "(string | undefined)",
388
+ value: input.node
389
+ }, _errorFactory));
390
+ const _io0 = input => "string" === typeof input.project && "string" === typeof input.tsconfig && (Array.isArray(input.nodes) && input.nodes.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && (Array.isArray(input.edges) && input.edges.every(elem => "object" === typeof elem && null !== elem && _io5(elem))) && (undefined === input.diagnostics || Array.isArray(input.diagnostics) && input.diagnostics.every(elem => "object" === typeof elem && null !== elem && _io6(elem)));
391
+ const _io1 = input => "string" === typeof input.id && true === _iv4.has(input.kind) && "string" === typeof input.name && (undefined === input.qualifiedName || "string" === typeof input.qualifiedName) && "string" === typeof input.file && "boolean" === typeof input.external && (undefined === input.ignored || "boolean" === typeof input.ignored) && (undefined === input.exported || "boolean" === typeof input.exported) && (undefined === input.modifiers || Array.isArray(input.modifiers) && input.modifiers.every(elem => true === _iv6.has(elem))) && (undefined === input.decorators || Array.isArray(input.decorators) && input.decorators.every(elem => "object" === typeof elem && null !== elem && _io2(elem))) && (undefined === input.evidence || "object" === typeof input.evidence && null !== input.evidence && _io4(input.evidence)) && (undefined === input.implementation || "object" === typeof input.implementation && null !== input.implementation && _io4(input.implementation));
392
+ const _io2 = input => "string" === typeof input.name && (Array.isArray(input.arguments) && input.arguments.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io3(elem)));
393
+ const _io3 = input => undefined === input.literal || "string" === typeof input.literal || "number" === typeof input.literal || "boolean" === typeof input.literal;
394
+ const _io4 = input => "string" === typeof input.file && "number" === typeof input.startLine && (undefined === input.startCol || "number" === typeof input.startCol) && (undefined === input.endLine || "number" === typeof input.endLine) && (undefined === input.endCol || "number" === typeof input.endCol);
395
+ const _io5 = input => "string" === typeof input.from && "string" === typeof input.to && true === _iv9.has(input.kind) && (undefined === input.evidence || "object" === typeof input.evidence && null !== input.evidence && _io4(input.evidence));
396
+ const _io6 = input => "string" === typeof input.file && "number" === typeof input.line && (undefined === input.column || "number" === typeof input.column) && ("string" === typeof input.code || "number" === typeof input.code) && "string" === typeof input.message && (undefined === input.severity || "error" === input.severity || "hint" === input.severity || "info" === input.severity || "warning" === input.severity) && (undefined === input.origin || "lint" === input.origin || "plugin" === input.origin || "tsc" === input.origin) && (undefined === input.node || "string" === typeof input.node);
397
+ const __is = input => "object" === typeof input && null !== input && _io0(input);
398
+ let _errorFactory;
399
+ return (input, errorFactory) => {
400
+ if (false === __is(input)) {
401
+ _errorFactory = errorFactory;
402
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _a._assertGuard(true, {
403
+ method: "typia.assert",
404
+ path: _path + "",
405
+ expected: "ITtscGraphDump",
406
+ value: input
407
+ }, _errorFactory)) && _ao0(input, _path + "", true) || _a._assertGuard(true, {
408
+ method: "typia.assert",
409
+ path: _path + "",
410
+ expected: "ITtscGraphDump",
411
+ value: input
412
+ }, _errorFactory))(input, "$input", true);
413
+ }
414
+ return input;
415
+ };
416
+ })()(value);
417
+ }
418
+ //# sourceMappingURL=loadGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadGraph.js","sourceRoot":"","sources":["../../src/model/loadGraph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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D,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,+CACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;IACJ,CAAC;IACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAoC,KAAK,EAAE;AAC7C,CAAC"}
package/lib/reduce.js ADDED
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ // Reduce a raw `ttscgraph dump` to the payload the bundled 3D viewer renders.
3
+ // This mirrors website/src/components/graph/graphReduce.ts (the same pure
4
+ // transform); keep the two in sync. The CLI reduces in Node before serving, so
5
+ // the browser viewer only ever renders a ready `{ nodes, links }`.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.reduce = reduce;
8
+ function posix(p) {
9
+ return p.replace(/\\/g, "/");
10
+ }
11
+ function commonRoot(files) {
12
+ if (files.length === 0)
13
+ return "";
14
+ let parts = posix(files[0]).split("/");
15
+ for (const file of files.slice(1)) {
16
+ const other = posix(file).split("/");
17
+ let i = 0;
18
+ while (i < parts.length && i < other.length && parts[i] === other[i])
19
+ i++;
20
+ parts = parts.slice(0, i);
21
+ if (parts.length === 0)
22
+ break;
23
+ }
24
+ return parts.join("/");
25
+ }
26
+ function relativize(abs, root) {
27
+ const a = posix(abs);
28
+ const r = posix(root).replace(/\/+$/, "");
29
+ if (r && (a === r || a.startsWith(r + "/")))
30
+ return a.slice(r.length).replace(/^\/+/, "");
31
+ const nm = a.lastIndexOf("node_modules/");
32
+ if (nm >= 0)
33
+ return a.slice(nm);
34
+ const slash = a.lastIndexOf("/");
35
+ return slash >= 0 ? a.slice(slash + 1) : a;
36
+ }
37
+ function rewriteId(id, root) {
38
+ const hash = id.indexOf("#");
39
+ if (hash < 0)
40
+ return id;
41
+ return relativize(id.slice(0, hash), root) + id.slice(hash);
42
+ }
43
+ function degreeOf(nodes, edges) {
44
+ const degree = new Map(nodes.map((n) => [n.id, 0]));
45
+ for (const e of edges) {
46
+ if (degree.has(e.from))
47
+ degree.set(e.from, degree.get(e.from) + 1);
48
+ if (degree.has(e.to))
49
+ degree.set(e.to, degree.get(e.to) + 1);
50
+ }
51
+ return degree;
52
+ }
53
+ function reduce(raw, { maxNodes = 1200, keepExternal = false, } = {}) {
54
+ const keptByExternal = raw.nodes.filter((n) => keepExternal || !n.external);
55
+ const root = commonRoot(raw.nodes.filter((n) => !n.external).map((n) => n.file));
56
+ const liveIds = new Set(keptByExternal.map((n) => n.id));
57
+ const liveEdges = raw.edges.filter((e) => liveIds.has(e.from) && liveIds.has(e.to));
58
+ const degree = degreeOf(keptByExternal, liveEdges);
59
+ let kept = keptByExternal;
60
+ let droppedByCap = 0;
61
+ if (kept.length > maxNodes) {
62
+ kept = [...kept]
63
+ .sort((a, b) => (degree.get(b.id) ?? 0) - (degree.get(a.id) ?? 0))
64
+ .slice(0, maxNodes);
65
+ droppedByCap = keptByExternal.length - kept.length;
66
+ }
67
+ const keptIds = new Set(kept.map((n) => n.id));
68
+ const edges = liveEdges.filter((e) => keptIds.has(e.from) && keptIds.has(e.to));
69
+ const finalDegree = degreeOf(kept, edges);
70
+ const nodes = kept
71
+ .filter((n) => (finalDegree.get(n.id) ?? 0) > 0)
72
+ .map((n) => ({
73
+ id: rewriteId(n.id, root),
74
+ name: n.name,
75
+ kind: n.kind,
76
+ file: relativize(n.file, root),
77
+ degree: finalDegree.get(n.id) ?? 0,
78
+ }));
79
+ const nodeIds = new Set(nodes.map((n) => n.id));
80
+ const links = edges
81
+ .map((e) => ({
82
+ source: rewriteId(e.from, root),
83
+ target: rewriteId(e.to, root),
84
+ kind: e.kind,
85
+ }))
86
+ .filter((e) => nodeIds.has(e.source) && nodeIds.has(e.target));
87
+ return {
88
+ project: raw.project ?? "",
89
+ counts: {
90
+ rawNodes: raw.nodes.length,
91
+ rawEdges: raw.edges.length,
92
+ nodes: nodes.length,
93
+ links: links.length,
94
+ droppedExternal: raw.nodes.length - keptByExternal.length,
95
+ droppedByCap,
96
+ },
97
+ nodes,
98
+ links,
99
+ };
100
+ }
101
+ //# sourceMappingURL=reduce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reduce.js","sourceRoot":"","sources":["../src/reduce.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,+EAA+E;AAC/E,mEAAmE;;;AAkDnE,SAAS,KAAK,CAAC,CAAS;IACtB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,UAAU,CAAC,KAAe;IACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,C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,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjE,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;QAC1B,MAAM,EAAE;YACN,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM;YAC1B,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM;YAC1B,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,eAAe,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM;YACzD,YAAY;SACb;QACD,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveGraphBinary = resolveGraphBinary;
7
+ const node_module_1 = require("node:module");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ /**
10
+ * Resolve the per-platform `ttscgraph` binary, or `null` when it cannot be
11
+ * located.
12
+ *
13
+ * `ttsc` is a peer the user installs alongside `@ttsc/graph` (not a dependency
14
+ * of this launcher), so resolution starts from the user's project, not from
15
+ * this package's own tree.
16
+ *
17
+ * Resolution order:
18
+ *
19
+ * 1. `TTSC_GRAPH_BINARY` env var, when set to an absolute path.
20
+ * 2. The per-platform npm package `@ttsc/<platform>-<arch>/bin/ttscgraph[.exe]`.
21
+ * That package carries `ttsc`, `ttscserver`, and `ttscgraph` together and is
22
+ * an `optionalDependency` of `ttsc`, so it is resolved from `ttsc`'s
23
+ * location — found from `process.cwd()` (the project where the agent ran the
24
+ * server).
25
+ */
26
+ function resolveGraphBinary(env = process.env, cwd = process.cwd()) {
27
+ if (env.TTSC_GRAPH_BINARY && node_path_1.default.isAbsolute(env.TTSC_GRAPH_BINARY)) {
28
+ return env.TTSC_GRAPH_BINARY;
29
+ }
30
+ const exe = process.platform === "win32" ? "ttscgraph.exe" : "ttscgraph";
31
+ try {
32
+ const ttscPackageJson = require.resolve("ttsc/package.json", {
33
+ paths: [cwd],
34
+ });
35
+ const fromTtsc = (0, node_module_1.createRequire)(ttscPackageJson);
36
+ return fromTtsc.resolve(`@ttsc/${process.platform}-${process.arch}/bin/${exe}`);
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ }
42
+ //# sourceMappingURL=resolveGraphBinary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveGraphBinary.js","sourceRoot":"","sources":["../src/resolveGraphBinary.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,0DAA6B;AAE7B;;;;;;;;;;;;;;;;GAgBG;AACH,4BACE,GAAG,GAAsB,OAAO,CAAC,GAAG,EACpC,GAAG,GAAW,OAAO,CAAC,GAAG,EAAE;IAE3B,IAAI,GAAG,CAAC,iBAAiB,IAAI,mBAAI,CAAC,UAAU,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACpE,OAAO,GAAG,CAAC,iBAAiB,CAAC;IAC/B,CAAC;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC;IACzE,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE;YAC3D,KAAK,EAAE,CAAC,GAAG,CAAC;SACb,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,IAAA,2BAAa,EAAC,eAAe,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,OAAO,CACrB,SAAS,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,QAAQ,GAAG,EAAE,CACvD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.accessAliasesFor = accessAliasesFor;
4
+ /**
5
+ * Derive stable access-path aliases for a member edge from its source
6
+ * expression. If a hop reaches `Owner.member` through `obj.path.member`, the
7
+ * alias `Owner.path.member` keeps both the resolved owner and the concrete
8
+ * access path visible without reopening source.
9
+ */
10
+ function accessAliasesFor(node, evidenceText) {
11
+ if (node === undefined ||
12
+ node.qualifiedName === undefined ||
13
+ evidenceText === undefined) {
14
+ return undefined;
15
+ }
16
+ const segments = dottedSegments(evidenceText);
17
+ if (segments.length < 2 || segments[segments.length - 1] !== node.name) {
18
+ return undefined;
19
+ }
20
+ const dot = node.qualifiedName.lastIndexOf(".");
21
+ if (dot < 0)
22
+ return undefined;
23
+ const owner = node.qualifiedName.slice(0, dot);
24
+ const suffix = segments.slice(1).join(".");
25
+ const aliases = new Set();
26
+ for (const candidate of [...ownerDisplayAliases(owner), owner]) {
27
+ const alias = `${candidate}.${suffix}`;
28
+ if (alias !== node.qualifiedName)
29
+ aliases.add(alias);
30
+ }
31
+ return aliases.size > 0 ? [...aliases] : undefined;
32
+ }
33
+ function dottedSegments(text) {
34
+ const normalized = text.trim().replace(/\?\./g, ".");
35
+ const parts = normalized.split(".");
36
+ if (parts.length < 2)
37
+ return [];
38
+ return parts.every((part) => /^[A-Za-z_$][\w$]*$/.test(part)) ? parts : [];
39
+ }
40
+ function ownerDisplayAliases(owner) {
41
+ const display = owner.replace(/^_+/, "");
42
+ const out = new Set();
43
+ for (const suffix of ["Internals", "Internal"]) {
44
+ if (display.length > suffix.length && display.endsWith(suffix)) {
45
+ out.add(display.slice(0, -suffix.length));
46
+ }
47
+ }
48
+ if (out.size === 0 && display !== owner)
49
+ out.add(display);
50
+ out.delete(owner);
51
+ return [...out];
52
+ }
53
+ //# sourceMappingURL=accessAliases.js.map
@@ -0,0 +1 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