index.min.js.map 3.14 KB
{"version":3,"file":"index.min.js","sources":["../src/index.js"],"sourcesContent":["// @flow\nimport type {\n  RegisteredCache,\n  CSSContextType,\n  ScopedInsertableStyles\n} from './types'\n\nexport const isBrowser = typeof document !== 'undefined'\n\nexport function getRegisteredStyles(\n  registered: RegisteredCache,\n  registeredStyles: string[],\n  classNames: string\n) {\n  let rawClassName = ''\n\n  classNames.split(' ').forEach(className => {\n    if (registered[className] !== undefined) {\n      registeredStyles.push(registered[className])\n    } else {\n      rawClassName += `${className} `\n    }\n  })\n  return rawClassName\n}\n\nexport const insertStyles = (\n  context: CSSContextType,\n  insertable: ScopedInsertableStyles,\n  isStringTag: boolean\n) => {\n  if (\n    // we only need to add the styles to the registered cache if the\n    // class name could be used further down\n    // the tree but if it's a string tag, we know it won't\n    // so we don't have to add it to registered cache.\n    // this improves memory usage since we can avoid storing the whole style string\n    (isStringTag === false ||\n      // we need to always store it if we're in compat mode and\n      // in node since emotion-server relies on whether a style is in\n      // the registered cache to know whether a style is global or not\n      // also, note that this check will be dead code eliminated in the browser\n      (isBrowser === false && context.compat !== undefined)) &&\n    context.registered[`${context.key}-${insertable.name}`] === undefined\n  ) {\n    context.registered[`${context.key}-${insertable.name}`] = insertable.styles\n  }\n  if (context.inserted[insertable.name] === undefined) {\n    let rules = context.stylis(\n      `.${context.key}-${insertable.name}`,\n      insertable.styles\n    )\n    context.inserted[insertable.name] = true\n\n    if (isBrowser) {\n      rules.forEach(context.sheet.insert, context.sheet)\n    } else {\n      let joinedRules = rules.join('')\n      if (context.compat === undefined) {\n        // in regular mode, we don't set the styles on the inserted cache\n        // since we don't need to and that would be wasting memory\n        // we return them so that they are rendered in a style tag\n        return joinedRules\n      } else {\n        // in compat mode, we put the styles on the inserted cache so\n        // that emotion-server can pull out the styles\n        context.inserted[insertable.name] = joinedRules\n      }\n    }\n  }\n}\n\nexport * from './types'\n"],"names":["registered","registeredStyles","classNames","rawClassName","split","forEach","className","undefined","push","context","insertable","isStringTag","key","name","styles","inserted","rules","stylis","sheet","insert"],"mappings":"oOASO,SACLA,EACAC,EACAC,OAEIC,EAAe,UAEnBD,EAAWE,MAAM,KAAKC,QAAQ,SAAAC,QACEC,IAA1BP,EAAWM,GACbL,EAAiBO,KAAKR,EAAWM,IAEjCH,GAAmBG,QAGhBH,kBAGmB,SAC1BM,EACAC,EACAC,OAQmB,IAAhBA,QAM2DJ,IAA5DE,EAAQT,WAAcS,EAAQG,QAAOF,EAAWG,QAEhDJ,EAAQT,WAAcS,EAAQG,QAAOF,EAAWG,MAAUH,EAAWI,aAE7BP,IAAtCE,EAAQM,SAASL,EAAWG,MAAqB,KAC/CG,EAAQP,EAAQQ,WACdR,EAAQG,QAAOF,EAAWG,KAC9BH,EAAWI,QAEbL,EAAQM,SAASL,EAAWG,OAAQ,EAGlCG,EAAMX,QAAQI,EAAQS,MAAMC,OAAQV,EAAQS"}