@superdoc/mcp 1.3.0-next.7 → 1.3.0-next.8

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 +32 -7
  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.0-next.7";
31321
+ var SDK_VERSION = "2.16.0-next.8";
31322
31322
 
31323
31323
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31324
31324
  import { chmodSync, existsSync } from "node:fs";
@@ -200600,7 +200600,7 @@ function isolateSimpleTextRangeInParagraphXml(input) {
200600
200600
  if (input.rangeStart < 0 || input.rangeEnd <= input.rangeStart) {
200601
200601
  return { ok: false, reason: "invalid-range" };
200602
200602
  }
200603
- const contextualRejection = rejectSimpleTextRangeContext(input.paragraphXml, input.rangeStart, input.rangeEnd);
200603
+ const contextualRejection = rejectSimpleTextRangeContext(input.paragraphXml, input.rangeStart, input.rangeEnd, input.allowDisjointTracked ?? false);
200604
200604
  if (contextualRejection)
200605
200605
  return { ok: false, reason: contextualRejection };
200606
200606
  const paragraphOpen = /^<([\w.-]+):p\b[^>]*>/.exec(input.paragraphXml);
@@ -200613,10 +200613,21 @@ function isolateSimpleTextRangeInParagraphXml(input) {
200613
200613
  }
200614
200614
  const runs = [];
200615
200615
  const runRe = /<([\w.-]+):r\b[^>]*>[\s\S]*?<\/\1:r>/g;
200616
+ const ordinaryRunStarts = input.allowDisjointTracked ? new Map : null;
200617
+ if (ordinaryRunStarts) {
200618
+ for (const piece of parseParagraphInlineMap(input.paragraphXml).leaves()) {
200619
+ if (piece.kind === "text" && piece.textRole === "visible" && piece.containerStack.length === 0 && !ordinaryRunStarts.has(piece.runCharStart)) {
200620
+ ordinaryRunStarts.set(piece.runCharStart, piece.visibleStart);
200621
+ }
200622
+ }
200623
+ }
200616
200624
  let visibleCursor = 0;
200617
200625
  let match;
200618
200626
  while ((match = runRe.exec(input.paragraphXml)) != null) {
200619
- const parsed = parseSimpleTextRunForRange(match[0], match.index, visibleCursor);
200627
+ const textStart = ordinaryRunStarts?.get(match.index) ?? visibleCursor;
200628
+ if (ordinaryRunStarts && !ordinaryRunStarts.has(match.index))
200629
+ continue;
200630
+ const parsed = parseSimpleTextRunForRange(match[0], match.index, textStart);
200620
200631
  if (!parsed)
200621
200632
  return { ok: false, reason: "unsupported-context" };
200622
200633
  runs.push(parsed);
@@ -200677,14 +200688,17 @@ function renderSimpleTextRunSlice(slice, options = {}) {
200677
200688
  }).join("");
200678
200689
  return `${slice.runOpenTag}${options.rPrXml ?? slice.rPrXml}${textXml}${slice.runCloseTag}`;
200679
200690
  }
200680
- function rejectSimpleTextRangeContext(paragraphXml, rangeStart, rangeEnd) {
200691
+ function rejectSimpleTextRangeContext(paragraphXml, rangeStart, rangeEnd, allowDisjointTracked) {
200681
200692
  if (/<[\w.-]+:(?:fldSimple|fldChar|instrText|delInstrText)\b/.test(paragraphXml))
200682
200693
  return "field";
200683
200694
  if (/<[\w.-]+:(?:commentRangeStart|commentRangeEnd|commentReference)\b/.test(paragraphXml)) {
200684
200695
  return "comment";
200685
200696
  }
200686
- if (/<[\w.-]+:(?:ins|del|moveFrom|moveTo)\b/.test(paragraphXml))
200687
- return "tracked";
200697
+ if (/<[\w.-]+:(?:ins|del|moveFrom|moveTo)\b/.test(paragraphXml)) {
200698
+ if (!allowDisjointTracked || hasTrackedOverlap(parseParagraphInlineMap(paragraphXml).pieces, rangeStart, rangeEnd)) {
200699
+ return "tracked";
200700
+ }
200701
+ }
200688
200702
  if (/<[\w.-]+:hyperlink\b/.test(paragraphXml)) {
200689
200703
  const hyperlinkRange = inspectHyperlinkRange(parseParagraphInlineMap(paragraphXml).pieces, rangeStart, rangeEnd);
200690
200704
  if (!hyperlinkRange.found || hyperlinkRange.overlaps)
@@ -200698,6 +200712,16 @@ function rejectSimpleTextRangeContext(paragraphXml, rangeStart, rangeEnd) {
200698
200712
  return "drawing";
200699
200713
  return null;
200700
200714
  }
200715
+ function hasTrackedOverlap(pieces, rangeStart, rangeEnd) {
200716
+ for (const piece of pieces) {
200717
+ if (piece.kind === "tracked" && rangeStart < piece.visibleEnd && rangeEnd > piece.visibleStart) {
200718
+ return true;
200719
+ }
200720
+ if ((piece.kind === "tracked" || piece.kind === "container") && hasTrackedOverlap(piece.children, rangeStart, rangeEnd))
200721
+ return true;
200722
+ }
200723
+ return false;
200724
+ }
200701
200725
  function inspectHyperlinkRange(pieces, rangeStart, rangeEnd) {
200702
200726
  let found = false;
200703
200727
  for (const piece of pieces) {
@@ -238505,7 +238529,8 @@ function runHyperlinkWrapCommit(input) {
238505
238529
  const isolated = isolateSimpleTextRangeInParagraphXml({
238506
238530
  paragraphXml: paraXml,
238507
238531
  rangeStart: op.on.startOffset,
238508
- rangeEnd: op.on.endOffset
238532
+ rangeEnd: op.on.endOffset,
238533
+ allowDisjointTracked: true
238509
238534
  });
238510
238535
  if (!isolated.ok) {
238511
238536
  return rejected19(input.txId, mapSimpleTextRangeIsolationReason(isolated.reason));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.3.0-next.7",
3
+ "version": "1.3.0-next.8",
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.0-next.7",
27
+ "@superdoc/sdk": "2.16.0-next.8",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.19.0-next.6",
33
- "@superdoc/docx-engine": "0.18.0-next.6",
32
+ "superdoc": "2.19.0-next.7",
33
+ "@superdoc/docx-engine": "0.18.0-next.7",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",