@widgetic/canvas 0.5.40 → 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 (120) hide show
  1. package/README.md +7 -3
  2. package/dist/canvas/DomCanvas.svelte +4 -0
  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.js +18 -17
  9. package/dist/canvas/eventScope.js +14 -10
  10. package/dist/canvas/host/CanvasHost.d.ts +6 -0
  11. package/dist/canvas/host/CanvasHost.js +1556 -1267
  12. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  13. package/dist/canvas/host/CanvasHostApi.js +25 -4
  14. package/dist/canvas/host/browserServices.js +116 -65
  15. package/dist/canvas/host/conversion.js +170 -82
  16. package/dist/canvas/host/hostObject.js +7 -7
  17. package/dist/canvas/host/pageEvents.js +4 -4
  18. package/dist/canvas/host/screenRects.js +31 -28
  19. package/dist/canvas/host/strokeSnap.js +143 -88
  20. package/dist/canvas/openMarks.js +2 -2
  21. package/dist/canvas/outsideClickDeselect.js +7 -6
  22. package/dist/canvas/panZoomPosition.js +2 -2
  23. package/dist/canvas/preferredTextFont.js +25 -13
  24. package/dist/canvas/shapes/ShapeLibrary.js +148 -138
  25. package/dist/canvas/shapes/shapeImageStore.js +3 -3
  26. package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
  27. package/dist/canvas/toolbarPosition.js +2 -2
  28. package/dist/canvas/ui/CanvasHint.svelte +16 -3
  29. package/dist/canvas/ui/CanvasHint.svelte.d.ts +2 -17
  30. package/dist/canvas/ui/CanvasToolbar.svelte +7 -7
  31. package/dist/canvas/ui/ToolButton.svelte +11 -3
  32. package/dist/canvas/ui/ToolButton.svelte.d.ts +2 -0
  33. package/dist/canvas/ui/colorModel.js +32 -21
  34. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  35. package/dist/canvas/ui/floatingCard.js +18 -18
  36. package/dist/canvas/ui/floatingLayer.js +6 -5
  37. package/dist/canvas/ui/keyHints.js +11 -9
  38. package/dist/canvas/ui/popoverSide.js +3 -2
  39. package/dist/canvas/ui/selectionTraits.js +40 -34
  40. package/dist/canvas/ui/sizeLabelVisibility.d.ts +1 -1
  41. package/dist/canvas/ui/sizeLabelVisibility.js +1 -1
  42. package/dist/canvas/view/SelectionOverlay.svelte +33 -14
  43. package/dist/canvas/view/erasingMarks.js +7 -7
  44. package/dist/canvas/view/geometry.d.ts +14 -4
  45. package/dist/canvas/view/geometry.js +103 -77
  46. package/dist/components/preferenceStorage.js +2 -2
  47. package/dist/engine/EngineCore.d.ts +4 -1
  48. package/dist/engine/EngineCore.js +801 -695
  49. package/dist/engine/codec/canvasDocument.js +173 -173
  50. package/dist/engine/codec/hostReadableKeys.js +1 -1
  51. package/dist/engine/core/arrange.js +38 -26
  52. package/dist/engine/core/arrow.d.ts +10 -3
  53. package/dist/engine/core/arrow.js +96 -75
  54. package/dist/engine/core/arrowBinding.d.ts +69 -0
  55. package/dist/engine/core/arrowBinding.js +344 -0
  56. package/dist/engine/core/arrowBindingRecords.d.ts +43 -0
  57. package/dist/engine/core/arrowBindingRecords.js +141 -0
  58. package/dist/engine/core/brush.js +94 -67
  59. package/dist/engine/core/defaults.js +51 -90
  60. package/dist/engine/core/freehand.js +163 -147
  61. package/dist/engine/core/geometry.js +54 -47
  62. package/dist/engine/core/history.js +50 -33
  63. package/dist/engine/core/hitTest.d.ts +3 -0
  64. package/dist/engine/core/hitTest.js +83 -69
  65. package/dist/engine/core/matrix.js +20 -18
  66. package/dist/engine/core/pathData.js +210 -183
  67. package/dist/engine/core/rotationReset.js +6 -5
  68. package/dist/engine/core/scene.d.ts +3 -0
  69. package/dist/engine/core/scene.js +192 -129
  70. package/dist/engine/core/scribble.js +84 -59
  71. package/dist/engine/core/shapePaths.js +15 -12
  72. package/dist/engine/core/shapeTools.js +63 -72
  73. package/dist/engine/core/snapping.js +117 -65
  74. package/dist/engine/core/style.js +64 -31
  75. package/dist/engine/core/transform.js +94 -83
  76. package/dist/engine/core/types.d.ts +29 -0
  77. package/dist/engine/core/types.js +4 -4
  78. package/dist/engine/core/viewport.js +36 -23
  79. package/dist/engine/input/PointerController.js +476 -447
  80. package/dist/engine/input/arrowHandles.js +12 -12
  81. package/dist/engine/input/gestures.d.ts +12 -1
  82. package/dist/engine/input/gestures.js +342 -251
  83. package/dist/engine/input/hoverCursor.js +1 -1
  84. package/dist/engine/input/keyboard.d.ts +9 -1
  85. package/dist/engine/input/keyboard.js +46 -27
  86. package/dist/engine/input/selectionHandles.js +50 -45
  87. package/dist/engine/input/types.js +1 -1
  88. package/dist/engine/render/rasterize.js +158 -86
  89. package/dist/engine/state.d.ts +6 -1
  90. package/dist/engine/state.js +17 -5
  91. package/dist/engine/text/layoutText.js +62 -43
  92. package/dist/engine/text/textMetrics.js +10 -8
  93. package/dist/engine/widgets.js +137 -101
  94. package/dist/fonts/interFont.js +68 -17
  95. package/dist/fonts/workspaceFonts.js +90 -32
  96. package/dist/i18n/labels.js +4 -4
  97. package/dist/i18n/language.js +4 -4
  98. package/dist/i18n/messages.js +1 -1
  99. package/dist/i18n/shortcuts.d.ts +12 -0
  100. package/dist/i18n/shortcuts.js +32 -18
  101. package/dist/settings/workspaceToolSettings.js +48 -32
  102. package/dist/tools/components/catalog.d.ts +11 -0
  103. package/dist/tools/components/catalog.js +270 -0
  104. package/dist/tools/components/grouping.d.ts +9 -0
  105. package/dist/tools/components/grouping.js +33 -0
  106. package/dist/tools/definitions.d.ts +19 -0
  107. package/dist/tools/definitions.js +147 -0
  108. package/dist/tools/executors.d.ts +7 -0
  109. package/dist/tools/executors.js +324 -0
  110. package/dist/tools/hostAdapter.d.ts +14 -0
  111. package/dist/tools/hostAdapter.js +40 -0
  112. package/dist/tools/index.d.ts +6 -0
  113. package/dist/tools/index.js +6 -0
  114. package/dist/tools/sceneSummary.d.ts +24 -0
  115. package/dist/tools/sceneSummary.js +170 -0
  116. package/dist/tools/sketchIntent.d.ts +17 -0
  117. package/dist/tools/sketchIntent.js +166 -0
  118. package/dist/tools/types.d.ts +54 -0
  119. package/dist/tools/types.js +11 -0
  120. package/package.json +7 -2
@@ -1,15 +1,53 @@
1
1
  /**
2
2
  * Workspace brand-kit fonts registered for the canvas font picker (item B15).
3
3
  */
4
- const registered = new Set();
5
- let registerPass = null;
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ var __generator = (this && this.__generator) || function (thisArg, body) {
14
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
15
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
16
+ function verb(n) { return function (v) { return step([n, v]); }; }
17
+ function step(op) {
18
+ if (f) throw new TypeError("Generator is already executing.");
19
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
20
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
21
+ if (y = 0, t) op = [op[0] & 2, t.value];
22
+ switch (op[0]) {
23
+ case 0: case 1: t = op; break;
24
+ case 4: _.label++; return { value: op[1], done: false };
25
+ case 5: _.label++; y = op[1]; op = [0]; continue;
26
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
27
+ default:
28
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
29
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
30
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
31
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
32
+ if (t[2]) _.ops.pop();
33
+ _.trys.pop(); continue;
34
+ }
35
+ op = body.call(thisArg, _);
36
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
37
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
38
+ }
39
+ };
40
+ var registered = new Set();
41
+ var registerPass = null;
6
42
  function familyKey(font) {
7
- return `${font.family}|${font.weight ?? '400'}|${font.style ?? 'normal'}`;
43
+ var _a, _b;
44
+ return "".concat(font.family, "|").concat((_a = font.weight) !== null && _a !== void 0 ? _a : '400', "|").concat((_b = font.style) !== null && _b !== void 0 ? _b : 'normal');
8
45
  }
9
46
  export function listWorkspaceFontFamilies(fonts) {
10
- const seen = new Set();
11
- const out = [];
12
- for (const font of fonts) {
47
+ var seen = new Set();
48
+ var out = [];
49
+ for (var _i = 0, fonts_1 = fonts; _i < fonts_1.length; _i++) {
50
+ var font = fonts_1[_i];
13
51
  if (!font.family || seen.has(font.family))
14
52
  continue;
15
53
  seen.add(font.family);
@@ -18,34 +56,54 @@ export function listWorkspaceFontFamilies(fonts) {
18
56
  return out;
19
57
  }
20
58
  export function registerWorkspaceFonts(fonts) {
59
+ var _this = this;
21
60
  if (typeof document === 'undefined' || typeof FontFace === 'undefined')
22
61
  return Promise.resolve();
23
- registerPass ??= (async () => {
24
- for (const font of fonts) {
25
- const key = familyKey(font);
26
- if (registered.has(key) || !font.url)
27
- continue;
28
- try {
29
- const format = font.format ? ` format('${font.format}')` : '';
30
- const source = `url(${JSON.stringify(font.url)})${format}`;
31
- const face = new FontFace(font.family, source, {
32
- weight: String(font.weight ?? '400'),
33
- style: font.style ?? 'normal',
34
- display: 'swap'
35
- });
36
- const loaded = await Promise.race([
37
- face.load(),
38
- new Promise((_, reject) => {
39
- setTimeout(() => reject(new Error('font load timeout')), 12_000);
40
- })
41
- ]);
42
- document.fonts.add(loaded);
43
- registered.add(key);
44
- }
45
- catch (error) {
46
- console.warn(`Canvas: workspace font "${font.family}" could not load`, error);
62
+ registerPass !== null && registerPass !== void 0 ? registerPass : (registerPass = (function () { return __awaiter(_this, void 0, void 0, function () {
63
+ var _i, fonts_2, font, key, format, source, face, loaded, error_1;
64
+ var _a, _b;
65
+ return __generator(this, function (_c) {
66
+ switch (_c.label) {
67
+ case 0:
68
+ _i = 0, fonts_2 = fonts;
69
+ _c.label = 1;
70
+ case 1:
71
+ if (!(_i < fonts_2.length)) return [3 /*break*/, 6];
72
+ font = fonts_2[_i];
73
+ key = familyKey(font);
74
+ if (registered.has(key) || !font.url)
75
+ return [3 /*break*/, 5];
76
+ _c.label = 2;
77
+ case 2:
78
+ _c.trys.push([2, 4, , 5]);
79
+ format = font.format ? " format('".concat(font.format, "')") : '';
80
+ source = "url(".concat(JSON.stringify(font.url), ")").concat(format);
81
+ face = new FontFace(font.family, source, {
82
+ weight: String((_a = font.weight) !== null && _a !== void 0 ? _a : '400'),
83
+ style: (_b = font.style) !== null && _b !== void 0 ? _b : 'normal',
84
+ display: 'swap'
85
+ });
86
+ return [4 /*yield*/, Promise.race([
87
+ face.load(),
88
+ new Promise(function (_, reject) {
89
+ setTimeout(function () { return reject(new Error('font load timeout')); }, 12000);
90
+ })
91
+ ])];
92
+ case 3:
93
+ loaded = _c.sent();
94
+ document.fonts.add(loaded);
95
+ registered.add(key);
96
+ return [3 /*break*/, 5];
97
+ case 4:
98
+ error_1 = _c.sent();
99
+ console.warn("Canvas: workspace font \"".concat(font.family, "\" could not load"), error_1);
100
+ return [3 /*break*/, 5];
101
+ case 5:
102
+ _i++;
103
+ return [3 /*break*/, 1];
104
+ case 6: return [2 /*return*/];
47
105
  }
48
- }
49
- })();
106
+ });
107
+ }); })());
50
108
  return registerPass;
51
109
  }
@@ -1,7 +1,7 @@
1
1
  import { getShapeByKey } from '../canvas/shapes/ShapeLibrary.js';
2
2
  // The groups of the shape library are kept under their English names (a shape of a saved canvas knows its group by that
3
3
  // name); this says each in the page's language.
4
- const CATEGORY_KEYS = {
4
+ var CATEGORY_KEYS = {
5
5
  'Geometric Shapes': 'canvas.category.geometric',
6
6
  'Arrow Shapes': 'canvas.category.arrows',
7
7
  'Media Icons': 'canvas.category.media',
@@ -11,14 +11,14 @@ const CATEGORY_KEYS = {
11
11
  /** The name of a group of the shape library, by the English name the library keeps it under. */
12
12
  export function categoryLabel(category, t) {
13
13
  // Only the table's own entries: a group called "constructor" is not a method of the table.
14
- const key = Object.prototype.hasOwnProperty.call(CATEGORY_KEYS, category) ? CATEGORY_KEYS[category] : undefined;
14
+ var key = Object.prototype.hasOwnProperty.call(CATEGORY_KEYS, category) ? CATEGORY_KEYS[category] : undefined;
15
15
  return key ? t(key) : category;
16
16
  }
17
17
  /** The name of a library shape the library no longer knows (an old save): its key as words ("arrow-right" → "Arrow Right"). */
18
18
  function wordsOfKey(shapeKey) {
19
19
  return shapeKey
20
20
  .split('-')
21
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
21
+ .map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1); })
22
22
  .join(' ');
23
23
  }
24
24
  /**
@@ -49,7 +49,7 @@ export function objectName(object, t) {
49
49
  return t('canvas.tool.triangle');
50
50
  if (object.shape === 'arrow')
51
51
  return t('canvas.tool.arrow');
52
- const known = getShapeByKey(object.shape);
52
+ var known = getShapeByKey(object.shape);
53
53
  return t('canvas.type.drawingOf', { name: known ? t(known.labelKey) : wordsOfKey(object.shape) });
54
54
  }
55
55
  }
@@ -6,23 +6,23 @@ import { CANVAS_MESSAGES } from './messages.js';
6
6
  * canvas) reads its words from it (`useCanvasLanguage`). The context belongs to one root, so two canvases on a page can
7
7
  * speak two languages.
8
8
  */
9
- const canvasWords = createI18n({ catalog: CANVAS_MESSAGES, label: 'Canvas' });
9
+ var canvasWords = createI18n({ catalog: CANVAS_MESSAGES, label: 'Canvas' });
10
10
  /**
11
11
  * Called by the root component of a canvas while it is created, so everything inside it speaks the page's language.
12
12
  * It gives back the words as stores and `update(settings)` for when the page sets the language again.
13
13
  */
14
- export const provideCanvasLanguage = canvasWords.provideI18n;
14
+ export var provideCanvasLanguage = canvasWords.provideI18n;
15
15
  /**
16
16
  * Called by a part of the canvas while it is created. Gives its words as stores, so a part that is already on the screen
17
17
  * changes when the page sets the language again. Outside a canvas (a part used on its own, such as the colour control)
18
18
  * it speaks English.
19
19
  */
20
- export const useCanvasLanguage = canvasWords.useI18n;
20
+ export var useCanvasLanguage = canvasWords.useI18n;
21
21
  /**
22
22
  * The English `t` of the canvas, for code that has no component around it. The screens of the canvas get their words, in
23
23
  * the page's language, from `useCanvasLanguage`.
24
24
  */
25
- export const translateEnglish = canvasWords.translateEnglish;
25
+ export var translateEnglish = canvasWords.translateEnglish;
26
26
  /**
27
27
  * Checks a page's `messages` against the canvas's catalog without showing anything: a key that does not exist (with the
28
28
  * nearest real one), a value that is not text, a template that does not parse, or one that asks for a value the message
@@ -14,7 +14,7 @@
14
14
  * - the English names the canvas keeps for the things it saves ("libraryShape", "Symbol Shapes", a shape's key): they
15
15
  * are data, and a screen says them with the messages below.
16
16
  */
17
- export const CANVAS_MESSAGES = {
17
+ export var CANVAS_MESSAGES = {
18
18
  // ===== The canvas itself =====
19
19
  'canvas.state.loading': 'Loading canvas…',
20
20
  'canvas.state.initFailed': 'Canvas failed to initialize.',
@@ -17,6 +17,18 @@ export declare const TOOL_KEYS: {
17
17
  readonly text: "T";
18
18
  readonly image: "I";
19
19
  };
20
+ /**
21
+ * The number that also chooses each tool of the drawing bar: the place of its button on the bar, counted from the start of it.
22
+ * The hints and the list of keyboard shortcuts show it beside the letter. A digit is the same on every keyboard, so it is not a
23
+ * message either. The engine's table (`TOOL_DIGITS`) is the one that answers the key; a test holds the two together.
24
+ */
25
+ export declare const TOOL_DIGIT_KEYS: {
26
+ readonly select: "1";
27
+ readonly draw: "2";
28
+ readonly erase: "3";
29
+ readonly arrow: "4";
30
+ readonly text: "5";
31
+ };
20
32
  /**
21
33
  * One key of a shortcut: a key that is a word (a message, so a language can write "Strg" for "Ctrl"), a key cap that
22
34
  * reads the same everywhere ("V", "↑", "]"), or `null` for the "+" that is drawn between two keys (a `null` rather than
@@ -2,7 +2,7 @@
2
2
  * The key that chooses each tool. The hints of the toolbar and the list of keyboard shortcuts read the same letters, so
3
3
  * the two cannot disagree. A letter is the same on every keyboard, so it is not a message.
4
4
  */
5
- export const TOOL_KEYS = {
5
+ export var TOOL_KEYS = {
6
6
  select: 'V',
7
7
  hand: 'H',
8
8
  erase: 'E',
@@ -14,26 +14,40 @@ export const TOOL_KEYS = {
14
14
  text: 'T',
15
15
  image: 'I'
16
16
  };
17
- const named = (name) => ({ name });
18
- const cap = (text) => ({ cap: text });
19
- const PLUS = null;
20
- const CTRL = named('canvas.key.ctrlCmd');
21
- const ALT = named('canvas.key.alt');
22
- const SHIFT = named('canvas.key.shift');
17
+ /**
18
+ * The number that also chooses each tool of the drawing bar: the place of its button on the bar, counted from the start of it.
19
+ * The hints and the list of keyboard shortcuts show it beside the letter. A digit is the same on every keyboard, so it is not a
20
+ * message either. The engine's table (`TOOL_DIGITS`) is the one that answers the key; a test holds the two together.
21
+ */
22
+ export var TOOL_DIGIT_KEYS = {
23
+ select: '1',
24
+ draw: '2',
25
+ erase: '3',
26
+ arrow: '4',
27
+ text: '5'
28
+ };
29
+ var named = function (name) { return ({ name: name }); };
30
+ var cap = function (text) { return ({ cap: text }); };
31
+ var PLUS = null;
32
+ var CTRL = named('canvas.key.ctrlCmd');
33
+ var ALT = named('canvas.key.alt');
34
+ var SHIFT = named('canvas.key.shift');
23
35
  /** The keyboard shortcuts of the canvas, in the order of the list that opens with "?". */
24
- export const SHORTCUT_GROUPS = [
36
+ export var SHORTCUT_GROUPS = [
25
37
  {
26
38
  title: 'canvas.shortcuts.groupTools',
27
39
  shortcuts: [
28
- { keys: [cap(TOOL_KEYS.select)], label: 'canvas.tool.select' },
40
+ // The five tools of the drawing bar show two key caps next to each other (the letter, then the number), like the four
41
+ // arrow keys of "move" below: either key does it.
42
+ { keys: [cap(TOOL_KEYS.select), cap(TOOL_DIGIT_KEYS.select)], label: 'canvas.tool.select' },
29
43
  { keys: [cap(TOOL_KEYS.hand)], label: 'canvas.tool.hand' },
30
- { keys: [cap(TOOL_KEYS.erase)], label: 'canvas.tool.erase' },
31
- { keys: [cap(TOOL_KEYS.draw)], label: 'canvas.tool.draw' },
32
- { keys: [cap(TOOL_KEYS.arrow)], label: 'canvas.tool.arrow' },
44
+ { keys: [cap(TOOL_KEYS.erase), cap(TOOL_DIGIT_KEYS.erase)], label: 'canvas.tool.erase' },
45
+ { keys: [cap(TOOL_KEYS.draw), cap(TOOL_DIGIT_KEYS.draw)], label: 'canvas.tool.draw' },
46
+ { keys: [cap(TOOL_KEYS.arrow), cap(TOOL_DIGIT_KEYS.arrow)], label: 'canvas.tool.arrow' },
33
47
  { keys: [cap(TOOL_KEYS.rectangle)], label: 'canvas.tool.rectangle' },
34
48
  { keys: [cap(TOOL_KEYS.triangle)], label: 'canvas.tool.triangle' },
35
49
  { keys: [cap(TOOL_KEYS.ellipse)], label: 'canvas.tool.ellipse' },
36
- { keys: [cap(TOOL_KEYS.text)], label: 'canvas.tool.text' },
50
+ { keys: [cap(TOOL_KEYS.text), cap(TOOL_DIGIT_KEYS.text)], label: 'canvas.tool.text' },
37
51
  { keys: [cap(TOOL_KEYS.image)], label: 'canvas.tool.image' }
38
52
  ]
39
53
  },
@@ -85,11 +99,11 @@ export const SHORTCUT_GROUPS = [
85
99
  ];
86
100
  /** The list of keyboard shortcuts in the page's language. */
87
101
  export function shortcutGroups(t) {
88
- return SHORTCUT_GROUPS.map((group) => ({
102
+ return SHORTCUT_GROUPS.map(function (group) { return ({
89
103
  title: t(group.title),
90
- shortcuts: group.shortcuts.map((shortcut) => ({
104
+ shortcuts: group.shortcuts.map(function (shortcut) { return ({
91
105
  label: t(shortcut.label),
92
- keys: shortcut.keys.map((key) => (key === null ? null : 'name' in key ? t(key.name) : key.cap))
93
- }))
94
- }));
106
+ keys: shortcut.keys.map(function (key) { return (key === null ? null : 'name' in key ? t(key.name) : key.cap); })
107
+ }); })
108
+ }); });
95
109
  }
@@ -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,40 @@ 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
+ var pending = null;
62
+ var debounceTimer;
63
+ export function saveWorkspaceToolSettingsDebounced(scope, patch, adapter) {
64
+ var _a;
65
+ if (adapter === void 0) { adapter = adapterFromPreferenceStorage(); }
66
+ var current = (_a = loadWorkspaceToolSettings(scope, adapter)) !== null && _a !== void 0 ? _a : { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
67
+ var merged = {
53
68
  v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION,
54
- text: { ...current.text, ...patch.text },
55
- paint: { ...current.paint, ...patch.paint },
56
- arrow: { ...current.arrow, ...patch.arrow }
69
+ text: __assign(__assign({}, current.text), patch.text),
70
+ paint: __assign(__assign({}, current.paint), patch.paint),
71
+ arrow: __assign(__assign({}, current.arrow), patch.arrow)
57
72
  };
58
- pending = { scope, value: merged, adapter };
73
+ pending = { scope: scope, value: merged, adapter: adapter };
59
74
  if (debounceTimer !== undefined)
60
75
  clearTimeout(debounceTimer);
61
- debounceTimer = setTimeout(() => flushWorkspaceToolSettingsPending(), 400);
76
+ debounceTimer = setTimeout(function () { return flushWorkspaceToolSettingsPending(); }, 400);
62
77
  }
63
78
  export function flushWorkspaceToolSettingsPending() {
64
79
  if (!pending)
65
80
  return;
66
- const { scope, value, adapter } = pending;
81
+ var scope = pending.scope, value = pending.value, adapter = pending.adapter;
67
82
  pending = null;
68
83
  if (debounceTimer !== undefined) {
69
84
  clearTimeout(debounceTimer);
@@ -72,18 +87,19 @@ export function flushWorkspaceToolSettingsPending() {
72
87
  try {
73
88
  adapter.save(storageKey(scope), JSON.stringify(value));
74
89
  }
75
- catch {
90
+ catch (_a) {
76
91
  // ignored
77
92
  }
78
93
  }
79
94
  /** Merges a patch into settings without debounce (tests). */
80
95
  export function saveWorkspaceToolSettingsNow(scope, patch, adapter) {
81
- const current = loadWorkspaceToolSettings(scope, adapter) ?? { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
82
- const merged = {
96
+ var _a;
97
+ var current = (_a = loadWorkspaceToolSettings(scope, adapter)) !== null && _a !== void 0 ? _a : { v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION };
98
+ var merged = {
83
99
  v: WORKSPACE_TOOL_SETTINGS_SCHEMA_VERSION,
84
- text: { ...current.text, ...patch.text },
85
- paint: { ...current.paint, ...patch.paint },
86
- arrow: { ...current.arrow, ...patch.arrow }
100
+ text: __assign(__assign({}, current.text), patch.text),
101
+ paint: __assign(__assign({}, current.paint), patch.paint),
102
+ arrow: __assign(__assign({}, current.arrow), patch.arrow)
87
103
  };
88
104
  adapter.save(storageKey(scope), JSON.stringify(merged));
89
105
  return merged;
@@ -0,0 +1,11 @@
1
+ import type { SceneObject } from '../../engine/core/types.js';
2
+ import type { ObjectId } from '../../engine/core/types.js';
3
+ import type { UiComponentKind } from '../types.js';
4
+ export interface ComponentPlacement {
5
+ objects: SceneObject[];
6
+ rootLabel: string;
7
+ /** Ids the assistant should target (e.g. navigation group). */
8
+ highlightIds?: ObjectId[];
9
+ }
10
+ export declare function drawUiComponent(kind: UiComponentKind, x: number, y: number, width: number, height: number, label?: string): ComponentPlacement;
11
+ export declare function makeArrowBetween(fromX: number, fromY: number, toX: number, toY: number, strokeWidth?: number): SceneObject;