@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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fontResolution.d.ts","sourceRoot":"","sources":["../../src/core/fontResolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"fontResolution.d.ts","sourceRoot":"","sources":["../../src/core/fontResolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAehC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,yBAAyB,EACnC,KAAK,EAAE,WAAW,EAClB,KAAK,CAAC,EAAE,eAAe,EACvB,QAAQ,CAAC,EAAE,iBAAiB,EAAE;AAC9B;;;;;;;;GAQG;AACH,gBAAgB,UAAQ,GACvB,OAAO,CAAC,YAAY,EAAE,CAAC,CAyFzB"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,46 @@ var __export = (target, all) => {
|
|
|
14
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/utils/generationContext.ts
|
|
18
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
19
|
+
import { isAbsolute, resolve } from "path";
|
|
20
|
+
function runWithBaseDir(baseDir, callback) {
|
|
21
|
+
return baseDir === void 0 ? callback() : baseDirStorage.run(resolve(baseDir), callback);
|
|
22
|
+
}
|
|
23
|
+
function getBaseDir() {
|
|
24
|
+
return baseDirStorage.getStore();
|
|
25
|
+
}
|
|
26
|
+
function resolveFromBaseDir(filePath) {
|
|
27
|
+
const base = baseDirStorage.getStore();
|
|
28
|
+
if (!base || isAbsolute(filePath)) return filePath;
|
|
29
|
+
return resolve(base, filePath);
|
|
30
|
+
}
|
|
31
|
+
function runWithWarnings(warnings, callback) {
|
|
32
|
+
return warnings === void 0 ? callback() : warningsStorage.run(warnings, callback);
|
|
33
|
+
}
|
|
34
|
+
function reportWarning(component, code, message, context) {
|
|
35
|
+
const warnings = warningsStorage.getStore();
|
|
36
|
+
if (warnings) {
|
|
37
|
+
warnings.push({
|
|
38
|
+
component,
|
|
39
|
+
message,
|
|
40
|
+
severity: "warning",
|
|
41
|
+
context: { code, ...context }
|
|
42
|
+
});
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
console.warn(`[json-to-docx] [${code}] ${message}`);
|
|
46
|
+
}
|
|
47
|
+
var generationDateStorage, baseDirStorage, warningsStorage;
|
|
48
|
+
var init_generationContext = __esm({
|
|
49
|
+
"src/utils/generationContext.ts"() {
|
|
50
|
+
"use strict";
|
|
51
|
+
generationDateStorage = new AsyncLocalStorage();
|
|
52
|
+
baseDirStorage = new AsyncLocalStorage();
|
|
53
|
+
warningsStorage = new AsyncLocalStorage();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
17
57
|
// src/themes/defaults.ts
|
|
18
58
|
import { designColors } from "@json-to-office/shared";
|
|
19
59
|
function ensureThemeDefaults(theme) {
|
|
@@ -2447,43 +2487,6 @@ var init_widthUtils = __esm({
|
|
|
2447
2487
|
}
|
|
2448
2488
|
});
|
|
2449
2489
|
|
|
2450
|
-
// src/utils/generationContext.ts
|
|
2451
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
2452
|
-
import { isAbsolute, resolve } from "path";
|
|
2453
|
-
function runWithBaseDir(baseDir, callback) {
|
|
2454
|
-
return baseDir === void 0 ? callback() : baseDirStorage.run(resolve(baseDir), callback);
|
|
2455
|
-
}
|
|
2456
|
-
function resolveFromBaseDir(filePath) {
|
|
2457
|
-
const base = baseDirStorage.getStore();
|
|
2458
|
-
if (!base || isAbsolute(filePath)) return filePath;
|
|
2459
|
-
return resolve(base, filePath);
|
|
2460
|
-
}
|
|
2461
|
-
function runWithWarnings(warnings, callback) {
|
|
2462
|
-
return warnings === void 0 ? callback() : warningsStorage.run(warnings, callback);
|
|
2463
|
-
}
|
|
2464
|
-
function reportWarning(component, code, message, context) {
|
|
2465
|
-
const warnings = warningsStorage.getStore();
|
|
2466
|
-
if (warnings) {
|
|
2467
|
-
warnings.push({
|
|
2468
|
-
component,
|
|
2469
|
-
message,
|
|
2470
|
-
severity: "warning",
|
|
2471
|
-
context: { code, ...context }
|
|
2472
|
-
});
|
|
2473
|
-
return;
|
|
2474
|
-
}
|
|
2475
|
-
console.warn(`[json-to-docx] [${code}] ${message}`);
|
|
2476
|
-
}
|
|
2477
|
-
var generationDateStorage, baseDirStorage, warningsStorage;
|
|
2478
|
-
var init_generationContext = __esm({
|
|
2479
|
-
"src/utils/generationContext.ts"() {
|
|
2480
|
-
"use strict";
|
|
2481
|
-
generationDateStorage = new AsyncLocalStorage();
|
|
2482
|
-
baseDirStorage = new AsyncLocalStorage();
|
|
2483
|
-
warningsStorage = new AsyncLocalStorage();
|
|
2484
|
-
}
|
|
2485
|
-
});
|
|
2486
|
-
|
|
2487
2490
|
// src/utils/imageUtils.ts
|
|
2488
2491
|
import { readFileSync } from "fs";
|
|
2489
2492
|
import { availableParallelism } from "os";
|
|
@@ -7068,6 +7071,7 @@ import {
|
|
|
7068
7071
|
import { assertRendererSupports } from "@json-to-office/shared/rendering";
|
|
7069
7072
|
|
|
7070
7073
|
// src/core/fontResolution.ts
|
|
7074
|
+
init_generationContext();
|
|
7071
7075
|
import {
|
|
7072
7076
|
collectFontNamesFromDocx,
|
|
7073
7077
|
validateFontReferences,
|
|
@@ -7121,8 +7125,14 @@ async function resolveDocumentFonts(document, theme, fonts, warnings, forceMater
|
|
|
7121
7125
|
if (!fonts?.onResolved && !forceMaterialize) return [];
|
|
7122
7126
|
const registry2 = new FontRegistry({
|
|
7123
7127
|
// Spread keeps baseDir/googleFonts/mode/substitution intact for
|
|
7124
|
-
// materializeSource; extraEntries carries the merged registry.
|
|
7125
|
-
|
|
7128
|
+
// materializeSource; extraEntries carries the merged registry. Without a
|
|
7129
|
+
// `fonts.baseDir` of its own, kind:"file" sources resolve against the
|
|
7130
|
+
// render's baseDir, as images do — not against process.cwd().
|
|
7131
|
+
opts: {
|
|
7132
|
+
...fonts,
|
|
7133
|
+
baseDir: fonts?.baseDir ?? getBaseDir(),
|
|
7134
|
+
extraEntries: registryEntries
|
|
7135
|
+
},
|
|
7126
7136
|
fileLoader: loadFileFontSource,
|
|
7127
7137
|
variableLoader: fetchVariableFontSource,
|
|
7128
7138
|
diskCache: fonts?.googleFonts?.cacheDir ? new FontDiskCache(fonts.googleFonts.cacheDir) : void 0
|