@lightningjs/blits 1.38.1 → 1.38.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 +15 -0
- package/package.json +1 -1
- package/src/component/base/methods.js +12 -0
- package/src/component.js +8 -5
- package/src/lib/reactivity/reactive.js +1 -1
- package/src/lib/symbols.js +2 -0
- package/src/router/router.js +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.38.3
|
|
4
|
+
|
|
5
|
+
_4 Sept 2025_
|
|
6
|
+
|
|
7
|
+
- Fixed clearing of `idle` and `frameTick` hooks upon component destroy
|
|
8
|
+
- Fixed updating of router state to before init hook
|
|
9
|
+
|
|
10
|
+
## v1.38.2
|
|
11
|
+
|
|
12
|
+
_1 Sept 2025_
|
|
13
|
+
|
|
14
|
+
- Fixed issue with `reuseComponent` storing the same page multiple times
|
|
15
|
+
- Fixed last array patch method (sort) not triggering reactivity
|
|
16
|
+
|
|
17
|
+
|
|
3
18
|
## v1.38.1
|
|
4
19
|
|
|
5
20
|
_28 Aug 2025_
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ import eventListeners from '../../lib/eventListeners.js'
|
|
|
21
21
|
import { trigger } from '../../lib/reactivity/effect.js'
|
|
22
22
|
import { Log } from '../../lib/log.js'
|
|
23
23
|
import { removeGlobalEffects } from '../../lib/reactivity/effect.js'
|
|
24
|
+
import { renderer } from '../../launch.js'
|
|
24
25
|
|
|
25
26
|
export default {
|
|
26
27
|
focus: {
|
|
@@ -83,6 +84,17 @@ export default {
|
|
|
83
84
|
this.$clearTimeouts()
|
|
84
85
|
this.$clearIntervals()
|
|
85
86
|
eventListeners.removeListeners(this)
|
|
87
|
+
|
|
88
|
+
const rendererEventListenersLength = this[symbols.rendererEventListeners].length
|
|
89
|
+
if (rendererEventListenersLength > 0) {
|
|
90
|
+
for (let i = 0; i < rendererEventListenersLength; i++) {
|
|
91
|
+
const eventListener = this[symbols.rendererEventListeners][i]
|
|
92
|
+
renderer.off(eventListener.event, eventListener.cb)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this[symbols.rendererEventListeners] = null
|
|
97
|
+
|
|
86
98
|
deleteChildren(this[symbols.children])
|
|
87
99
|
this[symbols.children].length = 0
|
|
88
100
|
removeGlobalEffects(this[symbols.effects])
|
package/src/component.js
CHANGED
|
@@ -263,19 +263,22 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
263
263
|
// create a reference to an array of children that are slots
|
|
264
264
|
this[symbols.slots] = this[symbols.children].filter((child) => child[symbols.isSlot])
|
|
265
265
|
|
|
266
|
+
this[symbols.rendererEventListeners] = []
|
|
266
267
|
// register hooks if component has hooks specified
|
|
267
268
|
if (config.hooks) {
|
|
268
269
|
// frame tick event
|
|
269
270
|
if (config.hooks.frameTick) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)
|
|
271
|
+
const cb = (r, data) => emit('frameTick', this[symbols.identifier], this, [data])
|
|
272
|
+
this[symbols.rendererEventListeners].push({ event: 'frameTick', cb })
|
|
273
|
+
renderer.on('frameTick', cb)
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
if (config.hooks.idle) {
|
|
276
|
-
|
|
277
|
+
const cb = () => {
|
|
277
278
|
emit('idle', this[symbols.identifier], this)
|
|
278
|
-
}
|
|
279
|
+
}
|
|
280
|
+
this[symbols.rendererEventListeners].push({ event: 'idle', cb })
|
|
281
|
+
renderer.on('idle', cb)
|
|
279
282
|
}
|
|
280
283
|
|
|
281
284
|
// inBounds event emiting a lifecycle attach event
|
|
@@ -155,7 +155,7 @@ const reactiveDefineProperty = (target, global) => {
|
|
|
155
155
|
if (Object.getPrototypeOf(target[key]) === Object.prototype) {
|
|
156
156
|
return reactiveDefineProperty(target[key])
|
|
157
157
|
} else if (Array.isArray(target[key]) === true) {
|
|
158
|
-
for (let i = 0; i < arrayPatchMethods.length
|
|
158
|
+
for (let i = 0; i < arrayPatchMethods.length; i++) {
|
|
159
159
|
target[key][arrayPatchMethods[i]] = function (v) {
|
|
160
160
|
Array.prototype[arrayPatchMethods[i]].call(this, v)
|
|
161
161
|
trigger(target, key)
|
package/src/lib/symbols.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @property {symbol} cursorTagStart
|
|
8
8
|
* @property {symbol} computedKeys
|
|
9
9
|
* @property {symbol} destroy
|
|
10
|
+
* @property {symbol} rendererEventListeners
|
|
10
11
|
* @property {symbol} getChildren
|
|
11
12
|
* @property {symbol} holder
|
|
12
13
|
* @property {symbol} id
|
|
@@ -59,6 +60,7 @@ export default {
|
|
|
59
60
|
cursorTagStart: Symbol('cursorTagStart'),
|
|
60
61
|
computedKeys: Symbol('computedKeys'),
|
|
61
62
|
destroy: Symbol('destroy'),
|
|
63
|
+
rendererEventListeners: Symbol('rendererEventListeners'),
|
|
62
64
|
getChildren: Symbol('getChildren'),
|
|
63
65
|
holder: Symbol('holder'),
|
|
64
66
|
id: Symbol('id'),
|
package/src/router/router.js
CHANGED
|
@@ -233,6 +233,7 @@ export const navigate = async function () {
|
|
|
233
233
|
...navigationData,
|
|
234
234
|
...queryParamsData,
|
|
235
235
|
}
|
|
236
|
+
|
|
236
237
|
// Adding the location hash to the route if it exists.
|
|
237
238
|
if (hash !== null) {
|
|
238
239
|
route.hash = hash
|
|
@@ -314,6 +315,13 @@ export const navigate = async function () {
|
|
|
314
315
|
Announcer.speak(route.announce.message, route.announce.politeness)
|
|
315
316
|
}
|
|
316
317
|
|
|
318
|
+
// Update router state after announcements and final route resolution,
|
|
319
|
+
// right before initializing or restoring the view
|
|
320
|
+
state.path = route.path
|
|
321
|
+
state.params = route.params || {}
|
|
322
|
+
state.hash = route.hash
|
|
323
|
+
state.data = route.data || {}
|
|
324
|
+
|
|
317
325
|
if (!view) {
|
|
318
326
|
// create a holder element for the new view
|
|
319
327
|
holder = stage.element({ parent: this[symbols.children][0] })
|
|
@@ -358,7 +366,9 @@ export const navigate = async function () {
|
|
|
358
366
|
}
|
|
359
367
|
}
|
|
360
368
|
|
|
361
|
-
|
|
369
|
+
if (reuse === false) {
|
|
370
|
+
this[symbols.children].push(view)
|
|
371
|
+
}
|
|
362
372
|
|
|
363
373
|
// keep reference to the previous focus for storing in cache
|
|
364
374
|
previousFocus = Focus.get()
|
|
@@ -394,11 +404,6 @@ export const navigate = async function () {
|
|
|
394
404
|
}
|
|
395
405
|
}
|
|
396
406
|
|
|
397
|
-
state.path = route.path
|
|
398
|
-
state.params = route.params
|
|
399
|
-
state.hash = hash
|
|
400
|
-
state.data = route.data
|
|
401
|
-
|
|
402
407
|
// apply in transition
|
|
403
408
|
if (route.transition.in) {
|
|
404
409
|
if (Array.isArray(route.transition.in)) {
|