Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APNG to GIF + updates and a lot of fixes #103

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
name: Build
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
build_on_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22
- name: Install Dependencies
run: yarn install
- name: Build
run: yarn make
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4
with:
name: Linux
path: out/make

build_on_mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22
- name: Install Dependencies
run: yarn install
- name: Build
run: yarn make
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4
with:
name: MacOS
path: out/make

build_on_win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22
- name: Install Dependencies
run: yarn install
- name: Build
run: yarn make
- name: Upload Artifacts
uses: actions/upload-artifact@v3.1.2
uses: actions/upload-artifact@v4
with:
name: Windows
path: out/make
30 changes: 21 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
name: Release

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
publish_on_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22
- name: install dependencies
run: yarn install
- name: publish
env:
authToken: ${{ secrets.GITHUB_TOKEN }}
ACCESS_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: electron-forge:*
run: yarn run publish

publish_on_mac:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22
- name: install dependencies
run: yarn install
- name: publish
env:
authToken: ${{ secrets.GITHUB_TOKEN }}
ACCESS_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: electron-forge:*
run: yarn run publish

publish_on_win:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@master
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.15.0
node-version: 22
- name: install dependencies
run: yarn install
- name: publish
env:
authToken: ${{ secrets.GITHUB_TOKEN }}
ACCESS_KEY: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: electron-forge:*
run: yarn run publish
29 changes: 29 additions & 0 deletions copy-native-dlls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fse = require('fs-extra');
const path = require('path');

async function copyDlls() {
const sourceDir = path.join(__dirname, 'node_modules', '@img', 'sharp-win32-x64', 'lib');

// Construct the destination path directly:
const destDir = path.join(
__dirname,
'out',
'StampNyaa-win32-x64',
'resources',
'app.asar.unpacked',
'node_modules',
'@img',
'sharp-win32-x64',
'lib'
);

try {
await fse.copy(path.join(sourceDir, 'libvips-cpp.dll'), path.join(destDir, 'libvips-cpp.dll'));
await fse.copy(path.join(sourceDir, 'libvips-42.dll'), path.join(destDir, 'libvips-42.dll'));
console.log('DLLs copied successfully.');
} catch (error) {
console.error('Error copying DLLs:', error);
}
}

module.exports = copyDlls;
23 changes: 21 additions & 2 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const fs = require('fs');
const path = require('path');

const copyDlls = require('./copy-native-dlls');
module.exports = {
packagerConfig: {
asar: true,
asarOptions: {
unpackDir: 'node_modules/@img/sharp-win32-x64/lib',
},
asarUnpack: ['**/node_modules/sharp/**/*', '**/node_modules/@img/**/*'],
executableName: 'stampnyaa',
icon: './assets/icon',
},
Expand Down Expand Up @@ -78,12 +82,27 @@ module.exports = {
},
],
hooks: {
postPackage: async (forgeConfig, buildPath, electronVersion, platform, arch) => {
if (platform === 'win32') {
// No arguments needed
await copyDlls();
}
},
// Fix sqlite links out of the package https://www.update.rocks/blog/fixing-the-python3/
packageAfterPrune: async (forgeConfig, buildPath, electronVersion, platform, arch) => {
if (platform === 'darwin' || platform === 'linux') {
console.log('We need to remove the problematic link file on macOS/Linux');
console.log(`Build path ${buildPath}`);
fs.unlinkSync(path.join(buildPath, 'node_modules/sqlite3/build/node_gyp_bins/python3'));
const python3Path = path.join(buildPath, 'node_modules/sqlite3/build/node_gyp_bins/python3');
if (fs.existsSync(python3Path)) {
try {
fs.unlinkSync(python3Path);
} catch (error) {
console.error(`Error deleting python3: ${error.message}`);
}
} else {
console.log(`python3 not found at: ${python3Path}`);
}
}
},
},
Expand Down
48 changes: 27 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stampnyaa",
"productName": "StampNyaa",
"version": "1.6.0",
"version": "1.6.1",
"description": "A simple app for using LINE stickers in your favorite messaging applications.",
"repository": {
"type": "git",
Expand All @@ -15,7 +15,8 @@
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\"",
"format": "prettier --write \"src/**/*.{js,ts}\"",
"prepare": "husky install"
"prepare": "husky install",
"rebuild": "electron-rebuild -w -A"
},
"keywords": [],
"author": {
Expand All @@ -24,38 +25,43 @@
},
"license": "GPL-3.0",
"dependencies": {
"@nut-tree/nut-js": "^3.1.2",
"@nut-tree-fork/nut-js": "^4.2.4",
"@shopify/draggable": "1.0.0-beta.11",
"axios": "^1.4.0",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^8.1.0",
"jimp": "^0.22.8",
"jsdom": "^22.1.0",
"file-type": "^16.5.4",
"fs-extra": "^11.3.0",
"jsdom": "^26.0.0",
"sharp": "^0.33.5",
"sharp-apng": "^0.1.5",
"sqlite3": "^5.1.6",
"update-electron-app": "^2.0.1"
},
"optionalDependencies": {
"electron-clipboard-ex": "^1.3.3"
},
"devDependencies": {
"@electron-forge/cli": "^6.2.1",
"@electron-forge/maker-deb": "^6.2.1",
"@electron-forge/maker-rpm": "^6.2.1",
"@electron-forge/maker-squirrel": "^6.2.1",
"@electron-forge/maker-zip": "^6.2.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.2.1",
"@electron-forge/plugin-vite": "^6.2.1",
"@electron-forge/publisher-github": "^6.2.1",
"@types/node": "^20.4.4",
"electron": "25.2.0",
"electron-builder": "^24.4.0",
"@electron-forge/cli": "7.2.0",
"@electron-forge/maker-deb": "7.2.0",
"@electron-forge/maker-rpm": "7.2.0",
"@electron-forge/maker-squirrel": "7.2.0",
"@electron-forge/maker-zip": "7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "7.2.0",
"@electron-forge/plugin-vite": "7.2.0",
"@electron-forge/publisher-github": "7.2.0",
"@types/node": "^22.13.5",
"electron": "^34.0.0",
"electron-builder": "^25.1.8",
"electron-rebuild": "^3.2.9",
"electronmon": "^2.0.2",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "3.0.0",
"typescript": "^5.1.6"
"husky": "^9.1.7",
"lint-staged": "^15.4.3",
"prettier": "^3.5.2",
"typescript": "^5.1.6",
"vite": "^5.0.0"
},
"lint-staged": {
"*.{js,ts}": "prettier --write"
}
}
}
4 changes: 2 additions & 2 deletions src/utils/lineDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { JSDOM } = require('jsdom');
import fs from 'fs';
import { finished } from 'node:stream/promises';
import path from 'path';
import Jimp from 'jimp';
import sharp from 'sharp';
import { MessagePortMain } from 'electron';

const cdnURL = 'https://stickershop.line-scdn.net';
Expand Down Expand Up @@ -186,7 +186,7 @@ async function downloadImage(url: string, dir: string, filename: string) {
*/
async function checkImageValidity(imagePath: string) {
try {
await Jimp.read(imagePath);
await sharp(imagePath);
console.log('Image is valid.');
return true;
} catch (error) {
Expand Down
Loading