pake-cli 2.4.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/README.md CHANGED
@@ -279,139 +279,146 @@ Pake's development can not be without these Hackers. They contributed a lot of c
279
279
  </a>
280
280
  </td>
281
281
  <td align="center">
282
- <a href="https://github.com/exposir">
283
- <img src="https://avatars.githubusercontent.com/u/33340988?v=4" width="90;" alt="exposir"/>
282
+ <a href="https://github.com/QingZ11">
283
+ <img src="https://avatars.githubusercontent.com/u/38887077?v=4" width="90;" alt="QingZ11"/>
284
284
  <br />
285
- <sub><b>孟世博</b></sub>
285
+ <sub><b>Steam</b></sub>
286
286
  </a>
287
287
  </td>
288
288
  <td align="center">
289
- <a href="https://github.com/QingZ11">
290
- <img src="https://avatars.githubusercontent.com/u/38887077?v=4" width="90;" alt="QingZ11"/>
289
+ <a href="https://github.com/exposir">
290
+ <img src="https://avatars.githubusercontent.com/u/33340988?v=4" width="90;" alt="exposir"/>
291
291
  <br />
292
- <sub><b>Steam</b></sub>
292
+ <sub><b>孟世博</b></sub>
293
293
  </a>
294
294
  </td>
295
295
  <td align="center">
296
- <a href="https://github.com/hetz">
297
- <img src="https://avatars.githubusercontent.com/u/820141?v=4" width="90;" alt="hetz"/>
296
+ <a href="https://github.com/2nthony">
297
+ <img src="https://avatars.githubusercontent.com/u/19513289?v=4" width="90;" alt="2nthony"/>
298
298
  <br />
299
- <sub><b>贺天卓</b></sub>
299
+ <sub><b>2nthony</b></sub>
300
300
  </a>
301
301
  </td>
302
302
  <td align="center">
303
- <a href="https://github.com/piaoyidage">
304
- <img src="https://avatars.githubusercontent.com/u/5135405?v=4" width="90;" alt="piaoyidage"/>
303
+ <a href="https://github.com/ACGNnsj">
304
+ <img src="https://avatars.githubusercontent.com/u/22112141?v=4" width="90;" alt="ACGNnsj"/>
305
305
  <br />
306
- <sub><b>Ranger</b></sub>
306
+ <sub><b>Null</b></sub>
307
307
  </a>
308
308
  </td></tr>
309
309
  <tr>
310
310
  <td align="center">
311
- <a href="https://github.com/liusishan">
312
- <img src="https://avatars.githubusercontent.com/u/33129823?v=4" width="90;" alt="liusishan"/>
311
+ <a href="https://github.com/imabutahersiddik">
312
+ <img src="https://avatars.githubusercontent.com/u/138387257?v=4" width="90;" alt="imabutahersiddik"/>
313
313
  <br />
314
- <sub><b>Liusishan</b></sub>
314
+ <sub><b>Abu Taher Siddik</b></sub>
315
315
  </a>
316
316
  </td>
317
317
  <td align="center">
318
- <a href="https://github.com/liudonghua123">
319
- <img src="https://avatars.githubusercontent.com/u/2276718?v=4" width="90;" alt="liudonghua123"/>
318
+ <a href="https://github.com/kidylee">
319
+ <img src="https://avatars.githubusercontent.com/u/841310?v=4" width="90;" alt="kidylee"/>
320
320
  <br />
321
- <sub><b>Liudonghua</b></sub>
321
+ <sub><b>An Li</b></sub>
322
322
  </a>
323
323
  </td>
324
324
  <td align="center">
325
- <a href="https://github.com/lakca">
326
- <img src="https://avatars.githubusercontent.com/u/16255922?v=4" width="90;" alt="lakca"/>
325
+ <a href="https://github.com/nekomeowww">
326
+ <img src="https://avatars.githubusercontent.com/u/11081491?v=4" width="90;" alt="nekomeowww"/>
327
327
  <br />
328
- <sub><b>Null</b></sub>
328
+ <sub><b>Ayaka Neko</b></sub>
329
329
  </a>
330
330
  </td>
331
331
  <td align="center">
332
- <a href="https://github.com/houhoz">
333
- <img src="https://avatars.githubusercontent.com/u/19684376?v=4" width="90;" alt="houhoz"/>
332
+ <a href="https://github.com/turkyden">
333
+ <img src="https://avatars.githubusercontent.com/u/24560160?v=4" width="90;" alt="turkyden"/>
334
334
  <br />
335
- <sub><b>Hyzhao</b></sub>
335
+ <sub><b>Dengju Deng</b></sub>
336
336
  </a>
337
337
  </td>
338
338
  <td align="center">
339
- <a href="https://github.com/geekvest">
340
- <img src="https://avatars.githubusercontent.com/u/126322776?v=4" width="90;" alt="geekvest"/>
339
+ <a href="https://github.com/Fechin">
340
+ <img src="https://avatars.githubusercontent.com/u/2541482?v=4" width="90;" alt="Fechin"/>
341
341
  <br />
342
- <sub><b>Null</b></sub>
342
+ <sub><b>Fechin</b></sub>
343
343
  </a>
344
344
  </td>
345
345
  <td align="center">
346
- <a href="https://github.com/princemaple">
347
- <img src="https://avatars.githubusercontent.com/u/1329716?v=4" width="90;" alt="princemaple"/>
346
+ <a href="https://github.com/eltociear">
347
+ <img src="https://avatars.githubusercontent.com/u/22633385?v=4" width="90;" alt="eltociear"/>
348
348
  <br />
349
- <sub><b>Po Chen</b></sub>
349
+ <sub><b>Ikko Eltociear Ashimine</b></sub>
350
350
  </a>
351
351
  </td>
352
352
  <td align="center">
353
- <a href="https://github.com/Milo123459">
354
- <img src="https://avatars.githubusercontent.com/u/50248166?v=4" width="90;" alt="Milo123459"/>
353
+ <a href="https://github.com/droid-Q">
354
+ <img src="https://avatars.githubusercontent.com/u/708277?v=4" width="90;" alt="droid-Q"/>
355
355
  <br />
356
- <sub><b>Milo</b></sub>
356
+ <sub><b>Jiaqi Gu</b></sub>
357
357
  </a>
358
358
  </td></tr>
359
359
  <tr>
360
360
  <td align="center">
361
- <a href="https://github.com/eltociear">
362
- <img src="https://avatars.githubusercontent.com/u/22633385?v=4" width="90;" alt="eltociear"/>
361
+ <a href="https://github.com/Milo123459">
362
+ <img src="https://avatars.githubusercontent.com/u/50248166?v=4" width="90;" alt="Milo123459"/>
363
363
  <br />
364
- <sub><b>Ikko Eltociear Ashimine</b></sub>
364
+ <sub><b>Milo</b></sub>
365
365
  </a>
366
366
  </td>
367
367
  <td align="center">
368
- <a href="https://github.com/Fechin">
369
- <img src="https://avatars.githubusercontent.com/u/2541482?v=4" width="90;" alt="Fechin"/>
368
+ <a href="https://github.com/princemaple">
369
+ <img src="https://avatars.githubusercontent.com/u/1329716?v=4" width="90;" alt="princemaple"/>
370
370
  <br />
371
- <sub><b>Fechin</b></sub>
371
+ <sub><b>Po Chen</b></sub>
372
372
  </a>
373
373
  </td>
374
374
  <td align="center">
375
- <a href="https://github.com/turkyden">
376
- <img src="https://avatars.githubusercontent.com/u/24560160?v=4" width="90;" alt="turkyden"/>
375
+ <a href="https://github.com/geekvest">
376
+ <img src="https://avatars.githubusercontent.com/u/126322776?v=4" width="90;" alt="geekvest"/>
377
377
  <br />
378
- <sub><b>Dengju Deng</b></sub>
378
+ <sub><b>Null</b></sub>
379
379
  </a>
380
380
  </td>
381
381
  <td align="center">
382
- <a href="https://github.com/nekomeowww">
383
- <img src="https://avatars.githubusercontent.com/u/11081491?v=4" width="90;" alt="nekomeowww"/>
382
+ <a href="https://github.com/houhoz">
383
+ <img src="https://avatars.githubusercontent.com/u/19684376?v=4" width="90;" alt="houhoz"/>
384
384
  <br />
385
- <sub><b>Ayaka Neko</b></sub>
385
+ <sub><b>Hyzhao</b></sub>
386
386
  </a>
387
387
  </td>
388
388
  <td align="center">
389
- <a href="https://github.com/kidylee">
390
- <img src="https://avatars.githubusercontent.com/u/841310?v=4" width="90;" alt="kidylee"/>
389
+ <a href="https://github.com/lakca">
390
+ <img src="https://avatars.githubusercontent.com/u/16255922?v=4" width="90;" alt="lakca"/>
391
391
  <br />
392
- <sub><b>An Li</b></sub>
392
+ <sub><b>Null</b></sub>
393
393
  </a>
394
394
  </td>
395
395
  <td align="center">
396
- <a href="https://github.com/imabutahersiddik">
397
- <img src="https://avatars.githubusercontent.com/u/138387257?v=4" width="90;" alt="imabutahersiddik"/>
396
+ <a href="https://github.com/liudonghua123">
397
+ <img src="https://avatars.githubusercontent.com/u/2276718?v=4" width="90;" alt="liudonghua123"/>
398
398
  <br />
399
- <sub><b>Abu Taher Siddik</b></sub>
399
+ <sub><b>Liudonghua</b></sub>
400
400
  </a>
401
401
  </td>
402
402
  <td align="center">
403
- <a href="https://github.com/ACGNnsj">
404
- <img src="https://avatars.githubusercontent.com/u/22112141?v=4" width="90;" alt="ACGNnsj"/>
403
+ <a href="https://github.com/liusishan">
404
+ <img src="https://avatars.githubusercontent.com/u/33129823?v=4" width="90;" alt="liusishan"/>
405
405
  <br />
406
- <sub><b>Null</b></sub>
406
+ <sub><b>Liusishan</b></sub>
407
407
  </a>
408
408
  </td></tr>
409
409
  <tr>
410
410
  <td align="center">
411
- <a href="https://github.com/2nthony">
412
- <img src="https://avatars.githubusercontent.com/u/19513289?v=4" width="90;" alt="2nthony"/>
411
+ <a href="https://github.com/piaoyidage">
412
+ <img src="https://avatars.githubusercontent.com/u/5135405?v=4" width="90;" alt="piaoyidage"/>
413
413
  <br />
414
- <sub><b>2nthony</b></sub>
414
+ <sub><b>Ranger</b></sub>
415
+ </a>
416
+ </td>
417
+ <td align="center">
418
+ <a href="https://github.com/hetz">
419
+ <img src="https://avatars.githubusercontent.com/u/820141?v=4" width="90;" alt="hetz"/>
420
+ <br />
421
+ <sub><b>贺天卓</b></sub>
415
422
  </a>
416
423
  </td></tr>
417
424
  </table>
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.4.0";
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,16 +465,18 @@ 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 = `" + fileContent + "`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });";
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;
474
476
  }
475
477
 
476
478
  async function mergeConfig(url, options, tauriConf) {
477
- const { width, height, fullscreen, hideTitleBar, alwaysOnTop, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, iterCopyFile, identifier, name, resizable = true, inject, safeDomain, } = options;
479
+ const { width, height, fullscreen, hideTitleBar, alwaysOnTop, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, safeDomain, } = options;
478
480
  const { platform } = process;
479
481
  // Set Windows parameters.
480
482
  const tauriConfWindowOptions = {
@@ -499,7 +501,7 @@ async function mergeConfig(url, options, tauriConf) {
499
501
  const dirName = path.dirname(url);
500
502
  const distDir = path.join(npmDirectory, 'dist');
501
503
  const distBakDir = path.join(npmDirectory, 'dist_bak');
502
- if (!iterCopyFile) {
504
+ if (!useLocalFile) {
503
505
  const urlPath = path.join(distDir, fileName);
504
506
  await fsExtra.copy(url, urlPath);
505
507
  }
@@ -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
  }
@@ -838,7 +840,7 @@ const DEFAULT_PAKE_OPTIONS = {
838
840
  showSystemTray: false,
839
841
  multiArch: false,
840
842
  targets: 'deb',
841
- iterCopyFile: false,
843
+ useLocalFile: false,
842
844
  systemTrayIcon: '',
843
845
  debug: false,
844
846
  inject: [],
@@ -1014,27 +1016,29 @@ ${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')
1024
1023
  .option('--icon <string>', 'Application icon', DEFAULT_PAKE_OPTIONS.icon)
1025
1024
  .option('--width <number>', 'Window width', validateNumberInput, DEFAULT_PAKE_OPTIONS.width)
1026
1025
  .option('--height <number>', 'Window height', validateNumberInput, DEFAULT_PAKE_OPTIONS.height)
1026
+ .option('--use-local-file', 'Use local file packaging', DEFAULT_PAKE_OPTIONS.useLocalFile)
1027
1027
  .option('--fullscreen', 'Start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
1028
1028
  .option('--hide-title-bar', 'Only for Mac, hide title bar', DEFAULT_PAKE_OPTIONS.hideTitleBar)
1029
1029
  .option('--activation-shortcut <string>', 'Shortcut key to active App', DEFAULT_PAKE_OPTIONS.activationShortcut)
1030
1030
  .option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch)
1031
1031
  .option('--inject [injects...]', 'Injection of .js or .css Files', DEFAULT_PAKE_OPTIONS.inject)
1032
- .option('--safe-domain [domains...]', 'Domains that Require Security Configuration"', DEFAULT_PAKE_OPTIONS.safeDomain)
1033
1032
  .option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug)
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').default(DEFAULT_PAKE_OPTIONS.disabledWebShortcuts).hideHelp())
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())
1038
1042
  .addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp())
1039
1043
  .addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())
1040
1044
  .version(packageJson.version, '-v, --version', 'Output the current version')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。",
5
5
  "engines": {
6
6
  "node": ">=16.0.0"
@@ -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
- '0': () => setZoom('100%'),
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((currentZoom) => `${Math.min(parseInt(currentZoom) + 10, 200)}%`);
25
+ zoomCommon(currentZoom => `${Math.min(parseInt(currentZoom) + 10, 200)}%`);
26
26
  }
27
27
 
28
28
  function zoomOut() {
29
- zoomCommon((currentZoom) => `${Math.max(parseInt(currentZoom) - 10, 30)}%`);
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', 'fla', 'flv', 'gif', 'gz', 'gzip',
43
- 'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg',
44
- 'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg',
45
- 'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip',
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', (e) => {
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((fullscreen) => {
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', (event) => {
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 = (blob) => {
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((resolve) => {
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((binary) => {
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 = (el) => {
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('click', (e) => {
167
- const url = anchorEle.href;
168
- const filename = anchorEle.download || getFilenameFromUrl(url);
169
- if (window.blobToUrlCaches.has(url)) {
170
- downloadFromBlobUrl(url, filename);
171
- // case: download from dataURL -> convert dataURL ->
172
- } else if (url.startsWith('data:')) {
173
- downloadFromDataUri(url, filename);
174
- } else if (isDownloadLink(url) || anchorEle.hostname !== window.location.host) {
175
- handleExternalLink(e, url);
176
- }
177
- }, true);
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 = (link) => window.location.host !== link.host;
190
+ const isExternalLink = link => window.location.host !== link.host;
184
191
  // process special download protocol['data:','blob:']
185
- const isSpecialDownload = (url) => ['blob', 'data'].some(protocol => url.startsWith(protocol));
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 = (e) => {
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('keydown', (e) => {
253
- if (e.keyCode === 229) e.stopPropagation();
254
- }, true);
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": "",