Socket
Socket
Sign inDemoInstall

pake-cli

Package Overview
Dependencies
Maintainers
3
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pake-cli - npm Package Compare versions

Comparing version 2.1.12 to 2.2.0

dist/cli.dev.js

2

dist/cli.js

@@ -23,3 +23,3 @@ import chalk from 'chalk';

var name = "pake-cli";
var version = "2.1.12";
var version = "2.2.0";
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";

@@ -26,0 +26,0 @@ var engines = {

{
"name": "pake-cli",
"version": "2.1.12",
"version": "2.2.0",
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。",

@@ -5,0 +5,0 @@ "engines": {

@@ -62,3 +62,3 @@ <h4 align="right"><strong>English</strong> | <a href="https://github.com/tw93/Pake/blob/master/README_CN.md">简体中文</a></h4>

<td><img src=https://cdn.fliggy.com/upic/Ld5ZCJ.png width=600/></td>
<td><img src=https://cdn.fliggy.com/upic/7QUfi3.png width=600/></td>
<td><img src=https://gw.alipayobjects.com/zos/k/95/bcGBut.png width=600/></td>
</tr>

@@ -79,3 +79,3 @@ <tr>

<td><img src=https://cdn.fliggy.com/upic/iz3mtQ.png width=600/></td>
<td><img src=https://cdn.fliggy.com/upic/s4ZLNC.jpg width=600/></td>
<td><img src=https://gw.alipayobjects.com/zos/k/pn/1.jpg width=600/></td>
</tr>

@@ -96,3 +96,3 @@ <tr>

<td><img src=https://cdn.fliggy.com/upic/nYEKqN.jpg width=600/></td>
<td><img src=https://cdn.fliggy.com/upic/0C9lju.jpg width=600/></td>
<td><img src=https://gw.alipayobjects.com/zos/k/r7/0C9lju.jpg width=600/></td>
</tr>

@@ -129,3 +129,3 @@ <tr>

<td><img src=https://gw.alipayobjects.com/zos/k/30/RoUSUf.png width=600/></td>
<td><img src=https://cdn.fliggy.com/upic/yJVwyi.png width=600/></td>
<td><img src=https://gw.alipayobjects.com/zos/k/89/yJVwyi.png width=600/></td>
</tr>

@@ -205,3 +205,3 @@ </table>

## Developer
## Developers

@@ -335,2 +335,9 @@ Pake's development can not be without these Hackers. They contributed a lot of capabilities for Pake. Also, welcome to follow them! ❤️

<td align="center">
<a href="https://github.com/Milo123459">
<img src="https://avatars.githubusercontent.com/u/50248166?v=4" width="90;" alt="Milo123459"/>
<br />
<sub><b>Milo</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/princemaple">

@@ -355,3 +362,4 @@ <img src="https://avatars.githubusercontent.com/u/1329716?v=4" width="90;" alt="princemaple"/>

</a>
</td>
</td></tr>
<tr>
<td align="center">

@@ -363,4 +371,3 @@ <a href="https://github.com/liusishan">

</a>
</td></tr>
<tr>
</td>
<td align="center">

@@ -367,0 +374,0 @@ <a href="https://github.com/piaoyidage">

@@ -99,3 +99,3 @@ document.addEventListener('DOMContentLoaded', () => {

urlSubmit.onclick = function () {
urlSubmit.onclick = function() {
const url = urlInput.value;

@@ -107,7 +107,7 @@ if (url) {

urlClose.onclick = function () {
urlClose.onclick = function() {
urlModal.style.display = 'none';
};
urlInput.addEventListener('keydown', function (event) {
urlInput.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {

@@ -121,3 +121,3 @@ const url = urlInput.value;

document.addEventListener('keydown', function (event) {
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape' && urlModal.style.display === 'block') {

@@ -128,3 +128,3 @@ urlModal.style.display = 'none';

window.showUrlModal = function () {
window.showUrlModal = function() {
urlModal.style.display = 'block';

@@ -141,7 +141,7 @@ urlInput.focus();

document.body.appendChild(m);
setTimeout(function () {
setTimeout(function() {
const d = 0.5;
m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
m.style.opacity = '0';
setTimeout(function () {
setTimeout(function() {
document.body.removeChild(m);

@@ -154,33 +154,2 @@ }, d * 1000);

// chatgpt supports unlimited times of GPT4-Mobile
if (window.location.hostname === 'chat.openai.com') {
const originFetch = fetch;
window.fetch = (url, options) => {
return originFetch(url, options).then(async response => {
if (url.indexOf('/backend-api/models') === -1) {
return response;
}
const responseClone = response.clone();
let res = await responseClone.json();
res.models = res.models.map(m => {
m.tags = m.tags.filter(t => {
return t !== 'mobile';
});
if (m.slug === 'gpt-4-mobile') {
res.categories.push({
browsing_model: null,
category: 'gpt_4',
code_interpreter_model: null,
default_model: 'gpt-4-mobile',
human_category_name: 'GPT-4-Mobile',
plugins_model: null,
subscription_level: 'plus',
});
}
return m;
});
return new Response(JSON.stringify(res), response);
});
};
}
});
const shortcuts = {
ArrowUp: () => scrollTo(0, 0),
ArrowDown: () => scrollTo(0, document.body.scrollHeight),
// Don't use command + ArrowLeft or command + ArrowRight
// When editing text in page, it causes unintended page navigation.
// ArrowLeft: () => window.history.back(),
// ArrowRight: () => window.history.forward(),
'ArrowUp': () => scrollTo(0, 0),
'ArrowDown': () => scrollTo(0, document.body.scrollHeight),
'[': () => window.history.back(),
']': () => window.history.forward(),
r: () => window.location.reload(),
'r': () => window.location.reload(),
'-': () => zoomOut(),
'=': () => zoomIn(),
'+': () => zoomIn(),
0: () => setZoom('100%'),
'0': () => setZoom('100%'),
};

@@ -43,42 +39,2 @@

//这里参考 ChatGPT 的代码
const uid = () => window.crypto.getRandomValues(new Uint32Array(1))[0];
function transformCallback(callback = () => {}, once = false) {
const identifier = uid();
const prop = `_${identifier}`;
Object.defineProperty(window, prop, {
value: (result) => {
if (once) {
Reflect.deleteProperty(window, prop);
}
return callback(result);
},
writable: false,
configurable: true,
});
return identifier;
}
async function invoke(cmd, args) {
return new Promise((resolve, reject) => {
if (!window.__TAURI_POST_MESSAGE__)
reject('__TAURI_POST_MESSAGE__ does not exist~');
const callback = transformCallback((e) => {
resolve(e);
Reflect.deleteProperty(window, `_${error}`);
}, true);
const error = transformCallback((e) => {
reject(e);
Reflect.deleteProperty(window, `_${callback}`);
}, true);
window.__TAURI_POST_MESSAGE__({
cmd,
callback,
error,
...args,
});
});
}
// Judgment of file download.

@@ -109,2 +65,3 @@ function isDownloadLink(url) {

const appWindow = tauri.window.appWindow;
const invoke = tauri.tauri.invoke;

@@ -142,38 +99,32 @@ const topDom = document.createElement('div');

const isExternalLink = (url, host) => window.location.host !== host;
const isDownloadRequired = (url, anchorElement, e) =>
anchorElement.download || e.metaKey || e.ctrlKey || isDownloadLink(url);
const handleExternalLink = (e, url) => {
e.preventDefault();
tauri.shell.open(url);
};
const handleDownloadLink = (e, url, filename) => {
e.preventDefault();
invoke('download_file', { params: { url, filename } });
};
const detectAnchorElementClick = (e) => {
const anchorElement = e.target.closest('a');
if (anchorElement && anchorElement.href) {
const target = anchorElement.target;
anchorElement.target = '_self';
const hrefUrl = new URL(anchorElement.href);
const absoluteUrl = hrefUrl.href;
let filename = anchorElement.download || getFilenameFromUrl(absoluteUrl);
// Handling external link redirection.
if (
window.location.host !== hrefUrl.host &&
(target === '_blank' || target === '_new' || externalTargetLink())
) {
e.preventDefault && e.preventDefault();
tauri.shell.open(absoluteUrl);
if (isExternalLink(absoluteUrl, hrefUrl.host) && (['_blank', '_new'].includes(anchorElement.target) || externalTargetLink())) {
handleExternalLink(e, absoluteUrl);
return;
}
let filename = anchorElement.download || getFilenameFromUrl(absoluteUrl);
// Process download links for Rust to handle.
// If the download attribute is set, the download attribute is used as the file name.
if (
(anchorElement.download ||
e.metaKey ||
e.ctrlKey ||
isDownloadLink(absoluteUrl)) &&
!externalDownLoadLink()
) {
e.preventDefault();
invoke('download_file', {
params: {
url: absoluteUrl,
filename,
},
});
if (isDownloadRequired(absoluteUrl, anchorElement, e) && !externalDownLoadLink()) {
handleDownloadLink(e, absoluteUrl, filename);
}

@@ -212,2 +163,8 @@ }

}
// Fix Chinese input method "Enter" on Safari
document.addEventListener('keydown', (e) => {
if (e.keyCode === 229) e.stopPropagation();
}, true);
});

@@ -224,24 +181,5 @@

const urlPath = new URL(url).pathname;
const filename = urlPath.substring(urlPath.lastIndexOf('/') + 1);
return filename;
return urlPath.substring(urlPath.lastIndexOf('/') + 1);
}
function removeUrlParameters(url) {
const parsedUrl = new URL(url);
parsedUrl.search = '';
return parsedUrl.toString();
}
// Toggle video playback when the window is hidden.
function toggleVideoPlayback(pause) {
const videos = document.getElementsByTagName('video');
for (const video of videos) {
if (pause) {
video.pause();
} else {
video.play();
}
}
}
// Collect blob urls to blob by overriding window.URL.createObjectURL

@@ -270,31 +208,47 @@ function collectUrlToBlobs() {

function downloadFromBlobUrl(blobUrl, filename) {
const tauri = window.__TAURI__;
convertBlobUrlToBinary(blobUrl).then((binary) => {
console.log('binary', binary);
tauri.fs.writeBinaryFile(filename, binary, {
async function downloadFromBlobUrl(blobUrl, filename) {
try {
const tauri = window.__TAURI__;
const binary = await convertBlobUrlToBinary(blobUrl);
await tauri.fs.writeBinaryFile(filename, binary, {
dir: tauri.fs.BaseDirectory.Download,
}).then(() => {
window.pakeToast('Download successful, saved to download directory~');
});
});
const lang = getSystemLanguage();
window.pakeToast(lang === 'en' ? 'Download successful, saved to download directory~' : '下载成功,已保存到下载目录~');
} catch (error) {
console.error('Error downloading from Blob URL:', error);
}
}
// detect blob download by createElement("a")
function detectDownloadByCreateAnchor() {
const createEle = document.createElement;
document.createElement = (el) => {
if (el !== 'a') return createEle.call(document, el);
const anchorEle = createEle.call(document, el);
const originalCreateElement = document.createElement;
// use addEventListener to avoid overriding the original click event.
anchorEle.addEventListener('click', () => {
const url = anchorEle.href;
if (window.blobToUrlCaches.has(url)) {
downloadFromBlobUrl(url, anchorEle.download || getFilenameFromUrl(url));
}
});
document.createElement = function(el, ...args) {
const element = originalCreateElement.call(this, el, ...args);
return anchorEle;
if (el === 'a') {
element.addEventListener('click', (event) => {
const url = element.href;
if (window.blobToUrlCaches.has(url)) {
// Prevent default 'click' event if a blob URL is detected
event.preventDefault();
const filename = element.download || getFilenameFromUrl(url);
downloadFromBlobUrl(url, filename);
}
});
}
return element;
};
}
// Determine the language of the current system.
function getSystemLanguage() {
const lang = navigator.language.substr(0, 2);
return lang === 'ch' ? 'ch' : 'en';
}

@@ -174,2 +174,3 @@ window.addEventListener('DOMContentLoaded', _event => {

#react-root a[href*="/i/communitynotes"][role="link"][aria-label],
#react-root a[role="link"][aria-label="Communities"],
#react-root a[href*="/i/verified-orgs-signup"][role="link"][aria-label] {

@@ -176,0 +177,0 @@ display: none !important;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc