@emotion/cache
Advanced tools
Comparing version 10.0.0-beta.5 to 10.0.0-beta.6
@@ -9,2 +9,3 @@ 'use strict'; | ||
var Stylis = _interopDefault(require('@emotion/stylis')); | ||
require('@emotion/weak-memoize'); | ||
@@ -19,15 +20,12 @@ // https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet | ||
if (block) { | ||
current.push(block + '}'); | ||
Sheet.current.insert(block + '}'); | ||
} | ||
} | ||
var Sheet = { | ||
current: null | ||
}; | ||
var ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) { | ||
switch (context) { | ||
case -1: | ||
{ | ||
current = []; | ||
break; | ||
} | ||
// property | ||
case 1: | ||
@@ -40,3 +38,3 @@ { | ||
if (depth === 0) { | ||
current.push(content + ';'); | ||
Sheet.current.insert(content + ';'); | ||
return ''; | ||
@@ -77,3 +75,3 @@ } | ||
{ | ||
current.push(selectors[0] + content); | ||
Sheet.current.insert(selectors[0] + content); | ||
return ''; | ||
@@ -92,3 +90,2 @@ } | ||
content.split(needle).forEach(toSheet); | ||
return current; | ||
} | ||
@@ -98,4 +95,2 @@ } | ||
var current; | ||
var createCache = function createCache(options) { | ||
@@ -113,3 +108,2 @@ if (options === undefined) options = {}; | ||
var stylis = new Stylis(stylisOptions); | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
@@ -121,21 +115,2 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
@@ -163,4 +138,50 @@ | ||
var _insert; | ||
{ | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
_insert = function insert(selector, serialized, sheet$$1, shouldCache) { | ||
var name = serialized.name; | ||
Sheet.current = sheet$$1; | ||
if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) { | ||
var map = serialized.map; | ||
Sheet.current = { | ||
insert: function insert(rule) { | ||
sheet$$1.insert(rule + map); | ||
} | ||
}; | ||
} | ||
stylis(selector, serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[name] = true; | ||
} | ||
}; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
var cache = { | ||
stylis: stylis, | ||
key: key, | ||
@@ -175,3 +196,4 @@ sheet: new sheet.StyleSheet({ | ||
inserted: inserted, | ||
registered: {} | ||
registered: {}, | ||
insert: _insert | ||
}; | ||
@@ -178,0 +200,0 @@ return cache; |
import { StyleSheet } from '@emotion/sheet'; | ||
import Stylis from '@emotion/stylis'; | ||
import '@emotion/weak-memoize'; | ||
@@ -12,15 +13,12 @@ // https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet | ||
if (block) { | ||
current.push(block + '}'); | ||
Sheet.current.insert(block + '}'); | ||
} | ||
} | ||
var Sheet = { | ||
current: null | ||
}; | ||
var ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) { | ||
switch (context) { | ||
case -1: | ||
{ | ||
current = []; | ||
break; | ||
} | ||
// property | ||
case 1: | ||
@@ -33,3 +31,3 @@ { | ||
if (depth === 0) { | ||
current.push(content + ';'); | ||
Sheet.current.insert(content + ';'); | ||
return ''; | ||
@@ -70,3 +68,3 @@ } | ||
{ | ||
current.push(selectors[0] + content); | ||
Sheet.current.insert(selectors[0] + content); | ||
return ''; | ||
@@ -85,3 +83,2 @@ } | ||
content.split(needle).forEach(toSheet); | ||
return current; | ||
} | ||
@@ -91,4 +88,2 @@ } | ||
var current; | ||
var createCache = function createCache(options) { | ||
@@ -106,3 +101,2 @@ if (options === undefined) options = {}; | ||
var stylis = new Stylis(stylisOptions); | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
@@ -114,21 +108,2 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
@@ -156,4 +131,50 @@ | ||
var _insert; | ||
{ | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
Sheet.current = sheet; | ||
if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) { | ||
var map = serialized.map; | ||
Sheet.current = { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + map); | ||
} | ||
}; | ||
} | ||
stylis(selector, serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[name] = true; | ||
} | ||
}; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
var cache = { | ||
stylis: stylis, | ||
key: key, | ||
@@ -168,3 +189,4 @@ sheet: new StyleSheet({ | ||
inserted: inserted, | ||
registered: {} | ||
registered: {}, | ||
insert: _insert | ||
}; | ||
@@ -171,0 +193,0 @@ return cache; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
var Stylis = _interopDefault(require('@emotion/stylis')); | ||
var weakMemoize = _interopDefault(require('@emotion/weak-memoize')); | ||
@@ -20,15 +21,12 @@ // https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet | ||
if (block) { | ||
current.push(block + '}'); | ||
Sheet.current.insert(block + '}'); | ||
} | ||
} | ||
var Sheet = { | ||
current: null | ||
}; | ||
var ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) { | ||
switch (context) { | ||
case -1: | ||
{ | ||
current = []; | ||
break; | ||
} | ||
// property | ||
case 1: | ||
@@ -41,3 +39,3 @@ { | ||
if (depth === 0) { | ||
current.push(content + ';'); | ||
Sheet.current.insert(content + ';'); | ||
return ''; | ||
@@ -78,3 +76,3 @@ } | ||
{ | ||
current.push(selectors[0] + content); | ||
Sheet.current.insert(selectors[0] + content); | ||
return ''; | ||
@@ -93,9 +91,34 @@ } | ||
content.split(needle).forEach(toSheet); | ||
return current; | ||
} | ||
} | ||
}; | ||
var removeLabel = function removeLabel(context, content) { | ||
if (context === 1 && // charcode for l | ||
content.charCodeAt(0) === 108 && // charcode for b | ||
content.charCodeAt(2) === 98 // this ignores label | ||
) { | ||
return ''; | ||
} | ||
}; | ||
var current; | ||
var rootServerStylisCache = {}; | ||
var getServerStylisCache = utils.isBrowser ? undefined : weakMemoize(function () { | ||
var getCache = weakMemoize(function () { | ||
return {}; | ||
}); | ||
var prefixTrueCache = {}; | ||
var prefixFalseCache = {}; | ||
return function (prefix) { | ||
if (prefix === undefined || prefix === true) { | ||
return prefixTrueCache; | ||
} | ||
if (prefix === false) { | ||
return prefixFalseCache; | ||
} | ||
return getCache(prefix); | ||
}; | ||
}); | ||
var createCache = function createCache(options) { | ||
@@ -113,3 +136,2 @@ if (options === undefined) options = {}; | ||
var stylis = new Stylis(stylisOptions); | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
@@ -121,21 +143,2 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
@@ -163,4 +166,94 @@ | ||
var _insert; | ||
if (utils.isBrowser) { | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
_insert = function insert(selector, serialized, sheet$$1, shouldCache) { | ||
var name = serialized.name; | ||
Sheet.current = sheet$$1; | ||
if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) { | ||
var map = serialized.map; | ||
Sheet.current = { | ||
insert: function insert(rule) { | ||
sheet$$1.insert(rule + map); | ||
} | ||
}; | ||
} | ||
stylis(selector, serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[name] = true; | ||
} | ||
}; | ||
} else { | ||
stylis.use(removeLabel); | ||
var serverStylisCache = rootServerStylisCache; | ||
if (options.stylisPlugins || options.prefix !== undefined) { | ||
stylis.use(options.stylisPlugins); // $FlowFixMe | ||
serverStylisCache = getServerStylisCache(options.stylisPlugins || rootServerStylisCache)(options.prefix); | ||
} | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
if (serverStylisCache[name] === undefined) { | ||
serverStylisCache[name] = stylis(selector, serialized.styles); | ||
} | ||
return serverStylisCache[name]; | ||
}; | ||
_insert = function _insert(selector, serialized, sheet$$1, shouldCache) { | ||
var name = serialized.name; | ||
var rules = getRules(selector, serialized); | ||
if (cache.compat === undefined) { | ||
// in regular mode, we don't set the styles on the inserted cache | ||
// since we don't need to and that would be wasting memory | ||
// we return them so that they are rendered in a style tag | ||
if (shouldCache) { | ||
cache.inserted[name] = true; | ||
} | ||
return rules; | ||
} else { | ||
// in compat mode, we put the styles on the inserted cache so | ||
// that emotion-server can pull out the styles | ||
// except when we don't want to cache it(just the Global component right now) | ||
if (shouldCache) { | ||
cache.inserted[name] = rules; | ||
} else { | ||
return rules; | ||
} | ||
} | ||
}; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
var cache = { | ||
stylis: stylis, | ||
key: key, | ||
@@ -175,3 +268,4 @@ sheet: new sheet.StyleSheet({ | ||
inserted: inserted, | ||
registered: {} | ||
registered: {}, | ||
insert: _insert | ||
}; | ||
@@ -178,0 +272,0 @@ return cache; |
@@ -9,8 +9,9 @@ "use strict"; | ||
Stylis = _interopDefault(require("@emotion/stylis")), | ||
weakMemoize = _interopDefault(require("@emotion/weak-memoize")), | ||
delimiter = "/*|*/", | ||
needle = delimiter + "}"; | ||
function toSheet(block) { | ||
block && current.push(block + "}"); | ||
block && Sheet.current.insert(block + "}"); | ||
} | ||
var current, | ||
var Sheet = { current: null }, | ||
ruleSheet = function( | ||
@@ -29,9 +30,6 @@ context, | ||
switch (context) { | ||
case -1: | ||
current = []; | ||
break; | ||
case 1: | ||
switch (content.charCodeAt(0)) { | ||
case 64: | ||
if (0 === depth) return current.push(content + ";"), ""; | ||
if (0 === depth) return Sheet.current.insert(content + ";"), ""; | ||
break; | ||
@@ -49,3 +47,3 @@ case 108: | ||
case 112: | ||
return current.push(selectors[0] + content), ""; | ||
return Sheet.current.insert(selectors[0] + content), ""; | ||
default: | ||
@@ -55,5 +53,30 @@ return content + (0 === at ? delimiter : ""); | ||
case -2: | ||
return content.split(needle).forEach(toSheet), current; | ||
content.split(needle).forEach(toSheet); | ||
} | ||
}, | ||
removeLabel = function(context, content) { | ||
if ( | ||
1 === context && | ||
108 === content.charCodeAt(0) && | ||
98 === content.charCodeAt(2) | ||
) | ||
return ""; | ||
}, | ||
rootServerStylisCache = {}, | ||
getServerStylisCache = utils.isBrowser | ||
? void 0 | ||
: weakMemoize(function() { | ||
var getCache = weakMemoize(function() { | ||
return {}; | ||
}), | ||
prefixTrueCache = {}, | ||
prefixFalseCache = {}; | ||
return function(prefix) { | ||
return void 0 === prefix || !0 === prefix | ||
? prefixTrueCache | ||
: !1 === prefix | ||
? prefixFalseCache | ||
: getCache(prefix); | ||
}; | ||
}), | ||
createCache = function(options) { | ||
@@ -64,5 +87,5 @@ void 0 === options && (options = {}); | ||
void 0 !== options.prefix && (stylisOptions = { prefix: options.prefix }); | ||
var stylis = new Stylis(stylisOptions); | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
var container, | ||
_insert, | ||
stylis = new Stylis(stylisOptions), | ||
inserted = {}; | ||
@@ -82,4 +105,36 @@ if (utils.isBrowser) { | ||
} | ||
return { | ||
stylis: stylis, | ||
if (utils.isBrowser) | ||
stylis.use(options.stylisPlugins)(ruleSheet), | ||
(_insert = function(selector, serialized, sheet$$1, shouldCache) { | ||
var name = serialized.name; | ||
(Sheet.current = sheet$$1), | ||
stylis(selector, serialized.styles), | ||
shouldCache && (cache.inserted[name] = !0); | ||
}); | ||
else { | ||
stylis.use(removeLabel); | ||
var serverStylisCache = rootServerStylisCache; | ||
(options.stylisPlugins || void 0 !== options.prefix) && | ||
(stylis.use(options.stylisPlugins), | ||
(serverStylisCache = getServerStylisCache( | ||
options.stylisPlugins || rootServerStylisCache | ||
)(options.prefix))); | ||
_insert = function(selector, serialized, sheet$$1, shouldCache) { | ||
var name = serialized.name, | ||
rules = (function(selector, serialized) { | ||
var name = serialized.name; | ||
return ( | ||
void 0 === serverStylisCache[name] && | ||
(serverStylisCache[name] = stylis(selector, serialized.styles)), | ||
serverStylisCache[name] | ||
); | ||
})(selector, serialized); | ||
return void 0 === cache.compat | ||
? (shouldCache && (cache.inserted[name] = !0), rules) | ||
: shouldCache | ||
? void (cache.inserted[name] = rules) | ||
: rules; | ||
}; | ||
} | ||
var cache = { | ||
key: key, | ||
@@ -94,5 +149,7 @@ sheet: new sheet.StyleSheet({ | ||
inserted: inserted, | ||
registered: {} | ||
registered: {}, | ||
insert: _insert | ||
}; | ||
return cache; | ||
}; | ||
exports.default = createCache; |
import { StyleSheet } from '@emotion/sheet'; | ||
import { isBrowser } from '@emotion/utils'; | ||
import Stylis from '@emotion/stylis'; | ||
import weakMemoize from '@emotion/weak-memoize'; | ||
@@ -13,15 +14,12 @@ // https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet | ||
if (block) { | ||
current.push(block + '}'); | ||
Sheet.current.insert(block + '}'); | ||
} | ||
} | ||
var Sheet = { | ||
current: null | ||
}; | ||
var ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) { | ||
switch (context) { | ||
case -1: | ||
{ | ||
current = []; | ||
break; | ||
} | ||
// property | ||
case 1: | ||
@@ -34,3 +32,3 @@ { | ||
if (depth === 0) { | ||
current.push(content + ';'); | ||
Sheet.current.insert(content + ';'); | ||
return ''; | ||
@@ -71,3 +69,3 @@ } | ||
{ | ||
current.push(selectors[0] + content); | ||
Sheet.current.insert(selectors[0] + content); | ||
return ''; | ||
@@ -86,9 +84,34 @@ } | ||
content.split(needle).forEach(toSheet); | ||
return current; | ||
} | ||
} | ||
}; | ||
var removeLabel = function removeLabel(context, content) { | ||
if (context === 1 && // charcode for l | ||
content.charCodeAt(0) === 108 && // charcode for b | ||
content.charCodeAt(2) === 98 // this ignores label | ||
) { | ||
return ''; | ||
} | ||
}; | ||
var current; | ||
var rootServerStylisCache = {}; | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () { | ||
var getCache = weakMemoize(function () { | ||
return {}; | ||
}); | ||
var prefixTrueCache = {}; | ||
var prefixFalseCache = {}; | ||
return function (prefix) { | ||
if (prefix === undefined || prefix === true) { | ||
return prefixTrueCache; | ||
} | ||
if (prefix === false) { | ||
return prefixFalseCache; | ||
} | ||
return getCache(prefix); | ||
}; | ||
}); | ||
var createCache = function createCache(options) { | ||
@@ -106,3 +129,2 @@ if (options === undefined) options = {}; | ||
var stylis = new Stylis(stylisOptions); | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
@@ -114,21 +136,2 @@ if (process.env.NODE_ENV !== 'production') { | ||
} | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
@@ -156,4 +159,94 @@ | ||
var _insert; | ||
if (isBrowser) { | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
Sheet.current = sheet; | ||
if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) { | ||
var map = serialized.map; | ||
Sheet.current = { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + map); | ||
} | ||
}; | ||
} | ||
stylis(selector, serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[name] = true; | ||
} | ||
}; | ||
} else { | ||
stylis.use(removeLabel); | ||
var serverStylisCache = rootServerStylisCache; | ||
if (options.stylisPlugins || options.prefix !== undefined) { | ||
stylis.use(options.stylisPlugins); // $FlowFixMe | ||
serverStylisCache = getServerStylisCache(options.stylisPlugins || rootServerStylisCache)(options.prefix); | ||
} | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
if (serverStylisCache[name] === undefined) { | ||
serverStylisCache[name] = stylis(selector, serialized.styles); | ||
} | ||
return serverStylisCache[name]; | ||
}; | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
var rules = getRules(selector, serialized); | ||
if (cache.compat === undefined) { | ||
// in regular mode, we don't set the styles on the inserted cache | ||
// since we don't need to and that would be wasting memory | ||
// we return them so that they are rendered in a style tag | ||
if (shouldCache) { | ||
cache.inserted[name] = true; | ||
} | ||
return rules; | ||
} else { | ||
// in compat mode, we put the styles on the inserted cache so | ||
// that emotion-server can pull out the styles | ||
// except when we don't want to cache it(just the Global component right now) | ||
if (shouldCache) { | ||
cache.inserted[name] = rules; | ||
} else { | ||
return rules; | ||
} | ||
} | ||
}; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
stylis.use(function (context, content, selectors) { | ||
switch (context) { | ||
case 2: | ||
{ | ||
for (var i = 0, len = selectors.length; len > i; i++) { | ||
// :last-child isn't included here since it's safe | ||
// because a style element will never be the last element | ||
var match = selectors[i].match(/:(first|nth|nth-last)-child/); | ||
if (match !== null) { | ||
console.error("The pseudo class \"" + match[0] + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + match[1] + "-of-type\""); | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
}); | ||
} | ||
var cache = { | ||
stylis: stylis, | ||
key: key, | ||
@@ -168,3 +261,4 @@ sheet: new StyleSheet({ | ||
inserted: inserted, | ||
registered: {} | ||
registered: {}, | ||
insert: _insert | ||
}; | ||
@@ -171,0 +265,0 @@ return cache; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.emotionCache=t()}(this,function(){"use strict";var n=function(){function e(e){this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container}var t=e.prototype;return t.insert=function(e){if(this.ctr%(this.isSpeedy?65e3:1)==0){var t,r=(a=this,(c=document.createElement("style")).setAttribute("data-emotion",a.key),void 0!==a.nonce&&c.setAttribute("nonce",a.nonce),c.appendChild(document.createTextNode("")),c);t=0===this.tags.length?this.before:this.tags[this.tags.length-1].nextSibling,this.container.insertBefore(r,t),this.tags.push(r)}var a,c,s=this.tags[this.tags.length-1];if(this.isSpeedy){var i=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(s);try{var n=105===e.charCodeAt(1)&&64===e.charCodeAt(0);i.insertRule(e,n?0:i.cssRules.length)}catch(e){}}else s.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0},e}();function o(e){function z(e,t,r){var a=t.trim().split(f),c=(t=a).length,s=e.length;switch(s){case 0:case 1:var i=0;for(e=0===s?"":e[0]+" ";i<c;++i)t[i]=h(e,t[i],r).trim();break;default:var n=i=0;for(t=[];i<c;++i)for(var o=0;o<s;++o)t[n++]=h(e[o]+" ",a[i],r).trim()}return t}function h(e,t,r){var a=t.charCodeAt(0);switch(a<33&&(a=(t=t.trim()).charCodeAt(0)),a){case 38:return t.replace(c,"$1"+e.trim());case 58:return e.trim()+t.replace(c,"$1"+e.trim());default:if(0<1*r&&0<t.indexOf("\f"))return t.replace(c,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function E(e,t,r,a){var c=e+";",s=2*t+3*r+4*a;if(944===s){e=c.indexOf(":",9)+1;var i=c.substring(e,c.length-1).trim();return i=c.substring(0,e).trim()+i+";",1===J||2===J&&N(i,1)?"-webkit-"+i+i:i}if(0===J||2===J&&!N(c,1))return c;switch(s){case 1015:return 97===c.charCodeAt(10)?"-webkit-"+c+c:c;case 951:return 116===c.charCodeAt(3)?"-webkit-"+c+c:c;case 963:return 110===c.charCodeAt(5)?"-webkit-"+c+c:c;case 1009:if(100!==c.charCodeAt(4))break;case 969:case 942:return"-webkit-"+c+c;case 978:return"-webkit-"+c+"-moz-"+c+c;case 1019:case 983:return"-webkit-"+c+"-moz-"+c+"-ms-"+c+c;case 883:if(45===c.charCodeAt(8))return"-webkit-"+c+c;if(0<c.indexOf("image-set(",11))return c.replace(p,"$1-webkit-$2")+c;break;case 932:if(45===c.charCodeAt(4))switch(c.charCodeAt(5)){case 103:return"-webkit-box-"+c.replace("-grow","")+"-webkit-"+c+"-ms-"+c.replace("grow","positive")+c;case 115:return"-webkit-"+c+"-ms-"+c.replace("shrink","negative")+c;case 98:return"-webkit-"+c+"-ms-"+c.replace("basis","preferred-size")+c}return"-webkit-"+c+"-ms-"+c+c;case 964:return"-webkit-"+c+"-ms-flex-"+c+c;case 1023:if(99!==c.charCodeAt(8))break;return"-webkit-box-pack"+(i=c.substring(c.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+c+"-ms-flex-pack"+i+c;case 1005:return o.test(c)?c.replace(n,":-webkit-")+c.replace(n,":-moz-")+c:c;case 1e3:switch(t=(i=c.substring(13).trim()).indexOf("-")+1,i.charCodeAt(0)+i.charCodeAt(t)){case 226:i=c.replace(u,"tb");break;case 232:i=c.replace(u,"tb-rl");break;case 220:i=c.replace(u,"lr");break;default:return c}return"-webkit-"+c+"-ms-"+i+c;case 1017:if(-1===c.indexOf("sticky",9))break;case 975:switch(t=(c=e).length-10,s=(i=(33===c.charCodeAt(t)?c.substring(0,t):c).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|i.charCodeAt(7))){case 203:if(i.charCodeAt(8)<111)break;case 115:c=c.replace(i,"-webkit-"+i)+";"+c;break;case 207:case 102:c=c.replace(i,"-webkit-"+(102<s?"inline-":"")+"box")+";"+c.replace(i,"-webkit-"+i)+";"+c.replace(i,"-ms-"+i+"box")+";"+c}return c+";";case 938:if(45===c.charCodeAt(5))switch(c.charCodeAt(6)){case 105:return i=c.replace("-items",""),"-webkit-"+c+"-webkit-box-"+i+"-ms-flex-"+i+c;case 115:return"-webkit-"+c+"-ms-flex-item-"+c.replace(b,"")+c;default:return"-webkit-"+c+"-ms-flex-line-pack"+c.replace("align-content","").replace(b,"")+c}break;case 973:case 989:if(45!==c.charCodeAt(3)||122===c.charCodeAt(4))break;case 931:case 953:if(!0===k.test(e))return 115===(i=e.substring(e.indexOf(":")+1)).charCodeAt(0)?E(e.replace("stretch","fill-available"),t,r,a).replace(":fill-available",":stretch"):c.replace(i,"-webkit-"+i)+c.replace(i,"-moz-"+i.replace("fill-",""))+c;break;case 962:if(c="-webkit-"+c+(102===c.charCodeAt(5)?"-ms-"+c:"")+c,211===r+a&&105===c.charCodeAt(13)&&0<c.indexOf("transform",10))return c.substring(0,c.indexOf(";",27)+1).replace(l,"$1-webkit-$2")+c}return c}function N(e,t){var r=e.indexOf(1===t?":":"{"),a=e.substring(0,3!==t?r:10);return r=e.substring(r+1,e.length-1),i(2!==t?a:a.replace(s,"$1"),r,t)}function j(e,t){var r=E(t,t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2));return r!==t+";"?r.replace(a," or ($1)").substring(4):"("+t+")"}function B(e,t,r,a,c,s,i,n,o,h){for(var l,f=0,u=t;f<L;++f)switch(l=w[f].call(d,e,u,r,a,c,s,i,n,o,h)){case void 0:case!1:case!0:case null:break;default:u=l}if(u!==t)return u}function t(e){return void 0!==(e=e.prefix)&&(i=null,e?"function"!=typeof e?J=1:(J=2,i=e):J=0),t}function d(e,t){var r=e;if(r.charCodeAt(0)<33&&(r=r.trim()),r=[r],0<L){var a=B(-1,t,r,r,H,G,0,0,0,0);void 0!==a&&"string"==typeof a&&(t=a)}var c=function e(t,r,a,c,s){for(var i,n,o,h,l,f=0,u=0,d=0,b=0,k=0,p=0,w=o=i=0,g=0,m=0,A=0,C=0,v=a.length,y=v-1,x="",$="",O="",S="";g<v;){if(n=a.charCodeAt(g),g===y&&0!==u+b+d+f&&(0!==u&&(n=47===u?10:47),b=d=f=0,v++,y++),0===u+b+d+f){if(g===y&&(0<m&&(x=x.replace(T,"")),0<x.trim().length)){switch(n){case 32:case 9:case 59:case 13:case 10:break;default:x+=a.charAt(g)}n=59}switch(n){case 123:for(i=(x=x.trim()).charCodeAt(0),o=1,C=++g;g<v;){switch(n=a.charCodeAt(g)){case 123:o++;break;case 125:o--;break;case 47:switch(n=a.charCodeAt(g+1)){case 42:case 47:e:{for(w=g+1;w<y;++w)switch(a.charCodeAt(w)){case 47:if(42===n&&42===a.charCodeAt(w-1)&&g+2!==w){g=w+1;break e}break;case 10:if(47===n){g=w+1;break e}}g=w}}break;case 91:n++;case 40:n++;case 34:case 39:for(;g++<y&&a.charCodeAt(g)!==n;);}if(0===o)break;g++}switch(o=a.substring(C,g),0===i&&(i=(x=x.replace(R,"").trim()).charCodeAt(0)),i){case 64:switch(0<m&&(x=x.replace(T,"")),n=x.charCodeAt(1)){case 100:case 109:case 115:case 45:m=r;break;default:m=K}if(C=(o=e(r,m,o,n,s+1)).length,0<L&&(l=B(3,o,m=z(K,x,A),r,H,G,C,n,s,c),x=m.join(""),void 0!==l&&0===(C=(o=l.trim()).length)&&(n=0,o="")),0<C)switch(n){case 115:x=x.replace(D,j);case 100:case 109:case 45:o=x+"{"+o+"}";break;case 107:o=(x=x.replace(q,"$1 $2"))+"{"+o+"}",o=1===J||2===J&&N("@"+o,3)?"@-webkit-"+o+"@"+o:"@"+o;break;default:o=x+o,112===c&&($+=o,o="")}else o="";break;default:o=e(r,z(r,x,A),o,c,s+1)}O+=o,o=A=m=w=i=0,x="",n=a.charCodeAt(++g);break;case 125:case 59:if(1<(C=(x=(0<m?x.replace(T,""):x).trim()).length))switch(0===w&&(i=x.charCodeAt(0),45===i||96<i&&i<123)&&(C=(x=x.replace(" ",":")).length),0<L&&void 0!==(l=B(1,x,r,t,H,G,$.length,c,s,c))&&0===(C=(x=l.trim()).length)&&(x="\0\0"),i=x.charCodeAt(0),n=x.charCodeAt(1),i){case 0:break;case 64:if(105===n||99===n){S+=x+a.charAt(g);break}default:58!==x.charCodeAt(C-1)&&($+=E(x,i,n,x.charCodeAt(2)))}A=m=w=i=0,x="",n=a.charCodeAt(++g)}}switch(n){case 13:case 10:47===u?u=0:0===1+i&&107!==c&&0<x.length&&(m=1,x+="\0"),0<L*M&&B(0,x,r,t,H,G,$.length,c,s,c),G=1,H++;break;case 59:case 125:if(0===u+b+d+f){G++;break}default:switch(G++,h=a.charAt(g),n){case 9:case 32:if(0===b+f+u)switch(k){case 44:case 58:case 9:case 32:h="";break;default:32!==n&&(h=" ")}break;case 0:h="\\0";break;case 12:h="\\f";break;case 11:h="\\v";break;case 38:0===b+u+f&&(m=A=1,h="\f"+h);break;case 108:if(0===b+u+f+I&&0<w)switch(g-w){case 2:112===k&&58===a.charCodeAt(g-3)&&(I=k);case 8:111===p&&(I=p)}break;case 58:0===b+u+f&&(w=g);break;case 44:0===u+d+b+f&&(m=1,h+="\r");break;case 34:case 39:0===u&&(b=b===n?0:0===b?n:b);break;case 91:0===b+u+d&&f++;break;case 93:0===b+u+d&&f--;break;case 41:0===b+u+f&&d--;break;case 40:if(0===b+u+f){if(0===i)switch(2*k+3*p){case 533:break;default:i=1}d++}break;case 64:0===u+d+b+f+w+o&&(o=1);break;case 42:case 47:if(!(0<b+f+d))switch(u){case 0:switch(2*n+3*a.charCodeAt(g+1)){case 235:u=47;break;case 220:C=g,u=42}break;case 42:47===n&&42===k&&C+2!==g&&(33===a.charCodeAt(C+2)&&($+=a.substring(C,g+1)),h="",u=0)}}0===u&&(x+=h)}p=k,k=n,g++}if(0<(C=$.length)){if(m=r,0<L&&void 0!==(l=B(2,$,m,t,H,G,C,c,s,c))&&0===($=l).length)return S+$+O;if($=m.join(",")+"{"+$+"}",0!=J*I){switch(2!==J||N($,2)||(I=0),I){case 111:$=$.replace(P,":-moz-$1")+$;break;case 112:$=$.replace(F,"::-webkit-input-$1")+$.replace(F,"::-moz-$1")+$.replace(F,":-ms-input-$1")+$}I=0}}return S+$+O}(K,r,t,0,0);return 0<L&&(void 0!==(a=B(-2,c,r,r,H,G,c.length,0,0,0))&&(c=a)),"",I=0,G=H=1,c}var R=/^\0+/g,T=/[\0\r\f]/g,n=/: */g,o=/zoo|gra/,l=/([,: ])(transform)/g,f=/,\r+?/g,c=/([\t\r\n ])*\f?&/g,q=/@(k\w+)\s*(\S*)\s*/,F=/::(place)/g,P=/:(read-only)/g,u=/[svh]\w+-[tblr]{2}/,D=/\(\s*(.*)\s*\)/g,a=/([\s\S]*?);/g,b=/-self|flex-/g,s=/[^]*?(:[rp][el]a[\w-]+)[^]*/,k=/stretch|:\s*\w+\-(?:conte|avail)/,p=/([^-])(image-set\()/,G=1,H=1,I=0,J=1,K=[],w=[],L=0,i=null,M=0;return d.use=function e(t){switch(t){case void 0:case null:L=w.length=0;break;default:switch(t.constructor){case Array:for(var r=0,a=t.length;r<a;++r)e(t[r]);break;case Function:w[L++]=t;break;case Boolean:M=0|!!t}}return e},d.set=t,void 0!==e&&t(e),d}var l="/*|*/";function f(e){e&&u.push(e+"}")}var u,h=function(e,t,r,a,c,s,i,n,o,h){switch(e){case-1:u=[];break;case 1:switch(t.charCodeAt(0)){case 64:if(0===o)return u.push(t+";"),"";break;case 108:if(98===t.charCodeAt(2))return""}break;case 2:if(0===n)return t+l;break;case 3:switch(n){case 102:case 112:return u.push(r[0]+t),"";default:return t+(0===h?l:"")}case-2:return t.split("/*|*/}").forEach(f),u}};return function(e){void 0===e&&(e={});var t,r=e.key||"css";void 0!==e.prefix&&(t={prefix:e.prefix});var a=new o(t);a.use(e.stylisPlugins)(h);var c,s={};c=e.container||document.head;var i=document.querySelectorAll("style[data-emotion-"+r+"]");return Array.prototype.forEach.call(i,function(e){e.getAttribute("data-emotion-"+r).split(" ").forEach(function(e){s[e]=!0}),e.parentNode!==c&&c.appendChild(e)}),{stylis:a,key:r,sheet:new n({key:r,container:c,nonce:e.nonce,speedy:e.speedy}),nonce:e.nonce,inserted:s,registered:{}}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.emotionCache=t()}(this,function(){"use strict";var h=function(){function e(e){this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container}var t=e.prototype;return t.insert=function(e){if(this.ctr%(this.isSpeedy?65e3:1)==0){var t,r=(a=this,(c=document.createElement("style")).setAttribute("data-emotion",a.key),void 0!==a.nonce&&c.setAttribute("nonce",a.nonce),c.appendChild(document.createTextNode("")),c);t=0===this.tags.length?this.before:this.tags[this.tags.length-1].nextSibling,this.container.insertBefore(r,t),this.tags.push(r)}var a,c,s=this.tags[this.tags.length-1];if(this.isSpeedy){var i=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(s);try{var n=105===e.charCodeAt(1)&&64===e.charCodeAt(0);i.insertRule(e,n?0:i.cssRules.length)}catch(e){}}else s.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0},e}();function l(e){function z(e,t,r){var a=t.trim().split(u),c=(t=a).length,s=e.length;switch(s){case 0:case 1:var i=0;for(e=0===s?"":e[0]+" ";i<c;++i)t[i]=h(e,t[i],r).trim();break;default:var n=i=0;for(t=[];i<c;++i)for(var o=0;o<s;++o)t[n++]=h(e[o]+" ",a[i],r).trim()}return t}function h(e,t,r){var a=t.charCodeAt(0);switch(a<33&&(a=(t=t.trim()).charCodeAt(0)),a){case 38:return t.replace(c,"$1"+e.trim());case 58:return e.trim()+t.replace(c,"$1"+e.trim());default:if(0<1*r&&0<t.indexOf("\f"))return t.replace(c,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function E(e,t,r,a){var c=e+";",s=2*t+3*r+4*a;if(944===s){e=c.indexOf(":",9)+1;var i=c.substring(e,c.length-1).trim();return i=c.substring(0,e).trim()+i+";",1===J||2===J&&N(i,1)?"-webkit-"+i+i:i}if(0===J||2===J&&!N(c,1))return c;switch(s){case 1015:return 97===c.charCodeAt(10)?"-webkit-"+c+c:c;case 951:return 116===c.charCodeAt(3)?"-webkit-"+c+c:c;case 963:return 110===c.charCodeAt(5)?"-webkit-"+c+c:c;case 1009:if(100!==c.charCodeAt(4))break;case 969:case 942:return"-webkit-"+c+c;case 978:return"-webkit-"+c+"-moz-"+c+c;case 1019:case 983:return"-webkit-"+c+"-moz-"+c+"-ms-"+c+c;case 883:if(45===c.charCodeAt(8))return"-webkit-"+c+c;if(0<c.indexOf("image-set(",11))return c.replace(p,"$1-webkit-$2")+c;break;case 932:if(45===c.charCodeAt(4))switch(c.charCodeAt(5)){case 103:return"-webkit-box-"+c.replace("-grow","")+"-webkit-"+c+"-ms-"+c.replace("grow","positive")+c;case 115:return"-webkit-"+c+"-ms-"+c.replace("shrink","negative")+c;case 98:return"-webkit-"+c+"-ms-"+c.replace("basis","preferred-size")+c}return"-webkit-"+c+"-ms-"+c+c;case 964:return"-webkit-"+c+"-ms-flex-"+c+c;case 1023:if(99!==c.charCodeAt(8))break;return"-webkit-box-pack"+(i=c.substring(c.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+c+"-ms-flex-pack"+i+c;case 1005:return o.test(c)?c.replace(n,":-webkit-")+c.replace(n,":-moz-")+c:c;case 1e3:switch(t=(i=c.substring(13).trim()).indexOf("-")+1,i.charCodeAt(0)+i.charCodeAt(t)){case 226:i=c.replace(f,"tb");break;case 232:i=c.replace(f,"tb-rl");break;case 220:i=c.replace(f,"lr");break;default:return c}return"-webkit-"+c+"-ms-"+i+c;case 1017:if(-1===c.indexOf("sticky",9))break;case 975:switch(t=(c=e).length-10,s=(i=(33===c.charCodeAt(t)?c.substring(0,t):c).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|i.charCodeAt(7))){case 203:if(i.charCodeAt(8)<111)break;case 115:c=c.replace(i,"-webkit-"+i)+";"+c;break;case 207:case 102:c=c.replace(i,"-webkit-"+(102<s?"inline-":"")+"box")+";"+c.replace(i,"-webkit-"+i)+";"+c.replace(i,"-ms-"+i+"box")+";"+c}return c+";";case 938:if(45===c.charCodeAt(5))switch(c.charCodeAt(6)){case 105:return i=c.replace("-items",""),"-webkit-"+c+"-webkit-box-"+i+"-ms-flex-"+i+c;case 115:return"-webkit-"+c+"-ms-flex-item-"+c.replace(b,"")+c;default:return"-webkit-"+c+"-ms-flex-line-pack"+c.replace("align-content","").replace(b,"")+c}break;case 973:case 989:if(45!==c.charCodeAt(3)||122===c.charCodeAt(4))break;case 931:case 953:if(!0===k.test(e))return 115===(i=e.substring(e.indexOf(":")+1)).charCodeAt(0)?E(e.replace("stretch","fill-available"),t,r,a).replace(":fill-available",":stretch"):c.replace(i,"-webkit-"+i)+c.replace(i,"-moz-"+i.replace("fill-",""))+c;break;case 962:if(c="-webkit-"+c+(102===c.charCodeAt(5)?"-ms-"+c:"")+c,211===r+a&&105===c.charCodeAt(13)&&0<c.indexOf("transform",10))return c.substring(0,c.indexOf(";",27)+1).replace(l,"$1-webkit-$2")+c}return c}function N(e,t){var r=e.indexOf(1===t?":":"{"),a=e.substring(0,3!==t?r:10);return r=e.substring(r+1,e.length-1),i(2!==t?a:a.replace(s,"$1"),r,t)}function j(e,t){var r=E(t,t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2));return r!==t+";"?r.replace(a," or ($1)").substring(4):"("+t+")"}function B(e,t,r,a,c,s,i,n,o,h){for(var l,u=0,f=t;u<L;++u)switch(l=w[u].call(d,e,f,r,a,c,s,i,n,o,h)){case void 0:case!1:case!0:case null:break;default:f=l}if(f!==t)return f}function t(e){return void 0!==(e=e.prefix)&&(i=null,e?"function"!=typeof e?J=1:(J=2,i=e):J=0),t}function d(e,t){var r=e;if(r.charCodeAt(0)<33&&(r=r.trim()),r=[r],0<L){var a=B(-1,t,r,r,H,G,0,0,0,0);void 0!==a&&"string"==typeof a&&(t=a)}var c=function e(t,r,a,c,s){for(var i,n,o,h,l,u=0,f=0,d=0,b=0,k=0,p=0,w=o=i=0,g=0,m=0,A=0,C=0,v=a.length,y=v-1,x="",$="",O="",S="";g<v;){if(n=a.charCodeAt(g),g===y&&0!==f+b+d+u&&(0!==f&&(n=47===f?10:47),b=d=u=0,v++,y++),0===f+b+d+u){if(g===y&&(0<m&&(x=x.replace(T,"")),0<x.trim().length)){switch(n){case 32:case 9:case 59:case 13:case 10:break;default:x+=a.charAt(g)}n=59}switch(n){case 123:for(i=(x=x.trim()).charCodeAt(0),o=1,C=++g;g<v;){switch(n=a.charCodeAt(g)){case 123:o++;break;case 125:o--;break;case 47:switch(n=a.charCodeAt(g+1)){case 42:case 47:e:{for(w=g+1;w<y;++w)switch(a.charCodeAt(w)){case 47:if(42===n&&42===a.charCodeAt(w-1)&&g+2!==w){g=w+1;break e}break;case 10:if(47===n){g=w+1;break e}}g=w}}break;case 91:n++;case 40:n++;case 34:case 39:for(;g++<y&&a.charCodeAt(g)!==n;);}if(0===o)break;g++}switch(o=a.substring(C,g),0===i&&(i=(x=x.replace(R,"").trim()).charCodeAt(0)),i){case 64:switch(0<m&&(x=x.replace(T,"")),n=x.charCodeAt(1)){case 100:case 109:case 115:case 45:m=r;break;default:m=K}if(C=(o=e(r,m,o,n,s+1)).length,0<L&&(l=B(3,o,m=z(K,x,A),r,H,G,C,n,s,c),x=m.join(""),void 0!==l&&0===(C=(o=l.trim()).length)&&(n=0,o="")),0<C)switch(n){case 115:x=x.replace(D,j);case 100:case 109:case 45:o=x+"{"+o+"}";break;case 107:o=(x=x.replace(q,"$1 $2"))+"{"+o+"}",o=1===J||2===J&&N("@"+o,3)?"@-webkit-"+o+"@"+o:"@"+o;break;default:o=x+o,112===c&&($+=o,o="")}else o="";break;default:o=e(r,z(r,x,A),o,c,s+1)}O+=o,o=A=m=w=i=0,x="",n=a.charCodeAt(++g);break;case 125:case 59:if(1<(C=(x=(0<m?x.replace(T,""):x).trim()).length))switch(0===w&&(i=x.charCodeAt(0),45===i||96<i&&i<123)&&(C=(x=x.replace(" ",":")).length),0<L&&void 0!==(l=B(1,x,r,t,H,G,$.length,c,s,c))&&0===(C=(x=l.trim()).length)&&(x="\0\0"),i=x.charCodeAt(0),n=x.charCodeAt(1),i){case 0:break;case 64:if(105===n||99===n){S+=x+a.charAt(g);break}default:58!==x.charCodeAt(C-1)&&($+=E(x,i,n,x.charCodeAt(2)))}A=m=w=i=0,x="",n=a.charCodeAt(++g)}}switch(n){case 13:case 10:47===f?f=0:0===1+i&&107!==c&&0<x.length&&(m=1,x+="\0"),0<L*M&&B(0,x,r,t,H,G,$.length,c,s,c),G=1,H++;break;case 59:case 125:if(0===f+b+d+u){G++;break}default:switch(G++,h=a.charAt(g),n){case 9:case 32:if(0===b+u+f)switch(k){case 44:case 58:case 9:case 32:h="";break;default:32!==n&&(h=" ")}break;case 0:h="\\0";break;case 12:h="\\f";break;case 11:h="\\v";break;case 38:0===b+f+u&&(m=A=1,h="\f"+h);break;case 108:if(0===b+f+u+I&&0<w)switch(g-w){case 2:112===k&&58===a.charCodeAt(g-3)&&(I=k);case 8:111===p&&(I=p)}break;case 58:0===b+f+u&&(w=g);break;case 44:0===f+d+b+u&&(m=1,h+="\r");break;case 34:case 39:0===f&&(b=b===n?0:0===b?n:b);break;case 91:0===b+f+d&&u++;break;case 93:0===b+f+d&&u--;break;case 41:0===b+f+u&&d--;break;case 40:if(0===b+f+u){if(0===i)switch(2*k+3*p){case 533:break;default:i=1}d++}break;case 64:0===f+d+b+u+w+o&&(o=1);break;case 42:case 47:if(!(0<b+u+d))switch(f){case 0:switch(2*n+3*a.charCodeAt(g+1)){case 235:f=47;break;case 220:C=g,f=42}break;case 42:47===n&&42===k&&C+2!==g&&(33===a.charCodeAt(C+2)&&($+=a.substring(C,g+1)),h="",f=0)}}0===f&&(x+=h)}p=k,k=n,g++}if(0<(C=$.length)){if(m=r,0<L&&void 0!==(l=B(2,$,m,t,H,G,C,c,s,c))&&0===($=l).length)return S+$+O;if($=m.join(",")+"{"+$+"}",0!=J*I){switch(2!==J||N($,2)||(I=0),I){case 111:$=$.replace(P,":-moz-$1")+$;break;case 112:$=$.replace(F,"::-webkit-input-$1")+$.replace(F,"::-moz-$1")+$.replace(F,":-ms-input-$1")+$}I=0}}return S+$+O}(K,r,t,0,0);return 0<L&&(void 0!==(a=B(-2,c,r,r,H,G,c.length,0,0,0))&&(c=a)),"",I=0,G=H=1,c}var R=/^\0+/g,T=/[\0\r\f]/g,n=/: */g,o=/zoo|gra/,l=/([,: ])(transform)/g,u=/,\r+?/g,c=/([\t\r\n ])*\f?&/g,q=/@(k\w+)\s*(\S*)\s*/,F=/::(place)/g,P=/:(read-only)/g,f=/[svh]\w+-[tblr]{2}/,D=/\(\s*(.*)\s*\)/g,a=/([\s\S]*?);/g,b=/-self|flex-/g,s=/[^]*?(:[rp][el]a[\w-]+)[^]*/,k=/stretch|:\s*\w+\-(?:conte|avail)/,p=/([^-])(image-set\()/,G=1,H=1,I=0,J=1,K=[],w=[],L=0,i=null,M=0;return d.use=function e(t){switch(t){case void 0:case null:L=w.length=0;break;default:switch(t.constructor){case Array:for(var r=0,a=t.length;r<a;++r)e(t[r]);break;case Function:w[L++]=t;break;case Boolean:M=0|!!t}}return e},d.set=t,void 0!==e&&t(e),d}var u="/*|*/";function f(e){e&&d.current.insert(e+"}")}var d={current:null},b=function(e,t,r,a,c,s,i,n,o,h){switch(e){case 1:switch(t.charCodeAt(0)){case 64:if(0===o)return d.current.insert(t+";"),"";break;case 108:if(98===t.charCodeAt(2))return""}break;case 2:if(0===n)return t+u;break;case 3:switch(n){case 102:case 112:return d.current.insert(r[0]+t),"";default:return t+(0===h?u:"")}case-2:t.split("/*|*/}").forEach(f)}};return function(e){void 0===e&&(e={});var t,r=e.key||"css";void 0!==e.prefix&&(t={prefix:e.prefix});var a,s=new l(t),c={};a=e.container||document.head;var i,n=document.querySelectorAll("style[data-emotion-"+r+"]");Array.prototype.forEach.call(n,function(e){e.getAttribute("data-emotion-"+r).split(" ").forEach(function(e){c[e]=!0}),e.parentNode!==a&&a.appendChild(e)}),s.use(e.stylisPlugins)(b),i=function(e,t,r,a){var c=t.name;d.current=r,s(e,t.styles),a&&(o.inserted[c]=!0)};var o={key:r,sheet:new h({key:r,container:a,nonce:e.nonce,speedy:e.speedy}),nonce:e.nonce,inserted:c,registered:{},insert:i};return o}}); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@emotion/cache", | ||
"version": "10.0.0-beta.5", | ||
"version": "10.0.0-beta.6", | ||
"description": "emotion's cache", | ||
@@ -16,5 +16,7 @@ "main": "dist/cache.cjs.js", | ||
"@emotion/stylis": "^0.8.0", | ||
"@emotion/utils": "^0.9.0" | ||
"@emotion/utils": "^0.10.0", | ||
"@emotion/weak-memoize": "^0.2.0" | ||
}, | ||
"devDependencies": { | ||
"@emotion/hash": "^0.7.0", | ||
"dtslint": "^0.3.0" | ||
@@ -21,0 +23,0 @@ }, |
154
src/index.js
// @flow | ||
import { StyleSheet } from '@emotion/sheet' | ||
import { isBrowser, type EmotionCache } from '@emotion/utils' | ||
import { | ||
isBrowser, | ||
type EmotionCache, | ||
type SerializedStyles | ||
} from '@emotion/utils' | ||
import Stylis from '@emotion/stylis' | ||
import ruleSheetPlugin from './rule-sheet' | ||
import weakMemoize from '@emotion/weak-memoize' | ||
import { Sheet, removeLabel, ruleSheet } from './stylis-plugins' | ||
import type { StylisPlugin } from './types' | ||
@@ -23,2 +28,21 @@ | ||
let rootServerStylisCache = {} | ||
let getServerStylisCache = isBrowser | ||
? undefined | ||
: weakMemoize(() => { | ||
let getCache = weakMemoize(() => ({})) | ||
let prefixTrueCache = {} | ||
let prefixFalseCache = {} | ||
return prefix => { | ||
if (prefix === undefined || prefix === true) { | ||
return prefixTrueCache | ||
} | ||
if (prefix === false) { | ||
return prefixFalseCache | ||
} | ||
return getCache(prefix) | ||
} | ||
}) | ||
let createCache = (options?: Options): EmotionCache => { | ||
@@ -37,4 +61,2 @@ if (options === undefined) options = {} | ||
stylis.use(options.stylisPlugins)(ruleSheetPlugin) | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -47,2 +69,103 @@ // $FlowFixMe | ||
} | ||
} | ||
let inserted = {} | ||
// $FlowFixMe | ||
let container: HTMLElement | ||
if (isBrowser) { | ||
container = options.container || document.head | ||
const nodes = document.querySelectorAll(`style[data-emotion-${key}]`) | ||
Array.prototype.forEach.call(nodes, (node: HTMLStyleElement) => { | ||
const attrib = node.getAttribute(`data-emotion-${key}`) | ||
// $FlowFixMe | ||
attrib.split(' ').forEach(id => { | ||
inserted[id] = true | ||
}) | ||
if (node.parentNode !== container) { | ||
container.appendChild(node) | ||
} | ||
}) | ||
} | ||
let insert: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void | ||
if (isBrowser) { | ||
stylis.use(options.stylisPlugins)(ruleSheet) | ||
insert = ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
): void => { | ||
let name = serialized.name | ||
Sheet.current = sheet | ||
if ( | ||
process.env.NODE_ENV !== 'production' && | ||
serialized.map !== undefined | ||
) { | ||
let map = serialized.map | ||
Sheet.current = { | ||
insert: (rule: string) => { | ||
sheet.insert(rule + map) | ||
} | ||
} | ||
} | ||
stylis(selector, serialized.styles) | ||
if (shouldCache) { | ||
cache.inserted[name] = true | ||
} | ||
} | ||
} else { | ||
stylis.use(removeLabel) | ||
let serverStylisCache = rootServerStylisCache | ||
if (options.stylisPlugins || options.prefix !== undefined) { | ||
stylis.use(options.stylisPlugins) | ||
// $FlowFixMe | ||
serverStylisCache = getServerStylisCache( | ||
options.stylisPlugins || rootServerStylisCache | ||
)(options.prefix) | ||
} | ||
let getRules = (selector: string, serialized: SerializedStyles): string => { | ||
let name = serialized.name | ||
if (serverStylisCache[name] === undefined) { | ||
serverStylisCache[name] = stylis(selector, serialized.styles) | ||
} | ||
return serverStylisCache[name] | ||
} | ||
insert = ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
): string | void => { | ||
let name = serialized.name | ||
let rules = getRules(selector, serialized) | ||
if (cache.compat === undefined) { | ||
// in regular mode, we don't set the styles on the inserted cache | ||
// since we don't need to and that would be wasting memory | ||
// we return them so that they are rendered in a style tag | ||
if (shouldCache) { | ||
cache.inserted[name] = true | ||
} | ||
return rules | ||
} else { | ||
// in compat mode, we put the styles on the inserted cache so | ||
// that emotion-server can pull out the styles | ||
// except when we don't want to cache it(just the Global component right now) | ||
if (shouldCache) { | ||
cache.inserted[name] = rules | ||
} else { | ||
return rules | ||
} | ||
} | ||
} | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
stylis.use((context, content, selectors) => { | ||
@@ -70,24 +193,4 @@ switch (context) { | ||
} | ||
let inserted = {} | ||
// $FlowFixMe | ||
let container: HTMLElement | ||
if (isBrowser) { | ||
container = options.container || document.head | ||
const nodes = document.querySelectorAll(`style[data-emotion-${key}]`) | ||
Array.prototype.forEach.call(nodes, (node: HTMLStyleElement) => { | ||
const attrib = node.getAttribute(`data-emotion-${key}`) | ||
// $FlowFixMe | ||
attrib.split(' ').forEach(id => { | ||
inserted[id] = true | ||
}) | ||
if (node.parentNode !== container) { | ||
container.appendChild(node) | ||
} | ||
}) | ||
} | ||
const cache: EmotionCache = { | ||
stylis, | ||
key, | ||
@@ -102,3 +205,4 @@ sheet: new StyleSheet({ | ||
inserted, | ||
registered: {} | ||
registered: {}, | ||
insert | ||
} | ||
@@ -105,0 +209,0 @@ return cache |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91994
1300
4
2
17
+ Added@emotion/weak-memoize@^0.2.0
+ Added@emotion/utils@0.10.1(transitive)
+ Added@emotion/weak-memoize@0.2.5(transitive)
- Removed@emotion/utils@0.9.0(transitive)
Updated@emotion/utils@^0.10.0