@pixerate/editor 0.80.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/dist/agent/index.cjs +138 -13
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +9 -5
- package/dist/agent/index.d.ts +9 -5
- package/dist/agent/index.js +144 -19
- package/dist/agent/index.js.map +1 -1
- package/dist/animation-editor/index.d.cts +1 -1
- package/dist/animation-editor/index.d.ts +1 -1
- package/dist/bridge/index.d.cts +3 -3
- package/dist/bridge/index.d.ts +3 -3
- package/dist/{bridge-client-C5dRjrz5.d.ts → bridge-client-CMGfnjTl.d.ts} +1 -1
- package/dist/{bridge-client-C5OziCRK.d.cts → bridge-client-VpnICVxP.d.cts} +1 -1
- package/dist/{builtins-BKYlHH1s.d.ts → builtins-CV1fDj64.d.ts} +5 -1
- package/dist/{builtins-1kqwLUnb.d.cts → builtins-c4w0eAYl.d.cts} +5 -1
- package/dist/canvas/index.cjs +235 -104
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +59 -1
- package/dist/canvas/index.d.ts +59 -1
- package/dist/canvas/index.js +234 -103
- package/dist/canvas/index.js.map +1 -1
- package/dist/capture-DFEMFmVt.d.cts +133 -0
- package/dist/capture-wwNGaW05.d.ts +133 -0
- package/dist/chart/index.d.cts +1 -1
- package/dist/chart/index.d.ts +1 -1
- package/dist/{chunk-2CJ3LPYQ.js → chunk-424H3P4I.js} +13 -295
- package/dist/chunk-424H3P4I.js.map +1 -0
- package/dist/{chunk-K73CKYUM.cjs → chunk-EI2MOVQ3.cjs} +198 -3
- package/dist/chunk-EI2MOVQ3.cjs.map +1 -0
- package/dist/chunk-FURT6ZFZ.cjs +1 -0
- package/dist/chunk-FURT6ZFZ.cjs.map +1 -0
- package/dist/{chunk-GPWNYQ7R.js → chunk-O2W2SP3C.js} +197 -2
- package/dist/chunk-O2W2SP3C.js.map +1 -0
- package/dist/{chunk-UN33YOXW.cjs → chunk-PA5S7KPC.cjs} +293 -2
- package/dist/chunk-PA5S7KPC.cjs.map +1 -0
- package/dist/{chunk-IB3ZHQAX.js → chunk-PTYWCFFW.js} +29 -4
- package/dist/chunk-PTYWCFFW.js.map +1 -0
- package/dist/{chunk-JQ3BB3E6.js → chunk-PXDEFEG2.js} +293 -2
- package/dist/chunk-PXDEFEG2.js.map +1 -0
- package/dist/chunk-REOJJIY3.js +201 -0
- package/dist/chunk-REOJJIY3.js.map +1 -0
- package/dist/chunk-RJ2BFKEN.js +1 -0
- package/dist/chunk-RJ2BFKEN.js.map +1 -0
- package/dist/{chunk-YU4WQE5M.cjs → chunk-TAPXWP2B.cjs} +95 -377
- package/dist/chunk-TAPXWP2B.cjs.map +1 -0
- package/dist/{chunk-HXDMZQTD.cjs → chunk-TPOT575P.cjs} +29 -4
- package/dist/{chunk-IB3ZHQAX.js.map → chunk-TPOT575P.cjs.map} +1 -1
- package/dist/chunk-VJUVNERT.cjs +201 -0
- package/dist/chunk-VJUVNERT.cjs.map +1 -0
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +2 -2
- package/dist/commands/index.d.ts +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/diagram/index.d.cts +1 -1
- package/dist/diagram/index.d.ts +1 -1
- package/dist/dom-capture-7Wvf6Tyg.d.ts +59 -0
- package/dist/dom-capture-GyYuE-zq.d.cts +59 -0
- package/dist/generation/index.cjs +932 -791
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +268 -242
- package/dist/generation/index.d.ts +268 -242
- package/dist/generation/index.js +926 -785
- package/dist/generation/index.js.map +1 -1
- package/dist/image-editor/index.cjs +362 -2
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +35 -2
- package/dist/image-editor/index.d.ts +35 -2
- package/dist/image-editor/index.js +361 -1
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -16
- package/dist/{registry-DIpIaCkH.d.cts → registry-BqA1AZt0.d.cts} +1 -1
- package/dist/{registry-7AZFuand.d.ts → registry-D-4fit9C.d.ts} +1 -1
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +16 -16
- package/dist/tools/index.cjs +33 -4
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +4 -2
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.js +43 -14
- package/dist/video-editor/index.d.cts +1 -1
- package/dist/video-editor/index.d.ts +1 -1
- package/package.json +2 -1
- package/skills/README.md +55 -0
- package/skills/pixerate-agent-tools/SKILL.md +75 -0
- package/skills/pixerate-animation-editor/SKILL.md +155 -0
- package/skills/pixerate-animation-editor/references/commands.md +123 -0
- package/skills/pixerate-canvas/SKILL.md +231 -0
- package/skills/pixerate-chart/SKILL.md +190 -0
- package/skills/pixerate-diagram/SKILL.md +134 -0
- package/skills/pixerate-generation/SKILL.md +109 -0
- package/skills/pixerate-image-editor/SKILL.md +140 -0
- package/skills/pixerate-parameters/SKILL.md +83 -0
- package/skills/pixerate-rich-text/SKILL.md +160 -0
- package/skills/pixerate-spreadsheet/SKILL.md +146 -0
- package/skills/pixerate-vector/SKILL.md +191 -0
- package/skills/pixerate-vector/references/commands.md +138 -0
- package/skills/pixerate-video-editor/SKILL.md +173 -0
- package/dist/chunk-2CJ3LPYQ.js.map +0 -1
- package/dist/chunk-GPWNYQ7R.js.map +0 -1
- package/dist/chunk-HXDMZQTD.cjs.map +0 -1
- package/dist/chunk-JQ3BB3E6.js.map +0 -1
- package/dist/chunk-K73CKYUM.cjs.map +0 -1
- package/dist/chunk-UN33YOXW.cjs.map +0 -1
- package/dist/chunk-YU4WQE5M.cjs.map +0 -1
package/dist/canvas/index.js
CHANGED
|
@@ -63,6 +63,15 @@ import {
|
|
|
63
63
|
overlaps,
|
|
64
64
|
placeBeside
|
|
65
65
|
} from "../chunk-VHZCXHS4.js";
|
|
66
|
+
import {
|
|
67
|
+
CAPTURE_EXCLUDE_SELECTOR,
|
|
68
|
+
CAPTURE_OVERLAY_SELECTORS,
|
|
69
|
+
rasterizeElement
|
|
70
|
+
} from "../chunk-O2W2SP3C.js";
|
|
71
|
+
import {
|
|
72
|
+
createCaptureToolProvider,
|
|
73
|
+
unionCaptureRects
|
|
74
|
+
} from "../chunk-REOJJIY3.js";
|
|
66
75
|
import {
|
|
67
76
|
DEFAULT_ARRANGE_SHORTCUTS,
|
|
68
77
|
matchArrangeShortcut
|
|
@@ -854,17 +863,17 @@ function readStyleSize(style) {
|
|
|
854
863
|
};
|
|
855
864
|
return { width: read("width"), height: read("height") };
|
|
856
865
|
}
|
|
857
|
-
function withStyleSize(style,
|
|
866
|
+
function withStyleSize(style, size2) {
|
|
858
867
|
if (!style) return style ?? void 0;
|
|
859
868
|
if (typeof style === "object") {
|
|
860
869
|
const next2 = { ...style };
|
|
861
|
-
if (
|
|
862
|
-
if (
|
|
870
|
+
if (size2.width !== void 0 && "width" in next2) next2.width = size2.width;
|
|
871
|
+
if (size2.height !== void 0 && "height" in next2) next2.height = size2.height;
|
|
863
872
|
return next2;
|
|
864
873
|
}
|
|
865
874
|
let next = style;
|
|
866
875
|
for (const prop of ["width", "height"]) {
|
|
867
|
-
const value =
|
|
876
|
+
const value = size2[prop];
|
|
868
877
|
if (value === void 0) continue;
|
|
869
878
|
next = next.replace(
|
|
870
879
|
new RegExp(`((?:^|;)\\s*${prop}\\s*:\\s*)[^;]+`, "i"),
|
|
@@ -1009,9 +1018,9 @@ function alignNodes(nodes, ids, edge, options = {}) {
|
|
|
1009
1018
|
}
|
|
1010
1019
|
function distributeAxis(items, horizontal, mode, gapOverride, targets) {
|
|
1011
1020
|
const start = (r) => horizontal ? r.x : r.y;
|
|
1012
|
-
const
|
|
1021
|
+
const size2 = (r) => horizontal ? r.width : r.height;
|
|
1013
1022
|
const sorted = [...items].sort(
|
|
1014
|
-
(a, b) => start(a.rect) +
|
|
1023
|
+
(a, b) => start(a.rect) + size2(a.rect) / 2 - (start(b.rect) + size2(b.rect) / 2)
|
|
1015
1024
|
);
|
|
1016
1025
|
const first = sorted[0].rect;
|
|
1017
1026
|
const last = sorted[sorted.length - 1].rect;
|
|
@@ -1022,19 +1031,19 @@ function distributeAxis(items, horizontal, mode, gapOverride, targets) {
|
|
|
1022
1031
|
targets.set(item.node.id, horizontal ? { ...current, x: value } : { ...current, y: value });
|
|
1023
1032
|
};
|
|
1024
1033
|
if (mode === "centres") {
|
|
1025
|
-
const c0 = start(first) +
|
|
1026
|
-
const c1 = start(last) +
|
|
1034
|
+
const c0 = start(first) + size2(first) / 2;
|
|
1035
|
+
const c1 = start(last) + size2(last) / 2;
|
|
1027
1036
|
const step = (c1 - c0) / (n3 - 1);
|
|
1028
|
-
sorted.forEach((item, i) => set(item, c0 + step * i -
|
|
1037
|
+
sorted.forEach((item, i) => set(item, c0 + step * i - size2(item.rect) / 2));
|
|
1029
1038
|
return;
|
|
1030
1039
|
}
|
|
1031
|
-
const span = start(last) +
|
|
1032
|
-
const total = sorted.reduce((sum, item) => sum +
|
|
1040
|
+
const span = start(last) + size2(last) - start(first);
|
|
1041
|
+
const total = sorted.reduce((sum, item) => sum + size2(item.rect), 0);
|
|
1033
1042
|
const gap = gapOverride ?? (span - total) / (n3 - 1);
|
|
1034
1043
|
let cursor = start(first);
|
|
1035
1044
|
for (const item of sorted) {
|
|
1036
1045
|
set(item, cursor);
|
|
1037
|
-
cursor +=
|
|
1046
|
+
cursor += size2(item.rect) + gap;
|
|
1038
1047
|
}
|
|
1039
1048
|
}
|
|
1040
1049
|
function distributeNodes(nodes, ids, axis, mode = "gaps", options = {}) {
|
|
@@ -1175,9 +1184,9 @@ function invertNodeUpdates(nodes, updates) {
|
|
|
1175
1184
|
if (update.position) back.position = { ...node.position };
|
|
1176
1185
|
if (update.zIndex !== void 0) back.zIndex = typeof node.zIndex === "number" ? node.zIndex : 0;
|
|
1177
1186
|
if (update.width !== void 0 || update.height !== void 0) {
|
|
1178
|
-
const
|
|
1179
|
-
if (update.width !== void 0) back.width =
|
|
1180
|
-
if (update.height !== void 0) back.height =
|
|
1187
|
+
const size2 = getNodeSize(node);
|
|
1188
|
+
if (update.width !== void 0) back.width = size2.width;
|
|
1189
|
+
if (update.height !== void 0) back.height = size2.height;
|
|
1181
1190
|
}
|
|
1182
1191
|
inverse.push(back);
|
|
1183
1192
|
}
|
|
@@ -1247,7 +1256,7 @@ function spacingCandidate(rects, moving, horizontal, tolerance) {
|
|
|
1247
1256
|
const end = (r) => horizontal ? r.x + r.width : r.y + r.height;
|
|
1248
1257
|
const crossStart = (r) => horizontal ? r.y : r.x;
|
|
1249
1258
|
const crossEnd = (r) => horizontal ? r.y + r.height : r.x + r.width;
|
|
1250
|
-
const
|
|
1259
|
+
const size2 = end(moving) - start(moving);
|
|
1251
1260
|
const inLane = (r, lane2) => crossStart(r) < crossEnd(lane2) && crossEnd(r) > crossStart(lane2);
|
|
1252
1261
|
const lane = rects.filter((r) => inLane(r, moving));
|
|
1253
1262
|
if (lane.length === 0) return null;
|
|
@@ -1273,13 +1282,13 @@ function spacingCandidate(rects, moving, horizontal, tolerance) {
|
|
|
1273
1282
|
if (before && after) {
|
|
1274
1283
|
const b = before;
|
|
1275
1284
|
const a = after;
|
|
1276
|
-
const pos = (end(b) + start(a) -
|
|
1285
|
+
const pos = (end(b) + start(a) - size2) / 2;
|
|
1277
1286
|
if (pos >= end(b)) {
|
|
1278
1287
|
candidates.push({
|
|
1279
1288
|
pos,
|
|
1280
1289
|
guides: (p) => [
|
|
1281
1290
|
segment(end(b), p, crossMid(b, moving)),
|
|
1282
|
-
segment(p +
|
|
1291
|
+
segment(p + size2, start(a), crossMid(a, moving))
|
|
1283
1292
|
]
|
|
1284
1293
|
});
|
|
1285
1294
|
}
|
|
@@ -1301,8 +1310,8 @@ function spacingCandidate(rects, moving, horizontal, tolerance) {
|
|
|
1301
1310
|
if (next) {
|
|
1302
1311
|
const gap = start(next) - end(a);
|
|
1303
1312
|
candidates.push({
|
|
1304
|
-
pos: start(a) - gap -
|
|
1305
|
-
guides: (p) => [segment(p +
|
|
1313
|
+
pos: start(a) - gap - size2,
|
|
1314
|
+
guides: (p) => [segment(p + size2, start(a), crossMid(a, moving)), segment(end(a), start(next), crossMid(a, next))]
|
|
1306
1315
|
});
|
|
1307
1316
|
}
|
|
1308
1317
|
}
|
|
@@ -1325,7 +1334,7 @@ function computeSnapGuides(moving, targets, options = {}) {
|
|
|
1325
1334
|
const eps = 0.5 / zoom;
|
|
1326
1335
|
const snapAxis = (horizontal) => {
|
|
1327
1336
|
const start = horizontal ? moving.x : moving.y;
|
|
1328
|
-
const
|
|
1337
|
+
const size2 = horizontal ? moving.width : moving.height;
|
|
1329
1338
|
const edgeAxis = horizontal ? index.edgeX : index.edgeY;
|
|
1330
1339
|
const centreAxis = horizontal ? index.centreX : index.centreY;
|
|
1331
1340
|
let delta = null;
|
|
@@ -1334,9 +1343,9 @@ function computeSnapGuides(moving, targets, options = {}) {
|
|
|
1334
1343
|
};
|
|
1335
1344
|
if (useEdges) {
|
|
1336
1345
|
consider(nearest(edgeAxis, start, tolerance));
|
|
1337
|
-
consider(nearest(edgeAxis, start +
|
|
1346
|
+
consider(nearest(edgeAxis, start + size2, tolerance));
|
|
1338
1347
|
}
|
|
1339
|
-
if (useCentres) consider(nearest(centreAxis, start +
|
|
1348
|
+
if (useCentres) consider(nearest(centreAxis, start + size2 / 2, tolerance));
|
|
1340
1349
|
const spacing = useSpacing ? spacingCandidate(index.rects, moving, horizontal, tolerance) : null;
|
|
1341
1350
|
if (spacing && (delta === null || Math.abs(spacing.delta) < Math.abs(delta) - eps)) {
|
|
1342
1351
|
return { delta: spacing.delta, spacing };
|
|
@@ -1353,14 +1362,14 @@ function computeSnapGuides(moving, targets, options = {}) {
|
|
|
1353
1362
|
const guides = [];
|
|
1354
1363
|
const alignmentGuides = (horizontal) => {
|
|
1355
1364
|
const start = horizontal ? snapped.x : snapped.y;
|
|
1356
|
-
const
|
|
1365
|
+
const size2 = horizontal ? snapped.width : snapped.height;
|
|
1357
1366
|
const lines = [];
|
|
1358
1367
|
if (useEdges) {
|
|
1359
1368
|
const axis = horizontal ? index.edgeX : index.edgeY;
|
|
1360
|
-
lines.push({ value: start, kind: "edge", axis }, { value: start +
|
|
1369
|
+
lines.push({ value: start, kind: "edge", axis }, { value: start + size2, kind: "edge", axis });
|
|
1361
1370
|
}
|
|
1362
1371
|
if (useCentres) {
|
|
1363
|
-
lines.push({ value: start +
|
|
1372
|
+
lines.push({ value: start + size2 / 2, kind: "centre", axis: horizontal ? index.centreX : index.centreY });
|
|
1364
1373
|
}
|
|
1365
1374
|
for (const line4 of lines) {
|
|
1366
1375
|
const aligned = matches(line4.axis, line4.value, eps);
|
|
@@ -1762,22 +1771,22 @@ var CanvasScenesStore = class {
|
|
|
1762
1771
|
function createCanvasScenesStore(options) {
|
|
1763
1772
|
return new CanvasScenesStore(options);
|
|
1764
1773
|
}
|
|
1765
|
-
function fitViewportToRect(rect2,
|
|
1774
|
+
function fitViewportToRect(rect2, size2, options = {}) {
|
|
1766
1775
|
const { padding = 0.1, minZoom = 0.1, maxZoom = 2 } = options;
|
|
1767
1776
|
const paddedWidth = Math.max(rect2.width * (1 + padding * 2), 1);
|
|
1768
1777
|
const paddedHeight = Math.max(rect2.height * (1 + padding * 2), 1);
|
|
1769
|
-
const raw = Math.min(
|
|
1778
|
+
const raw = Math.min(size2.width / paddedWidth, size2.height / paddedHeight);
|
|
1770
1779
|
const zoom = Math.min(maxZoom, Math.max(minZoom, raw));
|
|
1771
1780
|
const cx = rect2.x + rect2.width / 2;
|
|
1772
1781
|
const cy = rect2.y + rect2.height / 2;
|
|
1773
|
-
return { x:
|
|
1782
|
+
return { x: size2.width / 2 - cx * zoom, y: size2.height / 2 - cy * zoom, zoom };
|
|
1774
1783
|
}
|
|
1775
|
-
function fitViewportToNodes(nodes,
|
|
1784
|
+
function fitViewportToNodes(nodes, size2, ids, options = {}) {
|
|
1776
1785
|
const lookup = createNodeLookup(nodes);
|
|
1777
1786
|
const wanted = ids ? new Set(ids) : null;
|
|
1778
1787
|
const rects = nodes.filter((n3) => wanted ? wanted.has(n3.id) : true).map((n3) => getNodeRect(n3, lookup, options));
|
|
1779
1788
|
const bounds = boundsOf(rects);
|
|
1780
|
-
return bounds ? fitViewportToRect(bounds,
|
|
1789
|
+
return bounds ? fitViewportToRect(bounds, size2, options) : null;
|
|
1781
1790
|
}
|
|
1782
1791
|
|
|
1783
1792
|
// src/canvas/shapeNodes.ts
|
|
@@ -1800,18 +1809,18 @@ function getNodeShape(node) {
|
|
|
1800
1809
|
function shapeNodeToPolygon(node, lookup, options = {}) {
|
|
1801
1810
|
const shape = getNodeShape(node);
|
|
1802
1811
|
if (!shape) return null;
|
|
1803
|
-
const
|
|
1812
|
+
const size2 = getNodeSize(node, options);
|
|
1804
1813
|
const origin = node.parentId && lookup ? getAbsolutePosition(node, lookup) : node.position;
|
|
1805
|
-
const { rings, fillRule } = shapeToPolygon(shape,
|
|
1814
|
+
const { rings, fillRule } = shapeToPolygon(shape, size2, { tolerance: options.tolerance });
|
|
1806
1815
|
return {
|
|
1807
1816
|
rings: rings.map((ring) => ring.map(([x, y]) => [x + origin.x, y + origin.y])),
|
|
1808
1817
|
fillRule
|
|
1809
1818
|
};
|
|
1810
1819
|
}
|
|
1811
|
-
function shapeToBezierPath(shape,
|
|
1812
|
-
const { width: w, height: h } =
|
|
1820
|
+
function shapeToBezierPath(shape, size2) {
|
|
1821
|
+
const { width: w, height: h } = size2;
|
|
1813
1822
|
if (!(w > 0) || !(h > 0)) return { path: [], fillRule: "nonzero" };
|
|
1814
|
-
const svg = getShapeSvg({ ...shape, rotation: 0 },
|
|
1823
|
+
const svg = getShapeSvg({ ...shape, rotation: 0 }, size2);
|
|
1815
1824
|
let path = toBezierPath(svg.d);
|
|
1816
1825
|
if (shape.kind === "path" && shape.viewBox) {
|
|
1817
1826
|
const vb = shape.viewBox;
|
|
@@ -1836,9 +1845,9 @@ function shapeToBezierPath(shape, size) {
|
|
|
1836
1845
|
function shapeNodeToBezierPath(node, lookup, options = {}) {
|
|
1837
1846
|
const shape = getNodeShape(node);
|
|
1838
1847
|
if (!shape) return null;
|
|
1839
|
-
const
|
|
1848
|
+
const size2 = getNodeSize(node, options);
|
|
1840
1849
|
const origin = node.parentId && lookup ? getAbsolutePosition(node, lookup) : node.position;
|
|
1841
|
-
const { path, fillRule } = shapeToBezierPath(shape,
|
|
1850
|
+
const { path, fillRule } = shapeToBezierPath(shape, size2);
|
|
1842
1851
|
return { path: transformBezierPath(path, [1, 0, 0, 1, origin.x, origin.y]), fillRule };
|
|
1843
1852
|
}
|
|
1844
1853
|
var idCounter = 0;
|
|
@@ -2233,8 +2242,8 @@ function snapResize(rect2, handle, targets, options = {}) {
|
|
|
2233
2242
|
const fixed = horizontal ? dir < 0 ? x1 : x0 : dir < 0 ? y1 : y0;
|
|
2234
2243
|
const min = (horizontal ? options.minWidth : options.minHeight) ?? 0;
|
|
2235
2244
|
const valid = (t) => {
|
|
2236
|
-
const
|
|
2237
|
-
return Number.isFinite(
|
|
2245
|
+
const size2 = dir < 0 ? fixed - t : t - fixed;
|
|
2246
|
+
return Number.isFinite(size2) && size2 > 1e-9 && size2 >= min;
|
|
2238
2247
|
};
|
|
2239
2248
|
let best = null;
|
|
2240
2249
|
const consider = (values, kind) => {
|
|
@@ -2351,8 +2360,8 @@ function snapNodeResize(nodes, id, rect2, handle, options = {}) {
|
|
|
2351
2360
|
}
|
|
2352
2361
|
function getResizingNodeRect(node, lookup, options = {}) {
|
|
2353
2362
|
const { x, y } = node.parentId ? getAbsolutePosition(node, lookup) : node.position;
|
|
2354
|
-
const
|
|
2355
|
-
return { x, y, width: node.width ??
|
|
2363
|
+
const size2 = getNodeSize(node, options);
|
|
2364
|
+
return { x, y, width: node.width ?? size2.width, height: node.height ?? size2.height };
|
|
2356
2365
|
}
|
|
2357
2366
|
|
|
2358
2367
|
// src/canvas/autoLayout.ts
|
|
@@ -2408,15 +2417,15 @@ var LayoutState = class {
|
|
|
2408
2417
|
constructor(nodes, options = {}) {
|
|
2409
2418
|
this.measure = options.measure ?? {};
|
|
2410
2419
|
for (const node of nodes) {
|
|
2411
|
-
const
|
|
2420
|
+
const size2 = this.measure.size?.(node) ?? getNodeSize(node, options.rectOptions);
|
|
2412
2421
|
const box = {
|
|
2413
2422
|
id: node.id,
|
|
2414
2423
|
node,
|
|
2415
2424
|
parent: node.parentId,
|
|
2416
2425
|
x: finite(node.position?.x),
|
|
2417
2426
|
y: finite(node.position?.y),
|
|
2418
|
-
w: finite(
|
|
2419
|
-
h: finite(
|
|
2427
|
+
w: finite(size2.width),
|
|
2428
|
+
h: finite(size2.height),
|
|
2420
2429
|
kids: []
|
|
2421
2430
|
};
|
|
2422
2431
|
this.boxes.set(node.id, box);
|
|
@@ -2911,9 +2920,9 @@ function trackContent(cells, sizes, tracks, n3, gap, columns, hug) {
|
|
|
2911
2920
|
}
|
|
2912
2921
|
function trackRanges(start, sizes, gap) {
|
|
2913
2922
|
let x = start;
|
|
2914
|
-
return sizes.map((
|
|
2915
|
-
const r = [x, x +
|
|
2916
|
-
x +=
|
|
2923
|
+
return sizes.map((size2) => {
|
|
2924
|
+
const r = [x, x + size2];
|
|
2925
|
+
x += size2 + gap;
|
|
2917
2926
|
return r;
|
|
2918
2927
|
});
|
|
2919
2928
|
}
|
|
@@ -3908,14 +3917,14 @@ function createCanvasAutoLayoutController(options) {
|
|
|
3908
3917
|
* Resizes node `id` (its children follow their constraints) and lays out around it,
|
|
3909
3918
|
* as one step.
|
|
3910
3919
|
*/
|
|
3911
|
-
resizeNode(id,
|
|
3920
|
+
resizeNode(id, size2) {
|
|
3912
3921
|
const nodes = options.getNodes();
|
|
3913
3922
|
const node = nodes.find((n3) => n3.id === id);
|
|
3914
3923
|
if (!node) return [];
|
|
3915
3924
|
const old = getNodeSize(node, options.rectOptions);
|
|
3916
3925
|
const update = { id };
|
|
3917
|
-
if (
|
|
3918
|
-
if (
|
|
3926
|
+
if (size2.width !== void 0) update.width = size2.width;
|
|
3927
|
+
if (size2.height !== void 0) update.height = size2.height;
|
|
3919
3928
|
const resized = applyNodeUpdates(nodes, [update]);
|
|
3920
3929
|
const constrained = mergeNodeUpdates([update], applyConstraints(resized, id, old, layoutOptions()));
|
|
3921
3930
|
return run("Resize", identity, identity, () => [id], constrained);
|
|
@@ -6538,9 +6547,9 @@ function rootReference(g, comp) {
|
|
|
6538
6547
|
}
|
|
6539
6548
|
function fixMeasured(node, old) {
|
|
6540
6549
|
const measured2 = old?.measured ?? node.measured;
|
|
6541
|
-
const
|
|
6542
|
-
const w =
|
|
6543
|
-
const h =
|
|
6550
|
+
const size2 = sizeOf(node);
|
|
6551
|
+
const w = size2.width ?? size2.styleWidth;
|
|
6552
|
+
const h = size2.height ?? size2.styleHeight;
|
|
6544
6553
|
if (!measured2) {
|
|
6545
6554
|
if (node.measured === void 0) return node;
|
|
6546
6555
|
const next = { ...node };
|
|
@@ -6648,17 +6657,17 @@ function buildInstance(g, instId, opts, taken) {
|
|
|
6648
6657
|
const sizing = getLayoutSizing(next, axis);
|
|
6649
6658
|
return sizing === "hug" && !!getAutoLayout(next) || sizing === "fill" && flows;
|
|
6650
6659
|
};
|
|
6651
|
-
const
|
|
6660
|
+
const size2 = { ...sizeOf(next) };
|
|
6652
6661
|
const oldSize = sizeOf(o);
|
|
6653
6662
|
if (derived("width")) {
|
|
6654
|
-
|
|
6655
|
-
|
|
6663
|
+
size2.width = oldSize.width;
|
|
6664
|
+
size2.styleWidth = oldSize.styleWidth;
|
|
6656
6665
|
}
|
|
6657
6666
|
if (derived("height")) {
|
|
6658
|
-
|
|
6659
|
-
|
|
6667
|
+
size2.height = oldSize.height;
|
|
6668
|
+
size2.styleHeight = oldSize.styleHeight;
|
|
6660
6669
|
}
|
|
6661
|
-
return writeOverrideGroup(next, "size",
|
|
6670
|
+
return writeOverrideGroup(next, "size", size2);
|
|
6662
6671
|
};
|
|
6663
6672
|
const instanceRoot = (look, place2, old2, id, parentId, sourceId, instance, previousComponent, topLevel) => {
|
|
6664
6673
|
const reference = rootReference(g, look);
|
|
@@ -7699,10 +7708,10 @@ function addCanvasVariant(nodes, setId, options = {}) {
|
|
|
7699
7708
|
});
|
|
7700
7709
|
if (autoLayout && !options.position) after = relayoutSet(after, setId, options);
|
|
7701
7710
|
else {
|
|
7702
|
-
const
|
|
7703
|
-
const w = Math.max(
|
|
7704
|
-
const h = Math.max(
|
|
7705
|
-
if (w !==
|
|
7711
|
+
const size2 = getNodeSize(edit.set);
|
|
7712
|
+
const w = Math.max(size2.width, position.x + width + VARIANT_GAP);
|
|
7713
|
+
const h = Math.max(size2.height, position.y + height + VARIANT_GAP);
|
|
7714
|
+
if (w !== size2.width || h !== size2.height) after = applyNodeUpdates(after, [{ id: setId, width: w, height: h }]);
|
|
7706
7715
|
}
|
|
7707
7716
|
return done(nodes, after, [id], options);
|
|
7708
7717
|
}
|
|
@@ -8692,11 +8701,11 @@ function diagramGroupSize(groupId, graph, positions, sizes, meta, pad = 24, titl
|
|
|
8692
8701
|
let maxX = 0;
|
|
8693
8702
|
let maxY = 0;
|
|
8694
8703
|
for (const id of members) {
|
|
8695
|
-
const
|
|
8696
|
-
sizes[id] =
|
|
8704
|
+
const size2 = sizes[id] ?? (graph.groups.some((g) => g.id === id) ? diagramGroupSize(id, graph, positions, sizes, meta, pad, titleH) : { width: DEFAULT_DIAGRAM_NODE_WIDTH, height: DEFAULT_DIAGRAM_NODE_HEIGHT });
|
|
8705
|
+
sizes[id] = size2;
|
|
8697
8706
|
const [x, y] = positions[id] ?? [gx, gy];
|
|
8698
|
-
maxX = Math.max(maxX, x - gx +
|
|
8699
|
-
maxY = Math.max(maxY, y - gy +
|
|
8707
|
+
maxX = Math.max(maxX, x - gx + size2.width);
|
|
8708
|
+
maxY = Math.max(maxY, y - gy + size2.height);
|
|
8700
8709
|
}
|
|
8701
8710
|
return { width: maxX + pad, height: maxY + pad };
|
|
8702
8711
|
}
|
|
@@ -8743,7 +8752,7 @@ function mermaidFlowNodes(graph, layout2, options = {}) {
|
|
|
8743
8752
|
return { x: x - px2, y: y - py };
|
|
8744
8753
|
};
|
|
8745
8754
|
const groups = graph.groups.map((g) => {
|
|
8746
|
-
const
|
|
8755
|
+
const size2 = sizes[g.id] ?? { width: 240, height: 160 };
|
|
8747
8756
|
return {
|
|
8748
8757
|
id: g.id,
|
|
8749
8758
|
type: "mermaid-group",
|
|
@@ -8755,9 +8764,9 @@ function mermaidFlowNodes(graph, layout2, options = {}) {
|
|
|
8755
8764
|
resolvedStyles: resolveMermaidStyles(g.classes, g.styles, graph.classDefs),
|
|
8756
8765
|
editable
|
|
8757
8766
|
},
|
|
8758
|
-
width:
|
|
8759
|
-
height:
|
|
8760
|
-
style: { width:
|
|
8767
|
+
width: size2.width,
|
|
8768
|
+
height: size2.height,
|
|
8769
|
+
style: { width: size2.width, height: size2.height },
|
|
8761
8770
|
draggable: editable && !g.data?.locked,
|
|
8762
8771
|
selectable: editable,
|
|
8763
8772
|
connectable: editable && !g.data?.locked,
|
|
@@ -8765,7 +8774,7 @@ function mermaidFlowNodes(graph, layout2, options = {}) {
|
|
|
8765
8774
|
};
|
|
8766
8775
|
});
|
|
8767
8776
|
const nodes = graph.nodes.map((n3) => {
|
|
8768
|
-
const
|
|
8777
|
+
const size2 = sizes[n3.id] ?? { width: 160, height: 56 };
|
|
8769
8778
|
return {
|
|
8770
8779
|
id: n3.id,
|
|
8771
8780
|
type: "mermaid-node",
|
|
@@ -8777,9 +8786,9 @@ function mermaidFlowNodes(graph, layout2, options = {}) {
|
|
|
8777
8786
|
resolvedStyles: resolveMermaidStyles(n3.classes, n3.styles, graph.classDefs),
|
|
8778
8787
|
editable
|
|
8779
8788
|
},
|
|
8780
|
-
width:
|
|
8781
|
-
height:
|
|
8782
|
-
style: { width:
|
|
8789
|
+
width: size2.width,
|
|
8790
|
+
height: size2.height,
|
|
8791
|
+
style: { width: size2.width, height: size2.height },
|
|
8783
8792
|
draggable: editable && !n3.data?.locked,
|
|
8784
8793
|
selectable: editable,
|
|
8785
8794
|
connectable: editable && !n3.data?.locked && !n3.data?.synthetic,
|
|
@@ -8833,11 +8842,11 @@ function diagramLayoutBounds(layout2) {
|
|
|
8833
8842
|
let maxX = -Infinity;
|
|
8834
8843
|
let maxY = -Infinity;
|
|
8835
8844
|
for (const [id, [x, y]] of Object.entries(layout2.positions)) {
|
|
8836
|
-
const
|
|
8845
|
+
const size2 = layout2.sizes[id] ?? { width: 0, height: 0 };
|
|
8837
8846
|
minX = Math.min(minX, x);
|
|
8838
8847
|
minY = Math.min(minY, y);
|
|
8839
|
-
maxX = Math.max(maxX, x +
|
|
8840
|
-
maxY = Math.max(maxY, y +
|
|
8848
|
+
maxX = Math.max(maxX, x + size2.width);
|
|
8849
|
+
maxY = Math.max(maxY, y + size2.height);
|
|
8841
8850
|
}
|
|
8842
8851
|
if (minX === Infinity) return null;
|
|
8843
8852
|
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
@@ -8867,9 +8876,9 @@ function blendDiagramLayout(from, to, t) {
|
|
|
8867
8876
|
positions[id] = origin ? [mix2(origin[0], x, t), mix2(origin[1], y, t)] : [x, y];
|
|
8868
8877
|
}
|
|
8869
8878
|
const sizes = {};
|
|
8870
|
-
for (const [id,
|
|
8879
|
+
for (const [id, size2] of Object.entries(to.sizes)) {
|
|
8871
8880
|
const origin = from.sizes[id];
|
|
8872
|
-
sizes[id] = origin ? { width: mix2(origin.width,
|
|
8881
|
+
sizes[id] = origin ? { width: mix2(origin.width, size2.width, t), height: mix2(origin.height, size2.height, t) } : size2;
|
|
8873
8882
|
}
|
|
8874
8883
|
return { positions, sizes };
|
|
8875
8884
|
}
|
|
@@ -8989,8 +8998,8 @@ var DIAGRAM_TITLE_TARGET = "::title";
|
|
|
8989
8998
|
function sceneColor(theme, i) {
|
|
8990
8999
|
return theme.palette[(i % theme.palette.length + theme.palette.length) % theme.palette.length];
|
|
8991
9000
|
}
|
|
8992
|
-
function estimateTextWidth2(text2,
|
|
8993
|
-
return text2.length *
|
|
9001
|
+
function estimateTextWidth2(text2, size2) {
|
|
9002
|
+
return text2.length * size2 * 0.58;
|
|
8994
9003
|
}
|
|
8995
9004
|
|
|
8996
9005
|
// src/canvas/mermaid/families/pie.ts
|
|
@@ -9383,13 +9392,13 @@ var TITLE_SIZE2 = 32;
|
|
|
9383
9392
|
function actorColor(theme, slot) {
|
|
9384
9393
|
return sceneColor(theme, M3.sectionColours + slot);
|
|
9385
9394
|
}
|
|
9386
|
-
function wrapLines(text2,
|
|
9395
|
+
function wrapLines(text2, size2, max) {
|
|
9387
9396
|
const lines = [];
|
|
9388
9397
|
for (const para of text2.replace(/<br\s*\/?>/gi, "\n").split("\n")) {
|
|
9389
9398
|
let line4 = "";
|
|
9390
9399
|
for (const word of para.split(/\s+/).filter(Boolean)) {
|
|
9391
9400
|
const next = line4 ? `${line4} ${word}` : word;
|
|
9392
|
-
if (line4 && estimateTextWidth2(next,
|
|
9401
|
+
if (line4 && estimateTextWidth2(next, size2) > max) {
|
|
9393
9402
|
lines.push(line4);
|
|
9394
9403
|
line4 = word;
|
|
9395
9404
|
} else line4 = next;
|
|
@@ -9399,13 +9408,13 @@ function wrapLines(text2, size, max) {
|
|
|
9399
9408
|
return lines;
|
|
9400
9409
|
}
|
|
9401
9410
|
function boxLabel(key, role, target, text2, box, fill) {
|
|
9402
|
-
let
|
|
9403
|
-
let lines = wrapLines(text2,
|
|
9411
|
+
let size2 = M3.fontSize;
|
|
9412
|
+
let lines = wrapLines(text2, size2, box.width - 10);
|
|
9404
9413
|
if (lines.length > 2) {
|
|
9405
|
-
|
|
9406
|
-
lines = wrapLines(text2,
|
|
9414
|
+
size2 = 13;
|
|
9415
|
+
lines = wrapLines(text2, size2, box.width - 8);
|
|
9407
9416
|
}
|
|
9408
|
-
const lineHeight =
|
|
9417
|
+
const lineHeight = size2 * 1.15;
|
|
9409
9418
|
const max = Math.max(1, Math.floor(box.height / lineHeight));
|
|
9410
9419
|
if (lines.length > max) lines = [...lines.slice(0, max - 1), `${lines[max - 1]}\u2026`];
|
|
9411
9420
|
const top = box.y + box.height / 2 - lines.length * lineHeight / 2 + lineHeight / 2;
|
|
@@ -9419,7 +9428,7 @@ function boxLabel(key, role, target, text2, box, fill) {
|
|
|
9419
9428
|
text: line4,
|
|
9420
9429
|
anchor: "middle",
|
|
9421
9430
|
baseline: "middle",
|
|
9422
|
-
size,
|
|
9431
|
+
size: size2,
|
|
9423
9432
|
fill
|
|
9424
9433
|
}));
|
|
9425
9434
|
}
|
|
@@ -10148,7 +10157,7 @@ var c4Scene = ({ graph, layout: layout2, theme }) => {
|
|
|
10148
10157
|
} else marks.push({ kind: "rect", key: `element:${node.id}`, role: "element", ...common, x, y, width: w, height: h, radius: 12 });
|
|
10149
10158
|
let top = y + geo.textCenter.y - geo.textHeight / 2;
|
|
10150
10159
|
for (const section of geo.sections) {
|
|
10151
|
-
const
|
|
10160
|
+
const size2 = section.part === "label" ? NAME_SIZE : section.part === "tech" ? TYPE_SIZE : DESCR_SIZE;
|
|
10152
10161
|
const lh = section.fontSize * LINE_HEIGHT2;
|
|
10153
10162
|
section.lines.forEach((line4, i) => {
|
|
10154
10163
|
if (!line4) return;
|
|
@@ -10162,7 +10171,7 @@ var c4Scene = ({ graph, layout: layout2, theme }) => {
|
|
|
10162
10171
|
text: line4,
|
|
10163
10172
|
anchor: "middle",
|
|
10164
10173
|
baseline: "middle",
|
|
10165
|
-
size,
|
|
10174
|
+
size: size2,
|
|
10166
10175
|
weight: section.bold ? 700 : void 0,
|
|
10167
10176
|
fill: fg
|
|
10168
10177
|
});
|
|
@@ -10316,8 +10325,8 @@ var ARCH_GLYPHS = {
|
|
|
10316
10325
|
],
|
|
10317
10326
|
blank: []
|
|
10318
10327
|
};
|
|
10319
|
-
function iconMarks(key, target, icon, x, y,
|
|
10320
|
-
const s =
|
|
10328
|
+
function iconMarks(key, target, icon, x, y, size2, theme) {
|
|
10329
|
+
const s = size2 / 80;
|
|
10321
10330
|
if (!icon)
|
|
10322
10331
|
return [
|
|
10323
10332
|
{
|
|
@@ -10332,7 +10341,7 @@ function iconMarks(key, target, icon, x, y, size, theme) {
|
|
|
10332
10341
|
dash: "8"
|
|
10333
10342
|
}
|
|
10334
10343
|
];
|
|
10335
|
-
const marks = [{ kind: "rect", key: `icon:${key}`, role: "icon", target, x, y, width:
|
|
10344
|
+
const marks = [{ kind: "rect", key: `icon:${key}`, role: "icon", target, x, y, width: size2, height: size2, fill: ICON_BG }];
|
|
10336
10345
|
const glyph = ARCH_GLYPHS[icon];
|
|
10337
10346
|
if (glyph) {
|
|
10338
10347
|
glyph.forEach(
|
|
@@ -10356,7 +10365,7 @@ function iconMarks(key, target, icon, x, y, size, theme) {
|
|
|
10356
10365
|
const shown = lines.slice(0, Math.max(1, Math.floor(72 * s / (font * 1.2))));
|
|
10357
10366
|
const lh = font * 1.2;
|
|
10358
10367
|
shown.forEach(
|
|
10359
|
-
(text2, i) => marks.push({ kind: "text", key: `icon-name:${key}:${i}`, role: "icon-name", target, x: x +
|
|
10368
|
+
(text2, i) => marks.push({ kind: "text", key: `icon-name:${key}:${i}`, role: "icon-name", target, x: x + size2 / 2, y: y + size2 / 2 + (i - (shown.length - 1) / 2) * lh, text: text2, anchor: "middle", baseline: "middle", size: font, fill: ICON_FG })
|
|
10360
10369
|
);
|
|
10361
10370
|
return marks;
|
|
10362
10371
|
}
|
|
@@ -11186,10 +11195,10 @@ async function rasterizeSvg(svg, options) {
|
|
|
11186
11195
|
const doc = options.document ?? globalThis.document;
|
|
11187
11196
|
const ImageCtor = doc?.defaultView?.Image ?? globalThis.Image;
|
|
11188
11197
|
if (!doc || typeof doc.createElement !== "function" || !ImageCtor) throw new Error(NO_DOM);
|
|
11189
|
-
const
|
|
11198
|
+
const size2 = rasterSize(options.width, options.height, options.scale, options.maxSize);
|
|
11190
11199
|
const canvas = doc.createElement("canvas");
|
|
11191
|
-
canvas.width =
|
|
11192
|
-
canvas.height =
|
|
11200
|
+
canvas.width = size2.width;
|
|
11201
|
+
canvas.height = size2.height;
|
|
11193
11202
|
let context = null;
|
|
11194
11203
|
try {
|
|
11195
11204
|
context = canvas.getContext("2d");
|
|
@@ -11206,12 +11215,12 @@ async function rasterizeSvg(svg, options) {
|
|
|
11206
11215
|
const background = options.background ?? "#ffffff";
|
|
11207
11216
|
if (background !== "transparent") {
|
|
11208
11217
|
context.fillStyle = background;
|
|
11209
|
-
context.fillRect(0, 0,
|
|
11218
|
+
context.fillRect(0, 0, size2.width, size2.height);
|
|
11210
11219
|
}
|
|
11211
|
-
context.drawImage(image, 0, 0,
|
|
11220
|
+
context.drawImage(image, 0, 0, size2.width, size2.height);
|
|
11212
11221
|
const url = canvas.toDataURL("image/png");
|
|
11213
11222
|
if (!url.startsWith("data:image/png")) throw new Error("This canvas cannot export PNG (toDataURL returned no image).");
|
|
11214
|
-
return { data: url.slice(url.indexOf(",") + 1), mimeType: "image/png", width:
|
|
11223
|
+
return { data: url.slice(url.indexOf(",") + 1), mimeType: "image/png", width: size2.width, height: size2.height };
|
|
11215
11224
|
}
|
|
11216
11225
|
function diagramFileName(doc, extension2) {
|
|
11217
11226
|
const base = (doc.graph.title ?? "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
@@ -11385,6 +11394,122 @@ function isAgentCursor(cursor) {
|
|
|
11385
11394
|
}
|
|
11386
11395
|
return false;
|
|
11387
11396
|
}
|
|
11397
|
+
|
|
11398
|
+
// src/canvas/capture.ts
|
|
11399
|
+
var CANVAS_CAPTURE_VIEWPORT_SELECTOR = ".xyflow__viewport, .react-flow__viewport, .svelte-flow__viewport";
|
|
11400
|
+
var CANVAS_CAPTURE_CHROME_SELECTORS = [
|
|
11401
|
+
CAPTURE_EXCLUDE_SELECTOR,
|
|
11402
|
+
".react-flow__panel",
|
|
11403
|
+
".svelte-flow__panel",
|
|
11404
|
+
".react-flow__minimap",
|
|
11405
|
+
".svelte-flow__minimap",
|
|
11406
|
+
".react-flow__controls",
|
|
11407
|
+
".svelte-flow__controls",
|
|
11408
|
+
".react-flow__attribution",
|
|
11409
|
+
".svelte-flow__attribution"
|
|
11410
|
+
];
|
|
11411
|
+
var CANVAS_CAPTURE_OVERLAY_SELECTORS = [
|
|
11412
|
+
...CAPTURE_OVERLAY_SELECTORS,
|
|
11413
|
+
".react-flow__nodesselection",
|
|
11414
|
+
".svelte-flow__nodesselection",
|
|
11415
|
+
".react-flow__selection",
|
|
11416
|
+
".svelte-flow__selection",
|
|
11417
|
+
".react-flow__resize-control",
|
|
11418
|
+
".svelte-flow__resize-control"
|
|
11419
|
+
];
|
|
11420
|
+
var size = (node) => ({
|
|
11421
|
+
width: node.measured?.width ?? node.width ?? 0,
|
|
11422
|
+
height: node.measured?.height ?? node.height ?? 0
|
|
11423
|
+
});
|
|
11424
|
+
function canvasNodeCaptureRect(node, nodes) {
|
|
11425
|
+
if (node.hidden) return null;
|
|
11426
|
+
let x = node.position.x;
|
|
11427
|
+
let y = node.position.y;
|
|
11428
|
+
const seen = /* @__PURE__ */ new Set([node.id]);
|
|
11429
|
+
let parentId = node.parentId ?? node.parentNode;
|
|
11430
|
+
while (parentId && !seen.has(parentId)) {
|
|
11431
|
+
seen.add(parentId);
|
|
11432
|
+
const parent = nodes.find((n3) => n3.id === parentId);
|
|
11433
|
+
if (!parent) break;
|
|
11434
|
+
x += parent.position.x;
|
|
11435
|
+
y += parent.position.y;
|
|
11436
|
+
parentId = parent.parentId ?? parent.parentNode;
|
|
11437
|
+
}
|
|
11438
|
+
const { width, height } = size(node);
|
|
11439
|
+
return { x, y, width, height };
|
|
11440
|
+
}
|
|
11441
|
+
function createCanvasCaptureSurface(options) {
|
|
11442
|
+
const getElement = () => (typeof options.element === "function" ? options.element() : options.element) ?? null;
|
|
11443
|
+
const nodeRect = (node, nodes) => (options.getNodeRect ?? canvasNodeCaptureRect)(node, nodes);
|
|
11444
|
+
const rectsOf = (nodes, pick) => nodes.filter(pick).map((n3) => nodeRect(n3, nodes)).filter((r) => !!r && r.width > 0 && r.height > 0);
|
|
11445
|
+
const viewportSelector = options.viewportSelector ?? CANVAS_CAPTURE_VIEWPORT_SELECTOR;
|
|
11446
|
+
const viewport = () => {
|
|
11447
|
+
const el = getElement();
|
|
11448
|
+
const vp = options.getViewport();
|
|
11449
|
+
if (!el || !el.clientWidth || !el.clientHeight || !(vp.zoom > 0)) return null;
|
|
11450
|
+
return { x: -vp.x / vp.zoom, y: -vp.y / vp.zoom, width: el.clientWidth / vp.zoom, height: el.clientHeight / vp.zoom };
|
|
11451
|
+
};
|
|
11452
|
+
return {
|
|
11453
|
+
units: "canvas units",
|
|
11454
|
+
viewport,
|
|
11455
|
+
content: () => unionCaptureRects(rectsOf(options.getNodes(), () => true)),
|
|
11456
|
+
selection: () => {
|
|
11457
|
+
const nodes = options.getNodes();
|
|
11458
|
+
const selected = (n3) => !!n3.selected && !n3.hidden;
|
|
11459
|
+
return { rect: unionCaptureRects(rectsOf(nodes, selected)), ids: nodes.filter(selected).map((n3) => n3.id) };
|
|
11460
|
+
},
|
|
11461
|
+
items: {
|
|
11462
|
+
region: "nodes",
|
|
11463
|
+
noun: "node",
|
|
11464
|
+
source: "the canvas state",
|
|
11465
|
+
bounds: (ids) => {
|
|
11466
|
+
const nodes = options.getNodes();
|
|
11467
|
+
const missing = ids.filter((id) => !nodes.some((n3) => n3.id === id));
|
|
11468
|
+
return { rect: unionCaptureRects(rectsOf(nodes, (n3) => ids.includes(n3.id))), missing };
|
|
11469
|
+
}
|
|
11470
|
+
},
|
|
11471
|
+
overlays: "selection boxes, resize handles and agent cursors",
|
|
11472
|
+
maxScale: options.maxScale ?? 2,
|
|
11473
|
+
render: (request) => {
|
|
11474
|
+
const el = getElement();
|
|
11475
|
+
if (!el || !el.isConnected) throw new Error("The canvas is not mounted, so there is nothing to capture.");
|
|
11476
|
+
const rasterize = options.rasterize ?? rasterizeElement;
|
|
11477
|
+
const exclude = [
|
|
11478
|
+
...options.chromeSelectors ?? CANVAS_CAPTURE_CHROME_SELECTORS,
|
|
11479
|
+
...request.includeOverlays ? [] : options.overlaySelectors ?? CANVAS_CAPTURE_OVERLAY_SELECTORS
|
|
11480
|
+
];
|
|
11481
|
+
const common = { pixelWidth: request.width, pixelHeight: request.height, format: request.format, quality: request.quality, background: options.background };
|
|
11482
|
+
if (request.region === "viewport") {
|
|
11483
|
+
return rasterize(el, { ...common, width: el.clientWidth, height: el.clientHeight, exclude });
|
|
11484
|
+
}
|
|
11485
|
+
const zoom = request.scale;
|
|
11486
|
+
return rasterize(el, {
|
|
11487
|
+
...common,
|
|
11488
|
+
width: request.width,
|
|
11489
|
+
height: request.height,
|
|
11490
|
+
exclude,
|
|
11491
|
+
prepare: (clone) => {
|
|
11492
|
+
const vpEl = clone.querySelector(viewportSelector);
|
|
11493
|
+
if (!vpEl) throw new Error(`The canvas has no viewport element (${viewportSelector}); pass viewportSelector.`);
|
|
11494
|
+
vpEl.style.transform = `translate(${-request.rect.x * zoom}px, ${-request.rect.y * zoom}px) scale(${zoom})`;
|
|
11495
|
+
vpEl.style.transformOrigin = "0 0";
|
|
11496
|
+
for (let node = vpEl; node && node !== clone; node = node.parentElement) {
|
|
11497
|
+
for (const sibling of Array.from(node.parentElement?.children ?? [])) {
|
|
11498
|
+
if (sibling !== node) sibling.remove();
|
|
11499
|
+
}
|
|
11500
|
+
}
|
|
11501
|
+
}
|
|
11502
|
+
});
|
|
11503
|
+
}
|
|
11504
|
+
};
|
|
11505
|
+
}
|
|
11506
|
+
function createCanvasCaptureToolProvider(options) {
|
|
11507
|
+
return createCaptureToolProvider(createCanvasCaptureSurface(options), {
|
|
11508
|
+
subject: "the canvas",
|
|
11509
|
+
...options,
|
|
11510
|
+
id: options.id ?? "canvas-capture"
|
|
11511
|
+
});
|
|
11512
|
+
}
|
|
11388
11513
|
export {
|
|
11389
11514
|
ANIMATABLE_PROPERTIES,
|
|
11390
11515
|
ANIMATION_DATA_KEY,
|
|
@@ -11395,6 +11520,9 @@ export {
|
|
|
11395
11520
|
AnimationEditError,
|
|
11396
11521
|
AnimationPlayer,
|
|
11397
11522
|
BUILTIN_FAMILY_SCENES,
|
|
11523
|
+
CANVAS_CAPTURE_CHROME_SELECTORS,
|
|
11524
|
+
CANVAS_CAPTURE_OVERLAY_SELECTORS,
|
|
11525
|
+
CANVAS_CAPTURE_VIEWPORT_SELECTOR,
|
|
11398
11526
|
CANVAS_COMPONENT_DRAG_TYPE,
|
|
11399
11527
|
CANVAS_GRADIENT_PRESETS,
|
|
11400
11528
|
CANVAS_TOKEN_PROPERTIES,
|
|
@@ -11478,6 +11606,7 @@ export {
|
|
|
11478
11606
|
canOffsetShapeNodes,
|
|
11479
11607
|
canOutlineShapeNodeStrokes,
|
|
11480
11608
|
canvasHeight,
|
|
11609
|
+
canvasNodeCaptureRect,
|
|
11481
11610
|
centerNodes,
|
|
11482
11611
|
centre,
|
|
11483
11612
|
clampAnimationValue,
|
|
@@ -11502,6 +11631,8 @@ export {
|
|
|
11502
11631
|
createCanvasAnimationController,
|
|
11503
11632
|
createCanvasArrangeController,
|
|
11504
11633
|
createCanvasAutoLayoutController,
|
|
11634
|
+
createCanvasCaptureSurface,
|
|
11635
|
+
createCanvasCaptureToolProvider,
|
|
11505
11636
|
createCanvasComponent,
|
|
11506
11637
|
createCanvasComponentsController,
|
|
11507
11638
|
createCanvasDrawController,
|