@lightningjs/blits 1.8.1 → 1.8.3

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.8.3
4
+
5
+ _31 oct 2024_
6
+
7
+ - Exported TS interfaces and improved return type of before route hook
8
+ - Fixed test cases for codegenerator
9
+
10
+
11
+ ## v1.8.2
12
+
13
+ _30 oct 2024_
14
+
15
+ - Fixed edge case issue with array based props not triggering reactivity
16
+
17
+
3
18
  ## v1.8.1
4
19
 
5
20
  _29 oct 2024_
package/index.d.ts CHANGED
@@ -19,7 +19,7 @@ import {type ShaderEffect as RendererShaderEffect, type WebGlCoreShader} from '@
19
19
 
20
20
  declare module '@lightningjs/blits' {
21
21
 
22
- interface Hooks {
22
+ export interface Hooks {
23
23
  /**
24
24
  * Fires when the Component is being instantiated
25
25
  * At this moment child elements will not be available yet
@@ -77,7 +77,7 @@ declare module '@lightningjs/blits' {
77
77
  exit?: () => void;
78
78
  }
79
79
 
80
- interface Input {
80
+ export interface Input {
81
81
  [key: string]: (event: KeyboardEvent) => void | undefined,
82
82
  /**
83
83
  * Catch all input function
@@ -88,7 +88,7 @@ declare module '@lightningjs/blits' {
88
88
  any?: (event: KeyboardEvent) => void
89
89
  }
90
90
 
91
- interface Log {
91
+ export interface Log {
92
92
  /**
93
93
  * Log an info message
94
94
  */
@@ -109,16 +109,16 @@ declare module '@lightningjs/blits' {
109
109
 
110
110
 
111
111
 
112
- interface RouteData {
112
+ export interface RouteData {
113
113
  [key: string]: any
114
114
  }
115
115
 
116
116
  // todo: specify valid route options
117
- interface RouteOptions {
117
+ export interface RouteOptions {
118
118
  [key: string]: any
119
119
  }
120
120
 
121
- interface Router {
121
+ export interface Router {
122
122
  /**
123
123
  * Navigate to a different location
124
124
  *
@@ -148,7 +148,7 @@ declare module '@lightningjs/blits' {
148
148
 
149
149
  }
150
150
 
151
- type ComponentBase = {
151
+ export type ComponentBase = {
152
152
  /**
153
153
  * Listen to events emitted by other components
154
154
  */
@@ -246,7 +246,7 @@ declare module '@lightningjs/blits' {
246
246
  /**
247
247
  * Prop object
248
248
  */
249
- type PropObject = {
249
+ export type PropObject = {
250
250
  /**
251
251
  * Name of the prop
252
252
  */
@@ -274,7 +274,7 @@ declare module '@lightningjs/blits' {
274
274
  };
275
275
 
276
276
  // Props Array
277
- type Props = (string | PropObject)[];
277
+ export type Props = (string | PropObject)[];
278
278
 
279
279
  // Extract the prop names from the props array
280
280
  type ExtractPropNames<P extends Props> = {
@@ -282,11 +282,11 @@ declare module '@lightningjs/blits' {
282
282
  };
283
283
 
284
284
  // Update the PropsDefinition to handle props as strings or objects
285
- type PropsDefinition<P extends Props> = ExtractPropNames<P>;
285
+ export type PropsDefinition<P extends Props> = ExtractPropNames<P>;
286
286
 
287
- type ComponentContext<P extends Props, S, M, C> = ThisType<PropsDefinition<P> & S & M & C & ComponentBase>
287
+ export type ComponentContext<P extends Props, S, M, C> = ThisType<PropsDefinition<P> & S & M & C & ComponentBase>
288
288
 
289
- interface ComponentConfig<P extends Props, S, M, C, W> {
289
+ export interface ComponentConfig<P extends Props, S, M, C, W> {
290
290
  components?: {
291
291
  [key: string]: ComponentFactory,
292
292
  },
@@ -365,7 +365,7 @@ declare module '@lightningjs/blits' {
365
365
  watch?: W & ComponentContext<P, S, M, C>
366
366
  }
367
367
 
368
- interface ApplicationConfig<P extends Props, S, M, C, W> extends ComponentConfig<P, S, M, C, W> {
368
+ export interface ApplicationConfig<P extends Props, S, M, C, W> extends ComponentConfig<P, S, M, C, W> {
369
369
  /**
370
370
  * Routes definition
371
371
  *
@@ -383,7 +383,7 @@ declare module '@lightningjs/blits' {
383
383
  }
384
384
 
385
385
 
386
- interface Transition {
386
+ export interface Transition {
387
387
  /**
388
388
  * Name of the prop to transition (i.e. 'x', 'y', 'alpha', 'color')
389
389
  */
@@ -406,7 +406,7 @@ declare module '@lightningjs/blits' {
406
406
  delay?: number
407
407
  }
408
408
 
409
- interface Before {
409
+ export interface Before {
410
410
  /**
411
411
  * Name of the prop to set before the transition starts
412
412
  */
@@ -417,7 +417,7 @@ declare module '@lightningjs/blits' {
417
417
  value: any,
418
418
  }
419
419
 
420
- interface RouteTransition {
420
+ export interface RouteTransition {
421
421
  /**
422
422
  * Setting or Array of Settings before new view enters into the router view
423
423
  */
@@ -432,9 +432,9 @@ declare module '@lightningjs/blits' {
432
432
  out: Transition | Transition[],
433
433
  }
434
434
 
435
- type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
435
+ export type RouteTransitionFunction = (previousRoute: Route, currentRoute: Route) => RequireAtLeastOne<RouteTransition>
436
436
 
437
- interface RouteAnnounce {
437
+ export interface RouteAnnounce {
438
438
  /**
439
439
  * Message to be announced
440
440
  */
@@ -447,15 +447,15 @@ declare module '@lightningjs/blits' {
447
447
  politeness?: 'off' | 'polite' | 'assertive'
448
448
  }
449
449
 
450
- type RequireAtLeastOne<T> = {
450
+ export type RequireAtLeastOne<T> = {
451
451
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>
452
452
  }[keyof T]
453
453
 
454
- interface RouteHooks {
455
- before?: (to: Route, from: Route) => string | Route;
454
+ export interface RouteHooks {
455
+ before?: (to: Route, from: Route) => string | Route | Promise<string | Route>;
456
456
  }
457
457
 
458
- type Route = {
458
+ export type Route = {
459
459
  /**
460
460
  * URI path for the route
461
461
  */
@@ -575,7 +575,7 @@ declare module '@lightningjs/blits' {
575
575
  * Launcher function that sets up the Lightning renderer and instantiates
576
576
  * the Blits App
577
577
  */
578
- interface Settings {
578
+ export interface Settings {
579
579
  /**
580
580
  * Width of the Application
581
581
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -25,6 +25,7 @@ export default () =>
25
25
  const elms = []
26
26
  let componentType
27
27
  const rootComponent = component
28
+ let propData
28
29
  const elementConfig0 = {}
29
30
 
30
31
  elms[0] = this.element({ parent: parent || 'root' }, component)
@@ -27,6 +27,7 @@ export default () =>
27
27
  const elms = []
28
28
  let componentType
29
29
  const rootComponent = component
30
+ let propData
30
31
  const elementConfig0 = {}
31
32
 
32
33
  elms[0] = this.element({ parent: parent || 'root' }, component)
@@ -142,7 +143,11 @@ export default () =>
142
143
  props7['w'] = 20
143
144
  props7['map'] = component.sprite
144
145
 
145
- props7['frame'] = component.fps[0]
146
+ propData = component.fps[0]
147
+ if (Array.isArray(propData) === true) {
148
+ propData = getRaw(propData).slice(0)
149
+ }
150
+ props7['frame'] = propData
146
151
 
147
152
  componentType = props7['is'] || 'Sprite'
148
153
 
@@ -200,7 +205,11 @@ export default () =>
200
205
  props9['w'] = 20
201
206
  props9['map'] = component.sprite
202
207
 
203
- props9['frame'] = component.fps[1]
208
+ propData = component.fps[1]
209
+ if (Array.isArray(propData) === true) {
210
+ propData = getRaw(propData).slice(0)
211
+ }
212
+ props9['frame'] = propData
204
213
 
205
214
  componentType = props9['is'] || 'Sprite'
206
215
 
@@ -258,7 +267,11 @@ export default () =>
258
267
  props11['w'] = 20
259
268
  props11['map'] = component.sprite
260
269
 
261
- props11['frame'] = component.fps[2]
270
+ propData = component.fps[2]
271
+ if (Array.isArray(propData) === true) {
272
+ propData = getRaw(propData).slice(0)
273
+ }
274
+ props11['frame'] = propData
262
275
 
263
276
  componentType = props11['is'] || 'Sprite'
264
277
 
@@ -390,7 +403,11 @@ export default () =>
390
403
  props17['w'] = 20
391
404
  props17['map'] = component.sprite
392
405
 
393
- props17['frame'] = component.avgFps[0]
406
+ propData = component.avgFps[0]
407
+ if (Array.isArray(propData) === true) {
408
+ propData = getRaw(propData).slice(0)
409
+ }
410
+ props17['frame'] = propData
394
411
 
395
412
  componentType = props17['is'] || 'Sprite'
396
413
 
@@ -448,7 +465,11 @@ export default () =>
448
465
  props19['w'] = 20
449
466
  props19['map'] = component.sprite
450
467
 
451
- props19['frame'] = component.avgFps[1]
468
+ propData = component.avgFps[1]
469
+ if (Array.isArray(propData) === true) {
470
+ propData = getRaw(propData).slice(0)
471
+ }
472
+ props19['frame'] = propData
452
473
 
453
474
  componentType = props19['is'] || 'Sprite'
454
475
 
@@ -506,7 +527,11 @@ export default () =>
506
527
  props21['w'] = 20
507
528
  props21['map'] = component.sprite
508
529
 
509
- props21['frame'] = component.avgFps[2]
530
+ propData = component.avgFps[2]
531
+ if (Array.isArray(propData) === true) {
532
+ propData = getRaw(propData).slice(0)
533
+ }
534
+ props21['frame'] = propData
510
535
 
511
536
  componentType = props21['is'] || 'Sprite'
512
537
 
@@ -639,7 +664,11 @@ export default () =>
639
664
  props27['w'] = 20
640
665
  props27['map'] = component.sprite
641
666
 
642
- props27['frame'] = component.minFps[0]
667
+ propData = component.minFps[0]
668
+ if (Array.isArray(propData) === true) {
669
+ propData = getRaw(propData).slice(0)
670
+ }
671
+ props27['frame'] = propData
643
672
 
644
673
  componentType = props27['is'] || 'Sprite'
645
674
 
@@ -697,7 +726,11 @@ export default () =>
697
726
  props29['w'] = 20
698
727
  props29['map'] = component.sprite
699
728
 
700
- props29['frame'] = component.minFps[1]
729
+ propData = component.minFps[1]
730
+ if (Array.isArray(propData) === true) {
731
+ propData = getRaw(propData).slice(0)
732
+ }
733
+ props29['frame'] = propData
701
734
 
702
735
  componentType = props29['is'] || 'Sprite'
703
736
 
@@ -755,7 +788,11 @@ export default () =>
755
788
  props31['w'] = 20
756
789
  props31['map'] = component.sprite
757
790
 
758
- props31['frame'] = component.minFps[2]
791
+ propData = component.minFps[2]
792
+ if (Array.isArray(propData) === true) {
793
+ propData = getRaw(propData).slice(0)
794
+ }
795
+ props31['frame'] = propData
759
796
 
760
797
  componentType = props31['is'] || 'Sprite'
761
798
 
@@ -886,7 +923,11 @@ export default () =>
886
923
  props37['w'] = 20
887
924
  props37['map'] = component.sprite
888
925
 
889
- props37['frame'] = component.maxFps[0]
926
+ propData = component.maxFps[0]
927
+ if (Array.isArray(propData) === true) {
928
+ propData = getRaw(propData).slice(0)
929
+ }
930
+ props37['frame'] = propData
890
931
 
891
932
  componentType = props37['is'] || 'Sprite'
892
933
 
@@ -944,7 +985,11 @@ export default () =>
944
985
  props39['w'] = 20
945
986
  props39['map'] = component.sprite
946
987
 
947
- props39['frame'] = component.maxFps[1]
988
+ propData = component.maxFps[1]
989
+ if (Array.isArray(propData) === true) {
990
+ propData = getRaw(propData).slice(0)
991
+ }
992
+ props39['frame'] = propData
948
993
 
949
994
  componentType = props39['is'] || 'Sprite'
950
995
 
@@ -1002,7 +1047,11 @@ export default () =>
1002
1047
  props41['w'] = 20
1003
1048
  props41['map'] = component.sprite
1004
1049
 
1005
- props41['frame'] = component.maxFps[2]
1050
+ propData = component.maxFps[2]
1051
+ if (Array.isArray(propData) === true) {
1052
+ propData = getRaw(propData).slice(0)
1053
+ }
1054
+ props41['frame'] = propData
1006
1055
 
1007
1056
  componentType = props41['is'] || 'Sprite'
1008
1057
 
@@ -8,6 +8,7 @@ export default () => {
8
8
  const elms = []
9
9
  let componentType
10
10
  const rootComponent = component
11
+ let propData
11
12
  const elementConfig0 = {}
12
13
 
13
14
  elms[0] = this.element({ parent: parent || 'root' }, component)
@@ -28,6 +28,7 @@ export default () =>
28
28
  const elms = []
29
29
  let componentType
30
30
  const rootComponent = component
31
+ let propData
31
32
  const elementConfig0 = {}
32
33
 
33
34
  elms[0] = this.element({ parent: parent || 'root' }, component)
@@ -27,6 +27,7 @@ export default () =>
27
27
  const elms = []
28
28
  let componentType
29
29
  const rootComponent = component
30
+ let propData
30
31
  const elementConfig0 = {}
31
32
 
32
33
  elms[0] = this.element({ parent: parent || 'root' }, component)
@@ -19,7 +19,12 @@ let counter
19
19
 
20
20
  export default function (templateObject = { children: [] }) {
21
21
  const ctx = {
22
- renderCode: ['const elms = []', 'let componentType', 'const rootComponent = component'],
22
+ renderCode: [
23
+ 'const elms = []',
24
+ 'let componentType',
25
+ 'const rootComponent = component',
26
+ 'let propData',
27
+ ],
23
28
  effectsCode: [],
24
29
  context: { props: [], components: this.components },
25
30
  }
@@ -213,10 +218,11 @@ const generateComponentCode = function (
213
218
  options.component
214
219
  )}`)
215
220
  renderCode.push(`
216
- props${counter}['${key.substring(1)}']= ${interpolate(
217
- templateObject[key],
218
- options.component
219
- )}`)
221
+ propData = ${interpolate(templateObject[key], options.component)}
222
+ if (Array.isArray(propData) === true) {
223
+ propData = getRaw(propData).slice(0)
224
+ }
225
+ props${counter}['${key.substring(1)}'] = propData`)
220
226
  } else {
221
227
  renderCode.push(
222
228
  `props${counter}['${key}'] = ${cast(templateObject[key], key, options.component)}`