@json-to-office/jto-ops 7.2.0 → 7.6.2

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 CHANGED
@@ -926,6 +926,22 @@ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototyp
926
926
  function safeThemeKey(name) {
927
927
  return name && !UNSAFE_KEYS.has(name) ? name : "custom";
928
928
  }
929
+ function anchorThemeFontFiles(theme, themeFile) {
930
+ const registry = theme?.fontRegistry;
931
+ if (!Array.isArray(registry)) return theme;
932
+ const themeDir = path5.dirname(path5.resolve(process.cwd(), themeFile));
933
+ return {
934
+ ...theme,
935
+ fontRegistry: registry.map(
936
+ (entry) => Array.isArray(entry?.sources) ? {
937
+ ...entry,
938
+ sources: entry.sources.map(
939
+ (source) => source?.kind === "file" && typeof source.path === "string" && !path5.isAbsolute(source.path) ? { ...source, path: path5.resolve(themeDir, source.path) } : source
940
+ )
941
+ } : entry
942
+ )
943
+ };
944
+ }
929
945
  var CLI_THEME_KEY = "jto-cli-theme";
930
946
  function withRequestedTheme(document, theme, customThemes) {
931
947
  if (!theme || typeof document !== "object" || document === null) {
@@ -1323,6 +1339,7 @@ var DocxFormatAdapter = class {
1323
1339
  );
1324
1340
  }
1325
1341
  if (fileTheme) {
1342
+ fileTheme = anchorThemeFontFiles(fileTheme, options.themePath);
1326
1343
  registry[safeThemeKey(fileTheme.name)] = fileTheme;
1327
1344
  }
1328
1345
  }
@@ -1337,7 +1354,10 @@ var DocxFormatAdapter = class {
1337
1354
  if (options.theme.endsWith(".json") && fs5.existsSync(options.theme)) {
1338
1355
  try {
1339
1356
  return {
1340
- requested: await core.loadThemeFromFile(options.theme),
1357
+ requested: anchorThemeFontFiles(
1358
+ await core.loadThemeFromFile(options.theme),
1359
+ options.theme
1360
+ ),
1341
1361
  customThemes,
1342
1362
  label: options.theme
1343
1363
  };
@@ -1717,6 +1737,7 @@ var PptxFormatAdapter = class {
1717
1737
  );
1718
1738
  }
1719
1739
  if (fileTheme) {
1740
+ fileTheme = anchorThemeFontFiles(fileTheme, options.themePath);
1720
1741
  registry[safeThemeKey(fileTheme.name)] = fileTheme;
1721
1742
  }
1722
1743
  }
@@ -1735,7 +1756,7 @@ var PptxFormatAdapter = class {
1735
1756
  "utf-8"
1736
1757
  );
1737
1758
  return {
1738
- requested: JSON.parse(content),
1759
+ requested: anchorThemeFontFiles(JSON.parse(content), options.theme),
1739
1760
  customThemes,
1740
1761
  label: options.theme
1741
1762
  };
@@ -4181,10 +4202,8 @@ function conditions(props, children, theme, font, canvas) {
4181
4202
  const page = isRecord2(props2.page) ? props2.page : {};
4182
4203
  return { ...child, props: { ...props2, page: { ...page, size: canvas } } };
4183
4204
  });
4184
- const chart = JSON.stringify(sections).includes('"name":"chart"');
4185
4205
  return {
4186
4206
  name: "docx",
4187
- ...chart && { renderer: "office-open" },
4188
4207
  props: {
4189
4208
  ...props,
4190
4209
  theme,