adspower-browser 2.0.3 → 2.0.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.
package/README.MD CHANGED
@@ -65,7 +65,7 @@ ads start
65
65
 
66
66
  The CLI supports prefix tab completion for subcommands and common flags (`-k`, `-p`, etc.) via [`@bomb.sh/tab`](https://bomb.sh/docs/tab/). Enable it once in your shell:
67
67
 
68
- **zsh**
68
+ **macOS — zsh**
69
69
 
70
70
  ```bash
71
71
  ads complete zsh > ~/.ads-completion.zsh
@@ -73,7 +73,7 @@ echo 'source ~/.ads-completion.zsh' >> ~/.zshrc
73
73
  source ~/.ads-completion.zsh
74
74
  ```
75
75
 
76
- **bash**
76
+ **Linux — bash**
77
77
 
78
78
  ```bash
79
79
  ads complete bash > ~/.ads-completion.bash
@@ -81,7 +81,34 @@ echo 'source ~/.ads-completion.bash' >> ~/.bashrc
81
81
  source ~/.ads-completion.bash
82
82
  ```
83
83
 
84
- After setup, `ads`, `adspower`, and `adspower-browser` share the same completions:
84
+ On Linux login shells, ensure `~/.bashrc` is sourced (e.g. from `~/.bash_profile`).
85
+
86
+ **Linux — zsh**
87
+
88
+ ```bash
89
+ ads complete zsh > ~/.ads-completion.zsh
90
+ echo 'source ~/.ads-completion.zsh' >> ~/.zshrc
91
+ source ~/.ads-completion.zsh
92
+ ```
93
+
94
+ **Windows — PowerShell**
95
+
96
+ ```powershell
97
+ ads complete powershell > $HOME\.ads-completion.ps1
98
+ if (-not (Test-Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force }
99
+ Add-Content $PROFILE '. $HOME\.ads-completion.ps1'
100
+ . $HOME\.ads-completion.ps1
101
+ ```
102
+
103
+ **Windows — Git Bash**
104
+
105
+ ```bash
106
+ ads complete bash > ~/.ads-completion.bash
107
+ echo 'source ~/.ads-completion.bash' >> ~/.bashrc
108
+ source ~/.ads-completion.bash
109
+ ```
110
+
111
+ After setup on zsh/bash, `ads`, `adspower`, and `adspower-browser` share the same completions. On PowerShell and Git Bash, use `ads` for tab completion:
85
112
 
86
113
  ```bash
87
114
  ads <Tab><Tab> # list subcommands
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ // src/core/winHideChildProcess.js
4
+ if (process.platform !== "win32") {
5
+ return;
6
+ }
7
+ var cp = require("child_process");
8
+ function withWindowsHide(options) {
9
+ if (typeof options === "object" && options !== null && !Array.isArray(options)) {
10
+ if (options.windowsHide === false) {
11
+ return options;
12
+ }
13
+ return { ...options, windowsHide: true };
14
+ }
15
+ return { windowsHide: true };
16
+ }
17
+ function normalizeExecArgs(options, callback) {
18
+ if (typeof options === "function") {
19
+ return { options: { windowsHide: true }, callback: options };
20
+ }
21
+ return { options: withWindowsHide(options || {}), callback };
22
+ }
23
+ function normalizeSpawnArgs(args, options) {
24
+ if (Array.isArray(args)) {
25
+ return { args, options: withWindowsHide(options || {}) };
26
+ }
27
+ return { args: [], options: withWindowsHide(args || {}) };
28
+ }
29
+ var origExec = cp.exec.bind(cp);
30
+ cp.exec = function exec(cmd, options, callback) {
31
+ const { options: opts, callback: cb } = normalizeExecArgs(options, callback);
32
+ return origExec(cmd, opts, cb);
33
+ };
34
+ var origExecSync = cp.execSync.bind(cp);
35
+ cp.execSync = function execSync(cmd, options) {
36
+ return origExecSync(cmd, withWindowsHide(options || {}));
37
+ };
38
+ var origSpawn = cp.spawn.bind(cp);
39
+ cp.spawn = function spawn(command, args, options) {
40
+ const normalized = normalizeSpawnArgs(args, options);
41
+ return origSpawn(command, normalized.args, normalized.options);
42
+ };
43
+ var origSpawnSync = cp.spawnSync.bind(cp);
44
+ cp.spawnSync = function spawnSync(command, args, options) {
45
+ const normalized = normalizeSpawnArgs(args, options);
46
+ return origSpawnSync(command, normalized.args, normalized.options);
47
+ };
package/cli/index.js CHANGED
@@ -93,6 +93,7 @@ var Store = class {
93
93
  var store = new Store();
94
94
 
95
95
  // src/core/start.ts
96
+ var fs2 = __toESM(require("fs"));
96
97
  var path2 = __toESM(require("path"));
97
98
  var import_node_child_process2 = require("child_process");
98
99
 
@@ -134,7 +135,7 @@ var browsersKill = async () => {
134
135
  };
135
136
  var taskKillBrowser = () => new Promise((resolve) => {
136
137
  const cmd = ["linux", "darwin"].includes(process.platform) ? 'pkill -u `whoami` -f "SunBrowser"' : "taskkill -PID SunBrowser.exe";
137
- (0, import_node_child_process.exec)(cmd, (err) => {
138
+ (0, import_node_child_process.exec)(cmd, { windowsHide: true }, (err) => {
138
139
  if (err) {
139
140
  }
140
141
  resolve();
@@ -142,7 +143,7 @@ var taskKillBrowser = () => new Promise((resolve) => {
142
143
  });
143
144
  var taskKillFlowser = () => new Promise((resolve) => {
144
145
  const cmd = ["linux", "darwin"].includes(process.platform) ? 'pkill -u `whoami` -f "FlowerBrowser"' : "taskkill -PID FlowerBrowser.exe";
145
- (0, import_node_child_process.exec)(cmd, (err) => {
146
+ (0, import_node_child_process.exec)(cmd, { windowsHide: true }, (err) => {
146
147
  if (err) {
147
148
  }
148
149
  resolve();
@@ -184,6 +185,7 @@ var isRunning = (pid) => {
184
185
  if (pid) {
185
186
  (0, import_node_child_process.exec)(
186
187
  util.format(process.platform === "win32" ? 'tasklist /fi "PID eq %s" | findstr /i "node.exe"' : 'ps -f -p %s | grep "node"', pid),
188
+ { windowsHide: true },
187
189
  function(err, stdout, stderr) {
188
190
  resolve(!err && !!stdout.toString().trim());
189
191
  }
@@ -288,6 +290,16 @@ var initSqlite3 = () => {
288
290
  };
289
291
 
290
292
  // src/core/start.ts
293
+ var getRuntimeExecArgv = () => {
294
+ if (process.platform !== "win32") {
295
+ return [];
296
+ }
297
+ const preload = path2.join(__dirname, "core/winHideChildProcess.js");
298
+ if (!fs2.existsSync(preload)) {
299
+ return [];
300
+ }
301
+ return ["--require", preload];
302
+ };
291
303
  var getEnv = () => {
292
304
  const env = {
293
305
  ...process.env,
@@ -328,7 +340,8 @@ var startChild = (type) => {
328
340
  detached: true,
329
341
  windowsHide: true,
330
342
  // 隐藏子进程的控制台窗口
331
- stdio: ["ignore", "ignore", "ignore", "ipc"]
343
+ stdio: ["ignore", "ignore", "ignore", "ipc"],
344
+ execArgv: getRuntimeExecArgv()
332
345
  };
333
346
  child = (0, import_node_child_process2.fork)(mainJs, [], forkOptions);
334
347
  ensureBrowserPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adspower-browser",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "main": "cli/index.js",
5
5
  "type": "commonjs",
6
6
  "bin": {