@lightningjs/blits 2.0.0-beta.4 → 2.0.0-beta.6
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/index.d.ts +5 -0
- package/package.json +1 -1
- package/src/announcer/announcer.js +5 -3
- package/src/application.js +3 -0
- package/src/components/Sprite.js +36 -0
- package/src/lib/codegenerator/generator.js +11 -1
package/CHANGELOG.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -400,6 +400,11 @@ declare module '@lightningjs/blits' {
|
|
|
400
400
|
*/
|
|
401
401
|
readonly $hasFocus: boolean,
|
|
402
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Parent component instance. Undefined for the root Application component or after destroy.
|
|
405
|
+
*/
|
|
406
|
+
readonly $parent: ComponentBase | null | undefined,
|
|
407
|
+
|
|
403
408
|
/**
|
|
404
409
|
* Indicates whether the component currently is hovered
|
|
405
410
|
*
|
package/package.json
CHANGED
|
@@ -149,9 +149,11 @@ const processQueue = async () => {
|
|
|
149
149
|
processQueue()
|
|
150
150
|
})
|
|
151
151
|
.catch((e) => {
|
|
152
|
-
currentId
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
if (id === currentId) {
|
|
153
|
+
currentId = null
|
|
154
|
+
currentResolveFn = null
|
|
155
|
+
isProcessing = false
|
|
156
|
+
}
|
|
155
157
|
Log.debug(`Announcer - error ("${e.error}") while speaking: "${message}" (id: ${id})`)
|
|
156
158
|
resolveFn(e.error)
|
|
157
159
|
processQueue()
|
package/src/application.js
CHANGED
|
@@ -45,6 +45,9 @@ const Application = (config) => {
|
|
|
45
45
|
let mouseListenersAdded = false
|
|
46
46
|
|
|
47
47
|
config.hooks[symbols.destroy] = function () {
|
|
48
|
+
// Cancel pending key-hold timeout and reset hold state so focus is not left in hold mode after teardown
|
|
49
|
+
clearTimeout(holdTimeout)
|
|
50
|
+
Focus.hold = false
|
|
48
51
|
document.removeEventListener('keydown', keyDownHandler)
|
|
49
52
|
document.removeEventListener('keyup', keyUpHandler)
|
|
50
53
|
if (mouseListenersAdded) {
|
package/src/components/Sprite.js
CHANGED
|
@@ -147,6 +147,8 @@ export default () =>
|
|
|
147
147
|
rounded: undefined,
|
|
148
148
|
border: undefined,
|
|
149
149
|
shadow: undefined,
|
|
150
|
+
'@loaded': undefined,
|
|
151
|
+
'@error': undefined,
|
|
150
152
|
},
|
|
151
153
|
state() {
|
|
152
154
|
return {
|
|
@@ -155,6 +157,33 @@ export default () =>
|
|
|
155
157
|
}
|
|
156
158
|
},
|
|
157
159
|
|
|
160
|
+
hooks: {
|
|
161
|
+
ready() {
|
|
162
|
+
const loaded = this['@loaded']
|
|
163
|
+
if (loaded && typeof loaded === 'function') {
|
|
164
|
+
const cb = (payload) => loaded({ w: payload?.w, h: payload?.h }, this[symbols.wrapper])
|
|
165
|
+
this._loadedCb = cb
|
|
166
|
+
if (this.spriteTexture !== undefined && this.spriteTexture !== null) {
|
|
167
|
+
this.spriteTexture.on('loaded', cb)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const error = this['@error']
|
|
171
|
+
if (error && typeof error === 'function') {
|
|
172
|
+
const cb = (payload) => error(payload, this[symbols.wrapper])
|
|
173
|
+
this._failedCb = cb
|
|
174
|
+
if (this.spriteTexture !== undefined && this.spriteTexture !== null) {
|
|
175
|
+
this.spriteTexture.on('failed', cb)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
destroy() {
|
|
180
|
+
if (this.spriteTexture !== undefined && this.spriteTexture !== null) {
|
|
181
|
+
if (this._loadedCb) this.spriteTexture.off('loaded', this._loadedCb)
|
|
182
|
+
if (this._failedCb) this.spriteTexture.off('failed', this._failedCb)
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
|
|
158
187
|
computed: {
|
|
159
188
|
texture() {
|
|
160
189
|
// If no image - nothing to render
|
|
@@ -174,10 +203,17 @@ export default () =>
|
|
|
174
203
|
this.spriteTexture === null ||
|
|
175
204
|
this.currentSrc !== this.image
|
|
176
205
|
) {
|
|
206
|
+
const prevTexture = this.spriteTexture
|
|
207
|
+
if (prevTexture !== undefined && prevTexture !== null) {
|
|
208
|
+
if (this._loadedCb) prevTexture.off('loaded', this._loadedCb)
|
|
209
|
+
if (this._failedCb) prevTexture.off('failed', this._failedCb)
|
|
210
|
+
}
|
|
177
211
|
this.spriteTexture = renderer.createTexture('ImageTexture', {
|
|
178
212
|
src: this.image,
|
|
179
213
|
})
|
|
180
214
|
this.currentSrc = this.image
|
|
215
|
+
if (this._loadedCb) this.spriteTexture.on('loaded', this._loadedCb)
|
|
216
|
+
if (this._failedCb) this.spriteTexture.on('failed', this._failedCb)
|
|
181
217
|
}
|
|
182
218
|
|
|
183
219
|
// Resolve frame data from sprite map
|
|
@@ -664,11 +664,21 @@ const generateForLoopCode = function (templateObject, parent) {
|
|
|
664
664
|
const forEndCounter = counter
|
|
665
665
|
|
|
666
666
|
for (let i = forStartCounter; i <= forEndCounter; i++) {
|
|
667
|
-
|
|
667
|
+
if (i == forStartCounter) {
|
|
668
|
+
destroyCode.push(`
|
|
668
669
|
elms[${i}][key] && elms[${i}][key].destroy()
|
|
669
670
|
elms[${i}][key] = null
|
|
670
671
|
delete elms[${i}][key]
|
|
671
672
|
`)
|
|
673
|
+
} else {
|
|
674
|
+
destroyCode.push(`
|
|
675
|
+
if (elms[${i}][key] && elms[${i}][key].$componentId !== undefined) {
|
|
676
|
+
elms[${i}][key] && elms[${i}][key].destroy()
|
|
677
|
+
}
|
|
678
|
+
elms[${i}][key] = null
|
|
679
|
+
delete elms[${i}][key]
|
|
680
|
+
`)
|
|
681
|
+
}
|
|
672
682
|
}
|
|
673
683
|
destroyCode.push(`
|
|
674
684
|
}
|