Comparing version 1.0.4 to 1.0.5
@@ -5,2 +5,1 @@ import { CSSObject } from "./types"; | ||
export declare function objectifyCSS(css: string): CSSObject; | ||
export declare function parse(css: string): CSSObject; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var stylable_value_parsers_1 = require("./stylable-value-parsers"); | ||
var postcss = require("postcss"); | ||
var objectify = require("../modules/post-css-objectify"); | ||
@@ -9,3 +10,3 @@ var stylis = require("stylis"); | ||
var postcssNested = require("postcss-nested"); | ||
var postcss = require("postcss"); | ||
var safeParser = require("postcss-safe-parser"); | ||
var stylableObjectifyConfig = { | ||
@@ -30,9 +31,5 @@ noCamel: [stylable_value_parsers_1.STYLABLE_VALUE_MATCHER], | ||
// return stylis('', css); | ||
return objectify(postcss.parse(css), stylableObjectifyConfig); | ||
return objectify(safeParser(css), stylableObjectifyConfig); | ||
} | ||
exports.objectifyCSS = objectifyCSS; | ||
function parse(css) { | ||
return processor.parse(css); | ||
} | ||
exports.parse = parse; | ||
//# sourceMappingURL=parser.js.map |
@@ -6,7 +6,4 @@ "use strict"; | ||
if (throwCondition === void 0) { throwCondition = 0; } | ||
if (throwCondition > 10 || value === undefined) { | ||
throw new Error('Unresolvable variable: ' + name); | ||
} | ||
return value.replace(/value\((.*?)\)/g, function (match, name) { | ||
var translatedValue = data[name]; | ||
var translatedValue; | ||
if (~name.indexOf(',')) { | ||
@@ -19,4 +16,10 @@ var nameParts = name.split(','); | ||
} | ||
else { | ||
translatedValue = data[name]; | ||
} | ||
if (throwCondition > 10 || translatedValue === undefined) { | ||
throw new Error('Unresolvable variable: ' + name); | ||
} | ||
var res = valueTemplate(translatedValue, data, debug, throwCondition + 1); | ||
return res !== undefined ? res + (debug ? "/*" + match + "*/" : '') : match; | ||
return res !== undefined ? res + (debug ? "/*" + name + "*/" : '') : match; | ||
}); | ||
@@ -23,0 +26,0 @@ } |
{ | ||
"name": "stylable", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "", | ||
@@ -41,2 +41,3 @@ "main": "./dist/src/index.js", | ||
"postcss-nested": "^2.0.2", | ||
"postcss-safe-parser": "^3.0.1", | ||
"stylis": "^3.2.3" | ||
@@ -43,0 +44,0 @@ }, |
import { CSSObject } from "./types"; | ||
import { STYLABLE_VALUE_MATCHER } from "./stylable-value-parsers"; | ||
import * as postcss from "postcss"; | ||
@@ -9,3 +10,3 @@ const objectify = require("../modules/post-css-objectify"); | ||
const postcssNested = require("postcss-nested"); | ||
const postcss = require("postcss"); | ||
const safeParser = require("postcss-safe-parser"); | ||
@@ -35,7 +36,3 @@ | ||
// return stylis('', css); | ||
return objectify(postcss.parse(css), stylableObjectifyConfig); | ||
return objectify(safeParser(css), stylableObjectifyConfig); | ||
} | ||
export function parse(css: string): CSSObject { | ||
return processor.parse(css); | ||
} |
import { Pojo } from "./types"; | ||
export function valueTemplate(value: string, data: Pojo, debug: boolean = false, throwCondition = 0): string { | ||
if (throwCondition > 10 || value === undefined) { throw new Error('Unresolvable variable: ' + name) } | ||
return value.replace(/value\((.*?)\)/g, function (match: string, name: string) { | ||
let translatedValue = data[name]; | ||
let translatedValue; | ||
if (~name.indexOf(',')) { | ||
@@ -13,6 +12,9 @@ const nameParts = name.split(','); | ||
translatedValue = data[variableName] || defaultValue; | ||
} else { | ||
translatedValue = data[name]; | ||
} | ||
if (throwCondition > 10 || translatedValue === undefined) { throw new Error('Unresolvable variable: ' + name) } | ||
const res = valueTemplate(translatedValue, data, debug, throwCondition + 1); | ||
return res !== undefined ? res + (debug ? `/*${match}*/` : '') : match; | ||
return res !== undefined ? res + (debug ? `/*${name}*/` : '') : match; | ||
}); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
232883
8
+ Addedpostcss-safe-parser@^3.0.1
+ Addedpostcss-safe-parser@3.0.1(transitive)