@turntrout/subfont 1.7.0 → 1.8.0

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.
Files changed (151) hide show
  1. package/CLAUDE.md +39 -13
  2. package/README.md +24 -14
  3. package/lib/FontTracerPool.d.ts +38 -0
  4. package/lib/FontTracerPool.d.ts.map +1 -0
  5. package/lib/FontTracerPool.js +230 -217
  6. package/lib/FontTracerPool.js.map +1 -0
  7. package/lib/HeadlessBrowser.d.ts +18 -0
  8. package/lib/HeadlessBrowser.d.ts.map +1 -0
  9. package/lib/HeadlessBrowser.js +216 -210
  10. package/lib/HeadlessBrowser.js.map +1 -0
  11. package/lib/cli.d.ts +3 -0
  12. package/lib/cli.d.ts.map +1 -0
  13. package/lib/cli.js +15 -12
  14. package/lib/cli.js.map +1 -0
  15. package/lib/codepointMaps.d.ts +4 -0
  16. package/lib/codepointMaps.d.ts.map +1 -0
  17. package/lib/codepointMaps.js +99 -0
  18. package/lib/codepointMaps.js.map +1 -0
  19. package/lib/collectFeatureGlyphIds.d.ts +3 -0
  20. package/lib/collectFeatureGlyphIds.d.ts.map +1 -0
  21. package/lib/collectFeatureGlyphIds.js +124 -138
  22. package/lib/collectFeatureGlyphIds.js.map +1 -0
  23. package/lib/collectTextsByPage.d.ts +41 -0
  24. package/lib/collectTextsByPage.d.ts.map +1 -0
  25. package/lib/collectTextsByPage.js +726 -965
  26. package/lib/collectTextsByPage.js.map +1 -0
  27. package/lib/concurrencyLimit.d.ts +3 -0
  28. package/lib/concurrencyLimit.d.ts.map +1 -0
  29. package/lib/concurrencyLimit.js +12 -11
  30. package/lib/concurrencyLimit.js.map +1 -0
  31. package/lib/escapeJsStringLiteral.d.ts +3 -0
  32. package/lib/escapeJsStringLiteral.d.ts.map +1 -0
  33. package/lib/escapeJsStringLiteral.js +7 -6
  34. package/lib/escapeJsStringLiteral.js.map +1 -0
  35. package/lib/extractReferencedCustomPropertyNames.d.ts +3 -0
  36. package/lib/extractReferencedCustomPropertyNames.d.ts.map +1 -0
  37. package/lib/extractReferencedCustomPropertyNames.js +15 -16
  38. package/lib/extractReferencedCustomPropertyNames.js.map +1 -0
  39. package/lib/extractVisibleText.d.ts +7 -0
  40. package/lib/extractVisibleText.d.ts.map +1 -0
  41. package/lib/extractVisibleText.js +110 -119
  42. package/lib/extractVisibleText.js.map +1 -0
  43. package/lib/findCustomPropertyDefinitions.d.ts +8 -0
  44. package/lib/findCustomPropertyDefinitions.d.ts.map +1 -0
  45. package/lib/findCustomPropertyDefinitions.js +41 -48
  46. package/lib/findCustomPropertyDefinitions.js.map +1 -0
  47. package/lib/fontConverter.d.ts +2 -0
  48. package/lib/fontConverter.d.ts.map +1 -0
  49. package/lib/fontConverter.js +40 -21
  50. package/lib/fontConverter.js.map +1 -0
  51. package/lib/fontConverterWorker.d.ts +2 -0
  52. package/lib/fontConverterWorker.d.ts.map +1 -0
  53. package/lib/fontConverterWorker.js +52 -15
  54. package/lib/fontConverterWorker.js.map +1 -0
  55. package/lib/fontFaceHelpers.d.ts +64 -0
  56. package/lib/fontFaceHelpers.d.ts.map +1 -0
  57. package/lib/fontFaceHelpers.js +237 -249
  58. package/lib/fontFaceHelpers.js.map +1 -0
  59. package/lib/fontFeatureHelpers.d.ts +30 -0
  60. package/lib/fontFeatureHelpers.d.ts.map +1 -0
  61. package/lib/fontFeatureHelpers.js +277 -212
  62. package/lib/fontFeatureHelpers.js.map +1 -0
  63. package/lib/fontTracerWorker.d.ts +11 -0
  64. package/lib/fontTracerWorker.d.ts.map +1 -0
  65. package/lib/fontTracerWorker.js +94 -60
  66. package/lib/fontTracerWorker.js.map +1 -0
  67. package/lib/gatherStylesheetsWithPredicates.d.ts +26 -0
  68. package/lib/gatherStylesheetsWithPredicates.d.ts.map +1 -0
  69. package/lib/gatherStylesheetsWithPredicates.js +75 -84
  70. package/lib/gatherStylesheetsWithPredicates.js.map +1 -0
  71. package/lib/getCssRulesByProperty.d.ts +29 -0
  72. package/lib/getCssRulesByProperty.d.ts.map +1 -0
  73. package/lib/getCssRulesByProperty.js +316 -316
  74. package/lib/getCssRulesByProperty.js.map +1 -0
  75. package/lib/getFontInfo.d.ts +11 -0
  76. package/lib/getFontInfo.d.ts.map +1 -0
  77. package/lib/getFontInfo.js +31 -33
  78. package/lib/getFontInfo.js.map +1 -0
  79. package/lib/initialValueByProp.d.ts +3 -0
  80. package/lib/initialValueByProp.d.ts.map +1 -0
  81. package/lib/initialValueByProp.js +20 -17
  82. package/lib/initialValueByProp.js.map +1 -0
  83. package/lib/injectSubsetDefinitions.d.ts +3 -0
  84. package/lib/injectSubsetDefinitions.d.ts.map +1 -0
  85. package/lib/injectSubsetDefinitions.js +55 -59
  86. package/lib/injectSubsetDefinitions.js.map +1 -0
  87. package/lib/normalizeFontPropertyValue.d.ts +3 -0
  88. package/lib/normalizeFontPropertyValue.d.ts.map +1 -0
  89. package/lib/normalizeFontPropertyValue.js +59 -54
  90. package/lib/normalizeFontPropertyValue.js.map +1 -0
  91. package/lib/parseCommandLineOptions.d.ts +9 -0
  92. package/lib/parseCommandLineOptions.d.ts.map +1 -0
  93. package/lib/parseCommandLineOptions.js +145 -149
  94. package/lib/parseCommandLineOptions.js.map +1 -0
  95. package/lib/parseFontVariationSettings.d.ts +3 -0
  96. package/lib/parseFontVariationSettings.d.ts.map +1 -0
  97. package/lib/parseFontVariationSettings.js +38 -36
  98. package/lib/parseFontVariationSettings.js.map +1 -0
  99. package/lib/progress.d.ts +27 -0
  100. package/lib/progress.d.ts.map +1 -0
  101. package/lib/progress.js +51 -54
  102. package/lib/progress.js.map +1 -0
  103. package/lib/sfntCache.d.ts +4 -0
  104. package/lib/sfntCache.d.ts.map +1 -0
  105. package/lib/sfntCache.js +67 -25
  106. package/lib/sfntCache.js.map +1 -0
  107. package/lib/stripLocalTokens.d.ts +3 -0
  108. package/lib/stripLocalTokens.d.ts.map +1 -0
  109. package/lib/stripLocalTokens.js +23 -21
  110. package/lib/stripLocalTokens.js.map +1 -0
  111. package/lib/subfont.d.ts +54 -0
  112. package/lib/subfont.d.ts.map +1 -0
  113. package/lib/subfont.js +531 -629
  114. package/lib/subfont.js.map +1 -0
  115. package/lib/subsetFontWithGlyphs.d.ts +21 -0
  116. package/lib/subsetFontWithGlyphs.d.ts.map +1 -0
  117. package/lib/subsetFontWithGlyphs.js +285 -259
  118. package/lib/subsetFontWithGlyphs.js.map +1 -0
  119. package/lib/subsetFonts.d.ts +55 -0
  120. package/lib/subsetFonts.d.ts.map +1 -0
  121. package/lib/subsetFonts.js +899 -1200
  122. package/lib/subsetFonts.js.map +1 -0
  123. package/lib/subsetGeneration.d.ts +36 -0
  124. package/lib/subsetGeneration.d.ts.map +1 -0
  125. package/lib/subsetGeneration.js +328 -325
  126. package/lib/subsetGeneration.js.map +1 -0
  127. package/lib/types/shared.d.ts +11 -0
  128. package/lib/types/shared.d.ts.map +1 -0
  129. package/lib/types/shared.js +3 -0
  130. package/lib/types/shared.js.map +1 -0
  131. package/lib/unicodeRange.d.ts +3 -0
  132. package/lib/unicodeRange.d.ts.map +1 -0
  133. package/lib/unicodeRange.js +17 -30
  134. package/lib/unicodeRange.js.map +1 -0
  135. package/lib/unquote.d.ts +3 -0
  136. package/lib/unquote.d.ts.map +1 -0
  137. package/lib/unquote.js +18 -25
  138. package/lib/unquote.js.map +1 -0
  139. package/lib/variationAxes.d.ts +33 -0
  140. package/lib/variationAxes.d.ts.map +1 -0
  141. package/lib/variationAxes.js +127 -157
  142. package/lib/variationAxes.js.map +1 -0
  143. package/lib/warnAboutMissingGlyphs.d.ts +43 -0
  144. package/lib/warnAboutMissingGlyphs.d.ts.map +1 -0
  145. package/lib/warnAboutMissingGlyphs.js +139 -147
  146. package/lib/warnAboutMissingGlyphs.js.map +1 -0
  147. package/lib/wasmQueue.d.ts +3 -0
  148. package/lib/wasmQueue.d.ts.map +1 -0
  149. package/lib/wasmQueue.js +13 -10
  150. package/lib/wasmQueue.js.map +1 -0
  151. package/package.json +12 -2
@@ -1,239 +1,252 @@
1
- const pathModule = require('path');
2
- const { Worker } = require('worker_threads');
3
-
1
+ "use strict";
2
+ const pathModule = require("path");
3
+ const worker_threads_1 = require("worker_threads");
4
4
  /**
5
5
  * Worker pool for running fontTracer in parallel across pages.
6
6
  * Each worker re-parses HTML with jsdom and runs fontTracer independently.
7
7
  */
8
8
  const DEFAULT_TASK_TIMEOUT_MS = 60_000;
9
-
10
9
  class FontTracerPool {
11
- constructor(numWorkers, { taskTimeoutMs = DEFAULT_TASK_TIMEOUT_MS } = {}) {
12
- this._workerPath = pathModule.join(__dirname, 'fontTracerWorker.js');
13
- this._numWorkers = numWorkers;
14
- this._taskTimeoutMs = taskTimeoutMs;
15
- this._workers = [];
16
- this._idle = [];
17
- this._pendingTasks = [];
18
- this._taskCallbacks = new Map();
19
- this._taskTimers = new Map();
20
- this._taskByWorker = new Map(); // track which taskId each worker is processing
21
- this._nextTaskId = 0;
22
- }
23
-
24
- async init() {
25
- const initPromises = [];
26
- for (let i = 0; i < this._numWorkers; i++) {
27
- const worker = new Worker(this._workerPath);
28
- this._workers.push(worker);
29
-
30
- const initPromise = new Promise((resolve, reject) => {
31
- const onError = reject;
32
- const onMessage = (msg) => {
33
- if (msg.type === 'ready') {
34
- worker.off('message', onMessage);
35
- worker.off('error', onError);
36
- worker.on('message', (msg) => this._onWorkerMessage(worker, msg));
37
- worker.on('exit', (code) => this._onWorkerExit(worker, code));
38
- this._idle.push(worker);
39
- resolve();
40
- }
41
- };
42
- worker.on('message', onMessage);
43
- worker.on('error', onError);
44
- });
45
-
46
- worker.postMessage({ type: 'init' });
47
-
48
- initPromises.push(initPromise);
49
- }
50
- await Promise.all(initPromises);
51
- }
52
-
53
- _clearTaskTimer(taskId) {
54
- const timer = this._taskTimers.get(taskId);
55
- if (timer) {
56
- clearTimeout(timer);
57
- this._taskTimers.delete(taskId);
10
+ _workerPath;
11
+ _numWorkers;
12
+ _taskTimeoutMs;
13
+ _workers;
14
+ _idle;
15
+ _pendingTasks;
16
+ _taskCallbacks;
17
+ _taskTimers;
18
+ _taskByWorker;
19
+ _nextTaskId;
20
+ constructor(numWorkers, { taskTimeoutMs = DEFAULT_TASK_TIMEOUT_MS } = {}) {
21
+ this._workerPath = pathModule.join(__dirname, 'fontTracerWorker.js');
22
+ this._numWorkers = numWorkers;
23
+ this._taskTimeoutMs = taskTimeoutMs;
24
+ this._workers = [];
25
+ this._idle = [];
26
+ this._pendingTasks = [];
27
+ this._taskCallbacks = new Map();
28
+ this._taskTimers = new Map();
29
+ this._taskByWorker = new Map();
30
+ this._nextTaskId = 0;
58
31
  }
59
- }
60
-
61
- _onWorkerMessage(worker, msg) {
62
- this._taskByWorker.delete(worker);
63
- this._clearTaskTimer(msg.taskId);
64
- const cb = this._taskCallbacks.get(msg.taskId);
65
- if (cb) {
66
- this._taskCallbacks.delete(msg.taskId);
67
- if (msg.type === 'result') {
68
- cb.resolve(msg.textByProps);
69
- } else if (msg.type === 'error') {
70
- cb.reject(new Error(`Worker error: ${msg.error}\n${msg.stack}`));
71
- }
32
+ async init() {
33
+ const initPromises = [];
34
+ for (let i = 0; i < this._numWorkers; i++) {
35
+ const worker = new worker_threads_1.Worker(this._workerPath);
36
+ this._workers.push(worker);
37
+ const initPromise = new Promise((resolve, reject) => {
38
+ const fail = (err) => {
39
+ worker.off('message', onMessage);
40
+ worker.off('error', fail);
41
+ const idx = this._workers.indexOf(worker);
42
+ if (idx !== -1)
43
+ this._workers.splice(idx, 1);
44
+ worker.terminate();
45
+ reject(err);
46
+ };
47
+ const onMessage = (msg) => {
48
+ if (msg.type === 'ready') {
49
+ worker.off('message', onMessage);
50
+ worker.off('error', fail);
51
+ worker.on('message', (msg) => this._onWorkerMessage(worker, msg));
52
+ worker.on('error', (err) => this._onWorkerError(worker, err));
53
+ worker.on('exit', (code) => this._onWorkerExit(worker, code));
54
+ this._idle.push(worker);
55
+ resolve();
56
+ }
57
+ };
58
+ worker.on('message', onMessage);
59
+ worker.on('error', fail);
60
+ });
61
+ worker.postMessage({ type: 'init' });
62
+ initPromises.push(initPromise);
63
+ }
64
+ await Promise.all(initPromises);
72
65
  }
73
- // Worker is now idle, check for pending tasks
74
- this._idle.push(worker);
75
- this._dispatchPending();
76
- }
77
-
78
- _onWorkerExit(worker, code) {
79
- // Remove crashed worker from tracking
80
- const workerIdx = this._workers.indexOf(worker);
81
- if (workerIdx !== -1) {
82
- this._workers.splice(workerIdx, 1);
66
+ _onWorkerError(worker, err) {
67
+ // A post-init worker emitted an error. Reject the in-flight task so
68
+ // callers don't hang. The worker is about to exit; _onWorkerExit will
69
+ // remove it from _workers/_idle.
70
+ const taskId = this._taskByWorker.get(worker);
71
+ if (taskId !== undefined) {
72
+ this._taskByWorker.delete(worker);
73
+ this._clearTaskTimer(taskId);
74
+ const cb = this._taskCallbacks.get(taskId);
75
+ if (cb) {
76
+ this._taskCallbacks.delete(taskId);
77
+ cb.reject(err);
78
+ }
79
+ }
83
80
  }
84
- const idleIdx = this._idle.indexOf(worker);
85
- if (idleIdx !== -1) {
86
- this._idle.splice(idleIdx, 1);
81
+ _clearTaskTimer(taskId) {
82
+ const timer = this._taskTimers.get(taskId);
83
+ if (timer) {
84
+ clearTimeout(timer);
85
+ this._taskTimers.delete(taskId);
86
+ }
87
87
  }
88
-
89
- if (code !== 0) {
90
- // Reject the task that was in-flight on this worker
91
- const taskId = this._taskByWorker.get(worker);
92
- this._taskByWorker.delete(worker);
93
- if (taskId !== undefined) {
94
- this._clearTaskTimer(taskId);
95
- const cb = this._taskCallbacks.get(taskId);
88
+ _onWorkerMessage(worker, msg) {
89
+ if (msg.type === 'ready')
90
+ return;
91
+ this._taskByWorker.delete(worker);
92
+ this._clearTaskTimer(msg.taskId);
93
+ const cb = this._taskCallbacks.get(msg.taskId);
96
94
  if (cb) {
97
- this._taskCallbacks.delete(taskId);
98
- cb.reject(new Error(`Worker exited with code ${code}`));
99
- }
100
- }
101
-
102
- // If no workers remain, reject all pending tasks
103
- if (this._workers.length === 0) {
104
- for (const task of this._pendingTasks) {
105
- const cb = this._taskCallbacks.get(task.message.taskId);
106
- if (cb) {
107
- this._taskCallbacks.delete(task.message.taskId);
108
- cb.reject(
109
- new Error('All workers have crashed, no workers available')
110
- );
111
- }
95
+ this._taskCallbacks.delete(msg.taskId);
96
+ if (msg.type === 'result') {
97
+ cb.resolve(msg.textByProps);
98
+ }
99
+ else if (msg.type === 'error') {
100
+ cb.reject(new Error(`Worker error: ${msg.error}\n${msg.stack}`));
101
+ }
112
102
  }
113
- this._pendingTasks = [];
114
- }
103
+ // Worker is now idle, check for pending tasks
104
+ this._idle.push(worker);
105
+ this._dispatchPending();
115
106
  }
116
- }
117
-
118
- _startTaskTimer(taskId) {
119
- if (this._taskTimeoutMs <= 0) return;
120
- const timer = setTimeout(() => {
121
- this._taskTimers.delete(taskId);
122
- const cb = this._taskCallbacks.get(taskId);
123
- if (cb) {
124
- this._taskCallbacks.delete(taskId);
125
- cb.reject(
126
- new Error(
127
- `Font tracing task ${taskId} timed out after ${this._taskTimeoutMs}ms`
128
- )
129
- );
130
- }
131
- // Terminate the hung worker so it doesn't permanently consume a pool
132
- // slot. _onWorkerExit will remove it from _workers and _idle.
133
- for (const [worker, tid] of this._taskByWorker) {
134
- if (tid === taskId) {
135
- this._taskByWorker.delete(worker);
136
- worker.terminate();
137
- break;
107
+ _onWorkerExit(worker, code) {
108
+ const workerIdx = this._workers.indexOf(worker);
109
+ if (workerIdx !== -1) {
110
+ this._workers.splice(workerIdx, 1);
111
+ }
112
+ const idleIdx = this._idle.indexOf(worker);
113
+ if (idleIdx !== -1) {
114
+ this._idle.splice(idleIdx, 1);
138
115
  }
139
- }
140
- }, this._taskTimeoutMs);
141
- timer.unref();
142
- this._taskTimers.set(taskId, timer);
143
- }
144
-
145
- _dispatchPending() {
146
- while (this._idle.length > 0 && this._pendingTasks.length > 0) {
147
- const worker = this._idle.pop();
148
- const task = this._pendingTasks.shift();
149
- this._taskByWorker.set(worker, task.message.taskId);
150
- try {
151
- worker.postMessage(task.message);
152
- this._startTaskTimer(task.message.taskId);
153
- } catch (err) {
154
- // postMessage can fail synchronously (e.g. structured clone error).
155
- // Return the worker to the idle pool and reject the task.
116
+ // Reject any task that was in-flight on this worker. A graceful exit
117
+ // (code 0) mid-task still leaves the caller waiting, so don't gate on
118
+ // code !== 0.
119
+ const taskId = this._taskByWorker.get(worker);
156
120
  this._taskByWorker.delete(worker);
157
- this._idle.push(worker);
158
- const cb = this._taskCallbacks.get(task.message.taskId);
159
- if (cb) {
160
- this._taskCallbacks.delete(task.message.taskId);
161
- cb.reject(err);
121
+ if (taskId !== undefined) {
122
+ this._clearTaskTimer(taskId);
123
+ const cb = this._taskCallbacks.get(taskId);
124
+ if (cb) {
125
+ this._taskCallbacks.delete(taskId);
126
+ cb.reject(new Error(`Worker exited with code ${code}`));
127
+ }
128
+ }
129
+ if (code !== 0 && this._workers.length === 0) {
130
+ for (const task of this._pendingTasks) {
131
+ const cb = this._taskCallbacks.get(task.message.taskId);
132
+ if (cb) {
133
+ this._taskCallbacks.delete(task.message.taskId);
134
+ cb.reject(new Error('All workers have crashed, no workers available'));
135
+ }
136
+ }
137
+ this._pendingTasks = [];
162
138
  }
163
- }
164
139
  }
165
- }
166
-
167
- /**
168
- * Run fontTracer on the given HTML text + stylesheets in a worker.
169
- * Returns a promise that resolves to textByProps.
170
- */
171
- trace(htmlText, stylesheetsWithPredicates) {
172
- const taskId = this._nextTaskId++;
173
- // Serialize stylesheets to plain data asset objects contain DOM/PostCSS
174
- // trees that cannot be transferred via structured clone.
175
- const serializedStylesheets = stylesheetsWithPredicates.map((entry) => ({
176
- text: entry.text || (entry.asset && entry.asset.text) || '',
177
- predicates: entry.predicates || {},
178
- }));
179
- const message = {
180
- type: 'trace',
181
- taskId,
182
- htmlText,
183
- stylesheetsWithPredicates: serializedStylesheets,
184
- };
185
-
186
- return new Promise((resolve, reject) => {
187
- this._taskCallbacks.set(taskId, { resolve, reject });
188
- this._pendingTasks.push({ message });
189
- this._dispatchPending();
190
- });
191
- }
192
-
193
- async destroy() {
194
- // Clear all task timers
195
- for (const timer of this._taskTimers.values()) {
196
- clearTimeout(timer);
140
+ _startTaskTimer(taskId) {
141
+ if (this._taskTimeoutMs <= 0)
142
+ return;
143
+ const timer = setTimeout(() => {
144
+ this._taskTimers.delete(taskId);
145
+ const cb = this._taskCallbacks.get(taskId);
146
+ if (cb) {
147
+ this._taskCallbacks.delete(taskId);
148
+ cb.reject(new Error(`Font tracing task ${taskId} timed out after ${this._taskTimeoutMs}ms`));
149
+ }
150
+ // Terminate the hung worker so it doesn't permanently consume a pool
151
+ // slot. _onWorkerExit will remove it from _workers and _idle.
152
+ for (const [worker, tid] of this._taskByWorker) {
153
+ if (tid === taskId) {
154
+ this._taskByWorker.delete(worker);
155
+ worker.terminate();
156
+ break;
157
+ }
158
+ }
159
+ }, this._taskTimeoutMs);
160
+ timer.unref();
161
+ this._taskTimers.set(taskId, timer);
197
162
  }
198
- this._taskTimers.clear();
199
-
200
- // Reject any tasks still waiting in the queue
201
- for (const task of this._pendingTasks) {
202
- const cb = this._taskCallbacks.get(task.message.taskId);
203
- if (cb) {
204
- this._taskCallbacks.delete(task.message.taskId);
205
- cb.reject(new Error('Worker pool destroyed'));
206
- }
163
+ _dispatchPending() {
164
+ while (this._idle.length > 0 && this._pendingTasks.length > 0) {
165
+ const worker = this._idle.pop();
166
+ const task = this._pendingTasks.shift();
167
+ this._taskByWorker.set(worker, task.message.taskId);
168
+ try {
169
+ worker.postMessage(task.message);
170
+ this._startTaskTimer(task.message.taskId);
171
+ }
172
+ catch (err) {
173
+ // postMessage can fail synchronously (e.g. structured clone error).
174
+ // Return the worker to the idle pool and reject the task.
175
+ this._taskByWorker.delete(worker);
176
+ this._idle.push(worker);
177
+ const cb = this._taskCallbacks.get(task.message.taskId);
178
+ if (cb) {
179
+ this._taskCallbacks.delete(task.message.taskId);
180
+ cb.reject(err);
181
+ }
182
+ }
183
+ }
184
+ }
185
+ /**
186
+ * Run fontTracer on the given HTML text + stylesheets in a worker.
187
+ * Returns a promise that resolves to textByProps.
188
+ */
189
+ // The pool is payload-agnostic; callers (subsetFonts.ts) interpret the
190
+ // returned textByProps according to font-tracer's contract.
191
+ trace(htmlText, stylesheetsWithPredicates
192
+ // eslint-disable-next-line no-restricted-syntax
193
+ ) {
194
+ const taskId = this._nextTaskId++;
195
+ // Serialize stylesheets to plain data — asset objects contain DOM/PostCSS
196
+ // trees that cannot be transferred via structured clone.
197
+ const serializedStylesheets = stylesheetsWithPredicates.map((entry) => ({
198
+ text: entry.text || (entry.asset && entry.asset.text) || '',
199
+ predicates: entry.predicates || {},
200
+ }));
201
+ const message = {
202
+ type: 'trace',
203
+ taskId,
204
+ htmlText,
205
+ stylesheetsWithPredicates: serializedStylesheets,
206
+ };
207
+ return new Promise((resolve, reject) => {
208
+ this._taskCallbacks.set(taskId, { resolve, reject });
209
+ this._pendingTasks.push({ message });
210
+ this._dispatchPending();
211
+ });
207
212
  }
208
- this._pendingTasks = [];
209
-
210
- // Reject any in-flight tasks still assigned to workers.
211
- // Clear _taskByWorker before terminate() so _onWorkerExit won't double-reject.
212
- for (const [, taskId] of this._taskByWorker) {
213
- const cb = this._taskCallbacks.get(taskId);
214
- if (cb) {
215
- this._taskCallbacks.delete(taskId);
216
- cb.reject(new Error('Worker pool destroyed'));
217
- }
213
+ async destroy() {
214
+ // Clear all task timers
215
+ for (const timer of this._taskTimers.values()) {
216
+ clearTimeout(timer);
217
+ }
218
+ this._taskTimers.clear();
219
+ // Reject any tasks still waiting in the queue
220
+ for (const task of this._pendingTasks) {
221
+ const cb = this._taskCallbacks.get(task.message.taskId);
222
+ if (cb) {
223
+ this._taskCallbacks.delete(task.message.taskId);
224
+ cb.reject(new Error('Worker pool destroyed'));
225
+ }
226
+ }
227
+ this._pendingTasks = [];
228
+ // Reject any in-flight tasks still assigned to workers.
229
+ // Clear _taskByWorker before terminate() so _onWorkerExit won't double-reject.
230
+ for (const [, taskId] of this._taskByWorker) {
231
+ const cb = this._taskCallbacks.get(taskId);
232
+ if (cb) {
233
+ this._taskCallbacks.delete(taskId);
234
+ cb.reject(new Error('Worker pool destroyed'));
235
+ }
236
+ }
237
+ this._taskByWorker.clear();
238
+ // Terminate workers with a 5-second timeout to prevent hanging
239
+ const TERMINATE_TIMEOUT_MS = 5000;
240
+ await Promise.all(this._workers.map((w) => Promise.race([
241
+ w.terminate(),
242
+ new Promise((resolve) => {
243
+ const timer = setTimeout(resolve, TERMINATE_TIMEOUT_MS);
244
+ timer.unref();
245
+ }),
246
+ ])));
247
+ this._workers = [];
248
+ this._idle = [];
218
249
  }
219
- this._taskByWorker.clear();
220
-
221
- // Terminate workers with a 5-second timeout to prevent hanging
222
- const TERMINATE_TIMEOUT_MS = 5000;
223
- await Promise.all(
224
- this._workers.map((w) =>
225
- Promise.race([
226
- w.terminate(),
227
- new Promise((resolve) => {
228
- const timer = setTimeout(resolve, TERMINATE_TIMEOUT_MS);
229
- timer.unref();
230
- }),
231
- ])
232
- )
233
- );
234
- this._workers = [];
235
- this._idle = [];
236
- }
237
250
  }
238
-
239
251
  module.exports = FontTracerPool;
252
+ //# sourceMappingURL=FontTracerPool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontTracerPool.js","sourceRoot":"","sources":["../src/FontTracerPool.ts"],"names":[],"mappings":";AAAA,mCAAoC;AACpC,mDAAwC;AAExC;;;GAGG;AACH,MAAM,uBAAuB,GAAG,MAAM,CAAC;AA2DvC,MAAM,cAAc;IACV,WAAW,CAAS;IACpB,WAAW,CAAS;IACpB,cAAc,CAAS;IACvB,QAAQ,CAAW;IACnB,KAAK,CAAW;IAChB,aAAa,CAAmC;IAChD,cAAc,CAA6B;IAC3C,WAAW,CAA8B;IACzC,aAAa,CAAsB;IACnC,WAAW,CAAS;IAE5B,YACE,UAAkB,EAClB,EAAE,aAAa,GAAG,uBAAuB,KAA4B,EAAE;QAEvE,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,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AAK,CAAC,KAAK,EAAE,CAAC;YAChB,CAAC,CAAC;SACH,CAAC,CACH,CACF,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;CACF;AAED,iBAAS,cAAc,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Asset } from 'assetgraph';
2
+ type TraceResult = Record<string, unknown>;
3
+ interface HeadlessBrowserOptions {
4
+ console: Console;
5
+ chromeArgs?: string[];
6
+ }
7
+ declare class HeadlessBrowser {
8
+ private console;
9
+ private _chromeArgs;
10
+ private _launchPromise?;
11
+ private _closed;
12
+ constructor({ console, chromeArgs }: HeadlessBrowserOptions);
13
+ private _launchBrowserMemoized;
14
+ tracePage(htmlAsset: Asset): Promise<TraceResult[]>;
15
+ close(): Promise<void>;
16
+ }
17
+ export = HeadlessBrowser;
18
+ //# sourceMappingURL=HeadlessBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeadlessBrowser.d.ts","sourceRoot":"","sources":["../src/HeadlessBrowser.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,YAAY,CAAC;AAKpD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA2E3C,UAAU,sBAAsB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,cAAM,eAAe;IACnB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,WAAW,CAAW;IAC9B,OAAO,CAAC,cAAc,CAAC,CAA4B;IACnD,OAAO,CAAC,OAAO,CAAkB;gBAErB,EAAE,OAAO,EAAE,UAAe,EAAE,EAAE,sBAAsB;IAKhE,OAAO,CAAC,sBAAsB;IAgBxB,SAAS,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAgHnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB7B;AAED,SAAS,eAAe,CAAC"}