pake-cli 2.0.0-alpha6 → 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 +1 -1
- package/dist/cli.js +31 -16
- package/package.json +1 -1
- package/src-tauri/Cargo.toml +5 -2
- package/src-tauri/src/inject/style.js +6 -5
- package/src-tauri/src/main.rs +5 -0
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
|
|
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
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
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-
|
|
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
package/src-tauri/Cargo.toml
CHANGED
|
@@ -31,5 +31,8 @@ custom-protocol = ["tauri/custom-protocol"]
|
|
|
31
31
|
|
|
32
32
|
# Pay attention to the code size during optimization in order to generate smaller binary files.
|
|
33
33
|
# [profile.release]
|
|
34
|
-
#
|
|
35
|
-
#
|
|
34
|
+
# panic = "abort" # Strip expensive panic clean-up logic
|
|
35
|
+
# codegen-units = 1 # Compile crates one after another so the compiler can optimize better
|
|
36
|
+
# lto = true # Enables link to optimizations
|
|
37
|
+
# opt-level = "s" # Optimize for binary size
|
|
38
|
+
# strip = true # Remove debug symbols
|
|
@@ -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
|
|
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 {
|
|
@@ -272,10 +277,6 @@ window.addEventListener('DOMContentLoaded', (_event) => {
|
|
|
272
277
|
}
|
|
273
278
|
}
|
|
274
279
|
|
|
275
|
-
#__next .prose ol {
|
|
276
|
-
overflow: hidden;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
280
|
#__next .prose ol li p {
|
|
280
281
|
margin: 0;
|
|
281
282
|
display: inline;
|
package/src-tauri/src/main.rs
CHANGED
|
@@ -55,7 +55,12 @@ pub fn run_app() {
|
|
|
55
55
|
})
|
|
56
56
|
.on_window_event(|event| {
|
|
57
57
|
if let tauri::WindowEvent::CloseRequested { api, .. } = event.event() {
|
|
58
|
+
#[cfg(target_os = "macos")]
|
|
58
59
|
event.window().minimize().unwrap();
|
|
60
|
+
|
|
61
|
+
#[cfg(not(target_os = "macos"))]
|
|
62
|
+
event.window().close().unwrap();
|
|
63
|
+
|
|
59
64
|
api.prevent_close();
|
|
60
65
|
}
|
|
61
66
|
})
|