@superdoc/mcp 1.10.0-next.3 → 1.10.0-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.
- package/dist/index.js +476 -382
- 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.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";
|
|
@@ -473028,6 +473028,347 @@ var init_seed = __esm(() => {
|
|
|
473028
473028
|
init_parse_paragraph();
|
|
473029
473029
|
});
|
|
473030
473030
|
|
|
473031
|
+
// ../../../v2/collaboration-v2/dist/story-shard/paragraph-namespace-bindings.js
|
|
473032
|
+
function createParagraphNamespaceBindingResolver(bytes, rootBindings) {
|
|
473033
|
+
let bindingsByByteStart = null;
|
|
473034
|
+
let namespaceDeclarationCounts = null;
|
|
473035
|
+
return (paragraph4) => {
|
|
473036
|
+
const paragraphPrefix = paragraphElementPrefix(paragraph4.xml);
|
|
473037
|
+
const prefixes = paragraphRsidPrefixes(paragraph4.xml).filter((prefix2) => prefix2 !== paragraphPrefix && !hasLocalBinding(paragraph4.xml, prefix2));
|
|
473038
|
+
if (prefixes.length === 0)
|
|
473039
|
+
return rootBindings;
|
|
473040
|
+
for (const prefix2 of prefixes) {
|
|
473041
|
+
const resolvedAtRoot = Object.prototype.hasOwnProperty.call(rootBindings, prefix2);
|
|
473042
|
+
if (!resolvedAtRoot) {
|
|
473043
|
+
bindingsByByteStart ?? (bindingsByByteStart = readParagraphNamespaceBindings(bytes));
|
|
473044
|
+
return bindingsByByteStart.get(paragraph4.byteStart) ?? rootBindings;
|
|
473045
|
+
}
|
|
473046
|
+
namespaceDeclarationCounts ?? (namespaceDeclarationCounts = countNamespaceDeclarations(bytes));
|
|
473047
|
+
if ((namespaceDeclarationCounts.get(prefix2) ?? 0) > 1) {
|
|
473048
|
+
bindingsByByteStart ?? (bindingsByByteStart = readParagraphNamespaceBindings(bytes));
|
|
473049
|
+
return bindingsByByteStart.get(paragraph4.byteStart) ?? rootBindings;
|
|
473050
|
+
}
|
|
473051
|
+
}
|
|
473052
|
+
return rootBindings;
|
|
473053
|
+
};
|
|
473054
|
+
}
|
|
473055
|
+
function readParagraphNamespaceBindings(bytes) {
|
|
473056
|
+
const xml = TEXT_DECODER8.decode(bytes);
|
|
473057
|
+
const paragraphs2 = scanWmlParagraphSpans(xml).paragraphs;
|
|
473058
|
+
const bindingsByByteStart = new Map;
|
|
473059
|
+
let charCursor = 0;
|
|
473060
|
+
let byteCursor = leadingBomLength(bytes);
|
|
473061
|
+
for (const paragraph4 of paragraphs2) {
|
|
473062
|
+
byteCursor += TEXT_ENCODER5.encode(xml.slice(charCursor, paragraph4.openStart)).byteLength;
|
|
473063
|
+
bindingsByByteStart.set(byteCursor, paragraph4.namespaceBindings);
|
|
473064
|
+
charCursor = paragraph4.openStart;
|
|
473065
|
+
}
|
|
473066
|
+
return bindingsByByteStart;
|
|
473067
|
+
}
|
|
473068
|
+
function paragraphRsidPrefixes(xml) {
|
|
473069
|
+
const openTag = xml.slice(0, xml.indexOf(">") + 1);
|
|
473070
|
+
return [...openTag.matchAll(/(?:^|\s)(?!xmlns:)([\w.-]+):rsidR\s*=/g)].map((match) => match[1]);
|
|
473071
|
+
}
|
|
473072
|
+
function paragraphElementPrefix(xml) {
|
|
473073
|
+
const qname = /^<([^\s/>]+)/.exec(xml)?.[1];
|
|
473074
|
+
if (!qname)
|
|
473075
|
+
return null;
|
|
473076
|
+
const colon = qname.indexOf(":");
|
|
473077
|
+
return colon < 0 ? "" : qname.slice(0, colon);
|
|
473078
|
+
}
|
|
473079
|
+
function hasLocalBinding(xml, prefix2) {
|
|
473080
|
+
const openTag = xml.slice(0, xml.indexOf(">") + 1);
|
|
473081
|
+
return new RegExp(String.raw`\bxmlns:${escapeRegex16(prefix2)}\s*=`).test(openTag);
|
|
473082
|
+
}
|
|
473083
|
+
function countNamespaceDeclarations(bytes) {
|
|
473084
|
+
const counts = new Map;
|
|
473085
|
+
const xml = TEXT_DECODER8.decode(bytes);
|
|
473086
|
+
const declaration = /\bxmlns:([\w.-]+)\s*=/g;
|
|
473087
|
+
let match;
|
|
473088
|
+
while (match = declaration.exec(xml)) {
|
|
473089
|
+
const prefix2 = match[1];
|
|
473090
|
+
counts.set(prefix2, (counts.get(prefix2) ?? 0) + 1);
|
|
473091
|
+
}
|
|
473092
|
+
return counts;
|
|
473093
|
+
}
|
|
473094
|
+
function escapeRegex16(value3) {
|
|
473095
|
+
return value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
473096
|
+
}
|
|
473097
|
+
function leadingBomLength(bytes) {
|
|
473098
|
+
return bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
473099
|
+
}
|
|
473100
|
+
var TEXT_DECODER8, TEXT_ENCODER5;
|
|
473101
|
+
var init_paragraph_namespace_bindings = __esm(() => {
|
|
473102
|
+
init_sd_document_session_internal();
|
|
473103
|
+
TEXT_DECODER8 = new TextDecoder("utf-8", { fatal: false });
|
|
473104
|
+
TEXT_ENCODER5 = new TextEncoder;
|
|
473105
|
+
});
|
|
473106
|
+
|
|
473107
|
+
// ../../../v2/collaboration-v2/dist/story-shard/table-structural-refs.js
|
|
473108
|
+
function buildParagraphTableRefsFromBytes(input) {
|
|
473109
|
+
if (input.paragraphs.length === 0)
|
|
473110
|
+
return new Map;
|
|
473111
|
+
const catalog = buildTableCatalog({
|
|
473112
|
+
bytes: input.bytes,
|
|
473113
|
+
storyId: input.storyId
|
|
473114
|
+
});
|
|
473115
|
+
return buildParagraphTableRefsFromCatalog({
|
|
473116
|
+
catalog,
|
|
473117
|
+
paragraphs: input.paragraphs
|
|
473118
|
+
});
|
|
473119
|
+
}
|
|
473120
|
+
function buildParagraphTableRefsFromCatalog(input) {
|
|
473121
|
+
const refsByBlockId = new Map;
|
|
473122
|
+
if (!input.catalog || input.paragraphs.length === 0)
|
|
473123
|
+
return refsByBlockId;
|
|
473124
|
+
for (const table of input.catalog.tables) {
|
|
473125
|
+
for (const row of table.rows) {
|
|
473126
|
+
for (const cell of row.cells) {
|
|
473127
|
+
if (cell.containsNestedTable)
|
|
473128
|
+
continue;
|
|
473129
|
+
for (const paragraph4 of input.paragraphs) {
|
|
473130
|
+
if (refsByBlockId.has(paragraph4.blockId))
|
|
473131
|
+
continue;
|
|
473132
|
+
if (paragraph4.byteStart < cell.bodyByteStart || paragraph4.byteEnd > cell.bodyByteEnd)
|
|
473133
|
+
continue;
|
|
473134
|
+
refsByBlockId.set(paragraph4.blockId, {
|
|
473135
|
+
tableNodeId: table.tableNodeId,
|
|
473136
|
+
rowNodeId: row.rowNodeId,
|
|
473137
|
+
cellNodeId: cell.cellNodeId
|
|
473138
|
+
});
|
|
473139
|
+
}
|
|
473140
|
+
}
|
|
473141
|
+
}
|
|
473142
|
+
}
|
|
473143
|
+
return refsByBlockId;
|
|
473144
|
+
}
|
|
473145
|
+
var init_table_structural_refs = __esm(() => {
|
|
473146
|
+
init_sd_document_session_internal();
|
|
473147
|
+
});
|
|
473148
|
+
|
|
473149
|
+
// ../../../v2/collaboration-v2/dist/setup/story-paragraph-seed.js
|
|
473150
|
+
function storySeedForSource(input) {
|
|
473151
|
+
const canonical = scanWmlParagraphSeedSpans(input.bytes);
|
|
473152
|
+
const shared = scanParagraphXmlSpans({ bytes: input.bytes });
|
|
473153
|
+
const rawParagraphs = canonical.length > 0 ? canonical : shared.length > 0 ? shared.map((span) => ({
|
|
473154
|
+
xml: span.xml,
|
|
473155
|
+
byteStart: span.byteStart,
|
|
473156
|
+
byteEnd: span.byteEnd,
|
|
473157
|
+
ordinal: span.ordinal,
|
|
473158
|
+
paraId: span.paraId,
|
|
473159
|
+
blockId: blockIdForParagraphXmlSpan(span)
|
|
473160
|
+
})) : scanParagraphXmlSpansLocal(input.bytes, input.storyKind);
|
|
473161
|
+
const window2 = resolveStoryContentWindow(input.bytes, input.storyKind, rawParagraphs);
|
|
473162
|
+
const rootNamespaceBindings = readRootNamespaceBindingsFromBytes(input.bytes);
|
|
473163
|
+
const resolveNamespaceBindings = createParagraphNamespaceBindingResolver(input.bytes, rootNamespaceBindings);
|
|
473164
|
+
const paragraphs2 = withTableRefs(input.bytes, input.storyId, addLeadingXml(input.bytes, input.storyKind, rawParagraphs)).map((paragraph4) => ({
|
|
473165
|
+
...paragraph4,
|
|
473166
|
+
namespaceBindings: paragraph4.namespaceBindings ?? resolveNamespaceBindings(paragraph4)
|
|
473167
|
+
}));
|
|
473168
|
+
const trailingStart = rawParagraphs.at(-1)?.byteEnd ?? window2.byteStart;
|
|
473169
|
+
return {
|
|
473170
|
+
paragraphs: paragraphs2,
|
|
473171
|
+
trailingXml: TEXT_DECODER9.decode(input.bytes.slice(trailingStart, window2.byteEnd))
|
|
473172
|
+
};
|
|
473173
|
+
}
|
|
473174
|
+
function scanWmlParagraphSeedSpans(bytes) {
|
|
473175
|
+
const xml = TEXT_DECODER9.decode(bytes);
|
|
473176
|
+
const scan = scanWmlParagraphSpans(xml);
|
|
473177
|
+
if (!scan.ok)
|
|
473178
|
+
return [];
|
|
473179
|
+
const spans = [];
|
|
473180
|
+
let charCursor = 0;
|
|
473181
|
+
let byteCursor = leadingBomLength2(bytes);
|
|
473182
|
+
let containingParagraphEnd = -1;
|
|
473183
|
+
for (const paragraph4 of scan.paragraphs) {
|
|
473184
|
+
if (paragraph4.openStart < containingParagraphEnd)
|
|
473185
|
+
continue;
|
|
473186
|
+
const ordinal = spans.length;
|
|
473187
|
+
byteCursor += TEXT_ENCODER6.encode(xml.slice(charCursor, paragraph4.openStart)).length;
|
|
473188
|
+
const paragraphXml = xml.slice(paragraph4.openStart, paragraph4.closeEnd);
|
|
473189
|
+
const byteStart = byteCursor;
|
|
473190
|
+
const byteEnd = byteStart + TEXT_ENCODER6.encode(paragraphXml).length;
|
|
473191
|
+
spans.push({
|
|
473192
|
+
xml: paragraphXml,
|
|
473193
|
+
byteStart,
|
|
473194
|
+
byteEnd,
|
|
473195
|
+
charStart: paragraph4.openStart,
|
|
473196
|
+
charEnd: paragraph4.closeEnd,
|
|
473197
|
+
ordinal,
|
|
473198
|
+
paraId: paragraph4.paraId,
|
|
473199
|
+
blockId: blockIdForParagraphXmlSpan({ paraId: paragraph4.paraId, ordinal }),
|
|
473200
|
+
namespaceBindings: paragraph4.namespaceBindings
|
|
473201
|
+
});
|
|
473202
|
+
containingParagraphEnd = paragraph4.closeEnd;
|
|
473203
|
+
charCursor = paragraph4.closeEnd;
|
|
473204
|
+
byteCursor = byteEnd;
|
|
473205
|
+
}
|
|
473206
|
+
return spans;
|
|
473207
|
+
}
|
|
473208
|
+
function withTableRefs(bytes, storyId, spans) {
|
|
473209
|
+
const refsByBlockId = buildParagraphTableRefsFromBytes({
|
|
473210
|
+
bytes,
|
|
473211
|
+
storyId,
|
|
473212
|
+
paragraphs: spans.map((span) => ({
|
|
473213
|
+
blockId: span.blockId,
|
|
473214
|
+
byteStart: span.byteStart,
|
|
473215
|
+
byteEnd: span.byteEnd
|
|
473216
|
+
}))
|
|
473217
|
+
});
|
|
473218
|
+
return spans.map((span) => {
|
|
473219
|
+
const refs = refsByBlockId.get(span.blockId);
|
|
473220
|
+
if (!refs)
|
|
473221
|
+
return { ...span };
|
|
473222
|
+
return {
|
|
473223
|
+
...span,
|
|
473224
|
+
tableNodeId: refs.tableNodeId,
|
|
473225
|
+
rowNodeId: refs.rowNodeId,
|
|
473226
|
+
cellNodeId: refs.cellNodeId
|
|
473227
|
+
};
|
|
473228
|
+
});
|
|
473229
|
+
}
|
|
473230
|
+
function addLeadingXml(bytes, storyKind, spans) {
|
|
473231
|
+
const window2 = resolveStoryContentWindow(bytes, storyKind, spans);
|
|
473232
|
+
let cursor = window2.byteStart;
|
|
473233
|
+
return spans.map((span) => {
|
|
473234
|
+
const leadingXml = TEXT_DECODER9.decode(bytes.slice(cursor, span.byteStart));
|
|
473235
|
+
cursor = span.byteEnd;
|
|
473236
|
+
return {
|
|
473237
|
+
...span,
|
|
473238
|
+
leadingXml
|
|
473239
|
+
};
|
|
473240
|
+
});
|
|
473241
|
+
}
|
|
473242
|
+
function scanParagraphXmlSpansLocal(bytes, storyKind) {
|
|
473243
|
+
const xml = TEXT_DECODER9.decode(bytes);
|
|
473244
|
+
const spans = [];
|
|
473245
|
+
const re = new RegExp(PARAGRAPH_REGEX.source, "g");
|
|
473246
|
+
let match;
|
|
473247
|
+
let charCursor = 0;
|
|
473248
|
+
let byteCursor = leadingBomLength2(bytes);
|
|
473249
|
+
let ordinal = 0;
|
|
473250
|
+
while (match = re.exec(xml)) {
|
|
473251
|
+
const paragraphXml = match[0];
|
|
473252
|
+
const matchIndex = match.index ?? 0;
|
|
473253
|
+
if (matchIndex > charCursor) {
|
|
473254
|
+
byteCursor += TEXT_ENCODER6.encode(xml.slice(charCursor, matchIndex)).length;
|
|
473255
|
+
}
|
|
473256
|
+
const byteStart = byteCursor;
|
|
473257
|
+
const byteEnd = byteStart + TEXT_ENCODER6.encode(paragraphXml).length;
|
|
473258
|
+
const openTag = paragraphXml.match(/^<[\w.-]+:p\b[^>]*[/]?>/)?.[0] ?? "";
|
|
473259
|
+
const paraId = attrLocal3(openTag, "paraId");
|
|
473260
|
+
spans.push({
|
|
473261
|
+
xml: paragraphXml,
|
|
473262
|
+
byteStart,
|
|
473263
|
+
byteEnd,
|
|
473264
|
+
ordinal,
|
|
473265
|
+
blockId: blockIdForParagraphXmlSpan({ paraId, ordinal }),
|
|
473266
|
+
charStart: matchIndex,
|
|
473267
|
+
charEnd: matchIndex + paragraphXml.length,
|
|
473268
|
+
paraId
|
|
473269
|
+
});
|
|
473270
|
+
byteCursor = byteEnd;
|
|
473271
|
+
charCursor = matchIndex + paragraphXml.length;
|
|
473272
|
+
ordinal += 1;
|
|
473273
|
+
}
|
|
473274
|
+
return addLeadingXml(bytes, storyKind, spans);
|
|
473275
|
+
}
|
|
473276
|
+
function resolveStoryContentWindow(bytes, storyKind, entries3) {
|
|
473277
|
+
const xml = TEXT_DECODER9.decode(bytes);
|
|
473278
|
+
const bomLength = leadingBomLength2(bytes);
|
|
473279
|
+
const root = extractRootEnvelope(xml);
|
|
473280
|
+
if (!root) {
|
|
473281
|
+
return deriveContentWindowFromEntrySpans(bytes, entries3);
|
|
473282
|
+
}
|
|
473283
|
+
if (storyKind === "main") {
|
|
473284
|
+
const body2 = extractNamedContainerEnvelope(xml, root.innerStartChar, root.innerEndChar, "body");
|
|
473285
|
+
if (body2) {
|
|
473286
|
+
return {
|
|
473287
|
+
byteStart: bomLength + utf8ByteLength8(xml, body2.innerStartChar),
|
|
473288
|
+
byteEnd: bomLength + utf8ByteLength8(xml, body2.innerEndChar)
|
|
473289
|
+
};
|
|
473290
|
+
}
|
|
473291
|
+
}
|
|
473292
|
+
return {
|
|
473293
|
+
byteStart: bomLength + utf8ByteLength8(xml, root.innerStartChar),
|
|
473294
|
+
byteEnd: bomLength + utf8ByteLength8(xml, root.innerEndChar)
|
|
473295
|
+
};
|
|
473296
|
+
}
|
|
473297
|
+
function deriveContentWindowFromEntrySpans(bytes, entries3) {
|
|
473298
|
+
if (entries3.length === 0) {
|
|
473299
|
+
return { byteStart: 0, byteEnd: bytes.length };
|
|
473300
|
+
}
|
|
473301
|
+
return {
|
|
473302
|
+
byteStart: entries3[0].byteStart,
|
|
473303
|
+
byteEnd: entries3[entries3.length - 1].byteEnd
|
|
473304
|
+
};
|
|
473305
|
+
}
|
|
473306
|
+
function extractRootEnvelope(xml) {
|
|
473307
|
+
const rootSearchStart = xmlDeclarationPrefixLength(xml);
|
|
473308
|
+
const openMatch = /<([^\s/>]+)\b[^>]*>/.exec(xml.slice(rootSearchStart));
|
|
473309
|
+
if (!openMatch)
|
|
473310
|
+
return null;
|
|
473311
|
+
const openTagStart = rootSearchStart + (openMatch.index ?? 0);
|
|
473312
|
+
const openTagXml = openMatch[0];
|
|
473313
|
+
const tagName = openMatch[1];
|
|
473314
|
+
const closeTagXml = `</${tagName}>`;
|
|
473315
|
+
const closeTagStart = xml.lastIndexOf(closeTagXml);
|
|
473316
|
+
if (closeTagStart < openTagStart + openTagXml.length) {
|
|
473317
|
+
return null;
|
|
473318
|
+
}
|
|
473319
|
+
return {
|
|
473320
|
+
innerStartChar: openTagStart + openTagXml.length,
|
|
473321
|
+
innerEndChar: closeTagStart
|
|
473322
|
+
};
|
|
473323
|
+
}
|
|
473324
|
+
function extractNamedContainerEnvelope(xml, searchStart, searchEnd, localName3) {
|
|
473325
|
+
const segment = xml.slice(searchStart, searchEnd);
|
|
473326
|
+
const match = new RegExp(`<([\\w.-]+:)?${localName3}\\b[^>]*>`).exec(segment);
|
|
473327
|
+
if (!match)
|
|
473328
|
+
return null;
|
|
473329
|
+
const openTagStart = searchStart + (match.index ?? 0);
|
|
473330
|
+
const openTagXml = match[0];
|
|
473331
|
+
const openTagName = /^<([^\s/>]+)/.exec(openTagXml)?.[1];
|
|
473332
|
+
if (!openTagName)
|
|
473333
|
+
return null;
|
|
473334
|
+
const closeTagXml = `</${openTagName}>`;
|
|
473335
|
+
const closeTagStart = xml.lastIndexOf(closeTagXml, searchEnd);
|
|
473336
|
+
const innerStartChar = openTagStart + openTagXml.length;
|
|
473337
|
+
if (closeTagStart < innerStartChar) {
|
|
473338
|
+
return null;
|
|
473339
|
+
}
|
|
473340
|
+
return {
|
|
473341
|
+
innerStartChar,
|
|
473342
|
+
innerEndChar: closeTagStart
|
|
473343
|
+
};
|
|
473344
|
+
}
|
|
473345
|
+
function xmlDeclarationPrefixLength(xml) {
|
|
473346
|
+
const match = /^\uFEFF?\s*<\?xml[\s\S]*?\?>\s*/i.exec(xml);
|
|
473347
|
+
return match ? match[0].length : 0;
|
|
473348
|
+
}
|
|
473349
|
+
function utf8ByteLength8(xml, codeUnitIndex) {
|
|
473350
|
+
if (codeUnitIndex <= 0)
|
|
473351
|
+
return 0;
|
|
473352
|
+
return TEXT_ENCODER6.encode(xml.slice(0, codeUnitIndex)).length;
|
|
473353
|
+
}
|
|
473354
|
+
function leadingBomLength2(bytes) {
|
|
473355
|
+
return bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
473356
|
+
}
|
|
473357
|
+
function attrLocal3(tag, localName3) {
|
|
473358
|
+
const re = new RegExp(String.raw`(?:[\w.-]+:)?${localName3}="([^"]+)"`);
|
|
473359
|
+
return tag.match(re)?.[1] ?? null;
|
|
473360
|
+
}
|
|
473361
|
+
var TEXT_DECODER9, TEXT_ENCODER6, PARAGRAPH_REGEX;
|
|
473362
|
+
var init_story_paragraph_seed = __esm(() => {
|
|
473363
|
+
init_sd_document_session_internal();
|
|
473364
|
+
init_parse_paragraph();
|
|
473365
|
+
init_paragraph_namespace_bindings();
|
|
473366
|
+
init_table_structural_refs();
|
|
473367
|
+
TEXT_DECODER9 = new TextDecoder("utf-8", { fatal: false });
|
|
473368
|
+
TEXT_ENCODER6 = new TextEncoder;
|
|
473369
|
+
PARAGRAPH_REGEX = /<[\w.-]+:p\b[^>]*\/>|<[\w.-]+:p\b[^>]*>[\s\S]*?<\/[\w.-]+:p>/g;
|
|
473370
|
+
});
|
|
473371
|
+
|
|
473031
473372
|
// ../../../v2/collaboration-v2/dist/story-shard/content-control-groups.js
|
|
473032
473373
|
function blockGroup(scope, blockId) {
|
|
473033
473374
|
const value3 = scope.order.get(MEMBER_PREFIX + blockId);
|
|
@@ -473305,6 +473646,85 @@ var init_content_control_groups = __esm(() => {
|
|
|
473305
473646
|
retainedOrders = new WeakMap;
|
|
473306
473647
|
});
|
|
473307
473648
|
|
|
473649
|
+
// ../../../v2/collaboration-v2/dist/story-shard/bom-boundary-repair.js
|
|
473650
|
+
function bindOriginalBomNoteBoundaries(input) {
|
|
473651
|
+
if (!["endnotes", "footnotes"].includes(input.storyKind) || input.partUri !== `/word/${input.storyKind}.xml` || input.bytes[0] !== 239 || input.bytes[1] !== 187 || input.bytes[2] !== 191)
|
|
473652
|
+
return false;
|
|
473653
|
+
const xml = DECODER4.decode(input.bytes);
|
|
473654
|
+
if (parseXmlForError(xml, { namespaceAware: true }) || !new RegExp(`<(?:[\\w.-]+:)?${input.storyKind}\\b`).test(xml))
|
|
473655
|
+
return false;
|
|
473656
|
+
const source = storySeedForSource(input);
|
|
473657
|
+
const first = source.paragraphs[0];
|
|
473658
|
+
const last2 = source.paragraphs.at(-1);
|
|
473659
|
+
if (!first || !last2 || new Set(source.paragraphs.map((p) => p.blockId)).size !== source.paragraphs.length || source.paragraphs.some((p) => !p.paraId || p.tableNodeId))
|
|
473660
|
+
return false;
|
|
473661
|
+
const start = first.byteStart - ENCODER2.encode(first.leadingXml).length;
|
|
473662
|
+
const end = last2.byteEnd + ENCODER2.encode(source.trailingXml).length;
|
|
473663
|
+
if (start < 3 || end - 3 < last2.byteEnd)
|
|
473664
|
+
return false;
|
|
473665
|
+
const scope = resolveStoryShardScope(input.target);
|
|
473666
|
+
const repair = {
|
|
473667
|
+
scope,
|
|
473668
|
+
storyId: input.storyId,
|
|
473669
|
+
storyKind: input.storyKind,
|
|
473670
|
+
partUri: input.partUri,
|
|
473671
|
+
paragraphs: source.paragraphs,
|
|
473672
|
+
leadingXml: first.leadingXml,
|
|
473673
|
+
legacyLeadingXml: DECODER4.decode(input.bytes.slice(start - 3, first.byteStart)),
|
|
473674
|
+
trailingXml: source.trailingXml,
|
|
473675
|
+
legacyTrailingXml: DECODER4.decode(input.bytes.slice(last2.byteEnd, end - 3))
|
|
473676
|
+
};
|
|
473677
|
+
if (!matches(repair))
|
|
473678
|
+
return false;
|
|
473679
|
+
const firstBlock = listOrderedBlocks(scope)[0].block;
|
|
473680
|
+
if (firstBlock.get(BLOCK_KEY.leadingXml) === repair.leadingXml && scope.meta.get(STORY_META_KEY.trailingXml) === repair.trailingXml)
|
|
473681
|
+
return false;
|
|
473682
|
+
BY_META.set(scope.meta, repair);
|
|
473683
|
+
BY_FIRST_BLOCK.set(firstBlock, repair);
|
|
473684
|
+
return true;
|
|
473685
|
+
}
|
|
473686
|
+
function matches(repair) {
|
|
473687
|
+
const { scope, paragraphs: paragraphs2 } = repair;
|
|
473688
|
+
if (scope.meta.get(STORY_META_KEY.storyId) !== repair.storyId || scope.meta.get(STORY_META_KEY.storyKind) !== repair.storyKind || scope.meta.get(STORY_META_KEY.sourcePartUri) !== repair.partUri || scope.tables.size !== 0 || hasContentControlGroups(scope) || scope.blocks.length !== paragraphs2.length)
|
|
473689
|
+
return false;
|
|
473690
|
+
const tail = scope.meta.get(STORY_META_KEY.trailingXml);
|
|
473691
|
+
if (tail !== repair.trailingXml && tail !== repair.legacyTrailingXml)
|
|
473692
|
+
return false;
|
|
473693
|
+
const ordered = listOrderedBlocks(scope);
|
|
473694
|
+
if (ordered.length !== paragraphs2.length)
|
|
473695
|
+
return false;
|
|
473696
|
+
return ordered.every(({ block, blockId }, index2) => {
|
|
473697
|
+
const paragraph4 = paragraphs2[index2];
|
|
473698
|
+
const anchor = block.get(BLOCK_KEY.sourceAnchor);
|
|
473699
|
+
if (!(anchor instanceof YMap))
|
|
473700
|
+
return false;
|
|
473701
|
+
const span = anchor.get("byteSpan");
|
|
473702
|
+
const leading = block.get(BLOCK_KEY.leadingXml);
|
|
473703
|
+
return blockId === paragraph4.blockId && block.get(BLOCK_KEY.blockKind) === "paragraph" && block.get(BLOCK_KEY.nativeIdStatus) === "native" && !block.get(BLOCK_KEY.splitFromBlockId) && !block.get(BLOCK_KEY.mergedIntoBlockId) && anchor.get("partId") === repair.partUri && anchor.get("storyId") === repair.storyId && anchor.get("nativeId") === paragraph4.paraId && Array.isArray(span) && span[0] === paragraph4.byteStart && span[1] === paragraph4.byteEnd && (leading === paragraph4.leadingXml || index2 === 0 && leading === repair.legacyLeadingXml);
|
|
473704
|
+
});
|
|
473705
|
+
}
|
|
473706
|
+
function readBomCorrectedTrailingXml(meta3) {
|
|
473707
|
+
const repair = BY_META.get(meta3);
|
|
473708
|
+
return repair && matches(repair) ? repair.trailingXml : String(meta3.get(STORY_META_KEY.trailingXml) ?? "");
|
|
473709
|
+
}
|
|
473710
|
+
function readBomCorrectedLeadingXml(block) {
|
|
473711
|
+
const repair = BY_FIRST_BLOCK.get(block);
|
|
473712
|
+
return repair && matches(repair) ? repair.leadingXml : String(block.get(BLOCK_KEY.leadingXml) ?? "");
|
|
473713
|
+
}
|
|
473714
|
+
var DECODER4, ENCODER2, BY_META, BY_FIRST_BLOCK;
|
|
473715
|
+
var init_bom_boundary_repair = __esm(() => {
|
|
473716
|
+
init_yjs();
|
|
473717
|
+
init_sd_document_session_internal();
|
|
473718
|
+
init_story_paragraph_seed();
|
|
473719
|
+
init_constants4();
|
|
473720
|
+
init_content_control_groups();
|
|
473721
|
+
init_scope3();
|
|
473722
|
+
DECODER4 = new TextDecoder;
|
|
473723
|
+
ENCODER2 = new TextEncoder;
|
|
473724
|
+
BY_META = new WeakMap;
|
|
473725
|
+
BY_FIRST_BLOCK = new WeakMap;
|
|
473726
|
+
});
|
|
473727
|
+
|
|
473308
473728
|
// ../../../v2/collaboration-v2/dist/story-shard/inline-control-position.js
|
|
473309
473729
|
function ownerText(atom) {
|
|
473310
473730
|
const array3 = atom.parent;
|
|
@@ -473433,7 +473853,7 @@ function readMeta(target) {
|
|
|
473433
473853
|
},
|
|
473434
473854
|
sourcePartRevision: normaliseNullableString(meta3.get(STORY_META_KEY.sourcePartRevision)),
|
|
473435
473855
|
sourceStoryRevision: normaliseNullableString(meta3.get(STORY_META_KEY.sourceStoryRevision)),
|
|
473436
|
-
trailingXml:
|
|
473856
|
+
trailingXml: readBomCorrectedTrailingXml(meta3),
|
|
473437
473857
|
...paragraphInsertBoundaries.length ? { paragraphInsertBoundaries } : {}
|
|
473438
473858
|
};
|
|
473439
473859
|
}
|
|
@@ -473443,7 +473863,7 @@ function snapshotBlock(blockMap) {
|
|
|
473443
473863
|
const nativeIdStatus = blockMap.get(BLOCK_KEY.nativeIdStatus) ?? "native";
|
|
473444
473864
|
const rsidR = normaliseNullableString(blockMap.get(BLOCK_KEY.rsidR));
|
|
473445
473865
|
const styleRef = blockMap.get(BLOCK_KEY.styleRef) ?? null;
|
|
473446
|
-
const leadingXml =
|
|
473866
|
+
const leadingXml = readBomCorrectedLeadingXml(blockMap);
|
|
473447
473867
|
const paragraphInsertBoundary = blockMap.get(BLOCK_KEY.paragraphInsertBoundary);
|
|
473448
473868
|
const pPrMap = getBlockPPr(blockMap);
|
|
473449
473869
|
const pPr = {};
|
|
@@ -473736,6 +474156,7 @@ function normaliseNullableString(value3) {
|
|
|
473736
474156
|
var STORY_BLOCK_INDEXES;
|
|
473737
474157
|
var init_read_view = __esm(() => {
|
|
473738
474158
|
init_yjs();
|
|
474159
|
+
init_bom_boundary_repair();
|
|
473739
474160
|
init_diagnostics2();
|
|
473740
474161
|
init_constants4();
|
|
473741
474162
|
init_schema4();
|
|
@@ -477180,18 +477601,18 @@ function applyTrackedTextDecideToStoryShard(input) {
|
|
|
477180
477601
|
try {
|
|
477181
477602
|
scope.doc.transact(() => {
|
|
477182
477603
|
for (const target of input.targets) {
|
|
477183
|
-
const
|
|
477184
|
-
if (
|
|
477604
|
+
const matches2 = findTrackedInsertionMatches(scope, target);
|
|
477605
|
+
if (matches2.length === 0) {
|
|
477185
477606
|
noOpCount += 1;
|
|
477186
477607
|
continue;
|
|
477187
477608
|
}
|
|
477188
|
-
if (
|
|
477609
|
+
if (matches2.length > 1) {
|
|
477189
477610
|
throw new Error(`tracked insertion ${target.rsid} is ambiguous in story shard`);
|
|
477190
477611
|
}
|
|
477191
477612
|
applyTrackedInsertionDecision({
|
|
477192
477613
|
scope,
|
|
477193
477614
|
decision: input.decision,
|
|
477194
|
-
match:
|
|
477615
|
+
match: matches2[0],
|
|
477195
477616
|
origin: input.origin
|
|
477196
477617
|
});
|
|
477197
477618
|
appliedCount += 1;
|
|
@@ -477225,7 +477646,7 @@ function applyTrackedInsertionDecision(input) {
|
|
|
477225
477646
|
}
|
|
477226
477647
|
function findTrackedInsertionMatches(scope, target) {
|
|
477227
477648
|
const blocks = target.blockId ? findBlockMap(scope, target.blockId) ? [findBlockMap(scope, target.blockId)] : [] : listBlockMaps(scope);
|
|
477228
|
-
const
|
|
477649
|
+
const matches2 = [];
|
|
477229
477650
|
for (const { block } of blocks) {
|
|
477230
477651
|
const blockId = String(block.get(BLOCK_KEY.blockId) ?? "");
|
|
477231
477652
|
const atoms = getBlockAtoms(block);
|
|
@@ -477258,7 +477679,7 @@ function findTrackedInsertionMatches(scope, target) {
|
|
|
477258
477679
|
if (!Number.isInteger(startOffset) || !Number.isInteger(endOffset) || endOffset < startOffset) {
|
|
477259
477680
|
throw new Error(`tracked insertion ${target.rsid} has invalid offsets`);
|
|
477260
477681
|
}
|
|
477261
|
-
|
|
477682
|
+
matches2.push({
|
|
477262
477683
|
blockId,
|
|
477263
477684
|
block,
|
|
477264
477685
|
startAtomIndex: startIndices[0],
|
|
@@ -477269,7 +477690,7 @@ function findTrackedInsertionMatches(scope, target) {
|
|
|
477269
477690
|
endOffset
|
|
477270
477691
|
});
|
|
477271
477692
|
}
|
|
477272
|
-
return
|
|
477693
|
+
return matches2;
|
|
477273
477694
|
}
|
|
477274
477695
|
function listBlockMaps(scope) {
|
|
477275
477696
|
const blocks = scope.blocks;
|
|
@@ -481519,10 +481940,10 @@ function captureTableRowInsertion(tableXml, tableNodeId, row, blocks, inherited
|
|
|
481519
481940
|
if (tables2.length !== 1)
|
|
481520
481941
|
return null;
|
|
481521
481942
|
const table = tables2[0];
|
|
481522
|
-
const
|
|
481523
|
-
if (
|
|
481943
|
+
const matches2 = ranges.filter((range) => range.tag.localName === "tr" && tableXml.slice(range.start, range.end) === row.xml);
|
|
481944
|
+
if (matches2.length !== 1)
|
|
481524
481945
|
return null;
|
|
481525
|
-
const sourceRow =
|
|
481946
|
+
const sourceRow = matches2[0];
|
|
481526
481947
|
const blocksById = new Map(blocks.map((block) => [block.blockId, block]));
|
|
481527
481948
|
const paragraphs2 = row.cells.flatMap((cell) => cell.paragraphIds.map((blockId) => ({ blockId, rowNodeId: row.rowNodeId, cellNodeId: cell.cellNodeId })));
|
|
481528
481949
|
const sourceIds = ranges.filter((range) => range.tag.localName === "p" && range.start > sourceRow.start && range.end < sourceRow.end).map(paragraphId4);
|
|
@@ -483406,7 +483827,7 @@ function threadingIdentityPatch(xml, paragraph4, paraId) {
|
|
|
483406
483827
|
return { start, end: start, xml: ` ${namespace}${prefix2}:paraId="${xmlEscape(paraId)}"` };
|
|
483407
483828
|
}
|
|
483408
483829
|
function currentCommentProjection(owner, source) {
|
|
483409
|
-
const xml = new Map([...source].map(([uri, bytes]) => [uri,
|
|
483830
|
+
const xml = new Map([...source].map(([uri, bytes]) => [uri, DECODER5.decode(bytes)]));
|
|
483410
483831
|
const current = ownedCommentProjections.get(owner);
|
|
483411
483832
|
if (current && current.xml.size === xml.size && [...xml].every(([uri, text4]) => current.xml.get(uri) === text4))
|
|
483412
483833
|
return current;
|
|
@@ -483578,13 +483999,13 @@ function projectCommentsFamilySource(comments, source, owner) {
|
|
|
483578
483999
|
}
|
|
483579
484000
|
return publish3(generated);
|
|
483580
484001
|
}
|
|
483581
|
-
var W30 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", W1411 = "http://schemas.microsoft.com/office/word/2010/wordml", W153 = "http://schemas.microsoft.com/office/word/2012/wordml", CID = "http://schemas.microsoft.com/office/word/2016/wordml/cid",
|
|
484002
|
+
var W30 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", W1411 = "http://schemas.microsoft.com/office/word/2010/wordml", W153 = "http://schemas.microsoft.com/office/word/2012/wordml", CID = "http://schemas.microsoft.com/office/word/2016/wordml/cid", DECODER5, BODY = "/word/comments.xml", EXTENDED = "/word/commentsExtended.xml", IDS = "/word/commentsIds.xml", ownedCommentProjections;
|
|
483582
484003
|
var init_comments_source = __esm(() => {
|
|
483583
484004
|
init_sd_document_session_internal();
|
|
483584
484005
|
init_canonical();
|
|
483585
484006
|
init_comments3();
|
|
483586
484007
|
init_package_xml();
|
|
483587
|
-
|
|
484008
|
+
DECODER5 = new TextDecoder;
|
|
483588
484009
|
ownedCommentProjections = new WeakMap;
|
|
483589
484010
|
});
|
|
483590
484011
|
|
|
@@ -484053,7 +484474,7 @@ function materializeProjectionInternal(input, recovery) {
|
|
|
484053
484474
|
const blockEntries = [];
|
|
484054
484475
|
const changedIndices = [];
|
|
484055
484476
|
const baseXmlPatchIndices = [];
|
|
484056
|
-
const trailingXml =
|
|
484477
|
+
const trailingXml = readMeta(readTarget).trailingXml;
|
|
484057
484478
|
const envelope = storyEnvelope(previous3.storyKind, bootstrap);
|
|
484058
484479
|
const trailingStart = projectedTrailingStart(previous3, trailingXml, bootstrap);
|
|
484059
484480
|
const trailingUnchanged = trailingStart !== null && previous3.xml.slice(trailingStart, previous3.xml.length - envelope.suffix.length) === trailingXml;
|
|
@@ -487199,7 +487620,7 @@ function isCompleteParagraphWithNativeId(sourceSlice, nativeId) {
|
|
|
487199
487620
|
return markerIndex >= 0 && markerIndex < paragraph4.openEnd;
|
|
487200
487621
|
}
|
|
487201
487622
|
function findUniqueBootstrapParagraphSpan(sourceXml, nativeId) {
|
|
487202
|
-
const
|
|
487623
|
+
const matches2 = [];
|
|
487203
487624
|
const matchedSpans = new Set;
|
|
487204
487625
|
let cursor = 0;
|
|
487205
487626
|
while (cursor < sourceXml.length) {
|
|
@@ -487213,14 +487634,14 @@ function findUniqueBootstrapParagraphSpan(sourceXml, nativeId) {
|
|
|
487213
487634
|
const key3 = `${paragraphStart}:${paragraph4.end}`;
|
|
487214
487635
|
if (!matchedSpans.has(key3)) {
|
|
487215
487636
|
matchedSpans.add(key3);
|
|
487216
|
-
|
|
487637
|
+
matches2.push([paragraphStart, paragraph4.end]);
|
|
487217
487638
|
}
|
|
487218
487639
|
cursor = paragraph4.openEnd;
|
|
487219
487640
|
continue;
|
|
487220
487641
|
}
|
|
487221
487642
|
cursor = markerIndex + 1;
|
|
487222
487643
|
}
|
|
487223
|
-
return
|
|
487644
|
+
return matches2.length === 1 ? matches2[0] : null;
|
|
487224
487645
|
}
|
|
487225
487646
|
function spansEqual(left, right) {
|
|
487226
487647
|
return Boolean(left && right && left[0] === right[0] && left[1] === right[1]);
|
|
@@ -488111,7 +488532,7 @@ function collectPackageParts(registry3, options) {
|
|
|
488111
488532
|
out.push({
|
|
488112
488533
|
partUri: "/word/people.xml",
|
|
488113
488534
|
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml",
|
|
488114
|
-
content: { kind: "xml", xml: peopleSource ?
|
|
488535
|
+
content: { kind: "xml", xml: peopleSource ? TEXT_DECODER10.decode(peopleSource) : serializePeopleXml(people) }
|
|
488115
488536
|
});
|
|
488116
488537
|
}
|
|
488117
488538
|
}
|
|
@@ -488311,7 +488732,7 @@ function rememberTextLocalStorySnapshot(story, target, snapshot3, validated2, bo
|
|
|
488311
488732
|
snapshot: snapshot3
|
|
488312
488733
|
});
|
|
488313
488734
|
}
|
|
488314
|
-
var WORD_ML_NS2 = 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"', WORD_ML_2010_NS = 'xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"', STORY_ROOT_NS,
|
|
488735
|
+
var WORD_ML_NS2 = 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"', WORD_ML_2010_NS = 'xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"', STORY_ROOT_NS, TEXT_DECODER10, STORY_BLOCK_INDEX_CACHE, STORY_XML_COORDINATES, SYNTHETIC_PARAGRAPH_BLOCK_ID_PREFIX4 = "__sd:paragraph:", UTF8_ENCODER4, SOURCE_XML_BYTE_ALIGNED_CACHE, IMPORTED_STORY_BOOTSTRAPS, XML_EMISSION_CONTEXTS, CONTENT_CONTROL_TOPOLOGIES, PROJECTED_NAMESPACE_CONTEXTS, RETAINED_TEXT_PROJECTIONS, retainedProjectionStatistics, PARAGRAPH_LOCAL_STORY_SNAPSHOTS, PARAGRAPH_PROPERTY_ORDER, RUN_PROPERTY_CONTENT_LOCAL_NAMES, TEXT_LOCAL_STORY_SNAPSHOTS;
|
|
488315
488736
|
var init_materialize = __esm(() => {
|
|
488316
488737
|
init_retained_story();
|
|
488317
488738
|
init_package_part();
|
|
@@ -488338,7 +488759,7 @@ var init_materialize = __esm(() => {
|
|
|
488338
488759
|
init_table_revision_decisions();
|
|
488339
488760
|
init_xml_emission_context();
|
|
488340
488761
|
STORY_ROOT_NS = `${WORD_ML_NS2} ${WORD_ML_2010_NS}`;
|
|
488341
|
-
|
|
488762
|
+
TEXT_DECODER10 = new TextDecoder("utf-8", { fatal: false });
|
|
488342
488763
|
STORY_BLOCK_INDEX_CACHE = new WeakMap;
|
|
488343
488764
|
STORY_XML_COORDINATES = new WeakMap;
|
|
488344
488765
|
UTF8_ENCODER4 = new TextEncoder;
|
|
@@ -489858,124 +490279,6 @@ var init_tracked_changes2 = __esm(() => {
|
|
|
489858
490279
|
// ../../../v2/collaboration-v2/dist/undo/index.js
|
|
489859
490280
|
var init_undo = () => {};
|
|
489860
490281
|
|
|
489861
|
-
// ../../../v2/collaboration-v2/dist/story-shard/paragraph-namespace-bindings.js
|
|
489862
|
-
function createParagraphNamespaceBindingResolver(bytes, rootBindings) {
|
|
489863
|
-
let bindingsByByteStart = null;
|
|
489864
|
-
let namespaceDeclarationCounts = null;
|
|
489865
|
-
return (paragraph4) => {
|
|
489866
|
-
const paragraphPrefix = paragraphElementPrefix(paragraph4.xml);
|
|
489867
|
-
const prefixes = paragraphRsidPrefixes(paragraph4.xml).filter((prefix2) => prefix2 !== paragraphPrefix && !hasLocalBinding(paragraph4.xml, prefix2));
|
|
489868
|
-
if (prefixes.length === 0)
|
|
489869
|
-
return rootBindings;
|
|
489870
|
-
for (const prefix2 of prefixes) {
|
|
489871
|
-
const resolvedAtRoot = Object.prototype.hasOwnProperty.call(rootBindings, prefix2);
|
|
489872
|
-
if (!resolvedAtRoot) {
|
|
489873
|
-
bindingsByByteStart ?? (bindingsByByteStart = readParagraphNamespaceBindings(bytes));
|
|
489874
|
-
return bindingsByByteStart.get(paragraph4.byteStart) ?? rootBindings;
|
|
489875
|
-
}
|
|
489876
|
-
namespaceDeclarationCounts ?? (namespaceDeclarationCounts = countNamespaceDeclarations(bytes));
|
|
489877
|
-
if ((namespaceDeclarationCounts.get(prefix2) ?? 0) > 1) {
|
|
489878
|
-
bindingsByByteStart ?? (bindingsByByteStart = readParagraphNamespaceBindings(bytes));
|
|
489879
|
-
return bindingsByByteStart.get(paragraph4.byteStart) ?? rootBindings;
|
|
489880
|
-
}
|
|
489881
|
-
}
|
|
489882
|
-
return rootBindings;
|
|
489883
|
-
};
|
|
489884
|
-
}
|
|
489885
|
-
function readParagraphNamespaceBindings(bytes) {
|
|
489886
|
-
const xml = TEXT_DECODER9.decode(bytes);
|
|
489887
|
-
const paragraphs2 = scanWmlParagraphSpans(xml).paragraphs;
|
|
489888
|
-
const bindingsByByteStart = new Map;
|
|
489889
|
-
let charCursor = 0;
|
|
489890
|
-
let byteCursor = leadingBomLength(bytes);
|
|
489891
|
-
for (const paragraph4 of paragraphs2) {
|
|
489892
|
-
byteCursor += TEXT_ENCODER5.encode(xml.slice(charCursor, paragraph4.openStart)).byteLength;
|
|
489893
|
-
bindingsByByteStart.set(byteCursor, paragraph4.namespaceBindings);
|
|
489894
|
-
charCursor = paragraph4.openStart;
|
|
489895
|
-
}
|
|
489896
|
-
return bindingsByByteStart;
|
|
489897
|
-
}
|
|
489898
|
-
function paragraphRsidPrefixes(xml) {
|
|
489899
|
-
const openTag = xml.slice(0, xml.indexOf(">") + 1);
|
|
489900
|
-
return [...openTag.matchAll(/(?:^|\s)(?!xmlns:)([\w.-]+):rsidR\s*=/g)].map((match) => match[1]);
|
|
489901
|
-
}
|
|
489902
|
-
function paragraphElementPrefix(xml) {
|
|
489903
|
-
const qname = /^<([^\s/>]+)/.exec(xml)?.[1];
|
|
489904
|
-
if (!qname)
|
|
489905
|
-
return null;
|
|
489906
|
-
const colon = qname.indexOf(":");
|
|
489907
|
-
return colon < 0 ? "" : qname.slice(0, colon);
|
|
489908
|
-
}
|
|
489909
|
-
function hasLocalBinding(xml, prefix2) {
|
|
489910
|
-
const openTag = xml.slice(0, xml.indexOf(">") + 1);
|
|
489911
|
-
return new RegExp(String.raw`\bxmlns:${escapeRegex16(prefix2)}\s*=`).test(openTag);
|
|
489912
|
-
}
|
|
489913
|
-
function countNamespaceDeclarations(bytes) {
|
|
489914
|
-
const counts = new Map;
|
|
489915
|
-
const xml = TEXT_DECODER9.decode(bytes);
|
|
489916
|
-
const declaration = /\bxmlns:([\w.-]+)\s*=/g;
|
|
489917
|
-
let match;
|
|
489918
|
-
while (match = declaration.exec(xml)) {
|
|
489919
|
-
const prefix2 = match[1];
|
|
489920
|
-
counts.set(prefix2, (counts.get(prefix2) ?? 0) + 1);
|
|
489921
|
-
}
|
|
489922
|
-
return counts;
|
|
489923
|
-
}
|
|
489924
|
-
function escapeRegex16(value3) {
|
|
489925
|
-
return value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
489926
|
-
}
|
|
489927
|
-
function leadingBomLength(bytes) {
|
|
489928
|
-
return bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
489929
|
-
}
|
|
489930
|
-
var TEXT_DECODER9, TEXT_ENCODER5;
|
|
489931
|
-
var init_paragraph_namespace_bindings = __esm(() => {
|
|
489932
|
-
init_sd_document_session_internal();
|
|
489933
|
-
TEXT_DECODER9 = new TextDecoder("utf-8", { fatal: false });
|
|
489934
|
-
TEXT_ENCODER5 = new TextEncoder;
|
|
489935
|
-
});
|
|
489936
|
-
|
|
489937
|
-
// ../../../v2/collaboration-v2/dist/story-shard/table-structural-refs.js
|
|
489938
|
-
function buildParagraphTableRefsFromBytes(input) {
|
|
489939
|
-
if (input.paragraphs.length === 0)
|
|
489940
|
-
return new Map;
|
|
489941
|
-
const catalog = buildTableCatalog({
|
|
489942
|
-
bytes: input.bytes,
|
|
489943
|
-
storyId: input.storyId
|
|
489944
|
-
});
|
|
489945
|
-
return buildParagraphTableRefsFromCatalog({
|
|
489946
|
-
catalog,
|
|
489947
|
-
paragraphs: input.paragraphs
|
|
489948
|
-
});
|
|
489949
|
-
}
|
|
489950
|
-
function buildParagraphTableRefsFromCatalog(input) {
|
|
489951
|
-
const refsByBlockId = new Map;
|
|
489952
|
-
if (!input.catalog || input.paragraphs.length === 0)
|
|
489953
|
-
return refsByBlockId;
|
|
489954
|
-
for (const table of input.catalog.tables) {
|
|
489955
|
-
for (const row of table.rows) {
|
|
489956
|
-
for (const cell of row.cells) {
|
|
489957
|
-
if (cell.containsNestedTable)
|
|
489958
|
-
continue;
|
|
489959
|
-
for (const paragraph4 of input.paragraphs) {
|
|
489960
|
-
if (refsByBlockId.has(paragraph4.blockId))
|
|
489961
|
-
continue;
|
|
489962
|
-
if (paragraph4.byteStart < cell.bodyByteStart || paragraph4.byteEnd > cell.bodyByteEnd)
|
|
489963
|
-
continue;
|
|
489964
|
-
refsByBlockId.set(paragraph4.blockId, {
|
|
489965
|
-
tableNodeId: table.tableNodeId,
|
|
489966
|
-
rowNodeId: row.rowNodeId,
|
|
489967
|
-
cellNodeId: cell.cellNodeId
|
|
489968
|
-
});
|
|
489969
|
-
}
|
|
489970
|
-
}
|
|
489971
|
-
}
|
|
489972
|
-
}
|
|
489973
|
-
return refsByBlockId;
|
|
489974
|
-
}
|
|
489975
|
-
var init_table_structural_refs = __esm(() => {
|
|
489976
|
-
init_sd_document_session_internal();
|
|
489977
|
-
});
|
|
489978
|
-
|
|
489979
490282
|
// ../../../v2/collaboration-v2/dist/backend/paragraph-inline-sync.js
|
|
489980
490283
|
function sameAttributes(left, right) {
|
|
489981
490284
|
const keys3 = Object.keys(left);
|
|
@@ -491319,7 +491622,7 @@ function loadStorySyncContext(session, storyId, blockIds) {
|
|
|
491319
491622
|
};
|
|
491320
491623
|
}
|
|
491321
491624
|
function readSessionStoryPayloads(context) {
|
|
491322
|
-
const contentWindow =
|
|
491625
|
+
const contentWindow = resolveStoryContentWindow2(context.bytes, context.storyKind, context.index.entries);
|
|
491323
491626
|
let cursor = contentWindow.byteStart;
|
|
491324
491627
|
const trackedWrapperIdentityState = {
|
|
491325
491628
|
storyId: context.storyId,
|
|
@@ -492159,27 +492462,28 @@ function assertNever4(value3) {
|
|
|
492159
492462
|
function inferStoryKindFromStoryId(storyId) {
|
|
492160
492463
|
return storyId.split(":", 1)[0] ?? "preserved";
|
|
492161
492464
|
}
|
|
492162
|
-
function
|
|
492465
|
+
function resolveStoryContentWindow2(bytes, storyKind, entries4) {
|
|
492163
492466
|
const xml = TD135.decode(bytes);
|
|
492164
|
-
const
|
|
492467
|
+
const bomLength = bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
492468
|
+
const root = extractRootEnvelope2(xml);
|
|
492165
492469
|
if (!root) {
|
|
492166
|
-
return
|
|
492470
|
+
return deriveContentWindowFromEntrySpans2(bytes, entries4);
|
|
492167
492471
|
}
|
|
492168
492472
|
if (storyKind === "main") {
|
|
492169
|
-
const body2 =
|
|
492473
|
+
const body2 = extractNamedContainerEnvelope2(xml, root.innerStartChar, root.innerEndChar, "body");
|
|
492170
492474
|
if (body2) {
|
|
492171
492475
|
return {
|
|
492172
|
-
byteStart:
|
|
492173
|
-
byteEnd:
|
|
492476
|
+
byteStart: bomLength + utf8ByteLength9(xml, body2.innerStartChar),
|
|
492477
|
+
byteEnd: bomLength + utf8ByteLength9(xml, body2.innerEndChar)
|
|
492174
492478
|
};
|
|
492175
492479
|
}
|
|
492176
492480
|
}
|
|
492177
492481
|
return {
|
|
492178
|
-
byteStart:
|
|
492179
|
-
byteEnd:
|
|
492482
|
+
byteStart: bomLength + utf8ByteLength9(xml, root.innerStartChar),
|
|
492483
|
+
byteEnd: bomLength + utf8ByteLength9(xml, root.innerEndChar)
|
|
492180
492484
|
};
|
|
492181
492485
|
}
|
|
492182
|
-
function
|
|
492486
|
+
function deriveContentWindowFromEntrySpans2(bytes, entries4) {
|
|
492183
492487
|
if (entries4.length === 0) {
|
|
492184
492488
|
return { byteStart: 0, byteEnd: bytes.length };
|
|
492185
492489
|
}
|
|
@@ -492188,8 +492492,8 @@ function deriveContentWindowFromEntrySpans(bytes, entries4) {
|
|
|
492188
492492
|
byteEnd: entries4[entries4.length - 1].byteEnd
|
|
492189
492493
|
};
|
|
492190
492494
|
}
|
|
492191
|
-
function
|
|
492192
|
-
const rootSearchStart =
|
|
492495
|
+
function extractRootEnvelope2(xml) {
|
|
492496
|
+
const rootSearchStart = xmlDeclarationPrefixLength2(xml);
|
|
492193
492497
|
const openMatch = /<([^\s/>]+)\b[^>]*>/.exec(xml.slice(rootSearchStart));
|
|
492194
492498
|
if (!openMatch)
|
|
492195
492499
|
return null;
|
|
@@ -492206,7 +492510,7 @@ function extractRootEnvelope(xml) {
|
|
|
492206
492510
|
innerEndChar: closeTagStart
|
|
492207
492511
|
};
|
|
492208
492512
|
}
|
|
492209
|
-
function
|
|
492513
|
+
function extractNamedContainerEnvelope2(xml, searchStart, searchEnd, localName3) {
|
|
492210
492514
|
const segment = xml.slice(searchStart, searchEnd);
|
|
492211
492515
|
const match = new RegExp(`<([\\w.-]+:)?${localName3}\\b[^>]*>`).exec(segment);
|
|
492212
492516
|
if (!match)
|
|
@@ -492227,11 +492531,11 @@ function extractNamedContainerEnvelope(xml, searchStart, searchEnd, localName3)
|
|
|
492227
492531
|
innerEndChar: closeTagStart
|
|
492228
492532
|
};
|
|
492229
492533
|
}
|
|
492230
|
-
function
|
|
492534
|
+
function xmlDeclarationPrefixLength2(xml) {
|
|
492231
492535
|
const match = /^\uFEFF?\s*<\?xml[\s\S]*?\?>\s*/i.exec(xml);
|
|
492232
492536
|
return match ? match[0].length : 0;
|
|
492233
492537
|
}
|
|
492234
|
-
function
|
|
492538
|
+
function utf8ByteLength9(xml, codeUnitIndex) {
|
|
492235
492539
|
if (codeUnitIndex <= 0)
|
|
492236
492540
|
return 0;
|
|
492237
492541
|
if (codeUnitIndex >= xml.length)
|
|
@@ -496506,8 +496810,8 @@ function buildStoryPartBytePatches(previous3, next, encoder7, readLivePartBytes,
|
|
|
496506
496810
|
if (!range)
|
|
496507
496811
|
return { patches: null, reason: "no-live-range" };
|
|
496508
496812
|
const expected = encoder7.encode(priorBlock.xml);
|
|
496509
|
-
const
|
|
496510
|
-
if (!
|
|
496813
|
+
const matches2 = rangeSource ? boundedLiveWindowMatches(rangeSource, range.startByte, range.endByte, expected) : liveWindowMatches(liveBytes, range.startByte, range.endByte, expected);
|
|
496814
|
+
if (!matches2) {
|
|
496511
496815
|
return { patches: null, reason: "live-window-mismatch" };
|
|
496512
496816
|
}
|
|
496513
496817
|
patches.push({
|
|
@@ -496945,7 +497249,7 @@ var init_collaboration_v2_projection = __esm(() => {
|
|
|
496945
497249
|
|
|
496946
497250
|
// ../../../v2/headless/dist/internal/collaboration-v2-source-bootstrap.js
|
|
496947
497251
|
function extractRootEnvelopeBounds(xml) {
|
|
496948
|
-
const rootSearchStart =
|
|
497252
|
+
const rootSearchStart = xmlDeclarationPrefixLength3(xml);
|
|
496949
497253
|
const openRe = /<([^\s/>]+)\b[^>]*>/g;
|
|
496950
497254
|
openRe.lastIndex = rootSearchStart;
|
|
496951
497255
|
const openMatch = openRe.exec(xml);
|
|
@@ -496976,7 +497280,7 @@ function extractRootEnvelopeBounds(xml) {
|
|
|
496976
497280
|
selfClosing: false
|
|
496977
497281
|
};
|
|
496978
497282
|
}
|
|
496979
|
-
function
|
|
497283
|
+
function xmlDeclarationPrefixLength3(xml) {
|
|
496980
497284
|
const match = /^\uFEFF?\s*<\?xml[\s\S]*?\?>\s*/i.exec(xml);
|
|
496981
497285
|
return match ? match[0].length : 0;
|
|
496982
497286
|
}
|
|
@@ -497032,228 +497336,6 @@ function extractNamedContainerEnvelopeInWindow(xml, searchStart, searchEnd, loca
|
|
|
497032
497336
|
return { openTagXml, closeTagXml, innerStart: contentStart, innerEnd: closeIndex };
|
|
497033
497337
|
}
|
|
497034
497338
|
|
|
497035
|
-
// ../../../v2/collaboration-v2/dist/setup/story-paragraph-seed.js
|
|
497036
|
-
function storySeedForSource(input) {
|
|
497037
|
-
const canonical = scanWmlParagraphSeedSpans(input.bytes);
|
|
497038
|
-
const shared = scanParagraphXmlSpans({ bytes: input.bytes });
|
|
497039
|
-
const rawParagraphs = canonical.length > 0 ? canonical : shared.length > 0 ? shared.map((span) => ({
|
|
497040
|
-
xml: span.xml,
|
|
497041
|
-
byteStart: span.byteStart,
|
|
497042
|
-
byteEnd: span.byteEnd,
|
|
497043
|
-
ordinal: span.ordinal,
|
|
497044
|
-
paraId: span.paraId,
|
|
497045
|
-
blockId: blockIdForParagraphXmlSpan(span)
|
|
497046
|
-
})) : scanParagraphXmlSpansLocal(input.bytes, input.storyKind);
|
|
497047
|
-
const window2 = resolveStoryContentWindow2(input.bytes, input.storyKind, rawParagraphs);
|
|
497048
|
-
const rootNamespaceBindings = readRootNamespaceBindingsFromBytes(input.bytes);
|
|
497049
|
-
const resolveNamespaceBindings = createParagraphNamespaceBindingResolver(input.bytes, rootNamespaceBindings);
|
|
497050
|
-
const paragraphs2 = withTableRefs(input.bytes, input.storyId, addLeadingXml(input.bytes, input.storyKind, rawParagraphs)).map((paragraph4) => ({
|
|
497051
|
-
...paragraph4,
|
|
497052
|
-
namespaceBindings: paragraph4.namespaceBindings ?? resolveNamespaceBindings(paragraph4)
|
|
497053
|
-
}));
|
|
497054
|
-
const trailingStart = rawParagraphs.at(-1)?.byteEnd ?? window2.byteStart;
|
|
497055
|
-
return {
|
|
497056
|
-
paragraphs: paragraphs2,
|
|
497057
|
-
trailingXml: TEXT_DECODER10.decode(input.bytes.slice(trailingStart, window2.byteEnd))
|
|
497058
|
-
};
|
|
497059
|
-
}
|
|
497060
|
-
function scanWmlParagraphSeedSpans(bytes) {
|
|
497061
|
-
const xml = TEXT_DECODER10.decode(bytes);
|
|
497062
|
-
const scan = scanWmlParagraphSpans(xml);
|
|
497063
|
-
if (!scan.ok)
|
|
497064
|
-
return [];
|
|
497065
|
-
const spans = [];
|
|
497066
|
-
let charCursor = 0;
|
|
497067
|
-
let byteCursor = leadingBomLength2(bytes);
|
|
497068
|
-
let containingParagraphEnd = -1;
|
|
497069
|
-
for (const paragraph4 of scan.paragraphs) {
|
|
497070
|
-
if (paragraph4.openStart < containingParagraphEnd)
|
|
497071
|
-
continue;
|
|
497072
|
-
const ordinal = spans.length;
|
|
497073
|
-
byteCursor += TEXT_ENCODER6.encode(xml.slice(charCursor, paragraph4.openStart)).length;
|
|
497074
|
-
const paragraphXml = xml.slice(paragraph4.openStart, paragraph4.closeEnd);
|
|
497075
|
-
const byteStart = byteCursor;
|
|
497076
|
-
const byteEnd = byteStart + TEXT_ENCODER6.encode(paragraphXml).length;
|
|
497077
|
-
spans.push({
|
|
497078
|
-
xml: paragraphXml,
|
|
497079
|
-
byteStart,
|
|
497080
|
-
byteEnd,
|
|
497081
|
-
charStart: paragraph4.openStart,
|
|
497082
|
-
charEnd: paragraph4.closeEnd,
|
|
497083
|
-
ordinal,
|
|
497084
|
-
paraId: paragraph4.paraId,
|
|
497085
|
-
blockId: blockIdForParagraphXmlSpan({ paraId: paragraph4.paraId, ordinal }),
|
|
497086
|
-
namespaceBindings: paragraph4.namespaceBindings
|
|
497087
|
-
});
|
|
497088
|
-
containingParagraphEnd = paragraph4.closeEnd;
|
|
497089
|
-
charCursor = paragraph4.closeEnd;
|
|
497090
|
-
byteCursor = byteEnd;
|
|
497091
|
-
}
|
|
497092
|
-
return spans;
|
|
497093
|
-
}
|
|
497094
|
-
function withTableRefs(bytes, storyId, spans) {
|
|
497095
|
-
const refsByBlockId = buildParagraphTableRefsFromBytes({
|
|
497096
|
-
bytes,
|
|
497097
|
-
storyId,
|
|
497098
|
-
paragraphs: spans.map((span) => ({
|
|
497099
|
-
blockId: span.blockId,
|
|
497100
|
-
byteStart: span.byteStart,
|
|
497101
|
-
byteEnd: span.byteEnd
|
|
497102
|
-
}))
|
|
497103
|
-
});
|
|
497104
|
-
return spans.map((span) => {
|
|
497105
|
-
const refs = refsByBlockId.get(span.blockId);
|
|
497106
|
-
if (!refs)
|
|
497107
|
-
return { ...span };
|
|
497108
|
-
return {
|
|
497109
|
-
...span,
|
|
497110
|
-
tableNodeId: refs.tableNodeId,
|
|
497111
|
-
rowNodeId: refs.rowNodeId,
|
|
497112
|
-
cellNodeId: refs.cellNodeId
|
|
497113
|
-
};
|
|
497114
|
-
});
|
|
497115
|
-
}
|
|
497116
|
-
function addLeadingXml(bytes, storyKind, spans) {
|
|
497117
|
-
const window2 = resolveStoryContentWindow2(bytes, storyKind, spans);
|
|
497118
|
-
let cursor = window2.byteStart;
|
|
497119
|
-
return spans.map((span) => {
|
|
497120
|
-
const leadingXml = TEXT_DECODER10.decode(bytes.slice(cursor, span.byteStart));
|
|
497121
|
-
cursor = span.byteEnd;
|
|
497122
|
-
return {
|
|
497123
|
-
...span,
|
|
497124
|
-
leadingXml
|
|
497125
|
-
};
|
|
497126
|
-
});
|
|
497127
|
-
}
|
|
497128
|
-
function scanParagraphXmlSpansLocal(bytes, storyKind) {
|
|
497129
|
-
const xml = TEXT_DECODER10.decode(bytes);
|
|
497130
|
-
const spans = [];
|
|
497131
|
-
const re = new RegExp(PARAGRAPH_REGEX.source, "g");
|
|
497132
|
-
let match;
|
|
497133
|
-
let charCursor = 0;
|
|
497134
|
-
let byteCursor = leadingBomLength2(bytes);
|
|
497135
|
-
let ordinal = 0;
|
|
497136
|
-
while (match = re.exec(xml)) {
|
|
497137
|
-
const paragraphXml = match[0];
|
|
497138
|
-
const matchIndex = match.index ?? 0;
|
|
497139
|
-
if (matchIndex > charCursor) {
|
|
497140
|
-
byteCursor += TEXT_ENCODER6.encode(xml.slice(charCursor, matchIndex)).length;
|
|
497141
|
-
}
|
|
497142
|
-
const byteStart = byteCursor;
|
|
497143
|
-
const byteEnd = byteStart + TEXT_ENCODER6.encode(paragraphXml).length;
|
|
497144
|
-
const openTag = paragraphXml.match(/^<[\w.-]+:p\b[^>]*[/]?>/)?.[0] ?? "";
|
|
497145
|
-
const paraId = attrLocal3(openTag, "paraId");
|
|
497146
|
-
spans.push({
|
|
497147
|
-
xml: paragraphXml,
|
|
497148
|
-
byteStart,
|
|
497149
|
-
byteEnd,
|
|
497150
|
-
ordinal,
|
|
497151
|
-
blockId: blockIdForParagraphXmlSpan({ paraId, ordinal }),
|
|
497152
|
-
charStart: matchIndex,
|
|
497153
|
-
charEnd: matchIndex + paragraphXml.length,
|
|
497154
|
-
paraId
|
|
497155
|
-
});
|
|
497156
|
-
byteCursor = byteEnd;
|
|
497157
|
-
charCursor = matchIndex + paragraphXml.length;
|
|
497158
|
-
ordinal += 1;
|
|
497159
|
-
}
|
|
497160
|
-
return addLeadingXml(bytes, storyKind, spans);
|
|
497161
|
-
}
|
|
497162
|
-
function resolveStoryContentWindow2(bytes, storyKind, entries4) {
|
|
497163
|
-
const xml = TEXT_DECODER10.decode(bytes);
|
|
497164
|
-
const root = extractRootEnvelope2(xml);
|
|
497165
|
-
if (!root) {
|
|
497166
|
-
return deriveContentWindowFromEntrySpans2(bytes, entries4);
|
|
497167
|
-
}
|
|
497168
|
-
if (storyKind === "main") {
|
|
497169
|
-
const body2 = extractNamedContainerEnvelope2(xml, root.innerStartChar, root.innerEndChar, "body");
|
|
497170
|
-
if (body2) {
|
|
497171
|
-
return {
|
|
497172
|
-
byteStart: utf8ByteLength9(xml, body2.innerStartChar),
|
|
497173
|
-
byteEnd: utf8ByteLength9(xml, body2.innerEndChar)
|
|
497174
|
-
};
|
|
497175
|
-
}
|
|
497176
|
-
}
|
|
497177
|
-
return {
|
|
497178
|
-
byteStart: utf8ByteLength9(xml, root.innerStartChar),
|
|
497179
|
-
byteEnd: utf8ByteLength9(xml, root.innerEndChar)
|
|
497180
|
-
};
|
|
497181
|
-
}
|
|
497182
|
-
function deriveContentWindowFromEntrySpans2(bytes, entries4) {
|
|
497183
|
-
if (entries4.length === 0) {
|
|
497184
|
-
return { byteStart: 0, byteEnd: bytes.length };
|
|
497185
|
-
}
|
|
497186
|
-
return {
|
|
497187
|
-
byteStart: entries4[0].byteStart,
|
|
497188
|
-
byteEnd: entries4[entries4.length - 1].byteEnd
|
|
497189
|
-
};
|
|
497190
|
-
}
|
|
497191
|
-
function extractRootEnvelope2(xml) {
|
|
497192
|
-
const rootSearchStart = xmlDeclarationPrefixLength3(xml);
|
|
497193
|
-
const openMatch = /<([^\s/>]+)\b[^>]*>/.exec(xml.slice(rootSearchStart));
|
|
497194
|
-
if (!openMatch)
|
|
497195
|
-
return null;
|
|
497196
|
-
const openTagStart = rootSearchStart + (openMatch.index ?? 0);
|
|
497197
|
-
const openTagXml = openMatch[0];
|
|
497198
|
-
const tagName = openMatch[1];
|
|
497199
|
-
const closeTagXml = `</${tagName}>`;
|
|
497200
|
-
const closeTagStart = xml.lastIndexOf(closeTagXml);
|
|
497201
|
-
if (closeTagStart < openTagStart + openTagXml.length) {
|
|
497202
|
-
return null;
|
|
497203
|
-
}
|
|
497204
|
-
return {
|
|
497205
|
-
innerStartChar: openTagStart + openTagXml.length,
|
|
497206
|
-
innerEndChar: closeTagStart
|
|
497207
|
-
};
|
|
497208
|
-
}
|
|
497209
|
-
function extractNamedContainerEnvelope2(xml, searchStart, searchEnd, localName3) {
|
|
497210
|
-
const segment = xml.slice(searchStart, searchEnd);
|
|
497211
|
-
const match = new RegExp(`<([\\w.-]+:)?${localName3}\\b[^>]*>`).exec(segment);
|
|
497212
|
-
if (!match)
|
|
497213
|
-
return null;
|
|
497214
|
-
const openTagStart = searchStart + (match.index ?? 0);
|
|
497215
|
-
const openTagXml = match[0];
|
|
497216
|
-
const openTagName = /^<([^\s/>]+)/.exec(openTagXml)?.[1];
|
|
497217
|
-
if (!openTagName)
|
|
497218
|
-
return null;
|
|
497219
|
-
const closeTagXml = `</${openTagName}>`;
|
|
497220
|
-
const closeTagStart = xml.lastIndexOf(closeTagXml, searchEnd);
|
|
497221
|
-
const innerStartChar = openTagStart + openTagXml.length;
|
|
497222
|
-
if (closeTagStart < innerStartChar) {
|
|
497223
|
-
return null;
|
|
497224
|
-
}
|
|
497225
|
-
return {
|
|
497226
|
-
innerStartChar,
|
|
497227
|
-
innerEndChar: closeTagStart
|
|
497228
|
-
};
|
|
497229
|
-
}
|
|
497230
|
-
function xmlDeclarationPrefixLength3(xml) {
|
|
497231
|
-
const match = /^\uFEFF?\s*<\?xml[\s\S]*?\?>\s*/i.exec(xml);
|
|
497232
|
-
return match ? match[0].length : 0;
|
|
497233
|
-
}
|
|
497234
|
-
function utf8ByteLength9(xml, codeUnitIndex) {
|
|
497235
|
-
if (codeUnitIndex <= 0)
|
|
497236
|
-
return 0;
|
|
497237
|
-
return TEXT_ENCODER6.encode(xml.slice(0, codeUnitIndex)).length;
|
|
497238
|
-
}
|
|
497239
|
-
function leadingBomLength2(bytes) {
|
|
497240
|
-
return bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
497241
|
-
}
|
|
497242
|
-
function attrLocal3(tag, localName3) {
|
|
497243
|
-
const re = new RegExp(String.raw`(?:[\w.-]+:)?${localName3}="([^"]+)"`);
|
|
497244
|
-
return tag.match(re)?.[1] ?? null;
|
|
497245
|
-
}
|
|
497246
|
-
var TEXT_DECODER10, TEXT_ENCODER6, PARAGRAPH_REGEX;
|
|
497247
|
-
var init_story_paragraph_seed = __esm(() => {
|
|
497248
|
-
init_sd_document_session_internal();
|
|
497249
|
-
init_parse_paragraph();
|
|
497250
|
-
init_paragraph_namespace_bindings();
|
|
497251
|
-
init_table_structural_refs();
|
|
497252
|
-
TEXT_DECODER10 = new TextDecoder("utf-8", { fatal: false });
|
|
497253
|
-
TEXT_ENCODER6 = new TextEncoder;
|
|
497254
|
-
PARAGRAPH_REGEX = /<[\w.-]+:p\b[^>]*\/>|<[\w.-]+:p\b[^>]*>[\s\S]*?<\/[\w.-]+:p>/g;
|
|
497255
|
-
});
|
|
497256
|
-
|
|
497257
497339
|
// ../../../v2/collaboration-v2/dist/setup/bootstrap-docx.js
|
|
497258
497340
|
function openBootstrapPackage(docxBytes) {
|
|
497259
497341
|
if (docxBytes.byteLength === 0) {
|
|
@@ -497504,6 +497586,7 @@ var init_setup = __esm(() => {
|
|
|
497504
497586
|
init_bootstrap_docx();
|
|
497505
497587
|
init_bootstrap_docx_single_doc();
|
|
497506
497588
|
init_story_paragraph_seed();
|
|
497589
|
+
init_bom_boundary_repair();
|
|
497507
497590
|
});
|
|
497508
497591
|
|
|
497509
497592
|
// ../../../v2/headless/dist/internal/collaboration-v2-room-state.js
|
|
@@ -502391,6 +502474,8 @@ async function buildCanonicalShardGraph(input) {
|
|
|
502391
502474
|
const projectionHandles = new Map;
|
|
502392
502475
|
const requiredShardIds = new Set;
|
|
502393
502476
|
const maySeedStoryShardsFromLocalSource = input.bootstrap?.bootstrap.committed === true || input.bootstrap?.bootstrap.prepared === true;
|
|
502477
|
+
const origin = input.validation.snapshot?.meta.createdFrom;
|
|
502478
|
+
const hasOriginalSource = input.validation.ok && origin && !origin.migration && origin.byteLength === input.sourceBuffer.byteLength && origin.sha256Zip === sha256Hex2(input.sourceBuffer);
|
|
502394
502479
|
const stories = collectStoryInventory(input.session, input.validation.snapshot).map((story) => ({
|
|
502395
502480
|
story,
|
|
502396
502481
|
shardId: storyShardId2(input.runtime.rootId, story.storyKind, story.partUri),
|
|
@@ -502427,6 +502512,15 @@ async function buildCanonicalShardGraph(input) {
|
|
|
502427
502512
|
await waitForStoryShardSeeded(rootDoc, shardId);
|
|
502428
502513
|
unit = createCollabUnitHandle({ rootDoc, shardId, shardKind: SHARD_KIND.story });
|
|
502429
502514
|
}
|
|
502515
|
+
if (hasOriginalSource && bytes) {
|
|
502516
|
+
bindOriginalBomNoteBoundaries({
|
|
502517
|
+
target: unit,
|
|
502518
|
+
bytes,
|
|
502519
|
+
storyId: story.storyId,
|
|
502520
|
+
storyKind: story.storyKind,
|
|
502521
|
+
partUri: story.partUri
|
|
502522
|
+
});
|
|
502523
|
+
}
|
|
502430
502524
|
const handle = {
|
|
502431
502525
|
shardId,
|
|
502432
502526
|
shardKind: SHARD_KIND.story,
|
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.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.0-next.
|
|
27
|
+
"@superdoc/sdk": "2.23.0-next.4",
|
|
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.5",
|
|
33
|
+
"@superdoc/docx-engine": "0.25.0-next.5",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|