Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
FYI the version with automatic secret per each JSONChannel instance is there. You can provide a secret from GJS for a global channel or accept any channel ... it's your call on security side, really. Regards On Wed, Nov 1, 2017 at 2:44 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote:

Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
OK, I've done some test and apparently `notify::title` is queue so even if you change title twice in a row in WebKit/JS land, GJS will receive all changes. This made me able to create a simple JSONChannel class: https://gist.github.com/WebReflection/7ab0addec037508cc8380a9c37d285f2 I have that cl

Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
I'd be OK if WebKitGTK could at least accept strings and pass them along ... wkjscore-result should be part of the core, IMO. On Wed, Nov 1, 2017 at 12:28 PM, Sam Jansen wrote: > > > On 1 November 2017 at 15:23, Andrea Giammarchi < > andrea.giammar...@gmail.com> wrote: > >> so ... it looks rea

Re: GJS WebKit2 Extension

2017-11-01 Thread Sam Jansen
On 1 November 2017 at 15:23, Andrea Giammarchi wrote: > so ... it looks really like the exposed API is completely useless as it is > > ```js > webkit.messageHandlers.gjs.postMessage('hello'); > ``` > > Returns a > > [boxed instance proxy GIName:WebKit2.JavascriptResult jsobj@0x7fa08c2e4160 > nati

Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
the GJS code, in case you are wondering ... the if is executed, the jsResult is useless with any kind of data I pass (string, boolean, array, object, number, null): if (wvUCM.register_script_message_handler('gjs')) { wvUCM.connect('script-message-received', (self, jsResult) => { print(jsResult);

Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
so ... it looks really like the exposed API is completely useless as it is ```js webkit.messageHandlers.gjs.postMessage('hello'); ``` Returns a [boxed instance proxy GIName:WebKit2.JavascriptResult jsobj@0x7fa08c2e4160 native@0x7fa052081d80] and if you try to get its value it goes bananas with

Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
I've quickly provided a proof of concept but you could have a JSONChannel class singleton on the client side that queue each info and wait for the GJS side to receive one before sending another. I might try a real implementation though and see how it works. however, this is just a work around for

Re: GJS WebKit2 Extension

2017-11-01 Thread Sam Jansen
On 1 November 2017 at 11:55, Andrea Giammarchi wrote: > Actually the `notify::title` with a prefixed "secret-channel" and > serialized JSON looks like the best of them all, for the time being, as it > makes it straight forward for both client and server to communicate. > > ```js > // listen to ea

Re: GJS WebKit2 Extension

2017-11-01 Thread Andrea Giammarchi
Actually the `notify::title` with a prefixed "secret-channel" and serialized JSON looks like the best of them all, for the time being, as it makes it straight forward for both client and server to communicate. ```js // listen to each response new MutationObserver(m => { if (/^secret:response=/.t

Re: GJS WebKit2 Extension

2017-11-01 Thread Sam Jansen
On 1 November 2017 at 05:43, wrote: > On Thu, Oct 12, 2017 at 5:23 AM Andrea Giammarchi < > andrea.giammar...@gmail.com> wrote: > >> FWIW I've used the location with a private channel as protocol to >> intercept calls to/from the page and GJS. >> >> https://github.com/WebReflection/jsgtk-twitter/

Re: GJS WebKit2 Extension

2017-11-01 Thread philip . chimento
On Thu, Oct 12, 2017 at 5:23 AM Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > FWIW I've used the location with a private channel as protocol to > intercept calls to/from the page and GJS. > > https://github.com/WebReflection/jsgtk-twitter/blob/master/app#L162-L175 > > The channel is a

Re: GJS WebKit2 Extension

2017-10-12 Thread Andrea Giammarchi
FWIW I've used the location with a private channel as protocol to intercept calls to/from the page and GJS. https://github.com/WebReflection/jsgtk-twitter/blob/master/app#L162-L175 The channel is a random string: https://github.com/WebReflection/jsgtk-twitter/blob/master/app#L59 >From the page,

Re: GJS WebKit2 Extension

2017-10-10 Thread philip . chimento
On Wed, Oct 11, 2017, 06:17 Adriano Patrizio wrote: > It's possible write a WebKit2 Extension in JavaScript? I need to bind > javascript objects in my web based app and this is the only way. > Hi, Unfortunately that's not possible. For reference, there was some discussion on getting it to work