🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@emotion/utils

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emotion/utils - npm Package Compare versions

Comparing version
0.8.2
to
0.9.0
+75
dist/utils.cjs.dev.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var isBrowser = typeof document !== 'undefined';
function getRegisteredStyles(registered, registeredStyles, classNames) {
var rawClassName = '';
classNames.split(' ').forEach(function (className) {
if (registered[className] !== undefined) {
registeredStyles.push(registered[className]);
} else {
rawClassName += className + " ";
}
});
return rawClassName;
}
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
var className = cache.key + "-" + serialized.name;
if ( // we only need to add the styles to the registered cache if the
// class name could be used further down
// the tree but if it's a string tag, we know it won't
// so we don't have to add it to registered cache.
// this improves memory usage since we can avoid storing the whole style string
(isStringTag === false || // we need to always store it if we're in compat mode and
// in node since emotion-server relies on whether a style is in
// the registered cache to know whether a style is global or not
// also, note that this check will be dead code eliminated in the browser
isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
cache.registered[className] = serialized.styles;
}
if (cache.inserted[serialized.name] === undefined) {
var stylesForSSR = '';
var current = serialized;
do {
var rules = cache.stylis("." + className, current.styles);
cache.inserted[current.name] = true;
if (process.env.NODE_ENV !== 'production' && current.map !== undefined) {
for (var i = 0; i < rules.length; i++) {
rules[i] += current.map;
}
}
if (isBrowser) {
rules.forEach(cache.sheet.insert, cache.sheet);
} else {
var joinedRules = rules.join('');
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
stylesForSSR += joinedRules;
} else {
// in compat mode, we put the styles on the inserted cache so
// that emotion-server can pull out the styles
cache.inserted[current.name] = joinedRules;
}
}
current = current.next;
} while (current !== undefined);
if (!isBrowser && stylesForSSR.length !== 0) {
return stylesForSSR;
}
}
};
exports.isBrowser = isBrowser;
exports.getRegisteredStyles = getRegisteredStyles;
exports.insertStyles = insertStyles;
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
var isBrowser = "undefined" != typeof document;
function getRegisteredStyles(registered, registeredStyles, classNames) {
var rawClassName = "";
return (
classNames.split(" ").forEach(function(className) {
void 0 !== registered[className]
? registeredStyles.push(registered[className])
: (rawClassName += className + " ");
}),
rawClassName
);
}
var insertStyles = function(cache, serialized, isStringTag) {
var className = cache.key + "-" + serialized.name;
if (
((!1 === isStringTag || (!1 === isBrowser && void 0 !== cache.compat)) &&
void 0 === cache.registered[className] &&
(cache.registered[className] = serialized.styles),
void 0 === cache.inserted[serialized.name])
) {
var stylesForSSR = "",
current = serialized;
do {
var rules = cache.stylis("." + className, current.styles);
if (((cache.inserted[current.name] = !0), isBrowser))
rules.forEach(cache.sheet.insert, cache.sheet);
else {
var joinedRules = rules.join("");
void 0 === cache.compat
? (stylesForSSR += joinedRules)
: (cache.inserted[current.name] = joinedRules);
}
current = current.next;
} while (void 0 !== current);
if (!isBrowser && 0 !== stylesForSSR.length) return stylesForSSR;
}
};
(exports.isBrowser = isBrowser),
(exports.getRegisteredStyles = getRegisteredStyles),
(exports.insertStyles = insertStyles);
// Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
// TypeScript Version: 2.2
export interface RegisteredCache {
[key: string]: string
}
export interface StyleSheet {
container: HTMLElement
nonce?: string
key: string
insert(rule: string): void
flush(): void
tags: Array<HTMLStyleElement>
}
export interface EmotionCache {
stylis(key: string, value: string): Array<string>
inserted: {
[key: string]: string | true
}
registered: RegisteredCache
sheet: StyleSheet
key: string
compat?: true
nonce?: string
}
export interface SerializedStyles {
name: string
styles: string
map?: string
next?: SerializedStyles
}
export const isBrowser: boolean
export function getRegisteredStyles(
registered: RegisteredCache,
registeredStyles: Array<string>,
classNames: string
): string
export function insertStyles(
cache: EmotionCache,
serialized: SerializedStyles,
isStringTag: boolean
): string | void
import {
EmotionCache,
RegisteredCache,
SerializedStyles,
StyleSheet,
getRegisteredStyles,
insertStyles,
isBrowser
} from '@emotion/utils'
declare const testCache: EmotionCache
declare const testRegisteredCache: RegisteredCache
getRegisteredStyles(testRegisteredCache, [], 'abc')
getRegisteredStyles(testRegisteredCache, [], 'abc def')
getRegisteredStyles(testRegisteredCache, [], 'dead end')
getRegisteredStyles(testRegisteredCache, ['color: red;'], 'black parade')
// $ExpectError
getRegisteredStyles()
// $ExpectError
getRegisteredStyles(testRegisteredCache)
insertStyles(
testCache,
{
name: 'abc',
styles: 'color: green;background: red;'
},
false
)
// $ExpectError
insertStyles()
// $ExpectError
insertStyles(testCache)
// $ExpectError
insertStyles(testCache, {})
// $ExpectError
insertStyles(testCache, {
name: 'abc',
styles: 'font-size: 18px;'
})
const test0: boolean = isBrowser
// $ExpectError
const test1: number = isBrowser
{
"compilerOptions": {
"baseUrl": "../",
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": [
"es6",
"dom"
],
"module": "commonjs",
"noEmit": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"target": "es5",
"typeRoots": [
"../"
],
"types": []
},
"include": [
"./*.ts",
"./*.tsx"
]
}
{
"extends": "dtslint/dtslint.json",
"rules": {
"array-type": [
true,
"generic"
],
"semicolon": false
}
}
+1
-1

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.emotionUtils={})}(this,function(e){"use strict";e.isBrowser=!0,e.getRegisteredStyles=function(t,i,e){var n="";return e.split(" ").forEach(function(e){void 0!==t[e]?i.push(t[e]):n+=e+" "}),n},e.insertStyles=function(e,t,i){if(!1===i&&void 0===e.registered[e.key+"-"+t.name]&&(e.registered[e.key+"-"+t.name]=t.styles),void 0===e.inserted[t.name]){var n=e.stylis("."+e.key+"-"+t.name,t.styles);e.inserted[t.name]=!0,n.forEach(e.sheet.insert,e.sheet)}},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.emotionUtils={})}(this,function(e){"use strict";e.isBrowser=!0,e.getRegisteredStyles=function(t,i,e){var s="";return e.split(" ").forEach(function(e){void 0!==t[e]?i.push(t[e]):s+=e+" "}),s},e.insertStyles=function(e,t,i){var s=e.key+"-"+t.name;if(!1===i&&void 0===e.registered[s]&&(e.registered[s]=t.styles),void 0===e.inserted[t.name]){var n=t;do{var o=e.stylis("."+s,n.styles);e.inserted[n.name]=!0,o.forEach(e.sheet.insert,e.sheet),n=n.next}while(void 0!==n)}},Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=index.min.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.min.js","sources":["../src/index.js"],"sourcesContent":["// @flow\nimport type {\n RegisteredCache,\n CSSContextType,\n ScopedInsertableStyles\n} from './types'\n\nexport const isBrowser = typeof document !== 'undefined'\n\nexport function getRegisteredStyles(\n registered: RegisteredCache,\n registeredStyles: string[],\n classNames: string\n) {\n let rawClassName = ''\n\n classNames.split(' ').forEach(className => {\n if (registered[className] !== undefined) {\n registeredStyles.push(registered[className])\n } else {\n rawClassName += `${className} `\n }\n })\n return rawClassName\n}\n\nexport const insertStyles = (\n context: CSSContextType,\n insertable: ScopedInsertableStyles,\n isStringTag: boolean\n) => {\n if (\n // we only need to add the styles to the registered cache if the\n // class name could be used further down\n // the tree but if it's a string tag, we know it won't\n // so we don't have to add it to registered cache.\n // this improves memory usage since we can avoid storing the whole style string\n (isStringTag === false ||\n // we need to always store it if we're in compat mode and\n // in node since emotion-server relies on whether a style is in\n // the registered cache to know whether a style is global or not\n // also, note that this check will be dead code eliminated in the browser\n (isBrowser === false && context.compat !== undefined)) &&\n context.registered[`${context.key}-${insertable.name}`] === undefined\n ) {\n context.registered[`${context.key}-${insertable.name}`] = insertable.styles\n }\n if (context.inserted[insertable.name] === undefined) {\n let rules = context.stylis(\n `.${context.key}-${insertable.name}`,\n insertable.styles\n )\n context.inserted[insertable.name] = true\n\n if (isBrowser) {\n rules.forEach(context.sheet.insert, context.sheet)\n } else {\n let joinedRules = rules.join('')\n if (context.compat === undefined) {\n // in regular mode, we don't set the styles on the inserted cache\n // since we don't need to and that would be wasting memory\n // we return them so that they are rendered in a style tag\n return joinedRules\n } else {\n // in compat mode, we put the styles on the inserted cache so\n // that emotion-server can pull out the styles\n context.inserted[insertable.name] = joinedRules\n }\n }\n }\n}\n\nexport * from './types'\n"],"names":["registered","registeredStyles","classNames","rawClassName","split","forEach","className","undefined","push","context","insertable","isStringTag","key","name","styles","inserted","rules","stylis","sheet","insert"],"mappings":"oOASO,SACLA,EACAC,EACAC,OAEIC,EAAe,UAEnBD,EAAWE,MAAM,KAAKC,QAAQ,SAAAC,QACEC,IAA1BP,EAAWM,GACbL,EAAiBO,KAAKR,EAAWM,IAEjCH,GAAmBG,QAGhBH,kBAGmB,SAC1BM,EACAC,EACAC,OAQmB,IAAhBA,QAM2DJ,IAA5DE,EAAQT,WAAcS,EAAQG,QAAOF,EAAWG,QAEhDJ,EAAQT,WAAcS,EAAQG,QAAOF,EAAWG,MAAUH,EAAWI,aAE7BP,IAAtCE,EAAQM,SAASL,EAAWG,MAAqB,KAC/CG,EAAQP,EAAQQ,WACdR,EAAQG,QAAOF,EAAWG,KAC9BH,EAAWI,QAEbL,EAAQM,SAASL,EAAWG,OAAQ,EAGlCG,EAAMX,QAAQI,EAAQS,MAAMC,OAAQV,EAAQS"}
{"version":3,"file":"index.min.js","sources":["../src/index.js"],"sourcesContent":["// @flow\nimport type { RegisteredCache, EmotionCache, SerializedStyles } from './types'\n\nexport const isBrowser = typeof document !== 'undefined'\n\nexport function getRegisteredStyles(\n registered: RegisteredCache,\n registeredStyles: string[],\n classNames: string\n) {\n let rawClassName = ''\n\n classNames.split(' ').forEach(className => {\n if (registered[className] !== undefined) {\n registeredStyles.push(registered[className])\n } else {\n rawClassName += `${className} `\n }\n })\n return rawClassName\n}\n\nexport const insertStyles = (\n cache: EmotionCache,\n serialized: SerializedStyles,\n isStringTag: boolean\n) => {\n let className = `${cache.key}-${serialized.name}`\n if (\n // we only need to add the styles to the registered cache if the\n // class name could be used further down\n // the tree but if it's a string tag, we know it won't\n // so we don't have to add it to registered cache.\n // this improves memory usage since we can avoid storing the whole style string\n (isStringTag === false ||\n // we need to always store it if we're in compat mode and\n // in node since emotion-server relies on whether a style is in\n // the registered cache to know whether a style is global or not\n // also, note that this check will be dead code eliminated in the browser\n (isBrowser === false && cache.compat !== undefined)) &&\n cache.registered[className] === undefined\n ) {\n cache.registered[className] = serialized.styles\n }\n if (cache.inserted[serialized.name] === undefined) {\n let stylesForSSR = ''\n let current = serialized\n do {\n let rules = cache.stylis(`.${className}`, current.styles)\n cache.inserted[current.name] = true\n\n if (process.env.NODE_ENV !== 'production' && current.map !== undefined) {\n for (let i = 0; i < rules.length; i++) {\n rules[i] += current.map\n }\n }\n if (isBrowser) {\n rules.forEach(cache.sheet.insert, cache.sheet)\n } else {\n let joinedRules = rules.join('')\n if (cache.compat === undefined) {\n // in regular mode, we don't set the styles on the inserted cache\n // since we don't need to and that would be wasting memory\n // we return them so that they are rendered in a style tag\n stylesForSSR += joinedRules\n } else {\n // in compat mode, we put the styles on the inserted cache so\n // that emotion-server can pull out the styles\n cache.inserted[current.name] = joinedRules\n }\n }\n current = current.next\n } while (current !== undefined)\n if (!isBrowser && stylesForSSR.length !== 0) {\n return stylesForSSR\n }\n }\n}\n\nexport * from './types'\n"],"names":["registered","registeredStyles","classNames","rawClassName","split","forEach","className","undefined","push","cache","serialized","isStringTag","key","name","styles","inserted","current","rules","stylis","sheet","insert","next"],"mappings":"oOAKO,SACLA,EACAC,EACAC,OAEIC,EAAe,UAEnBD,EAAWE,MAAM,KAAKC,QAAQ,SAAAC,QACEC,IAA1BP,EAAWM,GACbL,EAAiBO,KAAKR,EAAWM,IAEjCH,GAAmBG,QAGhBH,kBAGmB,SAC1BM,EACAC,EACAC,OAEIL,EAAeG,EAAMG,QAAOF,EAAWG,SAOxB,IAAhBF,QAM+BJ,IAAhCE,EAAMT,WAAWM,KAEjBG,EAAMT,WAAWM,GAAaI,EAAWI,aAEHP,IAApCE,EAAMM,SAASL,EAAWG,MAAqB,KAE7CG,EAAUN,IACX,KACGO,EAAQR,EAAMS,WAAWZ,EAAaU,EAAQF,QAClDL,EAAMM,SAASC,EAAQH,OAAQ,EAQ7BI,EAAMZ,QAAQI,EAAMU,MAAMC,OAAQX,EAAMU,OAc1CH,EAAUA,EAAQK,gBACCd,IAAZS"}

@@ -17,3 +17,5 @@ 'use strict';

}
var insertStyles = function insertStyles(context, insertable, isStringTag) {
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
var className = cache.key + "-" + serialized.name;
if ( // we only need to add the styles to the registered cache if the

@@ -28,13 +30,25 @@ // class name could be used further down

// also, note that this check will be dead code eliminated in the browser
true === false && context.compat !== undefined) && context.registered[context.key + "-" + insertable.name] === undefined) {
context.registered[context.key + "-" + insertable.name] = insertable.styles;
true === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
cache.registered[className] = serialized.styles;
}
if (context.inserted[insertable.name] === undefined) {
var rules = context.stylis("." + context.key + "-" + insertable.name, insertable.styles);
context.inserted[insertable.name] = true;
if (cache.inserted[serialized.name] === undefined) {
var current = serialized;
{
rules.forEach(context.sheet.insert, context.sheet);
}
do {
var rules = cache.stylis("." + className, current.styles);
cache.inserted[current.name] = true;
if (process.env.NODE_ENV !== 'production' && current.map !== undefined) {
for (var i = 0; i < rules.length; i++) {
rules[i] += current.map;
}
}
{
rules.forEach(cache.sheet.insert, cache.sheet);
}
current = current.next;
} while (current !== undefined);
}

@@ -41,0 +55,0 @@ };

@@ -13,3 +13,5 @@ var isBrowser = true;

}
var insertStyles = function insertStyles(context, insertable, isStringTag) {
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
var className = cache.key + "-" + serialized.name;
if ( // we only need to add the styles to the registered cache if the

@@ -24,13 +26,25 @@ // class name could be used further down

// also, note that this check will be dead code eliminated in the browser
true === false && context.compat !== undefined) && context.registered[context.key + "-" + insertable.name] === undefined) {
context.registered[context.key + "-" + insertable.name] = insertable.styles;
true === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
cache.registered[className] = serialized.styles;
}
if (context.inserted[insertable.name] === undefined) {
var rules = context.stylis("." + context.key + "-" + insertable.name, insertable.styles);
context.inserted[insertable.name] = true;
if (cache.inserted[serialized.name] === undefined) {
var current = serialized;
{
rules.forEach(context.sheet.insert, context.sheet);
}
do {
var rules = cache.stylis("." + className, current.styles);
cache.inserted[current.name] = true;
if (process.env.NODE_ENV !== 'production' && current.map !== undefined) {
for (var i = 0; i < rules.length; i++) {
rules[i] += current.map;
}
}
{
rules.forEach(cache.sheet.insert, cache.sheet);
}
current = current.next;
} while (current !== undefined);
}

@@ -37,0 +51,0 @@ };

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var isBrowser = typeof document !== 'undefined';
function getRegisteredStyles(registered, registeredStyles, classNames) {
var rawClassName = '';
classNames.split(' ').forEach(function (className) {
if (registered[className] !== undefined) {
registeredStyles.push(registered[className]);
} else {
rawClassName += className + " ";
}
});
return rawClassName;
if (process.env.NODE_ENV === 'production') {
module.exports = require('./utils.cjs.prod.js');
} else {
module.exports = require('./utils.cjs.dev.js');
}
var insertStyles = function insertStyles(context, insertable, isStringTag) {
if ( // we only need to add the styles to the registered cache if the
// class name could be used further down
// the tree but if it's a string tag, we know it won't
// so we don't have to add it to registered cache.
// this improves memory usage since we can avoid storing the whole style string
(isStringTag === false || // we need to always store it if we're in compat mode and
// in node since emotion-server relies on whether a style is in
// the registered cache to know whether a style is global or not
// also, note that this check will be dead code eliminated in the browser
isBrowser === false && context.compat !== undefined) && context.registered[context.key + "-" + insertable.name] === undefined) {
context.registered[context.key + "-" + insertable.name] = insertable.styles;
}
if (context.inserted[insertable.name] === undefined) {
var rules = context.stylis("." + context.key + "-" + insertable.name, insertable.styles);
context.inserted[insertable.name] = true;
if (isBrowser) {
rules.forEach(context.sheet.insert, context.sheet);
} else {
var joinedRules = rules.join('');
if (context.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
return joinedRules;
} else {
// in compat mode, we put the styles on the inserted cache so
// that emotion-server can pull out the styles
context.inserted[insertable.name] = joinedRules;
}
}
}
};
exports.isBrowser = isBrowser;
exports.getRegisteredStyles = getRegisteredStyles;
exports.insertStyles = insertStyles;

@@ -13,3 +13,5 @@ var isBrowser = typeof document !== 'undefined';

}
var insertStyles = function insertStyles(context, insertable, isStringTag) {
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
var className = cache.key + "-" + serialized.name;
if ( // we only need to add the styles to the registered cache if the

@@ -24,25 +26,42 @@ // class name could be used further down

// also, note that this check will be dead code eliminated in the browser
isBrowser === false && context.compat !== undefined) && context.registered[context.key + "-" + insertable.name] === undefined) {
context.registered[context.key + "-" + insertable.name] = insertable.styles;
isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) {
cache.registered[className] = serialized.styles;
}
if (context.inserted[insertable.name] === undefined) {
var rules = context.stylis("." + context.key + "-" + insertable.name, insertable.styles);
context.inserted[insertable.name] = true;
if (cache.inserted[serialized.name] === undefined) {
var stylesForSSR = '';
var current = serialized;
if (isBrowser) {
rules.forEach(context.sheet.insert, context.sheet);
} else {
var joinedRules = rules.join('');
do {
var rules = cache.stylis("." + className, current.styles);
cache.inserted[current.name] = true;
if (context.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
return joinedRules;
if (process.env.NODE_ENV !== 'production' && current.map !== undefined) {
for (var i = 0; i < rules.length; i++) {
rules[i] += current.map;
}
}
if (isBrowser) {
rules.forEach(cache.sheet.insert, cache.sheet);
} else {
// in compat mode, we put the styles on the inserted cache so
// that emotion-server can pull out the styles
context.inserted[insertable.name] = joinedRules;
var joinedRules = rules.join('');
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
stylesForSSR += joinedRules;
} else {
// in compat mode, we put the styles on the inserted cache so
// that emotion-server can pull out the styles
cache.inserted[current.name] = joinedRules;
}
}
current = current.next;
} while (current !== undefined);
if (!isBrowser && stylesForSSR.length !== 0) {
return stylesForSSR;
}

@@ -49,0 +68,0 @@ }

{
"name": "@emotion/utils",
"version": "0.8.2",
"version": "0.9.0",
"description": "internal utils for emotion",

@@ -16,3 +16,3 @@ "main": "dist/utils.cjs.js",

},
"repository": "https://github.com/emotion-js/emotion/tree/master/next-packages/serialize",
"repository": "https://github.com/emotion-js/emotion/tree/master/packages/serialize",
"publishConfig": {

@@ -23,3 +23,4 @@ "access": "public"

"src",
"dist"
"dist",
"types"
],

@@ -29,4 +30,3 @@ "umd:main": "./dist/index.min.js",

"dtslint": "^0.3.0"
},
"gitHead": "94fed7652759a0f1962da66b922299398e39fe4d"
}
}
// @flow
import type {
RegisteredCache,
CSSContextType,
ScopedInsertableStyles
} from './types'
import type { RegisteredCache, EmotionCache, SerializedStyles } from './types'

@@ -28,6 +24,7 @@ export const isBrowser = typeof document !== 'undefined'

export const insertStyles = (
context: CSSContextType,
insertable: ScopedInsertableStyles,
cache: EmotionCache,
serialized: SerializedStyles,
isStringTag: boolean
) => {
let className = `${cache.key}-${serialized.name}`
if (

@@ -44,28 +41,38 @@ // we only need to add the styles to the registered cache if the

// also, note that this check will be dead code eliminated in the browser
(isBrowser === false && context.compat !== undefined)) &&
context.registered[`${context.key}-${insertable.name}`] === undefined
(isBrowser === false && cache.compat !== undefined)) &&
cache.registered[className] === undefined
) {
context.registered[`${context.key}-${insertable.name}`] = insertable.styles
cache.registered[className] = serialized.styles
}
if (context.inserted[insertable.name] === undefined) {
let rules = context.stylis(
`.${context.key}-${insertable.name}`,
insertable.styles
)
context.inserted[insertable.name] = true
if (cache.inserted[serialized.name] === undefined) {
let stylesForSSR = ''
let current = serialized
do {
let rules = cache.stylis(`.${className}`, current.styles)
cache.inserted[current.name] = true
if (isBrowser) {
rules.forEach(context.sheet.insert, context.sheet)
} else {
let joinedRules = rules.join('')
if (context.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
return joinedRules
if (process.env.NODE_ENV !== 'production' && current.map !== undefined) {
for (let i = 0; i < rules.length; i++) {
rules[i] += current.map
}
}
if (isBrowser) {
rules.forEach(cache.sheet.insert, cache.sheet)
} else {
// in compat mode, we put the styles on the inserted cache so
// that emotion-server can pull out the styles
context.inserted[insertable.name] = joinedRules
let joinedRules = rules.join('')
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
stylesForSSR += joinedRules
} else {
// in compat mode, we put the styles on the inserted cache so
// that emotion-server can pull out the styles
cache.inserted[current.name] = joinedRules
}
}
current = current.next
} while (current !== undefined)
if (!isBrowser && stylesForSSR.length !== 0) {
return stylesForSSR
}

@@ -72,0 +79,0 @@ }

@@ -13,3 +13,3 @@ // @flow

export type CSSContextType = {
export type EmotionCache = {
stylis: (string, string) => Array<string>,

@@ -19,5 +19,5 @@ inserted: { [string]: string | true },

sheet: StyleSheet,
theme: Object,
key: string,
compat?: true
compat?: true,
nonce?: string
}

@@ -27,5 +27,7 @@

export type ScopedInsertableStyles = {|
export type SerializedStyles = {|
name: string,
styles: string
styles: string,
map?: string,
next?: SerializedStyles
|}

Sorry, the diff of this file is not supported yet

The MIT License (MIT)
Copyright (c) 2016 Kye Hohenberger
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.