@superdoc/mcp 1.10.0-next.6 → 1.10.0-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.
- package/dist/index.js +175 -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.0-next.
|
|
31633
|
+
var SDK_VERSION = "2.23.0-next.7";
|
|
31634
31634
|
|
|
31635
31635
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31636
31636
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -485234,6 +485234,7 @@ function materializeProjectionInternal(input, recovery) {
|
|
|
485234
485234
|
storyId: storyIdHint,
|
|
485235
485235
|
partUri: partUriHint,
|
|
485236
485236
|
sourceXmlByteAligned,
|
|
485237
|
+
nativeControlBoundaries: controlledSnapshot != null,
|
|
485237
485238
|
tableReplacements: tableReplacements.filter((replacement2) => replacement2.xml !== "" || replacement2.tableBlockIds.length > 0 || findCurrentTableSpanFromTableNodeId(base3.xml, replacement2.tableNodeId) != null).map((replacement2) => ({ ...replacement2, creationPlacement: undefined }))
|
|
485238
485239
|
}) ?? base3;
|
|
485239
485240
|
stories.push(projected2);
|
|
@@ -486917,12 +486918,14 @@ function composeTableStructuralProjection(input) {
|
|
|
486917
486918
|
if (replacement2.creationPlacement && !previousOverlay) {
|
|
486918
486919
|
resolvedCreations.push({ replacement: replacement2, span });
|
|
486919
486920
|
}
|
|
486921
|
+
const inherited = baseNamespaces.at(span.start);
|
|
486922
|
+
const tableXml = input.nativeControlBoundaries && !replacement2.creationPlacement && !replacement2.relocation && !replacement2.rowReordered && replacement2.splitChildren.length === 0 ? composeControlledTableBoundaries(baseXml.slice(span.start, span.end), replacement2.xml, replacement2.tableNodeId, replacement2.tableBlockIds, storyBlocks, inherited) ?? replacement2.xml : replacement2.xml;
|
|
486920
486923
|
const projected2 = {
|
|
486921
486924
|
tableNodeId: replacement2.tableNodeId,
|
|
486922
486925
|
lastPreparedTxId: replacement2.lastPreparedTxId,
|
|
486923
486926
|
start: span.start,
|
|
486924
486927
|
end: span.end,
|
|
486925
|
-
xml: replacement2.splitSourceTableNodeId && replacement2.tableBlockIds.length === 0 ? "" : replacement2.creationPlacement && storyBlocks.some((block) => block.structuralRefs.tableNodeId === replacement2.tableNodeId) ? composeCreatedTableBlockXml(replacement2.xml, replacement2.tableNodeId, storyBlocks, replacement2.columnInsertions, replacement2.rowProperties, replacement2.cellProperties, replacement2.gridChangeXml, baseNamespaces.at(span.start)) : composeLiveTableBlockXml(
|
|
486928
|
+
xml: replacement2.splitSourceTableNodeId && replacement2.tableBlockIds.length === 0 ? "" : replacement2.creationPlacement && storyBlocks.some((block) => block.structuralRefs.tableNodeId === replacement2.tableNodeId) ? composeCreatedTableBlockXml(replacement2.xml, replacement2.tableNodeId, storyBlocks, replacement2.columnInsertions, replacement2.rowProperties, replacement2.cellProperties, replacement2.gridChangeXml, baseNamespaces.at(span.start)) : composeLiveTableBlockXml(tableXml, replacement2.tableNodeId, replacement2.tableBlockIds, storyBlocks, replacement2.rowInsertions, replacement2.columnInsertions, replacement2.rowProperties, replacement2.cellProperties, replacement2.gridChangeXml, inherited),
|
|
486926
486929
|
affectedBlockIds: replacement2.tableBlockIds,
|
|
486927
486930
|
suppressOverlay: false
|
|
486928
486931
|
};
|
|
@@ -487585,6 +487588,176 @@ function nestedTableParagraphIds(tableXml, inherited) {
|
|
|
487585
487588
|
return null;
|
|
487586
487589
|
return [...new Set(native4.filter((range) => range.tag.localName === "p").flatMap((range) => range.tag.attributes.filter((attribute3) => attribute3.localName === "paraId" && attribute3.namespaceUri === "http://schemas.microsoft.com/office/word/2010/wordml").map((attribute3) => attribute3.value)))];
|
|
487587
487590
|
}
|
|
487591
|
+
function composeControlledTableBoundaries(nativeXml, overlayXml, tableNodeId, overlayBlockIds, storyBlocks, inherited) {
|
|
487592
|
+
const blocks = new Map(storyBlocks.filter((block) => block.structuralRefs.tableNodeId === tableNodeId).map((block) => [block.blockId, block]));
|
|
487593
|
+
if (blocks.size === 0)
|
|
487594
|
+
return null;
|
|
487595
|
+
const retainedIds = new Set(overlayBlockIds);
|
|
487596
|
+
const inspect = (xml, native5) => {
|
|
487597
|
+
const parsed = collectXmlElementRanges(xml, { fragment: true, additionalNamespaces: inherited });
|
|
487598
|
+
const ranges = parsed.ranges.filter((range) => range.tag.namespaceUri === WORD_NAMESPACE10).sort((left, right) => left.start - right.start || right.end - left.end);
|
|
487599
|
+
const table = ranges.find((range) => range.tag.localName === "tbl");
|
|
487600
|
+
if (parsed.errors.length || !table || table.start !== 0 || table.end !== xml.length)
|
|
487601
|
+
return null;
|
|
487602
|
+
const nestedTables = ranges.filter((range) => range.tag.localName === "tbl" && range !== table);
|
|
487603
|
+
const outerRanges = ranges.filter((range) => !nestedTables.some((nested) => range.start >= nested.start && range.end <= nested.end));
|
|
487604
|
+
const allParagraphs = ranges.filter((range) => range.tag.localName === "p");
|
|
487605
|
+
const paragraphId5 = (paragraph4) => paragraph4.tag.attributes.find((attribute3) => attribute3.localName === "paraId" && attribute3.namespaceUri === WORD_2010_NAMESPACE3)?.value ?? null;
|
|
487606
|
+
const paragraphs2 = outerRanges.filter((range) => range.tag.localName === "p");
|
|
487607
|
+
const seen = new Set;
|
|
487608
|
+
const seenParagraphs = new Set;
|
|
487609
|
+
for (const paragraph4 of allParagraphs) {
|
|
487610
|
+
const id2 = paragraphId5(paragraph4);
|
|
487611
|
+
if (id2 && seenParagraphs.has(id2))
|
|
487612
|
+
return null;
|
|
487613
|
+
if (id2)
|
|
487614
|
+
seenParagraphs.add(id2);
|
|
487615
|
+
}
|
|
487616
|
+
const ownedParagraphs = new Set;
|
|
487617
|
+
const seenRows = new Set, seenCells = new Set;
|
|
487618
|
+
const owners3 = [];
|
|
487619
|
+
const rowProperties = new Map;
|
|
487620
|
+
const cellProperties = new Map;
|
|
487621
|
+
const opaqueCells = [];
|
|
487622
|
+
const opaqueRows = [];
|
|
487623
|
+
const removed = [];
|
|
487624
|
+
for (const row of tableRowSpans(xml, inherited)) {
|
|
487625
|
+
const cells = outerRanges.filter((range) => range.tag.localName === "tc" && range.start > row.start && range.end < row.end);
|
|
487626
|
+
const rowOwners = [];
|
|
487627
|
+
let rowId = null;
|
|
487628
|
+
for (const cell of cells) {
|
|
487629
|
+
if (nestedTables.some((nested) => nested.start > cell.start && nested.end < cell.end)) {
|
|
487630
|
+
if (allParagraphs.some((paragraph4) => paragraph4.start > cell.start && paragraph4.end < cell.end && blocks.has(paragraphId5(paragraph4) ?? "")))
|
|
487631
|
+
return null;
|
|
487632
|
+
opaqueCells.push(cell);
|
|
487633
|
+
rowOwners.push(null);
|
|
487634
|
+
continue;
|
|
487635
|
+
}
|
|
487636
|
+
const members = paragraphs2.filter((paragraph4) => paragraph4.start > cell.start && paragraph4.end < cell.end);
|
|
487637
|
+
const ids = members.map(paragraphId5);
|
|
487638
|
+
if (ids.some((id2) => !id2 || !native5 && !retainedIds.has(id2)))
|
|
487639
|
+
return null;
|
|
487640
|
+
for (const paragraph4 of members) {
|
|
487641
|
+
if (ownedParagraphs.has(paragraph4.start))
|
|
487642
|
+
return null;
|
|
487643
|
+
ownedParagraphs.add(paragraph4.start);
|
|
487644
|
+
removed.push(paragraph4);
|
|
487645
|
+
}
|
|
487646
|
+
const live = ids.flatMap((id2) => id2 && blocks.has(id2) ? [blocks.get(id2)] : []);
|
|
487647
|
+
const first = live[0]?.structuralRefs;
|
|
487648
|
+
if (!first?.rowNodeId || !first.cellNodeId || rowId && rowId !== first.rowNodeId || native5 && live.length !== members.length || new Set(live.map((block) => block.blockId)).size !== live.length || live.some((block) => block.structuralRefs.rowNodeId !== first.rowNodeId || block.structuralRefs.cellNodeId !== first.cellNodeId || seen.has(block.blockId)))
|
|
487649
|
+
return null;
|
|
487650
|
+
for (const block of live)
|
|
487651
|
+
seen.add(block.blockId);
|
|
487652
|
+
if (seenCells.has(first.cellNodeId))
|
|
487653
|
+
return null;
|
|
487654
|
+
seenCells.add(first.cellNodeId);
|
|
487655
|
+
rowId = first.rowNodeId;
|
|
487656
|
+
rowOwners.push(first.cellNodeId);
|
|
487657
|
+
cellProperties.set(first.cellNodeId, readDirectChildPropertyXml2(xml.slice(cell.start, cell.end), "tc", "tcPr"));
|
|
487658
|
+
}
|
|
487659
|
+
if (cells.length === 0 || rowId && seenRows.has(rowId))
|
|
487660
|
+
return null;
|
|
487661
|
+
if (rowId)
|
|
487662
|
+
seenRows.add(rowId);
|
|
487663
|
+
else
|
|
487664
|
+
opaqueRows.push(row);
|
|
487665
|
+
owners3.push([rowId, ...rowOwners]);
|
|
487666
|
+
if (rowId)
|
|
487667
|
+
rowProperties.set(rowId, readDirectChildPropertyXml2(xml.slice(row.start, row.end), "tr", "trPr"));
|
|
487668
|
+
}
|
|
487669
|
+
if (owners3.length === 0 || native5 && (seen.size !== blocks.size || [...blocks.keys()].some((id2) => !seen.has(id2))))
|
|
487670
|
+
return null;
|
|
487671
|
+
if (nestedTables.some((nested) => !opaqueCells.some((cell) => nested.start > cell.start && nested.end < cell.end)))
|
|
487672
|
+
return null;
|
|
487673
|
+
if (paragraphs2.some((paragraph4) => !ownedParagraphs.has(paragraph4.start) && !opaqueCells.some((cell) => paragraph4.start > cell.start && paragraph4.end < cell.end)))
|
|
487674
|
+
return null;
|
|
487675
|
+
const opaqueParagraphs = allParagraphs.filter((paragraph4) => opaqueCells.some((cell) => paragraph4.start > cell.start && paragraph4.end < cell.end));
|
|
487676
|
+
removed.push(...redundantOpaqueParagraphSpaceSpans(xml, opaqueParagraphs, parsed.ranges, inherited));
|
|
487677
|
+
for (const range of ranges) {
|
|
487678
|
+
if (opaqueCells.some((cell) => range.start >= cell.start && range.end <= cell.end) || opaqueRows.some((row) => range.start >= row.start && range.end <= row.end))
|
|
487679
|
+
continue;
|
|
487680
|
+
if (paragraphs2.some((paragraph4) => range.start >= paragraph4.start && range.end <= paragraph4.end))
|
|
487681
|
+
continue;
|
|
487682
|
+
if (["tblPr", "tblGrid", "trPr", "tcPr"].includes(range.tag.localName))
|
|
487683
|
+
removed.push(range);
|
|
487684
|
+
if (range.tag.localName === "sdt") {
|
|
487685
|
+
if (opaqueCells.some((cell) => range.start < cell.start && range.end > cell.end))
|
|
487686
|
+
continue;
|
|
487687
|
+
const contents = directElementSpans(xml, range.openEnd, range.closeStart, "sdtContent");
|
|
487688
|
+
const content3 = ranges.find((child) => child.tag.localName === "sdtContent" && child.start === contents[0]?.start);
|
|
487689
|
+
if (contents.length !== 1 || !content3)
|
|
487690
|
+
return null;
|
|
487691
|
+
removed.push({ start: range.start, end: content3.openEnd }, { start: content3.closeStart, end: range.end });
|
|
487692
|
+
}
|
|
487693
|
+
}
|
|
487694
|
+
let skeleton = "", cursor = 0;
|
|
487695
|
+
for (const span of removed.sort((left, right) => left.start - right.start || right.end - left.end)) {
|
|
487696
|
+
if (span.start < cursor)
|
|
487697
|
+
continue;
|
|
487698
|
+
skeleton += xml.slice(cursor, span.start);
|
|
487699
|
+
cursor = span.end;
|
|
487700
|
+
}
|
|
487701
|
+
return { skeleton: skeleton + xml.slice(cursor), owners: owners3, rowProperties, cellProperties };
|
|
487702
|
+
};
|
|
487703
|
+
const native4 = inspect(nativeXml, true), overlay = inspect(overlayXml, false);
|
|
487704
|
+
if (!native4 || !overlay || native4.skeleton !== overlay.skeleton || JSON.stringify(native4.owners) !== JSON.stringify(overlay.owners))
|
|
487705
|
+
return null;
|
|
487706
|
+
let composed = replaceLiveTableStructuralProperties(nativeXml, [...blocks.values()], overlay.rowProperties, overlay.cellProperties, inherited);
|
|
487707
|
+
composed = replaceDirectChildPropertyPrefix(composed, "tblGrid", readDirectChildPropertyXml2(overlayXml, "tbl", "tblGrid"));
|
|
487708
|
+
composed = replaceDirectChildPropertyPrefix(composed, "tblPr", readDirectChildPropertyXml2(overlayXml, "tbl", "tblPr"));
|
|
487709
|
+
return collectXmlElementRanges(composed, { fragment: true, additionalNamespaces: inherited }).errors.length ? null : composed;
|
|
487710
|
+
}
|
|
487711
|
+
function redundantOpaqueParagraphSpaceSpans(xml, paragraphs2, ranges, inherited) {
|
|
487712
|
+
const xmlNamespace = "http://www.w3.org/XML/1998/namespace";
|
|
487713
|
+
const isSpace = (attribute3) => attribute3.namespaceUri === xmlNamespace && attribute3.localName === "space";
|
|
487714
|
+
const removed = [];
|
|
487715
|
+
for (const range of ranges) {
|
|
487716
|
+
const space = range.tag.attributes.find(isSpace);
|
|
487717
|
+
if (range.tag.namespaceUri !== WORD_NAMESPACE10 || range.tag.localName !== "t" || space?.value !== "preserve" || !paragraphs2.some((paragraph4) => range.start > paragraph4.start && range.end < paragraph4.end) || ranges.some((ancestor) => ancestor.start < range.start && ancestor.end > range.end && ancestor.tag.attributes.some(isSpace)) || xml.slice(range.openEnd, range.closeStart).includes("<"))
|
|
487718
|
+
continue;
|
|
487719
|
+
let text4 = "";
|
|
487720
|
+
const decoded = walkXmlElements(xml.slice(range.start, range.end), {
|
|
487721
|
+
fragment: true,
|
|
487722
|
+
additionalNamespaces: { ...inherited, ...range.namespaceBindings },
|
|
487723
|
+
onText: (value3) => {
|
|
487724
|
+
text4 += value3;
|
|
487725
|
+
}
|
|
487726
|
+
});
|
|
487727
|
+
if (decoded.errors.length || !/^[^\s]+(?: [^\s]+)*$/u.test(text4))
|
|
487728
|
+
continue;
|
|
487729
|
+
let cursor = range.start + 1 + range.tag.name.length;
|
|
487730
|
+
while (cursor < range.openEnd) {
|
|
487731
|
+
const start = cursor;
|
|
487732
|
+
while (/[\x20\t\r\n]/.test(xml[cursor] ?? ""))
|
|
487733
|
+
cursor++;
|
|
487734
|
+
if (xml[cursor] === ">" || xml[cursor] === "/")
|
|
487735
|
+
break;
|
|
487736
|
+
const nameStart = cursor;
|
|
487737
|
+
while (cursor < range.openEnd && !/[\x20\t\r\n=]/.test(xml[cursor]))
|
|
487738
|
+
cursor++;
|
|
487739
|
+
const name = xml.slice(nameStart, cursor);
|
|
487740
|
+
while (/[\x20\t\r\n]/.test(xml[cursor] ?? ""))
|
|
487741
|
+
cursor++;
|
|
487742
|
+
if (xml[cursor++] !== "=")
|
|
487743
|
+
break;
|
|
487744
|
+
while (/[\x20\t\r\n]/.test(xml[cursor] ?? ""))
|
|
487745
|
+
cursor++;
|
|
487746
|
+
const quote2 = xml[cursor++];
|
|
487747
|
+
if (quote2 !== '"' && quote2 !== "'")
|
|
487748
|
+
break;
|
|
487749
|
+
const close = xml.indexOf(quote2, cursor);
|
|
487750
|
+
if (close < 0 || close >= range.openEnd)
|
|
487751
|
+
break;
|
|
487752
|
+
cursor = close + 1;
|
|
487753
|
+
if (name === space.name) {
|
|
487754
|
+
removed.push({ start, end: cursor });
|
|
487755
|
+
break;
|
|
487756
|
+
}
|
|
487757
|
+
}
|
|
487758
|
+
}
|
|
487759
|
+
return removed;
|
|
487760
|
+
}
|
|
487588
487761
|
function composeLiveTableBlockXml(tableXml, tableNodeId, tableBlockIds, storyBlocks, rowInsertions, columnInsertions, rowProperties, cellProperties, gridChangeXml, inherited) {
|
|
487589
487762
|
const nestedParagraphIds = nestedTableParagraphIds(tableXml, inherited);
|
|
487590
487763
|
const liveTableBlocks = storyBlocks.filter((block) => block.structuralRefs.tableNodeId === tableNodeId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.10.0-next.
|
|
3
|
+
"version": "1.10.0-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.23.0-next.
|
|
27
|
+
"@superdoc/sdk": "2.23.0-next.7",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.26.0-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.25.0-next.
|
|
32
|
+
"superdoc": "2.26.0-next.8",
|
|
33
|
+
"@superdoc/docx-engine": "0.25.0-next.8",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|