Workerware
workerware
A simple express-style middleware layer for service workers.
What is Workerware?
Workerware allows for the plugins to be loaded from an external source (i.e IndexedDB), and have it parsed and act as functional middleware.
Usage
workerware is simplistic by design. You just need to import the main library with importScripts
Then you can instantiate a new instance of workerware with the new
keyword.
And finally, you can load a middleware by either importing a script, or loading a compliant function string from a separate source, and calling new Function()
on the string.
Notes:
- The
name
property will be automatically set to either the passed in value,function.prototype.name
, or a random UUID. All depending on the options and passed in values. - The
function
property needs to be a function reference, for example,self.adblockExt.filterRequest()
will likely NOT properly work, as this will pass in the return value of the function, not the function itself.
A valid list of Worker events can be found here
Middlewares can also be deleted by event type or name, by doing the following.
or
This library is still being actively maintained, with features being frequently added. If you have an interesting feature idea, feel free to open an issue about it.
The workerware docs were largely by @wearrrrr.