This has a few moving parts.
First, we need a bit of code for keeping track of what other
extensions are installed and enabled. This isn't completely trivial
because we need to listen for "on {en,dis}abled" and "on
{,un}installed" events. This requires a new permission, `management`,
which is _annoying_, but not having this permission would require
extension detection to be done using kludgy messaging hacks that would
be on the critical path for essentially every navigation operation.
Second, we need to write code to talk to the other addons and ask them
if they're handling things. Thankfully they do provide public APIs and
and we can use their sample code to do exactly what we need to do.
Third, it turns out some important chunks of the firefox webext API
aren't handled by the web-ext-browser ts declaration we're
using. They *are* handled by a PR on @types/firefox-webext-browser,
though, so we can copy and paste that to make TS happy.
Fourth, and finally, we need to add some code to the autocontainer
logic to use the compatibility code. This is pretty easy, but
autocontainer logic starts taking a noticeable amount of time becuase
of all the sequences awaits we're doing, so I also have to tweak
things to do all of the async stuff in parallel.
This commit adds searchengine support to tridactyl. Avoiding code
duplication between open and tabopen required changing the way tabopen
works: first, it opens a new tab pointing to Tridactyl's newtab page and
only after that does it actually navigate to where the user wants.
Complete a circular buffer so we don't log too much data, config
settings for turning it on and off (default off, becuase performance)
and for changing the size of the buffer, an excmd for dumping the raw
json so you can pore over it, and for when you just want to
sanity-check yourself instead of groveling over your data for six days
with a deep learning toolkit and three hundred CPUs of compute, an
excmd for pretty-printing your stats in a nice histogram.
I didn't think far enough ahead and only implemented the easy way to
instrument a function, which is with a decorator. I'm getting _really_
angry at typescript not being able to handle decorators on free
functions. bah. I'll figure out a good way to wrap free
functions. Maybe just go the stupid route and make you change
`export async function foo(args)` to `export foo = measured(async
function(args) ...`. But that would break excmd parsing, so... :/
I think that I already want to do a refactor to break excmd.ts into a
bunch of one-line wrappers referencing implementations spread
throughout a bunch of libraries. This would go nicely with that.
Other things I did while I was here:
* Fix the ugliness we had with (window as any).tri by monkey-patching
the tri property into the window object in tridactyl.d.ts
It is already bound to "gr".
Unless and until the keyboard api is ready or Firefox allows
webextensions to inject scripts into the very security-sensitive
about:reader context, this will only switch on reader mode. One
can get out of reader mode, by pressing <Alt-←>.
Once one of the above conditions is met, the toggling should work
without any further changes.
exmode.parser now converts strings to the types given in excmd
signatures.
Messaging now works in both directions (but I haven't made excmds.ts use
the new system yet. Exercise for the reader (see keydown_* state() for a
simple example)).
keys are now being suppressed, but in a pretty stupid way.
I got fed up of not having proper itertools, or str conversions, so I
wrote some. Others have written them in JS, but they were fun to make.
Only the ones I'm using are tested.
Motivation:
- Most test frameworks expect modules
- I'm told they're the future
Changes:
- Every typescript source file is now an es6 module
- Build system is now webpack (tho rollup makes nicer outputs)
- Outputs of buildsystem are one js file per entry point (background,
content, commandline_frame)
- These bundled js files are generated by traversing the dependency
graph of each entry point
In addition to scrollByLine and scrollByPage,
an excmd to scroll by half pages is included to
mimic default <C-u> and <C-d> behavior. In a
future revision, it may be preferred to have some
variable V for scroll values that pulls current
window height when called.