@d-zero/replicator 0.10.2 → 0.10.4

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 (2) hide show
  1. package/README.md +21 -128
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,152 +1,45 @@
1
1
  # `@d-zero/replicator`
2
2
 
3
- ウェブページとそのリソースをレスポンシブ画像対応でローカルディレクトリに複製するツールです。複数のURLを並列処理し、効率的にリソースを取得します。
3
+ ウェブページとそのリソース(CSS / JS / 画像)をレスポンシブ画像対応でローカルディレクトリに複製する CLI。Phase 1(ページスキャン)と Phase 2(リソースダウンロード)の **2 段階処理** で並列度を独立制御する。**同一ホストのみサポート**(複数ホスト検出時はエラー)。
4
4
 
5
- ## インストール
5
+ ## Installation
6
6
 
7
- ```bash
8
- npm install @d-zero/replicator
7
+ ```sh
8
+ yarn add @d-zero/replicator
9
9
  ```
10
10
 
11
- ## 使い方
11
+ ## Usage
12
12
 
13
- ### CLI
14
-
15
- ```bash
13
+ ```sh
16
14
  npx @d-zero/replicator <url...> -o <output-directory> [options]
17
15
  ```
18
16
 
19
- #### オプション
20
-
21
- - `--version`: バージョンを表示(注: `-v`は`--verbose`のエイリアス)
22
- - `-o, --output <dir>`: 出力ディレクトリ(必須)
23
- - `-t, --timeout <ms>`: リクエストタイムアウト(ミリ秒、デフォルト: 30000)
24
- - `-d, --devices <devices>`: デバイスプリセット(カンマ区切り、デフォルト: desktop-compact,mobile)
25
- - `-l, --limit <number>`: ページスキャン(Phase 1)の並列処理数の上限(デフォルト: 3)
26
- - `--download-limit <number>`: リソースダウンロード(Phase 2)の並列処理数の上限(デフォルト: 10)
27
- - `--interval <ms>`: 並列実行間の間隔(デフォルト: なし)
28
- - 数値または"min-max"形式でランダム範囲を指定可能
29
- - `--only <type>`: ダウンロード対象を限定(`page` または `resource`)
30
- - `-a, --auth <user:pass>`: Basic認証の認証情報(`ユーザー名:パスワード` 形式)
31
- - `-v, --verbose`: 詳細ログモード
32
-
33
- ##### `--only` オプション
34
-
35
- - `page`: HTMLページのみをダウンロード(リソーススキャンをスキップして高速化)
36
- - `resource`: リソース(CSS、JS、画像など)のみをダウンロード(HTMLページを除外)
37
- - 未指定: すべてのファイルをダウンロード(デフォルト動作)
38
-
39
- #### 利用可能なデバイスプリセット
40
-
41
- - `desktop`: 1400px幅
42
- - `tablet`: 768px幅
43
- - `mobile`: 375px幅(2倍解像度)
44
- - `desktop-hd`: 1920px幅
45
- - `desktop-compact`: 1280px幅
46
- - `mobile-large`: 414px幅(3倍解像度)
47
- - `mobile-small`: 320px幅(2倍解像度)
48
-
49
- #### 使用例
50
-
51
- ```bash
52
- # 単一URL(デフォルトデバイス: desktop-compact, mobile)
53
- npx @d-zero/replicator https://example.com -o ./output
54
-
55
- # 複数URLを並列処理
56
- npx @d-zero/replicator https://example.com/page1 https://example.com/page2 -o ./output
57
-
58
- # 並列数を制限
59
- npx @d-zero/replicator https://example.com/page1 https://example.com/page2 -o ./output --limit 2
17
+ オプションは `--help`、デバイスプリセットは `src/devices.ts` を参照。
60
18
 
61
- # カスタムデバイス指定
62
- npx @d-zero/replicator https://example.com -o ./output --devices desktop,tablet,mobile
19
+ ### 主なオプション
63
20
 
64
- # タイムアウト指定
65
- npx @d-zero/replicator https://example.com -o ./output --timeout 60000
21
+ - `--limit <n>` … Phase 1(ページスキャン)の並列数(デフォルト 3)
22
+ - `--download-limit <n>` Phase 2(リソースダウンロード)の並列数(デフォルト 10)
23
+ - `--only page|resource` … HTML のみ/リソースのみに限定
24
+ - `-a, --auth user:pass` … Basic 認証
66
25
 
67
- # HTMLページのみダウンロード(高速)
68
- npx @d-zero/replicator https://example.com -o ./output --only page
26
+ ### `--only` の使い分け
69
27
 
70
- # リソースのみダウンロード(HTMLを除外)
71
- npx @d-zero/replicator https://example.com -o ./output --only resource
28
+ - `page` … リソーススキャンをスキップして HTML のみ高速取得
29
+ - `resource` HTML を除外し、CSS/JS/画像のみ
30
+ - 未指定 … 全部
72
31
 
73
- # Basic認証が必要なページ
74
- npx @d-zero/replicator https://example.com -o ./output -a username:password
75
- ```
32
+ Phase 分離・並列数の WHY・同一ホスト制約の理由・レスポンシブ画像取得時のマルチデバイスシミュレーションは `src/replicate.ts` の JSDoc を参照。
76
33
 
77
- ### プログラマティック使用
34
+ ### プログラマティック利用
78
35
 
79
- ```typescript
36
+ ```ts
80
37
  import { replicate } from '@d-zero/replicator';
81
38
 
82
- // 単一URL
83
- await replicate({
84
- urls: ['https://example.com'],
85
- outputDir: './output',
86
- });
87
-
88
- // 複数URLを並列処理
89
- await replicate({
90
- urls: [
91
- 'https://example.com/page1',
92
- 'https://example.com/page2',
93
- 'https://example.com/page3',
94
- ],
95
- outputDir: './output',
96
- limit: 2, // ページスキャン(Phase 1)は最大2並列
97
- downloadLimit: 5, // リソースダウンロード(Phase 2)は最大5並列
98
- });
99
-
100
- // カスタムデバイス
101
39
  await replicate({
102
40
  urls: ['https://example.com'],
103
41
  outputDir: './output',
104
- devices: {
105
- desktop: { width: 1400 },
106
- mobile: { width: 375, resolution: 2 },
107
- },
108
- timeout: 30000,
109
- verbose: true,
110
- });
111
-
112
- // HTMLページのみダウンロード
113
- await replicate({
114
- urls: ['https://example.com'],
115
- outputDir: './output',
116
- only: 'page',
117
- });
118
-
119
- // リソースのみダウンロード
120
- await replicate({
121
- urls: ['https://example.com'],
122
- outputDir: './output',
123
- only: 'resource',
124
- });
125
-
126
- // Basic認証が必要なページ
127
- await replicate({
128
- urls: ['https://example.com'],
129
- outputDir: './output',
130
- username: 'username',
131
- password: 'password',
42
+ limit: 2,
43
+ downloadLimit: 5,
132
44
  });
133
45
  ```
134
-
135
- ## 機能
136
-
137
- - **Basic認証対応**: `--auth user:pass`オプションでBasic認証が必要なページにアクセス可能
138
- - **並列処理**: 複数のURLを並列で効率的に処理
139
- - **メモリ効率**: リソースを直接ディスクに保存してメモリ使用量を最小化
140
- - **選択的ダウンロード**: `--only`オプションでHTMLページのみまたはリソースのみをダウンロード可能
141
- - **レスポンシブ画像対応**: 複数のデバイス幅で`<picture>`要素やメディアクエリのリソースを取得
142
- - **遅延読み込み対応**: ページを自動スクロールして`loading=lazy`や`IntersectionObserver`ベースのコンテンツを取得
143
- - **マルチデバイスシミュレーション**: 様々なデバイス幅と解像度をシミュレートして包括的なリソース取得を実現
144
- - HTMLページのディレクトリ構造を保持してダウンロード
145
- - 関連するすべてのリソース(CSS、JS、画像など)を取得
146
- - リソース間の相対リンクを維持
147
- - 同一ホストのリソースのみサポート(複数ホストが検出された場合はエラー)
148
- - 元のファイル拡張子とパスを保持
149
-
150
- ## License
151
-
152
- MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/replicator",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Replicate web pages with all their resources to local directories",
5
5
  "author": "D-ZERO",
6
6
  "license": "MIT",
@@ -24,11 +24,11 @@
24
24
  "clean": "tsc --build --clean"
25
25
  },
26
26
  "dependencies": {
27
- "@d-zero/cli-core": "1.3.9",
28
- "@d-zero/dealer": "1.8.0",
29
- "@d-zero/puppeteer-dealer": "0.7.12",
30
- "@d-zero/puppeteer-page-scan": "4.5.0",
31
- "@d-zero/puppeteer-scroll": "4.0.0",
27
+ "@d-zero/cli-core": "1.3.10",
28
+ "@d-zero/dealer": "1.9.1",
29
+ "@d-zero/puppeteer-dealer": "0.7.14",
30
+ "@d-zero/puppeteer-page-scan": "4.5.1",
31
+ "@d-zero/puppeteer-scroll": "4.0.1",
32
32
  "@d-zero/shared": "0.22.0",
33
33
  "ansi-colors": "4.1.3",
34
34
  "minimist": "1.2.8",
@@ -42,5 +42,5 @@
42
42
  "url": "https://github.com/d-zero-dev/tools.git",
43
43
  "directory": "packages/@d-zero/replicator"
44
44
  },
45
- "gitHead": "18fedbea276b214ad98d1f7e41e07b629e65439c"
45
+ "gitHead": "25b4043dcd70cf3490ddcefd76a88b22c60f7712"
46
46
  }