5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 17:41:24 +08:00
wails/v2/internal/frontend/runtime/desktop/ipc.js
2021-10-04 19:42:22 +11:00

31 lines
724 B
JavaScript

/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 6 */
/**
* WailsInvoke sends the given message to the backend
*
* @param {string} message
*/
(function () {
// Credit: https://stackoverflow.com/a/2631521
let _deeptest = function (s) {
var obj = window[s.shift()];
while (obj && s.length) obj = obj[s.shift()];
return obj;
};
window.WailsInvoke = _deeptest(["chrome", "webview", "postMessage"]) ||
_deeptest(["webkit", "messageHandlers", "external", "postMessage"]);
if (!window.WailsInvoke) {
console.error("Unsupported Platform");
}
})();