@nexiq/extension-sdk 1.0.2 → 1.0.4

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,129 +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 entities = batch?.entities || data.entities || [];
10
- const scopes = batch?.scopes || data.scopes || [];
11
- const symbols = batch?.symbols || data.symbols || [];
12
- const relations = batch?.relations || data.relations || [];
13
- const renders = batch?.renders || data.renders || [];
14
- const files = data.files || [];
15
- const fileMap = new Map(files.map((f) => [f.id, f.path]));
16
- // 1. Map Scopes to Combos
17
- for (const scope of scopes) {
18
- if (combos.some((c) => c.id === scope.id))
19
- continue;
20
- combos.push({
21
- id: scope.id,
22
- name: scope.kind,
23
- label: { text: scope.kind },
24
- combo: scope.parent_id || undefined,
25
- type: "scope",
26
- collapsed: true,
27
- });
28
- }
29
- // 2. Map Symbols to Nodes/Labels
30
- for (const symbol of symbols) {
31
- if (nodes.some((n) => n.id === symbol.id) ||
32
- combos.some((c) => c.id === symbol.id))
33
- continue;
34
- const entity = data.entities.find((e) => e.id === symbol.entity_id);
35
- if (!entity)
36
- continue;
37
- const scope = data.scopes.find((s) => s.id === symbol.scope_id);
38
- const file = scope ? fileMap.get(scope.file_id) : undefined;
39
- // Check if this symbol's entity has an associated block scope (the body)
40
- const blockScope = data.scopes.find((s) => s.entity_id === entity.id && s.kind === "block");
41
- if (blockScope) {
42
- // This symbol represents a scope (e.g. function body)
43
- // We update the combo created for this scope
44
- const combo = combos.find((c) => c.id === blockScope.id);
45
- if (combo) {
46
- combo.label = { text: symbol.name };
47
- combo.displayName = symbol.name;
48
- combo.type = entity.kind;
49
- combo.fileName = file;
50
- combo.loc = { line: entity.line || 0, column: entity.column || 0 };
51
- }
52
- }
53
- else {
54
- // Just a variable, create a node
55
- nodes.push({
56
- id: symbol.id,
57
- name: symbol.name,
58
- label: { text: symbol.name },
59
- combo: symbol.scope_id,
60
- type: entity.kind,
61
- fileName: file,
62
- loc: { line: entity.line || 0, column: entity.column || 0 },
63
- displayName: symbol.name,
64
- radius: 10,
65
- });
66
- }
67
- }
68
- // 3. Handle Renders (JSX)
69
- for (const render of renders) {
70
- if (nodes.some((n) => n.id === render.id) ||
71
- combos.some((c) => c.id === render.id))
72
- continue;
73
- const file = fileMap.get(render.file_id);
74
- const parentCombo = render.parent_render_id ||
75
- data.scopes.find((s) => s.entity_id === render.parent_entity_id && s.kind === "block")?.id;
76
- const commonData = {
77
- id: render.id,
78
- name: render.tag,
79
- label: { text: render.tag },
80
- combo: parentCombo,
81
- type: "render",
82
- fileName: file,
83
- loc: { line: render.line || 0, column: render.column || 0 },
84
- displayName: render.tag,
85
- };
86
- // If it has children (renders that point to it as parent_render_id), make it a combo
87
- const hasChildren = data.renders.some((r) => r.parent_render_id === render.id);
88
- if (hasChildren) {
89
- combos.push({
90
- ...commonData,
91
- collapsed: true,
92
- });
93
- }
94
- else {
95
- nodes.push({
96
- ...commonData,
97
- radius: 10,
98
- });
99
- }
100
- if (render.symbol_id) {
101
- edges.push({
102
- id: `${render.id}-${render.symbol_id}`,
103
- source: render.id,
104
- target: render.symbol_id,
105
- label: "reference",
106
- });
107
- }
108
- }
109
- // 4. Handle Relations (Edges)
110
- for (const rel of relations) {
111
- const edgeId = `${rel.from_id}-${rel.to_id}`;
112
- if (edges.some((e) => e.id === edgeId))
113
- continue;
114
- edges.push({
115
- id: edgeId,
116
- source: rel.from_id,
117
- target: rel.to_id,
118
- label: rel.kind,
119
- });
120
- }
121
- return {
122
- ...result,
123
- nodes,
124
- combos,
125
- edges,
126
- typeData,
127
- };
128
- },
129
- };
@@ -1,6 +0,0 @@
1
- import { type GraphViewTask } from "../index.js";
2
- /**
3
- * Task that applies Git status (added, modified, deleted) to nodes and combos.
4
- * This runs after the base graph has been generated.
5
- */
6
- export declare const gitTask: GraphViewTask;
@@ -1,69 +0,0 @@
1
- /**
2
- * Task that applies Git status (added, modified, deleted) to nodes and combos.
3
- * This runs after the base graph has been generated.
4
- */
5
- export const gitTask = {
6
- id: "git-status",
7
- priority: 100, // Run late to ensure all nodes/combos are present
8
- run: (graphData, result) => {
9
- const { added = [], modified = [], deleted = [] } = graphData.diff || {};
10
- // Skip if no diff data
11
- if (added.length === 0 && modified.length === 0 && deleted.length === 0) {
12
- return result;
13
- }
14
- const combos = [...result.combos];
15
- const nodes = [...result.nodes];
16
- const applyStatus = (item) => {
17
- // Find the base ID for mapping (e.g., stripping '-render-instanceId')
18
- let baseId = item.id;
19
- if (item.id.includes("-render-")) {
20
- baseId = item.id.split("-render-")[0];
21
- }
22
- else if (item.id.includes("-props")) {
23
- baseId = item.id.split("-props")[0];
24
- }
25
- else if (item.id.includes(":")) {
26
- // Handle virtual variables (parent:id)
27
- baseId = item.id.split(":")[0];
28
- }
29
- if (added.includes(item.id) || added.includes(baseId)) {
30
- item.gitStatus = "added";
31
- }
32
- else if (modified.includes(item.id) || modified.includes(baseId)) {
33
- item.gitStatus = "modified";
34
- }
35
- else if (deleted.includes(item.id) || deleted.includes(baseId)) {
36
- item.gitStatus = "deleted";
37
- }
38
- };
39
- nodes.forEach(applyStatus);
40
- combos.forEach(applyStatus);
41
- // Aggregate statuses for specialized combos (like 'props')
42
- combos.forEach((combo) => {
43
- if (combo.id.endsWith("-props")) {
44
- const childStatuses = [
45
- ...nodes
46
- .filter((n) => n.combo === combo.id)
47
- .map((n) => n.gitStatus),
48
- ...combos
49
- .filter((c) => c.combo === combo.id)
50
- .map((c) => c.gitStatus),
51
- ].filter(Boolean);
52
- if (childStatuses.length > 0) {
53
- const unique = new Set(childStatuses);
54
- if (unique.size === 1) {
55
- combo.gitStatus = childStatuses[0];
56
- }
57
- else {
58
- combo.gitStatus = "modified";
59
- }
60
- }
61
- }
62
- });
63
- return {
64
- ...result,
65
- nodes,
66
- combos,
67
- };
68
- },
69
- };
@@ -1,166 +0,0 @@
1
- import { type DatabaseData } from "@nexiq/shared";
2
- import {
3
- type GraphComboData,
4
- type GraphArrowData,
5
- type GraphNodeData,
6
- type GraphViewResult,
7
- type GraphViewTask,
8
- } from "../index.js";
9
-
10
- export const componentTask: GraphViewTask = {
11
- id: "component-structure",
12
- priority: 10,
13
- run: (
14
- data: DatabaseData,
15
- result: GraphViewResult,
16
- batch?: Partial<DatabaseData>,
17
- ): GraphViewResult => {
18
- const combos: GraphComboData[] = [...result.combos];
19
- const nodes: GraphNodeData[] = [...result.nodes];
20
- const edges: GraphArrowData[] = [...result.edges];
21
- const typeData = { ...result.typeData };
22
-
23
- const entities = batch?.entities || data.entities || [];
24
- const scopes = batch?.scopes || data.scopes || [];
25
- const symbols = batch?.symbols || data.symbols || [];
26
- const relations = batch?.relations || data.relations || [];
27
- const renders = batch?.renders || data.renders || [];
28
- const files = data.files || [];
29
-
30
- const fileMap = new Map(files.map((f) => [f.id, f.path]));
31
-
32
- // 1. Map Scopes to Combos
33
- for (const scope of scopes) {
34
- if (combos.some((c) => c.id === scope.id)) continue;
35
-
36
- combos.push({
37
- id: scope.id,
38
- name: scope.kind,
39
- label: { text: scope.kind },
40
- combo: scope.parent_id || undefined,
41
- type: "scope",
42
- collapsed: true,
43
- });
44
- }
45
-
46
- // 2. Map Symbols to Nodes/Labels
47
- for (const symbol of symbols) {
48
- if (
49
- nodes.some((n) => n.id === symbol.id) ||
50
- combos.some((c) => c.id === symbol.id)
51
- )
52
- continue;
53
-
54
- const entity = data.entities.find((e) => e.id === symbol.entity_id);
55
- if (!entity) continue;
56
-
57
- const scope = data.scopes.find((s) => s.id === symbol.scope_id);
58
- const file = scope ? fileMap.get(scope.file_id) : undefined;
59
-
60
- // Check if this symbol's entity has an associated block scope (the body)
61
- const blockScope = data.scopes.find(
62
- (s) => s.entity_id === entity.id && s.kind === "block",
63
- );
64
-
65
- if (blockScope) {
66
- // This symbol represents a scope (e.g. function body)
67
- // We update the combo created for this scope
68
- const combo = combos.find((c) => c.id === blockScope.id);
69
- if (combo) {
70
- combo.label = { text: symbol.name };
71
- combo.displayName = symbol.name;
72
- combo.type = entity.kind;
73
- combo.fileName = file;
74
- combo.loc = { line: entity.line || 0, column: entity.column || 0 };
75
- }
76
- } else {
77
- // Just a variable, create a node
78
- nodes.push({
79
- id: symbol.id,
80
- name: symbol.name,
81
- label: { text: symbol.name },
82
- combo: symbol.scope_id,
83
- type: entity.kind,
84
- fileName: file,
85
- loc: { line: entity.line || 0, column: entity.column || 0 },
86
- displayName: symbol.name,
87
- radius: 10,
88
- });
89
- }
90
- }
91
-
92
- // 3. Handle Renders (JSX)
93
- for (const render of renders) {
94
- if (
95
- nodes.some((n) => n.id === render.id) ||
96
- combos.some((c) => c.id === render.id)
97
- )
98
- continue;
99
-
100
- const file = fileMap.get(render.file_id);
101
- const parentCombo =
102
- render.parent_render_id ||
103
- data.scopes.find(
104
- (s) => s.entity_id === render.parent_entity_id && s.kind === "block",
105
- )?.id;
106
-
107
- const commonData = {
108
- id: render.id,
109
- name: render.tag,
110
- label: { text: render.tag },
111
- combo: parentCombo,
112
- type: "render",
113
- fileName: file,
114
- loc: { line: render.line || 0, column: render.column || 0 },
115
- displayName: render.tag,
116
- };
117
-
118
- // If it has children (renders that point to it as parent_render_id), make it a combo
119
- const hasChildren = data.renders.some(
120
- (r) => r.parent_render_id === render.id,
121
- );
122
-
123
- if (hasChildren) {
124
- combos.push({
125
- ...commonData,
126
- collapsed: true,
127
- });
128
- } else {
129
- nodes.push({
130
- ...commonData,
131
- radius: 10,
132
- });
133
- }
134
-
135
- if (render.symbol_id) {
136
- edges.push({
137
- id: `${render.id}-${render.symbol_id}`,
138
- source: render.id,
139
- target: render.symbol_id,
140
- label: "reference",
141
- });
142
- }
143
- }
144
-
145
- // 4. Handle Relations (Edges)
146
- for (const rel of relations) {
147
- const edgeId = `${rel.from_id}-${rel.to_id}`;
148
- if (edges.some((e) => e.id === edgeId)) continue;
149
-
150
- edges.push({
151
- id: edgeId,
152
- source: rel.from_id,
153
- target: rel.to_id,
154
- label: rel.kind,
155
- });
156
- }
157
-
158
- return {
159
- ...result,
160
- nodes,
161
- combos,
162
- edges,
163
- typeData,
164
- };
165
- },
166
- };
@@ -1,83 +0,0 @@
1
- import { type DatabaseData } from "@nexiq/shared";
2
- import {
3
- type GraphComboData,
4
- type GraphNodeData,
5
- type GraphViewResult,
6
- type GraphViewTask,
7
- } from "../index.js";
8
-
9
- /**
10
- * Task that applies Git status (added, modified, deleted) to nodes and combos.
11
- * This runs after the base graph has been generated.
12
- */
13
- export const gitTask: GraphViewTask = {
14
- id: "git-status",
15
- priority: 100, // Run late to ensure all nodes/combos are present
16
- run: (graphData: DatabaseData, result: GraphViewResult): GraphViewResult => {
17
- const { added = [], modified = [], deleted = [] } = graphData.diff || {};
18
-
19
- // Skip if no diff data
20
- if (added.length === 0 && modified.length === 0 && deleted.length === 0) {
21
- return result;
22
- }
23
-
24
- const combos = [...result.combos];
25
- const nodes = [...result.nodes];
26
-
27
- const applyStatus = (item: GraphComboData | GraphNodeData) => {
28
- // Find the base ID for mapping (e.g., stripping '-render-instanceId')
29
- let baseId = item.id;
30
- if (item.id.includes("-render-")) {
31
- baseId = item.id.split("-render-")[0]!;
32
- } else if (item.id.includes("-props")) {
33
- baseId = item.id.split("-props")[0]!;
34
- } else if (item.id.includes(":")) {
35
- // Handle virtual variables (parent:id)
36
- baseId = item.id.split(":")[0]!;
37
- }
38
-
39
- if (added.includes(item.id) || added.includes(baseId)) {
40
- item.gitStatus = "added";
41
- } else if (modified.includes(item.id) || modified.includes(baseId)) {
42
- item.gitStatus = "modified";
43
- } else if (deleted.includes(item.id) || deleted.includes(baseId)) {
44
- item.gitStatus = "deleted";
45
- }
46
- };
47
-
48
- nodes.forEach(applyStatus);
49
- combos.forEach(applyStatus);
50
-
51
- // Aggregate statuses for specialized combos (like 'props')
52
- combos.forEach((combo) => {
53
- if (combo.id.endsWith("-props")) {
54
- const childStatuses = [
55
- ...nodes
56
- .filter((n) => n.combo === combo.id)
57
- .map((n) => n.gitStatus),
58
- ...combos
59
- .filter((c) => c.combo === combo.id)
60
- .map((c) => c.gitStatus),
61
- ].filter(Boolean);
62
-
63
- if (childStatuses.length > 0) {
64
- const unique = new Set(childStatuses);
65
- if (unique.size === 1) {
66
- combo.gitStatus = childStatuses[0] as
67
- | "added"
68
- | "modified"
69
- | "deleted";
70
- } else {
71
- combo.gitStatus = "modified";
72
- }
73
- }
74
- }
75
- });
76
-
77
- return {
78
- ...result,
79
- nodes,
80
- combos,
81
- };
82
- },
83
- };