@superdoc-dev/cli 0.16.0-next.10 → 0.16.0-next.12

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 +249 -48
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -68110,7 +68110,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68110
68110
  emptyOptions2 = {};
68111
68111
  });
68112
68112
 
68113
- // ../../packages/superdoc/dist/chunks/SuperConverter-D9c2ow57.es.js
68113
+ // ../../packages/superdoc/dist/chunks/SuperConverter-BoqEhvrr.es.js
68114
68114
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68115
68115
  const fieldValue = extension$1.config[field];
68116
68116
  if (typeof fieldValue === "function")
@@ -104441,6 +104441,17 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
104441
104441
  const usePreviousFont = previousParagraphFont != null && resolvedParagraphProperties.numberingProperties != null && !hasExplicitParagraphRunProperties(paragraphProps);
104442
104442
  const defaultFont = usePreviousFont && previousParagraphFont.fontFamily ? previousParagraphFont.fontFamily : extracted.defaultFont;
104443
104443
  const defaultSize = usePreviousFont && previousParagraphFont.fontSize ? previousParagraphFont.fontSize : extracted.defaultSize;
104444
+ const finalizeParagraphBlocks = (outputBlocks) => {
104445
+ outputBlocks.forEach((block) => {
104446
+ if (block.kind === "paragraph")
104447
+ syncListMarkerFontFromParagraphRuns({
104448
+ block,
104449
+ converterContext,
104450
+ para
104451
+ });
104452
+ });
104453
+ return outputBlocks;
104454
+ };
104444
104455
  if (paragraphAttrs.pageBreakBefore)
104445
104456
  blocks.push({
104446
104457
  kind: "pageBreak",
@@ -104449,7 +104460,7 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
104449
104460
  });
104450
104461
  if (!para.content || para.content.length === 0) {
104451
104462
  if (paragraphProps.runProperties?.vanish)
104452
- return blocks;
104463
+ return finalizeParagraphBlocks(blocks);
104453
104464
  const paragraphMarkTrackedChange = getParagraphMarkTrackedChange(paragraphProps, storyKey);
104454
104465
  const paraPos = positions.get(para);
104455
104466
  const emptyRun = {
@@ -104477,15 +104488,15 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
104477
104488
  sourceAnchor
104478
104489
  });
104479
104490
  if (!trackedChangesConfig)
104480
- return blocks;
104491
+ return finalizeParagraphBlocks(blocks);
104481
104492
  const paragraphBlock = blocks[blocks.length - 1];
104482
104493
  if (paragraphBlock?.kind !== "paragraph")
104483
- return blocks;
104494
+ return finalizeParagraphBlocks(blocks);
104484
104495
  const filteredRuns = applyTrackedChangesModeToRuns(paragraphBlock.runs, trackedChangesConfig, hyperlinkConfig, applyMarksToRun, themeColors, enableComments, storyKey);
104485
104496
  const isGhostTrackedListArtifact = trackedChangesConfig.enabled && isGhostSuppressionMode(trackedChangesConfig.mode) && Boolean(paragraphAttrs.numberingProperties) && Boolean(paragraphMarkTrackedChange) && filteredRuns.length > 0 && filteredRuns.every(isEmptyTextRun);
104486
104497
  if (trackedChangesConfig.enabled && (filteredRuns.length === 0 || isGhostTrackedListArtifact)) {
104487
104498
  blocks.pop();
104488
- return blocks;
104499
+ return finalizeParagraphBlocks(blocks);
104489
104500
  }
104490
104501
  paragraphBlock.runs = filteredRuns;
104491
104502
  paragraphBlock.attrs = {
@@ -104493,7 +104504,7 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
104493
104504
  trackedChangesMode: trackedChangesConfig.mode,
104494
104505
  trackedChangesEnabled: trackedChangesConfig.enabled
104495
104506
  };
104496
- return blocks;
104507
+ return finalizeParagraphBlocks(blocks);
104497
104508
  }
104498
104509
  let currentRuns = [];
104499
104510
  let partIndex = 0;
@@ -104669,7 +104680,7 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
104669
104680
  block.runs = expandRunsForInlineNewlines(block.runs);
104670
104681
  });
104671
104682
  if (!trackedChangesConfig)
104672
- return blocks;
104683
+ return finalizeParagraphBlocks(blocks);
104673
104684
  const processedBlocks = [];
104674
104685
  blocks.forEach((block) => {
104675
104686
  if (block.kind !== "paragraph") {
@@ -104687,7 +104698,7 @@ function paragraphToFlowBlocks({ para, nextBlockId, positions, storyKey, tracked
104687
104698
  };
104688
104699
  processedBlocks.push(block);
104689
104700
  });
104690
- return processedBlocks;
104701
+ return finalizeParagraphBlocks(processedBlocks);
104691
104702
  }
104692
104703
  function getLastParagraphFont(blocks) {
104693
104704
  for (let i$1 = blocks.length - 1;i$1 >= 0; i$1--) {
@@ -104697,6 +104708,8 @@ function getLastParagraphFont(blocks) {
104697
104708
  if (!firstRun)
104698
104709
  continue;
104699
104710
  const run$1 = firstRun;
104711
+ if (typeof run$1.text === "string" && run$1.text.length === 0)
104712
+ continue;
104700
104713
  const fontFamily = typeof run$1.fontFamily === "string" ? run$1.fontFamily.trim() : "";
104701
104714
  const fontSize = typeof run$1.fontSize === "number" && Number.isFinite(run$1.fontSize) ? run$1.fontSize : NaN;
104702
104715
  if (fontFamily.length > 0 && fontSize > 0)
@@ -104730,6 +104743,18 @@ function handleParagraphNode(node3, context) {
104730
104743
  if (cached) {
104731
104744
  const delta = pmStart - cached.pmStart;
104732
104745
  const reusedBlocks = shiftCachedBlocks(cached.blocks, delta);
104746
+ const paragraphProps = node3.attrs?.paragraphProperties;
104747
+ const previousParagraphFont$2 = !hasExplicitParagraphRunProperties(paragraphProps) ? getLastParagraphFont(blocks) : undefined;
104748
+ reusedBlocks.forEach((block) => {
104749
+ if (block.kind === "paragraph")
104750
+ syncListMarkerFontFromParagraphRuns({
104751
+ block,
104752
+ converterContext,
104753
+ para: node3,
104754
+ contentFontSource: "paragraph",
104755
+ previousParagraphFont: previousParagraphFont$2
104756
+ });
104757
+ });
104733
104758
  applyTrackedGhostListAdjustments(node3, reusedBlocks, context);
104734
104759
  reusedBlocks.forEach((block) => {
104735
104760
  blocks.push(block);
@@ -127787,7 +127812,7 @@ var isRegExp = (value) => {
127787
127812
  };
127788
127813
  }, browser2, process3, cachedSetTimeout2, cachedClearTimeout2, queue2, draining2 = false, currentQueue2, queueIndex2 = -1, browserExports2, process$12, TWIPS_PER_INCH$1 = 1440, PX_PER_PT, VALID_TRACKED_MODES, DEFAULT_HYPERLINK_CONFIG, ATOMIC_INLINE_TYPES, TOKEN_INLINE_TYPES, isValidTrackedMode = (value) => {
127789
127814
  return typeof value === "string" && VALID_TRACKED_MODES.includes(value);
127790
- }, isTextRun$1 = (run$1) => {
127815
+ }, isTextRun$2 = (run$1) => {
127791
127816
  return "text" in run$1 && run$1.kind !== "tab";
127792
127817
  }, stripTrackedChangeFromRun = (run$1) => {
127793
127818
  if ("trackedChange" in run$1 && run$1.trackedChange)
@@ -127799,7 +127824,7 @@ var isRegExp = (value) => {
127799
127824
  return run$1.trackedChanges;
127800
127825
  return run$1.trackedChange ? [run$1.trackedChange] : [];
127801
127826
  }, isTrackedChangeRun = (run$1) => {
127802
- return isTextRun$1(run$1) || run$1.kind === "break";
127827
+ return isTextRun$2(run$1) || run$1.kind === "break";
127803
127828
  }, runHasTrackedChangeKind = (run$1, kind) => {
127804
127829
  if (!isTrackedChangeRun(run$1))
127805
127830
  return false;
@@ -127882,14 +127907,14 @@ var isRegExp = (value) => {
127882
127907
  runs.forEach((run$1) => stripTrackedChangeFromRun(run$1));
127883
127908
  else
127884
127909
  runs.forEach((run$1) => {
127885
- if (isTextRun$1(run$1))
127910
+ if (isTextRun$2(run$1))
127886
127911
  applyFormatChangeMarks(run$1, config$42, hyperlinkConfig, applyMarksToRun$1, themeColors, enableComments, storyKey);
127887
127912
  });
127888
127913
  return runs;
127889
127914
  }
127890
127915
  const filtered = [];
127891
127916
  runs.forEach((run$1) => {
127892
- if (!isTextRun$1(run$1) && run$1.kind !== "break") {
127917
+ if (!isTextRun$2(run$1) && run$1.kind !== "break") {
127893
127918
  filtered.push(run$1);
127894
127919
  return;
127895
127920
  }
@@ -127907,7 +127932,7 @@ var isRegExp = (value) => {
127907
127932
  filtered.forEach((run$1) => stripTrackedChangeFromRun(run$1));
127908
127933
  else {
127909
127934
  filtered.forEach((run$1) => {
127910
- if (isTextRun$1(run$1))
127935
+ if (isTextRun$2(run$1))
127911
127936
  applyFormatChangeMarks(run$1, config$42, hyperlinkConfig || DEFAULT_HYPERLINK_CONFIG, applyMarksToRun$1, themeColors, enableComments, storyKey);
127912
127937
  });
127913
127938
  if ((config$42.mode === "original" || config$42.mode === "final") && config$42.enabled)
@@ -128499,6 +128524,11 @@ var isRegExp = (value) => {
128499
128524
  inlineDirection,
128500
128525
  writingMode
128501
128526
  };
128527
+ }, numberingDefinesMarkerFontFamily = (numberingProperties, converterContext) => {
128528
+ const numId = numberingProperties?.numId;
128529
+ if (numId == null || numId === 0 || !converterContext)
128530
+ return false;
128531
+ return getNumberingProperties$1("runProperties", converterContext, numberingProperties?.ilvl ?? 0, numId).fontFamily != null;
128502
128532
  }, DEFAULT_DECIMAL_SEPARATOR = ".", DEFAULT_TAB_INTERVAL_TWIPS = 720, normalizeColor$1 = (value) => {
128503
128533
  if (typeof value !== "string")
128504
128534
  return;
@@ -128681,15 +128711,11 @@ var isRegExp = (value) => {
128681
128711
  if (normalizedNumberingProperties && normalizedListRendering) {
128682
128712
  const markerRunAttrs = computeRunAttrs(resolveRunProperties(converterContext, resolvedParagraphProperties.runProperties, resolvedParagraphProperties, converterContext.tableInfo, true, Boolean(paragraphProperties.numberingProperties)), converterContext);
128683
128713
  let markerFontFallback;
128684
- if (!hasExplicitParagraphRunProperties(paragraphProperties) && previousParagraphFont) {
128685
- const numProps = paragraphProperties.numberingProperties;
128686
- const numId = numProps?.numId;
128687
- const ilvl = numProps?.ilvl ?? 0;
128714
+ if (!hasExplicitParagraphRunProperties(paragraphProperties) && previousParagraphFont)
128688
128715
  markerFontFallback = {
128689
- fontFamily: (numId != null && numId !== 0 ? getNumberingProperties$1("runProperties", converterContext, ilvl, numId) : {}).fontFamily != null ? undefined : previousParagraphFont.fontFamily,
128716
+ fontFamily: numberingDefinesMarkerFontFamily(paragraphProperties.numberingProperties, converterContext) ? undefined : previousParagraphFont.fontFamily,
128690
128717
  fontSize: previousParagraphFont.fontSize
128691
128718
  };
128692
- }
128693
128719
  paragraphAttrs.wordLayout = computeWordParagraphLayout({
128694
128720
  paragraph: paragraphAttrs,
128695
128721
  listRenderingAttrs: normalizedListRendering,
@@ -129431,6 +129457,84 @@ var isRegExp = (value) => {
129431
129457
  merged.script = script;
129432
129458
  }
129433
129459
  return merged;
129460
+ }, isTextRun$1 = (run$1) => ("text" in run$1), pickFontPartial = (fontFamily, fontSize) => {
129461
+ const partial = {};
129462
+ if (typeof fontFamily === "string" && fontFamily.trim().length > 0)
129463
+ partial.fontFamily = fontFamily.trim();
129464
+ if (typeof fontSize === "number" && Number.isFinite(fontSize) && fontSize > 0)
129465
+ partial.fontSize = fontSize;
129466
+ return Object.keys(partial).length > 0 ? partial : undefined;
129467
+ }, getFontFromRuns = (runs) => {
129468
+ for (const run$1 of runs) {
129469
+ if (!isTextRun$1(run$1))
129470
+ continue;
129471
+ if (typeof run$1.text === "string" && run$1.text.length === 0)
129472
+ continue;
129473
+ const partial = pickFontPartial(run$1.fontFamily, run$1.fontSize);
129474
+ if (partial)
129475
+ return partial;
129476
+ }
129477
+ }, getFontFromTextStyleMark = (attrs) => {
129478
+ const probe = {
129479
+ text: "",
129480
+ fontFamily: "",
129481
+ fontSize: 0
129482
+ };
129483
+ applyTextStyleMark(probe, attrs);
129484
+ return pickFontPartial(probe.fontFamily, probe.fontSize);
129485
+ }, getFontFromParagraphContent = (node3) => {
129486
+ let found$1;
129487
+ const visit2 = (current) => {
129488
+ if (found$1 || current == null || typeof current !== "object")
129489
+ return;
129490
+ const candidate = current;
129491
+ if ((candidate.isText === true || typeof candidate.text === "string") && candidate.marks?.length)
129492
+ for (const mark of candidate.marks) {
129493
+ if ((typeof mark.type === "string" ? mark.type : mark.type?.name) !== "textStyle")
129494
+ continue;
129495
+ const partial = getFontFromTextStyleMark(mark.attrs ?? {});
129496
+ if (partial) {
129497
+ found$1 = partial;
129498
+ return;
129499
+ }
129500
+ }
129501
+ candidate.content?.forEach?.(visit2);
129502
+ };
129503
+ visit2(node3);
129504
+ return found$1;
129505
+ }, resolveContentFont = (block, para, source, previousParagraphFont) => {
129506
+ const fromRuns = getFontFromRuns(block.runs);
129507
+ const fromPara = para ? getFontFromParagraphContent(para) : undefined;
129508
+ if (source === "paragraph") {
129509
+ if (fromPara)
129510
+ return fromPara;
129511
+ return fromRuns ?? previousParagraphFont;
129512
+ }
129513
+ return fromRuns ?? fromPara;
129514
+ }, syncListMarkerFontFromParagraphRuns = ({ block, converterContext, para, contentFontSource = "runs", previousParagraphFont }) => {
129515
+ const markerRun = block.attrs?.wordLayout?.marker?.run;
129516
+ if (!markerRun)
129517
+ return;
129518
+ const contentFont = resolveContentFont(block, para, contentFontSource, previousParagraphFont);
129519
+ if (!contentFont)
129520
+ return;
129521
+ const paragraphProperties = para?.attrs?.paragraphProperties != null && typeof para.attrs.paragraphProperties === "object" ? para.attrs.paragraphProperties : undefined;
129522
+ const hasLiveTextStyleFont = para ? getFontFromParagraphContent(para) != null : false;
129523
+ const allowBodyFontSync = !hasExplicitParagraphRunProperties(paragraphProperties) || hasLiveTextStyleFont;
129524
+ if (contentFontSource === "paragraph") {
129525
+ const firstRun = block.runs[0];
129526
+ if (firstRun && isTextRun$1(firstRun) && firstRun.text.length === 0) {
129527
+ if (contentFont.fontFamily)
129528
+ firstRun.fontFamily = contentFont.fontFamily;
129529
+ if (contentFont.fontSize)
129530
+ firstRun.fontSize = contentFont.fontSize;
129531
+ }
129532
+ }
129533
+ const preserveNumberingFontFamily = numberingDefinesMarkerFontFamily(block.attrs?.numberingProperties, converterContext);
129534
+ if (allowBodyFontSync && !preserveNumberingFontFamily && contentFont.fontFamily)
129535
+ markerRun.fontFamily = contentFont.fontFamily;
129536
+ if (allowBodyFontSync && contentFont.fontSize)
129537
+ markerRun.fontSize = contentFont.fontSize;
129434
129538
  }, buildSyntheticTextNode = (displayText, marks) => ({
129435
129539
  type: "text",
129436
129540
  text: displayText,
@@ -130696,7 +130800,7 @@ var isRegExp = (value) => {
130696
130800
  state.kern = kernNode.attributes["w:val"];
130697
130801
  }
130698
130802
  }, SuperConverter;
130699
- var init_SuperConverter_D9c2ow57_es = __esm(() => {
130803
+ var init_SuperConverter_BoqEhvrr_es = __esm(() => {
130700
130804
  init_rolldown_runtime_Bg48TavK_es();
130701
130805
  init_jszip_C49i9kUs_es();
130702
130806
  init_xml_js_CqGKpaft_es();
@@ -169470,7 +169574,7 @@ var init_SuperConverter_D9c2ow57_es = __esm(() => {
169470
169574
  };
169471
169575
  });
169472
169576
 
169473
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-evnTxkbH.es.js
169577
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-BrbwjtJZ.es.js
169474
169578
  function parseSizeUnit(val = "0") {
169475
169579
  const length3 = val.toString() || "0";
169476
169580
  const value = Number.parseFloat(length3);
@@ -179801,8 +179905,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
179801
179905
  }
179802
179906
  };
179803
179907
  };
179804
- var init_create_headless_toolbar_evnTxkbH_es = __esm(() => {
179805
- init_SuperConverter_D9c2ow57_es();
179908
+ var init_create_headless_toolbar_BrbwjtJZ_es = __esm(() => {
179909
+ init_SuperConverter_BoqEhvrr_es();
179806
179910
  init_uuid_qzgm05fK_es();
179807
179911
  init_constants_D_X7xF4s_es();
179808
179912
  init_dist_B8HfvhaK_es();
@@ -228965,7 +229069,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
228965
229069
  init_remark_gfm_BhnWr3yf_es();
228966
229070
  });
228967
229071
 
228968
- // ../../packages/superdoc/dist/chunks/src-DKMFU0g3.es.js
229072
+ // ../../packages/superdoc/dist/chunks/src-HGVtAenV.es.js
228969
229073
  function deleteProps(obj, propOrProps) {
228970
229074
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
228971
229075
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -283300,7 +283404,7 @@ function updateMaxFontInfo(currentMaxSize, currentMaxInfo, newRun) {
283300
283404
  return getFontInfoFromRun(newRun);
283301
283405
  return currentMaxInfo;
283302
283406
  }
283303
- function isTextRun$2(run2) {
283407
+ function isTextRun$22(run2) {
283304
283408
  return run2.kind === "text" || run2.kind === undefined;
283305
283409
  }
283306
283410
  function isTabRun(run2) {
@@ -283427,9 +283531,9 @@ async function measureBlock(block, constraints) {
283427
283531
  async function measureParagraphBlock(block, maxWidth) {
283428
283532
  const ctx$1 = getCanvasContext();
283429
283533
  const wordLayout = block.attrs?.wordLayout;
283430
- const firstTextRunWithSize = block.runs.find((run2) => isTextRun$2(run2) && ("fontSize" in run2) && run2.fontSize != null);
283534
+ const firstTextRunWithSize = block.runs.find((run2) => isTextRun$22(run2) && ("fontSize" in run2) && run2.fontSize != null);
283431
283535
  const fallbackFontSize = normalizeFontSize2(firstTextRunWithSize?.fontSize, DEFAULT_PARAGRAPH_FONT_SIZE);
283432
- const fallbackFontFamily = block.runs.find((run2) => isTextRun$2(run2) && typeof run2.fontFamily === "string" && run2.fontFamily.trim().length > 0)?.fontFamily ?? DEFAULT_PARAGRAPH_FONT_FAMILY;
283536
+ const fallbackFontFamily = block.runs.find((run2) => isTextRun$22(run2) && typeof run2.fontFamily === "string" && run2.fontFamily.trim().length > 0)?.fontFamily ?? DEFAULT_PARAGRAPH_FONT_FAMILY;
283433
283537
  const normalizedRuns = normalizeRunsForMeasurement(block.runs, fallbackFontSize, fallbackFontFamily);
283434
283538
  const markerInfo = wordLayout?.marker ? (() => {
283435
283539
  const { font: markerFont } = buildFontString({
@@ -283651,10 +283755,10 @@ async function measureParagraphBlock(block, maxWidth) {
283651
283755
  });
283652
283756
  } else
283653
283757
  runsToProcess.push(run2);
283654
- if (runsToProcess.some((run2) => isTextRun$2(run2) && typeof run2.text === "string" && run2.text.includes("\t"))) {
283758
+ if (runsToProcess.some((run2) => isTextRun$22(run2) && typeof run2.text === "string" && run2.text.includes("\t"))) {
283655
283759
  const expandedRuns = [];
283656
283760
  for (const run2 of runsToProcess) {
283657
- if (!isTextRun$2(run2) || typeof run2.text !== "string" || !run2.text.includes("\t")) {
283761
+ if (!isTextRun$22(run2) || typeof run2.text !== "string" || !run2.text.includes("\t")) {
283658
283762
  expandedRuns.push(run2);
283659
283763
  continue;
283660
283764
  }
@@ -321734,7 +321838,80 @@ menclose::after {
321734
321838
  }
321735
321839
  }
321736
321840
  }
321737
- }, ENDNOTE_MARKER_DATA_ATTR = "data-sd-endnote-number", DEFAULT_MARKER_FONT_FAMILY = "Arial", DEFAULT_MARKER_FONT_SIZE = 12, FontReadinessGate = class {
321841
+ }, ENDNOTE_MARKER_DATA_ATTR = "data-sd-endnote-number", DEFAULT_MARKER_FONT_FAMILY = "Arial", DEFAULT_MARKER_FONT_SIZE = 12, FontLateLoadReflowScheduler = class {
321842
+ #quietMs;
321843
+ #cooldownMs;
321844
+ #flush;
321845
+ #scheduleTimeout;
321846
+ #cancelTimeout;
321847
+ #pending = /* @__PURE__ */ new Set;
321848
+ #quietHandle = null;
321849
+ #cooldownHandle = null;
321850
+ #trailing = false;
321851
+ constructor(options) {
321852
+ this.#quietMs = options.quietMs ?? 250;
321853
+ this.#cooldownMs = options.cooldownMs ?? 2000;
321854
+ this.#flush = options.flush;
321855
+ this.#scheduleTimeout = options.scheduleTimeout ?? ((cb, ms) => globalThis.setTimeout(cb, ms));
321856
+ this.#cancelTimeout = options.cancelTimeout ?? ((handle3) => globalThis.clearTimeout(handle3));
321857
+ }
321858
+ schedule(changedFaceKeys) {
321859
+ let added = false;
321860
+ for (const key2 of changedFaceKeys)
321861
+ if (!this.#pending.has(key2)) {
321862
+ this.#pending.add(key2);
321863
+ added = true;
321864
+ }
321865
+ if (!added)
321866
+ return;
321867
+ if (this.#cooldownHandle !== null) {
321868
+ this.#trailing = true;
321869
+ return;
321870
+ }
321871
+ if (this.#quietHandle !== null)
321872
+ return;
321873
+ this.#quietHandle = this.#scheduleTimeout(() => this.#onQuietElapsed(), this.#quietMs);
321874
+ }
321875
+ cancel() {
321876
+ this.#clearTimers();
321877
+ this.#pending.clear();
321878
+ this.#trailing = false;
321879
+ }
321880
+ #onQuietElapsed() {
321881
+ this.#quietHandle = null;
321882
+ this.#doFlush("quiet");
321883
+ }
321884
+ #onCooldownElapsed() {
321885
+ this.#cooldownHandle = null;
321886
+ if (this.#trailing && this.#pending.size > 0)
321887
+ this.#doFlush("throttle");
321888
+ }
321889
+ #doFlush(reason) {
321890
+ this.#trailing = false;
321891
+ try {
321892
+ if (this.#pending.size > 0) {
321893
+ const faceKeys = [...this.#pending];
321894
+ this.#pending.clear();
321895
+ this.#flush({
321896
+ reason,
321897
+ faceKeys
321898
+ });
321899
+ }
321900
+ } catch {} finally {
321901
+ this.#cooldownHandle = this.#scheduleTimeout(() => this.#onCooldownElapsed(), this.#cooldownMs);
321902
+ }
321903
+ }
321904
+ #clearTimers() {
321905
+ if (this.#quietHandle !== null) {
321906
+ this.#cancelTimeout(this.#quietHandle);
321907
+ this.#quietHandle = null;
321908
+ }
321909
+ if (this.#cooldownHandle !== null) {
321910
+ this.#cancelTimeout(this.#cooldownHandle);
321911
+ this.#cooldownHandle = null;
321912
+ }
321913
+ }
321914
+ }, FontReadinessGate = class {
321738
321915
  #getDocumentFonts;
321739
321916
  #getRequiredFaces;
321740
321917
  #resolveFamilies;
@@ -321753,6 +321930,7 @@ menclose::after {
321753
321930
  #seenAvailableFaces = /* @__PURE__ */ new Set;
321754
321931
  #lastSummary = null;
321755
321932
  #loadingDoneHandler = null;
321933
+ #lateLoadScheduler;
321756
321934
  constructor(options) {
321757
321935
  this.#getDocumentFonts = options.getDocumentFonts;
321758
321936
  this.#getRequiredFaces = options.getRequiredFaces ?? null;
@@ -321763,6 +321941,13 @@ menclose::after {
321763
321941
  this.#onRegistryResolved = options.onRegistryResolved ?? null;
321764
321942
  this.#timeoutMs = options.timeoutMs ?? 3000;
321765
321943
  this.#invalidateCaches = options.invalidateCaches ?? defaultInvalidate;
321944
+ this.#lateLoadScheduler = new FontLateLoadReflowScheduler({
321945
+ quietMs: options.reflowQuietMs,
321946
+ cooldownMs: options.reflowCooldownMs,
321947
+ flush: () => this.#flushLateFontLoads(),
321948
+ scheduleTimeout: options.scheduleTimeout,
321949
+ cancelTimeout: options.cancelTimeout
321950
+ });
321766
321951
  }
321767
321952
  get fontConfigVersion() {
321768
321953
  return this.#fontConfigVersion;
@@ -321845,17 +322030,29 @@ menclose::after {
321845
322030
  notifyFontConfigChanged() {
321846
322031
  this.#fontConfigVersion += 1;
321847
322032
  bumpFontConfigVersion();
321848
- this.#seenAvailable.clear();
321849
- this.#seenAvailableFaces.clear();
321850
- this.#requiredSignature = "";
322033
+ this.#resetRequiredAndSeen();
322034
+ this.#lateLoadScheduler.cancel();
321851
322035
  this.#invalidateCaches();
321852
322036
  this.#requestReflow();
321853
322037
  }
322038
+ resetForDocumentChange() {
322039
+ this.#lateLoadScheduler.cancel();
322040
+ this.#resetRequiredAndSeen();
322041
+ }
322042
+ #resetRequiredAndSeen() {
322043
+ this.#requiredSignature = "";
322044
+ this.#requiredFaceKeys = /* @__PURE__ */ new Set;
322045
+ this.#requiredFamilies = /* @__PURE__ */ new Set;
322046
+ this.#seenAvailable.clear();
322047
+ this.#seenAvailableFaces.clear();
322048
+ this.#lastSummary = null;
322049
+ }
321854
322050
  dispose() {
321855
322051
  const fontSet = this.#context?.fontSet ?? null;
321856
322052
  if (fontSet && this.#loadingDoneHandler && typeof fontSet.removeEventListener === "function")
321857
322053
  fontSet.removeEventListener("loadingdone", this.#loadingDoneHandler);
321858
322054
  this.#loadingDoneHandler = null;
322055
+ this.#lateLoadScheduler.cancel();
321859
322056
  }
321860
322057
  #resolveContext() {
321861
322058
  if (this.#context && this.#context.fontSet)
@@ -321887,7 +322084,7 @@ menclose::after {
321887
322084
  const faces = event?.fontfaces ?? [];
321888
322085
  if (faces.length === 0)
321889
322086
  return;
321890
- let changed = false;
322087
+ const changedKeys = [];
321891
322088
  if (this.#requiredFaceKeys.size > 0) {
321892
322089
  const loadedFaceKeys = new Set(faces.map((face) => faceKeyOf(face.family, normalizeWeightToken(face.weight), normalizeStyleToken(face.style))));
321893
322090
  for (const key2 of this.#requiredFaceKeys) {
@@ -321895,7 +322092,7 @@ menclose::after {
321895
322092
  continue;
321896
322093
  if (loadedFaceKeys.has(key2)) {
321897
322094
  this.#seenAvailableFaces.add(key2);
321898
- changed = true;
322095
+ changedKeys.push(key2);
321899
322096
  }
321900
322097
  }
321901
322098
  } else {
@@ -321905,15 +322102,18 @@ menclose::after {
321905
322102
  continue;
321906
322103
  if (loadedFamilies.has(normalizeFamilyKey(family$1))) {
321907
322104
  this.#seenAvailable.add(family$1);
321908
- changed = true;
322105
+ changedKeys.push(normalizeFamilyKey(family$1));
321909
322106
  }
321910
322107
  }
321911
322108
  }
321912
- if (!changed)
322109
+ if (changedKeys.length === 0)
321913
322110
  return;
321914
322111
  this.#fontConfigVersion += 1;
321915
322112
  bumpFontConfigVersion();
321916
322113
  this.#invalidateCaches();
322114
+ this.#lateLoadScheduler.schedule(changedKeys);
322115
+ }
322116
+ #flushLateFontLoads() {
321917
322117
  this.#requestReflow();
321918
322118
  }
321919
322119
  }, FACE_STATUS_PRIORITY, DEFAULT_SEMANTIC_FOOTNOTE_HEADING_STYLE, NATIVE_SELECTION_STYLES = `
@@ -321993,13 +322193,13 @@ menclose::after {
321993
322193
  return;
321994
322194
  console.log(...args$1);
321995
322195
  }, 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, TRACKED_MARK_NAMES;
321996
- var init_src_DKMFU0g3_es = __esm(() => {
322196
+ var init_src_HGVtAenV_es = __esm(() => {
321997
322197
  init_rolldown_runtime_Bg48TavK_es();
321998
- init_SuperConverter_D9c2ow57_es();
322198
+ init_SuperConverter_BoqEhvrr_es();
321999
322199
  init_jszip_C49i9kUs_es();
322000
322200
  init_xml_js_CqGKpaft_es();
322001
322201
  init_uuid_qzgm05fK_es();
322002
- init_create_headless_toolbar_evnTxkbH_es();
322202
+ init_create_headless_toolbar_BrbwjtJZ_es();
322003
322203
  init_constants_D_X7xF4s_es();
322004
322204
  init_dist_B8HfvhaK_es();
322005
322205
  init_unified_Dsuw2be5_es();
@@ -352418,6 +352618,7 @@ function print() { __p += __j.call(arguments, '') }
352418
352618
  handler: handleCollaborationReady
352419
352619
  });
352420
352620
  const handleDocumentReplaced = () => {
352621
+ this.#fontGate?.resetForDocumentChange();
352421
352622
  this.#refreshHeaderFooterStructureThenRerender({ purgeCachedEditors: true });
352422
352623
  };
352423
352624
  this.#editor.on("documentReplaced", handleDocumentReplaced);
@@ -356340,11 +356541,11 @@ function print() { __p += __j.call(arguments, '') }
356340
356541
  ]);
356341
356542
  });
356342
356543
 
356343
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DX0SYUhT.es.js
356544
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-SRtgJ7Vz.es.js
356344
356545
  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;
356345
- var init_create_super_doc_ui_DX0SYUhT_es = __esm(() => {
356346
- init_SuperConverter_D9c2ow57_es();
356347
- init_create_headless_toolbar_evnTxkbH_es();
356546
+ var init_create_super_doc_ui_SRtgJ7Vz_es = __esm(() => {
356547
+ init_SuperConverter_BoqEhvrr_es();
356548
+ init_create_headless_toolbar_BrbwjtJZ_es();
356348
356549
  MOD_ALIASES = new Set([
356349
356550
  "Mod",
356350
356551
  "Meta",
@@ -356386,16 +356587,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
356386
356587
 
356387
356588
  // ../../packages/superdoc/dist/super-editor.es.js
356388
356589
  var init_super_editor_es = __esm(() => {
356389
- init_src_DKMFU0g3_es();
356390
- init_SuperConverter_D9c2ow57_es();
356590
+ init_src_HGVtAenV_es();
356591
+ init_SuperConverter_BoqEhvrr_es();
356391
356592
  init_jszip_C49i9kUs_es();
356392
356593
  init_xml_js_CqGKpaft_es();
356393
- init_create_headless_toolbar_evnTxkbH_es();
356594
+ init_create_headless_toolbar_BrbwjtJZ_es();
356394
356595
  init_constants_D_X7xF4s_es();
356395
356596
  init_dist_B8HfvhaK_es();
356396
356597
  init_unified_Dsuw2be5_es();
356397
356598
  init_DocxZipper_nv_KfOqb_es();
356398
- init_create_super_doc_ui_DX0SYUhT_es();
356599
+ init_create_super_doc_ui_SRtgJ7Vz_es();
356399
356600
  init_ui_C5PAS9hY_es();
356400
356601
  init_eventemitter3_BnGqBE_Q_es();
356401
356602
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.16.0-next.10",
3
+ "version": "0.16.0-next.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -33,11 +33,11 @@
33
33
  "access": "public"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@superdoc-dev/cli-darwin-arm64": "0.16.0-next.10",
37
- "@superdoc-dev/cli-darwin-x64": "0.16.0-next.10",
38
- "@superdoc-dev/cli-linux-x64": "0.16.0-next.10",
39
- "@superdoc-dev/cli-windows-x64": "0.16.0-next.10",
40
- "@superdoc-dev/cli-linux-arm64": "0.16.0-next.10"
36
+ "@superdoc-dev/cli-darwin-arm64": "0.16.0-next.12",
37
+ "@superdoc-dev/cli-darwin-x64": "0.16.0-next.12",
38
+ "@superdoc-dev/cli-linux-x64": "0.16.0-next.12",
39
+ "@superdoc-dev/cli-linux-arm64": "0.16.0-next.12",
40
+ "@superdoc-dev/cli-windows-x64": "0.16.0-next.12"
41
41
  },
42
42
  "scripts": {
43
43
  "predev": "node scripts/ensure-superdoc-build.js",