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

stylis

Package Overview
Dependencies
Maintainers
1
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylis - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

5

CHANGELOG.md

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

## 0.8.2 (December 20, 2016)
- better handle line comments
- small improvements to compiler
## 0.8.1 (December 19, 2016)

@@ -2,0 +7,0 @@

2

package.json

@@ -5,3 +5,3 @@ {

"description": "stylis is a small css compiler",
"version": "0.8.1",
"version": "0.8.2",
"homepage": "https://github.com/thysultan/stylis.js",

@@ -8,0 +8,0 @@ "license": "MIT",

# Stylis
[![npm](https://img.shields.io/npm/v/stylis.svg?style=flat)](https://www.npmjs.com/package/stylis) [![licence](https://img.shields.io/badge/licence-MIT-blue.svg?style=flat)](https://github.com/thysultan/stylis.js/blob/master/LICENSE.md)
![dependencies](https://img.shields.io/badge/dependencies-none-green.svg?style=flat)
[![npm](https://img.shields.io/npm/v/stylis.svg?style=flat)](https://www.npmjs.com/package/stylis) [![licence](https://img.shields.io/badge/licence-MIT-blue.svg?style=flat)](https://github.com/thysultan/stylis.js/blob/master/LICENSE.md) [![Build Status](https://semaphoreci.com/api/v1/thysultan/stylis-js/branches/master/shields_badge.svg)](https://semaphoreci.com/thysultan/stylis-js) ![dependencies](https://img.shields.io/badge/dependencies-none-green.svg?style=flat)

@@ -226,3 +225,3 @@ - ~1Kb minified+gzipped

```html
<script src=https://unpkg.com/stylis@0.8.1/stylis.min.js></script>
<script src=https://unpkg.com/stylis@0.8.2/stylis.min.js></script>
```

@@ -229,0 +228,0 @@

@@ -14,385 +14,376 @@ /*!

(function (factory) {
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory(global);
} else if (typeof define === 'function' && define.amd) {
define(factory(window));
} else {
window.stylis = factory(window);
}
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = factory(global);
} else if (typeof define === 'function' && define.amd) {
define(factory(window));
} else {
window.stylis = factory(window);
}
}(function (window) {
'use strict';
'use strict';
/**
* css compiler
*
* @example compiler('.class1', 'css...', false);
*
* @param {string} selector
* @param {string} styles
* @param {boolean} nsAnimations
* @param {boolean} nsKeyframes
* @return {string}
*/
function stylis (selector, styles, nsAnimations, nsKeyframes) {
var prefix = '';
var id = '';
var type = selector.charCodeAt(0) || 0;
/**
* css compiler
*
* @example compiler('.class1', 'css...', false);
*
* @param {string} selector
* @param {string} styles
* @param {boolean} nsAnimations
* @param {boolean} nsKeyframes
* @return {string}
*/
function stylis (selector, styles, nsAnimations, nsKeyframes) {
var prefix = '';
var id = '';
var type = selector.charCodeAt(0) || 0;
// [ attr selector
if (type === 91) {
// `[data-id=namespace]` -> ['data-id', 'namespace']
var attr = selector.substring(1, selector.length-1).split('=');
var char = (id = attr[1]).charCodeAt(0);
// [ attr selector
if (type === 91) {
// `[data-id=namespace]` -> ['data-id', 'namespace']
var attr = selector.substring(1, selector.length-1).split('=');
var char = (id = attr[1]).charCodeAt(0);
// [data-id="namespace"]/[data-id='namespace']
// --> "namespace"/'namspace' -> namespace
if (char === 34 || char === 39) {
id = id.substring(1, id.length-1);
}
// [data-id="namespace"]/[data-id='namespace']
// --> "namespace"/'namspace' -> namespace
if (char === 34 || char === 39) {
id = id.substring(1, id.length-1);
}
prefix = '['+ attr[0] + '=\'' + id +'\']';
}
// `#` `.` `>` id class and descendant selectors
else if (type === 35 || type === 46 || type === 62) {
id = (prefix = selector).substring(1);
}
// element selector
else {
id = prefix = selector;
}
prefix = '['+ attr[0] + '=\'' + id +'\']';
}
// `#` `.` `>` id class and descendant selectors
else if (type === 35 || type === 46 || type === 62) {
id = (prefix = selector).substring(1);
}
// element selector
else {
id = prefix = selector;
}
var keyframeNs = (nsAnimations === void 0 || nsAnimations === true ) ? id : '';
var animationNs = (nsKeyframes === void 0 || nsKeyframes === true ) ? id : '';
var keyframeNs = (nsAnimations === void 0 || nsAnimations === true ) ? id : '';
var animationNs = (nsKeyframes === void 0 || nsKeyframes === true ) ? id : '';
var output = '';
var line = '';
var blob = '';
var prev = '';
var flat = '';
var output = '';
var line = '';
var blob = '';
var prev = '';
var flat = '';
var len = styles.length;
var len = styles.length;
var i = 0;
var special = 0;
var type = 0;
var close = 0;
var comment = 0;
var depth = 0;
var i = 0;
var special = 0;
var type = 0;
var close = 0;
var comment = 0;
var depth = 0;
// parse + compile
while (i < len) {
var code = styles.charCodeAt(i);
// parse + compile
while (i < len) {
var code = styles.charCodeAt(i);
// {, }, ; characters, parse line by line
if (code === 123 || code === 125 || code === 59) {
line += styles[i];
// {, }, ; characters, parse line by line
if (code === 123 || code === 125 || code === 59) {
line += styles[i];
var first = line.charCodeAt(0);
var first = line.charCodeAt(0);
// only trim when the first character is a space ` `
if (first === 32) {
first = (line = line.trim()).charCodeAt(0);
}
// only trim when the first character is a space ` `
if (first === 32) {
first = (line = line.trim()).charCodeAt(0);
}
// default to 0 instead of NaN if there is no second character
var second = line.charCodeAt(1) || 0;
// default to 0 instead of NaN if there is no second character
var second = line.charCodeAt(1) || 0;
// /, *, block comment
if (first === 47 && second === 42) {
// travel to end of comment and update first and second characters
first = (line = line.substring(line.indexOf('*/')+2)).charCodeAt(0);
second = line.charCodeAt(1) || 0;
}
// ignore comments
if (comment === 2) {
line = ''; comment = 0;
}
// @, special block
else if (first === 64) {
// @keyframe/@global, `k` or @global, `g` character
if (second === 107 || second === 103) {
// k, @keyframes
if (second === 107) {
blob = line.substring(1, 11) + keyframeNs + line.substring(11);
line = '@-webkit-'+blob;
type = 1;
}
// g, @global
else {
line = '';
}
}
// @media `m` character
else if (second === 109) {
type = 2;
}
// ignore line comments
if (comment === 1) {
line = ''; comment = 0;
}
// @, special block
else if (first === 64) {
// @keyframe/@global, `k` or @global, `g` character
if (second === 107 || second === 103) {
// k, @keyframes
if (second === 107) {
blob = line.substring(1, 11) + keyframeNs + line.substring(11);
line = '@-webkit-'+blob;
type = 1;
}
// g, @global
else {
line = '';
}
}
// @media `m` character
else if (second === 109) {
type = 2;
}
special++;
}
else {
var third = line.charCodeAt(2) || 0;
special++;
}
else {
var third = line.charCodeAt(2) || 0;
// animation: a, n, i characters
if (first === 97 && second === 110 && third === 105) {
var anims = line.substring(10).split(',');
var build = 'animation:';
// animation: a, n, i characters
if (first === 97 && second === 110 && third === 105) {
var anims = line.substring(10).split(',');
var build = 'animation:';
for (var j = 0, length = anims.length; j < length; j++) {
build += (j === 0 ? '' : ',') + animationNs + anims[j].trim();
}
for (var j = 0, length = anims.length; j < length; j++) {
build += (j === 0 ? '' : ',') + animationNs + anims[j].trim();
}
// vendor prefix
line = '-webkit-' + build + build;
}
// appearance: a, p, p
else if (first === 97 && second === 112 && third === 112) {
// vendor prefix -webkit- and -moz-
line = '-webkit-' + line + '-moz-' + line + line;
}
// hyphens: h, y, p
// user-select: u, s, e
else if (
(first === 104 && second === 121 && third === 112) ||
(first === 117 && second === 115 && third === 101)
) {
// vendor prefix all
line = '-webkit-' + line + '-moz-' + line + '-ms-' + line + line;
}
// flex: f, l, e
// order: o, r, d
else if (
(first === 102 && second === 108 && third === 101) ||
(first === 111 && second === 114 && third === 100)
) {
// vendor prefix only -webkit-
line = '-webkit-' + line + line;
}
// transforms & transitions: t, r, a
else if (first === 116 && second === 114 && third === 97) {
// vendor prefix -webkit- and -ms- if transform
line = '-webkit-' + line + (line.charCodeAt(5) === 102 ? '-ms-' + line : '') + line;
}
// display: d, i, s
else if (first === 100 && second === 105 && third === 115) {
if (line.indexOf('flex') > -1) {
// vendor prefix
line = 'display:-webkit-flex; display:flex;';
}
}
// { character, selector declaration
else if (code === 123) {
depth++;
// vendor prefix
line = '-webkit-' + build + build;
}
// appearance: a, p, p
else if (first === 97 && second === 112 && third === 112) {
// vendor prefix -webkit- and -moz-
line = '-webkit-' + line + '-moz-' + line + line;
}
// hyphens: h, y, p
// user-select: u, s, e
else if (
(first === 104 && second === 121 && third === 112) ||
(first === 117 && second === 115 && third === 101)
) {
// vendor prefix all
line = '-webkit-' + line + '-moz-' + line + '-ms-' + line + line;
}
// flex: f, l, e
// order: o, r, d
else if (
(first === 102 && second === 108 && third === 101) ||
(first === 111 && second === 114 && third === 100)
) {
// vendor prefix only -webkit-
line = '-webkit-' + line + line;
}
// transforms & transitions: t, r, a
else if (first === 116 && second === 114 && third === 97) {
// vendor prefix -webkit- and -ms- if transform
line = '-webkit-' + line + (line.charCodeAt(5) === 102 ? '-ms-' + line : '') + line;
}
// display: d, i, s
else if (first === 100 && second === 105 && third === 115) {
if (line.indexOf('flex') > -1) {
// vendor prefix
line = 'display:-webkit-flex; display:flex;';
}
}
// { character, selector declaration
else if (code === 123) {
depth++;
if (special === 0 || type === 2) {
// nested selector
if (depth === 2) {
// discard first character {
i++;
if (special === 0 || type === 2) {
// nested selector
if (depth === 2) {
// discard first character {
i++;
// inner content of block
var inner = '';
var nestSel = line.substring(0, line.length-1).split(',');
var prevSel = prev.substring(0, prev.length-1).split(',');
// inner content of block
var inner = '';
var nestSel = line.substring(0, line.length-1).split(',');
var prevSel = prev.substring(0, prev.length-1).split(',');
// keep track of opening `{` and `}` occurrences
var counter = 1;
// keep track of opening `{` and `}` occurrences
var counter = 1;
// travel to the end of the block
while (i < len) {
var char = styles.charCodeAt(i);
// {, }, nested blocks may have nested blocks
char === 123 ? counter++ : char === 125 && counter--;
// break when the has ended
if (counter === 0) break;
// build content of nested block
inner += styles[i++];
}
// travel to the end of the block
while (i < len) {
var char = styles.charCodeAt(i);
// {, }, nested blocks may have nested blocks
char === 123 ? counter++ : char === 125 && counter--;
// break when the has ended
if (counter === 0) break;
// build content of nested block
inner += styles[i++];
}
// handle multiple selectors: h1, h2 { div, h4 {} } should generate
// -> h1 div, h2 div, h2 h4, h2 div {}
for (var j = 0, length = prevSel.length; j < length; j++) {
// extract value, prep index for reuse
var val = prevSel[j]; prevSel[j] = '';
// since there can also be multiple nested selectors
for (var k = 0, l = nestSel.length; k < l; k++) {
prevSel[j] += (
(val.replace(prefix, '').trim() + ' ' + nestSel[k].trim()).trim() +
(k === l-1 ? '' : ',')
);
}
}
// handle multiple selectors: h1, h2 { div, h4 {} } should generate
// -> h1 div, h2 div, h2 h4, h2 div {}
for (var j = 0, length = prevSel.length; j < length; j++) {
// extract value, prep index for reuse
var val = prevSel[j]; prevSel[j] = '';
// since there can also be multiple nested selectors
for (var k = 0, l = nestSel.length; k < l; k++) {
prevSel[j] += (
(val.replace(prefix, '').trim() + ' ' + nestSel[k].trim()).trim() +
(k === l-1 ? '' : ',')
);
}
}
// create block and update styles length
len += (styles += (prevSel.join(',') + '{'+inner+'}').replace(/&| +&/g, '')).length;
// create block and update styles length
len += (styles += (prevSel.join(',') + '{'+inner+'}').replace(/&| +&/g, '')).length;
// clear current line, to avoid add block elements to the normal flow
line = '';
// clear current line, to avoid add block elements to the normal flow
line = '';
// decreament depth
depth--;
}
// top-level selector
else {
var split = line.split(',');
var build = '';
// decreament depth
depth--;
}
// top-level selector
else {
var split = line.split(',');
var build = '';
// prefix multiple selectors with namesapces
// @example h1, h2, h3 --> [namespace] h1, [namespace] h1, ....
for (var j = 0, length = split.length; j < length; j++) {
var selector = split[j];
var firstChar = selector.charCodeAt(0);
// prefix multiple selectors with namesapces
// @example h1, h2, h3 --> [namespace] h1, [namespace] h1, ....
for (var j = 0, length = split.length; j < length; j++) {
var selector = split[j];
var firstChar = selector.charCodeAt(0);
// ` `, trim if first char is space
if (firstChar === 32) {
firstChar = (selector = selector.trim()).charCodeAt(0);
}
// ` `, trim if first char is space
if (firstChar === 32) {
firstChar = (selector = selector.trim()).charCodeAt(0);
}
// [, [title="a,b,..."]
if (firstChar === 91) {
for (var k = j+1, l = length-j; k < l; k++) {
var broken = (selector += ',' + split[k]).trim();
// [, [title="a,b,..."]
if (firstChar === 91) {
for (var k = j+1, l = length-j; k < l; k++) {
var broken = (selector += ',' + split[k]).trim();
// ]
if (broken.charCodeAt(broken.length-1) === 93) {
length -= k;
split.splice(j, k);
break;
}
}
}
// ]
if (broken.charCodeAt(broken.length-1) === 93) {
length -= k;
split.splice(j, k);
break;
}
}
}
// &
if (firstChar === 38) {
// before: & {
selector = prefix + selector.substring(1);
// after: ${prefix} {
}
// :
else if (firstChar === 58) {
var secondChar = selector.charCodeAt(1);
// &
if (firstChar === 38) {
// before: & {
selector = prefix + selector.substring(1);
// after: ${prefix} {
}
// :
else if (firstChar === 58) {
var secondChar = selector.charCodeAt(1);
// :host
if (secondChar === 104) {
var nextChar = (selector = selector.substring(5)).charCodeAt(0);
// :host(selector)
if (nextChar === 40) {
// before: `(selector)`
selector = prefix + selector.substring(1).replace(')', '');
// after: ${prefx} selector {
}
// :host-context(selector)
else if (nextChar === 45) {
// before: `-context(selector)`
selector = selector.substring(9, selector.indexOf(')')) + ' ' + prefix + ' {';
// after: selector ${prefix} {
}
// :host
else {
selector = prefix + selector;
}
}
// :global(selector)
else if (secondChar === 103) {
// before: `:global(selector)`
selector = selector.substring(8).replace(')', '');
// after: selector
}
// :hover, :active, :focus, etc...
else {
selector = prefix + selector;
}
}
else {
selector = prefix + ' ' + selector;
}
// :host
if (secondChar === 104) {
var nextChar = (selector = selector.substring(5)).charCodeAt(0);
// :host(selector)
if (nextChar === 40) {
// before: `(selector)`
selector = prefix + selector.substring(1).replace(')', '');
// after: ${prefx} selector {
}
// :host-context(selector)
else if (nextChar === 45) {
// before: `-context(selector)`
selector = selector.substring(9, selector.indexOf(')')) + ' ' + prefix + ' {';
// after: selector ${prefix} {
}
// :host
else {
selector = prefix + selector;
}
}
// :global(selector)
else if (secondChar === 103) {
// before: `:global(selector)`
selector = selector.substring(8).replace(')', '');
// after: selector
}
// :hover, :active, :focus, etc...
else {
// :, insure `div:hover` does not end up as `div :hover`
selector = prefix + (firstChar === 58 ? '' : ' ') + selector;
}
}
else {
// :, insure `div:hover` does not end up as `div :hover`
selector = prefix + (firstChar === 58 ? '' : ' ') + selector;
}
// if first selector do not prefix with `,`
build += j === 0 ? selector : ',' + selector;
}
// if first selector do not prefix with `,`
build += j === 0 ? selector : ',' + selector;
}
prev = line = build;
}
}
}
// } character
else if (code === 125 && depth !== 0) {
depth--;
}
// @global/@keyframes
if (special !== 0) {
// find the closing tag
code === 125 ? close++ : (code === 123 && close !== 0 && close--);
prev = line = build;
}
}
}
// } character
else if (code === 125 && depth !== 0) {
depth--;
}
// @global/@keyframes
if (special !== 0) {
// find the closing tag
code === 125 ? close++ : (code === 123 && close !== 0 && close--);
// closing tag
if (close === 2) {
// @global
if (type === 0) {
line = '';
}
// @keyframes
else if (type === 1) {
// vendor prefix
line = '}@'+blob+'}';
// reset blob
blob = '';
}
// @media
else if (type === 2) {
blob.length !== 0 && (line = prefix + ' {'+blob+'}' + line);
// reset blob
blob = '';
}
// closing tag
if (close === 2) {
// @global
if (type === 0) {
line = '';
}
// @keyframes
else if (type === 1) {
// vendor prefix
line = '}@'+blob+'}';
// reset blob
blob = '';
}
// @media
else if (type === 2) {
blob.length !== 0 && (line = prefix + ' {'+blob+'}' + line);
// reset blob
blob = '';
}
// reset flags
type = 0; close--; special--;
}
// @keyframes
else if (type === 1) {
blob += line;
}
// @media flat context
else if (type === 2 && depth === 0 && code !== 125) {
blob += line; line = '';
}
}
// flat context
else if (depth === 0 && code !== 125) {
flat += line; line = '';
}
}
// reset flags
type = 0; close--; special--;
}
// @keyframes
else if (type === 1) {
blob += line;
}
// @media flat context
else if (type === 2 && depth === 0 && code !== 125) {
blob += line; line = '';
}
}
// flat context
else if (depth === 0 && code !== 125) {
flat += line; line = '';
}
}
// add line to output, reset line buffer and comment signal
output += line; line = ''; comment = 0;
}
// build line by line
else {
// \r, \n, ignore line and block comments
if (comment === 2 && (code === 13 || code === 10)) {
line = ''; comment = 0;
}
// not `\t`, `\r`, `\n` characters
else if (code !== 9 && code !== 13 && code !== 10) {
// / line comment signal
code === 47 && comment < 2 && comment++;
// add line to output, reset line buffer and comment signal
output += line; line = ''; comment = 0;
}
// build line by line
else {
// \r, \n, ignore line comments
if (comment === 1 && (code === 13 || code === 10)) {
line = '';
}
// not `\t`, `\r`, `\n` characters
else if (code !== 9 && code !== 13 && code !== 10) {
// / line comment signal
code === 47 && comment === 0 && (comment = 1);
// build line buffer
line += styles[i];
}
}
// build line buffer
line += styles[i];
}
}
// next character
i++;
}
// next character
i++;
}
// if there is flat css, append
return output + (flat.length === 0 ? '' : prefix + ' {' + flat + '}');
}
// if there is flat css, append
return output + (flat.length === 0 ? '' : prefix + ' {' + flat + '}');
}
return stylis;
return stylis;
}));

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

!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(global):"function"==typeof define&&define.amd?define(e(window)):window.stylis=e(window)}(function(e){"use strict";function t(e,t,i,r){var s="",n="",l=e.charCodeAt(0)||0;if(91===l){var a=e.substring(1,e.length-1).split("="),o=(n=a[1]).charCodeAt(0);34!==o&&39!==o||(n=n.substring(1,n.length-1)),s="["+a[0]+"='"+n+"']"}else n=35===l||46===l||62===l?(s=e).substring(1):s=e;for(var f=void 0===i||i===!0?n:"",d=void 0===r||r===!0?n:"",g="",h="",c="",b="",u="",v=t.length,p=0,A=0,l=0,C=0,m=0,w=0;p<v;){var k=t.charCodeAt(p);if(123===k||125===k||59===k){h+=t[p];var x=h.charCodeAt(0);32===x&&(x=(h=h.trim()).charCodeAt(0));var y=h.charCodeAt(1)||0;if(47===x&&42===y&&(x=(h=h.substring(h.indexOf("*/")+2)).charCodeAt(0),y=h.charCodeAt(1)||0),1===m)h="",m=0;else if(64===x)107===y||103===y?107===y?(c=h.substring(1,11)+f+h.substring(11),h="@-webkit-"+c,l=1):h="":109===y&&(l=2),A++;else{var O=h.charCodeAt(2)||0;if(97===x&&110===y&&105===O){for(var j=h.substring(10).split(","),z="animation:",q=0,B=j.length;q<B;q++)z+=(0===q?"":",")+d+j[q].trim();h="-webkit-"+z+z}else if(97===x&&112===y&&112===O)h="-webkit-"+h+"-moz-"+h+h;else if(104===x&&121===y&&112===O||117===x&&115===y&&101===O)h="-webkit-"+h+"-moz-"+h+"-ms-"+h+h;else if(102===x&&108===y&&101===O||111===x&&114===y&&100===O)h="-webkit-"+h+h;else if(116===x&&114===y&&97===O)h="-webkit-"+h+(102===h.charCodeAt(5)?"-ms-"+h:"")+h;else if(100===x&&105===y&&115===O)h.indexOf("flex")>-1&&(h="display:-webkit-flex; display:flex;");else if(123===k){if(w++,0===A||2===l)if(2===w){p++;for(var D="",E=h.substring(0,h.length-1).split(","),F=b.substring(0,b.length-1).split(","),G=1;p<v;){var o=t.charCodeAt(p);if(123===o?G++:125===o&&G--,0===G)break;D+=t[p++]}for(var q=0,B=F.length;q<B;q++){var H=F[q];F[q]="";for(var I=0,J=E.length;I<J;I++)F[q]+=(H.replace(s,"").trim()+" "+E[I].trim()).trim()+(I===J-1?"":",")}v+=(t+=(F.join(",")+"{"+D+"}").replace(/&| +&/g,"")).length,h="",w--}else{for(var K=h.split(","),z="",q=0,B=K.length;q<B;q++){var e=K[q],L=e.charCodeAt(0);if(32===L&&(L=(e=e.trim()).charCodeAt(0)),91===L)for(var I=q+1,J=B-q;I<J;I++){var M=(e+=","+K[I]).trim();if(93===M.charCodeAt(M.length-1)){B-=I,K.splice(q,I);break}}if(38===L)e=s+e.substring(1);else if(58===L){var N=e.charCodeAt(1);if(104===N){var P=(e=e.substring(5)).charCodeAt(0);e=40===P?s+e.substring(1).replace(")",""):45===P?e.substring(9,e.indexOf(")"))+" "+s+" {":s+e}else e=103===N?e.substring(8).replace(")",""):s+(58===L?"":" ")+e}else e=s+(58===L?"":" ")+e;z+=0===q?e:","+e}b=h=z}}else 125===k&&0!==w&&w--;0!==A?(125===k?C++:123===k&&0!==C&&C--,2===C?(0===l?h="":1===l?(h="}@"+c+"}",c=""):2===l&&(0!==c.length&&(h=s+" {"+c+"}"+h),c=""),l=0,C--,A--):1===l?c+=h:2===l&&0===w&&125!==k&&(c+=h,h="")):0===w&&125!==k&&(u+=h,h="")}g+=h,h="",m=0}else 1!==m||13!==k&&10!==k?9!==k&&13!==k&&10!==k&&(47===k&&0===m&&(m=1),h+=t[p]):h="";p++}return g+(0===u.length?"":s+" {"+u+"}")}return t});
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(global):"function"==typeof define&&define.amd?define(e(window)):window.stylis=e(window)}(function(e){"use strict";function t(e,t,i,r){var s="",n="",l=e.charCodeAt(0)||0;if(91===l){var a=e.substring(1,e.length-1).split("="),o=(n=a[1]).charCodeAt(0);34!==o&&39!==o||(n=n.substring(1,n.length-1)),s="["+a[0]+"='"+n+"']"}else n=35===l||46===l||62===l?(s=e).substring(1):s=e;for(var f=void 0===i||i===!0?n:"",d=void 0===r||r===!0?n:"",g="",h="",c="",b="",u="",v=t.length,p=0,m=0,l=0,A=0,C=0,w=0;p<v;){var k=t.charCodeAt(p);if(123===k||125===k||59===k){h+=t[p];var x=h.charCodeAt(0);32===x&&(x=(h=h.trim()).charCodeAt(0));var y=h.charCodeAt(1)||0;if(2===C)h="",C=0;else if(64===x)107===y||103===y?107===y?(c=h.substring(1,11)+f+h.substring(11),h="@-webkit-"+c,l=1):h="":109===y&&(l=2),m++;else{var j=h.charCodeAt(2)||0;if(97===x&&110===y&&105===j){for(var z=h.substring(10).split(","),O="animation:",q=0,B=z.length;q<B;q++)O+=(0===q?"":",")+d+z[q].trim();h="-webkit-"+O+O}else if(97===x&&112===y&&112===j)h="-webkit-"+h+"-moz-"+h+h;else if(104===x&&121===y&&112===j||117===x&&115===y&&101===j)h="-webkit-"+h+"-moz-"+h+"-ms-"+h+h;else if(102===x&&108===y&&101===j||111===x&&114===y&&100===j)h="-webkit-"+h+h;else if(116===x&&114===y&&97===j)h="-webkit-"+h+(102===h.charCodeAt(5)?"-ms-"+h:"")+h;else if(100===x&&105===y&&115===j)h.indexOf("flex")>-1&&(h="display:-webkit-flex; display:flex;");else if(123===k){if(w++,0===m||2===l)if(2===w){p++;for(var D="",E=h.substring(0,h.length-1).split(","),F=b.substring(0,b.length-1).split(","),G=1;p<v;){var o=t.charCodeAt(p);if(123===o?G++:125===o&&G--,0===G)break;D+=t[p++]}for(var q=0,B=F.length;q<B;q++){var H=F[q];F[q]="";for(var I=0,J=E.length;I<J;I++)F[q]+=(H.replace(s,"").trim()+" "+E[I].trim()).trim()+(I===J-1?"":",")}v+=(t+=(F.join(",")+"{"+D+"}").replace(/&| +&/g,"")).length,h="",w--}else{for(var K=h.split(","),O="",q=0,B=K.length;q<B;q++){var e=K[q],L=e.charCodeAt(0);if(32===L&&(L=(e=e.trim()).charCodeAt(0)),91===L)for(var I=q+1,J=B-q;I<J;I++){var M=(e+=","+K[I]).trim();if(93===M.charCodeAt(M.length-1)){B-=I,K.splice(q,I);break}}if(38===L)e=s+e.substring(1);else if(58===L){var N=e.charCodeAt(1);if(104===N){var P=(e=e.substring(5)).charCodeAt(0);e=40===P?s+e.substring(1).replace(")",""):45===P?e.substring(9,e.indexOf(")"))+" "+s+" {":s+e}else e=103===N?e.substring(8).replace(")",""):s+e}else e=s+" "+e;O+=0===q?e:","+e}b=h=O}}else 125===k&&0!==w&&w--;0!==m?(125===k?A++:123===k&&0!==A&&A--,2===A?(0===l?h="":1===l?(h="}@"+c+"}",c=""):2===l&&(0!==c.length&&(h=s+" {"+c+"}"+h),c=""),l=0,A--,m--):1===l?c+=h:2===l&&0===w&&125!==k&&(c+=h,h="")):0===w&&125!==k&&(u+=h,h="")}g+=h,h="",C=0}else 2!==C||13!==k&&10!==k?9!==k&&13!==k&&10!==k&&(47===k&&C<2&&C++,h+=t[p]):(h="",C=0);p++}return g+(0===u.length?"":s+" {"+u+"}")}return t});
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