From 19f60798b3e5a24ae125f9208368a10fba1d7c75 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 16 Dec 2024 21:10:56 +1100 Subject: [PATCH] Provide a way to initialise the runtime if not using any runtime features. --- docs/src/content/docs/changelog.mdx | 3 ++- .../runtime/desktop/@wailsio/runtime/src/index.js | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/src/content/docs/changelog.mdx b/docs/src/content/docs/changelog.mdx index 3c4470d13f5..09e1cbaaf0b 100644 --- a/docs/src/content/docs/changelog.mdx +++ b/docs/src/content/docs/changelog.mdx @@ -30,7 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `app.OpenFileManager(path string, selectFile bool)` to open the system file manager to the path `path` with optional highlighting via `selectFile` by [@Krzysztofz01](https://github.com/Krzysztofz01) [@rcalixte](https://github.com/rcalixte) - New `-git` flag for `wails3 init` command by [@leaanthony](https://github.com/leaanthony) -- New `wails3 generate webview2bootstrapper` command by [@leaanthony](https://github.com/leaanthony)2 +- New `wails3 generate webview2bootstrapper` command by [@leaanthony](https://github.com/leaanthony) +- Added `init()` method in runtime to allow manual initialisation of the runtime by [@leaanthony](https://github.com/leaanthony) ### Fixed diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js index 674d1ac1b79..071c60092e2 100644 --- a/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js +++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js @@ -43,12 +43,16 @@ export { WML }; -var initialised = false; +let initialised = false; +export function init() { + window._wails.invoke = System.invoke; + System.invoke("wails:runtime:ready"); + initialised = true; +} + window.addEventListener("load", () => { if (!initialised) { - window._wails.invoke = System.invoke; - System.invoke("wails:runtime:ready"); - initialised = true; + init(); } });