@dooboostore/dom-render 1.0.99 → 1.0.100
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 +172 -0
- package/components/ComponentBase.d.ts +17 -0
- package/components/ComponentBase.js +116 -77
- package/package.json +2 -2
- package/rawsets/RawSet.js +31 -27
- package/css/parse/index.d.ts +0 -49
- package/css/parse/index.js +0 -498
- package/css/stringify/compiler.d.ts +0 -34
- package/css/stringify/compiler.js +0 -36
- package/css/stringify/compress.d.ts +0 -104
- package/css/stringify/compress.js +0 -147
- package/css/stringify/identity.d.ts +0 -109
- package/css/stringify/identity.js +0 -183
- package/css/stringify/index.d.ts +0 -24
- package/css/stringify/index.js +0 -27
- package/css/stringify/types.d.ts +0 -15
- package/css/stringify/types.js +0 -2
- package/css/types.d.ts +0 -10
- package/css/types.js +0 -2
package/css/parse/index.js
DELETED
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
// http://www.w3.org/TR/CSS21/grammar.html
|
|
2
|
-
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
3
|
-
const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
4
|
-
export default function parse(css, options = {}) {
|
|
5
|
-
/**
|
|
6
|
-
* Positional.
|
|
7
|
-
*/
|
|
8
|
-
let lineno = 1;
|
|
9
|
-
let column = 1;
|
|
10
|
-
/**
|
|
11
|
-
* Update lineno and column based on `str`.
|
|
12
|
-
*/
|
|
13
|
-
function updatePosition(str) {
|
|
14
|
-
const lines = str.match(/\n/g);
|
|
15
|
-
if (lines)
|
|
16
|
-
lineno += lines.length;
|
|
17
|
-
const i = str.lastIndexOf('\n');
|
|
18
|
-
column = ~i ? str.length - i : column + str.length;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Mark position and patch `node.position`.
|
|
22
|
-
*/
|
|
23
|
-
function position() {
|
|
24
|
-
const start = { line: lineno, column: column };
|
|
25
|
-
return function (node) {
|
|
26
|
-
node.position = new Position(start);
|
|
27
|
-
whitespace();
|
|
28
|
-
return node;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Store position information for a node
|
|
33
|
-
*/
|
|
34
|
-
class Position {
|
|
35
|
-
constructor(start) {
|
|
36
|
-
this.start = start;
|
|
37
|
-
this.end = { line: lineno, column: column };
|
|
38
|
-
this.source = options.source;
|
|
39
|
-
this.content = css;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Error `msg`.
|
|
44
|
-
*/
|
|
45
|
-
const errorsList = [];
|
|
46
|
-
function error(msg) {
|
|
47
|
-
const err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
48
|
-
err['reason'] = msg;
|
|
49
|
-
err['filename'] = options.source;
|
|
50
|
-
err['line'] = lineno;
|
|
51
|
-
err['column'] = column;
|
|
52
|
-
err['source'] = css;
|
|
53
|
-
if (options.silent) {
|
|
54
|
-
errorsList.push(err);
|
|
55
|
-
throw err;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw err;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Parse stylesheet.
|
|
63
|
-
*/
|
|
64
|
-
function stylesheet() {
|
|
65
|
-
const rulesList = rules();
|
|
66
|
-
return {
|
|
67
|
-
type: 'stylesheet',
|
|
68
|
-
stylesheet: {
|
|
69
|
-
source: options.source,
|
|
70
|
-
rules: rulesList,
|
|
71
|
-
parsingErrors: errorsList
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Opening brace.
|
|
77
|
-
*/
|
|
78
|
-
function open() {
|
|
79
|
-
return match(/^{\s*/);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Closing brace.
|
|
83
|
-
*/
|
|
84
|
-
function close() {
|
|
85
|
-
return match(/^}/);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Parse ruleset.
|
|
89
|
-
*/
|
|
90
|
-
function rules() {
|
|
91
|
-
let node;
|
|
92
|
-
const rules = [];
|
|
93
|
-
whitespace();
|
|
94
|
-
comments(rules);
|
|
95
|
-
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) {
|
|
96
|
-
if (node) {
|
|
97
|
-
rules.push(node);
|
|
98
|
-
comments(rules);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return rules;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Match `re` and return captures.
|
|
105
|
-
*/
|
|
106
|
-
function match(re) {
|
|
107
|
-
const m = re.exec(css);
|
|
108
|
-
if (!m)
|
|
109
|
-
return null;
|
|
110
|
-
const str = m[0];
|
|
111
|
-
updatePosition(str);
|
|
112
|
-
css = css.slice(str.length);
|
|
113
|
-
return m;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Parse whitespace.
|
|
117
|
-
*/
|
|
118
|
-
function whitespace() {
|
|
119
|
-
match(/^\s*/);
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Parse comments;
|
|
123
|
-
*/
|
|
124
|
-
function comments(rules = []) {
|
|
125
|
-
let c;
|
|
126
|
-
while ((c = comment())) {
|
|
127
|
-
rules.push(c);
|
|
128
|
-
}
|
|
129
|
-
return rules;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Parse comment.
|
|
133
|
-
*/
|
|
134
|
-
function comment() {
|
|
135
|
-
const pos = position();
|
|
136
|
-
if ('/' != css.charAt(0) || '*' != css.charAt(1))
|
|
137
|
-
return null;
|
|
138
|
-
let i = 2;
|
|
139
|
-
while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1)))
|
|
140
|
-
++i;
|
|
141
|
-
i += 2;
|
|
142
|
-
if ("" === css.charAt(i - 1)) {
|
|
143
|
-
error('End of comment missing');
|
|
144
|
-
}
|
|
145
|
-
const str = css.slice(2, i - 2);
|
|
146
|
-
column += 2;
|
|
147
|
-
updatePosition(str);
|
|
148
|
-
css = css.slice(i);
|
|
149
|
-
column += 2;
|
|
150
|
-
return pos({ type: 'comment', comment: str });
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Parse selector.
|
|
154
|
-
*/
|
|
155
|
-
function selector() {
|
|
156
|
-
const m = match(/^([^{]+)/);
|
|
157
|
-
if (!m)
|
|
158
|
-
return undefined;
|
|
159
|
-
/* @fix Remove all comments from selectors
|
|
160
|
-
* http://ostermiller.org/findcomment.html */
|
|
161
|
-
return trim(m[0])
|
|
162
|
-
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
163
|
-
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
164
|
-
return m.replace(/,/g, '\u200C');
|
|
165
|
-
})
|
|
166
|
-
.split(/\s*(?![^(]*\]),\s*/)
|
|
167
|
-
.map(function (s) {
|
|
168
|
-
return s.replace(/\u200C/g, ',');
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Parse declaration.
|
|
173
|
-
*/
|
|
174
|
-
function declaration() {
|
|
175
|
-
const pos = position();
|
|
176
|
-
// prop
|
|
177
|
-
const prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
178
|
-
if (!prop)
|
|
179
|
-
return null;
|
|
180
|
-
const propValue = trim(prop[0]);
|
|
181
|
-
// :
|
|
182
|
-
if (!match(/^:\s*/))
|
|
183
|
-
error("property missing ':'");
|
|
184
|
-
// val
|
|
185
|
-
const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
186
|
-
const ret = pos({
|
|
187
|
-
type: 'declaration',
|
|
188
|
-
property: propValue.replace(commentre, ''),
|
|
189
|
-
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
190
|
-
});
|
|
191
|
-
// ;
|
|
192
|
-
match(/^[;\s]*/);
|
|
193
|
-
return ret;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Parse declarations.
|
|
197
|
-
*/
|
|
198
|
-
function declarations() {
|
|
199
|
-
const decls = [];
|
|
200
|
-
if (!open())
|
|
201
|
-
error("missing '{'");
|
|
202
|
-
comments(decls);
|
|
203
|
-
// declarations
|
|
204
|
-
let decl;
|
|
205
|
-
while ((decl = declaration())) {
|
|
206
|
-
decls.push(decl);
|
|
207
|
-
comments(decls);
|
|
208
|
-
}
|
|
209
|
-
if (!close())
|
|
210
|
-
error("missing '}'");
|
|
211
|
-
return decls;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Parse keyframe.
|
|
215
|
-
*/
|
|
216
|
-
function keyframe() {
|
|
217
|
-
const m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);
|
|
218
|
-
if (!m)
|
|
219
|
-
return null;
|
|
220
|
-
const vals = [];
|
|
221
|
-
const pos = position();
|
|
222
|
-
vals.push(m[1]);
|
|
223
|
-
match(/^,\s*/);
|
|
224
|
-
return pos({
|
|
225
|
-
type: 'keyframe',
|
|
226
|
-
values: vals,
|
|
227
|
-
declarations: declarations()
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Parse keyframes.
|
|
232
|
-
*/
|
|
233
|
-
function atkeyframes() {
|
|
234
|
-
const pos = position();
|
|
235
|
-
const m1 = match(/^@([-\w]+)?keyframes\s*/);
|
|
236
|
-
if (!m1)
|
|
237
|
-
return null;
|
|
238
|
-
const vendor = m1[1];
|
|
239
|
-
// identifier
|
|
240
|
-
const m2 = match(/^([-\w]+)\s*/);
|
|
241
|
-
if (!m2)
|
|
242
|
-
error("@keyframes missing name");
|
|
243
|
-
const name = m2[1];
|
|
244
|
-
if (!open())
|
|
245
|
-
error("@keyframes missing '{'");
|
|
246
|
-
let frame;
|
|
247
|
-
let frames = comments();
|
|
248
|
-
while ((frame = keyframe())) {
|
|
249
|
-
frames.push(frame);
|
|
250
|
-
frames = frames.concat(comments());
|
|
251
|
-
}
|
|
252
|
-
if (!close())
|
|
253
|
-
error("@keyframes missing '}'");
|
|
254
|
-
return pos({
|
|
255
|
-
type: 'keyframes',
|
|
256
|
-
name: name,
|
|
257
|
-
vendor: vendor,
|
|
258
|
-
keyframes: frames
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Parse supports.
|
|
263
|
-
*/
|
|
264
|
-
function atsupports() {
|
|
265
|
-
const pos = position();
|
|
266
|
-
const m = match(/^@supports *([^{]+)/);
|
|
267
|
-
if (!m)
|
|
268
|
-
return null;
|
|
269
|
-
const supports = trim(m[1]);
|
|
270
|
-
if (!open())
|
|
271
|
-
error("@supports missing '{'");
|
|
272
|
-
const style = comments().concat(rules());
|
|
273
|
-
if (!close())
|
|
274
|
-
error("@supports missing '}'");
|
|
275
|
-
return pos({
|
|
276
|
-
type: 'supports',
|
|
277
|
-
supports: supports,
|
|
278
|
-
rules: style
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Parse host.
|
|
283
|
-
*/
|
|
284
|
-
function athost() {
|
|
285
|
-
const pos = position();
|
|
286
|
-
const m = match(/^@host\s*/);
|
|
287
|
-
if (!m)
|
|
288
|
-
return null;
|
|
289
|
-
if (!open())
|
|
290
|
-
error("@host missing '{'");
|
|
291
|
-
const style = comments().concat(rules());
|
|
292
|
-
if (!close())
|
|
293
|
-
error("@host missing '}'");
|
|
294
|
-
return pos({
|
|
295
|
-
type: 'host',
|
|
296
|
-
rules: style
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Parse media.
|
|
301
|
-
*/
|
|
302
|
-
function atmedia() {
|
|
303
|
-
const pos = position();
|
|
304
|
-
const m = match(/^@media *([^{]+)/);
|
|
305
|
-
if (!m)
|
|
306
|
-
return null;
|
|
307
|
-
const media = trim(m[1]);
|
|
308
|
-
if (!open())
|
|
309
|
-
error("@media missing '{'");
|
|
310
|
-
const style = comments().concat(rules());
|
|
311
|
-
if (!close())
|
|
312
|
-
error("@media missing '}'");
|
|
313
|
-
return pos({
|
|
314
|
-
type: 'media',
|
|
315
|
-
media: media,
|
|
316
|
-
rules: style
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Parse custom-media.
|
|
321
|
-
*/
|
|
322
|
-
function atcustommedia() {
|
|
323
|
-
const pos = position();
|
|
324
|
-
const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
325
|
-
if (!m)
|
|
326
|
-
return null;
|
|
327
|
-
return pos({
|
|
328
|
-
type: 'custom-media',
|
|
329
|
-
name: trim(m[1]),
|
|
330
|
-
media: trim(m[2])
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Parse paged media.
|
|
335
|
-
*/
|
|
336
|
-
function atpage() {
|
|
337
|
-
const pos = position();
|
|
338
|
-
const m = match(/^@page */);
|
|
339
|
-
if (!m)
|
|
340
|
-
return null;
|
|
341
|
-
const sel = selector() || [];
|
|
342
|
-
if (!open())
|
|
343
|
-
error("@page missing '{'");
|
|
344
|
-
let decls = comments();
|
|
345
|
-
// declarations
|
|
346
|
-
let decl;
|
|
347
|
-
while ((decl = declaration())) {
|
|
348
|
-
decls.push(decl);
|
|
349
|
-
decls = decls.concat(comments());
|
|
350
|
-
}
|
|
351
|
-
if (!close())
|
|
352
|
-
error("@page missing '}'");
|
|
353
|
-
return pos({
|
|
354
|
-
type: 'page',
|
|
355
|
-
selectors: sel,
|
|
356
|
-
declarations: decls
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Parse document.
|
|
361
|
-
*/
|
|
362
|
-
function atdocument() {
|
|
363
|
-
const pos = position();
|
|
364
|
-
const m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
365
|
-
if (!m)
|
|
366
|
-
return null;
|
|
367
|
-
const vendor = trim(m[1]);
|
|
368
|
-
const doc = trim(m[2]);
|
|
369
|
-
if (!open())
|
|
370
|
-
error("@document missing '{'");
|
|
371
|
-
const style = comments().concat(rules());
|
|
372
|
-
if (!close())
|
|
373
|
-
error("@document missing '}'");
|
|
374
|
-
return pos({
|
|
375
|
-
type: 'document',
|
|
376
|
-
document: doc,
|
|
377
|
-
vendor: vendor,
|
|
378
|
-
rules: style
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Parse font-face.
|
|
383
|
-
*/
|
|
384
|
-
function atfontface() {
|
|
385
|
-
const pos = position();
|
|
386
|
-
const m = match(/^@font-face\s*/);
|
|
387
|
-
if (!m)
|
|
388
|
-
return null;
|
|
389
|
-
if (!open())
|
|
390
|
-
error("@font-face missing '{'");
|
|
391
|
-
let decls = comments();
|
|
392
|
-
// declarations
|
|
393
|
-
let decl;
|
|
394
|
-
while ((decl = declaration())) {
|
|
395
|
-
decls.push(decl);
|
|
396
|
-
decls = decls.concat(comments());
|
|
397
|
-
}
|
|
398
|
-
if (!close())
|
|
399
|
-
error("@font-face missing '}'");
|
|
400
|
-
return pos({
|
|
401
|
-
type: 'font-face',
|
|
402
|
-
declarations: decls
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Parse import
|
|
407
|
-
*/
|
|
408
|
-
const atimport = _compileAtrule('import');
|
|
409
|
-
/**
|
|
410
|
-
* Parse charset
|
|
411
|
-
*/
|
|
412
|
-
const atcharset = _compileAtrule('charset');
|
|
413
|
-
/**
|
|
414
|
-
* Parse namespace
|
|
415
|
-
*/
|
|
416
|
-
const atnamespace = _compileAtrule('namespace');
|
|
417
|
-
/**
|
|
418
|
-
* Parse non-block at-rules
|
|
419
|
-
*/
|
|
420
|
-
function _compileAtrule(name) {
|
|
421
|
-
const re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
422
|
-
return function () {
|
|
423
|
-
const pos = position();
|
|
424
|
-
const m = match(re);
|
|
425
|
-
if (!m)
|
|
426
|
-
return null;
|
|
427
|
-
const ret = { type: name };
|
|
428
|
-
ret[name] = m[1].trim();
|
|
429
|
-
return pos(ret);
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Parse at rule.
|
|
434
|
-
*/
|
|
435
|
-
function atrule() {
|
|
436
|
-
if (css[0] != '@')
|
|
437
|
-
return null;
|
|
438
|
-
return atkeyframes()
|
|
439
|
-
|| atmedia()
|
|
440
|
-
|| atcustommedia()
|
|
441
|
-
|| atsupports()
|
|
442
|
-
|| atimport()
|
|
443
|
-
|| atcharset()
|
|
444
|
-
|| atnamespace()
|
|
445
|
-
|| atdocument()
|
|
446
|
-
|| atpage()
|
|
447
|
-
|| athost()
|
|
448
|
-
|| atfontface();
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Parse rule.
|
|
452
|
-
*/
|
|
453
|
-
function rule() {
|
|
454
|
-
const pos = position();
|
|
455
|
-
const sel = selector();
|
|
456
|
-
if (!sel)
|
|
457
|
-
error('selector missing');
|
|
458
|
-
comments();
|
|
459
|
-
return pos({
|
|
460
|
-
type: 'rule',
|
|
461
|
-
selectors: sel,
|
|
462
|
-
declarations: declarations()
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
return addParent(stylesheet());
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Trim `str`.
|
|
469
|
-
*/
|
|
470
|
-
function trim(str) {
|
|
471
|
-
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Adds non-enumerable parent node reference to each node.
|
|
475
|
-
*/
|
|
476
|
-
function addParent(obj, parent) {
|
|
477
|
-
const isNode = obj && typeof obj.type === 'string';
|
|
478
|
-
const childParent = isNode ? obj : parent;
|
|
479
|
-
for (const k in obj) {
|
|
480
|
-
const value = obj[k];
|
|
481
|
-
if (Array.isArray(value)) {
|
|
482
|
-
value.forEach(function (v) { addParent(v, childParent); });
|
|
483
|
-
}
|
|
484
|
-
else if (value && typeof value === 'object') {
|
|
485
|
-
addParent(value, childParent);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
if (isNode) {
|
|
489
|
-
Object.defineProperty(obj, 'parent', {
|
|
490
|
-
configurable: true,
|
|
491
|
-
writable: true,
|
|
492
|
-
enumerable: false,
|
|
493
|
-
value: parent || null
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
return obj;
|
|
497
|
-
}
|
|
498
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface CompilerOptions {
|
|
2
|
-
compress?: boolean;
|
|
3
|
-
sourcemap?: boolean | 'generator';
|
|
4
|
-
indent?: string;
|
|
5
|
-
}
|
|
6
|
-
interface Node {
|
|
7
|
-
type: string;
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Base compiler class
|
|
12
|
-
*/
|
|
13
|
-
export declare class Compiler {
|
|
14
|
-
protected options: CompilerOptions;
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
/**
|
|
17
|
-
* Initialize a compiler.
|
|
18
|
-
*/
|
|
19
|
-
constructor(opts?: CompilerOptions);
|
|
20
|
-
/**
|
|
21
|
-
* Emit `str`
|
|
22
|
-
*/
|
|
23
|
-
emit(str: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Visit `node`.
|
|
26
|
-
*/
|
|
27
|
-
visit(node: Node): string;
|
|
28
|
-
/**
|
|
29
|
-
* Map visit over array of `nodes`, optionally using a `delim`
|
|
30
|
-
*/
|
|
31
|
-
mapVisit(nodes: Node[], delim?: string): string;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base compiler class
|
|
3
|
-
*/
|
|
4
|
-
export class Compiler {
|
|
5
|
-
/**
|
|
6
|
-
* Initialize a compiler.
|
|
7
|
-
*/
|
|
8
|
-
constructor(opts = {}) {
|
|
9
|
-
this.options = opts;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Emit `str`
|
|
13
|
-
*/
|
|
14
|
-
emit(str) {
|
|
15
|
-
return str;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Visit `node`.
|
|
19
|
-
*/
|
|
20
|
-
visit(node) {
|
|
21
|
-
return this[node.type](node);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Map visit over array of `nodes`, optionally using a `delim`
|
|
25
|
-
*/
|
|
26
|
-
mapVisit(nodes, delim = '') {
|
|
27
|
-
let buf = '';
|
|
28
|
-
for (let i = 0, length = nodes.length; i < length; i++) {
|
|
29
|
-
buf += this.visit(nodes[i]);
|
|
30
|
-
if (delim && i < length - 1)
|
|
31
|
-
buf += this.emit(delim);
|
|
32
|
-
}
|
|
33
|
-
return buf;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=compiler.js.map
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Compiler as BaseCompiler } from './compiler';
|
|
2
|
-
interface Node {
|
|
3
|
-
type: string;
|
|
4
|
-
position?: any;
|
|
5
|
-
stylesheet?: {
|
|
6
|
-
rules: Node[];
|
|
7
|
-
};
|
|
8
|
-
import?: string;
|
|
9
|
-
media?: string;
|
|
10
|
-
vendor?: string;
|
|
11
|
-
document?: string;
|
|
12
|
-
charset?: string;
|
|
13
|
-
namespace?: string;
|
|
14
|
-
supports?: string;
|
|
15
|
-
name?: string;
|
|
16
|
-
keyframes?: Node[];
|
|
17
|
-
values?: string[];
|
|
18
|
-
declarations?: Node[];
|
|
19
|
-
selectors?: string[];
|
|
20
|
-
rules?: Node[];
|
|
21
|
-
property?: string;
|
|
22
|
-
value?: string;
|
|
23
|
-
}
|
|
24
|
-
interface Declaration extends Node {
|
|
25
|
-
type: 'declaration';
|
|
26
|
-
property: string;
|
|
27
|
-
value: string;
|
|
28
|
-
position?: any;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Compressed CSS compiler
|
|
32
|
-
*/
|
|
33
|
-
export declare class CompressCompiler extends BaseCompiler {
|
|
34
|
-
/**
|
|
35
|
-
* Override emit to handle position
|
|
36
|
-
*/
|
|
37
|
-
emit(str: string, pos?: any): string;
|
|
38
|
-
/**
|
|
39
|
-
* Compile `node`.
|
|
40
|
-
*/
|
|
41
|
-
compile(node: Node): string;
|
|
42
|
-
/**
|
|
43
|
-
* Visit comment node.
|
|
44
|
-
*/
|
|
45
|
-
comment(node: Node): string;
|
|
46
|
-
/**
|
|
47
|
-
* Visit import node.
|
|
48
|
-
*/
|
|
49
|
-
import(node: Node): string;
|
|
50
|
-
/**
|
|
51
|
-
* Visit media node.
|
|
52
|
-
*/
|
|
53
|
-
media(node: Node): string;
|
|
54
|
-
/**
|
|
55
|
-
* Visit document node.
|
|
56
|
-
*/
|
|
57
|
-
document(node: Node): string;
|
|
58
|
-
/**
|
|
59
|
-
* Visit charset node.
|
|
60
|
-
*/
|
|
61
|
-
charset(node: Node): string;
|
|
62
|
-
/**
|
|
63
|
-
* Visit namespace node.
|
|
64
|
-
*/
|
|
65
|
-
namespace(node: Node): string;
|
|
66
|
-
/**
|
|
67
|
-
* Visit supports node.
|
|
68
|
-
*/
|
|
69
|
-
supports(node: Node): string;
|
|
70
|
-
/**
|
|
71
|
-
* Visit keyframes node.
|
|
72
|
-
*/
|
|
73
|
-
keyframes(node: Node): string;
|
|
74
|
-
/**
|
|
75
|
-
* Visit keyframe node.
|
|
76
|
-
*/
|
|
77
|
-
keyframe(node: Node): string;
|
|
78
|
-
/**
|
|
79
|
-
* Visit page node.
|
|
80
|
-
*/
|
|
81
|
-
page(node: Node): string;
|
|
82
|
-
/**
|
|
83
|
-
* Visit font-face node.
|
|
84
|
-
*/
|
|
85
|
-
'font-face'(node: Node): string;
|
|
86
|
-
/**
|
|
87
|
-
* Visit host node.
|
|
88
|
-
*/
|
|
89
|
-
host(node: Node): string;
|
|
90
|
-
/**
|
|
91
|
-
* Visit custom-media node.
|
|
92
|
-
*/
|
|
93
|
-
'custom-media'(node: Node): string;
|
|
94
|
-
/**
|
|
95
|
-
* Visit rule node.
|
|
96
|
-
*/
|
|
97
|
-
rule(node: Node): string;
|
|
98
|
-
/**
|
|
99
|
-
* Visit declaration node.
|
|
100
|
-
*/
|
|
101
|
-
declaration(node: Declaration): string;
|
|
102
|
-
}
|
|
103
|
-
export {};
|
|
104
|
-
//# sourceMappingURL=compress.d.ts.map
|