Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
import Stylis from 'stylis'
import type { Interpolation } from '../types'
const stylis = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: true,
compress: false,
semicolon: true,
})
const stringifyRules = (
rules: Array,
selector: ?string,
prefix: ?string,
): string => {
const flatCSS = rules
.join('')
.replace(/^\s*\/\/.*$/gm, '') // replace JS comments
return match;
});
return existingComponents.map(function (_ref, i) {
var componentId = _ref.componentId,
matchIndex = _ref.matchIndex;
var nextComp = existingComponents[i + 1];
var cssFromDOM = nextComp ? css.slice(matchIndex, nextComp.matchIndex) : css.slice(matchIndex);
return { componentId: componentId, cssFromDOM: cssFromDOM };
});
});
//
// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: false,
compress: false,
semicolon: true
});
var stylis = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: true,
compress: false,
semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
let insertRules = realCSS => {
let style = getStyleElement()
/* Get unique classname */
let className = getHash(realCSS)
/* Convert nested CSS */
let styles = stylis(`.${className}`, realCSS)
style.innerHTML += styles
return className
}
//
var COMMENT_REGEX = /^\s*\/\/.*$/gm;
// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: false,
compress: false,
semicolon: true
});
var stylis = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: true,
compress: false,
semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture
var parsingRules = [];
// eslint-disable-next-line consistent-return
var returnRulesPlugin = function returnRulesPlugin(context) {
if (context === -2) {
/* Handle objects */
ruleSet.push(
// $FlowFixMe have to add %checks somehow to isPlainObject
isPlainObject(chunk) ? objToCss(chunk) : chunk.toString());
return ruleSet;
}, []);
};
//
var COMMENT_REGEX = /^\s*\/\/.*$/gm;
// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: false,
compress: false,
semicolon: true
});
var stylis = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: true,
compress: false,
semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
/* Handle objects */
ruleSet.push(
// $FlowFixMe have to add %checks somehow to isPlainObject
isPlainObject(chunk) ? objToCss(chunk) : chunk.toString());
return ruleSet;
}, []);
};
//
var COMMENT_REGEX = /^\s*\/\/.*$/gm;
// NOTE: This stylis instance is only used to split rules from SSR'd style tags
var stylisSplitter = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: false,
compress: false,
semicolon: true
});
var stylis = new Stylis({
global: false,
cascade: true,
keyframe: false,
prefix: true,
compress: false,
semicolon: false // NOTE: This means "autocomplete missing semicolons"
});
generateAndInjectStyles (executionContext) {
const flatCSS = flatten(this.rules, executionContext).join('')
.replace(/^\s*\/\/.*$/gm, '') // replace JS comments
const hash = hashStr(flatCSS)
if (!inserted[hash]) {
const selector = nameGenerator(hash)
inserted[hash] = selector
const css = stylis(`.${selector}`, flatCSS)
this.insertedRule.appendRule(css)
}
return inserted[hash]
}
}
function insertStyles(styles) {
const className = getClassName(styles)
// skip if these styles are already inserted
if (isAlreadyInserted(className)) return className
insertedClasses.push(className)
const container = document.head.querySelector('#usecss')
const raw = stylis(`.` + className, styles)
container.append(raw)
return className
}
export default function getProcessedRules(
selector: string,
cssRules: string
): string {
return stylis(selector.replace(":", "\\:").replace("/", "\\/"), cssRules)
}
import Stylis from "stylis";
const stylis = new Stylis();
function disableNestingPlugin(...args) {
let [context, , , parent = [], line, column] = args;
if (context === 2) {
parent = parent[0];
if (
typeof parent === "string" &&
parent.trim().length > 0 &&
parent.charAt(0) !== "@"
) {
throw new Error(
`Nesting detected at ${line}:${column}. ` +
"Unfortunately nesting is not supported by styled-jsx."
);
}
}