@01.software/sdk 0.6.0 → 0.7.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/README.md +2 -2
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/{const-DQZQAXex.d.cts → const-B8iE-mDN.d.cts} +2 -2
- package/dist/{const-Bk3-zigV.d.ts → const-Chw71pKS.d.ts} +2 -2
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DCVm1syH.d.cts → payload-types-Cp10MoF6.d.cts} +53 -48
- package/dist/{payload-types-DCVm1syH.d.ts → payload-types-Cp10MoF6.d.ts} +53 -48
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/{server-StNHlSjW.d.cts → server-DxhuG-_s.d.cts} +34 -34
- package/dist/{server-StNHlSjW.d.ts → server-DxhuG-_s.d.ts} +34 -34
- package/dist/ui/{flow → canvas}/server.cjs +20 -20
- package/dist/ui/canvas/server.cjs.map +1 -0
- package/dist/ui/canvas/server.d.cts +3 -0
- package/dist/ui/canvas/server.d.ts +3 -0
- package/dist/ui/{flow → canvas}/server.js +19 -19
- package/dist/ui/canvas/server.js.map +1 -0
- package/dist/ui/{flow.cjs → canvas.cjs} +63 -63
- package/dist/ui/canvas.cjs.map +1 -0
- package/dist/ui/{flow.d.cts → canvas.d.cts} +35 -35
- package/dist/ui/{flow.d.ts → canvas.d.ts} +35 -35
- package/dist/ui/{flow.js → canvas.js} +59 -59
- package/dist/ui/canvas.js.map +1 -0
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/{webhook-BTtG_8f2.d.ts → webhook-BKhMTlFN.d.ts} +2 -2
- package/dist/{webhook-TDfT7aKA.d.cts → webhook-CiWsseVz.d.cts} +2 -2
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +13 -13
- package/dist/ui/flow/server.cjs.map +0 -1
- package/dist/ui/flow/server.d.cts +0 -3
- package/dist/ui/flow/server.d.ts +0 -3
- package/dist/ui/flow/server.js.map +0 -1
- package/dist/ui/flow.cjs.map +0 -1
- package/dist/ui/flow.js.map +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { C as CanvasData, N as NodeTypeDef, E as EdgeTypeDef,
|
|
2
|
-
export { o as BUILT_IN_EDGE_TYPES, B as BUILT_IN_NODE_TYPES,
|
|
1
|
+
import { C as CanvasData, N as NodeTypeDef, E as EdgeTypeDef, a as CanvasNode, b as NodeTypeFieldDef, D as DynamicNodeSlotProps, c as CanvasEdge, F as FrameNodeSlotProps, d as EdgeSlotProps, e as NodeWrapperSlotProps, f as CanvasViewport, g as CanvasBounds, S as SDKClient, h as FrameData } from '../server-DxhuG-_s.js';
|
|
2
|
+
export { o as BUILT_IN_EDGE_TYPES, B as BUILT_IN_NODE_TYPES, j as CanvasNodeData, i as CanvasNodePosition, k as DynamicNodeData, l as FrameNodeData, P as PrefetchCanvasOptions, U as UseCanvasOptions, p as UseCanvasResult, t as getFrameData, s as getFrames, r as getNodeBounds, m as isDynamicNode, n as isFrameNode, q as prefetchCanvas, u as useCanvas } from '../server-DxhuG-_s.js';
|
|
3
3
|
import { Edge } from '@xyflow/react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { I as ImageData } from '../image-TT8lTsk5.js';
|
|
6
6
|
import '@tanstack/react-query';
|
|
7
7
|
|
|
8
|
-
interface
|
|
9
|
-
/** Canvas data from
|
|
8
|
+
interface UseCanvasDataOptions {
|
|
9
|
+
/** Canvas data from Canvas document's `canvas` field */
|
|
10
10
|
data: CanvasData | undefined;
|
|
11
11
|
/** Node type definitions (defaults to built-in types) */
|
|
12
12
|
nodeTypeDefs?: NodeTypeDef[];
|
|
13
13
|
/** Edge type definitions (defaults to built-in types) */
|
|
14
14
|
edgeTypeDefs?: EdgeTypeDef[];
|
|
15
15
|
}
|
|
16
|
-
interface
|
|
16
|
+
interface UseCanvasDataResult {
|
|
17
17
|
/** Nodes from canvas data */
|
|
18
|
-
nodes:
|
|
18
|
+
nodes: CanvasNode[];
|
|
19
19
|
/** Edges from canvas data (typed for @xyflow/react) */
|
|
20
20
|
edges: Edge[];
|
|
21
21
|
/** Map of node type slug to definition */
|
|
@@ -28,7 +28,7 @@ interface UseFlowDataResult {
|
|
|
28
28
|
* maps from canvas data without any rendering. Useful for headless usage
|
|
29
29
|
* (custom layouts, analytics, server-side processing).
|
|
30
30
|
*/
|
|
31
|
-
declare function
|
|
31
|
+
declare function useCanvasData(options: UseCanvasDataOptions): UseCanvasDataResult;
|
|
32
32
|
|
|
33
33
|
interface CodeComponentProps {
|
|
34
34
|
fields: Record<string, unknown>;
|
|
@@ -67,7 +67,7 @@ declare function getBooleanField(fields: Record<string, unknown>, name: string):
|
|
|
67
67
|
declare function sanitizeCSS(css: string, scopeClass?: string): string;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* Renders a
|
|
70
|
+
* Renders a Canvas in read-only mode.
|
|
71
71
|
*
|
|
72
72
|
* Requires `@xyflow/react` peer dependency and its CSS:
|
|
73
73
|
* ```ts
|
|
@@ -78,8 +78,8 @@ declare function sanitizeCSS(css: string, scopeClass?: string): string;
|
|
|
78
78
|
* and `edgeRenderers` must be stable (defined outside render or wrapped with `useCallback`/`useMemo`).
|
|
79
79
|
* Unstable references recreate `nodeTypes`/`edgeTypes` every render, causing React Flow to remount all nodes.
|
|
80
80
|
*/
|
|
81
|
-
interface
|
|
82
|
-
/** Canvas data from
|
|
81
|
+
interface CanvasRendererProps {
|
|
82
|
+
/** Canvas data from Canvas document's `canvas` field */
|
|
83
83
|
data: CanvasData;
|
|
84
84
|
/** Container className */
|
|
85
85
|
className?: string;
|
|
@@ -98,17 +98,17 @@ interface FlowRendererProps {
|
|
|
98
98
|
/** Fit view on mount (default: true) */
|
|
99
99
|
fitView?: boolean;
|
|
100
100
|
/** Called when a node is clicked */
|
|
101
|
-
onNodeClick?: (event: React.MouseEvent, node:
|
|
101
|
+
onNodeClick?: (event: React.MouseEvent, node: CanvasNode) => void;
|
|
102
102
|
/** Called when a node is double-clicked */
|
|
103
|
-
onNodeDoubleClick?: (event: React.MouseEvent, node:
|
|
103
|
+
onNodeDoubleClick?: (event: React.MouseEvent, node: CanvasNode) => void;
|
|
104
104
|
/** Called on node right-click / context menu */
|
|
105
|
-
onNodeContextMenu?: (event: React.MouseEvent, node:
|
|
105
|
+
onNodeContextMenu?: (event: React.MouseEvent, node: CanvasNode) => void;
|
|
106
106
|
/** Called when mouse enters a node */
|
|
107
|
-
onNodeMouseEnter?: (event: React.MouseEvent, node:
|
|
107
|
+
onNodeMouseEnter?: (event: React.MouseEvent, node: CanvasNode) => void;
|
|
108
108
|
/** Called when mouse leaves a node */
|
|
109
|
-
onNodeMouseLeave?: (event: React.MouseEvent, node:
|
|
109
|
+
onNodeMouseLeave?: (event: React.MouseEvent, node: CanvasNode) => void;
|
|
110
110
|
/** Called when an edge is clicked */
|
|
111
|
-
onEdgeClick?: (event: React.MouseEvent, edge:
|
|
111
|
+
onEdgeClick?: (event: React.MouseEvent, edge: CanvasEdge) => void;
|
|
112
112
|
/** S1: Custom frame node renderer */
|
|
113
113
|
frameRenderer?: React.ComponentType<FrameNodeSlotProps>;
|
|
114
114
|
/** Hide frame nodes. Shorthand for `frameRenderer={() => null}`. Default: false */
|
|
@@ -122,19 +122,19 @@ interface FlowRendererProps {
|
|
|
122
122
|
/** S4: Show minimap (default: false) */
|
|
123
123
|
minimap?: boolean;
|
|
124
124
|
/** S4: Custom minimap node color function */
|
|
125
|
-
minimapNodeColor?: (node:
|
|
125
|
+
minimapNodeColor?: (node: CanvasNode) => string;
|
|
126
126
|
/** S4: Additional children rendered inside ReactFlow */
|
|
127
127
|
children?: React.ReactNode;
|
|
128
128
|
/** S5: Global override for all dynamic nodes. `content` is the resolved rendering (custom renderer output or default). `props.defaultRender` contains the original template/field-based rendering. */
|
|
129
129
|
renderNode?: (props: DynamicNodeSlotProps, content: React.ReactElement) => React.ReactElement | null;
|
|
130
130
|
/** S6: Called when viewport changes (pan/zoom) */
|
|
131
|
-
onViewportChange?: (viewport:
|
|
131
|
+
onViewportChange?: (viewport: CanvasViewport) => void;
|
|
132
132
|
/** S6: Default viewport (used when fitView is false) */
|
|
133
|
-
defaultViewport?:
|
|
133
|
+
defaultViewport?: CanvasViewport;
|
|
134
134
|
/** S8: Focus on specific bounds (used for initial viewport fit). */
|
|
135
|
-
bounds?:
|
|
135
|
+
bounds?: CanvasBounds;
|
|
136
136
|
/** S8: Separate bounds for panning/zoom restriction. When set, overrides bounds-based translateExtent. Useful when fitBounds (content) differs from clampBounds (frame area). */
|
|
137
|
-
clampBounds?:
|
|
137
|
+
clampBounds?: CanvasBounds;
|
|
138
138
|
/** S8: Padding for focus bounds (default: 0.1) */
|
|
139
139
|
focusPadding?: number;
|
|
140
140
|
/** S8: Animate focus transition (true=300ms, number=custom ms, false=instant) */
|
|
@@ -150,14 +150,14 @@ interface FlowRendererProps {
|
|
|
150
150
|
/** Maximum zoom level */
|
|
151
151
|
maxZoom?: number;
|
|
152
152
|
}
|
|
153
|
-
declare function
|
|
153
|
+
declare function CanvasRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseLeave, onEdgeClick, frameRenderer, hideFrames, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, clampBounds, focusPadding, focusAnimation, focusMode, responsiveFit, translateExtent: translateExtentProp, minZoom: minZoomProp, maxZoom: maxZoomProp, }: CanvasRendererProps): React.JSX.Element | null;
|
|
154
154
|
|
|
155
|
-
interface
|
|
155
|
+
interface CanvasFrameProps extends Omit<CanvasRendererProps, 'data' | 'nodeTypeDefs' | 'edgeTypeDefs' | 'bounds' | 'clampBounds' | 'fitView' | 'hideFrames' | 'translateExtent' | 'defaultViewport'> {
|
|
156
156
|
/** SDK client instance (Client or ServerClient) */
|
|
157
157
|
client: SDKClient;
|
|
158
|
-
/**
|
|
158
|
+
/** Canvas slug (URL-friendly identifier) */
|
|
159
159
|
slug?: string;
|
|
160
|
-
/**
|
|
160
|
+
/** Canvas document ID (UUID) */
|
|
161
161
|
id?: string;
|
|
162
162
|
/** Frame node ID to render */
|
|
163
163
|
frameId: string;
|
|
@@ -167,31 +167,31 @@ interface FlowFrameProps extends Omit<FlowRendererProps, 'data' | 'nodeTypeDefs'
|
|
|
167
167
|
error?: (err: Error) => React.ReactNode;
|
|
168
168
|
/**
|
|
169
169
|
* Called when frame data is ready — escape hatch for raw data access.
|
|
170
|
-
* Use `
|
|
170
|
+
* Use `prefetchCanvas({ client, slug })` for SSR.
|
|
171
171
|
*/
|
|
172
|
-
onDataReady?: (frameData: FrameData,
|
|
172
|
+
onDataReady?: (frameData: FrameData, canvas: Record<string, unknown>) => void;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
|
-
* Renders a single frame from a
|
|
175
|
+
* Renders a single frame from a Canvas document.
|
|
176
176
|
*
|
|
177
|
-
* Fetches the
|
|
178
|
-
* and passes the result to `
|
|
177
|
+
* Fetches the canvas via `useCanvas`, extracts the frame with `getFrameData`,
|
|
178
|
+
* and passes the result to `CanvasRenderer` with correct bounds wired.
|
|
179
179
|
*
|
|
180
|
-
* For SSR / prefetching use the existing `
|
|
180
|
+
* For SSR / prefetching use the existing `prefetchCanvas({ client, slug })`.
|
|
181
181
|
*
|
|
182
182
|
* @example
|
|
183
183
|
* ```tsx
|
|
184
|
-
* import {
|
|
184
|
+
* import { CanvasFrame } from '@01.software/sdk/ui/canvas'
|
|
185
185
|
*
|
|
186
186
|
* export default function Home() {
|
|
187
187
|
* return (
|
|
188
188
|
* <div className="w-full h-screen">
|
|
189
|
-
* <
|
|
189
|
+
* <CanvasFrame client={client} slug="home" frameId={FRAME_ID} interactive />
|
|
190
190
|
* </div>
|
|
191
191
|
* )
|
|
192
192
|
* }
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
|
-
declare function
|
|
195
|
+
declare function CanvasFrame({ client, slug, id, frameId, loading, error: renderError, onDataReady, ...rendererProps }: CanvasFrameProps): React.JSX.Element | null;
|
|
196
196
|
|
|
197
|
-
export {
|
|
197
|
+
export { CanvasBounds, CanvasData, CanvasEdge, CanvasFrame, type CanvasFrameProps, CanvasNode, CanvasRenderer, type CanvasRendererProps, CanvasViewport, type CodeComponentProps, DynamicNodeSlotProps, EdgeSlotProps, EdgeTypeDef, FrameData, FrameNodeSlotProps, NodeTypeDef, NodeTypeFieldDef, NodeWrapperSlotProps, SDKClient, type UseCanvasDataOptions, type UseCanvasDataResult, clearTemplateCache, compileTemplate, getBooleanField, getImageField, getNumberField, getTextField, renderFieldValue, sanitizeCSS, useCanvasData };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/ui/
|
|
3
|
+
// src/ui/Canvas/types.ts
|
|
4
4
|
function isDynamicNode(node) {
|
|
5
5
|
return node.type === "dynamic";
|
|
6
6
|
}
|
|
@@ -8,7 +8,7 @@ function isFrameNode(node) {
|
|
|
8
8
|
return node.type === "frame";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// src/ui/
|
|
11
|
+
// src/ui/Canvas/built-in-node-types.ts
|
|
12
12
|
var BUILT_IN_NODE_TYPES = [
|
|
13
13
|
{
|
|
14
14
|
slug: "text",
|
|
@@ -31,7 +31,7 @@ var BUILT_IN_NODE_TYPES = [
|
|
|
31
31
|
}
|
|
32
32
|
];
|
|
33
33
|
|
|
34
|
-
// src/ui/
|
|
34
|
+
// src/ui/Canvas/built-in-edge-types.ts
|
|
35
35
|
var BUILT_IN_EDGE_TYPES = [
|
|
36
36
|
{
|
|
37
37
|
slug: "default",
|
|
@@ -46,7 +46,7 @@ var BUILT_IN_EDGE_TYPES = [
|
|
|
46
46
|
}
|
|
47
47
|
];
|
|
48
48
|
|
|
49
|
-
// src/ui/
|
|
49
|
+
// src/ui/Canvas/useCanvas.ts
|
|
50
50
|
import { useQuery } from "@tanstack/react-query";
|
|
51
51
|
import { useMemo } from "react";
|
|
52
52
|
|
|
@@ -63,43 +63,43 @@ function collectionKeys(collection) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
// src/ui/
|
|
67
|
-
function
|
|
66
|
+
// src/ui/Canvas/query-options.ts
|
|
67
|
+
function canvasQueryOptions(client, slug, id) {
|
|
68
68
|
const identifier = id ?? slug ?? "";
|
|
69
69
|
return {
|
|
70
|
-
queryKey: collectionKeys("
|
|
70
|
+
queryKey: collectionKeys("canvases").detail(identifier),
|
|
71
71
|
queryFn: async () => {
|
|
72
|
-
if (id) return client.from("
|
|
73
|
-
const result = await client.from("
|
|
72
|
+
if (id) return client.from("canvases").findById(id);
|
|
73
|
+
const result = await client.from("canvases").find({
|
|
74
74
|
where: { slug: { equals: slug } },
|
|
75
75
|
limit: 1
|
|
76
76
|
});
|
|
77
77
|
const doc = result.docs[0];
|
|
78
|
-
if (!doc) throw new Error(`
|
|
78
|
+
if (!doc) throw new Error(`Canvas not found: ${slug}`);
|
|
79
79
|
return doc;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
function nodeTypesQueryOptions(client) {
|
|
84
84
|
return {
|
|
85
|
-
queryKey: collectionKeys("
|
|
85
|
+
queryKey: collectionKeys("canvas-node-types").lists(),
|
|
86
86
|
queryFn: async () => {
|
|
87
|
-
const result = await client.from("
|
|
87
|
+
const result = await client.from("canvas-node-types").find({ limit: 0 });
|
|
88
88
|
return result.docs;
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
function edgeTypesQueryOptions(client) {
|
|
93
93
|
return {
|
|
94
|
-
queryKey: collectionKeys("
|
|
94
|
+
queryKey: collectionKeys("canvas-edge-types").lists(),
|
|
95
95
|
queryFn: async () => {
|
|
96
|
-
const result = await client.from("
|
|
96
|
+
const result = await client.from("canvas-edge-types").find({ limit: 0 });
|
|
97
97
|
return result.docs;
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// src/ui/
|
|
102
|
+
// src/ui/Canvas/useCanvas.ts
|
|
103
103
|
function toNodeTypeDef(doc) {
|
|
104
104
|
return {
|
|
105
105
|
slug: String(doc.slug ?? ""),
|
|
@@ -128,12 +128,12 @@ function toEdgeTypeDef(doc) {
|
|
|
128
128
|
fields: Array.isArray(doc.fields) ? doc.fields : []
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function useCanvas(options) {
|
|
132
132
|
const { client, slug, id, enabled = true } = options;
|
|
133
133
|
const hasIdentifier = !!(slug || id);
|
|
134
|
-
const
|
|
134
|
+
const canvasQuery = useQuery(
|
|
135
135
|
{
|
|
136
|
-
...
|
|
136
|
+
...canvasQueryOptions(client, slug, id),
|
|
137
137
|
enabled: enabled && hasIdentifier
|
|
138
138
|
},
|
|
139
139
|
client.queryClient
|
|
@@ -164,34 +164,34 @@ function useFlow(options) {
|
|
|
164
164
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
165
165
|
return [...BUILT_IN_EDGE_TYPES, ...customDefs];
|
|
166
166
|
}, [edgeTypesQuery.data]);
|
|
167
|
-
const
|
|
168
|
-
const
|
|
167
|
+
const canvasDoc = canvasQuery.data;
|
|
168
|
+
const canvasData = canvasDoc?.canvas;
|
|
169
169
|
return {
|
|
170
|
-
data:
|
|
170
|
+
data: canvasData,
|
|
171
171
|
nodeTypeDefs,
|
|
172
172
|
edgeTypeDefs,
|
|
173
|
-
|
|
174
|
-
isLoading:
|
|
175
|
-
error:
|
|
173
|
+
canvas: canvasDoc,
|
|
174
|
+
isLoading: canvasQuery.isLoading || nodeTypesQuery.isLoading || edgeTypesQuery.isLoading,
|
|
175
|
+
error: canvasQuery.error ?? nodeTypesQuery.error ?? edgeTypesQuery.error
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
// src/ui/
|
|
180
|
-
async function
|
|
179
|
+
// src/ui/Canvas/prefetchCanvas.ts
|
|
180
|
+
async function prefetchCanvas(options) {
|
|
181
181
|
const { client, slug, id } = options;
|
|
182
182
|
if (!slug && !id) {
|
|
183
|
-
throw new Error("
|
|
183
|
+
throw new Error("prefetchCanvas requires either slug or id");
|
|
184
184
|
}
|
|
185
185
|
await Promise.all([
|
|
186
|
-
client.queryClient.prefetchQuery(
|
|
186
|
+
client.queryClient.prefetchQuery(canvasQueryOptions(client, slug, id)),
|
|
187
187
|
client.queryClient.prefetchQuery(nodeTypesQueryOptions(client)),
|
|
188
188
|
client.queryClient.prefetchQuery(edgeTypesQueryOptions(client))
|
|
189
189
|
]);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
// src/ui/
|
|
192
|
+
// src/ui/Canvas/useCanvasData.ts
|
|
193
193
|
import { useMemo as useMemo2 } from "react";
|
|
194
|
-
function
|
|
194
|
+
function useCanvasData(options) {
|
|
195
195
|
const { data, nodeTypeDefs: inputNodeDefs, edgeTypeDefs: inputEdgeDefs } = options;
|
|
196
196
|
const nodeTypeDefsMap = useMemo2(() => {
|
|
197
197
|
const allDefs = inputNodeDefs ?? BUILT_IN_NODE_TYPES;
|
|
@@ -211,7 +211,7 @@ function useFlowData(options) {
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
// src/ui/
|
|
214
|
+
// src/ui/Canvas/utils.ts
|
|
215
215
|
function getNodeSize(node) {
|
|
216
216
|
return {
|
|
217
217
|
width: node.style?.width ?? node.measured?.width ?? node.width ?? 200,
|
|
@@ -328,11 +328,11 @@ function getFrameData(data, frameId) {
|
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
// src/ui/
|
|
331
|
+
// src/ui/Canvas/template-compiler.ts
|
|
332
332
|
import React from "react";
|
|
333
333
|
import { transform } from "sucrase";
|
|
334
334
|
|
|
335
|
-
// src/ui/
|
|
335
|
+
// src/ui/Canvas/quickjs-loader.ts
|
|
336
336
|
import { useSyncExternalStore } from "react";
|
|
337
337
|
var _state = { status: "idle", module: null };
|
|
338
338
|
var _listeners = /* @__PURE__ */ new Set();
|
|
@@ -363,7 +363,7 @@ function useQuickJS() {
|
|
|
363
363
|
return useSyncExternalStore(subscribeQuickJS, getQuickJSSnapshot, () => null);
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
// src/ui/
|
|
366
|
+
// src/ui/Canvas/template-compiler.ts
|
|
367
367
|
var MAX_CACHE_SIZE = 100;
|
|
368
368
|
var MAX_MATERIALIZE_DEPTH = 20;
|
|
369
369
|
var IFRAME_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
@@ -641,7 +641,7 @@ function clearTemplateCache() {
|
|
|
641
641
|
rendererCache.clear();
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
-
// src/ui/
|
|
644
|
+
// src/ui/Canvas/node-renderers.tsx
|
|
645
645
|
import React2 from "react";
|
|
646
646
|
function sanitizeUrl(url) {
|
|
647
647
|
if (!url) return url;
|
|
@@ -810,7 +810,7 @@ function DefaultFrameNode({ data }) {
|
|
|
810
810
|
);
|
|
811
811
|
}
|
|
812
812
|
|
|
813
|
-
// src/ui/
|
|
813
|
+
// src/ui/Canvas/field-helpers.ts
|
|
814
814
|
function getImageField(fields, name) {
|
|
815
815
|
const val = fields?.[name];
|
|
816
816
|
if (val && typeof val === "object" && val !== null && "url" in val)
|
|
@@ -830,7 +830,7 @@ function getBooleanField(fields, name) {
|
|
|
830
830
|
return typeof val === "boolean" ? val : void 0;
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
-
// src/ui/
|
|
833
|
+
// src/ui/Canvas/css-sanitizer.ts
|
|
834
834
|
import postcss from "postcss";
|
|
835
835
|
var ALLOWED_AT_RULES = /* @__PURE__ */ new Set(["keyframes", "media", "supports", "container", "layer"]);
|
|
836
836
|
var BLOCKED_VALUE_PATTERNS = [/url\s*\(/i, /expression\s*\(/i, /paint\s*\(/i, /-moz-binding/i];
|
|
@@ -929,7 +929,7 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
929
929
|
return root.toString().replace(/<\/style/gi, "<\\/style");
|
|
930
930
|
}
|
|
931
931
|
|
|
932
|
-
// src/ui/
|
|
932
|
+
// src/ui/Canvas/CanvasRenderer.tsx
|
|
933
933
|
import React6 from "react";
|
|
934
934
|
import {
|
|
935
935
|
ReactFlow,
|
|
@@ -939,7 +939,7 @@ import {
|
|
|
939
939
|
MiniMap
|
|
940
940
|
} from "@xyflow/react";
|
|
941
941
|
|
|
942
|
-
// src/ui/
|
|
942
|
+
// src/ui/Canvas/node-types-factory.tsx
|
|
943
943
|
import React4 from "react";
|
|
944
944
|
|
|
945
945
|
// src/ui/Image/index.tsx
|
|
@@ -1103,7 +1103,7 @@ function Image({
|
|
|
1103
1103
|
));
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
|
-
// src/ui/
|
|
1106
|
+
// src/ui/Canvas/node-types-factory.tsx
|
|
1107
1107
|
function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode) {
|
|
1108
1108
|
const types = {};
|
|
1109
1109
|
types.dynamic = ((props) => {
|
|
@@ -1216,7 +1216,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1216
1216
|
return types;
|
|
1217
1217
|
}
|
|
1218
1218
|
|
|
1219
|
-
// src/ui/
|
|
1219
|
+
// src/ui/Canvas/edge-styles.ts
|
|
1220
1220
|
import { MarkerType } from "@xyflow/react";
|
|
1221
1221
|
function toMarkerType(value) {
|
|
1222
1222
|
if (value === "arrow") return MarkerType.Arrow;
|
|
@@ -1268,7 +1268,7 @@ function applyEdgeStyles(edges, edgeTypeDefsMap) {
|
|
|
1268
1268
|
});
|
|
1269
1269
|
}
|
|
1270
1270
|
|
|
1271
|
-
// src/ui/
|
|
1271
|
+
// src/ui/Canvas/focus-handler.tsx
|
|
1272
1272
|
import React5 from "react";
|
|
1273
1273
|
import { useReactFlow, useStoreApi } from "@xyflow/react";
|
|
1274
1274
|
function clampViewport(vp, cw, ch, extent) {
|
|
@@ -1398,9 +1398,9 @@ function FocusHandler({
|
|
|
1398
1398
|
);
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
|
-
// src/ui/
|
|
1401
|
+
// src/ui/Canvas/CanvasRenderer.tsx
|
|
1402
1402
|
var NullFrameRenderer = () => null;
|
|
1403
|
-
function
|
|
1403
|
+
function CanvasRenderer({
|
|
1404
1404
|
data,
|
|
1405
1405
|
className,
|
|
1406
1406
|
style,
|
|
@@ -1577,9 +1577,9 @@ function FlowRenderer({
|
|
|
1577
1577
|
));
|
|
1578
1578
|
}
|
|
1579
1579
|
|
|
1580
|
-
// src/ui/
|
|
1580
|
+
// src/ui/Canvas/CanvasFrame.tsx
|
|
1581
1581
|
import React7, { useMemo as useMemo3, useEffect, useRef as useRef2 } from "react";
|
|
1582
|
-
function
|
|
1582
|
+
function CanvasFrame({
|
|
1583
1583
|
client,
|
|
1584
1584
|
slug,
|
|
1585
1585
|
id,
|
|
@@ -1589,7 +1589,7 @@ function FlowFrame({
|
|
|
1589
1589
|
onDataReady,
|
|
1590
1590
|
...rendererProps
|
|
1591
1591
|
}) {
|
|
1592
|
-
const { data, nodeTypeDefs, edgeTypeDefs,
|
|
1592
|
+
const { data, nodeTypeDefs, edgeTypeDefs, canvas, isLoading, error } = useCanvas({
|
|
1593
1593
|
client,
|
|
1594
1594
|
slug,
|
|
1595
1595
|
id
|
|
@@ -1601,12 +1601,12 @@ function FlowFrame({
|
|
|
1601
1601
|
const onDataReadyRef = useRef2(onDataReady);
|
|
1602
1602
|
onDataReadyRef.current = onDataReady;
|
|
1603
1603
|
useEffect(() => {
|
|
1604
|
-
if (frameData &&
|
|
1605
|
-
onDataReadyRef.current?.(frameData,
|
|
1604
|
+
if (frameData && canvas) {
|
|
1605
|
+
onDataReadyRef.current?.(frameData, canvas);
|
|
1606
1606
|
}
|
|
1607
|
-
}, [frameData,
|
|
1607
|
+
}, [frameData, canvas]);
|
|
1608
1608
|
if (process.env.NODE_ENV !== "production" && !slug && !id) {
|
|
1609
|
-
console.warn('[
|
|
1609
|
+
console.warn('[CanvasFrame] Either "slug" or "id" must be provided.');
|
|
1610
1610
|
}
|
|
1611
1611
|
if (isLoading) return /* @__PURE__ */ React7.createElement(React7.Fragment, null, loading);
|
|
1612
1612
|
if (error) return renderError ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, renderError(error)) : null;
|
|
@@ -1614,13 +1614,13 @@ function FlowFrame({
|
|
|
1614
1614
|
if (process.env.NODE_ENV !== "production" && data) {
|
|
1615
1615
|
const frames = data.nodes.filter(isFrameNode).map((n) => n.id);
|
|
1616
1616
|
console.warn(
|
|
1617
|
-
`[
|
|
1617
|
+
`[CanvasFrame] Frame "${frameId}" not found. Available frames: ${frames.join(", ") || "(none)"}`
|
|
1618
1618
|
);
|
|
1619
1619
|
}
|
|
1620
1620
|
return null;
|
|
1621
1621
|
}
|
|
1622
1622
|
return /* @__PURE__ */ React7.createElement(
|
|
1623
|
-
|
|
1623
|
+
CanvasRenderer,
|
|
1624
1624
|
{
|
|
1625
1625
|
...rendererProps,
|
|
1626
1626
|
data: frameData.data,
|
|
@@ -1635,8 +1635,8 @@ function FlowFrame({
|
|
|
1635
1635
|
export {
|
|
1636
1636
|
BUILT_IN_EDGE_TYPES,
|
|
1637
1637
|
BUILT_IN_NODE_TYPES,
|
|
1638
|
-
|
|
1639
|
-
|
|
1638
|
+
CanvasFrame,
|
|
1639
|
+
CanvasRenderer,
|
|
1640
1640
|
clearTemplateCache,
|
|
1641
1641
|
compileTemplate,
|
|
1642
1642
|
getBooleanField,
|
|
@@ -1648,10 +1648,10 @@ export {
|
|
|
1648
1648
|
getTextField,
|
|
1649
1649
|
isDynamicNode,
|
|
1650
1650
|
isFrameNode,
|
|
1651
|
-
|
|
1651
|
+
prefetchCanvas,
|
|
1652
1652
|
renderFieldValue,
|
|
1653
1653
|
sanitizeCSS,
|
|
1654
|
-
|
|
1655
|
-
|
|
1654
|
+
useCanvas,
|
|
1655
|
+
useCanvasData
|
|
1656
1656
|
};
|
|
1657
|
-
//# sourceMappingURL=
|
|
1657
|
+
//# sourceMappingURL=canvas.js.map
|