@json-to-office/core-docx 7.6.0 → 7.6.4

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.
@@ -1666,6 +1666,46 @@ var init_themes = __esm({
1666
1666
  }
1667
1667
  });
1668
1668
 
1669
+ // src/utils/generationContext.ts
1670
+ import { AsyncLocalStorage } from "async_hooks";
1671
+ import { isAbsolute, resolve } from "path";
1672
+ function runWithBaseDir(baseDir, callback) {
1673
+ return baseDir === void 0 ? callback() : baseDirStorage.run(resolve(baseDir), callback);
1674
+ }
1675
+ function getBaseDir() {
1676
+ return baseDirStorage.getStore();
1677
+ }
1678
+ function resolveFromBaseDir(filePath) {
1679
+ const base = baseDirStorage.getStore();
1680
+ if (!base || isAbsolute(filePath)) return filePath;
1681
+ return resolve(base, filePath);
1682
+ }
1683
+ function runWithWarnings(warnings, callback) {
1684
+ return warnings === void 0 ? callback() : warningsStorage.run(warnings, callback);
1685
+ }
1686
+ function reportWarning(component, code, message, context) {
1687
+ const warnings = warningsStorage.getStore();
1688
+ if (warnings) {
1689
+ warnings.push({
1690
+ component,
1691
+ message,
1692
+ severity: "warning",
1693
+ context: { code, ...context }
1694
+ });
1695
+ return;
1696
+ }
1697
+ console.warn(`[json-to-docx] [${code}] ${message}`);
1698
+ }
1699
+ var generationDateStorage, baseDirStorage, warningsStorage;
1700
+ var init_generationContext = __esm({
1701
+ "src/utils/generationContext.ts"() {
1702
+ "use strict";
1703
+ generationDateStorage = new AsyncLocalStorage();
1704
+ baseDirStorage = new AsyncLocalStorage();
1705
+ warningsStorage = new AsyncLocalStorage();
1706
+ }
1707
+ });
1708
+
1669
1709
  // src/styles/utils/colorUtils.ts
1670
1710
  import {
1671
1711
  DEFAULT_CHART_THEME_COLORS,
@@ -2419,43 +2459,6 @@ var init_widthUtils = __esm({
2419
2459
  }
2420
2460
  });
2421
2461
 
2422
- // src/utils/generationContext.ts
2423
- import { AsyncLocalStorage } from "async_hooks";
2424
- import { isAbsolute, resolve } from "path";
2425
- function runWithBaseDir(baseDir, callback) {
2426
- return baseDir === void 0 ? callback() : baseDirStorage.run(resolve(baseDir), callback);
2427
- }
2428
- function resolveFromBaseDir(filePath) {
2429
- const base = baseDirStorage.getStore();
2430
- if (!base || isAbsolute(filePath)) return filePath;
2431
- return resolve(base, filePath);
2432
- }
2433
- function runWithWarnings(warnings, callback) {
2434
- return warnings === void 0 ? callback() : warningsStorage.run(warnings, callback);
2435
- }
2436
- function reportWarning(component, code, message, context) {
2437
- const warnings = warningsStorage.getStore();
2438
- if (warnings) {
2439
- warnings.push({
2440
- component,
2441
- message,
2442
- severity: "warning",
2443
- context: { code, ...context }
2444
- });
2445
- return;
2446
- }
2447
- console.warn(`[json-to-docx] [${code}] ${message}`);
2448
- }
2449
- var generationDateStorage, baseDirStorage, warningsStorage;
2450
- var init_generationContext = __esm({
2451
- "src/utils/generationContext.ts"() {
2452
- "use strict";
2453
- generationDateStorage = new AsyncLocalStorage();
2454
- baseDirStorage = new AsyncLocalStorage();
2455
- warningsStorage = new AsyncLocalStorage();
2456
- }
2457
- });
2458
-
2459
2462
  // src/utils/imageUtils.ts
2460
2463
  import { readFileSync } from "fs";
2461
2464
  import { availableParallelism } from "os";
@@ -7340,6 +7343,7 @@ async function exportPluginSchema(customComponents, outputPath, options = {}) {
7340
7343
  import { assertRendererSupports } from "@json-to-office/shared/rendering";
7341
7344
 
7342
7345
  // src/core/fontResolution.ts
7346
+ init_generationContext();
7343
7347
  import {
7344
7348
  collectFontNamesFromDocx,
7345
7349
  validateFontReferences,
@@ -7393,8 +7397,14 @@ async function resolveDocumentFonts(document, theme, fonts, warnings, forceMater
7393
7397
  if (!fonts?.onResolved && !forceMaterialize) return [];
7394
7398
  const registry2 = new FontRegistry({
7395
7399
  // Spread keeps baseDir/googleFonts/mode/substitution intact for
7396
- // materializeSource; extraEntries carries the merged registry.
7397
- opts: { ...fonts, extraEntries: registryEntries },
7400
+ // materializeSource; extraEntries carries the merged registry. Without a
7401
+ // `fonts.baseDir` of its own, kind:"file" sources resolve against the
7402
+ // render's baseDir, as images do — not against process.cwd().
7403
+ opts: {
7404
+ ...fonts,
7405
+ baseDir: fonts?.baseDir ?? getBaseDir(),
7406
+ extraEntries: registryEntries
7407
+ },
7398
7408
  fileLoader: loadFileFontSource,
7399
7409
  variableLoader: fetchVariableFontSource,
7400
7410
  diskCache: fonts?.googleFonts?.cacheDir ? new FontDiskCache(fonts.googleFonts.cacheDir) : void 0