@cellaware/utils 8.4.0 → 8.4.1

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/browser.d.ts CHANGED
@@ -1,3 +1,37 @@
1
+ import type { Browser } from "playwright-core";
2
+ /**
3
+ * Browserless (hosted) performance & reliability notes
4
+ *
5
+ * 1) Prefer connect-per-request (default)
6
+ * - We use chromium.connectOverCDP() instead of launching a local browser.
7
+ * - In serverless, connecting + closing per request is the safest and most cost-predictable option.
8
+ * - Hosted Browserless usage is typically metered by session/connection time, so leaving connections
9
+ * open while idle can increase cost.
10
+ *
11
+ * 2) Always isolate work in a fresh BrowserContext per PDF
12
+ * - Never reuse BrowserContext or Page across requests.
13
+ * - Context-per-request avoids cookie/storage leaks, cross-request interference, and memory growth.
14
+ *
15
+ * 3) Close deterministically (inner → outer)
16
+ * - Always close Page, then Context, then Browser (the CDP connection).
17
+ * - This releases remote resources quickly and prevents “dangling sessions” on the provider side.
18
+ *
19
+ * 4) Waiting strategy
20
+ * - Default waitUntil: "load" to avoid hanging on long-lived network activity (analytics/beacons).
21
+ * - If your HTML depends on external assets (remote CSS/fonts/images), consider "networkidle",
22
+ * or better: emit an explicit readiness signal and waitForFunction() for deterministic completion.
23
+ *
24
+ * 5) Biggest speed wins usually come from reducing network work
25
+ * - Inline critical CSS and avoid loading third-party scripts if possible.
26
+ * - Host/inline fonts and images where feasible to reduce variability and speed up rendering.
27
+ * - The less the page has to fetch, the faster and more consistent PDF generation becomes.
28
+ *
29
+ * 6) Optional burst optimization (only if needed)
30
+ * - If you generate many PDFs back-to-back on the same warm instance, you can reuse the CDP
31
+ * connection briefly (with a short idle timeout).
32
+ * - Still keep Context-per-request. Avoid keeping the connection open indefinitely to prevent idle cost.
33
+ */
34
+ export declare function getBrowser(): Promise<Browser>;
1
35
  export interface PdfOptions {
2
36
  /**
3
37
  * Display header and footer. Defaults to `false`.
package/dist/browser.js CHANGED
@@ -31,7 +31,7 @@ import { chromium } from "playwright-core";
31
31
  * connection briefly (with a short idle timeout).
32
32
  * - Still keep Context-per-request. Avoid keeping the connection open indefinitely to prevent idle cost.
33
33
  */
34
- async function getBrowser() {
34
+ export async function getBrowser() {
35
35
  const token = process.env.BROWSERLESS_TOKEN;
36
36
  if (!token) {
37
37
  throw new Error('BROWSER: `BROWSER_TOKEN` environment variable is not set');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.4.0",
3
+ "version": "8.4.1",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",
@@ -27,4 +27,4 @@
27
27
  "devDependencies": {
28
28
  "typescript": "^5.3.2"
29
29
  }
30
- }
30
+ }