mikser-io 7.10.1 → 7.10.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io",
3
- "version": "7.10.1",
3
+ "version": "7.10.2",
4
4
  "description": "<p align=\"center\"> <img src=\"mikser-lockup-stacked.svg\" alt=\"mikser\" width=\"198\" /> </p>",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -13,16 +13,6 @@ export async function setup({ config, logger }) {
13
13
  return
14
14
  }
15
15
 
16
- const { default: puppeteer } = await import('puppeteer').catch(() => {
17
- throw new Error('Puppeteer is required for the pdf postprocessor — run: npm install puppeteer')
18
- })
19
- // --no-sandbox / --disable-setuid-sandbox are required on most
20
- // headless Linux servers and Docker images where Chrome's sandbox
21
- // can't be set up. Applied by default and merged (deduped) with any
22
- // user-supplied launch.args so callers can add flags without losing
23
- // these. To run WITH the sandbox, override launch.args explicitly.
24
- const defaultArgs = ['--no-sandbox', '--disable-setuid-sandbox']
25
-
26
16
  // Resolve which chrome to use, in precedence order:
27
17
  // 1. config.launch.executablePath — explicit, wins
28
18
  // 2. config.executable — friendly top-level alias
@@ -33,16 +23,50 @@ export async function setup({ config, logger }) {
33
23
  // that fails when ~/.cache/puppeteer is half-populated)
34
24
  //
35
25
  // For headless production servers, pointing at a system chromium
36
- // installed via apt (executable: '/usr/bin/chromium') skips
37
- // puppeteer's postinstall download entirely. Set
38
- // PUPPETEER_SKIP_DOWNLOAD=true at npm install time to keep it from
39
- // even trying.
26
+ // installed via apt skips puppeteer's postinstall download entirely.
40
27
  const executablePath =
41
28
  config?.launch?.executablePath
42
29
  ?? config?.executable
43
30
  ?? process.env.PUPPETEER_EXECUTABLE_PATH
44
31
  ?? undefined
45
32
 
33
+ // Driver library: try `puppeteer` first (most common, bundles chrome),
34
+ // then `puppeteer-core` (same API without the chrome auto-download —
35
+ // the right choice when you've configured an external `executable`).
36
+ // Either is fine; either can drive any chrome binary you point at.
37
+ const puppeteer =
38
+ await import('puppeteer').then(m => m.default).catch(() => null)
39
+ ?? await import('puppeteer-core').then(m => m.default).catch(() => null)
40
+
41
+ if (!puppeteer) {
42
+ // Context-aware install instructions. If the user already configured
43
+ // an executable, they almost certainly want puppeteer-core (lean,
44
+ // no chrome download). Otherwise either works.
45
+ if (executablePath) {
46
+ throw new Error(
47
+ `post-pdf needs the puppeteer driver library to talk to chrome at ${executablePath}.\n` +
48
+ `Since you've configured an external executable, install the lean driver (no bundled chrome):\n` +
49
+ ` npm install puppeteer-core`
50
+ )
51
+ }
52
+ throw new Error(
53
+ 'post-pdf needs a puppeteer driver to render PDFs.\n' +
54
+ 'Two options:\n' +
55
+ ' - Quickest: npm install puppeteer (bundles chrome ~500MB)\n' +
56
+ ' - Headless: sudo apt install google-chrome-stable\n' +
57
+ ' npm install puppeteer-core (no chrome download)\n' +
58
+ ' # then in mikser.config.js:\n' +
59
+ " 'post-pdf': { executable: '/usr/bin/google-chrome-stable' }"
60
+ )
61
+ }
62
+
63
+ // --no-sandbox / --disable-setuid-sandbox are required on most
64
+ // headless Linux servers and Docker images where Chrome's sandbox
65
+ // can't be set up. Applied by default and merged (deduped) with any
66
+ // user-supplied launch.args so callers can add flags without losing
67
+ // these. To run WITH the sandbox, override launch.args explicitly.
68
+ const defaultArgs = ['--no-sandbox', '--disable-setuid-sandbox']
69
+
46
70
  browser = await puppeteer.launch({
47
71
  headless: true,
48
72
  ...config?.launch,