@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.
- package/CHANGELOG.md +19 -0
- package/boilerplate/js/default/src/index.js +2 -8
- package/docs/README.md +0 -21
- package/docs/_sidebar.md +25 -13
- package/docs/built-in/directives.md +44 -0
- package/docs/{component_state.md → components/component_state.md} +37 -5
- package/docs/components/computed_properties.md +48 -0
- package/docs/{lifecycle_events.md → components/lifecycle_events.md} +4 -2
- package/docs/components/methods.md +47 -0
- package/docs/components/props.md +58 -0
- package/docs/{user_input.md → components/user_input.md} +31 -26
- package/docs/components/utilities.md +4 -0
- package/docs/components/watchers.md +36 -0
- package/docs/essentials/application_root.md +21 -0
- package/docs/{components.md → essentials/components.md} +17 -5
- package/docs/{displaying_images.md → essentials/displaying_images.md} +7 -7
- package/docs/essentials/displaying_text.md +77 -0
- package/docs/{element_attributes.md → essentials/element_attributes.md} +17 -12
- package/docs/essentials/template_syntax.md +85 -0
- package/docs/getting_started/file_structure.md +61 -0
- package/docs/getting_started/getting_started.md +47 -0
- package/docs/{introduction.md → getting_started/intro.md} +2 -1
- package/docs/sidebar.json +70 -26
- package/docs/transitions_animations/transitions.md +132 -0
- package/package.json +2 -3
- package/src/component.js +12 -3
- package/src/element.js +3 -0
- package/src/fontLoader.js +20 -21
- package/src/launch.d.ts +5 -6
- package/src/launch.js +12 -2
- package/src/lib/codegenerator/generator.js +2 -2
- package/src/lib/colors/colors.js +50 -40
- package/src/lib/colors/colors.test.js +149 -49
- package/src/lib/colors/htmlColors.js +149 -149
- package/src/lib/hooks.js +7 -7
- package/src/lib/lifecycle.js +3 -2
- package/src/lib/setup/base.js +19 -11
- package/src/lib/setup/state.js +1 -1
- package/src/lib/symbols.js +2 -0
- package/src/lib/templateparser/parser.js +50 -12
- package/src/lib/templateparser/parser.test.js +378 -71
- package/src/router/router.js +6 -6
- package/vite/msdfGenerator.js +1 -1
- package/boilerplate/js/default/src/fontloader.js +0 -4
- package/docs/computed_properties.md +0 -18
- package/docs/getting_started.md +0 -40
- package/docs/props.md +0 -46
- package/docs/template_syntax.md +0 -65
- package/docs/watchers.md +0 -38
- /package/docs/{text-to-speech-announcer.md → plugins/text-to-speech-announcer.md} +0 -0
package/src/lib/setup/state.js
CHANGED
|
@@ -22,7 +22,7 @@ import symbols from '../symbols.js'
|
|
|
22
22
|
export default (component, state) => {
|
|
23
23
|
component[symbols.stateKeys] = []
|
|
24
24
|
|
|
25
|
-
state = state.apply(component.prototype)
|
|
25
|
+
state = { ...state.apply(component.prototype), ...{ hasFocus: false } }
|
|
26
26
|
Object.keys(state).forEach((key) => {
|
|
27
27
|
if (component[symbols.propKeys] && component[symbols.propKeys].indexOf(key) > -1) {
|
|
28
28
|
Log.error(`State ${key} already exists as a prop`)
|
package/src/lib/symbols.js
CHANGED
|
@@ -3,6 +3,8 @@ export default {
|
|
|
3
3
|
cursorTagStart: Symbol('cursorTagStart'),
|
|
4
4
|
computedKeys: Symbol('computedKeys'),
|
|
5
5
|
destroy: Symbol('destroy'),
|
|
6
|
+
id: Symbol('id'),
|
|
7
|
+
identifier: Symbol('identifier'),
|
|
6
8
|
index: Symbol('index'),
|
|
7
9
|
init: Symbol('init'),
|
|
8
10
|
inputEvents: Symbol('inputEvents'),
|
|
@@ -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
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
|