@widgetic/canvas 0.5.44 → 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 (160) hide show
  1. package/dist/canvas/DomCanvas.svelte +52 -3
  2. package/dist/canvas/DomCanvas.svelte.d.ts +59 -34
  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 +68 -1
  10. package/dist/canvas/host/CanvasHost.js +1901 -1407
  11. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  12. package/dist/canvas/host/CanvasHostApi.js +28 -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 +1 -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/ui/CanvasContextMenu.svelte +7 -0
  35. package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
  36. package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
  37. package/dist/canvas/ui/SelectionPanel.svelte +78 -17
  38. package/dist/canvas/ui/ShapesMenu.svelte +65 -31
  39. package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
  40. package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
  41. package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
  42. package/dist/canvas/ui/ToolButton.svelte +34 -55
  43. package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
  44. package/dist/canvas/ui/colorModel.js +32 -21
  45. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  46. package/dist/canvas/ui/floatingCard.d.ts +26 -4
  47. package/dist/canvas/ui/floatingCard.js +43 -21
  48. package/dist/canvas/ui/floatingLayer.js +6 -5
  49. package/dist/canvas/ui/icons.d.ts +1 -1
  50. package/dist/canvas/ui/icons.js +1 -1
  51. package/dist/canvas/ui/keyHints.js +11 -9
  52. package/dist/canvas/ui/popoverSide.js +3 -2
  53. package/dist/canvas/ui/selectionTraits.d.ts +12 -0
  54. package/dist/canvas/ui/selectionTraits.js +66 -35
  55. package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
  56. package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
  57. package/dist/canvas/view/CanvasStage.svelte +7 -2
  58. package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
  59. package/dist/canvas/view/SelectionOverlay.svelte +17 -10
  60. package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
  61. package/dist/canvas/view/erasingMarks.js +7 -7
  62. package/dist/canvas/view/geometry.d.ts +1 -1
  63. package/dist/canvas/view/geometry.js +90 -71
  64. package/dist/canvas/view/liftedScene.js +36 -24
  65. package/dist/canvas/view/mountedScene.js +79 -76
  66. package/dist/components/CanvasBoardPoster.svelte +206 -0
  67. package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
  68. package/dist/components/CanvasToolbarPlaceholder.svelte +115 -0
  69. package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +9 -0
  70. package/dist/components/index.d.ts +7 -0
  71. package/dist/components/index.js +8 -0
  72. package/dist/components/preferenceStorage.js +2 -2
  73. package/dist/engine/EngineCore.d.ts +37 -2
  74. package/dist/engine/EngineCore.js +946 -768
  75. package/dist/engine/codec/canvasDocument.d.ts +7 -0
  76. package/dist/engine/codec/canvasDocument.js +172 -186
  77. package/dist/engine/codec/hostReadableKeys.js +1 -1
  78. package/dist/engine/core/arrange.js +38 -26
  79. package/dist/engine/core/arrow.d.ts +18 -8
  80. package/dist/engine/core/arrow.js +109 -84
  81. package/dist/engine/core/arrowBinding.d.ts +1 -1
  82. package/dist/engine/core/arrowBinding.js +126 -101
  83. package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
  84. package/dist/engine/core/arrowBindingRecords.js +48 -29
  85. package/dist/engine/core/brush.d.ts +8 -0
  86. package/dist/engine/core/brush.js +98 -78
  87. package/dist/engine/core/cameraMove.d.ts +6 -0
  88. package/dist/engine/core/cameraMove.js +56 -38
  89. package/dist/engine/core/defaults.js +51 -90
  90. package/dist/engine/core/freehand.js +163 -147
  91. package/dist/engine/core/geometry.js +54 -47
  92. package/dist/engine/core/history.js +55 -38
  93. package/dist/engine/core/hitTest.js +81 -68
  94. package/dist/engine/core/matrix.js +20 -18
  95. package/dist/engine/core/pathData.js +210 -183
  96. package/dist/engine/core/rotationReset.js +6 -5
  97. package/dist/engine/core/scene.d.ts +22 -0
  98. package/dist/engine/core/scene.js +288 -139
  99. package/dist/engine/core/scribble.js +84 -59
  100. package/dist/engine/core/shapePaths.js +15 -12
  101. package/dist/engine/core/shapeTools.js +63 -72
  102. package/dist/engine/core/snapping.js +117 -65
  103. package/dist/engine/core/style.d.ts +10 -0
  104. package/dist/engine/core/style.js +82 -33
  105. package/dist/engine/core/transform.d.ts +6 -0
  106. package/dist/engine/core/transform.js +103 -83
  107. package/dist/engine/core/types.d.ts +7 -0
  108. package/dist/engine/core/types.js +4 -4
  109. package/dist/engine/core/viewport.js +36 -23
  110. package/dist/engine/input/PointerController.d.ts +15 -1
  111. package/dist/engine/input/PointerController.js +547 -476
  112. package/dist/engine/input/arrowHandles.js +12 -12
  113. package/dist/engine/input/gestures.d.ts +3 -1
  114. package/dist/engine/input/gestures.js +340 -266
  115. package/dist/engine/input/hoverCursor.js +1 -1
  116. package/dist/engine/input/keyboard.d.ts +22 -3
  117. package/dist/engine/input/keyboard.js +131 -32
  118. package/dist/engine/input/selectionHandles.js +50 -45
  119. package/dist/engine/input/types.d.ts +7 -0
  120. package/dist/engine/input/types.js +1 -1
  121. package/dist/engine/render/rasterize.js +158 -86
  122. package/dist/engine/state.d.ts +18 -0
  123. package/dist/engine/state.js +25 -4
  124. package/dist/engine/text/layoutText.js +62 -43
  125. package/dist/engine/text/textMetrics.js +10 -8
  126. package/dist/engine/widgets.js +137 -101
  127. package/dist/fonts/interFont.js +83 -30
  128. package/dist/fonts/workspaceFonts.d.ts +6 -0
  129. package/dist/fonts/workspaceFonts.js +108 -34
  130. package/dist/i18n/labels.js +4 -4
  131. package/dist/i18n/language.d.ts +3 -3
  132. package/dist/i18n/language.js +4 -4
  133. package/dist/i18n/messages.d.ts +6 -0
  134. package/dist/i18n/messages.js +7 -1
  135. package/dist/i18n/shortcuts.d.ts +6 -4
  136. package/dist/i18n/shortcuts.js +30 -26
  137. package/dist/index.d.ts +1 -0
  138. package/dist/poster/boardPlacement.d.ts +80 -0
  139. package/dist/poster/boardPlacement.js +140 -0
  140. package/dist/poster/boardPoster.d.ts +80 -0
  141. package/dist/poster/boardPoster.js +251 -0
  142. package/dist/poster/paintBoardPoster.d.ts +49 -0
  143. package/dist/poster/paintBoardPoster.js +112 -0
  144. package/dist/poster/posterPictures.d.ts +32 -0
  145. package/dist/poster/posterPictures.js +138 -0
  146. package/dist/settings/workspaceToolSettings.d.ts +6 -0
  147. package/dist/settings/workspaceToolSettings.js +58 -34
  148. package/dist/tools/components/catalog.js +74 -64
  149. package/dist/tools/components/grouping.js +28 -6
  150. package/dist/tools/definitions.js +31 -9
  151. package/dist/tools/executors.js +214 -106
  152. package/dist/tools/hostAdapter.d.ts +5 -1
  153. package/dist/tools/hostAdapter.js +15 -11
  154. package/dist/tools/sceneSummary.js +57 -43
  155. package/dist/tools/sketchIntent.js +21 -13
  156. package/dist/tools/styleArguments.d.ts +35 -0
  157. package/dist/tools/styleArguments.js +93 -0
  158. package/dist/tools/types.d.ts +26 -1
  159. package/dist/tools/types.js +2 -1
  160. package/package.json +1 -1
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Rotation is clockwise on screen (y grows downward), which is what CSS `rotate()` does.
8
8
  */
9
- export const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
9
+ export var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
10
10
  /** Converts degrees to radians. */
11
11
  export function degreesToRadians(degrees) {
12
12
  return (degrees * Math.PI) / 180;
@@ -17,24 +17,25 @@ export function radiansToDegrees(radians) {
17
17
  }
18
18
  /** Brings an angle into [0, 360). */
19
19
  export function normalizeDegrees(degrees) {
20
- const wrapped = degrees % 360;
20
+ var wrapped = degrees % 360;
21
21
  return wrapped < 0 ? wrapped + 360 : wrapped;
22
22
  }
23
23
  /** Brings an angle into (-180, 180]: the shortest signed turn. */
24
24
  export function normalizeSignedDegrees(degrees) {
25
- const wrapped = normalizeDegrees(degrees);
25
+ var wrapped = normalizeDegrees(degrees);
26
26
  return wrapped > 180 ? wrapped - 360 : wrapped;
27
27
  }
28
28
  export function translationMatrix(translateX, translateY) {
29
29
  return [1, 0, 0, 1, translateX, translateY];
30
30
  }
31
- export function scalingMatrix(scaleX, scaleY = scaleX) {
31
+ export function scalingMatrix(scaleX, scaleY) {
32
+ if (scaleY === void 0) { scaleY = scaleX; }
32
33
  return [scaleX, 0, 0, scaleY, 0, 0];
33
34
  }
34
35
  export function rotationMatrix(degrees) {
35
- const radians = degreesToRadians(degrees);
36
- const cosine = Math.cos(radians);
37
- const sine = Math.sin(radians);
36
+ var radians = degreesToRadians(degrees);
37
+ var cosine = Math.cos(radians);
38
+ var sine = Math.sin(radians);
38
39
  return [cosine, sine, -sine, cosine, 0, 0];
39
40
  }
40
41
  /** Rotation about a point other than the origin. */
@@ -46,8 +47,8 @@ export function rotationAboutMatrix(degrees, centerX, centerY) {
46
47
  * (the same order as `DOMMatrix.multiply`).
47
48
  */
48
49
  export function multiplyMatrices(first, second) {
49
- const [a1, b1, c1, d1, e1, f1] = first;
50
- const [a2, b2, c2, d2, e2, f2] = second;
50
+ var a1 = first[0], b1 = first[1], c1 = first[2], d1 = first[3], e1 = first[4], f1 = first[5];
51
+ var a2 = second[0], b2 = second[1], c2 = second[2], d2 = second[3], e2 = second[4], f2 = second[5];
51
52
  return [
52
53
  a1 * a2 + c1 * b2,
53
54
  b1 * a2 + d1 * b2,
@@ -59,11 +60,11 @@ export function multiplyMatrices(first, second) {
59
60
  }
60
61
  /** The matrix that undoes `matrix`, or null when it flattens the plane (zero determinant). */
61
62
  export function invertMatrix(matrix) {
62
- const [a, b, c, d, e, f] = matrix;
63
- const determinant = a * d - b * c;
63
+ var a = matrix[0], b = matrix[1], c = matrix[2], d = matrix[3], e = matrix[4], f = matrix[5];
64
+ var determinant = a * d - b * c;
64
65
  if (Math.abs(determinant) < 1e-12)
65
66
  return null;
66
- const inverseDeterminant = 1 / determinant;
67
+ var inverseDeterminant = 1 / determinant;
67
68
  return [
68
69
  d * inverseDeterminant,
69
70
  -b * inverseDeterminant,
@@ -74,12 +75,12 @@ export function invertMatrix(matrix) {
74
75
  ];
75
76
  }
76
77
  export function applyMatrixToPoint(matrix, point) {
77
- const [a, b, c, d, e, f] = matrix;
78
+ var a = matrix[0], b = matrix[1], c = matrix[2], d = matrix[3], e = matrix[4], f = matrix[5];
78
79
  return { x: a * point.x + c * point.y + e, y: b * point.x + d * point.y + f };
79
80
  }
80
81
  /** The scale the matrix applies along each axis (ignores skew, which the board never produces). */
81
82
  export function matrixScale(matrix) {
82
- const [a, b, c, d] = matrix;
83
+ var a = matrix[0], b = matrix[1], c = matrix[2], d = matrix[3];
83
84
  return { scaleX: Math.hypot(a, b), scaleY: Math.hypot(c, d) };
84
85
  }
85
86
  /**
@@ -87,13 +88,14 @@ export function matrixScale(matrix) {
87
88
  * width by height) onto the world.
88
89
  */
89
90
  export function boxToWorldMatrix(box) {
90
- const halfWidth = box.width / 2;
91
- const halfHeight = box.height / 2;
92
- return multiplyMatrices(translationMatrix(box.x + halfWidth, box.y + halfHeight), multiplyMatrices(rotationMatrix(box.rotation ?? 0), translationMatrix(-halfWidth, -halfHeight)));
91
+ var _a;
92
+ var halfWidth = box.width / 2;
93
+ var halfHeight = box.height / 2;
94
+ return multiplyMatrices(translationMatrix(box.x + halfWidth, box.y + halfHeight), multiplyMatrices(rotationMatrix((_a = box.rotation) !== null && _a !== void 0 ? _a : 0), translationMatrix(-halfWidth, -halfHeight)));
93
95
  }
94
96
  /** The CSS value of a matrix, with the digits trimmed so a style string does not grow for nothing. */
95
97
  export function matrixToCss(matrix) {
96
- return `matrix(${matrix.map((value) => Number(value.toFixed(5))).join(', ')})`;
98
+ return "matrix(".concat(matrix.map(function (value) { return Number(value.toFixed(5)); }).join(', '), ")");
97
99
  }
98
100
  /** The six numbers of a matrix as a fresh array (for JSON). */
99
101
  export function matrixToArray(matrix) {