@lightningjs/blits 1.18.1 → 1.19.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/.eslintrc.cjs +1 -0
- package/CHANGELOG.md +7 -0
- package/docs/router/basics.md +32 -0
- package/index.d.ts +47 -1
- package/package.json +1 -1
- package/src/component/base/router.js +3 -2
- package/src/components/Circle.js +41 -42
- package/src/components/FPScounter.js +1334 -1284
- package/src/components/RouterView.js +28 -23
- package/src/components/Sprite.js +35 -32
- package/src/constants.js +7 -0
- package/src/engines/L3/element.js +9 -2
- package/src/engines/L3/launch.js +6 -2
- package/src/focus.js +2 -2
- package/src/lib/reactivity/reactive.js +6 -2
- package/src/router/router.js +13 -10
package/.eslintrc.cjs
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.19.0
|
|
4
|
+
|
|
5
|
+
- Fixed `show`-attribute when an `alpha`-attribute is also present
|
|
6
|
+
- Added `inspector-data`-attribute to help with automated testing based on the Lightning inspector
|
|
7
|
+
- Added reactivity to Route changes (`this.$router.state.path` and `this.$router.state.navigating`)
|
|
8
|
+
- Added `renderQuality` launch setting
|
|
9
|
+
|
|
3
10
|
## v1.18.1
|
|
4
11
|
|
|
5
12
|
_27 jan 2025_
|
package/docs/router/basics.md
CHANGED
|
@@ -141,3 +141,35 @@ The Router API provides several useful methods and properties for managing route
|
|
|
141
141
|
- `this.$router.currentRoute` - retrieve the current route
|
|
142
142
|
- `this.$router.routes` - retrieve the list of all routes
|
|
143
143
|
- `this.$router.navigating` - retrieve the current navigating state
|
|
144
|
+
- `this.$router.state` - reactive router state (see below)
|
|
145
|
+
|
|
146
|
+
### Reactive router state
|
|
147
|
+
|
|
148
|
+
The reactive router state (`this.$router.state`) can be useful in situations where you want to hook up reactive changes in your App to Route changes.
|
|
149
|
+
|
|
150
|
+
The `state` variable on the `this.$router` object returns a reactive object with 2 keys: `path` and `navigating`. The values of these keys will automaticaly update when the router navigates from one page to another.
|
|
151
|
+
|
|
152
|
+
The router state changes can be used in a Blits template, they can be _watched_ and they can be used in generic busines logic, as demonstrated in the example below.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
export default Blits.Component('MyComponent', {
|
|
156
|
+
template: `
|
|
157
|
+
<Element w="1920" h="1080">
|
|
158
|
+
<!-- dynamically display the current path -->
|
|
159
|
+
<Text x="100" h="100" :content="$$router.state.path" />
|
|
160
|
+
<!-- show loading text when router is navigating -->
|
|
161
|
+
<Text :show="$showLoader">Loading ...</Text>
|
|
162
|
+
</Element>
|
|
163
|
+
`,
|
|
164
|
+
watch: {
|
|
165
|
+
'$router.state.path'(v, old) {
|
|
166
|
+
Log.info(`Router Path changed from ${old} to ${v}`)
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
computed: {
|
|
170
|
+
showLoader() {
|
|
171
|
+
return this.$router.state.navigating
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -161,6 +161,30 @@ declare module '@lightningjs/blits' {
|
|
|
161
161
|
*/
|
|
162
162
|
readonly navigating: boolean;
|
|
163
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Reactive router state
|
|
166
|
+
*/
|
|
167
|
+
state: {
|
|
168
|
+
/**
|
|
169
|
+
* Path of the current route
|
|
170
|
+
*
|
|
171
|
+
* Can be used in:
|
|
172
|
+
* - a template as `$$router.state.path`
|
|
173
|
+
* - inside business logic as `this.$router.state.path`
|
|
174
|
+
* - as a watcher as `$router.state.path(v) {}`
|
|
175
|
+
*/
|
|
176
|
+
readonly path: string
|
|
177
|
+
/**
|
|
178
|
+
* Whether or not the router is currently in the process of navigating
|
|
179
|
+
* between pages
|
|
180
|
+
*
|
|
181
|
+
* Can be used in:
|
|
182
|
+
* - a template as `$$router.state.navihating`
|
|
183
|
+
* - inside business logic as `this.$router.state.navigating`
|
|
184
|
+
* - as a watcher as `$router.state.navigating(v) {}`
|
|
185
|
+
*/
|
|
186
|
+
readonly navigating: boolean
|
|
187
|
+
}
|
|
164
188
|
}
|
|
165
189
|
|
|
166
190
|
export type ComponentBase = {
|
|
@@ -599,6 +623,7 @@ declare module '@lightningjs/blits' {
|
|
|
599
623
|
}
|
|
600
624
|
|
|
601
625
|
type ScreenResolutions = 'hd' | '720p' | 720 | 'fhd' | 'fullhd' | '1080p' | 1080 | '4k' | '2160p' | 2160
|
|
626
|
+
type RenderQualities = 'low' | 'medium' | 'high' | 'retina' | number
|
|
602
627
|
|
|
603
628
|
type ReactivityModes = 'Proxy' | 'defineProperty'
|
|
604
629
|
type RenderModes = 'webgl' | 'canvas'
|
|
@@ -667,7 +692,7 @@ declare module '@lightningjs/blits' {
|
|
|
667
692
|
*
|
|
668
693
|
* Currently 3 screen resolutions are supported, which can be defined with different alias values:
|
|
669
694
|
*
|
|
670
|
-
* For
|
|
695
|
+
* For 720x1280 (1px = 0.66666667px)
|
|
671
696
|
* - hd
|
|
672
697
|
* - 720p
|
|
673
698
|
* - 720
|
|
@@ -685,6 +710,27 @@ declare module '@lightningjs/blits' {
|
|
|
685
710
|
*/
|
|
686
711
|
screenResolution?: ScreenResolutions,
|
|
687
712
|
/**
|
|
713
|
+
* Controls the quality of the rendered App.
|
|
714
|
+
*
|
|
715
|
+
* Setting a lower quality leads to less detail on screen, but can positively affect overall
|
|
716
|
+
* performance and smoothness of the App (i.e. a higher FPS).
|
|
717
|
+
*
|
|
718
|
+
* The render quality can be one of the following presets:
|
|
719
|
+
*
|
|
720
|
+
* - `low` => 66% quality
|
|
721
|
+
* - `medium` => 85% quality
|
|
722
|
+
* - `high` => 100% quality
|
|
723
|
+
* - `retina` => 200% quality
|
|
724
|
+
*
|
|
725
|
+
* It's also possible to provide a custom value as a (decimal) number:
|
|
726
|
+
*
|
|
727
|
+
* - `0.2` => 20% quality
|
|
728
|
+
* - `1.5` => 150% quality
|
|
729
|
+
*
|
|
730
|
+
* Defaults to 1 (high quality) when not specified
|
|
731
|
+
*/
|
|
732
|
+
renderQuality?: RenderQualities,
|
|
733
|
+
/**
|
|
688
734
|
* Custom pixel ratio of the device used to convert dimensions
|
|
689
735
|
* and positions in the App code to the actual device logical coordinates
|
|
690
736
|
*
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import symbols from '../../lib/symbols.js'
|
|
19
|
-
import { to, currentRoute,
|
|
19
|
+
import { to, currentRoute, back, state } from '../../router/router.js'
|
|
20
20
|
|
|
21
21
|
export default {
|
|
22
22
|
$router: {
|
|
@@ -30,8 +30,9 @@ export default {
|
|
|
30
30
|
return this[symbols.routes]
|
|
31
31
|
},
|
|
32
32
|
get navigating() {
|
|
33
|
-
return navigating
|
|
33
|
+
return state.navigating
|
|
34
34
|
},
|
|
35
|
+
state,
|
|
35
36
|
},
|
|
36
37
|
writable: false,
|
|
37
38
|
enumerable: true,
|
package/src/components/Circle.js
CHANGED
|
@@ -19,52 +19,51 @@ import Component from '../component.js'
|
|
|
19
19
|
|
|
20
20
|
export default () =>
|
|
21
21
|
Component('Circle', {
|
|
22
|
-
/* eslint-disable no-unused-vars */
|
|
23
|
-
code: {
|
|
24
|
-
) {
|
|
25
|
-
const elms = []
|
|
26
|
-
let componentType
|
|
27
|
-
const rootComponent = component
|
|
28
|
-
let propData
|
|
29
|
-
let slotComponent
|
|
30
|
-
let inSlot = false
|
|
31
|
-
let slotChildCounter = 0
|
|
32
|
-
const elementConfig0 = {}
|
|
22
|
+
/* eslint-disable no-unused-vars */
|
|
23
|
+
code: {
|
|
24
|
+
render: function anonymous(parent, component, context, components, effect, getRaw) {
|
|
25
|
+
const elms = []
|
|
26
|
+
let componentType
|
|
27
|
+
const rootComponent = component
|
|
28
|
+
let propData
|
|
29
|
+
let slotComponent
|
|
30
|
+
let inSlot = false
|
|
31
|
+
let slotChildCounter = 0
|
|
32
|
+
const elementConfig0 = {}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
elementConfig0['h'] = component.size
|
|
39
|
-
elementConfig0['effects'] = [component.shader('radius', {radius: component.radius})]
|
|
40
|
-
elms[0].populate(elementConfig0)
|
|
34
|
+
elms[0] = this.element(
|
|
35
|
+
{ parent: parent || 'root' },
|
|
36
|
+
inSlot === true ? slotComponent : component
|
|
37
|
+
)
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, effects: [function anonymous(component,elms,context,components,rootComponent,effect
|
|
48
|
-
) {
|
|
39
|
+
elementConfig0['color'] = component.color
|
|
40
|
+
elementConfig0['w'] = component.size
|
|
41
|
+
elementConfig0['h'] = component.size
|
|
42
|
+
elementConfig0['effects'] = [component.shader('radius', { radius: component.radius })]
|
|
43
|
+
elms[0].populate(elementConfig0)
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
) {
|
|
45
|
+
if (inSlot === true) {
|
|
46
|
+
slotChildCounter -= 1
|
|
47
|
+
}
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
return elms
|
|
50
|
+
},
|
|
51
|
+
effects: [
|
|
52
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
53
|
+
elms[0].set('color', component.color)
|
|
54
|
+
},
|
|
55
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
56
|
+
elms[0].set('w', component.size)
|
|
57
|
+
},
|
|
58
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
59
|
+
elms[0].set('h', component.size)
|
|
60
|
+
},
|
|
61
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
62
|
+
elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
context: {},
|
|
66
|
+
},
|
|
68
67
|
props: [{ key: 'size', default: 40 }, 'color'],
|
|
69
68
|
computed: {
|
|
70
69
|
radius() {
|