@spinajs/templates-puppeteer 2.0.481 → 2.0.482

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/lib/cjs/index.js CHANGED
@@ -1,246 +1,267 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
2
13
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
14
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
15
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
16
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
17
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
18
  };
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
8
22
  var __metadata = (this && this.__metadata) || function (k, v) {
9
23
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
24
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
25
  Object.defineProperty(exports, "__esModule", { value: true });
15
26
  exports.PuppeteerRenderer = void 0;
16
- const puppeteer_1 = __importDefault(require("puppeteer"));
17
27
  const exceptions_1 = require("@spinajs/exceptions");
18
28
  const templates_1 = require("@spinajs/templates");
19
29
  const di_1 = require("@spinajs/di");
20
30
  const path_1 = require("path");
21
31
  const log_1 = require("@spinajs/log");
22
- const express_1 = __importDefault(require("express"));
23
- const cors_1 = __importDefault(require("cors"));
24
32
  require("@spinajs/templates-pug");
25
- const lodash_1 = __importDefault(require("lodash"));
33
+ const progress_js_1 = require("./progress.js");
34
+ const asset_server_js_1 = require("./asset-server.js");
35
+ const browser_pool_js_1 = require("./browser-pool.js");
36
+ __exportStar(require("./progress.js"), exports);
37
+ __exportStar(require("./asset-server.js"), exports);
38
+ __exportStar(require("./browser-pool.js"), exports);
39
+ /** Default navigation/render timeout when none is configured (ms). */
40
+ const DEFAULT_RENDER_TIMEOUT_MS = 30000;
41
+ /** Watchdog canceller used when timeouts are disabled (debug mode). */
42
+ const noop = () => {
43
+ /* nothing to cancel */
44
+ };
26
45
  class PuppeteerRenderer extends templates_1.TemplateRenderer {
27
- async renderToFile(template, model, filePath, language) {
28
- let server = null;
29
- let browser = null;
30
- try {
31
- this.Log.timeStart(`puppeteer-template-rendering-${filePath}`);
32
- this.Log.trace(`Rendering template ${template} to file ${filePath}`);
33
- const templateBasePath = (0, path_1.dirname)(template);
34
- // fire up local http server for serving images etc
35
- // becouse chromium prevents from reading local files when not
36
- // rendering file with file:// protocol for security reasons
37
- server = await this.runLocalServer(templateBasePath);
38
- const httpPort = server.address().port;
46
+ /**
47
+ * Per-instance options that give this renderer its identity for the DI
48
+ * @PerInstanceCheck pooling (see subclasses). Renderers that are not pooled
49
+ * per-instance inherit the `undefined` default.
50
+ */
51
+ get instanceOptions() {
52
+ return undefined;
53
+ }
54
+ /**
55
+ * DI @PerInstanceCheck hook: an existing instance is reused only when it was
56
+ * created with the same options.
57
+ */
58
+ __checkInstance__(creationOptions) {
59
+ return JSON.stringify(this.instanceOptions) === JSON.stringify(creationOptions);
60
+ }
61
+ /** Local static server used so Chromium can load relative asset URLs. Lazily created. */
62
+ get assetServer() {
63
+ return (this._assetServer ??= new asset_server_js_1.LocalAssetServer(this.Log, () => this.Options?.static?.portRange));
64
+ }
65
+ /**
66
+ * Pooled browser, launched lazily and reused across renders, closed on dispose().
67
+ * One pool per options-set (see @PerInstanceCheck on subclasses). Lazily created.
68
+ */
69
+ get browserPool() {
70
+ return (this._browserPool ??= new browser_pool_js_1.BrowserPool(this.Log, () => this.buildLaunchOptions()));
71
+ }
72
+ buildLaunchOptions() {
73
+ return {
74
+ ...(this.Options?.args || {}),
75
+ ...(this.Options?.executablePath && {
76
+ executablePath: this.Options.executablePath,
77
+ }),
78
+ };
79
+ }
80
+ async renderToFile(template, model, filePath, language, options) {
81
+ const templateBasePath = (0, path_1.dirname)(template);
82
+ await this.renderContentToFile(filePath, { assetBasePath: templateBasePath, onProgress: options?.onProgress }, async (page, httpPort, markLoading) => {
39
83
  const compiledTemplate = await this.TemplatingService.render((0, path_1.join)(templateBasePath, (0, path_1.basename)(template, this.Extension)) + '.pug', {
40
- // add template temporary server port
41
- // so we can use it to render images in template
84
+ // add template temporary server port so templates can reference local images
42
85
  __http_template_port__: httpPort,
43
- // for convinience add full url to local http server
86
+ // for convenience add full url to local http server
44
87
  __http_template_address__: `http://localhost:${httpPort}`,
45
88
  ...model,
46
89
  }, language);
47
- const launchOptions = {
48
- ...(this.Options?.args || {}),
49
- ...(this.Options?.executablePath && {
50
- executablePath: this.Options.executablePath,
51
- }),
52
- };
53
- browser = await puppeteer_1.default.launch(launchOptions);
54
- const page = await browser.newPage();
55
- // Skip timeouts in debug mode
56
- if (!this.Options?.debug?.close) {
57
- page.setDefaultNavigationTimeout(this.Options?.navigationTimeout || 30000); // Default 30s
58
- page.setDefaultTimeout(this.Options?.renderTimeout || 30000); // Default 30s
90
+ // template is compiled; resource loading starts with setContent
91
+ markLoading();
92
+ await page.setContent(compiledTemplate);
93
+ });
94
+ }
95
+ /**
96
+ * Render a raw HTML string to a file (image/pdf per the concrete renderer).
97
+ * Intended for CI (e.g. screenshot comparison) where HTML is already produced.
98
+ *
99
+ * @param html - the HTML content to render
100
+ * @param filePath - output file path
101
+ * @param options.assetBasePath - directory served over the local http server so
102
+ * relative asset URLs in the HTML resolve (defaults to the output file's dir)
103
+ * @param options.viewport - fixed viewport for deterministic captures
104
+ */
105
+ async renderHtmlToFile(html, filePath, options) {
106
+ await this.renderContentToFile(filePath, { assetBasePath: options?.assetBasePath ?? (0, path_1.dirname)(filePath), onProgress: options?.onProgress }, async (page, httpPort, markLoading) => {
107
+ if (options?.viewport) {
108
+ await page.setViewport(options.viewport);
59
109
  }
60
- // Set up render timeout (skip in debug mode)
61
- let renderTimeout;
62
- if (!this.Options?.debug?.close) {
63
- const timeoutMs = this.Options?.renderTimeout || 30000;
64
- renderTimeout = setTimeout(async () => {
65
- this.Log.warn(`Render timeout (${timeoutMs}ms) - forcing cleanup`);
66
- try {
67
- if (page)
68
- await page.close().catch(() => { });
69
- if (browser)
70
- await this.forceCloseBrowser(browser);
71
- }
72
- catch (err) {
73
- this.Log.error('Error during timeout cleanup:', err);
74
- }
75
- }, timeoutMs);
110
+ // resource loading starts with setContent
111
+ markLoading();
112
+ // inject a <base href> so relative asset URLs resolve via the local server
113
+ await page.setContent(this.injectBaseHref(html, `http://127.0.0.1:${httpPort}/`));
114
+ });
115
+ }
116
+ /**
117
+ * Shared render orchestration: local static server + pooled browser + page +
118
+ * timeout watchdog + cleanup. `prepare` populates the page content (template-compiled
119
+ * HTML, or raw HTML). The pooled browser survives; only the page is closed.
120
+ */
121
+ async renderContentToFile(filePath, opts, prepare) {
122
+ const timerLabel = `puppeteer-template-rendering-${filePath}`;
123
+ const progress = new progress_js_1.RenderProgressReporter(filePath, opts.onProgress);
124
+ let server = null;
125
+ let page = null;
126
+ // When debug.close === false the page is intentionally kept open for
127
+ // inspection, so timeouts must not be armed (the watchdog would close it).
128
+ // The browser itself is pooled and only closed on dispose().
129
+ const keepPageOpen = this.Options?.debug?.close === false;
130
+ try {
131
+ this.Log.timeStart(timerLabel);
132
+ this.Log.trace(`Rendering to file ${filePath}`);
133
+ progress.phase(templates_1.RenderPhase.Starting);
134
+ // fire up local http server for serving images etc, because chromium
135
+ // prevents reading local files when not using the file:// protocol
136
+ server = await this.assetServer.serve(opts.assetBasePath ?? process.cwd());
137
+ const httpPort = server.address().port;
138
+ // reuse the pooled browser; open a fresh page per render
139
+ const browser = await this.browserPool.acquire();
140
+ page = await browser.newPage();
141
+ progress.attach(page);
142
+ // In debug mode neither timeouts nor the watchdog are armed, so the page
143
+ // can be inspected indefinitely.
144
+ const cancelWatchdog = keepPageOpen ? noop : this.armRenderWatchdog(page);
145
+ if (!keepPageOpen) {
146
+ this.configurePageTimeouts(page);
76
147
  }
77
- // Add event listeners with explicit cleanup tracking
78
- const eventCleanup = this.addPageEventListeners(page);
148
+ const removeListeners = this.addPageEventListeners(page);
79
149
  try {
150
+ progress.phase(templates_1.RenderPhase.Preparing);
80
151
  await page.setBypassCSP(true);
81
- await page.setContent(compiledTemplate);
82
- // Call abstract method to perform specific rendering (PDF or image)
152
+ // prepare compiles/builds the HTML then calls markLoading() right before
153
+ // setContent, so template-compile time is separated from resource loading.
154
+ await prepare(page, httpPort, () => progress.phase(templates_1.RenderPhase.Loading));
155
+ // perform the concrete rendering (PDF or image)
156
+ progress.phase(templates_1.RenderPhase.Rendering);
83
157
  await this.performRender(page, filePath);
84
- // Clear timeout on successful completion
85
- if (renderTimeout) {
86
- clearTimeout(renderTimeout);
87
- renderTimeout = undefined;
88
- }
89
- // Clean up event listeners
90
- eventCleanup();
158
+ progress.phase(templates_1.RenderPhase.Done);
91
159
  }
92
160
  catch (renderError) {
93
- // Clear timeout on error
94
- if (renderTimeout) {
95
- clearTimeout(renderTimeout);
96
- renderTimeout = undefined;
97
- }
98
- this.Log.error(renderError, `Error during rendering for template ${template}`);
161
+ this.Log.error(renderError, `Error during rendering for ${filePath}`);
99
162
  throw renderError;
100
163
  }
164
+ finally {
165
+ cancelWatchdog();
166
+ removeListeners();
167
+ }
101
168
  }
102
169
  catch (err) {
103
- this.Log.error(err, `Error rendering template ${template} to file ${filePath}`);
170
+ progress.phase(templates_1.RenderPhase.Failed, err?.message);
171
+ this.Log.error(err, `Error rendering to file ${filePath}`);
104
172
  throw err;
105
173
  }
106
174
  finally {
107
- const duration = this.Log.timeEnd(`puppeteer-template-rendering-${filePath}`);
108
- this.Log.trace(`Ended rendering template ${template} to file ${filePath}, took: ${duration}ms`);
109
- if (this.Options && duration > this.Options.renderDurationWarning) {
110
- this.Log.warn(`Rendering template ${template} to file ${filePath} took too long.`);
175
+ progress.dispose();
176
+ const duration = this.Log.timeEnd(timerLabel);
177
+ this.Log.trace(`Ended rendering to file ${filePath}, took: ${duration}ms`);
178
+ this.warnIfSlow(filePath, duration);
179
+ // Close the page (not the pooled browser). Skip if debug.close is false
180
+ // so the rendered page can be inspected.
181
+ if (page && !keepPageOpen) {
182
+ await this.closePage(page);
111
183
  }
112
- // Skip browser cleanup if debug.close is false (keep browser open for inspection)
113
- if (browser && (!this.Options || this.Options.debug?.close !== false)) {
114
- await this.safeBrowserCleanup(browser);
115
- }
116
- else if (browser) {
117
- this.Log.info('Browser kept open for debugging (debug.close=false)');
184
+ else if (page) {
185
+ this.Log.info('Page kept open for debugging (debug.close=false)');
118
186
  }
119
187
  if (server) {
120
- await this.safeServerCleanup(server);
188
+ await this.assetServer.close(server);
121
189
  }
122
190
  }
123
191
  }
124
- async render(_templateName, _model, _language) {
125
- throw new exceptions_1.NotSupported('cannot render puppeteer template to string');
192
+ /** Effective render timeout: configured value, else the default. */
193
+ get renderTimeoutMs() {
194
+ return this.Options?.renderTimeout || DEFAULT_RENDER_TIMEOUT_MS;
126
195
  }
127
- // no compilation at start
128
- async compile(_path) { }
129
- async runLocalServer(basePath) {
130
- const self = this;
131
- const app = (0, express_1.default)();
132
- app.use((0, cors_1.default)());
133
- app.use(express_1.default.static(basePath));
134
- return new Promise((resolve, reject) => {
135
- const server = app
136
- // if no port is provided express will choose random port to start (available)
137
- // if not, we will get random from range in config
138
- .listen(!this.Options?.static?.portRange || this.Options.static.portRange.length === 0
139
- ? 0
140
- : lodash_1.default.random(this.Options.static.portRange[0], this.Options.static.portRange[1]))
141
- .on('listening', function () {
142
- self.Log.trace(`Puppeteer image server started on port ${this.address().port}`);
143
- self.Log.trace(`Puppeteer static file dir at ${basePath}`);
144
- resolve(this);
145
- })
146
- .on('error', (err) => {
147
- self.Log.error(err, `Puppeteer image server cannot start`);
148
- // Clean up the failed server
149
- if (server) {
150
- server.close(() => {
151
- reject(err);
152
- });
153
- }
154
- else {
155
- reject(err);
156
- }
157
- });
158
- // Set a timeout for server startup
159
- setTimeout(() => {
160
- if (!server.listening) {
161
- server.close();
162
- reject(new Error('Server startup timeout'));
163
- }
164
- }, 10000);
165
- });
196
+ /** Apply the configured (or default) navigation and render timeouts to a page. */
197
+ configurePageTimeouts(page) {
198
+ page.setDefaultNavigationTimeout(this.Options?.navigationTimeout || DEFAULT_RENDER_TIMEOUT_MS);
199
+ page.setDefaultTimeout(this.renderTimeoutMs);
166
200
  }
167
201
  /**
168
- * Enhanced browser cleanup with error handling
202
+ * Arm a watchdog that closes the page if a render exceeds the configured
203
+ * timeout - only the page is closed, the pooled browser may be serving other
204
+ * concurrent renders. Returns a function that cancels the watchdog.
169
205
  */
170
- async safeBrowserCleanup(browser) {
171
- try {
172
- // First try to close all pages
173
- const pages = await browser.pages();
174
- await Promise.allSettled(pages.map(page => page.close()));
175
- // Then close the browser normally
176
- await browser.close();
177
- }
178
- catch (err) {
179
- this.Log.warn(`Error during normal browser cleanup: ${err.message}`);
180
- // Force kill if normal close fails
181
- try {
182
- await this.forceCloseBrowser(browser);
183
- }
184
- catch (killErr) {
185
- this.Log.error(`Failed to force kill browser: ${killErr.message}`);
186
- }
206
+ armRenderWatchdog(page) {
207
+ const timeoutMs = this.renderTimeoutMs;
208
+ const handle = setTimeout(() => {
209
+ this.Log.warn(`Render timeout (${timeoutMs}ms) - closing page`);
210
+ page.close().catch(() => { });
211
+ }, timeoutMs);
212
+ return () => clearTimeout(handle);
213
+ }
214
+ /** Warn if a render took longer than the configured warning threshold. */
215
+ warnIfSlow(filePath, duration) {
216
+ if (this.Options && duration > this.Options.renderDurationWarning) {
217
+ this.Log.warn(`Rendering to file ${filePath} took too long.`);
187
218
  }
188
219
  }
220
+ /** Close a page, downgrading any close error to a warning (best-effort cleanup). */
221
+ async closePage(page) {
222
+ await page.close().catch((err) => this.Log.warn(`Error closing page: ${err.message}`));
223
+ }
189
224
  /**
190
- * Force close browser with process termination
225
+ * Insert a <base href> into the HTML <head> so relative asset URLs resolve
226
+ * against the local static server. No-op if the HTML already declares a <base>.
191
227
  */
192
- async forceCloseBrowser(browser) {
193
- try {
194
- const process = browser.process();
195
- if (process) {
196
- process.kill('SIGKILL');
197
- this.Log.warn('Browser process force killed');
198
- }
228
+ injectBaseHref(html, baseUrl) {
229
+ if (/<base\s/i.test(html)) {
230
+ return html;
199
231
  }
200
- catch (err) {
201
- this.Log.error(`Error force killing browser process: ${err.message}`);
232
+ if (/<head[^>]*>/i.test(html)) {
233
+ return html.replace(/<head([^>]*)>/i, `<head$1><base href="${baseUrl}">`);
234
+ }
235
+ if (/<html[^>]*>/i.test(html)) {
236
+ return html.replace(/<html([^>]*)>/i, `<html$1><head><base href="${baseUrl}"></head>`);
202
237
  }
238
+ return `<base href="${baseUrl}">${html}`;
203
239
  }
204
240
  /**
205
- * Enhanced server cleanup with timeout
241
+ * Close the pooled browser when the service is disposed (e.g. DI.dispose() at shutdown).
242
+ * Callers that render one-shot (CLI, single email) should dispose so the process can exit.
206
243
  */
207
- async safeServerCleanup(server) {
208
- try {
209
- await new Promise((resolve, reject) => {
210
- const timeout = setTimeout(() => {
211
- reject(new Error('Server close timeout'));
212
- }, 5000);
213
- server.close((err) => {
214
- clearTimeout(timeout);
215
- if (err)
216
- reject(err);
217
- else
218
- resolve();
219
- });
220
- });
221
- }
222
- catch (err) {
223
- this.Log.warn(`Error closing server: ${err.message}`);
224
- // Force close connections if available
225
- try {
226
- if ('closeAllConnections' in server) {
227
- server.closeAllConnections();
228
- }
229
- }
230
- catch (forceErr) {
231
- this.Log.error(`Error force closing server connections: ${forceErr.message}`);
232
- }
244
+ async dispose() {
245
+ if (this._browserPool) {
246
+ await this._browserPool.dispose();
233
247
  }
248
+ await super.dispose();
249
+ }
250
+ async render(_templateName, _model, _language) {
251
+ throw new exceptions_1.NotSupported('cannot render puppeteer template to string');
234
252
  }
235
253
  /**
236
254
  * Add page event listeners with cleanup function
237
255
  */
238
256
  addPageEventListeners(page) {
239
257
  const listeners = {
240
- console: (message) => this.Log.trace(`${message.type().substr(0, 3).toUpperCase()} ${message.text()}`),
241
- pageerror: ({ message }) => this.Log.error(message),
258
+ console: (message) => this.Log.trace(`${message.type().slice(0, 3).toUpperCase()} ${message.text()}`),
259
+ pageerror: (error) => this.Log.error(error.message),
242
260
  response: (response) => this.Log.trace(`${response.status()} ${response.url()}`),
243
- requestfailed: (request) => this.Log.error(`${request.failure().errorText} ${request.url()}`)
261
+ requestfailed: (request) => {
262
+ const failure = request.failure();
263
+ this.Log.error(`${failure ? failure.errorText : 'request failed'} ${request.url()}`);
264
+ }
244
265
  };
245
266
  // Add listeners
246
267
  page.on('console', listeners.console);
@@ -250,10 +271,10 @@ class PuppeteerRenderer extends templates_1.TemplateRenderer {
250
271
  // Return cleanup function
251
272
  return () => {
252
273
  try {
253
- page.removeListener('console', listeners.console);
254
- page.removeListener('pageerror', listeners.pageerror);
255
- page.removeListener('response', listeners.response);
256
- page.removeListener('requestfailed', listeners.requestfailed);
274
+ page.off('console', listeners.console);
275
+ page.off('pageerror', listeners.pageerror);
276
+ page.off('response', listeners.response);
277
+ page.off('requestfailed', listeners.requestfailed);
257
278
  }
258
279
  catch (err) {
259
280
  this.Log.warn(`Error removing page listeners: ${err.message}`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAA+E;AAC/E,oDAAmD;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AO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACvF,CAAC;SACF,CAAC;QAEF,gBAAgB;QAChB,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;QAElD,0BAA0B;QAC1B,OAAO,GAAG,EAAE;YACV,IAAI,CAAC;gBACH,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;gBACvC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;gBAC3C,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACzC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kCAAkC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF;AA/SD,8CA+SC;AA1RW;IADT,IAAA,YAAM,EAAC,qBAAqB,CAAC;8BACf,SAAG;8CAAC;AAGT;IADT,IAAA,eAAU,GAAE;8BACgB,qBAAS;4DAAC"}
@@ -0,0 +1,41 @@
1
+ import { Page } from 'puppeteer';
2
+ import { RenderPhase, RenderProgressCallback } from '@spinajs/templates';
3
+ /**
4
+ * Tracks a single puppeteer render and delivers throttled {@link IRenderProgress}
5
+ * snapshots to a callback. Resource counts come from the page's request lifecycle
6
+ * events; the percentage is phase-weighted (see {@link PHASE_BANDS}), and a
7
+ * heartbeat keeps it ticking during the long Loading/Rendering phases.
8
+ *
9
+ * When constructed without a callback it is entirely inert - no listeners, no
10
+ * timers, no allocations on the hot path - so callers can always create one.
11
+ */
12
+ export declare class RenderProgressReporter {
13
+ private readonly filePath;
14
+ private readonly enabled;
15
+ private readonly callback;
16
+ private readonly startedAt;
17
+ private phaseNow;
18
+ private loaded;
19
+ private pending;
20
+ private failed;
21
+ private lastEmitAt;
22
+ private lastPercent;
23
+ private heartbeat;
24
+ private page;
25
+ private readonly onRequest;
26
+ private readonly onRequestFinished;
27
+ private readonly onRequestFailed;
28
+ constructor(filePath: string, callback?: RenderProgressCallback);
29
+ /** Attach resource-lifecycle counters to the page. Call once, after newPage(). */
30
+ attach(page: Page): void;
31
+ /** Transition to a new phase and emit immediately (bypassing the throttle). */
32
+ phase(phase: RenderPhase, message?: string): void;
33
+ /** Stop the heartbeat and detach page listeners. Safe to call multiple times. */
34
+ dispose(): void;
35
+ private startHeartbeat;
36
+ private stopHeartbeat;
37
+ private computePercent;
38
+ private emit;
39
+ private defaultMessage;
40
+ }
41
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAmB,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAiB1F;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IA+BrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IA9BrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;IAEhD,OAAO,CAAC,QAAQ,CAAqC;IACrD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAK;IACpB,OA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