kritzel-stencil 0.1.62 → 0.1.63

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 (56) hide show
  1. package/dist/cjs/{alignment.enum-BhN7ih5b.js → alignment.enum-CCaamYTo.js} +2 -277
  2. package/dist/cjs/index.cjs.js +255 -2
  3. package/dist/cjs/kritzel-active-users_40.cjs.entry.js +68 -178
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/stencil.cjs.js +1 -1
  6. package/dist/collection/classes/core/core.class.js +13 -20
  7. package/dist/collection/classes/core/workspace.class.js +0 -2
  8. package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js +2 -23
  9. package/dist/collection/classes/structures/app-state-map.structure.js +0 -9
  10. package/dist/collection/classes/structures/object-map.structure.js +0 -9
  11. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +57 -195
  12. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +29 -210
  13. package/dist/collection/components/ui/kritzel-login-dialog/kritzel-login-dialog.js +12 -12
  14. package/dist/collection/constants/version.js +1 -1
  15. package/dist/collection/events/login.event.js +1 -0
  16. package/dist/collection/index.js +5 -7
  17. package/dist/components/index.js +1 -1
  18. package/dist/components/kritzel-editor.js +1 -1
  19. package/dist/components/kritzel-engine.js +1 -1
  20. package/dist/components/kritzel-login-dialog.js +1 -1
  21. package/dist/components/kritzel-settings.js +1 -1
  22. package/dist/components/kritzel-workspace-manager.js +1 -1
  23. package/dist/components/{p-CcSk-pE-.js → p-BFtP25sy.js} +1 -1
  24. package/dist/components/{p-Cy2FBvt8.js → p-BLI9Rdlk.js} +1 -1
  25. package/dist/components/{p-Cjp2eRqQ.js → p-BrGeTb3S.js} +1 -1
  26. package/dist/components/p-DQopSiEQ.js +9 -0
  27. package/dist/components/{p-D_hspNnP.js → p-DTPKVvYU.js} +1 -1
  28. package/dist/esm/{alignment.enum-DbE3cqsY.js → alignment.enum-p8wmDrWN.js} +1 -277
  29. package/dist/esm/index.js +256 -2
  30. package/dist/esm/kritzel-active-users_40.entry.js +68 -178
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/stencil.js +1 -1
  33. package/dist/stencil/index.esm.js +1 -1
  34. package/dist/stencil/p-b7108cb3.entry.js +9 -0
  35. package/dist/stencil/{p-DbE3cqsY.js → p-p8wmDrWN.js} +1 -1
  36. package/dist/stencil/stencil.esm.js +1 -1
  37. package/dist/types/classes/core/core.class.d.ts +4 -15
  38. package/dist/types/classes/providers/hocuspocus-sync-provider.class.d.ts +1 -4
  39. package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +7 -49
  40. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +7 -47
  41. package/dist/types/components/ui/kritzel-login-dialog/kritzel-login-dialog.d.ts +4 -3
  42. package/dist/types/components.d.ts +25 -92
  43. package/dist/types/constants/version.d.ts +1 -1
  44. package/dist/types/events/active-workspace-change.event.d.ts +7 -0
  45. package/dist/types/events/editor-is-ready.event.d.ts +13 -0
  46. package/dist/types/events/login.event.d.ts +3 -0
  47. package/dist/types/index.d.ts +5 -7
  48. package/dist/types/interfaces/login-config.interface.d.ts +3 -10
  49. package/dist/types/interfaces/sync-provider.interface.d.ts +0 -15
  50. package/package.json +1 -1
  51. package/dist/components/p-L3-e5aW3.js +0 -9
  52. package/dist/stencil/p-d65beb31.entry.js +0 -9
  53. package/dist/types/interfaces/auth-config.interface.d.ts +0 -26
  54. package/dist/types/interfaces/sync-status.interface.d.ts +0 -18
  55. /package/dist/collection/{interfaces/auth-config.interface.js → events/active-workspace-change.event.js} +0 -0
  56. /package/dist/collection/{interfaces/sync-status.interface.js → events/editor-is-ready.event.js} +0 -0
@@ -25132,280 +25132,6 @@ class HocuspocusProvider extends EventEmitter {
25132
25132
  }
25133
25133
  }
25134
25134
 
25135
- /**
25136
- * Hocuspocus sync provider for real-time collaboration
25137
- * Supports multiplexing - multiple documents can share the same WebSocket connection
25138
- */
25139
- class HocuspocusSyncProvider {
25140
- provider;
25141
- isConnected = false;
25142
- isSynced = false;
25143
- usesSharedSocket = false;
25144
- _statusCallbacks = [];
25145
- get awareness() {
25146
- return this.provider.awareness;
25147
- }
25148
- onStatusChange(callback) {
25149
- this._statusCallbacks.push(callback);
25150
- }
25151
- emitStatus(status, detail) {
25152
- for (const cb of this._statusCallbacks) {
25153
- cb(status, detail);
25154
- }
25155
- }
25156
- // Static shared WebSocket instance for multiplexing
25157
- static sharedWebSocketProvider = null;
25158
- constructor(docName, doc, options) {
25159
- const name = options?.name || docName;
25160
- const url = options?.url || 'ws://localhost:1234';
25161
- // Use provided websocketProvider or the static shared one
25162
- const websocketProvider = options?.websocketProvider || HocuspocusSyncProvider.sharedWebSocketProvider;
25163
- if (websocketProvider) {
25164
- // Multiplexing mode - use shared WebSocket connection
25165
- this.usesSharedSocket = true;
25166
- const config = {
25167
- websocketProvider,
25168
- name,
25169
- document: doc,
25170
- token: options?.token || null,
25171
- onConnect: () => {
25172
- if (this.isConnected) {
25173
- return;
25174
- }
25175
- this.isConnected = true;
25176
- this.emitStatus('connected');
25177
- if (!options?.quiet) {
25178
- console.info(`Hocuspocus connected: ${name}`);
25179
- }
25180
- if (options?.onConnect) {
25181
- options.onConnect();
25182
- }
25183
- },
25184
- onDisconnect: () => {
25185
- if (!this.isConnected && !this.isSynced) {
25186
- return;
25187
- }
25188
- this.isConnected = false;
25189
- this.isSynced = false;
25190
- this.emitStatus('disconnected');
25191
- if (!options?.quiet) {
25192
- console.info(`Hocuspocus disconnected: ${name}`);
25193
- }
25194
- if (options?.onDisconnect) {
25195
- options.onDisconnect();
25196
- }
25197
- },
25198
- onSynced: () => {
25199
- if (this.isSynced) {
25200
- return;
25201
- }
25202
- this.isSynced = true;
25203
- if (!options?.quiet) {
25204
- console.info(`Hocuspocus synced: ${name}`);
25205
- }
25206
- if (options?.onSynced) {
25207
- options.onSynced();
25208
- }
25209
- },
25210
- };
25211
- // Add optional settings
25212
- if (options?.forceSyncInterval !== undefined) {
25213
- config.forceSyncInterval = options.forceSyncInterval;
25214
- }
25215
- if (options?.onAuthenticationFailed) {
25216
- const originalHandler = options.onAuthenticationFailed;
25217
- config.onAuthenticationFailed = (data) => {
25218
- this.emitStatus('error', { message: 'Authentication failed' });
25219
- originalHandler(data);
25220
- };
25221
- }
25222
- if (options?.onStatus) {
25223
- config.onStatus = options.onStatus;
25224
- }
25225
- this.provider = new HocuspocusProvider(config);
25226
- // Must call attach() explicitly when using shared socket
25227
- this.provider.attach();
25228
- if (!options?.quiet) {
25229
- console.info(`Hocuspocus Provider initialized (multiplexed): ${name}`);
25230
- }
25231
- }
25232
- else {
25233
- // Standalone mode - create own WebSocket connection
25234
- this.usesSharedSocket = false;
25235
- const config = {
25236
- url,
25237
- name,
25238
- document: doc,
25239
- token: options?.token || null,
25240
- onConnect: () => {
25241
- if (this.isConnected) {
25242
- return;
25243
- }
25244
- this.isConnected = true;
25245
- this.emitStatus('connected');
25246
- if (!options?.quiet) {
25247
- console.info(`Hocuspocus connected: ${name}`);
25248
- }
25249
- if (options?.onConnect) {
25250
- options.onConnect();
25251
- }
25252
- },
25253
- onDisconnect: () => {
25254
- if (!this.isConnected && !this.isSynced) {
25255
- return;
25256
- }
25257
- this.isConnected = false;
25258
- this.isSynced = false;
25259
- this.emitStatus('disconnected');
25260
- if (!options?.quiet) {
25261
- console.info(`Hocuspocus disconnected: ${name}`);
25262
- }
25263
- if (options?.onDisconnect) {
25264
- options.onDisconnect();
25265
- }
25266
- },
25267
- onSynced: () => {
25268
- if (this.isSynced) {
25269
- return;
25270
- }
25271
- this.isSynced = true;
25272
- if (!options?.quiet) {
25273
- console.info(`Hocuspocus synced: ${name}`);
25274
- }
25275
- if (options?.onSynced) {
25276
- options.onSynced();
25277
- }
25278
- },
25279
- };
25280
- // Add optional settings
25281
- if (options?.forceSyncInterval !== undefined) {
25282
- config.forceSyncInterval = options.forceSyncInterval;
25283
- }
25284
- if (options?.onAuthenticationFailed) {
25285
- const originalHandler = options.onAuthenticationFailed;
25286
- config.onAuthenticationFailed = (data) => {
25287
- this.emitStatus('error', { message: 'Authentication failed' });
25288
- originalHandler(data);
25289
- };
25290
- }
25291
- if (options?.onStatus) {
25292
- config.onStatus = options.onStatus;
25293
- }
25294
- if (options?.WebSocketPolyfill) {
25295
- config.WebSocketPolyfill = options.WebSocketPolyfill;
25296
- }
25297
- this.provider = new HocuspocusProvider(config);
25298
- if (!options?.quiet) {
25299
- console.info(`Hocuspocus Provider initialized: ${url}/${name}`);
25300
- }
25301
- }
25302
- }
25303
- /**
25304
- * Create a shared WebSocket connection for multiplexing
25305
- * Call this once to create a shared connection that multiple providers can use
25306
- */
25307
- static createSharedWebSocket(options) {
25308
- if (HocuspocusSyncProvider.sharedWebSocketProvider) {
25309
- console.warn('Shared WebSocket already exists. Returning existing instance.');
25310
- return HocuspocusSyncProvider.sharedWebSocketProvider;
25311
- }
25312
- const config = {
25313
- url: options.url,
25314
- };
25315
- if (options.WebSocketPolyfill) {
25316
- config.WebSocketPolyfill = options.WebSocketPolyfill;
25317
- }
25318
- if (options.onConnect) {
25319
- config.onConnect = options.onConnect;
25320
- }
25321
- if (options.onDisconnect) {
25322
- config.onDisconnect = options.onDisconnect;
25323
- }
25324
- if (options.onStatus) {
25325
- config.onStatus = options.onStatus;
25326
- }
25327
- HocuspocusSyncProvider.sharedWebSocketProvider = new HocuspocusProviderWebsocket(config);
25328
- console.info(`Shared Hocuspocus WebSocket created: ${options.url}`);
25329
- return HocuspocusSyncProvider.sharedWebSocketProvider;
25330
- }
25331
- /**
25332
- * Destroy the shared WebSocket connection
25333
- * Call this when you're done with all multiplexed providers
25334
- */
25335
- static destroySharedWebSocket() {
25336
- if (HocuspocusSyncProvider.sharedWebSocketProvider) {
25337
- HocuspocusSyncProvider.sharedWebSocketProvider.destroy();
25338
- HocuspocusSyncProvider.sharedWebSocketProvider = null;
25339
- console.info('Shared Hocuspocus WebSocket destroyed');
25340
- }
25341
- }
25342
- /**
25343
- * Get the shared WebSocket provider instance (if it exists)
25344
- */
25345
- static getSharedWebSocket() {
25346
- return HocuspocusSyncProvider.sharedWebSocketProvider;
25347
- }
25348
- /**
25349
- * Static factory method for creating HocuspocusSyncProvider with configuration options
25350
- * Returns a ProviderFactory that can be used in sync configuration
25351
- */
25352
- static with(options) {
25353
- return {
25354
- create: (docName, doc, runtimeOptions) => {
25355
- const mergedOptions = runtimeOptions ? { ...options, ...runtimeOptions } : options;
25356
- return new HocuspocusSyncProvider(docName, doc, mergedOptions);
25357
- },
25358
- };
25359
- }
25360
- async connect() {
25361
- if (this.isSynced) {
25362
- return;
25363
- }
25364
- return new Promise((resolve, reject) => {
25365
- const timeout = setTimeout(() => {
25366
- reject(new Error('Hocuspocus connection timeout'));
25367
- }, 10000); // 10 second timeout
25368
- const syncHandler = () => {
25369
- clearTimeout(timeout);
25370
- this.provider.off('synced', syncHandler);
25371
- resolve();
25372
- };
25373
- this.provider.on('synced', syncHandler);
25374
- // If already synced, resolve immediately
25375
- if (this.provider.isSynced) {
25376
- clearTimeout(timeout);
25377
- this.provider.off('synced', syncHandler);
25378
- resolve();
25379
- return;
25380
- }
25381
- // Connect if not already connected (standalone mode only)
25382
- if (!this.isConnected && !this.usesSharedSocket) {
25383
- this.provider.connect();
25384
- }
25385
- });
25386
- }
25387
- disconnect() {
25388
- if (this.provider) {
25389
- if (this.usesSharedSocket) {
25390
- // Detach from shared socket instead of disconnecting
25391
- this.provider.detach();
25392
- }
25393
- else {
25394
- this.provider.disconnect();
25395
- }
25396
- }
25397
- this.isConnected = false;
25398
- this.isSynced = false;
25399
- }
25400
- destroy() {
25401
- if (this.provider) {
25402
- this.provider.destroy();
25403
- }
25404
- this.isConnected = false;
25405
- this.isSynced = false;
25406
- }
25407
- }
25408
-
25409
25135
  /** Current version of the workspace export format */
25410
25136
  const WORKSPACE_EXPORT_VERSION = '1.1.0';
25411
25137
  /**
@@ -25495,8 +25221,6 @@ class KritzelWorkspace {
25495
25221
  Object.assign(this, object);
25496
25222
  this.createdAt = new Date(object.createdAt);
25497
25223
  this.updatedAt = new Date(object.updatedAt);
25498
- // Backward compatibility: infer isPublic from old linkShare/visibility fields
25499
- this.isPublic = object.isPublic ?? object.linkShare?.enabled ?? (object.visibility === 'shared');
25500
25224
  return this;
25501
25225
  }
25502
25226
  }
@@ -26880,7 +26604,8 @@ exports.DEFAULT_BRUSH_CONFIG = DEFAULT_BRUSH_CONFIG;
26880
26604
  exports.DEFAULT_COLOR_PALETTE = DEFAULT_COLOR_PALETTE;
26881
26605
  exports.DEFAULT_LINE_TOOL_CONFIG = DEFAULT_LINE_TOOL_CONFIG;
26882
26606
  exports.DEFAULT_TEXT_CONFIG = DEFAULT_TEXT_CONFIG;
26883
- exports.HocuspocusSyncProvider = HocuspocusSyncProvider;
26607
+ exports.HocuspocusProvider = HocuspocusProvider;
26608
+ exports.HocuspocusProviderWebsocket = HocuspocusProviderWebsocket;
26884
26609
  exports.IndexedDBSyncProvider = IndexedDBSyncProvider;
26885
26610
  exports.KritzelAnchorManager = KritzelAnchorManager;
26886
26611
  exports.KritzelBaseHandler = KritzelBaseHandler;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var alignment_enum = require('./alignment.enum-BhN7ih5b.js');
3
+ var alignment_enum = require('./alignment.enum-CCaamYTo.js');
4
4
  var Y = require('yjs');
5
5
  var yWebsocket = require('y-websocket');
6
6
  require('y-indexeddb');
@@ -547,10 +547,262 @@ class WebSocketSyncProvider {
547
547
  }
548
548
  }
549
549
 
550
+ /**
551
+ * Hocuspocus sync provider for real-time collaboration
552
+ * Supports multiplexing - multiple documents can share the same WebSocket connection
553
+ */
554
+ class HocuspocusSyncProvider {
555
+ provider;
556
+ isConnected = false;
557
+ isSynced = false;
558
+ usesSharedSocket = false;
559
+ get awareness() {
560
+ return this.provider.awareness;
561
+ }
562
+ // Static shared WebSocket instance for multiplexing
563
+ static sharedWebSocketProvider = null;
564
+ constructor(docName, doc, options) {
565
+ const name = options?.name || docName;
566
+ const url = options?.url || 'ws://localhost:1234';
567
+ // Use provided websocketProvider or the static shared one
568
+ const websocketProvider = options?.websocketProvider || HocuspocusSyncProvider.sharedWebSocketProvider;
569
+ if (websocketProvider) {
570
+ // Multiplexing mode - use shared WebSocket connection
571
+ this.usesSharedSocket = true;
572
+ const config = {
573
+ websocketProvider,
574
+ name,
575
+ document: doc,
576
+ token: options?.token || null,
577
+ onConnect: () => {
578
+ if (this.isConnected) {
579
+ return;
580
+ }
581
+ this.isConnected = true;
582
+ if (!options?.quiet) {
583
+ console.info(`Hocuspocus connected: ${name}`);
584
+ }
585
+ if (options?.onConnect) {
586
+ options.onConnect();
587
+ }
588
+ },
589
+ onDisconnect: () => {
590
+ if (!this.isConnected && !this.isSynced) {
591
+ return;
592
+ }
593
+ this.isConnected = false;
594
+ this.isSynced = false;
595
+ if (!options?.quiet) {
596
+ console.info(`Hocuspocus disconnected: ${name}`);
597
+ }
598
+ if (options?.onDisconnect) {
599
+ options.onDisconnect();
600
+ }
601
+ },
602
+ onSynced: () => {
603
+ if (this.isSynced) {
604
+ return;
605
+ }
606
+ this.isSynced = true;
607
+ if (!options?.quiet) {
608
+ console.info(`Hocuspocus synced: ${name}`);
609
+ }
610
+ if (options?.onSynced) {
611
+ options.onSynced();
612
+ }
613
+ },
614
+ };
615
+ // Add optional settings
616
+ if (options?.forceSyncInterval !== undefined) {
617
+ config.forceSyncInterval = options.forceSyncInterval;
618
+ }
619
+ if (options?.onAuthenticationFailed) {
620
+ config.onAuthenticationFailed = options.onAuthenticationFailed;
621
+ }
622
+ if (options?.onStatus) {
623
+ config.onStatus = options.onStatus;
624
+ }
625
+ this.provider = new alignment_enum.HocuspocusProvider(config);
626
+ // Must call attach() explicitly when using shared socket
627
+ this.provider.attach();
628
+ if (!options?.quiet) {
629
+ console.info(`Hocuspocus Provider initialized (multiplexed): ${name}`);
630
+ }
631
+ }
632
+ else {
633
+ // Standalone mode - create own WebSocket connection
634
+ this.usesSharedSocket = false;
635
+ const config = {
636
+ url,
637
+ name,
638
+ document: doc,
639
+ token: options?.token || null,
640
+ onConnect: () => {
641
+ if (this.isConnected) {
642
+ return;
643
+ }
644
+ this.isConnected = true;
645
+ if (!options?.quiet) {
646
+ console.info(`Hocuspocus connected: ${name}`);
647
+ }
648
+ if (options?.onConnect) {
649
+ options.onConnect();
650
+ }
651
+ },
652
+ onDisconnect: () => {
653
+ if (!this.isConnected && !this.isSynced) {
654
+ return;
655
+ }
656
+ this.isConnected = false;
657
+ this.isSynced = false;
658
+ if (!options?.quiet) {
659
+ console.info(`Hocuspocus disconnected: ${name}`);
660
+ }
661
+ if (options?.onDisconnect) {
662
+ options.onDisconnect();
663
+ }
664
+ },
665
+ onSynced: () => {
666
+ if (this.isSynced) {
667
+ return;
668
+ }
669
+ this.isSynced = true;
670
+ if (!options?.quiet) {
671
+ console.info(`Hocuspocus synced: ${name}`);
672
+ }
673
+ if (options?.onSynced) {
674
+ options.onSynced();
675
+ }
676
+ },
677
+ };
678
+ // Add optional settings
679
+ if (options?.forceSyncInterval !== undefined) {
680
+ config.forceSyncInterval = options.forceSyncInterval;
681
+ }
682
+ if (options?.onAuthenticationFailed) {
683
+ config.onAuthenticationFailed = options.onAuthenticationFailed;
684
+ }
685
+ if (options?.onStatus) {
686
+ config.onStatus = options.onStatus;
687
+ }
688
+ if (options?.WebSocketPolyfill) {
689
+ config.WebSocketPolyfill = options.WebSocketPolyfill;
690
+ }
691
+ this.provider = new alignment_enum.HocuspocusProvider(config);
692
+ if (!options?.quiet) {
693
+ console.info(`Hocuspocus Provider initialized: ${url}/${name}`);
694
+ }
695
+ }
696
+ }
697
+ /**
698
+ * Create a shared WebSocket connection for multiplexing
699
+ * Call this once to create a shared connection that multiple providers can use
700
+ */
701
+ static createSharedWebSocket(options) {
702
+ if (HocuspocusSyncProvider.sharedWebSocketProvider) {
703
+ console.warn('Shared WebSocket already exists. Returning existing instance.');
704
+ return HocuspocusSyncProvider.sharedWebSocketProvider;
705
+ }
706
+ const config = {
707
+ url: options.url,
708
+ };
709
+ if (options.WebSocketPolyfill) {
710
+ config.WebSocketPolyfill = options.WebSocketPolyfill;
711
+ }
712
+ if (options.onConnect) {
713
+ config.onConnect = options.onConnect;
714
+ }
715
+ if (options.onDisconnect) {
716
+ config.onDisconnect = options.onDisconnect;
717
+ }
718
+ if (options.onStatus) {
719
+ config.onStatus = options.onStatus;
720
+ }
721
+ HocuspocusSyncProvider.sharedWebSocketProvider = new alignment_enum.HocuspocusProviderWebsocket(config);
722
+ console.info(`Shared Hocuspocus WebSocket created: ${options.url}`);
723
+ return HocuspocusSyncProvider.sharedWebSocketProvider;
724
+ }
725
+ /**
726
+ * Destroy the shared WebSocket connection
727
+ * Call this when you're done with all multiplexed providers
728
+ */
729
+ static destroySharedWebSocket() {
730
+ if (HocuspocusSyncProvider.sharedWebSocketProvider) {
731
+ HocuspocusSyncProvider.sharedWebSocketProvider.destroy();
732
+ HocuspocusSyncProvider.sharedWebSocketProvider = null;
733
+ console.info('Shared Hocuspocus WebSocket destroyed');
734
+ }
735
+ }
736
+ /**
737
+ * Get the shared WebSocket provider instance (if it exists)
738
+ */
739
+ static getSharedWebSocket() {
740
+ return HocuspocusSyncProvider.sharedWebSocketProvider;
741
+ }
742
+ /**
743
+ * Static factory method for creating HocuspocusSyncProvider with configuration options
744
+ * Returns a ProviderFactory that can be used in sync configuration
745
+ */
746
+ static with(options) {
747
+ return {
748
+ create: (docName, doc, runtimeOptions) => {
749
+ const mergedOptions = runtimeOptions ? { ...options, ...runtimeOptions } : options;
750
+ return new HocuspocusSyncProvider(docName, doc, mergedOptions);
751
+ },
752
+ };
753
+ }
754
+ async connect() {
755
+ if (this.isSynced) {
756
+ return;
757
+ }
758
+ return new Promise((resolve, reject) => {
759
+ const timeout = setTimeout(() => {
760
+ reject(new Error('Hocuspocus connection timeout'));
761
+ }, 10000); // 10 second timeout
762
+ const syncHandler = () => {
763
+ clearTimeout(timeout);
764
+ this.provider.off('synced', syncHandler);
765
+ resolve();
766
+ };
767
+ this.provider.on('synced', syncHandler);
768
+ // If already synced, resolve immediately
769
+ if (this.provider.isSynced) {
770
+ clearTimeout(timeout);
771
+ this.provider.off('synced', syncHandler);
772
+ resolve();
773
+ return;
774
+ }
775
+ // Connect if not already connected (standalone mode only)
776
+ if (!this.isConnected && !this.usesSharedSocket) {
777
+ this.provider.connect();
778
+ }
779
+ });
780
+ }
781
+ disconnect() {
782
+ if (this.provider) {
783
+ if (this.usesSharedSocket) {
784
+ // Detach from shared socket instead of disconnecting
785
+ this.provider.detach();
786
+ }
787
+ else {
788
+ this.provider.disconnect();
789
+ }
790
+ }
791
+ this.isConnected = false;
792
+ this.isSynced = false;
793
+ }
794
+ destroy() {
795
+ if (this.provider) {
796
+ this.provider.destroy();
797
+ }
798
+ this.isConnected = false;
799
+ this.isSynced = false;
800
+ }
801
+ }
802
+
550
803
  exports.DEFAULT_BRUSH_CONFIG = alignment_enum.DEFAULT_BRUSH_CONFIG;
551
804
  exports.DEFAULT_LINE_TOOL_CONFIG = alignment_enum.DEFAULT_LINE_TOOL_CONFIG;
552
805
  exports.DEFAULT_TEXT_CONFIG = alignment_enum.DEFAULT_TEXT_CONFIG;
553
- exports.HocuspocusSyncProvider = alignment_enum.HocuspocusSyncProvider;
554
806
  exports.IndexedDBSyncProvider = alignment_enum.IndexedDBSyncProvider;
555
807
  Object.defineProperty(exports, "KritzelAlignment", {
556
808
  enumerable: true,
@@ -581,4 +833,5 @@ exports.WORKSPACE_EXPORT_VERSION = alignment_enum.WORKSPACE_EXPORT_VERSION;
581
833
  exports.darkTheme = alignment_enum.darkTheme;
582
834
  exports.lightTheme = alignment_enum.lightTheme;
583
835
  exports.BroadcastSyncProvider = BroadcastSyncProvider;
836
+ exports.HocuspocusSyncProvider = HocuspocusSyncProvider;
584
837
  exports.WebSocketSyncProvider = WebSocketSyncProvider;