We couldn't have just invoked "check for updates" on every single
operation because it would've gone out to the RSS every time. This
refactor permits it to cache a highest known version for a
configurable interval. It should be safe to invoke this new
update-checking logic as frequently as desired.
BGSELF was a hack that I used when implementing ex commands for the
command line. It consisted of having .excmds_background.generated.ts
import itself as BGSELF in order to dynamically add commands to it. This
let us define excmds in other files while not changing anything in
parsers/exmode.ts.
This was awful so I decided to remove it. This required performing the
following changes:
- Moving text.* and ex.* command definitions to their own files where
they have zero side effects. While this was easy for text commands, ex
commands rely a lot on side effects. In order to work around this,
lib/commandline_cmds exports a single function, getCommandlineFns(),
which expects an object representing the commandline's state as
parameter.
- In the background script, import our side effect free files and wrap
them in proxys that will send "commandline_cmd" and "editorfn_content"
messages to tabs when needed.
- In the content script, add a listener that will either execute an
editor function or forward it to the command line when it receives an
"editorfn_content" message.
- In the commandline script, add a listener that will execute exmode
commands.
Apparently I have to run the prettifier before I can touch this file?
This behavior is actually pretty simple: If -c isn't set, check to see
if there's an autocontainer directive that matches the url. If there
is a matching container, go ahead and use it.
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 rule requires adding a new set of rules, tslint-etc.
no-unused-declaration used to be available in tslint:recommended but was
deprecated when --noUnusedVariables was added to typescript. The problem
with using TypeScript's --noUnusedVariables is that it turns unused
declarations into an error and prevents compilation, which isn't fun
when you're just prototyping things.
The no-misleading-array-reverse rule prevents using .sort() and
.reverse() in chains because this make these calls look like they return
a new sorted/reversed slice. But the truth is, these functions modify
the array in place and return that same array, which could cause quite a
lot of confusion if you don't expect that.
This rule enforces using `x as y` instead of `<y>x` in order to cast
elements. This makes things easier to read and protects against
conflicts with tsx.
The forin rule forbids using the `for (let key in object)` syntax. This
is because iterating with `for in` also iterates over keys obtained from
prototypal inheritance. This is most of the time wrong and using `for
(let key of Object.keys(object)` protects against that.
This rule requires that all single line comments must start with a
space, i.e. `//hello` is forbidden and `// hello` is allowed.
This made me discover a few pre-processor macro in files that aren't
taken into account by the macro-preprocessor and so I've decided to
remove these directives.
Note that this rule must stay disabled for excmds.ts as it would break
our preprocessor macros.