@emotion/cache
Advanced tools
Comparing version 11.13.5 to 11.14.0
@@ -1,2 +0,16 @@ | ||
export * from "../types/index.js" | ||
export { default } from "../types/index.js" | ||
import type { EmotionCache } from '@emotion/utils'; | ||
import { StylisPlugin } from "./types.js"; | ||
export interface Options { | ||
nonce?: string; | ||
stylisPlugins?: Array<StylisPlugin>; | ||
key: string; | ||
container?: Node; | ||
speedy?: boolean; | ||
/** @deprecate use `insertionPoint` instead */ | ||
prepend?: boolean; | ||
insertionPoint?: HTMLElement; | ||
} | ||
declare let createCache: (options: Options) => EmotionCache; | ||
export default createCache; | ||
export type { EmotionCache }; | ||
export type { StylisElement, StylisPlugin, StylisPluginCallback } from "./types.js"; |
@@ -88,4 +88,4 @@ 'use strict'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -350,7 +350,3 @@ | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -364,5 +360,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -389,4 +383,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -398,5 +390,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -413,10 +403,3 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -435,13 +418,3 @@ | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
@@ -457,5 +430,3 @@ | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -462,0 +433,0 @@ sheet: new sheet.StyleSheet({ |
@@ -88,4 +88,4 @@ 'use strict'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -462,5 +462,3 @@ | ||
getSourceMap = function getSourceMap(styles | ||
/*: string */ | ||
) { | ||
getSourceMap = function getSourceMap(styles) { | ||
var matches = styles.match(sourceMapPattern); | ||
@@ -472,7 +470,3 @@ if (!matches) return; | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -490,5 +484,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -521,4 +513,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -530,5 +520,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -545,10 +533,3 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -584,16 +565,6 @@ | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -603,5 +574,3 @@ | ||
currentSheet = { | ||
insert: function insert(rule | ||
/*: string */ | ||
) { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + sourceMap); | ||
@@ -621,5 +590,3 @@ } | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -626,0 +593,0 @@ sheet: new sheet.StyleSheet({ |
@@ -84,4 +84,4 @@ import { StyleSheet } from '@emotion/sheet'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -458,5 +458,3 @@ | ||
getSourceMap = function getSourceMap(styles | ||
/*: string */ | ||
) { | ||
getSourceMap = function getSourceMap(styles) { | ||
var matches = styles.match(sourceMapPattern); | ||
@@ -468,7 +466,3 @@ if (!matches) return; | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -486,5 +480,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -517,4 +509,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -526,5 +516,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -541,10 +529,3 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -580,16 +561,6 @@ | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -599,5 +570,3 @@ | ||
currentSheet = { | ||
insert: function insert(rule | ||
/*: string */ | ||
) { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + sourceMap); | ||
@@ -617,5 +586,3 @@ } | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -622,0 +589,0 @@ sheet: new StyleSheet({ |
@@ -84,4 +84,4 @@ import { StyleSheet } from '@emotion/sheet'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -346,7 +346,3 @@ | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -360,5 +356,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -385,4 +379,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -394,5 +386,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -409,10 +399,3 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -431,13 +414,3 @@ | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
@@ -453,5 +426,3 @@ | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -458,0 +429,0 @@ sheet: new StyleSheet({ |
@@ -95,4 +95,4 @@ 'use strict'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -355,22 +355,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize__default["default"](function () { | ||
return memoize__default["default"](function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -380,7 +363,3 @@ }); | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -394,5 +373,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -419,4 +396,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -428,5 +403,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -443,13 +416,6 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
if (isBrowser) { | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
@@ -465,13 +431,3 @@ var finalizingPlugins = [stylis.stringify, stylis.rulesheet(function (rule) { | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
@@ -496,9 +452,3 @@ | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -513,13 +463,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -554,5 +494,3 @@ var rules = getRules(selector, serialized); | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -559,0 +497,0 @@ sheet: new sheet.StyleSheet({ |
@@ -95,4 +95,4 @@ 'use strict'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -463,22 +463,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize__default["default"](function () { | ||
return memoize__default["default"](function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -492,5 +475,3 @@ }); | ||
getSourceMap = function getSourceMap(styles | ||
/*: string */ | ||
) { | ||
getSourceMap = function getSourceMap(styles) { | ||
var matches = styles.match(sourceMapPattern); | ||
@@ -502,7 +483,3 @@ if (!matches) return; | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -520,5 +497,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -551,4 +526,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -560,5 +533,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -575,10 +546,3 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -595,3 +559,3 @@ | ||
if (isBrowser) { | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
@@ -615,16 +579,6 @@ var finalizingPlugins = [stylis.stringify, function (element) { | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -634,5 +588,3 @@ | ||
currentSheet = { | ||
insert: function insert(rule | ||
/*: string */ | ||
) { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + sourceMap); | ||
@@ -661,9 +613,3 @@ } | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -678,13 +624,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -701,3 +637,3 @@ var rules = getRules(selector, serialized); | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -728,5 +664,3 @@ | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -733,0 +667,0 @@ sheet: new sheet.StyleSheet({ |
@@ -93,4 +93,4 @@ 'use strict'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -461,22 +461,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = weakMemoize__default["default"](function () { | ||
return memoize__default["default"](function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -490,5 +473,3 @@ }); | ||
getSourceMap = function getSourceMap(styles | ||
/*: string */ | ||
) { | ||
getSourceMap = function getSourceMap(styles) { | ||
var matches = styles.match(sourceMapPattern); | ||
@@ -500,7 +481,3 @@ if (!matches) return; | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -522,15 +499,6 @@ | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -547,3 +515,43 @@ | ||
{ | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
var finalizingPlugins = [stylis.stringify, function (element) { | ||
if (!element.root) { | ||
if (element["return"]) { | ||
currentSheet.insert(element["return"]); | ||
} else if (element.value && element.type !== stylis.COMMENT) { | ||
// insert empty rule in non-production environments | ||
// so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet | ||
currentSheet.insert(element.value + "{}"); | ||
} | ||
} | ||
} ]; | ||
var serializer = stylis.middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)); | ||
var stylis$1 = function stylis$1(styles) { | ||
return stylis.serialize(stylis.compile(styles), serializer); | ||
}; | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
if (sourceMap) { | ||
currentSheet = { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + sourceMap); | ||
} | ||
}; | ||
} | ||
} | ||
stylis$1(selector ? selector + "{" + serialized.styles + "}" : serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[serialized.name] = true; | ||
} | ||
}; | ||
} else { | ||
var _finalizingPlugins = [stylis.stringify]; | ||
@@ -559,9 +567,3 @@ | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -576,13 +578,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -599,3 +591,3 @@ var rules = getRules(selector, serialized); | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -626,5 +618,3 @@ | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -631,0 +621,0 @@ sheet: new sheet.StyleSheet({ |
import { StyleSheet } from '@emotion/sheet'; | ||
import { dealloc, alloc, next, token, from, peek, delimit, slice, position, RULESET, combine, match, serialize, copy, replace, WEBKIT, MOZ, MS, KEYFRAMES, DECLARATION, hash, charat, strlen, indexof, middleware, stringify, compile } from 'stylis'; | ||
import { dealloc, alloc, next, token, from, peek, delimit, slice, position, RULESET, combine, match, serialize, copy, replace, WEBKIT, MOZ, MS, KEYFRAMES, DECLARATION, hash, charat, strlen, indexof, middleware, stringify, COMMENT, compile } from 'stylis'; | ||
import weakMemoize from '@emotion/weak-memoize'; | ||
@@ -84,4 +84,4 @@ import memoize from '@emotion/memoize'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -452,22 +452,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = weakMemoize(function () { | ||
return memoize(function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -481,5 +464,3 @@ }); | ||
getSourceMap = function getSourceMap(styles | ||
/*: string */ | ||
) { | ||
getSourceMap = function getSourceMap(styles) { | ||
var matches = styles.match(sourceMapPattern); | ||
@@ -491,7 +472,3 @@ if (!matches) return; | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -513,15 +490,6 @@ | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -538,3 +506,43 @@ | ||
{ | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
var finalizingPlugins = [stringify, function (element) { | ||
if (!element.root) { | ||
if (element["return"]) { | ||
currentSheet.insert(element["return"]); | ||
} else if (element.value && element.type !== COMMENT) { | ||
// insert empty rule in non-production environments | ||
// so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet | ||
currentSheet.insert(element.value + "{}"); | ||
} | ||
} | ||
} ]; | ||
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)); | ||
var stylis = function stylis(styles) { | ||
return serialize(compile(styles), serializer); | ||
}; | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
if (sourceMap) { | ||
currentSheet = { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + sourceMap); | ||
} | ||
}; | ||
} | ||
} | ||
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[serialized.name] = true; | ||
} | ||
}; | ||
} else { | ||
var _finalizingPlugins = [stringify]; | ||
@@ -550,9 +558,3 @@ | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -567,13 +569,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -590,3 +582,3 @@ var rules = getRules(selector, serialized); | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -617,5 +609,3 @@ | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -622,0 +612,0 @@ sheet: new StyleSheet({ |
@@ -86,4 +86,4 @@ import { StyleSheet } from '@emotion/sheet'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -454,22 +454,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () { | ||
return memoize(function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -483,5 +466,3 @@ }); | ||
getSourceMap = function getSourceMap(styles | ||
/*: string */ | ||
) { | ||
getSourceMap = function getSourceMap(styles) { | ||
var matches = styles.match(sourceMapPattern); | ||
@@ -493,7 +474,3 @@ if (!matches) return; | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -511,5 +488,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -542,4 +517,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -551,5 +524,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -566,10 +537,3 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
@@ -586,3 +550,3 @@ | ||
if (isBrowser) { | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
@@ -606,16 +570,6 @@ var finalizingPlugins = [stringify, function (element) { | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -625,5 +579,3 @@ | ||
currentSheet = { | ||
insert: function insert(rule | ||
/*: string */ | ||
) { | ||
insert: function insert(rule) { | ||
sheet.insert(rule + sourceMap); | ||
@@ -652,9 +604,3 @@ } | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -669,13 +615,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -692,3 +628,3 @@ var rules = getRules(selector, serialized); | ||
{ | ||
if (getSourceMap) { | ||
var sourceMap = getSourceMap(serialized.styles); | ||
@@ -719,5 +655,3 @@ | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -724,0 +658,0 @@ sheet: new StyleSheet({ |
@@ -93,4 +93,4 @@ 'use strict'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -353,22 +353,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = weakMemoize__default["default"](function () { | ||
return memoize__default["default"](function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -378,7 +361,3 @@ }); | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -390,18 +369,29 @@ | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
{ | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
var finalizingPlugins = [stylis.stringify, stylis.rulesheet(function (rule) { | ||
currentSheet.insert(rule); | ||
})]; | ||
var serializer = stylis.middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)); | ||
var stylis$1 = function stylis$1(styles) { | ||
return stylis.serialize(stylis.compile(styles), serializer); | ||
}; | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
stylis$1(selector ? selector + "{" + serialized.styles + "}" : serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[serialized.name] = true; | ||
} | ||
}; | ||
} else { | ||
var _finalizingPlugins = [stylis.stringify]; | ||
@@ -417,9 +407,3 @@ | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -434,13 +418,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -475,5 +449,3 @@ var rules = getRules(selector, serialized); | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -480,0 +452,0 @@ sheet: new sheet.StyleSheet({ |
import { StyleSheet } from '@emotion/sheet'; | ||
import { dealloc, alloc, next, token, from, peek, delimit, slice, position, RULESET, combine, match, serialize, copy, replace, WEBKIT, MOZ, MS, KEYFRAMES, DECLARATION, hash, charat, strlen, indexof, middleware, stringify, compile } from 'stylis'; | ||
import { dealloc, alloc, next, token, from, peek, delimit, slice, position, RULESET, combine, match, serialize, copy, replace, WEBKIT, MOZ, MS, KEYFRAMES, DECLARATION, hash, charat, strlen, indexof, stringify, rulesheet, middleware, compile } from 'stylis'; | ||
import weakMemoize from '@emotion/weak-memoize'; | ||
@@ -84,4 +84,4 @@ import memoize from '@emotion/memoize'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -344,22 +344,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = weakMemoize(function () { | ||
return memoize(function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -369,7 +352,3 @@ }); | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -381,18 +360,29 @@ | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
{ | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
var finalizingPlugins = [stringify, rulesheet(function (rule) { | ||
currentSheet.insert(rule); | ||
})]; | ||
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)); | ||
var stylis = function stylis(styles) { | ||
return serialize(compile(styles), serializer); | ||
}; | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles); | ||
if (shouldCache) { | ||
cache.inserted[serialized.name] = true; | ||
} | ||
}; | ||
} else { | ||
var _finalizingPlugins = [stringify]; | ||
@@ -408,9 +398,3 @@ | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -425,13 +409,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -466,5 +440,3 @@ var rules = getRules(selector, serialized); | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -471,0 +443,0 @@ sheet: new StyleSheet({ |
@@ -86,4 +86,4 @@ import { StyleSheet } from '@emotion/sheet'; | ||
var value = element.value, | ||
parent = element.parent; | ||
var value = element.value; | ||
var parent = element.parent; | ||
var isImplicitRule = element.column === parent.column && element.line === parent.line; | ||
@@ -346,22 +346,5 @@ | ||
/* import type { StylisPlugin } from './types' */ | ||
/* | ||
export type Options = { | ||
nonce?: string, | ||
stylisPlugins?: StylisPlugin[], | ||
key: string, | ||
container?: HTMLElement, | ||
speedy?: boolean, | ||
prepend?: boolean, | ||
insertionPoint?: HTMLElement | ||
} | ||
*/ | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () { | ||
return memoize(function () { | ||
var cache = {}; | ||
return function (name) { | ||
return cache[name]; | ||
}; | ||
return {}; | ||
}); | ||
@@ -371,7 +354,3 @@ }); | ||
var createCache = function | ||
/*: EmotionCache */ | ||
createCache(options | ||
/*: Options */ | ||
) { | ||
var createCache = function createCache(options) { | ||
var key = options.key; | ||
@@ -385,5 +364,3 @@ | ||
Array.prototype.forEach.call(ssrStyles, function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
Array.prototype.forEach.call(ssrStyles, function (node) { | ||
// we want to only move elements which have a space in the data-emotion attribute value | ||
@@ -410,4 +387,2 @@ // because that indicates that it is an Emotion 11 server-side rendered style elements | ||
var container; | ||
/* : Node */ | ||
var nodesToHydrate = []; | ||
@@ -419,5 +394,3 @@ | ||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node | ||
/*: HTMLStyleElement */ | ||
) { | ||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) { | ||
var attrib = node.getAttribute("data-emotion").split(' '); | ||
@@ -434,13 +407,6 @@ | ||
var _insert; | ||
/*: ( | ||
selector: string, | ||
serialized: SerializedStyles, | ||
sheet: StyleSheet, | ||
shouldCache: boolean | ||
) => string | void */ | ||
var omnipresentPlugins = [compat, removeLabel]; | ||
if (isBrowser) { | ||
if (!getServerStylisCache) { | ||
var currentSheet; | ||
@@ -456,13 +422,3 @@ var finalizingPlugins = [stringify, rulesheet(function (rule) { | ||
_insert = function | ||
/*: void */ | ||
insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function insert(selector, serialized, sheet, shouldCache) { | ||
currentSheet = sheet; | ||
@@ -487,9 +443,3 @@ | ||
var getRules = function | ||
/*: string */ | ||
getRules(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
) { | ||
var getRules = function getRules(selector, serialized) { | ||
var name = serialized.name; | ||
@@ -504,13 +454,3 @@ | ||
_insert = function | ||
/*: string | void */ | ||
_insert(selector | ||
/*: string */ | ||
, serialized | ||
/*: SerializedStyles */ | ||
, sheet | ||
/*: StyleSheet */ | ||
, shouldCache | ||
/*: boolean */ | ||
) { | ||
_insert = function _insert(selector, serialized, sheet, shouldCache) { | ||
var name = serialized.name; | ||
@@ -545,5 +485,3 @@ var rules = getRules(selector, serialized); | ||
var cache | ||
/*: EmotionCache */ | ||
= { | ||
var cache = { | ||
key: key, | ||
@@ -550,0 +488,0 @@ sheet: new StyleSheet({ |
{ | ||
"name": "@emotion/cache", | ||
"version": "11.13.5", | ||
"version": "11.14.0", | ||
"description": "emotion's cache", | ||
"main": "dist/emotion-cache.cjs.js", | ||
"module": "dist/emotion-cache.esm.js", | ||
"types": "dist/emotion-cache.cjs.d.ts", | ||
"exports": { | ||
@@ -66,14 +67,13 @@ ".": { | ||
"#is-development": { | ||
"development": "./src/conditions/true.js", | ||
"default": "./src/conditions/false.js" | ||
"development": "./src/conditions/true.ts", | ||
"default": "./src/conditions/false.ts" | ||
}, | ||
"#is-browser": { | ||
"edge-light": "./src/conditions/false.js", | ||
"workerd": "./src/conditions/false.js", | ||
"worker": "./src/conditions/false.js", | ||
"browser": "./src/conditions/true.js", | ||
"default": "./src/conditions/is-browser.js" | ||
"edge-light": "./src/conditions/false.ts", | ||
"workerd": "./src/conditions/false.ts", | ||
"worker": "./src/conditions/false.ts", | ||
"browser": "./src/conditions/true.ts", | ||
"default": "./src/conditions/is-browser.ts" | ||
} | ||
}, | ||
"types": "types/index.d.ts", | ||
"license": "MIT", | ||
@@ -94,2 +94,3 @@ "repository": "https://github.com/emotion-js/emotion/tree/main/packages/cache", | ||
"@emotion/hash": "*", | ||
"@types/stylis": "^4.2.7", | ||
"typescript": "^5.4.5" | ||
@@ -99,5 +100,4 @@ }, | ||
"src", | ||
"dist", | ||
"types/*.d.ts" | ||
"dist" | ||
] | ||
} |
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
244106
4
39
6237