pake-cli 2.0.0-alpha7 → 2.0.0-alpha9

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
@@ -180,7 +180,7 @@ npm run build
180
180
  1. You can refer to the [codebase structure](https://github.com/tw93/Pake/wiki/Description-of-Pake's-code-structure) before working on Pake, which will help you much in development.
181
181
  2. Modify the `url` and `productName` fields in the `pake.json` file under the src-tauri directory, as well as the `icon` and `identifier` fields in the `tauri.xxx.conf.json` file. You can select a `icon` from the `icons` directory or download one from [macOSicons](https://macosicons.com/#/) to match your product needs.
182
182
  3. For configurations on window properties, you can modify the `pake.json` file to change the value of `width`, `height`, `fullscreen` (or not), `resizable` (or not) of the `windows` property. To adapt to the immersive header on Mac, change `transparent` to `true`, look for the `Header` element, and add the `padding-top` property.
183
- 4. For advanced usages such as style rewriting, advertisement removal, JS injection, container message communication, and user-defined shortcut keys, see [Advanced Usage of Make](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Pake).
183
+ 4. For advanced usages such as style rewriting, advertisement removal, JS injection, container message communication, and user-defined shortcut keys, see [Advanced Usage of Pake](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Pake).
184
184
 
185
185
  ## Developer
186
186
 
package/dist/cli.js CHANGED
@@ -15,9 +15,9 @@ import { fileTypeFromBuffer } from 'file-type';
15
15
  import { dir } from 'tmp-promise';
16
16
  import ora from 'ora';
17
17
  import shelljs from 'shelljs';
18
- import { exec } from 'child_process';
19
18
  import { promisify } from 'util';
20
19
  import dns from 'dns';
20
+ import http from 'http';
21
21
  import updateNotifier from 'update-notifier';
22
22
 
23
23
  /******************************************************************************
@@ -2019,53 +2019,66 @@ function shellExec(command) {
2019
2019
  });
2020
2020
  }
2021
2021
 
2022
+ const ping = (host) => __awaiter(void 0, void 0, void 0, function* () {
2023
+ const lookup = promisify(dns.lookup);
2024
+ const ip = yield lookup(host);
2025
+ const start = new Date();
2026
+ return new Promise((resolve, reject) => {
2027
+ const req = http.get(`http://${ip.address}`, (res) => {
2028
+ const delay = new Date().getTime() - start.getTime();
2029
+ res.resume();
2030
+ resolve(delay);
2031
+ });
2032
+ req.on('error', (err) => {
2033
+ reject(err);
2034
+ });
2035
+ });
2036
+ });
2022
2037
  const resolve = promisify(dns.resolve);
2023
2038
  function isChinaDomain(domain) {
2024
2039
  return __awaiter(this, void 0, void 0, function* () {
2025
2040
  try {
2026
2041
  // 解析域名为IP地址
2027
2042
  const [ip] = yield resolve(domain);
2028
- return yield isChinaIP(ip);
2043
+ return yield isChinaIP(ip, domain);
2029
2044
  }
2030
2045
  catch (error) {
2031
2046
  // 域名无法解析,返回false
2047
+ logger.info(`${domain} can't be parse, is not in China!`);
2032
2048
  return false;
2033
2049
  }
2034
2050
  });
2035
2051
  }
2036
- function isChinaIP(ip) {
2052
+ function isChinaIP(ip, domain) {
2037
2053
  return __awaiter(this, void 0, void 0, function* () {
2038
- return new Promise((resolve, reject) => {
2039
- exec(`ping -c 1 -w 1 ${ip}`, (error, stdout, stderr) => {
2040
- if (error) {
2041
- // 命令执行出错,返回false
2042
- resolve(false);
2043
- }
2044
- else {
2045
- // 解析输出信息,提取延迟值
2046
- const match = stdout.match(/time=(\d+\.\d+) ms/);
2047
- const latency = match ? parseFloat(match[1]) : 0;
2048
- // 判断延迟是否超过100ms
2049
- resolve(latency > 100);
2050
- }
2051
- });
2052
- });
2054
+ try {
2055
+ const delay = yield ping(ip);
2056
+ logger.info(`${domain} latency is ${delay} ms`);
2057
+ // 判断延迟是否超过500ms
2058
+ return delay > 500;
2059
+ }
2060
+ catch (error) {
2061
+ // 命令执行出错,返回false
2062
+ logger.info(`ping ${domain} failed!, is not in China!`);
2063
+ return false;
2064
+ }
2053
2065
  });
2054
2066
  }
2055
2067
 
2056
- const is_china = isChinaDomain("sh.rustup.rs");
2057
- let RustInstallScriptFocMac = "";
2058
- if (is_china) {
2059
- RustInstallScriptFocMac =
2060
- 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh';
2061
- }
2062
- else {
2063
- RustInstallScriptFocMac =
2064
- "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
2065
- }
2066
- const RustInstallScriptForWin = 'winget install --id Rustlang.Rustup';
2067
2068
  function installRust() {
2068
2069
  return __awaiter(this, void 0, void 0, function* () {
2070
+ const is_china = yield isChinaDomain("sh.rustup.rs");
2071
+ let RustInstallScriptFocMac = "";
2072
+ if (is_china) {
2073
+ logger.info("it's in China, use rust cn mirror to install rust");
2074
+ RustInstallScriptFocMac =
2075
+ 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh';
2076
+ }
2077
+ else {
2078
+ RustInstallScriptFocMac =
2079
+ "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
2080
+ }
2081
+ const RustInstallScriptForWin = 'winget install --id Rustlang.Rustup';
2069
2082
  const spinner = ora('Downloading Rust').start();
2070
2083
  try {
2071
2084
  yield shellExec(IS_WIN ? RustInstallScriptForWin : RustInstallScriptFocMac);
@@ -2298,11 +2311,15 @@ class MacBuilder {
2298
2311
  yield mergeTauriConfig(url, options, tauriConf);
2299
2312
  let dmgName;
2300
2313
  if (options.multiArch) {
2301
- const isChina = isChinaDomain("www.npmjs.com");
2314
+ const isChina = yield isChinaDomain("www.npmjs.com");
2302
2315
  if (isChina) {
2303
- // crates.io也顺便换源
2316
+ logger.info("it's in China, use npm/rust cn mirror");
2304
2317
  const rust_project_dir = path.join(npmDirectory, 'src-tauri', ".cargo");
2305
- const project_cn_conf = path.join(rust_project_dir, "cn_config.bak");
2318
+ const e1 = fs$1.access(rust_project_dir);
2319
+ if (e1) {
2320
+ yield fs$1.mkdir(rust_project_dir, { recursive: true });
2321
+ }
2322
+ const project_cn_conf = path.join(npmDirectory, "src-tauri", "cn_config.bak");
2306
2323
  const project_conf = path.join(rust_project_dir, "config");
2307
2324
  fs$1.copyFile(project_cn_conf, project_conf);
2308
2325
  yield shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com && npm run build:mac`);
@@ -2377,11 +2394,15 @@ class WinBuilder {
2377
2394
  logger.debug('PakeAppOptions', options);
2378
2395
  const { name } = options;
2379
2396
  yield mergeTauriConfig(url, options, tauriConf);
2380
- const isChina = isChinaDomain("www.npmjs.com");
2397
+ const isChina = yield isChinaDomain("www.npmjs.com");
2381
2398
  if (isChina) {
2382
- // crates.io也顺便换源
2399
+ logger.info("it's in China, use npm/rust cn mirror");
2383
2400
  const rust_project_dir = path.join(npmDirectory, 'src-tauri', ".cargo");
2384
- const project_cn_conf = path.join(rust_project_dir, "cn_config.bak");
2401
+ const e1 = fs$1.access(rust_project_dir);
2402
+ if (e1) {
2403
+ yield fs$1.mkdir(rust_project_dir, { recursive: true });
2404
+ }
2405
+ const project_cn_conf = path.join(npmDirectory, "src-tauri", "cn_config.bak");
2385
2406
  const project_conf = path.join(rust_project_dir, "config");
2386
2407
  fs$1.copyFile(project_cn_conf, project_conf);
2387
2408
  yield shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com && npm run build`);
@@ -2433,11 +2454,15 @@ class LinuxBuilder {
2433
2454
  logger.debug('PakeAppOptions', options);
2434
2455
  const { name } = options;
2435
2456
  yield mergeTauriConfig(url, options, tauriConf);
2436
- const isChina = isChinaDomain("www.npmjs.com");
2457
+ const isChina = yield isChinaDomain("www.npmjs.com");
2437
2458
  if (isChina) {
2438
- // crates.io也顺便换源
2459
+ logger.info("it's in China, use npm/rust cn mirror");
2439
2460
  const rust_project_dir = path.join(npmDirectory, 'src-tauri', ".cargo");
2440
- const project_cn_conf = path.join(rust_project_dir, "cn_config.bak");
2461
+ const e1 = fs$1.access(rust_project_dir);
2462
+ if (e1) {
2463
+ yield fs$1.mkdir(rust_project_dir, { recursive: true });
2464
+ }
2465
+ const project_cn_conf = path.join(npmDirectory, "src-tauri", "cn_config.bak");
2441
2466
  const project_conf = path.join(rust_project_dir, "config");
2442
2467
  fs$1.copyFile(project_cn_conf, project_conf);
2443
2468
  yield shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com && npm run build`);
@@ -2493,7 +2518,7 @@ class BuilderFactory {
2493
2518
  }
2494
2519
 
2495
2520
  var name = "pake-cli";
2496
- var version = "2.0.0-alpha7";
2521
+ var version = "2.0.0-alpha9";
2497
2522
  var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";
2498
2523
  var engines = {
2499
2524
  node: ">=16.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "2.0.0-alpha7",
3
+ "version": "2.0.0-alpha9",
4
4
  "description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。",
5
5
  "engines": {
6
6
  "node": ">=16.0.0"
@@ -60,6 +60,10 @@ window.addEventListener('DOMContentLoaded', (_event) => {
60
60
  visibility: hidden;
61
61
  }
62
62
 
63
+ #__next > div.overflow-hidden.w-full.h-full.relative.flex > div.dark.hidden.flex-shrink-0.bg-gray-900.md\\:flex.md\\:w-\\[260px\\].md\\:flex-col > div > div > nav {
64
+ width: 100%;
65
+ }
66
+
63
67
  .lark > .dashboard-sidebar, .lark > .dashboard-sidebar > .sidebar-user-info , .lark > .dashboard-sidebar .index-module_wrapper_F-Wbq{
64
68
  padding-top:15px;
65
69
  }
@@ -111,7 +115,7 @@ window.addEventListener('DOMContentLoaded', (_event) => {
111
115
  #react-root a[href*="quick_promote_web"],
112
116
  #react-root [data-testid="AppTabBar_Explore_Link"],
113
117
  #react-root a[href*="/lists"][role="link"][aria-label],
114
- #react-root a[href="/i/bookmarks"] {
118
+ #react-root a[href*="/i/verified-orgs-signup"][role="link"][aria-label] {
115
119
  display: none !important;
116
120
  }
117
121
 
@@ -159,6 +163,7 @@ window.addEventListener('DOMContentLoaded', (_event) => {
159
163
  #react-root header[role="banner"] > div > div > div {
160
164
  justify-content: center !important;
161
165
  padding-top: 0;
166
+ overflow-x: hidden;
162
167
  }
163
168
 
164
169
  #react-root form[role="search"] > div:nth-child(1) > div {