@01.software/sdk 0.4.3-dev.1774344568213 → 0.4.3-dev.1774352883356
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/README.md +13 -13
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -12
- package/dist/index.d.ts +21 -12
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js.map +1 -1
- package/dist/server-B80o7igg.d.cts +242 -0
- package/dist/server-B80o7igg.d.ts +242 -0
- package/dist/ui/flow/server.cjs +233 -0
- package/dist/ui/flow/server.cjs.map +1 -0
- package/dist/ui/flow/server.d.cts +3 -0
- package/dist/ui/flow/server.d.ts +3 -0
- package/dist/ui/flow/server.js +213 -0
- package/dist/ui/flow/server.js.map +1 -0
- package/dist/ui/flow.cjs +39 -0
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.d.cts +5 -222
- package/dist/ui/flow.d.ts +5 -222
- package/dist/ui/flow.js +39 -0
- package/dist/ui/flow.js.map +1 -1
- package/package.json +11 -1
package/dist/ui/flow.d.cts
CHANGED
|
@@ -1,191 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { N as NodeTypeDef, E as EdgeTypeDef, C as CanvasData, F as FlowNode, D as DynamicNodeSlotProps, a as FlowEdge, b as FrameNodeSlotProps, c as EdgeSlotProps, d as NodeWrapperSlotProps, e as FlowViewport, f as FlowBounds } from '../server-B80o7igg.cjs';
|
|
2
|
+
export { i as DynamicNodeData, h as FlowNodeData, g as FlowNodePosition, s as FrameData, j as FrameNodeData, k as NodeTypeFieldDef, P as PrefetchFlowOptions, S as SDKClient, U as UseFlowOptions, n as UseFlowResult, r as getFrameData, q as getFrames, o as getNodeBounds, l as isDynamicNode, m as isFrameNode, p as prefetchFlow, u as useFlow } from '../server-B80o7igg.cjs';
|
|
3
3
|
import { Edge } from '@xyflow/react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
nodeTypeSlug: string;
|
|
7
|
-
label: string;
|
|
8
|
-
fields: Record<string, unknown>;
|
|
9
|
-
}
|
|
10
|
-
type FlowNodeData = (DynamicNodeData | FrameNodeData) & Record<string, unknown>;
|
|
11
|
-
interface FlowNodePosition {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
}
|
|
15
|
-
interface FlowNode {
|
|
16
|
-
id: string;
|
|
17
|
-
type?: string;
|
|
18
|
-
position: FlowNodePosition;
|
|
19
|
-
data: FlowNodeData;
|
|
20
|
-
parentId?: string;
|
|
21
|
-
style?: React.CSSProperties;
|
|
22
|
-
width?: number;
|
|
23
|
-
height?: number;
|
|
24
|
-
measured?: {
|
|
25
|
-
width?: number;
|
|
26
|
-
height?: number;
|
|
27
|
-
};
|
|
28
|
-
draggable?: boolean;
|
|
29
|
-
selectable?: boolean;
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
}
|
|
32
|
-
interface FlowEdge {
|
|
33
|
-
id: string;
|
|
34
|
-
source: string;
|
|
35
|
-
target: string;
|
|
36
|
-
sourceHandle?: string | null;
|
|
37
|
-
targetHandle?: string | null;
|
|
38
|
-
type?: string;
|
|
39
|
-
style?: React.CSSProperties;
|
|
40
|
-
animated?: boolean;
|
|
41
|
-
markerStart?: unknown;
|
|
42
|
-
markerEnd?: unknown;
|
|
43
|
-
edgeTypeSlug?: string;
|
|
44
|
-
fields?: Record<string, unknown>;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
}
|
|
47
|
-
interface FlowViewport {
|
|
48
|
-
x: number;
|
|
49
|
-
y: number;
|
|
50
|
-
zoom: number;
|
|
51
|
-
}
|
|
52
|
-
interface CanvasData {
|
|
53
|
-
nodes: FlowNode[];
|
|
54
|
-
edges: FlowEdge[];
|
|
55
|
-
viewport: FlowViewport;
|
|
56
|
-
}
|
|
57
|
-
interface NodeTypeFieldDef {
|
|
58
|
-
name: string;
|
|
59
|
-
label: string;
|
|
60
|
-
fieldType: 'text' | 'textarea' | 'number' | 'url' | 'color' | 'image' | 'select' | 'toggle';
|
|
61
|
-
options?: {
|
|
62
|
-
label: string;
|
|
63
|
-
value: string;
|
|
64
|
-
}[];
|
|
65
|
-
defaultValue?: string;
|
|
66
|
-
required?: boolean;
|
|
67
|
-
}
|
|
68
|
-
interface NodeTypeDef {
|
|
69
|
-
slug: string;
|
|
70
|
-
name: string;
|
|
71
|
-
color: string;
|
|
72
|
-
defaultSize: {
|
|
73
|
-
width: number;
|
|
74
|
-
height: number;
|
|
75
|
-
};
|
|
76
|
-
fields: NodeTypeFieldDef[];
|
|
77
|
-
transparentBackground?: boolean;
|
|
78
|
-
template?: string | null;
|
|
79
|
-
customCSS?: string | null;
|
|
80
|
-
}
|
|
81
|
-
interface EdgeTypeDef {
|
|
82
|
-
slug: string;
|
|
83
|
-
name: string;
|
|
84
|
-
color: string;
|
|
85
|
-
strokeWidth: number;
|
|
86
|
-
animated: boolean;
|
|
87
|
-
lineStyle: string;
|
|
88
|
-
markerStart: string;
|
|
89
|
-
markerEnd: string;
|
|
90
|
-
fields: NodeTypeFieldDef[];
|
|
91
|
-
}
|
|
92
|
-
declare function isDynamicNode(node: FlowNode): node is FlowNode & {
|
|
93
|
-
data: DynamicNodeData;
|
|
94
|
-
};
|
|
95
|
-
declare function isFrameNode(node: FlowNode): node is FlowNode & {
|
|
96
|
-
data: FrameNodeData;
|
|
97
|
-
};
|
|
98
|
-
interface DynamicNodeSlotProps {
|
|
99
|
-
id: string;
|
|
100
|
-
nodeTypeSlug: string;
|
|
101
|
-
label: string;
|
|
102
|
-
fields: Record<string, unknown>;
|
|
103
|
-
nodeTypeDef?: NodeTypeDef;
|
|
104
|
-
/** Whether this node is currently selected */
|
|
105
|
-
selected?: boolean;
|
|
106
|
-
/** Measured node width (undefined before first measurement) */
|
|
107
|
-
width?: number;
|
|
108
|
-
/** Measured node height (undefined before first measurement) */
|
|
109
|
-
height?: number;
|
|
110
|
-
/** The default rendering (template or field-based). Allows custom renderers to wrap/extend instead of replacing entirely. */
|
|
111
|
-
defaultRender?: React.ReactElement;
|
|
112
|
-
}
|
|
113
|
-
interface FrameNodeData {
|
|
114
|
-
label: string;
|
|
115
|
-
color?: string;
|
|
116
|
-
padding?: number;
|
|
117
|
-
borderStyle?: 'dashed' | 'solid' | 'none';
|
|
118
|
-
opacity?: number;
|
|
119
|
-
}
|
|
120
|
-
interface FrameNodeSlotProps {
|
|
121
|
-
id: string;
|
|
122
|
-
label: string;
|
|
123
|
-
color?: string;
|
|
124
|
-
padding?: number;
|
|
125
|
-
borderStyle?: 'dashed' | 'solid' | 'none';
|
|
126
|
-
opacity?: number;
|
|
127
|
-
width?: number;
|
|
128
|
-
height?: number;
|
|
129
|
-
children?: React.ReactNode;
|
|
130
|
-
}
|
|
131
|
-
interface EdgeSlotProps {
|
|
132
|
-
id: string;
|
|
133
|
-
edgeTypeSlug?: string;
|
|
134
|
-
source: string;
|
|
135
|
-
target: string;
|
|
136
|
-
label?: string;
|
|
137
|
-
fields?: Record<string, unknown>;
|
|
138
|
-
edgeTypeDef?: EdgeTypeDef;
|
|
139
|
-
style?: React.CSSProperties;
|
|
140
|
-
}
|
|
141
|
-
interface NodeWrapperSlotProps {
|
|
142
|
-
id: string;
|
|
143
|
-
nodeTypeSlug: string;
|
|
144
|
-
label: string;
|
|
145
|
-
selected?: boolean;
|
|
146
|
-
nodeTypeDef?: NodeTypeDef;
|
|
147
|
-
children: React.ReactNode;
|
|
148
|
-
}
|
|
149
|
-
interface FlowBounds {
|
|
150
|
-
x: number;
|
|
151
|
-
y: number;
|
|
152
|
-
width: number;
|
|
153
|
-
height: number;
|
|
154
|
-
}
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@tanstack/react-query';
|
|
155
6
|
|
|
156
7
|
declare const BUILT_IN_NODE_TYPES: NodeTypeDef[];
|
|
157
8
|
|
|
158
9
|
declare const BUILT_IN_EDGE_TYPES: EdgeTypeDef[];
|
|
159
10
|
|
|
160
|
-
type FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types';
|
|
161
|
-
type AnyFn = (...args: any[]) => any;
|
|
162
|
-
interface SDKClient {
|
|
163
|
-
from(collection: FlowCollection): {
|
|
164
|
-
find: AnyFn;
|
|
165
|
-
findById: AnyFn;
|
|
166
|
-
};
|
|
167
|
-
queryClient: QueryClient;
|
|
168
|
-
}
|
|
169
|
-
interface UseFlowOptions {
|
|
170
|
-
/** SDK client instance (BrowserClient or ServerClient) */
|
|
171
|
-
client: SDKClient;
|
|
172
|
-
/** Flow slug (URL-friendly identifier) */
|
|
173
|
-
slug?: string;
|
|
174
|
-
/** Flow document ID (UUID) */
|
|
175
|
-
id?: string;
|
|
176
|
-
/** Enable/disable data fetching (default: true) */
|
|
177
|
-
enabled?: boolean;
|
|
178
|
-
}
|
|
179
|
-
interface UseFlowResult {
|
|
180
|
-
data: CanvasData | undefined;
|
|
181
|
-
nodeTypeDefs: NodeTypeDef[];
|
|
182
|
-
edgeTypeDefs: EdgeTypeDef[];
|
|
183
|
-
flow: Record<string, unknown> | undefined;
|
|
184
|
-
isLoading: boolean;
|
|
185
|
-
error: Error | null;
|
|
186
|
-
}
|
|
187
|
-
declare function useFlow(options: UseFlowOptions): UseFlowResult;
|
|
188
|
-
|
|
189
11
|
interface UseFlowDataOptions {
|
|
190
12
|
/** Canvas data from Flow document's `canvas` field */
|
|
191
13
|
data: CanvasData | undefined;
|
|
@@ -211,45 +33,6 @@ interface UseFlowDataResult {
|
|
|
211
33
|
*/
|
|
212
34
|
declare function useFlowData(options: UseFlowDataOptions): UseFlowDataResult;
|
|
213
35
|
|
|
214
|
-
/**
|
|
215
|
-
* Calculate bounding box for given node IDs.
|
|
216
|
-
* Pure function — usable in SSR, server components, or outside React.
|
|
217
|
-
*/
|
|
218
|
-
declare function getNodeBounds(nodes: FlowNode[], nodeIds: string[]): FlowBounds | undefined;
|
|
219
|
-
/**
|
|
220
|
-
* Get all frame nodes with their bounds.
|
|
221
|
-
* Sorted by position (top-left to bottom-right).
|
|
222
|
-
*/
|
|
223
|
-
declare function getFrames(nodes: FlowNode[]): Array<{
|
|
224
|
-
id: string;
|
|
225
|
-
label: string;
|
|
226
|
-
bounds: FlowBounds;
|
|
227
|
-
}>;
|
|
228
|
-
/** Result of getFrameData — contains filtered canvas + dual bounds. */
|
|
229
|
-
interface FrameData {
|
|
230
|
-
/** Canvas data containing only the frame's descendants (nodes have draggable: false). */
|
|
231
|
-
data: CanvasData;
|
|
232
|
-
/** Bounding box of child content nodes — use for initial viewport fit (centering). */
|
|
233
|
-
fitBounds: FlowBounds;
|
|
234
|
-
/** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */
|
|
235
|
-
clampBounds: FlowBounds;
|
|
236
|
-
/** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */
|
|
237
|
-
bounds: FlowBounds;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Extract a frame's descendants and related edges from canvas data.
|
|
241
|
-
* Recursively collects all nested children (supports nested frames).
|
|
242
|
-
* Returns undefined if frameId is not found or is not a frame node.
|
|
243
|
-
*
|
|
244
|
-
* Child nodes are marked `draggable: false` to prevent interfering with canvas panning.
|
|
245
|
-
* The frame node itself is included (use `frameRenderer={() => null}` to hide it).
|
|
246
|
-
*
|
|
247
|
-
* Returns dual bounds:
|
|
248
|
-
* - `fitBounds`: child content bounding box (for centering the viewport)
|
|
249
|
-
* - `clampBounds`: frame area bounding box (for panning restriction)
|
|
250
|
-
*/
|
|
251
|
-
declare function getFrameData(data: CanvasData, frameId: string): FrameData | undefined;
|
|
252
|
-
|
|
253
36
|
interface CodeComponentProps {
|
|
254
37
|
fields: Record<string, unknown>;
|
|
255
38
|
label: string;
|
|
@@ -341,4 +124,4 @@ interface FlowRendererProps {
|
|
|
341
124
|
}
|
|
342
125
|
declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseLeave, onEdgeClick, frameRenderer, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, clampBounds, focusPadding, focusAnimation, focusMode, responsiveFit, translateExtent: translateExtentProp, minZoom: minZoomProp, maxZoom: maxZoomProp, }: FlowRendererProps): React.JSX.Element | null;
|
|
343
126
|
|
|
344
|
-
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES,
|
|
127
|
+
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, CanvasData, type CodeComponentProps, DynamicNodeSlotProps, EdgeSlotProps, EdgeTypeDef, FlowBounds, FlowEdge, FlowNode, FlowRenderer, type FlowRendererProps, FlowViewport, FrameNodeSlotProps, NodeTypeDef, NodeWrapperSlotProps, type UseFlowDataOptions, type UseFlowDataResult, clearTemplateCache, compileTemplate, useFlowData };
|
package/dist/ui/flow.d.ts
CHANGED
|
@@ -1,191 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { N as NodeTypeDef, E as EdgeTypeDef, C as CanvasData, F as FlowNode, D as DynamicNodeSlotProps, a as FlowEdge, b as FrameNodeSlotProps, c as EdgeSlotProps, d as NodeWrapperSlotProps, e as FlowViewport, f as FlowBounds } from '../server-B80o7igg.js';
|
|
2
|
+
export { i as DynamicNodeData, h as FlowNodeData, g as FlowNodePosition, s as FrameData, j as FrameNodeData, k as NodeTypeFieldDef, P as PrefetchFlowOptions, S as SDKClient, U as UseFlowOptions, n as UseFlowResult, r as getFrameData, q as getFrames, o as getNodeBounds, l as isDynamicNode, m as isFrameNode, p as prefetchFlow, u as useFlow } from '../server-B80o7igg.js';
|
|
3
3
|
import { Edge } from '@xyflow/react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
nodeTypeSlug: string;
|
|
7
|
-
label: string;
|
|
8
|
-
fields: Record<string, unknown>;
|
|
9
|
-
}
|
|
10
|
-
type FlowNodeData = (DynamicNodeData | FrameNodeData) & Record<string, unknown>;
|
|
11
|
-
interface FlowNodePosition {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
}
|
|
15
|
-
interface FlowNode {
|
|
16
|
-
id: string;
|
|
17
|
-
type?: string;
|
|
18
|
-
position: FlowNodePosition;
|
|
19
|
-
data: FlowNodeData;
|
|
20
|
-
parentId?: string;
|
|
21
|
-
style?: React.CSSProperties;
|
|
22
|
-
width?: number;
|
|
23
|
-
height?: number;
|
|
24
|
-
measured?: {
|
|
25
|
-
width?: number;
|
|
26
|
-
height?: number;
|
|
27
|
-
};
|
|
28
|
-
draggable?: boolean;
|
|
29
|
-
selectable?: boolean;
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
}
|
|
32
|
-
interface FlowEdge {
|
|
33
|
-
id: string;
|
|
34
|
-
source: string;
|
|
35
|
-
target: string;
|
|
36
|
-
sourceHandle?: string | null;
|
|
37
|
-
targetHandle?: string | null;
|
|
38
|
-
type?: string;
|
|
39
|
-
style?: React.CSSProperties;
|
|
40
|
-
animated?: boolean;
|
|
41
|
-
markerStart?: unknown;
|
|
42
|
-
markerEnd?: unknown;
|
|
43
|
-
edgeTypeSlug?: string;
|
|
44
|
-
fields?: Record<string, unknown>;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
}
|
|
47
|
-
interface FlowViewport {
|
|
48
|
-
x: number;
|
|
49
|
-
y: number;
|
|
50
|
-
zoom: number;
|
|
51
|
-
}
|
|
52
|
-
interface CanvasData {
|
|
53
|
-
nodes: FlowNode[];
|
|
54
|
-
edges: FlowEdge[];
|
|
55
|
-
viewport: FlowViewport;
|
|
56
|
-
}
|
|
57
|
-
interface NodeTypeFieldDef {
|
|
58
|
-
name: string;
|
|
59
|
-
label: string;
|
|
60
|
-
fieldType: 'text' | 'textarea' | 'number' | 'url' | 'color' | 'image' | 'select' | 'toggle';
|
|
61
|
-
options?: {
|
|
62
|
-
label: string;
|
|
63
|
-
value: string;
|
|
64
|
-
}[];
|
|
65
|
-
defaultValue?: string;
|
|
66
|
-
required?: boolean;
|
|
67
|
-
}
|
|
68
|
-
interface NodeTypeDef {
|
|
69
|
-
slug: string;
|
|
70
|
-
name: string;
|
|
71
|
-
color: string;
|
|
72
|
-
defaultSize: {
|
|
73
|
-
width: number;
|
|
74
|
-
height: number;
|
|
75
|
-
};
|
|
76
|
-
fields: NodeTypeFieldDef[];
|
|
77
|
-
transparentBackground?: boolean;
|
|
78
|
-
template?: string | null;
|
|
79
|
-
customCSS?: string | null;
|
|
80
|
-
}
|
|
81
|
-
interface EdgeTypeDef {
|
|
82
|
-
slug: string;
|
|
83
|
-
name: string;
|
|
84
|
-
color: string;
|
|
85
|
-
strokeWidth: number;
|
|
86
|
-
animated: boolean;
|
|
87
|
-
lineStyle: string;
|
|
88
|
-
markerStart: string;
|
|
89
|
-
markerEnd: string;
|
|
90
|
-
fields: NodeTypeFieldDef[];
|
|
91
|
-
}
|
|
92
|
-
declare function isDynamicNode(node: FlowNode): node is FlowNode & {
|
|
93
|
-
data: DynamicNodeData;
|
|
94
|
-
};
|
|
95
|
-
declare function isFrameNode(node: FlowNode): node is FlowNode & {
|
|
96
|
-
data: FrameNodeData;
|
|
97
|
-
};
|
|
98
|
-
interface DynamicNodeSlotProps {
|
|
99
|
-
id: string;
|
|
100
|
-
nodeTypeSlug: string;
|
|
101
|
-
label: string;
|
|
102
|
-
fields: Record<string, unknown>;
|
|
103
|
-
nodeTypeDef?: NodeTypeDef;
|
|
104
|
-
/** Whether this node is currently selected */
|
|
105
|
-
selected?: boolean;
|
|
106
|
-
/** Measured node width (undefined before first measurement) */
|
|
107
|
-
width?: number;
|
|
108
|
-
/** Measured node height (undefined before first measurement) */
|
|
109
|
-
height?: number;
|
|
110
|
-
/** The default rendering (template or field-based). Allows custom renderers to wrap/extend instead of replacing entirely. */
|
|
111
|
-
defaultRender?: React.ReactElement;
|
|
112
|
-
}
|
|
113
|
-
interface FrameNodeData {
|
|
114
|
-
label: string;
|
|
115
|
-
color?: string;
|
|
116
|
-
padding?: number;
|
|
117
|
-
borderStyle?: 'dashed' | 'solid' | 'none';
|
|
118
|
-
opacity?: number;
|
|
119
|
-
}
|
|
120
|
-
interface FrameNodeSlotProps {
|
|
121
|
-
id: string;
|
|
122
|
-
label: string;
|
|
123
|
-
color?: string;
|
|
124
|
-
padding?: number;
|
|
125
|
-
borderStyle?: 'dashed' | 'solid' | 'none';
|
|
126
|
-
opacity?: number;
|
|
127
|
-
width?: number;
|
|
128
|
-
height?: number;
|
|
129
|
-
children?: React.ReactNode;
|
|
130
|
-
}
|
|
131
|
-
interface EdgeSlotProps {
|
|
132
|
-
id: string;
|
|
133
|
-
edgeTypeSlug?: string;
|
|
134
|
-
source: string;
|
|
135
|
-
target: string;
|
|
136
|
-
label?: string;
|
|
137
|
-
fields?: Record<string, unknown>;
|
|
138
|
-
edgeTypeDef?: EdgeTypeDef;
|
|
139
|
-
style?: React.CSSProperties;
|
|
140
|
-
}
|
|
141
|
-
interface NodeWrapperSlotProps {
|
|
142
|
-
id: string;
|
|
143
|
-
nodeTypeSlug: string;
|
|
144
|
-
label: string;
|
|
145
|
-
selected?: boolean;
|
|
146
|
-
nodeTypeDef?: NodeTypeDef;
|
|
147
|
-
children: React.ReactNode;
|
|
148
|
-
}
|
|
149
|
-
interface FlowBounds {
|
|
150
|
-
x: number;
|
|
151
|
-
y: number;
|
|
152
|
-
width: number;
|
|
153
|
-
height: number;
|
|
154
|
-
}
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import '@tanstack/react-query';
|
|
155
6
|
|
|
156
7
|
declare const BUILT_IN_NODE_TYPES: NodeTypeDef[];
|
|
157
8
|
|
|
158
9
|
declare const BUILT_IN_EDGE_TYPES: EdgeTypeDef[];
|
|
159
10
|
|
|
160
|
-
type FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types';
|
|
161
|
-
type AnyFn = (...args: any[]) => any;
|
|
162
|
-
interface SDKClient {
|
|
163
|
-
from(collection: FlowCollection): {
|
|
164
|
-
find: AnyFn;
|
|
165
|
-
findById: AnyFn;
|
|
166
|
-
};
|
|
167
|
-
queryClient: QueryClient;
|
|
168
|
-
}
|
|
169
|
-
interface UseFlowOptions {
|
|
170
|
-
/** SDK client instance (BrowserClient or ServerClient) */
|
|
171
|
-
client: SDKClient;
|
|
172
|
-
/** Flow slug (URL-friendly identifier) */
|
|
173
|
-
slug?: string;
|
|
174
|
-
/** Flow document ID (UUID) */
|
|
175
|
-
id?: string;
|
|
176
|
-
/** Enable/disable data fetching (default: true) */
|
|
177
|
-
enabled?: boolean;
|
|
178
|
-
}
|
|
179
|
-
interface UseFlowResult {
|
|
180
|
-
data: CanvasData | undefined;
|
|
181
|
-
nodeTypeDefs: NodeTypeDef[];
|
|
182
|
-
edgeTypeDefs: EdgeTypeDef[];
|
|
183
|
-
flow: Record<string, unknown> | undefined;
|
|
184
|
-
isLoading: boolean;
|
|
185
|
-
error: Error | null;
|
|
186
|
-
}
|
|
187
|
-
declare function useFlow(options: UseFlowOptions): UseFlowResult;
|
|
188
|
-
|
|
189
11
|
interface UseFlowDataOptions {
|
|
190
12
|
/** Canvas data from Flow document's `canvas` field */
|
|
191
13
|
data: CanvasData | undefined;
|
|
@@ -211,45 +33,6 @@ interface UseFlowDataResult {
|
|
|
211
33
|
*/
|
|
212
34
|
declare function useFlowData(options: UseFlowDataOptions): UseFlowDataResult;
|
|
213
35
|
|
|
214
|
-
/**
|
|
215
|
-
* Calculate bounding box for given node IDs.
|
|
216
|
-
* Pure function — usable in SSR, server components, or outside React.
|
|
217
|
-
*/
|
|
218
|
-
declare function getNodeBounds(nodes: FlowNode[], nodeIds: string[]): FlowBounds | undefined;
|
|
219
|
-
/**
|
|
220
|
-
* Get all frame nodes with their bounds.
|
|
221
|
-
* Sorted by position (top-left to bottom-right).
|
|
222
|
-
*/
|
|
223
|
-
declare function getFrames(nodes: FlowNode[]): Array<{
|
|
224
|
-
id: string;
|
|
225
|
-
label: string;
|
|
226
|
-
bounds: FlowBounds;
|
|
227
|
-
}>;
|
|
228
|
-
/** Result of getFrameData — contains filtered canvas + dual bounds. */
|
|
229
|
-
interface FrameData {
|
|
230
|
-
/** Canvas data containing only the frame's descendants (nodes have draggable: false). */
|
|
231
|
-
data: CanvasData;
|
|
232
|
-
/** Bounding box of child content nodes — use for initial viewport fit (centering). */
|
|
233
|
-
fitBounds: FlowBounds;
|
|
234
|
-
/** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */
|
|
235
|
-
clampBounds: FlowBounds;
|
|
236
|
-
/** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */
|
|
237
|
-
bounds: FlowBounds;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Extract a frame's descendants and related edges from canvas data.
|
|
241
|
-
* Recursively collects all nested children (supports nested frames).
|
|
242
|
-
* Returns undefined if frameId is not found or is not a frame node.
|
|
243
|
-
*
|
|
244
|
-
* Child nodes are marked `draggable: false` to prevent interfering with canvas panning.
|
|
245
|
-
* The frame node itself is included (use `frameRenderer={() => null}` to hide it).
|
|
246
|
-
*
|
|
247
|
-
* Returns dual bounds:
|
|
248
|
-
* - `fitBounds`: child content bounding box (for centering the viewport)
|
|
249
|
-
* - `clampBounds`: frame area bounding box (for panning restriction)
|
|
250
|
-
*/
|
|
251
|
-
declare function getFrameData(data: CanvasData, frameId: string): FrameData | undefined;
|
|
252
|
-
|
|
253
36
|
interface CodeComponentProps {
|
|
254
37
|
fields: Record<string, unknown>;
|
|
255
38
|
label: string;
|
|
@@ -341,4 +124,4 @@ interface FlowRendererProps {
|
|
|
341
124
|
}
|
|
342
125
|
declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseLeave, onEdgeClick, frameRenderer, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, clampBounds, focusPadding, focusAnimation, focusMode, responsiveFit, translateExtent: translateExtentProp, minZoom: minZoomProp, maxZoom: maxZoomProp, }: FlowRendererProps): React.JSX.Element | null;
|
|
343
126
|
|
|
344
|
-
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES,
|
|
127
|
+
export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, CanvasData, type CodeComponentProps, DynamicNodeSlotProps, EdgeSlotProps, EdgeTypeDef, FlowBounds, FlowEdge, FlowNode, FlowRenderer, type FlowRendererProps, FlowViewport, FrameNodeSlotProps, NodeTypeDef, NodeWrapperSlotProps, type UseFlowDataOptions, type UseFlowDataResult, clearTemplateCache, compileTemplate, useFlowData };
|
package/dist/ui/flow.js
CHANGED
|
@@ -205,6 +205,44 @@ function useFlow(options) {
|
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
// src/ui/Flow/prefetchFlow.ts
|
|
209
|
+
function prefetchFlow(options) {
|
|
210
|
+
return __async(this, null, function* () {
|
|
211
|
+
var _a;
|
|
212
|
+
const { client, slug, id } = options;
|
|
213
|
+
const identifier = (_a = id != null ? id : slug) != null ? _a : "";
|
|
214
|
+
yield Promise.all([
|
|
215
|
+
client.queryClient.prefetchQuery({
|
|
216
|
+
queryKey: collectionKeys("flows").detail(identifier),
|
|
217
|
+
queryFn: () => __async(null, null, function* () {
|
|
218
|
+
if (id) return client.from("flows").findById(id);
|
|
219
|
+
const result = yield client.from("flows").find({
|
|
220
|
+
where: { slug: { equals: slug } },
|
|
221
|
+
limit: 1
|
|
222
|
+
});
|
|
223
|
+
const doc = result.docs[0];
|
|
224
|
+
if (!doc) throw new Error(`Flow not found: ${slug}`);
|
|
225
|
+
return doc;
|
|
226
|
+
})
|
|
227
|
+
}),
|
|
228
|
+
client.queryClient.prefetchQuery({
|
|
229
|
+
queryKey: collectionKeys("flow-node-types").lists(),
|
|
230
|
+
queryFn: () => __async(null, null, function* () {
|
|
231
|
+
const result = yield client.from("flow-node-types").find({ limit: 100 });
|
|
232
|
+
return result.docs;
|
|
233
|
+
})
|
|
234
|
+
}),
|
|
235
|
+
client.queryClient.prefetchQuery({
|
|
236
|
+
queryKey: collectionKeys("flow-edge-types").lists(),
|
|
237
|
+
queryFn: () => __async(null, null, function* () {
|
|
238
|
+
const result = yield client.from("flow-edge-types").find({ limit: 100 });
|
|
239
|
+
return result.docs;
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
]);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
208
246
|
// src/ui/Flow/useFlowData.ts
|
|
209
247
|
import { useMemo as useMemo2 } from "react";
|
|
210
248
|
function useFlowData(options) {
|
|
@@ -1065,6 +1103,7 @@ export {
|
|
|
1065
1103
|
getNodeBounds,
|
|
1066
1104
|
isDynamicNode,
|
|
1067
1105
|
isFrameNode,
|
|
1106
|
+
prefetchFlow,
|
|
1068
1107
|
useFlow,
|
|
1069
1108
|
useFlowData
|
|
1070
1109
|
};
|