Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-emotion-server

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-emotion-server - npm Package Compare versions

Comparing version 11.0.0-next.0 to 11.0.0-next.10

6

CHANGELOG.md
# create-emotion-server
## 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-emotion-server` to `@emotion/server/create-instance`. Please change any imports of `create-emotion-server` to import `@emotion/server/create-instance` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
## 11.0.0-next.0

@@ -4,0 +10,0 @@

168

dist/create-emotion-server.cjs.dev.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var through = _interopDefault(require('through'));
var tokenize = _interopDefault(require('html-tokenize'));
var pipe = _interopDefault(require('multipipe'));
var createExtractCritical = function createExtractCritical(cache) {
return function (html) {
// parse out ids from html
// reconstruct css/rules/cache to pass
var RGX = new RegExp(cache.key + "-([a-zA-Z0-9-_]+)", 'gm');
var o = {
html: html,
ids: [],
css: ''
};
var match;
var ids = {};
while ((match = RGX.exec(html)) !== null) {
// $FlowFixMe
if (ids[match[1]] === undefined) {
// $FlowFixMe
ids[match[1]] = true;
}
}
o.ids = Object.keys(cache.inserted).filter(function (id) {
if ((ids[id] !== undefined || cache.registered[cache.key + "-" + id] === undefined) && cache.inserted[id] !== true) {
o.css += cache.inserted[id];
return true;
}
});
return o;
};
};
function generateStyleTag(cssKey, ids, styles, nonceString) {
return "<style data-emotion-" + cssKey + "=\"" + ids.substring(1) + "\"" + nonceString + ">" + styles + "</style>";
}
var createRenderStylesToString = function createRenderStylesToString(cache, nonceString) {
return function (html) {
var inserted = cache.inserted,
cssKey = cache.key,
registered = cache.registered;
var regex = new RegExp("<|" + cssKey + "-([a-zA-Z0-9-_]+)", 'gm');
var seen = {};
var result = '';
var globalIds = '';
var globalStyles = '';
for (var id in inserted) {
if (inserted.hasOwnProperty(id)) {
var style = inserted[id];
var key = cssKey + "-" + id;
if (style !== true && registered[key] === undefined) {
globalStyles += style;
globalIds += " " + id;
}
}
}
if (globalStyles !== '') {
result = generateStyleTag(cssKey, globalIds, globalStyles, nonceString);
}
var ids = '';
var styles = '';
var lastInsertionPoint = 0;
var match;
while ((match = regex.exec(html)) !== null) {
// $FlowFixMe
if (match[0] === '<') {
if (ids !== '') {
result += generateStyleTag(cssKey, ids, styles, nonceString);
ids = '';
styles = '';
} // $FlowFixMe
result += html.substring(lastInsertionPoint, match.index); // $FlowFixMe
lastInsertionPoint = match.index;
continue;
} // $FlowFixMe
var _id = match[1];
var _style = inserted[_id];
if (_style === true || _style === undefined || seen[_id]) {
continue;
}
seen[_id] = true;
styles += _style;
ids += " " + _id;
}
result += html.substring(lastInsertionPoint);
return result;
};
};
var createRenderStylesToNodeStream = function createRenderStylesToNodeStream(cache, nonceString) {
return function () {
var insed = {};
var tokenStream = tokenize();
var inlineStream = through(function write(thing) {
var type = thing[0],
data = thing[1];
if (type === 'open') {
var css = '';
var ids = {};
var match;
var fragment = data.toString();
var regex = new RegExp(cache.key + "-([a-zA-Z0-9-_]+)", 'gm');
while ((match = regex.exec(fragment)) !== null) {
if (match !== null && insed[match[1]] === undefined) {
ids[match[1]] = true;
}
}
Object.keys(cache.inserted).forEach(function (id) {
if (cache.inserted[id] !== true && insed[id] === undefined && (ids[id] === true || cache.registered[cache.key + "-" + id] === undefined && (ids[id] = true))) {
insed[id] = true; // $FlowFixMe flow thinks emotion.caches.inserted[id] can be true even though it's checked earlier
css += cache.inserted[id];
}
});
if (css !== '') {
this.queue("<style data-emotion-" + cache.key + "=\"" + Object.keys(ids).join(' ') + "\"" + nonceString + ">" + css + "</style>");
}
}
this.queue(data);
}, function end() {
this.queue(null);
});
return pipe(tokenStream, inlineStream);
};
};
function index (cache) {
if (cache.compat !== true) {
// is this good? should we do this automatically?
// this is only for when using the new apis (not emotion or create-emotion)
cache.compat = true;
}
var nonceString = cache.nonce !== undefined ? " nonce=\"" + cache.nonce + "\"" : '';
return {
extractCritical: createExtractCritical(cache),
renderStylesToString: createRenderStylesToString(cache, nonceString),
renderStylesToNodeStream: createRenderStylesToNodeStream(cache, nonceString)
};
}
exports.default = index;
throw new Error("The `create-emotion-server` package has been moved to `@emotion/server/create-instance`. Please import it like this `import { css } from '@emotion/css'`.");
"use strict";
function _interopDefault(ex) {
return ex && "object" == typeof ex && "default" in ex ? ex.default : ex;
}
Object.defineProperty(exports, "__esModule", {
value: !0
});
var through = _interopDefault(require("through")), tokenize = _interopDefault(require("html-tokenize")), pipe = _interopDefault(require("multipipe")), createExtractCritical = function(cache) {
return function(html) {
for (var match, RGX = new RegExp(cache.key + "-([a-zA-Z0-9-_]+)", "gm"), o = {
html: html,
ids: [],
css: ""
}, ids = {}; null !== (match = RGX.exec(html)); ) void 0 === ids[match[1]] && (ids[match[1]] = !0);
return o.ids = Object.keys(cache.inserted).filter(function(id) {
if ((void 0 !== ids[id] || void 0 === cache.registered[cache.key + "-" + id]) && !0 !== cache.inserted[id]) return o.css += cache.inserted[id],
!0;
}), o;
};
};
function generateStyleTag(cssKey, ids, styles, nonceString) {
return "<style data-emotion-" + cssKey + '="' + ids.substring(1) + '"' + nonceString + ">" + styles + "</style>";
}
var createRenderStylesToString = function(cache, nonceString) {
return function(html) {
var inserted = cache.inserted, cssKey = cache.key, registered = cache.registered, regex = new RegExp("<|" + cssKey + "-([a-zA-Z0-9-_]+)", "gm"), seen = {}, result = "", globalIds = "", globalStyles = "";
for (var id in inserted) if (inserted.hasOwnProperty(id)) {
var style = inserted[id];
!0 !== style && void 0 === registered[cssKey + "-" + id] && (globalStyles += style,
globalIds += " " + id);
}
"" !== globalStyles && (result = generateStyleTag(cssKey, globalIds, globalStyles, nonceString));
for (var match, ids = "", styles = "", lastInsertionPoint = 0; null !== (match = regex.exec(html)); ) if ("<" !== match[0]) {
var _id = match[1], _style = inserted[_id];
!0 === _style || void 0 === _style || seen[_id] || (seen[_id] = !0, styles += _style,
ids += " " + _id);
} else "" !== ids && (result += generateStyleTag(cssKey, ids, styles, nonceString),
ids = "", styles = ""), result += html.substring(lastInsertionPoint, match.index),
lastInsertionPoint = match.index;
return result += html.substring(lastInsertionPoint);
};
}, createRenderStylesToNodeStream = function(cache, nonceString) {
return function() {
var insed = {}, tokenStream = tokenize(), inlineStream = through(function(thing) {
var type = thing[0], data = thing[1];
if ("open" === type) {
for (var match, css = "", ids = {}, fragment = data.toString(), regex = new RegExp(cache.key + "-([a-zA-Z0-9-_]+)", "gm"); null !== (match = regex.exec(fragment)); ) null !== match && void 0 === insed[match[1]] && (ids[match[1]] = !0);
Object.keys(cache.inserted).forEach(function(id) {
!0 !== cache.inserted[id] && void 0 === insed[id] && (!0 === ids[id] || void 0 === cache.registered[cache.key + "-" + id] && (ids[id] = !0)) && (insed[id] = !0,
css += cache.inserted[id]);
}), "" !== css && this.queue("<style data-emotion-" + cache.key + '="' + Object.keys(ids).join(" ") + '"' + nonceString + ">" + css + "</style>");
}
this.queue(data);
}, function() {
this.queue(null);
});
return pipe(tokenStream, inlineStream);
};
};
function index(cache) {
!0 !== cache.compat && (cache.compat = !0);
var nonceString = void 0 !== cache.nonce ? ' nonce="' + cache.nonce + '"' : "";
return {
extractCritical: createExtractCritical(cache),
renderStylesToString: createRenderStylesToString(cache, nonceString),
renderStylesToNodeStream: createRenderStylesToNodeStream(cache, nonceString)
};
}
exports.default = index;
throw new Error("The `create-emotion-server` package has been moved to `@emotion/server/create-instance`. Please import it like this `import { css } from '@emotion/css'`.");
{
"name": "create-emotion-server",
"version": "11.0.0-next.0",
"version": "11.0.0-next.10",
"description": "SSR and style extraction tooling for emotion, The Next Generation of CSS-in-JS.",

@@ -10,17 +10,7 @@ "main": "dist/create-emotion-server.cjs.js",

"dist",
"types"
"types/*.d.ts"
],
"scripts": {
"test:typescript": "dtslint types"
"test:typescript": "exit 0"
},
"dependencies": {
"@emotion/utils": "0.11.2",
"html-tokenize": "^2.0.0",
"multipipe": "^1.0.2",
"through": "^2.3.8"
},
"devDependencies": {
"@types/node": "^10.11.4",
"dtslint": "^0.3.0"
},
"author": "Kye Hohenberger",

@@ -41,6 +31,3 @@ "homepage": "https://emotion.sh",

"url": "https://github.com/emotion-js/emotion/issues"
},
"browser": {
"./dist/create-emotion-server.cjs.js": "./dist/create-emotion-server.browser.cjs.js"
}
}

@@ -1,19 +0,3 @@

// @flow
import type { EmotionCache } from '@emotion/utils'
import createExtractCritical from './extract-critical'
import createRenderStylesToString from './inline'
import createRenderStylesToStream from './stream'
export default function(cache: EmotionCache) {
if (cache.compat !== true) {
// is this good? should we do this automatically?
// this is only for when using the new apis (not emotion or create-emotion)
cache.compat = true
}
const nonceString = cache.nonce !== undefined ? ` nonce="${cache.nonce}"` : ''
return {
extractCritical: createExtractCritical(cache),
renderStylesToString: createRenderStylesToString(cache, nonceString),
renderStylesToNodeStream: createRenderStylesToStream(cache, nonceString)
}
}
throw new Error(
"The `create-emotion-server` package has been moved to `@emotion/server/create-instance`. Please import it like this `import { css } from '@emotion/css'`."
)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc