kritzel-stencil 0.1.75 → 0.1.77
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 +2 -330
- package/dist/cjs/kritzel-active-users_42.cjs.entry.js +124 -22
- package/dist/cjs/{workspace.migrations-DkmVO6dE.js → workspace.migrations-OULs44dI.js} +331 -2
- package/dist/collection/classes/core/viewport.class.js +24 -1
- package/dist/collection/classes/objects/selection-group.class.js +2 -0
- package/dist/collection/classes/structures/object-map.structure.js +58 -2
- package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.css +8 -3
- package/dist/collection/components/core/kritzel-awareness-cursors/kritzel-awareness-cursors.js +11 -3
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +2 -0
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +12 -6
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +18 -8
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +1 -0
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-awareness-cursors.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/kritzel-utility-panel.js +1 -1
- package/dist/components/{p-DvIEvoZu.js → p-BK1hLBTd.js} +1 -1
- package/dist/components/p-BdGcOXa5.js +9 -0
- package/dist/components/{p-CsoDfhD5.js → p-C_X8stam.js} +1 -1
- package/dist/components/p-WotNmY5q.js +1 -0
- package/dist/components/{p-D0MQFmqi.js → p-XS5J5W5_.js} +1 -1
- package/dist/components/{p-CJ2eHeoV.js → p-_CqLIbO6.js} +1 -1
- package/dist/components/{p-2OYw6GJ7.js → p-_LbtY-TA.js} +1 -1
- package/dist/esm/index.js +2 -331
- package/dist/esm/kritzel-active-users_42.entry.js +124 -22
- package/dist/esm/{workspace.migrations-D48_Bqvh.js → workspace.migrations-D6whgl7G.js} +331 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-8fe1ec39.entry.js +9 -0
- package/dist/stencil/p-D6whgl7G.js +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/viewport.class.d.ts +8 -0
- package/dist/types/classes/objects/selection-group.class.d.ts +1 -0
- package/dist/types/classes/structures/object-map.structure.d.ts +6 -0
- package/dist/types/components.d.ts +8 -2
- package/dist/types/constants/version.d.ts +1 -1
- package/dist/types/interfaces/remote-cursor.interface.d.ts +1 -0
- package/package.json +1 -1
- package/dist/components/p-BSipRoFx.js +0 -1
- package/dist/components/p-WmxufeOo.js +0 -9
- package/dist/stencil/p-0dbd9a2f.entry.js +0 -9
- package/dist/stencil/p-D48_Bqvh.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var workspace_migrations = require('./workspace.migrations-
|
|
3
|
+
var workspace_migrations = require('./workspace.migrations-OULs44dI.js');
|
|
4
4
|
var Y = require('yjs');
|
|
5
5
|
var yWebsocket = require('y-websocket');
|
|
6
6
|
require('y-indexeddb');
|
|
@@ -557,340 +557,13 @@ class WebSocketSyncProvider {
|
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
/**
|
|
561
|
-
* Hocuspocus sync provider for real-time collaboration
|
|
562
|
-
* Supports multiplexing - multiple documents can share the same WebSocket connection
|
|
563
|
-
*/
|
|
564
|
-
class HocuspocusSyncProvider {
|
|
565
|
-
type = 'network';
|
|
566
|
-
provider;
|
|
567
|
-
isConnected = false;
|
|
568
|
-
isSynced = false;
|
|
569
|
-
usesSharedSocket = false;
|
|
570
|
-
isDestroyed = false;
|
|
571
|
-
connectTimeout = null;
|
|
572
|
-
pendingConnectReject = null;
|
|
573
|
-
connectionTimeoutMs;
|
|
574
|
-
_connectionStatus = 'disconnected';
|
|
575
|
-
visibilityHandler = null;
|
|
576
|
-
onlineHandler = null;
|
|
577
|
-
get awareness() {
|
|
578
|
-
return this.provider.awareness;
|
|
579
|
-
}
|
|
580
|
-
get connectionStatus() {
|
|
581
|
-
return this._connectionStatus;
|
|
582
|
-
}
|
|
583
|
-
// Static shared WebSocket instance for multiplexing
|
|
584
|
-
static sharedWebSocketProvider = null;
|
|
585
|
-
constructor(docName, doc, options) {
|
|
586
|
-
const name = options?.name || docName;
|
|
587
|
-
const url = options?.url || 'ws://localhost:1234';
|
|
588
|
-
this.connectionTimeoutMs = options?.connectionTimeout ?? 10000;
|
|
589
|
-
// Use provided websocketProvider or the static shared one
|
|
590
|
-
const websocketProvider = options?.websocketProvider || HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
591
|
-
// Build reconnect config from options
|
|
592
|
-
const reconnectConfig = {};
|
|
593
|
-
if (options?.delay !== undefined)
|
|
594
|
-
reconnectConfig.delay = options.delay;
|
|
595
|
-
if (options?.factor !== undefined)
|
|
596
|
-
reconnectConfig.factor = options.factor;
|
|
597
|
-
if (options?.maxAttempts !== undefined)
|
|
598
|
-
reconnectConfig.maxAttempts = options.maxAttempts;
|
|
599
|
-
if (options?.minDelay !== undefined)
|
|
600
|
-
reconnectConfig.minDelay = options.minDelay;
|
|
601
|
-
if (options?.maxDelay !== undefined)
|
|
602
|
-
reconnectConfig.maxDelay = options.maxDelay;
|
|
603
|
-
const onConnect = () => {
|
|
604
|
-
if (this.isDestroyed) {
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
|
-
this.isConnected = true;
|
|
608
|
-
this._connectionStatus = 'connected';
|
|
609
|
-
if (!options?.quiet) {
|
|
610
|
-
console.info(`Hocuspocus connected: ${name}`);
|
|
611
|
-
}
|
|
612
|
-
if (options?.onConnect) {
|
|
613
|
-
options.onConnect();
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
const onDisconnect = () => {
|
|
617
|
-
if (this.isDestroyed) {
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
this.isConnected = false;
|
|
621
|
-
this.isSynced = false;
|
|
622
|
-
this._connectionStatus = 'disconnected';
|
|
623
|
-
if (!options?.quiet) {
|
|
624
|
-
console.info(`Hocuspocus disconnected: ${name}`);
|
|
625
|
-
}
|
|
626
|
-
if (options?.onDisconnect) {
|
|
627
|
-
options.onDisconnect();
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
const onSynced = () => {
|
|
631
|
-
if (this.isDestroyed) {
|
|
632
|
-
return;
|
|
633
|
-
}
|
|
634
|
-
this.isSynced = true;
|
|
635
|
-
this._connectionStatus = 'synced';
|
|
636
|
-
if (!options?.quiet) {
|
|
637
|
-
console.info(`Hocuspocus synced: ${name}`);
|
|
638
|
-
}
|
|
639
|
-
if (options?.onSynced) {
|
|
640
|
-
options.onSynced();
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
const onStatus = (data) => {
|
|
644
|
-
if (this.isDestroyed) {
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
if (data.status === 'connecting') {
|
|
648
|
-
this._connectionStatus = 'connecting';
|
|
649
|
-
}
|
|
650
|
-
if (options?.onStatus) {
|
|
651
|
-
options.onStatus(data);
|
|
652
|
-
}
|
|
653
|
-
};
|
|
654
|
-
if (websocketProvider) {
|
|
655
|
-
// Multiplexing mode - use shared WebSocket connection
|
|
656
|
-
this.usesSharedSocket = true;
|
|
657
|
-
const config = {
|
|
658
|
-
websocketProvider,
|
|
659
|
-
name,
|
|
660
|
-
document: doc,
|
|
661
|
-
token: options?.token || null,
|
|
662
|
-
onStatus,
|
|
663
|
-
onConnect,
|
|
664
|
-
onDisconnect,
|
|
665
|
-
onSynced,
|
|
666
|
-
...reconnectConfig,
|
|
667
|
-
};
|
|
668
|
-
// Add optional settings
|
|
669
|
-
if (options?.forceSyncInterval !== undefined) {
|
|
670
|
-
config.forceSyncInterval = options.forceSyncInterval;
|
|
671
|
-
}
|
|
672
|
-
if (options?.onAuthenticationFailed) {
|
|
673
|
-
config.onAuthenticationFailed = options.onAuthenticationFailed;
|
|
674
|
-
}
|
|
675
|
-
this.provider = new workspace_migrations.HocuspocusProvider(config);
|
|
676
|
-
// Must call attach() explicitly when using shared socket
|
|
677
|
-
this.provider.attach();
|
|
678
|
-
if (!options?.quiet) {
|
|
679
|
-
console.info(`Hocuspocus Provider initialized (multiplexed): ${name}`);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
else {
|
|
683
|
-
// Standalone mode - create own WebSocket connection
|
|
684
|
-
this.usesSharedSocket = false;
|
|
685
|
-
const config = {
|
|
686
|
-
url,
|
|
687
|
-
name,
|
|
688
|
-
document: doc,
|
|
689
|
-
token: options?.token || null,
|
|
690
|
-
autoConnect: false,
|
|
691
|
-
onStatus,
|
|
692
|
-
onConnect,
|
|
693
|
-
onDisconnect,
|
|
694
|
-
onSynced,
|
|
695
|
-
...reconnectConfig,
|
|
696
|
-
};
|
|
697
|
-
// Add optional settings
|
|
698
|
-
if (options?.forceSyncInterval !== undefined) {
|
|
699
|
-
config.forceSyncInterval = options.forceSyncInterval;
|
|
700
|
-
}
|
|
701
|
-
if (options?.onAuthenticationFailed) {
|
|
702
|
-
config.onAuthenticationFailed = options.onAuthenticationFailed;
|
|
703
|
-
}
|
|
704
|
-
if (options?.WebSocketPolyfill) {
|
|
705
|
-
config.WebSocketPolyfill = options.WebSocketPolyfill;
|
|
706
|
-
}
|
|
707
|
-
this.provider = new workspace_migrations.HocuspocusProvider(config);
|
|
708
|
-
if (!options?.quiet) {
|
|
709
|
-
console.info(`Hocuspocus Provider initialized: ${url}/${name}`);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
this.setupBrowserEventListeners();
|
|
713
|
-
}
|
|
714
|
-
setupBrowserEventListeners() {
|
|
715
|
-
if (typeof document !== 'undefined') {
|
|
716
|
-
this.visibilityHandler = () => {
|
|
717
|
-
if (document.visibilityState === 'visible' && !this.isConnected && !this.isDestroyed) {
|
|
718
|
-
this.provider.connect();
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
document.addEventListener('visibilitychange', this.visibilityHandler);
|
|
722
|
-
}
|
|
723
|
-
if (typeof window !== 'undefined') {
|
|
724
|
-
this.onlineHandler = () => {
|
|
725
|
-
if (!this.isConnected && !this.isDestroyed) {
|
|
726
|
-
this.provider.connect();
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
window.addEventListener('online', this.onlineHandler);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
removeBrowserEventListeners() {
|
|
733
|
-
if (this.visibilityHandler && typeof document !== 'undefined') {
|
|
734
|
-
document.removeEventListener('visibilitychange', this.visibilityHandler);
|
|
735
|
-
this.visibilityHandler = null;
|
|
736
|
-
}
|
|
737
|
-
if (this.onlineHandler && typeof window !== 'undefined') {
|
|
738
|
-
window.removeEventListener('online', this.onlineHandler);
|
|
739
|
-
this.onlineHandler = null;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* Create a shared WebSocket connection for multiplexing
|
|
744
|
-
* Call this once to create a shared connection that multiple providers can use
|
|
745
|
-
*/
|
|
746
|
-
static createSharedWebSocket(options) {
|
|
747
|
-
if (HocuspocusSyncProvider.sharedWebSocketProvider) {
|
|
748
|
-
console.warn('Shared WebSocket already exists. Returning existing instance.');
|
|
749
|
-
return HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
750
|
-
}
|
|
751
|
-
const config = {
|
|
752
|
-
url: options.url,
|
|
753
|
-
};
|
|
754
|
-
if (options.WebSocketPolyfill) {
|
|
755
|
-
config.WebSocketPolyfill = options.WebSocketPolyfill;
|
|
756
|
-
}
|
|
757
|
-
if (options.onConnect) {
|
|
758
|
-
config.onConnect = options.onConnect;
|
|
759
|
-
}
|
|
760
|
-
if (options.onDisconnect) {
|
|
761
|
-
config.onDisconnect = options.onDisconnect;
|
|
762
|
-
}
|
|
763
|
-
if (options.onStatus) {
|
|
764
|
-
config.onStatus = options.onStatus;
|
|
765
|
-
}
|
|
766
|
-
HocuspocusSyncProvider.sharedWebSocketProvider = new workspace_migrations.HocuspocusProviderWebsocket(config);
|
|
767
|
-
console.info(`Shared Hocuspocus WebSocket created: ${options.url}`);
|
|
768
|
-
return HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Destroy the shared WebSocket connection
|
|
772
|
-
* Call this when you're done with all multiplexed providers
|
|
773
|
-
*/
|
|
774
|
-
static destroySharedWebSocket() {
|
|
775
|
-
if (HocuspocusSyncProvider.sharedWebSocketProvider) {
|
|
776
|
-
HocuspocusSyncProvider.sharedWebSocketProvider.destroy();
|
|
777
|
-
HocuspocusSyncProvider.sharedWebSocketProvider = null;
|
|
778
|
-
console.info('Shared Hocuspocus WebSocket destroyed');
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Get the shared WebSocket provider instance (if it exists)
|
|
783
|
-
*/
|
|
784
|
-
static getSharedWebSocket() {
|
|
785
|
-
return HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* Static factory method for creating HocuspocusSyncProvider with configuration options
|
|
789
|
-
* Returns a ProviderFactory that can be used in sync configuration
|
|
790
|
-
*/
|
|
791
|
-
static with(options) {
|
|
792
|
-
return {
|
|
793
|
-
create: (docName, doc, runtimeOptions) => {
|
|
794
|
-
const mergedOptions = runtimeOptions ? { ...options, ...runtimeOptions } : options;
|
|
795
|
-
return new HocuspocusSyncProvider(docName, doc, mergedOptions);
|
|
796
|
-
},
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
async connect() {
|
|
800
|
-
if (this.isSynced || this.isDestroyed) {
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
this._connectionStatus = 'connecting';
|
|
804
|
-
return new Promise((resolve, reject) => {
|
|
805
|
-
// Store reject function so we can cancel the connection if destroyed
|
|
806
|
-
this.pendingConnectReject = reject;
|
|
807
|
-
this.connectTimeout = setTimeout(() => {
|
|
808
|
-
this.pendingConnectReject = null;
|
|
809
|
-
this.connectTimeout = null;
|
|
810
|
-
reject(new Error('Hocuspocus connection timeout'));
|
|
811
|
-
}, this.connectionTimeoutMs);
|
|
812
|
-
const syncHandler = () => {
|
|
813
|
-
if (this.connectTimeout) {
|
|
814
|
-
clearTimeout(this.connectTimeout);
|
|
815
|
-
this.connectTimeout = null;
|
|
816
|
-
}
|
|
817
|
-
this.pendingConnectReject = null;
|
|
818
|
-
this.provider.off('synced', syncHandler);
|
|
819
|
-
if (!this.isDestroyed) {
|
|
820
|
-
resolve();
|
|
821
|
-
}
|
|
822
|
-
};
|
|
823
|
-
this.provider.on('synced', syncHandler);
|
|
824
|
-
// If already synced, resolve immediately
|
|
825
|
-
if (this.provider.isSynced) {
|
|
826
|
-
if (this.connectTimeout) {
|
|
827
|
-
clearTimeout(this.connectTimeout);
|
|
828
|
-
this.connectTimeout = null;
|
|
829
|
-
}
|
|
830
|
-
this.pendingConnectReject = null;
|
|
831
|
-
this.provider.off('synced', syncHandler);
|
|
832
|
-
resolve();
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
// Connect if not already connected (standalone mode only)
|
|
836
|
-
if (!this.isConnected && !this.usesSharedSocket) {
|
|
837
|
-
this.provider.connect();
|
|
838
|
-
}
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
async reconnect() {
|
|
842
|
-
this.disconnect();
|
|
843
|
-
return this.connect();
|
|
844
|
-
}
|
|
845
|
-
disconnect() {
|
|
846
|
-
// Cancel any pending connection attempt
|
|
847
|
-
if (this.connectTimeout) {
|
|
848
|
-
clearTimeout(this.connectTimeout);
|
|
849
|
-
this.connectTimeout = null;
|
|
850
|
-
}
|
|
851
|
-
if (this.pendingConnectReject) {
|
|
852
|
-
this.pendingConnectReject = null; // Don't reject, just abandon the promise
|
|
853
|
-
}
|
|
854
|
-
if (this.provider) {
|
|
855
|
-
if (this.usesSharedSocket) {
|
|
856
|
-
// Detach from shared socket instead of disconnecting
|
|
857
|
-
this.provider.detach();
|
|
858
|
-
}
|
|
859
|
-
else {
|
|
860
|
-
this.provider.disconnect();
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
this.isConnected = false;
|
|
864
|
-
this.isSynced = false;
|
|
865
|
-
this._connectionStatus = 'disconnected';
|
|
866
|
-
}
|
|
867
|
-
destroy() {
|
|
868
|
-
// Mark as destroyed first to prevent any callbacks from doing work
|
|
869
|
-
this.isDestroyed = true;
|
|
870
|
-
// Cancel any pending connection attempt
|
|
871
|
-
if (this.connectTimeout) {
|
|
872
|
-
clearTimeout(this.connectTimeout);
|
|
873
|
-
this.connectTimeout = null;
|
|
874
|
-
}
|
|
875
|
-
if (this.pendingConnectReject) {
|
|
876
|
-
this.pendingConnectReject = null; // Don't reject, just abandon the promise
|
|
877
|
-
}
|
|
878
|
-
this.removeBrowserEventListeners();
|
|
879
|
-
if (this.provider) {
|
|
880
|
-
this.provider.destroy();
|
|
881
|
-
}
|
|
882
|
-
this.isConnected = false;
|
|
883
|
-
this.isSynced = false;
|
|
884
|
-
this._connectionStatus = 'disconnected';
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
560
|
exports.APP_STATE_MIGRATIONS = workspace_migrations.APP_STATE_MIGRATIONS;
|
|
889
561
|
exports.CURRENT_APP_STATE_SCHEMA_VERSION = workspace_migrations.CURRENT_APP_STATE_SCHEMA_VERSION;
|
|
890
562
|
exports.CURRENT_WORKSPACE_SCHEMA_VERSION = workspace_migrations.CURRENT_WORKSPACE_SCHEMA_VERSION;
|
|
891
563
|
exports.DEFAULT_BRUSH_CONFIG = workspace_migrations.DEFAULT_BRUSH_CONFIG;
|
|
892
564
|
exports.DEFAULT_LINE_TOOL_CONFIG = workspace_migrations.DEFAULT_LINE_TOOL_CONFIG;
|
|
893
565
|
exports.DEFAULT_TEXT_CONFIG = workspace_migrations.DEFAULT_TEXT_CONFIG;
|
|
566
|
+
exports.HocuspocusSyncProvider = workspace_migrations.HocuspocusSyncProvider;
|
|
894
567
|
exports.IndexedDBSyncProvider = workspace_migrations.IndexedDBSyncProvider;
|
|
895
568
|
Object.defineProperty(exports, "KritzelAlignment", {
|
|
896
569
|
enumerable: true,
|
|
@@ -923,5 +596,4 @@ exports.darkTheme = workspace_migrations.darkTheme;
|
|
|
923
596
|
exports.lightTheme = workspace_migrations.lightTheme;
|
|
924
597
|
exports.runMigrations = workspace_migrations.runMigrations;
|
|
925
598
|
exports.BroadcastSyncProvider = BroadcastSyncProvider;
|
|
926
|
-
exports.HocuspocusSyncProvider = HocuspocusSyncProvider;
|
|
927
599
|
exports.WebSocketSyncProvider = WebSocketSyncProvider;
|