@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
@@ -42,6 +42,11 @@ export interface SerializeOptions {
42
42
  now?: Date;
43
43
  /** When given, inline image bytes go here and only a reference is written. */
44
44
  imageStore?: ImageBytesSink | null;
45
+ /**
46
+ * Called for a picture whose bytes the store refused (its `save` threw): they stay in the text instead. The engine writes
47
+ * nothing to the console, so the host decides how to report it (once per save, not once per picture).
48
+ */
49
+ onImageStoreRefused?: (ref: string, error: unknown) => void;
45
50
  }
46
51
  /** The document for a board, as a plain object (the form `serializeCanvasDocument` writes). */
47
52
  export declare function createCanvasDocument(scene: readonly SceneObject[], viewport: Viewport, options?: SerializeOptions): CanvasDocument;
@@ -12,26 +12,6 @@
12
12
  * - Everything read is validated and clamped, because a saved canvas is data from a database and from other
13
13
  * people's browsers: colours, fonts and addresses that could carry more than a value are replaced by defaults.
14
14
  */
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
27
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
28
- if (ar || !(i in from)) {
29
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
30
- ar[i] = from[i];
31
- }
32
- }
33
- return to.concat(ar || Array.prototype.slice.call(from));
34
- };
35
15
  import { arrowPointsOfLegacyPath, buildArrow } from '../core/arrow.js';
36
16
  import { dropDanglingBindings, withBindings } from '../core/arrowBindingRecords.js';
37
17
  import { BRUSH_MAX_POINTS, brushOutlineData } from '../core/brush.js';
@@ -44,17 +24,18 @@ import { CANVAS_DOCUMENT_VERSION, MIN_OBJECT_SIZE } from '../core/types.js';
44
24
  import { sanitizeViewport } from '../core/viewport.js';
45
25
  import { HOST_READABLE_KEYS } from './hostReadableKeys.js';
46
26
  /** The most objects a board may hold when it is read; a text with more is cut here and says so. */
47
- export var MAX_OBJECTS_PER_DOCUMENT = 20000;
48
- var MAX_TEXT_LENGTH = 100000;
49
- var MAX_PATH_DATA_LENGTH = 500000;
50
- var MAX_COORDINATE = 1000000;
51
- var MAX_SIZE = 100000;
27
+ export const MAX_OBJECTS_PER_DOCUMENT = 20_000;
28
+ const MAX_TEXT_LENGTH = 100_000;
29
+ const MAX_PATH_DATA_LENGTH = 500_000;
30
+ const MAX_COORDINATE = 1_000_000;
31
+ const MAX_SIZE = 100_000;
52
32
  // --- Writing -----------------------------------------------------------------------------------
53
- var BOX_KEYS = ['x', 'y', 'width', 'height', 'rotation', 'opacity'];
54
- var PAINT_KEYS = ['fill', 'fillOpacity', 'stroke', 'strokeWidth', 'strokeStyle'];
33
+ const BOX_KEYS = ['x', 'y', 'width', 'height', 'rotation', 'opacity'];
34
+ const PAINT_KEYS = ['fill', 'fillOpacity', 'stroke', 'strokeWidth', 'strokeStyle'];
55
35
  // The words audit reads every string inside a property called `text` as a sentence a person can read; these are the
56
36
  // names of fields, so the list of a text object's keys lives in a constant of its own.
57
- var TEXT_OBJECT_KEYS = __spreadArray(__spreadArray([], BOX_KEYS, true), [
37
+ const TEXT_OBJECT_KEYS = [
38
+ ...BOX_KEYS,
58
39
  'text',
59
40
  'color',
60
41
  'fontSize',
@@ -67,25 +48,52 @@ var TEXT_OBJECT_KEYS = __spreadArray(__spreadArray([], BOX_KEYS, true), [
67
48
  'padding',
68
49
  'backgroundColor',
69
50
  'autoWidth'
70
- ], false);
71
- var KEYS_BY_TYPE = {
72
- rect: __spreadArray(__spreadArray(__spreadArray([], BOX_KEYS, true), PAINT_KEYS, true), ['roundness'], false),
73
- ellipse: __spreadArray(__spreadArray(__spreadArray([], BOX_KEYS, true), PAINT_KEYS, true), ['aspectLocked'], false),
74
- path: __spreadArray(__spreadArray(__spreadArray([], BOX_KEYS, true), PAINT_KEYS, true), ['d', 'shape', 'roundness', 'aspectLocked', 'flipX', 'flipY', 'lineCap', 'lineJoin', 'ink', 'arrow'], false),
51
+ ];
52
+ const KEYS_BY_TYPE = {
53
+ rect: [...BOX_KEYS, ...PAINT_KEYS, 'roundness'],
54
+ ellipse: [...BOX_KEYS, ...PAINT_KEYS, 'aspectLocked'],
55
+ path: [...BOX_KEYS, ...PAINT_KEYS, 'd', 'shape', 'roundness', 'aspectLocked', 'flipX', 'flipY', 'lineCap', 'lineJoin', 'ink', 'arrow'],
75
56
  text: TEXT_OBJECT_KEYS,
76
- image: __spreadArray(__spreadArray([], BOX_KEYS, true), ['src', 'imageRef', 'fileName', 'naturalWidth', 'naturalHeight'], false),
77
- widget: __spreadArray(__spreadArray([], BOX_KEYS, true), ['widgetId', 'widgetName', 'isPrimary', 'thumbnail', 'thumbnailRef'], false),
57
+ image: [...BOX_KEYS, 'src', 'imageRef', 'fileName', 'naturalWidth', 'naturalHeight'],
58
+ widget: [...BOX_KEYS, 'widgetId', 'widgetName', 'isPrimary', 'thumbnail', 'thumbnailRef'],
78
59
  group: []
79
60
  };
61
+ /**
62
+ * Whether an address only lives as long as the page that made it (an object URL, `blob:`). A store may answer a reference with
63
+ * one instead of bytes, so that the picture is not a string megabytes long in the board and in every `<img>` that shows it.
64
+ */
65
+ function isPageLocalAddress(address) {
66
+ return address.startsWith('blob:');
67
+ }
80
68
  /** The reference and the (possibly inline) bytes of a picture, with the bytes moved to the store when there is one. */
81
- function externalizeBytes(inline, existingRef, makeRef, store) {
69
+ function externalizeBytes(inline, existingRef, makeRef, options) {
70
+ const store = options.imageStore;
71
+ // An object URL the store gave for a reference is not bytes, and it must never reach the text: the next page cannot read it, and
72
+ // a board that holds an address is not asked to read the picture again, so the card would stay blank. The picture is the
73
+ // store's already, under the reference it was given for: only the reference is written. With no store, or with no reference to
74
+ // say where the picture is, there is nothing to point at, and the address is left as it always was.
75
+ if (store && existingRef && inline && isPageLocalAddress(inline))
76
+ return { value: null, ref: existingRef };
82
77
  if (!store || !inline || !inline.startsWith('data:'))
83
78
  return { value: inline, ref: existingRef };
84
- var ref = existingRef !== null && existingRef !== void 0 ? existingRef : makeRef();
79
+ const ref = existingRef ?? makeRef();
85
80
  if (!ref)
86
81
  return { value: inline, ref: existingRef };
87
- store.save(ref, inline);
88
- return { value: null, ref: ref };
82
+ try {
83
+ store.save(ref, inline);
84
+ }
85
+ catch (error) {
86
+ // A store that refuses (it has nowhere to keep the bytes yet) must not take the whole save down with it, and must not
87
+ // cost a picture: the bytes stay in the text, as if there were no store, and are offered again at the next save.
88
+ try {
89
+ options.onImageStoreRefused?.(ref, error);
90
+ }
91
+ catch {
92
+ // The report is a courtesy; a report that fails changes nothing about the save.
93
+ }
94
+ return { value: inline, ref: existingRef };
95
+ }
96
+ return { value: null, ref };
89
97
  }
90
98
  /** A tie of an arrow's end as it is saved: the shape it holds to (`target`) and, for a point of the outline, where on the shape's box. */
91
99
  function writeArrowBinding(binding) {
@@ -94,21 +102,19 @@ function writeArrowBinding(binding) {
94
102
  : { target: binding.targetId, kind: 'center' };
95
103
  }
96
104
  function serializeObject(object, options) {
97
- var _a;
98
- var record = (_a = { id: object.id }, _a[HOST_READABLE_KEYS.objectType] = object.type, _a.parentId = object.parentId, _a);
99
- var source = object;
100
- var overrides = {};
105
+ const record = { id: object.id, [HOST_READABLE_KEYS.objectType]: object.type, parentId: object.parentId };
106
+ const source = object;
107
+ let overrides = {};
101
108
  if (object.type === 'widget') {
102
- var thumbnail = externalizeBytes(object.thumbnail, object.thumbnailRef, function () { return "widget:".concat(object.widgetId); }, options.imageStore);
109
+ const thumbnail = externalizeBytes(object.thumbnail, object.thumbnailRef, () => `widget:${object.widgetId}`, options);
103
110
  overrides = { thumbnail: thumbnail.value, thumbnailRef: thumbnail.ref };
104
111
  }
105
112
  else if (object.type === 'image') {
106
- var image = externalizeBytes(object.src, object.imageRef, function () { return "shape:".concat(object.id); }, options.imageStore);
113
+ const image = externalizeBytes(object.src, object.imageRef, () => `shape:${object.id}`, options);
107
114
  overrides = { src: image.value, imageRef: image.ref };
108
115
  }
109
- for (var _i = 0, _b = KEYS_BY_TYPE[object.type]; _i < _b.length; _i++) {
110
- var key = _b[_i];
111
- var value = key in overrides ? overrides[key] : source[key];
116
+ for (const key of KEYS_BY_TYPE[object.type]) {
117
+ const value = key in overrides ? overrides[key] : source[key];
112
118
  record[key] = typeof value === 'number' ? roundTo(value, 3) : value;
113
119
  }
114
120
  if (object.type === 'widget') {
@@ -129,8 +135,15 @@ function serializeObject(object, options) {
129
135
  // An arrow is saved as its two ends and its bend, for the same reason: its head and shaft are drawn from them when it is read.
130
136
  if (object.arrow) {
131
137
  delete record.d;
132
- var _c = object.arrow, start = _c.start, end = _c.end, bend = _c.bend, startBinding = _c.startBinding, endBinding = _c.endBinding;
133
- record.arrow = __assign(__assign({ start: [roundTo(start.x, 3), roundTo(start.y, 3)], end: [roundTo(end.x, 3), roundTo(end.y, 3)], bend: roundTo(bend, 3) }, (startBinding ? { startBinding: writeArrowBinding(startBinding) } : {})), (endBinding ? { endBinding: writeArrowBinding(endBinding) } : {}));
138
+ const { start, end, bend, startBinding, endBinding } = object.arrow;
139
+ record.arrow = {
140
+ start: [roundTo(start.x, 3), roundTo(start.y, 3)],
141
+ end: [roundTo(end.x, 3), roundTo(end.y, 3)],
142
+ bend: roundTo(bend, 3),
143
+ // What its ends are tied to, written only for an end that is tied: a board of free arrows is the text it always was.
144
+ ...(startBinding ? { startBinding: writeArrowBinding(startBinding) } : {}),
145
+ ...(endBinding ? { endBinding: writeArrowBinding(endBinding) } : {})
146
+ };
134
147
  }
135
148
  else
136
149
  delete record.arrow;
@@ -138,28 +151,23 @@ function serializeObject(object, options) {
138
151
  return record;
139
152
  }
140
153
  /** The document for a board, as a plain object (the form `serializeCanvasDocument` writes). */
141
- export function createCanvasDocument(scene, viewport, options) {
142
- var _a;
143
- if (options === void 0) { options = {}; }
154
+ export function createCanvasDocument(scene, viewport, options = {}) {
144
155
  return {
145
156
  version: CANVAS_DOCUMENT_VERSION,
146
- savedAt: ((_a = options.now) !== null && _a !== void 0 ? _a : new Date()).toISOString(),
157
+ savedAt: (options.now ?? new Date()).toISOString(),
147
158
  viewport: { x: roundTo(viewport.x, 2), y: roundTo(viewport.y, 2), zoom: roundTo(viewport.zoom, 4) },
148
- canvas: { objects: scene.map(function (object) { return serializeObject(object, options); }) }
159
+ canvas: { objects: scene.map((object) => serializeObject(object, options)) }
149
160
  };
150
161
  }
151
162
  /** The text a board is saved as. */
152
- export function serializeCanvasDocument(scene, viewport, options) {
153
- if (options === void 0) { options = {}; }
163
+ export function serializeCanvasDocument(scene, viewport, options = {}) {
154
164
  return JSON.stringify(createCanvasDocument(scene, viewport, options));
155
165
  }
156
166
  function isRecord(value) {
157
167
  return typeof value === 'object' && value !== null && !Array.isArray(value);
158
168
  }
159
- function readNumber(value, fallback, minimum, maximum) {
160
- if (minimum === void 0) { minimum = -Infinity; }
161
- if (maximum === void 0) { maximum = Infinity; }
162
- var number = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : NaN;
169
+ function readNumber(value, fallback, minimum = -Infinity, maximum = Infinity) {
170
+ const number = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : NaN;
163
171
  if (!Number.isFinite(number))
164
172
  return fallback;
165
173
  return clampNumber(number, minimum, maximum);
@@ -167,36 +175,34 @@ function readNumber(value, fallback, minimum, maximum) {
167
175
  function readBoolean(value, fallback) {
168
176
  return typeof value === 'boolean' ? value : fallback;
169
177
  }
170
- function readString(value, fallback, maximumLength) {
171
- if (maximumLength === void 0) { maximumLength = 1000; }
178
+ function readString(value, fallback, maximumLength = 1000) {
172
179
  return typeof value === 'string' ? value.slice(0, maximumLength) : fallback;
173
180
  }
174
- function readNullableString(value, maximumLength) {
175
- if (maximumLength === void 0) { maximumLength = 1000; }
181
+ function readNullableString(value, maximumLength = 1000) {
176
182
  return typeof value === 'string' && value !== '' ? value.slice(0, maximumLength) : null;
177
183
  }
178
184
  function readOneOf(value, allowed, fallback) {
179
185
  return typeof value === 'string' && allowed.includes(value) ? value : fallback;
180
186
  }
181
187
  /** A hex, `rgb()`, `hsl()` or named colour: nothing that could carry more than a colour into CSS or SVG. */
182
- var COLOR_PATTERN = /^(#[0-9a-f]{3,8}|(?:rgb|hsl)a?\([0-9a-z\s.,%/+-]{1,80}\)|[a-z]{3,30})$/i;
188
+ const COLOR_PATTERN = /^(#[0-9a-f]{3,8}|(?:rgb|hsl)a?\([0-9a-z\s.,%/+-]{1,80}\)|[a-z]{3,30})$/i;
183
189
  export function readColor(value, fallback) {
184
190
  return typeof value === 'string' && COLOR_PATTERN.test(value.trim()) ? value.trim() : fallback;
185
191
  }
186
- var FONT_FAMILY_PATTERN = /^[\p{L}\p{N}\s,'"\-_.]{1,200}$/u;
192
+ const FONT_FAMILY_PATTERN = /^[\p{L}\p{N}\s,'"\-_.]{1,200}$/u;
187
193
  function readFontFamily(value) {
188
194
  return typeof value === 'string' && FONT_FAMILY_PATTERN.test(value) ? value : TEXT_DEFAULTS.fontFamily;
189
195
  }
190
- var IMAGE_ADDRESS_PATTERN = /^(?:data:image\/[a-z0-9.+-]+[;,]|https?:\/\/|blob:|\/(?!\/))/i;
196
+ const IMAGE_ADDRESS_PATTERN = /^(?:data:image\/[a-z0-9.+-]+[;,]|https?:\/\/|blob:|\/(?!\/))/i;
191
197
  /** An image address the browser may load into an `<img>`: inline bytes, http(s), a blob or a path of this site. */
192
198
  export function readImageAddress(value) {
193
199
  if (typeof value !== 'string' || value === '')
194
200
  return null;
195
201
  return IMAGE_ADDRESS_PATTERN.test(value) ? value : null;
196
202
  }
197
- var STROKE_STYLES = ['solid', 'dashed', 'dotted'];
198
- var LINE_CAPS = ['butt', 'round', 'square'];
199
- var LINE_JOINS = ['miter', 'round', 'bevel'];
203
+ const STROKE_STYLES = ['solid', 'dashed', 'dotted'];
204
+ const LINE_CAPS = ['butt', 'round', 'square'];
205
+ const LINE_JOINS = ['miter', 'round', 'bevel'];
200
206
  function readBox(raw) {
201
207
  return {
202
208
  x: readNumber(raw.x, 0, -MAX_COORDINATE, MAX_COORDINATE),
@@ -216,9 +222,9 @@ function readPaint(raw, defaults) {
216
222
  strokeStyle: readOneOf(raw.strokeStyle, STROKE_STYLES, 'solid')
217
223
  };
218
224
  }
219
- var PAINT_FALLBACK = { fill: '#ffffff', stroke: '#374151', strokeWidth: 2 };
225
+ const PAINT_FALLBACK = { fill: '#ffffff', stroke: '#374151', strokeWidth: 2 };
220
226
  function readId(raw, seen) {
221
- var id = typeof raw.id === 'string' && raw.id !== '' && raw.id.length <= 128 ? raw.id : createObjectId();
227
+ let id = typeof raw.id === 'string' && raw.id !== '' && raw.id.length <= 128 ? raw.id : createObjectId();
222
228
  // Two objects with the same id would be one on the board: the second gets a new one.
223
229
  while (seen.has(id))
224
230
  id = createObjectId();
@@ -229,19 +235,30 @@ function readParentId(raw) {
229
235
  return typeof raw.parentId === 'string' && raw.parentId !== '' && raw.parentId.length <= 128 ? raw.parentId : null;
230
236
  }
231
237
  function readRect(raw, id) {
232
- return createRectObject(__assign(__assign(__assign({ id: id, parentId: readParentId(raw) }, readBox(raw)), readPaint(raw, PAINT_FALLBACK)), { roundness: readNumber(raw.roundness, 0, 0, 100) }));
238
+ return createRectObject({
239
+ id,
240
+ parentId: readParentId(raw),
241
+ ...readBox(raw),
242
+ ...readPaint(raw, PAINT_FALLBACK),
243
+ roundness: readNumber(raw.roundness, 0, 0, 100)
244
+ });
233
245
  }
234
246
  function readEllipse(raw, id) {
235
- return createEllipseObject(__assign(__assign(__assign({ id: id, parentId: readParentId(raw) }, readBox(raw)), readPaint(raw, PAINT_FALLBACK)), { aspectLocked: readBoolean(raw.aspectLocked, false) }));
247
+ return createEllipseObject({
248
+ id,
249
+ parentId: readParentId(raw),
250
+ ...readBox(raw),
251
+ ...readPaint(raw, PAINT_FALLBACK),
252
+ aspectLocked: readBoolean(raw.aspectLocked, false)
253
+ });
236
254
  }
237
- var BRUSH_PRESSURES = ['pen', 'speed'];
255
+ const BRUSH_PRESSURES = ['pen', 'speed'];
238
256
  /** The line of a brush stroke, or null when there is none to draw: points that are not numbers are dropped, and a long line is cut. */
239
257
  function readInk(value) {
240
258
  if (!isRecord(value) || !Array.isArray(value.points))
241
259
  return null;
242
- var points = [];
243
- for (var _i = 0, _a = value.points.slice(0, BRUSH_MAX_POINTS); _i < _a.length; _i++) {
244
- var entry = _a[_i];
260
+ const points = [];
261
+ for (const entry of value.points.slice(0, BRUSH_MAX_POINTS)) {
245
262
  if (!Array.isArray(entry) || typeof entry[0] !== 'number' || typeof entry[1] !== 'number')
246
263
  continue;
247
264
  if (!Number.isFinite(entry[0]) || !Number.isFinite(entry[1]))
@@ -254,24 +271,24 @@ function readInk(value) {
254
271
  }
255
272
  if (points.length === 0)
256
273
  return null;
257
- return { points: points, pressure: readOneOf(value.pressure, BRUSH_PRESSURES, 'speed') };
274
+ return { points, pressure: readOneOf(value.pressure, BRUSH_PRESSURES, 'speed') };
258
275
  }
259
276
  /** The two ends and the bend of an arrow, or null when the record has none that can be read. */
260
277
  function readArrowSpec(value) {
261
278
  if (!isRecord(value))
262
279
  return null;
263
- var readPoint = function (entry) {
280
+ const readPoint = (entry) => {
264
281
  if (!Array.isArray(entry) || typeof entry[0] !== 'number' || typeof entry[1] !== 'number')
265
282
  return null;
266
283
  if (!Number.isFinite(entry[0]) || !Number.isFinite(entry[1]))
267
284
  return null;
268
285
  return { x: clampNumber(entry[0], -MAX_COORDINATE, MAX_COORDINATE), y: clampNumber(entry[1], -MAX_COORDINATE, MAX_COORDINATE) };
269
286
  };
270
- var start = readPoint(value.start);
271
- var end = readPoint(value.end);
287
+ const start = readPoint(value.start);
288
+ const end = readPoint(value.end);
272
289
  if (!start || !end)
273
290
  return null;
274
- return withBindings({ start: start, end: end, bend: readNumber(value.bend, 0, -2 * MAX_SIZE, 2 * MAX_SIZE) }, { startBinding: readArrowBinding(value.startBinding), endBinding: readArrowBinding(value.endBinding) });
291
+ return withBindings({ start, end, bend: readNumber(value.bend, 0, -2 * MAX_SIZE, 2 * MAX_SIZE) }, { startBinding: readArrowBinding(value.startBinding), endBinding: readArrowBinding(value.endBinding) });
275
292
  }
276
293
  /**
277
294
  * What an end of an arrow is tied to, or null when the record says nothing that can be read: a shape (by its id), and for a point of
@@ -280,17 +297,17 @@ function readArrowSpec(value) {
280
297
  function readArrowBinding(value) {
281
298
  if (!isRecord(value))
282
299
  return null;
283
- var targetId = typeof value.target === 'string' && value.target !== '' && value.target.length <= 128 ? value.target : null;
300
+ const targetId = typeof value.target === 'string' && value.target !== '' && value.target.length <= 128 ? value.target : null;
284
301
  if (!targetId)
285
302
  return null;
286
303
  if (value.kind === 'center')
287
- return { targetId: targetId, kind: 'center' };
304
+ return { targetId, kind: 'center' };
288
305
  if (value.kind !== 'edge' || !Array.isArray(value.anchor))
289
306
  return null;
290
- var _a = value.anchor, across = _a[0], down = _a[1];
307
+ const [across, down] = value.anchor;
291
308
  if (typeof across !== 'number' || typeof down !== 'number' || !Number.isFinite(across) || !Number.isFinite(down))
292
309
  return null;
293
- return { targetId: targetId, kind: 'edge', anchor: { x: clampNumber(across, 0, 1), y: clampNumber(down, 0, 1) } };
310
+ return { targetId, kind: 'edge', anchor: { x: clampNumber(across, 0, 1), y: clampNumber(down, 0, 1) } };
294
311
  }
295
312
  /**
296
313
  * An arrow drawn from its points. They are in the coordinates of the saved box, which is kept as it is when it holds what is drawn
@@ -298,57 +315,56 @@ function readArrowBinding(value) {
298
315
  * where it was in the world. An arrow is upright: a turn the record carries is applied to its points.
299
316
  */
300
317
  function arrowFromSpec(spec, box, strokeWidth) {
301
- var _a, _b;
302
- var start = spec.start, end = spec.end;
318
+ let { start, end } = spec;
303
319
  // What its ends are tied to is not a place on the board: it needs no turn.
304
- var tiesOfSpec = { startBinding: (_a = spec.startBinding) !== null && _a !== void 0 ? _a : null, endBinding: (_b = spec.endBinding) !== null && _b !== void 0 ? _b : null };
320
+ const tiesOfSpec = { startBinding: spec.startBinding ?? null, endBinding: spec.endBinding ?? null };
305
321
  if (box.rotation !== 0) {
306
- var radians = degreesToRadians(box.rotation);
307
- var cosine_1 = Math.cos(radians);
308
- var sine_1 = Math.sin(radians);
309
- var centerX_1 = box.width / 2;
310
- var centerY_1 = box.height / 2;
311
- var turn = function (point) { return ({
312
- x: centerX_1 + (point.x - centerX_1) * cosine_1 - (point.y - centerY_1) * sine_1,
313
- y: centerY_1 + (point.x - centerX_1) * sine_1 + (point.y - centerY_1) * cosine_1
314
- }); };
322
+ const radians = degreesToRadians(box.rotation);
323
+ const cosine = Math.cos(radians);
324
+ const sine = Math.sin(radians);
325
+ const centerX = box.width / 2;
326
+ const centerY = box.height / 2;
327
+ const turn = (point) => ({
328
+ x: centerX + (point.x - centerX) * cosine - (point.y - centerY) * sine,
329
+ y: centerY + (point.x - centerX) * sine + (point.y - centerY) * cosine
330
+ });
315
331
  start = turn(start);
316
332
  end = turn(end);
317
333
  }
318
- var geometry = buildArrow(start, end, spec.bend, strokeWidth);
319
- var holdsWhatIsDrawn = box.rotation === 0 &&
334
+ const geometry = buildArrow(start, end, spec.bend, strokeWidth);
335
+ const holdsWhatIsDrawn = box.rotation === 0 &&
320
336
  Math.abs(geometry.box.x) <= 0.5 &&
321
337
  Math.abs(geometry.box.y) <= 0.5 &&
322
338
  Math.abs(geometry.box.width - box.width) <= 0.5 &&
323
339
  Math.abs(geometry.box.height - box.height) <= 0.5;
324
340
  if (holdsWhatIsDrawn) {
325
341
  // In the frame of the points, which is the frame of the saved box: the path comes back in the frame of its own bounds.
326
- var commands = translatePathCommands(geometry.commands, geometry.box.x, geometry.box.y);
327
- return { d: serializePathData(commands), arrow: withBindings({ start: start, end: end, bend: geometry.spec.bend }, tiesOfSpec), box: box };
342
+ const commands = translatePathCommands(geometry.commands, geometry.box.x, geometry.box.y);
343
+ return { d: serializePathData(commands), arrow: withBindings({ start, end, bend: geometry.spec.bend }, tiesOfSpec), box };
328
344
  }
329
345
  return {
330
346
  d: serializePathData(geometry.commands),
331
347
  arrow: withBindings(geometry.spec, tiesOfSpec),
332
- box: __assign(__assign({}, box), { rotation: 0, x: box.x + geometry.box.x, y: box.y + geometry.box.y, width: geometry.box.width, height: geometry.box.height })
348
+ box: { ...box, rotation: 0, x: box.x + geometry.box.x, y: box.y + geometry.box.y, width: geometry.box.width, height: geometry.box.height }
333
349
  };
334
350
  }
335
351
  function readPath(raw, id, index, warnings) {
336
- var paint = readPaint(raw, { fill: 'transparent', stroke: '#1f2937', strokeWidth: 3 });
337
- var ink = readInk(raw.ink);
338
- var shape = readNullableString(raw.shape, 100);
339
- var box = readBox(raw);
352
+ const paint = readPaint(raw, { fill: 'transparent', stroke: '#1f2937', strokeWidth: 3 });
353
+ const ink = readInk(raw.ink);
354
+ const shape = readNullableString(raw.shape, 100);
355
+ let box = readBox(raw);
340
356
  // An arrow has no outline of its own in the file either: it is drawn from its points. A board saved before arrows had points
341
357
  // has the outline only, and its arrow is found in that.
342
- var arrowSpec = ink ? null : readArrowSpec(raw.arrow);
358
+ let arrowSpec = ink ? null : readArrowSpec(raw.arrow);
343
359
  if (!ink && !arrowSpec && shape === 'arrow' && typeof raw.d === 'string' && raw.d.length <= MAX_PATH_DATA_LENGTH) {
344
- var legacy = arrowPointsOfLegacyPath(parsePathData(raw.d));
360
+ const legacy = arrowPointsOfLegacyPath(parsePathData(raw.d));
345
361
  if (legacy)
346
- arrowSpec = __assign(__assign({}, legacy), { bend: 0 });
362
+ arrowSpec = { ...legacy, bend: 0 };
347
363
  }
348
- var arrow = null;
349
- var d;
364
+ let arrow = null;
365
+ let d;
350
366
  if (arrowSpec) {
351
- var drawn = arrowFromSpec(arrowSpec, box, paint.strokeWidth);
367
+ const drawn = arrowFromSpec(arrowSpec, box, paint.strokeWidth);
352
368
  d = drawn.d;
353
369
  arrow = drawn.arrow;
354
370
  box = drawn.box;
@@ -358,45 +374,93 @@ function readPath(raw, id, index, warnings) {
358
374
  d = ink ? brushOutlineData(ink, paint.strokeWidth) : typeof raw.d === 'string' ? raw.d : '';
359
375
  }
360
376
  if (d.length === 0 || d.length > MAX_PATH_DATA_LENGTH || parsePathData(d).length < 2) {
361
- warnings.push({ code: 'bad-path', index: index, detail: 'The outline of the shape is missing or cannot be read.' });
377
+ warnings.push({ code: 'bad-path', index, detail: 'The outline of the shape is missing or cannot be read.' });
362
378
  return null;
363
379
  }
364
- return createPathObject(__assign(__assign(__assign({ id: id, parentId: readParentId(raw) }, box), paint), { d: d, shape: shape, roundness: readNumber(raw.roundness, 0, 0, 100), aspectLocked: readBoolean(raw.aspectLocked, false), flipX: readBoolean(raw.flipX, false), flipY: readBoolean(raw.flipY, false), lineCap: readOneOf(raw.lineCap, LINE_CAPS, 'round'), lineJoin: readOneOf(raw.lineJoin, LINE_JOINS, 'round'), ink: ink, arrow: arrow }));
380
+ return createPathObject({
381
+ id,
382
+ parentId: readParentId(raw),
383
+ ...box,
384
+ ...paint,
385
+ d,
386
+ shape,
387
+ roundness: readNumber(raw.roundness, 0, 0, 100),
388
+ aspectLocked: readBoolean(raw.aspectLocked, false),
389
+ flipX: readBoolean(raw.flipX, false),
390
+ flipY: readBoolean(raw.flipY, false),
391
+ lineCap: readOneOf(raw.lineCap, LINE_CAPS, 'round'),
392
+ lineJoin: readOneOf(raw.lineJoin, LINE_JOINS, 'round'),
393
+ ink,
394
+ arrow
395
+ });
365
396
  }
366
397
  function readText(raw, id) {
367
- return createTextObject(__assign(__assign({ id: id, parentId: readParentId(raw) }, readBox(raw)), { text: readString(raw.text, '', MAX_TEXT_LENGTH), color: readColor(raw.color, TEXT_DEFAULTS.color), fontSize: readNumber(raw.fontSize, TEXT_DEFAULTS.fontSize, 4, 600), fontFamily: readFontFamily(raw.fontFamily), fontWeight: readOneOf(raw.fontWeight, ['normal', 'bold'], 'normal'), fontStyle: readOneOf(raw.fontStyle, ['normal', 'italic'], 'normal'), underline: readBoolean(raw.underline, false), align: readOneOf(raw.align, ['left', 'center', 'right'], 'left'), lineHeight: readNumber(raw.lineHeight, 1.2, 0.5, 4), padding: readNumber(raw.padding, 0, 0, 200), backgroundColor: readColor(raw.backgroundColor, 'transparent'), autoWidth: readBoolean(raw.autoWidth, true) }));
398
+ return createTextObject({
399
+ id,
400
+ parentId: readParentId(raw),
401
+ ...readBox(raw),
402
+ text: readString(raw.text, '', MAX_TEXT_LENGTH),
403
+ color: readColor(raw.color, TEXT_DEFAULTS.color),
404
+ fontSize: readNumber(raw.fontSize, TEXT_DEFAULTS.fontSize, 4, 600),
405
+ fontFamily: readFontFamily(raw.fontFamily),
406
+ fontWeight: readOneOf(raw.fontWeight, ['normal', 'bold'], 'normal'),
407
+ fontStyle: readOneOf(raw.fontStyle, ['normal', 'italic'], 'normal'),
408
+ underline: readBoolean(raw.underline, false),
409
+ align: readOneOf(raw.align, ['left', 'center', 'right'], 'left'),
410
+ lineHeight: readNumber(raw.lineHeight, 1.2, 0.5, 4),
411
+ padding: readNumber(raw.padding, 0, 0, 200),
412
+ backgroundColor: readColor(raw.backgroundColor, 'transparent'),
413
+ autoWidth: readBoolean(raw.autoWidth, true)
414
+ });
368
415
  }
369
416
  function readImage(raw, id) {
370
- return createImageObject(__assign(__assign({ id: id, parentId: readParentId(raw) }, readBox(raw)), { src: readImageAddress(raw.src), imageRef: readNullableString(raw.imageRef, 200), fileName: readNullableString(raw.fileName, 300), naturalWidth: readNumber(raw.naturalWidth, 0, 0, MAX_SIZE), naturalHeight: readNumber(raw.naturalHeight, 0, 0, MAX_SIZE) }));
417
+ return createImageObject({
418
+ id,
419
+ parentId: readParentId(raw),
420
+ ...readBox(raw),
421
+ src: readImageAddress(raw.src),
422
+ imageRef: readNullableString(raw.imageRef, 200),
423
+ fileName: readNullableString(raw.fileName, 300),
424
+ naturalWidth: readNumber(raw.naturalWidth, 0, 0, MAX_SIZE),
425
+ naturalHeight: readNumber(raw.naturalHeight, 0, 0, MAX_SIZE)
426
+ });
371
427
  }
372
428
  function readWidget(raw, id, index, warnings) {
373
- var _a;
374
429
  // The creator reads `_widgetId`; the canvas's own key is `widgetId`. Either names the widget.
375
- var widgetId = (_a = readNullableString(raw.widgetId, 200)) !== null && _a !== void 0 ? _a : readNullableString(raw[HOST_READABLE_KEYS.widgetId], 200);
430
+ const widgetId = readNullableString(raw.widgetId, 200) ?? readNullableString(raw[HOST_READABLE_KEYS.widgetId], 200);
376
431
  if (!widgetId) {
377
- warnings.push({ code: 'bad-object', index: index, detail: 'A widget card has no widget id.' });
432
+ warnings.push({ code: 'bad-object', index, detail: 'A widget card has no widget id.' });
378
433
  return null;
379
434
  }
380
- return createWidgetObject(__assign(__assign({ id: id, widgetId: widgetId, parentId: readParentId(raw) }, readBox(raw)), { widgetName: readNullableString(raw.widgetName, 300), isPrimary: readBoolean(raw.isPrimary, false), thumbnail: readImageAddress(raw.thumbnail), thumbnailRef: readNullableString(raw.thumbnailRef, 200) }));
435
+ return createWidgetObject({
436
+ id,
437
+ widgetId,
438
+ parentId: readParentId(raw),
439
+ ...readBox(raw),
440
+ widgetName: readNullableString(raw.widgetName, 300),
441
+ isPrimary: readBoolean(raw.isPrimary, false),
442
+ thumbnail: readImageAddress(raw.thumbnail),
443
+ thumbnailRef: readNullableString(raw.thumbnailRef, 200)
444
+ });
381
445
  }
382
446
  function readGroup(raw, id) {
383
- return createGroupObject({ id: id, parentId: readParentId(raw) });
447
+ return createGroupObject({ id, parentId: readParentId(raw) });
384
448
  }
385
449
  function readObject(raw, index, seen, warnings) {
386
450
  if (!isRecord(raw)) {
387
- warnings.push({ code: 'bad-object', index: index, detail: 'An entry of the list is not an object.' });
451
+ warnings.push({ code: 'bad-object', index, detail: 'An entry of the list is not an object.' });
388
452
  return null;
389
453
  }
390
454
  // Readers outside the canvas treat these as "not there": so does the canvas.
391
455
  if (raw[HOST_READABLE_KEYS.visible] === false || raw[HOST_READABLE_KEYS.excludeFromExport] === true)
392
456
  return null;
393
- var type = raw[HOST_READABLE_KEYS.objectType];
394
- var known = ['rect', 'ellipse', 'path', 'text', 'image', 'widget', 'group'];
457
+ const type = raw[HOST_READABLE_KEYS.objectType];
458
+ const known = ['rect', 'ellipse', 'path', 'text', 'image', 'widget', 'group'];
395
459
  if (typeof type !== 'string' || !known.includes(type)) {
396
- warnings.push({ code: 'unknown-type', index: index, detail: typeof type === 'string' ? type : String(type) });
460
+ warnings.push({ code: 'unknown-type', index, detail: typeof type === 'string' ? type : String(type) });
397
461
  return null;
398
462
  }
399
- var id = readId(raw, seen);
463
+ const id = readId(raw, seen);
400
464
  switch (type) {
401
465
  case 'rect':
402
466
  return readRect(raw, id);
@@ -414,28 +478,27 @@ function readObject(raw, index, seen, warnings) {
414
478
  return readGroup(raw, id);
415
479
  }
416
480
  }
417
- var EMPTY_VIEWPORT = { x: 0, y: 0, zoom: 1 };
481
+ const EMPTY_VIEWPORT = { x: 0, y: 0, zoom: 1 };
418
482
  /**
419
483
  * Reads a saved canvas: the text `serializeCanvasDocument` wrote, or the same thing already parsed.
420
484
  * Never throws.
421
485
  */
422
486
  export function parseCanvasDocument(input) {
423
- var _a;
424
- var warnings = [];
425
- var nothing = function (status) { return ({
487
+ const warnings = [];
488
+ const nothing = (status) => ({
426
489
  scene: [],
427
- viewport: __assign({}, EMPTY_VIEWPORT),
428
- status: status,
429
- warnings: warnings
430
- }); };
490
+ viewport: { ...EMPTY_VIEWPORT },
491
+ status,
492
+ warnings
493
+ });
431
494
  if (input === null || input === undefined || (typeof input === 'string' && input.trim() === ''))
432
495
  return nothing('empty');
433
- var document = input;
496
+ let document = input;
434
497
  if (typeof input === 'string') {
435
498
  try {
436
499
  document = JSON.parse(input);
437
500
  }
438
- catch (_b) {
501
+ catch {
439
502
  warnings.push({ code: 'not-json' });
440
503
  return nothing('invalid');
441
504
  }
@@ -445,19 +508,19 @@ export function parseCanvasDocument(input) {
445
508
  return nothing('invalid');
446
509
  }
447
510
  if (document.version !== CANVAS_DOCUMENT_VERSION) {
448
- warnings.push({ code: 'unsupported-version', detail: String((_a = document.version) !== null && _a !== void 0 ? _a : 'none') });
511
+ warnings.push({ code: 'unsupported-version', detail: String(document.version ?? 'none') });
449
512
  return nothing('unsupported');
450
513
  }
451
- var canvas = document.canvas;
452
- var list = isRecord(canvas) && Array.isArray(canvas.objects) ? canvas.objects : [];
453
- var limited = list.length > MAX_OBJECTS_PER_DOCUMENT ? list.slice(0, MAX_OBJECTS_PER_DOCUMENT) : list;
514
+ const canvas = document.canvas;
515
+ const list = isRecord(canvas) && Array.isArray(canvas.objects) ? canvas.objects : [];
516
+ const limited = list.length > MAX_OBJECTS_PER_DOCUMENT ? list.slice(0, MAX_OBJECTS_PER_DOCUMENT) : list;
454
517
  if (limited.length < list.length) {
455
- warnings.push({ code: 'too-many-objects', detail: "".concat(list.length, " objects, the first ").concat(limited.length, " were read.") });
518
+ warnings.push({ code: 'too-many-objects', detail: `${list.length} objects, the first ${limited.length} were read.` });
456
519
  }
457
- var seen = new Set();
458
- var objects = [];
459
- limited.forEach(function (raw, index) {
460
- var object = readObject(raw, index, seen, warnings);
520
+ const seen = new Set();
521
+ const objects = [];
522
+ limited.forEach((raw, index) => {
523
+ const object = readObject(raw, index, seen, warnings);
461
524
  if (object)
462
525
  objects.push(object);
463
526
  });
@@ -466,6 +529,6 @@ export function parseCanvasDocument(input) {
466
529
  scene: dropDanglingBindings(normalizeScene(objects)),
467
530
  viewport: sanitizeViewport(document.viewport),
468
531
  status: 'ok',
469
- warnings: warnings
532
+ warnings
470
533
  };
471
534
  }
@@ -9,7 +9,7 @@
9
9
  * accepts them, and `tests/engine/codec.test.mjs` fails if either changes. Every other key of the format
10
10
  * is the canvas's own and can change with a version.
11
11
  */
12
- export var HOST_READABLE_KEYS = Object.freeze({
12
+ export const HOST_READABLE_KEYS = Object.freeze({
13
13
  /** `document.canvas.objects`: always an array. Readers fall back to `document.objects` for a bare list. */
14
14
  documentObjects: Object.freeze(['canvas', 'objects']),
15
15
  /** The kind of an object: a string. */