@wailsio/runtime 3.0.0-alpha.28 → 3.0.0-alpha.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/system.js +19 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wailsio/runtime",
3
3
  "type": "module",
4
- "version": "3.0.0-alpha.28",
4
+ "version": "3.0.0-alpha.29",
5
5
  "description": "Wails Runtime",
6
6
  "exports": {
7
7
  ".": {
package/src/system.js CHANGED
@@ -15,11 +15,26 @@ let call = newRuntimeCallerWithID(objectNames.System, '');
15
15
  const systemIsDarkMode = 0;
16
16
  const environment = 1;
17
17
 
18
- export function invoke(msg) {
19
- if(window.chrome) {
20
- return window.chrome.webview.postMessage(msg);
18
+ const _invoke = (() => {
19
+ try {
20
+ if(window?.chrome?.webview) {
21
+ return (msg) => window.chrome.webview.postMessage(msg);
22
+ }
23
+ if(window?.webkit?.messageHandlers?.external) {
24
+ return (msg) => window.webkit.messageHandlers.external.postMessage(msg);
25
+ }
26
+ } catch(e) {
27
+ console.warn('\n%c⚠️ Browser Environment Detected %c\n\n%cOnly UI previews are available in the browser. For full functionality, please run the application in desktop mode.\nMore information at: https://v3alpha.wails.io/learn/build/#using-a-browser-for-development\n',
28
+ 'background: #ffffff; color: #000000; font-weight: bold; padding: 4px 8px; border-radius: 4px; border: 2px solid #000000;',
29
+ 'background: transparent;',
30
+ 'color: #ffffff; font-style: italic; font-weight: bold;');
21
31
  }
22
- return window.webkit.messageHandlers.external.postMessage(msg);
32
+ return null;
33
+ })();
34
+
35
+ export function invoke(msg) {
36
+ if (!_invoke) return;
37
+ return _invoke(msg);
23
38
  }
24
39
 
25
40
  /**