@superdoc-dev/mcp 0.3.0-next.98 → 0.3.0-next.99

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 +62 -105
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51891,7 +51891,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
51891
51891
  emptyOptions2 = {};
51892
51892
  });
51893
51893
 
51894
- // ../../packages/superdoc/dist/chunks/SuperConverter-8A1MBmqJ.es.js
51894
+ // ../../packages/superdoc/dist/chunks/SuperConverter-uW-eKBtZ.es.js
51895
51895
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
51896
51896
  const fieldValue = extension$1.config[field];
51897
51897
  if (typeof fieldValue === "function")
@@ -88922,46 +88922,24 @@ function getBibliographyPartExportPaths(bibliographyPart) {
88922
88922
  bibliographyPart?.itemRelsPath
88923
88923
  ].filter((path2) => typeof path2 === "string" && path2.length > 0);
88924
88924
  }
88925
- function collectReferencedNumIds(convertedXml) {
88926
- const numIds = /* @__PURE__ */ new Set;
88927
- function walkElements$1(elements) {
88928
- if (!Array.isArray(elements))
88929
- return;
88930
- for (const el of elements) {
88931
- if (!el || typeof el !== "object")
88932
- continue;
88933
- if (el.name === "w:numId" && el.attributes?.["w:val"] != null)
88934
- numIds.add(Number(el.attributes["w:val"]));
88935
- if (el.elements)
88936
- walkElements$1(el.elements);
88937
- }
88938
- }
88939
- for (const [path2, xml] of Object.entries(convertedXml))
88940
- if (path2.startsWith("word/") && path2 !== "word/numbering.xml" && xml?.elements)
88941
- walkElements$1(xml.elements);
88942
- return numIds;
88943
- }
88944
- function getAbstractNumIdFromDef(numDef) {
88945
- const abstractEl = numDef.elements?.find((el) => el.name === "w:abstractNumId");
88946
- if (abstractEl?.attributes?.["w:val"] != null)
88947
- return Number(abstractEl.attributes["w:val"]);
88948
- }
88949
- function filterOrphanedNumberingDefinitions(numbering, referencedNumIds) {
88950
- const liveDefinitions = Object.values(numbering.definitions).filter((def) => referencedNumIds.has(Number(def.attributes?.["w:numId"])));
88951
- const referencedAbstractIds = /* @__PURE__ */ new Set;
88952
- for (const def of liveDefinitions) {
88953
- const abstractId = getAbstractNumIdFromDef(def);
88954
- if (abstractId != null)
88955
- referencedAbstractIds.add(abstractId);
88956
- }
88957
- return {
88958
- liveAbstracts: Object.values(numbering.abstracts).filter((abs) => referencedAbstractIds.has(Number(abs.attributes?.["w:abstractNumId"]))),
88959
- liveDefinitions
88960
- };
88961
- }
88962
88925
  function generateCustomXml() {
88963
88926
  return DEFAULT_CUSTOM_XML;
88964
88927
  }
88928
+ function hasBodyNumberingReferences(documentXml) {
88929
+ if (!documentXml || typeof documentXml !== "object")
88930
+ return false;
88931
+ const stack = Array.isArray(documentXml.elements) ? [...documentXml.elements] : [];
88932
+ while (stack.length) {
88933
+ const node2 = stack.pop();
88934
+ if (!node2 || typeof node2 !== "object")
88935
+ continue;
88936
+ if (node2.name === "w:numPr")
88937
+ return true;
88938
+ if (Array.isArray(node2.elements))
88939
+ stack.push(...node2.elements);
88940
+ }
88941
+ return false;
88942
+ }
88965
88943
  var isRegExp = (value) => {
88966
88944
  return Object.prototype.toString.call(value) === "[object RegExp]";
88967
88945
  }, dist_default$1, Fragment = class Fragment2 {
@@ -105666,7 +105644,7 @@ var isRegExp = (value) => {
105666
105644
  state.kern = kernNode.attributes["w:val"];
105667
105645
  }
105668
105646
  }, SuperConverter;
105669
- var init_SuperConverter_8A1MBmqJ_es = __esm(() => {
105647
+ var init_SuperConverter_uW_eKBtZ_es = __esm(() => {
105670
105648
  init_rolldown_runtime_Bg48TavK_es();
105671
105649
  init_jszip_C49i9kUs_es();
105672
105650
  init_xml_js_CqGKpaft_es();
@@ -143448,14 +143426,17 @@ var init_SuperConverter_8A1MBmqJ_es = __esm(() => {
143448
143426
  }
143449
143427
  #exportNumberingFile() {
143450
143428
  const numberingPath = "word/numbering.xml";
143429
+ const sourceHadNumberingXml = Boolean(this.convertedXml[numberingPath]);
143451
143430
  let numberingXml = this.convertedXml[numberingPath];
143452
143431
  if (!numberingXml)
143453
143432
  numberingXml = baseNumbering;
143454
143433
  const currentNumberingXml = numberingXml.elements[0];
143455
- const referencedNumIds = collectReferencedNumIds(this.convertedXml);
143434
+ if (!sourceHadNumberingXml && !hasBodyNumberingReferences(this.convertedXml["word/document.xml"]))
143435
+ return;
143456
143436
  if (this.numbering?.definitions && this.numbering?.abstracts) {
143457
- const { liveAbstracts, liveDefinitions } = filterOrphanedNumberingDefinitions(this.numbering, referencedNumIds);
143458
- currentNumberingXml.elements = [...liveAbstracts, ...liveDefinitions];
143437
+ const abstracts = Object.values(this.numbering.abstracts);
143438
+ const definitions = Object.values(this.numbering.definitions);
143439
+ currentNumberingXml.elements = [...abstracts, ...definitions];
143459
143440
  } else
143460
143441
  currentNumberingXml.elements = [];
143461
143442
  this.convertedXml[numberingPath] = numberingXml;
@@ -143656,7 +143637,7 @@ var init_SuperConverter_8A1MBmqJ_es = __esm(() => {
143656
143637
  };
143657
143638
  });
143658
143639
 
143659
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-1RfXz7Wm.es.js
143640
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DanjyDw8.es.js
143660
143641
  function parseSizeUnit(val = "0") {
143661
143642
  const length = val.toString() || "0";
143662
143643
  const value = Number.parseFloat(length);
@@ -146378,8 +146359,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
146378
146359
  }
146379
146360
  };
146380
146361
  };
146381
- var init_create_headless_toolbar_1RfXz7Wm_es = __esm(() => {
146382
- init_SuperConverter_8A1MBmqJ_es();
146362
+ var init_create_headless_toolbar_DanjyDw8_es = __esm(() => {
146363
+ init_SuperConverter_uW_eKBtZ_es();
146383
146364
  init_constants_DrU4EASo_es();
146384
146365
  init_dist_B8HfvhaK_es();
146385
146366
  CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
@@ -200611,7 +200592,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
200611
200592
  init_remark_gfm_BhnWr3yf_es();
200612
200593
  });
200613
200594
 
200614
- // ../../packages/superdoc/dist/chunks/src-Bnec7ggt.es.js
200595
+ // ../../packages/superdoc/dist/chunks/src-COP-2qVr.es.js
200615
200596
  function deleteProps(obj, propOrProps) {
200616
200597
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
200617
200598
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -295079,13 +295060,13 @@ menclose::after {
295079
295060
  return;
295080
295061
  console.log(...args$1);
295081
295062
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
295082
- var init_src_Bnec7ggt_es = __esm(() => {
295063
+ var init_src_COP_2qVr_es = __esm(() => {
295083
295064
  init_rolldown_runtime_Bg48TavK_es();
295084
- init_SuperConverter_8A1MBmqJ_es();
295065
+ init_SuperConverter_uW_eKBtZ_es();
295085
295066
  init_jszip_C49i9kUs_es();
295086
295067
  init_xml_js_CqGKpaft_es();
295087
295068
  init_uuid_qzgm05fK_es();
295088
- init_create_headless_toolbar_1RfXz7Wm_es();
295069
+ init_create_headless_toolbar_DanjyDw8_es();
295089
295070
  init_constants_DrU4EASo_es();
295090
295071
  init_dist_B8HfvhaK_es();
295091
295072
  init_unified_Dsuw2be5_es();
@@ -320952,7 +320933,7 @@ function print() { __p += __j.call(arguments, '') }
320952
320933
  }
320953
320934
  });
320954
320935
  const numberingData = this.converter.convertedXml["word/numbering.xml"];
320955
- const numbering = this.converter.schemaToXml(numberingData.elements[0]);
320936
+ const numbering = numberingData?.elements?.[0] ? this.converter.schemaToXml(numberingData.elements[0]) : null;
320956
320937
  const appXmlData = this.converter.convertedXml["docProps/app.xml"];
320957
320938
  const appXml = appXmlData?.elements?.[0] ? this.converter.schemaToXml(appXmlData.elements[0]) : null;
320958
320939
  const coreXmlData = this.converter.convertedXml["docProps/core.xml"];
@@ -320962,7 +320943,7 @@ function print() { __p += __j.call(arguments, '') }
320962
320943
  "word/document.xml": String(documentXml),
320963
320944
  "docProps/custom.xml": String(customXml),
320964
320945
  "word/_rels/document.xml.rels": String(rels),
320965
- "word/numbering.xml": String(numbering),
320946
+ ...numbering ? { "word/numbering.xml": String(numbering) } : {},
320966
320947
  "word/styles.xml": String(styles),
320967
320948
  ...updatedHeadersFooters,
320968
320949
  ...appXml ? { "docProps/app.xml": String(appXml) } : {},
@@ -333150,11 +333131,11 @@ function print() { __p += __j.call(arguments, '') }
333150
333131
  ];
333151
333132
  });
333152
333133
 
333153
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BLwvPPRc.es.js
333134
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-UV-HR537.es.js
333154
333135
  var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
333155
- var init_create_super_doc_ui_BLwvPPRc_es = __esm(() => {
333156
- init_SuperConverter_8A1MBmqJ_es();
333157
- init_create_headless_toolbar_1RfXz7Wm_es();
333136
+ var init_create_super_doc_ui_UV_HR537_es = __esm(() => {
333137
+ init_SuperConverter_uW_eKBtZ_es();
333138
+ init_create_headless_toolbar_DanjyDw8_es();
333158
333139
  MOD_ALIASES = new Set([
333159
333140
  "Mod",
333160
333141
  "Meta",
@@ -333196,16 +333177,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
333196
333177
 
333197
333178
  // ../../packages/superdoc/dist/super-editor.es.js
333198
333179
  var init_super_editor_es = __esm(() => {
333199
- init_src_Bnec7ggt_es();
333200
- init_SuperConverter_8A1MBmqJ_es();
333180
+ init_src_COP_2qVr_es();
333181
+ init_SuperConverter_uW_eKBtZ_es();
333201
333182
  init_jszip_C49i9kUs_es();
333202
333183
  init_xml_js_CqGKpaft_es();
333203
- init_create_headless_toolbar_1RfXz7Wm_es();
333184
+ init_create_headless_toolbar_DanjyDw8_es();
333204
333185
  init_constants_DrU4EASo_es();
333205
333186
  init_dist_B8HfvhaK_es();
333206
333187
  init_unified_Dsuw2be5_es();
333207
333188
  init_DocxZipper_Bphhij1P_es();
333208
- init_create_super_doc_ui_BLwvPPRc_es();
333189
+ init_create_super_doc_ui_UV_HR537_es();
333209
333190
  init_ui_CGB3qmy3_es();
333210
333191
  init_eventemitter3_UwU_CLPU_es();
333211
333192
  init_errors_C_DoKMoN_es();
@@ -428392,53 +428373,25 @@ var init_citation_sources = __esm(() => {
428392
428373
  XML_TAG_TO_SIMPLE_FIELD2 = Object.freeze(Object.fromEntries(Object.entries(SIMPLE_FIELD_TO_XML_TAG2).map(([field, tag]) => [tag, field])));
428393
428374
  });
428394
428375
 
428395
- // ../../packages/super-editor/src/editors/v1/core/super-converter/export-helpers/strip-orphaned-numbering.js
428396
- function collectReferencedNumIds2(convertedXml) {
428397
- const numIds = new Set;
428398
- function walkElements3(elements) {
428399
- if (!Array.isArray(elements))
428400
- return;
428401
- for (const el of elements) {
428402
- if (!el || typeof el !== "object")
428403
- continue;
428404
- if (el.name === "w:numId" && el.attributes?.["w:val"] != null) {
428405
- numIds.add(Number(el.attributes["w:val"]));
428406
- }
428407
- if (el.elements)
428408
- walkElements3(el.elements);
428409
- }
428410
- }
428411
- for (const [path3, xml2] of Object.entries(convertedXml)) {
428412
- if (path3.startsWith("word/") && path3 !== "word/numbering.xml" && xml2?.elements) {
428413
- walkElements3(xml2.elements);
428414
- }
428415
- }
428416
- return numIds;
428417
- }
428418
- function getAbstractNumIdFromDef2(numDef) {
428419
- const abstractEl = numDef.elements?.find((el) => el.name === "w:abstractNumId");
428420
- if (abstractEl?.attributes?.["w:val"] != null) {
428421
- return Number(abstractEl.attributes["w:val"]);
428422
- }
428423
- return;
428424
- }
428425
- function filterOrphanedNumberingDefinitions2(numbering, referencedNumIds) {
428426
- const liveDefinitions = Object.values(numbering.definitions).filter((def) => referencedNumIds.has(Number(def.attributes?.["w:numId"])));
428427
- const referencedAbstractIds = new Set;
428428
- for (const def of liveDefinitions) {
428429
- const abstractId = getAbstractNumIdFromDef2(def);
428430
- if (abstractId != null) {
428431
- referencedAbstractIds.add(abstractId);
428432
- }
428433
- }
428434
- const liveAbstracts = Object.values(numbering.abstracts).filter((abs3) => referencedAbstractIds.has(Number(abs3.attributes?.["w:abstractNumId"])));
428435
- return { liveAbstracts, liveDefinitions };
428436
- }
428437
-
428438
428376
  // ../../packages/super-editor/src/editors/v1/core/super-converter/SuperConverter.js
428439
428377
  function generateCustomXml2() {
428440
428378
  return DEFAULT_CUSTOM_XML2;
428441
428379
  }
428380
+ function hasBodyNumberingReferences2(documentXml) {
428381
+ if (!documentXml || typeof documentXml !== "object")
428382
+ return false;
428383
+ const stack = Array.isArray(documentXml.elements) ? [...documentXml.elements] : [];
428384
+ while (stack.length) {
428385
+ const node4 = stack.pop();
428386
+ if (!node4 || typeof node4 !== "object")
428387
+ continue;
428388
+ if (node4.name === "w:numPr")
428389
+ return true;
428390
+ if (Array.isArray(node4.elements))
428391
+ stack.push(...node4.elements);
428392
+ }
428393
+ return false;
428394
+ }
428442
428395
  var xmljs2, FONT_FAMILY_FALLBACKS3, DEFAULT_GENERIC_FALLBACK3 = "sans-serif", DEFAULT_FONT_SIZE_PT2 = 10, CURRENT_APP_VERSION3, collectRunDefaultProperties2 = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state }) => {
428443
428396
  if (!runProps?.elements?.length || !state)
428444
428397
  return;
@@ -429335,14 +429288,18 @@ var init_SuperConverter = __esm(() => {
429335
429288
  }
429336
429289
  #exportNumberingFile() {
429337
429290
  const numberingPath = "word/numbering.xml";
429291
+ const sourceHadNumberingXml = Boolean(this.convertedXml[numberingPath]);
429338
429292
  let numberingXml = this.convertedXml[numberingPath];
429339
429293
  if (!numberingXml)
429340
429294
  numberingXml = baseNumbering2;
429341
429295
  const currentNumberingXml = numberingXml.elements[0];
429342
- const referencedNumIds = collectReferencedNumIds2(this.convertedXml);
429296
+ if (!sourceHadNumberingXml && !hasBodyNumberingReferences2(this.convertedXml["word/document.xml"])) {
429297
+ return;
429298
+ }
429343
429299
  if (this.numbering?.definitions && this.numbering?.abstracts) {
429344
- const { liveAbstracts, liveDefinitions } = filterOrphanedNumberingDefinitions2(this.numbering, referencedNumIds);
429345
- currentNumberingXml.elements = [...liveAbstracts, ...liveDefinitions];
429300
+ const abstracts = Object.values(this.numbering.abstracts);
429301
+ const definitions = Object.values(this.numbering.definitions);
429302
+ currentNumberingXml.elements = [...abstracts, ...definitions];
429346
429303
  } else {
429347
429304
  currentNumberingXml.elements = [];
429348
429305
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/mcp",
3
- "version": "0.3.0-next.98",
3
+ "version": "0.3.0-next.99",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"