Open raddevus opened 1 year ago
I doubt it will mean much since the window.external object is being initialized/created by Photino itself. In the end it is a wrapper around window.chrome.webview.postMessage (Windows/Webview2), window.webkit.messageHandlers.Photinointerop (a custom handler, Linux/WebkitGTK) and window.webkit.messageHandlers.photinointerop (Mac/Webkit).
see for example (windows) https://github.com/tryphotino/photino.Native/blob/24be1c50d3dcb4c92c33a0081160ecc10959553c/Photino.Native/Photino.Windows.cpp#L751
window.external = {
sendMessage: function(message) {
window.chrome.webview.postMessage(message);
},
receiveMessage: function(callback) {
window.chrome.webview.addEventListener('message', function(e) {
callback(e.data);
});
}
};
The initialization is a raw declaration of a new object, regardless if 'window.external' already existed, which javascript allows (try overwriting console.log with a new function sometime). So the deprecation of a mechanism which wasn't used doesn't affect the project I think.
That is excellent info and great news. thanks for pointing out that this is actually a wrapper around those other (supported) methods.
Closed since window.external is a Photino wrapper around the proper code.
Going forward, we may need to implement this on a platform-by-platform basis.
WebKitGTK (Linux): maybe this? https://webkitgtk.org/reference/webkit2gtk/stable/method.WebView.run_javascript.html
WebKit (Mac): maybe this? https://stackoverflow.com/questions/62035494/how-to-call-postmessage-in-wkwebview-to-js
For now, to get around TypeScript compile errors you can do a work-around like (myObject as any).myMethod() or myObject.myMethod?.()
That would work.
I played around a bit and discovered // @ts-ignore
works too. The code runs, it just won't transpile because it isn't valid TypeScript.
We should look into the options you talked about, but I think there will still be an issue with TypeScript. This may not be a problem that requires us to make changes. I'm not sure.
Just discovered that window.external is being deprecated by browsers. You can see the deprecation warning on the MDN at: https://developer.mozilla.org/en-US/docs/Web/API/Window/external
What will this mean for Photino.NET moving forward?