1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.getHotReplaceTemplate = getHotReplaceTemplate;
7exports.pathToHtmlSafeName = pathToHtmlSafeName;
8exports.wrapDevelopmentCSS = wrapDevelopmentCSS;
9function pathToHtmlSafeName(path) {
10  return path.replace(/[^a-zA-Z0-9_]/g, '_');
11}
12function getHotReplaceTemplate(id) {
13  // In dev mode, we need to replace the style tag instead of appending it
14  // use the path as the expo-css-hmr attribute to find the style tag
15  // to replace.
16  const attr = JSON.stringify(pathToHtmlSafeName(id));
17  return `style.setAttribute('data-expo-css-hmr', ${attr});
18  const previousStyle = document.querySelector('[data-expo-css-hmr=${attr}]');
19  if (previousStyle) {
20    previousStyle.parentNode.removeChild(previousStyle);
21  }`;
22}
23function wrapDevelopmentCSS(props) {
24  return `(() => {
25  if (typeof document === 'undefined') {
26    return
27  }
28  const head = document.head || document.getElementsByTagName('head')[0];
29  const style = document.createElement('style');
30  ${getHotReplaceTemplate(props.filename)}
31  style.setAttribute('data-expo-loader', 'css');
32  head.appendChild(style);
33  const css = \`${props.src.replace(/`/, '`')}\`;
34  if (style.styleSheet){
35    style.styleSheet.cssText = css;
36  } else {
37    style.appendChild(document.createTextNode(css));
38  }
39})();`;
40}
41//# sourceMappingURL=css.js.map