@wordpress/components
Version:
UI components for WordPress.
8 lines (7 loc) • 2.22 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/style-provider/index.tsx"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport { CacheProvider } from '@emotion/react';\nimport createCache from '@emotion/cache';\nimport * as uuid from 'uuid';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst uuidCache = new Set();\n// Use a weak map so that when the container is detached it's automatically\n// dereferenced to avoid memory leak.\nconst containerCacheMap = new WeakMap();\nconst memoizedCreateCacheWithContainer = container => {\n if (containerCacheMap.has(container)) {\n return containerCacheMap.get(container);\n }\n\n // Emotion only accepts alphabetical and hyphenated keys so we just\n // strip the numbers from the UUID. It _should_ be fine.\n let key = uuid.v4().replace(/[0-9]/g, '');\n while (uuidCache.has(key)) {\n key = uuid.v4().replace(/[0-9]/g, '');\n }\n uuidCache.add(key);\n const cache = createCache({\n container,\n key\n });\n containerCacheMap.set(container, cache);\n return cache;\n};\nexport function StyleProvider(props) {\n const {\n children,\n document\n } = props;\n if (!document) {\n return null;\n }\n const cache = memoizedCreateCacheWithContainer(document.head);\n return /*#__PURE__*/_jsx(CacheProvider, {\n value: cache,\n children: children\n });\n}\nexport default StyleProvider;"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA8B;AAC9B,mBAAwB;AACxB,WAAsB;AAKtB,yBAA4B;AAC5B,IAAM,YAAY,oBAAI,IAAI;AAG1B,IAAM,oBAAoB,oBAAI,QAAQ;AACtC,IAAM,mCAAmC,eAAa;AACpD,MAAI,kBAAkB,IAAI,SAAS,GAAG;AACpC,WAAO,kBAAkB,IAAI,SAAS;AAAA,EACxC;AAIA,MAAI,MAAW,QAAG,EAAE,QAAQ,UAAU,EAAE;AACxC,SAAO,UAAU,IAAI,GAAG,GAAG;AACzB,UAAW,QAAG,EAAE,QAAQ,UAAU,EAAE;AAAA,EACtC;AACA,YAAU,IAAI,GAAG;AACjB,QAAM,YAAQ,aAAAA,SAAY;AAAA,IACxB;AAAA,IACA;AAAA,EACF,CAAC;AACD,oBAAkB,IAAI,WAAW,KAAK;AACtC,SAAO;AACT;AACO,SAAS,cAAc,OAAO;AACnC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI;AACJ,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,iCAAiC,SAAS,IAAI;AAC5D,SAAoB,uCAAAC,KAAK,4BAAe;AAAA,IACtC,OAAO;AAAA,IACP;AAAA,EACF,CAAC;AACH;AACA,IAAO,yBAAQ;",
"names": ["createCache", "_jsx"]
}