@pixerate/editor 0.14.3 → 0.15.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/dist/agent/index.cjs +28 -220
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +5 -154
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +113 -377
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +2 -2
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/index.js +18 -208
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-33UVEDOS.cjs +233 -0
- package/dist/chunk-33UVEDOS.cjs.map +1 -0
- package/dist/chunk-7FWEWE6T.js +1888 -0
- package/dist/chunk-7FWEWE6T.js.map +1 -0
- package/dist/chunk-BYCOFZAA.js +514 -0
- package/dist/chunk-BYCOFZAA.js.map +1 -0
- package/dist/chunk-CYKQLDYH.cjs +1290 -0
- package/dist/chunk-CYKQLDYH.cjs.map +1 -0
- package/dist/chunk-GLSIZKOX.js +17 -0
- package/dist/chunk-GLSIZKOX.js.map +1 -0
- package/dist/chunk-GWHJVZPI.js +233 -0
- package/dist/chunk-GWHJVZPI.js.map +1 -0
- package/dist/chunk-LDES3EOS.cjs +1888 -0
- package/dist/chunk-LDES3EOS.cjs.map +1 -0
- package/dist/chunk-MPPXH7U5.cjs +336 -0
- package/dist/chunk-MPPXH7U5.cjs.map +1 -0
- package/dist/chunk-NNJRJJSC.js +1290 -0
- package/dist/chunk-NNJRJJSC.js.map +1 -0
- package/dist/chunk-O7LOPQMH.js +336 -0
- package/dist/chunk-O7LOPQMH.js.map +1 -0
- package/dist/chunk-SEDR75VH.cjs +17 -0
- package/dist/chunk-SEDR75VH.cjs.map +1 -0
- package/dist/chunk-SHWP2A43.cjs +514 -0
- package/dist/chunk-SHWP2A43.cjs.map +1 -0
- package/dist/chunk-VHZCXHS4.js +222 -0
- package/dist/chunk-VHZCXHS4.js.map +1 -0
- package/dist/chunk-WADCJ7A7.cjs +222 -0
- package/dist/chunk-WADCJ7A7.cjs.map +1 -0
- package/dist/extensions/index.cjs +25 -1920
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.js +22 -1868
- package/dist/extensions/index.js.map +1 -1
- package/dist/grammar/index.cjs +44 -387
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.js +23 -321
- package/dist/grammar/index.js.map +1 -1
- package/dist/history/index.cjs +6 -257
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.js +4 -227
- package/dist/history/index.js.map +1 -1
- package/dist/image-editor/index.cjs +63 -106
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/index.cjs +324 -7232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +258 -7007
- package/dist/index.js.map +1 -1
- package/dist/serializers/index.cjs +28 -558
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.js +16 -496
- package/dist/serializers/index.js.map +1 -1
- package/dist/spreadsheet/index.cjs +21 -1319
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +14 -1274
- package/dist/spreadsheet/index.js.map +1 -1
- package/dist/{types-lGtRobRV.d.cts → types-DC8b2TsA.d.cts} +1 -1
- package/dist/{types-lGtRobRV.d.ts → types-DC8b2TsA.d.ts} +1 -1
- package/package.json +1 -1
package/dist/canvas/index.cjs
CHANGED
|
@@ -1,281 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/canvas/index.ts
|
|
31
|
-
var canvas_exports = {};
|
|
32
|
-
__export(canvas_exports, {
|
|
33
|
-
DEFAULT_NODE_HEIGHT: () => DEFAULT_NODE_HEIGHT,
|
|
34
|
-
DEFAULT_NODE_WIDTH: () => DEFAULT_NODE_WIDTH,
|
|
35
|
-
DEFAULT_PLACEMENT_GAP: () => DEFAULT_PLACEMENT_GAP,
|
|
36
|
-
ManualClock: () => ManualClock,
|
|
37
|
-
StreamingLayoutManager: () => StreamingLayoutManager,
|
|
38
|
-
blendLayout: () => blendLayout,
|
|
39
|
-
boundsOf: () => boundsOf,
|
|
40
|
-
calculateDagreReflowDisplacement: () => calculateDagreReflowDisplacement,
|
|
41
|
-
calculateDirectionalDisplacement: () => calculateDirectionalDisplacement,
|
|
42
|
-
canvasHeight: () => canvasHeight,
|
|
43
|
-
centerNodes: () => centerNodes,
|
|
44
|
-
centre: () => centre,
|
|
45
|
-
computeNodesBoundingBox: () => computeNodesBoundingBox,
|
|
46
|
-
connectedOnly: () => connectedOnly,
|
|
47
|
-
createBezierTrajectory: () => createBezierTrajectory,
|
|
48
|
-
createFanOutTrajectory: () => createFanOutTrajectory,
|
|
49
|
-
defaultEasing: () => defaultEasing,
|
|
50
|
-
ensureLayout: () => ensureLayout,
|
|
51
|
-
estimateCanvasHeight: () => estimateCanvasHeight,
|
|
52
|
-
estimateNodeSize: () => estimateNodeSize,
|
|
53
|
-
flowSide: () => flowSide,
|
|
54
|
-
getCenteredNodePosition: () => getCenteredNodePosition,
|
|
55
|
-
getLayoutedNodes: () => getLayoutedNodes,
|
|
56
|
-
isEventFromTextInput: () => isEventFromTextInput,
|
|
57
|
-
isValidCanvasNode: () => isValidCanvasNode,
|
|
58
|
-
isValidUrl: () => isValidUrl,
|
|
59
|
-
layoutBounds: () => layoutBounds,
|
|
60
|
-
linearPositionTrajectory: () => linearPositionTrajectory,
|
|
61
|
-
linearTrajectory: () => linearTrajectory,
|
|
62
|
-
overlaps: () => overlaps,
|
|
63
|
-
pageHidden: () => pageHidden,
|
|
64
|
-
parseCanvasClipboardData: () => parseCanvasClipboardData,
|
|
65
|
-
placeBeside: () => placeBeside,
|
|
66
|
-
realClock: () => realClock,
|
|
67
|
-
remapPastedNodes: () => remapPastedNodes,
|
|
68
|
-
repositionNodesTo: () => repositionNodesTo,
|
|
69
|
-
runMultiNodeTransition: () => runMultiNodeTransition,
|
|
70
|
-
serializeCanvasNodes: () => serializeCanvasNodes
|
|
71
|
-
});
|
|
72
|
-
module.exports = __toCommonJS(canvas_exports);
|
|
73
|
-
|
|
74
|
-
// src/canvas/layout.ts
|
|
75
|
-
var import_dagre = __toESM(require("@dagrejs/dagre"), 1);
|
|
76
|
-
var DEFAULT_NODE_WIDTH = 200;
|
|
77
|
-
var DEFAULT_NODE_HEIGHT = 60;
|
|
78
|
-
var DEFAULT_PLACEMENT_GAP = 48;
|
|
79
|
-
function getCenteredNodePosition(width = 0, height = 0, screenToFlowPosition, screenDimensions) {
|
|
80
|
-
const rect = screenDimensions ?? (typeof document !== "undefined" ? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight } : { width: 1920, height: 1080 });
|
|
81
|
-
const flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });
|
|
82
|
-
return {
|
|
83
|
-
x: flowPos.x - width / 2,
|
|
84
|
-
y: flowPos.y - height / 2
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function centerNodes(nodes, screenToFlowPosition, getNodesBounds, screenDimensions) {
|
|
88
|
-
if (nodes.length === 0) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
const bounds = getNodesBounds(nodes);
|
|
92
|
-
const boundingBoxOrigin = { x: bounds.x, y: bounds.y };
|
|
93
|
-
const centeredPosition = getCenteredNodePosition(
|
|
94
|
-
bounds.width,
|
|
95
|
-
bounds.height,
|
|
96
|
-
screenToFlowPosition,
|
|
97
|
-
screenDimensions
|
|
98
|
-
);
|
|
99
|
-
const deltaX = centeredPosition.x - boundingBoxOrigin.x;
|
|
100
|
-
const deltaY = centeredPosition.y - boundingBoxOrigin.y;
|
|
101
|
-
return nodes.map((node) => ({
|
|
102
|
-
...node,
|
|
103
|
-
position: {
|
|
104
|
-
x: node.position.x + deltaX,
|
|
105
|
-
y: node.position.y + deltaY
|
|
106
|
-
}
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
function getLayoutedNodes(nodes, edges, getNodesBounds, options = {}) {
|
|
110
|
-
if (nodes.length === 0) return [];
|
|
111
|
-
const {
|
|
112
|
-
direction = "LR",
|
|
113
|
-
ranksep = 100,
|
|
114
|
-
nodesep = 25,
|
|
115
|
-
defaultNodeWidth = DEFAULT_NODE_WIDTH,
|
|
116
|
-
defaultNodeHeight = DEFAULT_NODE_HEIGHT
|
|
117
|
-
} = options;
|
|
118
|
-
const dagreGraph = new import_dagre.default.graphlib.Graph();
|
|
119
|
-
dagreGraph.setDefaultEdgeLabel(() => ({}));
|
|
120
|
-
dagreGraph.setGraph({ rankdir: direction, ranksep, nodesep });
|
|
121
|
-
const nodeIds = new Set(nodes.map((node) => node.id));
|
|
122
|
-
nodes.forEach((node) => {
|
|
123
|
-
const nodeWidth = node.measured?.width ?? node.width ?? defaultNodeWidth;
|
|
124
|
-
const nodeHeight = node.measured?.height ?? node.height ?? defaultNodeHeight;
|
|
125
|
-
dagreGraph.setNode(node.id, { width: nodeWidth, height: nodeHeight });
|
|
126
|
-
});
|
|
127
|
-
edges.forEach((edge) => {
|
|
128
|
-
if (nodeIds.has(edge.source) && nodeIds.has(edge.target)) {
|
|
129
|
-
dagreGraph.setEdge(edge.source, edge.target);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
import_dagre.default.layout(dagreGraph);
|
|
133
|
-
return nodes.map((node) => {
|
|
134
|
-
const nodeWithPosition = dagreGraph.node(node.id);
|
|
135
|
-
const nodeWidth = node.measured?.width ?? node.width ?? defaultNodeWidth;
|
|
136
|
-
const nodeHeight = node.measured?.height ?? node.height ?? defaultNodeHeight;
|
|
137
|
-
return {
|
|
138
|
-
...node,
|
|
139
|
-
position: {
|
|
140
|
-
x: nodeWithPosition.x - nodeWidth / 2,
|
|
141
|
-
y: nodeWithPosition.y - nodeHeight / 2
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function estimateNodeSize(node, defaultWidth = DEFAULT_NODE_WIDTH, defaultHeight = DEFAULT_NODE_HEIGHT) {
|
|
147
|
-
const label = String(node.data?.label ?? node.data?.title ?? node.id ?? "");
|
|
148
|
-
const lines = label.split(/\n|<br\s*\/?>/);
|
|
149
|
-
const longest = Math.max(...lines.map((l) => l.replace(/<[^>]+>/g, "").length), 1);
|
|
150
|
-
const width = Math.min(480, Math.max(defaultWidth, longest * 8 + 48));
|
|
151
|
-
const height = Math.max(defaultHeight, lines.length * 20 + 24);
|
|
152
|
-
return { width, height };
|
|
153
|
-
}
|
|
154
|
-
function boundsOf(rects) {
|
|
155
|
-
if (!rects.length) return null;
|
|
156
|
-
const minX = Math.min(...rects.map((r) => r.x));
|
|
157
|
-
const minY = Math.min(...rects.map((r) => r.y));
|
|
158
|
-
const maxX = Math.max(...rects.map((r) => r.x + r.width));
|
|
159
|
-
const maxY = Math.max(...rects.map((r) => r.y + r.height));
|
|
160
|
-
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
161
|
-
}
|
|
162
|
-
function centre(r) {
|
|
163
|
-
return { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
164
|
-
}
|
|
165
|
-
function overlaps(a, b, pad = 16) {
|
|
166
|
-
return a.x < b.x + b.width + pad && a.x + a.width + pad > b.x && a.y < b.y + b.height + pad && a.y + a.height + pad > b.y;
|
|
167
|
-
}
|
|
168
|
-
function flowSide(direction = "LR") {
|
|
169
|
-
switch (direction) {
|
|
170
|
-
case "LR":
|
|
171
|
-
return "right";
|
|
172
|
-
case "RL":
|
|
173
|
-
return "left";
|
|
174
|
-
case "BT":
|
|
175
|
-
return "above";
|
|
176
|
-
case "TB":
|
|
177
|
-
default:
|
|
178
|
-
return "below";
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function ensureLayout(nodes, edges, options = {}) {
|
|
182
|
-
if (nodes.length === 0) return [];
|
|
183
|
-
const stored = options.storedPositions ?? {};
|
|
184
|
-
const missing = nodes.filter((n) => !stored[n.id]);
|
|
185
|
-
if (missing.length === 0) {
|
|
186
|
-
return nodes.map((n) => ({
|
|
187
|
-
...n,
|
|
188
|
-
position: { ...stored[n.id] }
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
const autoLayouted = getLayoutedNodes(nodes, edges, void 0, options);
|
|
192
|
-
const autoMap = new Map(
|
|
193
|
-
autoLayouted.map((n) => [n.id, n.position])
|
|
194
|
-
);
|
|
195
|
-
const both = nodes.filter((n) => stored[n.id] && autoMap.has(n.id));
|
|
196
|
-
if (both.length === 0) {
|
|
197
|
-
return autoLayouted;
|
|
198
|
-
}
|
|
199
|
-
let dx = 0;
|
|
200
|
-
let dy = 0;
|
|
201
|
-
for (const n of both) {
|
|
202
|
-
const s = stored[n.id];
|
|
203
|
-
const a = autoMap.get(n.id);
|
|
204
|
-
dx += s.x - a.x;
|
|
205
|
-
dy += s.y - a.y;
|
|
206
|
-
}
|
|
207
|
-
dx /= both.length;
|
|
208
|
-
dy /= both.length;
|
|
209
|
-
return nodes.map((node) => {
|
|
210
|
-
if (stored[node.id]) {
|
|
211
|
-
return {
|
|
212
|
-
...node,
|
|
213
|
-
position: { ...stored[node.id] }
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
const autoPos = autoMap.get(node.id) ?? { x: 0, y: 0 };
|
|
217
|
-
return {
|
|
218
|
-
...node,
|
|
219
|
-
position: {
|
|
220
|
-
x: Math.round(autoPos.x + dx),
|
|
221
|
-
y: Math.round(autoPos.y + dy)
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
function placeBeside(rects, size, side, nearNodeId, options = {}) {
|
|
227
|
-
const {
|
|
228
|
-
gap = DEFAULT_PLACEMENT_GAP,
|
|
229
|
-
ignore = [],
|
|
230
|
-
maxAttempts = 32
|
|
231
|
-
} = options;
|
|
232
|
-
const skip = new Set([nearNodeId, ...ignore].filter(Boolean));
|
|
233
|
-
const obstacles = Object.entries(rects).filter(([id]) => !skip.has(id)).map(([, r]) => r);
|
|
234
|
-
const anchor = nearNodeId && rects[nearNodeId] || boundsOf(Object.values(rects)) || { x: 0, y: 0, width: 0, height: 0 };
|
|
235
|
-
const anchorCenter = centre(anchor);
|
|
236
|
-
let baseX;
|
|
237
|
-
let baseY;
|
|
238
|
-
switch (side) {
|
|
239
|
-
case "right":
|
|
240
|
-
baseX = anchor.x + anchor.width + gap;
|
|
241
|
-
baseY = anchorCenter.y - size.height / 2;
|
|
242
|
-
break;
|
|
243
|
-
case "left":
|
|
244
|
-
baseX = anchor.x - gap - size.width;
|
|
245
|
-
baseY = anchorCenter.y - size.height / 2;
|
|
246
|
-
break;
|
|
247
|
-
case "above":
|
|
248
|
-
baseX = anchorCenter.x - size.width / 2;
|
|
249
|
-
baseY = anchor.y - gap - size.height;
|
|
250
|
-
break;
|
|
251
|
-
case "below":
|
|
252
|
-
default:
|
|
253
|
-
baseX = anchorCenter.x - size.width / 2;
|
|
254
|
-
baseY = anchor.y + anchor.height + gap;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
const isHorizontal = side === "right" || side === "left";
|
|
258
|
-
const step = (isHorizontal ? size.height : size.width) + 20;
|
|
259
|
-
for (let i = 0; i < maxAttempts; i++) {
|
|
260
|
-
const offset = i === 0 ? 0 : Math.ceil(i / 2) * step * (i % 2 === 1 ? 1 : -1);
|
|
261
|
-
const candidateBox = {
|
|
262
|
-
x: isHorizontal ? baseX : baseX + offset,
|
|
263
|
-
y: isHorizontal ? baseY + offset : baseY,
|
|
264
|
-
width: size.width,
|
|
265
|
-
height: size.height
|
|
266
|
-
};
|
|
267
|
-
if (!obstacles.some((obstacle) => overlaps(candidateBox, obstacle, 8))) {
|
|
268
|
-
return {
|
|
269
|
-
x: Math.round(candidateBox.x),
|
|
270
|
-
y: Math.round(candidateBox.y)
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return {
|
|
275
|
-
x: Math.round(baseX),
|
|
276
|
-
y: Math.round(baseY)
|
|
277
|
-
};
|
|
278
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkWADCJ7A7cjs = require('../chunk-WADCJ7A7.cjs');
|
|
279
16
|
|
|
280
17
|
// src/canvas/clock.ts
|
|
281
18
|
var pageHidden = () => typeof document !== "undefined" && document.hidden;
|
|
@@ -292,13 +29,13 @@ var realClock = {
|
|
|
292
29
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)))
|
|
293
30
|
};
|
|
294
31
|
var settle = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
295
|
-
var ManualClock = class {
|
|
296
|
-
live = false
|
|
297
|
-
|
|
298
|
-
frames = []
|
|
299
|
-
sleepers = []
|
|
300
|
-
seq = 0
|
|
301
|
-
constructor(start = 0) {
|
|
32
|
+
var ManualClock = (_class = class {
|
|
33
|
+
__init() {this.live = false}
|
|
34
|
+
|
|
35
|
+
__init2() {this.frames = []}
|
|
36
|
+
__init3() {this.sleepers = []}
|
|
37
|
+
__init4() {this.seq = 0}
|
|
38
|
+
constructor(start = 0) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
302
39
|
this.time = start;
|
|
303
40
|
}
|
|
304
41
|
now() {
|
|
@@ -348,7 +85,7 @@ var ManualClock = class {
|
|
|
348
85
|
async tick(fps = 60) {
|
|
349
86
|
await this.advance(Math.round(1e3 / fps));
|
|
350
87
|
}
|
|
351
|
-
};
|
|
88
|
+
}, _class);
|
|
352
89
|
|
|
353
90
|
// src/canvas/trajectory.ts
|
|
354
91
|
var defaultEasing = (t) => --t * t * t + 1;
|
|
@@ -413,7 +150,7 @@ function createBezierTrajectory(getControlPoint) {
|
|
|
413
150
|
}
|
|
414
151
|
function runMultiNodeTransition(transitions, options = {}) {
|
|
415
152
|
if (transitions.length === 0) {
|
|
416
|
-
options.onComplete
|
|
153
|
+
_optionalChain([options, 'access', _ => _.onComplete, 'optionalCall', _2 => _2()]);
|
|
417
154
|
return () => {
|
|
418
155
|
};
|
|
419
156
|
}
|
|
@@ -428,12 +165,12 @@ function runMultiNodeTransition(transitions, options = {}) {
|
|
|
428
165
|
const startTime = clock.now();
|
|
429
166
|
const items = transitions.map((tr, i) => ({
|
|
430
167
|
...tr,
|
|
431
|
-
index: tr.index
|
|
432
|
-
total: tr.total
|
|
433
|
-
duration: tr.duration
|
|
434
|
-
easing: tr.easing
|
|
435
|
-
delay: tr.delay
|
|
436
|
-
trajectory: tr.trajectory
|
|
168
|
+
index: _nullishCoalesce(tr.index, () => ( i)),
|
|
169
|
+
total: _nullishCoalesce(tr.total, () => ( transitions.length)),
|
|
170
|
+
duration: _nullishCoalesce(tr.duration, () => ( defaultDuration)),
|
|
171
|
+
easing: _nullishCoalesce(tr.easing, () => ( easingFunc)),
|
|
172
|
+
delay: _nullishCoalesce(tr.delay, () => ( 0)),
|
|
173
|
+
trajectory: _nullishCoalesce(tr.trajectory, () => ( linearTrajectory))
|
|
437
174
|
}));
|
|
438
175
|
function frame() {
|
|
439
176
|
if (isCancelled) return;
|
|
@@ -467,11 +204,11 @@ function runMultiNodeTransition(transitions, options = {}) {
|
|
|
467
204
|
allCompleted = false;
|
|
468
205
|
}
|
|
469
206
|
}
|
|
470
|
-
onUpdate
|
|
207
|
+
_optionalChain([onUpdate, 'optionalCall', _3 => _3()]);
|
|
471
208
|
if (!allCompleted) {
|
|
472
209
|
clock.frame().then(frame);
|
|
473
210
|
} else {
|
|
474
|
-
onComplete
|
|
211
|
+
_optionalChain([onComplete, 'optionalCall', _4 => _4()]);
|
|
475
212
|
}
|
|
476
213
|
}
|
|
477
214
|
frame();
|
|
@@ -481,7 +218,7 @@ function runMultiNodeTransition(transitions, options = {}) {
|
|
|
481
218
|
}
|
|
482
219
|
|
|
483
220
|
// src/canvas/displacement.ts
|
|
484
|
-
var
|
|
221
|
+
var _dagre = require('@dagrejs/dagre'); var _dagre2 = _interopRequireDefault(_dagre);
|
|
485
222
|
function computeNodesBoundingBox(nodes, defaultWidth = 200, defaultHeight = 60) {
|
|
486
223
|
if (nodes.length === 0) {
|
|
487
224
|
return { x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -491,8 +228,8 @@ function computeNodesBoundingBox(nodes, defaultWidth = 200, defaultHeight = 60)
|
|
|
491
228
|
let maxX = -Infinity;
|
|
492
229
|
let maxY = -Infinity;
|
|
493
230
|
for (const node of nodes) {
|
|
494
|
-
const width = node.measured
|
|
495
|
-
const height = node.measured
|
|
231
|
+
const width = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _5 => _5.measured, 'optionalAccess', _6 => _6.width]), () => ( node.width)), () => ( defaultWidth));
|
|
232
|
+
const height = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _7 => _7.measured, 'optionalAccess', _8 => _8.height]), () => ( node.height)), () => ( defaultHeight));
|
|
496
233
|
minX = Math.min(minX, node.position.x);
|
|
497
234
|
minY = Math.min(minY, node.position.y);
|
|
498
235
|
maxX = Math.max(maxX, node.position.x + width);
|
|
@@ -525,8 +262,8 @@ function calculateDirectionalDisplacement(params) {
|
|
|
525
262
|
return displacedMap;
|
|
526
263
|
}
|
|
527
264
|
const childBounds = getNodesBounds ? getNodesBounds(childNodes) : computeNodesBoundingBox(childNodes);
|
|
528
|
-
const originWidth = originNode.measured
|
|
529
|
-
const originHeight = originNode.measured
|
|
265
|
+
const originWidth = _nullishCoalesce(_nullishCoalesce(_optionalChain([originNode, 'access', _9 => _9.measured, 'optionalAccess', _10 => _10.width]), () => ( originNode.width)), () => ( 200));
|
|
266
|
+
const originHeight = _nullishCoalesce(_nullishCoalesce(_optionalChain([originNode, 'access', _11 => _11.measured, 'optionalAccess', _12 => _12.height]), () => ( originNode.height)), () => ( 60));
|
|
530
267
|
const deltaPrimary = direction === "right" || direction === "left" ? childBounds.width + gap : childBounds.height + gap;
|
|
531
268
|
const deltaUp = Math.max(0, originNode.position.y - childBounds.y + gap);
|
|
532
269
|
const deltaDown = Math.max(
|
|
@@ -629,13 +366,13 @@ function calculateDagreReflowDisplacement(params) {
|
|
|
629
366
|
} = options;
|
|
630
367
|
const anchorNode = currentNodes.find((n) => n.id === anchorNodeId);
|
|
631
368
|
if (!anchorNode) return /* @__PURE__ */ new Map();
|
|
632
|
-
const g = new
|
|
369
|
+
const g = new _dagre2.default.graphlib.Graph();
|
|
633
370
|
g.setDefaultEdgeLabel(() => ({}));
|
|
634
371
|
g.setGraph({ rankdir: direction, ranksep, nodesep });
|
|
635
372
|
const nodeIds = new Set(futureNodes.map((n) => n.id));
|
|
636
373
|
futureNodes.forEach((node) => {
|
|
637
|
-
const nodeWidth = node.measured
|
|
638
|
-
const nodeHeight = node.measured
|
|
374
|
+
const nodeWidth = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _13 => _13.measured, 'optionalAccess', _14 => _14.width]), () => ( node.width)), () => ( defaultNodeWidth));
|
|
375
|
+
const nodeHeight = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _15 => _15.measured, 'optionalAccess', _16 => _16.height]), () => ( node.height)), () => ( defaultNodeHeight));
|
|
639
376
|
g.setNode(node.id, { width: nodeWidth, height: nodeHeight });
|
|
640
377
|
});
|
|
641
378
|
futureEdges.forEach((edge) => {
|
|
@@ -643,11 +380,11 @@ function calculateDagreReflowDisplacement(params) {
|
|
|
643
380
|
g.setEdge(edge.source, edge.target);
|
|
644
381
|
}
|
|
645
382
|
});
|
|
646
|
-
|
|
383
|
+
_dagre2.default.layout(g);
|
|
647
384
|
const anchorLayoutPos = g.node(anchorNodeId);
|
|
648
385
|
if (!anchorLayoutPos) return /* @__PURE__ */ new Map();
|
|
649
|
-
const anchorWidth = anchorNode.measured
|
|
650
|
-
const anchorHeight = anchorNode.measured
|
|
386
|
+
const anchorWidth = _nullishCoalesce(_nullishCoalesce(_optionalChain([anchorNode, 'access', _17 => _17.measured, 'optionalAccess', _18 => _18.width]), () => ( anchorNode.width)), () => ( defaultNodeWidth));
|
|
387
|
+
const anchorHeight = _nullishCoalesce(_nullishCoalesce(_optionalChain([anchorNode, 'access', _19 => _19.measured, 'optionalAccess', _20 => _20.height]), () => ( anchorNode.height)), () => ( defaultNodeHeight));
|
|
651
388
|
const anchorLayoutUpperLeft = {
|
|
652
389
|
x: anchorLayoutPos.x - anchorWidth / 2,
|
|
653
390
|
y: anchorLayoutPos.y - anchorHeight / 2
|
|
@@ -659,8 +396,8 @@ function calculateDagreReflowDisplacement(params) {
|
|
|
659
396
|
if (node.id === anchorNodeId) return;
|
|
660
397
|
const layoutNode = g.node(node.id);
|
|
661
398
|
if (!layoutNode) return;
|
|
662
|
-
const nodeWidth = node.measured
|
|
663
|
-
const nodeHeight = node.measured
|
|
399
|
+
const nodeWidth = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _21 => _21.measured, 'optionalAccess', _22 => _22.width]), () => ( node.width)), () => ( defaultNodeWidth));
|
|
400
|
+
const nodeHeight = _nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _23 => _23.measured, 'optionalAccess', _24 => _24.height]), () => ( node.height)), () => ( defaultNodeHeight));
|
|
664
401
|
const upperLeftX = layoutNode.x - nodeWidth / 2 + deltaX;
|
|
665
402
|
const upperLeftY = layoutNode.y - nodeHeight / 2 + deltaY;
|
|
666
403
|
if (Math.abs(upperLeftX - node.position.x) > 1 || Math.abs(upperLeftY - node.position.y) > 1) {
|
|
@@ -674,7 +411,7 @@ function calculateDagreReflowDisplacement(params) {
|
|
|
674
411
|
function isEventFromTextInput(event) {
|
|
675
412
|
const target = event.target;
|
|
676
413
|
if (!target) return false;
|
|
677
|
-
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT" || target.isContentEditable || target.closest
|
|
414
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT" || target.isContentEditable || _optionalChain([target, 'access', _25 => _25.closest, 'optionalCall', _26 => _26('[contenteditable="true"]')]) || _optionalChain([target, 'access', _27 => _27.closest, 'optionalCall', _28 => _28(".ProseMirror")])) {
|
|
678
415
|
return true;
|
|
679
416
|
}
|
|
680
417
|
return false;
|
|
@@ -686,7 +423,7 @@ function isValidUrl(url) {
|
|
|
686
423
|
try {
|
|
687
424
|
const parsed = new URL(url);
|
|
688
425
|
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
689
|
-
} catch {
|
|
426
|
+
} catch (e2) {
|
|
690
427
|
return false;
|
|
691
428
|
}
|
|
692
429
|
}
|
|
@@ -704,7 +441,7 @@ function parseCanvasClipboardData(raw) {
|
|
|
704
441
|
if (typeof parsed === "object" && parsed !== null && Array.isArray(parsed.nodes) && parsed.nodes.length > 0 && parsed.nodes.every(isValidCanvasNode)) {
|
|
705
442
|
return parsed;
|
|
706
443
|
}
|
|
707
|
-
} catch {
|
|
444
|
+
} catch (e3) {
|
|
708
445
|
}
|
|
709
446
|
return null;
|
|
710
447
|
}
|
|
@@ -761,8 +498,8 @@ function layoutBounds(nodes) {
|
|
|
761
498
|
for (const node of nodes) {
|
|
762
499
|
const x = node.position.x;
|
|
763
500
|
const y = node.position.y;
|
|
764
|
-
const width = node.width
|
|
765
|
-
const height = node.height
|
|
501
|
+
const width = _nullishCoalesce(node.width, () => ( 180));
|
|
502
|
+
const height = _nullishCoalesce(node.height, () => ( 80));
|
|
766
503
|
minX = Math.min(minX, x);
|
|
767
504
|
minY = Math.min(minY, y);
|
|
768
505
|
maxX = Math.max(maxX, x + width);
|
|
@@ -772,7 +509,7 @@ function layoutBounds(nodes) {
|
|
|
772
509
|
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
773
510
|
}
|
|
774
511
|
function canvasHeight(nodes, options) {
|
|
775
|
-
return clampHeight(layoutBounds(nodes)
|
|
512
|
+
return clampHeight(_nullishCoalesce(_optionalChain([layoutBounds, 'call', _29 => _29(nodes), 'optionalAccess', _30 => _30.height]), () => ( 0)), options);
|
|
776
513
|
}
|
|
777
514
|
var DEFAULT_RANK_HEIGHT = 80 + 72;
|
|
778
515
|
var NODES_PER_RANK = 2;
|
|
@@ -812,22 +549,22 @@ function connectedOnly(nodes, edges) {
|
|
|
812
549
|
}
|
|
813
550
|
|
|
814
551
|
// src/canvas/streaming.ts
|
|
815
|
-
var StreamingLayoutManager = class {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
pendingTimer = null
|
|
823
|
-
activeTransitionCancel = null
|
|
824
|
-
targetPositions = /* @__PURE__ */ new Map()
|
|
825
|
-
constructor(options = {}) {
|
|
826
|
-
this.throttleMs = options.throttleMs
|
|
827
|
-
this.glideDurationMs = options.glideDurationMs
|
|
828
|
-
this.connectedOnly = options.connectedOnly
|
|
829
|
-
this.clock = options.clock
|
|
830
|
-
this.layoutOptions = options.layoutOptions
|
|
552
|
+
var StreamingLayoutManager = (_class2 = class {
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
__init5() {this.pendingTimer = null}
|
|
560
|
+
__init6() {this.activeTransitionCancel = null}
|
|
561
|
+
__init7() {this.targetPositions = /* @__PURE__ */ new Map()}
|
|
562
|
+
constructor(options = {}) {;_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);
|
|
563
|
+
this.throttleMs = _nullishCoalesce(options.throttleMs, () => ( 200));
|
|
564
|
+
this.glideDurationMs = _nullishCoalesce(options.glideDurationMs, () => ( 300));
|
|
565
|
+
this.connectedOnly = _nullishCoalesce(options.connectedOnly, () => ( false));
|
|
566
|
+
this.clock = _nullishCoalesce(options.clock, () => ( realClock));
|
|
567
|
+
this.layoutOptions = _nullishCoalesce(options.layoutOptions, () => ( { direction: "LR" }));
|
|
831
568
|
this.onLayoutUpdated = options.onLayoutUpdated;
|
|
832
569
|
}
|
|
833
570
|
/**
|
|
@@ -864,7 +601,7 @@ var StreamingLayoutManager = class {
|
|
|
864
601
|
for (const [id, pos] of currentPositions.entries()) {
|
|
865
602
|
stored[id] = pos;
|
|
866
603
|
}
|
|
867
|
-
const layouted = ensureLayout(targetNodes, edges, {
|
|
604
|
+
const layouted = _chunkWADCJ7A7cjs.ensureLayout.call(void 0, targetNodes, edges, {
|
|
868
605
|
...this.layoutOptions,
|
|
869
606
|
storedPositions: stored
|
|
870
607
|
});
|
|
@@ -873,7 +610,7 @@ var StreamingLayoutManager = class {
|
|
|
873
610
|
for (const node of layouted) {
|
|
874
611
|
const target = node.position;
|
|
875
612
|
nextPositions.set(node.id, target);
|
|
876
|
-
const current = currentPositions.get(node.id)
|
|
613
|
+
const current = _nullishCoalesce(currentPositions.get(node.id), () => ( target));
|
|
877
614
|
const distance = Math.hypot(target.x - current.x, target.y - current.y);
|
|
878
615
|
if (distance > 2) {
|
|
879
616
|
transitions.push({
|
|
@@ -894,15 +631,15 @@ var StreamingLayoutManager = class {
|
|
|
894
631
|
for (const trans of transitions) {
|
|
895
632
|
liveMap.set(trans.node.id, { ...trans.node.position });
|
|
896
633
|
}
|
|
897
|
-
this.onLayoutUpdated
|
|
634
|
+
_optionalChain([this, 'access', _31 => _31.onLayoutUpdated, 'optionalCall', _32 => _32(liveMap)]);
|
|
898
635
|
},
|
|
899
636
|
onComplete: () => {
|
|
900
637
|
this.activeTransitionCancel = null;
|
|
901
|
-
this.onLayoutUpdated
|
|
638
|
+
_optionalChain([this, 'access', _33 => _33.onLayoutUpdated, 'optionalCall', _34 => _34(nextPositions)]);
|
|
902
639
|
}
|
|
903
640
|
});
|
|
904
641
|
} else {
|
|
905
|
-
this.onLayoutUpdated
|
|
642
|
+
_optionalChain([this, 'access', _35 => _35.onLayoutUpdated, 'optionalCall', _36 => _36(nextPositions)]);
|
|
906
643
|
}
|
|
907
644
|
}
|
|
908
645
|
destroy() {
|
|
@@ -915,46 +652,45 @@ var StreamingLayoutManager = class {
|
|
|
915
652
|
this.activeTransitionCancel = null;
|
|
916
653
|
}
|
|
917
654
|
}
|
|
918
|
-
};
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
});
|
|
655
|
+
}, _class2);
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
exports.DEFAULT_NODE_HEIGHT = _chunkWADCJ7A7cjs.DEFAULT_NODE_HEIGHT; exports.DEFAULT_NODE_WIDTH = _chunkWADCJ7A7cjs.DEFAULT_NODE_WIDTH; exports.DEFAULT_PLACEMENT_GAP = _chunkWADCJ7A7cjs.DEFAULT_PLACEMENT_GAP; exports.ManualClock = ManualClock; exports.StreamingLayoutManager = StreamingLayoutManager; exports.blendLayout = blendLayout; exports.boundsOf = _chunkWADCJ7A7cjs.boundsOf; exports.calculateDagreReflowDisplacement = calculateDagreReflowDisplacement; exports.calculateDirectionalDisplacement = calculateDirectionalDisplacement; exports.canvasHeight = canvasHeight; exports.centerNodes = _chunkWADCJ7A7cjs.centerNodes; exports.centre = _chunkWADCJ7A7cjs.centre; exports.computeNodesBoundingBox = computeNodesBoundingBox; exports.connectedOnly = connectedOnly; exports.createBezierTrajectory = createBezierTrajectory; exports.createFanOutTrajectory = createFanOutTrajectory; exports.defaultEasing = defaultEasing; exports.ensureLayout = _chunkWADCJ7A7cjs.ensureLayout; exports.estimateCanvasHeight = estimateCanvasHeight; exports.estimateNodeSize = _chunkWADCJ7A7cjs.estimateNodeSize; exports.flowSide = _chunkWADCJ7A7cjs.flowSide; exports.getCenteredNodePosition = _chunkWADCJ7A7cjs.getCenteredNodePosition; exports.getLayoutedNodes = _chunkWADCJ7A7cjs.getLayoutedNodes; exports.isEventFromTextInput = isEventFromTextInput; exports.isValidCanvasNode = isValidCanvasNode; exports.isValidUrl = isValidUrl; exports.layoutBounds = layoutBounds; exports.linearPositionTrajectory = linearPositionTrajectory; exports.linearTrajectory = linearTrajectory; exports.overlaps = _chunkWADCJ7A7cjs.overlaps; exports.pageHidden = pageHidden; exports.parseCanvasClipboardData = parseCanvasClipboardData; exports.placeBeside = _chunkWADCJ7A7cjs.placeBeside; exports.realClock = realClock; exports.remapPastedNodes = remapPastedNodes; exports.repositionNodesTo = repositionNodesTo; exports.runMultiNodeTransition = runMultiNodeTransition; exports.serializeCanvasNodes = serializeCanvasNodes;
|
|
960
696
|
//# sourceMappingURL=index.cjs.map
|