change packager, following up the starting guide

This commit is contained in:
Mylloon 2023-07-29 14:29:14 +02:00
parent 792f8e1f2d
commit 1d01f8b0a9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
6 changed files with 2990 additions and 216 deletions

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
/node_modules /node_modules
/dist /dist
/dsr-win32-x64
out/

View file

@ -1,5 +1,12 @@
# Discord Video Sharing # Discord Video Sharing
- [ ] Try to keep the video under 25mn <!-- Use Handbrake preset? --> - [ ] Try to keep the video under 25mb <!-- Use Handbrake preset? -->
- [ ] If already under the limit, the file won't be compressed - [ ] If already under the limit, the file won't be compressed
- [ ] Merge all audio files into one track <!-- ffmpeg -i in.mp4 -filter_complex "[0:a]amerge=inputs=2[a]" -ac 1 -map 0:v -map "[a]" -c:v copy out.mp4 --> - [ ] Merge all audio files into one track <!-- ffmpeg -i in.mp4 -filter_complex "[0:a]amerge=inputs=2[a]" -ac 1 -map 0:v -map "[a]" -c:v copy out.mp4 -->
## Dev
```bash
npm install --platform=win32
npm run package
```

3159
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,8 @@
"main": "./dist/main.js", "main": "./dist/main.js",
"scripts": { "scripts": {
"build": "rm -rf ./dist 2> /dev/null; npx tsc", "build": "rm -rf ./dist 2> /dev/null; npx tsc",
"start": "npm run build && electron ./dist/main.js", "start": "electron-forge start",
"package": "npm run build && npx electron-packager . --platform=win32 --arch=x64" "package": "electron-forge package --platform=win32"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -22,7 +22,7 @@
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"devDependencies": { "devDependencies": {
"electron": "^25.3.2", "@electron-forge/cli": "^6.2.1",
"electron-packager": "^17.1.1" "electron": "^25.3.2"
} }
} }

View file

@ -1,17 +1,26 @@
import { app, BrowserWindow } from "electron"; import { app, BrowserWindow } from "electron";
import path = require("path");
const pathToFfmpeg = require("ffmpeg-static"); /* import ffmpegPath = require("ffmpeg-static"); */
const createWindow = () => { const createWindow = () => {
const win = new BrowserWindow({ const win = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
},
}); });
win.loadFile("../index.html"); win.loadFile("../index.html");
}; };
app.whenReady().then(() => { app.whenReady().then(() => {
/* console.log(pathToFfmpeg); */
createWindow(); createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
}); });

10
src/preload.ts Normal file
View file

@ -0,0 +1,10 @@
window.addEventListener("DOMContentLoaded", () => {
const replaceText = (selector: string, text: string) => {
const element = document.getElementById(selector);
if (element) element.innerText = text;
};
for (const dependency of ["chrome", "node", "electron"]) {
replaceText(`${dependency}-version`, process.versions[dependency]);
}
});