@lightningjs/blits 1.38.2 → 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 +7 -0
- package/package.json +1 -1
- package/src/component/base/methods.js +12 -0
- package/src/component.js +8 -5
- package/src/lib/symbols.js +2 -0
- package/src/router/router.js +8 -5
package/CHANGELOG.md
CHANGED
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
|
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] })
|
|
@@ -396,11 +404,6 @@ export const navigate = async function () {
|
|
|
396
404
|
}
|
|
397
405
|
}
|
|
398
406
|
|
|
399
|
-
state.path = route.path
|
|
400
|
-
state.params = route.params
|
|
401
|
-
state.hash = hash
|
|
402
|
-
state.data = route.data
|
|
403
|
-
|
|
404
407
|
// apply in transition
|
|
405
408
|
if (route.transition.in) {
|
|
406
409
|
if (Array.isArray(route.transition.in)) {
|