@01.software/sdk 0.5.4 → 0.5.6
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.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +22 -47
- package/dist/auth.js.map +1 -1
- package/dist/{const-JbuUTzeh.d.ts → const-Blyfn0_b.d.ts} +1 -1
- package/dist/{const-C9I6r5Wa.d.cts → const-DbDP4kYA.d.cts} +1 -1
- package/dist/index.cjs +922 -1069
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +922 -1072
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-D8fN_vZR.d.cts → payload-types-B98DjTLi.d.cts} +220 -66
- package/dist/{payload-types-D8fN_vZR.d.ts → payload-types-B98DjTLi.d.ts} +220 -66
- package/dist/realtime.cjs +75 -101
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- 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.d.cts +1 -1
- package/dist/ui/form.d.ts +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.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/ui/video.js +32 -52
- package/dist/ui/video.js.map +1 -1
- package/dist/{webhook-Dbx-pRib.d.cts → webhook-D8HqaKUG.d.cts} +2 -2
- package/dist/{webhook-BkwMrrL1.d.ts → webhook-DdVG08Bs.d.ts} +2 -2
- package/dist/webhook.cjs +48 -73
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/dist/webhook.js +48 -74
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/flow.cjs
CHANGED
|
@@ -2,39 +2,10 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defProps = Object.defineProperties;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
11
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
-
var __spreadValues = (a, b) => {
|
|
15
|
-
for (var prop in b || (b = {}))
|
|
16
|
-
if (__hasOwnProp.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
if (__getOwnPropSymbols)
|
|
19
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
-
if (__propIsEnum.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
};
|
|
25
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
-
var __objRest = (source, exclude) => {
|
|
27
|
-
var target = {};
|
|
28
|
-
for (var prop in source)
|
|
29
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
if (source != null && __getOwnPropSymbols)
|
|
32
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
-
target[prop] = source[prop];
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
};
|
|
38
9
|
var __export = (target, all) => {
|
|
39
10
|
for (var name in all)
|
|
40
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -56,26 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
56
27
|
mod
|
|
57
28
|
));
|
|
58
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
59
|
-
var __async = (__this, __arguments, generator) => {
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
var fulfilled = (value) => {
|
|
62
|
-
try {
|
|
63
|
-
step(generator.next(value));
|
|
64
|
-
} catch (e) {
|
|
65
|
-
reject(e);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var rejected = (value) => {
|
|
69
|
-
try {
|
|
70
|
-
step(generator.throw(value));
|
|
71
|
-
} catch (e) {
|
|
72
|
-
reject(e);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
76
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
30
|
|
|
80
31
|
// src/ui/Flow/index.tsx
|
|
81
32
|
var Flow_exports = {};
|
|
@@ -168,133 +119,128 @@ function collectionKeys(collection) {
|
|
|
168
119
|
|
|
169
120
|
// src/ui/Flow/query-options.ts
|
|
170
121
|
function flowQueryOptions(client, slug, id) {
|
|
171
|
-
|
|
172
|
-
const identifier = (_a = id != null ? id : slug) != null ? _a : "";
|
|
122
|
+
const identifier = id ?? slug ?? "";
|
|
173
123
|
return {
|
|
174
124
|
queryKey: collectionKeys("flows").detail(identifier),
|
|
175
|
-
queryFn: () =>
|
|
125
|
+
queryFn: async () => {
|
|
176
126
|
if (id) return client.from("flows").findById(id);
|
|
177
|
-
const result =
|
|
127
|
+
const result = await client.from("flows").find({
|
|
178
128
|
where: { slug: { equals: slug } },
|
|
179
129
|
limit: 1
|
|
180
130
|
});
|
|
181
131
|
const doc = result.docs[0];
|
|
182
132
|
if (!doc) throw new Error(`Flow not found: ${slug}`);
|
|
183
133
|
return doc;
|
|
184
|
-
}
|
|
134
|
+
}
|
|
185
135
|
};
|
|
186
136
|
}
|
|
187
137
|
function nodeTypesQueryOptions(client) {
|
|
188
138
|
return {
|
|
189
139
|
queryKey: collectionKeys("flow-node-types").lists(),
|
|
190
|
-
queryFn: () =>
|
|
191
|
-
const result =
|
|
140
|
+
queryFn: async () => {
|
|
141
|
+
const result = await client.from("flow-node-types").find({ limit: 0 });
|
|
192
142
|
return result.docs;
|
|
193
|
-
}
|
|
143
|
+
}
|
|
194
144
|
};
|
|
195
145
|
}
|
|
196
146
|
function edgeTypesQueryOptions(client) {
|
|
197
147
|
return {
|
|
198
148
|
queryKey: collectionKeys("flow-edge-types").lists(),
|
|
199
|
-
queryFn: () =>
|
|
200
|
-
const result =
|
|
149
|
+
queryFn: async () => {
|
|
150
|
+
const result = await client.from("flow-edge-types").find({ limit: 0 });
|
|
201
151
|
return result.docs;
|
|
202
|
-
}
|
|
152
|
+
}
|
|
203
153
|
};
|
|
204
154
|
}
|
|
205
155
|
|
|
206
156
|
// src/ui/Flow/useFlow.ts
|
|
207
157
|
function toNodeTypeDef(doc) {
|
|
208
|
-
var _a, _b, _c, _d, _e, _f;
|
|
209
158
|
return {
|
|
210
|
-
slug: String(
|
|
211
|
-
name: String(
|
|
212
|
-
color: String(
|
|
213
|
-
defaultSize:
|
|
159
|
+
slug: String(doc.slug ?? ""),
|
|
160
|
+
name: String(doc.title ?? ""),
|
|
161
|
+
color: String(doc.color ?? "#e5e7eb"),
|
|
162
|
+
defaultSize: doc.defaultSize ?? {
|
|
214
163
|
width: 200,
|
|
215
164
|
height: 200
|
|
216
165
|
},
|
|
217
166
|
fields: Array.isArray(doc.fields) ? doc.fields : [],
|
|
218
167
|
transparentBackground: Boolean(doc.transparentBackground),
|
|
219
|
-
template:
|
|
220
|
-
customCSS:
|
|
168
|
+
template: doc.template ?? null,
|
|
169
|
+
customCSS: doc.customCSS ?? null
|
|
221
170
|
};
|
|
222
171
|
}
|
|
223
172
|
function toEdgeTypeDef(doc) {
|
|
224
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
225
173
|
return {
|
|
226
|
-
slug: String(
|
|
227
|
-
name: String(
|
|
228
|
-
color: String(
|
|
229
|
-
strokeWidth:
|
|
230
|
-
animated:
|
|
231
|
-
lineStyle: String(
|
|
232
|
-
markerStart: String(
|
|
233
|
-
markerEnd: String(
|
|
174
|
+
slug: String(doc.slug ?? ""),
|
|
175
|
+
name: String(doc.title ?? ""),
|
|
176
|
+
color: String(doc.color ?? ""),
|
|
177
|
+
strokeWidth: doc.strokeWidth ?? 2,
|
|
178
|
+
animated: doc.animated ?? false,
|
|
179
|
+
lineStyle: String(doc.lineStyle ?? "default"),
|
|
180
|
+
markerStart: String(doc.markerStart ?? "none"),
|
|
181
|
+
markerEnd: String(doc.markerEnd ?? "arrow"),
|
|
234
182
|
fields: Array.isArray(doc.fields) ? doc.fields : []
|
|
235
183
|
};
|
|
236
184
|
}
|
|
237
185
|
function useFlow(options) {
|
|
238
|
-
var _a, _b;
|
|
239
186
|
const { client, slug, id, enabled = true } = options;
|
|
240
187
|
const hasIdentifier = !!(slug || id);
|
|
241
188
|
const flowQuery = (0, import_react_query.useQuery)(
|
|
242
|
-
|
|
189
|
+
{
|
|
190
|
+
...flowQueryOptions(client, slug, id),
|
|
243
191
|
enabled: enabled && hasIdentifier
|
|
244
|
-
}
|
|
192
|
+
},
|
|
245
193
|
client.queryClient
|
|
246
194
|
);
|
|
247
195
|
const nodeTypesQuery = (0, import_react_query.useQuery)(
|
|
248
|
-
|
|
196
|
+
{
|
|
197
|
+
...nodeTypesQueryOptions(client),
|
|
249
198
|
enabled
|
|
250
|
-
}
|
|
199
|
+
},
|
|
251
200
|
client.queryClient
|
|
252
201
|
);
|
|
253
202
|
const edgeTypesQuery = (0, import_react_query.useQuery)(
|
|
254
|
-
|
|
203
|
+
{
|
|
204
|
+
...edgeTypesQueryOptions(client),
|
|
255
205
|
enabled
|
|
256
|
-
}
|
|
206
|
+
},
|
|
257
207
|
client.queryClient
|
|
258
208
|
);
|
|
259
209
|
const nodeTypeDefs = (0, import_react.useMemo)(() => {
|
|
260
|
-
|
|
261
|
-
const apiDefs = ((_a2 = nodeTypesQuery.data) != null ? _a2 : []).map(toNodeTypeDef);
|
|
210
|
+
const apiDefs = (nodeTypesQuery.data ?? []).map(toNodeTypeDef);
|
|
262
211
|
const builtInSlugs = new Set(BUILT_IN_NODE_TYPES.map((t) => t.slug));
|
|
263
212
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
264
213
|
return [...BUILT_IN_NODE_TYPES, ...customDefs];
|
|
265
214
|
}, [nodeTypesQuery.data]);
|
|
266
215
|
const edgeTypeDefs = (0, import_react.useMemo)(() => {
|
|
267
|
-
|
|
268
|
-
const apiDefs = ((_a2 = edgeTypesQuery.data) != null ? _a2 : []).map(toEdgeTypeDef);
|
|
216
|
+
const apiDefs = (edgeTypesQuery.data ?? []).map(toEdgeTypeDef);
|
|
269
217
|
const builtInSlugs = new Set(BUILT_IN_EDGE_TYPES.map((t) => t.slug));
|
|
270
218
|
const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug));
|
|
271
219
|
return [...BUILT_IN_EDGE_TYPES, ...customDefs];
|
|
272
220
|
}, [edgeTypesQuery.data]);
|
|
273
221
|
const flow = flowQuery.data;
|
|
274
|
-
const canvas = flow
|
|
222
|
+
const canvas = flow?.canvas;
|
|
275
223
|
return {
|
|
276
224
|
data: canvas,
|
|
277
225
|
nodeTypeDefs,
|
|
278
226
|
edgeTypeDefs,
|
|
279
227
|
flow,
|
|
280
228
|
isLoading: flowQuery.isLoading || nodeTypesQuery.isLoading || edgeTypesQuery.isLoading,
|
|
281
|
-
error:
|
|
229
|
+
error: flowQuery.error ?? nodeTypesQuery.error ?? edgeTypesQuery.error
|
|
282
230
|
};
|
|
283
231
|
}
|
|
284
232
|
|
|
285
233
|
// src/ui/Flow/prefetchFlow.ts
|
|
286
|
-
function prefetchFlow(options) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
]);
|
|
297
|
-
});
|
|
234
|
+
async function prefetchFlow(options) {
|
|
235
|
+
const { client, slug, id } = options;
|
|
236
|
+
if (!slug && !id) {
|
|
237
|
+
throw new Error("prefetchFlow requires either slug or id");
|
|
238
|
+
}
|
|
239
|
+
await Promise.all([
|
|
240
|
+
client.queryClient.prefetchQuery(flowQueryOptions(client, slug, id)),
|
|
241
|
+
client.queryClient.prefetchQuery(nodeTypesQueryOptions(client)),
|
|
242
|
+
client.queryClient.prefetchQuery(edgeTypesQueryOptions(client))
|
|
243
|
+
]);
|
|
298
244
|
}
|
|
299
245
|
|
|
300
246
|
// src/ui/Flow/useFlowData.ts
|
|
@@ -302,21 +248,15 @@ var import_react2 = require("react");
|
|
|
302
248
|
function useFlowData(options) {
|
|
303
249
|
const { data, nodeTypeDefs: inputNodeDefs, edgeTypeDefs: inputEdgeDefs } = options;
|
|
304
250
|
const nodeTypeDefsMap = (0, import_react2.useMemo)(() => {
|
|
305
|
-
const allDefs = inputNodeDefs
|
|
251
|
+
const allDefs = inputNodeDefs ?? BUILT_IN_NODE_TYPES;
|
|
306
252
|
return new Map(allDefs.map((d) => [d.slug, d]));
|
|
307
253
|
}, [inputNodeDefs]);
|
|
308
254
|
const edgeTypeDefsMap = (0, import_react2.useMemo)(() => {
|
|
309
|
-
const allDefs = inputEdgeDefs
|
|
255
|
+
const allDefs = inputEdgeDefs ?? BUILT_IN_EDGE_TYPES;
|
|
310
256
|
return new Map(allDefs.map((d) => [d.slug, d]));
|
|
311
257
|
}, [inputEdgeDefs]);
|
|
312
|
-
const nodes = (0, import_react2.useMemo)(() =>
|
|
313
|
-
|
|
314
|
-
return (_a = data == null ? void 0 : data.nodes) != null ? _a : [];
|
|
315
|
-
}, [data == null ? void 0 : data.nodes]);
|
|
316
|
-
const edges = (0, import_react2.useMemo)(() => {
|
|
317
|
-
var _a;
|
|
318
|
-
return (_a = data == null ? void 0 : data.edges) != null ? _a : [];
|
|
319
|
-
}, [data == null ? void 0 : data.edges]);
|
|
258
|
+
const nodes = (0, import_react2.useMemo)(() => data?.nodes ?? [], [data?.nodes]);
|
|
259
|
+
const edges = (0, import_react2.useMemo)(() => data?.edges ?? [], [data?.edges]);
|
|
320
260
|
return {
|
|
321
261
|
nodes,
|
|
322
262
|
edges,
|
|
@@ -327,10 +267,9 @@ function useFlowData(options) {
|
|
|
327
267
|
|
|
328
268
|
// src/ui/Flow/utils.ts
|
|
329
269
|
function getNodeSize(node) {
|
|
330
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
331
270
|
return {
|
|
332
|
-
width:
|
|
333
|
-
height:
|
|
271
|
+
width: node.style?.width ?? node.measured?.width ?? node.width ?? 200,
|
|
272
|
+
height: node.style?.height ?? node.measured?.height ?? node.height ?? 200
|
|
334
273
|
};
|
|
335
274
|
}
|
|
336
275
|
function getAbsolutePosition(node, nodeMap) {
|
|
@@ -402,13 +341,12 @@ function getFrames(nodes) {
|
|
|
402
341
|
if (frames.length === 0) return [];
|
|
403
342
|
const nodeMap = new Map(nodes.map((n) => [n.id, n]));
|
|
404
343
|
return frames.map((f) => {
|
|
405
|
-
var _a;
|
|
406
344
|
const data = f.data;
|
|
407
345
|
const abs = getAbsolutePosition(f, nodeMap);
|
|
408
346
|
const { width: w, height: h } = getNodeSize(f);
|
|
409
347
|
return {
|
|
410
348
|
id: f.id,
|
|
411
|
-
label:
|
|
349
|
+
label: data.label ?? "",
|
|
412
350
|
bounds: { x: abs.x, y: abs.y, width: w, height: h }
|
|
413
351
|
};
|
|
414
352
|
}).sort((a, b) => a.bounds.y - b.bounds.y || a.bounds.x - b.bounds.x);
|
|
@@ -417,13 +355,13 @@ function getFrameData(data, frameId) {
|
|
|
417
355
|
const frame = data.nodes.find((n) => n.id === frameId);
|
|
418
356
|
if (!frame || frame.type !== "frame") return void 0;
|
|
419
357
|
const descendantIds = collectDescendants(data.nodes, frameId);
|
|
420
|
-
const childNodes = data.nodes.filter((n) => descendantIds.has(n.id)).map((n) =>
|
|
358
|
+
const childNodes = data.nodes.filter((n) => descendantIds.has(n.id)).map((n) => ({ ...n, draggable: false }));
|
|
421
359
|
const childEdges = data.edges.filter(
|
|
422
360
|
(e) => descendantIds.has(e.source) && descendantIds.has(e.target)
|
|
423
361
|
);
|
|
424
362
|
const frameBounds = getNodeBounds(data.nodes, [frameId]);
|
|
425
363
|
const { width: w, height: h } = getNodeSize(frame);
|
|
426
|
-
const clampBounds = frameBounds
|
|
364
|
+
const clampBounds = frameBounds ?? {
|
|
427
365
|
x: frame.position.x,
|
|
428
366
|
y: frame.position.y,
|
|
429
367
|
width: w,
|
|
@@ -431,7 +369,7 @@ function getFrameData(data, frameId) {
|
|
|
431
369
|
};
|
|
432
370
|
const contentNodeIds = childNodes.filter((n) => n.id !== frameId).map((n) => n.id);
|
|
433
371
|
const contentBounds = contentNodeIds.length > 0 ? getNodeBounds(data.nodes, contentNodeIds) : void 0;
|
|
434
|
-
const fitBounds = contentBounds
|
|
372
|
+
const fitBounds = contentBounds ?? clampBounds;
|
|
435
373
|
return {
|
|
436
374
|
data: {
|
|
437
375
|
nodes: childNodes,
|
|
@@ -482,6 +420,13 @@ function useQuickJS() {
|
|
|
482
420
|
// src/ui/Flow/template-compiler.ts
|
|
483
421
|
var MAX_CACHE_SIZE = 100;
|
|
484
422
|
var MAX_MATERIALIZE_DEPTH = 20;
|
|
423
|
+
var IFRAME_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
424
|
+
"srcdoc",
|
|
425
|
+
"allow",
|
|
426
|
+
"allowpaymentrequest",
|
|
427
|
+
"name",
|
|
428
|
+
"sandbox"
|
|
429
|
+
]);
|
|
485
430
|
var ALLOWED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
486
431
|
"div",
|
|
487
432
|
"span",
|
|
@@ -515,7 +460,8 @@ var ALLOWED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
515
460
|
"path",
|
|
516
461
|
"g",
|
|
517
462
|
"circle",
|
|
518
|
-
"rect"
|
|
463
|
+
"rect",
|
|
464
|
+
"iframe"
|
|
519
465
|
]);
|
|
520
466
|
var BLOCKED_PATTERNS = [
|
|
521
467
|
/\bdocument\s*\./,
|
|
@@ -595,7 +541,7 @@ function isSafeUrl(value) {
|
|
|
595
541
|
try {
|
|
596
542
|
const url = new URL(value);
|
|
597
543
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
598
|
-
} catch
|
|
544
|
+
} catch {
|
|
599
545
|
return false;
|
|
600
546
|
}
|
|
601
547
|
}
|
|
@@ -627,7 +573,6 @@ function sanitizeStyle(style) {
|
|
|
627
573
|
return safe;
|
|
628
574
|
}
|
|
629
575
|
function materialize(node, depth = 0) {
|
|
630
|
-
var _a;
|
|
631
576
|
if (depth > MAX_MATERIALIZE_DEPTH) return null;
|
|
632
577
|
if (node == null) return null;
|
|
633
578
|
if (typeof node === "string" || typeof node === "number") return node;
|
|
@@ -649,7 +594,7 @@ function materialize(node, depth = 0) {
|
|
|
649
594
|
);
|
|
650
595
|
}
|
|
651
596
|
if (d.$$t === "el") {
|
|
652
|
-
const type = String(
|
|
597
|
+
const type = String(d.type ?? "");
|
|
653
598
|
const props = d.props && typeof d.props === "object" ? d.props : {};
|
|
654
599
|
const ch = Array.isArray(d.ch) ? d.ch : [];
|
|
655
600
|
if (!ALLOWED_ELEMENTS.has(type.toLowerCase())) return null;
|
|
@@ -657,6 +602,7 @@ function materialize(node, depth = 0) {
|
|
|
657
602
|
for (const [k, v] of Object.entries(props)) {
|
|
658
603
|
if (k.startsWith("on")) continue;
|
|
659
604
|
if (k === "dangerouslySetInnerHTML" || k === "ref") continue;
|
|
605
|
+
if (type === "iframe" && IFRAME_BLOCKED_PROPS.has(k)) continue;
|
|
660
606
|
if ((k === "src" || k === "href") && !isSafeUrl(v)) continue;
|
|
661
607
|
if (k === "style") {
|
|
662
608
|
safeProps[k] = sanitizeStyle(v);
|
|
@@ -664,6 +610,9 @@ function materialize(node, depth = 0) {
|
|
|
664
610
|
}
|
|
665
611
|
safeProps[k] = v;
|
|
666
612
|
}
|
|
613
|
+
if (type === "iframe") {
|
|
614
|
+
safeProps["sandbox"] = "allow-scripts allow-same-origin";
|
|
615
|
+
}
|
|
667
616
|
const children = ch.map((c) => materialize(c, depth + 1));
|
|
668
617
|
return import_react4.default.createElement(type, safeProps, ...children);
|
|
669
618
|
}
|
|
@@ -697,7 +646,7 @@ function makeRenderer(jsCode) {
|
|
|
697
646
|
const raw = vm.dump(callResult.handle);
|
|
698
647
|
callResult.handle.dispose();
|
|
699
648
|
return materialize(JSON.parse(String(raw)));
|
|
700
|
-
} catch
|
|
649
|
+
} catch {
|
|
701
650
|
return null;
|
|
702
651
|
} finally {
|
|
703
652
|
vm.dispose();
|
|
@@ -706,8 +655,7 @@ function makeRenderer(jsCode) {
|
|
|
706
655
|
}
|
|
707
656
|
function makeReactFC(renderer, qjs) {
|
|
708
657
|
return function QuickJSTemplateComponent(props) {
|
|
709
|
-
|
|
710
|
-
return (_a = renderer(qjs, props)) != null ? _a : null;
|
|
658
|
+
return renderer(qjs, props) ?? null;
|
|
711
659
|
};
|
|
712
660
|
}
|
|
713
661
|
function compileTemplate(code, slug) {
|
|
@@ -731,7 +679,7 @@ function compileTemplate(code, slug) {
|
|
|
731
679
|
jsxFragmentPragma: "React.Fragment"
|
|
732
680
|
});
|
|
733
681
|
jsCode = result.code;
|
|
734
|
-
} catch
|
|
682
|
+
} catch {
|
|
735
683
|
return null;
|
|
736
684
|
}
|
|
737
685
|
const renderer = makeRenderer(jsCode);
|
|
@@ -755,15 +703,15 @@ function sanitizeUrl(url) {
|
|
|
755
703
|
const parsed = new URL(url);
|
|
756
704
|
if (parsed.protocol === "http:" || parsed.protocol === "https:") return url;
|
|
757
705
|
return void 0;
|
|
758
|
-
} catch
|
|
706
|
+
} catch {
|
|
759
707
|
return void 0;
|
|
760
708
|
}
|
|
761
709
|
}
|
|
762
710
|
function renderFieldValue(key, val, fieldDef) {
|
|
763
711
|
if (val == null || val === "") return null;
|
|
764
|
-
const fieldType = fieldDef
|
|
712
|
+
const fieldType = fieldDef?.fieldType;
|
|
765
713
|
if (fieldType === "image" || typeof val === "object" && val !== null && "url" in val) {
|
|
766
|
-
const imgUrl = typeof val === "string" ? val : val
|
|
714
|
+
const imgUrl = typeof val === "string" ? val : val?.url;
|
|
767
715
|
const safeUrl = sanitizeUrl(imgUrl);
|
|
768
716
|
if (!safeUrl) return null;
|
|
769
717
|
return /* @__PURE__ */ import_react5.default.createElement(
|
|
@@ -876,12 +824,11 @@ function EnhancedDynamicNode({
|
|
|
876
824
|
);
|
|
877
825
|
}
|
|
878
826
|
function DefaultFrameNode({ data }) {
|
|
879
|
-
var _a, _b, _c, _d;
|
|
880
827
|
const d = data;
|
|
881
|
-
const baseColor =
|
|
882
|
-
const padding =
|
|
883
|
-
const borderStyle =
|
|
884
|
-
const opacity =
|
|
828
|
+
const baseColor = d.color ?? "rgb(128,128,128)";
|
|
829
|
+
const padding = d.padding ?? 20;
|
|
830
|
+
const borderStyle = d.borderStyle ?? "dashed";
|
|
831
|
+
const opacity = d.opacity ?? 0.15;
|
|
885
832
|
const bgColor = (() => {
|
|
886
833
|
const m = baseColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
887
834
|
if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`;
|
|
@@ -915,21 +862,21 @@ function DefaultFrameNode({ data }) {
|
|
|
915
862
|
|
|
916
863
|
// src/ui/Flow/field-helpers.ts
|
|
917
864
|
function getImageField(fields, name) {
|
|
918
|
-
const val = fields
|
|
865
|
+
const val = fields?.[name];
|
|
919
866
|
if (val && typeof val === "object" && val !== null && "url" in val)
|
|
920
867
|
return val;
|
|
921
868
|
return void 0;
|
|
922
869
|
}
|
|
923
870
|
function getTextField(fields, name) {
|
|
924
|
-
const val = fields
|
|
871
|
+
const val = fields?.[name];
|
|
925
872
|
return typeof val === "string" ? val : void 0;
|
|
926
873
|
}
|
|
927
874
|
function getNumberField(fields, name) {
|
|
928
|
-
const val = fields
|
|
875
|
+
const val = fields?.[name];
|
|
929
876
|
return typeof val === "number" ? val : void 0;
|
|
930
877
|
}
|
|
931
878
|
function getBooleanField(fields, name) {
|
|
932
|
-
const val = fields
|
|
879
|
+
const val = fields?.[name];
|
|
933
880
|
return typeof val === "boolean" ? val : void 0;
|
|
934
881
|
}
|
|
935
882
|
|
|
@@ -947,7 +894,7 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
947
894
|
let root;
|
|
948
895
|
try {
|
|
949
896
|
root = import_postcss.default.parse(css);
|
|
950
|
-
} catch
|
|
897
|
+
} catch {
|
|
951
898
|
return "";
|
|
952
899
|
}
|
|
953
900
|
const safeScopeClass = scopeClass ? scopeClass.replace(/[{}()[\];,'"\\<>\s]/g, "") : "";
|
|
@@ -964,9 +911,8 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
964
911
|
if (safeScopeClass && keyframeNameMap.size > 0) {
|
|
965
912
|
const ANIM_KEYWORDS = /* @__PURE__ */ new Set(["none", "initial", "inherit", "unset", "revert"]);
|
|
966
913
|
const replaceAnimName = (token) => {
|
|
967
|
-
var _a;
|
|
968
914
|
const t = token.trim().replace(/^['"]|['"]$/g, "");
|
|
969
|
-
return ANIM_KEYWORDS.has(t) ? token :
|
|
915
|
+
return ANIM_KEYWORDS.has(t) ? token : keyframeNameMap.get(t) ?? token;
|
|
970
916
|
};
|
|
971
917
|
root.walkDecls(/^animation-name$/i, (node) => {
|
|
972
918
|
node.value = node.value.split(",").map(replaceAnimName).join(", ");
|
|
@@ -1024,7 +970,7 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
1024
970
|
return;
|
|
1025
971
|
}
|
|
1026
972
|
const parent = rule.parent;
|
|
1027
|
-
if (
|
|
973
|
+
if (parent?.type === "atrule" && parent.name.toLowerCase() === "keyframes") {
|
|
1028
974
|
return;
|
|
1029
975
|
}
|
|
1030
976
|
rule.selectors = rule.selectors.map((sel) => `.${safeScopeClass} ${sel}`);
|
|
@@ -1051,7 +997,7 @@ function getImageSrcSet(image) {
|
|
|
1051
997
|
if (sizes) {
|
|
1052
998
|
for (const size of IMAGE_SIZES) {
|
|
1053
999
|
const entry = sizes[String(size)];
|
|
1054
|
-
if (
|
|
1000
|
+
if (entry?.url && entry.width) {
|
|
1055
1001
|
parts.push(`${entry.url} ${entry.width}w`);
|
|
1056
1002
|
}
|
|
1057
1003
|
}
|
|
@@ -1062,11 +1008,10 @@ function getImageSrcSet(image) {
|
|
|
1062
1008
|
return parts.join(", ");
|
|
1063
1009
|
}
|
|
1064
1010
|
function getImagePlaceholderStyle(image, options) {
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
const paletteColor = (_b = options == null ? void 0 : options.paletteColor) != null ? _b : "muted";
|
|
1011
|
+
const type = options?.type ?? "blur";
|
|
1012
|
+
const paletteColor = options?.paletteColor ?? "muted";
|
|
1068
1013
|
if (type === "none") return {};
|
|
1069
|
-
const color =
|
|
1014
|
+
const color = image.palette?.[paletteColor];
|
|
1070
1015
|
if (type === "blur") {
|
|
1071
1016
|
const lqip = image.lqip;
|
|
1072
1017
|
if (lqip) {
|
|
@@ -1105,15 +1050,14 @@ function Image({
|
|
|
1105
1050
|
fill = false,
|
|
1106
1051
|
imageRendering
|
|
1107
1052
|
}) {
|
|
1108
|
-
var _a, _b;
|
|
1109
1053
|
const [loaded, setLoaded] = (0, import_react6.useState)(false);
|
|
1110
1054
|
const firedRef = (0, import_react6.useRef)(false);
|
|
1111
1055
|
const isPixelRendering = imageRendering === "pixelated" || imageRendering === "crisp-edges";
|
|
1112
|
-
const placeholder = placeholderProp
|
|
1113
|
-
const loading = priority ? "eager" : loadingProp
|
|
1056
|
+
const placeholder = placeholderProp ?? (isPixelRendering ? "none" : "blur");
|
|
1057
|
+
const loading = priority ? "eager" : loadingProp ?? "lazy";
|
|
1114
1058
|
const aspectRatio = !fill && image.width && image.height ? `${image.width} / ${image.height}` : void 0;
|
|
1115
1059
|
const srcSet = getImageSrcSet(image);
|
|
1116
|
-
const src =
|
|
1060
|
+
const src = image.url ?? void 0;
|
|
1117
1061
|
const hasLqip = placeholder === "blur" && !!image.lqip;
|
|
1118
1062
|
const placeholderStyle = getImagePlaceholderStyle(image, {
|
|
1119
1063
|
type: placeholder
|
|
@@ -1123,7 +1067,7 @@ function Image({
|
|
|
1123
1067
|
if (firedRef.current) return;
|
|
1124
1068
|
firedRef.current = true;
|
|
1125
1069
|
setLoaded(true);
|
|
1126
|
-
onLoad
|
|
1070
|
+
onLoad?.();
|
|
1127
1071
|
}, [onLoad]);
|
|
1128
1072
|
const imgRef = (0, import_react6.useCallback)(
|
|
1129
1073
|
(node) => {
|
|
@@ -1133,10 +1077,13 @@ function Image({
|
|
|
1133
1077
|
},
|
|
1134
1078
|
[fireLoad]
|
|
1135
1079
|
);
|
|
1136
|
-
const containerStyle =
|
|
1080
|
+
const containerStyle = {
|
|
1137
1081
|
position: "relative",
|
|
1138
|
-
overflow: "hidden"
|
|
1139
|
-
|
|
1082
|
+
overflow: "hidden",
|
|
1083
|
+
...fill ? { width: "100%", height: "100%" } : {},
|
|
1084
|
+
...aspectRatio ? { aspectRatio } : {},
|
|
1085
|
+
...style
|
|
1086
|
+
};
|
|
1140
1087
|
const overlayBase = {
|
|
1141
1088
|
position: "absolute",
|
|
1142
1089
|
top: 0,
|
|
@@ -1147,41 +1094,44 @@ function Image({
|
|
|
1147
1094
|
transition: "opacity 0.3s ease",
|
|
1148
1095
|
pointerEvents: "none"
|
|
1149
1096
|
};
|
|
1150
|
-
const mainImgStyle =
|
|
1097
|
+
const mainImgStyle = {
|
|
1151
1098
|
display: "block",
|
|
1152
1099
|
width: "100%",
|
|
1153
1100
|
height: "100%",
|
|
1154
|
-
objectFit
|
|
1155
|
-
|
|
1101
|
+
objectFit,
|
|
1102
|
+
...imageRendering ? { imageRendering } : {},
|
|
1156
1103
|
opacity: loaded ? 1 : 0,
|
|
1157
|
-
transition: "opacity 0.3s ease"
|
|
1158
|
-
|
|
1104
|
+
transition: "opacity 0.3s ease",
|
|
1105
|
+
...imgStyle
|
|
1106
|
+
};
|
|
1159
1107
|
return /* @__PURE__ */ import_react6.default.createElement("div", { className, style: containerStyle }, hasLqip && /* @__PURE__ */ import_react6.default.createElement(
|
|
1160
1108
|
"img",
|
|
1161
1109
|
{
|
|
1162
1110
|
"aria-hidden": true,
|
|
1163
1111
|
alt: "",
|
|
1164
1112
|
src: image.lqip,
|
|
1165
|
-
style:
|
|
1113
|
+
style: {
|
|
1114
|
+
...overlayBase,
|
|
1166
1115
|
display: "block",
|
|
1167
1116
|
objectFit,
|
|
1168
1117
|
filter: "blur(20px)",
|
|
1169
1118
|
transform: "scale(1.1)"
|
|
1170
|
-
}
|
|
1119
|
+
}
|
|
1171
1120
|
}
|
|
1172
1121
|
), placeholderColor && /* @__PURE__ */ import_react6.default.createElement(
|
|
1173
1122
|
"div",
|
|
1174
1123
|
{
|
|
1175
1124
|
"aria-hidden": true,
|
|
1176
|
-
style:
|
|
1125
|
+
style: {
|
|
1126
|
+
...overlayBase,
|
|
1177
1127
|
backgroundColor: placeholderColor
|
|
1178
|
-
}
|
|
1128
|
+
}
|
|
1179
1129
|
}
|
|
1180
1130
|
), /* @__PURE__ */ import_react6.default.createElement(
|
|
1181
1131
|
"img",
|
|
1182
1132
|
{
|
|
1183
1133
|
ref: imgRef,
|
|
1184
|
-
alt:
|
|
1134
|
+
alt: image.alt ?? "",
|
|
1185
1135
|
src,
|
|
1186
1136
|
srcSet: srcSet || void 0,
|
|
1187
1137
|
sizes,
|
|
@@ -1200,10 +1150,9 @@ function Image({
|
|
|
1200
1150
|
function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode) {
|
|
1201
1151
|
const types = {};
|
|
1202
1152
|
types.dynamic = ((props) => {
|
|
1203
|
-
var _a;
|
|
1204
1153
|
const d = props.data;
|
|
1205
|
-
const typeDef = nodeTypeDefsMap
|
|
1206
|
-
const CustomRenderer = nodeRenderers
|
|
1154
|
+
const typeDef = nodeTypeDefsMap?.get(d.nodeTypeSlug);
|
|
1155
|
+
const CustomRenderer = nodeRenderers?.[d.nodeTypeSlug];
|
|
1207
1156
|
const defaultRender = typeDef ? /* @__PURE__ */ import_react7.default.createElement(
|
|
1208
1157
|
EnhancedDynamicNode,
|
|
1209
1158
|
{
|
|
@@ -1212,7 +1161,7 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrap
|
|
|
1212
1161
|
width: props.width,
|
|
1213
1162
|
height: props.height
|
|
1214
1163
|
}
|
|
1215
|
-
) : /* @__PURE__ */ import_react7.default.createElement(DefaultDynamicNode,
|
|
1164
|
+
) : /* @__PURE__ */ import_react7.default.createElement(DefaultDynamicNode, { ...props });
|
|
1216
1165
|
const slotProps = {
|
|
1217
1166
|
id: props.id,
|
|
1218
1167
|
nodeTypeSlug: d.nodeTypeSlug,
|
|
@@ -1226,9 +1175,9 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrap
|
|
|
1226
1175
|
};
|
|
1227
1176
|
let content;
|
|
1228
1177
|
if (CustomRenderer) {
|
|
1229
|
-
content = /* @__PURE__ */ import_react7.default.createElement(CustomRenderer,
|
|
1178
|
+
content = /* @__PURE__ */ import_react7.default.createElement(CustomRenderer, { ...slotProps });
|
|
1230
1179
|
} else if (d.nodeTypeSlug === "image") {
|
|
1231
|
-
const imageVal =
|
|
1180
|
+
const imageVal = d.fields?.image;
|
|
1232
1181
|
if (imageVal && typeof imageVal === "object" && "url" in imageVal) {
|
|
1233
1182
|
content = /* @__PURE__ */ import_react7.default.createElement(
|
|
1234
1183
|
Image,
|
|
@@ -1291,8 +1240,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1291
1240
|
const types = {};
|
|
1292
1241
|
for (const [slug, Renderer] of Object.entries(edgeRenderers)) {
|
|
1293
1242
|
types[slug] = ((props) => {
|
|
1294
|
-
|
|
1295
|
-
const def = edgeTypeDefsMap == null ? void 0 : edgeTypeDefsMap.get(slug);
|
|
1243
|
+
const def = edgeTypeDefsMap?.get(slug);
|
|
1296
1244
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1297
1245
|
Renderer,
|
|
1298
1246
|
{
|
|
@@ -1301,7 +1249,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1301
1249
|
source: props.source,
|
|
1302
1250
|
target: props.target,
|
|
1303
1251
|
label: props.label,
|
|
1304
|
-
fields:
|
|
1252
|
+
fields: props.data?.fields,
|
|
1305
1253
|
edgeTypeDef: def,
|
|
1306
1254
|
style: props.style
|
|
1307
1255
|
}
|
|
@@ -1325,33 +1273,38 @@ var EDGE_TYPE_MAP = {
|
|
|
1325
1273
|
default: "default"
|
|
1326
1274
|
};
|
|
1327
1275
|
function applyEdgeStyles(edges, edgeTypeDefsMap) {
|
|
1328
|
-
if (!
|
|
1276
|
+
if (!edgeTypeDefsMap?.size) return edges;
|
|
1329
1277
|
return edges.map((edge) => {
|
|
1330
|
-
var _a;
|
|
1331
1278
|
const slug = edge.edgeTypeSlug;
|
|
1332
1279
|
if (!slug) return edge;
|
|
1333
1280
|
const def = edgeTypeDefsMap.get(slug);
|
|
1334
1281
|
if (!def) return edge;
|
|
1335
|
-
const styled =
|
|
1282
|
+
const styled = { ...edge };
|
|
1336
1283
|
if (!styled.type && def.lineStyle) {
|
|
1337
|
-
styled.type =
|
|
1284
|
+
styled.type = EDGE_TYPE_MAP[def.lineStyle] ?? "default";
|
|
1338
1285
|
}
|
|
1339
|
-
styled.style =
|
|
1286
|
+
styled.style = {
|
|
1287
|
+
...def.color ? { stroke: def.color } : void 0,
|
|
1288
|
+
...def.strokeWidth ? { strokeWidth: def.strokeWidth } : void 0,
|
|
1289
|
+
...edge.style
|
|
1290
|
+
};
|
|
1340
1291
|
if (styled.animated == null && def.animated) styled.animated = true;
|
|
1341
1292
|
if (!styled.markerStart) {
|
|
1342
1293
|
const startType = toMarkerType(def.markerStart);
|
|
1343
1294
|
if (startType) {
|
|
1344
|
-
styled.markerStart =
|
|
1345
|
-
type: startType
|
|
1346
|
-
|
|
1295
|
+
styled.markerStart = {
|
|
1296
|
+
type: startType,
|
|
1297
|
+
...def.color ? { color: def.color } : void 0
|
|
1298
|
+
};
|
|
1347
1299
|
}
|
|
1348
1300
|
}
|
|
1349
1301
|
if (!styled.markerEnd) {
|
|
1350
1302
|
const endType = toMarkerType(def.markerEnd);
|
|
1351
1303
|
if (endType) {
|
|
1352
|
-
styled.markerEnd =
|
|
1353
|
-
type: endType
|
|
1354
|
-
|
|
1304
|
+
styled.markerEnd = {
|
|
1305
|
+
type: endType,
|
|
1306
|
+
...def.color ? { color: def.color } : void 0
|
|
1307
|
+
};
|
|
1355
1308
|
}
|
|
1356
1309
|
}
|
|
1357
1310
|
return styled;
|
|
@@ -1426,7 +1379,7 @@ function FocusHandler({
|
|
|
1426
1379
|
if (bw === 0 || bh === 0) return;
|
|
1427
1380
|
const zoomFn = mode === "cover" ? Math.max : Math.min;
|
|
1428
1381
|
const zoom = zoomFn(containerSize.w / bw, containerSize.h / bh);
|
|
1429
|
-
const centerTarget = clampBounds
|
|
1382
|
+
const centerTarget = clampBounds ?? b;
|
|
1430
1383
|
const cx = centerTarget.x + centerTarget.width / 2;
|
|
1431
1384
|
const cy = centerTarget.y + centerTarget.height / 2;
|
|
1432
1385
|
const x = containerSize.w / 2 - cx * zoom;
|
|
@@ -1436,9 +1389,9 @@ function FocusHandler({
|
|
|
1436
1389
|
containerSize.w / clampBounds.width,
|
|
1437
1390
|
containerSize.h / clampBounds.height
|
|
1438
1391
|
);
|
|
1439
|
-
store.getState().setMinZoom(Math.max(Math.min(coverZoom, zoom), minZoomProp
|
|
1392
|
+
store.getState().setMinZoom(Math.max(Math.min(coverZoom, zoom), minZoomProp ?? 0));
|
|
1440
1393
|
} else {
|
|
1441
|
-
store.getState().setMinZoom(minZoomProp
|
|
1394
|
+
store.getState().setMinZoom(minZoomProp ?? 0.5);
|
|
1442
1395
|
}
|
|
1443
1396
|
let vp = { x, y, zoom };
|
|
1444
1397
|
if (isInitial || isBoundsChange) {
|
|
@@ -1446,12 +1399,12 @@ function FocusHandler({
|
|
|
1446
1399
|
if (extent) {
|
|
1447
1400
|
const visW = containerSize.w / zoom;
|
|
1448
1401
|
const visH = containerSize.h / zoom;
|
|
1449
|
-
onInitialFit
|
|
1402
|
+
onInitialFit?.([
|
|
1450
1403
|
[Math.min(extent[0][0], cx - visW / 2), Math.min(extent[0][1], cy - visH / 2)],
|
|
1451
1404
|
[Math.max(extent[1][0], cx + visW / 2), Math.max(extent[1][1], cy + visH / 2)]
|
|
1452
1405
|
]);
|
|
1453
1406
|
} else {
|
|
1454
|
-
onInitialFit
|
|
1407
|
+
onInitialFit?.();
|
|
1455
1408
|
}
|
|
1456
1409
|
} else {
|
|
1457
1410
|
if (extent) {
|
|
@@ -1527,14 +1480,13 @@ function FlowRenderer({
|
|
|
1527
1480
|
minZoom: minZoomProp,
|
|
1528
1481
|
maxZoom: maxZoomProp
|
|
1529
1482
|
}) {
|
|
1530
|
-
var _a, _b;
|
|
1531
1483
|
const resolvedFrameRenderer = hideFrames ? NullFrameRenderer : frameRenderer;
|
|
1532
1484
|
const nodeTypeDefsMap = import_react11.default.useMemo(() => {
|
|
1533
|
-
if (!
|
|
1485
|
+
if (!nodeTypeDefs?.length) return void 0;
|
|
1534
1486
|
return new Map(nodeTypeDefs.map((d) => [d.slug, d]));
|
|
1535
1487
|
}, [nodeTypeDefs]);
|
|
1536
1488
|
const edgeTypeDefsMap = import_react11.default.useMemo(() => {
|
|
1537
|
-
if (!
|
|
1489
|
+
if (!edgeTypeDefs?.length) return void 0;
|
|
1538
1490
|
return new Map(edgeTypeDefs.map((d) => [d.slug, d]));
|
|
1539
1491
|
}, [edgeTypeDefs]);
|
|
1540
1492
|
const nodeTypes = import_react11.default.useMemo(
|
|
@@ -1552,28 +1504,27 @@ function FlowRenderer({
|
|
|
1552
1504
|
[edgeRenderers, edgeTypeDefsMap]
|
|
1553
1505
|
);
|
|
1554
1506
|
const mergedCSS = import_react11.default.useMemo(() => {
|
|
1555
|
-
if (!
|
|
1507
|
+
if (!nodeTypeDefs?.length) return "";
|
|
1556
1508
|
return nodeTypeDefs.filter((d) => d.customCSS).map((d) => sanitizeCSS(d.customCSS, `flow-node--${d.slug}`)).join("\n");
|
|
1557
1509
|
}, [nodeTypeDefs]);
|
|
1558
1510
|
const styledEdges = import_react11.default.useMemo(() => {
|
|
1559
|
-
|
|
1560
|
-
let edges = applyEdgeStyles((_a2 = data == null ? void 0 : data.edges) != null ? _a2 : [], edgeTypeDefsMap);
|
|
1511
|
+
let edges = applyEdgeStyles(data?.edges ?? [], edgeTypeDefsMap);
|
|
1561
1512
|
if (edgeRenderers) {
|
|
1562
1513
|
edges = edges.map((edge) => {
|
|
1563
1514
|
const slug = edge.edgeTypeSlug;
|
|
1564
1515
|
if (slug && edgeRenderers[slug]) {
|
|
1565
|
-
return
|
|
1516
|
+
return { ...edge, type: slug };
|
|
1566
1517
|
}
|
|
1567
1518
|
return edge;
|
|
1568
1519
|
});
|
|
1569
1520
|
}
|
|
1570
1521
|
return edges;
|
|
1571
|
-
}, [data
|
|
1522
|
+
}, [data?.edges, edgeTypeDefsMap, edgeRenderers]);
|
|
1572
1523
|
const translateExtent = import_react11.default.useMemo(() => {
|
|
1573
1524
|
if (translateExtentProp) return translateExtentProp;
|
|
1574
|
-
const es = clampBounds
|
|
1525
|
+
const es = clampBounds ?? bounds;
|
|
1575
1526
|
if (!es) return void 0;
|
|
1576
|
-
const ep = clampBounds ? 0 : focusPadding
|
|
1527
|
+
const ep = clampBounds ? 0 : focusPadding ?? 0.1;
|
|
1577
1528
|
return [
|
|
1578
1529
|
[es.x - ep * es.width, es.y - ep * es.height],
|
|
1579
1530
|
[es.x + es.width * (1 + ep), es.y + es.height * (1 + ep)]
|
|
@@ -1597,23 +1548,24 @@ function FlowRenderer({
|
|
|
1597
1548
|
},
|
|
1598
1549
|
[]
|
|
1599
1550
|
);
|
|
1600
|
-
const activeExtent = !bounds || extentReadyRef.current ?
|
|
1551
|
+
const activeExtent = !bounds || extentReadyRef.current ? expandedExtentRef.current ?? translateExtent : void 0;
|
|
1601
1552
|
if (!data) return null;
|
|
1602
|
-
const resolvedDefaultViewport = defaultViewportProp
|
|
1553
|
+
const resolvedDefaultViewport = defaultViewportProp ?? (!fitView && data.viewport ? data.viewport : void 0);
|
|
1603
1554
|
return /* @__PURE__ */ import_react11.default.createElement(import_react12.ReactFlowProvider, null, /* @__PURE__ */ import_react11.default.createElement(
|
|
1604
1555
|
"div",
|
|
1605
1556
|
{
|
|
1606
1557
|
className,
|
|
1607
|
-
style:
|
|
1558
|
+
style: {
|
|
1608
1559
|
width: "100%",
|
|
1609
1560
|
height: "100%",
|
|
1610
|
-
background: "transparent"
|
|
1611
|
-
|
|
1561
|
+
background: "transparent",
|
|
1562
|
+
...style
|
|
1563
|
+
}
|
|
1612
1564
|
},
|
|
1613
1565
|
/* @__PURE__ */ import_react11.default.createElement(
|
|
1614
1566
|
import_react12.ReactFlow,
|
|
1615
1567
|
{
|
|
1616
|
-
nodes:
|
|
1568
|
+
nodes: data.nodes ?? [],
|
|
1617
1569
|
edges: styledEdges,
|
|
1618
1570
|
nodeTypes,
|
|
1619
1571
|
edgeTypes: customEdgeTypes,
|
|
@@ -1653,10 +1605,10 @@ function FlowRenderer({
|
|
|
1653
1605
|
FocusHandler,
|
|
1654
1606
|
{
|
|
1655
1607
|
bounds,
|
|
1656
|
-
padding: focusPadding
|
|
1657
|
-
animation: focusAnimation
|
|
1608
|
+
padding: focusPadding ?? 0.1,
|
|
1609
|
+
animation: focusAnimation ?? true,
|
|
1658
1610
|
mode: focusMode,
|
|
1659
|
-
responsive: responsiveFit
|
|
1611
|
+
responsive: responsiveFit ?? true,
|
|
1660
1612
|
extent: translateExtent,
|
|
1661
1613
|
clampBounds,
|
|
1662
1614
|
minZoomProp,
|
|
@@ -1670,24 +1622,16 @@ function FlowRenderer({
|
|
|
1670
1622
|
|
|
1671
1623
|
// src/ui/Flow/FlowFrame.tsx
|
|
1672
1624
|
var import_react13 = __toESM(require("react"), 1);
|
|
1673
|
-
function FlowFrame(
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
"client",
|
|
1684
|
-
"slug",
|
|
1685
|
-
"id",
|
|
1686
|
-
"frameId",
|
|
1687
|
-
"loading",
|
|
1688
|
-
"error",
|
|
1689
|
-
"onDataReady"
|
|
1690
|
-
]);
|
|
1625
|
+
function FlowFrame({
|
|
1626
|
+
client,
|
|
1627
|
+
slug,
|
|
1628
|
+
id,
|
|
1629
|
+
frameId,
|
|
1630
|
+
loading = null,
|
|
1631
|
+
error: renderError,
|
|
1632
|
+
onDataReady,
|
|
1633
|
+
...rendererProps
|
|
1634
|
+
}) {
|
|
1691
1635
|
const { data, nodeTypeDefs, edgeTypeDefs, flow, isLoading, error } = useFlow({
|
|
1692
1636
|
client,
|
|
1693
1637
|
slug,
|
|
@@ -1700,9 +1644,8 @@ function FlowFrame(_a) {
|
|
|
1700
1644
|
const onDataReadyRef = (0, import_react13.useRef)(onDataReady);
|
|
1701
1645
|
onDataReadyRef.current = onDataReady;
|
|
1702
1646
|
(0, import_react13.useEffect)(() => {
|
|
1703
|
-
var _a2;
|
|
1704
1647
|
if (frameData && flow) {
|
|
1705
|
-
|
|
1648
|
+
onDataReadyRef.current?.(frameData, flow);
|
|
1706
1649
|
}
|
|
1707
1650
|
}, [frameData, flow]);
|
|
1708
1651
|
if (process.env.NODE_ENV !== "production" && !slug && !id) {
|
|
@@ -1721,14 +1664,15 @@ function FlowFrame(_a) {
|
|
|
1721
1664
|
}
|
|
1722
1665
|
return /* @__PURE__ */ import_react13.default.createElement(
|
|
1723
1666
|
FlowRenderer,
|
|
1724
|
-
|
|
1667
|
+
{
|
|
1668
|
+
...rendererProps,
|
|
1725
1669
|
data: frameData.data,
|
|
1726
1670
|
nodeTypeDefs,
|
|
1727
1671
|
edgeTypeDefs,
|
|
1728
1672
|
bounds: frameData.fitBounds,
|
|
1729
1673
|
clampBounds: frameData.clampBounds,
|
|
1730
1674
|
hideFrames: true
|
|
1731
|
-
}
|
|
1675
|
+
}
|
|
1732
1676
|
);
|
|
1733
1677
|
}
|
|
1734
1678
|
//# sourceMappingURL=flow.cjs.map
|