Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

css-to-js-sourcemap-worker

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Issues
File Explorer

Advanced tools

css-to-js-sourcemap-worker

The purpose of this package is to generate CSS with arbitrary classes that have sourcemaps to arbitrary lines in JS (at runtime). This may be useful for CSS-in-JS abstractions.

    2.0.5latest
    npm

Version published
Maintainers
1
Weekly downloads
774
increased by16.22%

Weekly downloads

Readme

Source

css-to-js-sourcemap-worker

The purpose of this package is to generate CSS with arbitrary classes that have sourcemaps to arbitrary lines in JS (at runtime). This may be useful for CSS-in-JS abstractions.

Because parsing and generating sourcemaps is expensive, this package provides a web worker implementation so it can be performed off the main thread.

Worker protocol

type MessageToWorker = | {id: "init_wasm", url: string} | { id: "add_mapped_class", className: string, stackInfo: ErrorLikeObject, stackIndex: number } | {id: "set_render_interval", interval: number} | {id: "clear_render_interval"} | {id: "render"} | {id: "invalidate"}; type MessageFromWorker = {id: "render_css", css: string}; type ErrorLikeObject = { stack?: string, stacktrace?: string, message?: string };

Sample usage

const worker = new Worker("https://unpkg.com/css-to-js-sourcemap-worker/worker.js"); worker.onmessage = msg => { const {id, css} = msg.data; if (id === "render_css" && css) { const style = document.createElement("style"); style.appendChild(document.createTextNode(css)); document.head.appendChild(style); } }; const {stack, stacktrace, message} = new Error("create stack trace"); worker.postMessage({ id: "init_wasm", url: "https://unpkg.com/css-to-js-sourcemap-worker/mappings.wasm", }); worker.postMessage({ id: "add_mapped_class", className: "__debug-1", stackInfo: {stack, stacktrace, message}, stackIndex: 0, }); worker.postMessage({ id: "set_render_interval", interval: 120, });

FAQs

Last updated on 08 May 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc