From 9ee720eab3bb2278d3c482bab73d14b97ba27ecc Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Fri, 23 Oct 2026 03:20:18 -0700 Subject: [PATCH] Desktop: load the preload in packaged builds env.ts re-exported Forge's declared MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, which compiles to an export that stays undefined: DefinePlugin replaces only direct uses of the name. The window had no preload, so SP_ELECTRON, and with it the OBS setup bridge, was missing. The Forge globals are now declared ambiently and used directly. --- js/desktop/src/env.ts | 8 -------- js/desktop/src/forge.d.ts | 6 ++++++ js/desktop/src/tests/sync-test.ts | 1 - js/desktop/src/window.ts | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 js/desktop/src/forge.d.ts diff --git a/js/desktop/src/env.ts b/js/desktop/src/env.ts index f5dbb8a5b..a94483571 100644 --- a/js/desktop/src/env.ts +++ b/js/desktop/src/env.ts @@ -20,11 +20,3 @@ export default function getEnv() { updateBaseUrl, }; } - -// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack -// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on -// whether you're running in development or production). -declare const MAIN_WINDOW_WEBPACK_ENTRY: string; -declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string; - -export { MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, MAIN_WINDOW_WEBPACK_ENTRY }; diff --git a/js/desktop/src/forge.d.ts b/js/desktop/src/forge.d.ts new file mode 100644 index 000000000..b8678fcbc --- /dev/null +++ b/js/desktop/src/forge.d.ts @@ -0,0 +1,6 @@ +// The entry points Forge's webpack plugin defines (DefinePlugin), by the +// bundle's location in development or production. DefinePlugin substitutes +// only where these names are used, so reference them directly: a module +// that re-exports one exports undefined. +declare const MAIN_WINDOW_WEBPACK_ENTRY: string; +declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string; diff --git a/js/desktop/src/tests/sync-test.ts b/js/desktop/src/tests/sync-test.ts index 67dc14e33..bb3b67e4f 100644 --- a/js/desktop/src/tests/sync-test.ts +++ b/js/desktop/src/tests/sync-test.ts @@ -1,6 +1,5 @@ import { BrowserWindow, session, WebFrameMain, webFrameMain } from "electron"; import { v7 as uuidv7 } from "uuid"; -import { MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY } from "../env"; import { E2ETest, TestEnv } from "./test-env"; import { delay, PlayerReport } from "./util"; diff --git a/js/desktop/src/window.ts b/js/desktop/src/window.ts index 601dfba57..9012a70c2 100644 --- a/js/desktop/src/window.ts +++ b/js/desktop/src/window.ts @@ -1,6 +1,6 @@ import { BrowserWindow, globalShortcut } from "electron"; import { resolve } from "path"; -import getEnv, { MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY } from "./env"; +import getEnv from "./env"; export const makeWindow = async (): Promise => { const { isDev } = getEnv(); -- 2.54.0