@widgetic/canvas 0.5.45 → 0.5.47

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 (137) hide show
  1. package/README.md +3 -2
  2. package/dist/canvas/DomCanvas.svelte +1 -2
  3. package/dist/canvas/autosaveScheduler.js +37 -89
  4. package/dist/canvas/boardFrame.js +1 -1
  5. package/dist/canvas/boardSurface.js +1 -1
  6. package/dist/canvas/canvasLogger.js +7 -19
  7. package/dist/canvas/chromeLayout.js +19 -21
  8. package/dist/canvas/eventScope.js +10 -14
  9. package/dist/canvas/host/CanvasHost.d.ts +6 -5
  10. package/dist/canvas/host/CanvasHost.js +1664 -1861
  11. package/dist/canvas/host/CanvasHostApi.js +4 -19
  12. package/dist/canvas/host/boardFiles.js +35 -51
  13. package/dist/canvas/host/browserServices.js +108 -196
  14. package/dist/canvas/host/conversion.js +82 -170
  15. package/dist/canvas/host/hostObject.js +7 -7
  16. package/dist/canvas/host/nearCards.js +18 -21
  17. package/dist/canvas/host/pageEvents.js +5 -5
  18. package/dist/canvas/host/pauseCollector.d.ts +18 -0
  19. package/dist/canvas/host/pauseCollector.js +45 -0
  20. package/dist/canvas/host/pictureSaves.js +9 -11
  21. package/dist/canvas/host/screenRects.js +28 -31
  22. package/dist/canvas/host/storedPictures.js +149 -243
  23. package/dist/canvas/host/strokeSnap.js +88 -143
  24. package/dist/canvas/index.d.ts +1 -1
  25. package/dist/canvas/openMarks.js +2 -2
  26. package/dist/canvas/outsideClickDeselect.js +6 -7
  27. package/dist/canvas/panZoomPosition.js +2 -2
  28. package/dist/canvas/preferredTextFont.js +13 -25
  29. package/dist/canvas/shapes/ShapeLibrary.js +138 -148
  30. package/dist/canvas/shapes/shapeImageStore.js +4 -4
  31. package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
  32. package/dist/canvas/toolbarPosition.js +2 -2
  33. package/dist/canvas/types.d.ts +7 -1
  34. package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
  35. package/dist/canvas/ui/CanvasHint.svelte +10 -9
  36. package/dist/canvas/ui/SelectionPanel.svelte +14 -12
  37. package/dist/canvas/ui/SelectionPanel.svelte.d.ts +0 -2
  38. package/dist/canvas/ui/ShapesMenu.svelte +6 -4
  39. package/dist/canvas/ui/ToolButton.svelte +7 -6
  40. package/dist/canvas/ui/colorModel.js +21 -32
  41. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  42. package/dist/canvas/ui/floatingCard.d.ts +28 -8
  43. package/dist/canvas/ui/floatingCard.js +48 -28
  44. package/dist/canvas/ui/floatingLayer.js +5 -6
  45. package/dist/canvas/ui/keyHints.js +9 -11
  46. package/dist/canvas/ui/popoverSide.js +2 -3
  47. package/dist/canvas/ui/selectionTraits.d.ts +8 -4
  48. package/dist/canvas/ui/selectionTraits.js +44 -58
  49. package/dist/canvas/view/CanvasStage.svelte +1 -1
  50. package/dist/canvas/view/SelectionOverlay.svelte +2 -2
  51. package/dist/canvas/view/erasingMarks.js +7 -7
  52. package/dist/canvas/view/geometry.d.ts +1 -1
  53. package/dist/canvas/view/geometry.js +72 -91
  54. package/dist/canvas/view/liftedScene.js +24 -36
  55. package/dist/canvas/view/mountedScene.js +76 -79
  56. package/dist/components/CanvasBoardPlaceholder.svelte +68 -10
  57. package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +10 -2
  58. package/dist/components/CanvasToolbarPlaceholder.svelte +25 -11
  59. package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +6 -0
  60. package/dist/components/boardLoaderDelay.d.ts +39 -0
  61. package/dist/components/boardLoaderDelay.js +71 -0
  62. package/dist/components/input-controls/ColorIC.svelte +1 -1
  63. package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
  64. package/dist/components/preferenceStorage.js +2 -2
  65. package/dist/engine/EngineCore.d.ts +42 -10
  66. package/dist/engine/EngineCore.js +843 -916
  67. package/dist/engine/codec/canvasDocument.js +192 -155
  68. package/dist/engine/codec/hostReadableKeys.js +1 -1
  69. package/dist/engine/core/arrange.js +26 -38
  70. package/dist/engine/core/arrow.js +79 -92
  71. package/dist/engine/core/arrowBinding.js +98 -116
  72. package/dist/engine/core/arrowBindingRecords.js +23 -38
  73. package/dist/engine/core/brush.d.ts +24 -0
  74. package/dist/engine/core/brush.js +223 -103
  75. package/dist/engine/core/cameraMove.js +39 -51
  76. package/dist/engine/core/defaults.js +92 -51
  77. package/dist/engine/core/freehand.js +147 -163
  78. package/dist/engine/core/geometry.js +47 -54
  79. package/dist/engine/core/history.js +38 -55
  80. package/dist/engine/core/hitTest.js +68 -81
  81. package/dist/engine/core/matrix.js +18 -20
  82. package/dist/engine/core/pathData.js +183 -210
  83. package/dist/engine/core/rotationReset.js +5 -6
  84. package/dist/engine/core/scene.js +160 -224
  85. package/dist/engine/core/scribble.js +59 -84
  86. package/dist/engine/core/shapePaths.js +12 -15
  87. package/dist/engine/core/shapeTools.d.ts +23 -18
  88. package/dist/engine/core/shapeTools.js +104 -67
  89. package/dist/engine/core/snapping.js +65 -117
  90. package/dist/engine/core/style.d.ts +18 -2
  91. package/dist/engine/core/style.js +79 -80
  92. package/dist/engine/core/styleMemory.d.ts +88 -0
  93. package/dist/engine/core/styleMemory.js +189 -0
  94. package/dist/engine/core/transform.js +84 -95
  95. package/dist/engine/core/types.js +4 -4
  96. package/dist/engine/core/viewport.js +23 -36
  97. package/dist/engine/input/PointerController.js +513 -526
  98. package/dist/engine/input/arrowHandles.js +12 -12
  99. package/dist/engine/input/gestures.d.ts +8 -3
  100. package/dist/engine/input/gestures.js +378 -346
  101. package/dist/engine/input/hoverCursor.js +1 -1
  102. package/dist/engine/input/keyboard.js +42 -41
  103. package/dist/engine/input/selectionHandles.js +45 -50
  104. package/dist/engine/input/types.js +1 -1
  105. package/dist/engine/render/rasterize.js +86 -158
  106. package/dist/engine/state.js +6 -17
  107. package/dist/engine/text/layoutText.js +43 -62
  108. package/dist/engine/text/textMetrics.js +8 -10
  109. package/dist/engine/widgets.js +101 -137
  110. package/dist/fonts/interFont.js +30 -83
  111. package/dist/fonts/workspaceFonts.js +33 -92
  112. package/dist/i18n/labels.js +4 -4
  113. package/dist/i18n/language.js +4 -4
  114. package/dist/i18n/messages.js +1 -1
  115. package/dist/i18n/shortcuts.js +14 -14
  116. package/dist/index.d.ts +1 -1
  117. package/dist/poster/boardPlacement.d.ts +4 -1
  118. package/dist/poster/boardPlacement.js +34 -33
  119. package/dist/poster/boardPoster.js +58 -83
  120. package/dist/poster/paintBoardPoster.js +16 -39
  121. package/dist/poster/posterPictures.js +27 -43
  122. package/dist/settings/rememberedStyles.d.ts +22 -0
  123. package/dist/settings/rememberedStyles.js +47 -0
  124. package/dist/settings/rememberedTool.d.ts +50 -0
  125. package/dist/settings/rememberedTool.js +68 -0
  126. package/dist/settings/workspaceToolSettings.d.ts +25 -0
  127. package/dist/settings/workspaceToolSettings.js +38 -48
  128. package/dist/tools/components/catalog.js +64 -74
  129. package/dist/tools/components/grouping.js +6 -28
  130. package/dist/tools/definitions.js +5 -5
  131. package/dist/tools/executors.js +137 -169
  132. package/dist/tools/hostAdapter.js +10 -13
  133. package/dist/tools/sceneSummary.js +43 -57
  134. package/dist/tools/sketchIntent.js +13 -21
  135. package/dist/tools/styleArguments.js +19 -21
  136. package/dist/tools/types.js +1 -1
  137. package/package.json +5 -5
@@ -9,27 +9,27 @@
9
9
  import { arrowPointsInWorld, isArrow } from '../core/arrow.js';
10
10
  import { distanceBetween } from '../core/geometry.js';
11
11
  import { worldToScreen } from '../core/viewport.js';
12
- var MOUSE_ARROW_METRICS = { endReach: 12, bendReach: 10 };
13
- var TOUCH_ARROW_METRICS = { endReach: 24, bendReach: 22 };
12
+ const MOUSE_ARROW_METRICS = { endReach: 12, bendReach: 10 };
13
+ const TOUCH_ARROW_METRICS = { endReach: 24, bendReach: 22 };
14
14
  export function arrowHandleMetricsFor(pointerType) {
15
15
  return pointerType === 'touch' ? TOUCH_ARROW_METRICS : MOUSE_ARROW_METRICS;
16
16
  }
17
17
  /** An end of the arrow while nobody is near it: a round handle of this diameter (screen pixels). */
18
- export var ARROW_END_HANDLE_SIZE = 10;
18
+ export const ARROW_END_HANDLE_SIZE = 10;
19
19
  /** The bend handle at rest: a little smaller, so the ends read as the ends. */
20
- export var ARROW_BEND_HANDLE_SIZE = 8;
20
+ export const ARROW_BEND_HANDLE_SIZE = 8;
21
21
  /** Any arrow handle under the pointer, and while it is dragged. */
22
- export var ARROW_HANDLE_ACTIVE_SIZE = 14;
22
+ export const ARROW_HANDLE_ACTIVE_SIZE = 14;
23
23
  /** The arrow that is selected, when the selection is that arrow and nothing else: the one selection that has handles of its own. */
24
24
  export function singleArrowOf(shapes, selectedIds) {
25
25
  if (shapes.length !== 1 || selectedIds.length !== 1)
26
26
  return null;
27
- var only = shapes[0];
27
+ const only = shapes[0];
28
28
  return isArrow(only) && only.id === selectedIds[0] ? only : null;
29
29
  }
30
30
  /** The places of the three handles on the screen, in pixels of the board. */
31
31
  export function arrowHandlePositions(arrow, viewport) {
32
- var points = arrowPointsInWorld(arrow);
32
+ const points = arrowPointsInWorld(arrow);
33
33
  return {
34
34
  start: worldToScreen(viewport, points.start),
35
35
  end: worldToScreen(viewport, points.end),
@@ -41,17 +41,17 @@ export function arrowHandlePositions(arrow, viewport) {
41
41
  * reach on both (`TOUCH_ARROW_METRICS`), so that on no kind of pointer does its area sit on an end and cover it. A shorter arrow
42
42
  * has its two ends only, and the same arrow shows the same handles whoever holds the pointer.
43
43
  */
44
- export var BEND_HANDLE_CLEARANCE = 46;
44
+ export const BEND_HANDLE_CLEARANCE = 46;
45
45
  /** Whether the bend handle is offered for an arrow whose handles are at these places. */
46
46
  export function bendHandleAvailable(positions) {
47
47
  return distanceBetween(positions.start, positions.bend) > BEND_HANDLE_CLEARANCE && distanceBetween(positions.end, positions.bend) > BEND_HANDLE_CLEARANCE;
48
48
  }
49
49
  /** The handle of an arrow under a pixel of the board, or null. An end wins over the middle where their areas meet. */
50
50
  export function hitArrowHandle(arrow, viewport, screenPoint, metrics) {
51
- var positions = arrowHandlePositions(arrow, viewport);
52
- var startDistance = distanceBetween(positions.start, screenPoint);
53
- var endDistance = distanceBetween(positions.end, screenPoint);
54
- var nearestEnd = startDistance <= endDistance ? 'start' : 'end';
51
+ const positions = arrowHandlePositions(arrow, viewport);
52
+ const startDistance = distanceBetween(positions.start, screenPoint);
53
+ const endDistance = distanceBetween(positions.end, screenPoint);
54
+ const nearestEnd = startDistance <= endDistance ? 'start' : 'end';
55
55
  if (Math.min(startDistance, endDistance) <= metrics.endReach)
56
56
  return nearestEnd;
57
57
  if (bendHandleAvailable(positions) && distanceBetween(positions.bend, screenPoint) <= metrics.bendReach)
@@ -63,9 +63,14 @@ export declare function createPanGesture(context: GestureContext, start: Pointer
63
63
  }): Gesture;
64
64
  /**
65
65
  * Draws with the brush. The line is as thick as the hand presses: a pen's own pressure, or, for a mouse or a finger, the time the
66
- * hand spends (a slow stroke swells, a quick one thins). Shift draws a straight line from where the pointer went down to the pointer,
67
- * with the colour and the thickness of the lines drawn without Shift: the brush is the same, held at one pressure. The colour, the
68
- * width and the opacity of the line are the pen's (`EngineState.penStyle`), which the settings panel sets before a line is drawn.
66
+ * hand spends (a slow stroke swells, a quick one thins). The colour, the width and the opacity of the line are the pen's
67
+ * (`EngineState.penStyle`), which the settings panel sets before a line is drawn.
68
+ *
69
+ * Shift holds the line straight for as long as it is down. The straight stretch begins where the pointer is when the key goes down
70
+ * (what the hand has drawn up to there stays as it is) and runs to the pointer, with the colour and the thickness of the line
71
+ * drawn without Shift: the brush is the same, held at one pressure. When Shift is let go the stretch is kept up to where the
72
+ * pointer was, and the hand goes on drawing from there as before; Shift down again starts another stretch. With Shift down as the
73
+ * press begins the whole line is straight from the point of the press.
69
74
  */
70
75
  export declare function createDrawGesture(context: GestureContext, start: PointerInput): Gesture;
71
76
  /**