@01.software/sdk 0.5.4 → 0.5.5
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/auth.cjs +22 -46
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.js +22 -47
- package/dist/auth.js.map +1 -1
- package/dist/index.cjs +922 -1069
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +922 -1072
- package/dist/index.js.map +1 -1
- package/dist/realtime.cjs +75 -101
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +75 -102
- package/dist/realtime.js.map +1 -1
- package/dist/ui/code-block.cjs +13 -35
- package/dist/ui/code-block.cjs.map +1 -1
- package/dist/ui/code-block.js +13 -35
- package/dist/ui/code-block.js.map +1 -1
- package/dist/ui/flow/server.cjs +26 -68
- package/dist/ui/flow/server.cjs.map +1 -1
- package/dist/ui/flow/server.js +26 -71
- package/dist/ui/flow/server.js.map +1 -1
- package/dist/ui/flow.cjs +176 -232
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.js +176 -234
- package/dist/ui/flow.js.map +1 -1
- package/dist/ui/form.cjs +40 -84
- package/dist/ui/form.cjs.map +1 -1
- package/dist/ui/form.js +40 -86
- package/dist/ui/form.js.map +1 -1
- package/dist/ui/image.cjs +27 -40
- package/dist/ui/image.cjs.map +1 -1
- package/dist/ui/image.js +27 -42
- package/dist/ui/image.js.map +1 -1
- package/dist/ui/rich-text.cjs +33 -67
- package/dist/ui/rich-text.cjs.map +1 -1
- package/dist/ui/rich-text.js +33 -69
- package/dist/ui/rich-text.js.map +1 -1
- package/dist/ui/video.cjs +32 -50
- package/dist/ui/video.cjs.map +1 -1
- package/dist/ui/video.js +32 -52
- package/dist/ui/video.js.map +1 -1
- package/dist/webhook.cjs +48 -73
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.js +48 -74
- package/dist/webhook.js.map +1 -1
- package/package.json +3 -3
package/dist/ui/flow.js
CHANGED
|
@@ -1,55 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
|
-
var __async = (__this, __arguments, generator) => {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
var fulfilled = (value) => {
|
|
36
|
-
try {
|
|
37
|
-
step(generator.next(value));
|
|
38
|
-
} catch (e) {
|
|
39
|
-
reject(e);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var rejected = (value) => {
|
|
43
|
-
try {
|
|
44
|
-
step(generator.throw(value));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
reject(e);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
2
|
|
|
54
3
|
// src/ui/Flow/types.ts
|
|
55
4
|
function isDynamicNode(node) {
|
|
@@ -116,133 +65,128 @@ function collectionKeys(collection) {
|
|
|
116
65
|
|
|
117
66
|
// src/ui/Flow/query-options.ts
|
|
118
67
|
function flowQueryOptions(client, slug, id) {
|
|
119
|
-
|
|
120
|
-
const identifier = (_a = id != null ? id : slug) != null ? _a : "";
|
|
68
|
+
const identifier = id ?? slug ?? "";
|
|
121
69
|
return {
|
|
122
70
|
queryKey: collectionKeys("flows").detail(identifier),
|
|
123
|
-
queryFn: () =>
|
|
71
|
+
queryFn: async () => {
|
|
124
72
|
if (id) return client.from("flows").findById(id);
|
|
125
|
-
const result =
|
|
73
|
+
const result = await client.from("flows").find({
|
|
126
74
|
where: { slug: { equals: slug } },
|
|
127
75
|
limit: 1
|
|
128
76
|
});
|
|
129
77
|
const doc = result.docs[0];
|
|
130
78
|
if (!doc) throw new Error(`Flow not found: ${slug}`);
|
|
131
79
|
return doc;
|
|
132
|
-
}
|
|
80
|
+
}
|
|
133
81
|
};
|
|
134
82
|
}
|
|
135
83
|
function nodeTypesQueryOptions(client) {
|
|
136
84
|
return {
|
|
137
85
|
queryKey: collectionKeys("flow-node-types").lists(),
|
|
138
|
-
queryFn: () =>
|
|
139
|
-
const result =
|
|
86
|
+
queryFn: async () => {
|
|
87
|
+
const result = await client.from("flow-node-types").find({ limit: 0 });
|
|
140
88
|
return result.docs;
|
|
141
|
-
}
|
|
89
|
+
}
|
|
142
90
|
};
|
|
143
91
|
}
|
|
144
92
|
function edgeTypesQueryOptions(client) {
|
|
145
93
|
return {
|
|
146
94
|
queryKey: collectionKeys("flow-edge-types").lists(),
|
|
147
|
-
queryFn: () =>
|
|
148
|
-
const result =
|
|
95
|
+
queryFn: async () => {
|
|
96
|
+
const result = await client.from("flow-edge-types").find({ limit: 0 });
|
|
149
97
|
return result.docs;
|
|
150
|
-
}
|
|
98
|
+
}
|
|
151
99
|
};
|
|
152
100
|
}
|
|
153
101
|
|
|
154
102
|
// src/ui/Flow/useFlow.ts
|
|
155
103
|
function toNodeTypeDef(doc) {
|
|
156
|
-
var _a, _b, _c, _d, _e, _f;
|
|
157
104
|
return {
|
|
158
|
-
slug: String(
|
|
159
|
-
name: String(
|
|
160
|
-
color: String(
|
|
161
|
-
defaultSize:
|
|
105
|
+
slug: String(doc.slug ?? ""),
|
|
106
|
+
name: String(doc.title ?? ""),
|
|
107
|
+
color: String(doc.color ?? "#e5e7eb"),
|
|
108
|
+
defaultSize: doc.defaultSize ?? {
|
|
162
109
|
width: 200,
|
|
163
110
|
height: 200
|
|
164
111
|
},
|
|
165
112
|
fields: Array.isArray(doc.fields) ? doc.fields : [],
|
|
166
113
|
transparentBackground: Boolean(doc.transparentBackground),
|
|
167
|
-
template:
|
|
168
|
-
customCSS:
|
|
114
|
+
template: doc.template ?? null,
|
|
115
|
+
customCSS: doc.customCSS ?? null
|
|
169
116
|
};
|
|
170
117
|
}
|
|
171
118
|
function toEdgeTypeDef(doc) {
|
|
172
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
173
119
|
return {
|
|
174
|
-
slug: String(
|
|
175
|
-
name: String(
|
|
176
|
-
color: String(
|
|
177
|
-
strokeWidth:
|
|
178
|
-
animated:
|
|
179
|
-
lineStyle: String(
|
|
180
|
-
markerStart: String(
|
|
181
|
-
markerEnd: String(
|
|
120
|
+
slug: String(doc.slug ?? ""),
|
|
121
|
+
name: String(doc.title ?? ""),
|
|
122
|
+
color: String(doc.color ?? ""),
|
|
123
|
+
strokeWidth: doc.strokeWidth ?? 2,
|
|
124
|
+
animated: doc.animated ?? false,
|
|
125
|
+
lineStyle: String(doc.lineStyle ?? "default"),
|
|
126
|
+
markerStart: String(doc.markerStart ?? "none"),
|
|
127
|
+
markerEnd: String(doc.markerEnd ?? "arrow"),
|
|
182
128
|
fields: Array.isArray(doc.fields) ? doc.fields : []
|
|
183
129
|
};
|
|
184
130
|
}
|
|
185
131
|
function useFlow(options) {
|
|
186
|
-
var _a, _b;
|
|
187
132
|
const { client, slug, id, enabled = true } = options;
|
|
188
133
|
const hasIdentifier = !!(slug || id);
|
|
189
134
|
const flowQuery = useQuery(
|
|
190
|
-
|
|
135
|
+
{
|
|
136
|
+
...flowQueryOptions(client, slug, id),
|
|
191
137
|
enabled: enabled && hasIdentifier
|
|
192
|
-
}
|
|
138
|
+
},
|
|
193
139
|
client.queryClient
|
|
194
140
|
);
|
|
195
141
|
const nodeTypesQuery = useQuery(
|
|
196
|
-
|
|
142
|
+
{
|
|
143
|
+
...nodeTypesQueryOptions(client),
|
|
197
144
|
enabled
|
|
198
|
-
}
|
|
145
|
+
},
|
|
199
146
|
client.queryClient
|
|
200
147
|
);
|
|
201
148
|
const edgeTypesQuery = useQuery(
|
|
202
|
-
|
|
149
|
+
{
|
|
150
|
+
...edgeTypesQueryOptions(client),
|
|
203
151
|
enabled
|
|
204
|
-
}
|
|
152
|
+
},
|
|
205
153
|
client.queryClient
|
|
206
154
|
);
|
|
207
155
|
const nodeTypeDefs = useMemo(() => {
|
|
208
|
-
|
|
209
|
-
const apiDefs = ((_a2 = nodeTypesQuery.data) != null ? _a2 : []).map(toNodeTypeDef);
|
|
156
|
+
const apiDefs = (nodeTypesQuery.data ?? []).map(toNodeTypeDef);
|
|
210
157
|
const builtInSlugs = new Set(BUILT_IN_NODE_TYPES.map((t) => t.slug));
|
|
211
158
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
212
159
|
return [...BUILT_IN_NODE_TYPES, ...customDefs];
|
|
213
160
|
}, [nodeTypesQuery.data]);
|
|
214
161
|
const edgeTypeDefs = useMemo(() => {
|
|
215
|
-
|
|
216
|
-
const apiDefs = ((_a2 = edgeTypesQuery.data) != null ? _a2 : []).map(toEdgeTypeDef);
|
|
162
|
+
const apiDefs = (edgeTypesQuery.data ?? []).map(toEdgeTypeDef);
|
|
217
163
|
const builtInSlugs = new Set(BUILT_IN_EDGE_TYPES.map((t) => t.slug));
|
|
218
164
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
219
165
|
return [...BUILT_IN_EDGE_TYPES, ...customDefs];
|
|
220
166
|
}, [edgeTypesQuery.data]);
|
|
221
167
|
const flow = flowQuery.data;
|
|
222
|
-
const canvas = flow
|
|
168
|
+
const canvas = flow?.canvas;
|
|
223
169
|
return {
|
|
224
170
|
data: canvas,
|
|
225
171
|
nodeTypeDefs,
|
|
226
172
|
edgeTypeDefs,
|
|
227
173
|
flow,
|
|
228
174
|
isLoading: flowQuery.isLoading || nodeTypesQuery.isLoading || edgeTypesQuery.isLoading,
|
|
229
|
-
error:
|
|
175
|
+
error: flowQuery.error ?? nodeTypesQuery.error ?? edgeTypesQuery.error
|
|
230
176
|
};
|
|
231
177
|
}
|
|
232
178
|
|
|
233
179
|
// src/ui/Flow/prefetchFlow.ts
|
|
234
|
-
function prefetchFlow(options) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
]);
|
|
245
|
-
});
|
|
180
|
+
async function prefetchFlow(options) {
|
|
181
|
+
const { client, slug, id } = options;
|
|
182
|
+
if (!slug && !id) {
|
|
183
|
+
throw new Error("prefetchFlow requires either slug or id");
|
|
184
|
+
}
|
|
185
|
+
await Promise.all([
|
|
186
|
+
client.queryClient.prefetchQuery(flowQueryOptions(client, slug, id)),
|
|
187
|
+
client.queryClient.prefetchQuery(nodeTypesQueryOptions(client)),
|
|
188
|
+
client.queryClient.prefetchQuery(edgeTypesQueryOptions(client))
|
|
189
|
+
]);
|
|
246
190
|
}
|
|
247
191
|
|
|
248
192
|
// src/ui/Flow/useFlowData.ts
|
|
@@ -250,21 +194,15 @@ import { useMemo as useMemo2 } from "react";
|
|
|
250
194
|
function useFlowData(options) {
|
|
251
195
|
const { data, nodeTypeDefs: inputNodeDefs, edgeTypeDefs: inputEdgeDefs } = options;
|
|
252
196
|
const nodeTypeDefsMap = useMemo2(() => {
|
|
253
|
-
const allDefs = inputNodeDefs
|
|
197
|
+
const allDefs = inputNodeDefs ?? BUILT_IN_NODE_TYPES;
|
|
254
198
|
return new Map(allDefs.map((d) => [d.slug, d]));
|
|
255
199
|
}, [inputNodeDefs]);
|
|
256
200
|
const edgeTypeDefsMap = useMemo2(() => {
|
|
257
|
-
const allDefs = inputEdgeDefs
|
|
201
|
+
const allDefs = inputEdgeDefs ?? BUILT_IN_EDGE_TYPES;
|
|
258
202
|
return new Map(allDefs.map((d) => [d.slug, d]));
|
|
259
203
|
}, [inputEdgeDefs]);
|
|
260
|
-
const nodes = useMemo2(() =>
|
|
261
|
-
|
|
262
|
-
return (_a = data == null ? void 0 : data.nodes) != null ? _a : [];
|
|
263
|
-
}, [data == null ? void 0 : data.nodes]);
|
|
264
|
-
const edges = useMemo2(() => {
|
|
265
|
-
var _a;
|
|
266
|
-
return (_a = data == null ? void 0 : data.edges) != null ? _a : [];
|
|
267
|
-
}, [data == null ? void 0 : data.edges]);
|
|
204
|
+
const nodes = useMemo2(() => data?.nodes ?? [], [data?.nodes]);
|
|
205
|
+
const edges = useMemo2(() => data?.edges ?? [], [data?.edges]);
|
|
268
206
|
return {
|
|
269
207
|
nodes,
|
|
270
208
|
edges,
|
|
@@ -275,10 +213,9 @@ function useFlowData(options) {
|
|
|
275
213
|
|
|
276
214
|
// src/ui/Flow/utils.ts
|
|
277
215
|
function getNodeSize(node) {
|
|
278
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
279
216
|
return {
|
|
280
|
-
width:
|
|
281
|
-
height:
|
|
217
|
+
width: node.style?.width ?? node.measured?.width ?? node.width ?? 200,
|
|
218
|
+
height: node.style?.height ?? node.measured?.height ?? node.height ?? 200
|
|
282
219
|
};
|
|
283
220
|
}
|
|
284
221
|
function getAbsolutePosition(node, nodeMap) {
|
|
@@ -350,13 +287,12 @@ function getFrames(nodes) {
|
|
|
350
287
|
if (frames.length === 0) return [];
|
|
351
288
|
const nodeMap = new Map(nodes.map((n) => [n.id, n]));
|
|
352
289
|
return frames.map((f) => {
|
|
353
|
-
var _a;
|
|
354
290
|
const data = f.data;
|
|
355
291
|
const abs = getAbsolutePosition(f, nodeMap);
|
|
356
292
|
const { width: w, height: h } = getNodeSize(f);
|
|
357
293
|
return {
|
|
358
294
|
id: f.id,
|
|
359
|
-
label:
|
|
295
|
+
label: data.label ?? "",
|
|
360
296
|
bounds: { x: abs.x, y: abs.y, width: w, height: h }
|
|
361
297
|
};
|
|
362
298
|
}).sort((a, b) => a.bounds.y - b.bounds.y || a.bounds.x - b.bounds.x);
|
|
@@ -365,13 +301,13 @@ function getFrameData(data, frameId) {
|
|
|
365
301
|
const frame = data.nodes.find((n) => n.id === frameId);
|
|
366
302
|
if (!frame || frame.type !== "frame") return void 0;
|
|
367
303
|
const descendantIds = collectDescendants(data.nodes, frameId);
|
|
368
|
-
const childNodes = data.nodes.filter((n) => descendantIds.has(n.id)).map((n) =>
|
|
304
|
+
const childNodes = data.nodes.filter((n) => descendantIds.has(n.id)).map((n) => ({ ...n, draggable: false }));
|
|
369
305
|
const childEdges = data.edges.filter(
|
|
370
306
|
(e) => descendantIds.has(e.source) && descendantIds.has(e.target)
|
|
371
307
|
);
|
|
372
308
|
const frameBounds = getNodeBounds(data.nodes, [frameId]);
|
|
373
309
|
const { width: w, height: h } = getNodeSize(frame);
|
|
374
|
-
const clampBounds = frameBounds
|
|
310
|
+
const clampBounds = frameBounds ?? {
|
|
375
311
|
x: frame.position.x,
|
|
376
312
|
y: frame.position.y,
|
|
377
313
|
width: w,
|
|
@@ -379,7 +315,7 @@ function getFrameData(data, frameId) {
|
|
|
379
315
|
};
|
|
380
316
|
const contentNodeIds = childNodes.filter((n) => n.id !== frameId).map((n) => n.id);
|
|
381
317
|
const contentBounds = contentNodeIds.length > 0 ? getNodeBounds(data.nodes, contentNodeIds) : void 0;
|
|
382
|
-
const fitBounds = contentBounds
|
|
318
|
+
const fitBounds = contentBounds ?? clampBounds;
|
|
383
319
|
return {
|
|
384
320
|
data: {
|
|
385
321
|
nodes: childNodes,
|
|
@@ -430,6 +366,13 @@ function useQuickJS() {
|
|
|
430
366
|
// src/ui/Flow/template-compiler.ts
|
|
431
367
|
var MAX_CACHE_SIZE = 100;
|
|
432
368
|
var MAX_MATERIALIZE_DEPTH = 20;
|
|
369
|
+
var IFRAME_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
370
|
+
"srcdoc",
|
|
371
|
+
"allow",
|
|
372
|
+
"allowpaymentrequest",
|
|
373
|
+
"name",
|
|
374
|
+
"sandbox"
|
|
375
|
+
]);
|
|
433
376
|
var ALLOWED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
434
377
|
"div",
|
|
435
378
|
"span",
|
|
@@ -463,7 +406,8 @@ var ALLOWED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
463
406
|
"path",
|
|
464
407
|
"g",
|
|
465
408
|
"circle",
|
|
466
|
-
"rect"
|
|
409
|
+
"rect",
|
|
410
|
+
"iframe"
|
|
467
411
|
]);
|
|
468
412
|
var BLOCKED_PATTERNS = [
|
|
469
413
|
/\bdocument\s*\./,
|
|
@@ -543,7 +487,7 @@ function isSafeUrl(value) {
|
|
|
543
487
|
try {
|
|
544
488
|
const url = new URL(value);
|
|
545
489
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
546
|
-
} catch
|
|
490
|
+
} catch {
|
|
547
491
|
return false;
|
|
548
492
|
}
|
|
549
493
|
}
|
|
@@ -575,7 +519,6 @@ function sanitizeStyle(style) {
|
|
|
575
519
|
return safe;
|
|
576
520
|
}
|
|
577
521
|
function materialize(node, depth = 0) {
|
|
578
|
-
var _a;
|
|
579
522
|
if (depth > MAX_MATERIALIZE_DEPTH) return null;
|
|
580
523
|
if (node == null) return null;
|
|
581
524
|
if (typeof node === "string" || typeof node === "number") return node;
|
|
@@ -597,7 +540,7 @@ function materialize(node, depth = 0) {
|
|
|
597
540
|
);
|
|
598
541
|
}
|
|
599
542
|
if (d.$$t === "el") {
|
|
600
|
-
const type = String(
|
|
543
|
+
const type = String(d.type ?? "");
|
|
601
544
|
const props = d.props && typeof d.props === "object" ? d.props : {};
|
|
602
545
|
const ch = Array.isArray(d.ch) ? d.ch : [];
|
|
603
546
|
if (!ALLOWED_ELEMENTS.has(type.toLowerCase())) return null;
|
|
@@ -605,6 +548,7 @@ function materialize(node, depth = 0) {
|
|
|
605
548
|
for (const [k, v] of Object.entries(props)) {
|
|
606
549
|
if (k.startsWith("on")) continue;
|
|
607
550
|
if (k === "dangerouslySetInnerHTML" || k === "ref") continue;
|
|
551
|
+
if (type === "iframe" && IFRAME_BLOCKED_PROPS.has(k)) continue;
|
|
608
552
|
if ((k === "src" || k === "href") && !isSafeUrl(v)) continue;
|
|
609
553
|
if (k === "style") {
|
|
610
554
|
safeProps[k] = sanitizeStyle(v);
|
|
@@ -612,6 +556,9 @@ function materialize(node, depth = 0) {
|
|
|
612
556
|
}
|
|
613
557
|
safeProps[k] = v;
|
|
614
558
|
}
|
|
559
|
+
if (type === "iframe") {
|
|
560
|
+
safeProps["sandbox"] = "allow-scripts allow-same-origin";
|
|
561
|
+
}
|
|
615
562
|
const children = ch.map((c) => materialize(c, depth + 1));
|
|
616
563
|
return React.createElement(type, safeProps, ...children);
|
|
617
564
|
}
|
|
@@ -645,7 +592,7 @@ function makeRenderer(jsCode) {
|
|
|
645
592
|
const raw = vm.dump(callResult.handle);
|
|
646
593
|
callResult.handle.dispose();
|
|
647
594
|
return materialize(JSON.parse(String(raw)));
|
|
648
|
-
} catch
|
|
595
|
+
} catch {
|
|
649
596
|
return null;
|
|
650
597
|
} finally {
|
|
651
598
|
vm.dispose();
|
|
@@ -654,8 +601,7 @@ function makeRenderer(jsCode) {
|
|
|
654
601
|
}
|
|
655
602
|
function makeReactFC(renderer, qjs) {
|
|
656
603
|
return function QuickJSTemplateComponent(props) {
|
|
657
|
-
|
|
658
|
-
return (_a = renderer(qjs, props)) != null ? _a : null;
|
|
604
|
+
return renderer(qjs, props) ?? null;
|
|
659
605
|
};
|
|
660
606
|
}
|
|
661
607
|
function compileTemplate(code, slug) {
|
|
@@ -679,7 +625,7 @@ function compileTemplate(code, slug) {
|
|
|
679
625
|
jsxFragmentPragma: "React.Fragment"
|
|
680
626
|
});
|
|
681
627
|
jsCode = result.code;
|
|
682
|
-
} catch
|
|
628
|
+
} catch {
|
|
683
629
|
return null;
|
|
684
630
|
}
|
|
685
631
|
const renderer = makeRenderer(jsCode);
|
|
@@ -703,15 +649,15 @@ function sanitizeUrl(url) {
|
|
|
703
649
|
const parsed = new URL(url);
|
|
704
650
|
if (parsed.protocol === "http:" || parsed.protocol === "https:") return url;
|
|
705
651
|
return void 0;
|
|
706
|
-
} catch
|
|
652
|
+
} catch {
|
|
707
653
|
return void 0;
|
|
708
654
|
}
|
|
709
655
|
}
|
|
710
656
|
function renderFieldValue(key, val, fieldDef) {
|
|
711
657
|
if (val == null || val === "") return null;
|
|
712
|
-
const fieldType = fieldDef
|
|
658
|
+
const fieldType = fieldDef?.fieldType;
|
|
713
659
|
if (fieldType === "image" || typeof val === "object" && val !== null && "url" in val) {
|
|
714
|
-
const imgUrl = typeof val === "string" ? val : val
|
|
660
|
+
const imgUrl = typeof val === "string" ? val : val?.url;
|
|
715
661
|
const safeUrl = sanitizeUrl(imgUrl);
|
|
716
662
|
if (!safeUrl) return null;
|
|
717
663
|
return /* @__PURE__ */ React2.createElement(
|
|
@@ -824,12 +770,11 @@ function EnhancedDynamicNode({
|
|
|
824
770
|
);
|
|
825
771
|
}
|
|
826
772
|
function DefaultFrameNode({ data }) {
|
|
827
|
-
var _a, _b, _c, _d;
|
|
828
773
|
const d = data;
|
|
829
|
-
const baseColor =
|
|
830
|
-
const padding =
|
|
831
|
-
const borderStyle =
|
|
832
|
-
const opacity =
|
|
774
|
+
const baseColor = d.color ?? "rgb(128,128,128)";
|
|
775
|
+
const padding = d.padding ?? 20;
|
|
776
|
+
const borderStyle = d.borderStyle ?? "dashed";
|
|
777
|
+
const opacity = d.opacity ?? 0.15;
|
|
833
778
|
const bgColor = (() => {
|
|
834
779
|
const m = baseColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
835
780
|
if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`;
|
|
@@ -863,21 +808,21 @@ function DefaultFrameNode({ data }) {
|
|
|
863
808
|
|
|
864
809
|
// src/ui/Flow/field-helpers.ts
|
|
865
810
|
function getImageField(fields, name) {
|
|
866
|
-
const val = fields
|
|
811
|
+
const val = fields?.[name];
|
|
867
812
|
if (val && typeof val === "object" && val !== null && "url" in val)
|
|
868
813
|
return val;
|
|
869
814
|
return void 0;
|
|
870
815
|
}
|
|
871
816
|
function getTextField(fields, name) {
|
|
872
|
-
const val = fields
|
|
817
|
+
const val = fields?.[name];
|
|
873
818
|
return typeof val === "string" ? val : void 0;
|
|
874
819
|
}
|
|
875
820
|
function getNumberField(fields, name) {
|
|
876
|
-
const val = fields
|
|
821
|
+
const val = fields?.[name];
|
|
877
822
|
return typeof val === "number" ? val : void 0;
|
|
878
823
|
}
|
|
879
824
|
function getBooleanField(fields, name) {
|
|
880
|
-
const val = fields
|
|
825
|
+
const val = fields?.[name];
|
|
881
826
|
return typeof val === "boolean" ? val : void 0;
|
|
882
827
|
}
|
|
883
828
|
|
|
@@ -895,7 +840,7 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
895
840
|
let root;
|
|
896
841
|
try {
|
|
897
842
|
root = postcss.parse(css);
|
|
898
|
-
} catch
|
|
843
|
+
} catch {
|
|
899
844
|
return "";
|
|
900
845
|
}
|
|
901
846
|
const safeScopeClass = scopeClass ? scopeClass.replace(/[{}()[\];,'"\\<>\s]/g, "") : "";
|
|
@@ -912,9 +857,8 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
912
857
|
if (safeScopeClass && keyframeNameMap.size > 0) {
|
|
913
858
|
const ANIM_KEYWORDS = /* @__PURE__ */ new Set(["none", "initial", "inherit", "unset", "revert"]);
|
|
914
859
|
const replaceAnimName = (token) => {
|
|
915
|
-
var _a;
|
|
916
860
|
const t = token.trim().replace(/^['"]|['"]$/g, "");
|
|
917
|
-
return ANIM_KEYWORDS.has(t) ? token :
|
|
861
|
+
return ANIM_KEYWORDS.has(t) ? token : keyframeNameMap.get(t) ?? token;
|
|
918
862
|
};
|
|
919
863
|
root.walkDecls(/^animation-name$/i, (node) => {
|
|
920
864
|
node.value = node.value.split(",").map(replaceAnimName).join(", ");
|
|
@@ -972,7 +916,7 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
972
916
|
return;
|
|
973
917
|
}
|
|
974
918
|
const parent = rule.parent;
|
|
975
|
-
if (
|
|
919
|
+
if (parent?.type === "atrule" && parent.name.toLowerCase() === "keyframes") {
|
|
976
920
|
return;
|
|
977
921
|
}
|
|
978
922
|
rule.selectors = rule.selectors.map((sel) => `.${safeScopeClass} ${sel}`);
|
|
@@ -1005,7 +949,7 @@ function getImageSrcSet(image) {
|
|
|
1005
949
|
if (sizes) {
|
|
1006
950
|
for (const size of IMAGE_SIZES) {
|
|
1007
951
|
const entry = sizes[String(size)];
|
|
1008
|
-
if (
|
|
952
|
+
if (entry?.url && entry.width) {
|
|
1009
953
|
parts.push(`${entry.url} ${entry.width}w`);
|
|
1010
954
|
}
|
|
1011
955
|
}
|
|
@@ -1016,11 +960,10 @@ function getImageSrcSet(image) {
|
|
|
1016
960
|
return parts.join(", ");
|
|
1017
961
|
}
|
|
1018
962
|
function getImagePlaceholderStyle(image, options) {
|
|
1019
|
-
|
|
1020
|
-
const
|
|
1021
|
-
const paletteColor = (_b = options == null ? void 0 : options.paletteColor) != null ? _b : "muted";
|
|
963
|
+
const type = options?.type ?? "blur";
|
|
964
|
+
const paletteColor = options?.paletteColor ?? "muted";
|
|
1022
965
|
if (type === "none") return {};
|
|
1023
|
-
const color =
|
|
966
|
+
const color = image.palette?.[paletteColor];
|
|
1024
967
|
if (type === "blur") {
|
|
1025
968
|
const lqip = image.lqip;
|
|
1026
969
|
if (lqip) {
|
|
@@ -1059,15 +1002,14 @@ function Image({
|
|
|
1059
1002
|
fill = false,
|
|
1060
1003
|
imageRendering
|
|
1061
1004
|
}) {
|
|
1062
|
-
var _a, _b;
|
|
1063
1005
|
const [loaded, setLoaded] = useState(false);
|
|
1064
1006
|
const firedRef = useRef(false);
|
|
1065
1007
|
const isPixelRendering = imageRendering === "pixelated" || imageRendering === "crisp-edges";
|
|
1066
|
-
const placeholder = placeholderProp
|
|
1067
|
-
const loading = priority ? "eager" : loadingProp
|
|
1008
|
+
const placeholder = placeholderProp ?? (isPixelRendering ? "none" : "blur");
|
|
1009
|
+
const loading = priority ? "eager" : loadingProp ?? "lazy";
|
|
1068
1010
|
const aspectRatio = !fill && image.width && image.height ? `${image.width} / ${image.height}` : void 0;
|
|
1069
1011
|
const srcSet = getImageSrcSet(image);
|
|
1070
|
-
const src =
|
|
1012
|
+
const src = image.url ?? void 0;
|
|
1071
1013
|
const hasLqip = placeholder === "blur" && !!image.lqip;
|
|
1072
1014
|
const placeholderStyle = getImagePlaceholderStyle(image, {
|
|
1073
1015
|
type: placeholder
|
|
@@ -1077,7 +1019,7 @@ function Image({
|
|
|
1077
1019
|
if (firedRef.current) return;
|
|
1078
1020
|
firedRef.current = true;
|
|
1079
1021
|
setLoaded(true);
|
|
1080
|
-
onLoad
|
|
1022
|
+
onLoad?.();
|
|
1081
1023
|
}, [onLoad]);
|
|
1082
1024
|
const imgRef = useCallback(
|
|
1083
1025
|
(node) => {
|
|
@@ -1087,10 +1029,13 @@ function Image({
|
|
|
1087
1029
|
},
|
|
1088
1030
|
[fireLoad]
|
|
1089
1031
|
);
|
|
1090
|
-
const containerStyle =
|
|
1032
|
+
const containerStyle = {
|
|
1091
1033
|
position: "relative",
|
|
1092
|
-
overflow: "hidden"
|
|
1093
|
-
|
|
1034
|
+
overflow: "hidden",
|
|
1035
|
+
...fill ? { width: "100%", height: "100%" } : {},
|
|
1036
|
+
...aspectRatio ? { aspectRatio } : {},
|
|
1037
|
+
...style
|
|
1038
|
+
};
|
|
1094
1039
|
const overlayBase = {
|
|
1095
1040
|
position: "absolute",
|
|
1096
1041
|
top: 0,
|
|
@@ -1101,41 +1046,44 @@ function Image({
|
|
|
1101
1046
|
transition: "opacity 0.3s ease",
|
|
1102
1047
|
pointerEvents: "none"
|
|
1103
1048
|
};
|
|
1104
|
-
const mainImgStyle =
|
|
1049
|
+
const mainImgStyle = {
|
|
1105
1050
|
display: "block",
|
|
1106
1051
|
width: "100%",
|
|
1107
1052
|
height: "100%",
|
|
1108
|
-
objectFit
|
|
1109
|
-
|
|
1053
|
+
objectFit,
|
|
1054
|
+
...imageRendering ? { imageRendering } : {},
|
|
1110
1055
|
opacity: loaded ? 1 : 0,
|
|
1111
|
-
transition: "opacity 0.3s ease"
|
|
1112
|
-
|
|
1056
|
+
transition: "opacity 0.3s ease",
|
|
1057
|
+
...imgStyle
|
|
1058
|
+
};
|
|
1113
1059
|
return /* @__PURE__ */ React3.createElement("div", { className, style: containerStyle }, hasLqip && /* @__PURE__ */ React3.createElement(
|
|
1114
1060
|
"img",
|
|
1115
1061
|
{
|
|
1116
1062
|
"aria-hidden": true,
|
|
1117
1063
|
alt: "",
|
|
1118
1064
|
src: image.lqip,
|
|
1119
|
-
style:
|
|
1065
|
+
style: {
|
|
1066
|
+
...overlayBase,
|
|
1120
1067
|
display: "block",
|
|
1121
1068
|
objectFit,
|
|
1122
1069
|
filter: "blur(20px)",
|
|
1123
1070
|
transform: "scale(1.1)"
|
|
1124
|
-
}
|
|
1071
|
+
}
|
|
1125
1072
|
}
|
|
1126
1073
|
), placeholderColor && /* @__PURE__ */ React3.createElement(
|
|
1127
1074
|
"div",
|
|
1128
1075
|
{
|
|
1129
1076
|
"aria-hidden": true,
|
|
1130
|
-
style:
|
|
1077
|
+
style: {
|
|
1078
|
+
...overlayBase,
|
|
1131
1079
|
backgroundColor: placeholderColor
|
|
1132
|
-
}
|
|
1080
|
+
}
|
|
1133
1081
|
}
|
|
1134
1082
|
), /* @__PURE__ */ React3.createElement(
|
|
1135
1083
|
"img",
|
|
1136
1084
|
{
|
|
1137
1085
|
ref: imgRef,
|
|
1138
|
-
alt:
|
|
1086
|
+
alt: image.alt ?? "",
|
|
1139
1087
|
src,
|
|
1140
1088
|
srcSet: srcSet || void 0,
|
|
1141
1089
|
sizes,
|
|
@@ -1154,10 +1102,9 @@ function Image({
|
|
|
1154
1102
|
function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode) {
|
|
1155
1103
|
const types = {};
|
|
1156
1104
|
types.dynamic = ((props) => {
|
|
1157
|
-
var _a;
|
|
1158
1105
|
const d = props.data;
|
|
1159
|
-
const typeDef = nodeTypeDefsMap
|
|
1160
|
-
const CustomRenderer = nodeRenderers
|
|
1106
|
+
const typeDef = nodeTypeDefsMap?.get(d.nodeTypeSlug);
|
|
1107
|
+
const CustomRenderer = nodeRenderers?.[d.nodeTypeSlug];
|
|
1161
1108
|
const defaultRender = typeDef ? /* @__PURE__ */ React4.createElement(
|
|
1162
1109
|
EnhancedDynamicNode,
|
|
1163
1110
|
{
|
|
@@ -1166,7 +1113,7 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrap
|
|
|
1166
1113
|
width: props.width,
|
|
1167
1114
|
height: props.height
|
|
1168
1115
|
}
|
|
1169
|
-
) : /* @__PURE__ */ React4.createElement(DefaultDynamicNode,
|
|
1116
|
+
) : /* @__PURE__ */ React4.createElement(DefaultDynamicNode, { ...props });
|
|
1170
1117
|
const slotProps = {
|
|
1171
1118
|
id: props.id,
|
|
1172
1119
|
nodeTypeSlug: d.nodeTypeSlug,
|
|
@@ -1180,9 +1127,9 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrap
|
|
|
1180
1127
|
};
|
|
1181
1128
|
let content;
|
|
1182
1129
|
if (CustomRenderer) {
|
|
1183
|
-
content = /* @__PURE__ */ React4.createElement(CustomRenderer,
|
|
1130
|
+
content = /* @__PURE__ */ React4.createElement(CustomRenderer, { ...slotProps });
|
|
1184
1131
|
} else if (d.nodeTypeSlug === "image") {
|
|
1185
|
-
const imageVal =
|
|
1132
|
+
const imageVal = d.fields?.image;
|
|
1186
1133
|
if (imageVal && typeof imageVal === "object" && "url" in imageVal) {
|
|
1187
1134
|
content = /* @__PURE__ */ React4.createElement(
|
|
1188
1135
|
Image,
|
|
@@ -1245,8 +1192,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1245
1192
|
const types = {};
|
|
1246
1193
|
for (const [slug, Renderer] of Object.entries(edgeRenderers)) {
|
|
1247
1194
|
types[slug] = ((props) => {
|
|
1248
|
-
|
|
1249
|
-
const def = edgeTypeDefsMap == null ? void 0 : edgeTypeDefsMap.get(slug);
|
|
1195
|
+
const def = edgeTypeDefsMap?.get(slug);
|
|
1250
1196
|
return /* @__PURE__ */ React4.createElement(
|
|
1251
1197
|
Renderer,
|
|
1252
1198
|
{
|
|
@@ -1255,7 +1201,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1255
1201
|
source: props.source,
|
|
1256
1202
|
target: props.target,
|
|
1257
1203
|
label: props.label,
|
|
1258
|
-
fields:
|
|
1204
|
+
fields: props.data?.fields,
|
|
1259
1205
|
edgeTypeDef: def,
|
|
1260
1206
|
style: props.style
|
|
1261
1207
|
}
|
|
@@ -1279,33 +1225,38 @@ var EDGE_TYPE_MAP = {
|
|
|
1279
1225
|
default: "default"
|
|
1280
1226
|
};
|
|
1281
1227
|
function applyEdgeStyles(edges, edgeTypeDefsMap) {
|
|
1282
|
-
if (!
|
|
1228
|
+
if (!edgeTypeDefsMap?.size) return edges;
|
|
1283
1229
|
return edges.map((edge) => {
|
|
1284
|
-
var _a;
|
|
1285
1230
|
const slug = edge.edgeTypeSlug;
|
|
1286
1231
|
if (!slug) return edge;
|
|
1287
1232
|
const def = edgeTypeDefsMap.get(slug);
|
|
1288
1233
|
if (!def) return edge;
|
|
1289
|
-
const styled =
|
|
1234
|
+
const styled = { ...edge };
|
|
1290
1235
|
if (!styled.type && def.lineStyle) {
|
|
1291
|
-
styled.type =
|
|
1236
|
+
styled.type = EDGE_TYPE_MAP[def.lineStyle] ?? "default";
|
|
1292
1237
|
}
|
|
1293
|
-
styled.style =
|
|
1238
|
+
styled.style = {
|
|
1239
|
+
...def.color ? { stroke: def.color } : void 0,
|
|
1240
|
+
...def.strokeWidth ? { strokeWidth: def.strokeWidth } : void 0,
|
|
1241
|
+
...edge.style
|
|
1242
|
+
};
|
|
1294
1243
|
if (styled.animated == null && def.animated) styled.animated = true;
|
|
1295
1244
|
if (!styled.markerStart) {
|
|
1296
1245
|
const startType = toMarkerType(def.markerStart);
|
|
1297
1246
|
if (startType) {
|
|
1298
|
-
styled.markerStart =
|
|
1299
|
-
type: startType
|
|
1300
|
-
|
|
1247
|
+
styled.markerStart = {
|
|
1248
|
+
type: startType,
|
|
1249
|
+
...def.color ? { color: def.color } : void 0
|
|
1250
|
+
};
|
|
1301
1251
|
}
|
|
1302
1252
|
}
|
|
1303
1253
|
if (!styled.markerEnd) {
|
|
1304
1254
|
const endType = toMarkerType(def.markerEnd);
|
|
1305
1255
|
if (endType) {
|
|
1306
|
-
styled.markerEnd =
|
|
1307
|
-
type: endType
|
|
1308
|
-
|
|
1256
|
+
styled.markerEnd = {
|
|
1257
|
+
type: endType,
|
|
1258
|
+
...def.color ? { color: def.color } : void 0
|
|
1259
|
+
};
|
|
1309
1260
|
}
|
|
1310
1261
|
}
|
|
1311
1262
|
return styled;
|
|
@@ -1380,7 +1331,7 @@ function FocusHandler({
|
|
|
1380
1331
|
if (bw === 0 || bh === 0) return;
|
|
1381
1332
|
const zoomFn = mode === "cover" ? Math.max : Math.min;
|
|
1382
1333
|
const zoom = zoomFn(containerSize.w / bw, containerSize.h / bh);
|
|
1383
|
-
const centerTarget = clampBounds
|
|
1334
|
+
const centerTarget = clampBounds ?? b;
|
|
1384
1335
|
const cx = centerTarget.x + centerTarget.width / 2;
|
|
1385
1336
|
const cy = centerTarget.y + centerTarget.height / 2;
|
|
1386
1337
|
const x = containerSize.w / 2 - cx * zoom;
|
|
@@ -1390,9 +1341,9 @@ function FocusHandler({
|
|
|
1390
1341
|
containerSize.w / clampBounds.width,
|
|
1391
1342
|
containerSize.h / clampBounds.height
|
|
1392
1343
|
);
|
|
1393
|
-
store.getState().setMinZoom(Math.max(Math.min(coverZoom, zoom), minZoomProp
|
|
1344
|
+
store.getState().setMinZoom(Math.max(Math.min(coverZoom, zoom), minZoomProp ?? 0));
|
|
1394
1345
|
} else {
|
|
1395
|
-
store.getState().setMinZoom(minZoomProp
|
|
1346
|
+
store.getState().setMinZoom(minZoomProp ?? 0.5);
|
|
1396
1347
|
}
|
|
1397
1348
|
let vp = { x, y, zoom };
|
|
1398
1349
|
if (isInitial || isBoundsChange) {
|
|
@@ -1400,12 +1351,12 @@ function FocusHandler({
|
|
|
1400
1351
|
if (extent) {
|
|
1401
1352
|
const visW = containerSize.w / zoom;
|
|
1402
1353
|
const visH = containerSize.h / zoom;
|
|
1403
|
-
onInitialFit
|
|
1354
|
+
onInitialFit?.([
|
|
1404
1355
|
[Math.min(extent[0][0], cx - visW / 2), Math.min(extent[0][1], cy - visH / 2)],
|
|
1405
1356
|
[Math.max(extent[1][0], cx + visW / 2), Math.max(extent[1][1], cy + visH / 2)]
|
|
1406
1357
|
]);
|
|
1407
1358
|
} else {
|
|
1408
|
-
onInitialFit
|
|
1359
|
+
onInitialFit?.();
|
|
1409
1360
|
}
|
|
1410
1361
|
} else {
|
|
1411
1362
|
if (extent) {
|
|
@@ -1481,14 +1432,13 @@ function FlowRenderer({
|
|
|
1481
1432
|
minZoom: minZoomProp,
|
|
1482
1433
|
maxZoom: maxZoomProp
|
|
1483
1434
|
}) {
|
|
1484
|
-
var _a, _b;
|
|
1485
1435
|
const resolvedFrameRenderer = hideFrames ? NullFrameRenderer : frameRenderer;
|
|
1486
1436
|
const nodeTypeDefsMap = React6.useMemo(() => {
|
|
1487
|
-
if (!
|
|
1437
|
+
if (!nodeTypeDefs?.length) return void 0;
|
|
1488
1438
|
return new Map(nodeTypeDefs.map((d) => [d.slug, d]));
|
|
1489
1439
|
}, [nodeTypeDefs]);
|
|
1490
1440
|
const edgeTypeDefsMap = React6.useMemo(() => {
|
|
1491
|
-
if (!
|
|
1441
|
+
if (!edgeTypeDefs?.length) return void 0;
|
|
1492
1442
|
return new Map(edgeTypeDefs.map((d) => [d.slug, d]));
|
|
1493
1443
|
}, [edgeTypeDefs]);
|
|
1494
1444
|
const nodeTypes = React6.useMemo(
|
|
@@ -1506,28 +1456,27 @@ function FlowRenderer({
|
|
|
1506
1456
|
[edgeRenderers, edgeTypeDefsMap]
|
|
1507
1457
|
);
|
|
1508
1458
|
const mergedCSS = React6.useMemo(() => {
|
|
1509
|
-
if (!
|
|
1459
|
+
if (!nodeTypeDefs?.length) return "";
|
|
1510
1460
|
return nodeTypeDefs.filter((d) => d.customCSS).map((d) => sanitizeCSS(d.customCSS, `flow-node--${d.slug}`)).join("\n");
|
|
1511
1461
|
}, [nodeTypeDefs]);
|
|
1512
1462
|
const styledEdges = React6.useMemo(() => {
|
|
1513
|
-
|
|
1514
|
-
let edges = applyEdgeStyles((_a2 = data == null ? void 0 : data.edges) != null ? _a2 : [], edgeTypeDefsMap);
|
|
1463
|
+
let edges = applyEdgeStyles(data?.edges ?? [], edgeTypeDefsMap);
|
|
1515
1464
|
if (edgeRenderers) {
|
|
1516
1465
|
edges = edges.map((edge) => {
|
|
1517
1466
|
const slug = edge.edgeTypeSlug;
|
|
1518
1467
|
if (slug && edgeRenderers[slug]) {
|
|
1519
|
-
return
|
|
1468
|
+
return { ...edge, type: slug };
|
|
1520
1469
|
}
|
|
1521
1470
|
return edge;
|
|
1522
1471
|
});
|
|
1523
1472
|
}
|
|
1524
1473
|
return edges;
|
|
1525
|
-
}, [data
|
|
1474
|
+
}, [data?.edges, edgeTypeDefsMap, edgeRenderers]);
|
|
1526
1475
|
const translateExtent = React6.useMemo(() => {
|
|
1527
1476
|
if (translateExtentProp) return translateExtentProp;
|
|
1528
|
-
const es = clampBounds
|
|
1477
|
+
const es = clampBounds ?? bounds;
|
|
1529
1478
|
if (!es) return void 0;
|
|
1530
|
-
const ep = clampBounds ? 0 : focusPadding
|
|
1479
|
+
const ep = clampBounds ? 0 : focusPadding ?? 0.1;
|
|
1531
1480
|
return [
|
|
1532
1481
|
[es.x - ep * es.width, es.y - ep * es.height],
|
|
1533
1482
|
[es.x + es.width * (1 + ep), es.y + es.height * (1 + ep)]
|
|
@@ -1551,23 +1500,24 @@ function FlowRenderer({
|
|
|
1551
1500
|
},
|
|
1552
1501
|
[]
|
|
1553
1502
|
);
|
|
1554
|
-
const activeExtent = !bounds || extentReadyRef.current ?
|
|
1503
|
+
const activeExtent = !bounds || extentReadyRef.current ? expandedExtentRef.current ?? translateExtent : void 0;
|
|
1555
1504
|
if (!data) return null;
|
|
1556
|
-
const resolvedDefaultViewport = defaultViewportProp
|
|
1505
|
+
const resolvedDefaultViewport = defaultViewportProp ?? (!fitView && data.viewport ? data.viewport : void 0);
|
|
1557
1506
|
return /* @__PURE__ */ React6.createElement(ReactFlowProvider, null, /* @__PURE__ */ React6.createElement(
|
|
1558
1507
|
"div",
|
|
1559
1508
|
{
|
|
1560
1509
|
className,
|
|
1561
|
-
style:
|
|
1510
|
+
style: {
|
|
1562
1511
|
width: "100%",
|
|
1563
1512
|
height: "100%",
|
|
1564
|
-
background: "transparent"
|
|
1565
|
-
|
|
1513
|
+
background: "transparent",
|
|
1514
|
+
...style
|
|
1515
|
+
}
|
|
1566
1516
|
},
|
|
1567
1517
|
/* @__PURE__ */ React6.createElement(
|
|
1568
1518
|
ReactFlow,
|
|
1569
1519
|
{
|
|
1570
|
-
nodes:
|
|
1520
|
+
nodes: data.nodes ?? [],
|
|
1571
1521
|
edges: styledEdges,
|
|
1572
1522
|
nodeTypes,
|
|
1573
1523
|
edgeTypes: customEdgeTypes,
|
|
@@ -1607,10 +1557,10 @@ function FlowRenderer({
|
|
|
1607
1557
|
FocusHandler,
|
|
1608
1558
|
{
|
|
1609
1559
|
bounds,
|
|
1610
|
-
padding: focusPadding
|
|
1611
|
-
animation: focusAnimation
|
|
1560
|
+
padding: focusPadding ?? 0.1,
|
|
1561
|
+
animation: focusAnimation ?? true,
|
|
1612
1562
|
mode: focusMode,
|
|
1613
|
-
responsive: responsiveFit
|
|
1563
|
+
responsive: responsiveFit ?? true,
|
|
1614
1564
|
extent: translateExtent,
|
|
1615
1565
|
clampBounds,
|
|
1616
1566
|
minZoomProp,
|
|
@@ -1624,24 +1574,16 @@ function FlowRenderer({
|
|
|
1624
1574
|
|
|
1625
1575
|
// src/ui/Flow/FlowFrame.tsx
|
|
1626
1576
|
import React7, { useMemo as useMemo3, useEffect, useRef as useRef2 } from "react";
|
|
1627
|
-
function FlowFrame(
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
"client",
|
|
1638
|
-
"slug",
|
|
1639
|
-
"id",
|
|
1640
|
-
"frameId",
|
|
1641
|
-
"loading",
|
|
1642
|
-
"error",
|
|
1643
|
-
"onDataReady"
|
|
1644
|
-
]);
|
|
1577
|
+
function FlowFrame({
|
|
1578
|
+
client,
|
|
1579
|
+
slug,
|
|
1580
|
+
id,
|
|
1581
|
+
frameId,
|
|
1582
|
+
loading = null,
|
|
1583
|
+
error: renderError,
|
|
1584
|
+
onDataReady,
|
|
1585
|
+
...rendererProps
|
|
1586
|
+
}) {
|
|
1645
1587
|
const { data, nodeTypeDefs, edgeTypeDefs, flow, isLoading, error } = useFlow({
|
|
1646
1588
|
client,
|
|
1647
1589
|
slug,
|
|
@@ -1654,9 +1596,8 @@ function FlowFrame(_a) {
|
|
|
1654
1596
|
const onDataReadyRef = useRef2(onDataReady);
|
|
1655
1597
|
onDataReadyRef.current = onDataReady;
|
|
1656
1598
|
useEffect(() => {
|
|
1657
|
-
var _a2;
|
|
1658
1599
|
if (frameData && flow) {
|
|
1659
|
-
|
|
1600
|
+
onDataReadyRef.current?.(frameData, flow);
|
|
1660
1601
|
}
|
|
1661
1602
|
}, [frameData, flow]);
|
|
1662
1603
|
if (process.env.NODE_ENV !== "production" && !slug && !id) {
|
|
@@ -1675,14 +1616,15 @@ function FlowFrame(_a) {
|
|
|
1675
1616
|
}
|
|
1676
1617
|
return /* @__PURE__ */ React7.createElement(
|
|
1677
1618
|
FlowRenderer,
|
|
1678
|
-
|
|
1619
|
+
{
|
|
1620
|
+
...rendererProps,
|
|
1679
1621
|
data: frameData.data,
|
|
1680
1622
|
nodeTypeDefs,
|
|
1681
1623
|
edgeTypeDefs,
|
|
1682
1624
|
bounds: frameData.fitBounds,
|
|
1683
1625
|
clampBounds: frameData.clampBounds,
|
|
1684
1626
|
hideFrames: true
|
|
1685
|
-
}
|
|
1627
|
+
}
|
|
1686
1628
|
);
|
|
1687
1629
|
}
|
|
1688
1630
|
export {
|