@01.software/sdk 0.5.3 → 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 +244 -238
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.js +244 -240
- 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.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,
|
|
@@ -472,6 +410,7 @@ function ensureQuickJSLoaded() {
|
|
|
472
410
|
_notify();
|
|
473
411
|
}).catch(() => {
|
|
474
412
|
_state = { status: "failed", module: null };
|
|
413
|
+
_notify();
|
|
475
414
|
});
|
|
476
415
|
}
|
|
477
416
|
function useQuickJS() {
|
|
@@ -481,6 +420,13 @@ function useQuickJS() {
|
|
|
481
420
|
// src/ui/Flow/template-compiler.ts
|
|
482
421
|
var MAX_CACHE_SIZE = 100;
|
|
483
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
|
+
]);
|
|
484
430
|
var ALLOWED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
485
431
|
"div",
|
|
486
432
|
"span",
|
|
@@ -514,7 +460,8 @@ var ALLOWED_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
514
460
|
"path",
|
|
515
461
|
"g",
|
|
516
462
|
"circle",
|
|
517
|
-
"rect"
|
|
463
|
+
"rect",
|
|
464
|
+
"iframe"
|
|
518
465
|
]);
|
|
519
466
|
var BLOCKED_PATTERNS = [
|
|
520
467
|
/\bdocument\s*\./,
|
|
@@ -594,7 +541,7 @@ function isSafeUrl(value) {
|
|
|
594
541
|
try {
|
|
595
542
|
const url = new URL(value);
|
|
596
543
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
597
|
-
} catch
|
|
544
|
+
} catch {
|
|
598
545
|
return false;
|
|
599
546
|
}
|
|
600
547
|
}
|
|
@@ -616,13 +563,16 @@ function sanitizeStyle(style) {
|
|
|
616
563
|
for (const [k, v] of Object.entries(style)) {
|
|
617
564
|
if (BLOCKED_STYLE_PROPS.has(k)) continue;
|
|
618
565
|
if (typeof v === "string" && /url\s*\(/i.test(v)) continue;
|
|
619
|
-
if (k === "position" && typeof v === "string" && /fixed|
|
|
566
|
+
if (k === "position" && typeof v === "string" && /fixed|sticky/i.test(v)) continue;
|
|
567
|
+
if (k === "zIndex") {
|
|
568
|
+
const n = typeof v === "number" ? v : parseInt(String(v), 10);
|
|
569
|
+
if (isNaN(n) || n > 9998) continue;
|
|
570
|
+
}
|
|
620
571
|
safe[k] = v;
|
|
621
572
|
}
|
|
622
573
|
return safe;
|
|
623
574
|
}
|
|
624
575
|
function materialize(node, depth = 0) {
|
|
625
|
-
var _a;
|
|
626
576
|
if (depth > MAX_MATERIALIZE_DEPTH) return null;
|
|
627
577
|
if (node == null) return null;
|
|
628
578
|
if (typeof node === "string" || typeof node === "number") return node;
|
|
@@ -644,7 +594,7 @@ function materialize(node, depth = 0) {
|
|
|
644
594
|
);
|
|
645
595
|
}
|
|
646
596
|
if (d.$$t === "el") {
|
|
647
|
-
const type = String(
|
|
597
|
+
const type = String(d.type ?? "");
|
|
648
598
|
const props = d.props && typeof d.props === "object" ? d.props : {};
|
|
649
599
|
const ch = Array.isArray(d.ch) ? d.ch : [];
|
|
650
600
|
if (!ALLOWED_ELEMENTS.has(type.toLowerCase())) return null;
|
|
@@ -652,6 +602,7 @@ function materialize(node, depth = 0) {
|
|
|
652
602
|
for (const [k, v] of Object.entries(props)) {
|
|
653
603
|
if (k.startsWith("on")) continue;
|
|
654
604
|
if (k === "dangerouslySetInnerHTML" || k === "ref") continue;
|
|
605
|
+
if (type === "iframe" && IFRAME_BLOCKED_PROPS.has(k)) continue;
|
|
655
606
|
if ((k === "src" || k === "href") && !isSafeUrl(v)) continue;
|
|
656
607
|
if (k === "style") {
|
|
657
608
|
safeProps[k] = sanitizeStyle(v);
|
|
@@ -659,6 +610,9 @@ function materialize(node, depth = 0) {
|
|
|
659
610
|
}
|
|
660
611
|
safeProps[k] = v;
|
|
661
612
|
}
|
|
613
|
+
if (type === "iframe") {
|
|
614
|
+
safeProps["sandbox"] = "allow-scripts allow-same-origin";
|
|
615
|
+
}
|
|
662
616
|
const children = ch.map((c) => materialize(c, depth + 1));
|
|
663
617
|
return import_react4.default.createElement(type, safeProps, ...children);
|
|
664
618
|
}
|
|
@@ -692,7 +646,7 @@ function makeRenderer(jsCode) {
|
|
|
692
646
|
const raw = vm.dump(callResult.handle);
|
|
693
647
|
callResult.handle.dispose();
|
|
694
648
|
return materialize(JSON.parse(String(raw)));
|
|
695
|
-
} catch
|
|
649
|
+
} catch {
|
|
696
650
|
return null;
|
|
697
651
|
} finally {
|
|
698
652
|
vm.dispose();
|
|
@@ -701,8 +655,7 @@ function makeRenderer(jsCode) {
|
|
|
701
655
|
}
|
|
702
656
|
function makeReactFC(renderer, qjs) {
|
|
703
657
|
return function QuickJSTemplateComponent(props) {
|
|
704
|
-
|
|
705
|
-
return (_a = renderer(qjs, props)) != null ? _a : null;
|
|
658
|
+
return renderer(qjs, props) ?? null;
|
|
706
659
|
};
|
|
707
660
|
}
|
|
708
661
|
function compileTemplate(code, slug) {
|
|
@@ -712,10 +665,10 @@ function compileTemplate(code, slug) {
|
|
|
712
665
|
if (!qjs) return null;
|
|
713
666
|
const cacheKey = `${slug}:${code.length}:${hashCode(code)}`;
|
|
714
667
|
if (rendererCache.has(cacheKey)) {
|
|
715
|
-
const
|
|
668
|
+
const entry = rendererCache.get(cacheKey);
|
|
716
669
|
rendererCache.delete(cacheKey);
|
|
717
|
-
rendererCache.set(cacheKey,
|
|
718
|
-
return
|
|
670
|
+
rendererCache.set(cacheKey, entry);
|
|
671
|
+
return entry.fc;
|
|
719
672
|
}
|
|
720
673
|
let jsCode;
|
|
721
674
|
try {
|
|
@@ -726,16 +679,17 @@ function compileTemplate(code, slug) {
|
|
|
726
679
|
jsxFragmentPragma: "React.Fragment"
|
|
727
680
|
});
|
|
728
681
|
jsCode = result.code;
|
|
729
|
-
} catch
|
|
682
|
+
} catch {
|
|
730
683
|
return null;
|
|
731
684
|
}
|
|
732
685
|
const renderer = makeRenderer(jsCode);
|
|
686
|
+
const fc = makeReactFC(renderer, qjs);
|
|
733
687
|
if (rendererCache.size >= MAX_CACHE_SIZE) {
|
|
734
688
|
const oldest = rendererCache.keys().next().value;
|
|
735
689
|
if (oldest) rendererCache.delete(oldest);
|
|
736
690
|
}
|
|
737
|
-
rendererCache.set(cacheKey, renderer);
|
|
738
|
-
return
|
|
691
|
+
rendererCache.set(cacheKey, { renderer, fc });
|
|
692
|
+
return fc;
|
|
739
693
|
}
|
|
740
694
|
function clearTemplateCache() {
|
|
741
695
|
rendererCache.clear();
|
|
@@ -749,15 +703,15 @@ function sanitizeUrl(url) {
|
|
|
749
703
|
const parsed = new URL(url);
|
|
750
704
|
if (parsed.protocol === "http:" || parsed.protocol === "https:") return url;
|
|
751
705
|
return void 0;
|
|
752
|
-
} catch
|
|
706
|
+
} catch {
|
|
753
707
|
return void 0;
|
|
754
708
|
}
|
|
755
709
|
}
|
|
756
710
|
function renderFieldValue(key, val, fieldDef) {
|
|
757
711
|
if (val == null || val === "") return null;
|
|
758
|
-
const fieldType = fieldDef
|
|
712
|
+
const fieldType = fieldDef?.fieldType;
|
|
759
713
|
if (fieldType === "image" || typeof val === "object" && val !== null && "url" in val) {
|
|
760
|
-
const imgUrl = typeof val === "string" ? val : val
|
|
714
|
+
const imgUrl = typeof val === "string" ? val : val?.url;
|
|
761
715
|
const safeUrl = sanitizeUrl(imgUrl);
|
|
762
716
|
if (!safeUrl) return null;
|
|
763
717
|
return /* @__PURE__ */ import_react5.default.createElement(
|
|
@@ -870,12 +824,11 @@ function EnhancedDynamicNode({
|
|
|
870
824
|
);
|
|
871
825
|
}
|
|
872
826
|
function DefaultFrameNode({ data }) {
|
|
873
|
-
var _a, _b, _c, _d;
|
|
874
827
|
const d = data;
|
|
875
|
-
const baseColor =
|
|
876
|
-
const padding =
|
|
877
|
-
const borderStyle =
|
|
878
|
-
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;
|
|
879
832
|
const bgColor = (() => {
|
|
880
833
|
const m = baseColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
881
834
|
if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`;
|
|
@@ -909,21 +862,21 @@ function DefaultFrameNode({ data }) {
|
|
|
909
862
|
|
|
910
863
|
// src/ui/Flow/field-helpers.ts
|
|
911
864
|
function getImageField(fields, name) {
|
|
912
|
-
const val = fields
|
|
865
|
+
const val = fields?.[name];
|
|
913
866
|
if (val && typeof val === "object" && val !== null && "url" in val)
|
|
914
867
|
return val;
|
|
915
868
|
return void 0;
|
|
916
869
|
}
|
|
917
870
|
function getTextField(fields, name) {
|
|
918
|
-
const val = fields
|
|
871
|
+
const val = fields?.[name];
|
|
919
872
|
return typeof val === "string" ? val : void 0;
|
|
920
873
|
}
|
|
921
874
|
function getNumberField(fields, name) {
|
|
922
|
-
const val = fields
|
|
875
|
+
const val = fields?.[name];
|
|
923
876
|
return typeof val === "number" ? val : void 0;
|
|
924
877
|
}
|
|
925
878
|
function getBooleanField(fields, name) {
|
|
926
|
-
const val = fields
|
|
879
|
+
const val = fields?.[name];
|
|
927
880
|
return typeof val === "boolean" ? val : void 0;
|
|
928
881
|
}
|
|
929
882
|
|
|
@@ -932,21 +885,77 @@ var import_postcss = __toESM(require("postcss"), 1);
|
|
|
932
885
|
var ALLOWED_AT_RULES = /* @__PURE__ */ new Set(["keyframes", "media", "supports", "container", "layer"]);
|
|
933
886
|
var BLOCKED_VALUE_PATTERNS = [/url\s*\(/i, /expression\s*\(/i, /paint\s*\(/i, /-moz-binding/i];
|
|
934
887
|
var DANGEROUS_SELECTOR = /(?:^|[\s,])(?::root|html|body)\b/;
|
|
888
|
+
var BLOCKED_PROPERTY_VALUES = {
|
|
889
|
+
// absolute is allowed — contained by nearest positioned ancestor (node wrapper)
|
|
890
|
+
position: /fixed|sticky/i
|
|
891
|
+
};
|
|
892
|
+
var Z_INDEX_MAX = 9998;
|
|
935
893
|
function sanitizeCSS(css, scopeClass) {
|
|
936
894
|
let root;
|
|
937
895
|
try {
|
|
938
896
|
root = import_postcss.default.parse(css);
|
|
939
|
-
} catch
|
|
897
|
+
} catch {
|
|
940
898
|
return "";
|
|
941
899
|
}
|
|
900
|
+
const safeScopeClass = scopeClass ? scopeClass.replace(/[{}()[\];,'"\\<>\s]/g, "") : "";
|
|
901
|
+
const keyframeNameMap = /* @__PURE__ */ new Map();
|
|
902
|
+
if (safeScopeClass) {
|
|
903
|
+
root.walkAtRules(/^keyframes$/i, (node) => {
|
|
904
|
+
const rawName = node.params.trim().replace(/^['"]|['"]$/g, "");
|
|
905
|
+
const originalName = rawName;
|
|
906
|
+
const scopedName = `${safeScopeClass}__${rawName.replace(/\s+/g, "_")}`;
|
|
907
|
+
keyframeNameMap.set(originalName, scopedName);
|
|
908
|
+
node.params = scopedName;
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
if (safeScopeClass && keyframeNameMap.size > 0) {
|
|
912
|
+
const ANIM_KEYWORDS = /* @__PURE__ */ new Set(["none", "initial", "inherit", "unset", "revert"]);
|
|
913
|
+
const replaceAnimName = (token) => {
|
|
914
|
+
const t = token.trim().replace(/^['"]|['"]$/g, "");
|
|
915
|
+
return ANIM_KEYWORDS.has(t) ? token : keyframeNameMap.get(t) ?? token;
|
|
916
|
+
};
|
|
917
|
+
root.walkDecls(/^animation-name$/i, (node) => {
|
|
918
|
+
node.value = node.value.split(",").map(replaceAnimName).join(", ");
|
|
919
|
+
});
|
|
920
|
+
root.walkDecls(/^animation$/i, (node) => {
|
|
921
|
+
node.value = node.value.split(",").map(
|
|
922
|
+
(anim) => anim.split(/(\s+)/).map((token) => /\s/.test(token) ? token : replaceAnimName(token)).join("")
|
|
923
|
+
).join(",");
|
|
924
|
+
});
|
|
925
|
+
}
|
|
942
926
|
root.walkAtRules((node) => {
|
|
943
927
|
if (!ALLOWED_AT_RULES.has(node.name.toLowerCase())) {
|
|
944
928
|
node.remove();
|
|
945
929
|
}
|
|
946
930
|
});
|
|
947
931
|
root.walkDecls((node) => {
|
|
948
|
-
|
|
932
|
+
const normalizedValue = node.value.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
933
|
+
if (BLOCKED_VALUE_PATTERNS.some((p) => p.test(normalizedValue))) {
|
|
949
934
|
node.remove();
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
const propLower = node.prop.toLowerCase();
|
|
938
|
+
const blockedValuePattern = BLOCKED_PROPERTY_VALUES[propLower];
|
|
939
|
+
if (blockedValuePattern) {
|
|
940
|
+
const deescaped = normalizedValue.replace(
|
|
941
|
+
/\\([0-9a-fA-F]{1,6})\s?/g,
|
|
942
|
+
(_, hex) => String.fromCodePoint(parseInt(hex, 16))
|
|
943
|
+
);
|
|
944
|
+
if (blockedValuePattern.test(deescaped)) {
|
|
945
|
+
node.remove();
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
if (propLower === "z-index") {
|
|
950
|
+
const zv = node.value.trim();
|
|
951
|
+
if (zv === "auto" || zv === "initial" || zv === "inherit" || zv === "unset" || zv === "revert") {
|
|
952
|
+
} else {
|
|
953
|
+
const val = parseInt(zv, 10);
|
|
954
|
+
if (isNaN(val) || String(val) !== zv || val > Z_INDEX_MAX) {
|
|
955
|
+
node.remove();
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
950
959
|
}
|
|
951
960
|
});
|
|
952
961
|
root.walkRules((rule) => {
|
|
@@ -956,13 +965,12 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
956
965
|
return;
|
|
957
966
|
}
|
|
958
967
|
if (scopeClass) {
|
|
959
|
-
const safeScopeClass = scopeClass.replace(/[{}()[\];,'"\\<>]/g, "");
|
|
960
968
|
if (!safeScopeClass) {
|
|
961
969
|
rule.remove();
|
|
962
970
|
return;
|
|
963
971
|
}
|
|
964
972
|
const parent = rule.parent;
|
|
965
|
-
if (
|
|
973
|
+
if (parent?.type === "atrule" && parent.name.toLowerCase() === "keyframes") {
|
|
966
974
|
return;
|
|
967
975
|
}
|
|
968
976
|
rule.selectors = rule.selectors.map((sel) => `.${safeScopeClass} ${sel}`);
|
|
@@ -989,7 +997,7 @@ function getImageSrcSet(image) {
|
|
|
989
997
|
if (sizes) {
|
|
990
998
|
for (const size of IMAGE_SIZES) {
|
|
991
999
|
const entry = sizes[String(size)];
|
|
992
|
-
if (
|
|
1000
|
+
if (entry?.url && entry.width) {
|
|
993
1001
|
parts.push(`${entry.url} ${entry.width}w`);
|
|
994
1002
|
}
|
|
995
1003
|
}
|
|
@@ -1000,11 +1008,10 @@ function getImageSrcSet(image) {
|
|
|
1000
1008
|
return parts.join(", ");
|
|
1001
1009
|
}
|
|
1002
1010
|
function getImagePlaceholderStyle(image, options) {
|
|
1003
|
-
|
|
1004
|
-
const
|
|
1005
|
-
const paletteColor = (_b = options == null ? void 0 : options.paletteColor) != null ? _b : "muted";
|
|
1011
|
+
const type = options?.type ?? "blur";
|
|
1012
|
+
const paletteColor = options?.paletteColor ?? "muted";
|
|
1006
1013
|
if (type === "none") return {};
|
|
1007
|
-
const color =
|
|
1014
|
+
const color = image.palette?.[paletteColor];
|
|
1008
1015
|
if (type === "blur") {
|
|
1009
1016
|
const lqip = image.lqip;
|
|
1010
1017
|
if (lqip) {
|
|
@@ -1043,15 +1050,14 @@ function Image({
|
|
|
1043
1050
|
fill = false,
|
|
1044
1051
|
imageRendering
|
|
1045
1052
|
}) {
|
|
1046
|
-
var _a, _b;
|
|
1047
1053
|
const [loaded, setLoaded] = (0, import_react6.useState)(false);
|
|
1048
1054
|
const firedRef = (0, import_react6.useRef)(false);
|
|
1049
1055
|
const isPixelRendering = imageRendering === "pixelated" || imageRendering === "crisp-edges";
|
|
1050
|
-
const placeholder = placeholderProp
|
|
1051
|
-
const loading = priority ? "eager" : loadingProp
|
|
1056
|
+
const placeholder = placeholderProp ?? (isPixelRendering ? "none" : "blur");
|
|
1057
|
+
const loading = priority ? "eager" : loadingProp ?? "lazy";
|
|
1052
1058
|
const aspectRatio = !fill && image.width && image.height ? `${image.width} / ${image.height}` : void 0;
|
|
1053
1059
|
const srcSet = getImageSrcSet(image);
|
|
1054
|
-
const src =
|
|
1060
|
+
const src = image.url ?? void 0;
|
|
1055
1061
|
const hasLqip = placeholder === "blur" && !!image.lqip;
|
|
1056
1062
|
const placeholderStyle = getImagePlaceholderStyle(image, {
|
|
1057
1063
|
type: placeholder
|
|
@@ -1061,7 +1067,7 @@ function Image({
|
|
|
1061
1067
|
if (firedRef.current) return;
|
|
1062
1068
|
firedRef.current = true;
|
|
1063
1069
|
setLoaded(true);
|
|
1064
|
-
onLoad
|
|
1070
|
+
onLoad?.();
|
|
1065
1071
|
}, [onLoad]);
|
|
1066
1072
|
const imgRef = (0, import_react6.useCallback)(
|
|
1067
1073
|
(node) => {
|
|
@@ -1071,10 +1077,13 @@ function Image({
|
|
|
1071
1077
|
},
|
|
1072
1078
|
[fireLoad]
|
|
1073
1079
|
);
|
|
1074
|
-
const containerStyle =
|
|
1080
|
+
const containerStyle = {
|
|
1075
1081
|
position: "relative",
|
|
1076
|
-
overflow: "hidden"
|
|
1077
|
-
|
|
1082
|
+
overflow: "hidden",
|
|
1083
|
+
...fill ? { width: "100%", height: "100%" } : {},
|
|
1084
|
+
...aspectRatio ? { aspectRatio } : {},
|
|
1085
|
+
...style
|
|
1086
|
+
};
|
|
1078
1087
|
const overlayBase = {
|
|
1079
1088
|
position: "absolute",
|
|
1080
1089
|
top: 0,
|
|
@@ -1085,41 +1094,44 @@ function Image({
|
|
|
1085
1094
|
transition: "opacity 0.3s ease",
|
|
1086
1095
|
pointerEvents: "none"
|
|
1087
1096
|
};
|
|
1088
|
-
const mainImgStyle =
|
|
1097
|
+
const mainImgStyle = {
|
|
1089
1098
|
display: "block",
|
|
1090
1099
|
width: "100%",
|
|
1091
1100
|
height: "100%",
|
|
1092
|
-
objectFit
|
|
1093
|
-
|
|
1101
|
+
objectFit,
|
|
1102
|
+
...imageRendering ? { imageRendering } : {},
|
|
1094
1103
|
opacity: loaded ? 1 : 0,
|
|
1095
|
-
transition: "opacity 0.3s ease"
|
|
1096
|
-
|
|
1104
|
+
transition: "opacity 0.3s ease",
|
|
1105
|
+
...imgStyle
|
|
1106
|
+
};
|
|
1097
1107
|
return /* @__PURE__ */ import_react6.default.createElement("div", { className, style: containerStyle }, hasLqip && /* @__PURE__ */ import_react6.default.createElement(
|
|
1098
1108
|
"img",
|
|
1099
1109
|
{
|
|
1100
1110
|
"aria-hidden": true,
|
|
1101
1111
|
alt: "",
|
|
1102
1112
|
src: image.lqip,
|
|
1103
|
-
style:
|
|
1113
|
+
style: {
|
|
1114
|
+
...overlayBase,
|
|
1104
1115
|
display: "block",
|
|
1105
1116
|
objectFit,
|
|
1106
1117
|
filter: "blur(20px)",
|
|
1107
1118
|
transform: "scale(1.1)"
|
|
1108
|
-
}
|
|
1119
|
+
}
|
|
1109
1120
|
}
|
|
1110
1121
|
), placeholderColor && /* @__PURE__ */ import_react6.default.createElement(
|
|
1111
1122
|
"div",
|
|
1112
1123
|
{
|
|
1113
1124
|
"aria-hidden": true,
|
|
1114
|
-
style:
|
|
1125
|
+
style: {
|
|
1126
|
+
...overlayBase,
|
|
1115
1127
|
backgroundColor: placeholderColor
|
|
1116
|
-
}
|
|
1128
|
+
}
|
|
1117
1129
|
}
|
|
1118
1130
|
), /* @__PURE__ */ import_react6.default.createElement(
|
|
1119
1131
|
"img",
|
|
1120
1132
|
{
|
|
1121
1133
|
ref: imgRef,
|
|
1122
|
-
alt:
|
|
1134
|
+
alt: image.alt ?? "",
|
|
1123
1135
|
src,
|
|
1124
1136
|
srcSet: srcSet || void 0,
|
|
1125
1137
|
sizes,
|
|
@@ -1138,10 +1150,9 @@ function Image({
|
|
|
1138
1150
|
function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode) {
|
|
1139
1151
|
const types = {};
|
|
1140
1152
|
types.dynamic = ((props) => {
|
|
1141
|
-
var _a;
|
|
1142
1153
|
const d = props.data;
|
|
1143
|
-
const typeDef = nodeTypeDefsMap
|
|
1144
|
-
const CustomRenderer = nodeRenderers
|
|
1154
|
+
const typeDef = nodeTypeDefsMap?.get(d.nodeTypeSlug);
|
|
1155
|
+
const CustomRenderer = nodeRenderers?.[d.nodeTypeSlug];
|
|
1145
1156
|
const defaultRender = typeDef ? /* @__PURE__ */ import_react7.default.createElement(
|
|
1146
1157
|
EnhancedDynamicNode,
|
|
1147
1158
|
{
|
|
@@ -1150,7 +1161,7 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrap
|
|
|
1150
1161
|
width: props.width,
|
|
1151
1162
|
height: props.height
|
|
1152
1163
|
}
|
|
1153
|
-
) : /* @__PURE__ */ import_react7.default.createElement(DefaultDynamicNode,
|
|
1164
|
+
) : /* @__PURE__ */ import_react7.default.createElement(DefaultDynamicNode, { ...props });
|
|
1154
1165
|
const slotProps = {
|
|
1155
1166
|
id: props.id,
|
|
1156
1167
|
nodeTypeSlug: d.nodeTypeSlug,
|
|
@@ -1164,9 +1175,9 @@ function createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrap
|
|
|
1164
1175
|
};
|
|
1165
1176
|
let content;
|
|
1166
1177
|
if (CustomRenderer) {
|
|
1167
|
-
content = /* @__PURE__ */ import_react7.default.createElement(CustomRenderer,
|
|
1178
|
+
content = /* @__PURE__ */ import_react7.default.createElement(CustomRenderer, { ...slotProps });
|
|
1168
1179
|
} else if (d.nodeTypeSlug === "image") {
|
|
1169
|
-
const imageVal =
|
|
1180
|
+
const imageVal = d.fields?.image;
|
|
1170
1181
|
if (imageVal && typeof imageVal === "object" && "url" in imageVal) {
|
|
1171
1182
|
content = /* @__PURE__ */ import_react7.default.createElement(
|
|
1172
1183
|
Image,
|
|
@@ -1229,8 +1240,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1229
1240
|
const types = {};
|
|
1230
1241
|
for (const [slug, Renderer] of Object.entries(edgeRenderers)) {
|
|
1231
1242
|
types[slug] = ((props) => {
|
|
1232
|
-
|
|
1233
|
-
const def = edgeTypeDefsMap == null ? void 0 : edgeTypeDefsMap.get(slug);
|
|
1243
|
+
const def = edgeTypeDefsMap?.get(slug);
|
|
1234
1244
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1235
1245
|
Renderer,
|
|
1236
1246
|
{
|
|
@@ -1239,7 +1249,7 @@ function createEdgeTypes(edgeRenderers, edgeTypeDefsMap) {
|
|
|
1239
1249
|
source: props.source,
|
|
1240
1250
|
target: props.target,
|
|
1241
1251
|
label: props.label,
|
|
1242
|
-
fields:
|
|
1252
|
+
fields: props.data?.fields,
|
|
1243
1253
|
edgeTypeDef: def,
|
|
1244
1254
|
style: props.style
|
|
1245
1255
|
}
|
|
@@ -1263,33 +1273,38 @@ var EDGE_TYPE_MAP = {
|
|
|
1263
1273
|
default: "default"
|
|
1264
1274
|
};
|
|
1265
1275
|
function applyEdgeStyles(edges, edgeTypeDefsMap) {
|
|
1266
|
-
if (!
|
|
1276
|
+
if (!edgeTypeDefsMap?.size) return edges;
|
|
1267
1277
|
return edges.map((edge) => {
|
|
1268
|
-
var _a;
|
|
1269
1278
|
const slug = edge.edgeTypeSlug;
|
|
1270
1279
|
if (!slug) return edge;
|
|
1271
1280
|
const def = edgeTypeDefsMap.get(slug);
|
|
1272
1281
|
if (!def) return edge;
|
|
1273
|
-
const styled =
|
|
1282
|
+
const styled = { ...edge };
|
|
1274
1283
|
if (!styled.type && def.lineStyle) {
|
|
1275
|
-
styled.type =
|
|
1284
|
+
styled.type = EDGE_TYPE_MAP[def.lineStyle] ?? "default";
|
|
1276
1285
|
}
|
|
1277
|
-
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
|
+
};
|
|
1278
1291
|
if (styled.animated == null && def.animated) styled.animated = true;
|
|
1279
1292
|
if (!styled.markerStart) {
|
|
1280
1293
|
const startType = toMarkerType(def.markerStart);
|
|
1281
1294
|
if (startType) {
|
|
1282
|
-
styled.markerStart =
|
|
1283
|
-
type: startType
|
|
1284
|
-
|
|
1295
|
+
styled.markerStart = {
|
|
1296
|
+
type: startType,
|
|
1297
|
+
...def.color ? { color: def.color } : void 0
|
|
1298
|
+
};
|
|
1285
1299
|
}
|
|
1286
1300
|
}
|
|
1287
1301
|
if (!styled.markerEnd) {
|
|
1288
1302
|
const endType = toMarkerType(def.markerEnd);
|
|
1289
1303
|
if (endType) {
|
|
1290
|
-
styled.markerEnd =
|
|
1291
|
-
type: endType
|
|
1292
|
-
|
|
1304
|
+
styled.markerEnd = {
|
|
1305
|
+
type: endType,
|
|
1306
|
+
...def.color ? { color: def.color } : void 0
|
|
1307
|
+
};
|
|
1293
1308
|
}
|
|
1294
1309
|
}
|
|
1295
1310
|
return styled;
|
|
@@ -1364,7 +1379,7 @@ function FocusHandler({
|
|
|
1364
1379
|
if (bw === 0 || bh === 0) return;
|
|
1365
1380
|
const zoomFn = mode === "cover" ? Math.max : Math.min;
|
|
1366
1381
|
const zoom = zoomFn(containerSize.w / bw, containerSize.h / bh);
|
|
1367
|
-
const centerTarget = clampBounds
|
|
1382
|
+
const centerTarget = clampBounds ?? b;
|
|
1368
1383
|
const cx = centerTarget.x + centerTarget.width / 2;
|
|
1369
1384
|
const cy = centerTarget.y + centerTarget.height / 2;
|
|
1370
1385
|
const x = containerSize.w / 2 - cx * zoom;
|
|
@@ -1374,9 +1389,9 @@ function FocusHandler({
|
|
|
1374
1389
|
containerSize.w / clampBounds.width,
|
|
1375
1390
|
containerSize.h / clampBounds.height
|
|
1376
1391
|
);
|
|
1377
|
-
store.getState().setMinZoom(Math.max(Math.min(coverZoom, zoom), minZoomProp
|
|
1392
|
+
store.getState().setMinZoom(Math.max(Math.min(coverZoom, zoom), minZoomProp ?? 0));
|
|
1378
1393
|
} else {
|
|
1379
|
-
store.getState().setMinZoom(minZoomProp
|
|
1394
|
+
store.getState().setMinZoom(minZoomProp ?? 0.5);
|
|
1380
1395
|
}
|
|
1381
1396
|
let vp = { x, y, zoom };
|
|
1382
1397
|
if (isInitial || isBoundsChange) {
|
|
@@ -1384,12 +1399,12 @@ function FocusHandler({
|
|
|
1384
1399
|
if (extent) {
|
|
1385
1400
|
const visW = containerSize.w / zoom;
|
|
1386
1401
|
const visH = containerSize.h / zoom;
|
|
1387
|
-
onInitialFit
|
|
1402
|
+
onInitialFit?.([
|
|
1388
1403
|
[Math.min(extent[0][0], cx - visW / 2), Math.min(extent[0][1], cy - visH / 2)],
|
|
1389
1404
|
[Math.max(extent[1][0], cx + visW / 2), Math.max(extent[1][1], cy + visH / 2)]
|
|
1390
1405
|
]);
|
|
1391
1406
|
} else {
|
|
1392
|
-
onInitialFit
|
|
1407
|
+
onInitialFit?.();
|
|
1393
1408
|
}
|
|
1394
1409
|
} else {
|
|
1395
1410
|
if (extent) {
|
|
@@ -1465,14 +1480,13 @@ function FlowRenderer({
|
|
|
1465
1480
|
minZoom: minZoomProp,
|
|
1466
1481
|
maxZoom: maxZoomProp
|
|
1467
1482
|
}) {
|
|
1468
|
-
var _a, _b;
|
|
1469
1483
|
const resolvedFrameRenderer = hideFrames ? NullFrameRenderer : frameRenderer;
|
|
1470
1484
|
const nodeTypeDefsMap = import_react11.default.useMemo(() => {
|
|
1471
|
-
if (!
|
|
1485
|
+
if (!nodeTypeDefs?.length) return void 0;
|
|
1472
1486
|
return new Map(nodeTypeDefs.map((d) => [d.slug, d]));
|
|
1473
1487
|
}, [nodeTypeDefs]);
|
|
1474
1488
|
const edgeTypeDefsMap = import_react11.default.useMemo(() => {
|
|
1475
|
-
if (!
|
|
1489
|
+
if (!edgeTypeDefs?.length) return void 0;
|
|
1476
1490
|
return new Map(edgeTypeDefs.map((d) => [d.slug, d]));
|
|
1477
1491
|
}, [edgeTypeDefs]);
|
|
1478
1492
|
const nodeTypes = import_react11.default.useMemo(
|
|
@@ -1490,28 +1504,27 @@ function FlowRenderer({
|
|
|
1490
1504
|
[edgeRenderers, edgeTypeDefsMap]
|
|
1491
1505
|
);
|
|
1492
1506
|
const mergedCSS = import_react11.default.useMemo(() => {
|
|
1493
|
-
if (!
|
|
1507
|
+
if (!nodeTypeDefs?.length) return "";
|
|
1494
1508
|
return nodeTypeDefs.filter((d) => d.customCSS).map((d) => sanitizeCSS(d.customCSS, `flow-node--${d.slug}`)).join("\n");
|
|
1495
1509
|
}, [nodeTypeDefs]);
|
|
1496
1510
|
const styledEdges = import_react11.default.useMemo(() => {
|
|
1497
|
-
|
|
1498
|
-
let edges = applyEdgeStyles((_a2 = data == null ? void 0 : data.edges) != null ? _a2 : [], edgeTypeDefsMap);
|
|
1511
|
+
let edges = applyEdgeStyles(data?.edges ?? [], edgeTypeDefsMap);
|
|
1499
1512
|
if (edgeRenderers) {
|
|
1500
1513
|
edges = edges.map((edge) => {
|
|
1501
1514
|
const slug = edge.edgeTypeSlug;
|
|
1502
1515
|
if (slug && edgeRenderers[slug]) {
|
|
1503
|
-
return
|
|
1516
|
+
return { ...edge, type: slug };
|
|
1504
1517
|
}
|
|
1505
1518
|
return edge;
|
|
1506
1519
|
});
|
|
1507
1520
|
}
|
|
1508
1521
|
return edges;
|
|
1509
|
-
}, [data
|
|
1522
|
+
}, [data?.edges, edgeTypeDefsMap, edgeRenderers]);
|
|
1510
1523
|
const translateExtent = import_react11.default.useMemo(() => {
|
|
1511
1524
|
if (translateExtentProp) return translateExtentProp;
|
|
1512
|
-
const es = clampBounds
|
|
1525
|
+
const es = clampBounds ?? bounds;
|
|
1513
1526
|
if (!es) return void 0;
|
|
1514
|
-
const ep = clampBounds ? 0 : focusPadding
|
|
1527
|
+
const ep = clampBounds ? 0 : focusPadding ?? 0.1;
|
|
1515
1528
|
return [
|
|
1516
1529
|
[es.x - ep * es.width, es.y - ep * es.height],
|
|
1517
1530
|
[es.x + es.width * (1 + ep), es.y + es.height * (1 + ep)]
|
|
@@ -1535,23 +1548,24 @@ function FlowRenderer({
|
|
|
1535
1548
|
},
|
|
1536
1549
|
[]
|
|
1537
1550
|
);
|
|
1538
|
-
const activeExtent = !bounds || extentReadyRef.current ?
|
|
1551
|
+
const activeExtent = !bounds || extentReadyRef.current ? expandedExtentRef.current ?? translateExtent : void 0;
|
|
1539
1552
|
if (!data) return null;
|
|
1540
|
-
const resolvedDefaultViewport = defaultViewportProp
|
|
1553
|
+
const resolvedDefaultViewport = defaultViewportProp ?? (!fitView && data.viewport ? data.viewport : void 0);
|
|
1541
1554
|
return /* @__PURE__ */ import_react11.default.createElement(import_react12.ReactFlowProvider, null, /* @__PURE__ */ import_react11.default.createElement(
|
|
1542
1555
|
"div",
|
|
1543
1556
|
{
|
|
1544
1557
|
className,
|
|
1545
|
-
style:
|
|
1558
|
+
style: {
|
|
1546
1559
|
width: "100%",
|
|
1547
1560
|
height: "100%",
|
|
1548
|
-
background: "transparent"
|
|
1549
|
-
|
|
1561
|
+
background: "transparent",
|
|
1562
|
+
...style
|
|
1563
|
+
}
|
|
1550
1564
|
},
|
|
1551
1565
|
/* @__PURE__ */ import_react11.default.createElement(
|
|
1552
1566
|
import_react12.ReactFlow,
|
|
1553
1567
|
{
|
|
1554
|
-
nodes:
|
|
1568
|
+
nodes: data.nodes ?? [],
|
|
1555
1569
|
edges: styledEdges,
|
|
1556
1570
|
nodeTypes,
|
|
1557
1571
|
edgeTypes: customEdgeTypes,
|
|
@@ -1591,10 +1605,10 @@ function FlowRenderer({
|
|
|
1591
1605
|
FocusHandler,
|
|
1592
1606
|
{
|
|
1593
1607
|
bounds,
|
|
1594
|
-
padding: focusPadding
|
|
1595
|
-
animation: focusAnimation
|
|
1608
|
+
padding: focusPadding ?? 0.1,
|
|
1609
|
+
animation: focusAnimation ?? true,
|
|
1596
1610
|
mode: focusMode,
|
|
1597
|
-
responsive: responsiveFit
|
|
1611
|
+
responsive: responsiveFit ?? true,
|
|
1598
1612
|
extent: translateExtent,
|
|
1599
1613
|
clampBounds,
|
|
1600
1614
|
minZoomProp,
|
|
@@ -1608,24 +1622,16 @@ function FlowRenderer({
|
|
|
1608
1622
|
|
|
1609
1623
|
// src/ui/Flow/FlowFrame.tsx
|
|
1610
1624
|
var import_react13 = __toESM(require("react"), 1);
|
|
1611
|
-
function FlowFrame(
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
"client",
|
|
1622
|
-
"slug",
|
|
1623
|
-
"id",
|
|
1624
|
-
"frameId",
|
|
1625
|
-
"loading",
|
|
1626
|
-
"error",
|
|
1627
|
-
"onDataReady"
|
|
1628
|
-
]);
|
|
1625
|
+
function FlowFrame({
|
|
1626
|
+
client,
|
|
1627
|
+
slug,
|
|
1628
|
+
id,
|
|
1629
|
+
frameId,
|
|
1630
|
+
loading = null,
|
|
1631
|
+
error: renderError,
|
|
1632
|
+
onDataReady,
|
|
1633
|
+
...rendererProps
|
|
1634
|
+
}) {
|
|
1629
1635
|
const { data, nodeTypeDefs, edgeTypeDefs, flow, isLoading, error } = useFlow({
|
|
1630
1636
|
client,
|
|
1631
1637
|
slug,
|
|
@@ -1638,9 +1644,8 @@ function FlowFrame(_a) {
|
|
|
1638
1644
|
const onDataReadyRef = (0, import_react13.useRef)(onDataReady);
|
|
1639
1645
|
onDataReadyRef.current = onDataReady;
|
|
1640
1646
|
(0, import_react13.useEffect)(() => {
|
|
1641
|
-
var _a2;
|
|
1642
1647
|
if (frameData && flow) {
|
|
1643
|
-
|
|
1648
|
+
onDataReadyRef.current?.(frameData, flow);
|
|
1644
1649
|
}
|
|
1645
1650
|
}, [frameData, flow]);
|
|
1646
1651
|
if (process.env.NODE_ENV !== "production" && !slug && !id) {
|
|
@@ -1659,14 +1664,15 @@ function FlowFrame(_a) {
|
|
|
1659
1664
|
}
|
|
1660
1665
|
return /* @__PURE__ */ import_react13.default.createElement(
|
|
1661
1666
|
FlowRenderer,
|
|
1662
|
-
|
|
1667
|
+
{
|
|
1668
|
+
...rendererProps,
|
|
1663
1669
|
data: frameData.data,
|
|
1664
1670
|
nodeTypeDefs,
|
|
1665
1671
|
edgeTypeDefs,
|
|
1666
1672
|
bounds: frameData.fitBounds,
|
|
1667
1673
|
clampBounds: frameData.clampBounds,
|
|
1668
1674
|
hideFrames: true
|
|
1669
|
-
}
|
|
1675
|
+
}
|
|
1670
1676
|
);
|
|
1671
1677
|
}
|
|
1672
1678
|
//# sourceMappingURL=flow.cjs.map
|