pake-cli 3.6.2 โ 3.6.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/dist/cli.js +161 -143
- package/package.json +1 -3
- package/src-tauri/.cargo/config.toml +10 -0
- package/src-tauri/.pake/pake.json +3 -4
- package/src-tauri/.pake/tauri.conf.json +7 -6
- package/src-tauri/.pake/tauri.linux.conf.json +0 -1
- package/src-tauri/.pake/tauri.macos.conf.json +3 -3
- package/src-tauri/Cargo.lock +1 -1
- package/src-tauri/Cargo.toml +7 -2
- package/src-tauri/src/app/invoke.rs +56 -26
- package/src-tauri/src/app/menu.rs +151 -188
- package/src-tauri/src/lib.rs +12 -7
- package/src-tauri/tauri.linux.conf.json +0 -1
- package/dist/dev.js +0 -1943
- package/dist/dev.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import log from 'loglevel';
|
|
3
|
+
import updateNotifier from 'update-notifier';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import fsExtra from 'fs-extra';
|
|
5
6
|
import { fileURLToPath } from 'url';
|
|
@@ -13,8 +14,6 @@ import dns from 'dns';
|
|
|
13
14
|
import http from 'http';
|
|
14
15
|
import { promisify } from 'util';
|
|
15
16
|
import fs from 'fs';
|
|
16
|
-
import updateNotifier from 'update-notifier';
|
|
17
|
-
import axios from 'axios';
|
|
18
17
|
import { dir } from 'tmp-promise';
|
|
19
18
|
import { fileTypeFromBuffer } from 'file-type';
|
|
20
19
|
import icongen from 'icon-gen';
|
|
@@ -22,6 +21,112 @@ import sharp from 'sharp';
|
|
|
22
21
|
import * as psl from 'psl';
|
|
23
22
|
import { InvalidArgumentError, program as program$1, Option } from 'commander';
|
|
24
23
|
|
|
24
|
+
var name = "pake-cli";
|
|
25
|
+
var version = "3.6.4";
|
|
26
|
+
var description = "๐คฑ๐ป Turn any webpage into a desktop app with one command. ๐คฑ๐ป ไธ้ฎๆๅ
็ฝ้กต็ๆ่ฝป้ๆก้ขๅบ็จใ";
|
|
27
|
+
var engines = {
|
|
28
|
+
node: ">=18.0.0"
|
|
29
|
+
};
|
|
30
|
+
var packageManager = "pnpm@10.15.0";
|
|
31
|
+
var bin = {
|
|
32
|
+
pake: "./dist/cli.js"
|
|
33
|
+
};
|
|
34
|
+
var repository = {
|
|
35
|
+
type: "git",
|
|
36
|
+
url: "https://github.com/tw93/pake.git"
|
|
37
|
+
};
|
|
38
|
+
var author = {
|
|
39
|
+
name: "Tw93",
|
|
40
|
+
email: "tw93@qq.com"
|
|
41
|
+
};
|
|
42
|
+
var keywords = [
|
|
43
|
+
"pake",
|
|
44
|
+
"pake-cli",
|
|
45
|
+
"rust",
|
|
46
|
+
"tauri",
|
|
47
|
+
"no-electron",
|
|
48
|
+
"productivity"
|
|
49
|
+
];
|
|
50
|
+
var files = [
|
|
51
|
+
"dist",
|
|
52
|
+
"src-tauri"
|
|
53
|
+
];
|
|
54
|
+
var scripts = {
|
|
55
|
+
start: "pnpm run dev",
|
|
56
|
+
dev: "pnpm run tauri dev",
|
|
57
|
+
build: "tauri build",
|
|
58
|
+
"build:debug": "tauri build --debug",
|
|
59
|
+
"build:mac": "tauri build --target universal-apple-darwin",
|
|
60
|
+
analyze: "cd src-tauri && cargo bloat --release --crates",
|
|
61
|
+
tauri: "tauri",
|
|
62
|
+
cli: "cross-env NODE_ENV=development rollup -c -w",
|
|
63
|
+
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
64
|
+
test: "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
65
|
+
format: "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
66
|
+
"format:check": "prettier --check . --ignore-unknown",
|
|
67
|
+
update: "pnpm update --verbose && cd src-tauri && cargo update",
|
|
68
|
+
prepublishOnly: "pnpm run cli:build"
|
|
69
|
+
};
|
|
70
|
+
var type = "module";
|
|
71
|
+
var exports = "./dist/cli.js";
|
|
72
|
+
var license = "MIT";
|
|
73
|
+
var dependencies = {
|
|
74
|
+
"@tauri-apps/api": "^2.9.0",
|
|
75
|
+
"@tauri-apps/cli": "^2.9.0",
|
|
76
|
+
chalk: "^5.6.2",
|
|
77
|
+
commander: "^12.1.0",
|
|
78
|
+
execa: "^9.6.0",
|
|
79
|
+
"file-type": "^18.7.0",
|
|
80
|
+
"fs-extra": "^11.3.2",
|
|
81
|
+
"icon-gen": "^5.0.0",
|
|
82
|
+
loglevel: "^1.9.2",
|
|
83
|
+
ora: "^8.2.0",
|
|
84
|
+
prompts: "^2.4.2",
|
|
85
|
+
psl: "^1.15.0",
|
|
86
|
+
sharp: "^0.33.5",
|
|
87
|
+
"tmp-promise": "^3.0.3",
|
|
88
|
+
"update-notifier": "^7.3.1"
|
|
89
|
+
};
|
|
90
|
+
var devDependencies = {
|
|
91
|
+
"@rollup/plugin-alias": "^5.1.1",
|
|
92
|
+
"@rollup/plugin-commonjs": "^28.0.8",
|
|
93
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
94
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
95
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
96
|
+
"@types/fs-extra": "^11.0.4",
|
|
97
|
+
"@types/node": "^20.19.23",
|
|
98
|
+
"@types/page-icon": "^0.3.6",
|
|
99
|
+
"@types/prompts": "^2.4.9",
|
|
100
|
+
"@types/tmp": "^0.2.6",
|
|
101
|
+
"@types/update-notifier": "^6.0.8",
|
|
102
|
+
"app-root-path": "^3.1.0",
|
|
103
|
+
"cross-env": "^7.0.3",
|
|
104
|
+
prettier: "^3.6.2",
|
|
105
|
+
rollup: "^4.52.5",
|
|
106
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
107
|
+
tslib: "^2.8.1",
|
|
108
|
+
typescript: "^5.9.3",
|
|
109
|
+
vitest: "^4.0.15"
|
|
110
|
+
};
|
|
111
|
+
var packageJson = {
|
|
112
|
+
name: name,
|
|
113
|
+
version: version,
|
|
114
|
+
description: description,
|
|
115
|
+
engines: engines,
|
|
116
|
+
packageManager: packageManager,
|
|
117
|
+
bin: bin,
|
|
118
|
+
repository: repository,
|
|
119
|
+
author: author,
|
|
120
|
+
keywords: keywords,
|
|
121
|
+
files: files,
|
|
122
|
+
scripts: scripts,
|
|
123
|
+
type: type,
|
|
124
|
+
exports: exports,
|
|
125
|
+
license: license,
|
|
126
|
+
dependencies: dependencies,
|
|
127
|
+
devDependencies: devDependencies
|
|
128
|
+
};
|
|
129
|
+
|
|
25
130
|
// Convert the current module URL to a file path
|
|
26
131
|
const currentModulePath = fileURLToPath(import.meta.url);
|
|
27
132
|
// Resolve the parent directory of the current module
|
|
@@ -385,7 +490,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
385
490
|
disabled_web_shortcuts: disabledWebShortcuts,
|
|
386
491
|
hide_on_close: platformHideOnClose,
|
|
387
492
|
incognito: incognito,
|
|
388
|
-
title: title
|
|
493
|
+
title: title,
|
|
389
494
|
enable_wasm: wasm,
|
|
390
495
|
enable_drag_drop: enableDragDrop,
|
|
391
496
|
start_to_tray: startToTray && showSystemTray,
|
|
@@ -399,9 +504,9 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
399
504
|
tauriConf.productName = name;
|
|
400
505
|
tauriConf.identifier = identifier;
|
|
401
506
|
tauriConf.version = appVersion;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
507
|
+
// Always set mainBinaryName to ensure binary uniqueness
|
|
508
|
+
const linuxBinaryName = `pake-${generateLinuxPackageName(name)}`;
|
|
509
|
+
tauriConf.mainBinaryName = platform === 'linux' ? linuxBinaryName : `pake-${generateIdentifierSafeName(name)}`;
|
|
405
510
|
if (platform == 'win32') {
|
|
406
511
|
tauriConf.bundle.windows.wix.language[0] = installerLanguage;
|
|
407
512
|
}
|
|
@@ -446,9 +551,9 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
446
551
|
// Remove hardcoded desktop files and regenerate with correct app name
|
|
447
552
|
delete tauriConf.bundle.linux.deb.files;
|
|
448
553
|
// Generate correct desktop file configuration
|
|
449
|
-
const
|
|
450
|
-
const
|
|
451
|
-
const
|
|
554
|
+
const linuxName = generateLinuxPackageName(name);
|
|
555
|
+
const desktopFileName = `com.pake.${linuxName}.desktop`;
|
|
556
|
+
const iconName = `${linuxName}_512`;
|
|
452
557
|
// Create desktop file content
|
|
453
558
|
// Determine if title contains Chinese characters for Name[zh_CN]
|
|
454
559
|
const chineseName = title && /[\u4e00-\u9fa5]/.test(title) ? title : null;
|
|
@@ -458,11 +563,12 @@ Type=Application
|
|
|
458
563
|
Name=${name}
|
|
459
564
|
${chineseName ? `Name[zh_CN]=${chineseName}` : ''}
|
|
460
565
|
Comment=${name}
|
|
461
|
-
Exec
|
|
462
|
-
Icon=${
|
|
463
|
-
Categories=Network;WebBrowser;
|
|
566
|
+
Exec=${linuxBinaryName}
|
|
567
|
+
Icon=${iconName}
|
|
568
|
+
Categories=Network;WebBrowser;Utility;
|
|
464
569
|
MimeType=text/html;text/xml;application/xhtml_xml;
|
|
465
570
|
StartupNotify=true
|
|
571
|
+
Terminal=false
|
|
466
572
|
`;
|
|
467
573
|
// Write desktop file to src-tauri/assets directory where Tauri expects it
|
|
468
574
|
const srcAssetsDir = path.join(npmDirectory, 'src-tauri/assets');
|
|
@@ -471,8 +577,16 @@ StartupNotify=true
|
|
|
471
577
|
await fsExtra.writeFile(srcDesktopFilePath, desktopContent);
|
|
472
578
|
// Set up desktop file in bundle configuration
|
|
473
579
|
// Use absolute path from src-tauri directory to assets
|
|
580
|
+
const desktopInstallPath = `/usr/share/applications/${desktopFileName}`;
|
|
474
581
|
tauriConf.bundle.linux.deb.files = {
|
|
475
|
-
[
|
|
582
|
+
[desktopInstallPath]: `assets/${desktopFileName}`,
|
|
583
|
+
};
|
|
584
|
+
// Add desktop file support for RPM
|
|
585
|
+
if (!tauriConf.bundle.linux.rpm) {
|
|
586
|
+
tauriConf.bundle.linux.rpm = {};
|
|
587
|
+
}
|
|
588
|
+
tauriConf.bundle.linux.rpm.files = {
|
|
589
|
+
[desktopInstallPath]: `assets/${desktopFileName}`,
|
|
476
590
|
};
|
|
477
591
|
const validTargets = [
|
|
478
592
|
'deb',
|
|
@@ -510,7 +624,7 @@ StartupNotify=true
|
|
|
510
624
|
},
|
|
511
625
|
linux: {
|
|
512
626
|
fileExt: '.png',
|
|
513
|
-
path: `png/${
|
|
627
|
+
path: `png/${generateLinuxPackageName(name)}_512.png`,
|
|
514
628
|
defaultIcon: 'png/icon_512.png',
|
|
515
629
|
message: 'Linux icon must be .png and 512x512px.',
|
|
516
630
|
},
|
|
@@ -978,12 +1092,9 @@ class BaseBuilder {
|
|
|
978
1092
|
*/
|
|
979
1093
|
getBinaryName(appName) {
|
|
980
1094
|
const extension = process.platform === 'win32' ? '.exe' : '';
|
|
981
|
-
//
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
985
|
-
// Windows and macOS use 'pake' as binary name
|
|
986
|
-
return `pake${extension}`;
|
|
1095
|
+
// Use unique binary name for all platforms to avoid conflicts
|
|
1096
|
+
const nameToUse = process.platform === 'linux' ? generateLinuxPackageName(appName) : generateIdentifierSafeName(appName);
|
|
1097
|
+
return `pake-${nameToUse}${extension}`;
|
|
987
1098
|
}
|
|
988
1099
|
/**
|
|
989
1100
|
* Check if this build has architecture-specific target
|
|
@@ -1249,120 +1360,6 @@ class BuilderProvider {
|
|
|
1249
1360
|
}
|
|
1250
1361
|
}
|
|
1251
1362
|
|
|
1252
|
-
var name = "pake-cli";
|
|
1253
|
-
var version = "3.6.2";
|
|
1254
|
-
var description = "๐คฑ๐ป Turn any webpage into a desktop app with one command. ๐คฑ๐ป ไธ้ฎๆๅ
็ฝ้กต็ๆ่ฝป้ๆก้ขๅบ็จใ";
|
|
1255
|
-
var engines = {
|
|
1256
|
-
node: ">=18.0.0"
|
|
1257
|
-
};
|
|
1258
|
-
var packageManager = "pnpm@10.15.0";
|
|
1259
|
-
var bin = {
|
|
1260
|
-
pake: "./dist/cli.js"
|
|
1261
|
-
};
|
|
1262
|
-
var repository = {
|
|
1263
|
-
type: "git",
|
|
1264
|
-
url: "https://github.com/tw93/pake.git"
|
|
1265
|
-
};
|
|
1266
|
-
var author = {
|
|
1267
|
-
name: "Tw93",
|
|
1268
|
-
email: "tw93@qq.com"
|
|
1269
|
-
};
|
|
1270
|
-
var keywords = [
|
|
1271
|
-
"pake",
|
|
1272
|
-
"pake-cli",
|
|
1273
|
-
"rust",
|
|
1274
|
-
"tauri",
|
|
1275
|
-
"no-electron",
|
|
1276
|
-
"productivity"
|
|
1277
|
-
];
|
|
1278
|
-
var files = [
|
|
1279
|
-
"dist",
|
|
1280
|
-
"src-tauri"
|
|
1281
|
-
];
|
|
1282
|
-
var scripts = {
|
|
1283
|
-
start: "pnpm run dev",
|
|
1284
|
-
dev: "pnpm run tauri dev",
|
|
1285
|
-
build: "tauri build",
|
|
1286
|
-
"build:debug": "tauri build --debug",
|
|
1287
|
-
"build:mac": "tauri build --target universal-apple-darwin",
|
|
1288
|
-
analyze: "cd src-tauri && cargo bloat --release --crates",
|
|
1289
|
-
tauri: "tauri",
|
|
1290
|
-
cli: "cross-env NODE_ENV=development rollup -c -w",
|
|
1291
|
-
"cli:dev": "cross-env NODE_ENV=development rollup -c -w",
|
|
1292
|
-
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
1293
|
-
test: "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
1294
|
-
format: "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
1295
|
-
"format:check": "prettier --check . --ignore-unknown",
|
|
1296
|
-
update: "pnpm update --verbose && cd src-tauri && cargo update",
|
|
1297
|
-
prepublishOnly: "pnpm run cli:build"
|
|
1298
|
-
};
|
|
1299
|
-
var type = "module";
|
|
1300
|
-
var exports = "./dist/cli.js";
|
|
1301
|
-
var license = "MIT";
|
|
1302
|
-
var dependencies = {
|
|
1303
|
-
"@tauri-apps/api": "^2.9.0",
|
|
1304
|
-
"@tauri-apps/cli": "^2.9.0",
|
|
1305
|
-
axios: "^1.12.2",
|
|
1306
|
-
chalk: "^5.6.2",
|
|
1307
|
-
commander: "^12.1.0",
|
|
1308
|
-
execa: "^9.6.0",
|
|
1309
|
-
"file-type": "^18.7.0",
|
|
1310
|
-
"fs-extra": "^11.3.2",
|
|
1311
|
-
"icon-gen": "^5.0.0",
|
|
1312
|
-
loglevel: "^1.9.2",
|
|
1313
|
-
ora: "^8.2.0",
|
|
1314
|
-
prompts: "^2.4.2",
|
|
1315
|
-
psl: "^1.15.0",
|
|
1316
|
-
sharp: "^0.33.5",
|
|
1317
|
-
"tmp-promise": "^3.0.3",
|
|
1318
|
-
"update-notifier": "^7.3.1"
|
|
1319
|
-
};
|
|
1320
|
-
var devDependencies = {
|
|
1321
|
-
"@rollup/plugin-alias": "^5.1.1",
|
|
1322
|
-
"@rollup/plugin-commonjs": "^28.0.8",
|
|
1323
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
1324
|
-
"@rollup/plugin-replace": "^6.0.2",
|
|
1325
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
1326
|
-
"@types/fs-extra": "^11.0.4",
|
|
1327
|
-
"@types/node": "^20.19.23",
|
|
1328
|
-
"@types/page-icon": "^0.3.6",
|
|
1329
|
-
"@types/prompts": "^2.4.9",
|
|
1330
|
-
"@types/tmp": "^0.2.6",
|
|
1331
|
-
"@types/update-notifier": "^6.0.8",
|
|
1332
|
-
"app-root-path": "^3.1.0",
|
|
1333
|
-
"cross-env": "^7.0.3",
|
|
1334
|
-
prettier: "^3.6.2",
|
|
1335
|
-
rollup: "^4.52.5",
|
|
1336
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
1337
|
-
tslib: "^2.8.1",
|
|
1338
|
-
typescript: "^5.9.3",
|
|
1339
|
-
vitest: "^4.0.15"
|
|
1340
|
-
};
|
|
1341
|
-
var packageJson = {
|
|
1342
|
-
name: name,
|
|
1343
|
-
version: version,
|
|
1344
|
-
description: description,
|
|
1345
|
-
engines: engines,
|
|
1346
|
-
packageManager: packageManager,
|
|
1347
|
-
bin: bin,
|
|
1348
|
-
repository: repository,
|
|
1349
|
-
author: author,
|
|
1350
|
-
keywords: keywords,
|
|
1351
|
-
files: files,
|
|
1352
|
-
scripts: scripts,
|
|
1353
|
-
type: type,
|
|
1354
|
-
exports: exports,
|
|
1355
|
-
license: license,
|
|
1356
|
-
dependencies: dependencies,
|
|
1357
|
-
devDependencies: devDependencies
|
|
1358
|
-
};
|
|
1359
|
-
|
|
1360
|
-
async function checkUpdateTips() {
|
|
1361
|
-
updateNotifier({ pkg: packageJson, updateCheckInterval: 1000 * 60 }).notify({
|
|
1362
|
-
isGlobal: true,
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
1363
|
const ICON_CONFIG = {
|
|
1367
1364
|
minFileSize: 100,
|
|
1368
1365
|
supportedFormats: ['png', 'ico', 'jpeg', 'jpg', 'webp', 'icns'],
|
|
@@ -1705,24 +1702,40 @@ async function tryGetFavicon(url, appName) {
|
|
|
1705
1702
|
* Downloads icon from URL
|
|
1706
1703
|
*/
|
|
1707
1704
|
async function downloadIcon(iconUrl, showSpinner = true, customTimeout) {
|
|
1705
|
+
const controller = new AbortController();
|
|
1706
|
+
const timeoutId = setTimeout(() => {
|
|
1707
|
+
controller.abort();
|
|
1708
|
+
}, customTimeout || 10000);
|
|
1708
1709
|
try {
|
|
1709
|
-
const response = await
|
|
1710
|
-
|
|
1711
|
-
timeout: customTimeout || 10000,
|
|
1710
|
+
const response = await fetch(iconUrl, {
|
|
1711
|
+
signal: controller.signal,
|
|
1712
1712
|
});
|
|
1713
|
-
|
|
1714
|
-
if (!
|
|
1713
|
+
clearTimeout(timeoutId);
|
|
1714
|
+
if (!response.ok) {
|
|
1715
|
+
if (response.status === 404 && !showSpinner) {
|
|
1716
|
+
return null;
|
|
1717
|
+
}
|
|
1718
|
+
throw new Error(`HTTP ${response.status} ${response.statusText}`);
|
|
1719
|
+
}
|
|
1720
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
1721
|
+
if (!arrayBuffer || arrayBuffer.byteLength < ICON_CONFIG.minFileSize)
|
|
1715
1722
|
return null;
|
|
1716
|
-
const fileDetails = await fileTypeFromBuffer(
|
|
1723
|
+
const fileDetails = await fileTypeFromBuffer(arrayBuffer);
|
|
1717
1724
|
if (!fileDetails ||
|
|
1718
1725
|
!ICON_CONFIG.supportedFormats.includes(fileDetails.ext)) {
|
|
1719
1726
|
return null;
|
|
1720
1727
|
}
|
|
1721
|
-
return await saveIconFile(
|
|
1728
|
+
return await saveIconFile(arrayBuffer, fileDetails.ext);
|
|
1722
1729
|
}
|
|
1723
1730
|
catch (error) {
|
|
1724
|
-
|
|
1725
|
-
|
|
1731
|
+
clearTimeout(timeoutId);
|
|
1732
|
+
if (showSpinner) {
|
|
1733
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
1734
|
+
logger.error('Icon download timed out!');
|
|
1735
|
+
}
|
|
1736
|
+
else {
|
|
1737
|
+
logger.error('Icon download failed!', error instanceof Error ? error.message : String(error));
|
|
1738
|
+
}
|
|
1726
1739
|
}
|
|
1727
1740
|
return null;
|
|
1728
1741
|
}
|
|
@@ -2041,6 +2054,11 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
|
|
|
2041
2054
|
}
|
|
2042
2055
|
|
|
2043
2056
|
const program = getCliProgram();
|
|
2057
|
+
async function checkUpdateTips() {
|
|
2058
|
+
updateNotifier({ pkg: packageJson, updateCheckInterval: 1000 * 60 }).notify({
|
|
2059
|
+
isGlobal: true,
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2044
2062
|
program.action(async (url, options) => {
|
|
2045
2063
|
await checkUpdateTips();
|
|
2046
2064
|
if (!url) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pake-cli",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.4",
|
|
4
4
|
"description": "๐คฑ๐ป Turn any webpage into a desktop app with one command. ๐คฑ๐ป ไธ้ฎๆๅ
็ฝ้กต็ๆ่ฝป้ๆก้ขๅบ็จใ",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"analyze": "cd src-tauri && cargo bloat --release --crates",
|
|
39
39
|
"tauri": "tauri",
|
|
40
40
|
"cli": "cross-env NODE_ENV=development rollup -c -w",
|
|
41
|
-
"cli:dev": "cross-env NODE_ENV=development rollup -c -w",
|
|
42
41
|
"cli:build": "cross-env NODE_ENV=production rollup -c",
|
|
43
42
|
"test": "pnpm run cli:build && cross-env PAKE_CREATE_APP=1 node tests/index.js",
|
|
44
43
|
"format": "prettier --write . --ignore-unknown && find tests -name '*.js' -exec sed -i '' 's/[[:space:]]*$//' {} \\; && cd src-tauri && cargo fmt --verbose",
|
|
@@ -52,7 +51,6 @@
|
|
|
52
51
|
"dependencies": {
|
|
53
52
|
"@tauri-apps/api": "^2.9.0",
|
|
54
53
|
"@tauri-apps/cli": "^2.9.0",
|
|
55
|
-
"axios": "^1.12.2",
|
|
56
54
|
"chalk": "^5.6.2",
|
|
57
55
|
"commander": "^12.1.0",
|
|
58
56
|
"execa": "^9.6.0",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[source.crates-io]
|
|
2
|
+
replace-with = 'rsproxy-sparse'
|
|
3
|
+
[source.rsproxy]
|
|
4
|
+
registry = "https://rsproxy.cn/crates.io-index"
|
|
5
|
+
[source.rsproxy-sparse]
|
|
6
|
+
registry = "sparse+https://rsproxy.cn/index/"
|
|
7
|
+
[registries.rsproxy]
|
|
8
|
+
index = "https://rsproxy.cn/crates.io-index"
|
|
9
|
+
[net]
|
|
10
|
+
git-fetch-with-cli = true
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"windows": [
|
|
3
3
|
{
|
|
4
|
-
"url": "https://
|
|
4
|
+
"url": "https://example.com",
|
|
5
5
|
"url_type": "web",
|
|
6
|
-
"hide_title_bar":
|
|
6
|
+
"hide_title_bar": false,
|
|
7
7
|
"fullscreen": false,
|
|
8
8
|
"width": 1200,
|
|
9
|
-
"height":
|
|
9
|
+
"height": 780,
|
|
10
10
|
"resizable": true,
|
|
11
11
|
"always_on_top": false,
|
|
12
12
|
"dark_mode": false,
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"maximize": false,
|
|
20
20
|
"start_to_tray": false,
|
|
21
21
|
"force_internal_navigation": false,
|
|
22
|
-
"title": null,
|
|
23
22
|
"zoom": 100,
|
|
24
23
|
"min_width": 0,
|
|
25
24
|
"min_height": 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"productName": "
|
|
3
|
-
"identifier": "com.pake.
|
|
2
|
+
"productName": "Final App",
|
|
3
|
+
"identifier": "com.pake.c984d0",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"app": {
|
|
6
6
|
"withGlobalTauri": true,
|
|
@@ -14,14 +14,15 @@
|
|
|
14
14
|
},
|
|
15
15
|
"bundle": {
|
|
16
16
|
"icon": [
|
|
17
|
-
"icons/
|
|
17
|
+
"icons/final_app.icns"
|
|
18
18
|
],
|
|
19
19
|
"active": true,
|
|
20
20
|
"targets": [
|
|
21
|
-
"
|
|
21
|
+
"dmg"
|
|
22
22
|
],
|
|
23
23
|
"resources": [
|
|
24
|
-
"icons/
|
|
24
|
+
"icons/final_app.icns"
|
|
25
25
|
]
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"mainBinaryName": "pake-finalapp"
|
|
27
28
|
}
|
package/src-tauri/Cargo.lock
CHANGED
package/src-tauri/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "pake"
|
|
3
|
-
version = "3.6.
|
|
3
|
+
version = "3.6.4"
|
|
4
4
|
description = "๐คฑ๐ป Turn any webpage into a desktop app with Rust."
|
|
5
5
|
authors = ["Tw93"]
|
|
6
6
|
license = "MIT"
|
|
@@ -21,7 +21,12 @@ tauri-build = { version = "2.5.3", features = [] }
|
|
|
21
21
|
serde_json = "1.0.145"
|
|
22
22
|
serde = { version = "1.0.228", features = ["derive"] }
|
|
23
23
|
tokio = { version = "1.48.0", features = ["full"] }
|
|
24
|
-
tauri = { version = "2.9.4", features = [
|
|
24
|
+
tauri = { version = "2.9.4", features = [
|
|
25
|
+
"tray-icon",
|
|
26
|
+
"image-ico",
|
|
27
|
+
"image-png",
|
|
28
|
+
"macos-proxy",
|
|
29
|
+
] }
|
|
25
30
|
tauri-plugin-window-state = "2.4.1"
|
|
26
31
|
tauri-plugin-oauth = "2.0.0"
|
|
27
32
|
tauri-plugin-http = "2.5.4"
|
|
@@ -32,29 +32,48 @@ pub struct NotificationParams {
|
|
|
32
32
|
|
|
33
33
|
#[command]
|
|
34
34
|
pub async fn download_file(app: AppHandle, params: DownloadFileParams) -> Result<(), String> {
|
|
35
|
-
let window: WebviewWindow = app.get_webview_window("pake").
|
|
35
|
+
let window: WebviewWindow = app.get_webview_window("pake").ok_or("Window not found")?;
|
|
36
|
+
|
|
36
37
|
show_toast(
|
|
37
38
|
&window,
|
|
38
39
|
&get_download_message_with_lang(MessageType::Start, params.language.clone()),
|
|
39
40
|
);
|
|
40
41
|
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
let download_dir = app
|
|
43
|
+
.path()
|
|
44
|
+
.download_dir()
|
|
45
|
+
.map_err(|e| format!("Failed to get download dir: {}", e))?;
|
|
46
|
+
|
|
47
|
+
let output_path = download_dir.join(¶ms.filename);
|
|
48
|
+
|
|
49
|
+
let path_str = output_path.to_str().ok_or("Invalid output path")?;
|
|
50
|
+
|
|
51
|
+
let file_path = check_file_or_append(path_str);
|
|
44
52
|
|
|
45
|
-
let
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
let client = ClientBuilder::new()
|
|
54
|
+
.build()
|
|
55
|
+
.map_err(|e| format!("Failed to build client: {}", e))?;
|
|
56
|
+
|
|
57
|
+
let url = Url::from_str(¶ms.url).map_err(|e| format!("Invalid URL: {}", e))?;
|
|
58
|
+
|
|
59
|
+
let request = Request::new(Method::GET, url);
|
|
60
|
+
|
|
61
|
+
let response = client.execute(request).await;
|
|
51
62
|
|
|
52
63
|
match response {
|
|
53
64
|
Ok(mut res) => {
|
|
54
|
-
let mut file =
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
let mut file =
|
|
66
|
+
File::create(file_path).map_err(|e| format!("Failed to create file: {}", e))?;
|
|
67
|
+
|
|
68
|
+
while let Some(chunk) = res
|
|
69
|
+
.chunk()
|
|
70
|
+
.await
|
|
71
|
+
.map_err(|e| format!("Failed to get chunk: {}", e))?
|
|
72
|
+
{
|
|
73
|
+
file.write_all(&chunk)
|
|
74
|
+
.map_err(|e| format!("Failed to write chunk: {}", e))?;
|
|
57
75
|
}
|
|
76
|
+
|
|
58
77
|
show_toast(
|
|
59
78
|
&window,
|
|
60
79
|
&get_download_message_with_lang(MessageType::Success, params.language.clone()),
|
|
@@ -76,15 +95,25 @@ pub async fn download_file_by_binary(
|
|
|
76
95
|
app: AppHandle,
|
|
77
96
|
params: BinaryDownloadParams,
|
|
78
97
|
) -> Result<(), String> {
|
|
79
|
-
let window: WebviewWindow = app.get_webview_window("pake").
|
|
98
|
+
let window: WebviewWindow = app.get_webview_window("pake").ok_or("Window not found")?;
|
|
99
|
+
|
|
80
100
|
show_toast(
|
|
81
101
|
&window,
|
|
82
102
|
&get_download_message_with_lang(MessageType::Start, params.language.clone()),
|
|
83
103
|
);
|
|
84
|
-
|
|
85
|
-
let
|
|
86
|
-
|
|
87
|
-
|
|
104
|
+
|
|
105
|
+
let download_dir = app
|
|
106
|
+
.path()
|
|
107
|
+
.download_dir()
|
|
108
|
+
.map_err(|e| format!("Failed to get download dir: {}", e))?;
|
|
109
|
+
|
|
110
|
+
let output_path = download_dir.join(¶ms.filename);
|
|
111
|
+
|
|
112
|
+
let path_str = output_path.to_str().ok_or("Invalid output path")?;
|
|
113
|
+
|
|
114
|
+
let file_path = check_file_or_append(path_str);
|
|
115
|
+
|
|
116
|
+
match fs::write(file_path, ¶ms.binary) {
|
|
88
117
|
Ok(_) => {
|
|
89
118
|
show_toast(
|
|
90
119
|
&window,
|
|
@@ -111,7 +140,7 @@ pub fn send_notification(app: AppHandle, params: NotificationParams) -> Result<(
|
|
|
111
140
|
.body(¶ms.body)
|
|
112
141
|
.icon(¶ms.icon)
|
|
113
142
|
.show()
|
|
114
|
-
.
|
|
143
|
+
.map_err(|e| format!("Failed to show notification: {}", e))?;
|
|
115
144
|
Ok(())
|
|
116
145
|
}
|
|
117
146
|
|
|
@@ -119,13 +148,14 @@ pub fn send_notification(app: AppHandle, params: NotificationParams) -> Result<(
|
|
|
119
148
|
pub async fn update_theme_mode(app: AppHandle, mode: String) {
|
|
120
149
|
#[cfg(target_os = "macos")]
|
|
121
150
|
{
|
|
122
|
-
let window = app.get_webview_window("pake")
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
151
|
+
if let Some(window) = app.get_webview_window("pake") {
|
|
152
|
+
let theme = if mode == "dark" {
|
|
153
|
+
Theme::Dark
|
|
154
|
+
} else {
|
|
155
|
+
Theme::Light
|
|
156
|
+
};
|
|
157
|
+
let _ = window.set_theme(Some(theme));
|
|
158
|
+
}
|
|
129
159
|
}
|
|
130
160
|
#[cfg(not(target_os = "macos"))]
|
|
131
161
|
{
|