diff --git a/desktop/.gitignore b/desktop/.gitignore index b01288f0a..9b7e0cc60 100644 --- a/desktop/.gitignore +++ b/desktop/.gitignore @@ -11,10 +11,11 @@ node_modules/ .env .env.*.local -# Generated code during build -# - tsc transpiles src/**/*.ts and emits the generated JS into build/app -# - The out dir from the photos web app is symlinked to build/out -build/ +# tsc transpiles src/**/*.ts and emits the generated JS into app +app/ + +# out is a symlink to the photos web app's dir +out # electron-builder dist/ diff --git a/desktop/README.md b/desktop/README.md index 9d637de04..e947e2a70 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -10,12 +10,6 @@ To know more about Ente, see [our main README](../README.md) or visit ## Building from source -> [!CAUTION] -> -> We moved a few things around when switching to a monorepo recently, and the -> desktop app is not currently building with these instructions below. Hang -> tight, we're on it, and will fix soon. - Fetch submodules ```sh @@ -28,22 +22,32 @@ Install dependencies yarn install ``` -Run the app +Create a binary for your platform + +```sh +yarn build +``` + +## Developing + +Instead of building, you can run the app in development mode ```sh yarn dev ``` -To recompile automatically using electron-reload, run this in a separate +> [!CAUTION] +> +> `yarn dev` is currently not working (we'll fix soon). If you just want to +> build from source and use the generated binary, use `yarn build` as described +> above. + +This'll launch a development server to serve the pages loaded by the renderer +process, and will hot reload on changes. + +If you also want hot reload for the main process, run this in a separate terminal: -```bash +```sh yarn watch ``` - -`yarn dev` is handy during development, but if you wish, you can also create a -binary for your platform by using - -```sh -yarn build -``` diff --git a/desktop/resources/entitlements.mac.plist b/desktop/build/entitlements.mac.plist similarity index 100% rename from desktop/resources/entitlements.mac.plist rename to desktop/build/entitlements.mac.plist diff --git a/desktop/resources/error.html b/desktop/build/error.html similarity index 100% rename from desktop/resources/error.html rename to desktop/build/error.html diff --git a/desktop/resources/ggmlclip-linux b/desktop/build/ggmlclip-linux similarity index 100% rename from desktop/resources/ggmlclip-linux rename to desktop/build/ggmlclip-linux diff --git a/desktop/resources/ggmlclip-mac b/desktop/build/ggmlclip-mac similarity index 100% rename from desktop/resources/ggmlclip-mac rename to desktop/build/ggmlclip-mac diff --git a/desktop/resources/ggmlclip-windows.exe b/desktop/build/ggmlclip-windows.exe similarity index 100% rename from desktop/resources/ggmlclip-windows.exe rename to desktop/build/ggmlclip-windows.exe diff --git a/desktop/resources/icon.icns b/desktop/build/icon.icns similarity index 100% rename from desktop/resources/icon.icns rename to desktop/build/icon.icns diff --git a/desktop/resources/icon.png b/desktop/build/icon.png similarity index 100% rename from desktop/resources/icon.png rename to desktop/build/icon.png diff --git a/desktop/resources/image-magick b/desktop/build/image-magick similarity index 100% rename from desktop/resources/image-magick rename to desktop/build/image-magick diff --git a/desktop/resources/msvcp140d.dll b/desktop/build/msvcp140d.dll similarity index 100% rename from desktop/resources/msvcp140d.dll rename to desktop/build/msvcp140d.dll diff --git a/desktop/resources/splash.html b/desktop/build/splash.html similarity index 100% rename from desktop/resources/splash.html rename to desktop/build/splash.html diff --git a/desktop/resources/taskbar-icon-Template.png b/desktop/build/taskbar-icon-Template.png similarity index 100% rename from desktop/resources/taskbar-icon-Template.png rename to desktop/build/taskbar-icon-Template.png diff --git a/desktop/resources/taskbar-icon-Template@2x.png b/desktop/build/taskbar-icon-Template@2x.png similarity index 100% rename from desktop/resources/taskbar-icon-Template@2x.png rename to desktop/build/taskbar-icon-Template@2x.png diff --git a/desktop/resources/taskbar-icon-Template@3x.png b/desktop/build/taskbar-icon-Template@3x.png similarity index 100% rename from desktop/resources/taskbar-icon-Template@3x.png rename to desktop/build/taskbar-icon-Template@3x.png diff --git a/desktop/resources/taskbar-icon.png b/desktop/build/taskbar-icon.png similarity index 100% rename from desktop/resources/taskbar-icon.png rename to desktop/build/taskbar-icon.png diff --git a/desktop/resources/taskbar-icon@2x.png b/desktop/build/taskbar-icon@2x.png similarity index 100% rename from desktop/resources/taskbar-icon@2x.png rename to desktop/build/taskbar-icon@2x.png diff --git a/desktop/resources/taskbar-icon@3x.png b/desktop/build/taskbar-icon@3x.png similarity index 100% rename from desktop/resources/taskbar-icon@3x.png rename to desktop/build/taskbar-icon@3x.png diff --git a/desktop/resources/ucrtbased.dll b/desktop/build/ucrtbased.dll similarity index 100% rename from desktop/resources/ucrtbased.dll rename to desktop/build/ucrtbased.dll diff --git a/desktop/resources/vcruntime140_1d.dll b/desktop/build/vcruntime140_1d.dll similarity index 100% rename from desktop/resources/vcruntime140_1d.dll rename to desktop/build/vcruntime140_1d.dll diff --git a/desktop/resources/vcruntime140d.dll b/desktop/build/vcruntime140d.dll similarity index 100% rename from desktop/resources/vcruntime140d.dll rename to desktop/build/vcruntime140d.dll diff --git a/desktop/resources/version.html b/desktop/build/version.html similarity index 100% rename from desktop/resources/version.html rename to desktop/build/version.html diff --git a/desktop/resources/window-icon.png b/desktop/build/window-icon.png similarity index 100% rename from desktop/resources/window-icon.png rename to desktop/build/window-icon.png diff --git a/desktop/docs/dev.md b/desktop/docs/dev.md new file mode 100644 index 000000000..4575188fd --- /dev/null +++ b/desktop/docs/dev.md @@ -0,0 +1,4 @@ +# Development tips + +* `yarn build:quick` is a variant of `yarn build` that uses the + `--config.compression=store` flag to (slightly) speed up electron-builder. diff --git a/desktop/package.json b/desktop/package.json index fe0b9b8ff..a835b81c6 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -4,14 +4,16 @@ "private": true, "description": "Desktop client for Ente Photos", "author": "Ente ", - "main": "build/app/main.js", + "main": "app/main.js", "scripts": { - "build": "mkdir -p build && yarn build-renderer && yarn build-main", - "build-main": "tsc && electron-builder --config.compression=store", - "build-renderer": "cd ../web && yarn install && yarn build:photos && cd ../desktop/build && rm -f out && ln -sf ../../web/apps/photos/out", + "build": "yarn build-renderer && yarn build-main", + "build-main": "tsc && electron-builder", + "build-main:quick": "tsc && electron-builder --config.compression=store", + "build-renderer": "cd ../web && yarn install && yarn build:photos && cd ../desktop && rm -f out && ln -sf ../web/apps/photos/out", + "build:quick": "yarn build-renderer && yarn build-main:quick", "dev": "concurrently \"yarn dev-main\" \"yarn dev-renderer\"", "dev-main": "tsc && electron build/app/main.js", - "dev-renderer": "cd ../web && yarn install && yarn dev:photos && cd ../desktop/build && rm -f out && ln -sf ../../web/apps/photos/out", + "dev-renderer": "cd ../web && yarn install && yarn dev:photos", "postinstall": "electron-builder install-app-deps", "lint": "yarn prettier --check . && eslint \"src/**/*.ts\"", "lint-fix": "yarn prettier --write . && eslint --fix .", @@ -110,26 +112,20 @@ "x64ArchFiles": "Contents/Resources/ggmlclip-mac" }, "afterSign": "electron-builder-notarize", - "extraFiles": [ - { - "from": "resources", - "to": "resources", - "filter": [ - "**/*" - ] - } - ], "asarUnpack": [ "node_modules/ffmpeg-static/bin/${os}/${arch}/ffmpeg", "node_modules/ffmpeg-static/index.js", "node_modules/ffmpeg-static/package.json" ], - "files": [ - "build/app/**/*", + "extraFiles": [ { - "from": "build/out", - "to": "out" + "from": "build", + "to": "resources" } + ], + "files": [ + "app/**/*", + "out" ] }, "productName": "ente", diff --git a/desktop/src/utils/createWindow.ts b/desktop/src/utils/createWindow.ts index b9e6a5b47..29fc785d2 100644 --- a/desktop/src/utils/createWindow.ts +++ b/desktop/src/utils/createWindow.ts @@ -1,13 +1,13 @@ import { app, BrowserWindow, nativeImage } from "electron"; import ElectronLog from "electron-log"; import * as path from "path"; -import { PROD_HOST_URL } from "../config"; import { isAppQuitting } from "../main"; import autoLauncher from "../services/autoLauncher"; import { logErrorSentry } from "../services/sentry"; import { getHideDockIconPreference } from "../services/userPreference"; import { isDev } from "./common"; import { isPlatform } from "./common/platform"; +import { PROD_HOST_URL } from "./main"; export async function createWindow(): Promise { const appImgPath = isDev diff --git a/desktop/src/utils/main.ts b/desktop/src/utils/main.ts index 8f850af79..417e5cc48 100644 --- a/desktop/src/utils/main.ts +++ b/desktop/src/utils/main.ts @@ -14,7 +14,7 @@ import { isPlatform } from "./common/platform"; import { buildContextMenu, buildMenuBar } from "./menu"; const execAsync = util.promisify(require("child_process").exec); -const PROD_HOST_URL: string = "ente://app"; +export const PROD_HOST_URL: string = "ente://app"; const RENDERER_OUTPUT_DIR: string = "./out"; export async function handleUpdates(mainWindow: BrowserWindow) { @@ -79,6 +79,10 @@ export async function setupMainMenu(mainWindow: BrowserWindow) { } export function setupMainHotReload() { + // Hot reload the main process if anything changes in the source directory + // that we're running from. In particular, this gets triggered when `yarn + // watch` rebuilds JS files in the `app/` directory when we change the TS + // files in the `src/` directory. if (isDev) { electronReload(__dirname, {}); } diff --git a/desktop/tsconfig.json b/desktop/tsconfig.json index 1efdc3d01..142c36005 100644 --- a/desktop/tsconfig.json +++ b/desktop/tsconfig.json @@ -3,8 +3,8 @@ "target": "es2021", "module": "commonjs", "esModuleInterop": true, - /* Emit the generated JS into build/app */ - "outDir": "build/app", + /* Emit the generated JS into app */ + "outDir": "app", "noImplicitAny": true, "sourceMap": true, "baseUrl": "src",