@widgetic/canvas 0.5.43 → 0.5.45

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 (162) hide show
  1. package/dist/canvas/DomCanvas.svelte +56 -3
  2. package/dist/canvas/DomCanvas.svelte.d.ts +59 -28
  3. package/dist/canvas/autosaveScheduler.js +89 -37
  4. package/dist/canvas/boardFrame.js +1 -1
  5. package/dist/canvas/boardSurface.js +1 -1
  6. package/dist/canvas/canvasLogger.js +19 -7
  7. package/dist/canvas/chromeLayout.js +21 -19
  8. package/dist/canvas/eventScope.js +14 -10
  9. package/dist/canvas/host/CanvasHost.d.ts +87 -2
  10. package/dist/canvas/host/CanvasHost.js +1948 -1394
  11. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  12. package/dist/canvas/host/CanvasHostApi.js +32 -5
  13. package/dist/canvas/host/boardFiles.d.ts +90 -0
  14. package/dist/canvas/host/boardFiles.js +155 -0
  15. package/dist/canvas/host/browserServices.d.ts +17 -0
  16. package/dist/canvas/host/browserServices.js +211 -65
  17. package/dist/canvas/host/conversion.js +170 -82
  18. package/dist/canvas/host/hostObject.js +7 -7
  19. package/dist/canvas/host/nearCards.js +21 -18
  20. package/dist/canvas/host/pageEvents.js +5 -5
  21. package/dist/canvas/host/pictureSaves.js +11 -9
  22. package/dist/canvas/host/screenRects.js +31 -28
  23. package/dist/canvas/host/storedPictures.js +243 -149
  24. package/dist/canvas/host/strokeSnap.js +143 -88
  25. package/dist/canvas/index.d.ts +2 -0
  26. package/dist/canvas/openMarks.js +2 -2
  27. package/dist/canvas/outsideClickDeselect.js +7 -6
  28. package/dist/canvas/panZoomPosition.js +2 -2
  29. package/dist/canvas/preferredTextFont.js +25 -13
  30. package/dist/canvas/shapes/ShapeLibrary.js +148 -138
  31. package/dist/canvas/shapes/shapeImageStore.js +4 -4
  32. package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
  33. package/dist/canvas/toolbarPosition.js +2 -2
  34. package/dist/canvas/types.d.ts +17 -0
  35. package/dist/canvas/ui/CanvasContextMenu.svelte +7 -0
  36. package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
  37. package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
  38. package/dist/canvas/ui/ColorField.svelte +7 -2
  39. package/dist/canvas/ui/SelectionPanel.svelte +105 -42
  40. package/dist/canvas/ui/ShapesMenu.svelte +65 -31
  41. package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
  42. package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
  43. package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
  44. package/dist/canvas/ui/ToolButton.svelte +35 -54
  45. package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
  46. package/dist/canvas/ui/colorModel.js +32 -21
  47. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  48. package/dist/canvas/ui/floatingCard.d.ts +26 -4
  49. package/dist/canvas/ui/floatingCard.js +43 -21
  50. package/dist/canvas/ui/floatingLayer.js +6 -5
  51. package/dist/canvas/ui/icons.d.ts +1 -1
  52. package/dist/canvas/ui/icons.js +1 -1
  53. package/dist/canvas/ui/keyHints.js +11 -9
  54. package/dist/canvas/ui/popoverSide.js +3 -2
  55. package/dist/canvas/ui/selectionTraits.d.ts +12 -0
  56. package/dist/canvas/ui/selectionTraits.js +66 -35
  57. package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
  58. package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
  59. package/dist/canvas/view/CanvasStage.svelte +7 -2
  60. package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
  61. package/dist/canvas/view/SelectionOverlay.svelte +17 -10
  62. package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
  63. package/dist/canvas/view/erasingMarks.js +7 -7
  64. package/dist/canvas/view/geometry.d.ts +1 -1
  65. package/dist/canvas/view/geometry.js +90 -71
  66. package/dist/canvas/view/liftedScene.js +36 -24
  67. package/dist/canvas/view/mountedScene.js +79 -76
  68. package/dist/components/CanvasBoardPoster.svelte +206 -0
  69. package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
  70. package/dist/components/CanvasToolbarPlaceholder.svelte +115 -0
  71. package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +9 -0
  72. package/dist/components/index.d.ts +7 -0
  73. package/dist/components/index.js +8 -0
  74. package/dist/components/preferenceStorage.js +2 -2
  75. package/dist/engine/EngineCore.d.ts +111 -2
  76. package/dist/engine/EngineCore.js +1013 -707
  77. package/dist/engine/codec/canvasDocument.d.ts +7 -0
  78. package/dist/engine/codec/canvasDocument.js +172 -186
  79. package/dist/engine/codec/hostReadableKeys.js +1 -1
  80. package/dist/engine/core/arrange.js +38 -26
  81. package/dist/engine/core/arrow.d.ts +18 -8
  82. package/dist/engine/core/arrow.js +109 -84
  83. package/dist/engine/core/arrowBinding.d.ts +1 -1
  84. package/dist/engine/core/arrowBinding.js +126 -101
  85. package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
  86. package/dist/engine/core/arrowBindingRecords.js +48 -29
  87. package/dist/engine/core/brush.d.ts +8 -0
  88. package/dist/engine/core/brush.js +98 -78
  89. package/dist/engine/core/cameraMove.d.ts +73 -0
  90. package/dist/engine/core/cameraMove.js +172 -0
  91. package/dist/engine/core/defaults.js +51 -90
  92. package/dist/engine/core/freehand.js +163 -147
  93. package/dist/engine/core/geometry.js +54 -47
  94. package/dist/engine/core/history.js +55 -38
  95. package/dist/engine/core/hitTest.js +81 -68
  96. package/dist/engine/core/matrix.js +20 -18
  97. package/dist/engine/core/pathData.js +210 -183
  98. package/dist/engine/core/rotationReset.js +6 -5
  99. package/dist/engine/core/scene.d.ts +22 -0
  100. package/dist/engine/core/scene.js +288 -139
  101. package/dist/engine/core/scribble.js +84 -59
  102. package/dist/engine/core/shapePaths.js +15 -12
  103. package/dist/engine/core/shapeTools.js +63 -72
  104. package/dist/engine/core/snapping.js +117 -65
  105. package/dist/engine/core/style.d.ts +10 -0
  106. package/dist/engine/core/style.js +82 -33
  107. package/dist/engine/core/transform.d.ts +6 -0
  108. package/dist/engine/core/transform.js +103 -83
  109. package/dist/engine/core/types.d.ts +7 -0
  110. package/dist/engine/core/types.js +4 -4
  111. package/dist/engine/core/viewport.js +36 -23
  112. package/dist/engine/input/PointerController.d.ts +15 -1
  113. package/dist/engine/input/PointerController.js +549 -466
  114. package/dist/engine/input/arrowHandles.js +12 -12
  115. package/dist/engine/input/gestures.d.ts +3 -1
  116. package/dist/engine/input/gestures.js +340 -266
  117. package/dist/engine/input/hoverCursor.js +1 -1
  118. package/dist/engine/input/keyboard.d.ts +22 -3
  119. package/dist/engine/input/keyboard.js +131 -32
  120. package/dist/engine/input/selectionHandles.js +50 -45
  121. package/dist/engine/input/types.d.ts +7 -0
  122. package/dist/engine/input/types.js +1 -1
  123. package/dist/engine/render/rasterize.js +158 -86
  124. package/dist/engine/state.d.ts +18 -0
  125. package/dist/engine/state.js +25 -4
  126. package/dist/engine/text/layoutText.js +62 -43
  127. package/dist/engine/text/textMetrics.js +10 -8
  128. package/dist/engine/widgets.js +137 -101
  129. package/dist/fonts/interFont.js +83 -30
  130. package/dist/fonts/workspaceFonts.d.ts +6 -0
  131. package/dist/fonts/workspaceFonts.js +108 -34
  132. package/dist/i18n/labels.js +4 -4
  133. package/dist/i18n/language.d.ts +3 -3
  134. package/dist/i18n/language.js +4 -4
  135. package/dist/i18n/messages.d.ts +6 -0
  136. package/dist/i18n/messages.js +7 -1
  137. package/dist/i18n/shortcuts.d.ts +6 -4
  138. package/dist/i18n/shortcuts.js +30 -26
  139. package/dist/index.d.ts +2 -1
  140. package/dist/poster/boardPlacement.d.ts +80 -0
  141. package/dist/poster/boardPlacement.js +140 -0
  142. package/dist/poster/boardPoster.d.ts +80 -0
  143. package/dist/poster/boardPoster.js +251 -0
  144. package/dist/poster/paintBoardPoster.d.ts +49 -0
  145. package/dist/poster/paintBoardPoster.js +112 -0
  146. package/dist/poster/posterPictures.d.ts +32 -0
  147. package/dist/poster/posterPictures.js +138 -0
  148. package/dist/settings/workspaceToolSettings.d.ts +6 -0
  149. package/dist/settings/workspaceToolSettings.js +58 -34
  150. package/dist/tools/components/catalog.js +74 -64
  151. package/dist/tools/components/grouping.js +28 -6
  152. package/dist/tools/definitions.js +31 -9
  153. package/dist/tools/executors.js +214 -106
  154. package/dist/tools/hostAdapter.d.ts +5 -1
  155. package/dist/tools/hostAdapter.js +15 -11
  156. package/dist/tools/sceneSummary.js +57 -43
  157. package/dist/tools/sketchIntent.js +21 -13
  158. package/dist/tools/styleArguments.d.ts +35 -0
  159. package/dist/tools/styleArguments.js +93 -0
  160. package/dist/tools/types.d.ts +26 -1
  161. package/dist/tools/types.js +2 -1
  162. package/package.json +1 -1
@@ -3,6 +3,17 @@
3
3
  * which cursor the board shows. Plain functions of the engine's records and the viewport, free of Svelte and the DOM, so
4
4
  * a view only writes what they return and Node can test them.
5
5
  */
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
6
17
  import { isArrow } from '../../engine/core/arrow.js';
7
18
  import { strokeDashArray } from '../../engine/core/defaults.js';
8
19
  import { boxToWorldMatrix, degreesToRadians, matrixToCss } from '../../engine/core/matrix.js';
@@ -17,23 +28,23 @@ import { fontShorthand } from '../../engine/text/layoutText.js';
17
28
  */
18
29
  export function placementCss(box) {
19
30
  if (!box.rotation)
20
- return `matrix(1, 0, 0, 1, ${Number(box.x.toFixed(5))}, ${Number(box.y.toFixed(5))})`;
31
+ return "matrix(1, 0, 0, 1, ".concat(Number(box.x.toFixed(5)), ", ").concat(Number(box.y.toFixed(5)), ")");
21
32
  return matrixToCss(boxToWorldMatrix(box));
22
33
  }
23
34
  /** The size of an object's box and the corner it turns about: what its style says apart from where it stands. */
24
35
  export function boxSizeCss(box) {
25
- return `left:0;top:0;width:${trim(box.width)}px;height:${trim(box.height)}px;transform-origin:0 0;`;
36
+ return "left:0;top:0;width:".concat(trim(box.width), "px;height:").concat(trim(box.height), "px;transform-origin:0 0;");
26
37
  }
27
38
  /** The CSS that puts an object's box where it belongs in the world layer: its size, and its turn about its own middle. */
28
39
  export function boxStyle(box) {
29
- return `${boxSizeCss(box)}transform:${placementCss(box)};`;
40
+ return "".concat(boxSizeCss(box), "transform:").concat(placementCss(box), ";");
30
41
  }
31
42
  /** What a text's style says apart from its box: the padding, the colours, the font, and how its lines sit in the box. */
32
43
  export function textBoxCss(text) {
33
- return `padding:${text.padding}px;background-color:${text.backgroundColor};color:${text.color};font:${fontShorthand(text)};line-height:${text.lineHeight};text-align:${text.align};${text.underline ? 'text-decoration:underline;' : ''}`;
44
+ return "padding:".concat(text.padding, "px;background-color:").concat(text.backgroundColor, ";color:").concat(text.color, ";font:").concat(fontShorthand(text), ";line-height:").concat(text.lineHeight, ";text-align:").concat(text.align, ";").concat(text.underline ? 'text-decoration:underline;' : '');
34
45
  }
35
46
  /** The fields of a record that say where an object stands; every other field says what it looks like. */
36
- const PLACEMENT_FIELDS = new Set(['x', 'y', 'rotation']);
47
+ var PLACEMENT_FIELDS = new Set(['x', 'y', 'rotation']);
37
48
  /**
38
49
  * True when two records of an object differ only in where they stand (its position and its turn).
39
50
  *
@@ -46,14 +57,14 @@ export function sameLook(first, second) {
46
57
  return true;
47
58
  if (first.type !== second.type)
48
59
  return false;
49
- const before = first;
50
- const after = second;
51
- for (const key in after) {
60
+ var before = first;
61
+ var after = second;
62
+ for (var key in after) {
52
63
  if (!PLACEMENT_FIELDS.has(key) && before[key] !== after[key])
53
64
  return false;
54
65
  }
55
66
  // A field that was dropped is a change too (a record with the same fields never takes this loop further).
56
- for (const key in before) {
67
+ for (var key in before) {
57
68
  if (!PLACEMENT_FIELDS.has(key) && !(key in after))
58
69
  return false;
59
70
  }
@@ -61,8 +72,8 @@ export function sameLook(first, second) {
61
72
  }
62
73
  /** A colour of `transparent` (or a stroke with no width) is "none" in SVG. */
63
74
  export function svgPaintOf(shape) {
64
- const hasStroke = shape.stroke !== 'transparent' && shape.strokeWidth > 0;
65
- const dash = hasStroke ? strokeDashArray(shape.strokeStyle, shape.strokeWidth) : null;
75
+ var hasStroke = shape.stroke !== 'transparent' && shape.strokeWidth > 0;
76
+ var dash = hasStroke ? strokeDashArray(shape.strokeStyle, shape.strokeWidth) : null;
66
77
  return {
67
78
  fill: shape.fill === 'transparent' ? 'none' : shape.fill,
68
79
  fillOpacity: shape.fillOpacity,
@@ -74,10 +85,10 @@ export function svgPaintOf(shape) {
74
85
  };
75
86
  }
76
87
  export function screenFrameOf(frame, viewport) {
77
- const center = worldToScreen(viewport, { x: frame.x + frame.width / 2, y: frame.y + frame.height / 2 });
78
- const width = frame.width * viewport.zoom;
79
- const height = frame.height * viewport.zoom;
80
- return { left: center.x - width / 2, top: center.y - height / 2, width, height, rotation: frame.rotation, centerX: center.x, centerY: center.y };
88
+ var center = worldToScreen(viewport, { x: frame.x + frame.width / 2, y: frame.y + frame.height / 2 });
89
+ var width = frame.width * viewport.zoom;
90
+ var height = frame.height * viewport.zoom;
91
+ return { left: center.x - width / 2, top: center.y - height / 2, width: width, height: height, rotation: frame.rotation, centerX: center.x, centerY: center.y };
81
92
  }
82
93
  /**
83
94
  * The CSS that places a box in a layer that covers the board, in pixels from the layer's top left corner.
@@ -86,14 +97,15 @@ export function screenFrameOf(frame, viewport) {
86
97
  * a physical distance from the left edge, and is not written with the start of the line.
87
98
  */
88
99
  export function layerBoxStyle(box) {
89
- const size = (box.width === undefined ? '' : `width:${trim(box.width)}px;`) + (box.height === undefined ? '' : `height:${trim(box.height)}px;`);
100
+ var size = (box.width === undefined ? '' : "width:".concat(trim(box.width), "px;")) + (box.height === undefined ? '' : "height:".concat(trim(box.height), "px;"));
90
101
  // rtl-ok: a place on the drawing, measured from the left edge of the layer on every screen
91
- return `left:${trim(box.left)}px;top:${trim(box.top)}px;${size}`;
102
+ return "left:".concat(trim(box.left), "px;top:").concat(trim(box.top), "px;").concat(size);
92
103
  }
93
104
  /** The CSS that puts a box of `width` by `height` (a square when only `width` is given) with its middle on a point of the layer that covers the board. */
94
- export function layerCenteredStyle(center, width, height = width) {
105
+ export function layerCenteredStyle(center, width, height) {
106
+ if (height === void 0) { height = width; }
95
107
  // rtl-ok: a place on the drawing, measured from the left edge of the layer on every screen
96
- return layerBoxStyle({ left: center.x - width / 2, top: center.y - height / 2, width, height });
108
+ return layerBoxStyle({ left: center.x - width / 2, top: center.y - height / 2, width: width, height: height });
97
109
  }
98
110
  /** The CSS that places a point of the layer that covers the board (the corner a label starts from). */
99
111
  export function layerPointStyle(point) {
@@ -104,20 +116,20 @@ export function layerPointStyle(point) {
104
116
  * on the screen, and the scale from the coordinates of its path to pixels.
105
117
  */
106
118
  export function arrowOutlinePlacement(box, viewport) {
107
- const corner = worldToScreen(viewport, { x: box.x, y: box.y });
119
+ var corner = worldToScreen(viewport, { x: box.x, y: box.y });
108
120
  return { style: layerBoxStyle({ left: corner.x, top: corner.y }), scale: viewport.zoom };
109
121
  }
110
122
  /** The CSS that places a screen frame in a layer that covers the board. */
111
123
  export function screenFrameStyle(frame) {
112
- const turn = frame.rotation === 0 ? '' : `transform:rotate(${trim(frame.rotation)}deg);`;
113
- return `${layerBoxStyle(frame)}${turn}`;
124
+ var turn = frame.rotation === 0 ? '' : "transform:rotate(".concat(trim(frame.rotation), "deg);");
125
+ return "".concat(layerBoxStyle(frame)).concat(turn);
114
126
  }
115
127
  /**
116
128
  * What the figure in the middle of a selection says: a size as `450 × 149`, an angle as `35°`. Numbers and signs, no
117
129
  * words, so it needs no translation (the page that shows it sets its direction to left to right, so the order holds).
118
130
  */
119
131
  export function formatReadout(readout) {
120
- return readout.kind === 'size' ? `${readout.width} × ${readout.height}` : `${readout.degrees}°`;
132
+ return readout.kind === 'size' ? "".concat(readout.width, " \u00D7 ").concat(readout.height) : "".concat(readout.degrees, "\u00B0");
121
133
  }
122
134
  /**
123
135
  * Where the size label sits: in the middle of the selection (the middle of the frame, whatever its turn, and of the box around
@@ -129,8 +141,8 @@ export function restingSizeLabelPoint(frame, _text) {
129
141
  }
130
142
  /** A point at `distance` pixels below the bottom edge of a turned frame, in the middle of that edge: where the turning dot goes. */
131
143
  export function pointBelowFrame(frame, distance) {
132
- const radians = degreesToRadians(frame.rotation);
133
- const reach = frame.height / 2 + distance;
144
+ var radians = degreesToRadians(frame.rotation);
145
+ var reach = frame.height / 2 + distance;
134
146
  return { x: frame.centerX - Math.sin(radians) * reach, y: frame.centerY + Math.cos(radians) * reach };
135
147
  }
136
148
  /**
@@ -138,27 +150,27 @@ export function pointBelowFrame(frame, distance) {
138
150
  * shape, the upright rectangle around the members for a group.
139
151
  */
140
152
  export function outlineOfUnit(scene, id) {
141
- const object = scene.find((candidate) => candidate.id === id);
153
+ var object = scene.find(function (candidate) { return candidate.id === id; });
142
154
  if (!object)
143
155
  return null;
144
156
  if (object.type !== 'group') {
145
- const shape = object;
157
+ var shape = object;
146
158
  return { x: shape.x, y: shape.y, width: shape.width, height: shape.height, rotation: shape.rotation };
147
159
  }
148
- const bounds = boundsOfObjects(scene, [id]);
149
- return bounds ? { ...bounds, rotation: 0 } : null;
160
+ var bounds = boundsOfObjects(scene, [id]);
161
+ return bounds ? __assign(__assign({}, bounds), { rotation: 0 }) : null;
150
162
  }
151
163
  /** The mark for the tie the engine says is in the offing, or null when there is none (or its shape is not on the board any more). */
152
164
  export function arrowBindMarkOf(scene, hint, viewport) {
153
165
  if (!hint)
154
166
  return null;
155
- const outline = outlineOfUnit(scene, hint.targetId);
167
+ var outline = outlineOfUnit(scene, hint.targetId);
156
168
  if (!outline)
157
169
  return null;
158
170
  return { frame: screenFrameOf(outline, viewport), point: worldToScreen(viewport, hint.point), kind: hint.kind };
159
171
  }
160
172
  /** What a marquee that takes nothing draws: the one shared empty answer, so a derived value that holds it stays the same. */
161
- export const NO_MARQUEE_OUTLINES = Object.freeze({ frames: Object.freeze([]), arrows: Object.freeze([]) });
173
+ export var NO_MARQUEE_OUTLINES = Object.freeze({ frames: Object.freeze([]), arrows: Object.freeze([]) });
162
174
  /**
163
175
  * The outlines of the units a marquee would take, in the order given (paint order). One pass over the scene finds the units,
164
176
  * so a marquee over the whole board costs one more pass for every group in it and no more for a shape.
@@ -166,32 +178,34 @@ export const NO_MARQUEE_OUTLINES = Object.freeze({ frames: Object.freeze([]), ar
166
178
  export function marqueeOutlinesOf(scene, ids, viewport) {
167
179
  if (ids.length === 0)
168
180
  return NO_MARQUEE_OUTLINES;
169
- const wanted = new Set(ids);
170
- const found = new Map();
171
- for (const object of scene) {
181
+ var wanted = new Set(ids);
182
+ var found = new Map();
183
+ for (var _i = 0, scene_1 = scene; _i < scene_1.length; _i++) {
184
+ var object = scene_1[_i];
172
185
  if (wanted.has(object.id))
173
186
  found.set(object.id, object);
174
187
  }
175
- const frames = [];
176
- const arrows = [];
177
- for (const id of ids) {
178
- const object = found.get(id);
188
+ var frames = [];
189
+ var arrows = [];
190
+ for (var _a = 0, ids_1 = ids; _a < ids_1.length; _a++) {
191
+ var id = ids_1[_a];
192
+ var object = found.get(id);
179
193
  if (!object)
180
194
  continue;
181
195
  if (object.type === 'path' && isArrow(object)) {
182
196
  arrows.push(object);
183
197
  continue;
184
198
  }
185
- const outline = object.type === 'group' ? outlineOfUnit(scene, id) : { x: object.x, y: object.y, width: object.width, height: object.height, rotation: object.rotation };
199
+ var outline = object.type === 'group' ? outlineOfUnit(scene, id) : { x: object.x, y: object.y, width: object.width, height: object.height, rotation: object.rotation };
186
200
  if (outline)
187
- frames.push({ id, frame: screenFrameOf(outline, viewport) });
201
+ frames.push({ id: id, frame: screenFrameOf(outline, viewport) });
188
202
  }
189
- return frames.length === 0 && arrows.length === 0 ? NO_MARQUEE_OUTLINES : { frames, arrows };
203
+ return frames.length === 0 && arrows.length === 0 ? NO_MARQUEE_OUTLINES : { frames: frames, arrows: arrows };
190
204
  }
191
205
  /** What a marquee that takes nothing draws: the one shared empty answer. */
192
- export const NO_OUTLINE_PATHS = Object.freeze({ upright: '', turned: '' });
206
+ export var NO_OUTLINE_PATHS = Object.freeze({ upright: '', turned: '' });
193
207
  /** Half the width of the line, in pixels: the line is centred this far outside the edge, so it covers the pixel just outside it. */
194
- const OUTLINE_HALF_WIDTH = 0.5;
208
+ var OUTLINE_HALF_WIDTH = 0.5;
195
209
  /**
196
210
  * The paths of the outlines of some frames, in the order given.
197
211
  *
@@ -203,41 +217,46 @@ const OUTLINE_HALF_WIDTH = 0.5;
203
217
  export function outlinePathsOf(frames) {
204
218
  if (frames.length === 0)
205
219
  return NO_OUTLINE_PATHS;
206
- let upright = '';
207
- let turned = '';
208
- for (const { frame } of frames) {
220
+ var upright = '';
221
+ var turned = '';
222
+ var _loop_1 = function (frame) {
209
223
  if (!Number.isFinite(frame.left + frame.top + frame.width + frame.height + frame.rotation))
210
- continue;
224
+ return "continue";
211
225
  if (frame.rotation === 0) {
212
- const left = Math.round(frame.left);
213
- const top = Math.round(frame.top);
214
- const reachRight = Math.round(frame.left + frame.width) - left + 2 * OUTLINE_HALF_WIDTH;
215
- const reachDown = Math.round(frame.top + frame.height) - top + 2 * OUTLINE_HALF_WIDTH;
216
- upright += `M${left - OUTLINE_HALF_WIDTH} ${top - OUTLINE_HALF_WIDTH}h${reachRight}v${reachDown}h${-reachRight}z`;
217
- continue;
226
+ var left = Math.round(frame.left);
227
+ var top = Math.round(frame.top);
228
+ var reachRight = Math.round(frame.left + frame.width) - left + 2 * OUTLINE_HALF_WIDTH;
229
+ var reachDown = Math.round(frame.top + frame.height) - top + 2 * OUTLINE_HALF_WIDTH;
230
+ upright += "M".concat(left - OUTLINE_HALF_WIDTH, " ").concat(top - OUTLINE_HALF_WIDTH, "h").concat(reachRight, "v").concat(reachDown, "h").concat(-reachRight, "z");
231
+ return "continue";
218
232
  }
219
- const radians = degreesToRadians(frame.rotation);
220
- const cosine = Math.cos(radians);
221
- const sine = Math.sin(radians);
222
- const halfWidth = frame.width / 2 + OUTLINE_HALF_WIDTH;
223
- const halfHeight = frame.height / 2 + OUTLINE_HALF_WIDTH;
233
+ var radians = degreesToRadians(frame.rotation);
234
+ var cosine = Math.cos(radians);
235
+ var sine = Math.sin(radians);
236
+ var halfWidth = frame.width / 2 + OUTLINE_HALF_WIDTH;
237
+ var halfHeight = frame.height / 2 + OUTLINE_HALF_WIDTH;
224
238
  // The four corners of the box grown by half the width of the line, turned about the middle of the box (clockwise, as CSS turns).
225
- const corners = [
239
+ var corners = [
226
240
  [-halfWidth, -halfHeight],
227
241
  [halfWidth, -halfHeight],
228
242
  [halfWidth, halfHeight],
229
243
  [-halfWidth, halfHeight]
230
244
  ];
231
245
  turned += corners
232
- .map(([cornerX, cornerY], index) => {
233
- const x = frame.centerX + cornerX * cosine - cornerY * sine;
234
- const y = frame.centerY + cornerX * sine + cornerY * cosine;
235
- return `${index === 0 ? 'M' : 'L'}${Math.round(x * 100) / 100} ${Math.round(y * 100) / 100}`;
246
+ .map(function (_a, index) {
247
+ var cornerX = _a[0], cornerY = _a[1];
248
+ var x = frame.centerX + cornerX * cosine - cornerY * sine;
249
+ var y = frame.centerY + cornerX * sine + cornerY * cosine;
250
+ return "".concat(index === 0 ? 'M' : 'L').concat(Math.round(x * 100) / 100, " ").concat(Math.round(y * 100) / 100);
236
251
  })
237
252
  .join('');
238
253
  turned += 'z';
254
+ };
255
+ for (var _i = 0, frames_1 = frames; _i < frames_1.length; _i++) {
256
+ var frame = frames_1[_i].frame;
257
+ _loop_1(frame);
239
258
  }
240
- return upright === '' && turned === '' ? NO_OUTLINE_PATHS : { upright, turned };
259
+ return upright === '' && turned === '' ? NO_OUTLINE_PATHS : { upright: upright, turned: turned };
241
260
  }
242
261
  /** The rectangle around a shape as the board shows it: for a shape that is turned, the box that holds its corners. */
243
262
  export function upright(shape) {
@@ -247,23 +266,23 @@ export function upright(shape) {
247
266
  * The dot grid under the objects (Figma "Dot Grid": a dot every 24 world units, 2 pixels across, the ink colour at 30%).
248
267
  * It moves and scales with the world, and doubles its step while the dots would be closer than 12 pixels.
249
268
  */
250
- export const DOT_GRID_STEP = 24;
251
- const DOT_GRID_MIN_SCREEN_STEP = 12;
269
+ export var DOT_GRID_STEP = 24;
270
+ var DOT_GRID_MIN_SCREEN_STEP = 12;
252
271
  /**
253
272
  * One dot in the middle of a cell, as a gradient: it takes its colour from the page's `foreground` token (a data URL
254
273
  * cannot), stays two pixels across at every zoom, and costs one background layer however large the board is.
255
274
  */
256
- export const DOT_GRID_IMAGE = 'radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--foreground, #0f172a) 30%, transparent) 0, color-mix(in srgb, var(--foreground, #0f172a) 30%, transparent) 1px, transparent 1.5px)';
275
+ export var DOT_GRID_IMAGE = 'radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--canvas-ink, var(--foreground, #0f172a)) 30%, transparent) 0, color-mix(in srgb, var(--canvas-ink, var(--foreground, #0f172a)) 30%, transparent) 1px, transparent 1.5px)';
257
276
  export function dotGridStyle(viewport) {
258
- let step = DOT_GRID_STEP;
277
+ var step = DOT_GRID_STEP;
259
278
  while (step * viewport.zoom < DOT_GRID_MIN_SCREEN_STEP)
260
279
  step *= 2;
261
- const size = step * viewport.zoom;
280
+ var size = step * viewport.zoom;
262
281
  // The cells follow the world origin, and the dot is in the middle of each, as in the design.
263
- return `background-image:${DOT_GRID_IMAGE};background-size:${trim(size)}px ${trim(size)}px;background-position:${trim(viewport.x)}px ${trim(viewport.y)}px;`;
282
+ return "background-image:".concat(DOT_GRID_IMAGE, ";background-size:").concat(trim(size), "px ").concat(trim(size), "px;background-position:").concat(trim(viewport.x), "px ").concat(trim(viewport.y), "px;");
264
283
  }
265
284
  /** The pointer of the board has a name for the turning handle that CSS does not know: it is drawn as a small arc with an arrowhead. */
266
- const ROTATE_CURSOR_CSS = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%230f2010' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7'/%3E%3Cpath d='M20 4v7h-7'/%3E%3C/svg%3E\") 12 12, grab";
285
+ var ROTATE_CURSOR_CSS = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%230f2010' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7'/%3E%3Cpath d='M20 4v7h-7'/%3E%3C/svg%3E\") 12 12, grab";
267
286
  /** The CSS `cursor` for what the engine asked the board to show. */
268
287
  export function cssCursor(cursor) {
269
288
  return cursor === ROTATE_CURSOR ? ROTATE_CURSOR_CSS : cursor;
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  /**
2
13
  * A big selection that is carried, drawn as one layer.
3
14
  *
@@ -28,23 +39,24 @@
28
39
  import { isBoxedObject } from '../../engine/core/types.js';
29
40
  import { canvasLog } from '../canvasLogger.js';
30
41
  /** A carried selection is drawn as one layer only when at least this many of its objects have an element: a few cost nothing to write. */
31
- export const LIFT_MINIMUM_CARRIED = 40;
42
+ export var LIFT_MINIMUM_CARRIED = 40;
32
43
  /**
33
44
  * ...and only when the objects that are not carried (and have an element) are at most this share of the ones that are, when the drag
34
45
  * begins: the work of a step is the work for those, so that is how much of the work is left (a third at the most, with one half).
35
46
  */
36
- export const LIFT_UNCARRIED_SHARE = 0.5;
37
- const NO_OBJECTS = Object.freeze([]);
47
+ export var LIFT_UNCARRIED_SHARE = 0.5;
48
+ var NO_OBJECTS = Object.freeze([]);
38
49
  /** An object moved by a distance (the same object when the distance is none): a group draws nothing and has no place to move. */
39
50
  function movedBy(object, distanceX, distanceY) {
40
51
  if ((distanceX === 0 && distanceY === 0) || !isBoxedObject(object))
41
52
  return object;
42
- return { ...object, x: object.x + distanceX, y: object.y + distanceY };
53
+ return __assign(__assign({}, object), { x: object.x + distanceX, y: object.y + distanceY });
43
54
  }
44
55
  /** How many of the objects are carried. */
45
56
  export function countCarried(objects, shapeIds) {
46
- let carriedCount = 0;
47
- for (const object of objects) {
57
+ var carriedCount = 0;
58
+ for (var _i = 0, objects_1 = objects; _i < objects_1.length; _i++) {
59
+ var object = objects_1[_i];
48
60
  if (shapeIds.has(object.id))
49
61
  carriedCount += 1;
50
62
  }
@@ -56,11 +68,11 @@ export function countCarried(objects, shapeIds) {
56
68
  * object has no record from the start, which says that what the engine handed over is not what this drag is made of.
57
69
  */
58
70
  export function recordsWhileLifted(mounted, carry) {
59
- const records = new Array(mounted.length);
60
- for (let position = 0; position < mounted.length; position += 1) {
61
- const object = mounted[position];
71
+ var records = new Array(mounted.length);
72
+ for (var position = 0; position < mounted.length; position += 1) {
73
+ var object = mounted[position];
62
74
  if (carry.shapeIds.has(object.id)) {
63
- const recordFromTheStart = carry.startRecords.get(object.id);
75
+ var recordFromTheStart = carry.startRecords.get(object.id);
64
76
  if (recordFromTheStart === undefined)
65
77
  return null;
66
78
  records[position] = recordFromTheStart;
@@ -77,7 +89,7 @@ function sameRecordsInOrder(first, second) {
77
89
  return true;
78
90
  if (first.length !== second.length)
79
91
  return false;
80
- for (let position = 0; position < first.length; position += 1) {
92
+ for (var position = 0; position < first.length; position += 1) {
81
93
  if (first[position] !== second[position])
82
94
  return false;
83
95
  }
@@ -85,15 +97,15 @@ function sameRecordsInOrder(first, second) {
85
97
  }
86
98
  export function createLiftedView() {
87
99
  // The drag that was seen last, told by the set of its shapes (one set for a drag, the same one at every step), and what was decided for it.
88
- let seenDrag = null;
89
- let decision = 'undecided';
100
+ var seenDrag = null;
101
+ var decision = 'undecided';
90
102
  // What was handed out last: the same records again are handed out as the very same list, so that the stage is told nothing.
91
- let lastList = NO_OBJECTS;
103
+ var lastList = NO_OBJECTS;
92
104
  // Once the work has failed the objects are drawn the plain way from then on (and the failure is said once).
93
- let failed = false;
94
- const drawnPlain = (mounted) => ({ objects: mounted, offsetX: 0, offsetY: 0 });
105
+ var failed = false;
106
+ var drawnPlain = function (mounted) { return ({ objects: mounted, offsetX: 0, offsetY: 0 }); };
95
107
  return {
96
- show(mounted, carry) {
108
+ show: function (mounted, carry) {
97
109
  if (carry === null) {
98
110
  seenDrag = null;
99
111
  decision = 'undecided';
@@ -110,29 +122,29 @@ export function createLiftedView() {
110
122
  }
111
123
  if (decision === 'plain')
112
124
  return drawnPlain(mounted);
113
- const carriedCount = countCarried(mounted, carry.shapeIds);
114
- const uncarriedCount = mounted.length - carriedCount;
125
+ var carriedCount = countCarried(mounted, carry.shapeIds);
126
+ var uncarriedCount = mounted.length - carriedCount;
115
127
  if (decision === 'undecided') {
116
- const worthIt = carriedCount >= LIFT_MINIMUM_CARRIED && uncarriedCount <= carriedCount * LIFT_UNCARRIED_SHARE;
128
+ var worthIt = carriedCount >= LIFT_MINIMUM_CARRIED && uncarriedCount <= carriedCount * LIFT_UNCARRIED_SHARE;
117
129
  decision = worthIt ? 'lifted' : 'plain';
118
130
  // Said once for the drag, and only for the drags that are drawn another way: the plain way is every other drag.
119
131
  if (worthIt)
120
- canvasLog(`Canvas: a drag of ${carriedCount} objects (${uncarriedCount} others with an element) is drawn as one layer`);
132
+ canvasLog("Canvas: a drag of ".concat(carriedCount, " objects (").concat(uncarriedCount, " others with an element) is drawn as one layer"));
121
133
  }
122
134
  else if (uncarriedCount > carriedCount) {
123
135
  // The drag has come to a crowd of objects that are not carried: moving each of them back costs more than writing the carried ones.
124
136
  decision = 'plain';
125
- canvasLog(`Canvas: the drag came to ${uncarriedCount} objects that are not carried, so it is drawn object by object from here`);
137
+ canvasLog("Canvas: the drag came to ".concat(uncarriedCount, " objects that are not carried, so it is drawn object by object from here"));
126
138
  }
127
139
  if (decision === 'plain')
128
140
  return drawnPlain(mounted);
129
- const records = recordsWhileLifted(mounted, carry);
141
+ var records = recordsWhileLifted(mounted, carry);
130
142
  if (records === null) {
131
143
  decision = 'plain';
132
144
  canvasLog('Canvas: a carried object had no record from the start of the drag, so the drag is drawn object by object');
133
145
  return drawnPlain(mounted);
134
146
  }
135
- const list = sameRecordsInOrder(records, lastList) ? lastList : records;
147
+ var list = sameRecordsInOrder(records, lastList) ? lastList : records;
136
148
  lastList = list;
137
149
  return { objects: list, offsetX: carry.deltaX, offsetY: carry.deltaY };
138
150
  }