kritzel-stencil 0.1.78 → 0.1.80

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 (163) hide show
  1. package/dist/cjs/{index-BRZ6e6oa.js → index-CFnj_FXt.js} +36 -9
  2. package/dist/cjs/index.cjs.js +1 -1
  3. package/dist/cjs/kritzel-active-users_42.cjs.entry.js +333 -177
  4. package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/stencil.cjs.js +3 -3
  7. package/dist/cjs/{workspace.migrations-sUPrO23c.js → workspace.migrations-DUXtSb7C.js} +244 -197
  8. package/dist/collection/classes/core/core.class.js +39 -31
  9. package/dist/collection/classes/core/store.class.js +57 -16
  10. package/dist/collection/classes/core/viewport.class.js +12 -12
  11. package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
  12. package/dist/collection/classes/handlers/line-handle.handler.js +7 -4
  13. package/dist/collection/classes/handlers/move.handler.js +11 -8
  14. package/dist/collection/classes/handlers/resize.handler.js +12 -3
  15. package/dist/collection/classes/handlers/rotation.handler.js +12 -3
  16. package/dist/collection/classes/handlers/selection.handler.js +20 -15
  17. package/dist/collection/classes/managers/anchor.manager.js +4 -4
  18. package/dist/collection/classes/objects/base-object.class.js +6 -6
  19. package/dist/collection/classes/objects/custom-element.class.js +2 -2
  20. package/dist/collection/classes/objects/group.class.js +10 -10
  21. package/dist/collection/classes/objects/image.class.js +2 -2
  22. package/dist/collection/classes/objects/line.class.js +7 -7
  23. package/dist/collection/classes/objects/path.class.js +5 -5
  24. package/dist/collection/classes/objects/selection-box.class.js +1 -1
  25. package/dist/collection/classes/objects/selection-group.class.js +16 -16
  26. package/dist/collection/classes/objects/shape.class.js +37 -31
  27. package/dist/collection/classes/objects/text.class.js +40 -32
  28. package/dist/collection/classes/structures/app-state-map.structure.js +18 -16
  29. package/dist/collection/classes/structures/object-map.structure.js +30 -27
  30. package/dist/collection/classes/tools/brush-tool.class.js +14 -14
  31. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  32. package/dist/collection/classes/tools/line-tool.class.js +14 -14
  33. package/dist/collection/classes/tools/selection-tool.class.js +2 -2
  34. package/dist/collection/classes/tools/shape-tool.class.js +6 -6
  35. package/dist/collection/classes/tools/text-tool.class.js +2 -2
  36. package/dist/collection/collection-manifest.json +1 -1
  37. package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.js +6 -6
  38. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +2 -2
  39. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +70 -11
  40. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -1
  41. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +159 -60
  42. package/dist/collection/configs/default-engine-config.js +2 -2
  43. package/dist/collection/constants/version.js +1 -1
  44. package/dist/collection/helpers/keyboard.helper.js +15 -11
  45. package/dist/components/index.js +1 -1
  46. package/dist/components/kritzel-active-users.js +1 -1
  47. package/dist/components/kritzel-avatar.js +1 -1
  48. package/dist/components/kritzel-awareness-cursors.js +1 -1
  49. package/dist/components/kritzel-back-to-content.js +1 -1
  50. package/dist/components/kritzel-brush-style.js +1 -1
  51. package/dist/components/kritzel-button.js +1 -1
  52. package/dist/components/kritzel-color-palette.js +1 -1
  53. package/dist/components/kritzel-color.js +1 -1
  54. package/dist/components/kritzel-context-menu.js +1 -1
  55. package/dist/components/kritzel-controls.js +1 -1
  56. package/dist/components/kritzel-current-user-dialog.js +1 -1
  57. package/dist/components/kritzel-current-user.js +1 -1
  58. package/dist/components/kritzel-cursor-trail.js +1 -1
  59. package/dist/components/kritzel-dialog.js +1 -1
  60. package/dist/components/kritzel-dropdown.js +1 -1
  61. package/dist/components/kritzel-editor.js +1 -1
  62. package/dist/components/kritzel-engine.js +1 -1
  63. package/dist/components/kritzel-export.js +1 -1
  64. package/dist/components/kritzel-font-family.js +1 -1
  65. package/dist/components/kritzel-font-size.js +1 -1
  66. package/dist/components/kritzel-font.js +1 -1
  67. package/dist/components/kritzel-icon.js +1 -1
  68. package/dist/components/kritzel-input.js +1 -1
  69. package/dist/components/kritzel-line-endings.js +1 -1
  70. package/dist/components/kritzel-login-dialog.js +1 -1
  71. package/dist/components/kritzel-master-detail.js +1 -1
  72. package/dist/components/kritzel-menu-item.js +1 -1
  73. package/dist/components/kritzel-menu.js +1 -1
  74. package/dist/components/kritzel-more-menu.js +1 -1
  75. package/dist/components/kritzel-numeric-input.js +1 -1
  76. package/dist/components/kritzel-opacity-slider.js +1 -1
  77. package/dist/components/kritzel-pill-tabs.js +1 -1
  78. package/dist/components/kritzel-portal.js +1 -1
  79. package/dist/components/kritzel-settings.js +1 -1
  80. package/dist/components/kritzel-shape-fill.js +1 -1
  81. package/dist/components/kritzel-share-dialog.js +1 -1
  82. package/dist/components/kritzel-slide-toggle.js +1 -1
  83. package/dist/components/kritzel-split-button.js +1 -1
  84. package/dist/components/kritzel-stroke-size.js +1 -1
  85. package/dist/components/kritzel-tool-config.js +1 -1
  86. package/dist/components/kritzel-tooltip.js +1 -1
  87. package/dist/components/kritzel-utility-panel.js +1 -1
  88. package/dist/components/kritzel-workspace-manager.js +1 -1
  89. package/dist/components/{p-Md9Y-b3d.js → p-1ppb4M65.js} +1 -1
  90. package/dist/components/{p-KJ4dHzrS.js → p-7yR-sKH8.js} +1 -1
  91. package/dist/components/{p-CN8IxBlU.js → p-B-Gej_Ak.js} +1 -1
  92. package/dist/components/{p-76W5pG2O.js → p-B4F19Aqj.js} +1 -1
  93. package/dist/components/{p-BuI6Gkzg.js → p-B5WII1Lk.js} +1 -1
  94. package/dist/components/p-BWj1eE2b.js +1 -0
  95. package/dist/components/{p-ZC5YELQJ.js → p-BZ8bK8qT.js} +1 -1
  96. package/dist/components/{p-DkWWzVg8.js → p-BaaFG0p-.js} +1 -1
  97. package/dist/components/{p-6NFl6EB2.js → p-Bat829Bg.js} +1 -1
  98. package/dist/components/p-BcwZ36sO.js +1 -0
  99. package/dist/components/{p-53di1Zko.js → p-BjPmEs5A.js} +1 -1
  100. package/dist/components/{p-D5IhryUR.js → p-Brwz_Dpb.js} +1 -1
  101. package/dist/components/p-BzQmBVwr.js +9 -0
  102. package/dist/components/{p-C2l9mZ1P.js → p-C-MtTi6x.js} +1 -1
  103. package/dist/components/p-C8WnYSHi.js +1 -0
  104. package/dist/components/{p-BLsH_Oi0.js → p-C9zsWWH2.js} +1 -1
  105. package/dist/components/{p-ZQ2bKafG.js → p-CJKsuQun.js} +1 -1
  106. package/dist/components/{p-m1nVDC3G.js → p-CJzg_ejc.js} +1 -1
  107. package/dist/components/{p-Dte67BWd.js → p-CM7rYf9A.js} +1 -1
  108. package/dist/components/{p-Dr3-pKVg.js → p-CMGHx71q.js} +1 -1
  109. package/dist/components/{p-CI9Nbh-x.js → p-CNMpVlot.js} +1 -1
  110. package/dist/components/{p-DDKjsXCe.js → p-CS7r-zhx.js} +1 -1
  111. package/dist/components/{p-DaGZEV0R.js → p-C_fSm7T4.js} +1 -1
  112. package/dist/components/{p-Ck1dhpUQ.js → p-CfEGaTaV.js} +1 -1
  113. package/dist/components/{p-CWMFGEe0.js → p-CvyE2Wg-.js} +1 -1
  114. package/dist/components/{p-D3pNw-SV.js → p-D5BXoK9m.js} +1 -1
  115. package/dist/components/{p-DV7Z_qfa.js → p-D7pwbRUy.js} +1 -1
  116. package/dist/components/{p-CBslLN3-.js → p-DCH4Rlqx.js} +1 -1
  117. package/dist/components/{p-CYh7yV-K.js → p-DEOUiiyI.js} +1 -1
  118. package/dist/components/{p-pCC6t6BH.js → p-DKeBfe_l.js} +1 -1
  119. package/dist/components/{p-DWsCbu01.js → p-DUQmBcTy.js} +1 -1
  120. package/dist/components/{p-D14QNK3X.js → p-DUnKjQN7.js} +1 -1
  121. package/dist/components/{p-BrZ_gL8Q.js → p-DYcsC2zO.js} +1 -1
  122. package/dist/components/{p-D7yzmu1l.js → p-DkT0KZCm.js} +1 -1
  123. package/dist/components/{p-Cns7qSKS.js → p-DrsORMoT.js} +1 -1
  124. package/dist/components/{p-BueaqfA2.js → p-Dw0Obsn5.js} +1 -1
  125. package/dist/components/{p-DxzDda_J.js → p-Gm5hSQ-e.js} +1 -1
  126. package/dist/components/{p-C4fKLlrd.js → p-HK-6khHo.js} +1 -1
  127. package/dist/components/{p-_QEHfsIk.js → p-V3VW2JKl.js} +1 -1
  128. package/dist/components/{p-Lhyh6KeB.js → p-VxgCvVox.js} +1 -1
  129. package/dist/components/{p-l_YGO7RB.js → p-cjeDomsc.js} +1 -1
  130. package/dist/components/{p-gtQlsorg.js → p-rNu5JVNH.js} +1 -1
  131. package/dist/components/p-xYCbKFih.js +1 -0
  132. package/dist/esm/{index-BbOHefEf.js → index-D9HaikfQ.js} +36 -9
  133. package/dist/esm/index.js +1 -1
  134. package/dist/esm/kritzel-active-users_42.entry.js +333 -177
  135. package/dist/esm/kritzel-brush-style.entry.js +1 -1
  136. package/dist/esm/loader.js +3 -3
  137. package/dist/esm/stencil.js +4 -4
  138. package/dist/esm/{workspace.migrations-NhRgr2_H.js → workspace.migrations-OzSSw5kt.js} +244 -197
  139. package/dist/stencil/index.esm.js +1 -1
  140. package/dist/stencil/p-D9HaikfQ.js +2 -0
  141. package/dist/stencil/p-OzSSw5kt.js +1 -0
  142. package/dist/stencil/{p-98238bf9.entry.js → p-b0be4da1.entry.js} +1 -1
  143. package/dist/stencil/p-f7be06a8.entry.js +9 -0
  144. package/dist/stencil/stencil.esm.js +1 -1
  145. package/dist/types/classes/core/store.class.d.ts +23 -0
  146. package/dist/types/classes/objects/shape.class.d.ts +1 -0
  147. package/dist/types/classes/objects/text.class.d.ts +1 -0
  148. package/dist/types/classes/providers/hocuspocus-sync-provider.class.d.ts +1 -1
  149. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +7 -5
  150. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +10 -4
  151. package/dist/types/components.d.ts +35 -13
  152. package/dist/types/constants/version.d.ts +1 -1
  153. package/dist/types/helpers/tool-config.helper.d.ts +1 -1
  154. package/dist/types/interfaces/engine-state.interface.d.ts +10 -10
  155. package/package.json +1 -1
  156. package/dist/components/p-Ban3OlgZ.js +0 -9
  157. package/dist/components/p-CGGiwvWZ.js +0 -1
  158. package/dist/components/p-CHY71o5B.js +0 -1
  159. package/dist/components/p-DXpYcAnT.js +0 -1
  160. package/dist/components/p-pGzF7PUB.js +0 -1
  161. package/dist/stencil/p-4a4b38e4.entry.js +0 -9
  162. package/dist/stencil/p-BbOHefEf.js +0 -2
  163. package/dist/stencil/p-NhRgr2_H.js +0 -1
@@ -10,8 +10,8 @@ import { KritzelBaseHandler } from "./base.handler";
10
10
  * via shift/ctrl modifiers.
11
11
  */
12
12
  export class KritzelSelectionHandler extends KritzelBaseHandler {
13
- startX;
14
- startY;
13
+ startX = 0;
14
+ startY = 0;
15
15
  touchStartX = 0;
16
16
  touchStartY = 0;
17
17
  touchStartTimeout = null;
@@ -89,7 +89,10 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
89
89
  const moveThreshold = 5;
90
90
  if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._core.store.state.isSelecting) {
91
91
  this.updateTouchSelection();
92
- clearTimeout(this._core.store.state.longTouchTimeout);
92
+ const timeout = this._core.store.state.longTouchTimeout;
93
+ if (timeout) {
94
+ globalThis.clearTimeout?.(timeout);
95
+ }
93
96
  }
94
97
  }
95
98
  }
@@ -154,9 +157,9 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
154
157
  */
155
158
  removeSelectionBox() {
156
159
  this._core.store.state.isSelecting = false;
157
- this._core.store.state.objects.remove(o => o instanceof KritzelSelectionBox);
160
+ this._core.store.objects.remove(o => o instanceof KritzelSelectionBox);
158
161
  this._core.store.setSelectionBox(null);
159
- this._core.store.state.objects.clearLocalSelectionBox();
162
+ this._core.store.objects.clearLocalSelectionBox();
160
163
  }
161
164
  /**
162
165
  * Initiates a mouse-based selection by creating a selection box at the click position.
@@ -175,12 +178,12 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
175
178
  selectionBox.translateX = this.startX;
176
179
  selectionBox.translateY = this.startY;
177
180
  this._core.store.state.isSelecting = true;
178
- this._core.store.state.objects.remove(o => o instanceof KritzelSelectionBox || (!isAdditive && o instanceof KritzelSelectionGroup && (o.userId == null || o.userId === this._core.user?.id)));
181
+ this._core.store.objects.remove(o => o instanceof KritzelSelectionBox || (!isAdditive && o instanceof KritzelSelectionGroup && (o.userId == null || o.userId === this._core.user?.id)));
179
182
  this._core.store.setSelectionBox(null);
180
183
  if (!isAdditive) {
181
184
  this._core.store.setSelectionGroup(null);
182
185
  }
183
- this._core.store.state.objects.insert(selectionBox);
186
+ this._core.store.objects.insert(selectionBox);
184
187
  this._core.store.setSelectionBox(selectionBox);
185
188
  }
186
189
  /**
@@ -207,12 +210,12 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
207
210
  selectionBox.translateX = this.startX;
208
211
  selectionBox.translateY = this.startY;
209
212
  this._core.store.state.isSelecting = true;
210
- this._core.store.state.objects.remove(o => o instanceof KritzelSelectionBox || (!isAdditive && o instanceof KritzelSelectionGroup && (o.userId == null || o.userId === this._core.user?.id)));
213
+ this._core.store.objects.remove(o => o instanceof KritzelSelectionBox || (!isAdditive && o instanceof KritzelSelectionGroup && (o.userId == null || o.userId === this._core.user?.id)));
211
214
  this._core.store.setSelectionBox(null);
212
215
  if (!isAdditive) {
213
216
  this._core.store.setSelectionGroup(null);
214
217
  }
215
- this._core.store.state.objects.insert(selectionBox);
218
+ this._core.store.objects.insert(selectionBox);
216
219
  this._core.store.setSelectionBox(selectionBox);
217
220
  }
218
221
  /**
@@ -235,7 +238,7 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
235
238
  selectionBox.height = height;
236
239
  selectionBox.translateX = Math.min(currentX, this.startX);
237
240
  selectionBox.translateY = Math.min(currentY, this.startY);
238
- this._core.store.state.objects.setLocalSelectionBox({
241
+ this._core.store.objects.setLocalSelectionBox({
239
242
  x: selectionBox.translateX,
240
243
  y: selectionBox.translateY,
241
244
  width: width / selectionBox.scale,
@@ -274,7 +277,7 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
274
277
  selectionBox.height = height;
275
278
  selectionBox.translateX = Math.min(currentX, this.startX);
276
279
  selectionBox.translateY = Math.min(currentY, this.startY);
277
- this._core.store.state.objects.setLocalSelectionBox({
280
+ this._core.store.objects.setLocalSelectionBox({
278
281
  x: selectionBox.translateX,
279
282
  y: selectionBox.translateY,
280
283
  width: width / selectionBox.scale,
@@ -314,9 +317,9 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
314
317
  y: minY,
315
318
  z: selectionBox.scale,
316
319
  width: maxX - minX,
317
- height: maxY - minY
320
+ height: maxY - minY,
318
321
  };
319
- const candidates = this._core.store.state.objects.query(selectionBounds);
322
+ const candidates = this._core.store.objects.query(selectionBounds);
320
323
  // Track newly selected objects for efficient comparison
321
324
  const newlySelectedObjects = new Set();
322
325
  // Only test candidates that overlap the bounding box
@@ -348,7 +351,9 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
348
351
  const selectedObject = this.getTopmostHitObject(event);
349
352
  const isAdditive = event.shiftKey || event.ctrlKey;
350
353
  this.clearSelectionPreview();
351
- this.addObjectToSelectionGroup(selectedObject, isAdditive);
354
+ if (selectedObject) {
355
+ this.addObjectToSelectionGroup(selectedObject, isAdditive);
356
+ }
352
357
  this.removeSelectionBox();
353
358
  }
354
359
  /**
@@ -431,7 +436,7 @@ export class KritzelSelectionHandler extends KritzelBaseHandler {
431
436
  return;
432
437
  }
433
438
  // Build parent group lookup map ONCE - O(g * c) instead of O(n * g * c)
434
- const allGroups = this._core.store.state.objects.filter(obj => obj.__class__ === 'KritzelGroup');
439
+ const allGroups = this._core.store.objects.filter(obj => obj.__class__ === 'KritzelGroup');
435
440
  const childToParentMap = new Map();
436
441
  for (const group of allGroups) {
437
442
  for (const childId of group.childIds) {
@@ -61,7 +61,7 @@ export class KritzelAnchorManager {
61
61
  // Snap the endpoint to the target's center
62
62
  this.snapEndpointToObject(line, endpoint, targetObjectId);
63
63
  // Persist the change
64
- this._core.store.state.objects.update(line);
64
+ this._core.store.objects.update(line);
65
65
  }
66
66
  /**
67
67
  * Removes an anchor from a line endpoint.
@@ -440,7 +440,7 @@ export class KritzelAnchorManager {
440
440
  // Update the line to persist the change
441
441
  const line = this.getLineById(entry.lineId);
442
442
  if (line) {
443
- this._core.store.state.objects.update(line);
443
+ this._core.store.objects.update(line);
444
444
  }
445
445
  }
446
446
  // Remove the object from the index
@@ -542,7 +542,7 @@ export class KritzelAnchorManager {
542
542
  * @returns The KritzelLine object if found and is a line, null otherwise.
543
543
  */
544
544
  getLineById(lineId) {
545
- const objects = this._core.store.state.objects.filter(o => o.id === lineId);
545
+ const objects = this._core.store.objects.filter(o => o.id === lineId);
546
546
  if (objects.length === 0) {
547
547
  return null;
548
548
  }
@@ -556,7 +556,7 @@ export class KritzelAnchorManager {
556
556
  * @returns The KritzelBaseObject if found, null otherwise.
557
557
  */
558
558
  getObjectById(objectId) {
559
- const objects = this._core.store.state.objects.filter(o => o.id === objectId);
559
+ const objects = this._core.store.objects.filter(o => o.id === objectId);
560
560
  return objects.length > 0 ? objects[0] : null;
561
561
  }
562
562
  /**
@@ -208,7 +208,7 @@ export class KritzelBaseObject {
208
208
  const object = new KritzelBaseObject();
209
209
  object._core = core;
210
210
  object.zIndex = core.store.currentZIndex;
211
- object.workspaceId = core.store.state.activeWorkspace.id;
211
+ object.workspaceId = core.store.activeWorkspace.id;
212
212
  object.userId = core.user?.id;
213
213
  return object;
214
214
  }
@@ -276,7 +276,7 @@ export class KritzelBaseObject {
276
276
  * Triggers a re-render of the object in the canvas.
277
277
  */
278
278
  update() {
279
- this._core.store.state.objects.update(this);
279
+ this._core.store.objects.update(this);
280
280
  }
281
281
  /**
282
282
  * Moves the object based on the delta between start and end coordinates.
@@ -291,7 +291,7 @@ export class KritzelBaseObject {
291
291
  const deltaY = (startY - endY) / this._core.store.state.scale;
292
292
  this.translateX += deltaX;
293
293
  this.translateY += deltaY;
294
- this._core.store.state.objects.update(this);
294
+ this._core.store.objects.update(this);
295
295
  }
296
296
  /**
297
297
  * Resizes the object to new dimensions and position.
@@ -310,7 +310,7 @@ export class KritzelBaseObject {
310
310
  this.height = height;
311
311
  this.translateX = x;
312
312
  this.translateY = y;
313
- this._core.store.state.objects.update(this);
313
+ this._core.store.objects.update(this);
314
314
  // Update any lines that are anchored to this object (after position is updated)
315
315
  this._core.anchorManager.updateAnchorsForObject(this.id);
316
316
  }
@@ -320,7 +320,7 @@ export class KritzelBaseObject {
320
320
  */
321
321
  rotate(value) {
322
322
  this.rotation = value;
323
- this._core.store.state.objects.update(this);
323
+ this._core.store.objects.update(this);
324
324
  }
325
325
  /**
326
326
  * Creates a shallow clone of this object with the same ID.
@@ -425,6 +425,6 @@ export class KritzelBaseObject {
425
425
  updatePosition(x, y) {
426
426
  this.translateX = x;
427
427
  this.translateY = y;
428
- this._core.store.state.objects.update(this);
428
+ this._core.store.objects.update(this);
429
429
  }
430
430
  }
@@ -48,7 +48,7 @@ export class KritzelCustomElement extends KritzelBaseObject {
48
48
  const object = new KritzelCustomElement(config);
49
49
  object._core = core;
50
50
  object.id = object.generateId();
51
- object.workspaceId = core.store.state.activeWorkspace.id;
51
+ object.workspaceId = core.store.activeWorkspace.id;
52
52
  object.userId = core.user?.id;
53
53
  return object;
54
54
  }
@@ -94,7 +94,7 @@ export class KritzelCustomElement extends KritzelBaseObject {
94
94
  this.element.style.height = `${height}px`;
95
95
  }
96
96
  // Update to sync changes to y.js and propagate to other tabs
97
- this._core.store.state.objects.update(this);
97
+ this._core.store.objects.update(this);
98
98
  }
99
99
  /**
100
100
  * Creates a deep copy of this custom element.
@@ -47,7 +47,7 @@ export class KritzelGroup extends KritzelBaseObject {
47
47
  }
48
48
  return this.childIds
49
49
  .map(id => {
50
- const found = this._core.store.state.objects.filter(obj => obj.id === id);
50
+ const found = this._core.store.objects.filter(obj => obj.id === id);
51
51
  return found.length > 0 ? found[0] : null;
52
52
  })
53
53
  .filter((obj) => obj !== null);
@@ -69,7 +69,7 @@ export class KritzelGroup extends KritzelBaseObject {
69
69
  const group = new KritzelGroup();
70
70
  group._core = core;
71
71
  group.id = group.generateId();
72
- group.workspaceId = core.store.state.activeWorkspace.id;
72
+ group.workspaceId = core.store.activeWorkspace.id;
73
73
  group.userId = core.user?.id;
74
74
  group.scale = core.store.state.scale;
75
75
  group.zIndex = core.store.currentZIndex;
@@ -102,7 +102,7 @@ export class KritzelGroup extends KritzelBaseObject {
102
102
  * @returns The parent KritzelGroup if found, or null if the object is not a child of any group.
103
103
  */
104
104
  static findParentGroup(core, objectId) {
105
- const allGroups = core.store.state.objects
105
+ const allGroups = core.store.objects
106
106
  .filter(obj => obj.__class__ === 'KritzelGroup');
107
107
  for (const group of allGroups) {
108
108
  if (group.childIds.includes(objectId)) {
@@ -288,8 +288,8 @@ export class KritzelGroup extends KritzelBaseObject {
288
288
  const deltaY = (startY - endY) / this._core.store.state.scale;
289
289
  this.translateX += deltaX;
290
290
  this.translateY += deltaY;
291
- this._core.store.state.objects.transaction(() => {
292
- this._core.store.state.objects.update(this);
291
+ this._core.store.objects.transaction(() => {
292
+ this._core.store.objects.update(this);
293
293
  this.children.forEach(child => {
294
294
  child.move(startX, startY, endX, endY);
295
295
  // Update any lines anchored to this child
@@ -327,7 +327,7 @@ export class KritzelGroup extends KritzelBaseObject {
327
327
  const sin = Math.sin(-rotation);
328
328
  const cosR = Math.cos(rotation);
329
329
  const sinR = Math.sin(rotation);
330
- this._core.store.state.objects.transaction(() => {
330
+ this._core.store.objects.transaction(() => {
331
331
  this.children.forEach(child => {
332
332
  // Calculate child center
333
333
  const childCenterX = child.translateX + child.totalWidth / 2 / child.scale;
@@ -365,7 +365,7 @@ export class KritzelGroup extends KritzelBaseObject {
365
365
  });
366
366
  this.refreshBoundingBox();
367
367
  this.captureChildSnapshots();
368
- this._core.store.state.objects.update(this);
368
+ this._core.store.objects.update(this);
369
369
  });
370
370
  }
371
371
  /**
@@ -381,8 +381,8 @@ export class KritzelGroup extends KritzelBaseObject {
381
381
  const angle = value - this.snapshotRotation;
382
382
  const cos = Math.cos(angle);
383
383
  const sin = Math.sin(angle);
384
- this._core.store.state.objects.transaction(() => {
385
- this._core.store.state.objects.update(this);
384
+ this._core.store.objects.transaction(() => {
385
+ this._core.store.objects.update(this);
386
386
  this.children.forEach(child => {
387
387
  const unchangedSnapshot = this.unchangedChildSnapshots.get(child.id);
388
388
  if (!unchangedSnapshot)
@@ -508,7 +508,7 @@ export class KritzelGroup extends KritzelBaseObject {
508
508
  * Triggers synchronization with y.js for collaborative editing.
509
509
  */
510
510
  update() {
511
- this._core.store.state.objects.update(this);
511
+ this._core.store.objects.update(this);
512
512
  }
513
513
  /**
514
514
  * Updates the workspace ID for this group and all its children recursively.
@@ -39,7 +39,7 @@ export class KritzelImage extends KritzelBaseObject {
39
39
  const object = new KritzelImage();
40
40
  object._core = core;
41
41
  object.id = object.generateId();
42
- object.workspaceId = core.store.state.activeWorkspace.id;
42
+ object.workspaceId = core.store.activeWorkspace.id;
43
43
  object.userId = core.user?.id;
44
44
  object.x = 0;
45
45
  object.y = 0;
@@ -68,7 +68,7 @@ export class KritzelImage extends KritzelBaseObject {
68
68
  this.translateX = x;
69
69
  this.translateY = y;
70
70
  // Update to sync changes to y.js and propagate to other tabs
71
- this._core.store.state.objects.update(this);
71
+ this._core.store.objects.update(this);
72
72
  }
73
73
  /**
74
74
  * Creates a KritzelImage from a URL, handling image loading and dimension calculation.
@@ -79,7 +79,7 @@ export class KritzelLine extends KritzelBaseObject {
79
79
  const object = new KritzelLine();
80
80
  object._core = core;
81
81
  object.id = object.generateId();
82
- object.workspaceId = core.store.state.activeWorkspace.id;
82
+ object.workspaceId = core.store.activeWorkspace.id;
83
83
  object.userId = core.user?.id;
84
84
  object.options = options;
85
85
  object.startX = options?.startX ?? 0;
@@ -135,7 +135,7 @@ export class KritzelLine extends KritzelBaseObject {
135
135
  this.translateY = y;
136
136
  this._adjustedPoints = null;
137
137
  this._clipInfo = null;
138
- this._core.store.state.objects.update(this);
138
+ this._core.store.objects.update(this);
139
139
  // Update anchors after the line is updated
140
140
  this._core.anchorManager.updateAnchorsForObject(this.id);
141
141
  if (this.startAnchor) {
@@ -154,7 +154,7 @@ export class KritzelLine extends KritzelBaseObject {
154
154
  this.rotation = value;
155
155
  this._adjustedPoints = null;
156
156
  this._clipInfo = null;
157
- this._core.store.state.objects.update(this);
157
+ this._core.store.objects.update(this);
158
158
  }
159
159
  /**
160
160
  * Moves the line by calculating the delta between start and end positions.
@@ -178,7 +178,7 @@ export class KritzelLine extends KritzelBaseObject {
178
178
  }
179
179
  this._adjustedPoints = null;
180
180
  this._clipInfo = null;
181
- this._core.store.state.objects.update(this);
181
+ this._core.store.objects.update(this);
182
182
  }
183
183
  /**
184
184
  * Tests if a point intersects with the line within the stroke tolerance.
@@ -305,7 +305,7 @@ export class KritzelLine extends KritzelBaseObject {
305
305
  this.translateY = y;
306
306
  this._adjustedPoints = null;
307
307
  this._clipInfo = null;
308
- this._core.store.state.objects.update(this);
308
+ this._core.store.objects.update(this);
309
309
  }
310
310
  /**
311
311
  * Updates a specific endpoint of the line (start or end).
@@ -363,7 +363,7 @@ export class KritzelLine extends KritzelBaseObject {
363
363
  // Clear cached adjusted points
364
364
  this._adjustedPoints = null;
365
365
  this._clipInfo = null;
366
- this._core.store.state.objects.update(this);
366
+ this._core.store.objects.update(this);
367
367
  }
368
368
  /**
369
369
  * Updates the control point for a quadratic Bezier curve.
@@ -413,7 +413,7 @@ export class KritzelLine extends KritzelBaseObject {
413
413
  // Clear cached adjusted points
414
414
  this._adjustedPoints = null;
415
415
  this._clipInfo = null;
416
- this._core.store.state.objects.update(this);
416
+ this._core.store.objects.update(this);
417
417
  }
418
418
  /**
419
419
  * Computes the line endpoints in world coordinates, accounting for rotation,
@@ -61,7 +61,7 @@ export class KritzelPath extends KritzelBaseObject {
61
61
  const object = new KritzelPath();
62
62
  object._core = core;
63
63
  object.id = object.generateId();
64
- object.workspaceId = core.store.state.activeWorkspace.id;
64
+ object.workspaceId = core.store.activeWorkspace.id;
65
65
  object.userId = core.user?.id;
66
66
  object.options = options;
67
67
  object.points = options?.points ?? [];
@@ -119,7 +119,7 @@ export class KritzelPath extends KritzelBaseObject {
119
119
  this.translateX = x;
120
120
  this.translateY = y;
121
121
  this._adjustedPoints = null;
122
- this._core.store.state.objects.update(this);
122
+ this._core.store.objects.update(this);
123
123
  }
124
124
  /**
125
125
  * Rotates the path by the specified angle.
@@ -129,7 +129,7 @@ export class KritzelPath extends KritzelBaseObject {
129
129
  rotate(value) {
130
130
  this.rotation = value;
131
131
  this._adjustedPoints = null;
132
- this._core.store.state.objects.update(this);
132
+ this._core.store.objects.update(this);
133
133
  }
134
134
  /**
135
135
  * Moves the path by calculating the delta between start and end positions.
@@ -145,7 +145,7 @@ export class KritzelPath extends KritzelBaseObject {
145
145
  this.translateX += deltaX;
146
146
  this.translateY += deltaY;
147
147
  this._adjustedPoints = null;
148
- this._core.store.state.objects.update(this);
148
+ this._core.store.objects.update(this);
149
149
  }
150
150
  /**
151
151
  * Tests whether a point intersects with the path's stroke.
@@ -240,7 +240,7 @@ export class KritzelPath extends KritzelBaseObject {
240
240
  this.translateX = x;
241
241
  this.translateY = y;
242
242
  this._adjustedPoints = null;
243
- this._core.store.state.objects.update(this);
243
+ this._core.store.objects.update(this);
244
244
  }
245
245
  /**
246
246
  * Lifecycle hook called after properties have been updated.
@@ -18,7 +18,7 @@ export class KritzelSelectionBox extends KritzelBaseObject {
18
18
  const object = new KritzelSelectionBox();
19
19
  object._core = core;
20
20
  object.id = object.generateId();
21
- object.workspaceId = core.store.state.activeWorkspace.id;
21
+ object.workspaceId = core.store.activeWorkspace.id;
22
22
  object.userId = core.user?.id;
23
23
  object.scale = core.store.state.scale;
24
24
  object.zIndex = 99999;
@@ -21,10 +21,10 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
21
21
  snapshotTranslateX = 0;
22
22
  snapshotTranslateY = 0;
23
23
  clientId;
24
- minX;
25
- maxX;
26
- minY;
27
- maxY;
24
+ minX = 0;
25
+ maxX = 0;
26
+ minY = 0;
27
+ maxY = 0;
28
28
  // Selection styling properties
29
29
  handleColor;
30
30
  handleStrokeColor;
@@ -64,7 +64,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
64
64
  return this._cachedObjects;
65
65
  }
66
66
  const idSet = new Set(this._objectIds);
67
- const foundObjects = this._core.store.state.objects.filter(obj => idSet.has(obj.id));
67
+ const foundObjects = this._core.store.objects.filter(obj => idSet.has(obj.id));
68
68
  // Preserve the original order from objectIds
69
69
  const objectMap = new Map(foundObjects.map(obj => [obj.id, obj]));
70
70
  this._cachedObjects = this._objectIds
@@ -91,9 +91,9 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
91
91
  const object = new KritzelSelectionGroup();
92
92
  object._core = core;
93
93
  object.id = object.generateId();
94
- object.workspaceId = core.store.state.activeWorkspace.id;
94
+ object.workspaceId = core.store.activeWorkspace.id;
95
95
  object.userId = core.user?.id;
96
- object.clientId = core.store.state.objects?.localClientId ?? undefined;
96
+ object.clientId = core.store.objects?.localClientId ?? undefined;
97
97
  object.scale = core.store.state.scale;
98
98
  object.zIndex = 99999;
99
99
  // Initialize styling with theme-aware defaults
@@ -232,7 +232,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
232
232
  });
233
233
  this.translateX = x;
234
234
  this.translateY = y;
235
- this._core.store.state.objects.update(this);
235
+ this._core.store.objects.update(this);
236
236
  }
237
237
  /**
238
238
  * Capture snapshots of current object states for undo/redo operations
@@ -309,7 +309,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
309
309
  // Only update the selection group itself
310
310
  // Child objects are already updated during move/resize/rotate operations
311
311
  // Updating them again here would create redundant y.js updates
312
- this._core.store.state.objects.update(this);
312
+ this._core.store.objects.update(this);
313
313
  }
314
314
  /**
315
315
  * Moves the selection group and all its contained objects by calculating the delta from drag coordinates.
@@ -325,8 +325,8 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
325
325
  const deltaY = (startY - endY) / this._core.store.state.scale;
326
326
  this.translateX += deltaX;
327
327
  this.translateY += deltaY;
328
- this._core.store.state.objects.transaction(() => {
329
- this._core.store.state.objects.update(this);
328
+ this._core.store.objects.transaction(() => {
329
+ this._core.store.objects.update(this);
330
330
  const children = this.objects;
331
331
  for (const obj of children) {
332
332
  obj.move(startX, startY, endX, endY);
@@ -369,7 +369,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
369
369
  const sin = Math.sin(-rotation);
370
370
  const cosR = Math.cos(rotation);
371
371
  const sinR = Math.sin(rotation);
372
- this._core.store.state.objects.transaction(() => {
372
+ this._core.store.objects.transaction(() => {
373
373
  // Cache objects once to avoid repeated getter calls during resize
374
374
  const children = this.objects;
375
375
  children.forEach(child => {
@@ -421,7 +421,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
421
421
  // Note: Don't capture new snapshots here - we need to preserve the original snapshots
422
422
  // until the transform operation is complete to avoid compounding errors during drag
423
423
  this.refreshObjectDimensions(children);
424
- this._core.store.state.objects.update(this);
424
+ this._core.store.objects.update(this);
425
425
  });
426
426
  }
427
427
  /**
@@ -439,9 +439,9 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
439
439
  const sin = Math.sin(angle);
440
440
  // Cache objects once to avoid repeated getter calls during rotation
441
441
  const children = this.objects;
442
- this._core.store.state.objects.transaction(() => {
442
+ this._core.store.objects.transaction(() => {
443
443
  // Update the SelectionGroup itself to propagate rotation to other tabs
444
- this._core.store.state.objects.update(this);
444
+ this._core.store.objects.update(this);
445
445
  const childCount = children.length;
446
446
  for (const child of children) {
447
447
  const unchangedSnapshot = this.unchangedObjectSnapshots.get(child.id);
@@ -538,7 +538,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
538
538
  this.translateY = cy - (this.height / this.scale + 2 * this.padding) / 2;
539
539
  }
540
540
  if (!skipPersist) {
541
- this._core.store.state.objects.update(this);
541
+ this._core.store.objects.update(this);
542
542
  }
543
543
  }
544
544
  /**