@widgetic/canvas 0.5.39 → 0.5.41

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 (134) hide show
  1. package/README.md +7 -3
  2. package/dist/canvas/DomCanvas.svelte +7 -3
  3. package/dist/canvas/DomCanvas.svelte.d.ts +8 -0
  4. package/dist/canvas/autosaveScheduler.js +89 -37
  5. package/dist/canvas/boardFrame.js +1 -1
  6. package/dist/canvas/boardSurface.js +1 -1
  7. package/dist/canvas/canvasLogger.js +19 -7
  8. package/dist/canvas/chromeLayout.d.ts +2 -0
  9. package/dist/canvas/chromeLayout.js +31 -17
  10. package/dist/canvas/eventScope.js +14 -10
  11. package/dist/canvas/host/CanvasHost.d.ts +6 -0
  12. package/dist/canvas/host/CanvasHost.js +1556 -1255
  13. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  14. package/dist/canvas/host/CanvasHostApi.js +25 -4
  15. package/dist/canvas/host/browserServices.js +116 -65
  16. package/dist/canvas/host/conversion.js +170 -82
  17. package/dist/canvas/host/hostObject.js +7 -7
  18. package/dist/canvas/host/pageEvents.js +4 -4
  19. package/dist/canvas/host/screenRects.js +31 -28
  20. package/dist/canvas/host/strokeSnap.js +143 -88
  21. package/dist/canvas/openMarks.js +2 -2
  22. package/dist/canvas/outsideClickDeselect.js +7 -6
  23. package/dist/canvas/panZoomPosition.js +2 -2
  24. package/dist/canvas/preferredTextFont.js +25 -13
  25. package/dist/canvas/shapes/ShapeLibrary.js +148 -138
  26. package/dist/canvas/shapes/shapeImageStore.js +3 -3
  27. package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
  28. package/dist/canvas/toolbarPosition.js +2 -2
  29. package/dist/canvas/ui/CanvasContextMenu.svelte +69 -39
  30. package/dist/canvas/ui/CanvasHint.svelte +17 -4
  31. package/dist/canvas/ui/CanvasHint.svelte.d.ts +2 -17
  32. package/dist/canvas/ui/CanvasToolbar.svelte +27 -10
  33. package/dist/canvas/ui/ColorField.svelte +1 -1
  34. package/dist/canvas/ui/SelectionPanel.svelte +24 -20
  35. package/dist/canvas/ui/ShapesMenu.svelte +0 -2
  36. package/dist/canvas/ui/ToolButton.svelte +11 -3
  37. package/dist/canvas/ui/ToolButton.svelte.d.ts +2 -0
  38. package/dist/canvas/ui/WidgetActions.svelte +1 -1
  39. package/dist/canvas/ui/ZoomControl.svelte +39 -4
  40. package/dist/canvas/ui/ZoomControl.svelte.d.ts +2 -2
  41. package/dist/canvas/ui/colorModel.js +32 -21
  42. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  43. package/dist/canvas/ui/floatingCard.d.ts +7 -5
  44. package/dist/canvas/ui/floatingCard.js +23 -21
  45. package/dist/canvas/ui/floatingLayer.js +6 -5
  46. package/dist/canvas/ui/keyHints.d.ts +5 -0
  47. package/dist/canvas/ui/keyHints.js +23 -7
  48. package/dist/canvas/ui/popoverSide.js +3 -2
  49. package/dist/canvas/ui/selectionTraits.js +40 -34
  50. package/dist/canvas/ui/sizeLabelVisibility.d.ts +5 -2
  51. package/dist/canvas/ui/sizeLabelVisibility.js +7 -6
  52. package/dist/canvas/ui/widgetSelectionPanel.d.ts +6 -0
  53. package/dist/canvas/ui/widgetSelectionPanel.js +9 -0
  54. package/dist/canvas/view/ObjectView.svelte +2 -1
  55. package/dist/canvas/view/SelectionOverlay.svelte +34 -14
  56. package/dist/canvas/view/erasingMarks.js +7 -7
  57. package/dist/canvas/view/geometry.d.ts +14 -4
  58. package/dist/canvas/view/geometry.js +103 -77
  59. package/dist/components/preferenceStorage.js +2 -2
  60. package/dist/engine/EngineCore.d.ts +4 -1
  61. package/dist/engine/EngineCore.js +801 -695
  62. package/dist/engine/codec/canvasDocument.js +173 -173
  63. package/dist/engine/codec/hostReadableKeys.js +1 -1
  64. package/dist/engine/core/arrange.js +38 -26
  65. package/dist/engine/core/arrow.d.ts +10 -3
  66. package/dist/engine/core/arrow.js +96 -75
  67. package/dist/engine/core/arrowBinding.d.ts +69 -0
  68. package/dist/engine/core/arrowBinding.js +344 -0
  69. package/dist/engine/core/arrowBindingRecords.d.ts +43 -0
  70. package/dist/engine/core/arrowBindingRecords.js +141 -0
  71. package/dist/engine/core/brush.js +94 -67
  72. package/dist/engine/core/defaults.js +51 -90
  73. package/dist/engine/core/freehand.js +163 -147
  74. package/dist/engine/core/geometry.js +54 -47
  75. package/dist/engine/core/history.js +50 -33
  76. package/dist/engine/core/hitTest.d.ts +3 -0
  77. package/dist/engine/core/hitTest.js +83 -69
  78. package/dist/engine/core/matrix.js +20 -18
  79. package/dist/engine/core/pathData.js +210 -183
  80. package/dist/engine/core/rotationReset.js +6 -5
  81. package/dist/engine/core/scene.d.ts +3 -0
  82. package/dist/engine/core/scene.js +192 -129
  83. package/dist/engine/core/scribble.js +84 -59
  84. package/dist/engine/core/shapePaths.js +15 -12
  85. package/dist/engine/core/shapeTools.js +63 -72
  86. package/dist/engine/core/snapping.js +117 -65
  87. package/dist/engine/core/style.js +64 -31
  88. package/dist/engine/core/transform.js +94 -83
  89. package/dist/engine/core/types.d.ts +29 -0
  90. package/dist/engine/core/types.js +4 -4
  91. package/dist/engine/core/viewport.js +36 -23
  92. package/dist/engine/input/PointerController.js +476 -447
  93. package/dist/engine/input/arrowHandles.js +12 -12
  94. package/dist/engine/input/gestures.d.ts +12 -1
  95. package/dist/engine/input/gestures.js +342 -251
  96. package/dist/engine/input/hoverCursor.js +1 -1
  97. package/dist/engine/input/keyboard.d.ts +9 -1
  98. package/dist/engine/input/keyboard.js +46 -27
  99. package/dist/engine/input/selectionHandles.js +50 -45
  100. package/dist/engine/input/types.js +1 -1
  101. package/dist/engine/render/rasterize.js +158 -86
  102. package/dist/engine/state.d.ts +6 -1
  103. package/dist/engine/state.js +17 -5
  104. package/dist/engine/text/layoutText.js +62 -43
  105. package/dist/engine/text/textMetrics.js +10 -8
  106. package/dist/engine/widgets.js +137 -101
  107. package/dist/fonts/interFont.js +68 -17
  108. package/dist/fonts/workspaceFonts.js +90 -32
  109. package/dist/i18n/labels.js +6 -5
  110. package/dist/i18n/language.js +4 -4
  111. package/dist/i18n/messages.d.ts +6 -6
  112. package/dist/i18n/messages.js +7 -7
  113. package/dist/i18n/shortcuts.d.ts +12 -0
  114. package/dist/i18n/shortcuts.js +32 -18
  115. package/dist/settings/workspaceToolSettings.js +48 -32
  116. package/dist/tools/components/catalog.d.ts +11 -0
  117. package/dist/tools/components/catalog.js +270 -0
  118. package/dist/tools/components/grouping.d.ts +9 -0
  119. package/dist/tools/components/grouping.js +33 -0
  120. package/dist/tools/definitions.d.ts +19 -0
  121. package/dist/tools/definitions.js +147 -0
  122. package/dist/tools/executors.d.ts +7 -0
  123. package/dist/tools/executors.js +324 -0
  124. package/dist/tools/hostAdapter.d.ts +14 -0
  125. package/dist/tools/hostAdapter.js +40 -0
  126. package/dist/tools/index.d.ts +6 -0
  127. package/dist/tools/index.js +6 -0
  128. package/dist/tools/sceneSummary.d.ts +24 -0
  129. package/dist/tools/sceneSummary.js +170 -0
  130. package/dist/tools/sketchIntent.d.ts +17 -0
  131. package/dist/tools/sketchIntent.js +166 -0
  132. package/dist/tools/types.d.ts +54 -0
  133. package/dist/tools/types.js +11 -0
  134. package/package.json +7 -2
@@ -3,7 +3,7 @@
3
3
  * Pure function so Node can test the owner's hover rules (item 19).
4
4
  */
5
5
  /** The CSS cursor keyword for hovering a canvas object (pointing hand, not an open grab). */
6
- export const HOVER_SHAPE_CURSOR = 'pointer';
6
+ export var HOVER_SHAPE_CURSOR = 'pointer';
7
7
  /**
8
8
  * Resolves the board cursor from hover state. Dragging and panning are handled elsewhere; this is idle hover only.
9
9
  */
@@ -5,7 +5,8 @@
5
5
  * in a form field, is a text being typed on the board, which tools the host allows), and this module answers
6
6
  * whether the board used the key. When it did, the shell stops the browser from also acting on it. The rules are
7
7
  * the ones the board has always had (delete, arrows, copy and paste, group, undo, layers, save, zoom, the letter
8
- * of each tool); they live here, apart from the DOM, so each one is tested with a plain record.
8
+ * of each tool, and the number of each tool of the drawing bar); they live here, apart from the DOM, so each one is
9
+ * tested with a plain record.
9
10
  */
10
11
  import type { EngineCore } from '../EngineCore.js';
11
12
  import type { PointerController } from './PointerController.js';
@@ -25,6 +26,13 @@ export interface KeyInput {
25
26
  export type ToolShortcut = 'select' | 'erase' | 'draw' | 'pan' | 'arrow' | 'rect' | 'triangle' | 'ellipse' | 'text' | 'image';
26
27
  /** The letter of each tool (the same letters the hints and the list of shortcuts show). */
27
28
  export declare const TOOL_LETTERS: Readonly<Record<string, ToolShortcut>>;
29
+ /**
30
+ * The number of each tool of the drawing bar, in the order the bar lists them (select, draw, erase, arrow, text): the
31
+ * digits 1 to 5 choose them, besides their letters. A digit is the one the person types (`key`), on the number row or on the
32
+ * numpad, so a layout whose number row needs Shift to type a digit reaches the tools as it types the digit. The hints and the
33
+ * list of shortcuts show these same numbers (`TOOL_DIGIT_KEYS` in `i18n/shortcuts.ts`; a test holds the two together).
34
+ */
35
+ export declare const TOOL_DIGITS: Readonly<Record<string, ToolShortcut>>;
28
36
  /** What the shell does that the engine does not: the things outside the board. */
29
37
  export interface KeyboardActions {
30
38
  /** Chooses a tool. The image tool opens the file picker, so the shell does it, not the engine. */
@@ -5,10 +5,11 @@
5
5
  * in a form field, is a text being typed on the board, which tools the host allows), and this module answers
6
6
  * whether the board used the key. When it did, the shell stops the browser from also acting on it. The rules are
7
7
  * the ones the board has always had (delete, arrows, copy and paste, group, undo, layers, save, zoom, the letter
8
- * of each tool); they live here, apart from the DOM, so each one is tested with a plain record.
8
+ * of each tool, and the number of each tool of the drawing bar); they live here, apart from the DOM, so each one is
9
+ * tested with a plain record.
9
10
  */
10
11
  /** The letter of each tool (the same letters the hints and the list of shortcuts show). */
11
- export const TOOL_LETTERS = Object.freeze({
12
+ export var TOOL_LETTERS = Object.freeze({
12
13
  V: 'select',
13
14
  E: 'erase',
14
15
  D: 'draw',
@@ -20,22 +21,35 @@ export const TOOL_LETTERS = Object.freeze({
20
21
  T: 'text',
21
22
  I: 'image'
22
23
  });
24
+ /**
25
+ * The number of each tool of the drawing bar, in the order the bar lists them (select, draw, erase, arrow, text): the
26
+ * digits 1 to 5 choose them, besides their letters. A digit is the one the person types (`key`), on the number row or on the
27
+ * numpad, so a layout whose number row needs Shift to type a digit reaches the tools as it types the digit. The hints and the
28
+ * list of shortcuts show these same numbers (`TOOL_DIGIT_KEYS` in `i18n/shortcuts.ts`; a test holds the two together).
29
+ */
30
+ export var TOOL_DIGITS = Object.freeze({
31
+ '1': 'select',
32
+ '2': 'draw',
33
+ '3': 'erase',
34
+ '4': 'arrow',
35
+ '5': 'text'
36
+ });
23
37
  /** The tools that belong to the drawing bar: they are hidden, and so are their letters, when the host turns that bar off. */
24
- const DRAWING_TOOLS = new Set(['select', 'erase', 'draw', 'arrow', 'text']);
25
- const ARROW_STEPS = Object.freeze({
38
+ var DRAWING_TOOLS = new Set(['select', 'erase', 'draw', 'arrow', 'text']);
39
+ var ARROW_STEPS = Object.freeze({
26
40
  ArrowUp: [0, -1],
27
41
  ArrowDown: [0, 1],
28
42
  ArrowLeft: [-1, 0],
29
43
  ArrowRight: [1, 0]
30
44
  });
31
45
  /** The nudge of an arrow key, and of an arrow key with Shift, in world units. */
32
- export const NUDGE_DISTANCE = 1;
33
- export const NUDGE_DISTANCE_WITH_SHIFT = 10;
46
+ export var NUDGE_DISTANCE = 1;
47
+ export var NUDGE_DISTANCE_WITH_SHIFT = 10;
34
48
  /** Keys the browser zooms the page with: kept from doing so whatever layout the person has. */
35
49
  export function isBrowserZoomKey(input) {
36
50
  if (!(input.ctrlKey || input.metaKey))
37
51
  return false;
38
- const { key, code } = input;
52
+ var key = input.key, code = input.code;
39
53
  return (key === '=' ||
40
54
  key === '+' ||
41
55
  key === '-' ||
@@ -56,7 +70,7 @@ function selectionExists(engine) {
56
70
  }
57
71
  /** Escape: leaves whatever is going on, one level at a time. */
58
72
  function handleEscape(host) {
59
- const { engine, controller, actions } = host;
73
+ var engine = host.engine, controller = host.controller, actions = host.actions;
60
74
  if (actions.closePanels())
61
75
  return true;
62
76
  if (controller.cancelGesture())
@@ -81,11 +95,11 @@ function handleEscape(host) {
81
95
  }
82
96
  /** Ctrl or Cmd with a key. Returns undefined when the combination is not one of the board's. */
83
97
  function handleShortcut(input, host) {
84
- const { engine, controller, actions } = host;
85
- const key = input.key;
86
- const lowerKey = key.length === 1 ? key.toLowerCase() : key;
87
- const editingText = !!engine.state.editingTextId;
88
- const typing = host.typingInField || editingText;
98
+ var engine = host.engine, controller = host.controller, actions = host.actions;
99
+ var key = input.key;
100
+ var lowerKey = key.length === 1 ? key.toLowerCase() : key;
101
+ var editingText = !!engine.state.editingTextId;
102
+ var typing = host.typingInField || editingText;
89
103
  // The save and the zoom work wherever the focus is.
90
104
  if (lowerKey === 's') {
91
105
  actions.save();
@@ -158,7 +172,7 @@ function handleShortcut(input, host) {
158
172
  // What a drag is doing is not a step yet: the history waits for the release.
159
173
  if (controller.gestureKind)
160
174
  return true;
161
- const redo = input.code === 'KeyY' || input.shiftKey;
175
+ var redo = input.code === 'KeyY' || input.shiftKey;
162
176
  if (redo)
163
177
  engine.redo();
164
178
  else
@@ -173,13 +187,13 @@ function handleShortcut(input, host) {
173
187
  * The bare brackets keep moving one step, as they always did on this board.
174
188
  */
175
189
  function handleLayerKey(input, host) {
176
- const { engine } = host;
177
- const forward = input.code === 'BracketRight';
190
+ var engine = host.engine;
191
+ var forward = input.code === 'BracketRight';
178
192
  if (host.typingInField || engine.state.editingTextId)
179
193
  return false;
180
194
  if (!selectionExists(engine))
181
195
  return false;
182
- const toEnd = (input.ctrlKey || input.metaKey) && input.shiftKey;
196
+ var toEnd = (input.ctrlKey || input.metaKey) && input.shiftKey;
183
197
  engine.reorderSelection(forward ? (toEnd ? 'front' : 'forward') : toEnd ? 'back' : 'backward');
184
198
  return true;
185
199
  }
@@ -192,8 +206,9 @@ export function toolIsAvailable(tool, tools) {
192
206
  * does not also scroll, zoom or select the page.
193
207
  */
194
208
  export function routeKeyDown(input, host) {
195
- const { engine, controller, actions } = host;
196
- const key = input.key;
209
+ var _a, _b;
210
+ var engine = host.engine, controller = host.controller, actions = host.actions;
211
+ var key = input.key;
197
212
  if (key === 'Escape')
198
213
  return handleEscape(host);
199
214
  // The keys that only change what a gesture does while it runs are not answered here: the shell tells the controller.
@@ -202,11 +217,11 @@ export function routeKeyDown(input, host) {
202
217
  if (input.code === 'BracketRight' || input.code === 'BracketLeft')
203
218
  return handleLayerKey(input, host);
204
219
  if (input.ctrlKey || input.metaKey) {
205
- const answered = handleShortcut(input, host);
220
+ var answered = handleShortcut(input, host);
206
221
  // A combination that is not ours (Ctrl+R, Ctrl+P) is the browser's.
207
222
  return answered === true;
208
223
  }
209
- const editingText = !!engine.state.editingTextId;
224
+ var editingText = !!engine.state.editingTextId;
210
225
  if (host.typingInField || editingText)
211
226
  return false;
212
227
  if (input.code === 'Space') {
@@ -216,7 +231,7 @@ export function routeKeyDown(input, host) {
216
231
  if (engine.state.tool === 'pan')
217
232
  return false;
218
233
  controller.setSpaceHeld(true);
219
- actions.spacePanChanged?.(true);
234
+ (_a = actions.spacePanChanged) === null || _a === void 0 ? void 0 : _a.call(actions, true);
220
235
  return true;
221
236
  }
222
237
  if (key === 'Delete' || key === 'Backspace') {
@@ -225,13 +240,13 @@ export function routeKeyDown(input, host) {
225
240
  void engine.deleteSelection();
226
241
  return true;
227
242
  }
228
- const step = ARROW_STEPS[key];
243
+ var step = ARROW_STEPS[key];
229
244
  if (step) {
230
245
  if (host.selectorHintOpen)
231
246
  return false;
232
247
  if (!selectionExists(engine))
233
248
  return false;
234
- const distance = input.shiftKey ? NUDGE_DISTANCE_WITH_SHIFT : NUDGE_DISTANCE;
249
+ var distance = input.shiftKey ? NUDGE_DISTANCE_WITH_SHIFT : NUDGE_DISTANCE;
235
250
  engine.nudgeSelection(step[0] * distance, step[1] * distance);
236
251
  return true;
237
252
  }
@@ -241,7 +256,9 @@ export function routeKeyDown(input, host) {
241
256
  }
242
257
  if (input.altKey)
243
258
  return false;
244
- const tool = key.length === 1 ? TOOL_LETTERS[key.toUpperCase()] : undefined;
259
+ // A letter chooses its tool, and so does the number of a tool of the drawing bar. This point is only reached when the person is
260
+ // not typing (a field of the page, or a text on the board: both returned above), so a digit written into a text stays a digit.
261
+ var tool = key.length === 1 ? ((_b = TOOL_LETTERS[key.toUpperCase()]) !== null && _b !== void 0 ? _b : TOOL_DIGITS[key]) : undefined;
245
262
  if (tool && toolIsAvailable(tool, host.tools)) {
246
263
  actions.chooseTool(tool);
247
264
  return true;
@@ -250,15 +267,17 @@ export function routeKeyDown(input, host) {
250
267
  }
251
268
  /** A key was released. Returns whether the board used it. */
252
269
  export function routeKeyUp(input, host) {
270
+ var _a, _b;
253
271
  if (input.code === 'Space') {
254
272
  host.controller.setSpaceHeld(false);
255
- host.actions.spacePanChanged?.(false);
273
+ (_b = (_a = host.actions).spacePanChanged) === null || _b === void 0 ? void 0 : _b.call(_a, false);
256
274
  return true;
257
275
  }
258
276
  return false;
259
277
  }
260
278
  /** The window lost the focus: nothing is held any more. */
261
279
  export function releaseHeldKeys(host) {
280
+ var _a, _b;
262
281
  host.controller.setSpaceHeld(false);
263
- host.actions.spacePanChanged?.(false);
282
+ (_b = (_a = host.actions).spacePanChanged) === null || _b === void 0 ? void 0 : _b.call(_a, false);
264
283
  }
@@ -13,29 +13,29 @@
13
13
  import { degreesToRadians } from '../core/matrix.js';
14
14
  import { handleDirection } from '../core/transform.js';
15
15
  import { worldToScreen } from '../core/viewport.js';
16
- const MOUSE_METRICS = { cornerReach: 10, edgeReach: 13, rotateZone: 22, dotReach: 18 };
17
- const TOUCH_METRICS = { cornerReach: 22, edgeReach: 20, rotateZone: 40, dotReach: 24 };
16
+ var MOUSE_METRICS = { cornerReach: 10, edgeReach: 13, rotateZone: 22, dotReach: 18 };
17
+ var TOUCH_METRICS = { cornerReach: 22, edgeReach: 20, rotateZone: 40, dotReach: 24 };
18
18
  export function handleMetricsFor(pointerType) {
19
19
  return pointerType === 'touch' ? TOUCH_METRICS : MOUSE_METRICS;
20
20
  }
21
21
  /** When false, only the dot under the frame turns the selection (corner zones stay in code but do not hit). */
22
- export const ENABLE_CORNER_ROTATE_ZONES = false;
22
+ export var ENABLE_CORNER_ROTATE_ZONES = false;
23
23
  /** How far under the bottom edge of the frame the turning dot rests, to its middle: half an edge handle, 4 px of air, half the grown dot. */
24
- export const ROTATION_DOT_OFFSET = 21;
24
+ export var ROTATION_DOT_OFFSET = 21;
25
25
  /** The turning dot while nobody is near it: a small handle. */
26
- export const ROTATION_DOT_REST_SIZE = 8;
26
+ export var ROTATION_DOT_REST_SIZE = 8;
27
27
  /** The turning dot under the pointer, and while it turns the selection. */
28
- export const ROTATION_DOT_ACTIVE_SIZE = 24;
28
+ export var ROTATION_DOT_ACTIVE_SIZE = 24;
29
29
  /** A selection thinner than this (screen pixels) has no edge handles: they would cover it, and it could not be moved. */
30
- export const MIN_EDGE_HANDLE_PIXELS = 16;
31
- export const ALL_HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
32
- export const CORNER_HANDLES = ['nw', 'ne', 'se', 'sw'];
30
+ export var MIN_EDGE_HANDLE_PIXELS = 16;
31
+ export var ALL_HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'];
32
+ export var CORNER_HANDLES = ['nw', 'ne', 'se', 'sw'];
33
33
  /** A text has no top or bottom handle: its height is its lines, so only the corners (which scale the letters) and the sides (which set the width) do anything. */
34
- export const TEXT_HANDLES = ['nw', 'ne', 'se', 'sw', 'e', 'w'];
34
+ export var TEXT_HANDLES = ['nw', 'ne', 'se', 'sw', 'e', 'w'];
35
35
  /** Which handles a selection shows, before its size is looked at (`handleAvailability` does that). */
36
36
  export function visibleHandles(shapes) {
37
37
  if (shapes.length === 1) {
38
- const only = shapes[0];
38
+ var only = shapes[0];
39
39
  if ((only.type === 'path' || only.type === 'ellipse') && only.aspectLocked)
40
40
  return CORNER_HANDLES;
41
41
  if (only.type === 'text')
@@ -44,14 +44,14 @@ export function visibleHandles(shapes) {
44
44
  return ALL_HANDLES;
45
45
  }
46
46
  /** What a selection with nothing special offers. */
47
- export const FULL_AVAILABILITY = Object.freeze({ handles: ALL_HANDLES, canRotate: true });
47
+ export var FULL_AVAILABILITY = Object.freeze({ handles: ALL_HANDLES, canRotate: true });
48
48
  /**
49
49
  * Whether the person can turn a selection. Not when a text is in it, alone, among other shapes, or inside a group: a text
50
50
  * is read upright, so it has no turning dot under its frame and no turning zone outside its corners (the owner's call, 8 Nov
51
51
  * 2026). A text that was saved turned stays as it was saved; nothing here turns it, and nothing turns it back.
52
52
  */
53
53
  export function canRotateSelection(shapes) {
54
- return !shapes.some((shape) => shape.type === 'text');
54
+ return !shapes.some(function (shape) { return shape.type === 'text'; });
55
55
  }
56
56
  /**
57
57
  * The handles of a selection. A widget card is plainer while the page's advanced tools are off (its four corners, no
@@ -59,17 +59,19 @@ export function canRotateSelection(shapes) {
59
59
  * (`canRotateSelection`). A selection that is thinner than `MIN_EDGE_HANDLE_PIXELS` on the screen (`screenSize`) keeps its
60
60
  * corners only.
61
61
  */
62
- export function handleAvailability(shapes, plainCards = false, screenSize) {
62
+ export function handleAvailability(shapes, plainCards, screenSize) {
63
+ if (plainCards === void 0) { plainCards = false; }
63
64
  if (plainCards && shapes.length === 1 && shapes[0].type === 'widget')
64
65
  return { handles: CORNER_HANDLES, canRotate: false };
65
- let handles = visibleHandles(shapes);
66
+ var handles = visibleHandles(shapes);
66
67
  if (screenSize && Math.min(screenSize.width, screenSize.height) < MIN_EDGE_HANDLE_PIXELS) {
67
68
  handles = handles.filter(isCornerHandle);
68
69
  }
69
- return { handles, canRotate: canRotateSelection(shapes) };
70
+ return { handles: handles, canRotate: canRotateSelection(shapes) };
70
71
  }
71
72
  /** The handles of a selection whose frame stands on the board at this zoom: `handleAvailability` with the frame's size on the screen. */
72
- export function availableHandles(shapes, frame, viewport, plainCards = false) {
73
+ export function availableHandles(shapes, frame, viewport, plainCards) {
74
+ if (plainCards === void 0) { plainCards = false; }
73
75
  return handleAvailability(shapes, plainCards, { width: frame.width * viewport.zoom, height: frame.height * viewport.zoom });
74
76
  }
75
77
  /** Whether a handle sits on a corner of the frame. */
@@ -78,10 +80,10 @@ export function isCornerHandle(handle) {
78
80
  }
79
81
  /** A point of the screen in the frame's own space: pixels from its centre, with the frame's turn undone. */
80
82
  function toFrameSpace(frame, viewport, screenPoint) {
81
- const center = worldToScreen(viewport, { x: frame.x + frame.width / 2, y: frame.y + frame.height / 2 });
82
- const radians = -degreesToRadians(frame.rotation);
83
- const deltaX = screenPoint.x - center.x;
84
- const deltaY = screenPoint.y - center.y;
83
+ var center = worldToScreen(viewport, { x: frame.x + frame.width / 2, y: frame.y + frame.height / 2 });
84
+ var radians = -degreesToRadians(frame.rotation);
85
+ var deltaX = screenPoint.x - center.x;
86
+ var deltaY = screenPoint.y - center.y;
85
87
  return {
86
88
  local: {
87
89
  x: deltaX * Math.cos(radians) - deltaY * Math.sin(radians),
@@ -105,39 +107,41 @@ function innerReach(reach, shortSide) {
105
107
  * The turning dot comes first (it is drawn above the others), then the corners, then the edges, and last the zone just
106
108
  * outside a corner. Nothing is taken for a selection that offers no turning.
107
109
  */
108
- export function hitSelectionHandle(frame, viewport, screenPoint, metrics, available = FULL_AVAILABILITY) {
109
- const { local, halfWidth, halfHeight } = toFrameSpace(frame, viewport, screenPoint);
110
- const { handles, canRotate } = available;
111
- const shortSide = Math.min(halfWidth, halfHeight) * 2;
110
+ export function hitSelectionHandle(frame, viewport, screenPoint, metrics, available) {
111
+ if (available === void 0) { available = FULL_AVAILABILITY; }
112
+ var _a = toFrameSpace(frame, viewport, screenPoint), local = _a.local, halfWidth = _a.halfWidth, halfHeight = _a.halfHeight;
113
+ var handles = available.handles, canRotate = available.canRotate;
114
+ var shortSide = Math.min(halfWidth, halfHeight) * 2;
112
115
  // The dot under the bottom edge.
113
116
  if (canRotate && Math.abs(local.x) <= metrics.dotReach && Math.abs(local.y - (halfHeight + ROTATION_DOT_OFFSET)) <= metrics.dotReach) {
114
117
  return { type: 'rotate', source: 'dot' };
115
118
  }
116
119
  // The corners: a square that reaches `cornerReach` outside the frame and a little into it. The nearest one wins where squares meet.
117
- const cornerInner = innerReach(metrics.cornerReach, shortSide);
118
- let nearest = null;
119
- for (const handle of handles) {
120
+ var cornerInner = innerReach(metrics.cornerReach, shortSide);
121
+ var nearest = null;
122
+ for (var _i = 0, handles_1 = handles; _i < handles_1.length; _i++) {
123
+ var handle = handles_1[_i];
120
124
  if (!isCornerHandle(handle))
121
125
  continue;
122
- const direction = handleDirection(handle);
123
- const offsetX = local.x - direction.x * halfWidth;
124
- const offsetY = local.y - direction.y * halfHeight;
126
+ var direction = handleDirection(handle);
127
+ var offsetX = local.x - direction.x * halfWidth;
128
+ var offsetY = local.y - direction.y * halfHeight;
125
129
  // Positive is out of the frame, on the side the corner points to.
126
- const outwardX = offsetX * direction.x;
127
- const outwardY = offsetY * direction.y;
130
+ var outwardX = offsetX * direction.x;
131
+ var outwardY = offsetY * direction.y;
128
132
  if (outwardX > metrics.cornerReach || outwardX < -cornerInner || outwardY > metrics.cornerReach || outwardY < -cornerInner)
129
133
  continue;
130
- const distance = Math.hypot(offsetX, offsetY);
134
+ var distance = Math.hypot(offsetX, offsetY);
131
135
  if (!nearest || distance < nearest.distance)
132
- nearest = { handle, distance };
136
+ nearest = { handle: handle, distance: distance };
133
137
  }
134
138
  if (nearest)
135
139
  return { type: 'resize', handle: nearest.handle };
136
140
  // The edges: a strip along the whole edge, between the corners.
137
- const edgeInner = innerReach(metrics.edgeReach, shortSide);
138
- const onEdge = (outward) => outward <= metrics.edgeReach && outward >= -edgeInner;
139
- const withinWidth = Math.abs(local.x) <= halfWidth;
140
- const withinHeight = Math.abs(local.y) <= halfHeight;
141
+ var edgeInner = innerReach(metrics.edgeReach, shortSide);
142
+ var onEdge = function (outward) { return outward <= metrics.edgeReach && outward >= -edgeInner; };
143
+ var withinWidth = Math.abs(local.x) <= halfWidth;
144
+ var withinHeight = Math.abs(local.y) <= halfHeight;
141
145
  if (withinWidth && handles.includes('n') && onEdge(-(local.y + halfHeight)))
142
146
  return { type: 'resize', handle: 'n' };
143
147
  if (withinWidth && handles.includes('s') && onEdge(local.y - halfHeight))
@@ -148,8 +152,9 @@ export function hitSelectionHandle(frame, viewport, screenPoint, metrics, availa
148
152
  return { type: 'resize', handle: 'e' };
149
153
  // Just outside a corner the selection turns (optional: the dot below the frame is the main control).
150
154
  if (ENABLE_CORNER_ROTATE_ZONES && canRotate && (!withinWidth || !withinHeight)) {
151
- for (const handle of CORNER_HANDLES) {
152
- const direction = handleDirection(handle);
155
+ for (var _b = 0, CORNER_HANDLES_1 = CORNER_HANDLES; _b < CORNER_HANDLES_1.length; _b++) {
156
+ var handle = CORNER_HANDLES_1[_b];
157
+ var direction = handleDirection(handle);
153
158
  if (Math.hypot(local.x - direction.x * halfWidth, local.y - direction.y * halfHeight) <= metrics.rotateZone) {
154
159
  return { type: 'rotate', source: 'corner' };
155
160
  }
@@ -159,11 +164,11 @@ export function hitSelectionHandle(frame, viewport, screenPoint, metrics, availa
159
164
  }
160
165
  /** The CSS cursor of a resize handle on a frame turned by `rotation` degrees. */
161
166
  export function cursorForHandle(handle, rotation) {
162
- const direction = handleDirection(handle);
163
- const angle = ((Math.atan2(direction.y, direction.x) * 180) / Math.PI + rotation + 360 * 4) % 180;
167
+ var direction = handleDirection(handle);
168
+ var angle = ((Math.atan2(direction.y, direction.x) * 180) / Math.PI + rotation + 360 * 4) % 180;
164
169
  // 0: along x, 45: down-right, 90: along y, 135: down-left, measured on a screen where y grows downward.
165
- const step = Math.round(angle / 45) % 4;
170
+ var step = Math.round(angle / 45) % 4;
166
171
  return ['ew-resize', 'nwse-resize', 'ns-resize', 'nesw-resize'][step];
167
172
  }
168
173
  /** The name the board maps to its turning cursor: there is no CSS keyword for it. */
169
- export const ROTATE_CURSOR = 'rotate';
174
+ export var ROTATE_CURSOR = 'rotate';
@@ -2,4 +2,4 @@
2
2
  * What the input layer exchanges with the shell: plain records, so the whole gesture logic runs in Node tests with
3
3
  * simulated pointers and no browser.
4
4
  */
5
- export const NO_MODIFIERS = Object.freeze({ shiftKey: false, altKey: false, metaKey: false, ctrlKey: false });
5
+ export var NO_MODIFIERS = Object.freeze({ shiftKey: false, altKey: false, metaKey: false, ctrlKey: false });