style-to-object 1.0.8 → 1.0.10
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/cjs/index.d.ts +1 -1
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +6 -6
- package/cjs/index.js.map +1 -1
- package/dist/style-to-object.js +271 -262
- 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.d.mts → index.d.ts} +2 -1
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +38 -0
- package/esm/index.js.map +1 -0
- package/esm/index.mjs +40 -3
- package/esm/index.mjs.map +1 -0
- package/package.json +39 -30
- package/src/index.ts +1 -1
package/cjs/index.d.ts
CHANGED
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,MAAM,WAAW,WAAW;IAC1B,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
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = StyleToObject;
|
|
7
|
-
|
|
7
|
+
const inline_style_parser_1 = __importDefault(require("inline-style-parser"));
|
|
8
8
|
/**
|
|
9
9
|
* Parses inline style to object.
|
|
10
10
|
*
|
|
@@ -20,17 +20,17 @@ var inline_style_parser_1 = __importDefault(require("inline-style-parser"));
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
function StyleToObject(style, iterator) {
|
|
23
|
-
|
|
23
|
+
let styleObject = null;
|
|
24
24
|
if (!style || typeof style !== 'string') {
|
|
25
25
|
return styleObject;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
declarations.forEach(
|
|
27
|
+
const declarations = (0, inline_style_parser_1.default)(style);
|
|
28
|
+
const hasIterator = typeof iterator === 'function';
|
|
29
|
+
declarations.forEach((declaration) => {
|
|
30
30
|
if (declaration.type !== 'declaration') {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
const { property, value } = declaration;
|
|
34
34
|
if (hasIterator) {
|
|
35
35
|
iterator(property, value, declaration);
|
|
36
36
|
}
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AA6BA,gCA6BC;AAzDD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AA6BA,gCA6BC;AAzDD,8EAAwC;AAcxC;;;;;;;;;;;;;GAaG;AACH,SAAwB,aAAa,CACnC,KAAa,EACb,QAAmB;IAEnB,IAAI,WAAW,GAAuB,IAAI,CAAC;IAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,YAAY,GAAG,IAAA,6BAAK,EAAC,KAAK,CAAC,CAAC;IAClC,MAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC;IAEnD,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACnC,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC;QAExC,IAAI,WAAW,EAAE,CAAC;YAChB,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QACzC,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;YAChC,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/style-to-object.js
CHANGED
|
@@ -8,265 +8,274 @@
|
|
|
8
8
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
11
|
+
var inlineStyleParser;
|
|
12
|
+
var hasRequiredInlineStyleParser;
|
|
13
|
+
|
|
14
|
+
function requireInlineStyleParser () {
|
|
15
|
+
if (hasRequiredInlineStyleParser) return inlineStyleParser;
|
|
16
|
+
hasRequiredInlineStyleParser = 1;
|
|
17
|
+
// http://www.w3.org/TR/CSS21/grammar.html
|
|
18
|
+
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
19
|
+
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
20
|
+
|
|
21
|
+
var NEWLINE_REGEX = /\n/g;
|
|
22
|
+
var WHITESPACE_REGEX = /^\s*/;
|
|
23
|
+
|
|
24
|
+
// declaration
|
|
25
|
+
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
|
26
|
+
var COLON_REGEX = /^:\s*/;
|
|
27
|
+
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
|
28
|
+
var SEMICOLON_REGEX = /^[;\s]*/;
|
|
29
|
+
|
|
30
|
+
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
31
|
+
var TRIM_REGEX = /^\s+|\s+$/g;
|
|
32
|
+
|
|
33
|
+
// strings
|
|
34
|
+
var NEWLINE = '\n';
|
|
35
|
+
var FORWARD_SLASH = '/';
|
|
36
|
+
var ASTERISK = '*';
|
|
37
|
+
var EMPTY_STRING = '';
|
|
38
|
+
|
|
39
|
+
// types
|
|
40
|
+
var TYPE_COMMENT = 'comment';
|
|
41
|
+
var TYPE_DECLARATION = 'declaration';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {String} style
|
|
45
|
+
* @param {Object} [options]
|
|
46
|
+
* @return {Object[]}
|
|
47
|
+
* @throws {TypeError}
|
|
48
|
+
* @throws {Error}
|
|
49
|
+
*/
|
|
50
|
+
inlineStyleParser = function (style, options) {
|
|
51
|
+
if (typeof style !== 'string') {
|
|
52
|
+
throw new TypeError('First argument must be a string');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!style) return [];
|
|
56
|
+
|
|
57
|
+
options = options || {};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Positional.
|
|
61
|
+
*/
|
|
62
|
+
var lineno = 1;
|
|
63
|
+
var column = 1;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Update lineno and column based on `str`.
|
|
67
|
+
*
|
|
68
|
+
* @param {String} str
|
|
69
|
+
*/
|
|
70
|
+
function updatePosition(str) {
|
|
71
|
+
var lines = str.match(NEWLINE_REGEX);
|
|
72
|
+
if (lines) lineno += lines.length;
|
|
73
|
+
var i = str.lastIndexOf(NEWLINE);
|
|
74
|
+
column = ~i ? str.length - i : column + str.length;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Mark position and patch `node.position`.
|
|
79
|
+
*
|
|
80
|
+
* @return {Function}
|
|
81
|
+
*/
|
|
82
|
+
function position() {
|
|
83
|
+
var start = { line: lineno, column: column };
|
|
84
|
+
return function (node) {
|
|
85
|
+
node.position = new Position(start);
|
|
86
|
+
whitespace();
|
|
87
|
+
return node;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Store position information for a node.
|
|
93
|
+
*
|
|
94
|
+
* @constructor
|
|
95
|
+
* @property {Object} start
|
|
96
|
+
* @property {Object} end
|
|
97
|
+
* @property {undefined|String} source
|
|
98
|
+
*/
|
|
99
|
+
function Position(start) {
|
|
100
|
+
this.start = start;
|
|
101
|
+
this.end = { line: lineno, column: column };
|
|
102
|
+
this.source = options.source;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Non-enumerable source string.
|
|
107
|
+
*/
|
|
108
|
+
Position.prototype.content = style;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Error `msg`.
|
|
112
|
+
*
|
|
113
|
+
* @param {String} msg
|
|
114
|
+
* @throws {Error}
|
|
115
|
+
*/
|
|
116
|
+
function error(msg) {
|
|
117
|
+
var err = new Error(
|
|
118
|
+
options.source + ':' + lineno + ':' + column + ': ' + msg
|
|
119
|
+
);
|
|
120
|
+
err.reason = msg;
|
|
121
|
+
err.filename = options.source;
|
|
122
|
+
err.line = lineno;
|
|
123
|
+
err.column = column;
|
|
124
|
+
err.source = style;
|
|
125
|
+
|
|
126
|
+
if (options.silent) ; else {
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Match `re` and return captures.
|
|
133
|
+
*
|
|
134
|
+
* @param {RegExp} re
|
|
135
|
+
* @return {undefined|Array}
|
|
136
|
+
*/
|
|
137
|
+
function match(re) {
|
|
138
|
+
var m = re.exec(style);
|
|
139
|
+
if (!m) return;
|
|
140
|
+
var str = m[0];
|
|
141
|
+
updatePosition(str);
|
|
142
|
+
style = style.slice(str.length);
|
|
143
|
+
return m;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Parse whitespace.
|
|
148
|
+
*/
|
|
149
|
+
function whitespace() {
|
|
150
|
+
match(WHITESPACE_REGEX);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Parse comments.
|
|
155
|
+
*
|
|
156
|
+
* @param {Object[]} [rules]
|
|
157
|
+
* @return {Object[]}
|
|
158
|
+
*/
|
|
159
|
+
function comments(rules) {
|
|
160
|
+
var c;
|
|
161
|
+
rules = rules || [];
|
|
162
|
+
while ((c = comment())) {
|
|
163
|
+
if (c !== false) {
|
|
164
|
+
rules.push(c);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return rules;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Parse comment.
|
|
172
|
+
*
|
|
173
|
+
* @return {Object}
|
|
174
|
+
* @throws {Error}
|
|
175
|
+
*/
|
|
176
|
+
function comment() {
|
|
177
|
+
var pos = position();
|
|
178
|
+
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
179
|
+
|
|
180
|
+
var i = 2;
|
|
181
|
+
while (
|
|
182
|
+
EMPTY_STRING != style.charAt(i) &&
|
|
183
|
+
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
|
184
|
+
) {
|
|
185
|
+
++i;
|
|
186
|
+
}
|
|
187
|
+
i += 2;
|
|
188
|
+
|
|
189
|
+
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
190
|
+
return error('End of comment missing');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var str = style.slice(2, i - 2);
|
|
194
|
+
column += 2;
|
|
195
|
+
updatePosition(str);
|
|
196
|
+
style = style.slice(i);
|
|
197
|
+
column += 2;
|
|
198
|
+
|
|
199
|
+
return pos({
|
|
200
|
+
type: TYPE_COMMENT,
|
|
201
|
+
comment: str
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Parse declaration.
|
|
207
|
+
*
|
|
208
|
+
* @return {Object}
|
|
209
|
+
* @throws {Error}
|
|
210
|
+
*/
|
|
211
|
+
function declaration() {
|
|
212
|
+
var pos = position();
|
|
213
|
+
|
|
214
|
+
// prop
|
|
215
|
+
var prop = match(PROPERTY_REGEX);
|
|
216
|
+
if (!prop) return;
|
|
217
|
+
comment();
|
|
218
|
+
|
|
219
|
+
// :
|
|
220
|
+
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
221
|
+
|
|
222
|
+
// val
|
|
223
|
+
var val = match(VALUE_REGEX);
|
|
224
|
+
|
|
225
|
+
var ret = pos({
|
|
226
|
+
type: TYPE_DECLARATION,
|
|
227
|
+
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
|
228
|
+
value: val
|
|
229
|
+
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
|
|
230
|
+
: EMPTY_STRING
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// ;
|
|
234
|
+
match(SEMICOLON_REGEX);
|
|
235
|
+
|
|
236
|
+
return ret;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Parse declarations.
|
|
241
|
+
*
|
|
242
|
+
* @return {Object[]}
|
|
243
|
+
*/
|
|
244
|
+
function declarations() {
|
|
245
|
+
var decls = [];
|
|
246
|
+
|
|
247
|
+
comments(decls);
|
|
248
|
+
|
|
249
|
+
// declarations
|
|
250
|
+
var decl;
|
|
251
|
+
while ((decl = declaration())) {
|
|
252
|
+
if (decl !== false) {
|
|
253
|
+
decls.push(decl);
|
|
254
|
+
comments(decls);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return decls;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
whitespace();
|
|
262
|
+
return declarations();
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Trim `str`.
|
|
267
|
+
*
|
|
268
|
+
* @param {String} str
|
|
269
|
+
* @return {String}
|
|
270
|
+
*/
|
|
271
|
+
function trim(str) {
|
|
272
|
+
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
273
|
+
}
|
|
274
|
+
return inlineStyleParser;
|
|
267
275
|
}
|
|
268
276
|
|
|
269
|
-
var
|
|
277
|
+
var inlineStyleParserExports = requireInlineStyleParser();
|
|
278
|
+
var parse = /*@__PURE__*/getDefaultExportFromCjs(inlineStyleParserExports);
|
|
270
279
|
|
|
271
280
|
/**
|
|
272
281
|
* Parses inline style to object.
|
|
@@ -283,17 +292,17 @@
|
|
|
283
292
|
* ```
|
|
284
293
|
*/
|
|
285
294
|
function StyleToObject(style, iterator) {
|
|
286
|
-
|
|
295
|
+
let styleObject = null;
|
|
287
296
|
if (!style || typeof style !== 'string') {
|
|
288
297
|
return styleObject;
|
|
289
298
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
declarations.forEach(
|
|
299
|
+
const declarations = parse(style);
|
|
300
|
+
const hasIterator = typeof iterator === 'function';
|
|
301
|
+
declarations.forEach((declaration) => {
|
|
293
302
|
if (declaration.type !== 'declaration') {
|
|
294
303
|
return;
|
|
295
304
|
}
|
|
296
|
-
|
|
305
|
+
const { property, value } = declaration;
|
|
297
306
|
if (hasIterator) {
|
|
298
307
|
iterator(property, value, declaration);
|
|
299
308
|
}
|
|
@@ -1 +1 @@
|
|
|
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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CACA;CACA;CACA;CACA,SAAS,IAAI,CAAC,GAAG,EAAE;CACnB,EAAE,OAAO,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,GAAG,YAAY,CAAC;CACpE,CAAA;;;;CCrPA;;;;;;;;;;;;;CAaG;CACW,SAAU,aAAa,CACnC,KAAa,EACb,QAAmB,EAAA;KAEnB,IAAI,WAAW,GAAuB,IAAI,CAAC;KAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;CACvC,QAAA,OAAO,WAAW,CAAC;MACpB;CAED,IAAA,IAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;CAClC,IAAA,IAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC;CAEnD,IAAA,YAAY,CAAC,OAAO,CAAC,UAAC,WAAW,EAAA;CAC/B,QAAA,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE;aACtC,OAAO;UACR;SAEO,IAAA,QAAQ,GAAY,WAAW,CAAA,QAAvB,EAAE,KAAK,GAAK,WAAW,CAAA,KAAhB,CAAiB;SAExC,IAAI,WAAW,EAAE;CACf,YAAA,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;UACxC;cAAM,IAAI,KAAK,EAAE;CAChB,YAAA,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;CAChC,YAAA,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;UAC/B;CACH,KAAC,CAAC,CAAC;CAEH,IAAA,OAAO,WAAW,CAAC;CACrB;;;;;;;;","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;EACA,IAAI,aAAa,GAAG,iCAAiC;;EAErD,IAAI,aAAa,GAAG,KAAK;EACzB,IAAI,gBAAgB,GAAG,MAAM;;CAE7B;EACA,IAAI,cAAc,GAAG,wCAAwC;EAC7D,IAAI,WAAW,GAAG,OAAO;EACzB,IAAI,WAAW,GAAG,sDAAsD;EACxE,IAAI,eAAe,GAAG,SAAS;;CAE/B;EACA,IAAI,UAAU,GAAG,YAAY;;CAE7B;EACA,IAAI,OAAO,GAAG,IAAI;EAClB,IAAI,aAAa,GAAG,GAAG;EACvB,IAAI,QAAQ,GAAG,GAAG;EAClB,IAAI,YAAY,GAAG,EAAE;;CAErB;EACA,IAAI,YAAY,GAAG,SAAS;EAC5B,IAAI,gBAAgB,GAAG,aAAa;;CAEpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA,CAAA,iBAAc,GAAG,UAAU,KAAK,EAAE,OAAO,EAAE;CAC3C,GAAE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;CACjC,KAAI,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC;CAC1D,GAAA;;CAEA,GAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE;;CAEvB,GAAE,OAAO,GAAG,OAAO,IAAI,EAAE;;CAEzB;CACA;CACA;IACE,IAAI,MAAM,GAAG,CAAC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,GAAG,KAAK,CAAC,KAAK,CAAC;CACjC,IAAA,MAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU;CAElD,IAAA,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,KAAI;CACnC,QAAA,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE;aACtC;SACF;CAEA,QAAA,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,WAAW;SAEvC,IAAI,WAAW,EAAE;CACf,YAAA,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC;SACxC;cAAO,IAAI,KAAK,EAAE;CAChB,YAAA,WAAW,GAAG,WAAW,IAAI,EAAE;CAC/B,YAAA,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK;SAC/B;CACF,IAAA,CAAC,CAAC;CAEF,IAAA,OAAO,WAAW;CACpB;;;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(n,
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).StyleToObject=t()}(this,(function(){"use strict";function n(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var t,e;var r=n(function(){if(e)return t;e=1;var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,o=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,u=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,f=/^[;\s]*/,a=/^\s+|\s+$/g,s="";function l(n){return n?n.replace(a,s):s}return t=function(t,e){if("string"!=typeof t)throw new TypeError("First argument must be a string");if(!t)return[];e=e||{};var a=1,p=1;function h(n){var t=n.match(r);t&&(a+=t.length);var e=n.lastIndexOf("\n");p=~e?n.length-e:p+n.length}function v(){var n={line:a,column:p};return function(t){return t.position=new d(n),g(),t}}function d(n){this.start=n,this.end={line:a,column:p},this.source=e.source}function m(n){var r=new Error(e.source+":"+a+":"+p+": "+n);if(r.reason=n,r.filename=e.source,r.line=a,r.column=p,r.source=t,!e.silent)throw r}function y(n){var e=n.exec(t);if(e){var r=e[0];return h(r),t=t.slice(r.length),e}}function g(){y(o)}function w(n){var t;for(n=n||[];t=b();)!1!==t&&n.push(t);return n}function b(){var n=v();if("/"==t.charAt(0)&&"*"==t.charAt(1)){for(var e=2;s!=t.charAt(e)&&("*"!=t.charAt(e)||"/"!=t.charAt(e+1));)++e;if(e+=2,s===t.charAt(e-1))return m("End of comment missing");var r=t.slice(2,e-2);return p+=2,h(r),t=t.slice(e),p+=2,n({type:"comment",comment:r})}}function A(){var t=v(),e=y(i);if(e){if(b(),!y(u))return m("property missing ':'");var r=y(c),o=t({type:"declaration",property:l(e[0].replace(n,s)),value:r?l(r[0].replace(n,s)):s});return y(f),o}}return d.prototype.content=t,g(),function(){var n,t=[];for(w(t);n=A();)!1!==n&&(t.push(n),w(t));return t}()}}());return function(n,t){let e=null;if(!n||"string"!=typeof n)return e;const o=r(n),i="function"==typeof t;return o.forEach((n=>{if("declaration"!==n.type)return;const{property:r,value:o}=n;i?t(r,o,n):o&&(e=e||{},e[r]=o)})),e}}));
|
|
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","../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":"
|
|
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","inlineStyleParser","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":"+XAEA,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,QAnOAI,EAAiB,SAAUC,EAAOC,GAChC,GAAqB,iBAAVD,EACT,MAAM,IAAIE,UAAU,mCAGtB,IAAKF,EAAO,MAAO,GAEnBC,EAAUA,GAAW,CAAA,EAKrB,IAAIE,EAAS,EACTC,EAAS,EAOb,SAASC,EAAeR,GACtB,IAAIS,EAAQT,EAAIU,MAAMnB,GAClBkB,IAAOH,GAAUG,EAAME,QAC3B,IAAIC,EAAIZ,EAAIa,YAvCF,MAwCVN,GAAUK,EAAIZ,EAAIW,OAASC,EAAIL,EAASP,EAAIW,MAChD,CAOE,SAASG,IACP,IAAIC,EAAQ,CAAEC,KAAMV,EAAQC,OAAQA,GACpC,OAAO,SAAUU,GAGf,OAFAA,EAAKH,SAAW,IAAII,EAASH,GAC7BI,IACOF,CACb,CACA,CAUE,SAASC,EAASH,GAChBK,KAAKL,MAAQA,EACbK,KAAKC,IAAM,CAAEL,KAAMV,EAAQC,OAAQA,GACnCa,KAAKE,OAASlB,EAAQkB,MAC1B,CAeE,SAASC,EAAMC,GACb,IAAIC,EAAM,IAAIC,MACZtB,EAAQkB,OAAS,IAAMhB,EAAS,IAAMC,EAAS,KAAOiB,GAQxD,GANAC,EAA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1C,QAAQX,EAAeQ,IAC9CiD,MAAOH,EACH7C,EAAK6C,EAAI,GAAG3C,QAAQX,EAAeQ,IACnCA,IAMN,OAFAY,EAAMd,GAECiD,CApBI,CAqBf,CAyBE,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,CACX,CAGSC,EACT,aC7Nc,SACZjD,EACAkD,GAEA,IAAIC,EAAkC,KAEtC,IAAKnD,GAA0B,iBAAVA,EACnB,OAAOmD,EAGT,MAAMF,EAAeG,EAAMpD,GACrBqD,EAAkC,mBAAbH,EAiB3B,OAfAD,EAAaK,SAASf,IACpB,GAAyB,gBAArBA,EAAYD,KACd,OAGF,MAAMK,SAAEA,EAAQC,MAAEA,GAAUL,EAExBc,EACFH,EAASP,EAAUC,EAAOL,GACjBK,IACTO,EAAcA,GAAe,CAAA,EAC7BA,EAAYR,GAAYC,EAC1B,IAGKO,CACT","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Declaration } from 'inline-style-parser';
|
|
2
2
|
export { Declaration };
|
|
3
|
-
interface StyleObject {
|
|
3
|
+
export interface StyleObject {
|
|
4
4
|
[name: string]: string;
|
|
5
5
|
}
|
|
6
6
|
type Iterator = (property: string, value: string, declaration: Declaration) => void;
|
|
@@ -19,3 +19,4 @@ type Iterator = (property: string, value: string, declaration: Declaration) => v
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
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":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,MAAM,WAAW,WAAW;IAC1B,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/esm/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import parse from 'inline-style-parser';
|
|
2
|
+
/**
|
|
3
|
+
* Parses inline style to object.
|
|
4
|
+
*
|
|
5
|
+
* @param style - Inline style.
|
|
6
|
+
* @param iterator - Iterator.
|
|
7
|
+
* @returns - Style object or null.
|
|
8
|
+
*
|
|
9
|
+
* @example Parsing inline style to object:
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* import parse from 'style-to-object';
|
|
13
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export default function StyleToObject(style, iterator) {
|
|
17
|
+
let styleObject = null;
|
|
18
|
+
if (!style || typeof style !== 'string') {
|
|
19
|
+
return styleObject;
|
|
20
|
+
}
|
|
21
|
+
const declarations = parse(style);
|
|
22
|
+
const hasIterator = typeof iterator === 'function';
|
|
23
|
+
declarations.forEach((declaration) => {
|
|
24
|
+
if (declaration.type !== 'declaration') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { property, value } = declaration;
|
|
28
|
+
if (hasIterator) {
|
|
29
|
+
iterator(property, value, declaration);
|
|
30
|
+
}
|
|
31
|
+
else if (value) {
|
|
32
|
+
styleObject = styleObject || {};
|
|
33
|
+
styleObject[property] = value;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return styleObject;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAcxC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,KAAa,EACb,QAAmB;IAEnB,IAAI,WAAW,GAAuB,IAAI,CAAC;IAE3C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU,CAAC;IAEnD,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACnC,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC;QAExC,IAAI,WAAW,EAAE,CAAC;YAChB,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QACzC,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;YAChC,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;QAChC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/esm/index.mjs
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import parse from 'inline-style-parser';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Parses inline style to object.
|
|
5
|
+
*
|
|
6
|
+
* @param style - Inline style.
|
|
7
|
+
* @param iterator - Iterator.
|
|
8
|
+
* @returns - Style object or null.
|
|
9
|
+
*
|
|
10
|
+
* @example Parsing inline style to object:
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* import parse from 'style-to-object';
|
|
14
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function StyleToObject(style, iterator) {
|
|
18
|
+
let styleObject = null;
|
|
19
|
+
if (!style || typeof style !== 'string') {
|
|
20
|
+
return styleObject;
|
|
21
|
+
}
|
|
22
|
+
const declarations = parse(style);
|
|
23
|
+
const hasIterator = typeof iterator === 'function';
|
|
24
|
+
declarations.forEach((declaration) => {
|
|
25
|
+
if (declaration.type !== 'declaration') {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const { property, value } = declaration;
|
|
29
|
+
if (hasIterator) {
|
|
30
|
+
iterator(property, value, declaration);
|
|
31
|
+
}
|
|
32
|
+
else if (value) {
|
|
33
|
+
styleObject = styleObject || {};
|
|
34
|
+
styleObject[property] = value;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return styleObject;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { StyleToObject as default };
|
|
41
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAeA;;;;;;;;;;;;;AAaG;AACW,SAAU,aAAa,CACnC,KAAa,EACb,QAAmB,EAAA;IAEnB,IAAI,WAAW,GAAuB,IAAI;IAE1C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACvC,QAAA,OAAO,WAAW;IACpB;AAEA,IAAA,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;AACjC,IAAA,MAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,UAAU;AAElD,IAAA,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,KAAI;AACnC,QAAA,IAAI,WAAW,CAAC,IAAI,KAAK,aAAa,EAAE;YACtC;QACF;AAEA,QAAA,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,WAAW;QAEvC,IAAI,WAAW,EAAE;AACf,YAAA,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC;QACxC;aAAO,IAAI,KAAK,EAAE;AAChB,YAAA,WAAW,GAAG,WAAW,IAAI,EAAE;AAC/B,YAAA,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK;QAC/B;AACF,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,WAAW;AACpB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "style-to-object",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Parse CSS inline style to JavaScript object.",
|
|
5
5
|
"author": "Mark <mark@remarkablemark.org>",
|
|
6
6
|
"main": "./cjs/index.js",
|
|
7
7
|
"module": "./esm/index.mjs",
|
|
8
|
+
"types": "./esm/index.d.mts",
|
|
8
9
|
"exports": {
|
|
9
|
-
"import":
|
|
10
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./esm/index.d.mts",
|
|
12
|
+
"default": "./esm/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./cjs/index.d.ts",
|
|
16
|
+
"default": "./cjs/index.js"
|
|
17
|
+
}
|
|
11
18
|
},
|
|
12
19
|
"scripts": {
|
|
13
20
|
"build": "run-s build:*",
|
|
14
|
-
"build:cjs": "tsc",
|
|
15
|
-
"build:esm": "
|
|
21
|
+
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
22
|
+
"build:esm": "tsc --project tsconfig.json",
|
|
16
23
|
"build:umd": "rollup --config --failAfterWarnings",
|
|
17
|
-
"clean": "rm -rf cjs coverage dist",
|
|
24
|
+
"clean": "rm -rf cjs coverage dist esm",
|
|
18
25
|
"lint": "eslint .",
|
|
19
26
|
"lint:fix": "npm run lint -- --fix",
|
|
20
27
|
"lint:tsc": "tsc --noEmit",
|
|
@@ -22,12 +29,12 @@
|
|
|
22
29
|
"prepublishOnly": "run-s lint lint:tsc test clean build",
|
|
23
30
|
"test": "jest",
|
|
24
31
|
"test:ci": "CI=true jest --ci --colors --coverage",
|
|
25
|
-
"test:esm": "npm run build
|
|
32
|
+
"test:esm": "npm run build && node --test **/*.test.mjs",
|
|
26
33
|
"test:watch": "npm run test -- --watch"
|
|
27
34
|
},
|
|
28
35
|
"repository": {
|
|
29
36
|
"type": "git",
|
|
30
|
-
"url": "https://github.com/remarkablemark/style-to-object"
|
|
37
|
+
"url": "git+https://github.com/remarkablemark/style-to-object.git"
|
|
31
38
|
},
|
|
32
39
|
"bugs": {
|
|
33
40
|
"url": "https://github.com/remarkablemark/style-to-object/issues"
|
|
@@ -45,31 +52,33 @@
|
|
|
45
52
|
"inline-style-parser": "0.2.4"
|
|
46
53
|
},
|
|
47
54
|
"devDependencies": {
|
|
48
|
-
"@commitlint/cli": "
|
|
49
|
-
"@commitlint/config-conventional": "
|
|
50
|
-
"@eslint/compat": "1.
|
|
51
|
-
"@eslint/eslintrc": "3.1
|
|
52
|
-
"@eslint/js": "9.
|
|
53
|
-
"@rollup/plugin-commonjs": "
|
|
54
|
-
"@rollup/plugin-node-resolve": "
|
|
55
|
+
"@commitlint/cli": "20.1.0",
|
|
56
|
+
"@commitlint/config-conventional": "20.0.0",
|
|
57
|
+
"@eslint/compat": "1.4.0",
|
|
58
|
+
"@eslint/eslintrc": "3.3.1",
|
|
59
|
+
"@eslint/js": "9.36.0",
|
|
60
|
+
"@rollup/plugin-commonjs": "28.0.6",
|
|
61
|
+
"@rollup/plugin-node-resolve": "16.0.1",
|
|
55
62
|
"@rollup/plugin-terser": "0.4.4",
|
|
56
|
-
"@rollup/plugin-typescript": "
|
|
57
|
-
"@types/jest": "
|
|
58
|
-
"@types/node": "
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
60
|
-
"@typescript-eslint/parser": "8.
|
|
61
|
-
"eslint": "9.
|
|
62
|
-
"eslint-plugin-prettier": "5.
|
|
63
|
+
"@rollup/plugin-typescript": "12.1.4",
|
|
64
|
+
"@types/jest": "30.0.0",
|
|
65
|
+
"@types/node": "24.6.2",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "8.45.0",
|
|
67
|
+
"@typescript-eslint/parser": "8.45.0",
|
|
68
|
+
"eslint": "9.36.0",
|
|
69
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
63
70
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
64
|
-
"globals": "
|
|
65
|
-
"husky": "9.1.
|
|
66
|
-
"jest": "
|
|
67
|
-
"lint-staged": "
|
|
71
|
+
"globals": "16.4.0",
|
|
72
|
+
"husky": "9.1.7",
|
|
73
|
+
"jest": "30.2.0",
|
|
74
|
+
"lint-staged": "16.2.3",
|
|
68
75
|
"npm-run-all": "4.1.5",
|
|
69
|
-
"prettier": "3.
|
|
70
|
-
"rollup": "4.
|
|
71
|
-
"ts-jest": "29.
|
|
72
|
-
"
|
|
76
|
+
"prettier": "3.6.2",
|
|
77
|
+
"rollup": "4.52.3",
|
|
78
|
+
"ts-jest": "29.4.4",
|
|
79
|
+
"ts-node": "10.9.2",
|
|
80
|
+
"tslib": "2.8.1",
|
|
81
|
+
"typescript": "5.9.3"
|
|
73
82
|
},
|
|
74
83
|
"files": [
|
|
75
84
|
"/cjs",
|