@wailsio/runtime 3.0.0-alpha.28 → 3.0.0-alpha.30
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.
- package/package.json +3 -2
- package/src/event_types.js +1 -0
- package/src/index.js +14 -2
- package/src/system.js +19 -4
- package/src/window.js +1 -1
- package/types/event_types.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wailsio/runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-alpha.
|
|
4
|
+
"version": "3.0.0-alpha.30",
|
|
5
5
|
"description": "Wails Runtime",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./types/index.d.ts",
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"build:types": "npx -p typescript tsc src/index.js --declaration --allowJs --emitDeclarationOnly --outDir types",
|
|
20
21
|
"postbuild:types": "wails3 task generate:events",
|
|
21
22
|
"build:docs": "npx typedoc ./src/index.js",
|
|
22
|
-
"build:docs:md": "npx typedoc --plugin typedoc-plugin-markdown --namedAnchors true --hideBreadcrumbs true --out ../../../../../../
|
|
23
|
+
"build:docs:md": "npx typedoc --plugin typedoc-plugin-markdown --namedAnchors true --hideBreadcrumbs true --out ../../../../../../old_mkdocs/docs/en/api/js ./src/index.js"
|
|
23
24
|
},
|
|
24
25
|
"author": "The Wails Team",
|
|
25
26
|
"license": "MIT",
|
package/src/event_types.js
CHANGED
package/src/index.js
CHANGED
|
@@ -43,6 +43,18 @@ export {
|
|
|
43
43
|
WML
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
let initialised = false;
|
|
47
|
+
export function init() {
|
|
48
|
+
window._wails.invoke = System.invoke;
|
|
49
|
+
System.invoke("wails:runtime:ready");
|
|
50
|
+
initialised = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
window.addEventListener("load", () => {
|
|
54
|
+
if (!initialised) {
|
|
55
|
+
init();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
46
59
|
// Notify backend
|
|
47
|
-
|
|
48
|
-
System.invoke("wails:runtime:ready");
|
|
60
|
+
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
32
|
+
return null;
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
export function invoke(msg) {
|
|
36
|
+
if (!_invoke) return;
|
|
37
|
+
return _invoke(msg);
|
|
23
38
|
}
|
|
24
39
|
|
|
25
40
|
/**
|
package/src/window.js
CHANGED