diff --git a/v2/internal/runtime/js/core/main.js b/v2/internal/runtime/js/core/main.js index 15d997efc..f3185fb0e 100644 --- a/v2/internal/runtime/js/core/main.js +++ b/v2/internal/runtime/js/core/main.js @@ -50,8 +50,9 @@ export function Init() { // Setup system. Store uses window.wails so needs to be setup after that window.wails.System = { - IsDarkMode: Store.New('isdarkmode'), - LogLevel: Store.New('loglevel'), + IsDarkMode: Store.New('wails:isdarkmode'), + LogLevel: Store.New('wails:loglevel'), + AppConfig: Store.New('wails:appconfig'), }; // Copy platform specific information into it Object.assign(window.wails.System, Platform.System); diff --git a/v2/internal/runtime/js/core/store.js b/v2/internal/runtime/js/core/store.js index 33c0db2c7..aa32c3487 100644 --- a/v2/internal/runtime/js/core/store.js +++ b/v2/internal/runtime/js/core/store.js @@ -84,6 +84,9 @@ export function New(name, optionalDefault) { this.set(optionalDefault); } + // Trigger an update to the store + window.wails.Events.Emit('wails:sync:store:resync:'+name); + return { subscribe, get, diff --git a/v2/internal/runtime/js/runtime/package.json b/v2/internal/runtime/js/runtime/package.json index 5313ff969..10ba81aa7 100644 --- a/v2/internal/runtime/js/runtime/package.json +++ b/v2/internal/runtime/js/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@wails/runtime", - "version": "1.2.2", + "version": "1.2.4", "description": "Wails V2 Javascript runtime library", "main": "main.js", "types": "runtime.d.ts", diff --git a/v2/internal/runtime/js/runtime/system.js b/v2/internal/runtime/js/runtime/system.js index bf3a5e2e9..ff736a2b3 100644 --- a/v2/internal/runtime/js/runtime/system.js +++ b/v2/internal/runtime/js/runtime/system.js @@ -33,10 +33,66 @@ function DarkModeEnabled() { return window.wails.System.IsDarkMode.get(); } +/** + * Mac Application Config + * @typedef {Object} MacAppConfig + * @param {MacTitleBar} TitleBar - The window's titlebar configuration + */ + + /** + * Mac Title Bar Config + * Check out https://github.com/lukakerr/NSWindowStyles for some examples of these settings + * @typedef {Object} MacTitleBar + * @param {bool} TitleBarAppearsTransparent - NSWindow.titleBarAppearsTransparent + * @param {bool} HideTitle - NSWindow.hideTitle + * @param {bool} HideTitleBar - NSWindow.hideTitleBar + * @param {bool} FullSizeContent - Makes the webview portion of the window the full size of the window, even over the titlebar + * @param {bool} UseToolbar - Set true to add a blank toolbar to the window (makes the title bar larger) + * @param {bool} HideToolbarSeparator - Set true to remove the separator between the toolbar and the main content area + * + */ + +/** + * The application configuration + * + * @typedef {Object} AppConfig + * @param {string} Title - Application Title + * @param {number} Width - Window Width + * @param {number} Height - Window Height + * @param {boolean} DisableResize - True if resize is disabled + * @param {boolean} Fullscreen - App started in fullscreen + * @param {number} MinWidth - Window Minimum Width + * @param {number} MinHeight - Window Minimum Height + * @param {number} MaxWidth - Window Maximum Width + * @param {number} MaxHeight - Window Maximum Height + * @param {bool} StartHidden - Start with window hidden + * @param {bool} DevTools - Enables the window devtools + * @param {number} RBGA - The initial window colour. Convert to hex then it'll mean 0xRRGGBBAA + * @param {MacAppConfig} [Mac] - Configuration when running on Mac + * @param {LinuxAppConfig} [Linux] - Configuration when running on Linux + * @param {WindowsAppConfig} [Windows] - Configuration when running on Windows + * @param {string} Appearance - The default application appearance. Use the values listed here: https://developer.apple.com/documentation/appkit/nsappearance?language=objc + * @param {number} WebviewIsTransparent - Makes the background of the webview content transparent. Use this with the Alpha part of the window colour to make parts of your application transparent. + * @param {number} WindowBackgroundIsTranslucent - Makes the transparent parts of the application window translucent. Example: https://en.wikipedia.org/wiki/MacOS_Big_Sur#/media/File:MacOS_Big_Sur_-_Safari_Extensions_category_in_App_Store.jpg + * @param {number} LogLevel - The initial log level (lower is more verbose) + * + */ + +/** + * Returns the application configuration. + * + * @export + * @returns {Promise} + */ +function AppConfig() { + return window.wails.System.AppConfig.get(); +} + module.exports = { OnThemeChange: OnThemeChange, DarkModeEnabled: DarkModeEnabled, LogLevel: window.wails.System.LogLevel, Platform: window.wails.System.Platform, - AppType: window.wails.System.AppType + AppType: window.wails.System.AppType, + AppConfig: AppConfig, }; \ No newline at end of file