dom-render 1.0.96 → 1.0.97

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