@superdoc/mcp 1.10.1-next.2 → 1.10.1-next.4

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 +200 -26
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31630,7 +31630,7 @@ var init_host = __esm(() => {
31630
31630
  });
31631
31631
 
31632
31632
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31633
- var SDK_VERSION = "2.23.1-next.2";
31633
+ var SDK_VERSION = "2.23.1-next.4";
31634
31634
 
31635
31635
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31636
31636
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -159805,7 +159805,7 @@ function readResidentReviewComponent(state, mode, sourceIds, includeCoordinates
159805
159805
  cached2.lookupContext.dispose();
159806
159806
  }
159807
159807
  if (component.wrapped.length <= 2 * 1024 * 1024) {
159808
- while (review.selectionCatalogs.size >= 64 || review.componentCharacters + component.wrapped.length > 2 * 1024 * 1024) {
159808
+ while (review.selectionCatalogs.size >= 512 || review.componentCharacters + component.wrapped.length > 2 * 1024 * 1024) {
159809
159809
  const oldest = review.selectionCatalogs.entries().next().value;
159810
159810
  if (!oldest)
159811
159811
  break;
@@ -182170,6 +182170,14 @@ function readResidentParagraphNamespaces(state, blockId) {
182170
182170
  return null;
182171
182171
  return store.paragraphs.get(blockId)?.namespaceBindings ?? store.readOnlyNamespaces.get(blockId)?.namespaceBindings ?? null;
182172
182172
  }
182173
+ function readResidentParagraphNamespaceScope(state, blockId) {
182174
+ const namespaceBindings = readResidentParagraphNamespaces(state, blockId);
182175
+ if (!namespaceBindings)
182176
+ return null;
182177
+ const store = stores.get(state);
182178
+ const parentNamespaceBindings = store.paragraphs.get(blockId)?.parentNamespaceBindings ?? store.readOnlyNamespaces.get(blockId)?.parentNamespaceBindings;
182179
+ return parentNamespaceBindings ? Object.freeze({ namespaceBindings, parentNamespaceBindings }) : null;
182180
+ }
182173
182181
  function prepareResidentParagraphOwnershipPublication(state, group) {
182174
182182
  const store = stores.get(state);
182175
182183
  if (!store)
@@ -196568,7 +196576,7 @@ function resolveEditScope(pieces, start, end, collapsedInlineAffinity, collapsed
196568
196576
  let emptySdt;
196569
196577
  let requiresCollaborationSessionSync = false;
196570
196578
  for (;; ) {
196571
- const container = current.find((piece) => piece.kind === "container" && containerContainsRange(piece, start, end)) ?? (start === end ? findCollapsedEdgeContainer(current, start, collapsedInlineAffinity, collapsedOutsideContentControl) : undefined);
196579
+ const container = start === end ? findCaretContainer(current, start, collapsedInlineAffinity, collapsedOutsideContentControl) : current.find((piece) => piece.kind === "container" && containerContainsRange(piece, start, end));
196572
196580
  if (!container) {
196573
196581
  if (start === end) {
196574
196582
  return {
@@ -196671,6 +196679,9 @@ function containerContainsRange(piece, start, end) {
196671
196679
  return piece.visibleStart < start && start < piece.visibleEnd;
196672
196680
  return piece.visibleStart <= start && end <= piece.visibleEnd;
196673
196681
  }
196682
+ function findCaretContainer(pieces, at, collapsedInlineAffinity, collapsedOutsideContentControl = false) {
196683
+ return pieces.find((piece) => piece.kind === "container" && containerContainsRange(piece, at, at)) ?? findCollapsedEdgeContainer(pieces, at, collapsedInlineAffinity, collapsedOutsideContentControl);
196684
+ }
196674
196685
  function findCollapsedEdgeContainer(pieces, at, collapsedInlineAffinity, collapsedOutsideContentControl = false) {
196675
196686
  const emptySdtsAtPoint = pieces.filter((piece) => piece.kind === "container" && piece.containerKind === "sdt" && piece.visibleStart === at && piece.visibleEnd === at);
196676
196687
  return pieces.find((piece) => {
@@ -221834,13 +221845,57 @@ function resolveCaretRunPropertiesForInsertion(paragraphXml, charOffset, inherit
221834
221845
  }
221835
221846
  return cloneAdjacentRunPropertiesForInsert(paragraphXml, "before", paragraphMarkRunPropertiesXml, inheritedNamespaceBindings, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary);
221836
221847
  }
221837
- function adjacentFormattingCarrierRun(paragraphXml, placement2, inheritedNamespaceBindings = {}, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary) {
221848
+ function readCaretRunProperties(paragraphXml, charOffset, inheritedNamespaceBindings = {}, collapsedInlineAffinity, collapsedObjectBoundary) {
221849
+ const sourceXml = stripElements(paragraphXml, "txbxContent");
221850
+ const model = parseParagraphInlineMap(sourceXml, inheritedNamespaceBindings);
221851
+ let source;
221852
+ let properties2;
221853
+ if (!collapsedObjectBoundary && (model.visibleLength === 0 || collapsedOutsideContainerAt(model.pieces, charOffset, collapsedInlineAffinity))) {
221854
+ source = findFirstElement(sourceXml, "pPr") ?? undefined;
221855
+ properties2 = source ? extractParagraphMarkRunProperties(source.xml) : "";
221856
+ if (properties2 === null)
221857
+ return { ok: false, reason: "unsupported-context" };
221858
+ } else {
221859
+ let caretPieces = model.pieces;
221860
+ if (!collapsedObjectBoundary) {
221861
+ for (;; ) {
221862
+ const container = findCaretContainer(caretPieces, charOffset, collapsedInlineAffinity);
221863
+ if (!container)
221864
+ break;
221865
+ if (container.policy === "atomic" || container.policy === "fail-closed") {
221866
+ return { ok: false, reason: "unsupported-context" };
221867
+ }
221868
+ caretPieces = container.children;
221869
+ }
221870
+ caretPieces = caretPieces.filter((piece) => piece.kind !== "container" || piece.policy === "fail-closed");
221871
+ }
221872
+ const carrier = adjacentFormattingCarrierRun(sourceXml, "before", inheritedNamespaceBindings, charOffset, undefined, collapsedInlineAffinity, collapsedObjectBoundary, caretPieces);
221873
+ if (!carrier.ok)
221874
+ return carrier;
221875
+ source = carrier.run;
221876
+ properties2 = source ? readRunPropertiesXml(source.xml) : null;
221877
+ }
221878
+ if (!source || !properties2)
221879
+ return { ok: true, runPropertiesXml: null };
221880
+ const node2 = readXmlNodeAt(properties2, 0);
221881
+ if (!node2 || node2.kind !== "element")
221882
+ return { ok: false, reason: "unsupported-context" };
221883
+ if (node2.selfClosing)
221884
+ return { ok: true, runPropertiesXml: null };
221885
+ const namespaces = namespaceSourceForRunProperties(sourceXml, source, properties2, inheritedNamespaceBindings);
221886
+ if (!namespaces || runPropertiesContainForeignRevisionLikeElement(properties2, namespaces.openTag) !== false) {
221887
+ return { ok: false, reason: "unsupported-context" };
221888
+ }
221889
+ const liveProperties = normalizeClonedRunProperties(properties2);
221890
+ return { ok: true, runPropertiesXml: liveProperties ? namespaces.openTag + liveProperties.slice(node2.openEnd) : null };
221891
+ }
221892
+ function adjacentFormattingCarrierRun(paragraphXml, placement2, inheritedNamespaceBindings = {}, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary, resolvedPieces) {
221838
221893
  const paragraphPrefix = /^<(?:(?<prefix>[\w.-]+):)?p\b/.exec(paragraphXml)?.groups?.prefix ?? "";
221839
221894
  const additionalNamespaces = xmlFragmentAdditionalNamespaces(paragraphXml, new Map(Object.entries(inheritedNamespaceBindings)), { w: NS_W, [paragraphPrefix]: NS_W });
221840
221895
  const parsed = collectXmlElementRanges(paragraphXml, { additionalNamespaces });
221841
221896
  if (parsed.errors.length > 0)
221842
221897
  return { ok: true, run: undefined };
221843
- const pieces = parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings).pieces;
221898
+ const pieces = resolvedPieces ?? parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings).pieces;
221844
221899
  const downstream = charOffset !== undefined && (replaceToOffset ?? charOffset) === charOffset && collapsedInlineAffinity === "downstream" ? findDownstreamVisibleCarrierAfterHiddenRun(paragraphXml, pieces, charOffset, inheritedNamespaceBindings) : null;
221845
221900
  const carrier = collapsedObjectBoundary && charOffset !== undefined ? { ok: true, piece: visibleTextBesideObjectAt(pieces, charOffset, collapsedObjectBoundary) ?? undefined } : downstream ? { ok: true, piece: downstream } : charOffset === undefined ? adjacentFormattingCarrierPiece(pieces, placement2) : formattingCarrierPieceAtOffset(pieces, charOffset, replaceToOffset);
221846
221901
  if (!carrier.ok)
@@ -281365,6 +281420,74 @@ function getSDDocumentSessionInternalMainRelationshipsPartUri(session) {
281365
281420
  throw new Error("internal: unknown SDDocumentSession instance");
281366
281421
  return internal.state.mainStoryId ? relsUriFor(storyPartUriFromStoryId(internal.state.mainStoryId)) : null;
281367
281422
  }
281423
+ function readSDDocumentSessionInternalParagraphNamespaceScope(session, storyId, blockId, storyByteRange) {
281424
+ const internal = INTERNALS.get(session);
281425
+ if (!internal)
281426
+ throw new Error("internal: unknown SDDocumentSession instance");
281427
+ const state = internal.state;
281428
+ const index = getStoryParagraphIndexFromState(state, storyId);
281429
+ const candidates = storyByteRange ? index?.entries.filter((entry2) => entry2.blockId === blockId && entry2.byteStart >= storyByteRange[0] && entry2.byteEnd <= storyByteRange[1]) : null;
281430
+ const entry = candidates ? candidates.length === 1 ? candidates[0] : null : index?.byParaId(blockId);
281431
+ if (!entry || !storyByteRange && index.duplicateParaIds.has(blockId))
281432
+ return null;
281433
+ const canonical = !storyByteRange ? peekSDCanonicalResidentParagraph(state, storyId, blockId) : null;
281434
+ if (canonical)
281435
+ return canonical.scope;
281436
+ const ownership = storyId === state.mainStoryId ? readResidentParagraphOwnership(state, blockId) : null;
281437
+ let scope = ownership ? Object.freeze({
281438
+ namespaceBindings: ownership.namespaceBindings,
281439
+ parentNamespaceBindings: ownership.parentNamespaceBindings
281440
+ }) : storyId === state.mainStoryId ? readResidentParagraphNamespaceScope(state, blockId) : null;
281441
+ if (!ownership && entry.hasNonEditableBlockSdtContent && storyId === state.mainStoryId) {
281442
+ const namespaces = readResidentParagraphNamespaces(state, blockId);
281443
+ if (namespaces) {
281444
+ return { namespaceBindings: namespaces, parentNamespaceBindings: namespaces };
281445
+ }
281446
+ }
281447
+ let cached2 = state.paragraphNamespaceCache.get(entry.partUri);
281448
+ if (cached2?.revision !== entry.partRevision) {
281449
+ cached2 = { revision: entry.partRevision, bindingsByByteStart: new Map };
281450
+ state.paragraphNamespaceCache.set(entry.partUri, cached2);
281451
+ }
281452
+ scope ?? (scope = cached2.bindingsByByteStart.get(entry.byteStart) ?? null);
281453
+ if (!scope) {
281454
+ const prefix2 = readPartRangeFromStateSync(state, entry.partUri, 0, entry.byteEnd);
281455
+ if (!prefix2)
281456
+ return null;
281457
+ const xml = new TextDecoder().decode(prefix2);
281458
+ const expectedStart = new TextDecoder().decode(prefix2.subarray(0, entry.byteStart)).length;
281459
+ const parser = createXmlSaxParser({ namespaceAware: true, position: true });
281460
+ const namespaceStack = [CANONICAL_XML_EMPTY_NAMESPACE_BINDINGS];
281461
+ let malformed2 = false;
281462
+ parser.on("error", () => {
281463
+ malformed2 = true;
281464
+ });
281465
+ parser.on("opentag", (tag) => {
281466
+ const parentNamespaceBindings = namespaceStack[namespaceStack.length - 1];
281467
+ const namespaceBindings = Object.keys(tag.namespaceBindings).length > 0 ? { ...parentNamespaceBindings, ...tag.namespaceBindings } : parentNamespaceBindings;
281468
+ namespaceStack.push(namespaceBindings);
281469
+ if (scope || malformed2 || tag.localName !== "p" || tag.namespaceUri !== NS_W)
281470
+ return;
281471
+ const charStart = xml.lastIndexOf("<", parser.position - 1);
281472
+ if (charStart === expectedStart)
281473
+ scope = Object.freeze({
281474
+ namespaceBindings: createCanonicalXmlNamespaceBindings(Object.entries(namespaceBindings)),
281475
+ parentNamespaceBindings: createCanonicalXmlNamespaceBindings(Object.entries(parentNamespaceBindings))
281476
+ });
281477
+ });
281478
+ parser.on("closetag", () => {
281479
+ if (namespaceStack.length > 1)
281480
+ namespaceStack.pop();
281481
+ });
281482
+ parser.write(xml);
281483
+ if (!scope)
281484
+ return null;
281485
+ if (cached2.bindingsByByteStart.size >= 2048)
281486
+ cached2.bindingsByByteStart.clear();
281487
+ cached2.bindingsByByteStart.set(entry.byteStart, scope);
281488
+ }
281489
+ return scope;
281490
+ }
281368
281491
  function getSDDocumentSessionInternalResidentMainStructureIdentity(session) {
281369
281492
  const internal = INTERNALS.get(session);
281370
281493
  if (!internal)
@@ -286295,6 +286418,7 @@ var init_sd_document_session = __esm(() => {
286295
286418
  init_hyperlink_catalog();
286296
286419
  init_field_catalog();
286297
286420
  init_remote_paragraph_publication();
286421
+ init_xml_sax();
286298
286422
  init_revision_id_export();
286299
286423
  init_resident_review();
286300
286424
  init_canonical_xml_analysis_frame();
@@ -287719,6 +287843,7 @@ var init_sd_document_session_internal = __esm(() => {
287719
287843
  init_paragraph_inline_model();
287720
287844
  init_simple_text_run_split();
287721
287845
  init_compile_edit_text_inline_plan();
287846
+ init_insertion_formatting_context();
287722
287847
  init_compile_edit_text();
287723
287848
  init_tracked_inline_replacement();
287724
287849
  init_tracked_paragraph_content();
@@ -372378,8 +372503,13 @@ async function readAttempt(context, input, readState) {
372378
372503
  const paragraph3 = first ? await loadParagraph(context, first, model, resolveTableInfo, readState, collapsed ? input.pendingInline : undefined) : null;
372379
372504
  if (!paragraph3)
372380
372505
  recordAll("source-unavailable");
372381
- else
372382
- record3(paragraph3.runAtCaret(first.startOffset));
372506
+ else {
372507
+ const run = paragraph3.runAtCaret(first.startOffset);
372508
+ if (run)
372509
+ record3(run);
372510
+ else
372511
+ recordAll("unsupported-context");
372512
+ }
372383
372513
  }
372384
372514
  const properties2 = {};
372385
372515
  for (const key3 of input.keys) {
@@ -372410,8 +372540,7 @@ async function loadParagraph(context, range, model, resolveTableInfo, readState,
372410
372540
  const paragraphMarkFormatsBreakRuns = leaves.length > 0 && leaves.every((leaf) => leaf.kind === "control" && leaf.control !== "tab");
372411
372541
  const paragraphMarkRPrXml = extractParagraphMarkRPrXml2(paragraphXml);
372412
372542
  const readRun = (runPropertiesXml) => {
372413
- const inheritsMark = runPropertiesXml == null && paragraphMarkFormatsBreakRuns;
372414
- let sourceXml = inheritsMark ? paragraphMarkRPrXml : runPropertiesXml;
372543
+ let sourceXml = runPropertiesXml;
372415
372544
  if (pendingInline) {
372416
372545
  const patched = applyInlinePatchToRPr2(sourceXml ?? "", pendingInline);
372417
372546
  if (patched.ok)
@@ -372428,7 +372557,6 @@ async function loadParagraph(context, range, model, resolveTableInfo, readState,
372428
372557
  })
372429
372558
  };
372430
372559
  };
372431
- const paragraphMarkRun = () => readRun(paragraphMarkRPrXml);
372432
372560
  return {
372433
372561
  runsInRange(start, end) {
372434
372562
  const seen = new Set;
@@ -372439,18 +372567,16 @@ async function loadParagraph(context, range, model, resolveTableInfo, readState,
372439
372567
  if (seen.has(leaf.runCharStart))
372440
372568
  continue;
372441
372569
  seen.add(leaf.runCharStart);
372442
- runs.push(readRun(leaf.runProperties));
372570
+ runs.push(readRun(leaf.runProperties ?? (paragraphMarkFormatsBreakRuns ? paragraphMarkRPrXml : null)));
372443
372571
  }
372444
372572
  return runs;
372445
372573
  },
372446
372574
  runAtCaret(offset) {
372447
- let before;
372448
- for (const leaf of leaves) {
372449
- if (leaf.visibleStart < offset && leaf.visibleEnd >= offset)
372450
- before = leaf;
372451
- }
372452
- const chosen = before ?? leaves.find((leaf) => leaf.visibleStart >= offset && leaf.visibleEnd > leaf.visibleStart);
372453
- return chosen ? readRun(chosen.runProperties) : paragraphMarkRun();
372575
+ const scope = readSDDocumentSessionInternalParagraphNamespaceScope(context.session, range.storyId, range.startBlockId);
372576
+ if (!scope)
372577
+ return null;
372578
+ const carrier = readCaretRunProperties(paragraphXml, offset, scope.namespaceBindings, range.collapsedInlineAffinity, range.collapsedObjectBoundary);
372579
+ return carrier.ok ? readRun(carrier.runPropertiesXml) : null;
372454
372580
  }
372455
372581
  };
372456
372582
  }
@@ -400488,6 +400614,7 @@ class V2TrackedChangesAdapter {
400488
400614
  this.context = context;
400489
400615
  this.supportsCommentRetention = true;
400490
400616
  this.reviewReadCache = null;
400617
+ this.reviewSnapshotWork = { discoveryItemBuilds: 0, discoveryItemReuses: 0, residentReads: 0, fullViewReads: 0 };
400491
400618
  this.discoveryIdentity = null;
400492
400619
  this.retainedDiscoveryItems = new Map;
400493
400620
  this.residentProjectionViews = new WeakMap;
@@ -400551,12 +400678,21 @@ class V2TrackedChangesAdapter {
400551
400678
  readReviewProjectionIdentity() {
400552
400679
  return readSDDocumentSessionInternalCurrentTrackedChangeLogicalCatalog(this.context.session, resolveReplacementMode(this.context.trackedChangesReplacementMode))?.reviewProjectionIdentity ?? null;
400553
400680
  }
400681
+ readReviewSnapshotWork(reset = false) {
400682
+ const work = { ...this.reviewSnapshotWork };
400683
+ if (reset)
400684
+ for (const counter of Object.keys(this.reviewSnapshotWork))
400685
+ this.reviewSnapshotWork[counter] = 0;
400686
+ return work;
400687
+ }
400554
400688
  readLeanDiscoveryItemsForReviewSnapshotBatch(requests) {
400555
400689
  const residentViews = new Map;
400556
400690
  const discoveryItems = new Map;
400557
400691
  const frame = { validatedCache: null, readLimit: Math.min(128, Math.max(32, requests.length * 2)) };
400692
+ this.readReviewSnapshotWork(true);
400558
400693
  const allIds = [...new Set(requests.flatMap((request) => [...request.requestedIds]))];
400559
400694
  if (readSDDocumentSessionInternalCurrentTrackedChangeLogicalCatalog(this.context.session, resolveReplacementMode(this.context.trackedChangesReplacementMode))) {
400695
+ this.reviewSnapshotWork.fullViewReads += 1;
400560
400696
  const current = this.buildView();
400561
400697
  for (const id of allIds)
400562
400698
  residentViews.set(id, current);
@@ -400674,6 +400810,13 @@ class V2TrackedChangesAdapter {
400674
400810
  requestedByAlias.set(alias, requested);
400675
400811
  }
400676
400812
  let fullView;
400813
+ const readFullView = () => {
400814
+ if (!fullView) {
400815
+ this.reviewSnapshotWork.fullViewReads += 1;
400816
+ fullView = this.buildView();
400817
+ }
400818
+ return fullView;
400819
+ };
400677
400820
  const storyFilter = story ? resolveStoryFilter(story, this.context.session) : undefined;
400678
400821
  const structuralScope = source?.structuralOwner ? resolveReviewSnapshotStructuralScope(this.context, source, storyFilter) : undefined;
400679
400822
  const paragraphScope2 = source?.paragraphOwner ? resolveReviewSnapshotParagraphScope(this.context, source, storyFilter) : undefined;
@@ -400717,6 +400860,7 @@ class V2TrackedChangesAdapter {
400717
400860
  orderedRequestedIds.push(id);
400718
400861
  let view = residentViews.get(id) ?? fullView;
400719
400862
  if (!view) {
400863
+ this.reviewSnapshotWork.residentReads += 1;
400720
400864
  const resident = this.readResidentProjectionView([reviewSnapshotMoveSideId(id)?.id ?? id]);
400721
400865
  if (resident) {
400722
400866
  view = resident;
@@ -400739,12 +400883,12 @@ class V2TrackedChangesAdapter {
400739
400883
  residentViews.set(requested, resident);
400740
400884
  }
400741
400885
  } else
400742
- view = fullView ?? (fullView = this.buildView());
400886
+ view = readFullView();
400743
400887
  }
400744
400888
  const localEntry = reviewSnapshotMoveSideId(id) ? null : getLocalTrackedTextEntry(this.context, id);
400745
400889
  let entry = localEntry && (!storyFilter || logicalEntryMatchesStoryFilter(localEntry, storyFilter)) && reviewSnapshotEntryMatchesSource(localEntry, sourceFilter, id) ? localEntry : resolve2(view, id);
400746
400890
  if (!entry && view !== fullView && [...view.logical.byId.values()].every((candidate2) => source?.partUri && candidate2.partUri !== source.partUri || storyFilter && !logicalEntryMatchesStoryFilter(candidate2, storyFilter))) {
400747
- view = fullView ?? (fullView = this.buildView());
400891
+ view = readFullView();
400748
400892
  entry = resolve2(view, id);
400749
400893
  }
400750
400894
  if (!entry) {
@@ -400767,11 +400911,13 @@ class V2TrackedChangesAdapter {
400767
400911
  }
400768
400912
  let item = itemsByEntry.get(entry) ?? (identity ? this.retainedDiscoveryItems.get(entry.id) : undefined);
400769
400913
  if (!item) {
400914
+ this.reviewSnapshotWork.discoveryItemBuilds += 1;
400770
400915
  item = buildDiscoveryItem2(entry, this.context, view.logical, undefined, resolveSession);
400771
400916
  itemsByEntry.set(entry, item);
400772
400917
  if (identity)
400773
400918
  this.retainedDiscoveryItems.set(entry.id, item);
400774
- }
400919
+ } else if (!itemsByEntry.has(entry))
400920
+ this.reviewSnapshotWork.discoveryItemReuses += 1;
400775
400921
  reviewSnapshotOrder.set(item, { storyId: entry.storyId, start: entry.documentOrderStart });
400776
400922
  items.push(item);
400777
400923
  }
@@ -414382,6 +414528,32 @@ function projectionDiagnostic(input) {
414382
414528
  function sortProjectionDiagnostics(diagnostics) {
414383
414529
  return [...diagnostics].sort((left, right) => diagnosticKey(left).localeCompare(diagnosticKey(right)));
414384
414530
  }
414531
+ function createProjectionDiagnosticLookup(diagnostics) {
414532
+ const codes2 = new Map;
414533
+ let indexedThrough = 0;
414534
+ return (diagnostic2) => {
414535
+ while (indexedThrough < diagnostics.length) {
414536
+ const candidate2 = diagnostics[indexedThrough++];
414537
+ const { blockId: blockId2, range: range2 } = candidate2.source;
414538
+ if (Number.isNaN(range2?.start) || Number.isNaN(range2?.end))
414539
+ continue;
414540
+ let blocks = codes2.get(candidate2.code);
414541
+ if (!blocks)
414542
+ codes2.set(candidate2.code, blocks = new Map);
414543
+ let starts = blocks.get(blockId2);
414544
+ if (!starts)
414545
+ blocks.set(blockId2, starts = new Map);
414546
+ let ends = starts.get(range2?.start);
414547
+ if (!ends)
414548
+ starts.set(range2?.start, ends = new Set);
414549
+ ends.add(range2?.end);
414550
+ }
414551
+ const { blockId, range } = diagnostic2.source;
414552
+ if (Number.isNaN(range?.start) || Number.isNaN(range?.end))
414553
+ return false;
414554
+ return codes2.get(diagnostic2.code)?.get(blockId)?.get(range?.start)?.has(range?.end) ?? false;
414555
+ };
414556
+ }
414385
414557
  async function sortProjectionDiagnosticsCooperatively(diagnostics, sliceGate) {
414386
414558
  let source = [];
414387
414559
  for (const diagnostic2 of diagnostics) {
@@ -415496,6 +415668,7 @@ function prepareProjectionBuild(context, input, supplied) {
415496
415668
  imageNamespaces: projectionStoryRootNamespaceBindings(context, resolved),
415497
415669
  imageTargets: supplied?.imageTargets ?? sourceExternalTargets(projectionPartBytes(context, ownerRelationshipsPartUri(resolved.partUri)), "image"),
415498
415670
  diagnostics,
415671
+ hasDiagnostic: createProjectionDiagnosticLookup(diagnostics),
415499
415672
  visibleToTracked,
415500
415673
  paragraphTrackedRanges: new Map,
415501
415674
  progress: { storyTrackedCursor: 0 },
@@ -415561,7 +415734,8 @@ function visitProjectionParagraph(state, paragraph4) {
415561
415734
  styleModel,
415562
415735
  resolvedParagraphProperties,
415563
415736
  tableInfo,
415564
- diagnostics
415737
+ diagnostics,
415738
+ hasDiagnostic: state.hasDiagnostic
415565
415739
  }));
415566
415740
  const bookmarks = standaloneHorizontalRule ? [] : tokenRead.bookmarks.filter((bookmark) => trackedWrappersAreEmitted(bookmark.trackedWrappers, reviewMode)).map((bookmark) => ({ name: bookmark.name, offset: bookmark.offset }));
415567
415741
  const blockDiagnostics = [];
@@ -417066,7 +417240,7 @@ function projectToken(input) {
417066
417240
  changeIds,
417067
417241
  commentIds
417068
417242
  });
417069
- if (!input.diagnostics.some((candidate2) => candidate2.code === diagnostic2.code && candidate2.source.blockId === diagnostic2.source.blockId && candidate2.source.range?.start === diagnostic2.source.range?.start && candidate2.source.range?.end === diagnostic2.source.range?.end))
417243
+ if (!input.hasDiagnostic(diagnostic2))
417070
417244
  input.diagnostics.push(diagnostic2);
417071
417245
  }
417072
417246
  const referenceField = hyperlink && "classification" in hyperlink.descriptor && (hyperlink.descriptor.classification === "ref" || hyperlink.descriptor.classification === "pageRef");
@@ -421777,7 +421951,7 @@ function provePlainBlockHasNoHyperlink(context, query3) {
421777
421951
  return null;
421778
421952
  }
421779
421953
  const prefix2 = bytes.subarray(0, paragraph4.byteStart);
421780
- if (!bytesContainAsciiToken(prefix2, FLD_CHAR_TOKEN)) {
421954
+ if (!bytesContainAsciiToken(prefix2, ONLY_TOKEN_THAT_CAN_OPEN_A_FIELD_ACROSS_PARAGRAPHS)) {
421781
421955
  return { storyId: body.storyId, partUri: body.partUri };
421782
421956
  }
421783
421957
  const prefixXml = TD114.decode(prefix2);
@@ -422195,7 +422369,7 @@ function escapeRegex13(value3) {
422195
422369
  function defaultRelationshipsXml2() {
422196
422370
  return '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
422197
422371
  }
422198
- var HYPERLINK_REL_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", TD114, TE65, FLD_CHAR_TOKEN;
422372
+ var HYPERLINK_REL_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", TD114, TE65, ONLY_TOKEN_THAT_CAN_OPEN_A_FIELD_ACROSS_PARAGRAPHS;
422199
422373
  var init_adapter21 = __esm(() => {
422200
422374
  init_applied_change_mode();
422201
422375
  init_sd_document_session_internal();
@@ -422213,7 +422387,7 @@ var init_adapter21 = __esm(() => {
422213
422387
  init_registry3();
422214
422388
  TD114 = new TextDecoder;
422215
422389
  TE65 = new TextEncoder;
422216
- FLD_CHAR_TOKEN = Uint8Array.from("fldChar", (char) => char.charCodeAt(0));
422390
+ ONLY_TOKEN_THAT_CAN_OPEN_A_FIELD_ACROSS_PARAGRAPHS = Uint8Array.from("fldChar", (char) => char.charCodeAt(0));
422217
422391
  });
422218
422392
 
422219
422393
  // ../../../v2/document-api-v2-adapter/dist/images/pending-image-insertion.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.10.1-next.2",
3
+ "version": "1.10.1-next.4",
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.23.1-next.2",
27
+ "@superdoc/sdk": "2.23.1-next.4",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.26.1-next.2",
33
- "@superdoc/docx-engine": "0.25.1-next.2",
32
+ "superdoc": "2.26.1-next.4",
33
+ "@superdoc/docx-engine": "0.25.1-next.4",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",