create-emotion
Advanced tools
Comparing version 11.0.0-next.8 to 11.0.0-next.10
# create-emotion | ||
## 11.0.0-next.10 | ||
### Major Changes | ||
- [`b8476e08`](https://github.com/emotion-js/emotion/commit/b8476e08af4a2e8de94a112cb0daf6e8e4d56fe1) [#1600](https://github.com/emotion-js/emotion/pull/1600) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Move create `create-emotion` to `@emotion/css/create-instance`. Please change any imports of `create-emotion` to import `@emotion/css/create-instance` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`. | ||
## 11.0.0-next.8 | ||
@@ -4,0 +10,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var createCache = _interopDefault(require('@emotion/cache')); | ||
var serialize = require('@emotion/serialize'); | ||
var utils = require('@emotion/utils'); | ||
function insertWithoutScoping(cache, serialized) { | ||
if (cache.inserted[serialized.name] === undefined) { | ||
return cache.insert('', serialized, cache.sheet, true); | ||
} | ||
} | ||
function merge(registered, css, className) { | ||
var registeredStyles = []; | ||
var rawClassName = utils.getRegisteredStyles(registered, registeredStyles, className); | ||
if (registeredStyles.length < 2) { | ||
return className; | ||
} | ||
return rawClassName + css(registeredStyles); | ||
} | ||
var createEmotion = function createEmotion(options) { | ||
var cache = createCache(options); // $FlowFixMe | ||
cache.sheet.speedy = function (value) { | ||
if (process.env.NODE_ENV !== 'production' && this.ctr !== 0) { | ||
throw new Error('speedy must be changed before any rules are inserted'); | ||
} | ||
this.isSpeedy = value; | ||
}; | ||
cache.compat = true; | ||
var css = function css() { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var serialized = serialize.serializeStyles(args, cache.registered, undefined); | ||
utils.insertStyles(cache, serialized, false); | ||
return cache.key + "-" + serialized.name; | ||
}; | ||
var keyframes = function keyframes() { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
var serialized = serialize.serializeStyles(args, cache.registered); | ||
var animation = "animation-" + serialized.name; | ||
insertWithoutScoping(cache, { | ||
name: serialized.name, | ||
styles: "@keyframes " + animation + "{" + serialized.styles + "}" | ||
}); | ||
return animation; | ||
}; | ||
var injectGlobal = function injectGlobal() { | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
var serialized = serialize.serializeStyles(args, cache.registered); | ||
insertWithoutScoping(cache, serialized); | ||
}; | ||
var cx = function cx() { | ||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
args[_key4] = arguments[_key4]; | ||
} | ||
return merge(cache.registered, css, classnames(args)); | ||
}; | ||
return { | ||
css: css, | ||
cx: cx, | ||
injectGlobal: injectGlobal, | ||
keyframes: keyframes, | ||
hydrate: function hydrate(ids) { | ||
ids.forEach(function (key) { | ||
cache.inserted[key] = true; | ||
}); | ||
}, | ||
flush: function flush() { | ||
cache.registered = {}; | ||
cache.inserted = {}; | ||
cache.sheet.flush(); | ||
}, | ||
// $FlowFixMe | ||
sheet: cache.sheet, | ||
cache: cache, | ||
getRegisteredStyles: utils.getRegisteredStyles.bind(null, cache.registered), | ||
merge: merge.bind(null, cache.registered, css) | ||
}; | ||
}; | ||
var classnames = function classnames(args) { | ||
var cls = ''; | ||
for (var i = 0; i < args.length; i++) { | ||
var arg = args[i]; | ||
if (arg == null) continue; | ||
var toAdd = void 0; | ||
switch (typeof arg) { | ||
case 'boolean': | ||
break; | ||
case 'object': | ||
{ | ||
if (Array.isArray(arg)) { | ||
toAdd = classnames(arg); | ||
} else { | ||
toAdd = ''; | ||
for (var k in arg) { | ||
if (arg[k] && k) { | ||
toAdd && (toAdd += ' '); | ||
toAdd += k; | ||
} | ||
} | ||
} | ||
break; | ||
} | ||
default: | ||
{ | ||
toAdd = arg; | ||
} | ||
} | ||
if (toAdd) { | ||
cls && (cls += ' '); | ||
cls += toAdd; | ||
} | ||
} | ||
return cls; | ||
}; | ||
exports.default = createEmotion; | ||
throw new Error("The `create-emotion` package has been moved to `@emotion/css/create-instance`. Please import it like this `import createEmotion from '@emotion/css/create-instance'`."); |
"use strict"; | ||
function _interopDefault(ex) { | ||
return ex && "object" == typeof ex && "default" in ex ? ex.default : ex; | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
}); | ||
var createCache = _interopDefault(require("@emotion/cache")), serialize = require("@emotion/serialize"), utils = require("@emotion/utils"); | ||
function insertWithoutScoping(cache, serialized) { | ||
if (void 0 === cache.inserted[serialized.name]) return cache.insert("", serialized, cache.sheet, !0); | ||
} | ||
function merge(registered, css, className) { | ||
var registeredStyles = [], rawClassName = utils.getRegisteredStyles(registered, registeredStyles, className); | ||
return registeredStyles.length < 2 ? className : rawClassName + css(registeredStyles); | ||
} | ||
var createEmotion = function(options) { | ||
var cache = createCache(options); | ||
cache.sheet.speedy = function(value) { | ||
this.isSpeedy = value; | ||
}, cache.compat = !0; | ||
var css = function() { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key]; | ||
var serialized = serialize.serializeStyles(args, cache.registered, void 0); | ||
return utils.insertStyles(cache, serialized, !1), cache.key + "-" + serialized.name; | ||
}; | ||
return { | ||
css: css, | ||
cx: function() { | ||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4]; | ||
return merge(cache.registered, css, classnames(args)); | ||
}, | ||
injectGlobal: function() { | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) args[_key3] = arguments[_key3]; | ||
var serialized = serialize.serializeStyles(args, cache.registered); | ||
insertWithoutScoping(cache, serialized); | ||
}, | ||
keyframes: function() { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) args[_key2] = arguments[_key2]; | ||
var serialized = serialize.serializeStyles(args, cache.registered), animation = "animation-" + serialized.name; | ||
return insertWithoutScoping(cache, { | ||
name: serialized.name, | ||
styles: "@keyframes " + animation + "{" + serialized.styles + "}" | ||
}), animation; | ||
}, | ||
hydrate: function(ids) { | ||
ids.forEach((function(key) { | ||
cache.inserted[key] = !0; | ||
})); | ||
}, | ||
flush: function() { | ||
cache.registered = {}, cache.inserted = {}, cache.sheet.flush(); | ||
}, | ||
sheet: cache.sheet, | ||
cache: cache, | ||
getRegisteredStyles: utils.getRegisteredStyles.bind(null, cache.registered), | ||
merge: merge.bind(null, cache.registered, css) | ||
}; | ||
}, classnames = function classnames(args) { | ||
for (var cls = "", i = 0; i < args.length; i++) { | ||
var arg = args[i]; | ||
if (null != arg) { | ||
var toAdd = void 0; | ||
switch (typeof arg) { | ||
case "boolean": | ||
break; | ||
case "object": | ||
if (Array.isArray(arg)) toAdd = classnames(arg); else for (var k in toAdd = "", | ||
arg) arg[k] && k && (toAdd && (toAdd += " "), toAdd += k); | ||
break; | ||
default: | ||
toAdd = arg; | ||
} | ||
toAdd && (cls && (cls += " "), cls += toAdd); | ||
} | ||
} | ||
return cls; | ||
}; | ||
exports.default = createEmotion; | ||
throw new Error("The `create-emotion` package has been moved to `@emotion/css/create-instance`. Please import it like this `import createEmotion from '@emotion/css/create-instance'`."); |
{ | ||
"name": "create-emotion", | ||
"version": "11.0.0-next.8", | ||
"version": "11.0.0-next.10", | ||
"description": "The Next Generation of CSS-in-JS.", | ||
"main": "dist/create-emotion.cjs.js", | ||
"module": "dist/create-emotion.esm.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
@@ -14,19 +12,8 @@ "src", | ||
"scripts": { | ||
"test:typescript": "dtslint types" | ||
"test:typescript": "exit 0" | ||
}, | ||
"dependencies": { | ||
"@emotion/cache": "^11.0.0-next.6", | ||
"@emotion/serialize": "^0.12.0-next.3", | ||
"@emotion/sheet": "0.10.0-next.0", | ||
"@emotion/utils": "0.11.2" | ||
}, | ||
"devDependencies": { | ||
"babel-plugin-transform-define": "^1.3.0", | ||
"create-emotion-server": "11.0.0-next.0", | ||
"dtslint": "^0.3.0" | ||
}, | ||
"author": "Kye Hohenberger", | ||
"homepage": "https://emotion.sh", | ||
"license": "MIT", | ||
"repository": "https://github.com/emotion-js/emotion/tree/master/packages/create-emotion", | ||
"repository": "https://github.com/emotion-js/emotion/tree/master/removed-packages/create-emotion", | ||
"keywords": [ | ||
@@ -41,7 +28,3 @@ "styles", | ||
"url": "https://github.com/emotion-js/emotion/issues" | ||
}, | ||
"browser": { | ||
"./dist/create-emotion.cjs.js": "./dist/create-emotion.browser.cjs.js", | ||
"./dist/create-emotion.esm.js": "./dist/create-emotion.browser.esm.js" | ||
} | ||
} |
164
src/index.js
@@ -1,161 +0,3 @@ | ||
// @flow | ||
import createCache from '@emotion/cache' | ||
import { serializeStyles } from '@emotion/serialize' | ||
import { | ||
insertStyles, | ||
getRegisteredStyles, | ||
type EmotionCache, | ||
type SerializedStyles | ||
} from '@emotion/utils' | ||
function insertWithoutScoping(cache, serialized: SerializedStyles) { | ||
if (cache.inserted[serialized.name] === undefined) { | ||
return cache.insert('', serialized, cache.sheet, true) | ||
} | ||
} | ||
function merge(registered: Object, css: (*) => string, className: string) { | ||
const registeredStyles = [] | ||
const rawClassName = getRegisteredStyles( | ||
registered, | ||
registeredStyles, | ||
className | ||
) | ||
if (registeredStyles.length < 2) { | ||
return className | ||
} | ||
return rawClassName + css(registeredStyles) | ||
} | ||
export type Interpolation = any | ||
export type Interpolations = Array<Interpolation> | ||
type CreateStyles<ReturnValue> = (...args: Interpolations) => ReturnValue | ||
type ClassNameArg = | ||
| string | ||
| boolean | ||
| { [key: string]: boolean | void | null } | ||
| Array<ClassNameArg> | ||
| void | ||
| null | ||
declare class StyleSheet { | ||
insert(rule: string): void; | ||
flush(): void; | ||
speedy(newVal: boolean): void; | ||
tags: Array<HTMLStyleElement>; | ||
isSpeedy: number; | ||
ctr: number; | ||
} | ||
export type Emotion = { | ||
css: CreateStyles<string>, | ||
cx: (...classNames: Array<ClassNameArg>) => string, | ||
flush: () => void, | ||
hydrate: (ids: Array<string>) => void, | ||
injectGlobal: CreateStyles<void>, | ||
keyframes: CreateStyles<string>, | ||
sheet: StyleSheet, | ||
cache: EmotionCache, | ||
merge: *, | ||
getRegisteredStyles: * | ||
} | ||
let createEmotion = (options: *): Emotion => { | ||
let cache = createCache(options) | ||
// $FlowFixMe | ||
cache.sheet.speedy = function(value: boolean) { | ||
if (process.env.NODE_ENV !== 'production' && this.ctr !== 0) { | ||
throw new Error('speedy must be changed before any rules are inserted') | ||
} | ||
this.isSpeedy = value | ||
} | ||
cache.compat = true | ||
let css = (...args) => { | ||
let serialized = serializeStyles(args, cache.registered, undefined) | ||
insertStyles(cache, serialized, false) | ||
return `${cache.key}-${serialized.name}` | ||
} | ||
let keyframes = (...args) => { | ||
let serialized = serializeStyles(args, cache.registered) | ||
let animation = `animation-${serialized.name}` | ||
insertWithoutScoping(cache, { | ||
name: serialized.name, | ||
styles: `@keyframes ${animation}{${serialized.styles}}` | ||
}) | ||
return animation | ||
} | ||
let injectGlobal = (...args) => { | ||
let serialized = serializeStyles(args, cache.registered) | ||
insertWithoutScoping(cache, serialized) | ||
} | ||
let cx = (...args) => { | ||
return merge(cache.registered, css, classnames(args)) | ||
} | ||
return { | ||
css, | ||
cx, | ||
injectGlobal, | ||
keyframes, | ||
hydrate(ids: Array<string>) { | ||
ids.forEach(key => { | ||
cache.inserted[key] = true | ||
}) | ||
}, | ||
flush() { | ||
cache.registered = {} | ||
cache.inserted = {} | ||
cache.sheet.flush() | ||
}, | ||
// $FlowFixMe | ||
sheet: cache.sheet, | ||
cache, | ||
getRegisteredStyles: getRegisteredStyles.bind(null, cache.registered), | ||
merge: merge.bind(null, cache.registered, css) | ||
} | ||
} | ||
let classnames = args => { | ||
let cls = '' | ||
for (let i = 0; i < args.length; i++) { | ||
let arg = args[i] | ||
if (arg == null) continue | ||
let toAdd | ||
switch (typeof arg) { | ||
case 'boolean': | ||
break | ||
case 'object': { | ||
if (Array.isArray(arg)) { | ||
toAdd = classnames(arg) | ||
} else { | ||
toAdd = '' | ||
for (const k in arg) { | ||
if (arg[k] && k) { | ||
toAdd && (toAdd += ' ') | ||
toAdd += k | ||
} | ||
} | ||
} | ||
break | ||
} | ||
default: { | ||
toAdd = arg | ||
} | ||
} | ||
if (toAdd) { | ||
cls && (cls += ' ') | ||
cls += toAdd | ||
} | ||
} | ||
return cls | ||
} | ||
export default createEmotion | ||
throw new Error( | ||
"The `create-emotion` package has been moved to `@emotion/css/create-instance`. Please import it like this `import createEmotion from '@emotion/css/create-instance'`." | ||
) |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
0
2
3684
6
13
1
0
1
- Removed@emotion/cache@^11.0.0-next.6
- Removed@emotion/serialize@^0.12.0-next.3
- Removed@emotion/sheet@0.10.0-next.0
- Removed@emotion/utils@0.11.2
- Removed@emotion/cache@11.13.1(transitive)
- Removed@emotion/hash@0.7.3(transitive)
- Removed@emotion/memoize@0.7.30.9.0(transitive)
- Removed@emotion/serialize@0.12.0-next.3(transitive)
- Removed@emotion/sheet@0.10.0-next.01.4.0(transitive)
- Removed@emotion/unitless@0.7.4(transitive)
- Removed@emotion/utils@0.11.21.4.1(transitive)
- Removed@emotion/weak-memoize@0.4.0(transitive)
- Removedcsstype@2.6.21(transitive)
- Removedstylis@4.2.0(transitive)