Skip to content

Commit 2d732ea

Browse files
committed
fix(core): Replace sharp with image-size and release v1.0.8
- Replaced native 'sharp' dependency with 'image-size' in core to fix CLI bundling issues with pkg. - Updated CLI pkg configuration to remove unnecessary native asset inclusion. - Bumped version to 1.0.8.
1 parent ffae8ec commit 2d732ea

6 files changed

Lines changed: 20 additions & 220 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@munlicode/munliwall-root",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Desktop and CLI wallpaper tool",
55
"workspaces": [
66
"packages/*"

packages/cli/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
},
1010
"pkg": {
1111
"scripts": "dist/cli.js",
12-
"assets": [
13-
"node_modules/sharp/**/*",
14-
"../../node_modules/sharp/**/*"
15-
],
12+
"assets": [],
1613
"outputPath": "dist"
1714
},
1815
"scripts": {
19-
"build": "npx esbuild src/cli.ts --bundle --platform=node --format=cjs --outfile=dist/cli.js --external:sharp --external:wallpaper --external:electron",
16+
"build": "npx esbuild src/cli.ts --bundle --platform=node --format=cjs --outfile=dist/cli.js --external:wallpaper --external:electron",
2017
"dev": "tsc --watch",
2118
"dist": "pnpm run build && pkg package.json --targets node18-linux-x64,node18-macos-x64,node18-win-x64 --out-dir dist"
2219
},

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"lowdb": "^7.0.1",
2626
"nekosapi": "^0.7.0",
2727
"screen-resolution": "^1.0.0",
28-
"sharp": "0.32.6",
2928
"wallpaper": "^7.2.1"
3029
},
3130
"devDependencies": {

packages/core/src/sources/local.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ISource, Wallpaper } from '../types.js';
22
import { readdir } from 'fs/promises';
33
import { join, sep } from 'path';
4-
import sharp from 'sharp';
4+
import { imageSizeFromFile } from 'image-size/fromFile';
55

66
export class LocalSource implements ISource {
77
public name = 'local';
@@ -26,8 +26,19 @@ export class LocalSource implements ISource {
2626
const randomImage = images[Math.floor(Math.random() * images.length)];
2727
const fullPath = join(folderPath, randomImage);
2828

29-
// --- Get dimensions using sharp ---
30-
const metadata = await sharp(fullPath).metadata();
29+
// --- Get dimensions using image-size/fromFile ---
30+
let width = 0;
31+
let height = 0;
32+
try {
33+
const dimensions = await imageSizeFromFile(fullPath); // Use the correct async function
34+
if (dimensions) {
35+
width = dimensions.width ?? 0;
36+
height = dimensions.height ?? 0;
37+
}
38+
} catch (error) {
39+
// Ignore dimension errors, fallback to 0
40+
console.error(`Failed to read dimensions for ${fullPath}`, error);
41+
}
3142
// ----------------------------------
3243

3344
const fileUrl = `file://${fullPath}`; // URL for local file access
@@ -43,8 +54,8 @@ export class LocalSource implements ISource {
4354
source: this.name,
4455
author: 'Unknown', // Author is generally not available for local files
4556
tags: [folderPath.split(sep).pop() || 'local'], // Use folder name as a tag
46-
width: metadata.width ?? 0,
47-
height: metadata.height ?? 0,
57+
width,
58+
height,
4859
};
4960
}
5061
}

packages/desktop-app/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@munlicode/munliwall-desktop",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "A simple yet powerful tool designed to transform your workspace with ease. Wallpaper lets you effortlessly manage your desktop backgrounds — download stunning wallpapers, upload your own creations, or update your setup automatically.",
55
"author": "Nurzhan Murakhan <nurzhanmuratkhan@gmail.com>",
66
"homepage": "https://github.com/munlicode/munliwall",
@@ -30,7 +30,6 @@
3030
"lowdb": "^7.0.1",
3131
"nekosapi": "^0.7.0",
3232
"screen-resolution": "^1.0.0",
33-
"sharp": "0.32.6",
3433
"wallpaper": "^7.2.1"
3534
},
3635
"devDependencies": {

0 commit comments

Comments
 (0)