Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

chore: update sponsors.svg CDN URL to jsdelivr @main

Tw933f62646fcd5d
diff --git a/README.md b/README.md
index d249c423..ee391dff 100644
--- a/README.md
+++ b/README.md
@@ -204,4 +204,4 @@ Pake's development can not be without these Hackers. They contributed a lot of c
1. I have two cats, TangYuan and Coke. If you think Pake delights your life, you can feed them <a href="https://miaoyan.app/cats.html?name=Pake" target="_blank">food 🥩</a>.
-<a href="https://miaoyan.app/cats.html?name=Pake"><img src="https://rawcdn.githack.com/tw93/MiaoYan/vercel/assets/sponsors.svg" width="1000" loading="lazy" /></a> 2. If you like Pake, you can star it on GitHub. Also, welcome to [recommend Pake](https://twitter.com/intent/tweet?url=https://github.com/tw93/Pake&text=Pake%20-%20Turn%20any%20webpage%20into%20a%20desktop%20app%20with%20one%20command.%20Nearly%2020x%20smaller%20than%20Electron%20packages,%20supports%20macOS%20Windows%20Linux) to your friends. 3. You can follow my [Twitter](https://twitter.com/HiTw93) to get the latest news of Pake or join our [Telegram](https://t.me/+GclQS9ZnxyI2ODQ1) chat group. 4. I hope that you enjoy playing with it. Let us know if you find a website that would be great for a Mac App!
+<a href="https://miaoyan.app/cats.html?name=Pake"><img src="https://cdn.jsdelivr.net/gh/tw93/MiaoYan@main/assets/sponsors.svg" width="1000" loading="lazy" /></a> 2. If you like Pake, you can star it on GitHub. Also, welcome to [recommend Pake](https://twitter.com/intent/tweet?url=https://github.com/tw93/Pake&text=Pake%20-%20Turn%20any%20webpage%20into%20a%20desktop%20app%20with%20one%20command.%20Nearly%2020x%20smaller%20than%20Electron%20packages,%20supports%20macOS%20Windows%20Linux) to your friends. 3. You can follow my [Twitter](https://twitter.com/HiTw93) to get the latest news of Pake or join our [Telegram](https://t.me/+GclQS9ZnxyI2ODQ1) chat group. 4. I hope that you enjoy playing with it. Let us know if you find a website that would be great for a Mac App!
diff --git a/README_CN.md b/README_CN.md
index d5c223da..921d11a5 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -203,7 +203,7 @@ Pake 的发展离不开这些优秀的贡献者 ❤️
## 支持
-<a href="https://miaoyan.app/cats.html?name=Pake"><img src="https://rawcdn.githack.com/tw93/MiaoYan/vercel/assets/sponsors.svg" width="1000px" /></a>
+<a href="https://miaoyan.app/cats.html?name=Pake"><img src="https://cdn.jsdelivr.net/gh/tw93/MiaoYan@main/assets/sponsors.svg" width="1000px" /></a>
1. 我有两只猫,一只叫汤圆,一只可乐,假如 Pake 让你生活更美好,可以给她们 <a href="https://miaoyan.app/cats.html?name=Pake" target="_blank">喂罐头 🥩</a>。
2. 如果你喜欢 Pake,可以在 Github Star,更欢迎 [推荐](https://twitter.com/intent/tweet?url=https://github.com/tw93/Pake&text=Pake%20-%20一键打包网页生成轻量桌面应用,比%20Electron%20小%2020%20倍,支持%20macOS%20Windows%20Linux) 给志同道合的朋友使用。
diff --git a/dist/cli.js b/dist/cli.js
index 3469c7f3..8306efc4 100644
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -1650,10 +1650,48 @@ async function writeIcoWithPreferredSize(sourcePath, outputPath, preferredSize)
return false;
}
}
+/**
+ * Builds an ICO file from an array of PNG buffers using the PNG-in-ICO format
+ * (supported since Windows Vista). This preserves alpha transparency.
+ */
+function buildIcoFromPngBuffers(frames) {
+ const count = frames.length;
+ const headerSize = ICO_HEADER_SIZE + count * ICO_DIR_ENTRY_SIZE;
+ const totalPayload = frames.reduce((acc, f) => acc + f.png.length, 0);
+ const output = Buffer.alloc(headerSize + totalPayload);
+ output.writeUInt16LE(0, 0);
+ output.writeUInt16LE(ICO_TYPE_ICON, 2);
+ output.writeUInt16LE(count, 4);
+ let currentOffset = headerSize;
+ for (let i = 0; i < count; i++) {
+ const { size, png } = frames[i];
+ const entryOffset = ICO_HEADER_SIZE + i * ICO_DIR_ENTRY_SIZE;
+ const sizeByte = size >= 256 ? 0 : size;
+ output.writeUInt8(sizeByte, entryOffset);
+ output.writeUInt8(sizeByte, entryOffset + 1);
+ output.writeUInt8(0, entryOffset + 2);
+ output.writeUInt8(0, entryOffset + 3);
+ output.writeUInt16LE(1, entryOffset + 4);
+ output.writeUInt16LE(32, entryOffset + 6);
+ output.writeUInt32LE(png.length, entryOffset + 8);
+ output.writeUInt32LE(currentOffset, entryOffset + 12);
+ png.copy(output, currentOffset);
+ currentOffset += png.length;
+ }
+ return output;
+}
const ICON_CONFIG = {
minFileSize: 100,
- supportedFormats: ['png', 'ico', 'jpeg', 'jpg', 'webp', 'icns', 'svg'],
+ supportedFormats: [
+ 'png',
+ 'ico',
+ 'jpeg',
+ 'jpg',
+ 'webp',
+ 'icns',
+ 'svg',
+ ],
transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },
downloadTimeout: {
ci: 5000,
@@ -1792,15 +1830,21 @@ async function convertIconFormat(inputPath, appName) {
const iconName = getIconBaseName(appName);
// Generate platform-specific format
if (IS_WIN) {
- // Support multiple sizes for better Windows compatibility
- await icongen(processedInputPath, platformOutputDir, {
- report: false,
- ico: {
- name: `${iconName}_256`,
- sizes: PLATFORM_CONFIG.win.sizes,
- },
- });
- return path.join(platformOutputDir, `${iconName}_256${PLATFORM_CONFIG.win.format}`);
+ const icoPath = path.join(platformOutputDir, `${iconName}_256${PLATFORM_CONFIG.win.format}`);
+ const frames = await Promise.all(PLATFORM_CONFIG.win.sizes.map(async (size) => {
+ const png = await sharp(processedInputPath)
+ .resize(size, size, {
+ fit: 'contain',
+ background: { r: 0, g: 0, b: 0, alpha: 0 },
+ })
+ .ensureAlpha()
+ .png()
+ .toBuffer();
+ return { size, png };
+ }));
+ const icoBuffer = buildIcoFromPngBuffers(frames);
+ await fsExtra.outputFile(icoPath, icoBuffer);
+ return icoPath;
}
if (IS_LINUX) {
const outputPath = path.join(platformOutputDir, `${iconName}_${PLATFORM_CONFIG.linux.size}${PLATFORM_CONFIG.linux.format}`);
@@ -1981,7 +2025,10 @@ async function detectDownloadedIconExtension(response, arrayBuffer, iconUrl) {
if (fileDetails && isSupportedIconFormat(fileDetails.ext)) {
return fileDetails.ext;
}
- const contentType = response.headers.get('content-type')?.split(';')[0].trim();
+ const contentType = response.headers
+ .get('content-type')
+ ?.split(';')[0]
+ .trim();
if (contentType === 'image/svg+xml' && looksLikeSvg(arrayBuffer)) {
return 'svg';
}