@nexiq/extension-sdk 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.
- package/dist/extension-sdk/src/index.d.ts +94 -0
- package/dist/extension-sdk/src/index.js +2 -0
- package/dist/extension-sdk/src/tasks/componentTask.d.ts +2 -0
- package/dist/extension-sdk/src/tasks/componentTask.js +129 -0
- package/dist/extension-sdk/src/tasks/gitTask.d.ts +6 -0
- package/dist/extension-sdk/src/tasks/gitTask.js +69 -0
- package/dist/shared/src/component.d.ts +273 -0
- package/dist/shared/src/component.js +1 -0
- package/dist/shared/src/index.d.ts +126 -0
- package/dist/shared/src/index.js +3 -0
- package/dist/shared/src/types/backend.d.ts +109 -0
- package/dist/shared/src/types/backend.js +1 -0
- package/dist/shared/src/types/config.d.ts +42 -0
- package/dist/shared/src/types/config.js +1 -0
- package/dist/shared/src/types/git.d.ts +41 -0
- package/dist/shared/src/types/git.js +1 -0
- package/dist/shared/src/types/index.d.ts +80 -0
- package/dist/shared/src/types/index.js +5 -0
- package/dist/shared/src/types/object.d.ts +24 -0
- package/dist/shared/src/types/object.js +1 -0
- package/dist/shared/src/types/primitive.d.ts +175 -0
- package/dist/shared/src/types/primitive.js +1 -0
- package/dist/shared/src/utils.d.ts +5 -0
- package/dist/shared/src/utils.js +81 -0
- package/eslint.config.js +31 -0
- package/package.json +35 -0
- package/src/index.ts +112 -0
- package/src/tasks/componentTask.ts +166 -0
- package/src/tasks/gitTask.ts +83 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const getDisplayName = (name) => {
|
|
2
|
+
if (!name)
|
|
3
|
+
return "unknown";
|
|
4
|
+
if (typeof name === "string")
|
|
5
|
+
return name;
|
|
6
|
+
if (name.type === "identifier")
|
|
7
|
+
return name.name;
|
|
8
|
+
if (name.type === "rest")
|
|
9
|
+
return `...${getDisplayName(name.argument)}`;
|
|
10
|
+
return "raw" in name ? name.raw : "unknown";
|
|
11
|
+
};
|
|
12
|
+
export function parseRawDiff(rawDiff, filterFile) {
|
|
13
|
+
const files = [];
|
|
14
|
+
if (!rawDiff)
|
|
15
|
+
return files;
|
|
16
|
+
const fileDiffs = rawDiff.split(/^diff --git /m).slice(1);
|
|
17
|
+
for (const fileDiff of fileDiffs) {
|
|
18
|
+
const lines = fileDiff.split("\n");
|
|
19
|
+
const header = lines[0];
|
|
20
|
+
if (!header)
|
|
21
|
+
continue;
|
|
22
|
+
const pathMatch = header.match(/a\/(.*) b\/(.*)/);
|
|
23
|
+
if (!pathMatch)
|
|
24
|
+
continue;
|
|
25
|
+
const filePath = pathMatch[2];
|
|
26
|
+
if (filterFile && filePath !== filterFile)
|
|
27
|
+
continue;
|
|
28
|
+
const hunks = [];
|
|
29
|
+
let currentHunk = null;
|
|
30
|
+
let oldLineNum = 0;
|
|
31
|
+
let newLineNum = 0;
|
|
32
|
+
for (let i = 1; i < lines.length; i++) {
|
|
33
|
+
const line = lines[i];
|
|
34
|
+
if (line.startsWith("@@")) {
|
|
35
|
+
const hunkMatch = line.match(/@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/);
|
|
36
|
+
if (hunkMatch) {
|
|
37
|
+
oldLineNum = parseInt(hunkMatch[1]);
|
|
38
|
+
newLineNum = parseInt(hunkMatch[3]);
|
|
39
|
+
currentHunk = {
|
|
40
|
+
content: line,
|
|
41
|
+
lines: [],
|
|
42
|
+
oldStart: oldLineNum,
|
|
43
|
+
oldLines: parseInt(hunkMatch[2] || "1"),
|
|
44
|
+
newStart: newLineNum,
|
|
45
|
+
newLines: parseInt(hunkMatch[4] || "1"),
|
|
46
|
+
};
|
|
47
|
+
hunks.push(currentHunk);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (currentHunk) {
|
|
51
|
+
if (line.startsWith("+")) {
|
|
52
|
+
currentHunk.lines.push({
|
|
53
|
+
type: "added",
|
|
54
|
+
content: line.substring(1),
|
|
55
|
+
newLineNumber: newLineNum++,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else if (line.startsWith("-")) {
|
|
59
|
+
currentHunk.lines.push({
|
|
60
|
+
type: "deleted",
|
|
61
|
+
content: line.substring(1),
|
|
62
|
+
oldLineNumber: oldLineNum++,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else if (line.startsWith(" ")) {
|
|
66
|
+
currentHunk.lines.push({
|
|
67
|
+
type: "normal",
|
|
68
|
+
content: line.substring(1),
|
|
69
|
+
oldLineNumber: oldLineNum++,
|
|
70
|
+
newLineNumber: newLineNum++,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
files.push({
|
|
76
|
+
path: filePath,
|
|
77
|
+
hunks,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return files;
|
|
81
|
+
}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
5
|
+
|
|
6
|
+
export default defineConfig([
|
|
7
|
+
globalIgnores(["dist"]),
|
|
8
|
+
{
|
|
9
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
10
|
+
files: ["**/*.{ts,tsx}"],
|
|
11
|
+
languageOptions: {
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
globals: { ...globals.node, ...globals.browser },
|
|
14
|
+
parserOptions: {
|
|
15
|
+
projectService: true,
|
|
16
|
+
tsconfigRootDir: import.meta.dirname,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
"@typescript-eslint/no-unused-vars": [
|
|
21
|
+
"error",
|
|
22
|
+
{
|
|
23
|
+
argsIgnorePattern: "^_",
|
|
24
|
+
varsIgnorePattern: "^_",
|
|
25
|
+
caughtErrorsIgnorePattern: "^_",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
"no-debugger": "warn",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexiq/extension-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SDK for creating nexu extensions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/Naputt1/nexu.git",
|
|
17
|
+
"directory": "packages/extension-sdk"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"registry": "https://registry.npmjs.org/",
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
25
|
+
"@nexiq/shared": "1.0.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"typescript": "^5.0.0",
|
|
29
|
+
"@types/react": "^18.0.0 || ^19.0.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TypeDataDeclare,
|
|
3
|
+
ComponentFileVar,
|
|
4
|
+
VariableName,
|
|
5
|
+
DatabaseData,
|
|
6
|
+
} from "@nexiq/shared";
|
|
7
|
+
|
|
8
|
+
// Re-exporting these from shared for convenience if needed by extensions
|
|
9
|
+
export type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData };
|
|
10
|
+
|
|
11
|
+
export interface GraphItemPosition {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GraphNodeData {
|
|
17
|
+
id: string;
|
|
18
|
+
name: VariableName | string;
|
|
19
|
+
label?: { text: string; fill?: string };
|
|
20
|
+
type?: string;
|
|
21
|
+
fileName?: string;
|
|
22
|
+
pureFileName?: string;
|
|
23
|
+
loc?: { line: number; column: number };
|
|
24
|
+
radius?: number;
|
|
25
|
+
color?: string;
|
|
26
|
+
combo?: string;
|
|
27
|
+
gitStatus?: "added" | "modified" | "deleted";
|
|
28
|
+
declarationKind?: "const" | "let" | "var" | "using" | "await using";
|
|
29
|
+
tag?: string;
|
|
30
|
+
raw?: ComponentFileVar;
|
|
31
|
+
displayName?: string;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface GraphComboData extends GraphNodeData {
|
|
36
|
+
collapsed?: boolean;
|
|
37
|
+
collapsedRadius?: number;
|
|
38
|
+
expandedRadius?: number;
|
|
39
|
+
padding?: number;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface GraphArrowData {
|
|
44
|
+
id: string;
|
|
45
|
+
source: string;
|
|
46
|
+
target: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
combo?: string;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface useGraphProps {
|
|
53
|
+
nodes: GraphNodeData[];
|
|
54
|
+
edges: GraphArrowData[];
|
|
55
|
+
combos: GraphComboData[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface GraphViewResult extends useGraphProps {
|
|
59
|
+
typeData: Record<string, TypeDataDeclare>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface GraphViewTask {
|
|
63
|
+
id: string;
|
|
64
|
+
priority: number;
|
|
65
|
+
run: (
|
|
66
|
+
data: DatabaseData,
|
|
67
|
+
result: GraphViewResult,
|
|
68
|
+
batch?: Partial<DatabaseData>,
|
|
69
|
+
) => GraphViewResult;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface DetailSectionProps {
|
|
73
|
+
selectedId: string;
|
|
74
|
+
item: GraphNodeData | GraphComboData;
|
|
75
|
+
graph: unknown; // GraphData instance
|
|
76
|
+
projectPath: string;
|
|
77
|
+
typeData: Record<string, TypeDataDeclare>;
|
|
78
|
+
onSelect?: (id: string) => void;
|
|
79
|
+
renderNodes?: GraphNodeData[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DetailSection {
|
|
83
|
+
id: string;
|
|
84
|
+
title: string;
|
|
85
|
+
priority: number;
|
|
86
|
+
component: React.ComponentType<DetailSectionProps>;
|
|
87
|
+
shouldShow: (item: GraphNodeData | GraphComboData) => boolean;
|
|
88
|
+
defaultOpen?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface MCPToolHandlerArgs {
|
|
92
|
+
projectPath?: string;
|
|
93
|
+
projectManager: unknown; // We use unknown here to avoid dependency on server package
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface MCPTool {
|
|
98
|
+
name: string;
|
|
99
|
+
description: string;
|
|
100
|
+
inputSchema: Record<string, unknown>;
|
|
101
|
+
handler: (args: MCPToolHandlerArgs) => Promise<unknown>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface Extension {
|
|
105
|
+
id: string;
|
|
106
|
+
viewTasks?: Record<string, GraphViewTask[]>; // Mapping of GraphViewType to tasks
|
|
107
|
+
detailSections?: DetailSection[];
|
|
108
|
+
mcpTools?: MCPTool[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export * from "./tasks/componentTask.js";
|
|
112
|
+
export * from "./tasks/gitTask.js";
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"jsx": "react-jsx",
|
|
14
|
+
"baseUrl": ".",
|
|
15
|
+
"paths": {
|
|
16
|
+
"@nexiq/shared": ["../shared/src/index.ts"],
|
|
17
|
+
"@nexiq/shared/*": ["../shared/src/*"]
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"include": ["src"]
|
|
21
|
+
}
|