This PR starts to standardise the messaging format between the different JS files, with the goal of being able to validate and type messages from cradle to grave, from JS to Swift and back again.
The core idea is that all JS files communicate with the following object:
destination is used to multiplex the browser runtime events channel, and permit more generic method names. method is currently general-purpose, but will later be typed, ditto params. sessionId is currently unused.
It also:
simplifies the view rendering logic
removes much of the global state from background, content and popup, preferring a more injected, localised and functional approach
adds tab-specific sessionId generation, which is stored in and read from localStorage
adds a lot of logging to the frontend code
adds a very rough loading state for initial popup load
My approach here has been to try to build in an 'invisible' way, so the extension should work mostly as it did before. Signing wasn't working for me before, so I've been unable to test it properly.
Explicitly not included in this PR:
TypeScript
Reusability of messaging primatives between JS files (ie there is some duplication right now)
Unit testing of messaging primatives
Standardisation of the JS <-> Swift interface
Session-specific network connections
The above list provides a pretty good roadmap for what I'll be working on this week :)
This PR starts to standardise the messaging format between the different JS files, with the goal of being able to validate and type messages from cradle to grave, from JS to Swift and back again.
The core idea is that all JS files communicate with the following object:
destination
is used to multiplex the browser runtime events channel, and permit more generic method names.method
is currently general-purpose, but will later be typed, dittoparams
.sessionId
is currently unused.It also:
sessionId
generation, which is stored in and read from localStorageMy approach here has been to try to build in an 'invisible' way, so the extension should work mostly as it did before. Signing wasn't working for me before, so I've been unable to test it properly.
Explicitly not included in this PR:
The above list provides a pretty good roadmap for what I'll be working on this week :)