@widgetic/canvas 0.5.41 → 0.5.43

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 (131) hide show
  1. package/README.md +1 -0
  2. package/dist/canvas/DomCanvas.svelte +49 -20
  3. package/dist/canvas/DomCanvas.svelte.d.ts +13 -7
  4. package/dist/canvas/autosaveScheduler.js +37 -89
  5. package/dist/canvas/boardFrame.js +1 -1
  6. package/dist/canvas/boardSurface.js +1 -1
  7. package/dist/canvas/canvasLogger.js +7 -19
  8. package/dist/canvas/chromeLayout.d.ts +14 -3
  9. package/dist/canvas/chromeLayout.js +30 -20
  10. package/dist/canvas/eventScope.js +10 -14
  11. package/dist/canvas/host/CanvasHost.d.ts +47 -5
  12. package/dist/canvas/host/CanvasHost.js +1481 -1566
  13. package/dist/canvas/host/CanvasHostApi.js +4 -19
  14. package/dist/canvas/host/browserServices.js +65 -116
  15. package/dist/canvas/host/conversion.js +82 -170
  16. package/dist/canvas/host/hostObject.js +7 -7
  17. package/dist/canvas/host/nearCards.d.ts +33 -0
  18. package/dist/canvas/host/nearCards.js +78 -0
  19. package/dist/canvas/host/pageEvents.d.ts +16 -4
  20. package/dist/canvas/host/pageEvents.js +17 -8
  21. package/dist/canvas/host/pictureSaves.d.ts +33 -0
  22. package/dist/canvas/host/pictureSaves.js +42 -0
  23. package/dist/canvas/host/screenRects.d.ts +5 -0
  24. package/dist/canvas/host/screenRects.js +28 -31
  25. package/dist/canvas/host/storedPictures.d.ts +88 -0
  26. package/dist/canvas/host/storedPictures.js +288 -0
  27. package/dist/canvas/host/strokeSnap.js +88 -143
  28. package/dist/canvas/index.d.ts +1 -1
  29. package/dist/canvas/index.js +1 -1
  30. package/dist/canvas/openMarks.js +2 -2
  31. package/dist/canvas/outsideClickDeselect.js +6 -7
  32. package/dist/canvas/panZoomPosition.js +2 -2
  33. package/dist/canvas/preferredTextFont.js +13 -25
  34. package/dist/canvas/shapes/ShapeLibrary.js +138 -148
  35. package/dist/canvas/shapes/shapeImageStore.d.ts +45 -2
  36. package/dist/canvas/shapes/shapeImageStore.js +10 -3
  37. package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
  38. package/dist/canvas/toolbarPosition.d.ts +2 -2
  39. package/dist/canvas/toolbarPosition.js +4 -4
  40. package/dist/canvas/ui/SelectionPanel.svelte +28 -5
  41. package/dist/canvas/ui/SelectionPanel.svelte.d.ts +7 -0
  42. package/dist/canvas/ui/SelectorIndicator.svelte +81 -0
  43. package/dist/canvas/ui/SelectorIndicator.svelte.d.ts +11 -0
  44. package/dist/canvas/ui/ToolButton.svelte +8 -2
  45. package/dist/canvas/ui/colorModel.js +21 -32
  46. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  47. package/dist/canvas/ui/floatingCard.d.ts +2 -2
  48. package/dist/canvas/ui/floatingCard.js +20 -20
  49. package/dist/canvas/ui/floatingLayer.d.ts +13 -2
  50. package/dist/canvas/ui/floatingLayer.js +18 -7
  51. package/dist/canvas/ui/keyHints.js +9 -11
  52. package/dist/canvas/ui/popoverSide.js +2 -3
  53. package/dist/canvas/ui/selectionTraits.js +34 -40
  54. package/dist/canvas/view/CanvasStage.svelte +101 -67
  55. package/dist/canvas/view/LeftToRightScope.svelte +21 -0
  56. package/dist/canvas/view/LeftToRightScope.svelte.d.ts +7 -0
  57. package/dist/canvas/view/ObjectView.svelte +15 -10
  58. package/dist/canvas/view/ObjectView.svelte.d.ts +1 -1
  59. package/dist/canvas/view/erasingMarks.js +7 -7
  60. package/dist/canvas/view/geometry.js +71 -90
  61. package/dist/canvas/view/liftedScene.d.ts +31 -0
  62. package/dist/canvas/view/liftedScene.js +146 -0
  63. package/dist/canvas/view/mountedScene.d.ts +71 -0
  64. package/dist/canvas/view/mountedScene.js +363 -0
  65. package/dist/components/preferenceStorage.js +2 -2
  66. package/dist/engine/EngineCore.d.ts +15 -1
  67. package/dist/engine/EngineCore.js +724 -797
  68. package/dist/engine/codec/canvasDocument.d.ts +5 -0
  69. package/dist/engine/codec/canvasDocument.js +212 -149
  70. package/dist/engine/codec/hostReadableKeys.js +1 -1
  71. package/dist/engine/core/arrange.js +26 -38
  72. package/dist/engine/core/arrow.js +76 -89
  73. package/dist/engine/core/arrowBinding.js +98 -116
  74. package/dist/engine/core/arrowBindingRecords.js +23 -38
  75. package/dist/engine/core/brush.js +67 -94
  76. package/dist/engine/core/defaults.js +90 -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.d.ts +6 -0
  80. package/dist/engine/core/history.js +49 -50
  81. package/dist/engine/core/hitTest.js +68 -81
  82. package/dist/engine/core/matrix.js +18 -20
  83. package/dist/engine/core/pathData.js +183 -210
  84. package/dist/engine/core/rotationReset.js +5 -6
  85. package/dist/engine/core/scene.d.ts +10 -0
  86. package/dist/engine/core/scene.js +153 -187
  87. package/dist/engine/core/scribble.js +59 -84
  88. package/dist/engine/core/shapePaths.js +12 -15
  89. package/dist/engine/core/shapeTools.js +72 -63
  90. package/dist/engine/core/snapping.js +65 -117
  91. package/dist/engine/core/style.js +31 -64
  92. package/dist/engine/core/transform.js +83 -94
  93. package/dist/engine/core/types.d.ts +8 -2
  94. package/dist/engine/core/types.js +4 -4
  95. package/dist/engine/core/viewport.js +23 -36
  96. package/dist/engine/input/PointerController.js +467 -474
  97. package/dist/engine/input/arrowHandles.js +12 -12
  98. package/dist/engine/input/gestures.js +265 -309
  99. package/dist/engine/input/hoverCursor.js +1 -1
  100. package/dist/engine/input/keyboard.js +27 -30
  101. package/dist/engine/input/selectionHandles.js +45 -50
  102. package/dist/engine/input/types.js +1 -1
  103. package/dist/engine/render/rasterize.js +86 -158
  104. package/dist/engine/state.d.ts +20 -0
  105. package/dist/engine/state.js +5 -15
  106. package/dist/engine/text/layoutText.js +43 -62
  107. package/dist/engine/text/textMetrics.js +8 -10
  108. package/dist/engine/widgets.js +101 -137
  109. package/dist/fonts/interFont.d.ts +10 -1
  110. package/dist/fonts/interFont.js +47 -75
  111. package/dist/fonts/workspaceFonts.js +32 -90
  112. package/dist/i18n/labels.js +4 -4
  113. package/dist/i18n/language.d.ts +3 -3
  114. package/dist/i18n/language.js +4 -4
  115. package/dist/i18n/messages.d.ts +8 -1
  116. package/dist/i18n/messages.js +10 -2
  117. package/dist/i18n/shortcuts.js +14 -14
  118. package/dist/index.d.ts +1 -1
  119. package/dist/index.js +1 -1
  120. package/dist/settings/workspaceToolSettings.js +32 -48
  121. package/dist/tools/components/catalog.js +64 -74
  122. package/dist/tools/components/grouping.js +6 -28
  123. package/dist/tools/definitions.js +5 -5
  124. package/dist/tools/executors.js +105 -141
  125. package/dist/tools/hostAdapter.js +11 -13
  126. package/dist/tools/sceneSummary.js +43 -57
  127. package/dist/tools/sketchIntent.js +13 -21
  128. package/dist/tools/types.js +1 -1
  129. package/package.json +1 -1
  130. package/dist/canvas/ui/SelectorBar.svelte +0 -84
  131. package/dist/canvas/ui/SelectorBar.svelte.d.ts +0 -12
@@ -16,15 +16,58 @@
16
16
  * With no store installed nothing changes — shapes keep serializing inline, so
17
17
  * a consumer that has not wired one up is never left with blank shapes.
18
18
  */
19
+ /**
20
+ * What the canvas tells the store about a read, when it knows (see `ShapeImageStore.load`).
21
+ *
22
+ * `visible`: the picture is on screen right now, and the person is looking at its place: answer as soon as you can.
23
+ * `background`: the picture is of an object that is off the screen, asked for ahead of time: nobody is waiting for it, so a
24
+ * store that has a queue, a network or a limit of its own may serve it after the ones that are `visible`. It must still
25
+ * answer: a board that is panned to it expects its picture to be there, or on its way.
26
+ */
27
+ export interface ShapeImageLoadOptions {
28
+ priority?: 'visible' | 'background';
29
+ }
19
30
  export interface ShapeImageStore {
20
31
  /**
21
32
  * Persist the bytes for a reference. Called during serialization, so it must
22
33
  * return immediately — write in the background and swallow failures.
23
34
  */
24
35
  save(ref: string, dataUrl: string): void;
25
- /** Resolve a reference to a data URL or any URL an `Image` can load. */
26
- load(ref: string): Promise<string | null>;
36
+ /**
37
+ * Resolve a reference to a data URL or any URL an `Image` can load.
38
+ *
39
+ * An object URL (`blob:`) is a good answer for a picture that is big: the board holds a short address instead of megabytes of
40
+ * text, and the browser reads the bytes where it keeps them. The canvas never writes one into the saved text (it writes the
41
+ * reference, which the store resolves again at the next load), so the store may hand out one it will not be able to hand out
42
+ * again after a reload. What a `blob:` address cannot do is leave the page: a card whose screenshot is one is not answered by
43
+ * `getWidgetShapeDataUrl` (it needs bytes), so a store gives `blob:` addresses for the pictures of the person's own and
44
+ * bytes for the screenshots of widget cards, unless the page that asks for the bytes can read an object URL.
45
+ *
46
+ * The canvas asks for the pictures on screen first, a few at a time, and for the others after them; the second argument says
47
+ * which kind this one is. A store written before the argument existed ignores it, which is fine.
48
+ */
49
+ load(ref: string, options?: ShapeImageLoadOptions): Promise<string | null>;
50
+ /**
51
+ * Optional. A picture the person has just put on the board (dropped, pasted or chosen), as bytes (a data URL).
52
+ *
53
+ * The store may keep the bytes under `ref` (as `save` does) and answer with a short address, an object URL (`blob:`), for the
54
+ * board to hold instead of the text: the board then never holds the megabytes, and the picture is the store's from the first
55
+ * moment, so the saved text carries the reference only. Answer `null` to leave the picture as it is (a small one, a page that
56
+ * cannot show an object URL, a limit reached, nowhere to keep the bytes yet): the canvas then keeps the bytes inline, and the
57
+ * next save hands them to `save` as it always did. When this answers with an address the bytes MUST have been kept: the canvas
58
+ * will not offer them again. It must return at once and never throw (a throw is treated as `null`).
59
+ *
60
+ * A store written before this existed has no `adopt`, and nothing changes for it.
61
+ */
62
+ adopt?(ref: string, dataUrl: string): string | null;
27
63
  }
64
+ /**
65
+ * Whether this canvas knows what to do with an object URL (`blob:`) that a store gives for a reference: it keeps the address for as
66
+ * long as the page lives, and writes the reference in the saved text, never the address (see `externalizeBytes`). A page that
67
+ * wants to give object URLs asks for this first, so that a page updated before the canvas is does not get a saved board with
68
+ * addresses in it that no other page can read.
69
+ */
70
+ export declare const SHAPE_IMAGE_STORE_OBJECT_URLS = true;
28
71
  export declare function setShapeImageStore(store: ShapeImageStore | null): void;
29
72
  export declare function getShapeImageStore(): ShapeImageStore | null;
30
73
  /** Inline bytes — the thing that must not reach the canvas JSON. */
@@ -16,7 +16,14 @@
16
16
  * With no store installed nothing changes — shapes keep serializing inline, so
17
17
  * a consumer that has not wired one up is never left with blank shapes.
18
18
  */
19
- var installedStore = null;
19
+ /**
20
+ * Whether this canvas knows what to do with an object URL (`blob:`) that a store gives for a reference: it keeps the address for as
21
+ * long as the page lives, and writes the reference in the saved text, never the address (see `externalizeBytes`). A page that
22
+ * wants to give object URLs asks for this first, so that a page updated before the canvas is does not get a saved board with
23
+ * addresses in it that no other page can read.
24
+ */
25
+ export const SHAPE_IMAGE_STORE_OBJECT_URLS = true;
26
+ let installedStore = null;
20
27
  export function setShapeImageStore(store) {
21
28
  installedStore = store;
22
29
  }
@@ -34,8 +41,8 @@ export function isInlineImageData(url) {
34
41
  */
35
42
  export function shapeImageRef(widgetId, objectId) {
36
43
  if (widgetId)
37
- return "widget:".concat(widgetId);
44
+ return `widget:${widgetId}`;
38
45
  if (objectId)
39
- return "shape:".concat(objectId);
46
+ return `shape:${objectId}`;
40
47
  return null;
41
48
  }