@lightningjs/blits 0.6.13 → 0.7.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 +6 -0
- package/package.json +1 -1
- package/src/components/FPScounter.js +64 -32
- package/src/launch.d.ts +10 -0
- package/src/launch.js +2 -1
- package/src/lib/codegenerator/generator.js +4 -4
- package/src/router/router.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# v0.7.0
|
|
4
|
+
|
|
5
|
+
- Added support for dynamic components through the `is`-attribute (`<Component is="Poster" />` or `<Component is="$dynamicComponent" />`)
|
|
6
|
+
- Added functionality to pass extra data / props when navigating to a new route ( _breaking change_ in signature of `router.to()` method - previously: `router.to(path, options)`, now: `router.to(path, data, options)`)
|
|
7
|
+
- Added configuration option to set the canvas color (aka clear color)
|
|
8
|
+
|
|
3
9
|
# v0.6.13
|
|
4
10
|
|
|
5
11
|
_16 feb 2024_
|
package/package.json
CHANGED
|
@@ -96,9 +96,11 @@ export default () =>
|
|
|
96
96
|
props4['frame'] = 'fps'
|
|
97
97
|
|
|
98
98
|
if (!elms[4]) {
|
|
99
|
+
const componentType = props4['is'] || 'Sprite'
|
|
100
|
+
|
|
99
101
|
elms[4] = (
|
|
100
|
-
(context.components && context.components[
|
|
101
|
-
component[Symbol.for('components')][
|
|
102
|
+
(context.components && context.components[componentType]) ||
|
|
103
|
+
component[Symbol.for('components')][componentType] ||
|
|
102
104
|
(() => {
|
|
103
105
|
console.error('component Sprite not found')
|
|
104
106
|
})
|
|
@@ -162,9 +164,11 @@ export default () =>
|
|
|
162
164
|
props7['frame'] = component.fps[0]
|
|
163
165
|
|
|
164
166
|
if (!elms[7]) {
|
|
167
|
+
const componentType = props7['is'] || 'Sprite'
|
|
168
|
+
|
|
165
169
|
elms[7] = (
|
|
166
|
-
(context.components && context.components[
|
|
167
|
-
component[Symbol.for('components')][
|
|
170
|
+
(context.components && context.components[componentType]) ||
|
|
171
|
+
component[Symbol.for('components')][componentType] ||
|
|
168
172
|
(() => {
|
|
169
173
|
console.error('component Sprite not found')
|
|
170
174
|
})
|
|
@@ -214,9 +218,11 @@ export default () =>
|
|
|
214
218
|
props9['frame'] = component.fps[1]
|
|
215
219
|
|
|
216
220
|
if (!elms[9]) {
|
|
221
|
+
const componentType = props9['is'] || 'Sprite'
|
|
222
|
+
|
|
217
223
|
elms[9] = (
|
|
218
|
-
(context.components && context.components[
|
|
219
|
-
component[Symbol.for('components')][
|
|
224
|
+
(context.components && context.components[componentType]) ||
|
|
225
|
+
component[Symbol.for('components')][componentType] ||
|
|
220
226
|
(() => {
|
|
221
227
|
console.error('component Sprite not found')
|
|
222
228
|
})
|
|
@@ -266,9 +272,11 @@ export default () =>
|
|
|
266
272
|
props11['frame'] = component.fps[2]
|
|
267
273
|
|
|
268
274
|
if (!elms[11]) {
|
|
275
|
+
const componentType = props11['is'] || 'Sprite'
|
|
276
|
+
|
|
269
277
|
elms[11] = (
|
|
270
|
-
(context.components && context.components[
|
|
271
|
-
component[Symbol.for('components')][
|
|
278
|
+
(context.components && context.components[componentType]) ||
|
|
279
|
+
component[Symbol.for('components')][componentType] ||
|
|
272
280
|
(() => {
|
|
273
281
|
console.error('component Sprite not found')
|
|
274
282
|
})
|
|
@@ -332,9 +340,11 @@ export default () =>
|
|
|
332
340
|
props14['frame'] = 'avg'
|
|
333
341
|
|
|
334
342
|
if (!elms[14]) {
|
|
343
|
+
const componentType = props14['is'] || 'Sprite'
|
|
344
|
+
|
|
335
345
|
elms[14] = (
|
|
336
|
-
(context.components && context.components[
|
|
337
|
-
component[Symbol.for('components')][
|
|
346
|
+
(context.components && context.components[componentType]) ||
|
|
347
|
+
component[Symbol.for('components')][componentType] ||
|
|
338
348
|
(() => {
|
|
339
349
|
console.error('component Sprite not found')
|
|
340
350
|
})
|
|
@@ -398,9 +408,11 @@ export default () =>
|
|
|
398
408
|
props17['frame'] = component.avgFps[0]
|
|
399
409
|
|
|
400
410
|
if (!elms[17]) {
|
|
411
|
+
const componentType = props17['is'] || 'Sprite'
|
|
412
|
+
|
|
401
413
|
elms[17] = (
|
|
402
|
-
(context.components && context.components[
|
|
403
|
-
component[Symbol.for('components')][
|
|
414
|
+
(context.components && context.components[componentType]) ||
|
|
415
|
+
component[Symbol.for('components')][componentType] ||
|
|
404
416
|
(() => {
|
|
405
417
|
console.error('component Sprite not found')
|
|
406
418
|
})
|
|
@@ -450,9 +462,11 @@ export default () =>
|
|
|
450
462
|
props19['frame'] = component.avgFps[1]
|
|
451
463
|
|
|
452
464
|
if (!elms[19]) {
|
|
465
|
+
const componentType = props19['is'] || 'Sprite'
|
|
466
|
+
|
|
453
467
|
elms[19] = (
|
|
454
|
-
(context.components && context.components[
|
|
455
|
-
component[Symbol.for('components')][
|
|
468
|
+
(context.components && context.components[componentType]) ||
|
|
469
|
+
component[Symbol.for('components')][componentType] ||
|
|
456
470
|
(() => {
|
|
457
471
|
console.error('component Sprite not found')
|
|
458
472
|
})
|
|
@@ -502,9 +516,11 @@ export default () =>
|
|
|
502
516
|
props21['frame'] = component.avgFps[2]
|
|
503
517
|
|
|
504
518
|
if (!elms[21]) {
|
|
519
|
+
const componentType = props21['is'] || 'Sprite'
|
|
520
|
+
|
|
505
521
|
elms[21] = (
|
|
506
|
-
(context.components && context.components[
|
|
507
|
-
component[Symbol.for('components')][
|
|
522
|
+
(context.components && context.components[componentType]) ||
|
|
523
|
+
component[Symbol.for('components')][componentType] ||
|
|
508
524
|
(() => {
|
|
509
525
|
console.error('component Sprite not found')
|
|
510
526
|
})
|
|
@@ -569,9 +585,11 @@ export default () =>
|
|
|
569
585
|
props24['frame'] = 'min'
|
|
570
586
|
|
|
571
587
|
if (!elms[24]) {
|
|
588
|
+
const componentType = props24['is'] || 'Sprite'
|
|
589
|
+
|
|
572
590
|
elms[24] = (
|
|
573
|
-
(context.components && context.components[
|
|
574
|
-
component[Symbol.for('components')][
|
|
591
|
+
(context.components && context.components[componentType]) ||
|
|
592
|
+
component[Symbol.for('components')][componentType] ||
|
|
575
593
|
(() => {
|
|
576
594
|
console.error('component Sprite not found')
|
|
577
595
|
})
|
|
@@ -635,9 +653,11 @@ export default () =>
|
|
|
635
653
|
props27['frame'] = component.minFps[0]
|
|
636
654
|
|
|
637
655
|
if (!elms[27]) {
|
|
656
|
+
const componentType = props27['is'] || 'Sprite'
|
|
657
|
+
|
|
638
658
|
elms[27] = (
|
|
639
|
-
(context.components && context.components[
|
|
640
|
-
component[Symbol.for('components')][
|
|
659
|
+
(context.components && context.components[componentType]) ||
|
|
660
|
+
component[Symbol.for('components')][componentType] ||
|
|
641
661
|
(() => {
|
|
642
662
|
console.error('component Sprite not found')
|
|
643
663
|
})
|
|
@@ -687,9 +707,11 @@ export default () =>
|
|
|
687
707
|
props29['frame'] = component.minFps[1]
|
|
688
708
|
|
|
689
709
|
if (!elms[29]) {
|
|
710
|
+
const componentType = props29['is'] || 'Sprite'
|
|
711
|
+
|
|
690
712
|
elms[29] = (
|
|
691
|
-
(context.components && context.components[
|
|
692
|
-
component[Symbol.for('components')][
|
|
713
|
+
(context.components && context.components[componentType]) ||
|
|
714
|
+
component[Symbol.for('components')][componentType] ||
|
|
693
715
|
(() => {
|
|
694
716
|
console.error('component Sprite not found')
|
|
695
717
|
})
|
|
@@ -739,9 +761,11 @@ export default () =>
|
|
|
739
761
|
props31['frame'] = component.minFps[2]
|
|
740
762
|
|
|
741
763
|
if (!elms[31]) {
|
|
764
|
+
const componentType = props31['is'] || 'Sprite'
|
|
765
|
+
|
|
742
766
|
elms[31] = (
|
|
743
|
-
(context.components && context.components[
|
|
744
|
-
component[Symbol.for('components')][
|
|
767
|
+
(context.components && context.components[componentType]) ||
|
|
768
|
+
component[Symbol.for('components')][componentType] ||
|
|
745
769
|
(() => {
|
|
746
770
|
console.error('component Sprite not found')
|
|
747
771
|
})
|
|
@@ -804,9 +828,11 @@ export default () =>
|
|
|
804
828
|
props34['frame'] = 'max'
|
|
805
829
|
|
|
806
830
|
if (!elms[34]) {
|
|
831
|
+
const componentType = props34['is'] || 'Sprite'
|
|
832
|
+
|
|
807
833
|
elms[34] = (
|
|
808
|
-
(context.components && context.components[
|
|
809
|
-
component[Symbol.for('components')][
|
|
834
|
+
(context.components && context.components[componentType]) ||
|
|
835
|
+
component[Symbol.for('components')][componentType] ||
|
|
810
836
|
(() => {
|
|
811
837
|
console.error('component Sprite not found')
|
|
812
838
|
})
|
|
@@ -870,9 +896,11 @@ export default () =>
|
|
|
870
896
|
props37['frame'] = component.maxFps[0]
|
|
871
897
|
|
|
872
898
|
if (!elms[37]) {
|
|
899
|
+
const componentType = props37['is'] || 'Sprite'
|
|
900
|
+
|
|
873
901
|
elms[37] = (
|
|
874
|
-
(context.components && context.components[
|
|
875
|
-
component[Symbol.for('components')][
|
|
902
|
+
(context.components && context.components[componentType]) ||
|
|
903
|
+
component[Symbol.for('components')][componentType] ||
|
|
876
904
|
(() => {
|
|
877
905
|
console.error('component Sprite not found')
|
|
878
906
|
})
|
|
@@ -922,9 +950,11 @@ export default () =>
|
|
|
922
950
|
props39['frame'] = component.maxFps[1]
|
|
923
951
|
|
|
924
952
|
if (!elms[39]) {
|
|
953
|
+
const componentType = props39['is'] || 'Sprite'
|
|
954
|
+
|
|
925
955
|
elms[39] = (
|
|
926
|
-
(context.components && context.components[
|
|
927
|
-
component[Symbol.for('components')][
|
|
956
|
+
(context.components && context.components[componentType]) ||
|
|
957
|
+
component[Symbol.for('components')][componentType] ||
|
|
928
958
|
(() => {
|
|
929
959
|
console.error('component Sprite not found')
|
|
930
960
|
})
|
|
@@ -974,9 +1004,11 @@ export default () =>
|
|
|
974
1004
|
props41['frame'] = component.maxFps[2]
|
|
975
1005
|
|
|
976
1006
|
if (!elms[41]) {
|
|
1007
|
+
const componentType = props41['is'] || 'Sprite'
|
|
1008
|
+
|
|
977
1009
|
elms[41] = (
|
|
978
|
-
(context.components && context.components[
|
|
979
|
-
component[Symbol.for('components')][
|
|
1010
|
+
(context.components && context.components[componentType]) ||
|
|
1011
|
+
component[Symbol.for('components')][componentType] ||
|
|
980
1012
|
(() => {
|
|
981
1013
|
console.error('component Sprite not found')
|
|
982
1014
|
})
|
package/src/launch.d.ts
CHANGED
|
@@ -162,6 +162,16 @@ export interface Settings {
|
|
|
162
162
|
* `navigator.hardwareConcurrency` (or 2 if `navigator.hardwareConcurrency` is not supported)
|
|
163
163
|
*/
|
|
164
164
|
webWorkersLimit?: number
|
|
165
|
+
/**
|
|
166
|
+
* Background color of the canvas (also known as the clearColor)
|
|
167
|
+
*
|
|
168
|
+
* Can be a color name (red, blue, silver), a hexadecimal color (`#000000`, `#ccc`),
|
|
169
|
+
* or a color number in rgba order (`0xff0033ff`)
|
|
170
|
+
*
|
|
171
|
+
* Defauls to transparent (`0x00000000`)
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
canvasColor?: string,
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
/**
|
package/src/launch.js
CHANGED
|
@@ -20,7 +20,7 @@ import { MainCoreDriver, RendererMain } from '@lightningjs/renderer'
|
|
|
20
20
|
import Settings from './settings.js'
|
|
21
21
|
import { initLog, Log } from './lib/log.js'
|
|
22
22
|
import { screenResolutions } from './lib/utils.js'
|
|
23
|
-
|
|
23
|
+
import colors from './lib/colors/colors.js'
|
|
24
24
|
|
|
25
25
|
export let renderer
|
|
26
26
|
|
|
@@ -51,6 +51,7 @@ export default (App, target, settings) => {
|
|
|
51
51
|
'webWorkersLimit' in settings
|
|
52
52
|
? settings.webWorkersLimit
|
|
53
53
|
: window.navigator.hardwareConcurrency || 2,
|
|
54
|
+
clearColor: (settings.canvasColor && colors.normalize(settings.canvasColor)) || 0x00000000,
|
|
54
55
|
},
|
|
55
56
|
target,
|
|
56
57
|
driver
|
|
@@ -169,11 +169,11 @@ const generateComponentCode = function (
|
|
|
169
169
|
|
|
170
170
|
renderCode.push(`
|
|
171
171
|
if(!${elm}) {
|
|
172
|
-
${
|
|
172
|
+
const componentType = props${counter}['is'] || '${
|
|
173
173
|
templateObject[Symbol.for('componentType')]
|
|
174
|
-
}'
|
|
175
|
-
|
|
176
|
-
}'] || (() => { console.error('component ${
|
|
174
|
+
}'
|
|
175
|
+
|
|
176
|
+
${elm} = (context.components && context.components[componentType] || component[Symbol.for('components')][componentType] || (() => { console.error('component ${
|
|
177
177
|
templateObject[Symbol.for('componentType')]
|
|
178
178
|
} not found')})).call(null, {props: props${counter}}, ${parent}, component)
|
|
179
179
|
if (${elm}[Symbol.for('slots')][0]) {
|
package/src/router/router.js
CHANGED
|
@@ -28,7 +28,9 @@ export let navigating = false
|
|
|
28
28
|
|
|
29
29
|
const cacheMap = new WeakMap()
|
|
30
30
|
const history = []
|
|
31
|
+
|
|
31
32
|
let overrideOptions = {}
|
|
33
|
+
let navigationData = {}
|
|
32
34
|
let navigatingBack = false
|
|
33
35
|
let previousFocus
|
|
34
36
|
|
|
@@ -133,7 +135,8 @@ export const navigate = async function () {
|
|
|
133
135
|
holder.set('w', '100%')
|
|
134
136
|
holder.set('h', '100%')
|
|
135
137
|
// merge props with potential route params to be injected into the component instance
|
|
136
|
-
const props = { ...this[symbols.props], ...route.params }
|
|
138
|
+
const props = { ...this[symbols.props], ...route.params, ...navigationData }
|
|
139
|
+
|
|
137
140
|
view = await route.component({ props }, holder, this)
|
|
138
141
|
if (view[Symbol.toStringTag] === 'Module') {
|
|
139
142
|
if (view.default && typeof view.default === 'function') {
|
|
@@ -250,7 +253,8 @@ const setOrAnimate = (node, transition, shouldAnimate = true) => {
|
|
|
250
253
|
: node.set(transition.prop, transition.value)
|
|
251
254
|
}
|
|
252
255
|
|
|
253
|
-
export const to = (location, options = {}) => {
|
|
256
|
+
export const to = (location, data = {}, options = {}) => {
|
|
257
|
+
navigationData = data
|
|
254
258
|
overrideOptions = options
|
|
255
259
|
window.location.hash = `#${location}`
|
|
256
260
|
}
|