@nexiq/shared 1.0.1

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 (62) hide show
  1. package/dist/component.d.ts +274 -0
  2. package/dist/component.d.ts.map +1 -0
  3. package/dist/component.js +2 -0
  4. package/dist/component.js.map +1 -0
  5. package/dist/db/index.d.ts +2 -0
  6. package/dist/db/index.d.ts.map +1 -0
  7. package/dist/db/index.js +2 -0
  8. package/dist/db/index.js.map +1 -0
  9. package/dist/db/sqlite.d.ts +23 -0
  10. package/dist/db/sqlite.d.ts.map +1 -0
  11. package/dist/db/sqlite.js +55 -0
  12. package/dist/db/sqlite.js.map +1 -0
  13. package/dist/index.d.ts +127 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +4 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/types/backend.d.ts +110 -0
  18. package/dist/types/backend.d.ts.map +1 -0
  19. package/dist/types/backend.js +2 -0
  20. package/dist/types/backend.js.map +1 -0
  21. package/dist/types/config.d.ts +43 -0
  22. package/dist/types/config.d.ts.map +1 -0
  23. package/dist/types/config.js +2 -0
  24. package/dist/types/config.js.map +1 -0
  25. package/dist/types/function.d.ts +20 -0
  26. package/dist/types/function.d.ts.map +1 -0
  27. package/dist/types/function.js +2 -0
  28. package/dist/types/function.js.map +1 -0
  29. package/dist/types/git.d.ts +42 -0
  30. package/dist/types/git.d.ts.map +1 -0
  31. package/dist/types/git.js +2 -0
  32. package/dist/types/git.js.map +1 -0
  33. package/dist/types/index.d.ts +81 -0
  34. package/dist/types/index.d.ts.map +1 -0
  35. package/dist/types/index.js +6 -0
  36. package/dist/types/index.js.map +1 -0
  37. package/dist/types/object.d.ts +25 -0
  38. package/dist/types/object.d.ts.map +1 -0
  39. package/dist/types/object.js +2 -0
  40. package/dist/types/object.js.map +1 -0
  41. package/dist/types/primitive.d.ts +176 -0
  42. package/dist/types/primitive.d.ts.map +1 -0
  43. package/dist/types/primitive.js +2 -0
  44. package/dist/types/primitive.js.map +1 -0
  45. package/dist/utils.d.ts +6 -0
  46. package/dist/utils.d.ts.map +1 -0
  47. package/dist/utils.js +82 -0
  48. package/dist/utils.js.map +1 -0
  49. package/package.json +40 -0
  50. package/src/component.ts +379 -0
  51. package/src/db/index.ts +1 -0
  52. package/src/db/sqlite.ts +73 -0
  53. package/src/index.ts +147 -0
  54. package/src/types/backend.ts +88 -0
  55. package/src/types/config.ts +48 -0
  56. package/src/types/function.ts +26 -0
  57. package/src/types/git.ts +48 -0
  58. package/src/types/index.ts +92 -0
  59. package/src/types/object.ts +37 -0
  60. package/src/types/primitive.ts +268 -0
  61. package/src/utils.ts +89 -0
  62. package/tsconfig.json +46 -0
@@ -0,0 +1,48 @@
1
+ export type AppTheme = "dark" | "light";
2
+
3
+ export interface CustomColors {
4
+ nodeHighlight?: string;
5
+ comboHighlight?: string;
6
+ arrowColor?: string;
7
+ labelColor?: string;
8
+ gitAdded?: string;
9
+ gitModified?: string;
10
+ gitDeleted?: string;
11
+ // Node types
12
+ stateNode?: string;
13
+ memoNode?: string;
14
+ callbackNode?: string;
15
+ refNode?: string;
16
+ effectNode?: string;
17
+ propNode?: string;
18
+ componentNode?: string;
19
+ hookNode?: string;
20
+ renderNode?: string;
21
+ // Type highlighting
22
+ typeKeyword?: string;
23
+ typeLiteral?: string;
24
+ typeString?: string;
25
+ typeNumber?: string;
26
+ typeBoolean?: string;
27
+ typePunctuation?: string;
28
+ typeReference?: string;
29
+ typeComponent?: string;
30
+ typeDefault?: string;
31
+ // UI Specific
32
+ genericsColor?: string;
33
+ }
34
+
35
+ export interface SubProject {
36
+ name: string;
37
+ path: string;
38
+ }
39
+
40
+ export interface ReactMapConfig {
41
+ entry?: string;
42
+ aliases?: Record<string, string>;
43
+ extensions?: string[];
44
+ dependencyDepth?: number;
45
+ analysisPath?: string;
46
+ ignorePatterns?: string[];
47
+ ignoreSubProjects?: string[];
48
+ }
@@ -0,0 +1,26 @@
1
+ import type { FuncParam } from "./object.js";
2
+ import type { TypeData, TypeDataLiteralBody } from "./primitive.js";
3
+
4
+ export interface TypeDataFunctionParameterBase {
5
+ optional?: boolean;
6
+ //TODO: handle rest
7
+ decorator: never;
8
+ }
9
+
10
+ export interface TypeDataFunctionParameterName
11
+ extends TypeDataFunctionParameterBase {
12
+ name: string;
13
+ body: TypeData;
14
+ }
15
+
16
+ export interface TypeDataFunctionParameterObject
17
+ extends TypeDataFunctionParameterBase {
18
+ name: string;
19
+ body: TypeDataLiteralBody[];
20
+ properties: FuncParam[];
21
+ }
22
+
23
+ export interface TypeDataFunctionParameter {
24
+ name: string;
25
+ body: TypeData;
26
+ }
@@ -0,0 +1,48 @@
1
+
2
+ export interface GitFileStatus {
3
+ path: string;
4
+ index: string; // 'A', 'M', 'D', '?', etc.
5
+ working_dir: string;
6
+ }
7
+
8
+ export interface GitStatus {
9
+ current: string | null;
10
+ tracking: string | null;
11
+ detached: boolean;
12
+ files: GitFileStatus[];
13
+ staged: string[];
14
+ }
15
+
16
+ export interface GitCommit {
17
+ hash: string;
18
+ date: string;
19
+ message: string;
20
+ author_name: string;
21
+ author_email: string;
22
+ }
23
+
24
+ export interface GitDiff {
25
+ file: string;
26
+ diff: string;
27
+ }
28
+
29
+ export interface GitDiffLine {
30
+ type: 'added' | 'deleted' | 'normal';
31
+ content: string;
32
+ newLineNumber?: number;
33
+ oldLineNumber?: number;
34
+ }
35
+
36
+ export interface GitFileDiff {
37
+ path: string;
38
+ hunks: GitDiffHunk[];
39
+ }
40
+
41
+ export interface GitDiffHunk {
42
+ content: string;
43
+ lines: GitDiffLine[];
44
+ oldStart: number;
45
+ oldLines: number;
46
+ newStart: number;
47
+ newLines: number;
48
+ }
@@ -0,0 +1,92 @@
1
+ import type { ComponentLoc, VariableName } from "../component.js";
2
+ import type { TypeData, TypeDataLiteralBody } from "./primitive.js";
3
+ import type { ReactMapConfig, SubProject } from "./config.js";
4
+ export * from "./primitive.js";
5
+ export * from "./object.js";
6
+ export * from "./git.js";
7
+ export * from "./config.js";
8
+
9
+ export interface ProjectStatus {
10
+ hasConfig: boolean;
11
+ isMonorepo: boolean;
12
+ projectType: "vite" | "next" | "unknown";
13
+ config: ReactMapConfig | null;
14
+ subProjects: SubProject[];
15
+ }
16
+
17
+ export type GraphViewType = "component" | "file" | "router";
18
+
19
+ export interface AppStateData {
20
+ selectedSubProject: string | null;
21
+ centeredItemId: string | null;
22
+ selectedId: string | null;
23
+ isSidebarOpen: boolean;
24
+ activeTab: "projects" | "git";
25
+ selectedCommit: string | null;
26
+ viewport?: { x: number; y: number; zoom: number } | null;
27
+ view?: GraphViewType;
28
+ sidebar: {
29
+ right: {
30
+ width?: number;
31
+ height?: number;
32
+ };
33
+ };
34
+ }
35
+
36
+ export interface TypeDataParam {
37
+ name: string;
38
+ default?: TypeData;
39
+ constraint?: TypeData;
40
+ }
41
+
42
+ export interface TypeDataParamFunction extends TypeDataParam {
43
+ const?: boolean;
44
+ in?: boolean;
45
+ out?: boolean;
46
+ }
47
+
48
+ export interface TypeDataDeclareBase {
49
+ id: string;
50
+ type: "interface" | "type";
51
+ name: VariableName;
52
+ }
53
+
54
+ export interface TypeDataDeclareInterface
55
+ extends TypeDataDeclareBase, ComponentLoc {
56
+ type: "interface";
57
+ extends?: string[];
58
+ body: TypeDataLiteralBody[];
59
+ params?: Record<string, TypeDataParam>;
60
+ }
61
+
62
+ export interface TypeDataDeclareType extends TypeDataDeclareBase, ComponentLoc {
63
+ type: "type";
64
+ body: TypeData;
65
+ params?: TypeDataParam[];
66
+ }
67
+
68
+ export type TypeDataDeclare = TypeDataDeclareInterface | TypeDataDeclareType;
69
+
70
+ export type ComponentTypeData =
71
+ | {
72
+ type: "name";
73
+ name: string;
74
+ }
75
+ | {
76
+ type: "inline";
77
+ body: TypeData;
78
+ };
79
+
80
+ export interface UIItemState {
81
+ x: number;
82
+ y: number;
83
+ radius?: number;
84
+ collapsedRadius?: number;
85
+ expandedRadius?: number;
86
+ isLayoutCalculated?: boolean;
87
+ collapsed?: boolean;
88
+ }
89
+
90
+ export type UIStateMap = Record<string, UIItemState>;
91
+
92
+ export * from "./backend.js";
@@ -0,0 +1,37 @@
1
+
2
+ export interface FuncParamName {
3
+ type: "named";
4
+ name: string;
5
+ }
6
+
7
+ export interface FuncParamObjectProperty {
8
+ type: "object-property";
9
+ shorthand: boolean;
10
+ key: string;
11
+ value: FuncParam;
12
+ }
13
+
14
+ export type FuncParamObjectPatternProperty =
15
+ | FuncParamObjectProperty
16
+ | FuncParamRestElement;
17
+
18
+ export interface FuncParamObjectPattern {
19
+ type: "object-pattern";
20
+ property: FuncParamObjectPatternProperty[];
21
+ }
22
+
23
+ export interface FuncParamArrayPattern {
24
+ type: "array-pattern";
25
+ elements: FuncParam[];
26
+ }
27
+
28
+ export interface FuncParamRestElement {
29
+ type: "rest-element";
30
+ name: string;
31
+ }
32
+
33
+ export type FuncParam =
34
+ | FuncParamName
35
+ | FuncParamObjectPattern
36
+ | FuncParamArrayPattern
37
+ | FuncParamRestElement;
@@ -0,0 +1,268 @@
1
+ import type { FuncParam, TypeDataParamFunction } from "./index.js";
2
+
3
+ export interface TypeDataString {
4
+ type: "string";
5
+ }
6
+
7
+ export interface TypeDataNumber {
8
+ type: "number";
9
+ }
10
+
11
+ export interface TypeDataBigInt {
12
+ type: "bigint";
13
+ }
14
+
15
+ export interface TypeDataBoolean {
16
+ type: "boolean";
17
+ }
18
+
19
+ export interface TypeDataNull {
20
+ type: "null";
21
+ }
22
+
23
+ export interface TypeDataUndefined {
24
+ type: "undefined";
25
+ }
26
+
27
+ export interface TypeDataAny {
28
+ type: "any";
29
+ }
30
+
31
+ export interface TypeDataVoid {
32
+ type: "void";
33
+ }
34
+
35
+ export interface TypeDataUnknown {
36
+ type: "unknown";
37
+ }
38
+
39
+ export interface TypeDataNever {
40
+ type: "never";
41
+ }
42
+
43
+ export interface TypeDataLiteralTypeBigInt {
44
+ type: "bigint";
45
+ value: string;
46
+ }
47
+
48
+ export interface TypeDataLiteralTypeString {
49
+ type: "string";
50
+ value: string;
51
+ }
52
+
53
+ export interface TypeDataLiteralTypeNumber {
54
+ type: "number";
55
+ value: number;
56
+ }
57
+
58
+ export interface TypeDataLiteralTypeBoolean {
59
+ type: "boolean";
60
+ value: boolean;
61
+ }
62
+
63
+ export interface TypeDataLiteralTypeTemplate {
64
+ type: "template";
65
+ expression: TypeData[];
66
+ quasis: string[];
67
+ }
68
+
69
+ export interface TypeDataLiteralTypeUnary {
70
+ type: "unary";
71
+ operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof";
72
+ prefix: boolean;
73
+ argument: TypeDataLiteralTypeLiteral;
74
+ }
75
+
76
+ export type TypeDataLiteralTypeLiteral =
77
+ | TypeDataLiteralTypeBoolean
78
+ | TypeDataLiteralTypeNumber
79
+ | TypeDataLiteralTypeString
80
+ | TypeDataLiteralTypeUnary
81
+ | TypeDataLiteralTypeBigInt
82
+ | TypeDataLiteralTypeTemplate;
83
+
84
+ // string, number, boolean
85
+ export interface TypeDataLiteralType {
86
+ type: "literal-type";
87
+ literal: TypeDataLiteralTypeLiteral;
88
+ }
89
+
90
+ export type TypeDataRef = {
91
+ type: "ref";
92
+ params?: TypeData[];
93
+ } & (
94
+ | {
95
+ refType: "named";
96
+ name: string;
97
+ }
98
+ | {
99
+ refType: "qualified";
100
+ names: string[];
101
+ }
102
+ );
103
+
104
+ export interface TypeDataLiteralArray {
105
+ type: "literal-array";
106
+ elements: PropDataType[];
107
+ }
108
+
109
+ export interface TypeDataLiteralObject {
110
+ type: "literal-object";
111
+ properties: Record<string, PropDataType>;
112
+ }
113
+
114
+ export type PropDataType =
115
+ | TypeDataLiteralType
116
+ | TypeDataRef
117
+ | TypeDataNull
118
+ | TypeDataUndefined
119
+ | TypeDataLiteralArray
120
+ | TypeDataLiteralObject;
121
+
122
+ export type TypeDataFunctionParameter = {
123
+ param: FuncParam;
124
+ typeData?: TypeData;
125
+ optional?: boolean;
126
+ };
127
+
128
+ export type TypeDataFunction = {
129
+ type: "function";
130
+ // generic
131
+ params: TypeDataParamFunction[];
132
+ // function parameters
133
+ parameters: TypeDataFunctionParameter[];
134
+ return: TypeData;
135
+ };
136
+
137
+ export type TypeDataPrimitive =
138
+ | TypeDataString
139
+ | TypeDataNumber
140
+ | TypeDataBigInt
141
+ | TypeDataBoolean
142
+ | TypeDataNull
143
+ | TypeDataUndefined
144
+ | TypeDataAny
145
+ | TypeDataVoid
146
+ | TypeDataUnknown
147
+ | TypeDataNever
148
+ | TypeDataRef
149
+ | TypeDataLiteralType
150
+ | TypeDataFunction;
151
+
152
+ export interface TypeDataArray {
153
+ type: "array";
154
+ element: TypeData;
155
+ }
156
+ export interface TypeDataTupleElementBase {
157
+ type: "named" | "unnamed";
158
+ typeData: TypeData;
159
+ }
160
+
161
+ export interface TypeDataTupleElementNamed extends TypeDataTupleElementBase {
162
+ type: "named";
163
+ name: string;
164
+ optional: boolean;
165
+ }
166
+
167
+ export interface TypeDataTupleElementUnNamed extends TypeDataTupleElementBase {
168
+ type: "unnamed";
169
+ }
170
+
171
+ export type TypeDataTupleElement =
172
+ | TypeDataTupleElementNamed
173
+ | TypeDataTupleElementUnNamed;
174
+
175
+ export interface TypeDataTuple {
176
+ type: "tuple";
177
+ elements: TypeDataTupleElement[];
178
+ }
179
+
180
+ export interface TypeDataIndexAccess {
181
+ type: "index-access";
182
+ indexType: TypeData;
183
+ objectType: TypeData;
184
+ }
185
+
186
+ export interface TypeDataQuery {
187
+ type: "query";
188
+ expr: TypeData;
189
+ }
190
+
191
+ export interface TypeDataImport {
192
+ type: "import";
193
+ name: string;
194
+ qualifier?: string;
195
+ }
196
+
197
+ export interface TypeDataLiteralBodyBase {
198
+ signatureType: "property" | "index" | "method";
199
+ }
200
+
201
+ export interface TypeDataLiteralBodyIndexPrarameter {
202
+ name: string;
203
+ type: TypeData;
204
+ }
205
+
206
+ export interface TypeDataLiteralBodyIndex extends TypeDataLiteralBodyBase {
207
+ signatureType: "index";
208
+ type: TypeData;
209
+ parameter: TypeDataLiteralBodyIndexPrarameter;
210
+ }
211
+
212
+ export interface TypeDataLiteralBodyProperty extends TypeDataLiteralBodyBase {
213
+ signatureType: "property";
214
+ type: TypeData;
215
+ optional?: boolean;
216
+ computed?: boolean;
217
+ name: string;
218
+ }
219
+
220
+ export interface TypeDataLiteralBodyMethod extends TypeDataLiteralBodyBase {
221
+ signatureType: "method";
222
+ name: string;
223
+ optional?: boolean;
224
+ computed?: boolean;
225
+ params: TypeDataParamFunction[];
226
+ parameters: TypeDataFunctionParameter[];
227
+ return: TypeData;
228
+ }
229
+
230
+ export type TypeDataLiteralBody =
231
+ | TypeDataLiteralBodyProperty
232
+ | TypeDataLiteralBodyIndex
233
+ | TypeDataLiteralBodyMethod;
234
+
235
+ // object
236
+ export interface TypeDataTypeBodyLiteral {
237
+ type: "type-literal";
238
+ members: TypeDataLiteralBody[];
239
+ }
240
+
241
+ export interface TypeDataTypeBodyParathesis {
242
+ type: "parenthesis";
243
+ members: TypeData;
244
+ }
245
+
246
+ export interface TypeDataTypeBodyUnion {
247
+ type: "union";
248
+ members: TypeData[];
249
+ }
250
+
251
+ export interface TypeDataTypeBodyIntersection {
252
+ type: "intersection";
253
+ members: TypeData[];
254
+ }
255
+
256
+ export type TypeData =
257
+ | TypeDataPrimitive
258
+ | TypeDataArray
259
+ | TypeDataTuple
260
+ | TypeDataIndexAccess
261
+ | TypeDataQuery
262
+ | TypeDataImport
263
+ | TypeDataTypeBodyLiteral
264
+ | TypeDataTypeBodyUnion
265
+ | TypeDataTypeBodyIntersection
266
+ | TypeDataTypeBodyParathesis
267
+ | TypeDataLiteralArray
268
+ | TypeDataLiteralObject;
package/src/utils.ts ADDED
@@ -0,0 +1,89 @@
1
+ import type { VariableName } from "./component.js";
2
+ import type { GitFileDiff, GitDiffHunk } from "./types/git.js";
3
+
4
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
+
6
+ export const getDisplayName = (
7
+ name: VariableName | string | undefined,
8
+ ): string => {
9
+ if (!name) return "unknown";
10
+ if (typeof name === "string") return name;
11
+ if (name.type === "identifier") return name.name;
12
+ if (name.type === "rest") return `...${getDisplayName(name.argument)}`;
13
+ return "raw" in name ? name.raw : "unknown";
14
+ };
15
+
16
+ export function parseRawDiff(
17
+ rawDiff: string,
18
+ filterFile?: string,
19
+ ): GitFileDiff[] {
20
+ const files: GitFileDiff[] = [];
21
+ if (!rawDiff) return files;
22
+
23
+ const fileDiffs = rawDiff.split(/^diff --git /m).slice(1);
24
+
25
+ for (const fileDiff of fileDiffs) {
26
+ const lines = fileDiff.split("\n");
27
+ const header = lines[0];
28
+ if (!header) continue;
29
+ const pathMatch = header.match(/a\/(.*) b\/(.*)/);
30
+ if (!pathMatch) continue;
31
+
32
+ const filePath = pathMatch[2];
33
+ if (filterFile && filePath !== filterFile) continue;
34
+
35
+ const hunks: GitDiffHunk[] = [];
36
+ let currentHunk: GitDiffHunk | null = null;
37
+
38
+ let oldLineNum = 0;
39
+ let newLineNum = 0;
40
+
41
+ for (let i = 1; i < lines.length; i++) {
42
+ const line = lines[i]!;
43
+ if (line.startsWith("@@")) {
44
+ const hunkMatch = line.match(/@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/);
45
+ if (hunkMatch) {
46
+ oldLineNum = parseInt(hunkMatch[1]!);
47
+ newLineNum = parseInt(hunkMatch[3]!);
48
+ currentHunk = {
49
+ content: line,
50
+ lines: [],
51
+ oldStart: oldLineNum,
52
+ oldLines: parseInt(hunkMatch[2] || "1"),
53
+ newStart: newLineNum,
54
+ newLines: parseInt(hunkMatch[4] || "1"),
55
+ };
56
+ hunks.push(currentHunk);
57
+ }
58
+ } else if (currentHunk) {
59
+ if (line.startsWith("+")) {
60
+ currentHunk.lines.push({
61
+ type: "added",
62
+ content: line.substring(1),
63
+ newLineNumber: newLineNum++,
64
+ });
65
+ } else if (line.startsWith("-")) {
66
+ currentHunk.lines.push({
67
+ type: "deleted",
68
+ content: line.substring(1),
69
+ oldLineNumber: oldLineNum++,
70
+ });
71
+ } else if (line.startsWith(" ")) {
72
+ currentHunk.lines.push({
73
+ type: "normal",
74
+ content: line.substring(1),
75
+ oldLineNumber: oldLineNum++,
76
+ newLineNumber: newLineNum++,
77
+ });
78
+ }
79
+ }
80
+ }
81
+
82
+ files.push({
83
+ path: filePath!,
84
+ hunks,
85
+ });
86
+ }
87
+
88
+ return files;
89
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ // Visit https://aka.ms/tsconfig to read more about this file
3
+ "compilerOptions": {
4
+ // File Layout
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+
8
+ // Environment Settings
9
+ // See also https://aka.ms/tsconfig/module
10
+ "module": "nodenext",
11
+ "target": "esnext",
12
+ "types": [],
13
+ // For nodejs:
14
+ // "lib": ["esnext"],
15
+ // "types": ["node"],
16
+ // and npm install -D @types/node
17
+
18
+ // Other Outputs
19
+ "sourceMap": true,
20
+ "declaration": true,
21
+ "declarationMap": true,
22
+
23
+ // Stricter Typechecking Options
24
+ "noUncheckedIndexedAccess": true,
25
+ "exactOptionalPropertyTypes": true,
26
+
27
+ // Style Options
28
+ // "noImplicitReturns": true,
29
+ // "noImplicitOverride": true,
30
+ // "noUnusedLocals": true,
31
+ // "noUnusedParameters": true,
32
+ // "noFallthroughCasesInSwitch": true,
33
+ // "noPropertyAccessFromIndexSignature": true,
34
+
35
+ // Recommended Options
36
+ "strict": true,
37
+ "jsx": "react-jsx",
38
+ "verbatimModuleSyntax": true,
39
+ "isolatedModules": true,
40
+ "noUncheckedSideEffectImports": true,
41
+ "moduleDetection": "force",
42
+ "skipLibCheck": true,
43
+ },
44
+ "include": ["src"],
45
+ "exclude": ["tsconfig.json"]
46
+ }