@lightningjs/blits 1.2.0 → 1.3.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/NOTICE +9 -0
  3. package/docs/built-in/directives.md +4 -6
  4. package/docs/built-in/for-loop.md +6 -8
  5. package/docs/components/component_state.md +3 -5
  6. package/docs/components/computed_properties.md +3 -5
  7. package/docs/components/lifecycle_events.md +2 -4
  8. package/docs/components/methods.md +1 -3
  9. package/docs/components/props.md +3 -5
  10. package/docs/components/user_input.md +6 -8
  11. package/docs/components/utilities.md +1 -2
  12. package/docs/components/watchers.md +2 -4
  13. package/docs/essentials/application_root.md +1 -3
  14. package/docs/essentials/components.md +2 -4
  15. package/docs/essentials/displaying_images.md +4 -6
  16. package/docs/essentials/displaying_text.md +4 -6
  17. package/docs/essentials/element_attributes.md +10 -12
  18. package/docs/essentials/template_syntax.md +5 -7
  19. package/docs/getting_started/file_structure.md +9 -11
  20. package/docs/getting_started/getting_started.md +5 -7
  21. package/docs/plugins/language.md +8 -10
  22. package/docs/plugins/text-to-speech-announcer.md +2 -4
  23. package/docs/transitions_animations/transitions.md +5 -7
  24. package/package.json +1 -1
  25. package/src/component/base/methods.js +1 -2
  26. package/src/component/setup/state.js +9 -13
  27. package/src/component.js +4 -9
  28. package/src/components/FPScounter.js +56 -12
  29. package/src/engines/L3/element.js +55 -65
  30. package/src/lib/codegenerator/generator.js +91 -24
  31. package/src/lib/codegenerator/generator.test.js +132 -0
  32. package/src/lib/colors/colors.js +6 -7
  33. package/src/lib/reactivity/reactive.js +3 -5
  34. package/src/lib/templateparser/parser.js +1 -1
@@ -1,12 +1,10 @@
1
- # Blits - Lightning 3 App Development Framework
2
-
3
- ## Language plugin
1
+ # Language plugin
4
2
 
5
3
  Blits comes with a built-in Language plugin, that can be used to add internationalization (i18n) to your App.
6
4
 
7
5
  The Blits Language plugin is a simple and lightweight implementation, closely modeled after the tried and tested Language plugin in the Lightning-SDK (for Lightning 2). It is designed to provide a flexible and easy way of translating texts to multiple languages, in a performant way.
8
6
 
9
- ### Registering the plugin
7
+ ## Registering the plugin
10
8
 
11
9
  While the Language plugin is provided in the core Blits package, it's an _optional_ plugin that needs to be registered before you're able to use it. As such the Language plugin is _tree-shakable_, i.e. for Apps that don't have a need for translation functionality, the Language plugin will not be part of the final App bundle.
12
10
 
@@ -43,7 +41,7 @@ The Language plugin accepts an optional configuration object with 2 keys:
43
41
 
44
42
  After registration of the Language plugin, it will be availabe in each Blits Component as `this.$language`.
45
43
 
46
- ### Translations file
44
+ ## Translations file
47
45
 
48
46
  The most common way of defining a set of translations, is to use a dedicated JSON file, modeled after
49
47
  the following format:
@@ -80,7 +78,7 @@ When the JSON file is specified in the Plugin registration method, the language
80
78
 
81
79
  In case you want to load the file with translations manually, you can use the `this.$language.load()`-method anywhere in a Component and pass in the path to the JSON file as the first argument.
82
80
 
83
- ### Defining translations manualy
81
+ ## Defining translations manualy
84
82
 
85
83
  As an alternative to a JSON file with translations, you can also define translations directly via an object, using the `translations()`-method.
86
84
 
@@ -106,7 +104,7 @@ Blits.Component('MyComponent', {
106
104
  })
107
105
  ```
108
106
 
109
- ### Setting the language
107
+ ## Setting the language
110
108
 
111
109
  In order to set (or change) the current language, the `this.$language.set()`-method can be used, passing in the new language code (matching one of the languages defined in the translations).
112
110
 
@@ -121,11 +119,11 @@ Blits.Component('MyComponent', {
121
119
  })
122
120
  ```
123
121
 
124
- ### Getting the current language
122
+ ## Getting the current language
125
123
 
126
124
  The current language can be retrieved via the `this.$language.get()` method. It will return the currently set language code.
127
125
 
128
- ### Translating
126
+ ## Translating
129
127
 
130
128
  The most important functionality in the Language plugin is translating. The Language plugin exposes a `translate()` method that takes as string to translate as it's first argument. It will return the translated value in the currently set language. If either the language or the string to translate can't be found, it will return the inputed string.
131
129
 
@@ -153,7 +151,7 @@ to refer to the Component scope, as with any other state variable or computed pr
153
151
  The second `$`-sign is needed, since the Language plugin itself is prefixed with a dollar sign on the Component scope as well (i.e `this.$language`).
154
152
 
155
153
 
156
- #### Dynamic replacements
154
+ ### Dynamic replacements
157
155
 
158
156
  The `tranlate()`-method also supports dynamic replacements. This allows you to specify variables inside your translation string, and replace them with dynamic values passed into the `translate()`-method.
159
157
 
@@ -1,10 +1,8 @@
1
- # Blits - Lightning 3 App Development Framework
2
-
3
- ## Text-to-Speech / Announcer
1
+ # Text-to-Speech / Announcer
4
2
 
5
3
  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
4
 
7
- ### Integrated with the router
5
+ ## Integrated with the router
8
6
 
9
7
  The Announcer in Blits is directly integrated with the router functionality. This means that through simple configuration, a descriptive message can be announced, when navigating from page to page, without the need for adding extra custom code.
10
8
 
@@ -1,6 +1,4 @@
1
- # Blits - Lightning 3 App Development Framework
2
-
3
- ## Transitions
1
+ # Transitions
4
2
 
5
3
  So far we have explored how to create components and draw elements on the screen. But everything has
6
4
  been rather static so far.
@@ -28,7 +26,7 @@ export default Blits('Gold', {
28
26
 
29
27
  Using _transitions_ we really make our App come alive.
30
28
 
31
- ### Applying a transition
29
+ ## Applying a transition
32
30
 
33
31
  Blits offers an easy and intuitive way to apply transitions. All you need to do is add the `.transition` modifier to a reactive attribute, and now whenever you change the value referenced in the attribute, it will automatically _smooth_ into the new value.
34
32
 
@@ -55,7 +53,7 @@ If we try out the modified example above, you'll notice how much difference addi
55
53
 
56
54
  When the `.transition`-modifier is added to a reactive attribute, a default `ease-in` transition with a duration of `300ms` is applied
57
55
 
58
- ### Customizing transitions
56
+ ## Customizing transitions
59
57
 
60
58
  While the default transition will look pretty good out of the box and is great for quickly improving the look of your App, you may want to customize specific transitions.
61
59
 
@@ -86,7 +84,7 @@ Besides a reference to the `value`, you can also use dynamic values for the othe
86
84
  </Element>
87
85
  ```
88
86
 
89
- #### Available easing functions
87
+ ### Available easing functions
90
88
 
91
89
  - `ease-in`
92
90
  - `ease-out`
@@ -104,7 +102,7 @@ Besides a reference to the `value`, you can also use dynamic values for the othe
104
102
  - `ease-out-back`
105
103
  - `ease-in-out-back`
106
104
 
107
- ### Listening to transition events
105
+ ## Listening to transition events
108
106
 
109
107
  Sometimes you may want to perform an action when a transition ends or when it starts.
110
108
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -95,9 +95,8 @@ export default {
95
95
  },
96
96
  shader: {
97
97
  value: function (type, args) {
98
- const target = type
99
98
  return {
100
- type: target,
99
+ type: type,
101
100
  props: args,
102
101
  }
103
102
  // const shaders = renderer.driver.stage.shManager.getRegisteredEffects()
@@ -37,18 +37,14 @@ export default (component, state = () => {}) => {
37
37
  Log.error(`State ${key} already exists as a method`)
38
38
  }
39
39
  component[symbols.stateKeys].push(key)
40
- try {
41
- Object.defineProperty(component, key, {
42
- get() {
43
- return this[symbols.state] && key in this[symbols.state] && this[symbols.state][key]
44
- },
45
- set(v) {
46
- if (this[symbols.state]) this[symbols.state][key] = v
47
- },
48
- // enumerable: true,
49
- })
50
- } catch (e) {
51
- Log.error(e)
52
- }
40
+ Object.defineProperty(component, key, {
41
+ get() {
42
+ return this[symbols.state][key]
43
+ },
44
+ set(v) {
45
+ this[symbols.state][key] = v
46
+ },
47
+ // enumerable: true,
48
+ })
53
49
  })
54
50
  }
package/src/component.js CHANGED
@@ -160,16 +160,11 @@ const Component = (name = required('name'), config = required('config')) => {
160
160
 
161
161
  // setup (and execute) all the generated side effects based on the
162
162
  // reactive bindings define in the template
163
- for (let i = 0; i < config.code.effects.length; i++) {
163
+ const effects = config.code.effects
164
+ for (let i = 0; i < effects.length; i++) {
165
+ // console.log(config.code.effects[i].toString())
164
166
  effect(() => {
165
- config.code.effects[i].apply(stage, [
166
- this,
167
- this[symbols.children],
168
- config,
169
- globalComponents,
170
- rootComponent,
171
- effect,
172
- ])
167
+ effects[i](this, this[symbols.children], config, globalComponents, rootComponent, effect)
173
168
  })
174
169
  }
175
170
 
@@ -60,9 +60,11 @@ export default () =>
60
60
  elementConfig3['map'] = component.sprite
61
61
  elementConfig3['frame'] = 'fps'
62
62
 
63
+ const skip3 = []
63
64
  if (typeof cmp3 !== 'undefined') {
64
65
  for (let key in cmp3.config.props) {
65
66
  delete elementConfig3[cmp3.config.props[key]]
67
+ skip3.push(cmp3.config.props[key])
66
68
  }
67
69
  }
68
70
 
@@ -120,9 +122,11 @@ export default () =>
120
122
  elementConfig6['map'] = component.sprite
121
123
  elementConfig6['frame'] = component.fps[0]
122
124
 
125
+ const skip6 = []
123
126
  if (typeof cmp6 !== 'undefined') {
124
127
  for (let key in cmp6.config.props) {
125
128
  delete elementConfig6[cmp6.config.props[key]]
129
+ skip6.push(cmp6.config.props[key])
126
130
  }
127
131
  }
128
132
 
@@ -172,9 +176,11 @@ export default () =>
172
176
  elementConfig8['map'] = component.sprite
173
177
  elementConfig8['frame'] = component.fps[1]
174
178
 
179
+ const skip8 = []
175
180
  if (typeof cmp8 !== 'undefined') {
176
181
  for (let key in cmp8.config.props) {
177
182
  delete elementConfig8[cmp8.config.props[key]]
183
+ skip8.push(cmp8.config.props[key])
178
184
  }
179
185
  }
180
186
 
@@ -224,9 +230,11 @@ export default () =>
224
230
  elementConfig10['map'] = component.sprite
225
231
  elementConfig10['frame'] = component.fps[2]
226
232
 
233
+ const skip10 = []
227
234
  if (typeof cmp10 !== 'undefined') {
228
235
  for (let key in cmp10.config.props) {
229
236
  delete elementConfig10[cmp10.config.props[key]]
237
+ skip10.push(cmp10.config.props[key])
230
238
  }
231
239
  }
232
240
 
@@ -284,9 +292,11 @@ export default () =>
284
292
  elementConfig13['map'] = component.sprite
285
293
  elementConfig13['frame'] = 'avg'
286
294
 
295
+ const skip13 = []
287
296
  if (typeof cmp13 !== 'undefined') {
288
297
  for (let key in cmp13.config.props) {
289
298
  delete elementConfig13[cmp13.config.props[key]]
299
+ skip13.push(cmp13.config.props[key])
290
300
  }
291
301
  }
292
302
 
@@ -345,9 +355,11 @@ export default () =>
345
355
  elementConfig16['map'] = component.sprite
346
356
  elementConfig16['frame'] = component.avgFps[0]
347
357
 
358
+ const skip16 = []
348
359
  if (typeof cmp16 !== 'undefined') {
349
360
  for (let key in cmp16.config.props) {
350
361
  delete elementConfig16[cmp16.config.props[key]]
362
+ skip16.push(cmp16.config.props[key])
351
363
  }
352
364
  }
353
365
 
@@ -397,9 +409,11 @@ export default () =>
397
409
  elementConfig18['map'] = component.sprite
398
410
  elementConfig18['frame'] = component.avgFps[1]
399
411
 
412
+ const skip18 = []
400
413
  if (typeof cmp18 !== 'undefined') {
401
414
  for (let key in cmp18.config.props) {
402
415
  delete elementConfig18[cmp18.config.props[key]]
416
+ skip18.push(cmp18.config.props[key])
403
417
  }
404
418
  }
405
419
 
@@ -449,9 +463,11 @@ export default () =>
449
463
  elementConfig20['map'] = component.sprite
450
464
  elementConfig20['frame'] = component.avgFps[2]
451
465
 
466
+ const skip20 = []
452
467
  if (typeof cmp20 !== 'undefined') {
453
468
  for (let key in cmp20.config.props) {
454
469
  delete elementConfig20[cmp20.config.props[key]]
470
+ skip20.push(cmp20.config.props[key])
455
471
  }
456
472
  }
457
473
 
@@ -510,9 +526,11 @@ export default () =>
510
526
  elementConfig23['map'] = component.sprite
511
527
  elementConfig23['frame'] = 'min'
512
528
 
529
+ const skip23 = []
513
530
  if (typeof cmp23 !== 'undefined') {
514
531
  for (let key in cmp23.config.props) {
515
532
  delete elementConfig23[cmp23.config.props[key]]
533
+ skip23.push(cmp23.config.props[key])
516
534
  }
517
535
  }
518
536
 
@@ -571,9 +589,11 @@ export default () =>
571
589
  elementConfig26['map'] = component.sprite
572
590
  elementConfig26['frame'] = component.minFps[0]
573
591
 
592
+ const skip26 = []
574
593
  if (typeof cmp26 !== 'undefined') {
575
594
  for (let key in cmp26.config.props) {
576
595
  delete elementConfig26[cmp26.config.props[key]]
596
+ skip26.push(cmp26.config.props[key])
577
597
  }
578
598
  }
579
599
 
@@ -623,9 +643,11 @@ export default () =>
623
643
  elementConfig28['map'] = component.sprite
624
644
  elementConfig28['frame'] = component.minFps[1]
625
645
 
646
+ const skip28 = []
626
647
  if (typeof cmp28 !== 'undefined') {
627
648
  for (let key in cmp28.config.props) {
628
649
  delete elementConfig28[cmp28.config.props[key]]
650
+ skip28.push(cmp28.config.props[key])
629
651
  }
630
652
  }
631
653
 
@@ -675,9 +697,11 @@ export default () =>
675
697
  elementConfig30['map'] = component.sprite
676
698
  elementConfig30['frame'] = component.minFps[2]
677
699
 
700
+ const skip30 = []
678
701
  if (typeof cmp30 !== 'undefined') {
679
702
  for (let key in cmp30.config.props) {
680
703
  delete elementConfig30[cmp30.config.props[key]]
704
+ skip30.push(cmp30.config.props[key])
681
705
  }
682
706
  }
683
707
 
@@ -735,9 +759,11 @@ export default () =>
735
759
  elementConfig33['map'] = component.sprite
736
760
  elementConfig33['frame'] = 'max'
737
761
 
762
+ const skip33 = []
738
763
  if (typeof cmp33 !== 'undefined') {
739
764
  for (let key in cmp33.config.props) {
740
765
  delete elementConfig33[cmp33.config.props[key]]
766
+ skip33.push(cmp33.config.props[key])
741
767
  }
742
768
  }
743
769
 
@@ -795,9 +821,11 @@ export default () =>
795
821
  elementConfig36['map'] = component.sprite
796
822
  elementConfig36['frame'] = component.maxFps[0]
797
823
 
824
+ const skip36 = []
798
825
  if (typeof cmp36 !== 'undefined') {
799
826
  for (let key in cmp36.config.props) {
800
827
  delete elementConfig36[cmp36.config.props[key]]
828
+ skip36.push(cmp36.config.props[key])
801
829
  }
802
830
  }
803
831
 
@@ -847,9 +875,11 @@ export default () =>
847
875
  elementConfig38['map'] = component.sprite
848
876
  elementConfig38['frame'] = component.maxFps[1]
849
877
 
878
+ const skip38 = []
850
879
  if (typeof cmp38 !== 'undefined') {
851
880
  for (let key in cmp38.config.props) {
852
881
  delete elementConfig38[cmp38.config.props[key]]
882
+ skip38.push(cmp38.config.props[key])
853
883
  }
854
884
  }
855
885
 
@@ -899,9 +929,11 @@ export default () =>
899
929
  elementConfig40['map'] = component.sprite
900
930
  elementConfig40['frame'] = component.maxFps[2]
901
931
 
932
+ const skip40 = []
902
933
  if (typeof cmp40 !== 'undefined') {
903
934
  for (let key in cmp40.config.props) {
904
935
  delete elementConfig40[cmp40.config.props[key]]
936
+ skip40.push(cmp40.config.props[key])
905
937
  }
906
938
  }
907
939
 
@@ -941,73 +973,85 @@ export default () =>
941
973
  },
942
974
  effects: [
943
975
  function anonymous(component, elms, context, components, rootComponent, effect) {
944
- elms[6].set('frame', component.fps[0])
976
+ if (typeof skip6 === 'undefined' || skip6.indexOf('frame') === -1)
977
+ elms[6].set('frame', component.fps[0])
945
978
  },
946
979
  function anonymous(component, elms, context, components, rootComponent, effect) {
947
980
  elms[7][Symbol.for('props')]['frame'] = component.fps[0]
948
981
  },
949
982
  function anonymous(component, elms, context, components, rootComponent, effect) {
950
- elms[8].set('frame', component.fps[1])
983
+ if (typeof skip8 === 'undefined' || skip8.indexOf('frame') === -1)
984
+ elms[8].set('frame', component.fps[1])
951
985
  },
952
986
  function anonymous(component, elms, context, components, rootComponent, effect) {
953
987
  elms[9][Symbol.for('props')]['frame'] = component.fps[1]
954
988
  },
955
989
  function anonymous(component, elms, context, components, rootComponent, effect) {
956
- elms[10].set('frame', component.fps[2])
990
+ if (typeof skip10 === 'undefined' || skip10.indexOf('frame') === -1)
991
+ elms[10].set('frame', component.fps[2])
957
992
  },
958
993
  function anonymous(component, elms, context, components, rootComponent, effect) {
959
994
  elms[11][Symbol.for('props')]['frame'] = component.fps[2]
960
995
  },
961
996
  function anonymous(component, elms, context, components, rootComponent, effect) {
962
- elms[16].set('frame', component.avgFps[0])
997
+ if (typeof skip16 === 'undefined' || skip16.indexOf('frame') === -1)
998
+ elms[16].set('frame', component.avgFps[0])
963
999
  },
964
1000
  function anonymous(component, elms, context, components, rootComponent, effect) {
965
1001
  elms[17][Symbol.for('props')]['frame'] = component.avgFps[0]
966
1002
  },
967
1003
  function anonymous(component, elms, context, components, rootComponent, effect) {
968
- elms[18].set('frame', component.avgFps[1])
1004
+ if (typeof skip18 === 'undefined' || skip18.indexOf('frame') === -1)
1005
+ elms[18].set('frame', component.avgFps[1])
969
1006
  },
970
1007
  function anonymous(component, elms, context, components, rootComponent, effect) {
971
1008
  elms[19][Symbol.for('props')]['frame'] = component.avgFps[1]
972
1009
  },
973
1010
  function anonymous(component, elms, context, components, rootComponent, effect) {
974
- elms[20].set('frame', component.avgFps[2])
1011
+ if (typeof skip20 === 'undefined' || skip20.indexOf('frame') === -1)
1012
+ elms[20].set('frame', component.avgFps[2])
975
1013
  },
976
1014
  function anonymous(component, elms, context, components, rootComponent, effect) {
977
1015
  elms[21][Symbol.for('props')]['frame'] = component.avgFps[2]
978
1016
  },
979
1017
  function anonymous(component, elms, context, components, rootComponent, effect) {
980
- elms[26].set('frame', component.minFps[0])
1018
+ if (typeof skip26 === 'undefined' || skip26.indexOf('frame') === -1)
1019
+ elms[26].set('frame', component.minFps[0])
981
1020
  },
982
1021
  function anonymous(component, elms, context, components, rootComponent, effect) {
983
1022
  elms[27][Symbol.for('props')]['frame'] = component.minFps[0]
984
1023
  },
985
1024
  function anonymous(component, elms, context, components, rootComponent, effect) {
986
- elms[28].set('frame', component.minFps[1])
1025
+ if (typeof skip28 === 'undefined' || skip28.indexOf('frame') === -1)
1026
+ elms[28].set('frame', component.minFps[1])
987
1027
  },
988
1028
  function anonymous(component, elms, context, components, rootComponent, effect) {
989
1029
  elms[29][Symbol.for('props')]['frame'] = component.minFps[1]
990
1030
  },
991
1031
  function anonymous(component, elms, context, components, rootComponent, effect) {
992
- elms[30].set('frame', component.minFps[2])
1032
+ if (typeof skip30 === 'undefined' || skip30.indexOf('frame') === -1)
1033
+ elms[30].set('frame', component.minFps[2])
993
1034
  },
994
1035
  function anonymous(component, elms, context, components, rootComponent, effect) {
995
1036
  elms[31][Symbol.for('props')]['frame'] = component.minFps[2]
996
1037
  },
997
1038
  function anonymous(component, elms, context, components, rootComponent, effect) {
998
- elms[36].set('frame', component.maxFps[0])
1039
+ if (typeof skip36 === 'undefined' || skip36.indexOf('frame') === -1)
1040
+ elms[36].set('frame', component.maxFps[0])
999
1041
  },
1000
1042
  function anonymous(component, elms, context, components, rootComponent, effect) {
1001
1043
  elms[37][Symbol.for('props')]['frame'] = component.maxFps[0]
1002
1044
  },
1003
1045
  function anonymous(component, elms, context, components, rootComponent, effect) {
1004
- elms[38].set('frame', component.maxFps[1])
1046
+ if (typeof skip38 === 'undefined' || skip38.indexOf('frame') === -1)
1047
+ elms[38].set('frame', component.maxFps[1])
1005
1048
  },
1006
1049
  function anonymous(component, elms, context, components, rootComponent, effect) {
1007
1050
  elms[39][Symbol.for('props')]['frame'] = component.maxFps[1]
1008
1051
  },
1009
1052
  function anonymous(component, elms, context, components, rootComponent, effect) {
1010
- elms[40].set('frame', component.maxFps[2])
1053
+ if (typeof skip40 === 'undefined' || skip40.indexOf('frame') === -1)
1054
+ elms[40].set('frame', component.maxFps[2])
1011
1055
  },
1012
1056
  function anonymous(component, elms, context, components, rootComponent, effect) {
1013
1057
  elms[41][Symbol.for('props')]['frame'] = component.maxFps[2]