1{"version":3,"file":"css.js","names":["pathToHtmlSafeName","path","replace","getHotReplaceTemplate","id","attr","JSON","stringify","wrapDevelopmentCSS","props","filename","src"],"sources":["../../src/transform-worker/css.ts"],"sourcesContent":["export function pathToHtmlSafeName(path: string) {\n return path.replace(/[^a-zA-Z0-9_]/g, '_');\n}\n\nexport function getHotReplaceTemplate(id: string) {\n // In dev mode, we need to replace the style tag instead of appending it\n // use the path as the expo-css-hmr attribute to find the style tag\n // to replace.\n const attr = JSON.stringify(pathToHtmlSafeName(id));\n return `style.setAttribute('data-expo-css-hmr', ${attr});\n const previousStyle = document.querySelector('[data-expo-css-hmr=${attr}]');\n if (previousStyle) {\n previousStyle.parentNode.removeChild(previousStyle);\n }`;\n}\n\nexport function wrapDevelopmentCSS(props: { src: string; filename: string }) {\n return `(() => {\n if (typeof document === 'undefined') {\n return\n }\n const head = document.head || document.getElementsByTagName('head')[0];\n const style = document.createElement('style');\n ${getHotReplaceTemplate(props.filename)}\n style.setAttribute('data-expo-loader', 'css');\n head.appendChild(style);\n const css = \\`${props.src.replace(/`/, '`')}\\`;\n if (style.styleSheet){\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n})();`;\n}\n"],"mappings":";;;;;;;;AAAO,SAASA,kBAAkB,CAACC,IAAY,EAAE;EAC/C,OAAOA,IAAI,CAACC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAC5C;AAEO,SAASC,qBAAqB,CAACC,EAAU,EAAE;EAChD;EACA;EACA;EACA,MAAMC,IAAI,GAAGC,IAAI,CAACC,SAAS,CAACP,kBAAkB,CAACI,EAAE,CAAC,CAAC;EACnD,OAAQ,2CAA0CC,IAAK;AACzD,qEAAqEA,IAAK;AAC1E;AACA;AACA,IAAI;AACJ;AAEO,SAASG,kBAAkB,CAACC,KAAwC,EAAE;EAC3E,OAAQ;AACV;AACA;AACA;AACA;AACA;AACA,IAAIN,qBAAqB,CAACM,KAAK,CAACC,QAAQ,CAAE;AAC1C;AACA;AACA,kBAAkBD,KAAK,CAACE,GAAG,CAACT,OAAO,CAAC,GAAG,EAAE,GAAG,CAAE;AAC9C;AACA;AACA;AACA;AACA;AACA,MAAM;AACN"}