kritzel-stencil 0.4.23 → 0.4.25
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 +3 -46
- package/dist/cjs/kritzel-active-users_47.cjs.entry.js +93 -138
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/core/core.class.js +4 -0
- package/dist/collection/classes/providers/sync/hocuspocus-sync-provider.class.js +1 -19
- package/dist/collection/classes/providers/sync/websocket-sync-provider.class.js +2 -27
- package/dist/collection/classes/structures/app-state-map.structure.js +1 -4
- package/dist/collection/classes/structures/object-map.structure.js +64 -61
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +20 -32
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +21 -73
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +4 -47
- package/dist/components/kritzel-editor.js +20 -18
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/{p-Cb-xlpsJ.js → p-0fhjWRmT.js} +1 -1
- package/dist/components/{p-EijwLEZx.js → p-gJcH-huF.js} +75 -123
- package/dist/esm/index.js +3 -46
- package/dist/esm/kritzel-active-users_47.entry.js +93 -138
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +3 -46
- package/dist/stencil/{p-9e38407e.entry.js → p-dc5783ee.entry.js} +93 -138
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/providers/sync/hocuspocus-sync-provider.class.d.ts +1 -5
- package/dist/types/classes/providers/sync/websocket-sync-provider.class.d.ts +1 -6
- package/dist/types/classes/structures/object-map.structure.d.ts +16 -26
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +3 -4
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +3 -12
- package/dist/types/components.d.ts +7 -12
- package/dist/types/constants/version.d.ts +1 -1
- package/dist/types/interfaces/sync-provider.interface.d.ts +5 -11
- package/package.json +1 -1
|
@@ -47,11 +47,8 @@ export declare class WebSocketSyncProvider implements ISyncProvider {
|
|
|
47
47
|
private provider;
|
|
48
48
|
private isConnected;
|
|
49
49
|
private _quiet;
|
|
50
|
-
private _isSynced;
|
|
51
|
-
private _syncedResolvers;
|
|
52
50
|
get awareness(): Awareness;
|
|
53
|
-
|
|
54
|
-
get updateOrigin(): unknown;
|
|
51
|
+
get rawProvider(): unknown;
|
|
55
52
|
constructor(docName: string, doc: Y.Doc, options?: WebSocketOptions);
|
|
56
53
|
/**
|
|
57
54
|
* Static factory method for creating WebSocketSyncProvider with configuration options
|
|
@@ -59,8 +56,6 @@ export declare class WebSocketSyncProvider implements ISyncProvider {
|
|
|
59
56
|
*/
|
|
60
57
|
static with(options?: WebSocketOptions): ProviderFactory;
|
|
61
58
|
private setupEventListeners;
|
|
62
|
-
private releaseSyncedWaiters;
|
|
63
|
-
whenSynced(): Promise<void>;
|
|
64
59
|
connect(): Promise<void>;
|
|
65
60
|
disconnect(): void;
|
|
66
61
|
reconnect(): Promise<void>;
|
|
@@ -34,13 +34,14 @@ export declare class KritzelObjectMap<T extends KritzelBaseObject<any>> {
|
|
|
34
34
|
private _awarenessChangeHandler;
|
|
35
35
|
private _awarenessChangeCallbacks;
|
|
36
36
|
private _objectsChangeCallbacks;
|
|
37
|
-
private _remoteChangesCallbacks;
|
|
38
|
-
private _docUpdateHandler;
|
|
39
|
-
private _remoteOrigins;
|
|
40
|
-
private _appliedRemoteChanges;
|
|
41
37
|
private _lastAwarenessEmitTime;
|
|
42
38
|
private _awarenessEmitTimeout;
|
|
43
39
|
private readonly AWARENESS_THROTTLE_INTERVAL;
|
|
40
|
+
private _networkTransactionOrigins;
|
|
41
|
+
private _isSyncing;
|
|
42
|
+
private _syncingChangeCallbacks;
|
|
43
|
+
private _beforeTransactionHandler;
|
|
44
|
+
private _afterAllTransactionsHandler;
|
|
44
45
|
/**
|
|
45
46
|
* When true, update() only modifies local state (quadtree + idMap)
|
|
46
47
|
* without writing to Yjs. Used during drag operations to avoid
|
|
@@ -59,30 +60,10 @@ export declare class KritzelObjectMap<T extends KritzelBaseObject<any>> {
|
|
|
59
60
|
*/
|
|
60
61
|
get isReady(): boolean;
|
|
61
62
|
/**
|
|
62
|
-
* Promise that settles when network providers finish connecting
|
|
63
|
-
*
|
|
63
|
+
* Promise that settles when network providers finish connecting.
|
|
64
|
+
* Resolves immediately if no network providers. Awaited by the loading overlay.
|
|
64
65
|
*/
|
|
65
66
|
whenNetworkSynced(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Whether any configured provider synchronizes over the network.
|
|
68
|
-
*/
|
|
69
|
-
get hasNetworkSyncProvider(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Whether remote-originated changes can be told apart from local writes.
|
|
72
|
-
* Requires every network provider to expose its Yjs update origin.
|
|
73
|
-
*/
|
|
74
|
-
get supportsRemoteChangeDetection(): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Whether at least one update originating from a network provider has been
|
|
77
|
-
* applied to this document. Stays `false` when the remote held no data the
|
|
78
|
-
* local document was missing, because Yjs suppresses empty updates.
|
|
79
|
-
*/
|
|
80
|
-
get hasAppliedRemoteChanges(): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Registers a callback invoked whenever a network provider applies changes to this document.
|
|
83
|
-
* @returns A function that unregisters the callback.
|
|
84
|
-
*/
|
|
85
|
-
onRemoteChangesApplied(callback: () => void): () => void;
|
|
86
67
|
/**
|
|
87
68
|
* Returns the Yjs Awareness instance, if a network provider is available.
|
|
88
69
|
*/
|
|
@@ -149,6 +130,15 @@ export declare class KritzelObjectMap<T extends KritzelBaseObject<any>> {
|
|
|
149
130
|
* from the latest object data when a remote user is actively drawing.
|
|
150
131
|
*/
|
|
151
132
|
onObjectsChange(callback: () => void): () => void;
|
|
133
|
+
/**
|
|
134
|
+
* Whether the local copy currently differs from data a remote peer is in the process of merging in.
|
|
135
|
+
*/
|
|
136
|
+
get isSyncing(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Registers a callback invoked when a remote sync starts (`true`) or finishes (`false`).
|
|
139
|
+
* "Starts" fires from `beforeTransaction`, before the incoming remote update is merged.
|
|
140
|
+
*/
|
|
141
|
+
onSyncingChange(callback: (isSyncing: boolean) => void): () => void;
|
|
152
142
|
/**
|
|
153
143
|
* Returns the Yjs UndoManager instance for managing undo/redo operations.
|
|
154
144
|
* @returns The UndoManager instance, or `null` if not initialized
|
|
@@ -92,9 +92,7 @@ export declare class KritzelEditor {
|
|
|
92
92
|
login: EventEmitter<LoginEvent>;
|
|
93
93
|
isPublicChange: EventEmitter<IKritzelIsPublicChangedEvent>;
|
|
94
94
|
awarenessChange: EventEmitter<Map<number, Record<string, any>>>;
|
|
95
|
-
|
|
96
|
-
syncingChange: EventEmitter<boolean>;
|
|
97
|
-
loadingChange: EventEmitter<boolean>;
|
|
95
|
+
isSyncing: EventEmitter<boolean>;
|
|
98
96
|
isEngineReady: boolean;
|
|
99
97
|
isControlsReady: boolean;
|
|
100
98
|
isWorkspaceManagerReady: boolean;
|
|
@@ -119,8 +117,8 @@ export declare class KritzelEditor {
|
|
|
119
117
|
contextMenuState?: KritzelContextMenuState;
|
|
120
118
|
normalizedControls: KritzelToolbarControl[];
|
|
121
119
|
resolvedMoreMenuItems: IKritzelMenuItem[];
|
|
122
|
-
isSyncing: boolean;
|
|
123
120
|
isLoadingOverlayVisible: boolean;
|
|
121
|
+
isSyncingIndicatorVisible: boolean;
|
|
124
122
|
private notificationDismissTimeout?;
|
|
125
123
|
private notificationDismissAnimationTimeout?;
|
|
126
124
|
private readonly notificationDisplayDurationMs;
|
|
@@ -266,6 +264,7 @@ export declare class KritzelEditor {
|
|
|
266
264
|
handleViewportChange(event: CustomEvent<KritzelViewportState>): void;
|
|
267
265
|
private getZoomPercentFromScale;
|
|
268
266
|
handleAwarenessChange(event: CustomEvent<Map<number, Record<string, any>>>): void;
|
|
267
|
+
handleIsSyncingChange(event: CustomEvent<boolean>): void;
|
|
269
268
|
handleNotificationsChange(event: CustomEvent<KritzelNotification>): void;
|
|
270
269
|
handleContextMenuStateChange(event: CustomEvent<KritzelContextMenuState>): void;
|
|
271
270
|
private handleContextMenuActionSelected;
|
|
@@ -140,16 +140,15 @@ export declare class KritzelEngine {
|
|
|
140
140
|
viewportChange: EventEmitter<KritzelViewportState>;
|
|
141
141
|
/** Emitted when the awareness state changes (remote user cursors, presence). */
|
|
142
142
|
awarenessChange: EventEmitter<Map<number, Record<string, any>>>;
|
|
143
|
+
/** Emitted when a remote sync starts (`true`, data differs from the local copy) or finishes (`false`). */
|
|
144
|
+
isSyncing: EventEmitter<boolean>;
|
|
143
145
|
/** Emitted when notifications change. */
|
|
144
146
|
notificationsChange: EventEmitter<KritzelNotification>;
|
|
145
147
|
/** Emitted when context-menu visibility, items, or position changes. */
|
|
146
148
|
contextMenuStateChange: EventEmitter<KritzelContextMenuState>;
|
|
147
149
|
/** Emitted when the combined loading state (external `isLoading` prop or internal workspace loading) changes. */
|
|
148
150
|
loadingChange: EventEmitter<boolean>;
|
|
149
|
-
/** Emitted while remote changes are being applied to the active workspace. Stays silent when the remote holds nothing new. */
|
|
150
|
-
syncingChange: EventEmitter<boolean>;
|
|
151
151
|
forceUpdate: number;
|
|
152
|
-
isSyncing: boolean;
|
|
153
152
|
/** Manually triggers the `objectsSelectionChange` event. */
|
|
154
153
|
triggerSelectionChange(): Promise<void>;
|
|
155
154
|
/** Starts a scene bootstrap phase by hiding the scene immediately. */
|
|
@@ -634,7 +633,6 @@ export declare class KritzelEngine {
|
|
|
634
633
|
private _sceneBootstrapOpacity;
|
|
635
634
|
private _sceneBootstrapTransitionEnabled;
|
|
636
635
|
private _sceneBootstrapTransitionTimer;
|
|
637
|
-
private _remoteChangesUnsubscribe;
|
|
638
636
|
private readonly _defaultUndoState;
|
|
639
637
|
private readonly _objectDistanceFadeNearScale;
|
|
640
638
|
private readonly _objectDistanceFadeFarScale;
|
|
@@ -643,8 +641,6 @@ export declare class KritzelEngine {
|
|
|
643
641
|
private readonly _objectDistanceFadeCloseMaxScale;
|
|
644
642
|
private readonly _objectDistanceFadeCloseMinOpacity;
|
|
645
643
|
private syncLoadingState;
|
|
646
|
-
private syncSyncingState;
|
|
647
|
-
private clearRemoteChangesSubscription;
|
|
648
644
|
private isNetworkAvailable;
|
|
649
645
|
private emitContextMenuStateChange;
|
|
650
646
|
private applyToolConfig;
|
|
@@ -682,12 +678,6 @@ export declare class KritzelEngine {
|
|
|
682
678
|
private tryResolveActiveWorkspaceFromId;
|
|
683
679
|
private switchToWorkspaceById;
|
|
684
680
|
private initializeWorkspaceIfNeeded;
|
|
685
|
-
/**
|
|
686
|
-
* Reports syncing only while remote data is actually being reconciled into the
|
|
687
|
-
* active workspace. Yjs suppresses updates that carry nothing new, so a workspace
|
|
688
|
-
* that already matches the remote never reports syncing at all.
|
|
689
|
-
*/
|
|
690
|
-
private trackRemoteSynchronization;
|
|
691
681
|
emitObjectsChange(): void;
|
|
692
682
|
emitObjectsAdded(objects: KritzelBaseObject<any>[]): void;
|
|
693
683
|
emitObjectsRemoved(objects: KritzelBaseObject<any>[]): void;
|
|
@@ -696,6 +686,7 @@ export declare class KritzelEngine {
|
|
|
696
686
|
changedProperties: string[];
|
|
697
687
|
}[]): void;
|
|
698
688
|
emitAwarenessChange(states: Map<number, Record<string, any>>): void;
|
|
689
|
+
emitIsSyncing(isSyncing: boolean): void;
|
|
699
690
|
emitObjectsInViewportChange(): void;
|
|
700
691
|
private _registerStateChangeListeners;
|
|
701
692
|
private _handleActiveToolChange;
|
|
@@ -2003,8 +2003,7 @@ declare global {
|
|
|
2003
2003
|
"login": LoginEvent;
|
|
2004
2004
|
"isPublicChange": IKritzelIsPublicChangedEvent;
|
|
2005
2005
|
"awarenessChange": Map<number, Record<string, any>>;
|
|
2006
|
-
"
|
|
2007
|
-
"loadingChange": boolean;
|
|
2006
|
+
"isSyncing": boolean;
|
|
2008
2007
|
}
|
|
2009
2008
|
interface HTMLKritzelEditorElement extends Components.KritzelEditor, HTMLStencilElement {
|
|
2010
2009
|
addEventListener<K extends keyof HTMLKritzelEditorElementEventMap>(type: K, listener: (this: HTMLKritzelEditorElement, ev: KritzelEditorCustomEvent<HTMLKritzelEditorElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -2035,10 +2034,10 @@ declare global {
|
|
|
2035
2034
|
"objectsInViewportChange": ObjectsInViewportChangeEvent;
|
|
2036
2035
|
"viewportChange": KritzelViewportState;
|
|
2037
2036
|
"awarenessChange": Map<number, Record<string, any>>;
|
|
2037
|
+
"isSyncing": boolean;
|
|
2038
2038
|
"notificationsChange": KritzelNotification;
|
|
2039
2039
|
"contextMenuStateChange": KritzelContextMenuState;
|
|
2040
2040
|
"loadingChange": boolean;
|
|
2041
|
-
"syncingChange": boolean;
|
|
2042
2041
|
}
|
|
2043
2042
|
interface HTMLKritzelEngineElement extends Components.KritzelEngine, HTMLStencilElement {
|
|
2044
2043
|
addEventListener<K extends keyof HTMLKritzelEngineElementEventMap>(type: K, listener: (this: HTMLKritzelEngineElement, ev: KritzelEngineCustomEvent<HTMLKritzelEngineElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -3013,7 +3012,7 @@ declare namespace LocalJSX {
|
|
|
3013
3012
|
"onAwarenessChange"?: (event: KritzelEditorCustomEvent<Map<number, Record<string, any>>>) => void;
|
|
3014
3013
|
"onIsPublicChange"?: (event: KritzelEditorCustomEvent<IKritzelIsPublicChangedEvent>) => void;
|
|
3015
3014
|
"onIsReady"?: (event: KritzelEditorCustomEvent<EditorIsReadyEvent>) => void;
|
|
3016
|
-
"
|
|
3015
|
+
"onIsSyncing"?: (event: KritzelEditorCustomEvent<boolean>) => void;
|
|
3017
3016
|
"onLocaleChange"?: (event: KritzelEditorCustomEvent<LocaleCode>) => void;
|
|
3018
3017
|
"onLogin"?: (event: KritzelEditorCustomEvent<LoginEvent>) => void;
|
|
3019
3018
|
"onLogout"?: (event: KritzelEditorCustomEvent<void>) => void;
|
|
@@ -3021,10 +3020,6 @@ declare namespace LocalJSX {
|
|
|
3021
3020
|
"onObjectsChange"?: (event: KritzelEditorCustomEvent<KritzelBaseObject[]>) => void;
|
|
3022
3021
|
"onObjectsRemoved"?: (event: KritzelEditorCustomEvent<ObjectsRemovedEvent>) => void;
|
|
3023
3022
|
"onObjectsUpdated"?: (event: KritzelEditorCustomEvent<ObjectsUpdatedEvent>) => void;
|
|
3024
|
-
/**
|
|
3025
|
-
* Emitted while remote changes are being applied to the active workspace. Stays silent when the remote holds nothing new.
|
|
3026
|
-
*/
|
|
3027
|
-
"onSyncingChange"?: (event: KritzelEditorCustomEvent<boolean>) => void;
|
|
3028
3023
|
"onThemeChange"?: (event: KritzelEditorCustomEvent<ThemeName>) => void;
|
|
3029
3024
|
"onUndoStateChange"?: (event: KritzelEditorCustomEvent<KritzelUndoState1>) => void;
|
|
3030
3025
|
"onViewportChange"?: (event: KritzelEditorCustomEvent<KritzelViewportState>) => void;
|
|
@@ -3155,6 +3150,10 @@ declare namespace LocalJSX {
|
|
|
3155
3150
|
* Emitted when the engine has fully initialized and is ready for interaction.
|
|
3156
3151
|
*/
|
|
3157
3152
|
"onIsEngineReady"?: (event: KritzelEngineCustomEvent<KritzelEngineState>) => void;
|
|
3153
|
+
/**
|
|
3154
|
+
* Emitted when a remote sync starts (`true`, data differs from the local copy) or finishes (`false`).
|
|
3155
|
+
*/
|
|
3156
|
+
"onIsSyncing"?: (event: KritzelEngineCustomEvent<boolean>) => void;
|
|
3158
3157
|
/**
|
|
3159
3158
|
* Emitted when the combined loading state (external `isLoading` prop or internal workspace loading) changes.
|
|
3160
3159
|
*/
|
|
@@ -3191,10 +3190,6 @@ declare namespace LocalJSX {
|
|
|
3191
3190
|
* Emitted when one or more objects are updated on the canvas.
|
|
3192
3191
|
*/
|
|
3193
3192
|
"onObjectsUpdated"?: (event: KritzelEngineCustomEvent<ObjectsUpdatedEvent>) => void;
|
|
3194
|
-
/**
|
|
3195
|
-
* Emitted while remote changes are being applied to the active workspace. Stays silent when the remote holds nothing new.
|
|
3196
|
-
*/
|
|
3197
|
-
"onSyncingChange"?: (event: KritzelEngineCustomEvent<boolean>) => void;
|
|
3198
3193
|
/**
|
|
3199
3194
|
* Emitted when the undo/redo state changes, providing current undo availability.
|
|
3200
3195
|
*/
|
|
@@ -23,22 +23,16 @@ export interface ISyncProvider {
|
|
|
23
23
|
*/
|
|
24
24
|
readonly awareness?: Awareness | null;
|
|
25
25
|
/**
|
|
26
|
-
* The
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* The underlying third-party provider instance (e.g. `WebsocketProvider`, `HocuspocusProvider`)
|
|
27
|
+
* used as the Yjs transaction origin for updates it applies. Exposed so callers can
|
|
28
|
+
* distinguish genuine remote-origin transactions from local-only providers (IndexedDB,
|
|
29
|
+
* BroadcastChannel), which don't tag their transactions with a recognizable origin.
|
|
30
30
|
*/
|
|
31
|
-
readonly
|
|
31
|
+
readonly rawProvider?: unknown;
|
|
32
32
|
/**
|
|
33
33
|
* Initialize and connect the provider
|
|
34
34
|
*/
|
|
35
35
|
connect(): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Resolves once the Yjs sync handshake with the peer has completed, which is
|
|
38
|
-
* later than `connect()` for providers that resolve on transport connection.
|
|
39
|
-
* Never rejects.
|
|
40
|
-
*/
|
|
41
|
-
whenSynced?(): Promise<void>;
|
|
42
36
|
/**
|
|
43
37
|
* Disconnect the provider (can be reconnected later)
|
|
44
38
|
*/
|