pywebview icon indicating copy to clipboard operation
pywebview copied to clipboard

New JS API serializer

Open r0x0r opened this issue 1 year ago • 2 comments

The old implementation of JS API serializer (plain JSON.stringify) has a number of limitations. Namely inability to serialize DOM events, nodes or circular references. I have implemented a new serializer that overcomes these limitations. This, in turn, makes possible to add a support for DOM events in Python as proposed here https://github.com/r0x0r/pywebview/discussions/1212

The code for a new serializer is now in ~~master~~ the dom branch and the actual code can be found here https://github.com/r0x0r/pywebview/blob/0c62ed819f74cfec5e6ead81008b20ddb8d071f2/webview/js/api.py#L82

As this is quite a big change, I would appreciate feedback and testing, before it makes to the next release. Comments are welcomed.

r0x0r avatar Sep 12 '23 20:09 r0x0r

The new serializer is now used inevaluate_js as well. Changes also moved from master to the dom branch and will be released in the next major version.

r0x0r avatar Sep 14 '23 20:09 r0x0r

  • Functions are omitted altogether from serialization (previously replaced with a "function" string)
  • List like objects (ie. NodeList, FileList) are converted to arrays
  • Development moved to the 5.0 branch

r0x0r avatar Sep 29 '23 08:09 r0x0r