@turntrout/subfont 1.0.4 → 1.0.5

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.
@@ -159,6 +159,17 @@ class FontTracerPool {
159
159
  }
160
160
  this._pendingTasks = [];
161
161
 
162
+ // Reject any in-flight tasks still assigned to workers.
163
+ // Clear _taskByWorker before terminate() so _onWorkerExit won't double-reject.
164
+ for (const [, taskId] of this._taskByWorker) {
165
+ const cb = this._taskCallbacks.get(taskId);
166
+ if (cb) {
167
+ this._taskCallbacks.delete(taskId);
168
+ cb.reject(new Error('Worker pool destroyed'));
169
+ }
170
+ }
171
+ this._taskByWorker.clear();
172
+
162
173
  // Terminate workers with a 5-second timeout to prevent hanging
163
174
  const TERMINATE_TIMEOUT_MS = 5000;
164
175
  await Promise.all(
@@ -180,7 +180,8 @@ class HeadlessBrowser {
180
180
  urlTools.resolveUrl(
181
181
  baseUrl,
182
182
  urlTools.buildRelativeUrl(assetGraph.root, htmlAsset.url)
183
- )
183
+ ),
184
+ { timeout: 30000 }
184
185
  );
185
186
 
186
187
  await page.addScriptTag({
@@ -10,6 +10,7 @@ const INVISIBLE_ELEMENTS = new Set([
10
10
  'iframe',
11
11
  'object',
12
12
  'embed',
13
+ 'datalist',
13
14
  ]);
14
15
  const TEXT_ATTRIBUTES = new Set([
15
16
  'alt',
@@ -72,3 +73,4 @@ function extractVisibleText(html) {
72
73
  }
73
74
 
74
75
  module.exports = extractVisibleText;
76
+ module.exports.INVISIBLE_ELEMENTS = INVISIBLE_ELEMENTS;
package/lib/subfont.js CHANGED
@@ -216,14 +216,15 @@ module.exports = async function subfont(
216
216
  }
217
217
  }
218
218
 
219
- let sumSizesBefore = 0;
220
- for (const asset of assetGraph.findAssets({
219
+ const sizeableAssetQuery = {
221
220
  isInline: false,
222
221
  isLoaded: true,
223
222
  type: {
224
223
  $in: ['Html', 'Svg', 'Css', 'JavaScript'],
225
224
  },
226
- })) {
225
+ };
226
+ let sumSizesBefore = 0;
227
+ for (const asset of assetGraph.findAssets(sizeableAssetQuery)) {
227
228
  sumSizesBefore += asset.rawSrc.length;
228
229
  }
229
230
 
@@ -269,13 +270,7 @@ module.exports = async function subfont(
269
270
 
270
271
  phaseStart = Date.now();
271
272
  let sumSizesAfter = 0;
272
- for (const asset of assetGraph.findAssets({
273
- isInline: false,
274
- isLoaded: true,
275
- type: {
276
- $in: ['Html', 'Svg', 'Css', 'JavaScript'],
277
- },
278
- })) {
273
+ for (const asset of assetGraph.findAssets(sizeableAssetQuery)) {
279
274
  sumSizesAfter += asset.rawSrc.length;
280
275
  }
281
276
 
@@ -14,7 +14,7 @@ const getUnicodeRanges = (codePoints) => {
14
14
  const ranges = [];
15
15
  let start, end;
16
16
 
17
- codePoints.sort((a, b) => a - b);
17
+ codePoints = [...codePoints].sort((a, b) => a - b);
18
18
 
19
19
  for (let i = 0; i < codePoints.length; i++) {
20
20
  start = codePoints[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turntrout/subfont",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Automatically subset web fonts to only the characters used on your pages. Fork of Munter/subfont with modern defaults.",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"