@01.software/sdk 0.6.0 → 0.7.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.
- 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-6BfmvZug.d.cts} +2 -2
- package/dist/{const-Bk3-zigV.d.ts → const-DQYzabjw.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-CFDtFiSz.d.cts} +47 -47
- package/dist/{payload-types-DCVm1syH.d.ts → payload-types-CFDtFiSz.d.ts} +47 -47
- 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-BB8amLBv.d.ts} +2 -2
- package/dist/{webhook-TDfT7aKA.d.cts → webhook-CrBjPpUT.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/query/query-keys.ts","../../../src/ui/Canvas/query-options.ts","../../../src/ui/Canvas/prefetchCanvas.ts","../../../src/ui/Canvas/utils.ts","../../../src/ui/Canvas/types.ts","../../../src/ui/Canvas/built-in-node-types.ts","../../../src/ui/Canvas/built-in-edge-types.ts"],"sourcesContent":["import type { PublicCollection, ApiQueryOptions } from '../client/types'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n","import { collectionKeys } from '../../core/query/query-keys'\nimport type { SDKClient } from './useCanvas'\n\nexport function canvasQueryOptions(\n client: SDKClient,\n slug?: string,\n id?: string,\n) {\n const identifier = id ?? slug ?? ''\n return {\n queryKey: collectionKeys('canvases').detail(identifier),\n queryFn: async () => {\n if (id) return client.from('canvases').findById(id)\n const result = await client.from('canvases').find({\n where: { slug: { equals: slug } },\n limit: 1,\n })\n const doc = result.docs[0]\n if (!doc) throw new Error(`Canvas not found: ${slug}`)\n return doc\n },\n }\n}\n\nexport function nodeTypesQueryOptions(client: SDKClient) {\n return {\n queryKey: collectionKeys('canvas-node-types').lists(),\n queryFn: async () => {\n // limit: 0 = fetch all documents (Payload CMS convention, disables pagination)\n const result = await client.from('canvas-node-types').find({ limit: 0 })\n return result.docs\n },\n }\n}\n\nexport function edgeTypesQueryOptions(client: SDKClient) {\n return {\n queryKey: collectionKeys('canvas-edge-types').lists(),\n queryFn: async () => {\n const result = await client.from('canvas-edge-types').find({ limit: 0 })\n return result.docs\n },\n }\n}\n","import type { SDKClient } from './useCanvas'\nimport {\n canvasQueryOptions,\n nodeTypesQueryOptions,\n edgeTypesQueryOptions,\n} from './query-options'\n\nexport interface PrefetchCanvasOptions {\n /** SDK client instance (Client or ServerClient) */\n client: SDKClient\n /** Canvas slug (URL-friendly identifier) */\n slug?: string\n /** Canvas document ID (UUID) */\n id?: string\n}\n\n/**\n * Prefetch canvas data into the query cache.\n * Call in route loaders or server components to eliminate loading states on mount.\n *\n * ```ts\n * // React Router loader / Server Component\n * await prefetchCanvas({ client, slug: 'Home' })\n * ```\n */\nexport async function prefetchCanvas(\n options: PrefetchCanvasOptions,\n): Promise<void> {\n const { client, slug, id } = options\n\n if (!slug && !id) {\n throw new Error('prefetchCanvas requires either slug or id')\n }\n\n await Promise.all([\n client.queryClient.prefetchQuery(canvasQueryOptions(client, slug, id)),\n client.queryClient.prefetchQuery(nodeTypesQueryOptions(client)),\n client.queryClient.prefetchQuery(edgeTypesQueryOptions(client)),\n ])\n}\n","import type { CanvasNode, CanvasEdge, CanvasBounds, CanvasData } from './types'\n\n// ── Shared helpers ──\n\nfunction getNodeSize(node: CanvasNode): { width: number; height: number } {\n return {\n width:\n (node.style?.width as number) ??\n node.measured?.width ??\n node.width ??\n 200,\n height:\n (node.style?.height as number) ??\n node.measured?.height ??\n node.height ??\n 200,\n }\n}\n\nfunction getAbsolutePosition(\n node: CanvasNode,\n nodeMap: Map<string, CanvasNode>,\n): { x: number; y: number } {\n let x = node.position.x\n let y = node.position.y\n let current = node\n const visited = new Set<string>([node.id])\n while (current.parentId) {\n const parentId = current.parentId\n if (visited.has(parentId)) break\n const parent = nodeMap.get(parentId)\n if (!parent) break\n visited.add(parent.id)\n x += parent.position.x\n y += parent.position.y\n current = parent\n }\n return { x, y }\n}\n\n/** Collect a node and all its descendants using a pre-built parent→children map (O(N)). */\nfunction collectDescendants(\n nodes: CanvasNode[],\n rootId: string,\n): Set<string> {\n // Build parent → children lookup in O(N)\n const childrenMap = new Map<string, string[]>()\n for (const n of nodes) {\n if (n.parentId) {\n let siblings = childrenMap.get(n.parentId)\n if (!siblings) {\n siblings = []\n childrenMap.set(n.parentId, siblings)\n }\n siblings.push(n.id)\n }\n }\n\n // BFS over children map in O(descendants)\n const result = new Set<string>([rootId])\n const queue = [rootId]\n let i = 0\n while (i < queue.length) {\n const children = childrenMap.get(queue[i++]!)\n if (children) {\n for (const childId of children) {\n if (!result.has(childId)) {\n result.add(childId)\n queue.push(childId)\n }\n }\n }\n }\n return result\n}\n\n// ── Public utilities ──\n\n/**\n * Calculate bounding box for given node IDs.\n * Pure function — usable in SSR, server components, or outside React.\n */\nexport function getNodeBounds(\n nodes: CanvasNode[],\n nodeIds: string[],\n): CanvasBounds | undefined {\n const idSet = new Set(nodeIds)\n const targetNodes = nodes.filter((n) => idSet.has(n.id))\n if (targetNodes.length === 0) return undefined\n\n const nodeMap = new Map(nodes.map((n) => [n.id, n]))\n\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n\n for (const node of targetNodes) {\n const abs = getAbsolutePosition(node, nodeMap)\n const { width: w, height: h } = getNodeSize(node)\n minX = Math.min(minX, abs.x)\n minY = Math.min(minY, abs.y)\n maxX = Math.max(maxX, abs.x + w)\n maxY = Math.max(maxY, abs.y + h)\n }\n\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n\n/**\n * Get all frame nodes with their bounds.\n * Sorted by position (top-left to bottom-right).\n */\nexport function getFrames(\n nodes: CanvasNode[],\n): Array<{ id: string; label: string; bounds: CanvasBounds }> {\n const frames = nodes.filter((n) => n.type === 'frame')\n if (frames.length === 0) return []\n\n const nodeMap = new Map(nodes.map((n) => [n.id, n]))\n\n return frames\n .map((f) => {\n const data = f.data as { label?: string }\n const abs = getAbsolutePosition(f, nodeMap)\n const { width: w, height: h } = getNodeSize(f)\n return {\n id: f.id,\n label: data.label ?? '',\n bounds: { x: abs.x, y: abs.y, width: w, height: h },\n }\n })\n .sort((a, b) => a.bounds.y - b.bounds.y || a.bounds.x - b.bounds.x)\n}\n\n/** Result of getFrameData — contains filtered canvas + dual bounds. */\nexport interface FrameData {\n /** Canvas data containing only the frame's descendants (nodes have draggable: false). */\n data: CanvasData\n /** Bounding box of child content nodes — use for initial viewport fit (centering). */\n fitBounds: CanvasBounds\n /** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */\n clampBounds: CanvasBounds\n /** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */\n bounds: CanvasBounds\n}\n\n/**\n * Extract a frame's descendants and related edges from canvas data.\n * Recursively collects all nested children (supports nested frames).\n * Returns undefined if frameId is not found or is not a frame node.\n *\n * Child nodes are marked `draggable: false` to prevent interfering with canvas panning.\n * The frame node itself is included (use `frameRenderer={() => null}` to hide it).\n *\n * Returns dual bounds:\n * - `fitBounds`: child content bounding box (for centering the viewport)\n * - `clampBounds`: frame area bounding box (for panning restriction)\n */\nexport function getFrameData(\n data: CanvasData,\n frameId: string,\n): FrameData | undefined {\n const frame = data.nodes.find((n) => n.id === frameId)\n if (!frame || frame.type !== 'frame') return undefined\n\n // Recursively collect frame + all descendants\n const descendantIds = collectDescendants(data.nodes, frameId)\n const childNodes = data.nodes\n .filter((n) => descendantIds.has(n.id))\n .map((n) => ({ ...n, draggable: false }))\n\n // Keep only edges where both source and target are within the frame\n const childEdges = data.edges.filter(\n (e: CanvasEdge) => descendantIds.has(e.source) && descendantIds.has(e.target),\n )\n\n // clampBounds: frame's own bounding box (for panning restriction)\n const frameBounds = getNodeBounds(data.nodes, [frameId])\n const { width: w, height: h } = getNodeSize(frame)\n const clampBounds: CanvasBounds = frameBounds ?? {\n x: frame.position.x,\n y: frame.position.y,\n width: w,\n height: h,\n }\n\n // fitBounds: child content bounding box (for centering)\n const contentNodeIds = childNodes\n .filter((n) => n.id !== frameId)\n .map((n) => n.id)\n const contentBounds = contentNodeIds.length > 0\n ? getNodeBounds(data.nodes, contentNodeIds)\n : undefined\n const fitBounds = contentBounds ?? clampBounds\n\n return {\n data: {\n nodes: childNodes,\n edges: childEdges,\n viewport: data.viewport,\n },\n fitBounds,\n clampBounds,\n bounds: clampBounds,\n }\n}\n","import type React from 'react'\n\n// ── Dynamic node data ──\n\nexport interface DynamicNodeData {\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n}\n\nexport type CanvasNodeData = (DynamicNodeData | FrameNodeData) &\n Record<string, unknown>\n\n// ── Canvas types (mirrors @xyflow/react but standalone) ──\n\nexport interface CanvasNodePosition {\n x: number\n y: number\n}\n\nexport interface CanvasNode {\n id: string\n type?: string\n position: CanvasNodePosition\n data: CanvasNodeData\n parentId?: string\n style?: React.CSSProperties\n width?: number\n height?: number\n measured?: { width?: number; height?: number }\n draggable?: boolean\n selectable?: boolean\n [key: string]: unknown\n}\n\nexport interface CanvasEdge {\n id: string\n source: string\n target: string\n sourceHandle?: string | null\n targetHandle?: string | null\n type?: string\n style?: React.CSSProperties\n animated?: boolean\n markerStart?: unknown\n markerEnd?: unknown\n edgeTypeSlug?: string\n fields?: Record<string, unknown>\n [key: string]: unknown\n}\n\nexport interface CanvasViewport {\n x: number\n y: number\n zoom: number\n}\n\nexport interface CanvasData {\n nodes: CanvasNode[]\n edges: CanvasEdge[]\n viewport: CanvasViewport\n}\n\n// ── Node type definitions (mirrors console's NodeTypeDef) ──\n\nexport interface NodeTypeFieldDef {\n name: string\n label: string\n fieldType:\n | 'text'\n | 'textarea'\n | 'number'\n | 'url'\n | 'color'\n | 'image'\n | 'select'\n | 'toggle'\n options?: { label: string; value: string }[]\n defaultValue?: string\n required?: boolean\n}\n\nexport interface NodeTypeDef {\n slug: string\n name: string\n color: string\n defaultSize: { width: number; height: number }\n fields: NodeTypeFieldDef[]\n transparentBackground?: boolean\n template?: string | null\n customCSS?: string | null\n}\n\n// ── Edge type definitions (mirrors console's EdgeTypeDef) ──\n\nexport interface EdgeTypeDef {\n slug: string\n name: string\n color: string\n strokeWidth: number\n animated: boolean\n lineStyle: string\n markerStart: string\n markerEnd: string\n fields: NodeTypeFieldDef[]\n}\n\n// ── Type guards ──\n\nexport function isDynamicNode(\n node: CanvasNode,\n): node is CanvasNode & { data: DynamicNodeData } {\n return node.type === 'dynamic'\n}\n\nexport function isFrameNode(\n node: CanvasNode,\n): node is CanvasNode & { data: FrameNodeData } {\n return node.type === 'frame'\n}\n\n// ── Component slot props ──\n\nexport interface DynamicNodeSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n nodeTypeDef?: NodeTypeDef\n /** Whether this node is currently selected */\n selected?: boolean\n /** Measured node width (undefined before first measurement) */\n width?: number\n /** Measured node height (undefined before first measurement) */\n height?: number\n /** The default rendering (template or field-based). Allows custom renderers to wrap/extend instead of replacing entirely. */\n defaultRender?: React.ReactElement\n}\n\n// ── Frame node data ──\n\nexport interface FrameNodeData {\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n}\n\n// S1: Frame renderer slot\nexport interface FrameNodeSlotProps {\n id: string\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n width?: number\n height?: number\n children?: React.ReactNode\n}\n\n// S2: Edge renderer slot\nexport interface EdgeSlotProps {\n id: string\n edgeTypeSlug?: string\n source: string\n target: string\n label?: string\n fields?: Record<string, unknown>\n edgeTypeDef?: EdgeTypeDef\n style?: React.CSSProperties\n}\n\n// S3: Node wrapper slot\nexport interface NodeWrapperSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n selected?: boolean\n nodeTypeDef?: NodeTypeDef\n children: React.ReactNode\n}\n\n// S8: Viewport focus\nexport interface CanvasBounds {\n x: number\n y: number\n width: number\n height: number\n}\n","import type { NodeTypeDef } from './types'\n\nexport const BUILT_IN_NODE_TYPES: NodeTypeDef[] = [\n {\n slug: 'text',\n name: 'Text',\n color: '#e5e7eb',\n defaultSize: { width: 200, height: 200 },\n fields: [{ name: 'body', label: 'Body', fieldType: 'textarea' }],\n },\n {\n slug: 'image',\n name: 'Image',\n color: '#e5e7eb',\n transparentBackground: true,\n defaultSize: { width: 200, height: 200 },\n fields: [\n { name: 'image', label: 'Image', fieldType: 'image' },\n { name: 'alt', label: 'Alt Text', fieldType: 'text' },\n { name: 'caption', label: 'Caption', fieldType: 'text' },\n ],\n },\n]\n","import type { EdgeTypeDef } from './types'\n\nexport const BUILT_IN_EDGE_TYPES: EdgeTypeDef[] = [\n {\n slug: 'default',\n name: 'Default',\n color: '',\n strokeWidth: 2,\n animated: false,\n lineStyle: 'default',\n markerStart: 'none',\n markerEnd: 'arrow',\n fields: [],\n },\n]\n"],"mappings":";AAEO,SAAS,eAA2C,YAAe;AACxE,SAAO;AAAA,IACL,KAAK,CAAC,UAAU;AAAA,IAChB,OAAO,MAAM,CAAC,YAAY,MAAM;AAAA,IAChC,MAAM,CAAC,YAA8B,CAAC,YAAY,QAAQ,OAAO;AAAA,IACjE,SAAS,MAAM,CAAC,YAAY,QAAQ;AAAA,IACpC,QAAQ,CAAC,IAAY,YACnB,CAAC,YAAY,UAAU,IAAI,OAAO;AAAA,IACpC,WAAW,MAAM,CAAC,YAAY,UAAU;AAAA,IACxC,UAAU,CAAC,YACT,CAAC,YAAY,YAAY,OAAO;AAAA,EACpC;AACF;;;ACXO,SAAS,mBACd,QACA,MACA,IACA;AACA,QAAM,aAAa,MAAM,QAAQ;AACjC,SAAO;AAAA,IACL,UAAU,eAAe,UAAU,EAAE,OAAO,UAAU;AAAA,IACtD,SAAS,YAAY;AACnB,UAAI,GAAI,Q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F;;;ACjGO,SAAS,cACd,MACgD;AAChD,SAAO,KAAK,SAAS;AACvB;AAEO,SAAS,YACd,MAC8C;AAC9C,SAAO,KAAK,SAAS;AACvB;;;ACrHO,IAAM,sBAAqC;AAAA,EAChD;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,IACvC,QAAQ,CAAC,EAAE,MAAM,QAAQ,OAAO,QAAQ,WAAW,WAAW,CAAC;AAAA,EACjE;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,uBAAuB;AAAA,IACvB,aAAa,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,IACvC,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,OAAO,SAAS,WAAW,QAAQ;AAAA,MACpD,EAAE,MAAM,OAAO,OAAO,YAAY,WAAW,OAAO;AAAA,MACpD,EAAE,MAAM,WAAW,OAAO,WAAW,WAAW,OAAO;AAAA,IACzD;AAAA,EACF;AACF;;;ACpBO,IAAM,sBAAqC;AAAA,EAChD;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,IACV,WAAW;AAAA,IACX,aAAa;AAAA,IACb,WAAW;AAAA,IACX,QAAQ,CAAC;AAAA,EACX;AACF;","names":[]}
|
|
@@ -28,13 +28,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
));
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
|
|
31
|
-
// src/ui/
|
|
32
|
-
var
|
|
33
|
-
__export(
|
|
31
|
+
// src/ui/Canvas/index.tsx
|
|
32
|
+
var Canvas_exports = {};
|
|
33
|
+
__export(Canvas_exports, {
|
|
34
34
|
BUILT_IN_EDGE_TYPES: () => BUILT_IN_EDGE_TYPES,
|
|
35
35
|
BUILT_IN_NODE_TYPES: () => BUILT_IN_NODE_TYPES,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
CanvasFrame: () => CanvasFrame,
|
|
37
|
+
CanvasRenderer: () => CanvasRenderer,
|
|
38
38
|
clearTemplateCache: () => clearTemplateCache,
|
|
39
39
|
compileTemplate: () => compileTemplate,
|
|
40
40
|
getBooleanField: () => getBooleanField,
|
|
@@ -46,15 +46,15 @@ __export(Flow_exports, {
|
|
|
46
46
|
getTextField: () => getTextField,
|
|
47
47
|
isDynamicNode: () => isDynamicNode,
|
|
48
48
|
isFrameNode: () => isFrameNode,
|
|
49
|
-
|
|
49
|
+
prefetchCanvas: () => prefetchCanvas,
|
|
50
50
|
renderFieldValue: () => renderFieldValue,
|
|
51
51
|
sanitizeCSS: () => sanitizeCSS,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
useCanvas: () => useCanvas,
|
|
53
|
+
useCanvasData: () => useCanvasData
|
|
54
54
|
});
|
|
55
|
-
module.exports = __toCommonJS(
|
|
55
|
+
module.exports = __toCommonJS(Canvas_exports);
|
|
56
56
|
|
|
57
|
-
// src/ui/
|
|
57
|
+
// src/ui/Canvas/types.ts
|
|
58
58
|
function isDynamicNode(node) {
|
|
59
59
|
return node.type === "dynamic";
|
|
60
60
|
}
|
|
@@ -62,7 +62,7 @@ function isFrameNode(node) {
|
|
|
62
62
|
return node.type === "frame";
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
// src/ui/
|
|
65
|
+
// src/ui/Canvas/built-in-node-types.ts
|
|
66
66
|
var BUILT_IN_NODE_TYPES = [
|
|
67
67
|
{
|
|
68
68
|
slug: "text",
|
|
@@ -85,7 +85,7 @@ var BUILT_IN_NODE_TYPES = [
|
|
|
85
85
|
}
|
|
86
86
|
];
|
|
87
87
|
|
|
88
|
-
// src/ui/
|
|
88
|
+
// src/ui/Canvas/built-in-edge-types.ts
|
|
89
89
|
var BUILT_IN_EDGE_TYPES = [
|
|
90
90
|
{
|
|
91
91
|
slug: "default",
|
|
@@ -100,7 +100,7 @@ var BUILT_IN_EDGE_TYPES = [
|
|
|
100
100
|
}
|
|
101
101
|
];
|
|
102
102
|
|
|
103
|
-
// src/ui/
|
|
103
|
+
// src/ui/Canvas/useCanvas.ts
|
|
104
104
|
var import_react_query = require("@tanstack/react-query");
|
|
105
105
|
var import_react = require("react");
|
|
106
106
|
|
|
@@ -117,43 +117,43 @@ function collectionKeys(collection) {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// src/ui/
|
|
121
|
-
function
|
|
120
|
+
// src/ui/Canvas/query-options.ts
|
|
121
|
+
function canvasQueryOptions(client, slug, id) {
|
|
122
122
|
const identifier = id ?? slug ?? "";
|
|
123
123
|
return {
|
|
124
|
-
queryKey: collectionKeys("
|
|
124
|
+
queryKey: collectionKeys("canvases").detail(identifier),
|
|
125
125
|
queryFn: async () => {
|
|
126
|
-
if (id) return client.from("
|
|
127
|
-
const result = await client.from("
|
|
126
|
+
if (id) return client.from("canvases").findById(id);
|
|
127
|
+
const result = await client.from("canvases").find({
|
|
128
128
|
where: { slug: { equals: slug } },
|
|
129
129
|
limit: 1
|
|
130
130
|
});
|
|
131
131
|
const doc = result.docs[0];
|
|
132
|
-
if (!doc) throw new Error(`
|
|
132
|
+
if (!doc) throw new Error(`Canvas not found: ${slug}`);
|
|
133
133
|
return doc;
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
function nodeTypesQueryOptions(client) {
|
|
138
138
|
return {
|
|
139
|
-
queryKey: collectionKeys("
|
|
139
|
+
queryKey: collectionKeys("canvas-node-types").lists(),
|
|
140
140
|
queryFn: async () => {
|
|
141
|
-
const result = await client.from("
|
|
141
|
+
const result = await client.from("canvas-node-types").find({ limit: 0 });
|
|
142
142
|
return result.docs;
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
function edgeTypesQueryOptions(client) {
|
|
147
147
|
return {
|
|
148
|
-
queryKey: collectionKeys("
|
|
148
|
+
queryKey: collectionKeys("canvas-edge-types").lists(),
|
|
149
149
|
queryFn: async () => {
|
|
150
|
-
const result = await client.from("
|
|
150
|
+
const result = await client.from("canvas-edge-types").find({ limit: 0 });
|
|
151
151
|
return result.docs;
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
// src/ui/
|
|
156
|
+
// src/ui/Canvas/useCanvas.ts
|
|
157
157
|
function toNodeTypeDef(doc) {
|
|
158
158
|
return {
|
|
159
159
|
slug: String(doc.slug ?? ""),
|
|
@@ -182,12 +182,12 @@ function toEdgeTypeDef(doc) {
|
|
|
182
182
|
fields: Array.isArray(doc.fields) ? doc.fields : []
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function useCanvas(options) {
|
|
186
186
|
const { client, slug, id, enabled = true } = options;
|
|
187
187
|
const hasIdentifier = !!(slug || id);
|
|
188
|
-
const
|
|
188
|
+
const canvasQuery = (0, import_react_query.useQuery)(
|
|
189
189
|
{
|
|
190
|
-
...
|
|
190
|
+
...canvasQueryOptions(client, slug, id),
|
|
191
191
|
enabled: enabled && hasIdentifier
|
|
192
192
|
},
|
|
193
193
|
client.queryClient
|
|
@@ -218,34 +218,34 @@ function useFlow(options) {
|
|
|
218
218
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
219
219
|
return [...BUILT_IN_EDGE_TYPES, ...customDefs];
|
|
220
220
|
}, [edgeTypesQuery.data]);
|
|
221
|
-
const
|
|
222
|
-
const
|
|
221
|
+
const canvasDoc = canvasQuery.data;
|
|
222
|
+
const canvasData = canvasDoc?.canvas;
|
|
223
223
|
return {
|
|
224
|
-
data:
|
|
224
|
+
data: canvasData,
|
|
225
225
|
nodeTypeDefs,
|
|
226
226
|
edgeTypeDefs,
|
|
227
|
-
|
|
228
|
-
isLoading:
|
|
229
|
-
error:
|
|
227
|
+
canvas: canvasDoc,
|
|
228
|
+
isLoading: canvasQuery.isLoading || nodeTypesQuery.isLoading || edgeTypesQuery.isLoading,
|
|
229
|
+
error: canvasQuery.error ?? nodeTypesQuery.error ?? edgeTypesQuery.error
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
// src/ui/
|
|
234
|
-
async function
|
|
233
|
+
// src/ui/Canvas/prefetchCanvas.ts
|
|
234
|
+
async function prefetchCanvas(options) {
|
|
235
235
|
const { client, slug, id } = options;
|
|
236
236
|
if (!slug && !id) {
|
|
237
|
-
throw new Error("
|
|
237
|
+
throw new Error("prefetchCanvas requires either slug or id");
|
|
238
238
|
}
|
|
239
239
|
await Promise.all([
|
|
240
|
-
client.queryClient.prefetchQuery(
|
|
240
|
+
client.queryClient.prefetchQuery(canvasQueryOptions(client, slug, id)),
|
|
241
241
|
client.queryClient.prefetchQuery(nodeTypesQueryOptions(client)),
|
|
242
242
|
client.queryClient.prefetchQuery(edgeTypesQueryOptions(client))
|
|
243
243
|
]);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
// src/ui/
|
|
246
|
+
// src/ui/Canvas/useCanvasData.ts
|
|
247
247
|
var import_react2 = require("react");
|
|
248
|
-
function
|
|
248
|
+
function useCanvasData(options) {
|
|
249
249
|
const { data, nodeTypeDefs: inputNodeDefs, edgeTypeDefs: inputEdgeDefs } = options;
|
|
250
250
|
const nodeTypeDefsMap = (0, import_react2.useMemo)(() => {
|
|
251
251
|
const allDefs = inputNodeDefs ?? BUILT_IN_NODE_TYPES;
|
|
@@ -265,7 +265,7 @@ function useFlowData(options) {
|
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
// src/ui/
|
|
268
|
+
// src/ui/Canvas/utils.ts
|
|
269
269
|
function getNodeSize(node) {
|
|
270
270
|
return {
|
|
271
271
|
width: node.style?.width ?? node.measured?.width ?? node.width ?? 200,
|
|
@@ -382,11 +382,11 @@ function getFrameData(data, frameId) {
|
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
// src/ui/
|
|
385
|
+
// src/ui/Canvas/template-compiler.ts
|
|
386
386
|
var import_react4 = __toESM(require("react"), 1);
|
|
387
387
|
var import_sucrase = require("sucrase");
|
|
388
388
|
|
|
389
|
-
// src/ui/
|
|
389
|
+
// src/ui/Canvas/quickjs-loader.ts
|
|
390
390
|
var import_react3 = require("react");
|
|
391
391
|
var _state = { status: "idle", module: null };
|
|
392
392
|
var _listeners = /* @__PURE__ */ new Set();
|
|
@@ -417,7 +417,7 @@ function useQuickJS() {
|
|
|
417
417
|
return (0, import_react3.useSyncExternalStore)(subscribeQuickJS, getQuickJSSnapshot, () => null);
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
// src/ui/
|
|
420
|
+
// src/ui/Canvas/template-compiler.ts
|
|
421
421
|
var MAX_CACHE_SIZE = 100;
|
|
422
422
|
var MAX_MATERIALIZE_DEPTH = 20;
|
|
423
423
|
var IFRAME_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
@@ -695,7 +695,7 @@ function clearTemplateCache() {
|
|
|
695
695
|
rendererCache.clear();
|
|
696
696
|
}
|
|
697
697
|
|
|
698
|
-
// src/ui/
|
|
698
|
+
// src/ui/Canvas/node-renderers.tsx
|
|
699
699
|
var import_react5 = __toESM(require("react"), 1);
|
|
700
700
|
function sanitizeUrl(url) {
|
|
701
701
|
if (!url) return url;
|
|
@@ -864,7 +864,7 @@ function DefaultFrameNode({ data }) {
|
|
|
864
864
|
);
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
-
// src/ui/
|
|
867
|
+
// src/ui/Canvas/field-helpers.ts
|
|
868
868
|
function getImageField(fields, name) {
|
|
869
869
|
const val = fields?.[name];
|
|
870
870
|
if (val && typeof val === "object" && val !== null && "url" in val)
|
|
@@ -884,7 +884,7 @@ function getBooleanField(fields, name) {
|
|
|
884
884
|
return typeof val === "boolean" ? val : void 0;
|
|
885
885
|
}
|
|
886
886
|
|
|
887
|
-
// src/ui/
|
|
887
|
+
// src/ui/Canvas/css-sanitizer.ts
|
|
888
888
|
var import_postcss = __toESM(require("postcss"), 1);
|
|
889
889
|
var ALLOWED_AT_RULES = /* @__PURE__ */ new Set(["keyframes", "media", "supports", "container", "layer"]);
|
|
890
890
|
var BLOCKED_VALUE_PATTERNS = [/url\s*\(/i, /expression\s*\(/i, /paint\s*\(/i, /-moz-binding/i];
|
|
@@ -983,11 +983,11 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
983
983
|
return root.toString().replace(/<\/style/gi, "<\\/style");
|
|
984
984
|
}
|
|
985
985
|
|
|
986
|
-
// src/ui/
|
|
986
|
+
// src/ui/Canvas/CanvasRenderer.tsx
|
|
987
987
|
var import_react11 = __toESM(require("react"), 1);
|
|
988
988
|
var import_react12 = require("@xyflow/react");
|
|
989
989
|
|
|
990
|
-
// src/ui/
|
|
990
|
+
// src/ui/Canvas/node-types-factory.tsx
|
|
991
991
|
var import_react7 = __toESM(require("react"), 1);
|
|
992
992
|
|
|
993
993
|
// src/ui/Image/index.tsx
|
|
@@ -1151,7 +1151,7 @@ function Image({
|
|
|
1151
1151
|
));
|
|
1152
1152
|
}
|
|
1153
1153
|
|
|
1154
|
-
// src/ui/
|
|
1154
|
+
// src/ui/Canvas/node-types-factory.tsx
|
|
1155
1155
|
function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode) {
|
|
1156
1156
|
const types = {};
|
|
1157
1157
|
types.dynamic = ((props) => {
|
|
@@ -1264,7 +1264,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1264
1264
|
return types;
|
|
1265
1265
|
}
|
|
1266
1266
|
|
|
1267
|
-
// src/ui/
|
|
1267
|
+
// src/ui/Canvas/edge-styles.ts
|
|
1268
1268
|
var import_react8 = require("@xyflow/react");
|
|
1269
1269
|
function toMarkerType(value) {
|
|
1270
1270
|
if (value === "arrow") return import_react8.MarkerType.Arrow;
|
|
@@ -1316,7 +1316,7 @@ function applyEdgeStyles(edges, edgeTypeDefsMap) {
|
|
|
1316
1316
|
});
|
|
1317
1317
|
}
|
|
1318
1318
|
|
|
1319
|
-
// src/ui/
|
|
1319
|
+
// src/ui/Canvas/focus-handler.tsx
|
|
1320
1320
|
var import_react9 = __toESM(require("react"), 1);
|
|
1321
1321
|
var import_react10 = require("@xyflow/react");
|
|
1322
1322
|
function clampViewport(vp, cw, ch, extent) {
|
|
@@ -1446,9 +1446,9 @@ function FocusHandler({
|
|
|
1446
1446
|
);
|
|
1447
1447
|
}
|
|
1448
1448
|
|
|
1449
|
-
// src/ui/
|
|
1449
|
+
// src/ui/Canvas/CanvasRenderer.tsx
|
|
1450
1450
|
var NullFrameRenderer = () => null;
|
|
1451
|
-
function
|
|
1451
|
+
function CanvasRenderer({
|
|
1452
1452
|
data,
|
|
1453
1453
|
className,
|
|
1454
1454
|
style,
|
|
@@ -1625,9 +1625,9 @@ function FlowRenderer({
|
|
|
1625
1625
|
));
|
|
1626
1626
|
}
|
|
1627
1627
|
|
|
1628
|
-
// src/ui/
|
|
1628
|
+
// src/ui/Canvas/CanvasFrame.tsx
|
|
1629
1629
|
var import_react13 = __toESM(require("react"), 1);
|
|
1630
|
-
function
|
|
1630
|
+
function CanvasFrame({
|
|
1631
1631
|
client,
|
|
1632
1632
|
slug,
|
|
1633
1633
|
id,
|
|
@@ -1637,7 +1637,7 @@ function FlowFrame({
|
|
|
1637
1637
|
onDataReady,
|
|
1638
1638
|
...rendererProps
|
|
1639
1639
|
}) {
|
|
1640
|
-
const { data, nodeTypeDefs, edgeTypeDefs,
|
|
1640
|
+
const { data, nodeTypeDefs, edgeTypeDefs, canvas, isLoading, error } = useCanvas({
|
|
1641
1641
|
client,
|
|
1642
1642
|
slug,
|
|
1643
1643
|
id
|
|
@@ -1649,12 +1649,12 @@ function FlowFrame({
|
|
|
1649
1649
|
const onDataReadyRef = (0, import_react13.useRef)(onDataReady);
|
|
1650
1650
|
onDataReadyRef.current = onDataReady;
|
|
1651
1651
|
(0, import_react13.useEffect)(() => {
|
|
1652
|
-
if (frameData &&
|
|
1653
|
-
onDataReadyRef.current?.(frameData,
|
|
1652
|
+
if (frameData && canvas) {
|
|
1653
|
+
onDataReadyRef.current?.(frameData, canvas);
|
|
1654
1654
|
}
|
|
1655
|
-
}, [frameData,
|
|
1655
|
+
}, [frameData, canvas]);
|
|
1656
1656
|
if (process.env.NODE_ENV !== "production" && !slug && !id) {
|
|
1657
|
-
console.warn('[
|
|
1657
|
+
console.warn('[CanvasFrame] Either "slug" or "id" must be provided.');
|
|
1658
1658
|
}
|
|
1659
1659
|
if (isLoading) return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, loading);
|
|
1660
1660
|
if (error) return renderError ? /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, renderError(error)) : null;
|
|
@@ -1662,13 +1662,13 @@ function FlowFrame({
|
|
|
1662
1662
|
if (process.env.NODE_ENV !== "production" && data) {
|
|
1663
1663
|
const frames = data.nodes.filter(isFrameNode).map((n) => n.id);
|
|
1664
1664
|
console.warn(
|
|
1665
|
-
`[
|
|
1665
|
+
`[CanvasFrame] Frame "${frameId}" not found. Available frames: ${frames.join(", ") || "(none)"}`
|
|
1666
1666
|
);
|
|
1667
1667
|
}
|
|
1668
1668
|
return null;
|
|
1669
1669
|
}
|
|
1670
1670
|
return /* @__PURE__ */ import_react13.default.createElement(
|
|
1671
|
-
|
|
1671
|
+
CanvasRenderer,
|
|
1672
1672
|
{
|
|
1673
1673
|
...rendererProps,
|
|
1674
1674
|
data: frameData.data,
|
|
@@ -1680,4 +1680,4 @@ function FlowFrame({
|
|
|
1680
1680
|
}
|
|
1681
1681
|
);
|
|
1682
1682
|
}
|
|
1683
|
-
//# sourceMappingURL=
|
|
1683
|
+
//# sourceMappingURL=canvas.cjs.map
|