kritzel-stencil 0.1.82 → 0.1.83
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.
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-active-users_42.cjs.entry.js +28 -3
- package/dist/cjs/{workspace.migrations-4HATwIMK.js → workspace.migrations-K5oVASsb.js} +49 -9
- package/dist/collection/classes/handlers/move.handler.js +2 -0
- package/dist/collection/classes/objects/selection-group.class.js +47 -9
- package/dist/collection/classes/structures/object-map.structure.js +26 -1
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-tool-config.js +1 -1
- package/dist/components/{p-CgtykATT.js → p-CKfjz1gj.js} +2 -2
- package/dist/components/{p-C35iuSnC.js → p-CLo-TjD_.js} +1 -1
- package/dist/components/{p-DsfD4pGR.js → p-CYl_JKvH.js} +1 -1
- package/dist/components/{p-DK_d3fKa.js → p-DwemlMvt.js} +1 -1
- package/dist/components/{p-BPQOTise.js → p-zM6hQ55n.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-active-users_42.entry.js +28 -3
- package/dist/esm/{workspace.migrations-Be65cOkQ.js → workspace.migrations-D5iSPf3E.js} +49 -9
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/{p-Be65cOkQ.js → p-D5iSPf3E.js} +1 -1
- package/dist/stencil/p-c28b30ab.entry.js +9 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/selection-group.class.d.ts +15 -1
- package/dist/types/classes/structures/object-map.structure.d.ts +17 -0
- package/dist/types/constants/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/stencil/p-f318b7d5.entry.js +0 -9
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-CFnj_FXt.js');
|
|
4
|
-
var workspace_migrations = require('./workspace.migrations-
|
|
4
|
+
var workspace_migrations = require('./workspace.migrations-K5oVASsb.js');
|
|
5
5
|
var Y = require('yjs');
|
|
6
6
|
require('y-websocket');
|
|
7
7
|
require('y-indexeddb');
|
|
@@ -21354,6 +21354,12 @@ class KritzelObjectMap {
|
|
|
21354
21354
|
_lastAwarenessEmitTime = 0;
|
|
21355
21355
|
_awarenessEmitTimeout = null;
|
|
21356
21356
|
AWARENESS_THROTTLE_INTERVAL = 100; // milliseconds
|
|
21357
|
+
/**
|
|
21358
|
+
* When true, update() only modifies local state (quadtree + idMap)
|
|
21359
|
+
* without writing to Yjs. Used during drag operations to avoid
|
|
21360
|
+
* redundant full serializations of every child object per frame.
|
|
21361
|
+
*/
|
|
21362
|
+
_localOnlyMode = false;
|
|
21357
21363
|
/**
|
|
21358
21364
|
* Indicates whether the object map has been initialized and is ready for use.
|
|
21359
21365
|
* @returns `true` if providers are connected and the map is operational
|
|
@@ -21907,6 +21913,25 @@ class KritzelObjectMap {
|
|
|
21907
21913
|
this._ydoc.transact(callback, 'local');
|
|
21908
21914
|
}
|
|
21909
21915
|
}
|
|
21916
|
+
/**
|
|
21917
|
+
* Executes a callback where all update() calls only modify local state
|
|
21918
|
+
* (quadtree + idMap) without writing to Yjs. This avoids expensive full
|
|
21919
|
+
* serializations during continuous operations like dragging many objects.
|
|
21920
|
+
*
|
|
21921
|
+
* Objects updated inside this callback must be persisted later
|
|
21922
|
+
* (e.g., via a normal update() call at drag end).
|
|
21923
|
+
*
|
|
21924
|
+
* @param callback - The function containing operations to execute locally
|
|
21925
|
+
*/
|
|
21926
|
+
withLocalUpdatesOnly(callback) {
|
|
21927
|
+
this._localOnlyMode = true;
|
|
21928
|
+
try {
|
|
21929
|
+
callback();
|
|
21930
|
+
}
|
|
21931
|
+
finally {
|
|
21932
|
+
this._localOnlyMode = false;
|
|
21933
|
+
}
|
|
21934
|
+
}
|
|
21910
21935
|
/**
|
|
21911
21936
|
* Loads all objects from the Yjs objects map into the local quadtree.
|
|
21912
21937
|
* Clears the existing quadtree and repopulates it by deserializing each
|
|
@@ -21998,7 +22023,7 @@ class KritzelObjectMap {
|
|
|
21998
22023
|
}
|
|
21999
22024
|
this.quadtree.update(object);
|
|
22000
22025
|
this._idMap.set(object.id, object);
|
|
22001
|
-
if (this._objectsMap && this.isPersistable(object)) {
|
|
22026
|
+
if (!this._localOnlyMode && this._objectsMap && this.isPersistable(object)) {
|
|
22002
22027
|
const serialized = object.serialize();
|
|
22003
22028
|
const origin = options.temporary ? 'temporary' : 'local';
|
|
22004
22029
|
this._ydoc?.transact(() => {
|
|
@@ -28708,7 +28733,7 @@ const KritzelPortal = class {
|
|
|
28708
28733
|
* This file is auto-generated by the version bump scripts.
|
|
28709
28734
|
* Do not modify manually.
|
|
28710
28735
|
*/
|
|
28711
|
-
const KRITZEL_VERSION = '0.1.
|
|
28736
|
+
const KRITZEL_VERSION = '0.1.83';
|
|
28712
28737
|
|
|
28713
28738
|
const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
|
|
28714
28739
|
|
|
@@ -18543,6 +18543,10 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
18543
18543
|
handleColor;
|
|
18544
18544
|
handleStrokeColor;
|
|
18545
18545
|
handleSize = 6;
|
|
18546
|
+
/** Timestamp of the last Yjs persist for children during a drag */
|
|
18547
|
+
_lastChildPersistTime = 0;
|
|
18548
|
+
/** Minimum interval (ms) between child Yjs persists during drag */
|
|
18549
|
+
static CHILD_PERSIST_THROTTLE_MS = 100;
|
|
18546
18550
|
/**
|
|
18547
18551
|
* Gets the array of object IDs contained in this selection group.
|
|
18548
18552
|
* @returns Array of string IDs for the selected objects
|
|
@@ -18828,7 +18832,11 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
18828
18832
|
/**
|
|
18829
18833
|
* Moves the selection group and all its contained objects by calculating the delta from drag coordinates.
|
|
18830
18834
|
* Updates anchor points for any lines connected to the moved objects.
|
|
18831
|
-
*
|
|
18835
|
+
*
|
|
18836
|
+
* Child objects are moved locally without writing to Yjs during the drag to avoid
|
|
18837
|
+
* N+1 full serializations per frame, which can overwhelm the WebSocket server.
|
|
18838
|
+
* Children must be persisted at drag end via {@link persistChildren}.
|
|
18839
|
+
*
|
|
18832
18840
|
* @param startX - The starting x-coordinate of the drag operation (in screen space)
|
|
18833
18841
|
* @param startY - The starting y-coordinate of the drag operation (in screen space)
|
|
18834
18842
|
* @param endX - The ending x-coordinate of the drag operation (in screen space)
|
|
@@ -18839,21 +18847,51 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
18839
18847
|
const deltaY = (startY - endY) / this._core.store.state.scale;
|
|
18840
18848
|
this.translateX += deltaX;
|
|
18841
18849
|
this.translateY += deltaY;
|
|
18842
|
-
|
|
18850
|
+
const now = Date.now();
|
|
18851
|
+
const shouldPersistChildren = now - this._lastChildPersistTime >= KritzelSelectionGroup.CHILD_PERSIST_THROTTLE_MS;
|
|
18852
|
+
if (shouldPersistChildren) {
|
|
18853
|
+
// Periodically persist children to Yjs so remote peers see movement in real-time
|
|
18854
|
+
this._core.store.objects.transaction(() => {
|
|
18855
|
+
this._core.store.objects.update(this);
|
|
18856
|
+
const children = this.objects;
|
|
18857
|
+
for (const obj of children) {
|
|
18858
|
+
obj.move(startX, startY, endX, endY);
|
|
18859
|
+
this._core.anchorManager.updateAnchorsForObject(obj.id);
|
|
18860
|
+
}
|
|
18861
|
+
});
|
|
18862
|
+
this._lastChildPersistTime = now;
|
|
18863
|
+
}
|
|
18864
|
+
else {
|
|
18865
|
+
// Between throttle intervals, only persist the selection group itself.
|
|
18866
|
+
// Children are moved locally for smooth local rendering.
|
|
18843
18867
|
this._core.store.objects.update(this);
|
|
18844
|
-
|
|
18845
|
-
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18868
|
+
this._core.store.objects.withLocalUpdatesOnly(() => {
|
|
18869
|
+
const children = this.objects;
|
|
18870
|
+
for (const obj of children) {
|
|
18871
|
+
obj.move(startX, startY, endX, endY);
|
|
18872
|
+
this._core.anchorManager.updateAnchorsForObject(obj.id);
|
|
18873
|
+
}
|
|
18874
|
+
});
|
|
18875
|
+
}
|
|
18851
18876
|
// Update snapshots
|
|
18852
18877
|
this.unchangedObjectSnapshots.forEach(snapshot => {
|
|
18853
18878
|
snapshot.translateX += deltaX;
|
|
18854
18879
|
snapshot.translateY += deltaY;
|
|
18855
18880
|
});
|
|
18856
18881
|
}
|
|
18882
|
+
/**
|
|
18883
|
+
* Persists all child objects to Yjs in a single transaction.
|
|
18884
|
+
* Must be called after a drag operation completes to sync the final
|
|
18885
|
+
* positions of children that were only updated locally during the drag.
|
|
18886
|
+
*/
|
|
18887
|
+
persistChildren() {
|
|
18888
|
+
this._core.store.objects.transaction(() => {
|
|
18889
|
+
const children = this.objects;
|
|
18890
|
+
for (const obj of children) {
|
|
18891
|
+
this._core.store.objects.update(obj);
|
|
18892
|
+
}
|
|
18893
|
+
});
|
|
18894
|
+
}
|
|
18857
18895
|
/**
|
|
18858
18896
|
* Resizes the selection group and scales all contained objects proportionally.
|
|
18859
18897
|
* Uses snapshot values to avoid compounding errors during continuous drag operations.
|
|
@@ -20367,6 +20405,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
20367
20405
|
if (this._core.store.state.isDragging) {
|
|
20368
20406
|
this._core.store.state.isDragging = false;
|
|
20369
20407
|
if (this.hasMoved) {
|
|
20408
|
+
this._core.store.selectionGroup.persistChildren();
|
|
20370
20409
|
this._core.store.selectionGroup.update();
|
|
20371
20410
|
this._core.engine.emitObjectsChange();
|
|
20372
20411
|
this._core.store.state.hasObjectsChanged = true;
|
|
@@ -20377,6 +20416,7 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
20377
20416
|
if (this._core.store.state.isDragging) {
|
|
20378
20417
|
this._core.store.state.isDragging = false;
|
|
20379
20418
|
if (this.hasMoved) {
|
|
20419
|
+
this._core.store.selectionGroup.persistChildren();
|
|
20380
20420
|
this._core.store.selectionGroup.update();
|
|
20381
20421
|
this._core.engine.emitObjectsChange();
|
|
20382
20422
|
this._core.store.state.hasObjectsChanged = true;
|
|
@@ -210,6 +210,7 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
210
210
|
if (this._core.store.state.isDragging) {
|
|
211
211
|
this._core.store.state.isDragging = false;
|
|
212
212
|
if (this.hasMoved) {
|
|
213
|
+
this._core.store.selectionGroup.persistChildren();
|
|
213
214
|
this._core.store.selectionGroup.update();
|
|
214
215
|
this._core.engine.emitObjectsChange();
|
|
215
216
|
this._core.store.state.hasObjectsChanged = true;
|
|
@@ -220,6 +221,7 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
220
221
|
if (this._core.store.state.isDragging) {
|
|
221
222
|
this._core.store.state.isDragging = false;
|
|
222
223
|
if (this.hasMoved) {
|
|
224
|
+
this._core.store.selectionGroup.persistChildren();
|
|
223
225
|
this._core.store.selectionGroup.update();
|
|
224
226
|
this._core.engine.emitObjectsChange();
|
|
225
227
|
this._core.store.state.hasObjectsChanged = true;
|
|
@@ -29,6 +29,10 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
29
29
|
handleColor;
|
|
30
30
|
handleStrokeColor;
|
|
31
31
|
handleSize = 6;
|
|
32
|
+
/** Timestamp of the last Yjs persist for children during a drag */
|
|
33
|
+
_lastChildPersistTime = 0;
|
|
34
|
+
/** Minimum interval (ms) between child Yjs persists during drag */
|
|
35
|
+
static CHILD_PERSIST_THROTTLE_MS = 100;
|
|
32
36
|
/**
|
|
33
37
|
* Gets the array of object IDs contained in this selection group.
|
|
34
38
|
* @returns Array of string IDs for the selected objects
|
|
@@ -314,7 +318,11 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
314
318
|
/**
|
|
315
319
|
* Moves the selection group and all its contained objects by calculating the delta from drag coordinates.
|
|
316
320
|
* Updates anchor points for any lines connected to the moved objects.
|
|
317
|
-
*
|
|
321
|
+
*
|
|
322
|
+
* Child objects are moved locally without writing to Yjs during the drag to avoid
|
|
323
|
+
* N+1 full serializations per frame, which can overwhelm the WebSocket server.
|
|
324
|
+
* Children must be persisted at drag end via {@link persistChildren}.
|
|
325
|
+
*
|
|
318
326
|
* @param startX - The starting x-coordinate of the drag operation (in screen space)
|
|
319
327
|
* @param startY - The starting y-coordinate of the drag operation (in screen space)
|
|
320
328
|
* @param endX - The ending x-coordinate of the drag operation (in screen space)
|
|
@@ -325,21 +333,51 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
325
333
|
const deltaY = (startY - endY) / this._core.store.state.scale;
|
|
326
334
|
this.translateX += deltaX;
|
|
327
335
|
this.translateY += deltaY;
|
|
328
|
-
|
|
336
|
+
const now = Date.now();
|
|
337
|
+
const shouldPersistChildren = now - this._lastChildPersistTime >= KritzelSelectionGroup.CHILD_PERSIST_THROTTLE_MS;
|
|
338
|
+
if (shouldPersistChildren) {
|
|
339
|
+
// Periodically persist children to Yjs so remote peers see movement in real-time
|
|
340
|
+
this._core.store.objects.transaction(() => {
|
|
341
|
+
this._core.store.objects.update(this);
|
|
342
|
+
const children = this.objects;
|
|
343
|
+
for (const obj of children) {
|
|
344
|
+
obj.move(startX, startY, endX, endY);
|
|
345
|
+
this._core.anchorManager.updateAnchorsForObject(obj.id);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
this._lastChildPersistTime = now;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
// Between throttle intervals, only persist the selection group itself.
|
|
352
|
+
// Children are moved locally for smooth local rendering.
|
|
329
353
|
this._core.store.objects.update(this);
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
354
|
+
this._core.store.objects.withLocalUpdatesOnly(() => {
|
|
355
|
+
const children = this.objects;
|
|
356
|
+
for (const obj of children) {
|
|
357
|
+
obj.move(startX, startY, endX, endY);
|
|
358
|
+
this._core.anchorManager.updateAnchorsForObject(obj.id);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
337
362
|
// Update snapshots
|
|
338
363
|
this.unchangedObjectSnapshots.forEach(snapshot => {
|
|
339
364
|
snapshot.translateX += deltaX;
|
|
340
365
|
snapshot.translateY += deltaY;
|
|
341
366
|
});
|
|
342
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Persists all child objects to Yjs in a single transaction.
|
|
370
|
+
* Must be called after a drag operation completes to sync the final
|
|
371
|
+
* positions of children that were only updated locally during the drag.
|
|
372
|
+
*/
|
|
373
|
+
persistChildren() {
|
|
374
|
+
this._core.store.objects.transaction(() => {
|
|
375
|
+
const children = this.objects;
|
|
376
|
+
for (const obj of children) {
|
|
377
|
+
this._core.store.objects.update(obj);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
343
381
|
/**
|
|
344
382
|
* Resizes the selection group and scales all contained objects proportionally.
|
|
345
383
|
* Uses snapshot values to avoid compounding errors during continuous drag operations.
|
|
@@ -38,6 +38,12 @@ export class KritzelObjectMap {
|
|
|
38
38
|
_lastAwarenessEmitTime = 0;
|
|
39
39
|
_awarenessEmitTimeout = null;
|
|
40
40
|
AWARENESS_THROTTLE_INTERVAL = 100; // milliseconds
|
|
41
|
+
/**
|
|
42
|
+
* When true, update() only modifies local state (quadtree + idMap)
|
|
43
|
+
* without writing to Yjs. Used during drag operations to avoid
|
|
44
|
+
* redundant full serializations of every child object per frame.
|
|
45
|
+
*/
|
|
46
|
+
_localOnlyMode = false;
|
|
41
47
|
/**
|
|
42
48
|
* Indicates whether the object map has been initialized and is ready for use.
|
|
43
49
|
* @returns `true` if providers are connected and the map is operational
|
|
@@ -591,6 +597,25 @@ export class KritzelObjectMap {
|
|
|
591
597
|
this._ydoc.transact(callback, 'local');
|
|
592
598
|
}
|
|
593
599
|
}
|
|
600
|
+
/**
|
|
601
|
+
* Executes a callback where all update() calls only modify local state
|
|
602
|
+
* (quadtree + idMap) without writing to Yjs. This avoids expensive full
|
|
603
|
+
* serializations during continuous operations like dragging many objects.
|
|
604
|
+
*
|
|
605
|
+
* Objects updated inside this callback must be persisted later
|
|
606
|
+
* (e.g., via a normal update() call at drag end).
|
|
607
|
+
*
|
|
608
|
+
* @param callback - The function containing operations to execute locally
|
|
609
|
+
*/
|
|
610
|
+
withLocalUpdatesOnly(callback) {
|
|
611
|
+
this._localOnlyMode = true;
|
|
612
|
+
try {
|
|
613
|
+
callback();
|
|
614
|
+
}
|
|
615
|
+
finally {
|
|
616
|
+
this._localOnlyMode = false;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
594
619
|
/**
|
|
595
620
|
* Loads all objects from the Yjs objects map into the local quadtree.
|
|
596
621
|
* Clears the existing quadtree and repopulates it by deserializing each
|
|
@@ -682,7 +707,7 @@ export class KritzelObjectMap {
|
|
|
682
707
|
}
|
|
683
708
|
this.quadtree.update(object);
|
|
684
709
|
this._idMap.set(object.id, object);
|
|
685
|
-
if (this._objectsMap && this.isPersistable(object)) {
|
|
710
|
+
if (!this._localOnlyMode && this._objectsMap && this.isPersistable(object)) {
|
|
686
711
|
const serialized = object.serialize();
|
|
687
712
|
const origin = options.temporary ? 'temporary' : 'local';
|
|
688
713
|
this._ydoc?.transact(() => {
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-BWj1eE2b.js";export{d as KritzelBrushTool,b as KritzelGroup,a as KritzelImage,e as KritzelLineTool,h as KritzelSelectionTool,c as KritzelShape,g as KritzelShapeTool,K as KritzelText,f as KritzelTextTool,S as ShapeType}from"./p-
|
|
1
|
+
export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-BWj1eE2b.js";export{d as KritzelBrushTool,b as KritzelGroup,a as KritzelImage,e as KritzelLineTool,h as KritzelSelectionTool,c as KritzelShape,g as KritzelShapeTool,K as KritzelText,f as KritzelTextTool,S as ShapeType}from"./p-zM6hQ55n.js";export{a as KritzelLine,K as KritzelPath}from"./p-DQK_4lkI.js";export{A as APP_STATE_MIGRATIONS,I as IndexedDBSyncProvider,d as KritzelAlignment,c as KritzelAnchorManager,b as KritzelCursorHelper,K as KritzelEraserTool,a as KritzelImageTool,W as WORKSPACE_MIGRATIONS,r as runMigrations}from"./p-CKfjz1gj.js";import*as t from"yjs";import{WebsocketProvider as i}from"y-websocket";export{D as DEFAULT_BRUSH_CONFIG,b as DEFAULT_LINE_TOOL_CONFIG,a as DEFAULT_TEXT_CONFIG,H as HocuspocusSyncProvider,KritzelEditor,defineCustomElement as defineCustomElementKritzelEditor}from"./kritzel-editor.js";export{K as KritzelWorkspace,W as WORKSPACE_EXPORT_VERSION}from"./p-DhMlShij.js";export{K as KritzelThemeManager,d as darkTheme,l as lightTheme}from"./p-CjazGGq3.js";export{C as CURRENT_APP_STATE_SCHEMA_VERSION,a as CURRENT_WORKSPACE_SCHEMA_VERSION}from"./p-CW-VyJgK.js";export{KritzelActiveUsers,defineCustomElement as defineCustomElementKritzelActiveUsers}from"./kritzel-active-users.js";export{KritzelAvatar,defineCustomElement as defineCustomElementKritzelAvatar}from"./kritzel-avatar.js";export{KritzelAwarenessCursors,defineCustomElement as defineCustomElementKritzelAwarenessCursors}from"./kritzel-awareness-cursors.js";export{KritzelBackToContent,defineCustomElement as defineCustomElementKritzelBackToContent}from"./kritzel-back-to-content.js";export{KritzelBrushStyle,defineCustomElement as defineCustomElementKritzelBrushStyle}from"./kritzel-brush-style.js";export{KritzelButton,defineCustomElement as defineCustomElementKritzelButton}from"./kritzel-button.js";export{KritzelColor,defineCustomElement as defineCustomElementKritzelColor}from"./kritzel-color.js";export{KritzelColorPalette,defineCustomElement as defineCustomElementKritzelColorPalette}from"./kritzel-color-palette.js";export{KritzelContextMenu,defineCustomElement as defineCustomElementKritzelContextMenu}from"./kritzel-context-menu.js";export{KritzelControls,defineCustomElement as defineCustomElementKritzelControls}from"./kritzel-controls.js";export{KritzelCurrentUser,defineCustomElement as defineCustomElementKritzelCurrentUser}from"./kritzel-current-user.js";export{KritzelCurrentUserDialog,defineCustomElement as defineCustomElementKritzelCurrentUserDialog}from"./kritzel-current-user-dialog.js";export{KritzelCursorTrail,defineCustomElement as defineCustomElementKritzelCursorTrail}from"./kritzel-cursor-trail.js";export{KritzelDialog,defineCustomElement as defineCustomElementKritzelDialog}from"./kritzel-dialog.js";export{KritzelDropdown,defineCustomElement as defineCustomElementKritzelDropdown}from"./kritzel-dropdown.js";export{KritzelEngine,defineCustomElement as defineCustomElementKritzelEngine}from"./kritzel-engine.js";export{KritzelExport,defineCustomElement as defineCustomElementKritzelExport}from"./kritzel-export.js";export{KritzelFont,defineCustomElement as defineCustomElementKritzelFont}from"./kritzel-font.js";export{KritzelFontFamily,defineCustomElement as defineCustomElementKritzelFontFamily}from"./kritzel-font-family.js";export{KritzelFontSize,defineCustomElement as defineCustomElementKritzelFontSize}from"./kritzel-font-size.js";export{KritzelIcon,defineCustomElement as defineCustomElementKritzelIcon}from"./kritzel-icon.js";export{KritzelInput,defineCustomElement as defineCustomElementKritzelInput}from"./kritzel-input.js";export{KritzelLineEndings,defineCustomElement as defineCustomElementKritzelLineEndings}from"./kritzel-line-endings.js";export{KritzelLoginDialog,defineCustomElement as defineCustomElementKritzelLoginDialog}from"./kritzel-login-dialog.js";export{KritzelMasterDetail,defineCustomElement as defineCustomElementKritzelMasterDetail}from"./kritzel-master-detail.js";export{KritzelMenu,defineCustomElement as defineCustomElementKritzelMenu}from"./kritzel-menu.js";export{KritzelMenuItem,defineCustomElement as defineCustomElementKritzelMenuItem}from"./kritzel-menu-item.js";export{KritzelMoreMenu,defineCustomElement as defineCustomElementKritzelMoreMenu}from"./kritzel-more-menu.js";export{KritzelNumericInput,defineCustomElement as defineCustomElementKritzelNumericInput}from"./kritzel-numeric-input.js";export{KritzelOpacitySlider,defineCustomElement as defineCustomElementKritzelOpacitySlider}from"./kritzel-opacity-slider.js";export{KritzelPillTabs,defineCustomElement as defineCustomElementKritzelPillTabs}from"./kritzel-pill-tabs.js";export{KritzelPortal,defineCustomElement as defineCustomElementKritzelPortal}from"./kritzel-portal.js";export{KritzelSettings,defineCustomElement as defineCustomElementKritzelSettings}from"./kritzel-settings.js";export{KritzelShapeFill,defineCustomElement as defineCustomElementKritzelShapeFill}from"./kritzel-shape-fill.js";export{KritzelShareDialog,defineCustomElement as defineCustomElementKritzelShareDialog}from"./kritzel-share-dialog.js";export{KritzelSlideToggle,defineCustomElement as defineCustomElementKritzelSlideToggle}from"./kritzel-slide-toggle.js";export{KritzelSplitButton,defineCustomElement as defineCustomElementKritzelSplitButton}from"./kritzel-split-button.js";export{KritzelStrokeSize,defineCustomElement as defineCustomElementKritzelStrokeSize}from"./kritzel-stroke-size.js";export{KritzelToolConfig,defineCustomElement as defineCustomElementKritzelToolConfig}from"./kritzel-tool-config.js";export{KritzelTooltip,defineCustomElement as defineCustomElementKritzelTooltip}from"./kritzel-tooltip.js";export{KritzelUtilityPanel,defineCustomElement as defineCustomElementKritzelUtilityPanel}from"./kritzel-utility-panel.js";export{KritzelWorkspaceManager,defineCustomElement as defineCustomElementKritzelWorkspaceManager}from"./kritzel-workspace-manager.js";const o=Math.floor,n=127,m=Number.MAX_SAFE_INTEGER;class u{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const z=()=>new u,E=e=>{const t=new Uint8Array((e=>{let t=e.cpos;for(let r=0;r<e.bufs.length;r++)t+=e.bufs[r].length;return t})(e));let r=0;for(let s=0;s<e.bufs.length;s++){const i=e.bufs[s];t.set(i,r),r+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),r),t},p=(e,t)=>{const r=e.cbuf.length;e.cpos===r&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*r),e.cpos=0),e.cbuf[e.cpos++]=t},k=(e,t)=>{for(;t>n;)p(e,128|n&t),t=o(t/128);p(e,n&t)},x=(e,t)=>{k(e,t.byteLength),((e,t)=>{const r=e.cbuf.length,s=e.cpos,i=((e,t)=>e<t?e:t)(r-s,t.length),o=t.length-i;e.cbuf.set(t.subarray(0,i),s),e.cpos+=i,o>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(((e,t)=>e>t?e:t)(2*r,o)),e.cbuf.set(t.subarray(i)),e.cpos=o)})(e,t)},j=e=>Error(e),T=j("Unexpected end of array"),y=j("Integer out of Range");class w{constructor(e){this.arr=e,this.pos=0}}const P=e=>((e,t)=>{const r=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,r})(e,M(e)),M=e=>{let t=0,r=1;const s=e.arr.length;for(;e.pos<s;){const s=e.arr[e.pos++];if(t+=(s&n)*r,r*=128,s<128)return t;if(t>m)throw y}throw T};class U{type="local";doc;channel;_synced=!1;constructor(e,t,r){this.doc=t,this.channel=new BroadcastChannel(e),this.channel.onmessage=e=>{this.handleMessage(e.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),r?.quiet||console.info("BroadcastChannel Provider initialized: "+e)}handleDocUpdate=(e,t)=>{if(t!==this){const t=z();k(t,0),x(t,e),this.channel.postMessage(E(t))}};handleMessage(e){const r=(e=>new w(e))(new Uint8Array(e));switch(M(r)){case 0:const e=P(r);t.applyUpdate(this.doc,e,this);break;case 1:this.broadcastSync();break;case 2:const s=P(r),i=t.encodeStateAsUpdate(this.doc,s);if(i.length>0){const e=z();k(e,0),x(e,i),this.channel.postMessage(E(e))}}}broadcastSync(){const e=z();k(e,2),x(e,t.encodeStateVector(this.doc)),this.channel.postMessage(E(e))}async connect(){if(!this._synced)return new Promise((e=>{const t=()=>{this._synced?e():setTimeout(t,50)};t()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}class _{type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(e,t,r){const s=r?.url||"ws://localhost:1234",o=r?.roomName||e;this.provider=new i(s,o,t,{params:r?.params,protocols:r?.protocols,WebSocketPolyfill:r?.WebSocketPolyfill,awareness:r?.awareness,maxBackoffTime:r?.maxBackoffTime,disableBc:!0}),this._quiet=r?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${s}/${o}`)}static with(e){return{create:(t,r,s)=>{const i=s?{...e,...s}:e;return new _(t,r,i)}}}setupEventListeners(){this.provider.on("status",(({status:e})=>{"connected"===e?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===e&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(e=>{e&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((e,t)=>{const r=setTimeout((()=>{t(Error("WebSocket connection timeout"))}),1e4),s=({status:t})=>{"connected"===t&&(clearTimeout(r),this.provider.off("status",s),this.isConnected=!0,e())};this.provider.on("status",s),this.provider.wsconnected&&(clearTimeout(r),this.provider.off("status",s),this.isConnected=!0,e())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}export{U as BroadcastSyncProvider,_ as WebSocketSyncProvider}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-CLo-TjD_.js";const p=o,r=s;export{p as KritzelControls,r as defineCustomElement}
|