@superdoc/mcp 1.5.0-next.8 → 1.6.0-next.1

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 +373 -14
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31443,7 +31443,7 @@ var init_host = __esm(() => {
31443
31443
  });
31444
31444
 
31445
31445
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31446
- var SDK_VERSION = "2.18.0-next.8";
31446
+ var SDK_VERSION = "2.19.0-next.1";
31447
31447
 
31448
31448
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31449
31449
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -179119,10 +179119,15 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
179119
179119
  const ownerContentEffects = source.sourceKind === "textboxAtomReplacement" ? textboxOwnerContentEffects(state, prepared, result.storiesChanged ?? []) : [];
179120
179120
  if (!ownerContentEffects)
179121
179121
  return broad("multi-story");
179122
+ const checkboxRevisionOnlyEffects = source.sourceKind === "contentControlCheckbox" ? checkboxRevisionOnlyTextboxEffects(state, prepared, op, result.storiesChanged ?? []) : [];
179123
+ if (!checkboxRevisionOnlyEffects)
179124
+ return broad("multi-story");
179122
179125
  const ownerContentStoryIds = new Set(ownerContentEffects.map((effect) => effect.storyId));
179126
+ const checkboxRevisionOnlyStoryIds = new Set(checkboxRevisionOnlyEffects.map((effect) => effect.storyId));
179123
179127
  const storyEffects = exactStoryEffectsForPrimary(op.on.storyId, prepared.resolvedTargets.stories, result.storiesChanged ?? [], [
179124
- ...(result.auxiliaryStoryEffects ?? []).filter((effect) => !ownerContentStoryIds.has(effect.storyId)),
179125
- ...ownerContentEffects
179128
+ ...(result.auxiliaryStoryEffects ?? []).filter((effect) => !ownerContentStoryIds.has(effect.storyId) && !checkboxRevisionOnlyStoryIds.has(effect.storyId)),
179129
+ ...ownerContentEffects,
179130
+ ...checkboxRevisionOnlyEffects
179126
179131
  ]);
179127
179132
  if (!storyEffects)
179128
179133
  return broad("multi-story");
@@ -179164,7 +179169,7 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
179164
179169
  }
179165
179170
  const trackedDecisionRefDelta = source.sourceKind === "trackedChangeDecide" ? captureTrackedDecisionRefDelta(prepared, op.on.storyId) : null;
179166
179171
  const committedPatchGroup = result.forwardPatchGroup ?? prepared.localApplyBundle;
179167
- const localizedPatch = resolveLocalizedParagraphPatch(committedPatchGroup, prepared, source, {
179172
+ const localizedPatch = resolveLocalizedParagraphPatch(state, committedPatchGroup, prepared, source, {
179168
179173
  ...partDelta.previousRevision ? { originPartRevision: partDelta.previousRevision } : {},
179169
179174
  originStoryRevision: storyDelta.previousRevision
179170
179175
  });
@@ -179224,7 +179229,7 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
179224
179229
  }
179225
179230
  const exhaustedInsertionProved = proveExhaustedTrackedInsertionForRender(prepared, context.originParagraphXml, postParagraphXml);
179226
179231
  const trackedDecisionInvalidatedChangeIds = trackedDecisionRefDelta?.kind === "invalidated" ? trackedDecisionRefDelta.changeIds : trackedTextResolutionProved ? trackedTextResolution.changeIds : null;
179227
- const ownerByteDelta = postBytes.byteLength - (op.on.paragraphByteEnd - op.on.paragraphByteStart);
179232
+ const ownerByteDelta = localizedPatch.ownerByteDelta ?? postBytes.byteLength - (op.on.paragraphByteEnd - op.on.paragraphByteStart);
179228
179233
  const currentOwnerByteStart = ownerByteRange.byteStart;
179229
179234
  const currentOwnerByteEnd = ownerByteRange.byteEnd + ownerByteDelta;
179230
179235
  if (postBytes.byteLength > MAX_NARROW_SLICE_BYTES) {
@@ -179249,7 +179254,9 @@ function buildSDRenderCommitEnvelope(state, prepared, result, context = {}, opti
179249
179254
  changeMode: prepared.source.changeMode,
179250
179255
  coordinateSpace: prepared.source.on.coordinateSpace ?? "visible"
179251
179256
  } : null;
179252
- const sliceDependencyReason = source.annotation ? classifyAnnotationSliceDependency(context.originParagraphXml, postParagraphXml, source.annotation.commentId, source.annotation.operation) : source.sourceKind === "textboxAtomReplacement" ? classifyTextboxAtomSliceDependency(prepared, postParagraphXml, context.originParagraphXml, trackedAnnotations) : trackedDecisionRefDelta ? classifyTrackedDecisionSliceDependency(postParagraphXml, context.originParagraphXml, trackedDecisionRefDelta.kind) : classifyUnprovedSliceDependency(postParagraphXml, trackedAnnotations, context.originParagraphXml, {
179257
+ if (source.sourceKind === "contentControlCheckbox" && !checkboxStateChangeIsLocal(prepared, context.originOwnerXml, postCommitXml, context.originParagraphXml, postParagraphXml))
179258
+ return broad("global-dependency-change");
179259
+ const sliceDependencyReason = source.annotation ? classifyAnnotationSliceDependency(context.originParagraphXml, postParagraphXml, source.annotation.commentId, source.annotation.operation) : source.sourceKind === "contentControlCheckbox" ? null : source.sourceKind === "textboxAtomReplacement" ? classifyTextboxAtomSliceDependency(prepared, postParagraphXml, context.originParagraphXml, trackedAnnotations) : trackedDecisionRefDelta ? classifyTrackedDecisionSliceDependency(postParagraphXml, context.originParagraphXml, trackedDecisionRefDelta.kind) : classifyUnprovedSliceDependency(postParagraphXml, trackedAnnotations, context.originParagraphXml, {
179253
179260
  allowTrackedWrapperDelta: source.sourceKind === "trackedChangeDecide",
179254
179261
  trackedCarrierRefinementProved,
179255
179262
  trackedTextResolutionProved,
@@ -181053,6 +181060,27 @@ function textboxOwnerContentEffects(state, prepared, storyDeltas) {
181053
181060
  nextRevision: delta.nextRevision
181054
181061
  }];
181055
181062
  }
181063
+ function checkboxRevisionOnlyTextboxEffects(state, prepared, source, storyDeltas) {
181064
+ if (prepared.source.kind !== "storySurfaceRewrite" || prepared.source.operationId !== "content-control-checkbox-state" || !prepared.source.checkboxState)
181065
+ return null;
181066
+ const effects2 = [];
181067
+ for (const storyDelta of storyDeltas) {
181068
+ if (storyDelta.storyId === source.on.storyId)
181069
+ continue;
181070
+ const textbox = state.textboxRegistry.byStoryId.get(storyDelta.storyId);
181071
+ if (!textbox || textbox.ownerPartUri !== source.on.partUri)
181072
+ return null;
181073
+ effects2.push({
181074
+ storyId: storyDelta.storyId,
181075
+ kind: "revision-only",
181076
+ previousContentRange: [...textbox.contentRange],
181077
+ currentContentRange: [...textbox.contentRange],
181078
+ previousRevision: storyDelta.previousRevision,
181079
+ nextRevision: storyDelta.nextRevision
181080
+ });
181081
+ }
181082
+ return effects2;
181083
+ }
181056
181084
  function resolveAnnotationRenderSource(state, prepared, options) {
181057
181085
  const op = prepared.source;
181058
181086
  if (op.kind !== "insertComment" && op.kind !== "commentReply")
@@ -181217,6 +181245,10 @@ function resolveNarrowTextRenderSource(state, prepared, options) {
181217
181245
  const on = prepared.backendExtensions.storySurface?.exactParagraphRenderRange;
181218
181246
  return on ? { sourceKind: "storyFormatMutation", changeMode: "direct", on } : null;
181219
181247
  }
181248
+ if (prepared.source.kind === "storySurfaceRewrite" && prepared.source.checkboxState) {
181249
+ const on = prepared.backendExtensions.storySurface?.exactParagraphRenderRange;
181250
+ return on ? { sourceKind: "contentControlCheckbox", changeMode: "direct", on } : null;
181251
+ }
181220
181252
  if (prepared.source.kind !== "trackedChangeDecide")
181221
181253
  return null;
181222
181254
  const scope = resolveTrackedDecisionParagraphScope(prepared);
@@ -181278,10 +181310,30 @@ function resolveTrackedDecisionParagraphScopeFromGroup(prepared, patchGroup) {
181278
181310
  blockId: scope.blockIds[0]
181279
181311
  };
181280
181312
  }
181281
- function resolveLocalizedParagraphPatch(patchGroup, prepared, source, revisions) {
181313
+ function resolveLocalizedParagraphPatch(state, patchGroup, prepared, source, revisions) {
181282
181314
  const partEntry = patchGroup.perPart[source.on.partUri];
181283
181315
  if (!partEntry || partEntry.kind !== "modify")
181284
181316
  return null;
181317
+ if (source.sourceKind === "contentControlCheckbox") {
181318
+ if (partEntry.patches.length === 0)
181319
+ return null;
181320
+ let ownerByteDelta = 0;
181321
+ for (const patch2 of partEntry.patches) {
181322
+ const delta2 = patchByteDelta(patch2);
181323
+ if (delta2 == null)
181324
+ return null;
181325
+ ownerByteDelta += delta2;
181326
+ }
181327
+ const postEntry = state.paragraphIndexes.get(source.on.storyId)?.byParaId(source.on.startBlockId);
181328
+ if (!postEntry || postEntry.partUri !== source.on.partUri)
181329
+ return null;
181330
+ return {
181331
+ postStart: postEntry.byteStart,
181332
+ postEnd: postEntry.byteEnd,
181333
+ ownerByteDelta,
181334
+ ...revisions
181335
+ };
181336
+ }
181285
181337
  if (source.sourceKind === "textboxAtomReplacement" || source.annotation) {
181286
181338
  const window2 = { startByte: source.on.paragraphByteStart, endByte: source.on.paragraphByteEnd };
181287
181339
  let delta2 = 0;
@@ -181418,6 +181470,8 @@ function storySurfaceFamilyMatchesSource(family, sourceKind) {
181418
181470
  return family === "storyTrackedDecide";
181419
181471
  if (sourceKind === "formatRunRange" || sourceKind === "storyFormatMutation")
181420
181472
  return family === "storyFormat";
181473
+ if (sourceKind === "contentControlCheckbox")
181474
+ return family === "storyBlocks";
181421
181475
  return family === "storyText";
181422
181476
  }
181423
181477
  function hasOnlyTrackedChangeRefDelta(prepared) {
@@ -181852,6 +181906,62 @@ function classifyDeferrableSliceDependency(reason, xml, originXml, auxiliaryStor
181852
181906
  }
181853
181907
  return classes;
181854
181908
  }
181909
+ function checkboxStateChangeIsLocal(prepared, originOwnerXml, postOwnerXml, originParagraphXml, postParagraphXml) {
181910
+ const state = prepared.source.kind === "storySurfaceRewrite" ? prepared.source.checkboxState : undefined;
181911
+ if (!state || originOwnerXml == null || originParagraphXml == null)
181912
+ return false;
181913
+ if (!isolateCheckboxControl(originParagraphXml, state.controlId) || !isolateCheckboxControl(postParagraphXml, state.controlId))
181914
+ return false;
181915
+ const origin = isolateCheckboxControl(originOwnerXml, state.controlId);
181916
+ const post = isolateCheckboxControl(postOwnerXml, state.controlId);
181917
+ if (!origin || !post || origin.before !== post.before || origin.after !== post.after)
181918
+ return false;
181919
+ const before = normalizeCheckboxControlXml(origin.control);
181920
+ const after = normalizeCheckboxControlXml(post.control);
181921
+ if (!before || !after)
181922
+ return false;
181923
+ return before.checked !== state.checked && after.checked === state.checked && before.normalized === after.normalized;
181924
+ }
181925
+ function isolateCheckboxControl(ownerXml, controlId) {
181926
+ const parsed = collectXmlElementRanges(ownerXml);
181927
+ const matching = parsed.ranges.filter((range) => range.tag.localName === "sdt").filter((range) => parsed.ranges.some((candidate2) => candidate2.start > range.start && candidate2.end < range.end && candidate2.tag.localName === "id" && candidate2.tag.attributes.some((attribute) => attribute.localName === "val" && attribute.value === controlId))).sort((left, right) => left.end - left.start - (right.end - right.start));
181928
+ const control2 = matching[0];
181929
+ if (!control2)
181930
+ return null;
181931
+ return {
181932
+ before: ownerXml.slice(0, control2.start),
181933
+ control: ownerXml.slice(control2.start, control2.end),
181934
+ after: ownerXml.slice(control2.end)
181935
+ };
181936
+ }
181937
+ function normalizeCheckboxControlXml(controlXml) {
181938
+ const checked = [...controlXml.matchAll(/<w14:checked\b[^>]*\bw14:val="([01])"[^>]*\/>/g)];
181939
+ if (checked.length !== 1)
181940
+ return null;
181941
+ const content = /<w:sdtContent\b[^>]*>([\s\S]*?)<\/w:sdtContent>/.exec(controlXml);
181942
+ if (!content)
181943
+ return null;
181944
+ const text = [...content[1].matchAll(/<w:t\b[^>]*>([\s\S]*?)<\/w:t>/g)];
181945
+ if (text.length !== 1 || !text[0][1])
181946
+ return null;
181947
+ const checkedState = canonicalCheckboxSymbolStateTag(controlXml, "checkedState");
181948
+ const uncheckedState = canonicalCheckboxSymbolStateTag(controlXml, "uncheckedState");
181949
+ if (!checkedState || !uncheckedState)
181950
+ return null;
181951
+ const normalized = controlXml.replace(checked[0][0], "<w14:checked/>").replace(checkedState.raw, checkedState.normalized).replace(uncheckedState.raw, uncheckedState.normalized).replace(text[0][0], "<w:t>CHECKBOX_GLYPH</w:t>");
181952
+ return { checked: checked[0][1] === "1", normalized };
181953
+ }
181954
+ function canonicalCheckboxSymbolStateTag(controlXml, localName2) {
181955
+ const matches = [...controlXml.matchAll(new RegExp(`<w14:${localName2}\\b[^>]*\\/>`, "g"))];
181956
+ if (matches.length !== 1)
181957
+ return null;
181958
+ const raw = matches[0][0];
181959
+ const value = /\bw14:val="([^"]+)"/.exec(raw)?.[1];
181960
+ const font = /\bw14:font="([^"]+)"/.exec(raw)?.[1] ?? "";
181961
+ if (!value)
181962
+ return null;
181963
+ return { raw, normalized: `<w14:${localName2} w14:val="${value}" w14:font="${font}"/>` };
181964
+ }
181855
181965
  function classifyUnprovedSliceDependency(xml, trackedAnnotations, originXml, options = {}) {
181856
181966
  if (originXml == null)
181857
181967
  return "origin-slice-unavailable";
@@ -222948,6 +223058,7 @@ function runStorySurfaceRewriteCommit(input) {
222948
223058
  return rejected11(input.txId, "unsupported-context");
222949
223059
  }
222950
223060
  const headerFooterUpdate = prepareHeaderFooterUpdate(input.state, op, effectivePerPart);
223061
+ const exactParagraphRenderRange = contentControlRewrite ? resolveExactCheckboxParagraphRenderRange(input.state, op, contentControlRewrite) : null;
222951
223062
  const storySurface = {
222952
223063
  family,
222953
223064
  ...contentControlRewrite ? { contentControlRewrite } : {},
@@ -222960,6 +223071,7 @@ function runStorySurfaceRewriteCommit(input) {
222960
223071
  ...contentControlRewrite.leadingBlockIds
222961
223072
  ])] : [...new Set(op.targetBlockIds)],
222962
223073
  atomCarrierContract: SD_DEFAULT_ATOM_CARRIER_CONTRACT,
223074
+ ...exactParagraphRenderRange ? { exactParagraphRenderRange } : {},
222963
223075
  ...headerFooterSlotMaterialization ? { headerFooterSlotMaterialization } : {},
222964
223076
  ...headerFooterPartCreation ? { headerFooterPartCreation } : {},
222965
223077
  ...headerFooterUpdate ? { headerFooterUpdate } : {},
@@ -223388,11 +223500,46 @@ function bytesEqual9(left, right) {
223388
223500
  }
223389
223501
  return true;
223390
223502
  }
223503
+ function resolveExactCheckboxParagraphRenderRange(state, op, rewrite) {
223504
+ if (!op.checkboxState || op.changeMode === "tracked" || op.storyPartOwnership.length !== 1)
223505
+ return null;
223506
+ if (rewrite.removedBlockIds.length || rewrite.addedBlockIds.length || rewrite.trailingXmlChanged)
223507
+ return null;
223508
+ const touched = [...new Set([...rewrite.contentBlockIds, ...rewrite.leadingBlockIds])];
223509
+ const targetBlockId = op.targetBlockIds.length === 1 ? op.targetBlockIds[0] : touched.length === 1 ? touched[0] : null;
223510
+ if (!targetBlockId || !rewrite.contentBlockIds.includes(targetBlockId))
223511
+ return null;
223512
+ if (touched.some((blockId) => blockId !== targetBlockId))
223513
+ return null;
223514
+ const owner = op.storyPartOwnership[0];
223515
+ const index = getStoryParagraphIndexFromState(state, owner.storyId);
223516
+ if (!index || index.duplicateParaIds.has(targetBlockId))
223517
+ return null;
223518
+ const entry = index.byParaId(targetBlockId);
223519
+ if (!entry || entry.storyId !== owner.storyId || entry.partUri !== owner.partUri)
223520
+ return null;
223521
+ return {
223522
+ storyId: entry.storyId,
223523
+ storyRevision: entry.storyRevision,
223524
+ partUri: entry.partUri,
223525
+ partRevision: entry.partRevision,
223526
+ startByte: entry.byteStart,
223527
+ endByte: entry.byteEnd,
223528
+ paragraphByteStart: entry.byteStart,
223529
+ paragraphByteEnd: entry.byteEnd,
223530
+ startBlockId: entry.blockId,
223531
+ endBlockId: entry.blockId,
223532
+ startOffset: 0,
223533
+ endOffset: entry.textLength,
223534
+ sourceAddress: { blockId: entry.blockId, range: { start: 0, end: entry.textLength } }
223535
+ };
223536
+ }
223391
223537
  function rejected11(txId, reason) {
223392
223538
  return { txId, status: "rejected", rejectedReason: reason };
223393
223539
  }
223394
223540
  var DOCUMENT_PART_URI3 = "/word/document.xml", DOCUMENT_RELS_PART_URI5 = "/word/_rels/document.xml.rels", CONTENT_TYPES_PART_URI6 = "/[Content_Types].xml", HEADER_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", HEADER_CT = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", FOOTER_CT = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", TD58;
223395
223541
  var init_compile_story_surface_rewrite = __esm(() => {
223542
+ init_sd_document_state();
223396
223543
  init_source_backed_main_overlay();
223397
223544
  init_content_types();
223398
223545
  init_sha256_sync();
@@ -275843,6 +275990,13 @@ var init_source = __esm(() => {
275843
275990
  };
275844
275991
  }));
275845
275992
  V2_ONLY_ADAPTER_METHODS = Object.freeze([
275993
+ {
275994
+ method: "createDocumentApi(host.adapter).contentControls.deleteCheckboxSelection",
275995
+ stability: "internal",
275996
+ workerWired: true,
275997
+ relatedV1Operation: "contentControls.delete",
275998
+ rationale: "Atomic keyboard deletion of a mixed text and checkbox selection, preserving wrapper locks and undo."
275999
+ },
275846
276000
  {
275847
276001
  method: "createDocumentApi(host.adapter).fields.contextAtPosition",
275848
276002
  stability: "internal",
@@ -278151,6 +278305,7 @@ function commitKernelStorySurfacePatch(input) {
278151
278305
  operationId: input.txIdPrefix,
278152
278306
  family: storySurface.family,
278153
278307
  ...storySurface.contentControlRewrite ? { contentControlRewrite: true } : {},
278308
+ ...storySurface.checkboxState ? { checkboxState: storySurface.checkboxState } : {},
278154
278309
  storyLocal: prepared.storyLocal,
278155
278310
  ...storySurface.changeMode ? { changeMode: storySurface.changeMode } : {},
278156
278311
  storyIds: prepared.storyIds,
@@ -279143,6 +279298,7 @@ function commitWholePartUpdates(context, txIdPrefix, updates, options = {}) {
279143
279298
  txIdPrefix,
279144
279299
  perPart,
279145
279300
  storyIds: options.storyIds,
279301
+ signalLanesToRebuild: options.signalLanesToRebuild,
279146
279302
  semanticStyleDependencies,
279147
279303
  expectedRevision: normalizedRevision,
279148
279304
  ...storySurface ? { storySurface } : {},
@@ -286089,8 +286245,15 @@ var FONT_FAMILY_FALLBACKS, DEFAULT_GENERIC_FALLBACK = "sans-serif", INHERITED_FO
286089
286245
  let current = "";
286090
286246
  let inQuote = false;
286091
286247
  let quoteChar = null;
286248
+ let escaped = false;
286092
286249
  for (const char of str) {
286093
- if (!inQuote && (char === '"' || char === "'")) {
286250
+ if (escaped) {
286251
+ current += char;
286252
+ escaped = false;
286253
+ } else if (char === "\\") {
286254
+ current += char;
286255
+ escaped = true;
286256
+ } else if (!inQuote && (char === '"' || char === "'")) {
286094
286257
  inQuote = true;
286095
286258
  quoteChar = char;
286096
286259
  current += char;
@@ -286109,7 +286272,7 @@ var FONT_FAMILY_FALLBACKS, DEFAULT_GENERIC_FALLBACK = "sans-serif", INHERITED_FO
286109
286272
  if (current.trim())
286110
286273
  parts.push(current.trim());
286111
286274
  return parts;
286112
- };
286275
+ }, CSS_GENERIC_FAMILIES;
286113
286276
  var init_font_utils = __esm(() => {
286114
286277
  FONT_FAMILY_FALLBACKS = Object.freeze({
286115
286278
  swiss: "Arial, sans-serif",
@@ -286149,6 +286312,21 @@ var init_font_utils = __esm(() => {
286149
286312
  "dejavu sans mono",
286150
286313
  "source code pro"
286151
286314
  ]);
286315
+ CSS_GENERIC_FAMILIES = new Set([
286316
+ "serif",
286317
+ "sans-serif",
286318
+ "monospace",
286319
+ "cursive",
286320
+ "fantasy",
286321
+ "system-ui",
286322
+ "ui-serif",
286323
+ "ui-sans-serif",
286324
+ "ui-monospace",
286325
+ "ui-rounded",
286326
+ "emoji",
286327
+ "math",
286328
+ "fangsong"
286329
+ ]);
286152
286330
  });
286153
286331
 
286154
286332
  // ../../../v2/node_modules/.pnpm/@superdoc+style-engine@file+..+public+packages+layout-engine+style-engine/node_modules/@superdoc/style-engine/src/normalize/run-attrs.ts
@@ -336162,6 +336340,19 @@ var init_tracked_move = __esm(() => {
336162
336340
  });
336163
336341
 
336164
336342
  // ../../../v2/document-api-v2-adapter/dist/content-controls/adapter.js
336343
+ function resolveSingleParagraphTextRange(target) {
336344
+ if (target.kind !== "selection" || target.start.kind !== "text" || target.end.kind !== "text")
336345
+ return null;
336346
+ if (target.start.blockId !== target.end.blockId)
336347
+ return null;
336348
+ const story = target.story ?? target.start.story ?? target.end.story;
336349
+ return {
336350
+ blockId: target.start.blockId,
336351
+ start: Math.min(target.start.offset, target.end.offset),
336352
+ end: Math.max(target.start.offset, target.end.offset),
336353
+ ...story ? { story } : {}
336354
+ };
336355
+ }
336165
336356
  function bytesProveNoContentControlCarrier(bytes) {
336166
336357
  if (bytes.includes(0))
336167
336358
  return false;
@@ -336703,6 +336894,145 @@ class V2ContentControlsAdapter {
336703
336894
  delete(input, options) {
336704
336895
  return this.mutateControl(input.target, input, options, () => "", "content-control-delete", guardSdtWrapperUnlocked);
336705
336896
  }
336897
+ deleteCheckboxSelection(input, options) {
336898
+ if ((options?.changeMode ?? "direct") !== "direct") {
336899
+ return {
336900
+ success: false,
336901
+ failure: {
336902
+ code: "CAPABILITY_UNAVAILABLE",
336903
+ message: "Deleting a selection that crosses a checkbox content control is not supported in tracked mode."
336904
+ }
336905
+ };
336906
+ }
336907
+ const range = resolveSingleParagraphTextRange(input.target);
336908
+ if (!range) {
336909
+ return {
336910
+ success: false,
336911
+ failure: {
336912
+ code: "INVALID_CONTEXT",
336913
+ message: "Checkbox selection deletion requires a same-paragraph text range."
336914
+ }
336915
+ };
336916
+ }
336917
+ if (range.story?.storyType && range.story.storyType !== "body") {
336918
+ return {
336919
+ success: false,
336920
+ failure: { code: "CAPABILITY_UNAVAILABLE", message: SECONDARY_STORY_MUTATION_MESSAGE }
336921
+ };
336922
+ }
336923
+ const loaded = this.load();
336924
+ const requestedIds = [...new Set(input.controlIds)];
336925
+ if (requestedIds.length === 0) {
336926
+ return {
336927
+ success: false,
336928
+ failure: { code: "INVALID_INPUT", message: "Checkbox selection deletion requires at least one control." }
336929
+ };
336930
+ }
336931
+ const byId = new Map(loaded.controls.map((control2) => [control2.id, control2]));
336932
+ const controls = [];
336933
+ for (const id of requestedIds) {
336934
+ const control2 = byId.get(id);
336935
+ const controlRange = control2?.info.selectionTarget ? resolveSingleParagraphTextRange(control2.info.selectionTarget) : null;
336936
+ if (!control2 || !controlRange || control2.info.controlType !== "checkbox" || controlRange.blockId !== range.blockId || controlRange.start < range.start || controlRange.end > range.end) {
336937
+ return {
336938
+ success: false,
336939
+ failure: { code: "INVALID_CONTEXT", message: "The selected range no longer fully contains this checkbox." }
336940
+ };
336941
+ }
336942
+ try {
336943
+ guardSdtWrapperUnlocked(control2);
336944
+ } catch (error48) {
336945
+ return {
336946
+ success: false,
336947
+ failure: {
336948
+ code: "LOCK_VIOLATION",
336949
+ message: error48 instanceof Error ? error48.message : String(error48)
336950
+ }
336951
+ };
336952
+ }
336953
+ controls.push({ control: control2, start: controlRange.start, end: controlRange.end });
336954
+ }
336955
+ const selectedWidth = controls.reduce((width, control2) => width + (control2.end - control2.start), 0);
336956
+ if (selectedWidth <= 0 || range.end - selectedWidth < range.start) {
336957
+ return {
336958
+ success: false,
336959
+ failure: { code: "INVALID_CONTEXT", message: "The checkbox selection has an invalid text extent." }
336960
+ };
336961
+ }
336962
+ const validation = this.context.validateMutation({
336963
+ expectedRevision: expectedRevisionFrom(input, options) === undefined ? undefined : String(expectedRevisionFrom(input, options))
336964
+ });
336965
+ if (validation)
336966
+ return { success: false, failure: validation };
336967
+ let capturedTxIds = [];
336968
+ try {
336969
+ this.context.captureCommittedHistory((txIds) => {
336970
+ capturedTxIds = txIds;
336971
+ for (const { control: control2 } of [...controls].sort((left, right) => right.start - left.start)) {
336972
+ const deleted = this.delete({ target: control2.target }, { changeMode: "direct" });
336973
+ if (!deleted.success) {
336974
+ throw new CheckboxSelectionDeleteError(deleted.failure);
336975
+ }
336976
+ }
336977
+ const remainingEnd = range.end - selectedWidth;
336978
+ if (remainingEnd > range.start) {
336979
+ const textDeleted = new V2SelectionMutationAdapter(this.context).execute({
336980
+ kind: "replace",
336981
+ target: {
336982
+ kind: "selection",
336983
+ story: input.target.story,
336984
+ start: {
336985
+ kind: "text",
336986
+ story: input.target.story,
336987
+ blockId: range.blockId,
336988
+ offset: range.start
336989
+ },
336990
+ end: {
336991
+ kind: "text",
336992
+ story: input.target.story,
336993
+ blockId: range.blockId,
336994
+ offset: remainingEnd
336995
+ }
336996
+ },
336997
+ text: ""
336998
+ }, { changeMode: "direct" });
336999
+ if (!textDeleted.success) {
337000
+ throw new CheckboxSelectionDeleteError(textDeleted.failure);
337001
+ }
337002
+ }
337003
+ });
337004
+ } catch (error48) {
337005
+ rollbackCapturedHistory(this.context, capturedTxIds);
337006
+ if (error48 instanceof CheckboxSelectionDeleteError) {
337007
+ return { success: false, failure: error48.failure };
337008
+ }
337009
+ return {
337010
+ success: false,
337011
+ failure: {
337012
+ code: "INTERNAL_ERROR",
337013
+ message: error48 instanceof Error ? error48.message : String(error48)
337014
+ }
337015
+ };
337016
+ }
337017
+ const published = publishCapturedHistory(this.context, capturedTxIds, "content-control-checkbox-selection-delete");
337018
+ if (!published) {
337019
+ return {
337020
+ success: false,
337021
+ failure: { code: "INTERNAL_ERROR", message: "Checkbox selection deletion committed no history entry." }
337022
+ };
337023
+ }
337024
+ const result = {
337025
+ success: true,
337026
+ txId: published.txId,
337027
+ affectedStories: projectAffectedStories(published.storiesChanged ?? [], this.context.session, published.partsChanged, input.target.story ?? { kind: "story", storyType: "body" }),
337028
+ ...published.invalidatedRefs?.length ? { invalidatedRefs: projectAffectedRefs2(published.invalidatedRefs) } : {},
337029
+ ...published.textRangeShifts?.length ? { textRangeShifts: projectTextRangeShifts(published.textRangeShifts, this.context.session, input.target.story) } : {}
337030
+ };
337031
+ const renderCommit = getSDRenderCommitEnvelope(published);
337032
+ if (renderCommit)
337033
+ attachSDRenderCommitEnvelope(result, renderCommit);
337034
+ return result;
337035
+ }
336706
337036
  copy(input, options) {
336707
337037
  this.validateTrackedControlMutation(input, options);
336708
337038
  const loaded = this.load();
@@ -337388,7 +337718,7 @@ class V2ContentControlsAdapter {
337388
337718
  this.validateTrackedControlMutation(input, options);
337389
337719
  throw operationError("CAPABILITY_UNAVAILABLE", "This content-control change has no supported Word-compatible tracked representation.");
337390
337720
  }
337391
- mutateControl(target, input, options, transform2, prefix = "content-control-mutate", validate) {
337721
+ mutateControl(target, input, options, transform2, prefix = "content-control-mutate", validate, commitOverrides) {
337392
337722
  const loaded = this.load();
337393
337723
  const tracked = options?.changeMode === "tracked";
337394
337724
  const storyAware = prefix === "content-control-pr" || prefix === "content-control-unwrap" || prefix === "content-control-delete";
@@ -337428,10 +337758,13 @@ class V2ContentControlsAdapter {
337428
337758
  createdRefs = prepared.wordIds.map((entityId) => ({ kind: "trackedChange", entityId, storyId: control2.storyId }));
337429
337759
  }
337430
337760
  const nextXml = replaceRange3(part.xml, control2.start, control2.end, replacement);
337761
+ const explicitStorySurface = commitOverrides?.storySurface;
337762
+ const storySurface = explicitStorySurface?.checkboxState ? { ...explicitStorySurface, targetBlockIds: contentControlTextBlockIds(control2.info) } : explicitStorySurface;
337431
337763
  return this.commitDocument(nextXml, prefix, input, options, control2.target, {
337764
+ ...commitOverrides,
337432
337765
  partUri: part.partUri,
337433
- storySurface: { family: "storyBlocks", contentControlRewrite: true, targetBlockIds: [] },
337434
- preserveRenderCommit: this.context.isCollaborativeSession(),
337766
+ storySurface: storySurface ?? { family: "storyBlocks", contentControlRewrite: true, targetBlockIds: [] },
337767
+ preserveRenderCommit: commitOverrides?.preserveRenderCommit ?? this.context.isCollaborativeSession(),
337435
337768
  createdRefs
337436
337769
  });
337437
337770
  }
@@ -337551,13 +337884,22 @@ class V2ContentControlsAdapter {
337551
337884
  return this.mutateControl(target, input, options, (control2) => {
337552
337885
  const pr = upsertCheckbox(control2.prXml, { checked });
337553
337886
  const symbol2 = checked ? control2.info.properties.checkedSymbol ?? DEFAULT_CHECKED : control2.info.properties.uncheckedSymbol ?? DEFAULT_UNCHECKED;
337554
- const nextContent = buildContentXml(symbolToText(symbol2.char), control2.info.kind, createParaIdAllocator(this.context));
337887
+ const nextGlyph = symbolToText(symbol2.char);
337888
+ const nextContent = replaceCheckboxGlyphContent(control2, nextGlyph) ?? buildContentXml(nextGlyph, control2.info.kind, createParaIdAllocator(this.context));
337555
337889
  return replaceSdtPrXml(replaceSdtContentXml(control2, nextContent), pr);
337556
337890
  }, "content-control-checkbox-state", (control2) => {
337557
337891
  if (control2.info.controlType !== "checkbox") {
337558
337892
  throw operationError("INVALID_TARGET", "contentControls.checkbox.setState requires control type checkbox.");
337559
337893
  }
337560
337894
  guardContentUnlocked(control2);
337895
+ }, {
337896
+ storySurface: {
337897
+ family: "storyBlocks",
337898
+ contentControlRewrite: true,
337899
+ checkboxState: { controlId: target.nodeId, checked }
337900
+ },
337901
+ preserveRenderCommit: true,
337902
+ signalLanesToRebuild: ["paragraphIndex", "noteAnchorRefs"]
337561
337903
  });
337562
337904
  }
337563
337905
  requireProtectedControl(control2, loaded) {
@@ -337738,6 +338080,7 @@ class V2ContentControlsAdapter {
337738
338080
  extraPerPart: commitOptions.extraPerPart,
337739
338081
  semanticStyleDependencies: commitOptions.semanticStyleDependencies,
337740
338082
  storySurface: commitOptions.storySurface,
338083
+ signalLanesToRebuild: commitOptions.signalLanesToRebuild,
337741
338084
  storyIds: commitOptions.storySurface?.contentControlRewrite ? this.load().parts.filter((part) => part.partUri === partUri).map((part) => part.storyId) : undefined,
337742
338085
  createdRefs: commitOptions.createdRefs
337743
338086
  });
@@ -338899,6 +339242,13 @@ function replaceSdtContentXml(control2, contentXml) {
338899
339242
  return control2.xml;
338900
339243
  return `${control2.xml.slice(0, contentRange.openEnd)}${contentXml}${control2.xml.slice(contentRange.closeStart)}`;
338901
339244
  }
339245
+ function replaceCheckboxGlyphContent(control2, glyph) {
339246
+ const textNodes = collectXmlElementRanges(control2.contentXml).ranges.filter((range) => range.tag.localName === "t" && !range.tag.isSelfClosing);
339247
+ if (textNodes.length !== 1)
339248
+ return null;
339249
+ const text4 = textNodes[0];
339250
+ return `${control2.contentXml.slice(0, text4.openEnd)}${xmlEscapeText(glyph)}${control2.contentXml.slice(text4.closeStart)}`;
339251
+ }
338902
339252
  function unwrapSdtXml(sdtXml) {
338903
339253
  const contentRange = findDirectSdtChildRange(sdtXml, "sdtContent");
338904
339254
  return contentRange ? sdtXml.slice(contentRange.openEnd, contentRange.closeStart) : "";
@@ -339798,7 +340148,7 @@ function replaceTextRangeInParagraph2(paragraphXml, start, end, replacement) {
339798
340148
  }
339799
340149
  return paragraphXml;
339800
340150
  }
339801
- var DEFAULT_CHECKED, DEFAULT_UNCHECKED, SECONDARY_STORY_MUTATION_MESSAGE = "Content control mutations outside the document body are not supported by this adapter.", UNMODELED_TYPE_TAGS, TYPE_TAGS, COOPERATIVE_PARSE_SLICE_PARAGRAPHS = 128, COOPERATIVE_PARSE_SLICE_CONTROLS = 16, RAW_ATTRIBUTE_PATTERN, COPIED_PROPERTY_REVISIONS;
340151
+ var CheckboxSelectionDeleteError, DEFAULT_CHECKED, DEFAULT_UNCHECKED, SECONDARY_STORY_MUTATION_MESSAGE = "Content control mutations outside the document body are not supported by this adapter.", UNMODELED_TYPE_TAGS, TYPE_TAGS, COOPERATIVE_PARSE_SLICE_PARAGRAPHS = 128, COOPERATIVE_PARSE_SLICE_CONTROLS = 16, RAW_ATTRIBUTE_PATTERN, COPIED_PROPERTY_REVISIONS;
339802
340152
  var init_adapter10 = __esm(() => {
339803
340153
  init_sd_document_session_internal();
339804
340154
  init_src6();
@@ -339814,6 +340164,9 @@ var init_adapter10 = __esm(() => {
339814
340164
  init_tracked_structural_wrapper();
339815
340165
  init_mutation_guard();
339816
340166
  init_adapter9();
340167
+ init_composite();
340168
+ init_stories();
340169
+ init_text_range_shifts();
339817
340170
  init_rich_fragment_apply();
339818
340171
  init_receipt_entities();
339819
340172
  init_xml_rewrite();
@@ -339823,6 +340176,12 @@ var init_adapter10 = __esm(() => {
339823
340176
  init_tracked_content();
339824
340177
  init_native_ownership_visibility();
339825
340178
  init_tracked_move();
340179
+ CheckboxSelectionDeleteError = class CheckboxSelectionDeleteError extends Error {
340180
+ constructor(failure5) {
340181
+ super(failure5.message);
340182
+ this.failure = failure5;
340183
+ }
340184
+ };
339826
340185
  DEFAULT_CHECKED = { font: "MS Gothic", char: "2612" };
339827
340186
  DEFAULT_UNCHECKED = { font: "MS Gothic", char: "2610" };
339828
340187
  UNMODELED_TYPE_TAGS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.5.0-next.8",
3
+ "version": "1.6.0-next.1",
4
4
  "description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -24,13 +24,13 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.26.0",
27
- "@superdoc/sdk": "2.18.0-next.8",
27
+ "@superdoc/sdk": "2.19.0-next.1",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.21.0-next.6",
33
- "@superdoc/docx-engine": "0.20.0-next.6",
32
+ "superdoc": "2.22.0-next.1",
33
+ "@superdoc/docx-engine": "0.21.0-next.1",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",