pake-cli 2.0.0-alpha7 → 2.0.0-alpha8

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,35 +2019,50 @@ 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
2054
  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
- }
2055
+ // exec(`ping -c -w 1 ${ip}`, (error, stdout, stderr) => {
2056
+ ping(ip)
2057
+ .then((declay) => {
2058
+ logger.info(`${domain} latency is ${declay} ms`);
2059
+ // 判断延迟是否超过500ms
2060
+ resolve(declay > 500);
2061
+ })
2062
+ .catch((error) => {
2063
+ // 命令执行出错,返回false
2064
+ logger.info(`ping ${domain} failed!, is not in China!`);
2065
+ resolve(false);
2051
2066
  });
2052
2067
  });
2053
2068
  });
@@ -2493,7 +2508,7 @@ class BuilderFactory {
2493
2508
  }
2494
2509
 
2495
2510
  var name = "pake-cli";
2496
- var version = "2.0.0-alpha7";
2511
+ var version = "2.0.0-alpha8";
2497
2512
  var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";
2498
2513
  var engines = {
2499
2514
  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-alpha8",
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 {