style-to-object 0.4.4 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -41
- package/cjs/index.d.ts +22 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +44 -0
- package/cjs/index.js.map +1 -0
- package/dist/style-to-object.js +32 -42
- package/dist/style-to-object.js.map +1 -1
- package/dist/style-to-object.min.js +1 -1
- package/dist/style-to-object.min.js.map +1 -1
- package/esm/index.mjs +3 -0
- package/package.json +24 -21
- package/index.d.ts +0 -45
- package/index.js +0 -43
- package/index.mjs +0 -3
package/README.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
Parses inline style to object:
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
|
|
14
|
+
import parse from 'style-to-object';
|
|
15
|
+
|
|
15
16
|
parse('color: #C0FFEE; background: #BADA55;');
|
|
16
17
|
```
|
|
17
18
|
|
|
@@ -48,16 +49,18 @@ yarn add style-to-object
|
|
|
48
49
|
|
|
49
50
|
## Usage
|
|
50
51
|
|
|
51
|
-
Import
|
|
52
|
+
Import with ES Modules:
|
|
52
53
|
|
|
53
54
|
```js
|
|
54
|
-
// CommonJS
|
|
55
|
-
const parse = require('style-to-object');
|
|
56
|
-
|
|
57
|
-
// ES Modules
|
|
58
55
|
import parse from 'style-to-object';
|
|
59
56
|
```
|
|
60
57
|
|
|
58
|
+
Require with CommonJS:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const parse = require('style-to-object').default;
|
|
62
|
+
```
|
|
63
|
+
|
|
61
64
|
Parse single declaration:
|
|
62
65
|
|
|
63
66
|
```js
|
|
@@ -127,7 +130,7 @@ parse('/*'); // throws Error
|
|
|
127
130
|
If the 2nd argument is a function, then the parser will return `null`:
|
|
128
131
|
|
|
129
132
|
```js
|
|
130
|
-
parse('color: #f00',
|
|
133
|
+
parse('color: #f00', () => {}); // null
|
|
131
134
|
```
|
|
132
135
|
|
|
133
136
|
But the function will iterate through each declaration:
|
|
@@ -135,7 +138,7 @@ But the function will iterate through each declaration:
|
|
|
135
138
|
<!-- prettier-ignore-start -->
|
|
136
139
|
|
|
137
140
|
```js
|
|
138
|
-
parse('color: #f00',
|
|
141
|
+
parse('color: #f00', (name, value, declaration) => {
|
|
139
142
|
console.log(name); // 'color'
|
|
140
143
|
console.log(value); // '#f00'
|
|
141
144
|
console.log(declaration); // { type: 'declaration', property: 'color', value: '#f00' }
|
|
@@ -161,42 +164,14 @@ parse(style, iterator);
|
|
|
161
164
|
console.log(output); // [['color', 'red'], ['background', 'blue']]
|
|
162
165
|
```
|
|
163
166
|
|
|
164
|
-
##
|
|
165
|
-
|
|
166
|
-
Run tests:
|
|
167
|
-
|
|
168
|
-
```sh
|
|
169
|
-
npm test
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Run tests in watch mode:
|
|
173
|
-
|
|
174
|
-
```sh
|
|
175
|
-
npm run test:watch
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
Run tests with coverage:
|
|
179
|
-
|
|
180
|
-
```sh
|
|
181
|
-
npm run test:coverage
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Lint files:
|
|
185
|
-
|
|
186
|
-
```sh
|
|
187
|
-
npm run lint
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Fix lint errors:
|
|
167
|
+
## Migration
|
|
191
168
|
|
|
192
|
-
|
|
193
|
-
npm run lint:fix
|
|
194
|
-
```
|
|
169
|
+
### v1
|
|
195
170
|
|
|
196
|
-
|
|
171
|
+
Migrated to TypeScript. Iterator excludes `Comment`. CommonJS requires the `.default` key:
|
|
197
172
|
|
|
198
|
-
```
|
|
199
|
-
|
|
173
|
+
```js
|
|
174
|
+
const parse = require('style-to-object').default;
|
|
200
175
|
```
|
|
201
176
|
|
|
202
177
|
## Release
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Declaration } from 'inline-style-parser';
|
|
2
|
+
export { Declaration };
|
|
3
|
+
interface StyleObject {
|
|
4
|
+
[name: string]: string;
|
|
5
|
+
}
|
|
6
|
+
type Iterator = (property: string, value: string, declaration: Declaration) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Parses inline style to object.
|
|
9
|
+
*
|
|
10
|
+
* @param style - Inline style.
|
|
11
|
+
* @param iterator - Iterator.
|
|
12
|
+
* @returns - Style object or null.
|
|
13
|
+
*
|
|
14
|
+
* @example Parsing inline style to object:
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* import parse from 'style-to-object';
|
|
18
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export default function StyleToObject(style: string, iterator?: Iterator): StyleObject | null;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,UAAU,WAAW;IACnB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,KAAK,QAAQ,GAAG,CACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,KACrB,IAAI,CAAC;AAEV;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,QAAQ,GAClB,WAAW,GAAG,IAAI,CA0BpB"}
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var inline_style_parser_1 = __importDefault(require("inline-style-parser"));
|
|
7
|
+
/**
|
|
8
|
+
* Parses inline style to object.
|
|
9
|
+
*
|
|
10
|
+
* @param style - Inline style.
|
|
11
|
+
* @param iterator - Iterator.
|
|
12
|
+
* @returns - Style object or null.
|
|
13
|
+
*
|
|
14
|
+
* @example Parsing inline style to object:
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* import parse from 'style-to-object';
|
|
18
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function StyleToObject(style, iterator) {
|
|
22
|
+
var styleObject = null;
|
|
23
|
+
if (!style || typeof style !== 'string') {
|
|
24
|
+
return styleObject;
|
|
25
|
+
}
|
|
26
|
+
var declarations = (0, inline_style_parser_1.default)(style);
|
|
27
|
+
var hasIterator = typeof iterator === 'function';
|
|
28
|
+
declarations.forEach(function (declaration) {
|
|
29
|
+
if (declaration.type !== 'declaration') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var property = declaration.property, value = declaration.value;
|
|
33
|
+
if (hasIterator) {
|
|
34
|
+
iterator(property, value, declaration);
|
|
35
|
+
}
|
|
36
|
+
else if (value) {
|
|
37
|
+
styleObject = styleObject || {};
|
|
38
|
+
styleObject[property] = value;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return styleObject;
|
|
42
|
+
}
|
|
43
|
+
exports.default = StyleToObject;
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4EAAwC;AAexC;;;;;;;;;;;;;GAaG;AACH,SAAwB,aAAa,CACnC,KAAa,EACb,QAAmB;IAEnB,IAAI,WAAW,GAAuB,IAAI,CAAC;IAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACvC,OAAO,WAAW,CAAC;KACpB;IAED,IAAM,YAAY,GAAG,IAAA,6BAAK,EAAC,KAAK,CAAC,CAAC;IAClC,IAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC;IAEnD,YAAY,CAAC,OAAO,CAAC,UAAC,WAAW;QAC/B,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE;YACtC,OAAO;SACR;QAEO,IAAA,QAAQ,GAAY,WAAW,SAAvB,EAAE,KAAK,GAAK,WAAW,MAAhB,CAAiB;QAExC,IAAI,WAAW,EAAE;YACf,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;SACxC;aAAM,IAAI,KAAK,EAAE;YAChB,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;YAChC,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;SAC/B;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC;AA7BD,gCA6BC"}
|
package/dist/style-to-object.js
CHANGED
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
var styleToObject = {exports: {}};
|
|
12
|
-
|
|
13
11
|
// http://www.w3.org/TR/CSS21/grammar.html
|
|
14
12
|
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
15
13
|
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
@@ -43,7 +41,7 @@
|
|
|
43
41
|
* @throws {TypeError}
|
|
44
42
|
* @throws {Error}
|
|
45
43
|
*/
|
|
46
|
-
var inlineStyleParser = function(style, options) {
|
|
44
|
+
var inlineStyleParser = function (style, options) {
|
|
47
45
|
if (typeof style !== 'string') {
|
|
48
46
|
throw new TypeError('First argument must be a string');
|
|
49
47
|
}
|
|
@@ -77,7 +75,7 @@
|
|
|
77
75
|
*/
|
|
78
76
|
function position() {
|
|
79
77
|
var start = { line: lineno, column: column };
|
|
80
|
-
return function(node) {
|
|
78
|
+
return function (node) {
|
|
81
79
|
node.position = new Position(start);
|
|
82
80
|
whitespace();
|
|
83
81
|
return node;
|
|
@@ -268,54 +266,46 @@
|
|
|
268
266
|
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
269
267
|
}
|
|
270
268
|
|
|
271
|
-
var parse = inlineStyleParser;
|
|
269
|
+
var parse = /*@__PURE__*/getDefaultExportFromCjs(inlineStyleParser);
|
|
272
270
|
|
|
273
271
|
/**
|
|
274
272
|
* Parses inline style to object.
|
|
275
273
|
*
|
|
276
|
-
* @
|
|
277
|
-
*
|
|
278
|
-
*
|
|
274
|
+
* @param style - Inline style.
|
|
275
|
+
* @param iterator - Iterator.
|
|
276
|
+
* @returns - Style object or null.
|
|
277
|
+
*
|
|
278
|
+
* @example Parsing inline style to object:
|
|
279
279
|
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
280
|
+
* ```js
|
|
281
|
+
* import parse from 'style-to-object';
|
|
282
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
283
|
+
* ```
|
|
283
284
|
*/
|
|
284
285
|
function StyleToObject(style, iterator) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
var declaration;
|
|
291
|
-
var declarations = parse(style);
|
|
292
|
-
var hasIterator = typeof iterator === 'function';
|
|
293
|
-
var property;
|
|
294
|
-
var value;
|
|
295
|
-
|
|
296
|
-
for (var i = 0, len = declarations.length; i < len; i++) {
|
|
297
|
-
declaration = declarations[i];
|
|
298
|
-
property = declaration.property;
|
|
299
|
-
value = declaration.value;
|
|
300
|
-
|
|
301
|
-
if (hasIterator) {
|
|
302
|
-
iterator(property, value, declaration);
|
|
303
|
-
} else if (value) {
|
|
304
|
-
output || (output = {});
|
|
305
|
-
output[property] = value;
|
|
286
|
+
var styleObject = null;
|
|
287
|
+
if (!style || typeof style !== 'string') {
|
|
288
|
+
return styleObject;
|
|
306
289
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
290
|
+
var declarations = parse(style);
|
|
291
|
+
var hasIterator = typeof iterator === 'function';
|
|
292
|
+
declarations.forEach(function (declaration) {
|
|
293
|
+
if (declaration.type !== 'declaration') {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
var property = declaration.property, value = declaration.value;
|
|
297
|
+
if (hasIterator) {
|
|
298
|
+
iterator(property, value, declaration);
|
|
299
|
+
}
|
|
300
|
+
else if (value) {
|
|
301
|
+
styleObject = styleObject || {};
|
|
302
|
+
styleObject[property] = value;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return styleObject;
|
|
310
306
|
}
|
|
311
307
|
|
|
312
|
-
|
|
313
|
-
styleToObject.exports.default = StyleToObject; // ESM support
|
|
314
|
-
|
|
315
|
-
var styleToObjectExports = styleToObject.exports;
|
|
316
|
-
var index = /*@__PURE__*/getDefaultExportFromCjs(styleToObjectExports);
|
|
317
|
-
|
|
318
|
-
return index;
|
|
308
|
+
return StyleToObject;
|
|
319
309
|
|
|
320
310
|
}));
|
|
321
311
|
//# sourceMappingURL=style-to-object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-to-object.js","sources":["../node_modules/inline-style-parser/index.js","../index.js"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function(style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function(node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n","var parse = require('inline-style-parser');\n\n/**\n * Parses inline style to object.\n *\n * @example\n * // returns { 'line-height': '42' }\n * StyleToObject('line-height: 42;');\n *\n * @param {String} style - The inline style.\n * @param {Function} [iterator] - The iterator function.\n * @return {null|Object}\n */\nfunction StyleToObject(style, iterator) {\n var output = null;\n if (!style || typeof style !== 'string') {\n return output;\n }\n\n var declaration;\n var declarations = parse(style);\n var hasIterator = typeof iterator === 'function';\n var property;\n var value;\n\n for (var i = 0, len = declarations.length; i < len; i++) {\n declaration = declarations[i];\n property = declaration.property;\n value = declaration.value;\n\n if (hasIterator) {\n iterator(property, value, declaration);\n } else if (value) {\n output || (output = {});\n output[property] = value;\n }\n }\n\n return output;\n}\n\nmodule.exports = StyleToObject;\nmodule.exports.default = StyleToObject; // ESM support\n"],"names":["require$$0","styleToObjectModule"],"mappings":";;;;;;;;;;;;CAAA;CACA;CACA,IAAI,aAAa,GAAG,iCAAiC,CAAC;AACtD;CACA,IAAI,aAAa,GAAG,KAAK,CAAC;CAC1B,IAAI,gBAAgB,GAAG,MAAM,CAAC;AAC9B;CACA;CACA,IAAI,cAAc,GAAG,wCAAwC,CAAC;CAC9D,IAAI,WAAW,GAAG,OAAO,CAAC;CAC1B,IAAI,WAAW,GAAG,sDAAsD,CAAC;CACzE,IAAI,eAAe,GAAG,SAAS,CAAC;AAChC;CACA;CACA,IAAI,UAAU,GAAG,YAAY,CAAC;AAC9B;CACA;CACA,IAAI,OAAO,GAAG,IAAI,CAAC;CACnB,IAAI,aAAa,GAAG,GAAG,CAAC;CACxB,IAAI,QAAQ,GAAG,GAAG,CAAC;CACnB,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AAQ,EAAE;CAC3C,IAAI,OAAO,MAAM,CAAC;CAClB,GAAG;AACH;CACA,EAAE,IAAI,WAAW,CAAC;CAClB,EAAE,IAAI,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;CAClC,EAAE,IAAI,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC;CACnD,EAAE,IAAI,QAAQ,CAAC;CACf,EAAE,IAAI,KAAK,CAAC;AACZ;CACA,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;CAC3D,IAAI,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CAClC,IAAI,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;CACpC,IAAI,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;AAC9B;CACA,IAAI,IAAI,WAAW,EAAE;CACrB,MAAM,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;CAC7C,KAAK,MAAM,IAAI,KAAK,EAAE;CACtB,MAAM,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;CAC9B,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;CAC/B,KAAK;CACL,GAAG;AACH;CACA,EAAE,OAAO,MAAM,CAAC;CAChB,CAAC;AACD;AACAC,cAAc,CAAA,OAAA,GAAG,aAAa,CAAC;AACTA,cAAA,CAAA,OAAA,CAAA,OAAA,GAAG,cAAc;;;;;;;;;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"style-to-object.js","sources":["../node_modules/inline-style-parser/index.js","../src/index.ts"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function (style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n",null],"names":[],"mappings":";;;;;;;;;;CAAA;CACA;CACA,IAAI,aAAa,GAAG,iCAAiC,CAAC;AACtD;CACA,IAAI,aAAa,GAAG,KAAK,CAAC;CAC1B,IAAI,gBAAgB,GAAG,MAAM,CAAC;AAC9B;CACA;CACA,IAAI,cAAc,GAAG,wCAAwC,CAAC;CAC9D,IAAI,WAAW,GAAG,OAAO,CAAC;CAC1B,IAAI,WAAW,GAAG,sDAAsD,CAAC;CACzE,IAAI,eAAe,GAAG,SAAS,CAAC;AAChC;CACA;CACA,IAAI,UAAU,GAAG,YAAY,CAAC;AAC9B;CACA;CACA,IAAI,OAAO,GAAG,IAAI,CAAC;CACnB,IAAI,aAAa,GAAG,GAAG,CAAC;CACxB,IAAI,QAAQ,GAAG,GAAG,CAAC;CACnB,IAAI,YAAY,GAAG,EAAE,CAAC;AACtB;CACA;CACA,IAAI,YAAY,GAAG,SAAS,CAAC;CAC7B,IAAI,gBAAgB,GAAG,aAAa,CAAC;AACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,IAAA,iBAAc,GAAG,UAAU,KAAK,EAAE,OAAO,EAAE;CAC3C,EAAE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;CACjC,IAAI,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;CAC3D,GAAG;AACH;CACA,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;A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,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;CACxC,SAAA;CAAM,aAAA,IAAI,KAAK,EAAE;CAChB,YAAA,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;CAChC,YAAA,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;CAC/B,SAAA;CACH,KAAC,CAAC,CAAC;CAEH,IAAA,OAAO,WAAW,CAAC;CACrB;;;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e
|
|
1
|
+
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).StyleToObject=e()}(this,(function(){"use strict";function n(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,t=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,a="";function s(n){return n?n.replace(f,a):a}var l=n((function(n,f){if("string"!=typeof n)throw new TypeError("First argument must be a string");if(!n)return[];f=f||{};var l=1,p=1;function h(n){var e=n.match(r);e&&(l+=e.length);var t=n.lastIndexOf("\n");p=~t?n.length-t:p+n.length}function v(){var n={line:l,column:p};return function(e){return e.position=new d(n),g(),e}}function d(n){this.start=n,this.end={line:l,column:p},this.source=f.source}function m(e){var r=new Error(f.source+":"+l+":"+p+": "+e);if(r.reason=e,r.filename=f.source,r.line=l,r.column=p,r.source=n,!f.silent)throw r}function y(e){var r=e.exec(n);if(r){var t=r[0];return h(t),n=n.slice(t.length),r}}function g(){y(t)}function w(n){var e;for(n=n||[];e=b();)!1!==e&&n.push(e);return n}function b(){var e=v();if("/"==n.charAt(0)&&"*"==n.charAt(1)){for(var r=2;a!=n.charAt(r)&&("*"!=n.charAt(r)||"/"!=n.charAt(r+1));)++r;if(r+=2,a===n.charAt(r-1))return m("End of comment missing");var t=n.slice(2,r-2);return p+=2,h(t),n=n.slice(r),p+=2,e({type:"comment",comment:t})}}function A(){var n=v(),r=y(o);if(r){if(b(),!y(i))return m("property missing ':'");var t=y(u),f=n({type:"declaration",property:s(r[0].replace(e,a)),value:t?s(t[0].replace(e,a)):a});return y(c),f}}return d.prototype.content=n,g(),function(){var n,e=[];for(w(e);n=A();)!1!==n&&(e.push(n),w(e));return e}()}));return function(n,e){var r=null;if(!n||"string"!=typeof n)return r;var t=l(n),o="function"==typeof e;return t.forEach((function(n){if("declaration"===n.type){var t=n.property,i=n.value;o?e(t,i,n):i&&((r=r||{})[t]=i)}})),r}}));
|
|
2
2
|
//# sourceMappingURL=style-to-object.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-to-object.min.js","sources":["../node_modules/inline-style-parser/index.js","../index.
|
|
1
|
+
{"version":3,"file":"style-to-object.min.js","sources":["../node_modules/inline-style-parser/index.js","../src/index.ts"],"sourcesContent":["// http://www.w3.org/TR/CSS21/grammar.html\n// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027\nvar COMMENT_REGEX = /\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\//g;\n\nvar NEWLINE_REGEX = /\\n/g;\nvar WHITESPACE_REGEX = /^\\s*/;\n\n// declaration\nvar PROPERTY_REGEX = /^(\\*?[-#/*\\\\\\w]+(\\[[0-9a-z_-]+\\])?)\\s*/;\nvar COLON_REGEX = /^:\\s*/;\nvar VALUE_REGEX = /^((?:'(?:\\\\'|.)*?'|\"(?:\\\\\"|.)*?\"|\\([^)]*?\\)|[^};])+)/;\nvar SEMICOLON_REGEX = /^[;\\s]*/;\n\n// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill\nvar TRIM_REGEX = /^\\s+|\\s+$/g;\n\n// strings\nvar NEWLINE = '\\n';\nvar FORWARD_SLASH = '/';\nvar ASTERISK = '*';\nvar EMPTY_STRING = '';\n\n// types\nvar TYPE_COMMENT = 'comment';\nvar TYPE_DECLARATION = 'declaration';\n\n/**\n * @param {String} style\n * @param {Object} [options]\n * @return {Object[]}\n * @throws {TypeError}\n * @throws {Error}\n */\nmodule.exports = function (style, options) {\n if (typeof style !== 'string') {\n throw new TypeError('First argument must be a string');\n }\n\n if (!style) return [];\n\n options = options || {};\n\n /**\n * Positional.\n */\n var lineno = 1;\n var column = 1;\n\n /**\n * Update lineno and column based on `str`.\n *\n * @param {String} str\n */\n function updatePosition(str) {\n var lines = str.match(NEWLINE_REGEX);\n if (lines) lineno += lines.length;\n var i = str.lastIndexOf(NEWLINE);\n column = ~i ? str.length - i : column + str.length;\n }\n\n /**\n * Mark position and patch `node.position`.\n *\n * @return {Function}\n */\n function position() {\n var start = { line: lineno, column: column };\n return function (node) {\n node.position = new Position(start);\n whitespace();\n return node;\n };\n }\n\n /**\n * Store position information for a node.\n *\n * @constructor\n * @property {Object} start\n * @property {Object} end\n * @property {undefined|String} source\n */\n function Position(start) {\n this.start = start;\n this.end = { line: lineno, column: column };\n this.source = options.source;\n }\n\n /**\n * Non-enumerable source string.\n */\n Position.prototype.content = style;\n\n var errorsList = [];\n\n /**\n * Error `msg`.\n *\n * @param {String} msg\n * @throws {Error}\n */\n function error(msg) {\n var err = new Error(\n options.source + ':' + lineno + ':' + column + ': ' + msg\n );\n err.reason = msg;\n err.filename = options.source;\n err.line = lineno;\n err.column = column;\n err.source = style;\n\n if (options.silent) {\n errorsList.push(err);\n } else {\n throw err;\n }\n }\n\n /**\n * Match `re` and return captures.\n *\n * @param {RegExp} re\n * @return {undefined|Array}\n */\n function match(re) {\n var m = re.exec(style);\n if (!m) return;\n var str = m[0];\n updatePosition(str);\n style = style.slice(str.length);\n return m;\n }\n\n /**\n * Parse whitespace.\n */\n function whitespace() {\n match(WHITESPACE_REGEX);\n }\n\n /**\n * Parse comments.\n *\n * @param {Object[]} [rules]\n * @return {Object[]}\n */\n function comments(rules) {\n var c;\n rules = rules || [];\n while ((c = comment())) {\n if (c !== false) {\n rules.push(c);\n }\n }\n return rules;\n }\n\n /**\n * Parse comment.\n *\n * @return {Object}\n * @throws {Error}\n */\n function comment() {\n var pos = position();\n if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;\n\n var i = 2;\n while (\n EMPTY_STRING != style.charAt(i) &&\n (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))\n ) {\n ++i;\n }\n i += 2;\n\n if (EMPTY_STRING === style.charAt(i - 1)) {\n return error('End of comment missing');\n }\n\n var str = style.slice(2, i - 2);\n column += 2;\n updatePosition(str);\n style = style.slice(i);\n column += 2;\n\n return pos({\n type: TYPE_COMMENT,\n comment: str\n });\n }\n\n /**\n * Parse declaration.\n *\n * @return {Object}\n * @throws {Error}\n */\n function declaration() {\n var pos = position();\n\n // prop\n var prop = match(PROPERTY_REGEX);\n if (!prop) return;\n comment();\n\n // :\n if (!match(COLON_REGEX)) return error(\"property missing ':'\");\n\n // val\n var val = match(VALUE_REGEX);\n\n var ret = pos({\n type: TYPE_DECLARATION,\n property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),\n value: val\n ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))\n : EMPTY_STRING\n });\n\n // ;\n match(SEMICOLON_REGEX);\n\n return ret;\n }\n\n /**\n * Parse declarations.\n *\n * @return {Object[]}\n */\n function declarations() {\n var decls = [];\n\n comments(decls);\n\n // declarations\n var decl;\n while ((decl = declaration())) {\n if (decl !== false) {\n decls.push(decl);\n comments(decls);\n }\n }\n\n return decls;\n }\n\n whitespace();\n return declarations();\n};\n\n/**\n * Trim `str`.\n *\n * @param {String} str\n * @return {String}\n */\nfunction trim(str) {\n return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;\n}\n",null],"names":["COMMENT_REGEX","NEWLINE_REGEX","WHITESPACE_REGEX","PROPERTY_REGEX","COLON_REGEX","VALUE_REGEX","SEMICOLON_REGEX","TRIM_REGEX","EMPTY_STRING","trim","str","replace","style","options","TypeError","lineno","column","updatePosition","lines","match","length","i","lastIndexOf","position","start","line","node","Position","whitespace","this","end","source","error","msg","err","Error","reason","filename","silent","re","m","exec","slice","comments","rules","c","comment","push","pos","charAt","type","declaration","prop","val","ret","property","value","prototype","content","decl","decls","declarations","iterator","styleObject","parse","hasIterator","forEach"],"mappings":"kVAEA,IAAIA,EAAgB,kCAEhBC,EAAgB,MAChBC,EAAmB,OAGnBC,EAAiB,yCACjBC,EAAc,QACdC,EAAc,uDACdC,EAAkB,UAGlBC,EAAa,aAMbC,EAAe,GA8OnB,SAASC,EAAKC,GACZ,OAAOA,EAAMA,EAAIC,QAAQJ,EAAYC,GAAgBA,CACvD,UAnOiB,SAAUI,EAAOC,GAChC,GAAqB,iBAAVD,EACT,MAAM,IAAIE,UAAU,mCAGtB,IAAKF,EAAO,MAAO,GAEnBC,EAAUA,GAAW,GAKrB,IAAIE,EAAS,EACTC,EAAS,EAOb,SAASC,EAAeP,GACtB,IAAIQ,EAAQR,EAAIS,MAAMlB,GAClBiB,IAAOH,GAAUG,EAAME,QAC3B,IAAIC,EAAIX,EAAIY,YAvCF,MAwCVN,GAAUK,EAAIX,EAAIU,OAASC,EAAIL,EAASN,EAAIU,MAC7C,CAOD,SAASG,IACP,IAAIC,EAAQ,CAAEC,KAAMV,EAAQC,OAAQA,GACpC,OAAO,SAAUU,GAGf,OAFAA,EAAKH,SAAW,IAAII,EAASH,GAC7BI,IACOF,CACb,CACG,CAUD,SAASC,EAASH,GAChBK,KAAKL,MAAQA,EACbK,KAAKC,IAAM,CAAEL,KAAMV,EAAQC,OAAQA,GACnCa,KAAKE,OAASlB,EAAQkB,MACvB,CAeD,SAASC,EAAMC,GACb,IAAIC,EAAM,IAAIC,MACZtB,EAAQkB,OAAS,IAAMhB,EAAS,IAAMC,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U9C,EAAK2C,EAAK,GAAGzC,QAAQX,EAAeQ,IAC9CgD,MAAOH,EACH5C,EAAK4C,EAAI,GAAG1C,QAAQX,EAAeQ,IACnCA,IAMN,OAFAW,EAAMb,GAECgD,CApBW,CAqBnB,CAyBD,OA9JA3B,EAAS8B,UAAUC,QAAU9C,EA6J7BgB,IAjBA,WACE,IAKI+B,EALAC,EAAQ,GAMZ,IAJAjB,EAASiB,GAIDD,EAAOR,MACA,IAATQ,IACFC,EAAMb,KAAKY,GACXhB,EAASiB,IAIb,OAAOA,CACR,CAGMC,EACT,WC7Nc,SACZjD,EACAkD,GAEA,IAAIC,EAAkC,KAEtC,IAAKnD,GAA0B,iBAAVA,EACnB,OAAOmD,EAGT,IAAMF,EAAeG,EAAMpD,GACrBqD,EAAkC,mBAAbH,EAiB3B,OAfAD,EAAaK,SAAQ,SAACf,GACpB,GAAyB,gBAArBA,EAAYD,KAAhB,CAIQ,IAAAK,EAAoBJ,EAAWI,SAArBC,EAAUL,EAAWK,MAEnCS,EACFH,EAASP,EAAUC,EAAOL,GACjBK,KACTO,EAAcA,GAAe,IACjBR,GAAYC,EARzB,CAUH,IAEOO,CACT","x_google_ignoreList":[0]}
|
package/esm/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "style-to-object",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Converts inline style to object.",
|
|
5
5
|
"author": "Mark <mark@remarkablemark.org>",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"
|
|
8
|
-
"module": "index.mjs",
|
|
6
|
+
"main": "cjs/index.js",
|
|
7
|
+
"module": "esm/index.mjs",
|
|
9
8
|
"exports": {
|
|
10
|
-
"types": "./index.d.ts",
|
|
11
|
-
"import": "./index.mjs",
|
|
12
|
-
"require": "./index.js"
|
|
9
|
+
"types": "./cjs/index.d.ts",
|
|
10
|
+
"import": "./esm/index.mjs",
|
|
11
|
+
"require": "./cjs/index.js"
|
|
13
12
|
},
|
|
14
13
|
"scripts": {
|
|
15
|
-
"build": "
|
|
16
|
-
"
|
|
14
|
+
"build": "run-s build:*",
|
|
15
|
+
"build:cjs": "tsc --outDir cjs",
|
|
16
|
+
"build:umd": "rollup --config --failAfterWarnings",
|
|
17
|
+
"clean": "rm -rf cjs coverage dist",
|
|
17
18
|
"lint": "eslint --ignore-path .gitignore .",
|
|
18
19
|
"lint:fix": "npm run lint -- --fix",
|
|
19
|
-
"lint:
|
|
20
|
+
"lint:tsc": "tsc --noEmit",
|
|
20
21
|
"_postinstall": "husky install",
|
|
21
22
|
"postpublish": "pinst --enable",
|
|
22
|
-
"prepublishOnly": "pinst --disable && run-s lint lint:
|
|
23
|
+
"prepublishOnly": "pinst --disable && run-s lint lint:tsc test clean build",
|
|
23
24
|
"test": "jest",
|
|
24
25
|
"test:ci": "CI=true jest --ci --colors --coverage",
|
|
25
|
-
"test:esm": "node --test __tests__
|
|
26
|
+
"test:esm": "npm run build:cjs && node --test __tests__",
|
|
26
27
|
"test:watch": "npm run test -- --watch"
|
|
27
28
|
},
|
|
28
29
|
"repository": {
|
|
@@ -42,32 +43,34 @@
|
|
|
42
43
|
"pojo"
|
|
43
44
|
],
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"inline-style-parser": "0.
|
|
46
|
+
"inline-style-parser": "0.2.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@commitlint/cli": "17.8.0",
|
|
49
50
|
"@commitlint/config-conventional": "17.8.0",
|
|
50
|
-
"@
|
|
51
|
-
"@rollup/plugin-commonjs": "25.0.5",
|
|
51
|
+
"@rollup/plugin-commonjs": "25.0.7",
|
|
52
52
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
53
53
|
"@rollup/plugin-terser": "0.4.4",
|
|
54
|
-
"@typescript
|
|
54
|
+
"@rollup/plugin-typescript": "11.1.5",
|
|
55
|
+
"@types/jest": "29.5.5",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "6.7.5",
|
|
57
|
+
"@typescript-eslint/parser": "6.7.5",
|
|
55
58
|
"eslint": "8.51.0",
|
|
56
59
|
"eslint-plugin-prettier": "5.0.1",
|
|
57
60
|
"husky": "8.0.3",
|
|
58
61
|
"jest": "29.7.0",
|
|
59
|
-
"lint-staged": "
|
|
62
|
+
"lint-staged": "15.0.1",
|
|
60
63
|
"npm-run-all": "4.1.5",
|
|
61
64
|
"pinst": "3.0.0",
|
|
62
65
|
"prettier": "3.0.3",
|
|
63
|
-
"rollup": "4.1.
|
|
66
|
+
"rollup": "4.1.4",
|
|
67
|
+
"ts-jest": "29.1.1",
|
|
64
68
|
"typescript": "5.2.2"
|
|
65
69
|
},
|
|
66
70
|
"files": [
|
|
71
|
+
"/cjs",
|
|
67
72
|
"/dist",
|
|
68
|
-
"
|
|
69
|
-
"index.js",
|
|
70
|
-
"index.mjs"
|
|
73
|
+
"/esm"
|
|
71
74
|
],
|
|
72
75
|
"license": "MIT"
|
|
73
76
|
}
|
package/index.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses inline style to object.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* import parse from 'style-to-object';
|
|
8
|
-
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export default function StyleToObject(
|
|
12
|
-
style: string,
|
|
13
|
-
iterator?: Iterator
|
|
14
|
-
): { [name: string]: string } | null;
|
|
15
|
-
|
|
16
|
-
interface Position {
|
|
17
|
-
start: {
|
|
18
|
-
line: number;
|
|
19
|
-
column: number;
|
|
20
|
-
};
|
|
21
|
-
end: {
|
|
22
|
-
line: number;
|
|
23
|
-
column: number;
|
|
24
|
-
};
|
|
25
|
-
source?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface Declaration {
|
|
29
|
-
type: 'declaration';
|
|
30
|
-
property: string;
|
|
31
|
-
value: string;
|
|
32
|
-
position: Position;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface Comment {
|
|
36
|
-
type: 'comment';
|
|
37
|
-
comment: string;
|
|
38
|
-
position: Position;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type Iterator = (
|
|
42
|
-
property: string,
|
|
43
|
-
value: string,
|
|
44
|
-
declaration: Declaration | Comment
|
|
45
|
-
) => void;
|
package/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var parse = require('inline-style-parser');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Parses inline style to object.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* // returns { 'line-height': '42' }
|
|
8
|
-
* StyleToObject('line-height: 42;');
|
|
9
|
-
*
|
|
10
|
-
* @param {String} style - The inline style.
|
|
11
|
-
* @param {Function} [iterator] - The iterator function.
|
|
12
|
-
* @return {null|Object}
|
|
13
|
-
*/
|
|
14
|
-
function StyleToObject(style, iterator) {
|
|
15
|
-
var output = null;
|
|
16
|
-
if (!style || typeof style !== 'string') {
|
|
17
|
-
return output;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var declaration;
|
|
21
|
-
var declarations = parse(style);
|
|
22
|
-
var hasIterator = typeof iterator === 'function';
|
|
23
|
-
var property;
|
|
24
|
-
var value;
|
|
25
|
-
|
|
26
|
-
for (var i = 0, len = declarations.length; i < len; i++) {
|
|
27
|
-
declaration = declarations[i];
|
|
28
|
-
property = declaration.property;
|
|
29
|
-
value = declaration.value;
|
|
30
|
-
|
|
31
|
-
if (hasIterator) {
|
|
32
|
-
iterator(property, value, declaration);
|
|
33
|
-
} else if (value) {
|
|
34
|
-
output || (output = {});
|
|
35
|
-
output[property] = value;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return output;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = StyleToObject;
|
|
43
|
-
module.exports.default = StyleToObject; // ESM support
|
package/index.mjs
DELETED