@superdoc/mcp 1.3.1-next.5 → 1.3.1-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 +38 -20
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31318,7 +31318,7 @@ var init_host = __esm(() => {
31318
31318
  });
31319
31319
 
31320
31320
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31321
- var SDK_VERSION = "2.16.1-next.5";
31321
+ var SDK_VERSION = "2.16.1-next.7";
31322
31322
 
31323
31323
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31324
31324
  import { chmodSync, existsSync } from "node:fs";
@@ -134881,6 +134881,10 @@ function parseDirectRunSequence(xml, allowRevisions) {
134881
134881
  stack.push("control");
134882
134882
  return;
134883
134883
  }
134884
+ if (tag.uri === W_NS && tag.local === "lastRenderedPageBreak") {
134885
+ stack.push("control");
134886
+ return;
134887
+ }
134884
134888
  valid = false;
134885
134889
  stack.push("property");
134886
134890
  return;
@@ -135459,7 +135463,7 @@ function validateRunContents(xml, options) {
135459
135463
  if (withoutBookmarks === null || UNSUPPORTED_XML.test(withoutBookmarks) || RELATIONSHIP_REFERENCE.test(withoutBookmarks)) {
135460
135464
  return { ok: false, reason: "target runs require unsupported structural or relationship replay" };
135461
135465
  }
135462
- const namespaceResult = validateReplayNamespaces(withoutBookmarks.replace(PROOFING_BOUNDARY_TAG_RE, ""), "target runs use namespace prefixes that cannot be replayed safely");
135466
+ const namespaceResult = validateReplayNamespaces(withoutBookmarks.replace(TRANSPARENT_MARKER_TAG_RE, ""), "target runs use namespace prefixes that cannot be replayed safely");
135463
135467
  if (!namespaceResult.ok)
135464
135468
  return namespaceResult;
135465
135469
  if (!parseDirectRunSequence(withoutBookmarks, false)) {
@@ -135515,7 +135519,7 @@ function validateCompareReplayPayload(payload, options = {}) {
135515
135519
  if (payload.targetRevisionReplay.policy !== "preserve-target-revision-set" || payload.targetRunXml === undefined) {
135516
135520
  return { ok: false, reason: "target revision replay policy is incomplete" };
135517
135521
  }
135518
- const namespaceResult = validateReplayNamespaces(payload.targetRunXml.replace(PROOFING_BOUNDARY_TAG_RE, ""), "target revision runs use namespace prefixes that cannot be replayed safely");
135522
+ const namespaceResult = validateReplayNamespaces(payload.targetRunXml.replace(TRANSPARENT_MARKER_TAG_RE, ""), "target revision runs use namespace prefixes that cannot be replayed safely");
135519
135523
  if (!namespaceResult.ok)
135520
135524
  return namespaceResult;
135521
135525
  const inspected = inspectDirectParagraphRevisionRuns(payload.targetRunXml);
@@ -135535,14 +135539,14 @@ function validateCompareReplayPayload(payload, options = {}) {
135535
135539
  }
135536
135540
  return { ok: true };
135537
135541
  }
135538
- var import_saxes3, UNSUPPORTED_XML, RELATIONSHIP_REFERENCE, W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", PROOFING_BOUNDARY_TYPES, PROOFING_BOUNDARY_TAG_RE, DIRECT_RUN_PROPERTY_ELEMENTS;
135542
+ var import_saxes3, UNSUPPORTED_XML, RELATIONSHIP_REFERENCE, W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", PROOFING_BOUNDARY_TYPES, TRANSPARENT_MARKER_TAG_RE, DIRECT_RUN_PROPERTY_ELEMENTS;
135539
135543
  var init_replayability = __esm(() => {
135540
135544
  init_note_xml_validation();
135541
135545
  import_saxes3 = __toESM(require_saxes(), 1);
135542
135546
  UNSUPPORTED_XML = /<(?:[\w.-]+:)?(?:hyperlink|drawing|pict|object|fldSimple|fldChar|instrText|commentReference|commentRangeStart|commentRangeEnd|permStart|permEnd|sdt|customXml|oMath|oMathPara|footnoteReference|endnoteReference|ins|del|moveFrom|moveTo|pPrChange|rPrChange|sectPr)\b/i;
135543
135547
  RELATIONSHIP_REFERENCE = /\s(?:r:id|r:embed|r:link)\s*=/i;
135544
135548
  PROOFING_BOUNDARY_TYPES = new Set(["spellStart", "spellEnd", "gramStart", "gramEnd"]);
135545
- PROOFING_BOUNDARY_TAG_RE = /<(?:[A-Za-z_][\w.-]*:)?proofErr\b(?:[^>"']|"[^"]*"|'[^']*')*\/>/g;
135549
+ TRANSPARENT_MARKER_TAG_RE = /<(?:[A-Za-z_][\w.-]*:)?proofErr\b(?:[^>"']|"[^"]*"|'[^']*')*\/>|<((?:[A-Za-z_][\w.-]*:)?lastRenderedPageBreak)\b(?:[^>"']|"[^"]*"|'[^']*')*(?:\/>|>\s*<\/\1>)/g;
135546
135550
  DIRECT_RUN_PROPERTY_ELEMENTS = new Set([
135547
135551
  "rStyle",
135548
135552
  "rFonts",
@@ -135767,6 +135771,10 @@ function normalizeRunXmlForSignature(runXml) {
135767
135771
  const props = EMPTY_RUN_PROPERTIES_RE.test(rawProps) ? "" : rawProps;
135768
135772
  const propsIndex = propsMatch?.index ?? 0;
135769
135773
  const content = propsMatch ? runBody.slice(0, propsIndex) + runBody.slice(propsIndex + rawProps.length) : runBody;
135774
+ if (content.trim().length > 0 && content.replace(CACHED_PAGE_MARKER_RE, "").trim().length === 0) {
135775
+ lastIndex = index + fullMatch.length;
135776
+ continue;
135777
+ }
135770
135778
  if (stripTextAndControls(content, namespaceContext).trim().length > 0) {
135771
135779
  pieces.push(fullMatch);
135772
135780
  activeTextProperties = "";
@@ -135810,9 +135818,9 @@ function findRunProperties(runBody, namespaceContext) {
135810
135818
  return null;
135811
135819
  }
135812
135820
  function stripTextAndControls(content, namespaceContext) {
135813
- return content.replace(TEXTISH_RE, (markup, textName, textAttributes, controlName, controlAttributes) => {
135814
- const name = textName ?? controlName;
135815
- const attributes = textAttributes ?? controlAttributes;
135821
+ return content.replace(TEXTISH_RE, (markup, textName, textAttributes, controlName, controlAttributes, markerName, markerAttributes) => {
135822
+ const name = textName ?? controlName ?? markerName;
135823
+ const attributes = textAttributes ?? controlAttributes ?? markerAttributes;
135816
135824
  return isWordprocessingElement3(name, attributes, namespaceContext) ? "" : markup;
135817
135825
  });
135818
135826
  }
@@ -135824,7 +135832,7 @@ function isWordprocessingElement3(name, attributes, namespaceContext) {
135824
135832
  return true;
135825
135833
  return (declaration[2] ?? declaration[3] ?? "") === WORDPROCESSINGML_NAMESPACE2;
135826
135834
  }
135827
- var REVISION_ATTR_RE, REVISION_ELEMENT_RE, REVISION_ID_ATTR_RE, COMMENT_MARKUP_RE, PROOFING_BOUNDARY_MARKUP_RE, NOTE_REFERENCE_MARKUP_RE, RUN_RE, RUN_PROPERTIES_RE, EMPTY_RUN_PROPERTIES_RE, TEXTISH_RE, RUN_CONTROL_RE, ATTRIBUTE_RE, WORDPROCESSINGML_NAMESPACE2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NAMESPACE2 = "http://schemas.microsoft.com/office/word/2010/wordml", MARKUP_COMPATIBILITY_NAMESPACE2 = "http://schemas.openxmlformats.org/markup-compatibility/2006", XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace", XML_TAG_RE, BOOKMARK_OPENING_RE, BOOKMARK_TAG_RE;
135835
+ var REVISION_ATTR_RE, REVISION_ELEMENT_RE, REVISION_ID_ATTR_RE, COMMENT_MARKUP_RE, PROOFING_BOUNDARY_MARKUP_RE, NOTE_REFERENCE_MARKUP_RE, RUN_RE, RUN_PROPERTIES_RE, EMPTY_RUN_PROPERTIES_RE, TEXTISH_RE, CACHED_PAGE_MARKER_RE, RUN_CONTROL_RE, ATTRIBUTE_RE, WORDPROCESSINGML_NAMESPACE2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NAMESPACE2 = "http://schemas.microsoft.com/office/word/2010/wordml", MARKUP_COMPATIBILITY_NAMESPACE2 = "http://schemas.openxmlformats.org/markup-compatibility/2006", XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace", XML_TAG_RE, BOOKMARK_OPENING_RE, BOOKMARK_TAG_RE;
135828
135836
  var init_run_signature = __esm(() => {
135829
135837
  REVISION_ATTR_RE = /\s+(?:w:rsid\w*|w14:paraId|w14:textId)="[^"]*"/g;
135830
135838
  REVISION_ELEMENT_RE = /<w:(?:ins|del|moveFrom|moveTo)\b[^>]*>/g;
@@ -135835,7 +135843,8 @@ var init_run_signature = __esm(() => {
135835
135843
  RUN_RE = /<((?:[\w.-]+:)?r)\b([^>]*)>([\s\S]*?)<\/\1>/g;
135836
135844
  RUN_PROPERTIES_RE = /<((?:[\w.-]+:)?rPr)\b([^>]*)(?:\/>|>[\s\S]*?<\/\1>)/g;
135837
135845
  EMPTY_RUN_PROPERTIES_RE = /^(?:<(?:[\w.-]+:)?rPr\s*\/>|<(?:[\w.-]+:)?rPr\s*>\s*<\/(?:[\w.-]+:)?rPr\s*>)$/;
135838
- TEXTISH_RE = /<((?:[\w.-]+:)?t)\b([^>]*)>[\s\S]*?<\/\1>|<((?:[\w.-]+:)?(?:tab|br|cr))\b([^>]*)\/>/g;
135846
+ TEXTISH_RE = /<((?:[\w.-]+:)?t)\b([^>]*)>[\s\S]*?<\/\1>|<((?:[\w.-]+:)?(?:tab|br|cr))\b([^>]*)\/>|<((?:[\w.-]+:)?lastRenderedPageBreak)\b([^>]*)(?:\/>|>\s*<\/\5>)/g;
135847
+ CACHED_PAGE_MARKER_RE = /<w:lastRenderedPageBreak\b[^>]*(?:\/>|>\s*<\/w:lastRenderedPageBreak>)/g;
135839
135848
  RUN_CONTROL_RE = /<((?:[\w.-]+:)?(tab|br|cr))\b([^>]*)\/>/g;
135840
135849
  ATTRIBUTE_RE = /([\w.:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
135841
135850
  XML_TAG_RE = /<(\/?)(([A-Za-z_][\w.-]*)(?::([A-Za-z_][\w.-]*))?)((?:(?:"[^"]*"|'[^']*'|[^>"'])*))>/g;
@@ -199139,7 +199148,7 @@ function hasProvableSelectedCommentRange(paragraphXml, rangeStart, rangeEnd) {
199139
199148
  markerKindsById.set(marker.id, markerKinds);
199140
199149
  }
199141
199150
  for (const marker of markers) {
199142
- const selected = marker.markerKind === "commentRangeStart" ? rangeStart <= marker.visibleStart && marker.visibleStart < rangeEnd : rangeStart < marker.visibleStart && marker.visibleStart <= rangeEnd;
199151
+ const selected = marker.markerKind === "commentRangeStart" ? rangeStart <= marker.visibleStart && marker.visibleStart < rangeEnd : selectionStraddlesMarker2(rangeStart, rangeEnd, marker.visibleStart);
199143
199152
  if (!selected)
199144
199153
  continue;
199145
199154
  if (marker.id === null)
@@ -204319,7 +204328,7 @@ function hasSessionSyncStructuralInlineDeletion(xml, fragments, namespaceBinding
204319
204328
  onOpenTag({ tag, start, end }) {
204320
204329
  if (matched || !isInsideSelectedDeletion(start, end))
204321
204330
  return;
204322
- matched = tag.namespaceUri === NS_W ? tag.localName === "smartTag" || tag.localName === "dir" || tag.localName === "bdo" : tag.namespaceUri === OFFICE_MATH_NAMESPACE && tag.localName === "oMath";
204331
+ matched = tag.namespaceUri === NS_W ? tag.localName === "smartTag" || tag.localName === "dir" || tag.localName === "bdo" || tag.localName === "lastRenderedPageBreak" : tag.namespaceUri === OFFICE_MATH_NAMESPACE && tag.localName === "oMath";
204323
204332
  }
204324
204333
  });
204325
204334
  return matched;
@@ -223117,17 +223126,17 @@ function canonicalizeCompareBodyRunXml(xml, referenceSteps) {
223117
223126
  let result = "";
223118
223127
  let cursor = 0;
223119
223128
  for (const token of tokens) {
223120
- const canonicalGap = canonicalizeProofingRunGap(xml.slice(cursor, token.start));
223129
+ const canonicalGap = canonicalizeTransparentMarkerRunGap(xml.slice(cursor, token.start));
223121
223130
  if (canonicalGap === null)
223122
223131
  return null;
223123
223132
  result += canonicalGap + token.xml;
223124
223133
  cursor = token.end;
223125
223134
  }
223126
- const canonicalTail = canonicalizeProofingRunGap(xml.slice(cursor));
223135
+ const canonicalTail = canonicalizeTransparentMarkerRunGap(xml.slice(cursor));
223127
223136
  return canonicalTail === null ? null : result + canonicalTail;
223128
223137
  }
223129
- function canonicalizeProofingRunGap(xml) {
223130
- const markerRe = /<(?:[A-Za-z_][\w.-]*:)?proofErr\b(?:[^>"']|"[^"]*"|'[^']*')*\/>/g;
223138
+ function canonicalizeTransparentMarkerRunGap(xml) {
223139
+ const markerRe = /<(?:[A-Za-z_][\w.-]*:)?proofErr\b(?:[^>"']|"[^"]*"|'[^']*')*\/>|<((?:[A-Za-z_][\w.-]*:)?lastRenderedPageBreak)\b(?:[^>"']|"[^"]*"|'[^']*')*(?:\/>|>\s*<\/\1>)/g;
223131
223140
  let result = "";
223132
223141
  let cursor = 0;
223133
223142
  for (const marker of xml.matchAll(markerRe)) {
@@ -429188,7 +429197,7 @@ function replaceLiveTableStructuralProperties(tableXml, tableBlocks, rowProperti
429188
429197
  const replacements = [];
429189
429198
  for (const row of directElementSpans(tableXml, table.openEnd, table.closeStart, "tr")) {
429190
429199
  const cells = directElementSpans(tableXml, row.openEnd, row.closeStart, "tc");
429191
- const rowBlock = cells.flatMap((cell) => directParagraphSpans(tableXml, cell)).map((paragraph4) => blockIdFromParagraphXml(tableXml.slice(paragraph4.start, paragraph4.end))).map((blockId) => blockId == null ? undefined : blockById.get(blockId)).find(Boolean);
429200
+ const rowBlock = cells.flatMap((cell) => cellParagraphSpans(tableXml, cell)).map((paragraph4) => blockIdFromParagraphXml(tableXml.slice(paragraph4.start, paragraph4.end))).map((blockId) => blockId == null ? undefined : blockById.get(blockId)).find(Boolean);
429192
429201
  const rowNodeId = rowBlock?.structuralRefs.rowNodeId;
429193
429202
  if (rowNodeId && cells[0] && rowProperties.has(rowNodeId)) {
429194
429203
  const prefix = tableXml.slice(row.start, cells[0].start);
@@ -429199,12 +429208,12 @@ function replaceLiveTableStructuralProperties(tableXml, tableBlocks, rowProperti
429199
429208
  });
429200
429209
  }
429201
429210
  for (const cell of cells) {
429202
- const paragraphs = directParagraphSpans(tableXml, cell);
429211
+ const paragraphs = cellParagraphSpans(tableXml, cell);
429203
429212
  const cellBlock = paragraphs.map((paragraph4) => blockIdFromParagraphXml(tableXml.slice(paragraph4.start, paragraph4.end))).map((blockId) => blockId == null ? undefined : blockById.get(blockId)).find(Boolean);
429204
429213
  const cellNodeId = cellBlock?.structuralRefs.cellNodeId;
429205
429214
  if (!cellNodeId || !cellProperties.has(cellNodeId))
429206
429215
  continue;
429207
- const contentStart = paragraphs[0]?.start ?? cell.closeStart;
429216
+ const contentStart = directParagraphSpans(tableXml, cell)[0]?.start ?? cell.closeStart;
429208
429217
  const prefix = tableXml.slice(cell.start, contentStart);
429209
429218
  replacements.push({
429210
429219
  start: cell.start,
@@ -429524,7 +429533,7 @@ function tableBlockIdsFromXml(tableXml) {
429524
429533
  return blockIds;
429525
429534
  for (const row of directElementSpans(tableXml, table.openEnd, table.closeStart, "tr")) {
429526
429535
  for (const cell of directElementSpans(tableXml, row.openEnd, row.closeStart, "tc")) {
429527
- for (const paragraph4 of directParagraphSpans(tableXml, cell)) {
429536
+ for (const paragraph4 of cellParagraphSpans(tableXml, cell)) {
429528
429537
  const blockId = blockIdFromParagraphXml(tableXml.slice(paragraph4.start, paragraph4.end));
429529
429538
  if (blockId)
429530
429539
  blockIds.add(blockId);
@@ -429581,6 +429590,15 @@ function findContainingTableCellSpan(xml, offset) {
429581
429590
  }
429582
429591
  return containing;
429583
429592
  }
429593
+ function cellParagraphSpans(xml, cellSpan) {
429594
+ const spans = directParagraphSpans(xml, cellSpan);
429595
+ for (const control of directElementSpans(xml, cellSpan.openEnd, cellSpan.closeStart, "sdt")) {
429596
+ for (const content3 of directElementSpans(xml, control.openEnd, control.closeStart, "sdtContent")) {
429597
+ spans.push(...cellParagraphSpans(xml, content3));
429598
+ }
429599
+ }
429600
+ return spans;
429601
+ }
429584
429602
  function directParagraphSpans(xml, cellSpan) {
429585
429603
  const spans = [];
429586
429604
  let cursor = cellSpan.openEnd;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.3.1-next.5",
3
+ "version": "1.3.1-next.7",
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.16.1-next.5",
27
+ "@superdoc/sdk": "2.16.1-next.7",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.19.1-next.1",
33
- "@superdoc/docx-engine": "0.18.1-next.1",
32
+ "superdoc": "2.19.1-next.3",
33
+ "@superdoc/docx-engine": "0.18.1-next.3",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",