@json-to-office/core-pptx 0.26.0 → 0.28.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":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIjE,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA4BzE,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,GAAG,C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K,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA4DD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,UAAU,SAAK,EACf,WAAW,SAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAqKf"}
@@ -29,10 +29,14 @@ export interface ThemeContextOptions {
29
29
  defaultThemeName?: string;
30
30
  /**
31
31
  * Theme lookup for the base `props.theme` name. The plugin builder passes
32
- * its own (customThemes → constructor theme object → built-in); omit it to
33
- * use customThemes → built-in.
32
+ * its own (customThemes → doc-named built-in → constructor theme object →
33
+ * built-in); omit it to use customThemes → built-in. `authored` is true
34
+ * when the name came from the document's own `props.theme` (as opposed to
35
+ * `defaultThemeName` or the 'default' fallback), so the lookup can honor
36
+ * an explicitly doc-named built-in without the constructor object
37
+ * swallowing the default name too (#141).
34
38
  */
35
- resolveNamedTheme?: (name: string) => PptxThemeConfig;
39
+ resolveNamedTheme?: (name: string, authored: boolean) => PptxThemeConfig;
36
40
  }
37
41
  export interface GenerationThemeContext {
38
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"generationContext.d.ts","sourceRoot":"","sources":["../../src/core/generationContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,KAAK,CAAC,EA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mB,CACjC,UAAU,EAAE,+BAA+B,EAC3C,OAAO,GAAE,mBAAwB,GAChC,sBAAsB,CA6DxB"}
@@ -28,6 +28,12 @@ export interface GenerationOptions extends PresentationPackagingOptions {
28
28
  services?: ServicesConfig;
29
29
  fonts?: FontRuntimeOpts;
30
30
  validation?: GenerationValidationOptions;
31
+ /**
32
+ * Directory that relative asset paths (image `path` props, slide
33
+ * background images) resolve against. Defaults to `process.cwd()` when
34
+ * absent (#142).
35
+ */
36
+ baseDir?: string;
31
37
  }
32
38
  /**
33
39
  * Result from generateBufferWithWarnings
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EACf,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9E,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,2BAA2B;IAC1C,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,4BAA4B;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C;;;;OAIG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,2BAA2B,CAAC;CAC1C;AAID;;GAEG;AACH,MAAM,WAAW,gB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C,CAIf;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;CAQjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/core/render.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EAGf,MAAM,UAAU,CAAC;AAUlB,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,qBAAqB,EAChC,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,YAAY,CAAC,EAAE,cAAc,EAAE,GAC9B,OAAO,CAAC,SAAS,CAAC,CAiQpB"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/core/render.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EAGf,MAAM,UAAU,CAAC;AAWlB,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,qBAAqB,EAChC,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,YAAY,CAAC,EAAE,cAAc,EAAE,GAC9B,OAAO,CAAC,SAAS,CAAC,CAkQpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG1F,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,uBAAuB,EAC5B,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAgCrB"}
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAIlB,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,uBAAuB,EAC5B,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA2CrB"}
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ var W = {
19
19
  CHART_MULTI_SERIES: "CHART_MULTI_SERIES",
20
20
  IMAGE_NO_SOURCE: "IMAGE_NO_SOURCE",
21
21
  IMAGE_PROBE_FAILED: "IMAGE_PROBE_FAILED",
22
+ IMAGE_PATH_OUTSIDE_ROOTS: "IMAGE_PATH_OUTSIDE_ROOTS",
22
23
  MISSING_TEMPLATE: "MISSING_TEMPLATE",
23
24
  UNKNOWN_PLACEHOLDER: "UNKNOWN_PLACEHOLDER",
24
25
  PLACEHOLDER_NO_POSITION: "PLACEHOLDER_NO_POSITION",
@@ -214,6 +215,9 @@ var PPTX_THEMES = {
214
215
  function getPptxTheme(name) {
215
216
  return PPTX_THEMES[name] || DEFAULT_PPTX_THEME;
216
217
  }
218
+ function hasPptxTheme(name) {
219
+ return Object.prototype.hasOwnProperty.call(PPTX_THEMES, name);
220
+ }
217
221
  var pptxThemes = PPTX_THEMES;
218
222
 
219
223
  // src/utils/componentDefaults.ts
@@ -738,9 +742,28 @@ function renderTextComponent(slide, props, theme, warnings, slideCtx) {
738
742
  }
739
743
 
740
744
  // src/components/image.ts
741
- import path from "path";
745
+ import path2 from "path";
742
746
  import probe from "probe-image-size";
743
747
 
748
+ // src/utils/imageSource.ts
749
+ import path from "path";
750
+
751
+ // src/utils/baseDirContext.ts
752
+ import { AsyncLocalStorage } from "async_hooks";
753
+ import { isAbsolute, resolve } from "path";
754
+ var baseDirStorage = new AsyncLocalStorage();
755
+ function runWithBaseDir(baseDir, callback) {
756
+ return baseDir === void 0 ? callback() : baseDirStorage.run(resolve(baseDir), callback);
757
+ }
758
+ function getBaseDir() {
759
+ return baseDirStorage.getStore();
760
+ }
761
+ function resolveFromBaseDir(filePath) {
762
+ const base = baseDirStorage.getStore();
763
+ if (!base || isAbsolute(filePath)) return filePath;
764
+ return resolve(base, filePath);
765
+ }
766
+
744
767
  // src/utils/imageSource.ts
745
768
  var hasValue = (v) => typeof v === "string" && v.trim().length > 0;
746
769
  function resolveImageSource(props) {
@@ -752,6 +775,18 @@ function resolveImageSource(props) {
752
775
  if (hasValue(props.path)) return props.path;
753
776
  return void 0;
754
777
  }
778
+ function isAllowedLocalPath(resolved) {
779
+ const baseDir = getBaseDir();
780
+ const allowedRoots = baseDir ? [baseDir, process.cwd()] : [process.cwd()];
781
+ return allowedRoots.some(
782
+ (root) => resolved.startsWith(root + path.sep) || resolved === root
783
+ );
784
+ }
785
+ function safeLocalPath(source) {
786
+ if (/^(https?:\/\/|data:)/.test(source)) return source;
787
+ const resolved = path.resolve(resolveFromBaseDir(source));
788
+ return isAllowedLocalPath(resolved) ? resolved : void 0;
789
+ }
755
790
 
756
791
  // src/components/image.ts
757
792
  function isPrivateUrl(urlStr) {
@@ -782,8 +817,8 @@ async function probeImageSize(imagePath, warnings) {
782
817
  const result2 = await probe(imagePath, { timeout: 5e3 });
783
818
  return { width: result2.width, height: result2.height };
784
819
  }
785
- const resolved = path.resolve(imagePath);
786
- if (!resolved.startsWith(process.cwd())) return void 0;
820
+ const resolved = path2.resolve(resolveFromBaseDir(imagePath));
821
+ if (!isAllowedLocalPath(resolved)) return void 0;
787
822
  const { createReadStream } = await import("fs");
788
823
  const result = await probe(createReadStream(resolved));
789
824
  return result ? { width: result.width, height: result.height } : void 0;
@@ -821,7 +856,17 @@ async function renderImageComponent(slide, props, theme, warnings, slideWidth =
821
856
  if (source.startsWith("data:")) {
822
857
  opts.data = source;
823
858
  } else {
824
- opts.path = source;
859
+ const resolved = safeLocalPath(source);
860
+ if (resolved === void 0) {
861
+ warn(
862
+ warnings,
863
+ W.IMAGE_PATH_OUTSIDE_ROOTS,
864
+ `Image path resolves outside the document base directory: ${source}`,
865
+ { component: "image" }
866
+ );
867
+ return;
868
+ }
869
+ opts.path = resolved;
825
870
  }
826
871
  if (props.x !== void 0) opts.x = props.x;
827
872
  if (props.y !== void 0) opts.y = props.y;
@@ -1622,10 +1667,13 @@ function buildSlideTemplateProps(def, theme, warnings) {
1622
1667
  const result = { title: def.name };
1623
1668
  if (def.background) {
1624
1669
  if (def.background.color) {
1625
- result.background = { color: resolveColor(def.background.color, theme, warnings) };
1670
+ result.background = {
1671
+ color: resolveColor(def.background.color, theme, warnings)
1672
+ };
1626
1673
  } else if (def.background.image) {
1627
1674
  if (def.background.image.path) {
1628
- result.background = { path: def.background.image.path };
1675
+ const bgPath = safeLocalPath(def.background.image.path);
1676
+ if (bgPath !== void 0) result.background = { path: bgPath };
1629
1677
  } else if (def.background.image.base64) {
1630
1678
  result.background = { data: def.background.image.base64 };
1631
1679
  }
@@ -1637,10 +1685,18 @@ function buildSlideTemplateProps(def, theme, warnings) {
1637
1685
  x: def.slideNumber.x,
1638
1686
  y: def.slideNumber.y
1639
1687
  };
1640
- if (def.slideNumber.w !== void 0) result.slideNumber.w = def.slideNumber.w;
1641
- if (def.slideNumber.h !== void 0) result.slideNumber.h = def.slideNumber.h;
1642
- if (def.slideNumber.color) result.slideNumber.color = resolveColor(def.slideNumber.color, theme, warnings);
1643
- if (def.slideNumber.fontSize) result.slideNumber.fontSize = def.slideNumber.fontSize;
1688
+ if (def.slideNumber.w !== void 0)
1689
+ result.slideNumber.w = def.slideNumber.w;
1690
+ if (def.slideNumber.h !== void 0)
1691
+ result.slideNumber.h = def.slideNumber.h;
1692
+ if (def.slideNumber.color)
1693
+ result.slideNumber.color = resolveColor(
1694
+ def.slideNumber.color,
1695
+ theme,
1696
+ warnings
1697
+ );
1698
+ if (def.slideNumber.fontSize)
1699
+ result.slideNumber.fontSize = def.slideNumber.fontSize;
1644
1700
  }
1645
1701
  return result;
1646
1702
  }
@@ -1733,7 +1789,8 @@ async function renderPresentation(processed, warnings, pendingFills) {
1733
1789
  };
1734
1790
  } else if (slideData.background.image) {
1735
1791
  if (slideData.background.image.path) {
1736
- slide.background = { path: slideData.background.image.path };
1792
+ const bgPath = safeLocalPath(slideData.background.image.path);
1793
+ if (bgPath !== void 0) slide.background = { path: bgPath };
1737
1794
  } else if (slideData.background.image.base64) {
1738
1795
  slide.background = { data: slideData.background.image.base64 };
1739
1796
  }
@@ -1927,8 +1984,9 @@ function resolveThemeContext(documentIn, options = {}) {
1927
1984
  if (typeof document.props.theme === "object" && document.props.theme !== null) {
1928
1985
  inlineTheme = document.props.theme;
1929
1986
  }
1930
- const baseThemeName = inlineTheme ? inlineTheme.name || "inline-theme" : document.props.theme ?? defaultThemeName ?? "default";
1931
- let theme = inlineTheme ?? (resolveNamedTheme ? resolveNamedTheme(baseThemeName) : customThemes?.[baseThemeName] ?? getPptxTheme(baseThemeName));
1987
+ const authoredThemeName = typeof document.props.theme === "string" ? document.props.theme : void 0;
1988
+ const baseThemeName = inlineTheme ? inlineTheme.name || "inline-theme" : authoredThemeName ?? defaultThemeName ?? "default";
1989
+ let theme = inlineTheme ?? (resolveNamedTheme ? resolveNamedTheme(baseThemeName, authoredThemeName !== void 0) : customThemes?.[baseThemeName] ?? getPptxTheme(baseThemeName));
1932
1990
  const mode = applyExportMode({ doc: document, theme, fonts });
1933
1991
  document = mode.doc;
1934
1992
  theme = mode.theme;
@@ -2009,24 +2067,24 @@ function remapChartReferences(value, chartIds) {
2009
2067
  );
2010
2068
  }
2011
2069
  async function canonicalizeChartIds(zip) {
2012
- const sourceIds = Object.keys(zip.files).map((path2) => path2.match(/^ppt\/charts\/chart(\d+)\.xml$/)?.[1]).filter((value) => value !== void 0).map(Number).sort((a, b) => a - b);
2070
+ const sourceIds = Object.keys(zip.files).map((path3) => path3.match(/^ppt\/charts\/chart(\d+)\.xml$/)?.[1]).filter((value) => value !== void 0).map(Number).sort((a, b) => a - b);
2013
2071
  const chartIds = new Map(sourceIds.map((id, index) => [id, index + 1]));
2014
2072
  if (chartIds.size === 0) return;
2015
- for (const [path2, entry] of Object.entries(zip.files)) {
2016
- if (entry.dir || !path2.endsWith(".xml") && !path2.endsWith(".rels")) {
2073
+ for (const [path3, entry] of Object.entries(zip.files)) {
2074
+ if (entry.dir || !path3.endsWith(".xml") && !path3.endsWith(".rels")) {
2017
2075
  continue;
2018
2076
  }
2019
2077
  const xml = await entry.async("string");
2020
2078
  const remapped = remapChartReferences(xml, chartIds);
2021
- if (remapped !== xml) zip.file(path2, remapped);
2079
+ if (remapped !== xml) zip.file(path3, remapped);
2022
2080
  }
2023
2081
  const renames = [];
2024
- for (const [path2, entry] of Object.entries(zip.files)) {
2082
+ for (const [path3, entry] of Object.entries(zip.files)) {
2025
2083
  if (entry.dir) continue;
2026
- const remappedPath = remapChartReferences(path2, chartIds);
2027
- if (remappedPath === path2) continue;
2084
+ const remappedPath = remapChartReferences(path3, chartIds);
2085
+ if (remappedPath === path3) continue;
2028
2086
  renames.push({
2029
- from: path2,
2087
+ from: path3,
2030
2088
  to: remappedPath,
2031
2089
  data: await entry.async("nodebuffer"),
2032
2090
  date: entry.date
@@ -2056,12 +2114,12 @@ async function canonicalizePackage(zip, generatedAt, depth = 0) {
2056
2114
  zip.file("docProps/core.xml", coreXml);
2057
2115
  }
2058
2116
  if (depth < 3) {
2059
- for (const [path2, entry] of Object.entries(zip.files)) {
2060
- if (entry.dir || !EMBEDDED_OFFICE_PACKAGE.test(path2)) continue;
2117
+ for (const [path3, entry] of Object.entries(zip.files)) {
2118
+ if (entry.dir || !EMBEDDED_OFFICE_PACKAGE.test(path3)) continue;
2061
2119
  try {
2062
2120
  const nested = await JSZip.loadAsync(await entry.async("nodebuffer"));
2063
2121
  await canonicalizePackage(nested, generatedAt, depth + 1);
2064
- zip.file(path2, await generateZip(nested));
2122
+ zip.file(path3, await generateZip(nested));
2065
2123
  } catch {
2066
2124
  }
2067
2125
  }
@@ -2073,8 +2131,8 @@ async function canonicalizePackage(zip, generatedAt, depth = 0) {
2073
2131
  async function packagePresentationBuffer(buffer, options = {}) {
2074
2132
  const zip = await JSZip.loadAsync(buffer);
2075
2133
  let changed = false;
2076
- for (const [path2, entry] of Object.entries(zip.files)) {
2077
- if (!path2.match(/^ppt\/slides\/slide\d+\.xml$/)) continue;
2134
+ for (const [path3, entry] of Object.entries(zip.files)) {
2135
+ if (!path3.match(/^ppt\/slides\/slide\d+\.xml$/)) continue;
2078
2136
  let xml = await entry.async("string");
2079
2137
  let fileChanged = false;
2080
2138
  if (xml.includes(MEDIUM_STYLE_2_ACCENT_1)) {
@@ -2089,7 +2147,7 @@ async function packagePresentationBuffer(buffer, options = {}) {
2089
2147
  }
2090
2148
  }
2091
2149
  if (fileChanged) {
2092
- zip.file(path2, xml);
2150
+ zip.file(path3, xml);
2093
2151
  changed = true;
2094
2152
  }
2095
2153
  }
@@ -2148,8 +2206,10 @@ async function generatePresentation(document, options, warnings, pendingFills) {
2148
2206
  throw new Error("Top-level component must be a pptx component");
2149
2207
  }
2150
2208
  assertNoContentConflicts(document);
2151
- const processed = processPresentation(document, options);
2152
- return await renderPresentation(processed, warnings, pendingFills);
2209
+ return runWithBaseDir(options?.baseDir, async () => {
2210
+ const processed = processPresentation(document, options);
2211
+ return await renderPresentation(processed, warnings, pendingFills);
2212
+ });
2153
2213
  }
2154
2214
  async function generateBufferFromJson(jsonConfig, options) {
2155
2215
  const result = await generateBufferWithWarnings(jsonConfig, options);
@@ -2468,7 +2528,8 @@ function createBuilderImpl(state) {
2468
2528
  services: state.services,
2469
2529
  fonts: state.fonts,
2470
2530
  validation: state.validation,
2471
- packaging: state.packaging
2531
+ packaging: state.packaging,
2532
+ baseDir: state.baseDir
2472
2533
  };
2473
2534
  return createBuilderImpl(
2474
2535
  newState
@@ -2499,7 +2560,7 @@ function createBuilderImpl(state) {
2499
2560
  fonts: state.fonts,
2500
2561
  warnings,
2501
2562
  defaultThemeName: typeof state.theme === "string" ? state.theme : void 0,
2502
- resolveNamedTheme: (name) => state.customThemes?.[name] ?? (typeof state.theme === "object" && state.theme !== null ? state.theme : getPptxTheme(name))
2563
+ resolveNamedTheme: (name, authored) => state.customThemes?.[name] ?? (authored && hasPptxTheme(name) ? getPptxTheme(name) : void 0) ?? (typeof state.theme === "object" && state.theme !== null ? state.theme : getPptxTheme(name))
2503
2564
  });
2504
2565
  const modedRoot = context.document;
2505
2566
  const resolvedTheme = context.theme;
@@ -2561,12 +2622,22 @@ function createBuilderImpl(state) {
2561
2622
  state.fonts
2562
2623
  );
2563
2624
  assertNoContentConflicts(processedDocument);
2564
- const processed = processPresentation(processedDocument, {
2565
- theme: resolvedTheme,
2566
- services: state.services
2567
- });
2568
- const pendingFills = [];
2569
- const pptx = await renderPresentation(processed, warnings, pendingFills);
2625
+ const { pendingFills, pptx } = await runWithBaseDir(
2626
+ options?.baseDir ?? state.baseDir,
2627
+ async () => {
2628
+ const processed = processPresentation(processedDocument, {
2629
+ theme: resolvedTheme,
2630
+ services: state.services
2631
+ });
2632
+ const pendingFills2 = [];
2633
+ const pptx2 = await renderPresentation(
2634
+ processed,
2635
+ warnings,
2636
+ pendingFills2
2637
+ );
2638
+ return { pendingFills: pendingFills2, pptx: pptx2 };
2639
+ }
2640
+ );
2570
2641
  const data = await pptx.write({ outputType: "nodebuffer" });
2571
2642
  const buffer = await packagePresentationBuffer(data, {
2572
2643
  deterministic: options?.deterministic ?? state.packaging.deterministic,
@@ -2689,7 +2760,8 @@ function createPresentationGenerator(options = {}) {
2689
2760
  packaging: {
2690
2761
  deterministic: options.deterministic,
2691
2762
  generatedAt: options.generatedAt
2692
- }
2763
+ },
2764
+ baseDir: options.baseDir
2693
2765
  };
2694
2766
  return createBuilderImpl(initialState);
2695
2767
  }