@superdoc/mcp 1.4.1-next.1 → 1.4.1-next.3

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 +47 -4
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31330,7 +31330,7 @@ var init_host = __esm(() => {
31330
31330
  });
31331
31331
 
31332
31332
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31333
- var SDK_VERSION = "2.17.1-next.1";
31333
+ var SDK_VERSION = "2.17.1-next.3";
31334
31334
 
31335
31335
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31336
31336
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -252123,6 +252123,18 @@ function applySDDocumentSessionInternalProjection(session, input) {
252123
252123
  const projectedStoryIds = new Set(projectedStories.map((story) => story.storyId));
252124
252124
  const requestedChangedPartUris = new Set(input.changedPartUris);
252125
252125
  const requestedChangedStoryIds = new Set(input.changedStoryIds);
252126
+ if (!input.packageReplaced) {
252127
+ for (const { descriptor } of state.stories.values()) {
252128
+ if (descriptor.storyKind !== "textbox" || !descriptor.textbox?.ownerStoryId || projectedStoryIds.has(descriptor.storyId) || !projectedStoryIds.has(descriptor.textbox.ownerStoryId) || !projectedPartUris.has(descriptor.ownerPartUri) || requestedChangedPartUris.has(descriptor.ownerPartUri))
252129
+ continue;
252130
+ projectedStories.push({
252131
+ storyId: descriptor.storyId,
252132
+ storyKind: descriptor.storyKind,
252133
+ partUri: descriptor.ownerPartUri
252134
+ });
252135
+ projectedStoryIds.add(descriptor.storyId);
252136
+ }
252137
+ }
252126
252138
  const textPart = projectedParts.find((part) => requestedChangedPartUris.has(part.partUri));
252127
252139
  const textStory = projectedStories.find((story) => requestedChangedStoryIds.has(story.storyId));
252128
252140
  const inventoryUnchanged = projectedParts.length === state.partOrder.length && projectedPartUris.size === projectedParts.length && projectedParts.every((part) => state.parts.get(part.partUri)?.descriptor.contentType === part.contentType) && projectedStories.length === state.stories.size && projectedStoryIds.size === projectedStories.length && projectedStories.every((story) => {
@@ -292302,7 +292314,14 @@ function findMetadataAnchor(documentXml, id) {
292302
292314
  }
292303
292315
  function listMetadataAnchors(documentXml, knownIds) {
292304
292316
  const anchors = [];
292317
+ const textboxes = bodyTextboxRanges(documentXml);
292318
+ let textboxIndex = 0;
292305
292319
  for (const sdt of listSdtRanges(documentXml)) {
292320
+ while (textboxes[textboxIndex] && textboxes[textboxIndex].end <= sdt.start)
292321
+ textboxIndex += 1;
292322
+ const textbox = textboxes[textboxIndex];
292323
+ if (textbox && sdt.start >= textbox.start && sdt.start < textbox.end)
292324
+ continue;
292306
292325
  const pr = ownSdtPr(sdt.xml);
292307
292326
  const tag = attrValue(/<w:tag\b[^>]*\/>/.exec(pr)?.[0] ?? "", "val");
292308
292327
  if (!tag || !isMetadataAnchorPr(pr, tag, knownIds))
@@ -292313,6 +292332,25 @@ function listMetadataAnchors(documentXml, knownIds) {
292313
292332
  }
292314
292333
  return anchors.sort((left, right) => left.start - right.start);
292315
292334
  }
292335
+ function bodyTextboxRanges(documentXml) {
292336
+ const ranges = [];
292337
+ let depth = 0;
292338
+ walkXmlElements(documentXml, {
292339
+ onOpenTag({ tag, start }) {
292340
+ if (tag.namespaceUri !== WORD_NAMESPACE6 || tag.localName !== "txbxContent")
292341
+ return;
292342
+ if (depth++ === 0)
292343
+ ranges.push({ start, end: documentXml.length });
292344
+ },
292345
+ onCloseTag({ tag, end }) {
292346
+ if (tag.namespaceUri !== WORD_NAMESPACE6 || tag.localName !== "txbxContent")
292347
+ return;
292348
+ if (--depth === 0)
292349
+ ranges[ranges.length - 1].end = end;
292350
+ }
292351
+ });
292352
+ return ranges;
292353
+ }
292316
292354
  function ownSdtPr(sdtXml) {
292317
292355
  const openTag = /<w:sdt\b[^>]*>/.exec(sdtXml);
292318
292356
  if (!openTag)
@@ -292443,21 +292481,26 @@ function countBodyControlIds(documentXml) {
292443
292481
  const stack = [];
292444
292482
  const parser = createXmlSaxParser({ namespaceAware: true });
292445
292483
  let parseFailed = false;
292484
+ let textboxDepth = 0;
292446
292485
  parser.on("error", () => {
292447
292486
  parseFailed = true;
292448
292487
  });
292449
292488
  parser.on("opentag", (tag) => {
292489
+ if (tag.namespaceUri === WORD_NAMESPACE6 && tag.localName === "txbxContent")
292490
+ textboxDepth += 1;
292450
292491
  const parent = stack.at(-1);
292451
292492
  const owner = stack.at(-2);
292452
- if (tag.namespaceUri === WORD_NAMESPACE6 && tag.localName === "id" && parent?.namespaceUri === WORD_NAMESPACE6 && parent.localName === "sdtPr" && owner?.namespaceUri === WORD_NAMESPACE6 && owner.localName === "sdt") {
292493
+ if (textboxDepth === 0 && tag.namespaceUri === WORD_NAMESPACE6 && tag.localName === "id" && parent?.namespaceUri === WORD_NAMESPACE6 && parent.localName === "sdtPr" && owner?.namespaceUri === WORD_NAMESPACE6 && owner.localName === "sdt") {
292453
292494
  const value2 = tag.attributes.find((attribute) => attribute.namespaceUri === WORD_NAMESPACE6 && attribute.localName === "val")?.value;
292454
292495
  if (value2 !== undefined)
292455
292496
  counts.set(value2, (counts.get(value2) ?? 0) + 1);
292456
292497
  }
292457
292498
  stack.push(tag);
292458
292499
  });
292459
- parser.on("closetag", () => {
292500
+ parser.on("closetag", (tag) => {
292460
292501
  stack.pop();
292502
+ if (tag.namespaceUri === WORD_NAMESPACE6 && tag.localName === "txbxContent")
292503
+ textboxDepth -= 1;
292461
292504
  });
292462
292505
  try {
292463
292506
  parser.write(documentXml).close();
@@ -436560,7 +436603,7 @@ function mirrorStoryBlocksFromSession(input) {
436560
436603
  const headPayload = readSessionBlockPayload(context, source.target.paraId);
436561
436604
  const tailPayload = readSessionBlockPayload(context, tailBlockId);
436562
436605
  if (!findBlockMap(input.doc, tailBlockId)) {
436563
- const offset = source.coordinateSpace === "tracked" ? parseParagraphXml(headPayload.xml, headPayload.namespaceBindings, trackedWrapperIdentityStateForPayload(headPayload)).visibleText.length : source.offset;
436606
+ const offset = parseParagraphXml(headPayload.xml, headPayload.namespaceBindings, trackedWrapperIdentityStateForPayload(headPayload)).visibleText.length;
436564
436607
  splitBlock({
436565
436608
  doc: input.doc,
436566
436609
  blockId: source.target.paraId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.4.1-next.1",
3
+ "version": "1.4.1-next.3",
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.17.1-next.1",
27
+ "@superdoc/sdk": "2.17.1-next.3",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.20.1-next.1",
33
- "@superdoc/docx-engine": "0.19.1-next.1",
32
+ "superdoc": "2.20.1-next.3",
33
+ "@superdoc/docx-engine": "0.19.1-next.2",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",