@principal-ai/principal-view-react 0.16.57 → 0.16.58
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/subsystem/SubsystemComponentGraph.d.ts +10 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +379 -39
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/model.d.ts +34 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +1 -1
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts +28 -0
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +52 -3
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/utils/elkLayout.d.ts.map +1 -1
- package/dist/utils/elkLayout.js +4 -3
- package/dist/utils/elkLayout.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Subsystem/ComponentGraph/Flows.stories.tsx +181 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +533 -39
- package/src/subsystem/model.ts +37 -1
- package/src/subsystem/nodes.test.ts +56 -0
- package/src/subsystem/nodes.tsx +58 -4
- package/src/utils/elkLayout.ts +4 -3
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@xyflow/react/dist/style.css';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
5
|
+
import { SubsystemComponentGraph } from '../../../subsystem/SubsystemComponentGraph';
|
|
6
|
+
import type {
|
|
7
|
+
SubsystemComponent,
|
|
8
|
+
SubsystemComponentEdge,
|
|
9
|
+
SubsystemThroughline,
|
|
10
|
+
} from '../../../subsystem/model';
|
|
11
|
+
|
|
12
|
+
const meta = {
|
|
13
|
+
title: 'Subsystem/ComponentGraph/Flows',
|
|
14
|
+
component: SubsystemComponentGraph,
|
|
15
|
+
parameters: {
|
|
16
|
+
layout: 'fullscreen',
|
|
17
|
+
},
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
decorators: [
|
|
20
|
+
(Story) => (
|
|
21
|
+
<ThemeProvider theme={defaultEditorTheme}>
|
|
22
|
+
<Story />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
} satisfies Meta<typeof SubsystemComponentGraph>;
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Mirror of the retrofitted electron-app drawing graph: the sidebar's Files
|
|
33
|
+
// panel swaps to a Flows panel listing three throughlines (open / save /
|
|
34
|
+
// delete). Clicking a flow row toggles its steps; clicking a step focuses
|
|
35
|
+
// that step's edge and frames it on the canvas. Other opened flows stay
|
|
36
|
+
// dimmed; the rest of the graph is hidden.
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
const drawingComponents: SubsystemComponent[] = [
|
|
40
|
+
{
|
|
41
|
+
id: 'panel',
|
|
42
|
+
name: 'DrawingsLeftPanel',
|
|
43
|
+
construct: 'class',
|
|
44
|
+
file: 'src/panels/DrawingsLeftPanel.tsx',
|
|
45
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
46
|
+
purpose: 'lists drawings; emits open/delete intents',
|
|
47
|
+
symbol: 'DrawingsLeftPanel',
|
|
48
|
+
process: 'draw-list',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'host',
|
|
52
|
+
name: 'useDrawingsHost',
|
|
53
|
+
construct: 'function',
|
|
54
|
+
file: 'src/hooks/useDrawingsHost.ts',
|
|
55
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
56
|
+
purpose: 'hosts drawing CRUD; dispatches to storage and shell',
|
|
57
|
+
symbol: 'useDrawingsHost',
|
|
58
|
+
process: 'draw-list',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'storage',
|
|
62
|
+
name: 'DrawingsStorage',
|
|
63
|
+
construct: 'class',
|
|
64
|
+
file: 'src/storage/drawingsStorage.ts',
|
|
65
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
66
|
+
purpose: 'persists drawings as files',
|
|
67
|
+
symbol: 'DrawingsStorage',
|
|
68
|
+
process: 'draw-host',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'fs',
|
|
72
|
+
name: 'FileSystemService',
|
|
73
|
+
construct: 'external',
|
|
74
|
+
file: 'src/services/fileSystem.ts',
|
|
75
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
76
|
+
purpose: 'sandboxed host fd/fs access',
|
|
77
|
+
symbol: 'FileSystemService',
|
|
78
|
+
role: 'service',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'shell',
|
|
82
|
+
name: 'WorkspaceShell',
|
|
83
|
+
construct: 'class',
|
|
84
|
+
file: 'src/workspace/WorkspaceShell.tsx',
|
|
85
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
86
|
+
purpose: 'mounts tabs for opened drawings',
|
|
87
|
+
symbol: 'WorkspaceShell',
|
|
88
|
+
process: 'draw-host',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'tab',
|
|
92
|
+
name: 'DrawingTabContent',
|
|
93
|
+
construct: 'class',
|
|
94
|
+
file: 'src/components/DrawingTabContent.tsx',
|
|
95
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
96
|
+
purpose: 'loads/saves an open drawing',
|
|
97
|
+
symbol: 'DrawingTabContent',
|
|
98
|
+
process: 'draw-host',
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
const drawingEdges: SubsystemComponentEdge[] = [
|
|
103
|
+
{ id: 'e-scan', from: 'panel', to: 'storage', mechanism: 'calls' },
|
|
104
|
+
{ id: 'e-open-event', from: 'panel', to: 'host', mechanism: 'produces' },
|
|
105
|
+
{ id: 'e-refresh', from: 'host', to: 'panel', mechanism: 'produces' },
|
|
106
|
+
{ id: 'e-open', from: 'host', to: 'storage', mechanism: 'calls' },
|
|
107
|
+
{ id: 'e-read', from: 'storage', to: 'fs', mechanism: 'calls' },
|
|
108
|
+
{ id: 'e-delete', from: 'host', to: 'fs', mechanism: 'calls' },
|
|
109
|
+
{ id: 'e-show', from: 'host', to: 'shell', mechanism: 'produces' },
|
|
110
|
+
{ id: 'e-mount', from: 'shell', to: 'tab', mechanism: 'feeds' },
|
|
111
|
+
{ id: 'e-tab-io', from: 'tab', to: 'fs', mechanism: 'calls' },
|
|
112
|
+
{ id: 'e-saved-event', from: 'tab', to: 'host', mechanism: 'produces' },
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
const drawingThroughlines: SubsystemThroughline[] = [
|
|
116
|
+
{
|
|
117
|
+
id: 'tl-open-drawing',
|
|
118
|
+
title: 'Open drawing',
|
|
119
|
+
steps: [
|
|
120
|
+
{ edgeId: 'e-scan', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
|
|
121
|
+
{ edgeId: 'e-open-event', file: 'src/panels/DrawingsLeftPanel.tsx', line: 85, symbol: 'DrawingsLeftPanel.openDrawing' },
|
|
122
|
+
{ edgeId: 'e-open', file: 'src/hooks/useDrawingsHost.ts', line: 45, symbol: 'useDrawingsHost.openDrawing' },
|
|
123
|
+
{ edgeId: 'e-show', file: 'src/workspace/WorkspaceShell.tsx', line: 369, symbol: 'WorkspaceShell.openTab' },
|
|
124
|
+
{ edgeId: 'e-mount', file: 'src/workspace/WorkspaceShell.tsx', line: 372, symbol: 'WorkspaceShell.mountTab' },
|
|
125
|
+
{ edgeId: 'e-read', file: 'src/storage/drawingsStorage.ts', line: 90, symbol: 'DrawingsStorage.read' },
|
|
126
|
+
{ edgeId: 'e-tab-io', file: 'src/components/DrawingTabContent.tsx', line: 83, symbol: 'DrawingTabContent.load' },
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 'tl-save-drawing',
|
|
131
|
+
title: 'Save drawing',
|
|
132
|
+
steps: [
|
|
133
|
+
{ edgeId: 'e-tab-io', file: 'src/components/DrawingTabContent.tsx', line: 112, symbol: 'DrawingTabContent.save' },
|
|
134
|
+
{ edgeId: 'e-saved-event', file: 'src/components/DrawingTabContent.tsx', line: 121, symbol: 'DrawingTabContent.emitSaved' },
|
|
135
|
+
{ edgeId: 'e-refresh', file: 'src/hooks/useDrawingsHost.ts', line: 64, symbol: 'useDrawingsHost.onSaved' },
|
|
136
|
+
{ edgeId: 'e-scan', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'tl-delete-drawing',
|
|
141
|
+
title: 'Delete drawing',
|
|
142
|
+
steps: [
|
|
143
|
+
{ edgeId: 'e-delete', file: 'src/hooks/useDrawingsHost.ts', line: 64, symbol: 'useDrawingsHost.deleteDrawing' },
|
|
144
|
+
{ edgeId: 'e-refresh', file: 'src/hooks/useDrawingsHost.ts', line: 66, symbol: 'useDrawingsHost.refreshList' },
|
|
145
|
+
{ edgeId: 'e-scan', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
function FlowsDemo() {
|
|
151
|
+
return (
|
|
152
|
+
<div style={{ width: '100%', height: '100vh', display: 'flex', flexDirection: 'column' }}>
|
|
153
|
+
<SubsystemComponentGraph
|
|
154
|
+
components={drawingComponents}
|
|
155
|
+
edges={drawingEdges}
|
|
156
|
+
throughlines={drawingThroughlines}
|
|
157
|
+
title="drawing-files flow"
|
|
158
|
+
description="Three throughlines over one graph — opening, saving, and deleting a drawing. The sidebar's **Flows** panel lists each step by **symbol** (the frame at that hop); clicking a step focuses that edge on the canvas."
|
|
159
|
+
renderFileViewer={(file, opts) => (
|
|
160
|
+
<div
|
|
161
|
+
style={{
|
|
162
|
+
padding: 12,
|
|
163
|
+
fontFamily: 'monospace',
|
|
164
|
+
fontSize: 12,
|
|
165
|
+
color: '#bbb',
|
|
166
|
+
whiteSpace: 'pre',
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
{`// ${file}`}
|
|
170
|
+
{opts?.startLine != null ? `\n // → focus line ${opts.startLine}` : ''}
|
|
171
|
+
{'\n …'}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export const ThreeFlows: Story = {
|
|
180
|
+
render: () => <FlowsDemo />,
|
|
181
|
+
};
|