@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/dist/db.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ export type OutNode = {
2
+ id: string;
3
+ name: string;
4
+ type: string;
5
+ combo_id: string;
6
+ color: string;
7
+ radius: number;
8
+ display_name: string;
9
+ git_status: string;
10
+ meta_json: string;
11
+ };
12
+ export type OutEdge = {
13
+ id: string;
14
+ source: string;
15
+ target: string;
16
+ name: string;
17
+ kind: string;
18
+ category: string;
19
+ meta_json: string;
20
+ };
21
+ export type OutCombo = {
22
+ id: string;
23
+ name: string;
24
+ type: string;
25
+ parent_id: string;
26
+ color: string;
27
+ radius: number;
28
+ display_name: string;
29
+ collapsed: boolean;
30
+ git_status: string;
31
+ meta_json: string;
32
+ };
33
+ export type OutDetail = {
34
+ id: string;
35
+ file_name: string;
36
+ project_path: string;
37
+ line: number;
38
+ column: number;
39
+ data_json: string;
40
+ };
package/dist/db.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=db.js.map
package/dist/db.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,31 +1,86 @@
1
- import type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData } from "@nexiq/shared";
2
- export type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData };
1
+ import type { Database } from "better-sqlite3";
2
+ import type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData, GraphViewType, VariableScope, VariableLoc } from "@nexiq/shared";
3
+ export type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData, GraphViewType, VariableScope, VariableLoc, };
4
+ export interface UsageOccurrence {
5
+ usageId: string;
6
+ filePath: string;
7
+ line: number;
8
+ column: number;
9
+ ownerId: string;
10
+ ownerKind: string;
11
+ accessPath?: string[] | undefined;
12
+ isOptional?: boolean | undefined;
13
+ isComputed?: boolean | undefined;
14
+ hiddenIntermediate?: string | undefined;
15
+ displayLabel?: string | undefined;
16
+ }
17
+ export interface NodeAppearance {
18
+ color?: string | undefined;
19
+ radius?: number | undefined;
20
+ }
21
+ export interface GraphAppearance {
22
+ nodeHighlight?: string;
23
+ comboHighlight?: string;
24
+ arrowColor?: string;
25
+ directFlowColor?: string;
26
+ sideEffectFlowColor?: string;
27
+ labelColor?: string;
28
+ gitAdded?: string;
29
+ gitModified?: string;
30
+ gitDeleted?: string;
31
+ nodes?: Partial<Record<"package" | "scope" | "component" | "hook" | "renderGroup" | "sourceGroup" | "pathGroup" | "callback" | "state" | "memo" | "ref" | "effect" | "prop" | "render" | "variable", NodeAppearance>>;
32
+ typeKeyword?: string;
33
+ typeLiteral?: string;
34
+ typeString?: string;
35
+ typeNumber?: string;
36
+ typeBoolean?: string;
37
+ typePunctuation?: string;
38
+ typeReference?: string;
39
+ typeComponent?: string;
40
+ typeDefault?: string;
41
+ genericsColor?: string;
42
+ }
43
+ export type CustomColors = GraphAppearance;
44
+ export declare const DEFAULT_GRAPH_APPEARANCE: GraphAppearance;
45
+ export declare function normalizeGraphAppearance(appearance?: GraphAppearance | null): GraphAppearance;
3
46
  export interface GraphItemPosition {
4
47
  x: number;
5
48
  y: number;
6
49
  }
50
+ export interface AppearanceOverride {
51
+ color?: string;
52
+ radius?: number;
53
+ collapsedRadius?: number;
54
+ expandedRadius?: number;
55
+ }
56
+ export interface GraphNodeDetail {
57
+ id: string;
58
+ projectPath?: string;
59
+ fileName?: string;
60
+ pureFileName?: string;
61
+ loc?: VariableLoc;
62
+ declarationKind?: "const" | "let" | "var" | "using" | "await using";
63
+ tag?: string;
64
+ componentType?: "function" | "class" | string | null;
65
+ raw?: ComponentFileVar;
66
+ [key: string]: unknown;
67
+ }
7
68
  export interface GraphNodeData {
8
69
  id: string;
9
70
  name: VariableName | string;
10
- label?: {
11
- text: string;
12
- fill?: string;
13
- };
14
71
  type?: string;
15
- fileName?: string;
16
- pureFileName?: string;
17
- loc?: {
18
- line: number;
19
- column: number;
20
- };
21
72
  radius?: number;
22
73
  color?: string;
23
74
  combo?: string;
24
75
  gitStatus?: "added" | "modified" | "deleted";
25
- declarationKind?: "const" | "let" | "var" | "using" | "await using";
26
- tag?: string;
27
- raw?: ComponentFileVar;
76
+ appearanceOverride?: AppearanceOverride;
28
77
  displayName?: string;
78
+ hasProps?: boolean;
79
+ hasHooks?: boolean;
80
+ hasChildren?: boolean;
81
+ pureFileName?: string;
82
+ scope?: VariableScope | string;
83
+ loc?: VariableLoc;
29
84
  [key: string]: unknown;
30
85
  }
31
86
  export interface GraphComboData extends GraphNodeData {
@@ -33,13 +88,26 @@ export interface GraphComboData extends GraphNodeData {
33
88
  collapsedRadius?: number;
34
89
  expandedRadius?: number;
35
90
  padding?: number;
91
+ appearanceOverride?: AppearanceOverride;
36
92
  [key: string]: unknown;
37
93
  }
38
94
  export interface GraphArrowData {
39
95
  id: string;
40
96
  source: string;
41
97
  target: string;
42
- label?: string;
98
+ name?: string;
99
+ edgeKind?: string;
100
+ category?: string;
101
+ flowRole?: "direct" | "side-effect" | null;
102
+ usageCount?: number;
103
+ usages?: UsageOccurrence[];
104
+ highlighted?: boolean;
105
+ dimmed?: boolean;
106
+ opensTo?: {
107
+ fileName: string;
108
+ line: number;
109
+ column: number;
110
+ };
43
111
  combo?: string;
44
112
  [key: string]: unknown;
45
113
  }
@@ -50,11 +118,90 @@ export interface useGraphProps {
50
118
  }
51
119
  export interface GraphViewResult extends useGraphProps {
52
120
  typeData: Record<string, TypeDataDeclare>;
121
+ details?: Record<string, GraphNodeDetail>;
122
+ }
123
+ /**
124
+ * Context provided to tasks during graph view generation.
125
+ */
126
+ export interface TaskContext {
127
+ /**
128
+ * Database instance for querying graph data.
129
+ */
130
+ db?: Database;
131
+ /**
132
+ * Root path of the project being analyzed.
133
+ */
134
+ projectRoot: string;
135
+ /**
136
+ * Specific paths within the project to focus analysis on.
137
+ */
138
+ analysisPaths?: string[];
139
+ /**
140
+ * The type of view being generated.
141
+ */
142
+ viewType: GraphViewType;
143
+ /**
144
+ * Optional pre-loaded snapshot data, for backward compatibility or when already available.
145
+ */
146
+ snapshotData?: DatabaseData;
147
+ /**
148
+ * Request-scoped cache for aggregated task data so multiple tasks do not reread SQLite.
149
+ */
150
+ taskDataCache?: DatabaseData;
151
+ /**
152
+ * Path to the original Cache Database. Native Rust tasks use this to ATTACH the database directly.
153
+ */
154
+ cacheDbPath?: string;
155
+ /**
156
+ * Optional stage profiler provided by the caller.
157
+ */
158
+ profileStage?: (name: string, startedAt: number, detail?: string) => void | Promise<void>;
159
+ /**
160
+ * Buffer for storing node, edge, and combo data in FlatBuffer format.
161
+ */
162
+ nodeDataBuffer?: SharedArrayBuffer;
163
+ /**
164
+ * Shared buffer for storing node details.
165
+ */
166
+ detailBuffer?: SharedArrayBuffer;
167
+ /**
168
+ * Serialized SQLite database buffer containing both input data and output tables.
169
+ */
170
+ sqliteBuffer?: Uint8Array;
53
171
  }
172
+ /**
173
+ * Helper to retrieve required graph data from either TaskContext.snapshotData or TaskContext.db.
174
+ * It handles workspace databases and qualifies IDs to avoid collisions.
175
+ */
176
+ export declare function getTaskData(context: TaskContext): DatabaseData;
177
+ /**
178
+ * A task that contributes to the construction of a graph view.
179
+ */
54
180
  export interface GraphViewTask {
55
181
  id: string;
56
182
  priority: number;
57
- run: (data: DatabaseData, result: GraphViewResult, batch?: Partial<DatabaseData>) => GraphViewResult;
183
+ extensionPath?: string;
184
+ /**
185
+ * Run the task to update the graph result.
186
+ *
187
+ * @param result The current graph result to be updated
188
+ * @param context Context containing database and project information
189
+ * @returns Updated GraphViewResult
190
+ */
191
+ run?: (result: GraphViewResult, context: TaskContext) => GraphViewResult;
192
+ /**
193
+ * Run the task using buffers for improved performance.
194
+ *
195
+ * @param nodeData Shared buffer for node/edge/combo data
196
+ * @param detailBuffer Shared buffer for node details
197
+ * @param context Context containing database and project information
198
+ */
199
+ runBuffer?: (nodeData: SharedArrayBuffer, detailBuffer: SharedArrayBuffer, context: TaskContext) => number | void;
200
+ /**
201
+ * Run the task using an in-memory SQLite database.
202
+ * The database is expected to be initialized with input data and out_* tables.
203
+ */
204
+ runSqlite?: (context: TaskContext) => void | Promise<void> | Uint8Array | Promise<Uint8Array>;
58
205
  }
59
206
  export interface DetailSectionProps {
60
207
  selectedId: string;
@@ -62,6 +209,7 @@ export interface DetailSectionProps {
62
209
  graph: unknown;
63
210
  projectPath: string;
64
211
  typeData: Record<string, TypeDataDeclare>;
212
+ detail?: GraphNodeDetail;
65
213
  onSelect?: (id: string) => void;
66
214
  renderNodes?: GraphNodeData[];
67
215
  }
@@ -90,5 +238,8 @@ export interface Extension {
90
238
  detailSections?: DetailSection[];
91
239
  mcpTools?: MCPTool[];
92
240
  }
93
- export * from "./tasks/componentTask.js";
94
- export * from "./tasks/gitTask.js";
241
+ /**
242
+ * Initialize standard output tables in a SQLite database for extension results.
243
+ */
244
+ export declare function initOutputTables(db: Database): void;
245
+ export type * from "./db.js";