superdoc 2.13.0-next.7 → 2.13.0-next.9
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/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/document-api/src/content-controls/content-controls.types.d.ts +1 -1
- package/dist/style.css +25 -25
- package/dist/style.layered.css +25 -25
- package/dist/superdoc/src/core/collaboration/collaboration-exception.d.ts +2 -0
- package/dist/superdoc/src/core/collaboration/resolve-v2-collaboration-target.d.ts +9 -2
- package/dist/superdoc/src/core/types/index.d.ts +33 -31
- package/dist/superdoc/src/public/index.d.cts +4 -0
- package/dist/superdoc/src/public/index.d.ts +2 -0
- package/dist/superdoc.cjs +310 -265
- package/dist/superdoc.es.js +310 -265
- package/dist-cdn/style.layered.css +1 -1
- package/dist-cdn/superdoc.min.css +1 -1
- package/dist-cdn/superdoc.min.js +35 -35
- package/package.json +2 -2
package/dist/superdoc.es.js
CHANGED
|
@@ -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.13.0-next.
|
|
318
|
+
return "2.13.0-next.9";
|
|
319
319
|
} catch {
|
|
320
320
|
return "unknown";
|
|
321
321
|
}
|
|
@@ -5310,6 +5310,274 @@ function storeToRefs(store) {
|
|
|
5310
5310
|
return refs;
|
|
5311
5311
|
}
|
|
5312
5312
|
//#endregion
|
|
5313
|
+
//#region src/core/collaboration/resolve-v2-collaboration-target.ts
|
|
5314
|
+
/** Select the public spelling before validation; do not merge settings from different rooms. */
|
|
5315
|
+
function readCollaborationConfig(input) {
|
|
5316
|
+
return input.collaboration !== void 0 ? input.collaboration : input.v2Collaboration;
|
|
5317
|
+
}
|
|
5318
|
+
/**
|
|
5319
|
+
* Redact a connection URL for safe inclusion in diagnostics and artifacts.
|
|
5320
|
+
*
|
|
5321
|
+
* Strips the query string, fragment, and any embedded credentials (userinfo)
|
|
5322
|
+
* because those commonly carry auth tokens. Falls back to a coarse string scrub
|
|
5323
|
+
* when the value is not a parseable absolute URL so a malformed value with an
|
|
5324
|
+
* inline `?token=...` still cannot leak.
|
|
5325
|
+
*/
|
|
5326
|
+
function redactCollaborationUrl(url) {
|
|
5327
|
+
if (typeof url !== "string" || url.length === 0) return "<none>";
|
|
5328
|
+
try {
|
|
5329
|
+
const parsed = new URL(url);
|
|
5330
|
+
parsed.search = "";
|
|
5331
|
+
parsed.hash = "";
|
|
5332
|
+
parsed.username = "";
|
|
5333
|
+
parsed.password = "";
|
|
5334
|
+
const redactedQuery = url.includes("?") ? "?<redacted>" : "";
|
|
5335
|
+
return `${parsed.toString().replace(/\?$/, "")}${redactedQuery}`;
|
|
5336
|
+
} catch {
|
|
5337
|
+
const withoutCredentials = url.replace(/\/\/[^/@]+@/, "//");
|
|
5338
|
+
const cut = withoutCredentials.search(/[?#]/);
|
|
5339
|
+
if (cut === -1) return withoutCredentials;
|
|
5340
|
+
return `${withoutCredentials.slice(0, cut)}?<redacted>`;
|
|
5341
|
+
}
|
|
5342
|
+
}
|
|
5343
|
+
function normalizeNonEmptyString(value) {
|
|
5344
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
5345
|
+
}
|
|
5346
|
+
function normalizeWebsocketUrl(value) {
|
|
5347
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
5348
|
+
try {
|
|
5349
|
+
const parsed = new URL(value);
|
|
5350
|
+
return parsed.protocol === "ws:" || parsed.protocol === "wss:" ? value : null;
|
|
5351
|
+
} catch {
|
|
5352
|
+
return null;
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
function normalizeHttpUrl(value, baseUrl) {
|
|
5356
|
+
if (typeof value !== "string") return null;
|
|
5357
|
+
const normalized = value.trim();
|
|
5358
|
+
if (normalized.length === 0) return null;
|
|
5359
|
+
try {
|
|
5360
|
+
const parsed = new URL(normalized);
|
|
5361
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? normalized : null;
|
|
5362
|
+
} catch {
|
|
5363
|
+
if (typeof baseUrl !== "string" || baseUrl.trim().length === 0) return null;
|
|
5364
|
+
try {
|
|
5365
|
+
const parsed = new URL(normalized, baseUrl);
|
|
5366
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null;
|
|
5367
|
+
} catch {
|
|
5368
|
+
return null;
|
|
5369
|
+
}
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
function normalizeParams(value) {
|
|
5373
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
5374
|
+
const params = {};
|
|
5375
|
+
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") params[key] = raw;
|
|
5376
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
5377
|
+
}
|
|
5378
|
+
function normalizeRoomMode(value) {
|
|
5379
|
+
if (value === void 0) return "join";
|
|
5380
|
+
return value === "join" || value === "create" ? value : null;
|
|
5381
|
+
}
|
|
5382
|
+
function invalidRoomMode() {
|
|
5383
|
+
return {
|
|
5384
|
+
ok: false,
|
|
5385
|
+
reason: "invalid-room-mode",
|
|
5386
|
+
message: "SuperDoc v2 collaboration roomMode must be either \"join\" or \"create\"."
|
|
5387
|
+
};
|
|
5388
|
+
}
|
|
5389
|
+
/** Provider-family token recognized on a v2Collaboration config object. */
|
|
5390
|
+
function readProviderType(candidate) {
|
|
5391
|
+
const raw = candidate.providerType;
|
|
5392
|
+
return typeof raw === "string" && raw.length > 0 ? raw.toLowerCase() : null;
|
|
5393
|
+
}
|
|
5394
|
+
/**
|
|
5395
|
+
* Detect whether a legacy collaboration block names a provider family that the
|
|
5396
|
+
* shipped single-doc v2 runtime cannot drive. Returns the offending family name
|
|
5397
|
+
* (for diagnostics) or `null` when the block carries no recognizable family.
|
|
5398
|
+
*/
|
|
5399
|
+
function detectUnsupportedLegacyFamily(legacy) {
|
|
5400
|
+
if (!legacy || typeof legacy !== "object") return null;
|
|
5401
|
+
const providerType = typeof legacy.providerType === "string" ? legacy.providerType.toLowerCase() : "";
|
|
5402
|
+
if (providerType === "hocuspocus") return "hocuspocus";
|
|
5403
|
+
if (providerType === "liveblocks") return "liveblocks";
|
|
5404
|
+
if (providerType === "superdoc") return "superdoc";
|
|
5405
|
+
if (legacy.ydoc != null || legacy.provider != null) return "external-ydoc-provider";
|
|
5406
|
+
return null;
|
|
5407
|
+
}
|
|
5408
|
+
/** Resolve a websocket-backed family (y-websocket / Hocuspocus). */
|
|
5409
|
+
function resolveWebsocketFamily(family, candidate) {
|
|
5410
|
+
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
5411
|
+
if (!documentId) return {
|
|
5412
|
+
ok: false,
|
|
5413
|
+
reason: "invalid-document-id",
|
|
5414
|
+
message: `SuperDoc v2 collaboration requires a non-empty collaboration.documentId for the "${family}" provider.`
|
|
5415
|
+
};
|
|
5416
|
+
const rawUrl = candidate.url ?? candidate.serverUrl;
|
|
5417
|
+
const serverUrl = normalizeWebsocketUrl(rawUrl);
|
|
5418
|
+
if (!serverUrl) return {
|
|
5419
|
+
ok: false,
|
|
5420
|
+
reason: "invalid-server-url",
|
|
5421
|
+
message: `SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${family}" provider (received: ${redactCollaborationUrl(rawUrl)}).`
|
|
5422
|
+
};
|
|
5423
|
+
const params = normalizeParams(candidate.params);
|
|
5424
|
+
const token = family === "hocuspocus" && typeof candidate.token === "function" ? candidate.token : family === "hocuspocus" ? normalizeNonEmptyString(candidate.token) : null;
|
|
5425
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5426
|
+
if (!roomMode) return invalidRoomMode();
|
|
5427
|
+
return {
|
|
5428
|
+
ok: true,
|
|
5429
|
+
target: {
|
|
5430
|
+
providerFamily: family,
|
|
5431
|
+
documentId,
|
|
5432
|
+
roomMode,
|
|
5433
|
+
serverUrl,
|
|
5434
|
+
...params ? { params } : {},
|
|
5435
|
+
...token ? { token } : {}
|
|
5436
|
+
}
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
5439
|
+
function resolveProviderExtension(candidate) {
|
|
5440
|
+
const adapterId = normalizeNonEmptyString(candidate.adapterId);
|
|
5441
|
+
if (!adapterId) return {
|
|
5442
|
+
ok: false,
|
|
5443
|
+
reason: "invalid-adapter-id",
|
|
5444
|
+
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.adapterId."
|
|
5445
|
+
};
|
|
5446
|
+
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
5447
|
+
if (!documentId) return {
|
|
5448
|
+
ok: false,
|
|
5449
|
+
reason: "invalid-document-id",
|
|
5450
|
+
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.documentId."
|
|
5451
|
+
};
|
|
5452
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5453
|
+
if (!roomMode) return invalidRoomMode();
|
|
5454
|
+
if (Object.prototype.hasOwnProperty.call(candidate, "providerOptions")) try {
|
|
5455
|
+
structuredClone(candidate.providerOptions);
|
|
5456
|
+
} catch {
|
|
5457
|
+
return {
|
|
5458
|
+
ok: false,
|
|
5459
|
+
reason: "invalid-provider-options",
|
|
5460
|
+
message: "SuperDoc v2 provider extension options must be structured-clone-safe."
|
|
5461
|
+
};
|
|
5462
|
+
}
|
|
5463
|
+
const token = typeof candidate.token === "function" ? candidate.token : normalizeNonEmptyString(candidate.token);
|
|
5464
|
+
return {
|
|
5465
|
+
ok: true,
|
|
5466
|
+
target: {
|
|
5467
|
+
providerFamily: "extension",
|
|
5468
|
+
adapterId,
|
|
5469
|
+
documentId,
|
|
5470
|
+
roomMode,
|
|
5471
|
+
...Object.prototype.hasOwnProperty.call(candidate, "providerOptions") ? { providerOptions: candidate.providerOptions } : {},
|
|
5472
|
+
...token ? { token } : {}
|
|
5473
|
+
}
|
|
5474
|
+
};
|
|
5475
|
+
}
|
|
5476
|
+
/** Resolve the Liveblocks family (exactly one of publicApiKey / authEndpoint). */
|
|
5477
|
+
function resolveLiveblocksFamily(candidate, authEndpointBaseUrl) {
|
|
5478
|
+
const documentId = normalizeNonEmptyString(candidate.documentId ?? candidate.roomId);
|
|
5479
|
+
if (!documentId) return {
|
|
5480
|
+
ok: false,
|
|
5481
|
+
reason: "invalid-document-id",
|
|
5482
|
+
message: "SuperDoc v2 collaboration requires a non-empty collaboration.documentId (or roomId) for the \"liveblocks\" provider."
|
|
5483
|
+
};
|
|
5484
|
+
const publicApiKey = normalizeNonEmptyString(candidate.publicApiKey);
|
|
5485
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5486
|
+
if (!roomMode) return invalidRoomMode();
|
|
5487
|
+
const authEndpointRaw = candidate.authEndpoint;
|
|
5488
|
+
const hasAuthEndpoint = typeof authEndpointRaw === "string" && authEndpointRaw.length > 0;
|
|
5489
|
+
if (!publicApiKey && !hasAuthEndpoint) return {
|
|
5490
|
+
ok: false,
|
|
5491
|
+
reason: "missing-auth",
|
|
5492
|
+
message: "SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."
|
|
5493
|
+
};
|
|
5494
|
+
if (publicApiKey && hasAuthEndpoint) return {
|
|
5495
|
+
ok: false,
|
|
5496
|
+
reason: "mixed-auth",
|
|
5497
|
+
message: "SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."
|
|
5498
|
+
};
|
|
5499
|
+
if (publicApiKey) return {
|
|
5500
|
+
ok: true,
|
|
5501
|
+
target: {
|
|
5502
|
+
providerFamily: "liveblocks",
|
|
5503
|
+
documentId,
|
|
5504
|
+
roomMode,
|
|
5505
|
+
publicApiKey
|
|
5506
|
+
}
|
|
5507
|
+
};
|
|
5508
|
+
const authEndpoint = normalizeHttpUrl(authEndpointRaw, authEndpointBaseUrl);
|
|
5509
|
+
if (!authEndpoint) return {
|
|
5510
|
+
ok: false,
|
|
5511
|
+
reason: "invalid-auth-endpoint",
|
|
5512
|
+
message: "SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."
|
|
5513
|
+
};
|
|
5514
|
+
return {
|
|
5515
|
+
ok: true,
|
|
5516
|
+
target: {
|
|
5517
|
+
providerFamily: "liveblocks",
|
|
5518
|
+
documentId,
|
|
5519
|
+
roomMode,
|
|
5520
|
+
authEndpoint
|
|
5521
|
+
}
|
|
5522
|
+
};
|
|
5523
|
+
}
|
|
5524
|
+
/**
|
|
5525
|
+
* Resolve a constructor-time or upgrade-time collaboration request into a
|
|
5526
|
+
* supported v2 room target, or a stable redacted diagnostic.
|
|
5527
|
+
*/
|
|
5528
|
+
function resolveV2CollaborationTarget(input) {
|
|
5529
|
+
const { legacyCollaboration, documentType, documentCount, authEndpointBaseUrl } = input;
|
|
5530
|
+
const v2Collaboration = readCollaborationConfig(input);
|
|
5531
|
+
if (typeof documentCount === "number" && documentCount > 1) return {
|
|
5532
|
+
ok: false,
|
|
5533
|
+
reason: "unsupported-multi-document",
|
|
5534
|
+
message: `SuperDoc v2 collaboration supports exactly one document per room; received ${documentCount}.`
|
|
5535
|
+
};
|
|
5536
|
+
if (documentType != null && documentType !== "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return {
|
|
5537
|
+
ok: false,
|
|
5538
|
+
reason: "unsupported-document-type",
|
|
5539
|
+
message: "SuperDoc v2 collaboration supports DOCX documents only."
|
|
5540
|
+
};
|
|
5541
|
+
if (!(v2Collaboration != null && typeof v2Collaboration === "object")) {
|
|
5542
|
+
const family = detectUnsupportedLegacyFamily(legacyCollaboration);
|
|
5543
|
+
if (family) {
|
|
5544
|
+
const reason = family === "external-ydoc-provider" ? "unsupported-legacy-provider" : "unsupported-provider-family";
|
|
5545
|
+
const redactedUrl = redactCollaborationUrl(legacyCollaboration?.url);
|
|
5546
|
+
return {
|
|
5547
|
+
ok: false,
|
|
5548
|
+
reason,
|
|
5549
|
+
message: family === "external-ydoc-provider" ? "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. Provide a collaboration target (e.g. { providerType, documentId, url }) instead." : `SuperDoc v2 collaboration does not accept "${family}" through the legacy modules.collaboration block (server: ${redactedUrl}). Configure it as a document.collaboration target ({ providerType: "${family}", documentId, ... }) instead.`
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5552
|
+
return {
|
|
5553
|
+
ok: false,
|
|
5554
|
+
reason: "missing-target",
|
|
5555
|
+
message: "SuperDoc v2 collaboration requires a collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."
|
|
5556
|
+
};
|
|
5557
|
+
}
|
|
5558
|
+
const candidate = v2Collaboration;
|
|
5559
|
+
if (Object.prototype.hasOwnProperty.call(candidate, "createIfMissing")) return {
|
|
5560
|
+
ok: false,
|
|
5561
|
+
reason: "invalid-room-mode",
|
|
5562
|
+
message: "SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: \"create\" for creation or roomMode: \"join\" for normal opens."
|
|
5563
|
+
};
|
|
5564
|
+
if (candidate.ydoc != null || candidate.provider != null) return {
|
|
5565
|
+
ok: false,
|
|
5566
|
+
reason: "unsupported-legacy-provider",
|
|
5567
|
+
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
|
+
};
|
|
5569
|
+
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);
|
|
5574
|
+
return {
|
|
5575
|
+
ok: false,
|
|
5576
|
+
reason: "unsupported-provider-family",
|
|
5577
|
+
message: `SuperDoc v2 collaboration does not support the "${providerType}" provider family. Supported families are y-websocket, hocuspocus, liveblocks, and extension.`
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
//#endregion
|
|
5313
5581
|
//#region src/core/helpers/file.js
|
|
5314
5582
|
/**
|
|
5315
5583
|
* @typedef {Object} UploadWrapper
|
|
@@ -5433,6 +5701,14 @@ var GENERIC_BINARY_MIME = "application/octet-stream";
|
|
|
5433
5701
|
* @returns {DocumentEntry|any} A normalized entry, or the original value when it is unsupported or unchanged
|
|
5434
5702
|
*/
|
|
5435
5703
|
var normalizeDocumentEntry = (entry) => {
|
|
5704
|
+
if (entry && typeof entry === "object" && Object.prototype.hasOwnProperty.call(entry, "collaboration")) {
|
|
5705
|
+
const source = { ...entry };
|
|
5706
|
+
delete source.collaboration;
|
|
5707
|
+
entry = {
|
|
5708
|
+
...source,
|
|
5709
|
+
v2Collaboration: readCollaborationConfig(entry)
|
|
5710
|
+
};
|
|
5711
|
+
}
|
|
5436
5712
|
if (isDocumentByteSource(entry)) return {
|
|
5437
5713
|
type: DOCX,
|
|
5438
5714
|
data: documentByteSourceToUint8Array(entry),
|
|
@@ -5454,6 +5730,7 @@ var normalizeDocumentEntry = (entry) => {
|
|
|
5454
5730
|
});
|
|
5455
5731
|
else if (hasGenericType && inferredType && typeof Blob === "function" && maybeFile instanceof Blob) data = new Blob([maybeFile], { type });
|
|
5456
5732
|
return {
|
|
5733
|
+
...entry.v2Collaboration !== void 0 ? { v2Collaboration: entry.v2Collaboration } : {},
|
|
5457
5734
|
type,
|
|
5458
5735
|
data,
|
|
5459
5736
|
name
|
|
@@ -20440,266 +20717,31 @@ function unmarkRuntimeRoot(root) {
|
|
|
20440
20717
|
root.removeAttribute(RUNTIME_ROOT_ATTRIBUTE);
|
|
20441
20718
|
}
|
|
20442
20719
|
//#endregion
|
|
20443
|
-
//#region src/core/collaboration/
|
|
20444
|
-
|
|
20445
|
-
|
|
20446
|
-
|
|
20447
|
-
|
|
20448
|
-
|
|
20449
|
-
|
|
20450
|
-
|
|
20451
|
-
|
|
20452
|
-
|
|
20453
|
-
|
|
20454
|
-
|
|
20455
|
-
|
|
20456
|
-
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
return `${parsed.toString().replace(/\?$/, "")}${redactedQuery}`;
|
|
20462
|
-
} catch {
|
|
20463
|
-
const withoutCredentials = url.replace(/\/\/[^/@]+@/, "//");
|
|
20464
|
-
const cut = withoutCredentials.search(/[?#]/);
|
|
20465
|
-
if (cut === -1) return withoutCredentials;
|
|
20466
|
-
return `${withoutCredentials.slice(0, cut)}?<redacted>`;
|
|
20467
|
-
}
|
|
20468
|
-
}
|
|
20469
|
-
function normalizeNonEmptyString(value) {
|
|
20470
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20471
|
-
}
|
|
20472
|
-
function normalizeWebsocketUrl(value) {
|
|
20473
|
-
if (typeof value !== "string" || value.length === 0) return null;
|
|
20474
|
-
try {
|
|
20475
|
-
const parsed = new URL(value);
|
|
20476
|
-
return parsed.protocol === "ws:" || parsed.protocol === "wss:" ? value : null;
|
|
20477
|
-
} catch {
|
|
20478
|
-
return null;
|
|
20479
|
-
}
|
|
20480
|
-
}
|
|
20481
|
-
function normalizeHttpUrl(value, baseUrl) {
|
|
20482
|
-
if (typeof value !== "string") return null;
|
|
20483
|
-
const normalized = value.trim();
|
|
20484
|
-
if (normalized.length === 0) return null;
|
|
20485
|
-
try {
|
|
20486
|
-
const parsed = new URL(normalized);
|
|
20487
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:" ? normalized : null;
|
|
20488
|
-
} catch {
|
|
20489
|
-
if (typeof baseUrl !== "string" || baseUrl.trim().length === 0) return null;
|
|
20490
|
-
try {
|
|
20491
|
-
const parsed = new URL(normalized, baseUrl);
|
|
20492
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null;
|
|
20493
|
-
} catch {
|
|
20494
|
-
return null;
|
|
20495
|
-
}
|
|
20496
|
-
}
|
|
20497
|
-
}
|
|
20498
|
-
function normalizeParams(value) {
|
|
20499
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
20500
|
-
const params = {};
|
|
20501
|
-
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") params[key] = raw;
|
|
20502
|
-
return Object.keys(params).length > 0 ? params : void 0;
|
|
20503
|
-
}
|
|
20504
|
-
function normalizeRoomMode(value) {
|
|
20505
|
-
if (value === void 0) return "join";
|
|
20506
|
-
return value === "join" || value === "create" ? value : null;
|
|
20507
|
-
}
|
|
20508
|
-
function invalidRoomMode() {
|
|
20509
|
-
return {
|
|
20510
|
-
ok: false,
|
|
20511
|
-
reason: "invalid-room-mode",
|
|
20512
|
-
message: "SuperDoc v2 collaboration roomMode must be either \"join\" or \"create\"."
|
|
20513
|
-
};
|
|
20514
|
-
}
|
|
20515
|
-
/** Provider-family token recognized on a v2Collaboration config object. */
|
|
20516
|
-
function readProviderType(candidate) {
|
|
20517
|
-
const raw = candidate.providerType;
|
|
20518
|
-
return typeof raw === "string" && raw.length > 0 ? raw.toLowerCase() : null;
|
|
20519
|
-
}
|
|
20520
|
-
/**
|
|
20521
|
-
* Detect whether a legacy collaboration block names a provider family that the
|
|
20522
|
-
* shipped single-doc v2 runtime cannot drive. Returns the offending family name
|
|
20523
|
-
* (for diagnostics) or `null` when the block carries no recognizable family.
|
|
20524
|
-
*/
|
|
20525
|
-
function detectUnsupportedLegacyFamily(legacy) {
|
|
20526
|
-
if (!legacy || typeof legacy !== "object") return null;
|
|
20527
|
-
const providerType = typeof legacy.providerType === "string" ? legacy.providerType.toLowerCase() : "";
|
|
20528
|
-
if (providerType === "hocuspocus") return "hocuspocus";
|
|
20529
|
-
if (providerType === "liveblocks") return "liveblocks";
|
|
20530
|
-
if (providerType === "superdoc") return "superdoc";
|
|
20531
|
-
if (legacy.ydoc != null || legacy.provider != null) return "external-ydoc-provider";
|
|
20532
|
-
return null;
|
|
20533
|
-
}
|
|
20534
|
-
/** Resolve a websocket-backed family (y-websocket / Hocuspocus). */
|
|
20535
|
-
function resolveWebsocketFamily(family, candidate) {
|
|
20536
|
-
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
20537
|
-
if (!documentId) return {
|
|
20538
|
-
ok: false,
|
|
20539
|
-
reason: "invalid-document-id",
|
|
20540
|
-
message: `SuperDoc v2 collaboration requires a non-empty v2Collaboration.documentId for the "${family}" provider.`
|
|
20541
|
-
};
|
|
20542
|
-
const rawUrl = candidate.url ?? candidate.serverUrl;
|
|
20543
|
-
const serverUrl = normalizeWebsocketUrl(rawUrl);
|
|
20544
|
-
if (!serverUrl) return {
|
|
20545
|
-
ok: false,
|
|
20546
|
-
reason: "invalid-server-url",
|
|
20547
|
-
message: `SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${family}" provider (received: ${redactCollaborationUrl(rawUrl)}).`
|
|
20548
|
-
};
|
|
20549
|
-
const params = normalizeParams(candidate.params);
|
|
20550
|
-
const token = family === "hocuspocus" && typeof candidate.token === "function" ? candidate.token : family === "hocuspocus" ? normalizeNonEmptyString(candidate.token) : null;
|
|
20551
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20552
|
-
if (!roomMode) return invalidRoomMode();
|
|
20553
|
-
return {
|
|
20554
|
-
ok: true,
|
|
20555
|
-
target: {
|
|
20556
|
-
providerFamily: family,
|
|
20557
|
-
documentId,
|
|
20558
|
-
roomMode,
|
|
20559
|
-
serverUrl,
|
|
20560
|
-
...params ? { params } : {},
|
|
20561
|
-
...token ? { token } : {}
|
|
20562
|
-
}
|
|
20563
|
-
};
|
|
20564
|
-
}
|
|
20565
|
-
function resolveProviderExtension(candidate) {
|
|
20566
|
-
const adapterId = normalizeNonEmptyString(candidate.adapterId);
|
|
20567
|
-
if (!adapterId) return {
|
|
20568
|
-
ok: false,
|
|
20569
|
-
reason: "invalid-adapter-id",
|
|
20570
|
-
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.adapterId."
|
|
20571
|
-
};
|
|
20572
|
-
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
20573
|
-
if (!documentId) return {
|
|
20574
|
-
ok: false,
|
|
20575
|
-
reason: "invalid-document-id",
|
|
20576
|
-
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.documentId."
|
|
20577
|
-
};
|
|
20578
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20579
|
-
if (!roomMode) return invalidRoomMode();
|
|
20580
|
-
if (Object.prototype.hasOwnProperty.call(candidate, "providerOptions")) try {
|
|
20581
|
-
structuredClone(candidate.providerOptions);
|
|
20582
|
-
} catch {
|
|
20583
|
-
return {
|
|
20584
|
-
ok: false,
|
|
20585
|
-
reason: "invalid-provider-options",
|
|
20586
|
-
message: "SuperDoc v2 provider extension options must be structured-clone-safe."
|
|
20587
|
-
};
|
|
20588
|
-
}
|
|
20589
|
-
const token = typeof candidate.token === "function" ? candidate.token : normalizeNonEmptyString(candidate.token);
|
|
20590
|
-
return {
|
|
20591
|
-
ok: true,
|
|
20592
|
-
target: {
|
|
20593
|
-
providerFamily: "extension",
|
|
20594
|
-
adapterId,
|
|
20595
|
-
documentId,
|
|
20596
|
-
roomMode,
|
|
20597
|
-
...Object.prototype.hasOwnProperty.call(candidate, "providerOptions") ? { providerOptions: candidate.providerOptions } : {},
|
|
20598
|
-
...token ? { token } : {}
|
|
20599
|
-
}
|
|
20600
|
-
};
|
|
20601
|
-
}
|
|
20602
|
-
/** Resolve the Liveblocks family (exactly one of publicApiKey / authEndpoint). */
|
|
20603
|
-
function resolveLiveblocksFamily(candidate, authEndpointBaseUrl) {
|
|
20604
|
-
const documentId = normalizeNonEmptyString(candidate.documentId ?? candidate.roomId);
|
|
20605
|
-
if (!documentId) return {
|
|
20606
|
-
ok: false,
|
|
20607
|
-
reason: "invalid-document-id",
|
|
20608
|
-
message: "SuperDoc v2 collaboration requires a non-empty v2Collaboration.documentId (or roomId) for the \"liveblocks\" provider."
|
|
20609
|
-
};
|
|
20610
|
-
const publicApiKey = normalizeNonEmptyString(candidate.publicApiKey);
|
|
20611
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20612
|
-
if (!roomMode) return invalidRoomMode();
|
|
20613
|
-
const authEndpointRaw = candidate.authEndpoint;
|
|
20614
|
-
const hasAuthEndpoint = typeof authEndpointRaw === "string" && authEndpointRaw.length > 0;
|
|
20615
|
-
if (!publicApiKey && !hasAuthEndpoint) return {
|
|
20616
|
-
ok: false,
|
|
20617
|
-
reason: "missing-auth",
|
|
20618
|
-
message: "SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."
|
|
20619
|
-
};
|
|
20620
|
-
if (publicApiKey && hasAuthEndpoint) return {
|
|
20621
|
-
ok: false,
|
|
20622
|
-
reason: "mixed-auth",
|
|
20623
|
-
message: "SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."
|
|
20624
|
-
};
|
|
20625
|
-
if (publicApiKey) return {
|
|
20626
|
-
ok: true,
|
|
20627
|
-
target: {
|
|
20628
|
-
providerFamily: "liveblocks",
|
|
20629
|
-
documentId,
|
|
20630
|
-
roomMode,
|
|
20631
|
-
publicApiKey
|
|
20632
|
-
}
|
|
20633
|
-
};
|
|
20634
|
-
const authEndpoint = normalizeHttpUrl(authEndpointRaw, authEndpointBaseUrl);
|
|
20635
|
-
if (!authEndpoint) return {
|
|
20636
|
-
ok: false,
|
|
20637
|
-
reason: "invalid-auth-endpoint",
|
|
20638
|
-
message: "SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."
|
|
20639
|
-
};
|
|
20640
|
-
return {
|
|
20641
|
-
ok: true,
|
|
20642
|
-
target: {
|
|
20643
|
-
providerFamily: "liveblocks",
|
|
20644
|
-
documentId,
|
|
20645
|
-
roomMode,
|
|
20646
|
-
authEndpoint
|
|
20647
|
-
}
|
|
20648
|
-
};
|
|
20649
|
-
}
|
|
20650
|
-
/**
|
|
20651
|
-
* Resolve a constructor-time or upgrade-time collaboration request into a
|
|
20652
|
-
* supported v2 room target, or a stable redacted diagnostic.
|
|
20653
|
-
*/
|
|
20654
|
-
function resolveV2CollaborationTarget(input) {
|
|
20655
|
-
const { v2Collaboration, legacyCollaboration, documentType, documentCount, authEndpointBaseUrl } = input;
|
|
20656
|
-
if (typeof documentCount === "number" && documentCount > 1) return {
|
|
20657
|
-
ok: false,
|
|
20658
|
-
reason: "unsupported-multi-document",
|
|
20659
|
-
message: `SuperDoc v2 collaboration supports exactly one document per room; received ${documentCount}.`
|
|
20660
|
-
};
|
|
20661
|
-
if (documentType != null && documentType !== "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return {
|
|
20662
|
-
ok: false,
|
|
20663
|
-
reason: "unsupported-document-type",
|
|
20664
|
-
message: "SuperDoc v2 collaboration supports DOCX documents only."
|
|
20665
|
-
};
|
|
20666
|
-
if (!(v2Collaboration != null && typeof v2Collaboration === "object")) {
|
|
20667
|
-
const family = detectUnsupportedLegacyFamily(legacyCollaboration);
|
|
20668
|
-
if (family) {
|
|
20669
|
-
const reason = family === "external-ydoc-provider" ? "unsupported-legacy-provider" : "unsupported-provider-family";
|
|
20670
|
-
const redactedUrl = redactCollaborationUrl(legacyCollaboration?.url);
|
|
20671
|
-
return {
|
|
20672
|
-
ok: false,
|
|
20673
|
-
reason,
|
|
20674
|
-
message: family === "external-ydoc-provider" ? "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. Provide a v2Collaboration target (e.g. { providerType, documentId, url }) instead." : `SuperDoc v2 collaboration does not accept "${family}" through the legacy modules.collaboration block (server: ${redactedUrl}). Configure it as a v2Collaboration target ({ providerType: "${family}", documentId, ... }) instead.`
|
|
20675
|
-
};
|
|
20676
|
-
}
|
|
20677
|
-
return {
|
|
20678
|
-
ok: false,
|
|
20679
|
-
reason: "missing-target",
|
|
20680
|
-
message: "SuperDoc v2 collaboration requires a v2Collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."
|
|
20681
|
-
};
|
|
20720
|
+
//#region src/core/collaboration/collaboration-exception.ts
|
|
20721
|
+
function createCollaborationException(code, documentId) {
|
|
20722
|
+
let collaborationReason;
|
|
20723
|
+
let message;
|
|
20724
|
+
switch (code) {
|
|
20725
|
+
case "collaboration-access-denied":
|
|
20726
|
+
collaborationReason = "access-denied";
|
|
20727
|
+
message = "The collaboration server rejected access to this room.";
|
|
20728
|
+
break;
|
|
20729
|
+
case "collaboration-connection-failed":
|
|
20730
|
+
collaborationReason = "connection-failed";
|
|
20731
|
+
message = "The collaboration connection failed.";
|
|
20732
|
+
break;
|
|
20733
|
+
case "collaboration-sync-timeout":
|
|
20734
|
+
collaborationReason = "sync-timeout";
|
|
20735
|
+
message = "The collaboration room did not finish synchronizing in time.";
|
|
20736
|
+
break;
|
|
20737
|
+
default: return null;
|
|
20682
20738
|
}
|
|
20683
|
-
const candidate = v2Collaboration;
|
|
20684
|
-
if (Object.prototype.hasOwnProperty.call(candidate, "createIfMissing")) return {
|
|
20685
|
-
ok: false,
|
|
20686
|
-
reason: "invalid-room-mode",
|
|
20687
|
-
message: "SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: \"create\" for creation or roomMode: \"join\" for normal opens."
|
|
20688
|
-
};
|
|
20689
|
-
if (candidate.ydoc != null || candidate.provider != null) return {
|
|
20690
|
-
ok: false,
|
|
20691
|
-
reason: "unsupported-legacy-provider",
|
|
20692
|
-
message: "SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a v2Collaboration target ({ providerType, documentId, url | publicApiKey | authEndpoint }) instead."
|
|
20693
|
-
};
|
|
20694
|
-
const providerType = readProviderType(candidate);
|
|
20695
|
-
if (providerType === null || providerType === "y-websocket") return resolveWebsocketFamily("y-websocket", candidate);
|
|
20696
|
-
if (providerType === "hocuspocus") return resolveWebsocketFamily("hocuspocus", candidate);
|
|
20697
|
-
if (providerType === "liveblocks") return resolveLiveblocksFamily(candidate, authEndpointBaseUrl);
|
|
20698
|
-
if (providerType === "extension") return resolveProviderExtension(candidate);
|
|
20699
20739
|
return {
|
|
20700
|
-
|
|
20701
|
-
|
|
20702
|
-
|
|
20740
|
+
error: new Error(message),
|
|
20741
|
+
code,
|
|
20742
|
+
collaborationReason,
|
|
20743
|
+
documentId,
|
|
20744
|
+
editor: null
|
|
20703
20745
|
};
|
|
20704
20746
|
}
|
|
20705
20747
|
//#endregion
|
|
@@ -22910,7 +22952,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22910
22952
|
case "worker-init-failed": return "SuperDoc could not load the document editor because the browser worker failed to start.";
|
|
22911
22953
|
case "input-too-large-for-inline-review": return "SuperDoc could not load the document editor because this document is too large to open without the browser worker.";
|
|
22912
22954
|
case "collaboration-unsupported-huge-document": return "SuperDoc could not load the document editor because large documents cannot be opened with collaboration enabled yet.";
|
|
22913
|
-
case "collaboration-v1-config-unsupported": return "SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.
|
|
22955
|
+
case "collaboration-v1-config-unsupported": return "SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.collaboration with a v2 room instead.";
|
|
22914
22956
|
case "collaboration-room-format-unsupported": return "SuperDoc v2 cannot open this collaboration state because it is not stored in the SuperDoc v2 room format. No changes were made.";
|
|
22915
22957
|
case "collaboration-room-format-conflict": return "SuperDoc v2 found conflicting room formats in one collaboration document. No changes were made.";
|
|
22916
22958
|
case "collaboration-room-corrupt": return "SuperDoc v2 found a structurally invalid collaboration room. No changes were made.";
|
|
@@ -22928,7 +22970,8 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22928
22970
|
const reason = typeof payload?.reason === "string" && payload.reason.length > 0 ? payload.reason : "open-failed";
|
|
22929
22971
|
const detail = normalizeV2EditorFailureDetail(payload?.detail);
|
|
22930
22972
|
const documentId = typeof payload?.documentId === "string" && payload.documentId.length > 0 ? payload.documentId : null;
|
|
22931
|
-
const
|
|
22973
|
+
const collaborationException = createCollaborationException(reason, documentId);
|
|
22974
|
+
const message = collaborationException?.error.message ?? getV2EditorFailureMessage(reason);
|
|
22932
22975
|
const workerFailure = payload?.workerFailure && typeof payload.workerFailure === "object" ? payload.workerFailure : null;
|
|
22933
22976
|
setV2EditorFailure(documentId, {
|
|
22934
22977
|
reason,
|
|
@@ -22944,7 +22987,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
22944
22987
|
};
|
|
22945
22988
|
if (reason === "collaboration-v1-config-unsupported" || reason === "collaboration-room-format-unsupported" || reason === "collaboration-room-format-conflict" || reason === "collaboration-room-corrupt" || reason === "collaboration-v2-room-missing" || reason === "collaboration-v2-room-already-exists" || reason === "collaboration-v2-room-initializing" || reason === "collaboration-open-intent-invalid" || reason === "collaboration-config-invalid") console.warn(`[SuperDoc] ${message}`, logContext);
|
|
22946
22989
|
else console.error(`[SuperDoc] ${message}`, logContext);
|
|
22947
|
-
proxy.$superdoc.emit("exception", {
|
|
22990
|
+
proxy.$superdoc.emit("exception", collaborationException ?? {
|
|
22948
22991
|
error: new Error(message),
|
|
22949
22992
|
code: reason,
|
|
22950
22993
|
...documentId ? { documentId } : {},
|
|
@@ -24168,7 +24211,7 @@ var SuperDoc_default = /*#__PURE__*/ _plugin_vue_export_helper_default({
|
|
|
24168
24211
|
], 38);
|
|
24169
24212
|
};
|
|
24170
24213
|
}
|
|
24171
|
-
}, [["__scopeId", "data-v-
|
|
24214
|
+
}, [["__scopeId", "data-v-ebe9a1fb"]]);
|
|
24172
24215
|
//#endregion
|
|
24173
24216
|
//#region src/core/create-app.js
|
|
24174
24217
|
var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
|
|
@@ -45330,7 +45373,7 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
45330
45373
|
this.config.colors = shuffleArray(this.config.colors);
|
|
45331
45374
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
45332
45375
|
this.colorIndex = 0;
|
|
45333
|
-
this.version = "2.13.0-next.
|
|
45376
|
+
this.version = "2.13.0-next.9";
|
|
45334
45377
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
45335
45378
|
this.superdocId = config.superdocId || v4();
|
|
45336
45379
|
this.colors = this.config.colors ?? [];
|
|
@@ -46200,8 +46243,10 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
46200
46243
|
ydoc: options.ydoc,
|
|
46201
46244
|
provider: options.provider
|
|
46202
46245
|
} : collaborationModule ? { ...collaborationModule } : null;
|
|
46246
|
+
const v2Collaboration = options.v2Collaboration ?? this.#unwrapMaybeRef(configDoc.v2Collaboration) ?? collaborationModule?.v2Collaboration ?? collaborationModule?.v2 ?? null;
|
|
46203
46247
|
const resolution = resolveV2CollaborationTarget({
|
|
46204
|
-
|
|
46248
|
+
collaboration: options.collaboration,
|
|
46249
|
+
v2Collaboration,
|
|
46205
46250
|
legacyCollaboration,
|
|
46206
46251
|
documentType: DOCX,
|
|
46207
46252
|
documentCount: cfg.documents.length,
|