kritzel-stencil 0.1.56 → 0.1.58
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/{alignment.enum-DM2SB8lK.js → alignment.enum-DOlCH8zf.js} +8 -265
- package/dist/cjs/index.cjs.js +255 -2
- package/dist/cjs/kritzel-active-users_38.cjs.entry.js +128 -206
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/core/core.class.js +17 -72
- package/dist/collection/classes/core/workspace.class.js +6 -11
- package/dist/collection/classes/structures/app-state-map.structure.js +2 -2
- package/dist/collection/classes/structures/object-map.structure.js +30 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +26 -33
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +19 -77
- package/dist/collection/components/shared/kritzel-avatar/kritzel-avatar.js +3 -3
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-input/kritzel-input.js +1 -1
- package/dist/collection/components/shared/kritzel-master-detail/kritzel-master-detail.js +3 -3
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -2
- package/dist/collection/components/shared/kritzel-numeric-input/kritzel-numeric-input.js +1 -1
- package/dist/collection/components/shared/kritzel-opacity-slider/kritzel-opacity-slider.js +1 -1
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +1 -1
- package/dist/collection/components/shared/kritzel-slide-toggle/kritzel-slide-toggle.js +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +2 -2
- package/dist/collection/components/ui/kritzel-back-to-content/kritzel-back-to-content.js +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +5 -5
- package/dist/collection/components/ui/kritzel-export/kritzel-export.js +1 -1
- package/dist/collection/components/ui/kritzel-more-menu/kritzel-more-menu.js +1 -1
- package/dist/collection/components/ui/kritzel-settings/kritzel-settings.js +1 -1
- package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.js +31 -97
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +2 -3
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-active-users.js +1 -1
- package/dist/components/kritzel-avatar.js +1 -1
- package/dist/components/kritzel-back-to-content.js +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-current-user.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-export.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-input.js +1 -1
- package/dist/components/kritzel-master-detail.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-more-menu.js +1 -1
- package/dist/components/kritzel-numeric-input.js +1 -1
- package/dist/components/kritzel-opacity-slider.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-share-dialog.js +1 -1
- package/dist/components/kritzel-slide-toggle.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tool-config.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-CV8cEq9m.js → p-35nrk8s0.js} +1 -1
- package/dist/components/{p-Dptu13B1.js → p-B1C8xRSx.js} +1 -1
- package/dist/components/{p-D6nmycST.js → p-B59sC8zD.js} +1 -1
- package/dist/components/{p-CJe-9vrE.js → p-B5Ac_sYy.js} +1 -1
- package/dist/components/{p-Bk1Ispbf.js → p-B7A8ZQ6a.js} +1 -1
- package/dist/components/{p-EAOKZYjL.js → p-BG_gea_M.js} +1 -1
- package/dist/components/p-BQUv2XEK.js +1 -0
- package/dist/components/{p-Dq3xfuFo.js → p-BSaCA5Jj.js} +1 -1
- package/dist/components/{p-DVWXvsaq.js → p-BapO-IvB.js} +1 -1
- package/dist/components/{p-CT7393wO.js → p-BbMLnd5j.js} +1 -1
- package/dist/components/{p-B5xYzHxm.js → p-BcMBYm2s.js} +1 -1
- package/dist/components/{p-CWTGmIwr.js → p-BmkxwARP.js} +1 -1
- package/dist/components/{p-BbWIRdou.js → p-C-NKUCN6.js} +2 -2
- package/dist/components/{p-C1oYQPkf.js → p-C4eie_GY.js} +1 -1
- package/dist/components/{p-DZze1aAU.js → p-C8CwAurI.js} +1 -1
- package/dist/components/{p-CkLu89z5.js → p-CJA9CGbU.js} +1 -1
- package/dist/components/{p-CL-FyXke.js → p-CLrB0yxL.js} +1 -1
- package/dist/components/{p-smzbRw4q.js → p-CYoPQ4Dj.js} +1 -1
- package/dist/components/{p-CDm49CBI.js → p-CieEFRLA.js} +1 -1
- package/dist/components/{p-CZxHfZG_.js → p-CxOhQuk5.js} +1 -1
- package/dist/components/p-DCO0-Di5.js +1 -0
- package/dist/components/{p-BP5LGarp.js → p-DJMGWA0d.js} +1 -1
- package/dist/components/{p--IzLAmAC.js → p-DShwwLU7.js} +1 -1
- package/dist/components/{p-D76tTGW4.js → p-DXU24nta.js} +1 -1
- package/dist/components/{p-DQqLRcKD.js → p-D_v_rctu.js} +1 -1
- package/dist/components/{p-C3qb7mcP.js → p-Do-wFIls.js} +1 -1
- package/dist/components/{p-COc0ML8P.js → p-EO7igFuP.js} +1 -1
- package/dist/components/{p-Q8l2tydf.js → p-htegCYST.js} +1 -1
- package/dist/components/{p-CnQ7a1e-.js → p-xutFNQ9m.js} +1 -1
- package/dist/esm/{alignment.enum-DGrwm-y2.js → alignment.enum-C8H5Grk1.js} +7 -265
- package/dist/esm/index.js +256 -2
- package/dist/esm/kritzel-active-users_38.entry.js +128 -206
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-9f515bae.entry.js +9 -0
- package/dist/stencil/{p-DGrwm-y2.js → p-C8H5Grk1.js} +1 -1
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/core.class.d.ts +6 -25
- package/dist/types/classes/core/workspace.class.d.ts +2 -5
- package/dist/types/classes/structures/object-map.structure.d.ts +14 -0
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +6 -7
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +6 -14
- package/dist/types/components/ui/kritzel-share-dialog/kritzel-share-dialog.d.ts +6 -20
- package/dist/types/components.d.ts +22 -34
- package/dist/types/constants/version.d.ts +1 -1
- package/dist/types/interfaces/share.interface.d.ts +5 -30
- package/package.json +1 -1
- package/dist/components/p-12pZ_tzr.js +0 -1
- package/dist/components/p-AcQNA3C8.js +0 -1
- package/dist/stencil/p-70b0fb0d.entry.js +0 -9
|
@@ -25110,259 +25110,6 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
25110
25110
|
}
|
|
25111
25111
|
}
|
|
25112
25112
|
|
|
25113
|
-
/**
|
|
25114
|
-
* Hocuspocus sync provider for real-time collaboration
|
|
25115
|
-
* Supports multiplexing - multiple documents can share the same WebSocket connection
|
|
25116
|
-
*/
|
|
25117
|
-
class HocuspocusSyncProvider {
|
|
25118
|
-
provider;
|
|
25119
|
-
isConnected = false;
|
|
25120
|
-
isSynced = false;
|
|
25121
|
-
usesSharedSocket = false;
|
|
25122
|
-
get awareness() {
|
|
25123
|
-
return this.provider.awareness;
|
|
25124
|
-
}
|
|
25125
|
-
// Static shared WebSocket instance for multiplexing
|
|
25126
|
-
static sharedWebSocketProvider = null;
|
|
25127
|
-
constructor(docName, doc, options) {
|
|
25128
|
-
const name = options?.name || docName;
|
|
25129
|
-
const url = options?.url || 'ws://localhost:1234';
|
|
25130
|
-
// Use provided websocketProvider or the static shared one
|
|
25131
|
-
const websocketProvider = options?.websocketProvider || HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
25132
|
-
if (websocketProvider) {
|
|
25133
|
-
// Multiplexing mode - use shared WebSocket connection
|
|
25134
|
-
this.usesSharedSocket = true;
|
|
25135
|
-
const config = {
|
|
25136
|
-
websocketProvider,
|
|
25137
|
-
name,
|
|
25138
|
-
document: doc,
|
|
25139
|
-
token: options?.token || null,
|
|
25140
|
-
onConnect: () => {
|
|
25141
|
-
if (this.isConnected) {
|
|
25142
|
-
return;
|
|
25143
|
-
}
|
|
25144
|
-
this.isConnected = true;
|
|
25145
|
-
if (!options?.quiet) {
|
|
25146
|
-
console.info(`Hocuspocus connected: ${name}`);
|
|
25147
|
-
}
|
|
25148
|
-
if (options?.onConnect) {
|
|
25149
|
-
options.onConnect();
|
|
25150
|
-
}
|
|
25151
|
-
},
|
|
25152
|
-
onDisconnect: () => {
|
|
25153
|
-
if (!this.isConnected && !this.isSynced) {
|
|
25154
|
-
return;
|
|
25155
|
-
}
|
|
25156
|
-
this.isConnected = false;
|
|
25157
|
-
this.isSynced = false;
|
|
25158
|
-
if (!options?.quiet) {
|
|
25159
|
-
console.info(`Hocuspocus disconnected: ${name}`);
|
|
25160
|
-
}
|
|
25161
|
-
if (options?.onDisconnect) {
|
|
25162
|
-
options.onDisconnect();
|
|
25163
|
-
}
|
|
25164
|
-
},
|
|
25165
|
-
onSynced: () => {
|
|
25166
|
-
if (this.isSynced) {
|
|
25167
|
-
return;
|
|
25168
|
-
}
|
|
25169
|
-
this.isSynced = true;
|
|
25170
|
-
if (!options?.quiet) {
|
|
25171
|
-
console.info(`Hocuspocus synced: ${name}`);
|
|
25172
|
-
}
|
|
25173
|
-
if (options?.onSynced) {
|
|
25174
|
-
options.onSynced();
|
|
25175
|
-
}
|
|
25176
|
-
},
|
|
25177
|
-
};
|
|
25178
|
-
// Add optional settings
|
|
25179
|
-
if (options?.forceSyncInterval !== undefined) {
|
|
25180
|
-
config.forceSyncInterval = options.forceSyncInterval;
|
|
25181
|
-
}
|
|
25182
|
-
if (options?.onAuthenticationFailed) {
|
|
25183
|
-
config.onAuthenticationFailed = options.onAuthenticationFailed;
|
|
25184
|
-
}
|
|
25185
|
-
if (options?.onStatus) {
|
|
25186
|
-
config.onStatus = options.onStatus;
|
|
25187
|
-
}
|
|
25188
|
-
this.provider = new HocuspocusProvider(config);
|
|
25189
|
-
// Must call attach() explicitly when using shared socket
|
|
25190
|
-
this.provider.attach();
|
|
25191
|
-
if (!options?.quiet) {
|
|
25192
|
-
console.info(`Hocuspocus Provider initialized (multiplexed): ${name}`);
|
|
25193
|
-
}
|
|
25194
|
-
}
|
|
25195
|
-
else {
|
|
25196
|
-
// Standalone mode - create own WebSocket connection
|
|
25197
|
-
this.usesSharedSocket = false;
|
|
25198
|
-
const config = {
|
|
25199
|
-
url,
|
|
25200
|
-
name,
|
|
25201
|
-
document: doc,
|
|
25202
|
-
token: options?.token || null,
|
|
25203
|
-
onConnect: () => {
|
|
25204
|
-
if (this.isConnected) {
|
|
25205
|
-
return;
|
|
25206
|
-
}
|
|
25207
|
-
this.isConnected = true;
|
|
25208
|
-
if (!options?.quiet) {
|
|
25209
|
-
console.info(`Hocuspocus connected: ${name}`);
|
|
25210
|
-
}
|
|
25211
|
-
if (options?.onConnect) {
|
|
25212
|
-
options.onConnect();
|
|
25213
|
-
}
|
|
25214
|
-
},
|
|
25215
|
-
onDisconnect: () => {
|
|
25216
|
-
if (!this.isConnected && !this.isSynced) {
|
|
25217
|
-
return;
|
|
25218
|
-
}
|
|
25219
|
-
this.isConnected = false;
|
|
25220
|
-
this.isSynced = false;
|
|
25221
|
-
if (!options?.quiet) {
|
|
25222
|
-
console.info(`Hocuspocus disconnected: ${name}`);
|
|
25223
|
-
}
|
|
25224
|
-
if (options?.onDisconnect) {
|
|
25225
|
-
options.onDisconnect();
|
|
25226
|
-
}
|
|
25227
|
-
},
|
|
25228
|
-
onSynced: () => {
|
|
25229
|
-
if (this.isSynced) {
|
|
25230
|
-
return;
|
|
25231
|
-
}
|
|
25232
|
-
this.isSynced = true;
|
|
25233
|
-
if (!options?.quiet) {
|
|
25234
|
-
console.info(`Hocuspocus synced: ${name}`);
|
|
25235
|
-
}
|
|
25236
|
-
if (options?.onSynced) {
|
|
25237
|
-
options.onSynced();
|
|
25238
|
-
}
|
|
25239
|
-
},
|
|
25240
|
-
};
|
|
25241
|
-
// Add optional settings
|
|
25242
|
-
if (options?.forceSyncInterval !== undefined) {
|
|
25243
|
-
config.forceSyncInterval = options.forceSyncInterval;
|
|
25244
|
-
}
|
|
25245
|
-
if (options?.onAuthenticationFailed) {
|
|
25246
|
-
config.onAuthenticationFailed = options.onAuthenticationFailed;
|
|
25247
|
-
}
|
|
25248
|
-
if (options?.onStatus) {
|
|
25249
|
-
config.onStatus = options.onStatus;
|
|
25250
|
-
}
|
|
25251
|
-
if (options?.WebSocketPolyfill) {
|
|
25252
|
-
config.WebSocketPolyfill = options.WebSocketPolyfill;
|
|
25253
|
-
}
|
|
25254
|
-
this.provider = new HocuspocusProvider(config);
|
|
25255
|
-
if (!options?.quiet) {
|
|
25256
|
-
console.info(`Hocuspocus Provider initialized: ${url}/${name}`);
|
|
25257
|
-
}
|
|
25258
|
-
}
|
|
25259
|
-
}
|
|
25260
|
-
/**
|
|
25261
|
-
* Create a shared WebSocket connection for multiplexing
|
|
25262
|
-
* Call this once to create a shared connection that multiple providers can use
|
|
25263
|
-
*/
|
|
25264
|
-
static createSharedWebSocket(options) {
|
|
25265
|
-
if (HocuspocusSyncProvider.sharedWebSocketProvider) {
|
|
25266
|
-
console.warn('Shared WebSocket already exists. Returning existing instance.');
|
|
25267
|
-
return HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
25268
|
-
}
|
|
25269
|
-
const config = {
|
|
25270
|
-
url: options.url,
|
|
25271
|
-
};
|
|
25272
|
-
if (options.WebSocketPolyfill) {
|
|
25273
|
-
config.WebSocketPolyfill = options.WebSocketPolyfill;
|
|
25274
|
-
}
|
|
25275
|
-
if (options.onConnect) {
|
|
25276
|
-
config.onConnect = options.onConnect;
|
|
25277
|
-
}
|
|
25278
|
-
if (options.onDisconnect) {
|
|
25279
|
-
config.onDisconnect = options.onDisconnect;
|
|
25280
|
-
}
|
|
25281
|
-
if (options.onStatus) {
|
|
25282
|
-
config.onStatus = options.onStatus;
|
|
25283
|
-
}
|
|
25284
|
-
HocuspocusSyncProvider.sharedWebSocketProvider = new HocuspocusProviderWebsocket(config);
|
|
25285
|
-
console.info(`Shared Hocuspocus WebSocket created: ${options.url}`);
|
|
25286
|
-
return HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
25287
|
-
}
|
|
25288
|
-
/**
|
|
25289
|
-
* Destroy the shared WebSocket connection
|
|
25290
|
-
* Call this when you're done with all multiplexed providers
|
|
25291
|
-
*/
|
|
25292
|
-
static destroySharedWebSocket() {
|
|
25293
|
-
if (HocuspocusSyncProvider.sharedWebSocketProvider) {
|
|
25294
|
-
HocuspocusSyncProvider.sharedWebSocketProvider.destroy();
|
|
25295
|
-
HocuspocusSyncProvider.sharedWebSocketProvider = null;
|
|
25296
|
-
console.info('Shared Hocuspocus WebSocket destroyed');
|
|
25297
|
-
}
|
|
25298
|
-
}
|
|
25299
|
-
/**
|
|
25300
|
-
* Get the shared WebSocket provider instance (if it exists)
|
|
25301
|
-
*/
|
|
25302
|
-
static getSharedWebSocket() {
|
|
25303
|
-
return HocuspocusSyncProvider.sharedWebSocketProvider;
|
|
25304
|
-
}
|
|
25305
|
-
/**
|
|
25306
|
-
* Static factory method for creating HocuspocusSyncProvider with configuration options
|
|
25307
|
-
* Returns a ProviderFactory that can be used in sync configuration
|
|
25308
|
-
*/
|
|
25309
|
-
static with(options) {
|
|
25310
|
-
return {
|
|
25311
|
-
create: (docName, doc, runtimeOptions) => {
|
|
25312
|
-
const mergedOptions = runtimeOptions ? { ...options, ...runtimeOptions } : options;
|
|
25313
|
-
return new HocuspocusSyncProvider(docName, doc, mergedOptions);
|
|
25314
|
-
},
|
|
25315
|
-
};
|
|
25316
|
-
}
|
|
25317
|
-
async connect() {
|
|
25318
|
-
if (this.isSynced) {
|
|
25319
|
-
return;
|
|
25320
|
-
}
|
|
25321
|
-
return new Promise((resolve, reject) => {
|
|
25322
|
-
const timeout = setTimeout(() => {
|
|
25323
|
-
reject(new Error('Hocuspocus connection timeout'));
|
|
25324
|
-
}, 10000); // 10 second timeout
|
|
25325
|
-
const syncHandler = () => {
|
|
25326
|
-
clearTimeout(timeout);
|
|
25327
|
-
this.provider.off('synced', syncHandler);
|
|
25328
|
-
resolve();
|
|
25329
|
-
};
|
|
25330
|
-
this.provider.on('synced', syncHandler);
|
|
25331
|
-
// If already synced, resolve immediately
|
|
25332
|
-
if (this.provider.isSynced) {
|
|
25333
|
-
clearTimeout(timeout);
|
|
25334
|
-
this.provider.off('synced', syncHandler);
|
|
25335
|
-
resolve();
|
|
25336
|
-
return;
|
|
25337
|
-
}
|
|
25338
|
-
// Connect if not already connected (standalone mode only)
|
|
25339
|
-
if (!this.isConnected && !this.usesSharedSocket) {
|
|
25340
|
-
this.provider.connect();
|
|
25341
|
-
}
|
|
25342
|
-
});
|
|
25343
|
-
}
|
|
25344
|
-
disconnect() {
|
|
25345
|
-
if (this.provider) {
|
|
25346
|
-
if (this.usesSharedSocket) {
|
|
25347
|
-
// Detach from shared socket instead of disconnecting
|
|
25348
|
-
this.provider.detach();
|
|
25349
|
-
}
|
|
25350
|
-
else {
|
|
25351
|
-
this.provider.disconnect();
|
|
25352
|
-
}
|
|
25353
|
-
}
|
|
25354
|
-
this.isConnected = false;
|
|
25355
|
-
this.isSynced = false;
|
|
25356
|
-
}
|
|
25357
|
-
destroy() {
|
|
25358
|
-
if (this.provider) {
|
|
25359
|
-
this.provider.destroy();
|
|
25360
|
-
}
|
|
25361
|
-
this.isConnected = false;
|
|
25362
|
-
this.isSynced = false;
|
|
25363
|
-
}
|
|
25364
|
-
}
|
|
25365
|
-
|
|
25366
25113
|
/** Current version of the workspace export format */
|
|
25367
25114
|
const WORKSPACE_EXPORT_VERSION = '1.1.0';
|
|
25368
25115
|
/**
|
|
@@ -25382,10 +25129,8 @@ class KritzelWorkspace {
|
|
|
25382
25129
|
updatedAt;
|
|
25383
25130
|
/** Viewport state containing pan and zoom information */
|
|
25384
25131
|
viewport;
|
|
25385
|
-
/**
|
|
25386
|
-
|
|
25387
|
-
/** Link sharing configuration, null if link sharing has never been enabled */
|
|
25388
|
-
linkShare;
|
|
25132
|
+
/** Whether the workspace is publicly accessible via a share link */
|
|
25133
|
+
isPublic;
|
|
25389
25134
|
/** Reference to the KritzelCore instance managing this workspace */
|
|
25390
25135
|
_core;
|
|
25391
25136
|
/**
|
|
@@ -25400,8 +25145,7 @@ class KritzelWorkspace {
|
|
|
25400
25145
|
this.createdAt = new Date();
|
|
25401
25146
|
this.updatedAt = new Date();
|
|
25402
25147
|
this.viewport = viewport;
|
|
25403
|
-
this.
|
|
25404
|
-
this.linkShare = null;
|
|
25148
|
+
this.isPublic = false;
|
|
25405
25149
|
}
|
|
25406
25150
|
/**
|
|
25407
25151
|
* Factory method to create a workspace with a core reference.
|
|
@@ -25437,8 +25181,7 @@ class KritzelWorkspace {
|
|
|
25437
25181
|
createdAt: this.createdAt.toISOString(),
|
|
25438
25182
|
updatedAt: this.updatedAt.toISOString(),
|
|
25439
25183
|
viewport: this.viewport,
|
|
25440
|
-
|
|
25441
|
-
linkShare: this.linkShare,
|
|
25184
|
+
isPublic: this.isPublic,
|
|
25442
25185
|
};
|
|
25443
25186
|
if (options?.includeObjects && this._core) {
|
|
25444
25187
|
const allObjects = this._core.store.allNonSelectionObjects;
|
|
@@ -25456,9 +25199,8 @@ class KritzelWorkspace {
|
|
|
25456
25199
|
Object.assign(this, object);
|
|
25457
25200
|
this.createdAt = new Date(object.createdAt);
|
|
25458
25201
|
this.updatedAt = new Date(object.updatedAt);
|
|
25459
|
-
// Backward compatibility:
|
|
25460
|
-
this.
|
|
25461
|
-
this.linkShare = object.linkShare ?? null;
|
|
25202
|
+
// Backward compatibility: infer isPublic from old linkShare/visibility fields
|
|
25203
|
+
this.isPublic = object.isPublic ?? object.linkShare?.enabled ?? (object.visibility === 'shared') ?? false;
|
|
25462
25204
|
return this;
|
|
25463
25205
|
}
|
|
25464
25206
|
}
|
|
@@ -26842,7 +26584,8 @@ exports.DEFAULT_BRUSH_CONFIG = DEFAULT_BRUSH_CONFIG;
|
|
|
26842
26584
|
exports.DEFAULT_COLOR_PALETTE = DEFAULT_COLOR_PALETTE;
|
|
26843
26585
|
exports.DEFAULT_LINE_TOOL_CONFIG = DEFAULT_LINE_TOOL_CONFIG;
|
|
26844
26586
|
exports.DEFAULT_TEXT_CONFIG = DEFAULT_TEXT_CONFIG;
|
|
26845
|
-
exports.
|
|
26587
|
+
exports.HocuspocusProvider = HocuspocusProvider;
|
|
26588
|
+
exports.HocuspocusProviderWebsocket = HocuspocusProviderWebsocket;
|
|
26846
26589
|
exports.IndexedDBSyncProvider = IndexedDBSyncProvider;
|
|
26847
26590
|
exports.KritzelAnchorManager = KritzelAnchorManager;
|
|
26848
26591
|
exports.KritzelBaseHandler = KritzelBaseHandler;
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var alignment_enum = require('./alignment.enum-
|
|
3
|
+
var alignment_enum = require('./alignment.enum-DOlCH8zf.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;
|