style-to-js
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -5,3 +5,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var style_to_object_1 = __importDefault(require("style-to-object")); | ||
@@ -14,3 +14,3 @@ var utilities_1 = require("./utilities"); | ||
} | ||
(0, style_to_object_1["default"])(style, function (property, value) { | ||
(0, style_to_object_1.default)(style, function (property, value) { | ||
if (property && value) { | ||
@@ -22,2 +22,2 @@ output[(0, utilities_1.camelCase)(property, options)] = value; | ||
} | ||
exports["default"] = StyleToJS; | ||
exports.default = StyleToJS; |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.camelCase = void 0; | ||
@@ -4,0 +4,0 @@ var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; |
{ | ||
"name": "style-to-js", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Parses CSS inline style to JavaScript object (camelCased).", | ||
@@ -39,24 +39,24 @@ "author": "Mark <mark@remarkablemark.org>", | ||
"dependencies": { | ||
"style-to-object": "0.4.1" | ||
"style-to-object": "0.4.2" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "17.4.2", | ||
"@commitlint/config-conventional": "17.4.2", | ||
"@rollup/plugin-commonjs": "24.0.0", | ||
"@rollup/plugin-node-resolve": "15.0.1", | ||
"@rollup/plugin-typescript": "11.0.0", | ||
"@types/jest": "29.2.5", | ||
"@typescript-eslint/eslint-plugin": "5.48.1", | ||
"@typescript-eslint/parser": "5.48.1", | ||
"eslint": "8.32.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"@commitlint/cli": "17.7.1", | ||
"@commitlint/config-conventional": "17.7.0", | ||
"@rollup/plugin-commonjs": "25.0.4", | ||
"@rollup/plugin-node-resolve": "15.2.1", | ||
"@rollup/plugin-typescript": "11.1.3", | ||
"@types/jest": "29.5.4", | ||
"@typescript-eslint/eslint-plugin": "6.5.0", | ||
"@typescript-eslint/parser": "6.5.0", | ||
"eslint": "8.48.0", | ||
"eslint-plugin-prettier": "5.0.0", | ||
"husky": "8.0.3", | ||
"jest": "29.3.1", | ||
"lint-staged": "13.1.0", | ||
"jest": "29.6.4", | ||
"lint-staged": "14.0.1", | ||
"pinst": "3.0.0", | ||
"prettier": "2.8.3", | ||
"prettier": "3.0.3", | ||
"rollup": "2.79.1", | ||
"rollup-plugin-terser": "7.0.2", | ||
"ts-jest": "29.0.5", | ||
"typescript": "4.9.4" | ||
"ts-jest": "29.1.1", | ||
"typescript": "5.2.2" | ||
}, | ||
@@ -63,0 +63,0 @@ "files": [ |
@@ -5,6 +5,7 @@ # style-to-js | ||
[![NPM version](https://img.shields.io/npm/v/style-to-js.svg)](https://www.npmjs.com/package/style-to-js) | ||
[![NPM version](https://badgen.net/npm/v/style-to-js)](https://www.npmjs.com/package/style-to-js) | ||
[![Bundlephobia minified + gzip](https://badgen.net/bundlephobia/minzip/style-to-js)](https://bundlephobia.com/package/style-to-js) | ||
[![build](https://github.com/remarkablemark/style-to-js/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablemark/style-to-js/actions/workflows/build.yml) | ||
[![codecov](https://codecov.io/gh/remarkablemark/style-to-js/branch/master/graph/badge.svg?token=JWKUKTFT3E)](https://codecov.io/gh/remarkablemark/style-to-js) | ||
[![NPM downloads](https://img.shields.io/npm/dm/style-to-js.svg?style=flat-square)](https://www.npmjs.com/package/style-to-js) | ||
[![NPM downloads](https://badgen.net/npm/dm/style-to-js)](https://www.npmjs.com/package/style-to-js) | ||
@@ -11,0 +12,0 @@ Parses CSS inline style to JavaScript object (camelCased): |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.StyleToJS = factory()); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.StyleToJS = factory()); | ||
})(this, (function () { 'use strict'; | ||
var styleToObjectExports = {}; | ||
var styleToObject = { | ||
get exports(){ return styleToObjectExports; }, | ||
set exports(v){ styleToObjectExports = v; }, | ||
}; | ||
function getDefaultExportFromCjs (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; | ||
} | ||
// http://www.w3.org/TR/CSS21/grammar.html | ||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 | ||
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; | ||
var styleToObject = {exports: {}}; | ||
var NEWLINE_REGEX = /\n/g; | ||
var WHITESPACE_REGEX = /^\s*/; | ||
// http://www.w3.org/TR/CSS21/grammar.html | ||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 | ||
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; | ||
// declaration | ||
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/; | ||
var COLON_REGEX = /^:\s*/; | ||
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/; | ||
var SEMICOLON_REGEX = /^[;\s]*/; | ||
var NEWLINE_REGEX = /\n/g; | ||
var WHITESPACE_REGEX = /^\s*/; | ||
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill | ||
var TRIM_REGEX = /^\s+|\s+$/g; | ||
// declaration | ||
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/; | ||
var COLON_REGEX = /^:\s*/; | ||
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/; | ||
var SEMICOLON_REGEX = /^[;\s]*/; | ||
// strings | ||
var NEWLINE = '\n'; | ||
var FORWARD_SLASH = '/'; | ||
var ASTERISK = '*'; | ||
var EMPTY_STRING = ''; | ||
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill | ||
var TRIM_REGEX = /^\s+|\s+$/g; | ||
// types | ||
var TYPE_COMMENT = 'comment'; | ||
var TYPE_DECLARATION = 'declaration'; | ||
// strings | ||
var NEWLINE = '\n'; | ||
var FORWARD_SLASH = '/'; | ||
var ASTERISK = '*'; | ||
var EMPTY_STRING = ''; | ||
/** | ||
* @param {String} style | ||
* @param {Object} [options] | ||
* @return {Object[]} | ||
* @throws {TypeError} | ||
* @throws {Error} | ||
*/ | ||
var inlineStyleParser = function(style, options) { | ||
if (typeof style !== 'string') { | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
// types | ||
var TYPE_COMMENT = 'comment'; | ||
var TYPE_DECLARATION = 'declaration'; | ||
if (!style) return []; | ||
/** | ||
* @param {String} style | ||
* @param {Object} [options] | ||
* @return {Object[]} | ||
* @throws {TypeError} | ||
* @throws {Error} | ||
*/ | ||
var inlineStyleParser = function(style, options) { | ||
if (typeof style !== 'string') { | ||
throw new TypeError('First argument must be a string'); | ||
} | ||
options = options || {}; | ||
if (!style) return []; | ||
/** | ||
* Positional. | ||
*/ | ||
var lineno = 1; | ||
var column = 1; | ||
options = options || {}; | ||
/** | ||
* Update lineno and column based on `str`. | ||
* | ||
* @param {String} str | ||
*/ | ||
function updatePosition(str) { | ||
var lines = str.match(NEWLINE_REGEX); | ||
if (lines) lineno += lines.length; | ||
var i = str.lastIndexOf(NEWLINE); | ||
column = ~i ? str.length - i : column + str.length; | ||
} | ||
/** | ||
* Positional. | ||
*/ | ||
var lineno = 1; | ||
var column = 1; | ||
/** | ||
* Mark position and patch `node.position`. | ||
* | ||
* @return {Function} | ||
*/ | ||
function position() { | ||
var start = { line: lineno, column: column }; | ||
return function(node) { | ||
node.position = new Position(start); | ||
whitespace(); | ||
return node; | ||
}; | ||
} | ||
/** | ||
* Update lineno and column based on `str`. | ||
* | ||
* @param {String} str | ||
*/ | ||
function updatePosition(str) { | ||
var lines = str.match(NEWLINE_REGEX); | ||
if (lines) lineno += lines.length; | ||
var i = str.lastIndexOf(NEWLINE); | ||
column = ~i ? str.length - i : column + str.length; | ||
} | ||
/** | ||
* Store position information for a node. | ||
* | ||
* @constructor | ||
* @property {Object} start | ||
* @property {Object} end | ||
* @property {undefined|String} source | ||
*/ | ||
function Position(start) { | ||
this.start = start; | ||
this.end = { line: lineno, column: column }; | ||
this.source = options.source; | ||
} | ||
/** | ||
* Mark position and patch `node.position`. | ||
* | ||
* @return {Function} | ||
*/ | ||
function position() { | ||
var start = { line: lineno, column: column }; | ||
return function(node) { | ||
node.position = new Position(start); | ||
whitespace(); | ||
return node; | ||
}; | ||
} | ||
/** | ||
* Non-enumerable source string. | ||
*/ | ||
Position.prototype.content = style; | ||
/** | ||
* Store position information for a node. | ||
* | ||
* @constructor | ||
* @property {Object} start | ||
* @property {Object} end | ||
* @property {undefined|String} source | ||
*/ | ||
function Position(start) { | ||
this.start = start; | ||
this.end = { line: lineno, column: column }; | ||
this.source = options.source; | ||
} | ||
/** | ||
* Error `msg`. | ||
* | ||
* @param {String} msg | ||
* @throws {Error} | ||
*/ | ||
function error(msg) { | ||
var err = new Error( | ||
options.source + ':' + lineno + ':' + column + ': ' + msg | ||
); | ||
err.reason = msg; | ||
err.filename = options.source; | ||
err.line = lineno; | ||
err.column = column; | ||
err.source = style; | ||
/** | ||
* Non-enumerable source string. | ||
*/ | ||
Position.prototype.content = style; | ||
if (options.silent) ; else { | ||
throw err; | ||
} | ||
} | ||
/** | ||
* Error `msg`. | ||
* | ||
* @param {String} msg | ||
* @throws {Error} | ||
*/ | ||
function error(msg) { | ||
var err = new Error( | ||
options.source + ':' + lineno + ':' + column + ': ' + msg | ||
); | ||
err.reason = msg; | ||
err.filename = options.source; | ||
err.line = lineno; | ||
err.column = column; | ||
err.source = style; | ||
/** | ||
* Match `re` and return captures. | ||
* | ||
* @param {RegExp} re | ||
* @return {undefined|Array} | ||
*/ | ||
function match(re) { | ||
var m = re.exec(style); | ||
if (!m) return; | ||
var str = m[0]; | ||
updatePosition(str); | ||
style = style.slice(str.length); | ||
return m; | ||
} | ||
if (options.silent) ; else { | ||
throw err; | ||
} | ||
} | ||
/** | ||
* Parse whitespace. | ||
*/ | ||
function whitespace() { | ||
match(WHITESPACE_REGEX); | ||
} | ||
/** | ||
* Match `re` and return captures. | ||
* | ||
* @param {RegExp} re | ||
* @return {undefined|Array} | ||
*/ | ||
function match(re) { | ||
var m = re.exec(style); | ||
if (!m) return; | ||
var str = m[0]; | ||
updatePosition(str); | ||
style = style.slice(str.length); | ||
return m; | ||
} | ||
/** | ||
* Parse comments. | ||
* | ||
* @param {Object[]} [rules] | ||
* @return {Object[]} | ||
*/ | ||
function comments(rules) { | ||
var c; | ||
rules = rules || []; | ||
while ((c = comment())) { | ||
if (c !== false) { | ||
rules.push(c); | ||
} | ||
} | ||
return rules; | ||
} | ||
/** | ||
* Parse whitespace. | ||
*/ | ||
function whitespace() { | ||
match(WHITESPACE_REGEX); | ||
} | ||
/** | ||
* Parse comment. | ||
* | ||
* @return {Object} | ||
* @throws {Error} | ||
*/ | ||
function comment() { | ||
var pos = position(); | ||
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return; | ||
/** | ||
* Parse comments. | ||
* | ||
* @param {Object[]} [rules] | ||
* @return {Object[]} | ||
*/ | ||
function comments(rules) { | ||
var c; | ||
rules = rules || []; | ||
while ((c = comment())) { | ||
if (c !== false) { | ||
rules.push(c); | ||
} | ||
} | ||
return rules; | ||
} | ||
var i = 2; | ||
while ( | ||
EMPTY_STRING != style.charAt(i) && | ||
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1)) | ||
) { | ||
++i; | ||
} | ||
i += 2; | ||
/** | ||
* Parse comment. | ||
* | ||
* @return {Object} | ||
* @throws {Error} | ||
*/ | ||
function comment() { | ||
var pos = position(); | ||
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return; | ||
if (EMPTY_STRING === style.charAt(i - 1)) { | ||
return error('End of comment missing'); | ||
} | ||
var i = 2; | ||
while ( | ||
EMPTY_STRING != style.charAt(i) && | ||
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1)) | ||
) { | ||
++i; | ||
} | ||
i += 2; | ||
var str = style.slice(2, i - 2); | ||
column += 2; | ||
updatePosition(str); | ||
style = style.slice(i); | ||
column += 2; | ||
if (EMPTY_STRING === style.charAt(i - 1)) { | ||
return error('End of comment missing'); | ||
} | ||
return pos({ | ||
type: TYPE_COMMENT, | ||
comment: str | ||
}); | ||
} | ||
var str = style.slice(2, i - 2); | ||
column += 2; | ||
updatePosition(str); | ||
style = style.slice(i); | ||
column += 2; | ||
/** | ||
* Parse declaration. | ||
* | ||
* @return {Object} | ||
* @throws {Error} | ||
*/ | ||
function declaration() { | ||
var pos = position(); | ||
return pos({ | ||
type: TYPE_COMMENT, | ||
comment: str | ||
}); | ||
} | ||
// prop | ||
var prop = match(PROPERTY_REGEX); | ||
if (!prop) return; | ||
comment(); | ||
/** | ||
* Parse declaration. | ||
* | ||
* @return {Object} | ||
* @throws {Error} | ||
*/ | ||
function declaration() { | ||
var pos = position(); | ||
// : | ||
if (!match(COLON_REGEX)) return error("property missing ':'"); | ||
// prop | ||
var prop = match(PROPERTY_REGEX); | ||
if (!prop) return; | ||
comment(); | ||
// val | ||
var val = match(VALUE_REGEX); | ||
// : | ||
if (!match(COLON_REGEX)) return error("property missing ':'"); | ||
var ret = pos({ | ||
type: TYPE_DECLARATION, | ||
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)), | ||
value: val | ||
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) | ||
: EMPTY_STRING | ||
}); | ||
// val | ||
var val = match(VALUE_REGEX); | ||
// ; | ||
match(SEMICOLON_REGEX); | ||
var ret = pos({ | ||
type: TYPE_DECLARATION, | ||
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)), | ||
value: val | ||
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) | ||
: EMPTY_STRING | ||
}); | ||
return ret; | ||
} | ||
// ; | ||
match(SEMICOLON_REGEX); | ||
/** | ||
* Parse declarations. | ||
* | ||
* @return {Object[]} | ||
*/ | ||
function declarations() { | ||
var decls = []; | ||
return ret; | ||
} | ||
comments(decls); | ||
/** | ||
* Parse declarations. | ||
* | ||
* @return {Object[]} | ||
*/ | ||
function declarations() { | ||
var decls = []; | ||
// declarations | ||
var decl; | ||
while ((decl = declaration())) { | ||
if (decl !== false) { | ||
decls.push(decl); | ||
comments(decls); | ||
} | ||
} | ||
comments(decls); | ||
return decls; | ||
} | ||
// declarations | ||
var decl; | ||
while ((decl = declaration())) { | ||
if (decl !== false) { | ||
decls.push(decl); | ||
comments(decls); | ||
} | ||
} | ||
whitespace(); | ||
return declarations(); | ||
}; | ||
return decls; | ||
} | ||
/** | ||
* Trim `str`. | ||
* | ||
* @param {String} str | ||
* @return {String} | ||
*/ | ||
function trim(str) { | ||
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING; | ||
} | ||
whitespace(); | ||
return declarations(); | ||
}; | ||
var parse = inlineStyleParser; | ||
/** | ||
* Trim `str`. | ||
* | ||
* @param {String} str | ||
* @return {String} | ||
*/ | ||
function trim(str) { | ||
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING; | ||
} | ||
/** | ||
* Parses inline style to object. | ||
* | ||
* @example | ||
* // returns { 'line-height': '42' } | ||
* StyleToObject('line-height: 42;'); | ||
* | ||
* @param {String} style - The inline style. | ||
* @param {Function} [iterator] - The iterator function. | ||
* @return {null|Object} | ||
*/ | ||
function StyleToObject$1(style, iterator) { | ||
var output = null; | ||
if (!style || typeof style !== 'string') { | ||
return output; | ||
} | ||
var parse = inlineStyleParser; | ||
var declaration; | ||
var declarations = parse(style); | ||
var hasIterator = typeof iterator === 'function'; | ||
var property; | ||
var value; | ||
/** | ||
* Parses inline style to object. | ||
* | ||
* @example | ||
* // returns { 'line-height': '42' } | ||
* StyleToObject('line-height: 42;'); | ||
* | ||
* @param {String} style - The inline style. | ||
* @param {Function} [iterator] - The iterator function. | ||
* @return {null|Object} | ||
*/ | ||
function StyleToObject(style, iterator) { | ||
var output = null; | ||
if (!style || typeof style !== 'string') { | ||
return output; | ||
} | ||
for (var i = 0, len = declarations.length; i < len; i++) { | ||
declaration = declarations[i]; | ||
property = declaration.property; | ||
value = declaration.value; | ||
var declaration; | ||
var declarations = parse(style); | ||
var hasIterator = typeof iterator === 'function'; | ||
var property; | ||
var value; | ||
if (hasIterator) { | ||
iterator(property, value, declaration); | ||
} else if (value) { | ||
output || (output = {}); | ||
output[property] = value; | ||
} | ||
} | ||
for (var i = 0, len = declarations.length; i < len; i++) { | ||
declaration = declarations[i]; | ||
property = declaration.property; | ||
value = declaration.value; | ||
return output; | ||
} | ||
if (hasIterator) { | ||
iterator(property, value, declaration); | ||
} else if (value) { | ||
output || (output = {}); | ||
output[property] = value; | ||
} | ||
} | ||
styleToObject.exports = StyleToObject$1; | ||
styleToObjectExports.default = StyleToObject$1; // ESM support | ||
return output; | ||
} | ||
var StyleToObject = styleToObjectExports; | ||
styleToObject.exports = StyleToObject; | ||
styleToObject.exports.default = StyleToObject; // ESM support | ||
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
var HYPHEN_REGEX = /-([a-z])/g; | ||
var NO_HYPHEN_REGEX = /^[^-]+$/; | ||
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/; | ||
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/; | ||
var skipCamelCase = function (property) { | ||
return !property || | ||
NO_HYPHEN_REGEX.test(property) || | ||
CUSTOM_PROPERTY_REGEX.test(property); | ||
}; | ||
var capitalize = function (match, character) { | ||
return character.toUpperCase(); | ||
}; | ||
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); }; | ||
var camelCase = function (property, options) { | ||
if (options === void 0) { options = {}; } | ||
if (skipCamelCase(property)) { | ||
return property; | ||
} | ||
property = property.toLowerCase(); | ||
if (options.reactCompat) { | ||
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen); | ||
} | ||
else { | ||
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); | ||
} | ||
return property.replace(HYPHEN_REGEX, capitalize); | ||
}; | ||
var styleToObjectExports = styleToObject.exports; | ||
var StyleToObject$1 = /*@__PURE__*/getDefaultExportFromCjs(styleToObjectExports); | ||
function StyleToJS(style, options) { | ||
var output = {}; | ||
if (!style || typeof style !== 'string') { | ||
return output; | ||
} | ||
StyleToObject(style, function (property, value) { | ||
if (property && value) { | ||
output[camelCase(property, options)] = value; | ||
} | ||
}); | ||
return output; | ||
} | ||
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/; | ||
var HYPHEN_REGEX = /-([a-z])/g; | ||
var NO_HYPHEN_REGEX = /^[^-]+$/; | ||
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/; | ||
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/; | ||
var skipCamelCase = function (property) { | ||
return !property || | ||
NO_HYPHEN_REGEX.test(property) || | ||
CUSTOM_PROPERTY_REGEX.test(property); | ||
}; | ||
var capitalize = function (match, character) { | ||
return character.toUpperCase(); | ||
}; | ||
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); }; | ||
var camelCase = function (property, options) { | ||
if (options === void 0) { options = {}; } | ||
if (skipCamelCase(property)) { | ||
return property; | ||
} | ||
property = property.toLowerCase(); | ||
if (options.reactCompat) { | ||
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen); | ||
} | ||
else { | ||
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen); | ||
} | ||
return property.replace(HYPHEN_REGEX, capitalize); | ||
}; | ||
return StyleToJS; | ||
function StyleToJS(style, options) { | ||
var output = {}; | ||
if (!style || typeof style !== 'string') { | ||
return output; | ||
} | ||
StyleToObject$1(style, function (property, value) { | ||
if (property && value) { | ||
output[camelCase(property, options)] = value; | ||
} | ||
}); | ||
return output; | ||
} | ||
return StyleToJS; | ||
})); | ||
//# sourceMappingURL=style-to-js.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).StyleToJS=e()}(this,(function(){"use strict";var t={},e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,n=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,a=/^\s+|\s+$/g,f="";function s(t){return t?t.replace(a,f):f}var l=function(t,a){if("string"!=typeof t)throw new TypeError("First argument must be a string");if(!t)return[];a=a||{};var l=1,p=1;function h(t){var e=t.match(r);e&&(l+=e.length);var n=t.lastIndexOf("\n");p=~n?t.length-n:p+t.length}function m(){var t={line:l,column:p};return function(e){return e.position=new v(t),y(),e}}function v(t){this.start=t,this.end={line:l,column:p},this.source=a.source}function g(e){var r=new Error(a.source+":"+l+":"+p+": "+e);if(r.reason=e,r.filename=a.source,r.line=l,r.column=p,r.source=t,!a.silent)throw r}function d(e){var r=e.exec(t);if(r){var n=r[0];return h(n),t=t.slice(n.length),r}}function y(){d(n)}function w(t){var e;for(t=t||[];e=x();)!1!==e&&t.push(e);return t}function x(){var e=m();if("/"==t.charAt(0)&&"*"==t.charAt(1)){for(var r=2;f!=t.charAt(r)&&("*"!=t.charAt(r)||"/"!=t.charAt(r+1));)++r;if(r+=2,f===t.charAt(r-1))return g("End of comment missing");var n=t.slice(2,r-2);return p+=2,h(n),t=t.slice(r),p+=2,e({type:"comment",comment:n})}}function A(){var t=m(),r=d(o);if(r){if(x(),!d(i))return g("property missing ':'");var n=d(u),a=t({type:"declaration",property:s(r[0].replace(e,f)),value:n?s(n[0].replace(e,f)):f});return d(c),a}}return v.prototype.content=t,y(),function(){var t,e=[];for(w(e);t=A();)!1!==t&&(e.push(t),w(e));return e}()};function p(t,e){var r,n=null;if(!t||"string"!=typeof t)return n;for(var o,i,u=l(t),c="function"==typeof e,a=0,f=u.length;a<f;a++)o=(r=u[a]).property,i=r.value,c?e(o,i,r):i&&(n||(n={}),n[o]=i);return n}({get exports(){return t},set exports(e){t=e}}).exports=p,t.default=p;var h=t,m=/^--[a-zA-Z0-9-]+$/,v=/-([a-z])/g,g=/^[^-]+$/,d=/^-(webkit|moz|ms|o|khtml)-/,y=/^-(ms)-/,w=function(t,e){return e.toUpperCase()},x=function(t,e){return"".concat(e,"-")},A=function(t,e){return void 0===e&&(e={}),function(t){return!t||g.test(t)||m.test(t)}(t)?t:(t=t.toLowerCase(),(t=e.reactCompat?t.replace(y,x):t.replace(d,x)).replace(v,w))};return function(t,e){var r={};return t&&"string"==typeof t?(h(t,(function(t,n){t&&n&&(r[A(t,e)]=n)})),r):r}})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).StyleToJS=e()}(this,(function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={exports:{}},r=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,o=/^\s*/,u=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,f=/^\s+|\s+$/g,s="";function l(t){return t?t.replace(f,s):s}var p=function(t,e){if("string"!=typeof t)throw new TypeError("First argument must be a string");if(!t)return[];e=e||{};var f=1,p=1;function h(t){var e=t.match(n);e&&(f+=e.length);var r=t.lastIndexOf("\n");p=~r?t.length-r:p+t.length}function m(){var t={line:f,column:p};return function(e){return e.position=new v(t),y(),e}}function v(t){this.start=t,this.end={line:f,column:p},this.source=e.source}function d(r){var n=new Error(e.source+":"+f+":"+p+": "+r);if(n.reason=r,n.filename=e.source,n.line=f,n.column=p,n.source=t,!e.silent)throw n}function g(e){var r=e.exec(t);if(r){var n=r[0];return h(n),t=t.slice(n.length),r}}function y(){g(o)}function w(t){var e;for(t=t||[];e=x();)!1!==e&&t.push(e);return t}function x(){var e=m();if("/"==t.charAt(0)&&"*"==t.charAt(1)){for(var r=2;s!=t.charAt(r)&&("*"!=t.charAt(r)||"/"!=t.charAt(r+1));)++r;if(r+=2,s===t.charAt(r-1))return d("End of comment missing");var n=t.slice(2,r-2);return p+=2,h(n),t=t.slice(r),p+=2,e({type:"comment",comment:n})}}function A(){var t=m(),e=g(u);if(e){if(x(),!g(i))return d("property missing ':'");var n=g(c),o=t({type:"declaration",property:l(e[0].replace(r,s)),value:n?l(n[0].replace(r,s)):s});return g(a),o}}return v.prototype.content=t,y(),function(){var t,e=[];for(w(e);t=A();)!1!==t&&(e.push(t),w(e));return e}()};function h(t,e){var r,n=null;if(!t||"string"!=typeof t)return n;for(var o,u,i=p(t),c="function"==typeof e,a=0,f=i.length;a<f;a++)o=(r=i[a]).property,u=r.value,c?e(o,u,r):u&&(n||(n={}),n[o]=u);return n}e.exports=h,e.exports.default=h;var m=t(e.exports),v=/^--[a-zA-Z0-9-]+$/,d=/-([a-z])/g,g=/^[^-]+$/,y=/^-(webkit|moz|ms|o|khtml)-/,w=/^-(ms)-/,x=function(t,e){return e.toUpperCase()},A=function(t,e){return"".concat(e,"-")},b=function(t,e){return void 0===e&&(e={}),function(t){return!t||g.test(t)||v.test(t)}(t)?t:(t=t.toLowerCase(),(t=e.reactCompat?t.replace(w,A):t.replace(y,A)).replace(d,x))};return function(t,e){var r={};return t&&"string"==typeof t?(m(t,(function(t,n){t&&n&&(r[b(t,e)]=n)})),r):r}})); | ||
//# sourceMappingURL=style-to-js.min.js.map |
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
269
49637
+ Addedstyle-to-object@0.4.2(transitive)
- Removedstyle-to-object@0.4.1(transitive)
Updatedstyle-to-object@0.4.2