@lightningjs/blits 1.29.4 → 1.29.5

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,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- _03 jun 2025_
3
+ _12 jun 2025_
4
+
5
+ ## v1.29.5
6
+
7
+ - Simplified timeout and interval cleanup
8
+ - Added explicit reset of component state upon destruction
9
+ - Fixed `exit` lifecycle hook
10
+
11
+ _06 jun 2025_
4
12
 
5
13
  ## v1.29.4
6
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.29.4",
3
+ "version": "1.29.5",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -66,13 +66,22 @@ export default {
66
66
  value: function () {
67
67
  this.eol = true
68
68
  this.lifecycle.state = 'destroy'
69
+
70
+ for (let key in this[symbols.state]) {
71
+ if (Array.isArray(this[symbols.state][key])) {
72
+ this[symbols.state][key] = []
73
+ }
74
+ }
75
+
69
76
  this.$clearTimeouts()
70
77
  this.$clearIntervals()
71
78
  eventListeners.removeListeners(this)
72
79
  deleteChildren(this[symbols.children])
73
80
  this[symbols.children].length = 0
74
81
  removeGlobalEffects(this[symbols.effects])
82
+
75
83
  this[symbols.state] = {}
84
+
76
85
  this[symbols.props] = {}
77
86
  this[symbols.computed] = null
78
87
  this.lifecycle = {}
@@ -22,9 +22,10 @@ export default {
22
22
  value: function (fn, ms, ...params) {
23
23
  // early exit when component is marked as end of life
24
24
  if (this.eol === true) return
25
+
25
26
  const timeoutId = setTimeout(
26
27
  () => {
27
- this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
28
+ this.$clearTimeout(timeoutId)
28
29
  fn.apply(null, params)
29
30
  },
30
31
  ms,
@@ -39,8 +40,9 @@ export default {
39
40
  },
40
41
  $clearTimeout: {
41
42
  value: function (timeoutId) {
42
- if (this[symbols.timeouts].indexOf(timeoutId) > -1) {
43
- this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
43
+ const index = this[symbols.timeouts].indexOf(timeoutId)
44
+ if (index > -1) {
45
+ this[symbols.timeouts].splice(index, 1)
44
46
  clearTimeout(timeoutId)
45
47
  }
46
48
  },
@@ -73,9 +75,10 @@ export default {
73
75
  },
74
76
  $clearInterval: {
75
77
  value: function (intervalId) {
76
- if (this[symbols.intervals].indexOf(intervalId) > -1) {
77
- this[symbols.intervals] = this[symbols.intervals].filter((id) => id !== intervalId)
78
- clearInterval(intervalId)
78
+ const index = this[symbols.intervals].indexOf(intervalId)
79
+ if (index > -1) {
80
+ this[symbols.intervals].splice(index, 1)
81
+ clearTimeout(intervalId)
79
82
  }
80
83
  },
81
84
  writable: false,
package/src/component.js CHANGED
@@ -298,7 +298,7 @@ const Component = (name = required('name'), config = required('config')) => {
298
298
 
299
299
  // outOfViewport event emitting a lifecycle exit event
300
300
  if (config.hooks.exit) {
301
- this[symbols.wrapper].node.on('outOfViewport', () => {
301
+ this[symbols.wrapper].node.on('outOfBounds', () => {
302
302
  this.lifecycle.state = 'exit'
303
303
  })
304
304
  }
@@ -322,8 +322,8 @@ test('Component - Instance should initialize hook events', (assert) => {
322
322
  )
323
323
  assert.equal(
324
324
  nodeCalls[3].args[0],
325
- 'outOfViewport',
326
- '`outOfViewport` event should be registered in the wrapper'
325
+ 'outOfBounds',
326
+ '`outOfBounds` event should be registered in the wrapper'
327
327
  )
328
328
  assert.end()
329
329
  })