@superdoc/cli 0.39.0-next.6 → 0.39.0-next.7

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.
Files changed (2) hide show
  1. package/dist/index.js +119 -47
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -322748,7 +322748,35 @@ async function bootstrapV2Room(input) {
322748
322748
  diagnostics
322749
322749
  };
322750
322750
  }
322751
+ let supersededClaim = null;
322752
+ if (input.supersedeClaim) {
322753
+ const active = readBootstrapClaims(input.rootDoc).filter((claim) => claim.status === "pending");
322754
+ if (classification.classification !== ROOM_CLASSIFICATION.v2Pending || active.length !== 1 || active[0]?.claimerId !== input.supersedeClaim.claimerId || active[0]?.claimedAt !== input.supersedeClaim.claimedAt || active[0]?.sha256Zip !== seed.sha256Zip || input.supersedeClaim.claimerId === input.claimerId) {
322755
+ diagnostics.push({
322756
+ code: COLLAB_V2_DIAGNOSTICS.COLLAB_V2_BOOTSTRAP_CLAIM_LOST,
322757
+ message: "expired bootstrap claim changed before retry could take over"
322758
+ });
322759
+ return {
322760
+ classification: ROOM_CLASSIFICATION.v2Pending,
322761
+ committed: false,
322762
+ snapshot: readRoomManifest(input.rootDoc).snapshot,
322763
+ survivorClaimerId: active[0]?.claimerId ?? null,
322764
+ diagnostics
322765
+ };
322766
+ }
322767
+ supersededClaim = active[0] ?? null;
322768
+ }
322751
322769
  const publishPendingBootstrap = () => {
322770
+ if (supersededClaim) {
322771
+ writeBootstrapClaim({
322772
+ rootDoc: input.rootDoc,
322773
+ claimerId: supersededClaim.claimerId,
322774
+ claimedAt: supersededClaim.claimedAt,
322775
+ sha256Zip: supersededClaim.sha256Zip,
322776
+ byteLength: supersededClaim.byteLength,
322777
+ status: "aborted"
322778
+ });
322779
+ }
322752
322780
  writeBootstrapClaim({
322753
322781
  rootDoc: input.rootDoc,
322754
322782
  claimerId: input.claimerId,
@@ -322757,22 +322785,24 @@ async function bootstrapV2Room(input) {
322757
322785
  byteLength: seed.byteLength,
322758
322786
  status: "pending"
322759
322787
  });
322760
- writeRoomManifestMeta({
322761
- rootDoc: input.rootDoc,
322762
- roomDocumentId: rootId,
322763
- createdAt,
322764
- createdBy: input.createdBy ?? null,
322765
- createdFrom: {
322766
- kind: "docx",
322767
- sha256Zip: seed.sha256Zip,
322768
- byteLength: seed.byteLength,
322769
- filename: input.filename ?? null,
322770
- migration: input.migration ?? null
322771
- },
322772
- bootstrapState: BOOTSTRAP_STATE.pending,
322773
- compatibilityPolicy: input.compatibilityPolicy ?? DEFAULT_COMPATIBILITY_POLICY,
322774
- schemaVersion
322775
- });
322788
+ if (classification.classification !== ROOM_CLASSIFICATION.v2Pending) {
322789
+ writeRoomManifestMeta({
322790
+ rootDoc: input.rootDoc,
322791
+ roomDocumentId: rootId,
322792
+ createdAt,
322793
+ createdBy: input.createdBy ?? null,
322794
+ createdFrom: {
322795
+ kind: "docx",
322796
+ sha256Zip: seed.sha256Zip,
322797
+ byteLength: seed.byteLength,
322798
+ filename: input.filename ?? null,
322799
+ migration: input.migration ?? null
322800
+ },
322801
+ bootstrapState: BOOTSTRAP_STATE.pending,
322802
+ compatibilityPolicy: input.compatibilityPolicy ?? DEFAULT_COMPATIBILITY_POLICY,
322803
+ schemaVersion
322804
+ });
322805
+ }
322776
322806
  };
322777
322807
  if (replacingExistingRoom) {
322778
322808
  input.rootDoc.transact(() => {
@@ -322780,7 +322810,7 @@ async function bootstrapV2Room(input) {
322780
322810
  publishPendingBootstrap();
322781
322811
  }, "collab-v2:replace:prepare-bootstrap");
322782
322812
  } else {
322783
- publishPendingBootstrap();
322813
+ input.rootDoc.transact(publishPendingBootstrap, "collab-v2:create:prepare-bootstrap");
322784
322814
  }
322785
322815
  const waitForSettling = input.waitForSettling ?? DEFAULT_SETTLING_RESOLVER;
322786
322816
  await waitForSettling();
@@ -345092,6 +345122,8 @@ function createCollabV2SessionProjectionController(options) {
345092
345122
  subscription.unsubscribe();
345093
345123
  }
345094
345124
  for (const handle of options.projectionRegistry.listStories()) {
345125
+ if (handle.rootDoc && handle.scope && getUnitScope(handle.rootDoc, handle.shardId) !== handle.scope)
345126
+ continue;
345095
345127
  disposeStoryBlockIndex(shardReadTarget(handle));
345096
345128
  }
345097
345129
  if (SESSION_PROJECTION_CONTROLLERS.get(options.session) === controller) {
@@ -345700,6 +345732,7 @@ var init_session_controller = __esm(() => {
345700
345732
  init_runtime5();
345701
345733
  init_barrier();
345702
345734
  init_diagnostics2();
345735
+ init_content3();
345703
345736
  init_story_para_id_allocator();
345704
345737
  init_revision_wid_allocator2();
345705
345738
  init_session_controller_origin();
@@ -346092,6 +346125,7 @@ async function bootstrapV2RoomFromDocxSingleDoc(input) {
346092
346125
  docxBytes: input.docxBytes,
346093
346126
  filename: input.filename ?? null,
346094
346127
  claimerId: input.claimerId,
346128
+ ...input.supersedeClaim ? { supersedeClaim: input.supersedeClaim } : {},
346095
346129
  ...input.createdBy ? { createdBy: input.createdBy } : {},
346096
346130
  ...input.createdAt ? { createdAt: input.createdAt } : {},
346097
346131
  ...input.migration ? { migration: input.migration } : {},
@@ -346368,7 +346402,8 @@ function createHeadlessCollabRoomCoordinator(options) {
346368
346402
  const manifestObserver = () => {
346369
346403
  if (disposed)
346370
346404
  return;
346371
- if (observeReplacementCommits())
346405
+ const replacementCommitted = observeReplacementCommits();
346406
+ if (replacementCommitted)
346372
346407
  pruneReplacedRoomOrphans(options.rootDoc);
346373
346408
  const nextParts = getPackagePartsMap(options.rootDoc);
346374
346409
  const generationChanged = nextParts !== packageParts;
@@ -346378,7 +346413,7 @@ function createHeadlessCollabRoomCoordinator(options) {
346378
346413
  packageParts = nextParts;
346379
346414
  packageParts.observe(manifestObserver);
346380
346415
  meta.observe(manifestObserver);
346381
- packageReplacementPending = true;
346416
+ packageReplacementPending || (packageReplacementPending = replacementCommitted || Array.from(lock.entries()).some(([key2, value2]) => key2.startsWith("replaceFile:") && value2 != null && typeof value2 === "object" && (value2.state === "pending" || value2.state === "applying")));
346382
346417
  }
346383
346418
  syncCommittedRoomSourceIdentity();
346384
346419
  if (generationChanged)
@@ -350064,6 +350099,7 @@ function createHeadlessV2SingleDocCollaborationRuntimeSkeleton(options) {
350064
350099
  docxBytes: request.docxBytes,
350065
350100
  filename: request.filename ?? null,
350066
350101
  claimerId: request.claimerId,
350102
+ ...request.supersedeClaim ? { supersedeClaim: request.supersedeClaim } : {},
350067
350103
  ...request.createdBy ? { createdBy: request.createdBy } : {},
350068
350104
  ...request.createdAt ? { createdAt: request.createdAt } : {},
350069
350105
  ...request.migration ? { migration: request.migration } : {},
@@ -350182,6 +350218,7 @@ async function openV2CollaborativeDocumentSession(options) {
350182
350218
  const trace = createOpenTrace(options.runtime.rootId);
350183
350219
  const blobStore = runtimeBlobStore(options.runtime);
350184
350220
  const rootConn = options.runtime.connectRoot();
350221
+ const bootstrapClaimerId = options.claimerId ?? `headless-open-${crypto.randomUUID()}`;
350185
350222
  await rootConn.waitForSync();
350186
350223
  await waitForDocUpdateSettling(rootConn.ydoc, settleMaxMs);
350187
350224
  trace.mark("root-sync");
@@ -350254,7 +350291,10 @@ async function openV2CollaborativeDocumentSession(options) {
350254
350291
  }
350255
350292
  const pendingCreate = openIntent.mode === "create" && validation.classification.classification === ROOM_CLASSIFICATION.v2Pending;
350256
350293
  const pendingRoomStalled = validation.classification.classification === ROOM_CLASSIFICATION.v2Pending && isPendingRoomStalled(rootConn.ydoc);
350257
- if (openIntent.mode === "join" || pendingCreate && !canResumePendingBootstrap(rootConn.ydoc, options.claimerId ?? DEFAULT_CLAIMER_ID, sha256Hex2(resolveBootstrapBytes(openIntent, options.buffer)))) {
350294
+ const bootstrapSourceSha256 = openIntent.mode === "create" && pendingCreate ? sha256Hex2(resolveBootstrapBytes(openIntent, options.buffer)) : null;
350295
+ const resumableClaim = bootstrapSourceSha256 !== null ? resumablePendingBootstrapClaim(rootConn.ydoc, bootstrapSourceSha256) : null;
350296
+ const supersedeClaim = resumableClaim && options.profile === "browser" && options.claimerId === undefined ? { claimerId: resumableClaim.claimerId, claimedAt: resumableClaim.claimedAt } : null;
350297
+ if (openIntent.mode === "join" || pendingCreate && resumableClaim?.claimerId !== bootstrapClaimerId && !supersedeClaim) {
350258
350298
  const isPending = validation.classification.classification === ROOM_CLASSIFICATION.v2Pending;
350259
350299
  throw new CollabV2DiagnosticError(isPending ? pendingRoomStalled ? COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_BOOTSTRAP_STALLED : COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_INITIALIZING : COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_NOT_FOUND, isPending ? pendingRoomStalled ? "v2 collaboration room bootstrap appears stalled; this open did not modify the room" : "v2 collaboration room bootstrap is incomplete; open will not write into a pending room" : "no committed v2 collaboration room exists for join intent", redactForDiagnostics({
350260
350300
  classification: validation.classification.classification,
@@ -350263,17 +350303,22 @@ async function openV2CollaborativeDocumentSession(options) {
350263
350303
  }));
350264
350304
  }
350265
350305
  if (openIntent.mode === "create") {
350266
- stopBootstrapHeartbeat = startBootstrapHeartbeat(rootConn.ydoc, options.claimerId ?? DEFAULT_CLAIMER_ID, () => rootConn.state);
350306
+ stopBootstrapHeartbeat = startBootstrapHeartbeat(rootConn.ydoc, bootstrapClaimerId, () => rootConn.state);
350267
350307
  }
350268
350308
  const bootstrapBytes = resolveBootstrapBytes(openIntent, options.buffer);
350269
350309
  bootstrap = await options.runtime.bootstrapFromDocx({
350270
350310
  docxBytes: bootstrapBytes,
350271
350311
  filename: options.filename ?? null,
350272
- claimerId: options.claimerId ?? DEFAULT_CLAIMER_ID,
350312
+ claimerId: bootstrapClaimerId,
350313
+ ...supersedeClaim ? { supersedeClaim } : {},
350273
350314
  ...options.createdBy ? { createdBy: options.createdBy } : {},
350274
350315
  ...options.createdAt ? { createdAt: options.createdAt } : {},
350275
350316
  ...options.migration ? { migration: options.migration } : {}
350276
350317
  });
350318
+ if (bootstrap.bootstrap.diagnostics.some((diagnostic2) => diagnostic2.code === COLLAB_V2_DIAGNOSTICS.COLLAB_V2_BOOTSTRAP_CLAIM_LOST)) {
350319
+ const roomCommitted = readRoomManifest(rootConn.ydoc).snapshot?.meta.bootstrapState === "committed";
350320
+ throw new CollabV2DiagnosticError(roomCommitted ? COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_ALREADY_EXISTS : COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_INITIALIZING, roomCommitted ? "create intent targeted an already-committed v2 collaboration room" : "another creator is initializing this v2 collaboration room", { rootId: options.runtime.rootId });
350321
+ }
350277
350322
  trace.mark("bootstrap");
350278
350323
  validation = options.runtime.validateLateJoin({
350279
350324
  compatibility: { supports: COLLAB_V2_ROOM_SCHEMA_VERSION },
@@ -350281,7 +350326,7 @@ async function openV2CollaborativeDocumentSession(options) {
350281
350326
  });
350282
350327
  trace.mark("post-bootstrap-validation");
350283
350328
  }
350284
- const expectedClaimerId = options.claimerId ?? DEFAULT_CLAIMER_ID;
350329
+ const expectedClaimerId = bootstrapClaimerId;
350285
350330
  const ownsPreparedBootstrap = bootstrap?.bootstrap.prepared === true && bootstrap.bootstrap.survivorClaimerId === expectedClaimerId;
350286
350331
  if (!validation.ok && !ownsPreparedBootstrap) {
350287
350332
  throwLateJoinValidationFailure(validation, options.runtime.rootId);
@@ -350322,6 +350367,13 @@ async function openV2CollaborativeDocumentSession(options) {
350322
350367
  trace,
350323
350368
  retainImportedStorySources: options.retainImportedStorySources
350324
350369
  });
350370
+ const assertCurrentRoomScopes = () => {
350371
+ for (const handle of [...canonical.storyHandles.values(), ...canonical.projectionHandles.values()]) {
350372
+ if (handle.scope && getUnitScope(rootConn.ydoc, handle.shardId) !== handle.scope) {
350373
+ throw new CollabV2DiagnosticError(COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_INITIALIZING, "room content changed during this open; check the committed room and reopen with join", { rootId: options.runtime.rootId });
350374
+ }
350375
+ }
350376
+ };
350325
350377
  if (bootstrap?.bootstrap.prepared === true) {
350326
350378
  const finalized = finalizeV2RoomBootstrap({
350327
350379
  rootDoc: rootConn.ydoc,
@@ -350329,6 +350381,9 @@ async function openV2CollaborativeDocumentSession(options) {
350329
350381
  contentUnitIds: Array.from(canonical.contentUnitIds)
350330
350382
  });
350331
350383
  if (!finalized.committed) {
350384
+ if (finalized.diagnostics.some((diagnostic2) => diagnostic2.code === COLLAB_V2_DIAGNOSTICS.COLLAB_V2_BOOTSTRAP_CLAIM_LOST)) {
350385
+ throw new CollabV2DiagnosticError(COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_INITIALIZING, "another creator is initializing this v2 collaboration room", { rootId: options.runtime.rootId });
350386
+ }
350332
350387
  throw new CollabV2DiagnosticError(COLLAB_V2_DIAGNOSTICS.COLLAB_V2_ROOM_MANIFEST_CORRUPT, "single-doc collaboration bootstrap could not prove complete content before commit", redactForDiagnostics({
350333
350388
  rootId: options.runtime.rootId,
350334
350389
  diagnostics: finalized.diagnostics
@@ -350364,7 +350419,7 @@ async function openV2CollaborativeDocumentSession(options) {
350364
350419
  session,
350365
350420
  rootDoc: rootConn.ydoc,
350366
350421
  beforeBarrier() {
350367
- return coordinator?.waitForManifestSettled();
350422
+ return coordinator?.waitForManifestSettled().then(assertCurrentRoomScopes);
350368
350423
  },
350369
350424
  packageMutationSync(prepared) {
350370
350425
  coordinator?.syncPreparedPackageMutation(prepared);
@@ -350434,6 +350489,7 @@ async function openV2CollaborativeDocumentSession(options) {
350434
350489
  await waitForProjectionDocsSettling(rootConn.ydoc, canonical, settleMaxMs);
350435
350490
  trace.mark("post-attach-settle");
350436
350491
  }
350492
+ assertCurrentRoomScopes();
350437
350493
  const refreshed = collab.refresh();
350438
350494
  trace.mark("initial-refresh");
350439
350495
  trace.sessionSnapshot("after-initial-refresh", session);
@@ -350513,7 +350569,7 @@ async function openV2CollaborativeDocumentSession(options) {
350513
350569
  try {
350514
350570
  coordinator?.dispose();
350515
350571
  } catch {}
350516
- if (bootstrap?.bootstrap.prepared === true)
350572
+ if (bootstrap?.bootstrap.prepared === true && bootstrap.bootstrap.survivorClaimerId === bootstrapClaimerId && readRoomManifest(rootConn.ydoc).snapshot?.meta.bootstrapState === "pending" && readBootstrapClaims(rootConn.ydoc).filter((claim) => claim.status === "pending").every((claim) => claim.claimerId === bootstrapClaimerId))
350517
350573
  abortBootstrapState(rootConn.ydoc);
350518
350574
  setLocalSelectionStoryHandles(options.runtime, null);
350519
350575
  await session?.dispose().catch(() => {
@@ -350619,24 +350675,35 @@ async function applyPreparedRoomReplacement(input) {
350619
350675
  function createReplacementOperationId(rootDoc) {
350620
350676
  return `${rootDoc.clientID.toString(36)}-${Date.now().toString(36)}-${(replacementSequence++).toString(36)}`;
350621
350677
  }
350622
- function canResumePendingBootstrap(rootDoc, claimerId, sourceSha256) {
350678
+ function resumablePendingBootstrapClaim(rootDoc, sourceSha256) {
350623
350679
  const activeClaims = readBootstrapClaims(rootDoc).filter((claim) => claim.status === "pending");
350624
- if (activeClaims.length !== 1 || activeClaims[0]?.claimerId !== claimerId || activeClaims[0].sha256Zip !== sourceSha256) {
350625
- return false;
350680
+ if (activeClaims.length !== 1 || activeClaims[0]?.sha256Zip !== sourceSha256) {
350681
+ return null;
350626
350682
  }
350627
350683
  if (!isBootstrapLeaseExpired(rootDoc, activeClaims[0]))
350628
- return false;
350684
+ return null;
350629
350685
  const content3 = rootDoc.getMap(ROOT_MAP.content);
350630
350686
  for (const [shardId, scope] of content3.entries()) {
350631
350687
  if (!(scope instanceof YMap))
350632
- return false;
350633
- if (scope.size === 0)
350688
+ return null;
350689
+ if (scope.size === 0 || isUntouchedPackagePartScope(scope))
350634
350690
  continue;
350635
350691
  const meta = scope.get("meta");
350636
350692
  if (!(meta instanceof YMap) || meta.get("shardId") !== shardId || meta.get(CONTENT_UNIT_META_KEY.seedComplete) !== true)
350693
+ return null;
350694
+ }
350695
+ return activeClaims[0];
350696
+ }
350697
+ function isUntouchedPackagePartScope(scope) {
350698
+ if (scope.size !== 5)
350699
+ return false;
350700
+ for (const key2 of [PACKAGE_PART_ROOT.meta, PACKAGE_PART_ROOT.records, PACKAGE_PART_ROOT.index, PACKAGE_PART_ROOT.opaque]) {
350701
+ const child = scope.get(key2);
350702
+ if (!(child instanceof YMap) || child.size !== 0)
350637
350703
  return false;
350638
350704
  }
350639
- return true;
350705
+ const diagnostics = scope.get(PACKAGE_PART_ROOT.diagnostics);
350706
+ return diagnostics instanceof YArray && diagnostics.length === 0;
350640
350707
  }
350641
350708
  function isPendingRoomStalled(rootDoc) {
350642
350709
  const claims = readBootstrapClaims(rootDoc).filter((claim) => claim.status === "pending");
@@ -351636,7 +351703,7 @@ function formatLateJoinValidationFailure(validation) {
351636
351703
  const diagnostics = validation.diagnostics.length > 0 ? validation.diagnostics.map((diagnostic2) => `${diagnostic2.code}: ${diagnostic2.message}`).join("; ") : "no diagnostics reported";
351637
351704
  return `v2 collaboration late-join validation failed (${validation.classification.classification}, ${readiness}): ${diagnostics}`;
351638
351705
  }
351639
- var TEXT_DECODER11, DEFAULT_CLAIMER_ID = "headless-open", REPLACEMENT_REQUEST_KEY_PREFIX = "replaceFile:", REPLACEMENT_HEARTBEAT_INTERVAL_MS = 5000, REPLACEMENT_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_HEARTBEAT_INTERVAL_MS = 5000, BOOTSTRAP_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_LEASE_KEY_PREFIX = "bootstrapSeed:", SETTINGS_PART_URI7 = "/word/settings.xml", WEB_SETTINGS_PART_URI2 = "/word/webSettings.xml", COMMENTS_PART_URI6 = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI6 = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI6 = "/word/commentsIds.xml", PEOPLE_PART_URI2 = "/word/people.xml", MEDIA_OWNER_URI2 = "/word/media", INLINE_BINARY_FAMILIES, OPAQUE_PART_FAMILIES, DEFAULT_OPEN_INTENT, POST_SYNC_SETTLE_MAX_MS = 1000, POST_SYNC_QUIET_WINDOW_MS = 20, replacementSequence = 0, replacementHeartbeatObservations;
351706
+ var TEXT_DECODER11, REPLACEMENT_REQUEST_KEY_PREFIX = "replaceFile:", REPLACEMENT_HEARTBEAT_INTERVAL_MS = 5000, REPLACEMENT_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_HEARTBEAT_INTERVAL_MS = 5000, BOOTSTRAP_LEASE_TIMEOUT_MS = 30000, BOOTSTRAP_LEASE_KEY_PREFIX = "bootstrapSeed:", SETTINGS_PART_URI7 = "/word/settings.xml", WEB_SETTINGS_PART_URI2 = "/word/webSettings.xml", COMMENTS_PART_URI6 = "/word/comments.xml", COMMENTS_EXTENDED_PART_URI6 = "/word/commentsExtended.xml", COMMENTS_IDS_PART_URI6 = "/word/commentsIds.xml", PEOPLE_PART_URI2 = "/word/people.xml", MEDIA_OWNER_URI2 = "/word/media", INLINE_BINARY_FAMILIES, OPAQUE_PART_FAMILIES, DEFAULT_OPEN_INTENT, POST_SYNC_SETTLE_MAX_MS = 1000, POST_SYNC_QUIET_WINDOW_MS = 20, replacementSequence = 0, replacementHeartbeatObservations;
351640
351707
  var init_collaboration_v2_open = __esm(() => {
351641
351708
  init_dist9();
351642
351709
  init_setup();
@@ -354174,7 +354241,6 @@ __export(exports_document_v2, {
354174
354241
  openV2Document: () => openV2Document,
354175
354242
  openV2CollaborativeDocument: () => openV2CollaborativeDocument
354176
354243
  });
354177
- import { createHash as createHash3 } from "node:crypto";
354178
354244
  import path4 from "node:path";
354179
354245
  function cloneBytes(bytes) {
354180
354246
  return new Uint8Array(bytes);
@@ -354318,7 +354384,6 @@ async function openV2CollaborativeDocument(doc, io, profile, options = {}) {
354318
354384
  profile: "node",
354319
354385
  filePathLabel: meta.path ?? "replacement.docx",
354320
354386
  filename: meta.path ? path4.basename(meta.path) : "replacement.docx",
354321
- claimerId: createHash3("sha256").update(profile.documentId).digest("hex").slice(0, 12),
354322
354387
  createdBy: { hint: options.user?.email || options.user?.name || "CLI" },
354323
354388
  openIntent,
354324
354389
  ...profile.bootstrapSettlingMs != null ? { bootstrapSettlingMs: profile.bootstrapSettlingMs } : {},
@@ -354352,10 +354417,17 @@ async function openV2CollaborativeDocument(doc, io, profile, options = {}) {
354352
354417
  sessionType: "collab"
354353
354418
  });
354354
354419
  }
354355
- return {
354356
- bytes: await saveCollaborativeDocumentSession(collaborative.session),
354357
- warnings: []
354358
- };
354420
+ try {
354421
+ return {
354422
+ bytes: await saveCollaborativeDocumentSession(collaborative.session),
354423
+ warnings: []
354424
+ };
354425
+ } catch (error4) {
354426
+ const mapped = mapV2CollaborativeOpenError(error4, { message: "Failed to save collaborative document in the v2 runtime.", details: { source: meta } }, { sensitiveValues: options.collaborationAuth ? [options.collaborationAuth.token] : [] });
354427
+ if (mapped.code !== "DOCUMENT_OPEN_FAILED")
354428
+ throw mapped;
354429
+ throw error4;
354430
+ }
354359
354431
  }
354360
354432
  });
354361
354433
  return {
@@ -354480,7 +354552,7 @@ var init_document_v2 = __esm(() => {
354480
354552
  });
354481
354553
 
354482
354554
  // src/lib/document.ts
354483
- import { createHash as createHash4 } from "node:crypto";
354555
+ import { createHash as createHash3 } from "node:crypto";
354484
354556
  import { readFile as readFile5 } from "node:fs/promises";
354485
354557
  async function openSessionDocument(doc, io, metadata2, options = {}) {
354486
354558
  const { executionMode, sessionPool, sessionId } = options;
@@ -354554,7 +354626,7 @@ async function getFileChecksum(path5) {
354554
354626
  message
354555
354627
  });
354556
354628
  }
354557
- return createHash4("sha256").update(bytes).digest("hex");
354629
+ return createHash3("sha256").update(bytes).digest("hex");
354558
354630
  }
354559
354631
  async function exportOptionalSessionOutput(opened, io, outPath, force) {
354560
354632
  if (!outPath)
@@ -471157,7 +471229,7 @@ var _0x735373, _0x22de9b, _0x21b76c = (_0x1cf641, _0x31dedc) => () => (_0x31dedc
471157
471229
  }, _0x34a1f2, _0x596340, _0x2a68f3, _0x2421c4, _0xc6717, _0x433235, _0xf89ef1, _0x44888f, _0x113281, _0x170df8, _0x3d98b8, _0x51e1d5, _0x5ba782, _0x45a913, _0x2faa41, _0x43dff3 = 25000, _0x2480fe, _0x26e3ef = 2147483647, _0x58b9b0 = 63, _0x2f1757, _0x3d57c9 = 1638, _0x5d8a50 = 255, _0x442367 = 2147483647, _0x368af4 = 63, _0x446a21, _0x571e86, _0x2e665a, _0x2e2b6e, _0x415071, _0x1680a2, _0x3ca4b4, _0x229118 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x6b4356 = "http://schemas.microsoft.com/office/word/2010/wordml", _0x24fa1d = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", _0x244a1a = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x3e6d89, _0x1fd6f6 = "http://schemas.microsoft.com/office/word/2010/wordml", _0x2d9f38 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x478923, _0x5e5811, _0x2dc946 = "Content control mutations outside the document body are not supported by this adapter.", _0x5a9d42, _0x145cf3, _0x14942b = 128, _0xd389b8 = 16, _0x257abe, _0x2c864a = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x209f3e = (_0x36f503) => ({ ..._0x36f503, author: { name: _0x36f503["author"]["name"] } }), _0x48c13f = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x5c2605, _0x30ca20, _0x4644d0, _0x580c66, _0x203944, _0x3e39c8, _0xd71de5, _0x4c7049, _0x417cb0, _0xd53b7d, _0x147e4a, _0x522702, _0xaf3f1e = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x118314 = "http://schemas.microsoft.com/office/word/2010/wordml", _0x144a22, _0x3d34aa, _0x50fb02, _0x437114, _0x4f42d8, _0x1d4096, _0x39a34f = "__sd:paragraph:", _0x4e5ec9 = "__sd:textbox-paragraph:", _0x9bc02d = "tc-comment:", _0x55fac2, _0x136ae1, _0x366955, _0x4f2333, _0x2615e5, _0x361530 = "http://schemas.openxmlformats.org/drawingml/2006/main", _0x5a680f = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x15e962 = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", _0x51c93f = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", _0x2e8846, _0xea0e4d, _0x36d779, _0x1adac5 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x1e97bb = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", _0x519ce6, _0x33d5e0 = 32, _0x109652 = 262144, _0x283872 = 16384, _0x28f35e = 4096, _0x36fa02, _0x1516e5, _0x3938c9 = 256, _0x556b75, _0x50b369, _0xcbde2 = 4096, _0x10bd29 = 256, _0x861fc, _0x1a1256, _0x4f0763, _0x2c42e5, _0x41ecee, _0x5429ac, _0x1aab00, _0x4405bd, _0x1bcb4a, _0x2c545d, _0x35df37, _0x13d0df, _0x3cc107, _0x4a7484, _0x5c44de, _0x1a34dc, _0x1162bb, _0x1f3dde, _0x237618 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x3bfdbd, _0x3e1c61, _0x93ebb = 9525, _0x383479 = 1000, _0x54ce9e, _0x5b0082, _0x447f2b, _0x28ceb5 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", _0x46a165 = 9525, _0x4d9795 = 1000, _0x1d986e = 251659264, _0x8642d3 = "{C183D7F6-B498-43B3-948B-1728B52AA6E4}", _0x556509 = "http://schemas.microsoft.com/office/drawing/2017/decorative", _0x55a4ea = "http://schemas.openxmlformats.org/drawingml/2006/main", _0x487d5e = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", _0x46ad00, _0x4ac93b, _0x359bcb = 12240, _0x8f3460 = 1440, _0xbafe87 = 15, _0x44f365, _0x51dc35, _0x166367, _0x39b32c, _0x47d9fd, _0x193959, _0x4ff7f1, _0x421abe, _0x46a19c, _0x2ca86b, _0x55902c, _0x384718 = 32, _0x2e9ea4, _0x40f40c, _0x1b3039, _0x4b5d3f, _0x3b733f, _0x3be773 = "body:/word/document.xml", _0x2b7b3e = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x263e91, _0x5d6d90, _0x5071a2, _0x5f25b5 = "/word/document.xml", _0x4e01a9, _0x40e44a, _0xde4563, _0x484e82 = "/word/settings.xml", _0x5b85ff = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x73d60d, _0x1f27ac, _0xf1594e, _0x5e8a07 = "/word/document.xml", _0x461296 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps", _0x4d6b39, _0x3ba364, _0x4bd8ca = "/[Content_Types].xml", _0x3c550b = "/", _0x25d5f4, _0x57d914 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x431029, _0x7925fe, _0x50b603 = "http://schemas.openxmlformats.org/package/2006/relationships", _0x556c62 = "http://schemas.openxmlformats.org/package/2006/content-types", _0xb317b5, _0x23c6d7 = "/relationships/header", _0x48f1be = "/relationships/footer", _0x519e85 = "/relationships/footnotes", _0x38fa01 = "/relationships/endnotes", _0x2fd262 = "/word/_rels/document.xml.rels", _0x46160a = "/[Content_Types].xml", _0x1e57dd = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x56bb92, _0x3476c8, _0x1728d9, _0xb898bb, _0x231d0b = 9525, _0x570ca1, _0x2db519, _0x223d3f, _0x5c84d7, _0x593003, _0x43f55c, _0x33ed1b = "/word/_rels/document.xml.rels", _0x54d98c = "/[Content_Types].xml", _0xe78f84 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', _0x5433e4 = "/relationships/header", _0x1d57cb = "/relationships/footer", _0x4c5767, _0x17c106, _0x4da0d2, _0x3ddaaf = "body:/word/document.xml", _0x424511 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x2a209f = "http://schemas.microsoft.com/office/word/2010/wordml", _0x50c923 = "http://schemas.openxmlformats.org/markup-compatibility/2006", _0x2cc10b, _0x1ae9dc, _0x2f96d2, _0xb5f3cf, _0x4e5b72 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x16d3fa = "http://schemas.microsoft.com/office/word/2010/wordml", _0xfbf879 = "body:/word/document.xml", _0x130d74, _0x32c229 = (_0x4541b3) => _0x4541b3[_0x735373(1280)]["attributes"]["find"]((_0x32317e) => _0x32317e["namespaceUri"] === _0x16d3fa && _0x32317e["localName"] === "paraId")?.["value"], _0x13cc8d, _0x38e19d, _0x22e41e = "/word/styles.xml", _0x32129b, _0x55427d, _0x451eea = "/word/settings.xml", _0x4d40ca = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x550449 = "http://purl.oclc.org/ooxml/wordprocessingml/main", _0x2a6da6, _0x2107e8, _0x5c4d9f, _0x5801f7 = "/word/document.xml", _0x28ff5e = "body:/word/document.xml", _0x3364ee = "snapshot", _0x4f16ab = "superdoc-v2", _0x46c438, _0x47e072, _0x577507 = "superdoc-v2-full-diff-snapshot", _0x36c551 = "sd-diff-v2/full-snapshot/v1", _0x3be918 = "superdoc-v2-full-diff-payload", _0xdab633 = "sd-diff-v2/full-payload/v1", _0x22ea8b, _0x3dcbcf = "/word/_rels/document.xml.rels", _0x30ada6 = "/word/document.xml", _0x5c1dba = "/[Content_Types].xml", _0x14fd33, _0x753d66, _0x4c4368, _0x51f92c = "http://schemas.openxmlformats.org/package/2006/relationships", _0x548f40 = "http://schemas.openxmlformats.org/package/2006/content-types", _0x330bbc = "http://schemas.openxmlformats.org/drawingml/2006/main", _0x14c2f0 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x1760f2 = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", _0x3da216 = "http://purl.org/dc/terms/", _0x1ba1ca = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties", _0xd81862, _0x3894ba, _0x11a3f0 = 64, _0x660a11 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x5d41b8 = "/docMetadata/LabelInfo.xml", _0x497c75 = "/_rels/.rels", _0x5fb794 = "/[Content_Types].xml", _0x188463 = "http://schemas.microsoft.com/office/2020/02/relationships/classificationlabels", _0xf8bcbe = "application/vnd.ms-office.classificationlabels+xml", _0x42b859, _0x5aa63b, _0xe1f895, _0x39fe60, _0x4e1726 = "/word/document.xml", _0x59951e = "/word/numbering.xml", _0x14edc9, _0x5e899a, _0x15ee25 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x4d24fa = "http://schemas.microsoft.com/office/word/2010/wordml", _0x41782f = "http://schemas.openxmlformats.org/officeDocument/2006/math", _0x303cc3 = "http://schemas.openxmlformats.org/markup-compatibility/2006", _0x57b1bd = "urn:schemas-microsoft-com:vml", _0x31851c, _0xa5924c, _0x398d38, _0x269a33, _0x4d413b, _0x483df4 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x1dbc50 = "/word/numbering.xml", _0x16db72 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x47f9b2, _0x21023a, _0x107350, _0x476bc5, _0x35d902, _0xb70a92, _0x253d62, _0x51d085, _0x15a215, _0x56a9bb = "/word/document.xml", _0x153ee1, _0x1c281e, _0x43f03f, _0x369bad, _0x510bbd, _0x2819f0, _0x119a3f = 100, _0x5cf623 = 100, _0x15c8f7 = 100, _0x29fb22 = 1000, _0x5168e0 = 500, _0x408db1, _0x5aad3c = "v2-textbox-geometry", _0x17d07d, _0x449f6a, _0x4d682b, _0x3e74b2, _0x3110a3 = 100, _0x38e4d5, _0x1cdff0, _0xe368de, _0xeb053c = "hl-field:", _0x3c3cc6 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", _0xe9dca7, _0xa93429, _0x301b1e, _0x3356d5 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", _0x3ac642 = "application/vnd.openxmlformats-package.relationships+xml", _0x47539e = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', _0x5dee53, _0x3d98cf = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", _0x2737c8 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", _0x1412d5 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", _0x2fee78 = "application/vnd.openxmlformats-package.relationships+xml", _0x3d6e48 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', _0x42b2f6, _0xe92153, _0x572d57, _0x9bf464 = "http://schemas.microsoft.com/office/word/2010/wordml", _0x3e7dcf = "/word/footnotes.xml", _0x4f05f7 = "/word/endnotes.xml", _0x43f242 = "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", _0x2a2df3 = "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", _0x38f37b = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", _0xd9ec45 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", _0x44a676, _0x1f9023, _0x155b75, _0x94c8bf, _0xcca424 = 63, _0x83d05f = 1638, _0x326253 = 255, _0x25025e, _0x566984, _0x24dcb3, _0x11c65e = 64, _0x24cf36 = 8000, _0x44630b = 256, _0x34e147, _0x4e3a13, _0x1d679c, _0x33d58e, _0x4dd139, _0x19592a, _0x106d54, _0x4d6d8b, _0x3305fc, _0x1266b0, _0x38f0ba = 9525, _0x511769 = 1024, _0xf5f604, _0xfceda6, _0x31c136, _0x57ce49 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x1d61e5 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", _0x2fb3de, _0x20532b, _0x385da3 = 1024, _0x47785c = 134217728, _0x34a1f5, _0x323e95, _0x182b00, _0x2902cd, _0xd556b9, _0x7c4e2 = "all", _0x44010f, _0x45739b, _0x35477f, _0x5d492e = "[Content_Types].xml", _0x12bb37 = "/[Content_Types].xml", _0x137169 = "/word/document.xml", _0x226f43 = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", _0x2c1a06 = "http://purl.oclc.org/ooxml/wordprocessingml/main", _0x21c566 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", _0x1c7421 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", _0x5ba8b0 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings", _0x300cc2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", _0x18588a, _0x2334d3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", _0x2380ab, _0x55da72 = "word/styles.xml", _0xb14927, _0x5bab54 = "word/numbering.xml", _0x1b840f = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", _0x58f5f5, _0x132af9, _0x1f53f0, _0x5de3c7 = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', _0x14f8b3, _0x4e6af4, _0xf1ce21, _0x423742, _0x50f5c9, _0x35d74b, _0x31f8d2, _0x2c2a76, _0x25453d;
471158
471230
  var init_document_runtime = __esm(() => {
471159
471231
  /*!
471160
- * DOCX Engine v0.18.0-next.5
471232
+ * DOCX Engine v0.18.0-next.6
471161
471233
  * Proprietary software. Copyright © 2026 Harbour Enterprises, Inc., d/b/a SuperDoc.
471162
471234
  * Use governed by the DOCX Engine Proprietary License Agreement.
471163
471235
  * No reverse engineering, deobfuscation, redistribution,
@@ -488964,7 +489036,7 @@ var _0x18d6be, _0x39ae2b, _0xaf93c4 = "host.request.timeoutMs", _0x39ef6a = 2147
488964
489036
  var init_document_host_BV5jPLq6 = __esm(() => {
488965
489037
  init_document_runtime();
488966
489038
  /*!
488967
- * DOCX Engine v0.18.0-next.5
489039
+ * DOCX Engine v0.18.0-next.6
488968
489040
  * Proprietary software. Copyright © 2026 Harbour Enterprises, Inc., d/b/a SuperDoc.
488969
489041
  * Use governed by the DOCX Engine Proprietary License Agreement.
488970
489042
  * No reverse engineering, deobfuscation, redistribution,
@@ -489202,7 +489274,7 @@ function _0x19ec() {
489202
489274
  var init_document_host = __esm(() => {
489203
489275
  init_document_host_BV5jPLq6();
489204
489276
  /*!
489205
- * DOCX Engine v0.18.0-next.5
489277
+ * DOCX Engine v0.18.0-next.6
489206
489278
  * Proprietary software. Copyright © 2026 Harbour Enterprises, Inc., d/b/a SuperDoc.
489207
489279
  * Use governed by the DOCX Engine Proprietary License Agreement.
489208
489280
  * No reverse engineering, deobfuscation, redistribution,
@@ -499786,7 +499858,7 @@ var init_host2 = __esm(() => {
499786
499858
  });
499787
499859
 
499788
499860
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
499789
- var SDK_VERSION = "2.16.0-next.6";
499861
+ var SDK_VERSION = "2.16.0-next.7";
499790
499862
 
499791
499863
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
499792
499864
  import { chmodSync, existsSync } from "node:fs";
@@ -565696,7 +565768,7 @@ var init_local_document_runtime_sessions = __esm(() => {
565696
565768
  });
565697
565769
 
565698
565770
  // src/host/session-pool.ts
565699
- import { createHash as createHash5 } from "node:crypto";
565771
+ import { createHash as createHash4 } from "node:crypto";
565700
565772
  import { readFile as readFile10 } from "node:fs/promises";
565701
565773
  function stableStringify2(value2) {
565702
565774
  if (value2 === null || typeof value2 !== "object")
@@ -565707,7 +565779,7 @@ function stableStringify2(value2) {
565707
565779
  return `{${entries2.join(",")}}`;
565708
565780
  }
565709
565781
  function profileToFingerprint(profile) {
565710
- return createHash5("sha256").update(stableStringify2(profile)).digest("hex");
565782
+ return createHash4("sha256").update(stableStringify2(profile)).digest("hex");
565711
565783
  }
565712
565784
  function createSessionLocks() {
565713
565785
  const locks = new Map;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/cli",
3
- "version": "0.39.0-next.6",
3
+ "version": "0.39.0-next.7",
4
4
  "description": "Command-line interface for SuperDoc: inspect, convert, and edit .docx files from a terminal or a script.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -29,15 +29,15 @@
29
29
  "fast-glob": "^3.3.3",
30
30
  "happy-dom": "^20.3.4",
31
31
  "ws": "^8.18.0",
32
- "superdoc": "2.19.0-next.5",
32
+ "superdoc": "2.19.0-next.6",
33
33
  "y-websocket": "^3.0.0",
34
34
  "yjs": "13.6.31"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@hocuspocus/server": "^2.13.6",
38
- "@superdoc/sdk": "2.16.0-next.6",
38
+ "@superdoc/sdk": "2.16.0-next.7",
39
39
  "@superdoc/document-api": "0.1.0-alpha.0",
40
- "@superdoc/docx-engine": "0.18.0-next.5",
40
+ "@superdoc/docx-engine": "0.18.0-next.6",
41
41
  "@types/bun": "^1.3.8",
42
42
  "@types/node": "22.19.2",
43
43
  "@types/ws": "^8.5.13",
@@ -51,11 +51,11 @@
51
51
  "access": "public"
52
52
  },
53
53
  "optionalDependencies": {
54
- "@superdoc/cli-darwin-arm64": "0.39.0-next.6",
55
- "@superdoc/cli-darwin-x64": "0.39.0-next.6",
56
- "@superdoc/cli-linux-x64": "0.39.0-next.6",
57
- "@superdoc/cli-linux-arm64": "0.39.0-next.6",
58
- "@superdoc/cli-windows-x64": "0.39.0-next.6"
54
+ "@superdoc/cli-darwin-arm64": "0.39.0-next.7",
55
+ "@superdoc/cli-darwin-x64": "0.39.0-next.7",
56
+ "@superdoc/cli-linux-x64": "0.39.0-next.7",
57
+ "@superdoc/cli-linux-arm64": "0.39.0-next.7",
58
+ "@superdoc/cli-windows-x64": "0.39.0-next.7"
59
59
  },
60
60
  "scripts": {
61
61
  "predev": "node scripts/ensure-superdoc-build.js --internal",