superdoc 2.16.1-next.3 → 2.16.1-next.4

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.
@@ -19,7 +19,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
19
19
  var PRIVATE_ENGINE_INFO = (0, _superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
20
20
  var ENGINE_INFO = Object.freeze({
21
21
  ...PRIVATE_ENGINE_INFO,
22
- superdocVersion: "2.16.1-next.3",
22
+ superdocVersion: "2.16.1-next.4",
23
23
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
24
24
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
25
25
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -18,7 +18,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
18
18
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
19
19
  var ENGINE_INFO = Object.freeze({
20
20
  ...PRIVATE_ENGINE_INFO,
21
- superdocVersion: "2.16.1-next.3",
21
+ superdocVersion: "2.16.1-next.4",
22
22
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
23
23
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
24
24
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -20,7 +20,7 @@ export type SupportedV2ProviderFamily = 'y-websocket' | 'hocuspocus' | 'livebloc
20
20
  * collaboration room. These strings are part of the diagnostic contract and are
21
21
  * safe to assert against in tests; they never carry caller-provided values.
22
22
  */
23
- export type V2CollaborationUnsupportedReason = 'missing-target' | 'invalid-document-id' | 'invalid-server-url' | 'invalid-room-mode' | 'invalid-auth-endpoint' | 'invalid-adapter-id' | 'invalid-provider-options' | 'missing-auth' | 'mixed-auth' | 'unsupported-document-type' | 'unsupported-multi-document' | 'unsupported-legacy-provider' | 'unsupported-provider-family';
23
+ export type V2CollaborationUnsupportedReason = 'missing-target' | 'invalid-document-id' | 'invalid-server-url' | 'invalid-room-mode' | 'invalid-auth-endpoint' | 'invalid-adapter-id' | 'invalid-provider-options' | 'invalid-sync-timeout' | 'missing-auth' | 'mixed-auth' | 'unsupported-document-type' | 'unsupported-multi-document' | 'unsupported-legacy-provider' | 'unsupported-provider-family';
24
24
  /**
25
25
  * Normalized, supported v2 collaboration room target.
26
26
  *
@@ -47,6 +47,8 @@ export interface NormalizedV2CollaborationTarget {
47
47
  adapterId?: string;
48
48
  /** Structured-clone-safe options interpreted by the registered adapter. */
49
49
  providerOptions?: unknown;
50
+ /** Maximum initial synchronization wait in milliseconds. */
51
+ syncTimeoutMs?: number;
50
52
  /** Explicit room operation; join is the default at the untrusted input boundary. */
51
53
  roomMode: 'join' | 'create';
52
54
  }
@@ -644,6 +644,8 @@ export interface V2YWebsocketCollaborationConfig {
644
644
  * an auth token). Values are strings.
645
645
  */
646
646
  params?: Record<string, string> | null;
647
+ /** Maximum initial synchronization wait in milliseconds. Defaults to 30,000. */
648
+ syncTimeoutMs?: number;
647
649
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
648
650
  roomMode?: 'join' | 'create';
649
651
  }
@@ -660,6 +662,8 @@ export interface V2HocuspocusCollaborationConfig {
660
662
  params?: Record<string, string> | null;
661
663
  /** Static auth token or resolver invoked for every Hocuspocus connection. */
662
664
  token?: string | (() => string | Promise<string>);
665
+ /** Maximum initial synchronization wait in milliseconds. Defaults to 30,000. */
666
+ syncTimeoutMs?: number;
663
667
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
664
668
  roomMode?: 'join' | 'create';
665
669
  }
@@ -683,6 +687,8 @@ export interface V2LiveblocksCollaborationConfig {
683
687
  * page; non-browser SDK/CLI callers must use an absolute HTTP(S) URL.
684
688
  */
685
689
  authEndpoint?: string;
690
+ /** Maximum initial synchronization wait in milliseconds. Defaults to 30,000. */
691
+ syncTimeoutMs?: number;
686
692
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
687
693
  roomMode?: 'join' | 'create';
688
694
  }
@@ -697,6 +703,8 @@ export interface V2ProviderExtensionCollaborationConfig {
697
703
  providerOptions?: unknown;
698
704
  /** Optional host-owned credential resolver available to the adapter. */
699
705
  token?: string | (() => string | Promise<string>);
706
+ /** Maximum initial synchronization wait in milliseconds. Defaults to 30,000. */
707
+ syncTimeoutMs?: number;
700
708
  /** Explicit room operation. Defaults to `'join'`; `'create'` never joins an existing room. */
701
709
  roomMode?: 'join' | 'create';
702
710
  }
package/dist/superdoc.cjs CHANGED
@@ -316,7 +316,7 @@ var shuffleArray = (array) => {
316
316
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
317
317
  function getSuperdocVersion() {
318
318
  try {
319
- return "2.16.1-next.3";
319
+ return "2.16.1-next.4";
320
320
  } catch {
321
321
  return "unknown";
322
322
  }
@@ -5380,6 +5380,20 @@ function normalizeRoomMode(value) {
5380
5380
  if (value === void 0) return "join";
5381
5381
  return value === "join" || value === "create" ? value : null;
5382
5382
  }
5383
+ function normalizeSyncTimeoutMs(value) {
5384
+ if (value === void 0) return void 0;
5385
+ return typeof value === "number" && Number.isFinite(value) && value > 0 && value <= 2147483647 ? value : null;
5386
+ }
5387
+ function withSyncTimeout(resolution, syncTimeoutMs) {
5388
+ if (!resolution.ok || syncTimeoutMs === void 0) return resolution;
5389
+ return {
5390
+ ok: true,
5391
+ target: {
5392
+ ...resolution.target,
5393
+ syncTimeoutMs
5394
+ }
5395
+ };
5396
+ }
5383
5397
  function invalidRoomMode() {
5384
5398
  return {
5385
5399
  ok: false,
@@ -5567,11 +5581,17 @@ function resolveV2CollaborationTarget(input) {
5567
5581
  reason: "unsupported-legacy-provider",
5568
5582
  message: "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a collaboration target ({ providerType, documentId, serverUrl | publicApiKey | authEndpoint }) instead."
5569
5583
  };
5584
+ const syncTimeoutMs = normalizeSyncTimeoutMs(candidate.syncTimeoutMs);
5585
+ if (syncTimeoutMs === null) return {
5586
+ ok: false,
5587
+ reason: "invalid-sync-timeout",
5588
+ message: "SuperDoc v2 collaboration syncTimeoutMs must be a finite positive number within the JavaScript timer range."
5589
+ };
5570
5590
  const providerType = readProviderType(candidate);
5571
- if (providerType === null || providerType === "y-websocket") return resolveWebsocketFamily("y-websocket", candidate);
5572
- if (providerType === "hocuspocus") return resolveWebsocketFamily("hocuspocus", candidate);
5573
- if (providerType === "liveblocks") return resolveLiveblocksFamily(candidate, authEndpointBaseUrl);
5574
- if (providerType === "extension") return resolveProviderExtension(candidate);
5591
+ if (providerType === null || providerType === "y-websocket") return withSyncTimeout(resolveWebsocketFamily("y-websocket", candidate), syncTimeoutMs);
5592
+ if (providerType === "hocuspocus") return withSyncTimeout(resolveWebsocketFamily("hocuspocus", candidate), syncTimeoutMs);
5593
+ if (providerType === "liveblocks") return withSyncTimeout(resolveLiveblocksFamily(candidate, authEndpointBaseUrl), syncTimeoutMs);
5594
+ if (providerType === "extension") return withSyncTimeout(resolveProviderExtension(candidate), syncTimeoutMs);
5575
5595
  return {
5576
5596
  ok: false,
5577
5597
  reason: "unsupported-provider-family",
@@ -45690,7 +45710,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
45690
45710
  this.config.colors = shuffleArray(this.config.colors);
45691
45711
  this.userColorMap = /* @__PURE__ */ new Map();
45692
45712
  this.colorIndex = 0;
45693
- this.version = "2.16.1-next.3";
45713
+ this.version = "2.16.1-next.4";
45694
45714
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45695
45715
  this.superdocId = config.superdocId || require_uuid.v4();
45696
45716
  this.colors = this.config.colors ?? [];
@@ -46351,11 +46371,13 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46351
46371
  storeDoc.v2Collaboration = value;
46352
46372
  }
46353
46373
  #toV2CollaborationConfig(target) {
46374
+ const syncTimeoutOption = target.syncTimeoutMs === void 0 ? {} : { syncTimeoutMs: target.syncTimeoutMs };
46354
46375
  if (target.providerFamily === "extension") return {
46355
46376
  providerType: "extension",
46356
46377
  adapterId: target.adapterId,
46357
46378
  documentId: target.documentId,
46358
46379
  roomMode: target.roomMode,
46380
+ ...syncTimeoutOption,
46359
46381
  ...target.providerOptions !== void 0 ? { providerOptions: target.providerOptions } : {},
46360
46382
  ...target.token ? { token: target.token } : {}
46361
46383
  };
@@ -46363,6 +46385,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46363
46385
  providerType: "liveblocks",
46364
46386
  documentId: target.documentId,
46365
46387
  roomMode: target.roomMode,
46388
+ ...syncTimeoutOption,
46366
46389
  ...target.publicApiKey ? { publicApiKey: target.publicApiKey } : {},
46367
46390
  ...target.authEndpoint ? { authEndpoint: target.authEndpoint } : {}
46368
46391
  };
@@ -46370,6 +46393,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46370
46393
  providerType: "hocuspocus",
46371
46394
  documentId: target.documentId,
46372
46395
  roomMode: target.roomMode,
46396
+ ...syncTimeoutOption,
46373
46397
  ...target.serverUrl ? { serverUrl: target.serverUrl } : {},
46374
46398
  ...target.params ? { params: target.params } : {},
46375
46399
  ...target.token ? { token: target.token } : {}
@@ -46378,6 +46402,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46378
46402
  providerType: "y-websocket",
46379
46403
  documentId: target.documentId,
46380
46404
  roomMode: target.roomMode,
46405
+ ...syncTimeoutOption,
46381
46406
  ...target.serverUrl ? { serverUrl: target.serverUrl } : {},
46382
46407
  ...target.params ? { params: target.params } : {}
46383
46408
  };
@@ -315,7 +315,7 @@ var shuffleArray = (array) => {
315
315
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
316
316
  function getSuperdocVersion() {
317
317
  try {
318
- return "2.16.1-next.3";
318
+ return "2.16.1-next.4";
319
319
  } catch {
320
320
  return "unknown";
321
321
  }
@@ -5379,6 +5379,20 @@ function normalizeRoomMode(value) {
5379
5379
  if (value === void 0) return "join";
5380
5380
  return value === "join" || value === "create" ? value : null;
5381
5381
  }
5382
+ function normalizeSyncTimeoutMs(value) {
5383
+ if (value === void 0) return void 0;
5384
+ return typeof value === "number" && Number.isFinite(value) && value > 0 && value <= 2147483647 ? value : null;
5385
+ }
5386
+ function withSyncTimeout(resolution, syncTimeoutMs) {
5387
+ if (!resolution.ok || syncTimeoutMs === void 0) return resolution;
5388
+ return {
5389
+ ok: true,
5390
+ target: {
5391
+ ...resolution.target,
5392
+ syncTimeoutMs
5393
+ }
5394
+ };
5395
+ }
5382
5396
  function invalidRoomMode() {
5383
5397
  return {
5384
5398
  ok: false,
@@ -5566,11 +5580,17 @@ function resolveV2CollaborationTarget(input) {
5566
5580
  reason: "unsupported-legacy-provider",
5567
5581
  message: "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a collaboration target ({ providerType, documentId, serverUrl | publicApiKey | authEndpoint }) instead."
5568
5582
  };
5583
+ const syncTimeoutMs = normalizeSyncTimeoutMs(candidate.syncTimeoutMs);
5584
+ if (syncTimeoutMs === null) return {
5585
+ ok: false,
5586
+ reason: "invalid-sync-timeout",
5587
+ message: "SuperDoc v2 collaboration syncTimeoutMs must be a finite positive number within the JavaScript timer range."
5588
+ };
5569
5589
  const providerType = readProviderType(candidate);
5570
- if (providerType === null || providerType === "y-websocket") return resolveWebsocketFamily("y-websocket", candidate);
5571
- if (providerType === "hocuspocus") return resolveWebsocketFamily("hocuspocus", candidate);
5572
- if (providerType === "liveblocks") return resolveLiveblocksFamily(candidate, authEndpointBaseUrl);
5573
- if (providerType === "extension") return resolveProviderExtension(candidate);
5590
+ if (providerType === null || providerType === "y-websocket") return withSyncTimeout(resolveWebsocketFamily("y-websocket", candidate), syncTimeoutMs);
5591
+ if (providerType === "hocuspocus") return withSyncTimeout(resolveWebsocketFamily("hocuspocus", candidate), syncTimeoutMs);
5592
+ if (providerType === "liveblocks") return withSyncTimeout(resolveLiveblocksFamily(candidate, authEndpointBaseUrl), syncTimeoutMs);
5593
+ if (providerType === "extension") return withSyncTimeout(resolveProviderExtension(candidate), syncTimeoutMs);
5574
5594
  return {
5575
5595
  ok: false,
5576
5596
  reason: "unsupported-provider-family",
@@ -45621,7 +45641,7 @@ var SuperDoc = class extends import_eventemitter3.default {
45621
45641
  this.config.colors = shuffleArray(this.config.colors);
45622
45642
  this.userColorMap = /* @__PURE__ */ new Map();
45623
45643
  this.colorIndex = 0;
45624
- this.version = "2.16.1-next.3";
45644
+ this.version = "2.16.1-next.4";
45625
45645
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
45626
45646
  this.superdocId = config.superdocId || v4();
45627
45647
  this.colors = this.config.colors ?? [];
@@ -46282,11 +46302,13 @@ var SuperDoc = class extends import_eventemitter3.default {
46282
46302
  storeDoc.v2Collaboration = value;
46283
46303
  }
46284
46304
  #toV2CollaborationConfig(target) {
46305
+ const syncTimeoutOption = target.syncTimeoutMs === void 0 ? {} : { syncTimeoutMs: target.syncTimeoutMs };
46285
46306
  if (target.providerFamily === "extension") return {
46286
46307
  providerType: "extension",
46287
46308
  adapterId: target.adapterId,
46288
46309
  documentId: target.documentId,
46289
46310
  roomMode: target.roomMode,
46311
+ ...syncTimeoutOption,
46290
46312
  ...target.providerOptions !== void 0 ? { providerOptions: target.providerOptions } : {},
46291
46313
  ...target.token ? { token: target.token } : {}
46292
46314
  };
@@ -46294,6 +46316,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46294
46316
  providerType: "liveblocks",
46295
46317
  documentId: target.documentId,
46296
46318
  roomMode: target.roomMode,
46319
+ ...syncTimeoutOption,
46297
46320
  ...target.publicApiKey ? { publicApiKey: target.publicApiKey } : {},
46298
46321
  ...target.authEndpoint ? { authEndpoint: target.authEndpoint } : {}
46299
46322
  };
@@ -46301,6 +46324,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46301
46324
  providerType: "hocuspocus",
46302
46325
  documentId: target.documentId,
46303
46326
  roomMode: target.roomMode,
46327
+ ...syncTimeoutOption,
46304
46328
  ...target.serverUrl ? { serverUrl: target.serverUrl } : {},
46305
46329
  ...target.params ? { params: target.params } : {},
46306
46330
  ...target.token ? { token: target.token } : {}
@@ -46309,6 +46333,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46309
46333
  providerType: "y-websocket",
46310
46334
  documentId: target.documentId,
46311
46335
  roomMode: target.roomMode,
46336
+ ...syncTimeoutOption,
46312
46337
  ...target.serverUrl ? { serverUrl: target.serverUrl } : {},
46313
46338
  ...target.params ? { params: target.params } : {}
46314
46339
  };