@lightningjs/blits 0.9.6 → 0.9.8
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 -1
- package/boilerplate/common/eslint/.eslintrc.cjs +1 -1
- package/boilerplate/common/git/gitignore +4 -1
- package/boilerplate/js/default/.env.example +4 -0
- package/boilerplate/js/default/src/pages/Home.js +1 -1
- package/boilerplate/js/default/vite.config.js +2 -0
- package/docs/_sidebar.md +1 -0
- package/docs/built-in/directives.md +11 -3
- package/docs/built-in/for-loop.md +172 -0
- package/docs/components/component_state.md +1 -2
- package/docs/components/computed_properties.md +3 -4
- package/docs/components/methods.md +3 -3
- package/docs/components/props.md +1 -1
- package/docs/components/user_input.md +2 -2
- package/docs/components/watchers.md +1 -1
- package/docs/essentials/application_root.md +1 -1
- package/docs/essentials/components.md +3 -3
- package/docs/essentials/displaying_images.md +2 -2
- package/docs/essentials/displaying_text.md +12 -12
- package/docs/essentials/element_attributes.md +19 -13
- package/docs/essentials/template_syntax.md +8 -8
- package/docs/getting_started/file_structure.md +10 -11
- package/docs/getting_started/intro.md +3 -3
- package/docs/plugins/text-to-speech-announcer.md +2 -2
- package/docs/sidebar.json +4 -0
- package/docs/transitions_animations/transitions.md +10 -10
- package/package.json +2 -2
- package/src/component.js +1 -1
- package/src/components/Circle.js +30 -27
- package/src/components/Circle.orig.js +3 -29
- package/src/components/FPScounter.js +1078 -1024
- package/src/components/FPScounter.orig.js +41 -1024
- package/src/components/Image.js +21 -18
- package/src/components/Image.orig.js +2 -20
- package/src/components/RouterView.js +20 -17
- package/src/components/RouterView.orig.js +3 -19
- package/src/components/Sprite.js +27 -23
- package/src/components/Sprite.orig.js +3 -25
- package/src/components/Text.js +57 -53
- package/src/components/Text.orig.js +21 -55
- package/src/engines/L3/element.js +3 -0
- package/src/engines/L3/launch.js +1 -0
- package/src/launch.d.ts +11 -1
- package/src/lib/reactivity/effect.js +1 -0
- package/src/lib/reactivity/reactive.js +10 -1
- package/src/lib/setup/base.js +7 -3
- package/src/lib/setup/state.js +1 -1
- package/src/router/router.js +0 -7
|
@@ -8,23 +8,23 @@ Let's review the basic file structure, and take a closer look at the important o
|
|
|
8
8
|
|
|
9
9
|
### package.json
|
|
10
10
|
|
|
11
|
-
In the root of your newly created app you will obviously find a `package.json` with all the necessary (dev) dependencies.
|
|
11
|
+
In the root of your newly created app, you will obviously find a `package.json` with all the necessary (dev) dependencies.
|
|
12
12
|
|
|
13
13
|
In order to build a Blits based Lightning 3 app, all you need is `@lightningjs/blits` as a dependency. Blits will take care of hooking up the Lightning 3 renderer for you behind the scenes.
|
|
14
14
|
|
|
15
|
-
Feel free to install and import any custom library that your App may need. But always be mindful of the size and impact an external dependency may have - especially when developing for low powered devices (as
|
|
15
|
+
Feel free to install and import any custom library that your App may need. But always be mindful of the size and impact an external dependency may have - especially when developing for low powered devices (as is often the case with Lightning apps).
|
|
16
16
|
|
|
17
17
|
### index.html
|
|
18
18
|
|
|
19
|
-
You will also find an `index.html`
|
|
19
|
+
You will also find an `index.html` at the root of your project. This is where the browser will be pointed to, in order to launch your Blits App.
|
|
20
20
|
|
|
21
|
-
If you inspect the source you will see some minimal
|
|
21
|
+
If you inspect the source you will see some minimal HTML. The essential parts of the HTML are the `<div>` where the canvas will be injected into, and the `<script>`-tag that points to the `index.js` of the App.
|
|
22
22
|
|
|
23
23
|
### public
|
|
24
24
|
|
|
25
|
-
There is also a `public` folder in your project. This folder is used for storing
|
|
25
|
+
There is also a `public` folder in your project. This folder is used for storing public assets, such as App images and fonts.
|
|
26
26
|
|
|
27
|
-
During development your assets are loaded directly from this folder. And if you run a production build, the entire `public` folder is copied over to the distributable version.
|
|
27
|
+
During development, your assets are loaded directly from this folder. And if you run a production build, the entire `public` folder is copied over to the distributable version.
|
|
28
28
|
|
|
29
29
|
### src
|
|
30
30
|
|
|
@@ -37,7 +37,7 @@ The `src`-folder is where all your custom App code lives.
|
|
|
37
37
|
The `Blits.Launch()`-method accepts 3 parameters:
|
|
38
38
|
|
|
39
39
|
1) `app` - the root application component
|
|
40
|
-
2) `target` - the
|
|
40
|
+
2) `target` - the HTML target to append the canvas to. This can either be an `id` of an HTML element in `index.html`, or you can pass a reference to HTML element itself
|
|
41
41
|
3) `settings` - an `object` with settings
|
|
42
42
|
|
|
43
43
|
#### App.js
|
|
@@ -46,16 +46,15 @@ The `Blits.Launch()`-method accepts 3 parameters:
|
|
|
46
46
|
|
|
47
47
|
### components and pages folder
|
|
48
48
|
|
|
49
|
-
The rest of
|
|
50
|
-
to use a separate file for each component, and place them in the `src/components`-folder.
|
|
49
|
+
The rest of your App can be built out using components. You are free to organize your components as you wish, but we recommend using a separate file for each component and placing them in the `src/components`-folder.
|
|
51
50
|
|
|
52
51
|
The convention is to start the component file name with a capital letter, matching the name of the component (e.g. `src/components/Loader.js` or `src/components/MenuItem.js`).
|
|
53
52
|
|
|
54
53
|
Feel free to further organize and possibly nest your Component files to your own preferences.
|
|
55
54
|
|
|
56
|
-
Pages in your App are technically just Blits components as well. But to keep
|
|
55
|
+
Pages in your App are technically just Blits components as well. But to keep things clear, we often place them in a separate `pages`-folder alongside the `components`-folder (e.g. `src/pages/Home.js` and `src/pages/Details.js`)
|
|
57
56
|
|
|
58
57
|
#### Custom code
|
|
59
58
|
|
|
60
|
-
If your App needs libraries for specific (business) logic that can be shared
|
|
59
|
+
If your App needs libraries for specific (business) logic that can be shared across components (such as API calls) you can place them anywhere in your `src` folder. For example in a folder named `src/lib` or `src/api`.
|
|
61
60
|
|
|
@@ -10,11 +10,11 @@ The Blits framework uses a **readable** XML-style template syntax and comes with
|
|
|
10
10
|
|
|
11
11
|
## Why Blits?
|
|
12
12
|
|
|
13
|
-
You may be wondering where the name Blits comes from
|
|
13
|
+
You may be wondering where the name Blits comes from.
|
|
14
14
|
|
|
15
15
|
Firstly, it's short, memorable and just has a nice ring to it.
|
|
16
16
|
|
|
17
|
-
"Blits" is a Dutch word (a significant portion of the Lightning Open Source teams is based in the Netherlands). It means _flashy_ and it's often used
|
|
17
|
+
"Blits" is a Dutch word (a significant portion of the Lightning Open Source teams is based in the Netherlands). It means _flashy_ and it's often used for things that are _great_ or _cool_.
|
|
18
18
|
|
|
19
|
-
Finally it's a nerdy reference to the computer term "Bit Blits" commonly used in graphics processing, for rapidly moving a block of data into memory - quite similar to what Lightning is doing 🙂
|
|
19
|
+
Finally, it's a nerdy reference to the computer term "Bit Blits" commonly used in graphics processing, for rapidly moving a block of data into memory - quite similar to what Lightning is doing 🙂
|
|
20
20
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Text-to-Speech / Announcer
|
|
4
4
|
|
|
5
|
-
Blits comes with a built-in Text-to-Speech / Announcer functionality, to easily make your App more accessible. This is something that's often overlooked when developing an App, but having speech assistance integrated into your App is a huge deal for those users
|
|
5
|
+
Blits comes with a built-in Text-to-Speech / Announcer functionality, to easily make your App more accessible. This is something that's often overlooked when developing an App, but having speech assistance integrated into your App is a huge deal for those users who are visually impaired.
|
|
6
6
|
|
|
7
7
|
### Integrated with the router
|
|
8
8
|
|
|
@@ -24,7 +24,7 @@ const routes = [
|
|
|
24
24
|
|
|
25
25
|
## Custom announcement messages
|
|
26
26
|
|
|
27
|
-
Furthermore it's possible to speak out custom messages anywhere in your App logic, for example when a component receives focus, as a reaction to user input, or to announce error messages when
|
|
27
|
+
Furthermore, it's possible to speak out custom messages anywhere in your App logic, for example when a component receives focus, as a reaction to user input, or to announce error messages when a remote API call
|
|
28
28
|
fails.
|
|
29
29
|
|
|
30
30
|
Each component in Blits has a `this.$announcer.speak()` available, which accepts `string` of a message to be announced.
|
package/docs/sidebar.json
CHANGED
|
@@ -35,7 +35,7 @@ Blits offers an easy and intuitive way to apply transitions. All you need to do
|
|
|
35
35
|
```js
|
|
36
36
|
export default Blits('Gold', {
|
|
37
37
|
template: `
|
|
38
|
-
<Element color="gold" w="100" h="100" :x.
|
|
38
|
+
<Element color="gold" w="100" h="100" :x.transition="$x" :y.transition=:"$y" />
|
|
39
39
|
`,
|
|
40
40
|
state() {
|
|
41
41
|
return {
|
|
@@ -51,7 +51,7 @@ export default Blits('Gold', {
|
|
|
51
51
|
},
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
If we try out the modified example above, you'll notice how difference adding a simple transition makes.
|
|
54
|
+
If we try out the modified example above, you'll notice how much difference adding a simple transition makes.
|
|
55
55
|
|
|
56
56
|
When the `.transition`-modifier is added to a reactive attribute, a default `ease-in` transition with a duration of `300ms` is applied
|
|
57
57
|
|
|
@@ -61,19 +61,19 @@ While the default transition will look pretty good out of the box and is great f
|
|
|
61
61
|
|
|
62
62
|
Blits gives you full control over your transitions, with a simple to use format, right inside your template.
|
|
63
63
|
|
|
64
|
-
Instead of referencing your component's state variable directly, you can also supply an
|
|
64
|
+
Instead of referencing your component's state variable directly, you can also supply an inline `object literal`` in the attribute with a `.transition`-modifier. This will allow you to pass a number of options to change the way the transition will work.
|
|
65
65
|
|
|
66
66
|
The transition object must have a `value` key, which references the state variable (or prop or computed property) that triggers the transition.
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Furthermore, you can specify:
|
|
69
69
|
|
|
70
70
|
- `duration` - the duration of the transition in `ms`
|
|
71
71
|
- `delay` - the time in `ms` after which the transition should initiate
|
|
72
|
-
- `easing` - the easing function of the transition. Can be one of the
|
|
72
|
+
- `easing` - the easing function of the transition. Can be one of the default easing options listed below, or a custom `cubic-bezier` definition (i.e. `cubic-bezier(0,1.35,.99,-0.07)`).
|
|
73
73
|
|
|
74
74
|
```xml
|
|
75
75
|
<Element color="gold" w="100" h="100"
|
|
76
|
-
:x.
|
|
76
|
+
:x.transition="{value: $x, duration: 300, easing: 'ease-in-back', delay: 400}"
|
|
77
77
|
:y.transition=:"{value: $x, duration: 300, easing: 'cubic-bezier(1,-0.64,0.39,1.44)'}">
|
|
78
78
|
</Element>
|
|
79
79
|
```
|
|
@@ -82,7 +82,7 @@ Besides a reference to the `value`, you can also use dynamic values for the othe
|
|
|
82
82
|
|
|
83
83
|
```xml
|
|
84
84
|
<Element color="gold" w="100" h="100"
|
|
85
|
-
:x.
|
|
85
|
+
:x.transition="{value: $x, duration: $dynamicDuration, delay: $dynamicDelay}">
|
|
86
86
|
</Element>
|
|
87
87
|
```
|
|
88
88
|
|
|
@@ -108,15 +108,15 @@ Besides a reference to the `value`, you can also use dynamic values for the othe
|
|
|
108
108
|
|
|
109
109
|
Sometimes you may want to perform an action when a transition ends or when it starts.
|
|
110
110
|
|
|
111
|
-
You can easily hook into these
|
|
111
|
+
You can easily hook into these transition events by adding a `start` and `end` key to the transition object. Both values should be a function (or a reference to a `method` on your component).
|
|
112
112
|
|
|
113
|
-
The `start` function will be called when the transition actually starts (after a possible specified delay) and the `end` function is called as soon as the
|
|
113
|
+
The `start` function will be called when the transition actually starts (after a possible specified delay) and the `end` function is called as soon as the transition is finished.
|
|
114
114
|
|
|
115
115
|
```js
|
|
116
116
|
export default Blits('Gold', {
|
|
117
117
|
template: `
|
|
118
118
|
<Element color="gold" w="100" h="100"
|
|
119
|
-
:x.
|
|
119
|
+
:x.transition="{value: $x, start: $transitionBegin, end: $transitionEnd}"
|
|
120
120
|
/>
|
|
121
121
|
`,
|
|
122
122
|
///
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightningjs/blits",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "Blits: The Lightning 3 App Development Framework",
|
|
5
5
|
"bin": "bin/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"tape": "^5.5.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@lightningjs/renderer": "^0.8.
|
|
48
|
+
"@lightningjs/renderer": "^0.8.3",
|
|
49
49
|
"@lightningjs/vite-plugin-import-chunk-url": "^0.3.0",
|
|
50
50
|
"execa": "^8.0.1",
|
|
51
51
|
"kolorist": "^1.8.0",
|
package/src/component.js
CHANGED
|
@@ -68,7 +68,7 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
68
68
|
if (config.methods) setupMethods(component, config.methods)
|
|
69
69
|
|
|
70
70
|
// setup state
|
|
71
|
-
|
|
71
|
+
setupState(component, config.state)
|
|
72
72
|
|
|
73
73
|
// setup computed
|
|
74
74
|
if (config.computed) setupComputed(component, config.computed)
|
package/src/components/Circle.js
CHANGED
|
@@ -19,35 +19,38 @@ 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 = []
|
|
22
|
+
/* eslint-disable no-unused-vars */
|
|
23
|
+
code: {
|
|
24
|
+
render: function anonymous(parent, component, context) {
|
|
25
|
+
const elms = []
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
if (!elms[0]) {
|
|
28
|
+
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
29
|
+
}
|
|
30
|
+
const elementConfig0 = {}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return elms
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
if (!elms[0].nodeId) {
|
|
33
|
+
elms[0].populate(elementConfig0)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return elms
|
|
37
|
+
},
|
|
38
|
+
effects: [
|
|
39
|
+
function anonymous(component, elms, context) {
|
|
40
|
+
elms[0].set('color', component.color)
|
|
41
|
+
},
|
|
42
|
+
function anonymous(component, elms, context) {
|
|
43
|
+
elms[0].set('w', component.size)
|
|
44
|
+
},
|
|
45
|
+
function anonymous(component, elms, context) {
|
|
46
|
+
elms[0].set('h', component.size)
|
|
47
|
+
},
|
|
48
|
+
function anonymous(component, elms, context) {
|
|
49
|
+
elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
context: {},
|
|
53
|
+
},
|
|
51
54
|
props: [{ key: 'size', default: 40 }, 'color'],
|
|
52
55
|
computed: {
|
|
53
56
|
radius() {
|
|
@@ -19,35 +19,9 @@ import Component from '../component.js'
|
|
|
19
19
|
|
|
20
20
|
export default () =>
|
|
21
21
|
Component('Circle', {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const elms = []
|
|
26
|
-
|
|
27
|
-
if(!elms[0]) {
|
|
28
|
-
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
29
|
-
}
|
|
30
|
-
const elementConfig0 = {}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if(!elms[0].nodeId) {
|
|
34
|
-
elms[0].populate(elementConfig0)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return elms
|
|
38
|
-
}, effects: [function anonymous(component,elms,context
|
|
39
|
-
) {
|
|
40
|
-
elms[0].set('color', component.color)
|
|
41
|
-
},function anonymous(component,elms,context
|
|
42
|
-
) {
|
|
43
|
-
elms[0].set('w', component.size)
|
|
44
|
-
},function anonymous(component,elms,context
|
|
45
|
-
) {
|
|
46
|
-
elms[0].set('h', component.size)
|
|
47
|
-
},function anonymous(component,elms,context
|
|
48
|
-
) {
|
|
49
|
-
elms[0].set('effects', [component.shader('radius', {radius: component.radius})])
|
|
50
|
-
}], context: {}},
|
|
22
|
+
template: `
|
|
23
|
+
<Element :color="$color" :w="$size" :h="$size" :effects="[$shader('radius', {radius: $radius})]"></Element>
|
|
24
|
+
`,
|
|
51
25
|
props: [{ key: 'size', default: 40 }, 'color'],
|
|
52
26
|
computed: {
|
|
53
27
|
radius() {
|