wasm-html-to-image 1.0.12 → 1.0.13
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/core-orchestrate.js +1 -1
- package/dist/core-resources.d.ts +2 -0
- package/dist/core-resources.js +16 -13
- package/dist/diagnostics.d.ts +5 -0
- package/dist/html-to-image-wasm.js +3 -3
- package/dist/html-to-image.wasm +0 -0
- package/dist/web-workers.js +33 -51
- package/dist/workers-parent.js +10 -20
- package/package.json +2 -2
package/dist/core-orchestrate.js
CHANGED
|
@@ -132,7 +132,7 @@ export function createOrchestration(module, options) {
|
|
|
132
132
|
limits,
|
|
133
133
|
resolveResource,
|
|
134
134
|
diag,
|
|
135
|
-
usage: { resourceCount: 0, totalResourceBytes: 0 },
|
|
135
|
+
usage: { resourceCount: 0, totalResourceBytes: 0, fontsSkippedByCount: 0 },
|
|
136
136
|
t0,
|
|
137
137
|
emitLog,
|
|
138
138
|
addTime,
|
package/dist/core-resources.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface DiagState {
|
|
|
37
37
|
export interface ResourceUsage {
|
|
38
38
|
resourceCount: number;
|
|
39
39
|
totalResourceBytes: number;
|
|
40
|
+
/** Font files dropped because `maxResourceCount` was reached (across all rounds). */
|
|
41
|
+
fontsSkippedByCount: number;
|
|
40
42
|
}
|
|
41
43
|
/** Resolution context threaded through HTML discovery (internal). */
|
|
42
44
|
export interface ResolveContext {
|
package/dist/core-resources.js
CHANGED
|
@@ -450,7 +450,6 @@ export async function resolveHtmlResources(module, satoruInst, htmls, width, hei
|
|
|
450
450
|
.map((r, i) => ({ r, i }))
|
|
451
451
|
.sort((a, b) => rank(a.r.type) - rank(b.r.type) || a.i - b.i)
|
|
452
452
|
.map((e) => e.r);
|
|
453
|
-
let fontsSkippedByCount = 0;
|
|
454
453
|
await mapWithLimit(ordered, FETCH_CONCURRENCY, async (r) => {
|
|
455
454
|
const diag = ctx.diag;
|
|
456
455
|
const entry = diag
|
|
@@ -494,7 +493,7 @@ export async function resolveHtmlResources(module, satoruInst, htmls, width, hei
|
|
|
494
493
|
ctx.usage.resourceCount >= ctx.limits.maxResourceCount) {
|
|
495
494
|
const message = `Maximum resource count (${ctx.limits.maxResourceCount}) exceeded`;
|
|
496
495
|
if (r.type === "font")
|
|
497
|
-
fontsSkippedByCount++;
|
|
496
|
+
ctx.usage.fontsSkippedByCount++;
|
|
498
497
|
skipWithError(DIAGNOSTIC_CODES.LIMIT_RESOURCE_COUNT, message);
|
|
499
498
|
return;
|
|
500
499
|
}
|
|
@@ -551,17 +550,6 @@ export async function resolveHtmlResources(module, satoruInst, htmls, width, hei
|
|
|
551
550
|
diag?.warnings.push(d);
|
|
552
551
|
}
|
|
553
552
|
});
|
|
554
|
-
if (fontsSkippedByCount > 0) {
|
|
555
|
-
// Text in those fonts renders as tofu: say what to change instead of leaving a silent bad image.
|
|
556
|
-
const message = `${fontsSkippedByCount} font file(s) were not loaded because maxResourceCount ` +
|
|
557
|
-
`(${ctx.limits.maxResourceCount}) was reached; text using them may render as missing glyphs. ` +
|
|
558
|
-
"Raise limits.maxResourceCount (a Google Fonts stylesheet alone can reference over a hundred files).";
|
|
559
|
-
ctx.diag?.warnings.push({
|
|
560
|
-
code: DIAGNOSTIC_CODES.LIMIT_RESOURCE_COUNT,
|
|
561
|
-
message,
|
|
562
|
-
});
|
|
563
|
-
ctx.emitLog(LogLevel.Warning, message);
|
|
564
|
-
}
|
|
565
553
|
loadedCss.sort((a, b) => a.index - b.index);
|
|
566
554
|
for (const css of loadedCss) {
|
|
567
555
|
const text = new TextDecoder().decode(css.bytes);
|
|
@@ -570,6 +558,21 @@ export async function resolveHtmlResources(module, satoruInst, htmls, width, hei
|
|
|
570
558
|
(await addRes(satoruInst, css.url, 3, bytes));
|
|
571
559
|
}
|
|
572
560
|
}
|
|
561
|
+
if (ctx.usage.fontsSkippedByCount > 0) {
|
|
562
|
+
// Text in those fonts renders as tofu: say what to change instead of leaving a silent bad image.
|
|
563
|
+
// One message for the whole render, however many discovery rounds hit the limit.
|
|
564
|
+
const message = `${ctx.usage.fontsSkippedByCount} font file(s) were not loaded because maxResourceCount ` +
|
|
565
|
+
`(${ctx.limits.maxResourceCount}) was reached; text using them may render as missing glyphs. ` +
|
|
566
|
+
"Raise limits.maxResourceCount (a Google Fonts stylesheet alone can reference over a hundred files).";
|
|
567
|
+
ctx.diag?.warnings.push({
|
|
568
|
+
code: DIAGNOSTIC_CODES.LIMIT_RESOURCE_COUNT,
|
|
569
|
+
message,
|
|
570
|
+
});
|
|
571
|
+
ctx.emitLog(LogLevel.Warning, message);
|
|
572
|
+
if (ctx.limits.strictFonts) {
|
|
573
|
+
throw new Error(`[${DIAGNOSTIC_CODES.LIMIT_RESOURCE_COUNT}] ${message}`);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
573
576
|
// Merge the C++ collect-phase breakdown into the JS timings.
|
|
574
577
|
if (profileEnabled && ctx.diag) {
|
|
575
578
|
const getProfile = module.satoru_get_collect_profile;
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -108,6 +108,11 @@ export interface RenderLimits {
|
|
|
108
108
|
maxTotalResourceBytes?: number;
|
|
109
109
|
/** Maximum number of resources to load. */
|
|
110
110
|
maxResourceCount?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Throw (code `LIMIT_RESOURCE_COUNT`) instead of rendering when font files had to be skipped
|
|
113
|
+
* because of `maxResourceCount`, so text is never silently drawn as missing glyphs. Default `false`.
|
|
114
|
+
*/
|
|
115
|
+
strictFonts?: boolean;
|
|
111
116
|
/** Allowed URL protocols (e.g. `["http:", "https:"]`). */
|
|
112
117
|
allowedProtocols?: string[];
|
|
113
118
|
/** Allowed hostnames. */
|