dom-render 1.0.95 → 1.0.97

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/DomRender.d.ts +1 -1
  2. package/DomRender.js +3 -3
  3. package/DomRenderProxy.js +24 -30
  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 +1138 -385
  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/{DrDictionary.d.ts → DrThisProperty.d.ts} +1 -2
  38. package/operators/{DrDictionary.js → DrThisProperty.js} +19 -42
  39. package/operators/OperatorExecuter.d.ts +5 -5
  40. package/operators/OperatorExecuter.js +2 -2
  41. package/operators/OperatorExecuterAttrRequire.js +1 -1
  42. package/package.json +3 -3
  43. package/rawsets/AttrInitCallBack.d.ts +1 -1
  44. package/rawsets/Attrs.d.ts +4 -3
  45. package/rawsets/CreatorMetaData.d.ts +1 -1
  46. package/rawsets/ElementInitCallBack.d.ts +1 -1
  47. package/rawsets/RawSet.d.ts +19 -7
  48. package/rawsets/RawSet.js +144 -73
  49. package/rawsets/RawSetOperatorType.d.ts +3 -0
  50. package/rawsets/RawSetOperatorType.js +7 -0
  51. package/rawsets/Render.d.ts +1 -1
  52. package/routers/Router.d.ts +1 -1
  53. package/routers/Router.js +1 -1
  54. package/utils/dom/DomUtils.d.ts +1 -1
  55. package/utils/node/NodeUtils.d.ts +1 -1
  56. package/utils/script/ScriptUtils.js +2 -2
  57. package/utils/storage/StorageUtils.d.ts +7 -0
  58. package/utils/storage/StorageUtils.js +39 -0
  59. package/utils/string/StringUtils.d.ts +1 -0
  60. package/utils/string/StringUtils.js +17 -0
  61. package/validators/EmptyValidator.js +2 -2
  62. package/validators/NotEmptyValidator.js +2 -2
  63. package/validators/ValidMultipleValidator.d.ts +1 -1
  64. package/validators/Validator.d.ts +2 -2
  65. package/validators/ValidatorArray.d.ts +1 -1
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /**
3
+ * Module dependencies.
4
+ */
5
+ var Base = require('./compiler');
6
+ var inherits = require('inherits');
7
+ /**
8
+ * Expose compiler.
9
+ */
10
+ module.exports = Compiler;
11
+ /**
12
+ * Initialize a new `Compiler`.
13
+ */
14
+ function Compiler(options) {
15
+ Base.call(this, options);
16
+ }
17
+ /**
18
+ * Inherit from `Base.prototype`.
19
+ */
20
+ inherits(Compiler, Base);
21
+ /**
22
+ * Compile `node`.
23
+ */
24
+ Compiler.prototype.compile = function (node) {
25
+ return node.stylesheet
26
+ .rules.map(this.visit, this)
27
+ .join('');
28
+ };
29
+ /**
30
+ * Visit comment node.
31
+ */
32
+ Compiler.prototype.comment = function (node) {
33
+ return this.emit('', node.position);
34
+ };
35
+ /**
36
+ * Visit import node.
37
+ */
38
+ Compiler.prototype.import = function (node) {
39
+ return this.emit('@import ' + node.import + ';', node.position);
40
+ };
41
+ /**
42
+ * Visit media node.
43
+ */
44
+ Compiler.prototype.media = function (node) {
45
+ return this.emit('@media ' + node.media, node.position)
46
+ + this.emit('{')
47
+ + this.mapVisit(node.rules)
48
+ + this.emit('}');
49
+ };
50
+ /**
51
+ * Visit document node.
52
+ */
53
+ Compiler.prototype.document = function (node) {
54
+ var doc = '@' + (node.vendor || '') + 'document ' + node.document;
55
+ return this.emit(doc, node.position)
56
+ + this.emit('{')
57
+ + this.mapVisit(node.rules)
58
+ + this.emit('}');
59
+ };
60
+ /**
61
+ * Visit charset node.
62
+ */
63
+ Compiler.prototype.charset = function (node) {
64
+ return this.emit('@charset ' + node.charset + ';', node.position);
65
+ };
66
+ /**
67
+ * Visit namespace node.
68
+ */
69
+ Compiler.prototype.namespace = function (node) {
70
+ return this.emit('@namespace ' + node.namespace + ';', node.position);
71
+ };
72
+ /**
73
+ * Visit supports node.
74
+ */
75
+ Compiler.prototype.supports = function (node) {
76
+ return this.emit('@supports ' + node.supports, node.position)
77
+ + this.emit('{')
78
+ + this.mapVisit(node.rules)
79
+ + this.emit('}');
80
+ };
81
+ /**
82
+ * Visit keyframes node.
83
+ */
84
+ Compiler.prototype.keyframes = function (node) {
85
+ return this.emit('@'
86
+ + (node.vendor || '')
87
+ + 'keyframes '
88
+ + node.name, node.position)
89
+ + this.emit('{')
90
+ + this.mapVisit(node.keyframes)
91
+ + this.emit('}');
92
+ };
93
+ /**
94
+ * Visit keyframe node.
95
+ */
96
+ Compiler.prototype.keyframe = function (node) {
97
+ var decls = node.declarations;
98
+ return this.emit(node.values.join(','), node.position)
99
+ + this.emit('{')
100
+ + this.mapVisit(decls)
101
+ + this.emit('}');
102
+ };
103
+ /**
104
+ * Visit page node.
105
+ */
106
+ Compiler.prototype.page = function (node) {
107
+ var sel = node.selectors.length
108
+ ? node.selectors.join(', ')
109
+ : '';
110
+ return this.emit('@page ' + sel, node.position)
111
+ + this.emit('{')
112
+ + this.mapVisit(node.declarations)
113
+ + this.emit('}');
114
+ };
115
+ /**
116
+ * Visit font-face node.
117
+ */
118
+ Compiler.prototype['font-face'] = function (node) {
119
+ return this.emit('@font-face', node.position)
120
+ + this.emit('{')
121
+ + this.mapVisit(node.declarations)
122
+ + this.emit('}');
123
+ };
124
+ /**
125
+ * Visit host node.
126
+ */
127
+ Compiler.prototype.host = function (node) {
128
+ return this.emit('@host', node.position)
129
+ + this.emit('{')
130
+ + this.mapVisit(node.rules)
131
+ + this.emit('}');
132
+ };
133
+ /**
134
+ * Visit custom-media node.
135
+ */
136
+ Compiler.prototype['custom-media'] = function (node) {
137
+ return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
138
+ };
139
+ /**
140
+ * Visit rule node.
141
+ */
142
+ Compiler.prototype.rule = function (node) {
143
+ var decls = node.declarations;
144
+ if (!decls.length)
145
+ return '';
146
+ return this.emit(node.selectors.join(','), node.position)
147
+ + this.emit('{')
148
+ + this.mapVisit(decls)
149
+ + this.emit('}');
150
+ };
151
+ /**
152
+ * Visit declaration node.
153
+ */
154
+ Compiler.prototype.declaration = function (node) {
155
+ return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
156
+ };
@@ -0,0 +1,85 @@
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
+ indentation: any;
12
+ /**
13
+ * Compile `node`.
14
+ */
15
+ compile(node: any): any;
16
+ /**
17
+ * Visit stylesheet node.
18
+ */
19
+ stylesheet(node: any): any;
20
+ /**
21
+ * Visit comment node.
22
+ */
23
+ comment(node: any): any;
24
+ /**
25
+ * Visit import node.
26
+ */
27
+ import(node: any): any;
28
+ /**
29
+ * Visit media node.
30
+ */
31
+ media(node: any): any;
32
+ /**
33
+ * Visit document node.
34
+ */
35
+ document(node: any): any;
36
+ /**
37
+ * Visit charset node.
38
+ */
39
+ charset(node: any): any;
40
+ /**
41
+ * Visit namespace node.
42
+ */
43
+ namespace(node: any): any;
44
+ /**
45
+ * Visit supports node.
46
+ */
47
+ supports(node: any): any;
48
+ /**
49
+ * Visit keyframes node.
50
+ */
51
+ keyframes(node: any): any;
52
+ /**
53
+ * Visit keyframe node.
54
+ */
55
+ keyframe(node: any): any;
56
+ /**
57
+ * Visit page node.
58
+ */
59
+ page(node: any): any;
60
+ /**
61
+ * Visit font-face node.
62
+ */
63
+ 'font-face'(node: any): any;
64
+ /**
65
+ * Visit host node.
66
+ */
67
+ host(node: any): any;
68
+ /**
69
+ * Visit custom-media node.
70
+ */
71
+ 'custom-media'(node: any): any;
72
+ /**
73
+ * Visit rule node.
74
+ */
75
+ rule(node: any): any;
76
+ /**
77
+ * Visit declaration node.
78
+ */
79
+ declaration(node: any): any;
80
+ /**
81
+ * Increase, decrease or return current indentation.
82
+ */
83
+ indent(level: any): string;
84
+ level: any;
85
+ }
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ /**
3
+ * Module dependencies.
4
+ */
5
+ var Base = require('./compiler');
6
+ var inherits = require('inherits');
7
+ /**
8
+ * Expose compiler.
9
+ */
10
+ module.exports = Compiler;
11
+ /**
12
+ * Initialize a new `Compiler`.
13
+ */
14
+ function Compiler(options) {
15
+ options = options || {};
16
+ Base.call(this, options);
17
+ this.indentation = typeof options.indent === 'string' ? options.indent : ' ';
18
+ }
19
+ /**
20
+ * Inherit from `Base.prototype`.
21
+ */
22
+ inherits(Compiler, Base);
23
+ /**
24
+ * Compile `node`.
25
+ */
26
+ Compiler.prototype.compile = function (node) {
27
+ return this.stylesheet(node);
28
+ };
29
+ /**
30
+ * Visit stylesheet node.
31
+ */
32
+ Compiler.prototype.stylesheet = function (node) {
33
+ return this.mapVisit(node.stylesheet.rules, '\n\n');
34
+ };
35
+ /**
36
+ * Visit comment node.
37
+ */
38
+ Compiler.prototype.comment = function (node) {
39
+ return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
40
+ };
41
+ /**
42
+ * Visit import node.
43
+ */
44
+ Compiler.prototype.import = function (node) {
45
+ return this.emit('@import ' + node.import + ';', node.position);
46
+ };
47
+ /**
48
+ * Visit media node.
49
+ */
50
+ Compiler.prototype.media = function (node) {
51
+ return this.emit('@media ' + node.media, node.position)
52
+ + this.emit(' {\n'
53
+ + this.indent(1))
54
+ + this.mapVisit(node.rules, '\n\n')
55
+ + this.emit(this.indent(-1)
56
+ + '\n}');
57
+ };
58
+ /**
59
+ * Visit document node.
60
+ */
61
+ Compiler.prototype.document = function (node) {
62
+ var doc = '@' + (node.vendor || '') + 'document ' + node.document;
63
+ return this.emit(doc, node.position)
64
+ + this.emit(' '
65
+ + ' {\n'
66
+ + this.indent(1))
67
+ + this.mapVisit(node.rules, '\n\n')
68
+ + this.emit(this.indent(-1)
69
+ + '\n}');
70
+ };
71
+ /**
72
+ * Visit charset node.
73
+ */
74
+ Compiler.prototype.charset = function (node) {
75
+ return this.emit('@charset ' + node.charset + ';', node.position);
76
+ };
77
+ /**
78
+ * Visit namespace node.
79
+ */
80
+ Compiler.prototype.namespace = function (node) {
81
+ return this.emit('@namespace ' + node.namespace + ';', node.position);
82
+ };
83
+ /**
84
+ * Visit supports node.
85
+ */
86
+ Compiler.prototype.supports = function (node) {
87
+ return this.emit('@supports ' + node.supports, node.position)
88
+ + this.emit(' {\n'
89
+ + this.indent(1))
90
+ + this.mapVisit(node.rules, '\n\n')
91
+ + this.emit(this.indent(-1)
92
+ + '\n}');
93
+ };
94
+ /**
95
+ * Visit keyframes node.
96
+ */
97
+ Compiler.prototype.keyframes = function (node) {
98
+ return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position)
99
+ + this.emit(' {\n'
100
+ + this.indent(1))
101
+ + this.mapVisit(node.keyframes, '\n')
102
+ + this.emit(this.indent(-1)
103
+ + '}');
104
+ };
105
+ /**
106
+ * Visit keyframe node.
107
+ */
108
+ Compiler.prototype.keyframe = function (node) {
109
+ var decls = node.declarations;
110
+ return this.emit(this.indent())
111
+ + this.emit(node.values.join(', '), node.position)
112
+ + this.emit(' {\n'
113
+ + this.indent(1))
114
+ + this.mapVisit(decls, '\n')
115
+ + this.emit(this.indent(-1)
116
+ + '\n'
117
+ + this.indent() + '}\n');
118
+ };
119
+ /**
120
+ * Visit page node.
121
+ */
122
+ Compiler.prototype.page = function (node) {
123
+ var sel = node.selectors.length
124
+ ? node.selectors.join(', ') + ' '
125
+ : '';
126
+ return this.emit('@page ' + sel, node.position)
127
+ + this.emit('{\n')
128
+ + this.emit(this.indent(1))
129
+ + this.mapVisit(node.declarations, '\n')
130
+ + this.emit(this.indent(-1))
131
+ + this.emit('\n}');
132
+ };
133
+ /**
134
+ * Visit font-face node.
135
+ */
136
+ Compiler.prototype['font-face'] = function (node) {
137
+ return this.emit('@font-face ', node.position)
138
+ + this.emit('{\n')
139
+ + this.emit(this.indent(1))
140
+ + this.mapVisit(node.declarations, '\n')
141
+ + this.emit(this.indent(-1))
142
+ + this.emit('\n}');
143
+ };
144
+ /**
145
+ * Visit host node.
146
+ */
147
+ Compiler.prototype.host = function (node) {
148
+ return this.emit('@host', node.position)
149
+ + this.emit(' {\n'
150
+ + this.indent(1))
151
+ + this.mapVisit(node.rules, '\n\n')
152
+ + this.emit(this.indent(-1)
153
+ + '\n}');
154
+ };
155
+ /**
156
+ * Visit custom-media node.
157
+ */
158
+ Compiler.prototype['custom-media'] = function (node) {
159
+ return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
160
+ };
161
+ /**
162
+ * Visit rule node.
163
+ */
164
+ Compiler.prototype.rule = function (node) {
165
+ var indent = this.indent();
166
+ var decls = node.declarations;
167
+ if (!decls.length)
168
+ return '';
169
+ return this.emit(node.selectors.map(function (s) { return indent + s; }).join(',\n'), node.position)
170
+ + this.emit(' {\n')
171
+ + this.emit(this.indent(1))
172
+ + this.mapVisit(decls, '\n')
173
+ + this.emit(this.indent(-1))
174
+ + this.emit('\n' + this.indent() + '}');
175
+ };
176
+ /**
177
+ * Visit declaration node.
178
+ */
179
+ Compiler.prototype.declaration = function (node) {
180
+ return this.emit(this.indent())
181
+ + this.emit(node.property + ': ' + node.value, node.position)
182
+ + this.emit(';');
183
+ };
184
+ /**
185
+ * Increase, decrease or return current indentation.
186
+ */
187
+ Compiler.prototype.indent = function (level) {
188
+ this.level = this.level || 1;
189
+ if (null != level) {
190
+ this.level += level;
191
+ return '';
192
+ }
193
+ return Array(this.level).join(this.indentation);
194
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Stringfy the given AST `node`.
3
+ *
4
+ * Options:
5
+ *
6
+ * - `compress` space-optimized output
7
+ * - `sourcemap` return an object with `.code` and `.map`
8
+ *
9
+ * @param {Object} node
10
+ * @param {Object} [options]
11
+ * @return {String}
12
+ * @api public
13
+ */
14
+ export default function _default(node: Object, options?: Object | undefined): string;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Module dependencies.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var Compressed = require('./compress');
7
+ var Identity = require('./identity');
8
+ /**
9
+ * Stringfy the given AST `node`.
10
+ *
11
+ * Options:
12
+ *
13
+ * - `compress` space-optimized output
14
+ * - `sourcemap` return an object with `.code` and `.map`
15
+ *
16
+ * @param {Object} node
17
+ * @param {Object} [options]
18
+ * @return {String}
19
+ * @api public
20
+ */
21
+ function default_1(node, options) {
22
+ options = options || {};
23
+ var compiler = options.compress
24
+ ? new Compressed(options)
25
+ : new Identity(options);
26
+ // source maps
27
+ // if (options.sourcemap) {
28
+ // var sourcemaps = require('./source-map-support');
29
+ // sourcemaps(compiler);
30
+ //
31
+ // var code = compiler.compile(node);
32
+ // compiler.applySourceMaps();
33
+ //
34
+ // var map = options.sourcemap === 'generator'
35
+ // ? compiler.map
36
+ // : compiler.map.toJSON();
37
+ //
38
+ // return { code: code, map: map };
39
+ // }
40
+ var code = compiler.compile(node);
41
+ return code;
42
+ }
43
+ exports.default = default_1;
44
+ ;