@arach/arc 0.4.5 → 0.6.0

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.
@@ -0,0 +1,197 @@
1
+ // Arc Diagram Types
2
+ // Shared format for Arc editor and consumers (Talkie docs, etc.)
3
+
4
+ import type { NodeShape } from '../utils/nodeShape'
5
+
6
+ export type { NodeShape }
7
+
8
+ export type NodeSize = 'xs' | 's' | 'm' | 'l'
9
+
10
+ export type AnchorPosition =
11
+ | 'left' | 'right' | 'top' | 'bottom'
12
+ | 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight'
13
+
14
+ export type DiagramColor =
15
+ | 'violet' | 'emerald' | 'blue' | 'amber'
16
+ | 'sky' | 'zinc' | 'rose' | 'orange'
17
+
18
+ export interface NodePosition {
19
+ x: number
20
+ y: number
21
+ size: NodeSize
22
+ }
23
+
24
+ export interface NodeData {
25
+ icon: string
26
+ name: string
27
+ subtitle?: string
28
+ description?: string
29
+ color: DiagramColor
30
+ /** Per-node silhouette. Omit to follow the theme's own node shape. */
31
+ shape?: NodeShape
32
+ }
33
+
34
+ export interface Connector {
35
+ from: string
36
+ to: string
37
+ fromAnchor: AnchorPosition
38
+ toAnchor: AnchorPosition
39
+ style: string
40
+ curve?: 'natural' | 'step'
41
+ }
42
+
43
+ export interface ConnectorStyle {
44
+ color: DiagramColor
45
+ strokeWidth: number
46
+ label?: string
47
+ dashed?: boolean
48
+ }
49
+
50
+ export interface DiagramLayout {
51
+ width: number
52
+ height: number
53
+ }
54
+
55
+ export interface GridConfig {
56
+ enabled: boolean
57
+ size: number
58
+ color: string
59
+ opacity: number
60
+ type: 'dots' | 'lines'
61
+ }
62
+
63
+ export interface GroupShape {
64
+ id: string
65
+ x: number
66
+ y: number
67
+ width: number
68
+ height: number
69
+ type: 'rect' | 'circle'
70
+ color: DiagramColor
71
+ label?: string
72
+ dashed?: boolean
73
+ }
74
+
75
+ export interface FocusConnectorRef {
76
+ from: string
77
+ to: string
78
+ }
79
+
80
+ export interface FocusStep {
81
+ icon: string
82
+ label: string
83
+ }
84
+
85
+ /** A declarative highlight story activated by hovering or selecting a node. */
86
+ export interface FocusTarget {
87
+ /** `append` includes direct neighbors; `replace` uses only the explicit story. */
88
+ mode?: 'append' | 'replace'
89
+ nodes?: string[]
90
+ connectors?: FocusConnectorRef[]
91
+ caption?: string
92
+ steps?: FocusStep[]
93
+ }
94
+
95
+ export type LayoutAlignment = 'start' | 'center' | 'end'
96
+ export type GroupLayoutDirection = 'horizontal' | 'vertical'
97
+
98
+ /** Optional placement hints used by autoLayout when nodes belong to groups. */
99
+ export interface NodeLayoutHint {
100
+ /** ID of the group frame that owns this node. */
101
+ group?: string
102
+ /** Explicit layer within the group. Connected nodes are layered automatically otherwise. */
103
+ layer?: number
104
+ /** Stable ordering within a layer. Lower values render first. */
105
+ order?: number
106
+ }
107
+
108
+ /** Layout policy for the nodes inside one group frame. */
109
+ export interface GroupLayoutHint {
110
+ /** `horizontal` lays layers left-to-right; `vertical` lays them top-to-bottom. */
111
+ direction?: GroupLayoutDirection
112
+ padding?: number
113
+ layerGap?: number
114
+ itemGap?: number
115
+ align?: LayoutAlignment
116
+ justify?: LayoutAlignment | 'space-between'
117
+ }
118
+
119
+ export interface LayoutHints {
120
+ nodes?: Record<string, NodeLayoutHint>
121
+ groups?: Record<string, GroupLayoutHint>
122
+ }
123
+
124
+ export interface DiagramImage {
125
+ id: string
126
+ src: string
127
+ name: string
128
+ x: number
129
+ y: number
130
+ width: number
131
+ height: number
132
+ opacity: number
133
+ }
134
+
135
+ export interface ExportZone {
136
+ x: number
137
+ y: number
138
+ width: number
139
+ height: number
140
+ }
141
+
142
+ // Full diagram format (internal Arc state)
143
+ export interface ArcDiagram {
144
+ layout: DiagramLayout
145
+ grid: GridConfig
146
+ layoutHints?: LayoutHints
147
+ nodes: Record<string, NodePosition>
148
+ nodeData: Record<string, NodeData>
149
+ connectors: Connector[]
150
+ connectorStyles: Record<string, ConnectorStyle>
151
+ groups?: GroupShape[]
152
+ focusTargets?: Record<string, FocusTarget>
153
+ images?: DiagramImage[]
154
+ exportZone?: ExportZone | null
155
+ }
156
+
157
+ // Clean export format (for consumers)
158
+ export interface ArcDiagramData {
159
+ id?: string
160
+ layout: DiagramLayout
161
+ layoutHints?: LayoutHints
162
+ nodes: Record<string, NodePosition>
163
+ nodeData: Record<string, NodeData>
164
+ connectors: Connector[]
165
+ connectorStyles: Record<string, ConnectorStyle>
166
+ focusTargets?: Record<string, FocusTarget>
167
+ groups?: GroupShape[]
168
+ }
169
+
170
+ // Convert full diagram to clean export format
171
+ export function toExportFormat(diagram: ArcDiagram): ArcDiagramData {
172
+ return {
173
+ layout: diagram.layout,
174
+ layoutHints: diagram.layoutHints,
175
+ nodes: diagram.nodes,
176
+ nodeData: diagram.nodeData,
177
+ connectors: diagram.connectors,
178
+ connectorStyles: diagram.connectorStyles,
179
+ focusTargets: diagram.focusTargets,
180
+ groups: diagram.groups,
181
+ }
182
+ }
183
+
184
+ // Generate TypeScript source file content
185
+ export function toTypeScriptSource(diagram: ArcDiagram, name: string = 'diagram'): string {
186
+ const data = toExportFormat(diagram)
187
+ const json = JSON.stringify(data, null, 2)
188
+ .replace(/"([^"]+)":/g, '$1:') // Remove quotes from keys
189
+ .replace(/"/g, "'") // Use single quotes
190
+
191
+ return `import type { ArcDiagramData } from '@arach/arc'
192
+
193
+ const ${name}: ArcDiagramData = ${json}
194
+
195
+ export default ${name}
196
+ `
197
+ }
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/commands" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@lezer/highlight" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/lang-css" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/lang-html" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/lang-javascript" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/lang-json" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/lang-markdown" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/language" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/state" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };
@@ -1,5 +0,0 @@
1
- const o = {};
2
- throw new Error('Could not resolve "@codemirror/view" imported by "hudsonkit".');
3
- export {
4
- o as default
5
- };