@lightningjs/blits 1.32.1-rc.0 → 1.33.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ _08 Jul 2025_
4
+
5
+ ## v1.33.0
6
+
7
+ - Added dereferencing of previousFocus pointer to ensure memory cleanup
8
+ - Improved cleanup of components (via explicit dereference of closure scope)
9
+ - Optimized time function in logger
10
+ - Optimized initial registration of routes
11
+ - Added `maxFPS` launch setting
12
+
13
+ _04 Jul 2025_
14
+
15
+ ## v1.32.1
16
+
17
+ - Fixed issue with router data overwriting the orginal route definition
18
+
3
19
  _02 Jul 2025_
4
20
 
5
21
  ## v1.32.0
package/index.d.ts CHANGED
@@ -1015,6 +1015,15 @@ declare module '@lightningjs/blits' {
1015
1015
  * @default false
1016
1016
  */
1017
1017
  announcer?: boolean
1018
+ /**
1019
+ * Maximum FPS at which the App will be rendered
1020
+ *
1021
+ * Lowering the maximum FPS value can improve the overall experience on lower end devices.
1022
+ * Targetting a lower FPS may gives the CPU more time to construct each frame leading to a smoother rendering.
1023
+ *
1024
+ * Defaults to `0` which means no maximum
1025
+ */
1026
+ maxFPS?: number
1018
1027
  }
1019
1028
 
1020
1029
  interface State {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.32.1-rc.0",
3
+ "version": "1.33.0",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -40,6 +40,7 @@ export default {
40
40
  * @this {import('../../component').BlitsComponent}
41
41
  */
42
42
  value: function (e) {
43
+ if (this.eol === true) return
43
44
  this[symbols.state].hasFocus = true
44
45
  Focus.set(this, e)
45
46
  },
@@ -103,11 +104,15 @@ export default {
103
104
  delete this.componentId
104
105
  delete this[symbols.id]
105
106
  delete this.ref
107
+ delete this[symbols.state].hasFocus
106
108
 
107
109
  this[symbols.holder].destroy()
108
110
  this[symbols.holder] = null
109
111
  delete this[symbols.holder]
110
112
 
113
+ this[symbols.cleanup]()
114
+ delete this[symbols.cleanup]
115
+
111
116
  Log.debug(`Destroyed component ${this.componentId}`)
112
117
  },
113
118
  writable: false,
@@ -24,19 +24,16 @@ export default (component, data) => {
24
24
  routes = data.routes
25
25
  }
26
26
  component[symbols.routes] = []
27
- Object.keys(routes).forEach((key) => {
28
- // todo: validate routes[key] for expected format etc.
29
- component[symbols.routes][key] = {
30
- ...routes[key],
27
+
28
+ const l = routes.length
29
+ for (let i = 0; i < l; i++) {
30
+ component[symbols.routes][i] = routes[i]
31
+ // merge default route options with route specific options
32
+ component[symbols.routes][i].options = {
31
33
  ...{
32
- // merge default route options with route specific options
33
- options: {
34
- ...{
35
- inHistory: true,
36
- },
37
- ...routes[key].options,
38
- },
34
+ inHistory: true,
39
35
  },
36
+ ...routes[i].options,
40
37
  }
41
- })
38
+ }
42
39
  }
package/src/component.js CHANGED
@@ -243,16 +243,18 @@ const Component = (name = required('name'), config = required('config')) => {
243
243
 
244
244
  // execute the render code that constructs the initial state of the component
245
245
  // and store the children result (a flat map of elements and components)
246
- this[symbols.children] =
247
- config.code.render.apply(stage, [
248
- parentEl,
249
- this,
250
- config,
251
- globalComponents,
252
- effect,
253
- getRaw,
254
- Log,
255
- ]) || []
246
+ const { elms, cleanup } = config.code.render.apply(stage, [
247
+ parentEl,
248
+ this,
249
+ config,
250
+ globalComponents,
251
+ effect,
252
+ getRaw,
253
+ Log,
254
+ ]) || { elms: [], cleanup: () => {} }
255
+
256
+ this[symbols.children] = elms
257
+ this[symbols.cleanup] = cleanup
256
258
 
257
259
  // create a reference to the wrapper element of the component (i.e. the root Element of the component)
258
260
  this[symbols.wrapper] = this[symbols.children][0]
@@ -23,44 +23,65 @@ export default () =>
23
23
  code: {
24
24
  render: function anonymous(parent, component, context, components, effect, getRaw, Log) {
25
25
  const elms = []
26
+ const elementConfigs = []
27
+ const forloops = []
28
+ const props = []
29
+ const created = []
30
+ const skips = []
26
31
  let componentType
27
- const rootComponent = component
32
+ let rootComponent = component
28
33
  let propData
29
34
  let slotComponent
30
35
  let inSlot = false
31
36
  let slotChildCounter = 0
32
- const elementConfig0 = {}
37
+ let cmps = []
38
+ elementConfigs[0] = {}
33
39
 
34
40
  elms[0] = this.element(
35
41
  { parent: parent || 'root' },
36
42
  inSlot === true ? slotComponent : component
37
43
  )
38
44
 
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)
45
+ elementConfigs[0]['color'] = component.color
46
+ elementConfigs[0]['w'] = component.size
47
+ elementConfigs[0]['h'] = component.size
48
+ elementConfigs[0]['effects'] = [component.shader('radius', { radius: component.radius })]
49
+ elms[0].populate(elementConfigs[0])
44
50
 
45
51
  if (inSlot === true) {
46
52
  slotChildCounter -= 1
47
53
  }
48
54
 
49
- return elms
55
+ return {
56
+ elms,
57
+ cleanup: () => {
58
+ rootComponent = null
59
+ propData = null
60
+ slotComponent = null
61
+ component = null
62
+ parent = null
63
+ cmps.length = 0
64
+ elms.length = 0
65
+ components.length = 0
66
+ elementConfigs.length = 0
67
+ forloops.length = 0
68
+ props.length = 0
69
+ skips.length = 0
70
+ },
71
+ }
50
72
  },
51
73
  effects: [
52
74
  function anonymous(component, elms, context, components, rootComponent, effect) {
53
- if (elms[0] !== undefined) elms[0].set('color', component.color)
75
+ elms[0].set('color', component.color)
54
76
  },
55
77
  function anonymous(component, elms, context, components, rootComponent, effect) {
56
- if (elms[0] !== undefined) elms[0].set('w', component.size)
78
+ elms[0].set('w', component.size)
57
79
  },
58
80
  function anonymous(component, elms, context, components, rootComponent, effect) {
59
- if (elms[0] !== undefined) elms[0].set('h', component.size)
81
+ elms[0].set('h', component.size)
60
82
  },
61
83
  function anonymous(component, elms, context, components, rootComponent, effect) {
62
- if (elms[0] !== undefined)
63
- elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
84
+ elms[0].set('effects', [component.shader('radius', { radius: component.radius })])
64
85
  },
65
86
  ],
66
87
  context: {},