@lightningjs/blits 0.8.0 → 0.9.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/boilerplate/js/default/src/index.js +2 -8
  3. package/docs/README.md +0 -21
  4. package/docs/_sidebar.md +25 -13
  5. package/docs/built-in/directives.md +44 -0
  6. package/docs/{component_state.md → components/component_state.md} +37 -5
  7. package/docs/components/computed_properties.md +48 -0
  8. package/docs/{lifecycle_events.md → components/lifecycle_events.md} +4 -2
  9. package/docs/components/methods.md +47 -0
  10. package/docs/components/props.md +58 -0
  11. package/docs/{user_input.md → components/user_input.md} +31 -26
  12. package/docs/components/utilities.md +4 -0
  13. package/docs/components/watchers.md +36 -0
  14. package/docs/essentials/application_root.md +21 -0
  15. package/docs/{components.md → essentials/components.md} +17 -5
  16. package/docs/{displaying_images.md → essentials/displaying_images.md} +7 -7
  17. package/docs/essentials/displaying_text.md +77 -0
  18. package/docs/{element_attributes.md → essentials/element_attributes.md} +17 -12
  19. package/docs/essentials/template_syntax.md +85 -0
  20. package/docs/getting_started/file_structure.md +61 -0
  21. package/docs/getting_started/getting_started.md +47 -0
  22. package/docs/{introduction.md → getting_started/intro.md} +2 -1
  23. package/docs/sidebar.json +70 -26
  24. package/docs/transitions_animations/transitions.md +132 -0
  25. package/package.json +2 -3
  26. package/src/component.js +12 -3
  27. package/src/element.js +3 -0
  28. package/src/fontLoader.js +20 -21
  29. package/src/launch.d.ts +5 -6
  30. package/src/launch.js +12 -2
  31. package/src/lib/codegenerator/generator.js +2 -2
  32. package/src/lib/colors/colors.js +50 -40
  33. package/src/lib/colors/colors.test.js +149 -49
  34. package/src/lib/colors/htmlColors.js +149 -149
  35. package/src/lib/hooks.js +7 -7
  36. package/src/lib/lifecycle.js +3 -2
  37. package/src/lib/setup/base.js +19 -11
  38. package/src/lib/setup/state.js +1 -1
  39. package/src/lib/symbols.js +2 -0
  40. package/src/lib/templateparser/parser.js +50 -12
  41. package/src/lib/templateparser/parser.test.js +378 -71
  42. package/src/router/router.js +6 -6
  43. package/vite/msdfGenerator.js +1 -1
  44. package/boilerplate/js/default/src/fontloader.js +0 -4
  45. package/docs/computed_properties.md +0 -18
  46. package/docs/getting_started.md +0 -40
  47. package/docs/props.md +0 -46
  48. package/docs/template_syntax.md +0 -65
  49. package/docs/watchers.md +0 -38
  50. /package/docs/{text-to-speech-announcer.md → plugins/text-to-speech-announcer.md} +0 -0
@@ -27,8 +27,30 @@ test('Object', (assert) => {
27
27
  })
28
28
 
29
29
  test('6 character hex', (assert) => {
30
- const input = ['#ffffff', '#000000', '#c0ffee', '#7dd3fc', '#0c4a6e']
31
- const expected = ['0xffffffff', '0x000000ff', '0xc0ffeeff', '0x7dd3fcff', '0x0c4a6eff']
30
+ const input = [
31
+ '#ffffff',
32
+ '#000000',
33
+ '#c0ffee',
34
+ '#7dd3fc',
35
+ '#0c4a6e',
36
+ 'ffffff',
37
+ '000000',
38
+ 'c0ffee',
39
+ '7dd3fc',
40
+ '0c4a6e',
41
+ ]
42
+ const expected = [
43
+ '0xffffffff',
44
+ '0x000000ff',
45
+ '0xc0ffeeff',
46
+ '0x7dd3fcff',
47
+ '0x0c4a6eff',
48
+ '0xffffffff',
49
+ '0x000000ff',
50
+ '0xc0ffeeff',
51
+ '0x7dd3fcff',
52
+ '0x0c4a6eff',
53
+ ]
32
54
 
33
55
  const actual = input.map(colors.normalize)
34
56
 
@@ -41,8 +63,15 @@ test('6 character hex', (assert) => {
41
63
  })
42
64
 
43
65
  test('3 character hex', (assert) => {
44
- const input = ['#fff', '#000', '#c8c']
45
- const expected = ['0xffffffff', '0x000000ff', '0xcc88ccff']
66
+ const input = ['#fff', '#000', '#c8c', 'fff', '000', 'c8c']
67
+ const expected = [
68
+ '0xffffffff',
69
+ '0x000000ff',
70
+ '0xcc88ccff',
71
+ '0xffffffff',
72
+ '0x000000ff',
73
+ '0xcc88ccff',
74
+ ]
46
75
 
47
76
  const actual = input.map(colors.normalize)
48
77
 
@@ -55,8 +84,30 @@ test('3 character hex', (assert) => {
55
84
  })
56
85
 
57
86
  test('8 character hex (rgba)', (assert) => {
58
- const input = ['#ffffffff', '#000000ff', '#c0ffee80', '#7dd3fc10', '#0c4a6eff']
59
- const expected = ['0xffffffff', '0x000000ff', '0xc0ffee80', '0x7dd3fc10', '0x0c4a6eff']
87
+ const input = [
88
+ '#ffffffff',
89
+ '#000000ff',
90
+ '#c0ffee80',
91
+ '#7dd3fc10',
92
+ '#0c4a6eff',
93
+ 'ffffffff',
94
+ '000000ff',
95
+ 'c0ffee80',
96
+ '7dd3fc10',
97
+ '0c4a6eff',
98
+ ]
99
+ const expected = [
100
+ '0xffffffff',
101
+ '0x000000ff',
102
+ '0xc0ffee80',
103
+ '0x7dd3fc10',
104
+ '0x0c4a6eff',
105
+ '0xffffffff',
106
+ '0x000000ff',
107
+ '0xc0ffee80',
108
+ '0x7dd3fc10',
109
+ '0x0c4a6eff',
110
+ ]
60
111
 
61
112
  const actual = input.map(colors.normalize)
62
113
 
@@ -68,6 +119,44 @@ test('8 character hex (rgba)', (assert) => {
68
119
  assert.end()
69
120
  })
70
121
 
122
+ test('Invalid hex values', (assert) => {
123
+ const input = [
124
+ '#fde4',
125
+ '#1000',
126
+ '#ddc8c',
127
+ 'hg0',
128
+ '000fffa',
129
+ '#a',
130
+ '#0',
131
+ 'c8O',
132
+ 'fffff',
133
+ '000f00000',
134
+ '##000000',
135
+ ]
136
+ const expected = [
137
+ '0xffffffff',
138
+ '0xffffffff',
139
+ '0xffffffff',
140
+ '0xffffffff',
141
+ '0xffffffff',
142
+ '0xffffffff',
143
+ '0xffffffff',
144
+ '0xffffffff',
145
+ '0xffffffff',
146
+ '0xffffffff',
147
+ '0xffffffff',
148
+ ]
149
+
150
+ const actual = input.map((color) => colors.normalize(color))
151
+
152
+ assert.deepEqual(
153
+ actual,
154
+ expected,
155
+ 'Invalid hex values should return white color as the default color'
156
+ )
157
+ assert.end()
158
+ })
159
+
71
160
  test('RGB colors', (assert) => {
72
161
  const input = [
73
162
  'rgb(255,255,255)',
@@ -80,23 +169,35 @@ test('RGB colors', (assert) => {
80
169
 
81
170
  const actual = input.map(colors.normalize)
82
171
 
83
- assert.deepEqual(
84
- actual,
85
- expected,
86
- 'RGB codes prefixed with # should return the correct color in rgba format'
87
- )
172
+ assert.deepEqual(actual, expected, 'RGB codes should return the correct color in rgba format')
173
+ assert.end()
174
+ })
175
+
176
+ test('Invalid RGB colors', (assert) => {
177
+ const input = [
178
+ 'rgb(256,255,255)',
179
+ 'rgb(123,432,211)',
180
+ 'rgb(192, 255)',
181
+ 'rgb(125,, 211, 252)',
182
+ 'rgb(-12, 74, 110)',
183
+ ]
184
+ const expected = ['0xffffffff', '0xffffffff', '0xffffffff', '0xffffffff', '0xffffffff']
185
+
186
+ const actual = input.map((color) => colors.normalize(color))
187
+
188
+ assert.deepEqual(actual, expected, 'Invalid RGB codes should return white color in rgba format')
88
189
  assert.end()
89
190
  })
90
191
 
91
192
  test('RGBA colors', (assert) => {
92
193
  const input = [
93
- 'rgb(255,255,255,1)',
94
- 'rgb(0,0,0,1)',
95
- 'rgb(192, 255, 238, 0.5)',
96
- 'rgb(125, 211, 252, 0.1)',
97
- 'rgb(12, 74, 110, 0)',
98
- 'rgb(12, 74, 110, -0.5)', // negative alpha should become 0
99
- 'rgb(12, 74, 110, 1.2)', // highher than 1 alpha should become 1
194
+ 'rgba(255,255,255,1)',
195
+ 'rgba(0,0,0,1)',
196
+ 'rgba(192, 255, 238, 0.5)',
197
+ 'rgba(125, 211, 252, 0.1)',
198
+ 'rgba(12, 74, 110, 0)',
199
+ 'rgba(12, 74, 110, -0.5)', // negative alpha should become 0
200
+ 'rgba(12, 74, 110, 1.2)', // highher than 1 alpha should become 1
100
201
  ]
101
202
  const expected = [
102
203
  '0xffffffff',
@@ -110,61 +211,60 @@ test('RGBA colors', (assert) => {
110
211
 
111
212
  const actual = input.map(colors.normalize)
112
213
 
113
- assert.deepEqual(
114
- actual,
115
- expected,
116
- 'RGB codes prefixed with # should return the correct color in rgba format'
117
- )
214
+ assert.deepEqual(actual, expected, 'RGBA codes should return the correct color in rgba format')
118
215
  assert.end()
119
216
  })
120
217
 
121
- test('RGBA colors', (assert) => {
218
+ test('Invalid RGBA colors', (assert) => {
122
219
  const input = [
123
220
  'rgb(255,255,255,1)',
124
- 'rgb(0,0,0,1)',
125
- 'rgb(192, 255, 238, 0.5)',
126
- 'rgb(125, 211, 252, 0.1)',
127
- 'rgb(12, 74, 110, 0)',
128
- 'rgb(12, 74, 110, -0.5)', // negative alpha should become 0
129
- 'rgb(12, 74, 110, 1.2)', // highher than 1 alpha should become 1
221
+ 'rgba(0,0,0,a)',
222
+ 'rgba(192, 256, 238, 0.5)',
223
+ 'rgba(125, 252, 0.1)',
224
+ 'rgba(12,, 74, 110, 0)',
225
+ 'rgba(-12, 74, 110, -0.5)',
226
+ 'rgba(12, 74, 110, --1.2)',
130
227
  ]
131
228
  const expected = [
132
229
  '0xffffffff',
133
- '0x000000ff',
134
- '0xc0ffee80',
135
- '0x7dd3fc1a',
136
- '0x0c4a6e00',
137
- '0x0c4a6e00',
138
- '0x0c4a6eff',
230
+ '0xffffffff',
231
+ '0xffffffff',
232
+ '0xffffffff',
233
+ '0xffffffff',
234
+ '0xffffffff',
235
+ '0xffffffff',
139
236
  ]
140
237
 
238
+ const actual = input.map((color) => colors.normalize(color))
239
+
240
+ assert.deepEqual(actual, expected, 'Invalid RGBA codes should return white color in rgba format')
241
+ assert.end()
242
+ })
243
+
244
+ test('HTML colors', (assert) => {
245
+ const input = ['blanchedalmond', 'salmon', 'tomato', 'saddlebrown', 'red']
246
+ const expected = ['0xffebcdff', '0xfa8072ff', '0xff6347ff', '0x8b4513ff', '0xff0000ff']
247
+
141
248
  const actual = input.map(colors.normalize)
142
249
 
143
250
  assert.deepEqual(
144
251
  actual,
145
252
  expected,
146
- 'RGB codes prefixed with # should return the correct color in rgba format'
253
+ 'HTML color codes should return the correct color in rgba format'
147
254
  )
148
255
  assert.end()
149
256
  })
150
257
 
151
- test('HTML colors', (assert) => {
152
- const input = ['blanchedalmond', 'salmon', 'tomato', 'saddlebrown', 'red']
258
+ test('Invalid HTML colors', (assert) => {
259
+ const input = ['darkblanchedalmond', 'selmon', 'lighttomato', 'sadlebrown', 'darkbrown']
260
+ const expected = ['0xffffffff', '0xffffffff', '0xffffffff', '0xffffffff', '0xffffffff']
153
261
 
154
- const expected = [
155
- parseInt('0xffebcdff', 16),
156
- parseInt('0xfa8072ff', 16),
157
- parseInt('0xff6347ff', 16),
158
- parseInt('0x8b4513ff', 16),
159
- parseInt('0xff0000ff', 16),
160
- ]
161
-
162
- const actual = input.map(colors.normalize)
262
+ const actual = input.map((color) => colors.normalize(color))
163
263
 
164
264
  assert.deepEqual(
165
265
  actual,
166
266
  expected,
167
- 'RGB codes prefixed with # should return the correct color in rgba format'
267
+ 'Invalid HTML color codes should return white color in rgba format'
168
268
  )
169
269
  assert.end()
170
270
  })
@@ -16,153 +16,153 @@
16
16
  */
17
17
 
18
18
  export default {
19
- aliceblue: 0xf0f8ffff,
20
- antiquewhite: 0xfaebd7ff,
21
- aqua: 0xffffff00,
22
- aquamarine: 0x7fffd4ff,
23
- azure: 0xf0ffffff,
24
- beige: 0xf5f5dcff,
25
- bisque: 0xffe4c4ff,
26
- black: 0x000000ff,
27
- blanchedalmond: 0xffebcdff,
28
- blue: 0x0000ffff,
29
- blueviolet: 0x8a2be2ff,
30
- brown: 0xa52a2aff,
31
- burlywood: 0xdeb887ff,
32
- cadetblue: 0x5f9ea0ff,
33
- chartreuse: 0x7fff00ff,
34
- chocolate: 0xd2691eff,
35
- coral: 0xff7f50ff,
36
- cornflowerblue: 0x6495edff,
37
- cornsilk: 0xfff8dcff,
38
- crimson: 0xdc143cff,
39
- cyan: 0x00ffffff,
40
- darkblue: 0x00008bff,
41
- darkcyan: 0x008b8bff,
42
- darkgoldenrod: 0xb8860bff,
43
- darkgray: 0xa9a9a9ff,
44
- darkgreen: 0x006400ff,
45
- darkgrey: 0xa9a9a9ff,
46
- darkkhaki: 0xbdb76bff,
47
- darkmagenta: 0x8b008bff,
48
- darkolivegreen: 0x556b2fff,
49
- darkorange: 0xff8c00ff,
50
- darkorchid: 0x9932ccff,
51
- darkred: 0x8b0000ff,
52
- darksalmon: 0xe9967aff,
53
- darkseagreen: 0x8fbc8fff,
54
- darkslateblue: 0x483d8bff,
55
- darkslategray: 0x2f4f4fff,
56
- darkslategrey: 0x2f4f4fff,
57
- darkturquoise: 0x00ced1ff,
58
- darkviolet: 0x9400d3ff,
59
- deeppink: 0xff1493ff,
60
- deepskyblue: 0x00bfffff,
61
- dimgray: 0x696969ff,
62
- dimgrey: 0x696969ff,
63
- dodgerblue: 0x1e90ffff,
64
- firebrick: 0xb22222ff,
65
- floralwhite: 0xfffaf0ff,
66
- forestgreen: 0x228b22ff,
67
- fuchsia: 0xff00ffff,
68
- gainsboro: 0xdcdcdcff,
69
- ghostwhite: 0xf8f8ffff,
70
- gold: 0xffd700ff,
71
- goldenrod: 0xdaa520ff,
72
- gray: 0x808080ff,
73
- green: 0x008000ff,
74
- greenyellow: 0xadff2fff,
75
- grey: 0x808080ff,
76
- honeydew: 0xf0fff0ff,
77
- hotpink: 0xff69b4ff,
78
- indianred: 0xcd5c5cff,
79
- indigo: 0x4b0082ff,
80
- ivory: 0xfffff0ff,
81
- khaki: 0xf0e68cff,
82
- lavender: 0xe6e6faff,
83
- lavenderblush: 0xfff0f5ff,
84
- lawngreen: 0x7cfc00ff,
85
- lemonchiffon: 0xfffacdff,
86
- lightblue: 0xadd8e6ff,
87
- lightcoral: 0xf08080ff,
88
- lightcyan: 0xe0ffffff,
89
- lightgoldenrodyellow: 0xfafad2ff,
90
- lightgray: 0xd3d3d3ff,
91
- lightgreen: 0x90ee90ff,
92
- lightgrey: 0xd3d3d3ff,
93
- lightpink: 0xffb6c1ff,
94
- lightsalmon: 0xffa07aff,
95
- lightseagreen: 0x20b2aaff,
96
- lightskyblue: 0x87cefaff,
97
- lightslategray: 0x778899ff,
98
- lightslategrey: 0x778899ff,
99
- lightsteelblue: 0xb0c4deff,
100
- lightyellow: 0xffffe0ff,
101
- lime: 0x00ff00ff,
102
- limegreen: 0x32cd32ff,
103
- linen: 0xfaf0e6ff,
104
- magenta: 0xff00ffff,
105
- maroon: 0x800000ff,
106
- mediumaquamarine: 0x66cdaaff,
107
- mediumblue: 0x0000cdff,
108
- mediumorchid: 0xba55d3ff,
109
- mediumpurple: 0x9370dbff,
110
- mediumseagreen: 0x3cb371ff,
111
- mediumslateblue: 0x7b68eeff,
112
- mediumspringgreen: 0x00fa9aff,
113
- mediumturquoise: 0x48d1ccff,
114
- mediumvioletred: 0xc71585ff,
115
- midnightblue: 0x191970ff,
116
- mintcream: 0xf5fffaff,
117
- mistyrose: 0xffe4e1ff,
118
- moccasin: 0xffe4b5ff,
119
- navajowhite: 0xffdeadff,
120
- navy: 0x000080ff,
121
- oldlace: 0xfdf5e6ff,
122
- olive: 0x808000ff,
123
- olivedrab: 0x6b8e23ff,
124
- orange: 0xffa500ff,
125
- orangered: 0xff4500ff,
126
- orchid: 0xda70d6ff,
127
- palegoldenrod: 0xeee8aaff,
128
- palegreen: 0x98fb98ff,
129
- paleturquoise: 0xafeeeeff,
130
- palevioletred: 0xdb7093ff,
131
- papayawhip: 0xffefd5ff,
132
- peachpuff: 0xffdab9ff,
133
- peru: 0xcd853fff,
134
- pink: 0xffc0cbff,
135
- plum: 0xdda0ddff,
136
- powderblue: 0xb0e0e6ff,
137
- purple: 0x800080ff,
138
- rebeccapurple: 0x663399ff,
139
- red: 0xff0000ff,
140
- rosybrown: 0xbc8f8fff,
141
- royalblue: 0x4169e1ff,
142
- saddlebrown: 0x8b4513ff,
143
- salmon: 0xfa8072ff,
144
- sandybrown: 0xf4a460ff,
145
- seagreen: 0x2e8b57ff,
146
- seashell: 0xfff5eeff,
147
- sienna: 0xa0522dff,
148
- silver: 0xc0c0c0ff,
149
- skyblue: 0x87ceebff,
150
- slateblue: 0x6a5acdff,
151
- slategray: 0x708090ff,
152
- slategrey: 0x708090ff,
153
- snow: 0xfffafaff,
154
- springgreen: 0x00ff7fff,
155
- steelblue: 0x4682b4ff,
156
- tan: 0xd2b48cff,
157
- teal: 0x008080ff,
158
- thistle: 0xd8bfd8ff,
159
- tomato: 0xff6347ff,
160
- transparent: 0x00000000,
161
- turquoise: 0x40e0d0ff,
162
- violet: 0xee82eeff,
163
- wheat: 0xf5deb3ff,
164
- white: 0xffffffff,
165
- whitesmoke: 0xf5f5f5ff,
166
- yellow: 0xffff00ff,
167
- yellowgreen: 0x9acd32ff,
19
+ aliceblue: '0xf0f8ffff',
20
+ antiquewhite: '0xfaebd7ff',
21
+ aqua: '0xffffff00',
22
+ aquamarine: '0x7fffd4ff',
23
+ azure: '0xf0ffffff',
24
+ beige: '0xf5f5dcff',
25
+ bisque: '0xffe4c4ff',
26
+ black: '0x000000ff',
27
+ blanchedalmond: '0xffebcdff',
28
+ blue: '0x0000ffff',
29
+ blueviolet: '0x8a2be2ff',
30
+ brown: '0xa52a2aff',
31
+ burlywood: '0xdeb887ff',
32
+ cadetblue: '0x5f9ea0ff',
33
+ chartreuse: '0x7fff00ff',
34
+ chocolate: '0xd2691eff',
35
+ coral: '0xff7f50ff',
36
+ cornflowerblue: '0x6495edff',
37
+ cornsilk: '0xfff8dcff',
38
+ crimson: '0xdc143cff',
39
+ cyan: '0x00ffffff',
40
+ darkblue: '0x00008bff',
41
+ darkcyan: '0x008b8bff',
42
+ darkgoldenrod: '0xb8860bff',
43
+ darkgray: '0xa9a9a9ff',
44
+ darkgreen: '0x006400ff',
45
+ darkgrey: '0xa9a9a9ff',
46
+ darkkhaki: '0xbdb76bff',
47
+ darkmagenta: '0x8b008bff',
48
+ darkolivegreen: '0x556b2fff',
49
+ darkorange: '0xff8c00ff',
50
+ darkorchid: '0x9932ccff',
51
+ darkred: '0x8b0000ff',
52
+ darksalmon: '0xe9967aff',
53
+ darkseagreen: '0x8fbc8fff',
54
+ darkslateblue: '0x483d8bff',
55
+ darkslategray: '0x2f4f4fff',
56
+ darkslategrey: '0x2f4f4fff',
57
+ darkturquoise: '0x00ced1ff',
58
+ darkviolet: '0x9400d3ff',
59
+ deeppink: '0xff1493ff',
60
+ deepskyblue: '0x00bfffff',
61
+ dimgray: '0x696969ff',
62
+ dimgrey: '0x696969ff',
63
+ dodgerblue: '0x1e90ffff',
64
+ firebrick: '0xb22222ff',
65
+ floralwhite: '0xfffaf0ff',
66
+ forestgreen: '0x228b22ff',
67
+ fuchsia: '0xff00ffff',
68
+ gainsboro: '0xdcdcdcff',
69
+ ghostwhite: '0xf8f8ffff',
70
+ gold: '0xffd700ff',
71
+ goldenrod: '0xdaa520ff',
72
+ gray: '0x808080ff',
73
+ green: '0x008000ff',
74
+ greenyellow: '0xadff2fff',
75
+ grey: '0x808080ff',
76
+ honeydew: '0xf0fff0ff',
77
+ hotpink: '0xff69b4ff',
78
+ indianred: '0xcd5c5cff',
79
+ indigo: '0x4b0082ff',
80
+ ivory: '0xfffff0ff',
81
+ khaki: '0xf0e68cff',
82
+ lavender: '0xe6e6faff',
83
+ lavenderblush: '0xfff0f5ff',
84
+ lawngreen: '0x7cfc00ff',
85
+ lemonchiffon: '0xfffacdff',
86
+ lightblue: '0xadd8e6ff',
87
+ lightcoral: '0xf08080ff',
88
+ lightcyan: '0xe0ffffff',
89
+ lightgoldenrodyellow: '0xfafad2ff',
90
+ lightgray: '0xd3d3d3ff',
91
+ lightgreen: '0x90ee90ff',
92
+ lightgrey: '0xd3d3d3ff',
93
+ lightpink: '0xffb6c1ff',
94
+ lightsalmon: '0xffa07aff',
95
+ lightseagreen: '0x20b2aaff',
96
+ lightskyblue: '0x87cefaff',
97
+ lightslategray: '0x778899ff',
98
+ lightslategrey: '0x778899ff',
99
+ lightsteelblue: '0xb0c4deff',
100
+ lightyellow: '0xffffe0ff',
101
+ lime: '0x00ff00ff',
102
+ limegreen: '0x32cd32ff',
103
+ linen: '0xfaf0e6ff',
104
+ magenta: '0xff00ffff',
105
+ maroon: '0x800000ff',
106
+ mediumaquamarine: '0x66cdaaff',
107
+ mediumblue: '0x0000cdff',
108
+ mediumorchid: '0xba55d3ff',
109
+ mediumpurple: '0x9370dbff',
110
+ mediumseagreen: '0x3cb371ff',
111
+ mediumslateblue: '0x7b68eeff',
112
+ mediumspringgreen: '0x00fa9aff',
113
+ mediumturquoise: '0x48d1ccff',
114
+ mediumvioletred: '0xc71585ff',
115
+ midnightblue: '0x191970ff',
116
+ mintcream: '0xf5fffaff',
117
+ mistyrose: '0xffe4e1ff',
118
+ moccasin: '0xffe4b5ff',
119
+ navajowhite: '0xffdeadff',
120
+ navy: '0x000080ff',
121
+ oldlace: '0xfdf5e6ff',
122
+ olive: '0x808000ff',
123
+ olivedrab: '0x6b8e23ff',
124
+ orange: '0xffa500ff',
125
+ orangered: '0xff4500ff',
126
+ orchid: '0xda70d6ff',
127
+ palegoldenrod: '0xeee8aaff',
128
+ palegreen: '0x98fb98ff',
129
+ paleturquoise: '0xafeeeeff',
130
+ palevioletred: '0xdb7093ff',
131
+ papayawhip: '0xffefd5ff',
132
+ peachpuff: '0xffdab9ff',
133
+ peru: '0xcd853fff',
134
+ pink: '0xffc0cbff',
135
+ plum: '0xdda0ddff',
136
+ powderblue: '0xb0e0e6ff',
137
+ purple: '0x800080ff',
138
+ rebeccapurple: '0x663399ff',
139
+ red: '0xff0000ff',
140
+ rosybrown: '0xbc8f8fff',
141
+ royalblue: '0x4169e1ff',
142
+ saddlebrown: '0x8b4513ff',
143
+ salmon: '0xfa8072ff',
144
+ sandybrown: '0xf4a460ff',
145
+ seagreen: '0x2e8b57ff',
146
+ seashell: '0xfff5eeff',
147
+ sienna: '0xa0522dff',
148
+ silver: '0xc0c0c0ff',
149
+ skyblue: '0x87ceebff',
150
+ slateblue: '0x6a5acdff',
151
+ slategray: '0x708090ff',
152
+ slategrey: '0x708090ff',
153
+ snow: '0xfffafaff',
154
+ springgreen: '0x00ff7fff',
155
+ steelblue: '0x4682b4ff',
156
+ tan: '0xd2b48cff',
157
+ teal: '0x008080ff',
158
+ thistle: '0xd8bfd8ff',
159
+ tomato: '0xff6347ff',
160
+ transparent: '0x00000000',
161
+ turquoise: '0x40e0d0ff',
162
+ violet: '0xee82eeff',
163
+ wheat: '0xf5deb3ff',
164
+ white: '0xffffffff',
165
+ whitesmoke: '0xf5f5f5ff',
166
+ yellow: '0xffff00ff',
167
+ yellowgreen: '0x9acd32ff',
168
168
  }
package/src/lib/hooks.js CHANGED
@@ -19,20 +19,20 @@ import symbols from './symbols.js'
19
19
 
20
20
  const cbs = {}
21
21
 
22
- export const emit = (hook, name, scope, data = []) => {
23
- cbs[name] && cbs[name][hook] && cbs[name][hook].apply(scope, data)
22
+ export const emit = (hook, identifier, scope, data = []) => {
23
+ cbs[identifier] && cbs[identifier][hook] && cbs[identifier][hook].apply(scope, data)
24
24
  }
25
25
 
26
- export const privateEmit = (hook, name, scope) => {
26
+ export const privateEmit = (hook, identifier, scope) => {
27
27
  const symHook = symbols[hook]
28
- cbs[name] && cbs[name][symHook] && cbs[name][symHook].apply(scope)
28
+ cbs[identifier] && cbs[identifier][symHook] && cbs[identifier][symHook].apply(scope)
29
29
  }
30
30
 
31
- export const registerHooks = (hooks = {}, name) => {
32
- cbs[name] = {}
31
+ export const registerHooks = (hooks = {}, identifier) => {
32
+ cbs[identifier] = {}
33
33
  // Combines enumerable keys and symbol properties of the 'hooks' object
34
34
  const hookKeys = [...Object.keys(hooks), ...Object.getOwnPropertySymbols(hooks)]
35
35
  hookKeys.forEach((hook) => {
36
- if (typeof hooks[hook] === 'function') cbs[name][hook] = hooks[hook]
36
+ if (typeof hooks[hook] === 'function') cbs[identifier][hook] = hooks[hook]
37
37
  })
38
38
  }
@@ -17,6 +17,7 @@
17
17
 
18
18
  import { Log } from './log.js'
19
19
  import { emit, privateEmit } from './hooks.js'
20
+ import symbols from './symbols.js'
20
21
 
21
22
  const states = ['init', 'ready', 'focus', 'unfocus', 'destroy']
22
23
 
@@ -34,9 +35,9 @@ export default {
34
35
  this.previous = this.current
35
36
  this.current = v
36
37
  // emit 'private' hook
37
- privateEmit(v, this.component.name, this.component)
38
+ privateEmit(v, this.component[symbols.identifier], this.component)
38
39
  // emit 'public' hook
39
- emit(v, this.component.name, this.component)
40
+ emit(v, this.component[symbols.identifier], this.component)
40
41
  }
41
42
  },
42
43
  }
@@ -35,7 +35,7 @@ const shaderAlias = {
35
35
  rounded: 'radius',
36
36
  }
37
37
 
38
- export default (component, name) => {
38
+ export default (component, name, identifier) => {
39
39
  Object.defineProperties(component.prototype, {
40
40
  name: {
41
41
  value: name,
@@ -43,8 +43,15 @@ export default (component, name) => {
43
43
  enumerable: true,
44
44
  configurable: false,
45
45
  },
46
+ [symbols.identifier]: {
47
+ value: component[symbols.identifier],
48
+ writable: false,
49
+ enumerable: false,
50
+ configurable: false,
51
+ },
46
52
  focus: {
47
53
  value: function (e) {
54
+ this[symbols.state].hasFocus = true
48
55
  Focus.set(this, e)
49
56
  },
50
57
  writable: false,
@@ -53,6 +60,7 @@ export default (component, name) => {
53
60
  },
54
61
  unfocus: {
55
62
  value: function () {
63
+ this[symbols.state].hasFocus = false
56
64
  this.lifecycle.state = 'unfocus'
57
65
  },
58
66
  writable: false,
@@ -262,15 +270,15 @@ export default (component, name) => {
262
270
  }
263
271
 
264
272
  const deleteChildren = function (children) {
265
- for (let i = 0; i < children.length; i++) {
266
- if (!children[i]) return
267
- if (Array.isArray(children[i])) {
268
- deleteChildren(children[i])
269
- } else if (children[i].destroy) {
270
- children[i].destroy()
271
- }
272
- children[i] = null
273
- }
273
+ // for (let i = 0; i < children.length; i++) {
274
+ // if (!children[i]) return
275
+ // if (Array.isArray(children[i])) {
276
+ // deleteChildren(children[i])
277
+ // } else if (children[i].destroy) {
278
+ // children[i].destroy()
279
+ // }
280
+ // children[i] = null
281
+ // }
274
282
 
275
- children = []
283
+ children.length = 0
276
284
  }