Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
/*--------------------------------------------------------------------------------------------------------------------*/
// STYLESHEET PARSE
/*--------------------------------------------------------------------------------------------------------------------*/
import parse from "css-parse";
import Style from "../src/renderer/Style";
const CSS_PROPERTY_MAP = Style.CSS_PROPERTY_MAP;
const PropertyType = Style.PropertyType;
const STYLE_PROPERTY_INFO = Style.PROPERTY_INFO;
const dataPathCssOut = '../src/StyleSheet.js';
const dataPathCss = '../style/style.css';
const dataCss = parse(fs.readFileSync(dataPathCss, 'utf8'), {source : dataPathCss});
let rules = {};
for(let rule of dataCss.stylesheet.rules){
if(rule.type !== 'rule'){
continue;
}
let position = rule.position.start.line + ':' + rule.position.start.column;
let selectors = rule.selectors[0].split(' ');
if(selectors.length > 1){
log(`unsupported nested selectors: "${rule.selectors}"`,position);
continue;
}
let declarations = [];
for(let declaration of rule.declarations){
if(declaration.type !== 'declaration'){
continue;
styles.forEach(function (v) {
const cssAst = cssParse(v.content);
cssParsed = Object.assign({}, cssParsed, parseCss(cssAst));
});
function toStyleSheet(styleData) {
const { stylesheet: { rules } } = parser(styleData);
const result = {};
for (const { type: ruleType, selectors, declarations } of rules) {
if (ruleType !== RULE) continue;
for (const selector of selectors) {
const s = selector.replace(/\.|#/g, '');
result[s] = result[s] || {};
for (const { type: declarationType, value, property } of declarations) {
if (declarationType !== DECLARATION) continue;
const propertyName = ['-ios-', '-android-'].reduce((m, v) => m.replace(v, ''), property);
const camelizedPropName = camelize(propertyName);
if (value) {