UNPKG

@visulima/packem

Version:

A fast and modern bundler for Node.js and TypeScript.

2 lines (1 loc) 946 B
"use strict";var y=Object.defineProperty;var u=(r,t)=>y(r,"name",{value:t,configurable:!0});var m=Object.defineProperty,i=u((r,t)=>m(r,"name",{value:t,configurable:!0}),"d");const l=[],o=[],g=i((r,t)=>{if(!r||typeof document>"u")return;const c=t.prepend===!0?"prepend":"append",d=t.singleTag===!0,s=typeof t.container=="string"?document.querySelector(t.container):document.querySelectorAll("head")[0];if(!s)throw new Error("Unable to find container element");const a=i(()=>{const e=document.createElement("style");e.setAttribute("type","text/css"),t.attributes&&Object.entries(t.attributes).forEach(([f,b])=>{e.setAttribute(f,b)});const p=c==="prepend"?"afterbegin":"beforeend";return s.insertAdjacentElement(p,e),e},"createStyleTag");let n;if(d){let e=l.indexOf(s);e===-1&&(e=l.push(s)-1,o[e]={}),o[e][c]||(o[e][c]=a()),n=o[e][c]}else n=a();n.styleSheet?n.styleSheet.cssText+=r:n.append(document.createTextNode(r))},"default");module.exports=g;