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.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.13.0-next.
|
|
319
|
+
return "2.13.0-next.9";
|
|
320
320
|
} catch {
|
|
321
321
|
return "unknown";
|
|
322
322
|
}
|
|
@@ -5311,6 +5311,274 @@ function storeToRefs(store) {
|
|
|
5311
5311
|
return refs;
|
|
5312
5312
|
}
|
|
5313
5313
|
//#endregion
|
|
5314
|
+
//#region src/core/collaboration/resolve-v2-collaboration-target.ts
|
|
5315
|
+
/** Select the public spelling before validation; do not merge settings from different rooms. */
|
|
5316
|
+
function readCollaborationConfig(input) {
|
|
5317
|
+
return input.collaboration !== void 0 ? input.collaboration : input.v2Collaboration;
|
|
5318
|
+
}
|
|
5319
|
+
/**
|
|
5320
|
+
* Redact a connection URL for safe inclusion in diagnostics and artifacts.
|
|
5321
|
+
*
|
|
5322
|
+
* Strips the query string, fragment, and any embedded credentials (userinfo)
|
|
5323
|
+
* because those commonly carry auth tokens. Falls back to a coarse string scrub
|
|
5324
|
+
* when the value is not a parseable absolute URL so a malformed value with an
|
|
5325
|
+
* inline `?token=...` still cannot leak.
|
|
5326
|
+
*/
|
|
5327
|
+
function redactCollaborationUrl(url) {
|
|
5328
|
+
if (typeof url !== "string" || url.length === 0) return "<none>";
|
|
5329
|
+
try {
|
|
5330
|
+
const parsed = new URL(url);
|
|
5331
|
+
parsed.search = "";
|
|
5332
|
+
parsed.hash = "";
|
|
5333
|
+
parsed.username = "";
|
|
5334
|
+
parsed.password = "";
|
|
5335
|
+
const redactedQuery = url.includes("?") ? "?<redacted>" : "";
|
|
5336
|
+
return `${parsed.toString().replace(/\?$/, "")}${redactedQuery}`;
|
|
5337
|
+
} catch {
|
|
5338
|
+
const withoutCredentials = url.replace(/\/\/[^/@]+@/, "//");
|
|
5339
|
+
const cut = withoutCredentials.search(/[?#]/);
|
|
5340
|
+
if (cut === -1) return withoutCredentials;
|
|
5341
|
+
return `${withoutCredentials.slice(0, cut)}?<redacted>`;
|
|
5342
|
+
}
|
|
5343
|
+
}
|
|
5344
|
+
function normalizeNonEmptyString(value) {
|
|
5345
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
5346
|
+
}
|
|
5347
|
+
function normalizeWebsocketUrl(value) {
|
|
5348
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
5349
|
+
try {
|
|
5350
|
+
const parsed = new URL(value);
|
|
5351
|
+
return parsed.protocol === "ws:" || parsed.protocol === "wss:" ? value : null;
|
|
5352
|
+
} catch {
|
|
5353
|
+
return null;
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
function normalizeHttpUrl(value, baseUrl) {
|
|
5357
|
+
if (typeof value !== "string") return null;
|
|
5358
|
+
const normalized = value.trim();
|
|
5359
|
+
if (normalized.length === 0) return null;
|
|
5360
|
+
try {
|
|
5361
|
+
const parsed = new URL(normalized);
|
|
5362
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? normalized : null;
|
|
5363
|
+
} catch {
|
|
5364
|
+
if (typeof baseUrl !== "string" || baseUrl.trim().length === 0) return null;
|
|
5365
|
+
try {
|
|
5366
|
+
const parsed = new URL(normalized, baseUrl);
|
|
5367
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null;
|
|
5368
|
+
} catch {
|
|
5369
|
+
return null;
|
|
5370
|
+
}
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
function normalizeParams(value) {
|
|
5374
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
5375
|
+
const params = {};
|
|
5376
|
+
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") params[key] = raw;
|
|
5377
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
5378
|
+
}
|
|
5379
|
+
function normalizeRoomMode(value) {
|
|
5380
|
+
if (value === void 0) return "join";
|
|
5381
|
+
return value === "join" || value === "create" ? value : null;
|
|
5382
|
+
}
|
|
5383
|
+
function invalidRoomMode() {
|
|
5384
|
+
return {
|
|
5385
|
+
ok: false,
|
|
5386
|
+
reason: "invalid-room-mode",
|
|
5387
|
+
message: "SuperDoc v2 collaboration roomMode must be either \"join\" or \"create\"."
|
|
5388
|
+
};
|
|
5389
|
+
}
|
|
5390
|
+
/** Provider-family token recognized on a v2Collaboration config object. */
|
|
5391
|
+
function readProviderType(candidate) {
|
|
5392
|
+
const raw = candidate.providerType;
|
|
5393
|
+
return typeof raw === "string" && raw.length > 0 ? raw.toLowerCase() : null;
|
|
5394
|
+
}
|
|
5395
|
+
/**
|
|
5396
|
+
* Detect whether a legacy collaboration block names a provider family that the
|
|
5397
|
+
* shipped single-doc v2 runtime cannot drive. Returns the offending family name
|
|
5398
|
+
* (for diagnostics) or `null` when the block carries no recognizable family.
|
|
5399
|
+
*/
|
|
5400
|
+
function detectUnsupportedLegacyFamily(legacy) {
|
|
5401
|
+
if (!legacy || typeof legacy !== "object") return null;
|
|
5402
|
+
const providerType = typeof legacy.providerType === "string" ? legacy.providerType.toLowerCase() : "";
|
|
5403
|
+
if (providerType === "hocuspocus") return "hocuspocus";
|
|
5404
|
+
if (providerType === "liveblocks") return "liveblocks";
|
|
5405
|
+
if (providerType === "superdoc") return "superdoc";
|
|
5406
|
+
if (legacy.ydoc != null || legacy.provider != null) return "external-ydoc-provider";
|
|
5407
|
+
return null;
|
|
5408
|
+
}
|
|
5409
|
+
/** Resolve a websocket-backed family (y-websocket / Hocuspocus). */
|
|
5410
|
+
function resolveWebsocketFamily(family, candidate) {
|
|
5411
|
+
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
5412
|
+
if (!documentId) return {
|
|
5413
|
+
ok: false,
|
|
5414
|
+
reason: "invalid-document-id",
|
|
5415
|
+
message: `SuperDoc v2 collaboration requires a non-empty collaboration.documentId for the "${family}" provider.`
|
|
5416
|
+
};
|
|
5417
|
+
const rawUrl = candidate.url ?? candidate.serverUrl;
|
|
5418
|
+
const serverUrl = normalizeWebsocketUrl(rawUrl);
|
|
5419
|
+
if (!serverUrl) return {
|
|
5420
|
+
ok: false,
|
|
5421
|
+
reason: "invalid-server-url",
|
|
5422
|
+
message: `SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${family}" provider (received: ${redactCollaborationUrl(rawUrl)}).`
|
|
5423
|
+
};
|
|
5424
|
+
const params = normalizeParams(candidate.params);
|
|
5425
|
+
const token = family === "hocuspocus" && typeof candidate.token === "function" ? candidate.token : family === "hocuspocus" ? normalizeNonEmptyString(candidate.token) : null;
|
|
5426
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5427
|
+
if (!roomMode) return invalidRoomMode();
|
|
5428
|
+
return {
|
|
5429
|
+
ok: true,
|
|
5430
|
+
target: {
|
|
5431
|
+
providerFamily: family,
|
|
5432
|
+
documentId,
|
|
5433
|
+
roomMode,
|
|
5434
|
+
serverUrl,
|
|
5435
|
+
...params ? { params } : {},
|
|
5436
|
+
...token ? { token } : {}
|
|
5437
|
+
}
|
|
5438
|
+
};
|
|
5439
|
+
}
|
|
5440
|
+
function resolveProviderExtension(candidate) {
|
|
5441
|
+
const adapterId = normalizeNonEmptyString(candidate.adapterId);
|
|
5442
|
+
if (!adapterId) return {
|
|
5443
|
+
ok: false,
|
|
5444
|
+
reason: "invalid-adapter-id",
|
|
5445
|
+
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.adapterId."
|
|
5446
|
+
};
|
|
5447
|
+
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
5448
|
+
if (!documentId) return {
|
|
5449
|
+
ok: false,
|
|
5450
|
+
reason: "invalid-document-id",
|
|
5451
|
+
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.documentId."
|
|
5452
|
+
};
|
|
5453
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5454
|
+
if (!roomMode) return invalidRoomMode();
|
|
5455
|
+
if (Object.prototype.hasOwnProperty.call(candidate, "providerOptions")) try {
|
|
5456
|
+
structuredClone(candidate.providerOptions);
|
|
5457
|
+
} catch {
|
|
5458
|
+
return {
|
|
5459
|
+
ok: false,
|
|
5460
|
+
reason: "invalid-provider-options",
|
|
5461
|
+
message: "SuperDoc v2 provider extension options must be structured-clone-safe."
|
|
5462
|
+
};
|
|
5463
|
+
}
|
|
5464
|
+
const token = typeof candidate.token === "function" ? candidate.token : normalizeNonEmptyString(candidate.token);
|
|
5465
|
+
return {
|
|
5466
|
+
ok: true,
|
|
5467
|
+
target: {
|
|
5468
|
+
providerFamily: "extension",
|
|
5469
|
+
adapterId,
|
|
5470
|
+
documentId,
|
|
5471
|
+
roomMode,
|
|
5472
|
+
...Object.prototype.hasOwnProperty.call(candidate, "providerOptions") ? { providerOptions: candidate.providerOptions } : {},
|
|
5473
|
+
...token ? { token } : {}
|
|
5474
|
+
}
|
|
5475
|
+
};
|
|
5476
|
+
}
|
|
5477
|
+
/** Resolve the Liveblocks family (exactly one of publicApiKey / authEndpoint). */
|
|
5478
|
+
function resolveLiveblocksFamily(candidate, authEndpointBaseUrl) {
|
|
5479
|
+
const documentId = normalizeNonEmptyString(candidate.documentId ?? candidate.roomId);
|
|
5480
|
+
if (!documentId) return {
|
|
5481
|
+
ok: false,
|
|
5482
|
+
reason: "invalid-document-id",
|
|
5483
|
+
message: "SuperDoc v2 collaboration requires a non-empty collaboration.documentId (or roomId) for the \"liveblocks\" provider."
|
|
5484
|
+
};
|
|
5485
|
+
const publicApiKey = normalizeNonEmptyString(candidate.publicApiKey);
|
|
5486
|
+
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
5487
|
+
if (!roomMode) return invalidRoomMode();
|
|
5488
|
+
const authEndpointRaw = candidate.authEndpoint;
|
|
5489
|
+
const hasAuthEndpoint = typeof authEndpointRaw === "string" && authEndpointRaw.length > 0;
|
|
5490
|
+
if (!publicApiKey && !hasAuthEndpoint) return {
|
|
5491
|
+
ok: false,
|
|
5492
|
+
reason: "missing-auth",
|
|
5493
|
+
message: "SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."
|
|
5494
|
+
};
|
|
5495
|
+
if (publicApiKey && hasAuthEndpoint) return {
|
|
5496
|
+
ok: false,
|
|
5497
|
+
reason: "mixed-auth",
|
|
5498
|
+
message: "SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."
|
|
5499
|
+
};
|
|
5500
|
+
if (publicApiKey) return {
|
|
5501
|
+
ok: true,
|
|
5502
|
+
target: {
|
|
5503
|
+
providerFamily: "liveblocks",
|
|
5504
|
+
documentId,
|
|
5505
|
+
roomMode,
|
|
5506
|
+
publicApiKey
|
|
5507
|
+
}
|
|
5508
|
+
};
|
|
5509
|
+
const authEndpoint = normalizeHttpUrl(authEndpointRaw, authEndpointBaseUrl);
|
|
5510
|
+
if (!authEndpoint) return {
|
|
5511
|
+
ok: false,
|
|
5512
|
+
reason: "invalid-auth-endpoint",
|
|
5513
|
+
message: "SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."
|
|
5514
|
+
};
|
|
5515
|
+
return {
|
|
5516
|
+
ok: true,
|
|
5517
|
+
target: {
|
|
5518
|
+
providerFamily: "liveblocks",
|
|
5519
|
+
documentId,
|
|
5520
|
+
roomMode,
|
|
5521
|
+
authEndpoint
|
|
5522
|
+
}
|
|
5523
|
+
};
|
|
5524
|
+
}
|
|
5525
|
+
/**
|
|
5526
|
+
* Resolve a constructor-time or upgrade-time collaboration request into a
|
|
5527
|
+
* supported v2 room target, or a stable redacted diagnostic.
|
|
5528
|
+
*/
|
|
5529
|
+
function resolveV2CollaborationTarget(input) {
|
|
5530
|
+
const { legacyCollaboration, documentType, documentCount, authEndpointBaseUrl } = input;
|
|
5531
|
+
const v2Collaboration = readCollaborationConfig(input);
|
|
5532
|
+
if (typeof documentCount === "number" && documentCount > 1) return {
|
|
5533
|
+
ok: false,
|
|
5534
|
+
reason: "unsupported-multi-document",
|
|
5535
|
+
message: `SuperDoc v2 collaboration supports exactly one document per room; received ${documentCount}.`
|
|
5536
|
+
};
|
|
5537
|
+
if (documentType != null && documentType !== "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return {
|
|
5538
|
+
ok: false,
|
|
5539
|
+
reason: "unsupported-document-type",
|
|
5540
|
+
message: "SuperDoc v2 collaboration supports DOCX documents only."
|
|
5541
|
+
};
|
|
5542
|
+
if (!(v2Collaboration != null && typeof v2Collaboration === "object")) {
|
|
5543
|
+
const family = detectUnsupportedLegacyFamily(legacyCollaboration);
|
|
5544
|
+
if (family) {
|
|
5545
|
+
const reason = family === "external-ydoc-provider" ? "unsupported-legacy-provider" : "unsupported-provider-family";
|
|
5546
|
+
const redactedUrl = redactCollaborationUrl(legacyCollaboration?.url);
|
|
5547
|
+
return {
|
|
5548
|
+
ok: false,
|
|
5549
|
+
reason,
|
|
5550
|
+
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.`
|
|
5551
|
+
};
|
|
5552
|
+
}
|
|
5553
|
+
return {
|
|
5554
|
+
ok: false,
|
|
5555
|
+
reason: "missing-target",
|
|
5556
|
+
message: "SuperDoc v2 collaboration requires a collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."
|
|
5557
|
+
};
|
|
5558
|
+
}
|
|
5559
|
+
const candidate = v2Collaboration;
|
|
5560
|
+
if (Object.prototype.hasOwnProperty.call(candidate, "createIfMissing")) return {
|
|
5561
|
+
ok: false,
|
|
5562
|
+
reason: "invalid-room-mode",
|
|
5563
|
+
message: "SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: \"create\" for creation or roomMode: \"join\" for normal opens."
|
|
5564
|
+
};
|
|
5565
|
+
if (candidate.ydoc != null || candidate.provider != null) return {
|
|
5566
|
+
ok: false,
|
|
5567
|
+
reason: "unsupported-legacy-provider",
|
|
5568
|
+
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
|
+
};
|
|
5570
|
+
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);
|
|
5575
|
+
return {
|
|
5576
|
+
ok: false,
|
|
5577
|
+
reason: "unsupported-provider-family",
|
|
5578
|
+
message: `SuperDoc v2 collaboration does not support the "${providerType}" provider family. Supported families are y-websocket, hocuspocus, liveblocks, and extension.`
|
|
5579
|
+
};
|
|
5580
|
+
}
|
|
5581
|
+
//#endregion
|
|
5314
5582
|
//#region src/core/helpers/file.js
|
|
5315
5583
|
/**
|
|
5316
5584
|
* @typedef {Object} UploadWrapper
|
|
@@ -5434,6 +5702,14 @@ var GENERIC_BINARY_MIME = "application/octet-stream";
|
|
|
5434
5702
|
* @returns {DocumentEntry|any} A normalized entry, or the original value when it is unsupported or unchanged
|
|
5435
5703
|
*/
|
|
5436
5704
|
var normalizeDocumentEntry = (entry) => {
|
|
5705
|
+
if (entry && typeof entry === "object" && Object.prototype.hasOwnProperty.call(entry, "collaboration")) {
|
|
5706
|
+
const source = { ...entry };
|
|
5707
|
+
delete source.collaboration;
|
|
5708
|
+
entry = {
|
|
5709
|
+
...source,
|
|
5710
|
+
v2Collaboration: readCollaborationConfig(entry)
|
|
5711
|
+
};
|
|
5712
|
+
}
|
|
5437
5713
|
if (isDocumentByteSource(entry)) return {
|
|
5438
5714
|
type: DOCX,
|
|
5439
5715
|
data: documentByteSourceToUint8Array(entry),
|
|
@@ -5455,6 +5731,7 @@ var normalizeDocumentEntry = (entry) => {
|
|
|
5455
5731
|
});
|
|
5456
5732
|
else if (hasGenericType && inferredType && typeof Blob === "function" && maybeFile instanceof Blob) data = new Blob([maybeFile], { type });
|
|
5457
5733
|
return {
|
|
5734
|
+
...entry.v2Collaboration !== void 0 ? { v2Collaboration: entry.v2Collaboration } : {},
|
|
5458
5735
|
type,
|
|
5459
5736
|
data,
|
|
5460
5737
|
name
|
|
@@ -20472,266 +20749,31 @@ function unmarkRuntimeRoot(root) {
|
|
|
20472
20749
|
root.removeAttribute(RUNTIME_ROOT_ATTRIBUTE);
|
|
20473
20750
|
}
|
|
20474
20751
|
//#endregion
|
|
20475
|
-
//#region src/core/collaboration/
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
|
|
20479
|
-
|
|
20480
|
-
|
|
20481
|
-
|
|
20482
|
-
|
|
20483
|
-
|
|
20484
|
-
|
|
20485
|
-
|
|
20486
|
-
|
|
20487
|
-
|
|
20488
|
-
|
|
20489
|
-
|
|
20490
|
-
|
|
20491
|
-
|
|
20492
|
-
|
|
20493
|
-
return `${parsed.toString().replace(/\?$/, "")}${redactedQuery}`;
|
|
20494
|
-
} catch {
|
|
20495
|
-
const withoutCredentials = url.replace(/\/\/[^/@]+@/, "//");
|
|
20496
|
-
const cut = withoutCredentials.search(/[?#]/);
|
|
20497
|
-
if (cut === -1) return withoutCredentials;
|
|
20498
|
-
return `${withoutCredentials.slice(0, cut)}?<redacted>`;
|
|
20499
|
-
}
|
|
20500
|
-
}
|
|
20501
|
-
function normalizeNonEmptyString(value) {
|
|
20502
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
20503
|
-
}
|
|
20504
|
-
function normalizeWebsocketUrl(value) {
|
|
20505
|
-
if (typeof value !== "string" || value.length === 0) return null;
|
|
20506
|
-
try {
|
|
20507
|
-
const parsed = new URL(value);
|
|
20508
|
-
return parsed.protocol === "ws:" || parsed.protocol === "wss:" ? value : null;
|
|
20509
|
-
} catch {
|
|
20510
|
-
return null;
|
|
20511
|
-
}
|
|
20512
|
-
}
|
|
20513
|
-
function normalizeHttpUrl(value, baseUrl) {
|
|
20514
|
-
if (typeof value !== "string") return null;
|
|
20515
|
-
const normalized = value.trim();
|
|
20516
|
-
if (normalized.length === 0) return null;
|
|
20517
|
-
try {
|
|
20518
|
-
const parsed = new URL(normalized);
|
|
20519
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:" ? normalized : null;
|
|
20520
|
-
} catch {
|
|
20521
|
-
if (typeof baseUrl !== "string" || baseUrl.trim().length === 0) return null;
|
|
20522
|
-
try {
|
|
20523
|
-
const parsed = new URL(normalized, baseUrl);
|
|
20524
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed.href : null;
|
|
20525
|
-
} catch {
|
|
20526
|
-
return null;
|
|
20527
|
-
}
|
|
20528
|
-
}
|
|
20529
|
-
}
|
|
20530
|
-
function normalizeParams(value) {
|
|
20531
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
20532
|
-
const params = {};
|
|
20533
|
-
for (const [key, raw] of Object.entries(value)) if (typeof raw === "string") params[key] = raw;
|
|
20534
|
-
return Object.keys(params).length > 0 ? params : void 0;
|
|
20535
|
-
}
|
|
20536
|
-
function normalizeRoomMode(value) {
|
|
20537
|
-
if (value === void 0) return "join";
|
|
20538
|
-
return value === "join" || value === "create" ? value : null;
|
|
20539
|
-
}
|
|
20540
|
-
function invalidRoomMode() {
|
|
20541
|
-
return {
|
|
20542
|
-
ok: false,
|
|
20543
|
-
reason: "invalid-room-mode",
|
|
20544
|
-
message: "SuperDoc v2 collaboration roomMode must be either \"join\" or \"create\"."
|
|
20545
|
-
};
|
|
20546
|
-
}
|
|
20547
|
-
/** Provider-family token recognized on a v2Collaboration config object. */
|
|
20548
|
-
function readProviderType(candidate) {
|
|
20549
|
-
const raw = candidate.providerType;
|
|
20550
|
-
return typeof raw === "string" && raw.length > 0 ? raw.toLowerCase() : null;
|
|
20551
|
-
}
|
|
20552
|
-
/**
|
|
20553
|
-
* Detect whether a legacy collaboration block names a provider family that the
|
|
20554
|
-
* shipped single-doc v2 runtime cannot drive. Returns the offending family name
|
|
20555
|
-
* (for diagnostics) or `null` when the block carries no recognizable family.
|
|
20556
|
-
*/
|
|
20557
|
-
function detectUnsupportedLegacyFamily(legacy) {
|
|
20558
|
-
if (!legacy || typeof legacy !== "object") return null;
|
|
20559
|
-
const providerType = typeof legacy.providerType === "string" ? legacy.providerType.toLowerCase() : "";
|
|
20560
|
-
if (providerType === "hocuspocus") return "hocuspocus";
|
|
20561
|
-
if (providerType === "liveblocks") return "liveblocks";
|
|
20562
|
-
if (providerType === "superdoc") return "superdoc";
|
|
20563
|
-
if (legacy.ydoc != null || legacy.provider != null) return "external-ydoc-provider";
|
|
20564
|
-
return null;
|
|
20565
|
-
}
|
|
20566
|
-
/** Resolve a websocket-backed family (y-websocket / Hocuspocus). */
|
|
20567
|
-
function resolveWebsocketFamily(family, candidate) {
|
|
20568
|
-
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
20569
|
-
if (!documentId) return {
|
|
20570
|
-
ok: false,
|
|
20571
|
-
reason: "invalid-document-id",
|
|
20572
|
-
message: `SuperDoc v2 collaboration requires a non-empty v2Collaboration.documentId for the "${family}" provider.`
|
|
20573
|
-
};
|
|
20574
|
-
const rawUrl = candidate.url ?? candidate.serverUrl;
|
|
20575
|
-
const serverUrl = normalizeWebsocketUrl(rawUrl);
|
|
20576
|
-
if (!serverUrl) return {
|
|
20577
|
-
ok: false,
|
|
20578
|
-
reason: "invalid-server-url",
|
|
20579
|
-
message: `SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${family}" provider (received: ${redactCollaborationUrl(rawUrl)}).`
|
|
20580
|
-
};
|
|
20581
|
-
const params = normalizeParams(candidate.params);
|
|
20582
|
-
const token = family === "hocuspocus" && typeof candidate.token === "function" ? candidate.token : family === "hocuspocus" ? normalizeNonEmptyString(candidate.token) : null;
|
|
20583
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20584
|
-
if (!roomMode) return invalidRoomMode();
|
|
20585
|
-
return {
|
|
20586
|
-
ok: true,
|
|
20587
|
-
target: {
|
|
20588
|
-
providerFamily: family,
|
|
20589
|
-
documentId,
|
|
20590
|
-
roomMode,
|
|
20591
|
-
serverUrl,
|
|
20592
|
-
...params ? { params } : {},
|
|
20593
|
-
...token ? { token } : {}
|
|
20594
|
-
}
|
|
20595
|
-
};
|
|
20596
|
-
}
|
|
20597
|
-
function resolveProviderExtension(candidate) {
|
|
20598
|
-
const adapterId = normalizeNonEmptyString(candidate.adapterId);
|
|
20599
|
-
if (!adapterId) return {
|
|
20600
|
-
ok: false,
|
|
20601
|
-
reason: "invalid-adapter-id",
|
|
20602
|
-
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.adapterId."
|
|
20603
|
-
};
|
|
20604
|
-
const documentId = normalizeNonEmptyString(candidate.documentId);
|
|
20605
|
-
if (!documentId) return {
|
|
20606
|
-
ok: false,
|
|
20607
|
-
reason: "invalid-document-id",
|
|
20608
|
-
message: "SuperDoc v2 provider extensions require a non-empty v2Collaboration.documentId."
|
|
20609
|
-
};
|
|
20610
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20611
|
-
if (!roomMode) return invalidRoomMode();
|
|
20612
|
-
if (Object.prototype.hasOwnProperty.call(candidate, "providerOptions")) try {
|
|
20613
|
-
structuredClone(candidate.providerOptions);
|
|
20614
|
-
} catch {
|
|
20615
|
-
return {
|
|
20616
|
-
ok: false,
|
|
20617
|
-
reason: "invalid-provider-options",
|
|
20618
|
-
message: "SuperDoc v2 provider extension options must be structured-clone-safe."
|
|
20619
|
-
};
|
|
20620
|
-
}
|
|
20621
|
-
const token = typeof candidate.token === "function" ? candidate.token : normalizeNonEmptyString(candidate.token);
|
|
20622
|
-
return {
|
|
20623
|
-
ok: true,
|
|
20624
|
-
target: {
|
|
20625
|
-
providerFamily: "extension",
|
|
20626
|
-
adapterId,
|
|
20627
|
-
documentId,
|
|
20628
|
-
roomMode,
|
|
20629
|
-
...Object.prototype.hasOwnProperty.call(candidate, "providerOptions") ? { providerOptions: candidate.providerOptions } : {},
|
|
20630
|
-
...token ? { token } : {}
|
|
20631
|
-
}
|
|
20632
|
-
};
|
|
20633
|
-
}
|
|
20634
|
-
/** Resolve the Liveblocks family (exactly one of publicApiKey / authEndpoint). */
|
|
20635
|
-
function resolveLiveblocksFamily(candidate, authEndpointBaseUrl) {
|
|
20636
|
-
const documentId = normalizeNonEmptyString(candidate.documentId ?? candidate.roomId);
|
|
20637
|
-
if (!documentId) return {
|
|
20638
|
-
ok: false,
|
|
20639
|
-
reason: "invalid-document-id",
|
|
20640
|
-
message: "SuperDoc v2 collaboration requires a non-empty v2Collaboration.documentId (or roomId) for the \"liveblocks\" provider."
|
|
20641
|
-
};
|
|
20642
|
-
const publicApiKey = normalizeNonEmptyString(candidate.publicApiKey);
|
|
20643
|
-
const roomMode = normalizeRoomMode(candidate.roomMode);
|
|
20644
|
-
if (!roomMode) return invalidRoomMode();
|
|
20645
|
-
const authEndpointRaw = candidate.authEndpoint;
|
|
20646
|
-
const hasAuthEndpoint = typeof authEndpointRaw === "string" && authEndpointRaw.length > 0;
|
|
20647
|
-
if (!publicApiKey && !hasAuthEndpoint) return {
|
|
20648
|
-
ok: false,
|
|
20649
|
-
reason: "missing-auth",
|
|
20650
|
-
message: "SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."
|
|
20651
|
-
};
|
|
20652
|
-
if (publicApiKey && hasAuthEndpoint) return {
|
|
20653
|
-
ok: false,
|
|
20654
|
-
reason: "mixed-auth",
|
|
20655
|
-
message: "SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."
|
|
20656
|
-
};
|
|
20657
|
-
if (publicApiKey) return {
|
|
20658
|
-
ok: true,
|
|
20659
|
-
target: {
|
|
20660
|
-
providerFamily: "liveblocks",
|
|
20661
|
-
documentId,
|
|
20662
|
-
roomMode,
|
|
20663
|
-
publicApiKey
|
|
20664
|
-
}
|
|
20665
|
-
};
|
|
20666
|
-
const authEndpoint = normalizeHttpUrl(authEndpointRaw, authEndpointBaseUrl);
|
|
20667
|
-
if (!authEndpoint) return {
|
|
20668
|
-
ok: false,
|
|
20669
|
-
reason: "invalid-auth-endpoint",
|
|
20670
|
-
message: "SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."
|
|
20671
|
-
};
|
|
20672
|
-
return {
|
|
20673
|
-
ok: true,
|
|
20674
|
-
target: {
|
|
20675
|
-
providerFamily: "liveblocks",
|
|
20676
|
-
documentId,
|
|
20677
|
-
roomMode,
|
|
20678
|
-
authEndpoint
|
|
20679
|
-
}
|
|
20680
|
-
};
|
|
20681
|
-
}
|
|
20682
|
-
/**
|
|
20683
|
-
* Resolve a constructor-time or upgrade-time collaboration request into a
|
|
20684
|
-
* supported v2 room target, or a stable redacted diagnostic.
|
|
20685
|
-
*/
|
|
20686
|
-
function resolveV2CollaborationTarget(input) {
|
|
20687
|
-
const { v2Collaboration, legacyCollaboration, documentType, documentCount, authEndpointBaseUrl } = input;
|
|
20688
|
-
if (typeof documentCount === "number" && documentCount > 1) return {
|
|
20689
|
-
ok: false,
|
|
20690
|
-
reason: "unsupported-multi-document",
|
|
20691
|
-
message: `SuperDoc v2 collaboration supports exactly one document per room; received ${documentCount}.`
|
|
20692
|
-
};
|
|
20693
|
-
if (documentType != null && documentType !== "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return {
|
|
20694
|
-
ok: false,
|
|
20695
|
-
reason: "unsupported-document-type",
|
|
20696
|
-
message: "SuperDoc v2 collaboration supports DOCX documents only."
|
|
20697
|
-
};
|
|
20698
|
-
if (!(v2Collaboration != null && typeof v2Collaboration === "object")) {
|
|
20699
|
-
const family = detectUnsupportedLegacyFamily(legacyCollaboration);
|
|
20700
|
-
if (family) {
|
|
20701
|
-
const reason = family === "external-ydoc-provider" ? "unsupported-legacy-provider" : "unsupported-provider-family";
|
|
20702
|
-
const redactedUrl = redactCollaborationUrl(legacyCollaboration?.url);
|
|
20703
|
-
return {
|
|
20704
|
-
ok: false,
|
|
20705
|
-
reason,
|
|
20706
|
-
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.`
|
|
20707
|
-
};
|
|
20708
|
-
}
|
|
20709
|
-
return {
|
|
20710
|
-
ok: false,
|
|
20711
|
-
reason: "missing-target",
|
|
20712
|
-
message: "SuperDoc v2 collaboration requires a v2Collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."
|
|
20713
|
-
};
|
|
20752
|
+
//#region src/core/collaboration/collaboration-exception.ts
|
|
20753
|
+
function createCollaborationException(code, documentId) {
|
|
20754
|
+
let collaborationReason;
|
|
20755
|
+
let message;
|
|
20756
|
+
switch (code) {
|
|
20757
|
+
case "collaboration-access-denied":
|
|
20758
|
+
collaborationReason = "access-denied";
|
|
20759
|
+
message = "The collaboration server rejected access to this room.";
|
|
20760
|
+
break;
|
|
20761
|
+
case "collaboration-connection-failed":
|
|
20762
|
+
collaborationReason = "connection-failed";
|
|
20763
|
+
message = "The collaboration connection failed.";
|
|
20764
|
+
break;
|
|
20765
|
+
case "collaboration-sync-timeout":
|
|
20766
|
+
collaborationReason = "sync-timeout";
|
|
20767
|
+
message = "The collaboration room did not finish synchronizing in time.";
|
|
20768
|
+
break;
|
|
20769
|
+
default: return null;
|
|
20714
20770
|
}
|
|
20715
|
-
const candidate = v2Collaboration;
|
|
20716
|
-
if (Object.prototype.hasOwnProperty.call(candidate, "createIfMissing")) return {
|
|
20717
|
-
ok: false,
|
|
20718
|
-
reason: "invalid-room-mode",
|
|
20719
|
-
message: "SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: \"create\" for creation or roomMode: \"join\" for normal opens."
|
|
20720
|
-
};
|
|
20721
|
-
if (candidate.ydoc != null || candidate.provider != null) return {
|
|
20722
|
-
ok: false,
|
|
20723
|
-
reason: "unsupported-legacy-provider",
|
|
20724
|
-
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."
|
|
20725
|
-
};
|
|
20726
|
-
const providerType = readProviderType(candidate);
|
|
20727
|
-
if (providerType === null || providerType === "y-websocket") return resolveWebsocketFamily("y-websocket", candidate);
|
|
20728
|
-
if (providerType === "hocuspocus") return resolveWebsocketFamily("hocuspocus", candidate);
|
|
20729
|
-
if (providerType === "liveblocks") return resolveLiveblocksFamily(candidate, authEndpointBaseUrl);
|
|
20730
|
-
if (providerType === "extension") return resolveProviderExtension(candidate);
|
|
20731
20771
|
return {
|
|
20732
|
-
|
|
20733
|
-
|
|
20734
|
-
|
|
20772
|
+
error: new Error(message),
|
|
20773
|
+
code,
|
|
20774
|
+
collaborationReason,
|
|
20775
|
+
documentId,
|
|
20776
|
+
editor: null
|
|
20735
20777
|
};
|
|
20736
20778
|
}
|
|
20737
20779
|
//#endregion
|
|
@@ -22950,7 +22992,7 @@ var SuperDoc_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_v
|
|
|
22950
22992
|
case "worker-init-failed": return "SuperDoc could not load the document editor because the browser worker failed to start.";
|
|
22951
22993
|
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.";
|
|
22952
22994
|
case "collaboration-unsupported-huge-document": return "SuperDoc could not load the document editor because large documents cannot be opened with collaboration enabled yet.";
|
|
22953
|
-
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.
|
|
22995
|
+
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.";
|
|
22954
22996
|
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.";
|
|
22955
22997
|
case "collaboration-room-format-conflict": return "SuperDoc v2 found conflicting room formats in one collaboration document. No changes were made.";
|
|
22956
22998
|
case "collaboration-room-corrupt": return "SuperDoc v2 found a structurally invalid collaboration room. No changes were made.";
|
|
@@ -22968,7 +23010,8 @@ var SuperDoc_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_v
|
|
|
22968
23010
|
const reason = typeof payload?.reason === "string" && payload.reason.length > 0 ? payload.reason : "open-failed";
|
|
22969
23011
|
const detail = normalizeV2EditorFailureDetail(payload?.detail);
|
|
22970
23012
|
const documentId = typeof payload?.documentId === "string" && payload.documentId.length > 0 ? payload.documentId : null;
|
|
22971
|
-
const
|
|
23013
|
+
const collaborationException = createCollaborationException(reason, documentId);
|
|
23014
|
+
const message = collaborationException?.error.message ?? getV2EditorFailureMessage(reason);
|
|
22972
23015
|
const workerFailure = payload?.workerFailure && typeof payload.workerFailure === "object" ? payload.workerFailure : null;
|
|
22973
23016
|
setV2EditorFailure(documentId, {
|
|
22974
23017
|
reason,
|
|
@@ -22984,7 +23027,7 @@ var SuperDoc_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_v
|
|
|
22984
23027
|
};
|
|
22985
23028
|
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);
|
|
22986
23029
|
else console.error(`[SuperDoc] ${message}`, logContext);
|
|
22987
|
-
proxy.$superdoc.emit("exception", {
|
|
23030
|
+
proxy.$superdoc.emit("exception", collaborationException ?? {
|
|
22988
23031
|
error: new Error(message),
|
|
22989
23032
|
code: reason,
|
|
22990
23033
|
...documentId ? { documentId } : {},
|
|
@@ -24208,7 +24251,7 @@ var SuperDoc_default = /*#__PURE__*/ require__plugin_vue_export_helper._plugin_v
|
|
|
24208
24251
|
], 38);
|
|
24209
24252
|
};
|
|
24210
24253
|
}
|
|
24211
|
-
}, [["__scopeId", "data-v-
|
|
24254
|
+
}, [["__scopeId", "data-v-ebe9a1fb"]]);
|
|
24212
24255
|
//#endregion
|
|
24213
24256
|
//#region src/core/create-app.js
|
|
24214
24257
|
var PINIA_DEVTOOLS_SETUP_EVENT = "devtools-plugin:setup";
|
|
@@ -45399,7 +45442,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
|
|
|
45399
45442
|
this.config.colors = shuffleArray(this.config.colors);
|
|
45400
45443
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
45401
45444
|
this.colorIndex = 0;
|
|
45402
|
-
this.version = "2.13.0-next.
|
|
45445
|
+
this.version = "2.13.0-next.9";
|
|
45403
45446
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
45404
45447
|
this.superdocId = config.superdocId || require_uuid.v4();
|
|
45405
45448
|
this.colors = this.config.colors ?? [];
|
|
@@ -46269,8 +46312,10 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
|
|
|
46269
46312
|
ydoc: options.ydoc,
|
|
46270
46313
|
provider: options.provider
|
|
46271
46314
|
} : collaborationModule ? { ...collaborationModule } : null;
|
|
46315
|
+
const v2Collaboration = options.v2Collaboration ?? this.#unwrapMaybeRef(configDoc.v2Collaboration) ?? collaborationModule?.v2Collaboration ?? collaborationModule?.v2 ?? null;
|
|
46272
46316
|
const resolution = resolveV2CollaborationTarget({
|
|
46273
|
-
|
|
46317
|
+
collaboration: options.collaboration,
|
|
46318
|
+
v2Collaboration,
|
|
46274
46319
|
legacyCollaboration,
|
|
46275
46320
|
documentType: DOCX,
|
|
46276
46321
|
documentCount: cfg.documents.length,
|