pake-cli 2.5.0 → 2.5.1
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
CHANGED
|
@@ -20,7 +20,7 @@ import psl from 'psl';
|
|
|
20
20
|
import isUrl from 'is-url';
|
|
21
21
|
|
|
22
22
|
var name = "pake-cli";
|
|
23
|
-
var version = "2.5.
|
|
23
|
+
var version = "2.5.1";
|
|
24
24
|
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
|
|
25
25
|
var engines = {
|
|
26
26
|
node: ">=16.0.0"
|
|
@@ -465,9 +465,11 @@ async function combineFiles(files, output) {
|
|
|
465
465
|
const contents = files.map(file => {
|
|
466
466
|
const fileContent = fs.readFileSync(file);
|
|
467
467
|
if (file.endsWith('.css')) {
|
|
468
|
-
return "window.addEventListener('DOMContentLoaded', (_event) => { const css = `" +
|
|
468
|
+
return ("window.addEventListener('DOMContentLoaded', (_event) => { const css = `" +
|
|
469
|
+
fileContent +
|
|
470
|
+
"`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });");
|
|
469
471
|
}
|
|
470
|
-
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent +
|
|
472
|
+
return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + ' });';
|
|
471
473
|
});
|
|
472
474
|
fs.writeFileSync(output, contents.join('\n'));
|
|
473
475
|
return files;
|
|
@@ -633,7 +635,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
633
635
|
logger.error('The injected file must be in either CSS or JS format.');
|
|
634
636
|
return;
|
|
635
637
|
}
|
|
636
|
-
const files = inject.map(filepath => path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath));
|
|
638
|
+
const files = inject.map(filepath => (path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath)));
|
|
637
639
|
tauriConf.pake.inject = files;
|
|
638
640
|
await combineFiles(files, injectFilePath);
|
|
639
641
|
}
|
|
@@ -1014,10 +1016,7 @@ ${green('| |_) / _` | |/ / _ \\')}
|
|
|
1014
1016
|
${green('| __/ (_| | < __/')} ${yellow('https://github.com/tw93/pake')}
|
|
1015
1017
|
${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with Rust.')}
|
|
1016
1018
|
`;
|
|
1017
|
-
program
|
|
1018
|
-
.addHelpText('beforeAll', logo)
|
|
1019
|
-
.usage(`[url] [options]`)
|
|
1020
|
-
.showHelpAfterError();
|
|
1019
|
+
program.addHelpText('beforeAll', logo).usage(`[url] [options]`).showHelpAfterError();
|
|
1021
1020
|
program
|
|
1022
1021
|
.argument('[url]', 'The web URL you want to package', validateUrlInput)
|
|
1023
1022
|
.option('--name <string>', 'Application name')
|
|
@@ -1034,8 +1033,12 @@ program
|
|
|
1034
1033
|
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp())
|
|
1035
1034
|
.addOption(new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT_PAKE_OPTIONS.targets).hideHelp())
|
|
1036
1035
|
.addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT_PAKE_OPTIONS.alwaysOnTop).hideHelp())
|
|
1037
|
-
.addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
|
|
1038
|
-
.
|
|
1036
|
+
.addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
|
|
1037
|
+
.default(DEFAULT_PAKE_OPTIONS.disabledWebShortcuts)
|
|
1038
|
+
.hideHelp())
|
|
1039
|
+
.addOption(new Option('--safe-domain [domains...]', 'Domains that Require Security Configuration')
|
|
1040
|
+
.default(DEFAULT_PAKE_OPTIONS.safeDomain)
|
|
1041
|
+
.hideHelp())
|
|
1039
1042
|
.addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp())
|
|
1040
1043
|
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())
|
|
1041
1044
|
.version(packageJson.version, '-v, --version', 'Output the current version')
|
package/package.json
CHANGED
|
@@ -6,16 +6,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
6
6
|
m.style.cssText =
|
|
7
7
|
'max-width:60%;min-width: 80px;padding:0 12px;height: 32px;color: rgb(255, 255, 255);line-height: 32px;text-align: center;border-radius: 8px;position: fixed; bottom:24px;right: 28px;z-index: 999999;background: rgba(0, 0, 0,.8);font-size: 13px;';
|
|
8
8
|
document.body.appendChild(m);
|
|
9
|
-
setTimeout(function() {
|
|
9
|
+
setTimeout(function () {
|
|
10
10
|
const d = 0.5;
|
|
11
11
|
m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
|
|
12
12
|
m.style.opacity = '0';
|
|
13
|
-
setTimeout(function() {
|
|
13
|
+
setTimeout(function () {
|
|
14
14
|
document.body.removeChild(m);
|
|
15
15
|
}, d * 1000);
|
|
16
16
|
}, 3000);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
window.pakeToast = pakeToast;
|
|
20
|
-
|
|
21
20
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const shortcuts = {
|
|
2
|
-
'ArrowUp': () => scrollTo(0, 0),
|
|
3
|
-
'ArrowDown': () => scrollTo(0, document.body.scrollHeight),
|
|
4
2
|
'[': () => window.history.back(),
|
|
5
3
|
']': () => window.history.forward(),
|
|
6
|
-
'r': () => window.location.reload(),
|
|
7
4
|
'-': () => zoomOut(),
|
|
8
5
|
'=': () => zoomIn(),
|
|
9
6
|
'+': () => zoomIn(),
|
|
10
|
-
|
|
7
|
+
0: () => setZoom('100%'),
|
|
8
|
+
r: () => window.location.reload(),
|
|
9
|
+
ArrowUp: () => scrollTo(0, 0),
|
|
10
|
+
ArrowDown: () => scrollTo(0, document.body.scrollHeight),
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
function setZoom(zoom) {
|
|
@@ -22,11 +22,11 @@ function zoomCommon(zoomChange) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function zoomIn() {
|
|
25
|
-
zoomCommon(
|
|
25
|
+
zoomCommon(currentZoom => `${Math.min(parseInt(currentZoom) + 10, 200)}%`);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function zoomOut() {
|
|
29
|
-
zoomCommon(
|
|
29
|
+
zoomCommon(currentZoom => `${Math.max(parseInt(currentZoom) - 10, 30)}%`);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function handleShortcut(event) {
|
|
@@ -38,11 +38,14 @@ function handleShortcut(event) {
|
|
|
38
38
|
|
|
39
39
|
// Judgment of file download.
|
|
40
40
|
function isDownloadLink(url) {
|
|
41
|
+
// prettier-ignore
|
|
41
42
|
const fileExtensions = [
|
|
42
|
-
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx',
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
43
|
+
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx',
|
|
44
|
+
'fla', 'flv', 'gif', 'gz', 'gzip', 'ico', 'iso', 'indd', 'jar', 'jpeg',
|
|
45
|
+
'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg', 'mpeg', 'msi', 'odt',
|
|
46
|
+
'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss',
|
|
47
|
+
'svg', 'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp',
|
|
48
|
+
'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip', 'json', 'yaml', '7zip', 'mkv'
|
|
46
49
|
];
|
|
47
50
|
const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i');
|
|
48
51
|
return downloadLinkPattern.test(url);
|
|
@@ -75,7 +78,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
75
78
|
appWindow.startDragging().then();
|
|
76
79
|
});
|
|
77
80
|
|
|
78
|
-
domEl.addEventListener('mousedown',
|
|
81
|
+
domEl.addEventListener('mousedown', e => {
|
|
79
82
|
e.preventDefault();
|
|
80
83
|
if (e.buttons === 1 && e.detail !== 2) {
|
|
81
84
|
appWindow.startDragging().then();
|
|
@@ -83,13 +86,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
83
86
|
});
|
|
84
87
|
|
|
85
88
|
domEl.addEventListener('dblclick', () => {
|
|
86
|
-
appWindow.isFullscreen().then(
|
|
89
|
+
appWindow.isFullscreen().then(fullscreen => {
|
|
87
90
|
appWindow.setFullscreen(!fullscreen).then();
|
|
88
91
|
});
|
|
89
92
|
});
|
|
90
93
|
|
|
91
94
|
if (window['pakeConfig']?.disabled_web_shortcuts !== true) {
|
|
92
|
-
document.addEventListener('keyup',
|
|
95
|
+
document.addEventListener('keyup', event => {
|
|
93
96
|
if (/windows|linux/i.test(navigator.userAgent) && event.ctrlKey) {
|
|
94
97
|
handleShortcut(event);
|
|
95
98
|
}
|
|
@@ -103,7 +106,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
103
106
|
function collectUrlToBlobs() {
|
|
104
107
|
const backupCreateObjectURL = window.URL.createObjectURL;
|
|
105
108
|
window.blobToUrlCaches = new Map();
|
|
106
|
-
window.URL.createObjectURL =
|
|
109
|
+
window.URL.createObjectURL = blob => {
|
|
107
110
|
const url = backupCreateObjectURL.call(window.URL, blob);
|
|
108
111
|
window.blobToUrlCaches.set(url, blob);
|
|
109
112
|
return url;
|
|
@@ -111,7 +114,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
function convertBlobUrlToBinary(blobUrl) {
|
|
114
|
-
return new Promise(
|
|
117
|
+
return new Promise(resolve => {
|
|
115
118
|
const blob = window.blobToUrlCaches.get(blobUrl);
|
|
116
119
|
const reader = new FileReader();
|
|
117
120
|
|
|
@@ -145,7 +148,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
function downloadFromBlobUrl(blobUrl, filename) {
|
|
148
|
-
convertBlobUrlToBinary(blobUrl).then(
|
|
151
|
+
convertBlobUrlToBinary(blobUrl).then(binary => {
|
|
149
152
|
invoke('download_file_by_binary', {
|
|
150
153
|
params: {
|
|
151
154
|
filename,
|
|
@@ -155,37 +158,40 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
155
158
|
});
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
// detect blob download by createElement("a")
|
|
161
|
+
// detect blob download by createElement("a")
|
|
159
162
|
function detectDownloadByCreateAnchor() {
|
|
160
163
|
const createEle = document.createElement;
|
|
161
|
-
document.createElement =
|
|
164
|
+
document.createElement = el => {
|
|
162
165
|
if (el !== 'a') return createEle.call(document, el);
|
|
163
166
|
const anchorEle = createEle.call(document, el);
|
|
164
167
|
|
|
165
168
|
// use addEventListener to avoid overriding the original click event.
|
|
166
|
-
anchorEle.addEventListener(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
anchorEle.addEventListener(
|
|
170
|
+
'click',
|
|
171
|
+
e => {
|
|
172
|
+
const url = anchorEle.href;
|
|
173
|
+
const filename = anchorEle.download || getFilenameFromUrl(url);
|
|
174
|
+
if (window.blobToUrlCaches.has(url)) {
|
|
175
|
+
downloadFromBlobUrl(url, filename);
|
|
176
|
+
// case: download from dataURL -> convert dataURL ->
|
|
177
|
+
} else if (url.startsWith('data:')) {
|
|
178
|
+
downloadFromDataUri(url, filename);
|
|
179
|
+
} else if (isDownloadLink(url) || anchorEle.hostname !== window.location.host) {
|
|
180
|
+
handleExternalLink(e, url);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
true,
|
|
184
|
+
);
|
|
178
185
|
|
|
179
186
|
return anchorEle;
|
|
180
187
|
};
|
|
181
188
|
}
|
|
182
189
|
|
|
183
|
-
const isExternalLink =
|
|
190
|
+
const isExternalLink = link => window.location.host !== link.host;
|
|
184
191
|
// process special download protocol['data:','blob:']
|
|
185
|
-
const isSpecialDownload =
|
|
192
|
+
const isSpecialDownload = url => ['blob', 'data'].some(protocol => url.startsWith(protocol));
|
|
186
193
|
|
|
187
|
-
const isDownloadRequired = (url, anchorElement, e) =>
|
|
188
|
-
anchorElement.download || e.metaKey || e.ctrlKey || isDownloadLink(url);
|
|
194
|
+
const isDownloadRequired = (url, anchorElement, e) => anchorElement.download || e.metaKey || e.ctrlKey || isDownloadLink(url);
|
|
189
195
|
|
|
190
196
|
const handleExternalLink = (e, url) => {
|
|
191
197
|
e.preventDefault();
|
|
@@ -197,7 +203,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
197
203
|
invoke('download_file', { params: { url, filename } });
|
|
198
204
|
};
|
|
199
205
|
|
|
200
|
-
const detectAnchorElementClick =
|
|
206
|
+
const detectAnchorElementClick = e => {
|
|
201
207
|
const anchorElement = e.target.closest('a');
|
|
202
208
|
if (anchorElement && anchorElement.href) {
|
|
203
209
|
anchorElement.target = '_self';
|
|
@@ -226,7 +232,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
226
232
|
|
|
227
233
|
// Rewrite the window.open function.
|
|
228
234
|
const originalWindowOpen = window.open;
|
|
229
|
-
window.open = function(url, name, specs) {
|
|
235
|
+
window.open = function (url, name, specs) {
|
|
230
236
|
// Apple login and google login
|
|
231
237
|
if (name === 'AppleAuthentication') {
|
|
232
238
|
//do nothing
|
|
@@ -249,10 +255,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
249
255
|
}
|
|
250
256
|
|
|
251
257
|
// Fix Chinese input method "Enter" on Safari
|
|
252
|
-
document.addEventListener(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
258
|
+
document.addEventListener(
|
|
259
|
+
'keydown',
|
|
260
|
+
e => {
|
|
261
|
+
if (e.keyCode === 229) e.stopPropagation();
|
|
262
|
+
},
|
|
263
|
+
true,
|
|
264
|
+
);
|
|
256
265
|
});
|
|
257
266
|
|
|
258
267
|
function setDefaultZoom() {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"copyright": "",
|
|
9
9
|
"deb": {
|
|
10
10
|
"depends": ["curl", "wget"],
|
|
11
|
-
"files": {"/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"}
|
|
11
|
+
"files": { "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop" }
|
|
12
12
|
},
|
|
13
13
|
"externalBin": [],
|
|
14
14
|
"longDescription": "",
|