selectoplasm

worker.js

Once you have a state object generated by your config.html, Selectoplasm will pass this object to your web worker. Besides the following boilerplate, the rest of this plugin is entirely up to you. Here's the basic template to get started:

// onmessage is called when the user changes the config
self.onmessage = (event) => {
   const result = run(event.data); // event.data is your config
   self.postMessage(result);
}

function run(config) {
   // your code should go here.

   return { // we'll look at the return object next.
      html: "",
      css: "",
      rulesets: []
   }
}

As you can see, receiving your config is very straightforward. At this stage you might like to console.log the object to confirm your worker is receiving it correctly. If it isn't, double check your config.html for errors.

Now let's look at the return object.