Skip to content

Commit eae1552

Browse files
committed
feat: package manager change from pnpm to bun
1 parent dddb5ca commit eae1552

File tree

8 files changed

+59
-1599
lines changed

8 files changed

+59
-1599
lines changed

.github/workflows/jekyll-gh-pages.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v3
1717

18+
- name: Install Bun
19+
run: |
20+
curl -fsSL https://bun.sh/install | bash
21+
export BUN_INSTALL="$HOME/.bun"
22+
export PATH="$BUN_INSTALL/bin:$PATH"
23+
bun --version
24+
1825
- name: Setup Node.js
1926
uses: actions/setup-node@v3
2027
with:
2128
node-version: "22"
2229

2330
- name: Install dependencies
24-
run: npm install
31+
run: bun install
2532

2633
- name: Build project
27-
run: npm run build:dev
34+
run: bun run build:dev
2835

2936
- name: Deploy to GitHub Pages
3037
uses: peaceiris/actions-gh-pages@v3

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
bun.lockb

demo/index.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,25 @@ document.body.appendChild(container);
3232
input.onchange = async (): Promise<void> => {
3333
try {
3434
if (!input.files) return;
35+
const files = Array.from(input.files);
3536
let count = input.files.length;
3637
console.log("files count", count);
3738
console.time("compress");
3839
// const hash = await crypto.digest("SHA-256", await input.files[0].arrayBuffer());
39-
for (let file of input.files) {
40+
41+
files.forEach(async (file, i) => {
4042
const { size: beforeSize, name } = file;
41-
const promise = CEngine.runCompress(file, defaultConfig);
42-
promise.then((blob) => {
43-
const afterSize = blob.size;
44-
console.log(name, "beforeSize:", beforeSize >> 20, "afterSize:", afterSize >> 20, "rate:", (afterSize / beforeSize).toFixed(2));
43+
const blob = await CEngine.runCompress(file, defaultConfig);
44+
45+
const afterSize = blob.size;
46+
console.log(name, "beforeSize:", beforeSize >> 20, "afterSize:", afterSize >> 20, "rate:", (afterSize / beforeSize).toFixed(2));
4547

46-
count--;
47-
if (count === 0) {
48-
console.timeEnd("compress");
49-
}
50-
preDownloadForBlobs(blob);
51-
});
52-
}
48+
count--;
49+
if (count === 0) {
50+
console.timeEnd("compress");
51+
}
52+
preDownloadForBlobs(blob, i);
53+
});
5354

5455
// 下载 blob
5556
} catch (error) {
@@ -75,7 +76,7 @@ function preDownloadForBlobs(blob: Blob, i = 0): void {
7576
const a = document.createElement("a");
7677
a.href = url;
7778
a.download = `compressed-${i + 1}.${blob.type.split("/")[1]}`;
78-
a.textContent = `download`;
79+
a.textContent = `d-${i + 1}`;
7980

8081
const div = document.createElement("div");
8182
const img = document.createElement("img");

package.json

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"name": "zhiwen-img-compress",
33
"private": false,
4-
"version": "0.0.6",
4+
"version": "0.0.7",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
77
"types": "dist/index.d.ts",
88
"type": "module",
99
"description": "a fast tiny img compression tool for web",
1010
"scripts": {
11-
"dev": "vite",
12-
"build:dev": "vite build",
13-
"build": "tsc && vite build --mode lib",
11+
"dev": "bunx --bun vite",
12+
"build:dev": "bunx --bun vite build",
13+
"build": "tsc && bunx --bun vite build --mode lib",
1414
"pub": "pnpm run build && npm publish --no-git-checks"
1515
},
1616
"devDependencies": {
1717
"@tweakpane/core": "^2.0.5",
1818
"gh-pages": "^6.2.0",
1919
"tweakpane": "^4.0.5",
20-
"typescript": "~5.6.2",
21-
"vite": "^5.4.10",
20+
"typescript": "^5.7.0",
21+
"vite": "^6.0.0",
2222
"vite-plugin-dts": "^4.3.0"
2323
},
2424
"files": [
@@ -35,5 +35,10 @@
3535
"author": {
3636
"name": "Quark",
3737
"email": "caodahong@gmail.com"
38-
}
38+
},
39+
"keywords": [
40+
"img",
41+
"compress",
42+
"web"
43+
]
3944
}

0 commit comments

Comments
 (0)