@g9tm/lynxcontrols-canvas 0.0.0-stage → 2.5.8

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.
Files changed (60) hide show
  1. package/README.md +39 -2
  2. package/catalog/cards/G9Canvas.md +17 -0
  3. package/catalog/cards/G9CanvasStylePanel.md +13 -0
  4. package/catalog/catalog.json +2334 -0
  5. package/catalog/index.md +6 -0
  6. package/dist/.tsbuildinfo +1 -0
  7. package/dist/board-controller.d.ts +161 -0
  8. package/dist/board-controller.d.ts.map +1 -0
  9. package/dist/board-controller.jsx +812 -0
  10. package/dist/board-model.d.ts +42 -0
  11. package/dist/board-model.d.ts.map +1 -0
  12. package/dist/board-model.jsx +66 -0
  13. package/dist/canvas.css +81 -0
  14. package/dist/canvas.css.map +1 -0
  15. package/dist/canvas.d.ts +144 -0
  16. package/dist/canvas.d.ts.map +1 -0
  17. package/dist/canvas.jsx +481 -0
  18. package/dist/element-core.d.ts +155 -0
  19. package/dist/element-core.d.ts.map +1 -0
  20. package/dist/element-core.jsx +1104 -0
  21. package/dist/export.d.ts +7 -0
  22. package/dist/export.d.ts.map +1 -0
  23. package/dist/export.jsx +75 -0
  24. package/dist/index.d.ts +8 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.jsx +7 -0
  27. package/dist/observable.d.ts +5 -0
  28. package/dist/observable.d.ts.map +1 -0
  29. package/dist/observable.jsx +14 -0
  30. package/dist/protocol.d.ts +258 -0
  31. package/dist/protocol.d.ts.map +1 -0
  32. package/dist/protocol.jsx +2 -0
  33. package/dist/scene/edit.d.ts +59 -0
  34. package/dist/scene/edit.d.ts.map +1 -0
  35. package/dist/scene/edit.jsx +895 -0
  36. package/dist/scene/elements.d.ts +160 -0
  37. package/dist/scene/elements.d.ts.map +1 -0
  38. package/dist/scene/elements.jsx +392 -0
  39. package/dist/scene/geometry.d.ts +36 -0
  40. package/dist/scene/geometry.d.ts.map +1 -0
  41. package/dist/scene/geometry.jsx +367 -0
  42. package/dist/scene/index.d.ts +8 -0
  43. package/dist/scene/index.d.ts.map +1 -0
  44. package/dist/scene/index.jsx +6 -0
  45. package/dist/scene/path-data-parser.d.ts +17 -0
  46. package/dist/scene/path-data-parser.d.ts.map +1 -0
  47. package/dist/scene/path-data-parser.jsx +128 -0
  48. package/dist/scene/scene.d.ts +58 -0
  49. package/dist/scene/scene.d.ts.map +1 -0
  50. package/dist/scene/scene.jsx +169 -0
  51. package/dist/scene/shapes.d.ts +24 -0
  52. package/dist/scene/shapes.d.ts.map +1 -0
  53. package/dist/scene/shapes.jsx +807 -0
  54. package/dist/scene/types.d.ts +118 -0
  55. package/dist/scene/types.d.ts.map +1 -0
  56. package/dist/scene/types.jsx +1 -0
  57. package/dist/words.d.ts +100 -0
  58. package/dist/words.d.ts.map +1 -0
  59. package/dist/words.jsx +186 -0
  60. package/package.json +50 -4
@@ -0,0 +1,367 @@
1
+ import { isFrame, isPointsElement, isTransparent } from "./elements.jsx";
2
+ function absoluteCoords(element) {
3
+ var _element_points;
4
+ if (isPointsElement(element) && (null == (_element_points = element.points) ? void 0 : _element_points.length)) {
5
+ let minX = 1 / 0;
6
+ let minY = 1 / 0;
7
+ let maxX = -1 / 0;
8
+ let maxY = -1 / 0;
9
+ for (const [x, y] of element.points){
10
+ if (x < minX) minX = x;
11
+ if (y < minY) minY = y;
12
+ if (x > maxX) maxX = x;
13
+ if (y > maxY) maxY = y;
14
+ }
15
+ const x1 = minX + element.x;
16
+ const y1 = minY + element.y;
17
+ const x2 = maxX + element.x;
18
+ const y2 = maxY + element.y;
19
+ return [
20
+ x1,
21
+ y1,
22
+ x2,
23
+ y2,
24
+ (x1 + x2) / 2,
25
+ (y1 + y2) / 2
26
+ ];
27
+ }
28
+ const x2 = element.x + element.width;
29
+ const y2 = element.y + element.height;
30
+ return [
31
+ element.x,
32
+ element.y,
33
+ x2,
34
+ y2,
35
+ (element.x + x2) / 2,
36
+ (element.y + y2) / 2
37
+ ];
38
+ }
39
+ function rotate(point, center, angle) {
40
+ if (!angle) return point;
41
+ const cos = Math.cos(angle);
42
+ const sin = Math.sin(angle);
43
+ const dx = point[0] - center[0];
44
+ const dy = point[1] - center[1];
45
+ return [
46
+ dx * cos - dy * sin + center[0],
47
+ dx * sin + dy * cos + center[1]
48
+ ];
49
+ }
50
+ function elementBounds(element) {
51
+ var _element_points;
52
+ const [x1, y1, x2, y2, cx, cy] = absoluteCoords(element);
53
+ const angle = element.angle || 0;
54
+ if (!angle) return [
55
+ x1,
56
+ y1,
57
+ x2,
58
+ y2
59
+ ];
60
+ const corners = isPointsElement(element) && (null == (_element_points = element.points) ? void 0 : _element_points.length) ? element.points.map(([x, y])=>[
61
+ x + element.x,
62
+ y + element.y
63
+ ]) : [
64
+ [
65
+ x1,
66
+ y1
67
+ ],
68
+ [
69
+ x2,
70
+ y1
71
+ ],
72
+ [
73
+ x2,
74
+ y2
75
+ ],
76
+ [
77
+ x1,
78
+ y2
79
+ ]
80
+ ];
81
+ let minX = 1 / 0;
82
+ let minY = 1 / 0;
83
+ let maxX = -1 / 0;
84
+ let maxY = -1 / 0;
85
+ for (const corner of corners){
86
+ const [x, y] = rotate(corner, [
87
+ cx,
88
+ cy
89
+ ], angle);
90
+ if (x < minX) minX = x;
91
+ if (y < minY) minY = y;
92
+ if (x > maxX) maxX = x;
93
+ if (y > maxY) maxY = y;
94
+ }
95
+ return [
96
+ minX,
97
+ minY,
98
+ maxX,
99
+ maxY
100
+ ];
101
+ }
102
+ function commonBounds(elements) {
103
+ if (!elements.length) return null;
104
+ let minX = 1 / 0;
105
+ let minY = 1 / 0;
106
+ let maxX = -1 / 0;
107
+ let maxY = -1 / 0;
108
+ for (const element of elements){
109
+ const [x1, y1, x2, y2] = elementBounds(element);
110
+ if (x1 < minX) minX = x1;
111
+ if (y1 < minY) minY = y1;
112
+ if (x2 > maxX) maxX = x2;
113
+ if (y2 > maxY) maxY = y2;
114
+ }
115
+ return [
116
+ minX,
117
+ minY,
118
+ maxX,
119
+ maxY
120
+ ];
121
+ }
122
+ function boundsContain(outer, inner) {
123
+ return inner[0] >= outer[0] && inner[1] >= outer[1] && inner[2] <= outer[2] && inner[3] <= outer[3];
124
+ }
125
+ function boundsIntersect(a, b) {
126
+ return a[0] <= b[2] && a[2] >= b[0] && a[1] <= b[3] && a[3] >= b[1];
127
+ }
128
+ function normalizeBox(x1, y1, x2, y2) {
129
+ return [
130
+ Math.min(x1, x2),
131
+ Math.min(y1, y2),
132
+ Math.max(x1, x2),
133
+ Math.max(y1, y2)
134
+ ];
135
+ }
136
+ function distanceToSegment(p, a, b) {
137
+ const dx = b[0] - a[0];
138
+ const dy = b[1] - a[1];
139
+ const length = dx * dx + dy * dy;
140
+ let t = length ? ((p[0] - a[0]) * dx + (p[1] - a[1]) * dy) / length : 0;
141
+ t = Math.max(0, Math.min(1, t));
142
+ return Math.hypot(p[0] - (a[0] + t * dx), p[1] - (a[1] + t * dy));
143
+ }
144
+ function distanceToPolyline(p, points, closed = false) {
145
+ if (1 === points.length) return Math.hypot(p[0] - points[0][0], p[1] - points[0][1]);
146
+ let best = 1 / 0;
147
+ for(let i = 1; i < points.length; i++)best = Math.min(best, distanceToSegment(p, points[i - 1], points[i]));
148
+ if (closed && points.length > 2) best = Math.min(best, distanceToSegment(p, points[points.length - 1], points[0]));
149
+ return best;
150
+ }
151
+ function insidePolygon(p, points) {
152
+ let inside = false;
153
+ for(let i = 0, j = points.length - 1; i < points.length; j = i++){
154
+ const [xi, yi] = points[i];
155
+ const [xj, yj] = points[j];
156
+ if (yi > p[1] !== yj > p[1] && p[0] < (xj - xi) * (p[1] - yi) / (yj - yi || 1e-9) + xi) inside = !inside;
157
+ }
158
+ return inside;
159
+ }
160
+ function isLoop(points, zoom = 1) {
161
+ if (points.length < 3) return false;
162
+ const first = points[0];
163
+ const last = points[points.length - 1];
164
+ return Math.hypot(first[0] - last[0], first[1] - last[1]) <= 8 / zoom;
165
+ }
166
+ function hitElement(element, point, threshold) {
167
+ const [x1, y1, x2, y2, cx, cy] = absoluteCoords(element);
168
+ const p = rotate(point, [
169
+ cx,
170
+ cy
171
+ ], -(element.angle || 0));
172
+ const filled = !isTransparent(element.backgroundColor) && void 0 !== element.fillStyle;
173
+ const pad = threshold + (element.strokeWidth || 0) / 2;
174
+ switch(element.type){
175
+ case 'text':
176
+ case 'image':
177
+ case 'embeddable':
178
+ case 'iframe':
179
+ return p[0] >= x1 - threshold && p[0] <= x2 + threshold && p[1] >= y1 - threshold && p[1] <= y2 + threshold;
180
+ case 'frame':
181
+ case 'magicframe':
182
+ {
183
+ if (p[0] >= x1 && p[0] <= x2 && p[1] >= y1 - 24 && p[1] <= y1) return true;
184
+ const outline = [
185
+ [
186
+ x1,
187
+ y1
188
+ ],
189
+ [
190
+ x2,
191
+ y1
192
+ ],
193
+ [
194
+ x2,
195
+ y2
196
+ ],
197
+ [
198
+ x1,
199
+ y2
200
+ ]
201
+ ];
202
+ return distanceToPolyline(p, outline, true) <= pad;
203
+ }
204
+ case 'rectangle':
205
+ {
206
+ const outline = [
207
+ [
208
+ x1,
209
+ y1
210
+ ],
211
+ [
212
+ x2,
213
+ y1
214
+ ],
215
+ [
216
+ x2,
217
+ y2
218
+ ],
219
+ [
220
+ x1,
221
+ y2
222
+ ]
223
+ ];
224
+ if (filled && insidePolygon(p, outline)) return true;
225
+ return distanceToPolyline(p, outline, true) <= pad;
226
+ }
227
+ case 'diamond':
228
+ {
229
+ const w = x2 - x1;
230
+ const h = y2 - y1;
231
+ const outline = [
232
+ [
233
+ x1 + w / 2,
234
+ y1
235
+ ],
236
+ [
237
+ x2,
238
+ y1 + h / 2
239
+ ],
240
+ [
241
+ x1 + w / 2,
242
+ y2
243
+ ],
244
+ [
245
+ x1,
246
+ y1 + h / 2
247
+ ]
248
+ ];
249
+ if (filled && insidePolygon(p, outline)) return true;
250
+ return distanceToPolyline(p, outline, true) <= pad;
251
+ }
252
+ case 'ellipse':
253
+ {
254
+ const a = (x2 - x1) / 2;
255
+ const b = (y2 - y1) / 2;
256
+ if (a <= 0 || b <= 0) return Math.hypot(p[0] - cx, p[1] - cy) <= pad;
257
+ const nx = (p[0] - cx) / a;
258
+ const ny = (p[1] - cy) / b;
259
+ const r = Math.sqrt(nx * nx + ny * ny);
260
+ if (filled && r <= 1) return true;
261
+ return Math.abs(r - 1) * Math.min(a, b) <= pad;
262
+ }
263
+ case 'arrow':
264
+ case 'line':
265
+ case 'freedraw':
266
+ {
267
+ var _element_points, _element_points1;
268
+ const points = (null != (_element_points = element.points) ? _element_points : []).map(([x, y])=>[
269
+ x + element.x,
270
+ y + element.y
271
+ ]);
272
+ if (!points.length) return false;
273
+ if (filled && isLoop(null != (_element_points1 = element.points) ? _element_points1 : []) && insidePolygon(p, points)) return true;
274
+ const width = 'freedraw' === element.type ? 2 * (element.strokeWidth || 1) : 0;
275
+ return distanceToPolyline(p, points) <= pad + width;
276
+ }
277
+ default:
278
+ return p[0] >= x1 && p[0] <= x2 && p[1] >= y1 && p[1] <= y2;
279
+ }
280
+ }
281
+ function outlineOf(element) {
282
+ const [x1, y1, x2, y2, cx, cy] = absoluteCoords(element);
283
+ const w = x2 - x1;
284
+ const h = y2 - y1;
285
+ let points;
286
+ if ('diamond' === element.type) points = [
287
+ [
288
+ x1 + w / 2,
289
+ y1
290
+ ],
291
+ [
292
+ x2,
293
+ y1 + h / 2
294
+ ],
295
+ [
296
+ x1 + w / 2,
297
+ y2
298
+ ],
299
+ [
300
+ x1,
301
+ y1 + h / 2
302
+ ]
303
+ ];
304
+ else if ('ellipse' === element.type) {
305
+ points = [];
306
+ for(let i = 0; i < 48; i++){
307
+ const t = i / 48 * Math.PI * 2;
308
+ points.push([
309
+ cx + w / 2 * Math.cos(t),
310
+ cy + h / 2 * Math.sin(t)
311
+ ]);
312
+ }
313
+ } else points = [
314
+ [
315
+ x1,
316
+ y1
317
+ ],
318
+ [
319
+ x2,
320
+ y1
321
+ ],
322
+ [
323
+ x2,
324
+ y2
325
+ ],
326
+ [
327
+ x1,
328
+ y2
329
+ ]
330
+ ];
331
+ return points.map((point)=>rotate(point, [
332
+ cx,
333
+ cy
334
+ ], element.angle || 0));
335
+ }
336
+ function intersectOutline(outline, from, to) {
337
+ let best = null;
338
+ let bestT = 1 / 0;
339
+ for(let i = 0; i < outline.length; i++){
340
+ const a = outline[i];
341
+ const b = outline[(i + 1) % outline.length];
342
+ const r = [
343
+ to[0] - from[0],
344
+ to[1] - from[1]
345
+ ];
346
+ const s = [
347
+ b[0] - a[0],
348
+ b[1] - a[1]
349
+ ];
350
+ const denominator = r[0] * s[1] - r[1] * s[0];
351
+ if (Math.abs(denominator) < 1e-9) continue;
352
+ const t = ((a[0] - from[0]) * s[1] - (a[1] - from[1]) * s[0]) / denominator;
353
+ const u = ((a[0] - from[0]) * r[1] - (a[1] - from[1]) * r[0]) / denominator;
354
+ if (t >= 0 && t <= 1 && u >= 0 && u <= 1 && t < bestT) {
355
+ bestT = t;
356
+ best = [
357
+ from[0] + t * r[0],
358
+ from[1] + t * r[1]
359
+ ];
360
+ }
361
+ }
362
+ return best;
363
+ }
364
+ function isBindable(element) {
365
+ return !element.isDeleted && ('rectangle' === element.type || 'ellipse' === element.type || 'diamond' === element.type || 'text' === element.type || 'image' === element.type || isFrame(element)) && !element.locked;
366
+ }
367
+ export { absoluteCoords, boundsContain, boundsIntersect, commonBounds, distanceToPolyline, elementBounds, hitElement, insidePolygon, intersectOutline, isBindable, normalizeBox, outlineOf, rotate };
@@ -0,0 +1,8 @@
1
+ export * from './edit.js';
2
+ export * from './elements.js';
3
+ export * from './geometry.js';
4
+ export { parsePath, serialize } from './path-data-parser.js';
5
+ export * from './scene.js';
6
+ export * from './shapes.js';
7
+ export type * from './types.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scene/index.ts"],"names":[],"mappings":"AAEA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC1D,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,mBAAmB,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./edit.jsx";
2
+ export * from "./elements.jsx";
3
+ export * from "./geometry.jsx";
4
+ export * from "./scene.jsx";
5
+ export * from "./shapes.jsx";
6
+ export { parsePath, serialize } from "./path-data-parser.jsx";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `path-data-parser` 1.0.1 (MIT, Preet Shihn — roughjs's SVG path parser) with one change: its tokenizer reads matches
3
+ * through the legacy `RegExp.$1`, which PrimJS (Android/iOS) does not have — `roughjs`'s `generator.path()` (rounded
4
+ * rectangles and diamonds) threw there. `lynx.config.ts` resolves the package to this file; absolutize/normalize are
5
+ * the package's own.
6
+ */
7
+ export { absolutize } from 'path-data-parser/lib/absolutize.js';
8
+ export { normalize } from 'path-data-parser/lib/normalize.js';
9
+ export interface Segment {
10
+ key: string;
11
+ data: number[];
12
+ }
13
+ /** SVG path data as absolute segments (repeated numbers repeat the command). */
14
+ export declare function parsePath(d: string): Segment[];
15
+ /** Segments back to SVG path data. */
16
+ export declare function serialize(segments: Segment[]): string;
17
+ //# sourceMappingURL=path-data-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-data-parser.d.ts","sourceRoot":"","sources":["../../src/scene/path-data-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AA+DD,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAqC9C;AAED,sCAAsC;AACtC,wBAAgB,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAqBrD"}
@@ -0,0 +1,128 @@
1
+ const COMMAND = 0;
2
+ const NUMBER = 1;
3
+ const EOD = 2;
4
+ const PARAMS = {
5
+ A: 7,
6
+ a: 7,
7
+ C: 6,
8
+ c: 6,
9
+ H: 1,
10
+ h: 1,
11
+ L: 2,
12
+ l: 2,
13
+ M: 2,
14
+ m: 2,
15
+ Q: 4,
16
+ q: 4,
17
+ S: 4,
18
+ s: 4,
19
+ T: 2,
20
+ t: 2,
21
+ V: 1,
22
+ v: 1,
23
+ Z: 0,
24
+ z: 0
25
+ };
26
+ const SPACE = /^([ \t\r\n,]+)/;
27
+ const LETTER = /^([aAcChHlLmMqQsStTvVzZ])/;
28
+ const NUMERIC = /^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/;
29
+ function tokenize(d) {
30
+ const tokens = [];
31
+ while('' !== d){
32
+ let match = SPACE.exec(d);
33
+ if (match) {
34
+ d = d.substring(match[1].length);
35
+ continue;
36
+ }
37
+ match = LETTER.exec(d);
38
+ if (match) {
39
+ tokens.push({
40
+ type: COMMAND,
41
+ text: match[1]
42
+ });
43
+ d = d.substring(match[1].length);
44
+ continue;
45
+ }
46
+ match = NUMERIC.exec(d);
47
+ if (match) {
48
+ tokens.push({
49
+ type: NUMBER,
50
+ text: `${parseFloat(match[1])}`
51
+ });
52
+ d = d.substring(match[1].length);
53
+ continue;
54
+ }
55
+ return [];
56
+ }
57
+ tokens.push({
58
+ type: EOD,
59
+ text: ''
60
+ });
61
+ return tokens;
62
+ }
63
+ function parsePath(d) {
64
+ const segments = [];
65
+ const tokens = tokenize(d);
66
+ let mode = 'BOD';
67
+ let index = 0;
68
+ let token = tokens[index];
69
+ while(token && token.type !== EOD){
70
+ let paramsCount = 0;
71
+ const params = [];
72
+ if ('BOD' === mode) if ('M' !== token.text && 'm' !== token.text) return parsePath('M0,0' + d);
73
+ else {
74
+ index++;
75
+ paramsCount = PARAMS[token.text];
76
+ mode = token.text;
77
+ }
78
+ else if (token.type === NUMBER) paramsCount = PARAMS[mode];
79
+ else {
80
+ index++;
81
+ paramsCount = PARAMS[token.text];
82
+ mode = token.text;
83
+ }
84
+ if (index + paramsCount < tokens.length) {
85
+ for(let i = index; i < index + paramsCount; i++){
86
+ const number = tokens[i];
87
+ if (number.type === NUMBER) params.push(+number.text);
88
+ else throw new Error('Param not a number: ' + mode + ',' + number.text);
89
+ }
90
+ if ('number' == typeof PARAMS[mode]) {
91
+ segments.push({
92
+ key: mode,
93
+ data: params
94
+ });
95
+ index += paramsCount;
96
+ token = tokens[index];
97
+ if ('M' === mode) mode = 'L';
98
+ if ('m' === mode) mode = 'l';
99
+ } else throw new Error('Bad segment: ' + mode);
100
+ } else throw new Error('Path data ended short');
101
+ }
102
+ return segments;
103
+ }
104
+ function serialize(segments) {
105
+ const tokens = [];
106
+ for (const { key, data } of segments){
107
+ tokens.push(key);
108
+ switch(key){
109
+ case 'C':
110
+ case 'c':
111
+ tokens.push(data[0], `${data[1]},`, data[2], `${data[3]},`, data[4], data[5]);
112
+ break;
113
+ case 'S':
114
+ case 's':
115
+ case 'Q':
116
+ case 'q':
117
+ tokens.push(data[0], `${data[1]},`, data[2], data[3]);
118
+ break;
119
+ default:
120
+ tokens.push(...data);
121
+ break;
122
+ }
123
+ }
124
+ return tokens.join(' ');
125
+ }
126
+ export { absolutize } from "path-data-parser/lib/absolutize.js";
127
+ export { normalize } from "path-data-parser/lib/normalize.js";
128
+ export { parsePath, serialize };
@@ -0,0 +1,58 @@
1
+ import type { ExElement } from './types.js';
2
+ /**
3
+ * The scene of one board (Excalidraw's `Scene` + `reconcileElements` + per-user history): every element including
4
+ * tombstones, in Excalidraw's z-order. Local edits come in as already bumped elements (`commit`), remote ones are
5
+ * reconciled per element exactly like the server and the web app (a higher version wins, a tie goes to the lower
6
+ * versionNonce), so all copies converge. Undo/redo only touch my own changes and are themselves ordinary edits.
7
+ */
8
+ export interface SceneChange {
9
+ /** Elements whose content changed (new versions, including deleted ones). */
10
+ changed: ExElement[];
11
+ /** Mine (to push) or from the server. */
12
+ local: boolean;
13
+ /** The z-order changed (an element was added or its index moved). */
14
+ orderChanged: boolean;
15
+ }
16
+ /** The board's elements by id with their order, history (undo / redo) and remote changes. */
17
+ export declare class Scene {
18
+ private readonly map;
19
+ private ordered;
20
+ private orderDirty;
21
+ /** Elements changed without moving in the order: the cached list only needs fresh objects. */
22
+ private contentDirty;
23
+ private readonly undoStack;
24
+ private readonly redoStack;
25
+ private readonly listeners;
26
+ /** Elements being edited here right now (text in the input): a remote copy does not replace them (Excalidraw too). */
27
+ readonly editing: Set<string>;
28
+ constructor(elements?: readonly ExElement[]);
29
+ load(elements: readonly ExElement[]): void;
30
+ on(listener: (change: SceneChange) => void): () => void;
31
+ private emit;
32
+ get(id: string): ExElement | undefined;
33
+ /** Every element, tombstones included, bottom first. */
34
+ all(): readonly ExElement[];
35
+ /** The elements on the board (not deleted), bottom first. */
36
+ visible(): ExElement[];
37
+ /** The topmost index on the board (new elements go above it). */
38
+ lastIndex(): string | null;
39
+ /** Reconciles elements from the server; returns those that replaced the local copy. */
40
+ applyRemote(remote: readonly ExElement[]): ExElement[];
41
+ /**
42
+ * My edit: `elements` are the new versions (made with `bump` or new). Recorded for undo unless `history` is false
43
+ * (a step of a gesture that is recorded as a whole later, or an undo itself).
44
+ */
45
+ commit(elements: readonly ExElement[], history?: boolean): void;
46
+ /**
47
+ * Records one undo step for changes committed piece by piece without history (text typed live): `before` holds each
48
+ * element as it was before the first piece (null: new).
49
+ */
50
+ record(before: Map<string, ExElement | null>): void;
51
+ get canUndo(): boolean;
52
+ get canRedo(): boolean;
53
+ undo(): ExElement[];
54
+ redo(): ExElement[];
55
+ /** Brings elements back to the given states as new versions (so the others take them too). */
56
+ private restore;
57
+ }
58
+ //# sourceMappingURL=scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"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