@superdoc/mcp 1.4.1-next.6 → 1.4.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 +78 -7
  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.6";
31333
+ var SDK_VERSION = "2.17.1-next.7";
31334
31334
 
31335
31335
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31336
31336
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -164957,7 +164957,7 @@ function planDirectInlineEdit(paragraphBytes, startOffset, endOffset, newText, c
164957
164957
  return { ok: false, emptyParagraph: true };
164958
164958
  }
164959
164959
  if (startOffset === endOffset) {
164960
- const plan2 = planCollapsedInsert(paragraphBytes, xml, pieces, leaves, startOffset, newText, visibleLength === 0, inlineContext, collapsedInlineAffinity);
164960
+ const plan2 = planCollapsedInsert(paragraphBytes, xml, pieces, leaves, startOffset, newText, visibleLength === 0, inlineContext, collapsedInlineAffinity, inheritedNamespaceBindings);
164961
164961
  return plan2.ok && (scope.requiresCollaborationSessionSync || collapsedOutsideContentControl) ? { ...plan2, requiresCollaborationSessionSync: true } : plan2;
164962
164962
  }
164963
164963
  const plan = planReplace(paragraphBytes, pieces, leaves, startOffset, endOffset, newText, scope.wrapperRemovalOps);
@@ -165204,7 +165204,7 @@ function planReplace(paragraphBytes, pieces, leaves, start, end, newText, wrappe
165204
165204
  }
165205
165205
  return { ok: true, bytes: spliceBytes(paragraphBytes, ops) };
165206
165206
  }
165207
- function planCollapsedInsert(paragraphBytes, xml, pieces, leaves, at, newText, textEmptyParagraph, inlineContext, collapsedInlineAffinity) {
165207
+ function planCollapsedInsert(paragraphBytes, xml, pieces, leaves, at, newText, textEmptyParagraph, inlineContext, collapsedInlineAffinity, inheritedNamespaceBindings = {}) {
165208
165208
  if (newText.length === 0) {
165209
165209
  return { ok: true, bytes: Uint8Array.from(paragraphBytes) };
165210
165210
  }
@@ -165308,6 +165308,20 @@ function planCollapsedInsert(paragraphBytes, xml, pieces, leaves, at, newText, t
165308
165308
  runPropertiesXml: nextDownstreamMoveFromCarrier.runProperties ?? ""
165309
165309
  };
165310
165310
  }
165311
+ if (collapsedInlineAffinity === "downstream" && prevText && nextText && !markerAtPoint && downstreamMoveFromBoundary == null && findDownstreamVisibleCarrierAfterHiddenRun(xml, pieces, at, inheritedNamespaceBindings) === nextText) {
165312
+ const reason = runUnsafeReason(nextText, leaves);
165313
+ if (reason)
165314
+ return { ok: false, reason };
165315
+ return {
165316
+ ok: true,
165317
+ bytes: spliceBytes(paragraphBytes, [{
165318
+ start: nextText.byteStart,
165319
+ end: nextText.byteEnd,
165320
+ bytes: encodeTextNode(nextText.qname, newText + nextText.decodedText)
165321
+ }]),
165322
+ runPropertiesXml: nextText.runProperties ?? ""
165323
+ };
165324
+ }
165311
165325
  const onlyFieldMarkersAtPoint = markerAtPoint && markersAtPoint.every((piece) => isFieldMarker(piece.markerKind));
165312
165326
  const onlyRangeStartMarkersAfterMove = markerAtPoint && downstreamMoveFromBoundary != null && markersAtPoint.every((piece) => piece.role === "range-start" && !isFieldMarker(piece.markerKind) && (piece.runByteStart ?? piece.byteStart) >= downstreamMoveFromBoundary);
165313
165327
  if (prevText && (!markerAtPoint || onlyFieldMarkersAtPoint || collapsedInlineAffinity === "upstream" && onlyBookmarkEndMarkersAtPoint && downstreamMoveFromBoundary == null || collapsedInlineAffinity === "upstream" && downstreamMoveFromBoundary != null && onlyRangeStartMarkersAfterMove) && (collapsedInlineAffinity === "upstream" || downstreamMoveFromBoundary == null)) {
@@ -165783,6 +165797,47 @@ function extractEmptySdtRunProperties(sdtXml, content, namespaceBindings) {
165783
165797
  const endProperties = findFirstWordChildXml(sdtXml, "sdtEndPr", namespaceBindings);
165784
165798
  return endProperties ? findFirstWordChildXml(endProperties, "rPr", namespaceBindings) ?? "" : "";
165785
165799
  }
165800
+ function findDownstreamVisibleCarrierAfterHiddenRun(paragraphXml, pieces, at, inheritedNamespaceBindings = {}) {
165801
+ const previous = lastVisibleTextEndingAt(pieces, at);
165802
+ const next = firstVisibleTextStartingAt(pieces, at);
165803
+ if (!previous || !next || previous.runCharEnd > next.runCharStart)
165804
+ return null;
165805
+ if (paragraphXml.slice(previous.runCharEnd, next.runCharStart).trim() !== "")
165806
+ return null;
165807
+ return hasDirectVanish(previous, paragraphXml, inheritedNamespaceBindings) && !hasDirectVanish(next, paragraphXml, inheritedNamespaceBindings) ? next : null;
165808
+ }
165809
+ function hasDirectVanish(piece, paragraphXml, inheritedNamespaceBindings) {
165810
+ if (!piece.runProperties)
165811
+ return false;
165812
+ let depth = 0;
165813
+ let runDepth = 0;
165814
+ let propertiesDepth = 0;
165815
+ let enabled = false;
165816
+ const parsed = walkXmlElements(paragraphXml, {
165817
+ fragment: true,
165818
+ additionalNamespaces: xmlFragmentAdditionalNamespaces(paragraphXml, new Map(Object.entries(inheritedNamespaceBindings)), { w: NS_W }),
165819
+ onOpenTag: ({ tag, start }) => {
165820
+ depth += 1;
165821
+ if (start === piece.runCharStart)
165822
+ runDepth = depth;
165823
+ if (runDepth > 0 && depth === runDepth + 1 && tag.namespaceUri === NS_W && tag.localName === "rPr") {
165824
+ propertiesDepth = depth;
165825
+ }
165826
+ if (propertiesDepth > 0 && depth === propertiesDepth + 1 && tag.namespaceUri === NS_W && tag.localName === "vanish") {
165827
+ const value = tag.attributes.find((attribute) => attribute.namespaceUri === NS_W && attribute.localName === "val")?.value;
165828
+ enabled = value == null || value === "1" || value === "true" || value === "on";
165829
+ }
165830
+ },
165831
+ onCloseTag: () => {
165832
+ if (depth === propertiesDepth)
165833
+ propertiesDepth = 0;
165834
+ if (depth === runDepth)
165835
+ runDepth = 0;
165836
+ depth -= 1;
165837
+ }
165838
+ });
165839
+ return parsed.errors.length === 0 && enabled;
165840
+ }
165786
165841
  function findFirstWordChildXml(xml, localName2, namespaceBindings) {
165787
165842
  const additionalNamespaces = xmlFragmentAdditionalNamespaces(xml, namespaceBindings, { w: NS_W });
165788
165843
  let depth = 0;
@@ -199134,7 +199189,7 @@ function commitTracked(input, view) {
199134
199189
  date: stamping.date,
199135
199190
  newText: op.newText,
199136
199191
  allocateWIdBlock: allocateLocalizedWIdBlock
199137
- }) : compileOp.on.coordinateSpace === "tracked" ? (() => {
199192
+ }, inlineContext, namespaceBindings) : compileOp.on.coordinateSpace === "tracked" ? (() => {
199138
199193
  const overlap = tryOverlapRewriteTracked(compileInput, bytes, window2, byteBase, {
199139
199194
  rsid: op.rsid,
199140
199195
  insRsid,
@@ -199195,7 +199250,7 @@ function commitTracked(input, view) {
199195
199250
  date: stamping.date,
199196
199251
  newText: op.newText,
199197
199252
  allocateWIdBlock: allocateLocalizedWIdBlock
199198
- }, inlineContext);
199253
+ }, inlineContext, namespaceBindings);
199199
199254
  })() : rewriteLocalizedTracked(bytes, window2, compileOp, {
199200
199255
  rsid: op.rsid,
199201
199256
  insRsid,
@@ -199204,7 +199259,7 @@ function commitTracked(input, view) {
199204
199259
  date: stamping.date,
199205
199260
  newText: op.newText,
199206
199261
  allocateWIdBlock: allocateLocalizedWIdBlock
199207
- }, inlineContext);
199262
+ }, inlineContext, namespaceBindings);
199208
199263
  const canSpanningDelete = compileOp.on.coordinateSpace !== "tracked" && op.newText.length === 0 && compileOp.on.startOffset < compileOp.on.endOffset;
199209
199264
  const spanningDeleteWIds = [];
199210
199265
  let usedSpanningDelete = false;
@@ -200466,7 +200521,7 @@ function requiresStructuralTrackedRewriteSessionSync(paragraphXml, leaves, start
200466
200521
  const textStacks = affected.filter((piece) => piece.kind === "text").map(structuralStack);
200467
200522
  return textStacks.some((stack) => stack !== textStacks[0]);
200468
200523
  }
200469
- function rewriteLocalizedTracked(bytes, window2, op, stamp, preparedContext) {
200524
+ function rewriteLocalizedTracked(bytes, window2, op, stamp, preparedContext, inheritedNamespaceBindings = {}) {
200470
200525
  const paragraphBytes = bytes.subarray(window2.byteStart, window2.byteEnd);
200471
200526
  const inlineContext = preparedContext ?? prepareParagraphInlineEditContext(paragraphBytes);
200472
200527
  const paragraphXml = inlineContext.paragraphXml;
@@ -200546,6 +200601,22 @@ function rewriteLocalizedTracked(bytes, window2, op, stamp, preparedContext) {
200546
200601
  if (contained)
200547
200602
  return contained;
200548
200603
  }
200604
+ if (op.on.startOffset === op.on.endOffset && stamp.newText.length > 0 && !op.on.collapsedObjectBoundary && op.on.collapsedInlineAffinity === "downstream") {
200605
+ const carrier = findDownstreamVisibleCarrierAfterHiddenRun(paragraphXml, inlinePieces, op.on.startOffset, inheritedNamespaceBindings);
200606
+ if (carrier) {
200607
+ const insertion = buildInsWrapper(stamp.newText, carrier.runOpenTag, carrier.runCloseTag, carrier.runProperties ?? "", {
200608
+ rsid: stamp.insRsid,
200609
+ wId: stamp.wId,
200610
+ author: stamp.author,
200611
+ date: stamp.date
200612
+ });
200613
+ return {
200614
+ ok: true,
200615
+ bytes: TE16.encode(paragraphXml.slice(0, carrier.runCharStart) + insertion + paragraphXml.slice(carrier.runCharStart)),
200616
+ emittedBothSides: false
200617
+ };
200618
+ }
200619
+ }
200549
200620
  let rewritten = rewriteRunSpanTrackedReplace(paragraphXml, op.on.startOffset, op.on.endOffset, stamp, op.on.collapsedObjectBoundary);
200550
200621
  if (!rewritten.ok && isCollapsedInsert(op) && !op.on.collapsedObjectBoundary) {
200551
200622
  const normalized = splitCompoundRunsForTrackedReplace(paragraphXml, op.on.startOffset, op.on.endOffset, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.4.1-next.6",
3
+ "version": "1.4.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.17.1-next.6",
27
+ "@superdoc/sdk": "2.17.1-next.7",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.20.1-next.6",
33
- "@superdoc/docx-engine": "0.19.1-next.5",
32
+ "superdoc": "2.20.1-next.7",
33
+ "@superdoc/docx-engine": "0.19.1-next.6",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",