create-emotion-server
Advanced tools
Comparing version 11.0.0-next.0 to 11.0.0-next.10
# 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 @@ |
'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'`." | ||
) |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
0
2667
6
13
1
0
- Removed@emotion/utils@0.11.2
- Removedhtml-tokenize@^2.0.0
- Removedmultipipe@^1.0.2
- Removedthrough@^2.3.8
- Removed@emotion/utils@0.11.2(transitive)
- Removedbuffer-from@0.1.2(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removedhtml-tokenize@2.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.11.0.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmultipipe@1.0.2(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedobject-keys@0.4.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@1.0.342.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstring_decoder@0.10.311.1.1(transitive)
- Removedthrough@2.3.8(transitive)
- Removedthrough2@0.4.2(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedxtend@2.1.2(transitive)