@json-to-office/core-docx 6.8.0 → 7.0.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAEV,wBAAwB,EAOxB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAejB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,oFAAoF;IACpF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAoyBD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAkBvC"}
1
+ {"version":3,"file":"createDocumentGenerator.d.ts","sourceRoot":"","sources":["../../src/plugin/createDocumentGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAEV,wBAAwB,EAQxB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAgBjB;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,oFAAoF;IACpF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAq4BD;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,wBAAwB,CAAC,SAAS,EAAE,CAAC,CAkBvC"}
@@ -1336,7 +1336,8 @@ var init_consulting_docx_theme = __esm({
1336
1336
  },
1337
1337
  stat: {
1338
1338
  face: "heading",
1339
- weight: 700,
1339
+ size: 22,
1340
+ weight: 400,
1340
1341
  color: "accent",
1341
1342
  lineHeight: 1
1342
1343
  },
@@ -1643,7 +1644,7 @@ var init_themes = __esm({
1643
1644
  getTheme = (themeName) => {
1644
1645
  return themes[themeName];
1645
1646
  };
1646
- getThemeWithFallback = (themeName, fallbackTheme = "minimal") => {
1647
+ getThemeWithFallback = (themeName, fallbackTheme = "consulting") => {
1647
1648
  const theme = getTheme(themeName) || getTheme(fallbackTheme);
1648
1649
  if (!theme) {
1649
1650
  throw new Error(
@@ -1723,7 +1724,7 @@ function resolveTheme(theme, themeName) {
1723
1724
  if (themeName) {
1724
1725
  return getTheme(themeName);
1725
1726
  }
1726
- return getTheme("minimal");
1727
+ return getTheme("consulting");
1727
1728
  }
1728
1729
  function resolveFontFamily(theme, fontRef) {
1729
1730
  if (!theme?.fonts?.body?.family) {
@@ -3764,7 +3765,9 @@ function createDocxJsRenderer() {
3764
3765
  function buildDocument(ir, resources = /* @__PURE__ */ new Map()) {
3765
3766
  return new Document({
3766
3767
  styles: emitStyles(ir.styles),
3767
- sections: ir.sections.map((section2) => sectionOptions(section2, resources)),
3768
+ sections: ir.sections.map(
3769
+ (section2, index) => sectionOptions(section2, resources, index === ir.sections.length - 1)
3770
+ ),
3768
3771
  ...coreProperties(ir),
3769
3772
  features: {
3770
3773
  updateFields: ir.settings.updateFields,
@@ -3920,7 +3923,7 @@ function collectImagePlacements(ir) {
3920
3923
  }
3921
3924
  return placements;
3922
3925
  }
3923
- function sectionOptions(section2, resources) {
3926
+ function sectionOptions(section2, resources, closesDocument = false) {
3924
3927
  const { page, columns } = section2.properties;
3925
3928
  const options = {
3926
3929
  properties: {
@@ -3959,7 +3962,7 @@ function sectionOptions(section2, resources) {
3959
3962
  }
3960
3963
  } : {}
3961
3964
  },
3962
- children: sectionChildren(section2, resources)
3965
+ children: sectionChildren(section2, resources, closesDocument)
3963
3966
  };
3964
3967
  const headers = chromeSlots(section2.headers, Header, resources);
3965
3968
  if (headers) options.headers = headers;
@@ -3981,12 +3984,13 @@ function chromeSlots(set, Part, resources) {
3981
3984
  function partChildren(part, resources) {
3982
3985
  return part.children.map((block2) => emitBlock(block2, resources));
3983
3986
  }
3984
- function sectionChildren(section2, resources) {
3987
+ function sectionChildren(section2, resources, closesDocument = false) {
3985
3988
  const blocks = section2.children.map((block2) => emitBlock(block2, resources));
3986
3989
  const bookmark = section2.bookmark;
3987
- if (!bookmark) return blocks;
3990
+ const endsInFrame = closesDocument && lastBlockIsFrame(section2);
3991
+ if (!bookmark && !endsInFrame) return blocks;
3988
3992
  const out = [...blocks];
3989
- if (bookmark.opens) {
3993
+ if (bookmark?.opens) {
3990
3994
  const start = new BookmarkStart2(bookmark.name, bookmark.id);
3991
3995
  const first = out[0];
3992
3996
  if (first instanceof Paragraph2) {
@@ -3995,20 +3999,26 @@ function sectionChildren(section2, resources) {
3995
3999
  out.unshift(anchorParagraph(start));
3996
4000
  }
3997
4001
  }
3998
- if (bookmark.closes) {
4002
+ if (bookmark?.closes) {
3999
4003
  const end = new BookmarkEnd2(bookmark.id);
4000
4004
  const last = out[out.length - 1];
4001
- if (last instanceof Paragraph2) {
4005
+ if (last instanceof Paragraph2 && !endsInFrame) {
4002
4006
  last.addChildElement(end);
4003
4007
  } else {
4004
4008
  out.push(anchorParagraph(end));
4005
4009
  }
4010
+ } else if (endsInFrame) {
4011
+ out.push(anchorParagraph());
4006
4012
  }
4007
4013
  return out;
4008
4014
  }
4015
+ function lastBlockIsFrame(section2) {
4016
+ const last = section2.children[section2.children.length - 1];
4017
+ return last?.kind === "paragraph" && last.frame !== void 0;
4018
+ }
4009
4019
  function anchorParagraph(anchor) {
4010
4020
  return new Paragraph2({
4011
- children: [anchor],
4021
+ children: anchor ? [anchor] : [],
4012
4022
  spacing: { before: 0, after: 0, line: 20, lineRule: LineRuleType2.EXACT }
4013
4023
  });
4014
4024
  }
@@ -4827,7 +4837,7 @@ function borders2(value) {
4827
4837
  }
4828
4838
  return out;
4829
4839
  }
4830
- function section(value, ctx) {
4840
+ function section(value, ctx, closesDocument = false) {
4831
4841
  const { page, columns } = value.properties;
4832
4842
  return {
4833
4843
  properties: {
@@ -4879,7 +4889,7 @@ function section(value, ctx) {
4879
4889
  }
4880
4890
  } : {}
4881
4891
  },
4882
- children: sectionChildren2(value, ctx),
4892
+ children: sectionChildren2(value, ctx, closesDocument),
4883
4893
  ...value.headers ? { headers: headerFooterSet(value.headers, ctx) } : {},
4884
4894
  ...value.footers ? { footers: headerFooterSet(value.footers, ctx) } : {}
4885
4895
  };
@@ -4892,8 +4902,16 @@ function headerFooterSet(set, ctx) {
4892
4902
  }
4893
4903
  return out;
4894
4904
  }
4895
- function sectionChildren2(value, ctx) {
4905
+ function sectionChildren2(value, ctx, closesDocument = false) {
4896
4906
  const blocks = value.children.map((child) => block(child, ctx));
4907
+ const last = value.children[value.children.length - 1];
4908
+ if (closesDocument && last?.kind === "paragraph" && last.frame !== void 0)
4909
+ blocks.push({
4910
+ paragraph: {
4911
+ children: [],
4912
+ spacing: { before: 0, after: 0, line: 20, lineRule: "exact" }
4913
+ }
4914
+ });
4897
4915
  const bookmark = value.bookmark;
4898
4916
  if (!bookmark) return blocks;
4899
4917
  return [
@@ -5062,7 +5080,9 @@ async function buildDocumentOptions(ir, charts = [], svgRasterFallback) {
5062
5080
  };
5063
5081
  return {
5064
5082
  styles: emitStyles2(ir.styles),
5065
- sections: ir.sections.map((value) => section(value, ctx)),
5083
+ sections: ir.sections.map(
5084
+ (value, index) => section(value, ctx, index === ir.sections.length - 1)
5085
+ ),
5066
5086
  ...coreProperties2(ir),
5067
5087
  features: {
5068
5088
  updateFields: ir.settings.updateFields,
@@ -5525,7 +5545,7 @@ function resolveThemeContext(documentIn, options = {}) {
5525
5545
  }
5526
5546
  const document = documentIn.props === void 0 ? { ...documentIn, props: {} } : documentIn;
5527
5547
  const authoredThemeName = document.props.theme || void 0;
5528
- const baseThemeName = authoredThemeName ?? "minimal";
5548
+ const baseThemeName = authoredThemeName ?? "consulting";
5529
5549
  let theme = resolveNamedTheme ? resolveNamedTheme(
5530
5550
  baseThemeName,
5531
5551
  warnings,
@@ -7081,7 +7101,12 @@ function resolveColors(entries, at, deps) {
7081
7101
  init_themes();
7082
7102
  init_colorUtils();
7083
7103
  init_styleHelpers();
7084
- import { capsFormatting, synthesizeFamilyName } from "@json-to-office/shared";
7104
+ import {
7105
+ capsFormatting,
7106
+ designCanvas as designCanvas2,
7107
+ synthesizeFamilyName,
7108
+ typeScaleSizes
7109
+ } from "@json-to-office/shared";
7085
7110
  var RIGHT_MARGIN_TAB_TWIPS = 9026 * 2;
7086
7111
  var STATISTIC_NUMBER_STYLE_ID = "StatisticNumber";
7087
7112
  var STATISTIC_DESCRIPTION_STYLE_ID = "StatisticDescription";
@@ -7090,6 +7115,27 @@ var STATISTIC_SIZE_POINTS = {
7090
7115
  medium: 28,
7091
7116
  large: 40
7092
7117
  };
7118
+ function statisticSizes(theme, size) {
7119
+ const sizeOf = (style) => {
7120
+ const value = theme.styles?.[style]?.size;
7121
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
7122
+ };
7123
+ const role = sizeOf("stat");
7124
+ const medium = sizeOf(STATISTIC_NUMBER_STYLE_ID) ?? role ?? STATISTIC_SIZE_POINTS.medium;
7125
+ const scale = role === void 0 ? void 0 : theme.typography?.scale?.[designCanvas2("docx", theme.page?.size)];
7126
+ const steps = scale ? typeScaleSizes(scale) : [];
7127
+ const below = [...steps].reverse().find((step) => step < medium - 0.01);
7128
+ const above = steps.find((step) => step > medium + 0.01);
7129
+ const number = size === "small" ? role !== void 0 && below !== void 0 ? below : STATISTIC_SIZE_POINTS.small : size === "large" ? role !== void 0 && above !== void 0 ? above : STATISTIC_SIZE_POINTS.large : medium;
7130
+ const label = sizeOf("label");
7131
+ return {
7132
+ number,
7133
+ medium,
7134
+ // Half-points in the document, floored at 6pt.
7135
+ suffix: label ?? Math.max(12, Math.round(number)) / 2,
7136
+ description: sizeOf(STATISTIC_DESCRIPTION_STYLE_ID) ?? label ?? 10
7137
+ };
7138
+ }
7093
7139
  function getStyleSafe(theme, styleName) {
7094
7140
  return theme.styles && Object.hasOwn(theme.styles, styleName) ? theme.styles[styleName] : void 0;
7095
7141
  }
@@ -7265,8 +7311,8 @@ function chromeRun(fontProps, theme, sizeHalfPoints) {
7265
7311
  ...fontProps.italic !== void 0 && { italic: fontProps.italic }
7266
7312
  };
7267
7313
  }
7268
- function createDocumentStyles(themeNameOrObject = "minimal", language) {
7269
- const theme = typeof themeNameOrObject === "string" ? getTheme(themeNameOrObject) || getTheme("minimal") : themeNameOrObject;
7314
+ function createDocumentStyles(themeNameOrObject = "consulting", language) {
7315
+ const theme = typeof themeNameOrObject === "string" ? getTheme(themeNameOrObject) || getTheme("consulting") : themeNameOrObject;
7270
7316
  const paragraphStyles = [
7271
7317
  // Normal body text style
7272
7318
  {
@@ -7737,14 +7783,19 @@ function createDocumentStyles(themeNameOrObject = "minimal", language) {
7737
7783
  };
7738
7784
  }
7739
7785
  function createStatisticStyles(theme) {
7786
+ const sizes = statisticSizes(theme, "medium");
7787
+ const stat = theme.styles?.stat;
7788
+ const faces = ["heading", "body", "mono", "light"];
7789
+ const face = faces.find((candidate) => candidate === stat?.font) ?? "heading";
7790
+ const weight = typeof stat?.fontWeight === "number" ? stat.fontWeight : void 0;
7740
7791
  const definitions = [
7741
7792
  {
7742
7793
  id: STATISTIC_NUMBER_STYLE_ID,
7743
7794
  name: "Statistic Number",
7744
- font: "heading",
7745
- sizePoints: STATISTIC_SIZE_POINTS.medium,
7746
- color: theme.colors.primary,
7747
- bold: true,
7795
+ font: face,
7796
+ sizePoints: sizes.medium,
7797
+ color: typeof stat?.color === "string" ? stat.color : theme.colors.primary,
7798
+ bold: weight === void 0 ? true : weight >= 600,
7748
7799
  // Space above separates the figure from whatever preceded it; none below,
7749
7800
  // because the description is the other half of the same block.
7750
7801
  spacing: { before: 12, after: 0 },
@@ -7757,7 +7808,7 @@ function createStatisticStyles(theme) {
7757
7808
  id: STATISTIC_DESCRIPTION_STYLE_ID,
7758
7809
  name: "Statistic Description",
7759
7810
  font: "body",
7760
- sizePoints: 10,
7811
+ sizePoints: sizes.description,
7761
7812
  color: theme.colors.textMuted,
7762
7813
  bold: false,
7763
7814
  spacing: { before: 0, after: 12 },
@@ -10329,9 +10380,10 @@ function compileStatistic(component, scope) {
10329
10380
  );
10330
10381
  }
10331
10382
  const text = (value) => normalizeUnicodeText(String(value ?? ""));
10332
- const numberPoints = STATISTIC_SIZE_POINTS[String(props.size)] ?? STATISTIC_SIZE_POINTS.medium;
10333
- const resized = numberPoints !== STATISTIC_SIZE_POINTS.medium;
10334
- const suffixHalfPoints = Math.max(12, Math.round(numberPoints));
10383
+ const sizes = statisticSizes(ctx.theme, props.size);
10384
+ const numberPoints = sizes.number;
10385
+ const resized = numberPoints !== sizes.medium;
10386
+ const suffixHalfPoints = Math.round(sizes.suffix * 2);
10335
10387
  const numberRuns = [];
10336
10388
  const numberText = text(props.number);
10337
10389
  if (numberText) {
@@ -12630,10 +12682,10 @@ import {
12630
12682
  } from "@json-to-office/quality";
12631
12683
  import { DEFAULT_DOCX_RENDERER_ID as DEFAULT_DOCX_RENDERER_ID2 } from "@json-to-office/shared-docx";
12632
12684
  import {
12633
- designCanvas as designCanvas2,
12685
+ designCanvas as designCanvas3,
12634
12686
  designColors as designColors2,
12635
12687
  resolveDesignColor as resolveDesignColor2,
12636
- typeScaleSizes
12688
+ typeScaleSizes as typeScaleSizes2
12637
12689
  } from "@json-to-office/shared";
12638
12690
 
12639
12691
  // src/json/normalizer.ts
@@ -12969,7 +13021,8 @@ async function expandBlocksWithPlugins(document, theme, plugins, render, preserv
12969
13021
  document: second.standard,
12970
13022
  preserved: first.preserved,
12971
13023
  sourceMap: evaluator.sourceMap,
12972
- blocks: evaluator.blocks
13024
+ blocks: evaluator.blocks,
13025
+ pluginOutputs: evaluator.pluginOutputs
12973
13026
  };
12974
13027
  }
12975
13028
 
@@ -13756,10 +13809,7 @@ function textSizeFact(node, props, path3, typography, role) {
13756
13809
  };
13757
13810
  }
13758
13811
  function statisticSizeFacts(props, path3, typography) {
13759
- const named = STATISTIC_SIZE_POINTS[String(props.size)];
13760
- const styled = (id) => finiteNumber(asRecord2(typography.styles[id])?.size);
13761
- const numberPoints = named ?? STATISTIC_SIZE_POINTS.medium;
13762
- const painted = props.size === "small" || props.size === "large" ? numberPoints : styled("StatisticNumber") ?? numberPoints;
13812
+ const sizes = statisticSizes(typography.theme, props.size);
13763
13813
  const present = (value) => value !== void 0 && value !== null && String(value).trim() !== "";
13764
13814
  const facts = [];
13765
13815
  const add = (suffix, role, fontSizePt) => facts.push({
@@ -13770,19 +13820,11 @@ function statisticSizeFacts(props, path3, typography) {
13770
13820
  fontSizePt,
13771
13821
  authored: false
13772
13822
  });
13773
- if (present(props.number)) add("number", "statistic", painted);
13823
+ if (present(props.number)) add("number", "statistic", sizes.number);
13774
13824
  if (present(props.unit) || present(props.trend) || present(props.trendValue))
13775
- add(
13776
- "suffix",
13777
- "statistic-suffix",
13778
- Math.max(12, Math.round(numberPoints)) / 2
13779
- );
13825
+ add("suffix", "statistic-suffix", sizes.suffix);
13780
13826
  if (present(props.description))
13781
- add(
13782
- "description",
13783
- "statistic-description",
13784
- styled("StatisticDescription") ?? 10
13785
- );
13827
+ add("description", "statistic-description", sizes.description);
13786
13828
  return facts;
13787
13829
  }
13788
13830
  function tocSizeFacts(props, path3, typography) {
@@ -13884,8 +13926,8 @@ function prepareDocxQualityDocument(document, options = {}) {
13884
13926
  fonts: options.fonts,
13885
13927
  warnings: options.warnings
13886
13928
  });
13887
- const expanded = expandBlocks(themed.document, themed.theme);
13888
- const context = expanded.blocks.length > 0 ? { ...themed, document: expanded.document } : themed;
13929
+ const expanded = options.expanded ?? expandBlocks(themed.document, themed.theme);
13930
+ const context = options.expanded !== void 0 || expanded.blocks.length > 0 ? { ...themed, document: expanded.document } : themed;
13889
13931
  const resolved = resolveDocumentTree(context.document, context.theme);
13890
13932
  const basePage = pageBox(resolved.theme, context.themeName);
13891
13933
  const typography = {
@@ -13897,7 +13939,7 @@ function prepareDocxQualityDocument(document, options = {}) {
13897
13939
  let previousHeadingLevel;
13898
13940
  const authoredPath = (path3) => toAuthoredPointer(
13899
13941
  themed.sourceMap ?? {},
13900
- toAuthoredPointer(expanded.sourceMap, path3)
13942
+ toAuthoredPointer(expanded.sourceMap, path3, expanded.pluginOutputs)
13901
13943
  );
13902
13944
  const addFact = (raw) => {
13903
13945
  const fact = {
@@ -14036,7 +14078,7 @@ function prepareDocxQualityDocument(document, options = {}) {
14036
14078
  );
14037
14079
  if (size) roleSizesPt[key] = size.fontSizePt;
14038
14080
  }
14039
- const scale = resolved.theme.typography?.scale?.[designCanvas2("docx", resolved.theme.page?.size)];
14081
+ const scale = resolved.theme.typography?.scale?.[designCanvas3("docx", resolved.theme.page?.size)];
14040
14082
  const typeScalePt = [
14041
14083
  .../* @__PURE__ */ new Set([
14042
14084
  ...Object.values(roleSizesPt),
@@ -14044,7 +14086,7 @@ function prepareDocxQualityDocument(document, options = {}) {
14044
14086
  const size = resolveFontSize(resolved.theme, role);
14045
14087
  return size === void 0 ? [] : [size];
14046
14088
  }),
14047
- ...scale ? typeScaleSizes(scale) : []
14089
+ ...scale ? typeScaleSizes2(scale) : []
14048
14090
  ])
14049
14091
  ].sort((a, b) => a - b);
14050
14092
  addFact({
@@ -14200,6 +14242,7 @@ function prepareDocxQualityDocument(document, options = {}) {
14200
14242
  for (const fact of svgTextFacts(props, path3)) addFact(fact);
14201
14243
  const drawn = drawnRatio(props);
14202
14244
  const natural = readableRatio(props);
14245
+ const authored = authoredPropsAt(path3);
14203
14246
  addFact({
14204
14247
  id: `docx:image:${path3}`,
14205
14248
  kind: "docx/image",
@@ -14207,7 +14250,13 @@ function prepareDocxQualityDocument(document, options = {}) {
14207
14250
  ...typeof props.alt === "string" && props.alt.trim() !== "" && { alt: props.alt },
14208
14251
  captioned: isCaptioned(facts, authoredPath(path3)),
14209
14252
  ...drawn !== void 0 && { drawnRatio: drawn },
14210
- ...natural !== void 0 && { naturalRatio: natural }
14253
+ ...natural !== void 0 && { naturalRatio: natural },
14254
+ ...authoredPath(path3) === path3 && finiteNumber(authored?.width) !== void 0 && finiteNumber(authored?.height) !== void 0 && {
14255
+ authoredSizePx: {
14256
+ width: authored.width,
14257
+ height: authored.height
14258
+ }
14259
+ }
14211
14260
  });
14212
14261
  }
14213
14262
  if (node.name === "heading") {
@@ -14696,7 +14745,7 @@ function createBuilderImpl(state) {
14696
14745
  }
14697
14746
  return new Set(list);
14698
14747
  }
14699
- async function expandDocument(document, options) {
14748
+ async function expandDocument(document, options, provenance = false) {
14700
14749
  const preserveSet = resolvePreserveSet(options);
14701
14750
  const rootIn = document;
14702
14751
  const internalDocument = rootIn.props === void 0 ? { ...rootIn, props: {} } : rootIn;
@@ -14756,7 +14805,7 @@ function createBuilderImpl(state) {
14756
14805
  warnings,
14757
14806
  resolveNamedTheme: resolveDocumentTheme
14758
14807
  });
14759
- if (modedRoot.props.blocks !== void 0) {
14808
+ if (modedRoot.props.blocks !== void 0 || provenance) {
14760
14809
  const expanded = await expandBlocksWithPlugins(
14761
14810
  modedRoot,
14762
14811
  modedTheme,
@@ -14804,6 +14853,7 @@ function createBuilderImpl(state) {
14804
14853
  modedDoc: modedDoc2,
14805
14854
  sourceMap: expanded.sourceMap,
14806
14855
  blockPaths: expanded.blocks,
14856
+ pluginOutputs: expanded.pluginOutputs,
14807
14857
  warnings,
14808
14858
  preserveSet,
14809
14859
  processed: {
@@ -14852,8 +14902,64 @@ function createBuilderImpl(state) {
14852
14902
  throw error;
14853
14903
  }
14854
14904
  }
14905
+ async function prepareQuality(document, options) {
14906
+ const {
14907
+ modedRoot,
14908
+ modedTheme,
14909
+ themeName,
14910
+ modedDoc,
14911
+ sourceMap,
14912
+ blockPaths,
14913
+ pluginOutputs,
14914
+ warnings
14915
+ } = await expandDocument(document, options, true);
14916
+ const prepared = prepareDocxQualityDocument(
14917
+ document,
14918
+ {
14919
+ context: { document: modedRoot, theme: modedTheme, themeName },
14920
+ expanded: {
14921
+ document: modedDoc,
14922
+ sourceMap: sourceMap ?? {},
14923
+ blocks: blockPaths ?? [],
14924
+ ...pluginOutputs && { pluginOutputs }
14925
+ },
14926
+ customThemes: state.customThemes,
14927
+ fonts: state.fonts,
14928
+ renderer: options?.renderer ?? state.renderer ?? modedRoot.renderer,
14929
+ warnings
14930
+ }
14931
+ );
14932
+ return { prepared, warnings: warnings.length > 0 ? warnings : null };
14933
+ }
14934
+ async function generateBufferFromPrepared(prepared, options) {
14935
+ const { context } = prepared.model;
14936
+ const warnings = [];
14937
+ const baseDir = options?.baseDir ?? state.baseDir;
14938
+ const deterministic = options?.deterministic ?? state.deterministic;
14939
+ const generatedAt = options?.generatedAt ?? state.generatedAt;
14940
+ const renderer = options?.renderer ?? state.renderer ?? prepared.renderer;
14941
+ const { buffer } = await generateBufferViaIr(context.document, {
14942
+ context,
14943
+ prepared,
14944
+ ...state.services ? { services: state.services } : {},
14945
+ ...state.fonts ? { fonts: state.fonts } : {},
14946
+ ...baseDir !== void 0 ? { baseDir } : {},
14947
+ ...deterministic !== void 0 ? { deterministic } : {},
14948
+ ...generatedAt !== void 0 ? { generatedAt } : {},
14949
+ ...renderer !== void 0 ? { renderer } : {},
14950
+ warnings
14951
+ });
14952
+ return {
14953
+ buffer,
14954
+ warnings: warnings.length > 0 ? warnings : null,
14955
+ standardDefinition: context.document,
14956
+ preservedDefinition: void 0
14957
+ };
14958
+ }
14855
14959
  async function generateBuffer(document, options) {
14856
14960
  try {
14961
+ const reused = options?.prepared && resolvePreserveSet(options) === void 0 ? options.prepared : void 0;
14962
+ if (reused) return await generateBufferFromPrepared(reused, options);
14857
14963
  const {
14858
14964
  modedRoot,
14859
14965
  modedTheme,
@@ -14983,6 +15089,7 @@ function createBuilderImpl(state) {
14983
15089
  generateBuffer,
14984
15090
  generateFile,
14985
15091
  expandStandardDefinition,
15092
+ prepareQuality,
14986
15093
  getComponentNames,
14987
15094
  validate,
14988
15095
  generateSchema,