@d-zero/print 2.5.0 → 2.6.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.
package/README.md CHANGED
@@ -28,7 +28,14 @@ npx @d-zero/print <url>... [options]
28
28
  - `pdf`: PDFファイル(ブラウザの印刷機能を使用、Print CSSが適用されます)
29
29
  - `note`: PNG画像のスクリーンショットに対してメモ欄付きのPDFファイルが生成されます
30
30
  - `-d, --devices <devices>`: デバイスプリセット(カンマ区切り、デフォルト: desktop-compact,mobile)
31
+ - `-T, --timeout <ms>`: リクエストタイムアウト(ミリ秒、デフォルト: 30000)
32
+ - `-o, --open-disclosures`: キャプチャ前にすべての`<details>`要素を開き、すべての`button[aria-expanded="false"]`要素をクリックします
33
+ - 新しい要素が見つからなくなるまで繰り返し処理(最大1000回、各イテレーション後500ms待機)
34
+ - ネストされた要素や動的に生成される要素にも対応
35
+ - 最大イテレーション数に達した場合はエラーで終了
31
36
  - `--limit <number>`: 並列実行数の上限(デフォルト: 10)
37
+ - `--interval <ms>`: 並列実行間の間隔(デフォルト: なし)
38
+ - 数値または"min-max"形式でランダム範囲を指定可能
32
39
  - `--debug`: デバッグモード(デフォルト: false)
33
40
  - `--verbose`: 詳細ログモード(デフォルト: false)
34
41
 
@@ -56,6 +63,10 @@ npx @d-zero/print -f urls.txt --type pdf
56
63
 
57
64
  # ファイルから読み込み + デバイス指定
58
65
  npx @d-zero/print -f urls.txt --devices desktop,mobile
66
+
67
+ # disclosure要素を展開してキャプチャ
68
+ npx @d-zero/print https://example.com --open-disclosures
69
+ npx @d-zero/print https://example.com -o
59
70
  ```
60
71
 
61
72
  #### URLリストのファイルフォーマット
package/dist/cli.js CHANGED
@@ -14,6 +14,7 @@ const { options, args, hasConfigFile } = createCLI({
14
14
  t: 'type',
15
15
  d: 'devices',
16
16
  T: 'timeout',
17
+ o: 'openDisclosures',
17
18
  },
18
19
  usage: [
19
20
  'Usage:',
@@ -25,6 +26,7 @@ const { options, args, hasConfigFile } = createCLI({
25
26
  '\t-t, --type <type> Output type: png|pdf|note (default: png)',
26
27
  '\t-d, --devices <devices> Device presets (comma-separated, default: desktop-compact,mobile)',
27
28
  '\t-T, --timeout <ms> Request timeout in milliseconds (default: 30000)',
29
+ '\t-o, --open-disclosures Open all <details> and aria-expanded elements before capture',
28
30
  '\t--limit <number> Limit concurrent processes',
29
31
  '\t--interval <ms> Interval between parallel executions (default: none)',
30
32
  '\t Format: number or "min-max" for random range',
@@ -45,6 +47,7 @@ const { options, args, hasConfigFile } = createCLI({
45
47
  type: cli.type,
46
48
  devices: cli.devices,
47
49
  timeout: cli.timeout ? Number(cli.timeout) : undefined,
50
+ openDisclosures: cli['open-disclosures'] === true || cli.o === true ? true : undefined,
48
51
  }),
49
52
  validateArgs: (options, cli) => {
50
53
  return !!(options.listfile?.length || cli._.length > 0);
@@ -64,6 +67,7 @@ if (hasConfigFile) {
64
67
  devices,
65
68
  timeout: options.timeout,
66
69
  interval: options.interval,
70
+ openDisclosures: options.openDisclosures,
67
71
  });
68
72
  process.exit(0);
69
73
  }
@@ -76,6 +80,7 @@ if (args.length > 0) {
76
80
  devices,
77
81
  timeout: options.timeout,
78
82
  interval: options.interval,
83
+ openDisclosures: options.openDisclosures,
79
84
  });
80
85
  process.exit(0);
81
86
  }
@@ -9,5 +9,6 @@ import type { Page } from 'puppeteer';
9
9
  * @param hooks
10
10
  * @param devices
11
11
  * @param timeout
12
+ * @param openDisclosures
12
13
  */
13
- export declare function printPdf(page: Page, url: string, filePath: string, update: (log: string) => void, hooks?: readonly PageHook[], devices?: Sizes, timeout?: number): Promise<void>;
14
+ export declare function printPdf(page: Page, url: string, filePath: string, update: (log: string) => void, hooks?: readonly PageHook[], devices?: Sizes, timeout?: number, openDisclosures?: boolean): Promise<void>;
@@ -8,8 +8,9 @@ import { beforePageScan, pageScanListener, devicePresets, } from '@d-zero/puppet
8
8
  * @param hooks
9
9
  * @param devices
10
10
  * @param timeout
11
+ * @param openDisclosures
11
12
  */
12
- export async function printPdf(page, url, filePath, update, hooks, devices, timeout) {
13
+ export async function printPdf(page, url, filePath, update, hooks, devices, timeout, openDisclosures) {
13
14
  // Use the first desktop device or fallback to desktop preset
14
15
  const defaultWidth = devicePresets.desktop.width;
15
16
  let pdfWidth = defaultWidth;
@@ -32,6 +33,7 @@ export async function printPdf(page, url, filePath, update, hooks, devices, time
32
33
  listener: pageScanListener(update),
33
34
  hooks,
34
35
  timeout,
36
+ openDisclosures,
35
37
  });
36
38
  update('📄 Save as PDF');
37
39
  await page.pdf({
@@ -11,5 +11,6 @@ import type { Page } from 'puppeteer';
11
11
  * @param hooks
12
12
  * @param devices
13
13
  * @param timeout
14
+ * @param openDisclosures
14
15
  */
15
- export declare function printPng(page: Page, url: string, fileId: string, filePath: string, update: (log: string) => void, hooks?: readonly PageHook[], devices?: Sizes, timeout?: number): Promise<Record<string, import("@d-zero/puppeteer-screenshot").Screenshot>>;
16
+ export declare function printPng(page: Page, url: string, fileId: string, filePath: string, update: (log: string) => void, hooks?: readonly PageHook[], devices?: Sizes, timeout?: number, openDisclosures?: boolean): Promise<Record<string, import("@d-zero/puppeteer-screenshot").Screenshot>>;
@@ -10,8 +10,9 @@ import { screenshot, screenshotListener } from '@d-zero/puppeteer-screenshot';
10
10
  * @param hooks
11
11
  * @param devices
12
12
  * @param timeout
13
+ * @param openDisclosures
13
14
  */
14
- export function printPng(page, url, fileId, filePath, update, hooks, devices, timeout) {
15
+ export function printPng(page, url, fileId, filePath, update, hooks, devices, timeout, openDisclosures) {
15
16
  const defaultSizes = {
16
17
  'desktop-compact': devicePresets['desktop-compact'],
17
18
  mobile: devicePresets.mobile,
@@ -23,5 +24,6 @@ export function printPng(page, url, fileId, filePath, update, hooks, devices, ti
23
24
  listener: screenshotListener(update),
24
25
  hooks,
25
26
  timeout,
27
+ openDisclosures,
26
28
  });
27
29
  }
@@ -6,4 +6,5 @@ export type ChildProcessParams = {
6
6
  hooks?: readonly PageHook[];
7
7
  devices?: Sizes;
8
8
  timeout?: number;
9
+ openDisclosures?: boolean;
9
10
  };
@@ -4,18 +4,18 @@ import { pngToPdf } from './modules/png-to-pdf.js';
4
4
  import { printPdf } from './modules/print-pdf.js';
5
5
  import { printPng } from './modules/print-png.js';
6
6
  createChildProcess((param) => {
7
- const { dir, type, hooks, devices, timeout } = param;
7
+ const { dir, type, hooks, devices, timeout, openDisclosures } = param;
8
8
  return {
9
9
  async eachPage({ page, id, url }, logger) {
10
10
  const ext = type === 'pdf' ? 'pdf' : 'png';
11
11
  const fileName = `${id}.${ext}`;
12
12
  const filePath = path.resolve(dir, fileName);
13
13
  if (type === 'pdf') {
14
- await printPdf(page, url, filePath, logger, hooks, devices, timeout);
14
+ await printPdf(page, url, filePath, logger, hooks, devices, timeout, openDisclosures);
15
15
  logger('🔚 Closing');
16
16
  return;
17
17
  }
18
- const result = await printPng(page, url, id, filePath, logger, hooks, devices, timeout);
18
+ const result = await printPng(page, url, id, filePath, logger, hooks, devices, timeout, openDisclosures);
19
19
  if (type === 'png') {
20
20
  logger('🔚 Closing');
21
21
  return;
@@ -11,6 +11,7 @@ export interface PrintOptions {
11
11
  readonly devices?: Sizes;
12
12
  readonly timeout?: number;
13
13
  readonly interval?: number | DelayOptions;
14
+ readonly openDisclosures?: boolean;
14
15
  }
15
16
  /**
16
17
  *
@@ -25,9 +25,15 @@ export async function print(urlList, options) {
25
25
  hooks: options?.hooks,
26
26
  devices: options?.devices,
27
27
  timeout: options?.timeout,
28
+ openDisclosures: options?.openDisclosures,
28
29
  }, {
29
30
  ...options,
30
31
  interval: options?.interval,
31
32
  });
33
+ }, {
34
+ limit: options?.limit,
35
+ debug: options?.debug,
36
+ verbose: options?.verbose,
37
+ interval: options?.interval,
32
38
  });
33
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/print",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Print web pages to PDF or image files.",
5
5
  "author": "D-ZERO",
6
6
  "license": "MIT",
@@ -25,17 +25,17 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@d-zero/cli-core": "1.3.0",
28
- "@d-zero/html-distiller": "2.0.3",
29
- "@d-zero/puppeteer-dealer": "0.6.4",
30
- "@d-zero/puppeteer-page-scan": "4.3.5",
31
- "@d-zero/puppeteer-screenshot": "3.2.14",
32
- "@d-zero/readtext": "1.1.15",
28
+ "@d-zero/html-distiller": "2.0.4",
29
+ "@d-zero/puppeteer-dealer": "0.6.5",
30
+ "@d-zero/puppeteer-page-scan": "4.4.0",
31
+ "@d-zero/puppeteer-screenshot": "3.3.0",
32
+ "@d-zero/readtext": "1.1.16",
33
33
  "@d-zero/shared": "0.17.1",
34
34
  "ansi-colors": "4.1.3",
35
35
  "dayjs": "1.11.19",
36
36
  "front-matter": "4.0.2",
37
37
  "minimist": "1.2.8",
38
- "puppeteer": "24.34.0"
38
+ "puppeteer": "24.36.0"
39
39
  },
40
- "gitHead": "9aa03b3928e271d45865c6e2eff4c89041fe20a2"
40
+ "gitHead": "e2189e6878674b8fef5fa3c121ad109c448040fe"
41
41
  }