@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
@@ -0,0 +1,138 @@
1
+ /**
2
+ * The pictures a poster draws: the images of the board that have an address of their own, the screenshots of widget cards that were
3
+ * saved with one, and the pictures the board keeps in its host's store under a reference (the host is asked for those).
4
+ *
5
+ * They are asked for once and kept for the life of the page, so the second poster of a page (the one inside the canvas takes over
6
+ * from the one the host drew before it) paints them at once instead of waiting for them again. A picture that cannot be loaded is
7
+ * left out of the poster, not drawn broken. Everything checks for the browser first: nothing here may throw on the server.
8
+ *
9
+ * The painter asks for a picture by a key. For a picture with an address the key is the address; for one kept by reference it is
10
+ * `posterReferenceKey(reference)`, so the bytes the host hands over (a data URL, possibly megabytes) are never a map key.
11
+ */
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ /** What the page has loaded, by key. */
22
+ var loadedPictures = new Map();
23
+ /** What has been asked for already, loaded or not, so one picture is never fetched twice. */
24
+ var askedFor = new Set();
25
+ /** Who wants to know when a picture arrives: every poster that is on the screen. */
26
+ var listeners = new Set();
27
+ /** The most pictures kept; the oldest go first. A poster holds few, so this is a ceiling, not a working size. */
28
+ var MAX_KEPT_PICTURES = 64;
29
+ /** The key the painter asks for a picture by when the board keeps it in the host's store under `reference`. */
30
+ export function posterReferenceKey(reference) {
31
+ return "ref:".concat(reference);
32
+ }
33
+ /** The picture for a key, once it has loaded. Null while it has not, or when it never will. */
34
+ export function posterPictureFor(key) {
35
+ var _a;
36
+ return key ? ((_a = loadedPictures.get(key)) !== null && _a !== void 0 ? _a : null) : null;
37
+ }
38
+ /** Calls `listener` whenever a picture has arrived. Returns what stops it. */
39
+ export function subscribeToPosterPictures(listener) {
40
+ listeners.add(listener);
41
+ return function () {
42
+ listeners.delete(listener);
43
+ };
44
+ }
45
+ /** The browser's way to make an image, or null where there is none (the server). `createImage` is for tests. */
46
+ function imageMaker(createImage) {
47
+ if (createImage)
48
+ return createImage;
49
+ return typeof Image === 'undefined' ? null : function () { return new Image(); };
50
+ }
51
+ /** Tells every poster on the screen that a picture has arrived, once each; one that fails does not stop the others from hearing. */
52
+ function notifyListeners() {
53
+ for (var _i = 0, _a = __spreadArray([], listeners, true); _i < _a.length; _i++) {
54
+ var listener = _a[_i];
55
+ try {
56
+ listener();
57
+ }
58
+ catch (_b) {
59
+ // A subscriber that fails does not stop the others from hearing.
60
+ }
61
+ }
62
+ }
63
+ /** Starts loading `source` (an address or a data URL) under `key`. A picture that cannot be loaded stays asked for: it costs one try. */
64
+ function startLoading(key, source, make) {
65
+ try {
66
+ var image_1 = make();
67
+ image_1.decoding = 'async';
68
+ image_1.onload = function () {
69
+ loadedPictures.set(key, image_1);
70
+ if (loadedPictures.size > MAX_KEPT_PICTURES) {
71
+ var oldest = loadedPictures.keys().next().value;
72
+ if (oldest !== undefined)
73
+ loadedPictures.delete(oldest);
74
+ }
75
+ notifyListeners();
76
+ };
77
+ // Left out: the board draws it when it has it.
78
+ image_1.onerror = function () { };
79
+ image_1.src = source;
80
+ }
81
+ catch (_a) {
82
+ // The browser refused the picture; the poster goes on without it.
83
+ }
84
+ }
85
+ /**
86
+ * Starts loading the pictures that are not loaded yet and not asked for, each under its own address as the key. A picture that
87
+ * arrives tells every subscriber, once. `createImage` is for tests; the browser's `Image` is used otherwise.
88
+ */
89
+ export function requestPosterPictures(sources, createImage) {
90
+ var make = imageMaker(createImage);
91
+ if (!make)
92
+ return;
93
+ for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
94
+ var source = sources_1[_i];
95
+ if (loadedPictures.has(source) || askedFor.has(source))
96
+ continue;
97
+ askedFor.add(source);
98
+ startLoading(source, source, make);
99
+ }
100
+ }
101
+ /**
102
+ * Asks the host for the pictures the board keeps by reference, and loads what it hands over, under `posterReferenceKey(reference)`.
103
+ * Each reference is asked once at a time; one the host does not have (yet) is asked again at the next draw. Never throws: a host
104
+ * that fails, or answers with nothing, only means the picture is not in the poster.
105
+ */
106
+ export function requestReferencedPictures(references, resolve, createImage) {
107
+ var make = imageMaker(createImage);
108
+ if (!make)
109
+ return;
110
+ var _loop_1 = function (reference) {
111
+ var key = posterReferenceKey(reference);
112
+ if (loadedPictures.has(key) || askedFor.has(key))
113
+ return "continue";
114
+ askedFor.add(key);
115
+ void Promise.resolve()
116
+ .then(function () { return resolve(reference); })
117
+ .then(function (source) {
118
+ if (typeof source === 'string' && source !== '') {
119
+ startLoading(key, source, make);
120
+ return;
121
+ }
122
+ // The host does not have it (yet): it is asked again the next time the poster is drawn.
123
+ askedFor.delete(key);
124
+ })
125
+ .catch(function () {
126
+ askedFor.delete(key);
127
+ });
128
+ };
129
+ for (var _i = 0, references_1 = references; _i < references_1.length; _i++) {
130
+ var reference = references_1[_i];
131
+ _loop_1(reference);
132
+ }
133
+ }
134
+ /** Forgets every picture (for tests, and for a page that signs someone out). */
135
+ export function clearPosterPictures() {
136
+ loadedPictures.clear();
137
+ askedFor.clear();
138
+ }
@@ -32,6 +32,12 @@ export interface WorkspaceToolSettingsV1 {
32
32
  headStart?: boolean;
33
33
  headEnd?: boolean;
34
34
  };
35
+ /** How the Draw tool draws, set in the panel before a line is drawn (see `PenStyle`). Left out until the person sets the pen. */
36
+ pen?: {
37
+ color?: string;
38
+ width?: number;
39
+ opacity?: number;
40
+ };
35
41
  }
36
42
  export interface WorkspaceToolSettingsScope {
37
43
  workspaceId: string;
@@ -1,29 +1,41 @@
1
1
  /**
2
2
  * Last-used tool settings per workspace (item B16). Debounced writes, flush on pagehide.
3
3
  */
4
+ var __assign = (this && this.__assign) || function () {
5
+ __assign = Object.assign || function(t) {
6
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
7
+ s = arguments[i];
8
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
9
+ t[p] = s[p];
10
+ }
11
+ return t;
12
+ };
13
+ return __assign.apply(this, arguments);
14
+ };
4
15
  import { getCanvasPreferenceStorage } from '../components/preferenceStorage.js';
5
- export const WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION = 1;
6
- export const WORKSPACE_TOOL_SETTINGS_KEY_PREFIX = 'widgetic-canvas:workspace-tool-settings:v1:';
16
+ export var WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION = 1;
17
+ export var WORKSPACE_TOOL_SETTINGS_KEY_PREFIX = 'widgetic-canvas:workspace-tool-settings:v1:';
7
18
  function storageKey(scope) {
8
- const userPart = scope.userId ? `:${scope.userId}` : '';
9
- return `${WORKSPACE_TOOL_SETTINGS_KEY_PREFIX}${scope.workspaceId}${userPart}`;
19
+ var userPart = scope.userId ? ":".concat(scope.userId) : '';
20
+ return "".concat(WORKSPACE_TOOL_SETTINGS_KEY_PREFIX).concat(scope.workspaceId).concat(userPart);
10
21
  }
11
22
  function adapterFromPreferenceStorage() {
12
- const storage = getCanvasPreferenceStorage();
23
+ var storage = getCanvasPreferenceStorage();
13
24
  return {
14
- load(key) {
25
+ load: function (key) {
26
+ var _a;
15
27
  try {
16
- return storage?.getItem(key) ?? null;
28
+ return (_a = storage === null || storage === void 0 ? void 0 : storage.getItem(key)) !== null && _a !== void 0 ? _a : null;
17
29
  }
18
- catch {
30
+ catch (_b) {
19
31
  return null;
20
32
  }
21
33
  },
22
- save(key, value) {
34
+ save: function (key, value) {
23
35
  try {
24
- storage?.setItem(key, value);
36
+ storage === null || storage === void 0 ? void 0 : storage.setItem(key, value);
25
37
  }
26
- catch {
38
+ catch (_a) {
27
39
  // quota / private mode
28
40
  }
29
41
  }
@@ -33,37 +45,53 @@ export function parseWorkspaceToolSettings(raw) {
33
45
  if (!raw)
34
46
  return null;
35
47
  try {
36
- const parsed = JSON.parse(raw);
37
- if (parsed?.v !== WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION)
48
+ var parsed = JSON.parse(raw);
49
+ if ((parsed === null || parsed === void 0 ? void 0 : parsed.v) !== WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION)
38
50
  return null;
39
51
  return parsed;
40
52
  }
41
- catch {
53
+ catch (_a) {
42
54
  return null;
43
55
  }
44
56
  }
45
- export function loadWorkspaceToolSettings(scope, adapter = adapterFromPreferenceStorage()) {
57
+ export function loadWorkspaceToolSettings(scope, adapter) {
58
+ if (adapter === void 0) { adapter = adapterFromPreferenceStorage(); }
46
59
  return parseWorkspaceToolSettings(adapter.load(storageKey(scope)));
47
60
  }
48
- let pending = null;
49
- let debounceTimer;
50
- export function saveWorkspaceToolSettingsDebounced(scope, patch, adapter = adapterFromPreferenceStorage()) {
51
- const current = loadWorkspaceToolSettings(scope, adapter) ?? { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
52
- const merged = {
61
+ /** The settings with a patch laid over them: each part (text, paint, arrow, pen) keeps what the patch does not say. */
62
+ function mergeSettings(current, patch) {
63
+ var merged = {
53
64
  v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION,
54
- text: { ...current.text, ...patch.text },
55
- paint: { ...current.paint, ...patch.paint },
56
- arrow: { ...current.arrow, ...patch.arrow }
65
+ text: __assign(__assign({}, current.text), patch.text),
66
+ paint: __assign(__assign({}, current.paint), patch.paint),
67
+ arrow: __assign(__assign({}, current.arrow), patch.arrow)
57
68
  };
58
- pending = { scope, value: merged, adapter };
69
+ // The pen is written only when there is one: settings of a person who never touched it hold none.
70
+ if (current.pen || patch.pen)
71
+ merged.pen = __assign(__assign({}, current.pen), patch.pen);
72
+ return merged;
73
+ }
74
+ var pending = null;
75
+ var debounceTimer;
76
+ export function saveWorkspaceToolSettingsDebounced(scope, patch, adapter) {
77
+ var _a, _b;
78
+ if (adapter === void 0) { adapter = adapterFromPreferenceStorage(); }
79
+ // A change that waits for its write (see the delay below) is part of the settings already: the next change is laid over it, and not
80
+ // over what the storage still holds, so two changes made within the delay are both kept. A change that waits for another workspace
81
+ // is written first, and is not lost to this one.
82
+ if (pending && storageKey(pending.scope) !== storageKey(scope))
83
+ flushWorkspaceToolSettingsPending();
84
+ var current = (_b = (_a = pending === null || pending === void 0 ? void 0 : pending.value) !== null && _a !== void 0 ? _a : loadWorkspaceToolSettings(scope, adapter)) !== null && _b !== void 0 ? _b : { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
85
+ var merged = mergeSettings(current, patch);
86
+ pending = { scope: scope, value: merged, adapter: adapter };
59
87
  if (debounceTimer !== undefined)
60
88
  clearTimeout(debounceTimer);
61
- debounceTimer = setTimeout(() => flushWorkspaceToolSettingsPending(), 400);
89
+ debounceTimer = setTimeout(function () { return flushWorkspaceToolSettingsPending(); }, 400);
62
90
  }
63
91
  export function flushWorkspaceToolSettingsPending() {
64
92
  if (!pending)
65
93
  return;
66
- const { scope, value, adapter } = pending;
94
+ var scope = pending.scope, value = pending.value, adapter = pending.adapter;
67
95
  pending = null;
68
96
  if (debounceTimer !== undefined) {
69
97
  clearTimeout(debounceTimer);
@@ -72,19 +100,15 @@ export function flushWorkspaceToolSettingsPending() {
72
100
  try {
73
101
  adapter.save(storageKey(scope), JSON.stringify(value));
74
102
  }
75
- catch {
103
+ catch (_a) {
76
104
  // ignored
77
105
  }
78
106
  }
79
107
  /** Merges a patch into settings without debounce (tests). */
80
108
  export function saveWorkspaceToolSettingsNow(scope, patch, adapter) {
81
- const current = loadWorkspaceToolSettings(scope, adapter) ?? { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
82
- const merged = {
83
- v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION,
84
- text: { ...current.text, ...patch.text },
85
- paint: { ...current.paint, ...patch.paint },
86
- arrow: { ...current.arrow, ...patch.arrow }
87
- };
109
+ var _a;
110
+ var current = (_a = loadWorkspaceToolSettings(scope, adapter)) !== null && _a !== void 0 ? _a : { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
111
+ var merged = mergeSettings(current, patch);
88
112
  adapter.save(storageKey(scope), JSON.stringify(merged));
89
113
  return merged;
90
114
  }
@@ -1,3 +1,12 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
1
10
  import { createPathObject, createRectObject, createTextObject } from '../../engine/core/defaults.js';
2
11
  import { buildArrow } from '../../engine/core/arrow.js';
3
12
  import { serializePathData } from '../../engine/core/pathData.js';
@@ -5,27 +14,27 @@ import { packGroup } from './grouping.js';
5
14
  function snap(value) {
6
15
  return Math.round(value / 8) * 8;
7
16
  }
8
- const STROKE = '#9ca3af';
9
- const STROKE_WIDTH = 2;
17
+ var STROKE = '#9ca3af';
18
+ var STROKE_WIDTH = 2;
10
19
  export function drawUiComponent(kind, x, y, width, height, label) {
11
- const objects = [];
12
- const px = snap(x);
13
- const py = snap(y);
14
- const w = snap(Math.max(160, width));
15
- const h = snap(Math.max(120, height));
20
+ var objects = [];
21
+ var px = snap(x);
22
+ var py = snap(y);
23
+ var w = snap(Math.max(160, width));
24
+ var h = snap(Math.max(120, height));
16
25
  switch (kind) {
17
26
  case 'video_player': {
18
- const title = createTextObject({
27
+ var title = createTextObject({
19
28
  x: px,
20
29
  y: py - 28,
21
- text: label?.trim() || 'Video player',
30
+ text: (label === null || label === void 0 ? void 0 : label.trim()) || 'Video player',
22
31
  fontSize: 14,
23
32
  fontWeight: 'bold',
24
33
  autoWidth: true
25
34
  });
26
- const thumbW = w;
27
- const thumbH = snap(thumbW * (9 / 16));
28
- const frame = createRectObject({
35
+ var thumbW = w;
36
+ var thumbH = snap(thumbW * (9 / 16));
37
+ var frame = createRectObject({
29
38
  x: px,
30
39
  y: py,
31
40
  width: thumbW,
@@ -34,7 +43,7 @@ export function drawUiComponent(kind, x, y, width, height, label) {
34
43
  stroke: STROKE,
35
44
  strokeWidth: STROKE_WIDTH
36
45
  });
37
- const screen = createRectObject({
46
+ var screen = createRectObject({
38
47
  x: px + 12,
39
48
  y: py + 12,
40
49
  width: thumbW - 24,
@@ -44,15 +53,15 @@ export function drawUiComponent(kind, x, y, width, height, label) {
44
53
  stroke: 'transparent',
45
54
  strokeWidth: 0
46
55
  });
47
- const screenLabel = createTextObject({
56
+ var screenLabel = createTextObject({
48
57
  x: px + 16,
49
58
  y: py + 4,
50
59
  text: 'Thumbnail',
51
60
  fontSize: 11,
52
61
  autoWidth: true
53
62
  });
54
- const playSize = 56;
55
- const play = createRectObject({
63
+ var playSize = 56;
64
+ var play = createRectObject({
56
65
  x: px + thumbW / 2 - playSize / 2,
57
66
  y: py + thumbH / 2 - playSize / 2,
58
67
  width: playSize,
@@ -62,8 +71,8 @@ export function drawUiComponent(kind, x, y, width, height, label) {
62
71
  stroke: '#d1d5db',
63
72
  strokeWidth: 1
64
73
  });
65
- const screenGroup = packGroup([frame, screen, play, screenLabel], {});
66
- const navBar = createRectObject({
74
+ var screenGroup = packGroup([frame, screen, play, screenLabel], {});
75
+ var navBar = createRectObject({
67
76
  x: px,
68
77
  y: py + thumbH + 16,
69
78
  width: thumbW,
@@ -73,8 +82,8 @@ export function drawUiComponent(kind, x, y, width, height, label) {
73
82
  stroke: STROKE,
74
83
  strokeWidth: STROKE_WIDTH
75
84
  });
76
- const navThumbs = [];
77
- for (let i = 0; i < 5; i++) {
85
+ var navThumbs = [];
86
+ for (var i = 0; i < 5; i++) {
78
87
  navThumbs.push(createRectObject({
79
88
  x: px + 16 + i * 56,
80
89
  y: py + thumbH + 32,
@@ -86,7 +95,7 @@ export function drawUiComponent(kind, x, y, width, height, label) {
86
95
  strokeWidth: 0
87
96
  }));
88
97
  }
89
- const navTitle = createTextObject({
98
+ var navTitle = createTextObject({
90
99
  x: px,
91
100
  y: py + thumbH + 4,
92
101
  text: 'Navigation',
@@ -94,16 +103,16 @@ export function drawUiComponent(kind, x, y, width, height, label) {
94
103
  fontWeight: 'bold',
95
104
  autoWidth: true
96
105
  });
97
- const navGroup = packGroup([navBar, navTitle, ...navThumbs], {});
98
- objects.push(title, ...screenGroup.objects, ...navGroup.objects);
106
+ var navGroup = packGroup(__spreadArray([navBar, navTitle], navThumbs, true), {});
107
+ objects.push.apply(objects, __spreadArray(__spreadArray([title], screenGroup.objects, false), navGroup.objects, false));
99
108
  return {
100
- objects,
109
+ objects: objects,
101
110
  rootLabel: 'Video player',
102
111
  highlightIds: [navGroup.groupId]
103
112
  };
104
113
  }
105
114
  case 'navigation_bar': {
106
- const bar = createRectObject({
115
+ var bar = createRectObject({
107
116
  x: px,
108
117
  y: py + 20,
109
118
  width: w,
@@ -113,32 +122,32 @@ export function drawUiComponent(kind, x, y, width, height, label) {
113
122
  strokeWidth: STROKE_WIDTH,
114
123
  fill: '#f9fafb'
115
124
  });
116
- const title = createTextObject({
125
+ var title = createTextObject({
117
126
  x: px,
118
127
  y: py,
119
- text: label?.trim() || 'Navigation bar',
128
+ text: (label === null || label === void 0 ? void 0 : label.trim()) || 'Navigation bar',
120
129
  fontSize: 12,
121
130
  fontWeight: 'bold',
122
131
  autoWidth: true
123
132
  });
124
- const tabs = [];
125
- for (let i = 0; i < 4; i++) {
133
+ var tabs = [];
134
+ for (var i = 0; i < 4; i++) {
126
135
  tabs.push(createTextObject({
127
136
  x: px + 16 + i * 96,
128
137
  y: py + 36,
129
- text: `Nav ${i + 1}`,
138
+ text: "Nav ".concat(i + 1),
130
139
  fontSize: 14,
131
140
  autoWidth: true
132
141
  }));
133
142
  }
134
- const packed = packGroup([bar, ...tabs], {});
135
- objects.push(title, ...packed.objects);
136
- return { objects, rootLabel: label?.trim() || 'Navigation bar' };
143
+ var packed = packGroup(__spreadArray([bar], tabs, true), {});
144
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
145
+ return { objects: objects, rootLabel: (label === null || label === void 0 ? void 0 : label.trim()) || 'Navigation bar' };
137
146
  }
138
147
  case 'button': {
139
- const btnH = snap(Math.max(44, Math.min(48, h)));
140
- const btnW = snap(Math.max(128, w));
141
- const btn = createRectObject({
148
+ var btnH = snap(Math.max(44, Math.min(48, h)));
149
+ var btnW = snap(Math.max(128, w));
150
+ var btn = createRectObject({
142
151
  x: px,
143
152
  y: py + 22,
144
153
  width: btnW,
@@ -148,14 +157,14 @@ export function drawUiComponent(kind, x, y, width, height, label) {
148
157
  stroke: STROKE,
149
158
  strokeWidth: STROKE_WIDTH
150
159
  });
151
- const caption = createTextObject({
160
+ var caption = createTextObject({
152
161
  x: px + 16,
153
162
  y: py + 34,
154
- text: label ?? 'Button',
163
+ text: label !== null && label !== void 0 ? label : 'Button',
155
164
  fontSize: 15,
156
165
  autoWidth: true
157
166
  });
158
- const title = createTextObject({
167
+ var title = createTextObject({
159
168
  x: px,
160
169
  y: py,
161
170
  text: 'Button',
@@ -163,13 +172,13 @@ export function drawUiComponent(kind, x, y, width, height, label) {
163
172
  color: '#6b7280',
164
173
  autoWidth: true
165
174
  });
166
- const packed = packGroup([btn, caption], {});
167
- objects.push(title, ...packed.objects);
168
- return { objects, rootLabel: label ?? 'Button' };
175
+ var packed = packGroup([btn, caption], {});
176
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
177
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : 'Button' };
169
178
  }
170
179
  case 'card': {
171
- const cardH = snap(Math.max(160, h));
172
- const card = createRectObject({
180
+ var cardH = snap(Math.max(160, h));
181
+ var card = createRectObject({
173
182
  x: px,
174
183
  y: py + 24,
175
184
  width: w,
@@ -179,15 +188,15 @@ export function drawUiComponent(kind, x, y, width, height, label) {
179
188
  strokeWidth: STROKE_WIDTH,
180
189
  fill: '#ffffff'
181
190
  });
182
- const heading = createTextObject({
191
+ var heading = createTextObject({
183
192
  x: px + 16,
184
193
  y: py + 40,
185
- text: label ?? 'Card title',
194
+ text: label !== null && label !== void 0 ? label : 'Card title',
186
195
  fontSize: 18,
187
196
  fontWeight: 'bold',
188
197
  autoWidth: true
189
198
  });
190
- const body = createRectObject({
199
+ var body = createRectObject({
191
200
  x: px + 16,
192
201
  y: py + 72,
193
202
  width: w - 32,
@@ -197,15 +206,15 @@ export function drawUiComponent(kind, x, y, width, height, label) {
197
206
  stroke: 'transparent',
198
207
  strokeWidth: 0
199
208
  });
200
- const title = createTextObject({ x: px, y: py, text: 'Card', fontSize: 11, color: '#6b7280', autoWidth: true });
201
- const packed = packGroup([card, heading, body], {});
202
- objects.push(title, ...packed.objects);
203
- return { objects, rootLabel: label ?? 'Card' };
209
+ var title = createTextObject({ x: px, y: py, text: 'Card', fontSize: 11, color: '#6b7280', autoWidth: true });
210
+ var packed = packGroup([card, heading, body], {});
211
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
212
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : 'Card' };
204
213
  }
205
214
  case 'form': {
206
- const title = createTextObject({ x: px, y: py, text: label ?? 'Form', fontSize: 12, fontWeight: 'bold', autoWidth: true });
207
- const fields = [];
208
- for (let i = 0; i < 3; i++) {
215
+ var title = createTextObject({ x: px, y: py, text: label !== null && label !== void 0 ? label : 'Form', fontSize: 12, fontWeight: 'bold', autoWidth: true });
216
+ var fields = [];
217
+ for (var i = 0; i < 3; i++) {
209
218
  fields.push(createRectObject({
210
219
  x: px,
211
220
  y: py + 32 + i * 48,
@@ -217,12 +226,12 @@ export function drawUiComponent(kind, x, y, width, height, label) {
217
226
  fill: '#fff'
218
227
  }));
219
228
  }
220
- const packed = packGroup(fields, {});
221
- objects.push(title, ...packed.objects);
222
- return { objects, rootLabel: label ?? 'Form' };
229
+ var packed = packGroup(fields, {});
230
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
231
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : 'Form' };
223
232
  }
224
233
  default: {
225
- const box = createRectObject({
234
+ var box = createRectObject({
226
235
  x: px,
227
236
  y: py + 20,
228
237
  width: w,
@@ -231,20 +240,21 @@ export function drawUiComponent(kind, x, y, width, height, label) {
231
240
  stroke: STROKE,
232
241
  strokeWidth: STROKE_WIDTH
233
242
  });
234
- const title = createTextObject({
243
+ var title = createTextObject({
235
244
  x: px,
236
245
  y: py,
237
- text: label ?? kind.replace(/_/g, ' '),
246
+ text: label !== null && label !== void 0 ? label : kind.replace(/_/g, ' '),
238
247
  fontSize: 14,
239
248
  autoWidth: true
240
249
  });
241
250
  objects.push(title, box);
242
- return { objects, rootLabel: label ?? kind };
251
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : kind };
243
252
  }
244
253
  }
245
254
  }
246
- export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth = 2) {
247
- const geometry = buildArrow({ x: fromX, y: fromY }, { x: toX, y: toY }, 0, strokeWidth);
255
+ export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth) {
256
+ if (strokeWidth === void 0) { strokeWidth = 2; }
257
+ var geometry = buildArrow({ x: fromX, y: fromY }, { x: toX, y: toY }, 0, strokeWidth);
248
258
  return createPathObject({
249
259
  x: geometry.box.x,
250
260
  y: geometry.box.y,
@@ -254,7 +264,7 @@ export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth = 2) {
254
264
  shape: 'arrow',
255
265
  arrow: geometry.spec,
256
266
  stroke: '#111827',
257
- strokeWidth,
267
+ strokeWidth: strokeWidth,
258
268
  fill: 'transparent'
259
269
  });
260
270
  }
@@ -1,11 +1,33 @@
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
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
1
21
  import { createGroupObject, createObjectId } from '../../engine/core/defaults.js';
2
22
  /** Insert a group and its members in list order (group before members). */
3
- export function packGroup(members, options = {}) {
4
- const groupId = options.groupId ?? createObjectId('gp');
5
- const parentId = options.parentId ?? null;
6
- const withParents = members.map((object) => ({ ...object, parentId: groupId }));
23
+ export function packGroup(members, options) {
24
+ var _a, _b;
25
+ if (options === void 0) { options = {}; }
26
+ var groupId = (_a = options.groupId) !== null && _a !== void 0 ? _a : createObjectId('gp');
27
+ var parentId = (_b = options.parentId) !== null && _b !== void 0 ? _b : null;
28
+ var withParents = members.map(function (object) { return (__assign(__assign({}, object), { parentId: groupId })); });
7
29
  return {
8
- groupId,
9
- objects: [createGroupObject({ id: groupId, parentId }), ...withParents]
30
+ groupId: groupId,
31
+ objects: __spreadArray([createGroupObject({ id: groupId, parentId: parentId })], withParents, true)
10
32
  };
11
33
  }