@nexiq/extension-sdk 1.0.3 → 1.0.7

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/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "moduleResolution": "NodeNext",
6
6
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
7
7
  "declaration": true,
8
+ "sourceMap": true,
8
9
  "rootDir": "src",
9
10
  "outDir": "dist",
10
11
  "strict": true,
@@ -12,11 +13,14 @@
12
13
  "skipLibCheck": true,
13
14
  "forceConsistentCasingInFileNames": true,
14
15
  "jsx": "react-jsx",
15
- "baseUrl": ".",
16
+ "isolatedModules": true,
17
+ "verbatimModuleSyntax": true,
18
+ "moduleDetection": "force",
19
+ "types": ["node"],
16
20
  "paths": {
17
21
  "@nexiq/shared": ["../shared/dist/index.d.ts"],
18
22
  "@nexiq/shared/*": ["../shared/dist/*"]
19
- }
23
+ },
20
24
  },
21
25
  "include": ["src"]
22
26
  }
@@ -1,2 +0,0 @@
1
- import { type GraphViewTask } from "../index.js";
2
- export declare const componentTask: GraphViewTask;
@@ -1,332 +0,0 @@
1
- export const componentTask = {
2
- id: "component-structure",
3
- priority: 10,
4
- run: (data, result, batch) => {
5
- const combos = [...result.combos];
6
- const nodes = [...result.nodes];
7
- const edges = [...result.edges];
8
- const typeData = { ...result.typeData };
9
- const scopes = batch?.scopes || data.scopes || [];
10
- const symbols = batch?.symbols || data.symbols || [];
11
- const relations = batch?.relations || data.relations || [];
12
- const renders = batch?.renders || data.renders || [];
13
- const files = data.files || [];
14
- const fileMap = new Map(files.map((f) => [f.id, f.path]));
15
- // Identify automatic JSX symbols and their entities to skip them and their scopes
16
- const automaticJsxEntities = new Set();
17
- for (const symbol of symbols) {
18
- if (symbol.name.startsWith("jsx@")) {
19
- automaticJsxEntities.add(symbol.entity_id);
20
- }
21
- }
22
- // Build Export Map: Map<filePath, Map<exportName, symbolId>>
23
- const exportMap = new Map();
24
- for (const exp of data.exports) {
25
- const scope = data.scopes.find((s) => s.id === exp.scope_id);
26
- if (!scope)
27
- continue;
28
- const filePath = fileMap.get(scope.file_id);
29
- if (!filePath)
30
- continue;
31
- if (!exportMap.has(filePath)) {
32
- exportMap.set(filePath, new Map());
33
- }
34
- if (exp.symbol_id) {
35
- exportMap
36
- .get(filePath)
37
- .set(exp.is_default ? "default" : exp.name, exp.symbol_id);
38
- }
39
- }
40
- // Build Redirection Map: Map<importSymbolId, actualSymbolId>
41
- const redirectionMap = new Map();
42
- for (const symbol of data.symbols) {
43
- const entity = data.entities.find((e) => e.id === symbol.entity_id);
44
- if (entity?.kind === "import" && entity.data_json) {
45
- try {
46
- const impData = JSON.parse(entity.data_json);
47
- const sourcePath = impData.source;
48
- const importedName = impData.type === "default" ? "default" : impData.importedName;
49
- const targetSymbolId = exportMap.get(sourcePath)?.get(importedName);
50
- if (targetSymbolId) {
51
- redirectionMap.set(symbol.id, targetSymbolId);
52
- }
53
- }
54
- catch {
55
- // ignore
56
- }
57
- }
58
- }
59
- // 1. Map Scopes to Combos
60
- for (const scope of scopes) {
61
- if (scope.kind === "module")
62
- continue;
63
- if (combos.some((c) => c.id === scope.id))
64
- continue;
65
- // Skip scopes belonging to automatic JSX elements
66
- if (scope.entity_id && automaticJsxEntities.has(scope.entity_id))
67
- continue;
68
- const parentScope = data.scopes.find((s) => s.id === scope.parent_id);
69
- const parentComboId = parentScope && parentScope.kind !== "module"
70
- ? scope.parent_id
71
- : undefined;
72
- combos.push({
73
- id: scope.id,
74
- name: scope.kind,
75
- label: { text: scope.kind },
76
- combo: parentComboId || undefined,
77
- type: "scope",
78
- collapsed: true,
79
- });
80
- }
81
- // 2. Map Symbols to Nodes/Labels
82
- for (const symbol of symbols) {
83
- if (nodes.some((n) => n.id === symbol.id) ||
84
- combos.some((c) => c.id === symbol.id))
85
- continue;
86
- // Skip automatic JSX symbols to avoid clutter
87
- if (symbol.name.startsWith("jsx@"))
88
- continue;
89
- const entity = data.entities.find((e) => e.id === symbol.entity_id);
90
- if (!entity)
91
- continue;
92
- // Skip imports
93
- if (entity.kind === "import")
94
- continue;
95
- // Skip state setters (index 1 of the state array) to avoid showing both state and setter as separate nodes
96
- if (entity.kind === "state" && symbol.path) {
97
- try {
98
- const pathArr = JSON.parse(symbol.path);
99
- if (Array.isArray(pathArr) &&
100
- pathArr.length > 0 &&
101
- pathArr[0] !== "0") {
102
- continue;
103
- }
104
- }
105
- catch {
106
- // ignore
107
- }
108
- }
109
- const scope = data.scopes.find((s) => s.id === symbol.scope_id);
110
- const file = scope ? fileMap.get(scope.file_id) : undefined;
111
- // Check if this symbol's entity has an associated scope (e.g. the body)
112
- const blockScope = data.scopes.find((s) => s.entity_id === entity.id);
113
- if (blockScope) {
114
- // This symbol represents a scope (e.g. function body)
115
- // We update the combo created for this scope
116
- const combo = combos.find((c) => c.id === blockScope.id);
117
- if (combo) {
118
- combo.label = { text: symbol.name };
119
- combo.displayName = symbol.name;
120
- combo.type = entity.kind;
121
- combo.fileName = file;
122
- combo.loc = { line: entity.line || 0, column: entity.column || 0 };
123
- // Handle effects for this component/hook
124
- if (entity.data_json) {
125
- try {
126
- const metadata = JSON.parse(entity.data_json);
127
- if (metadata.effects) {
128
- for (const effect of Object.values(metadata.effects)) {
129
- const effectName = effect.name || "useEffect";
130
- nodes.push({
131
- id: effect.id,
132
- name: effectName,
133
- label: { text: effectName },
134
- combo: blockScope.id,
135
- type: "effect",
136
- fileName: file,
137
- loc: { line: effect.loc.line, column: effect.loc.column },
138
- displayName: effectName,
139
- });
140
- if (effect.reactDeps) {
141
- for (const dep of effect.reactDeps) {
142
- const targetId = redirectionMap.get(dep.id) || dep.id;
143
- if (targetId) {
144
- edges.push({
145
- id: `${targetId}-${effect.id}-effect-dep`,
146
- source: targetId,
147
- target: effect.id,
148
- label: "dependency",
149
- });
150
- }
151
- }
152
- }
153
- }
154
- }
155
- }
156
- catch {
157
- // ignore
158
- }
159
- }
160
- }
161
- }
162
- else {
163
- // Handle destructuring paths to group variables and reduce clutter
164
- let parentComboId = scope && scope.kind !== "module" ? symbol.scope_id : undefined;
165
- if (symbol.path && entity.kind !== "state") {
166
- try {
167
- const pathArr = JSON.parse(symbol.path);
168
- if (Array.isArray(pathArr) && pathArr.length >= 1) {
169
- // 1. Create a "source" combo for the entity (e.g., the hook call or variable)
170
- const sourceComboId = `${symbol.scope_id}:source:${symbol.entity_id}`;
171
- if (!combos.some((c) => c.id === sourceComboId)) {
172
- let sourceLabel = entity.name || entity.kind;
173
- if (entity.kind === "hook" && entity.data_json) {
174
- try {
175
- const meta = JSON.parse(entity.data_json);
176
- if (meta.call?.name)
177
- sourceLabel = meta.call.name;
178
- }
179
- catch {
180
- // ignore
181
- }
182
- }
183
- combos.push({
184
- id: sourceComboId,
185
- name: sourceLabel,
186
- label: { text: sourceLabel },
187
- combo: parentComboId,
188
- type: "source-group",
189
- collapsed: true,
190
- });
191
- }
192
- parentComboId = sourceComboId;
193
- // 2. Create intermediate combos for each segment of the path except the last one
194
- for (let i = 0; i < pathArr.length - 1; i++) {
195
- const segment = pathArr[i];
196
- // Use a stable ID for the path combo nested under the source combo
197
- const segmentId = `${sourceComboId}:path:${pathArr
198
- .slice(0, i + 1)
199
- .join("/")}`;
200
- if (!combos.some((c) => c.id === segmentId)) {
201
- combos.push({
202
- id: segmentId,
203
- name: segment.toString(),
204
- label: { text: segment.toString() },
205
- combo: parentComboId,
206
- type: "path-group",
207
- collapsed: true,
208
- });
209
- }
210
- parentComboId = segmentId;
211
- }
212
- }
213
- }
214
- catch {
215
- // ignore invalid path JSON
216
- }
217
- }
218
- const labelText = symbol.name;
219
- // Handle reactDeps and special labeling for hooks
220
- if (entity.data_json) {
221
- try {
222
- const metadata = JSON.parse(entity.data_json);
223
- if (metadata.reactDeps) {
224
- for (const dep of metadata.reactDeps) {
225
- const targetId = redirectionMap.get(dep.id) || dep.id;
226
- if (targetId) {
227
- edges.push({
228
- id: `${targetId}-${symbol.id}-react-dep`,
229
- source: targetId,
230
- target: symbol.id,
231
- label: "dependency",
232
- });
233
- }
234
- }
235
- }
236
- }
237
- catch {
238
- // ignore
239
- }
240
- }
241
- nodes.push({
242
- id: symbol.id,
243
- name: symbol.name,
244
- label: { text: labelText },
245
- combo: parentComboId,
246
- type: entity.kind,
247
- fileName: file,
248
- loc: { line: entity.line || 0, column: entity.column || 0 },
249
- displayName: symbol.name,
250
- });
251
- }
252
- }
253
- // 3. Handle Renders (JSX)
254
- for (const render of renders) {
255
- if (nodes.some((n) => n.id === render.id) ||
256
- combos.some((c) => c.id === render.id))
257
- continue;
258
- const file = fileMap.get(render.file_id);
259
- const parentScope = data.scopes.find((s) => s.entity_id === render.parent_entity_id);
260
- const parentCombo = parentScope?.id;
261
- // Create a "render" group combo within the parent combo if not exists
262
- let finalParentCombo = render.parent_render_id ?? parentCombo;
263
- if (parentCombo && !render.parent_render_id) {
264
- const renderGroupId = `render-group-${parentCombo}`;
265
- if (!combos.some((c) => c.id === renderGroupId)) {
266
- combos.push({
267
- id: renderGroupId,
268
- name: "render",
269
- label: { text: "render" },
270
- combo: parentCombo,
271
- type: "render-group",
272
- collapsed: true,
273
- });
274
- }
275
- finalParentCombo = renderGroupId;
276
- }
277
- const labelText = render.tag;
278
- const commonData = {
279
- id: render.id,
280
- name: render.tag,
281
- label: { text: labelText },
282
- combo: finalParentCombo,
283
- type: "render",
284
- fileName: file,
285
- loc: { line: render.line || 0, column: render.column || 0 },
286
- displayName: render.tag,
287
- };
288
- // Renders are now nodes that stack within the component combo
289
- combos.push(commonData);
290
- // Add edge for JSX hierarchy
291
- // if (render.parent_render_id) {
292
- // edges.push({
293
- // id: `${render.parent_render_id}-${render.id}-nesting`,
294
- // source: render.parent_render_id,
295
- // target: render.id,
296
- // label: "nesting",
297
- // });
298
- // }
299
- // if (render.symbol_id) {
300
- // const targetId =
301
- // redirectionMap.get(render.symbol_id) || render.symbol_id;
302
- // edges.push({
303
- // id: `${render.id}-${targetId}`,
304
- // source: render.id,
305
- // target: targetId,
306
- // label: "reference",
307
- // });
308
- // }
309
- }
310
- // 4. Handle Relations (Edges)
311
- for (const rel of relations) {
312
- const sourceId = redirectionMap.get(rel.from_id) || rel.from_id;
313
- const targetId = redirectionMap.get(rel.to_id) || rel.to_id;
314
- const edgeId = `${sourceId}-${targetId}-${rel.kind}`;
315
- if (edges.some((e) => e.id === edgeId))
316
- continue;
317
- edges.push({
318
- id: edgeId,
319
- source: sourceId,
320
- target: targetId,
321
- label: rel.kind,
322
- });
323
- }
324
- return {
325
- ...result,
326
- nodes,
327
- combos,
328
- edges,
329
- typeData,
330
- };
331
- },
332
- };
@@ -1 +0,0 @@
1
- export {};