@lightningjs/blits 0.8.0 → 0.8.1

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.
@@ -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
  }
@@ -262,15 +262,15 @@ export default (component, name) => {
262
262
  }
263
263
 
264
264
  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
- }
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
+ // }
274
274
 
275
- children = []
275
+ children.length = 0
276
276
  }
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import symbols from '../symbols.js'
19
+ import colors from '../colors/colors.js'
19
20
 
20
21
  export default (template = '', componentName, parentComponent, filePath = null) => {
21
22
  let cursor = 0
@@ -186,9 +187,50 @@ export default (template = '', componentName, parentComponent, filePath = null)
186
187
  const [objectName, attributeName] = name.split('.')
187
188
  return { name: objectName, value: `{${attributeName}: ${value}}` }
188
189
  }
190
+
191
+ // process color values
192
+ if (['color', ':color', ':effects', 'effects'].includes(name)) {
193
+ return processColors(name, value)
194
+ }
189
195
  return { name, value }
190
196
  }
191
197
 
198
+ const processColors = (name, value) => {
199
+ let newValue = value //copy for processing
200
+ let normalized = colors.normalize(newValue, null)
201
+
202
+ if (normalized === null) {
203
+ const stringTokenRegex = /'([^']+)'/g
204
+ let match
205
+ let lastIndex = 0
206
+ let result = ''
207
+
208
+ while ((match = stringTokenRegex.exec(value)) !== null) {
209
+ const potentialColor = match[1]
210
+ const matchIndex = match.index
211
+ const matchLength = match[0].length
212
+
213
+ result += value.slice(lastIndex, matchIndex)
214
+ normalized = colors.normalize(potentialColor, null)
215
+
216
+ if (normalized === null) {
217
+ result += value.slice(matchIndex, matchIndex + matchLength)
218
+ } else {
219
+ result += `'${normalized}'`
220
+ }
221
+
222
+ lastIndex = matchIndex + matchLength
223
+ }
224
+
225
+ result += value.slice(lastIndex)
226
+ newValue = result
227
+ } else {
228
+ newValue = normalized
229
+ }
230
+
231
+ return { name, value: newValue }
232
+ }
233
+
192
234
  /*
193
235
  Formatting & validation rules:
194
236
  #1: Every opening tag must have a corresponding closing tag at the same level. If a closing tag is encountered without
@@ -275,25 +317,21 @@ export default (template = '', componentName, parentComponent, filePath = null)
275
317
  const contextPaddingBefore = 10 // number of characters to show before the error location
276
318
  const contextPaddingAfter = 50 // number of characters to show after the error location
277
319
 
278
- const TemplateParseError = (message, context) => {
320
+ const TemplateParseError = (message) => {
279
321
  const location = getErrorLocation()
280
322
  message = `${message} in ${location}`
281
323
 
282
324
  const error = new Error(message)
283
325
  error.name = 'TemplateParseError'
284
326
 
285
- // generate context if the error is related to parsing
286
- if (!context) {
287
- const start = Math.max(0, prevCursor - contextPaddingBefore)
288
- const end = Math.min(template.length, cursor + contextPaddingAfter)
289
- const contextText = template.slice(start, end)
327
+ const start = Math.max(0, prevCursor - contextPaddingBefore)
328
+ const end = Math.min(template.length, cursor + contextPaddingAfter)
329
+ const contextText = template.slice(start, end)
330
+
331
+ // add ^ caret to show where the error is
332
+ const caretPosition = cursor - start
333
+ error.context = insertContextCaret(caretPosition, contextText)
290
334
 
291
- // add ^ caret to show where the error is
292
- const caretPosition = cursor - start
293
- error.context = insertContextCaret(caretPosition, contextText)
294
- } else {
295
- error.context = context
296
- }
297
335
  return error
298
336
  }
299
337