index.min.js.map 2.51 KB
{"version":3,"file":"index.min.js","sources":["../../weak-memoize/src/index.js","../src/index.js"],"sourcesContent":["// @flow\nlet weakMemoize = function<Arg, Return>(func: Arg => Return): Arg => Return {\n  let cache: WeakMap<Arg, Return> = new WeakMap()\n  return arg => {\n    if (cache.has(arg)) {\n      // $FlowFixMe\n      return cache.get(arg)\n    }\n    let ret = func(arg)\n    cache.set(arg, ret)\n    return ret\n  }\n}\n\nexport default weakMemoize\n","// @flow\nimport * as React from 'react'\nimport { withCSSContext, Provider } from '@emotion/core'\nimport weakMemoize from '@emotion/weak-memoize'\n\ntype Props = {\n  theme: Object | (Object => Object),\n  children: React.Node\n}\n\nlet getTheme = (outerTheme: Object, theme: Object | (Object => Object)) => {\n  if (typeof theme === 'function') {\n    const mergedTheme = theme(outerTheme)\n    if (\n      process.env.NODE_ENV !== 'production' &&\n      Object.prototype.toString.call(mergedTheme) !== '[object Object]'\n    ) {\n      throw new Error(\n        '[@emotion/provider] Please return an object from your theme function, i.e. theme={() => ({})}!'\n      )\n    }\n    return mergedTheme\n  }\n  if (\n    process.env.NODE_ENV !== 'production' &&\n    Object.prototype.toString.call(theme) !== '[object Object]'\n  ) {\n    throw new Error(\n      '[@emotion/provider] Please make your theme prop a plain object'\n    )\n  }\n\n  return { ...outerTheme, ...theme }\n}\n\nlet createCreateCacheWithTheme = weakMemoize(cache => {\n  return weakMemoize(theme => {\n    let actualTheme = getTheme(cache.theme, theme)\n    return {\n      ...cache,\n      theme: actualTheme\n    }\n  })\n})\n\nexport default withCSSContext((props: Props, context) => {\n  if (props.theme !== context.theme) {\n    context = createCreateCacheWithTheme(context)(props.theme)\n  }\n  return <Provider value={context}>{props.children}</Provider>\n})\n"],"names":["weakMemoize","func","cache","WeakMap","arg","has","get","ret","set","createCreateCacheWithTheme","theme","outerTheme","actualTheme","withCSSContext","props","context","React.createElement","Provider","value","children"],"mappings":"qeACA,IAAIA,EAAc,SAAsBC,OAClCC,EAA8B,IAAIC,eAC/B,SAAAC,MACDF,EAAMG,IAAID,UAELF,EAAMI,IAAIF,OAEfG,EAAMN,EAAKG,UACfF,EAAMM,IAAIJ,EAAKG,GACRA,ICyBPE,EAA6BT,EAAY,SAAAE,UACpCF,EAAY,SAAAU,OA1BLC,EAAoBD,EA2B5BE,GA3BQD,EA2BeT,EAAMQ,MA1Bd,mBADaA,EA2BQA,GAzBpBA,EAAMC,QAoBhBA,EAAeD,gBAOpBR,GACHQ,MAAOE,eAKEC,iBAAe,SAACC,EAAcC,UACvCD,EAAMJ,QAAUK,EAAQL,QAC1BK,EAAUN,EAA2BM,EAA3BN,CAAoCK,EAAMJ,QAE/CM,gBAACC,YAASC,MAAOH,GAAUD,EAAMK"}