@lightningjs/blits 1.24.0 → 1.25.1
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/.github/workflows/run-blits-tests.yml +2 -1
- package/CHANGELOG.md +13 -0
- package/docs/plugins/text-to-speech-announcer.md +12 -0
- package/index.d.ts +16 -1
- package/package.json +1 -1
- package/src/announcer/announcer.js +18 -0
- package/src/application.js +2 -0
- package/src/component/base/methods.js +2 -0
- package/src/engines/L3/element.js +14 -8
- package/src/engines/L3/element.test.js +0 -6
|
@@ -4,6 +4,7 @@ on:
|
|
|
4
4
|
pull_request_target:
|
|
5
5
|
branches:
|
|
6
6
|
- dev
|
|
7
|
+
- master
|
|
7
8
|
|
|
8
9
|
jobs:
|
|
9
10
|
run-blits-tests:
|
|
@@ -45,7 +46,7 @@ jobs:
|
|
|
45
46
|
echo "summary=$summary" >> $GITHUB_OUTPUT
|
|
46
47
|
|
|
47
48
|
# If the number of failed tests is greater than 1, exit with error.
|
|
48
|
-
if [ "$failed" -gt
|
|
49
|
+
if [ "$failed" -gt 0 ]; then
|
|
49
50
|
exit 1
|
|
50
51
|
fi
|
|
51
52
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.25.1
|
|
4
|
+
|
|
5
|
+
_01 apr 2025_
|
|
6
|
+
|
|
7
|
+
- Fixed issue with page rendering after being destroyed when data is loaded by an async request
|
|
8
|
+
|
|
9
|
+
## v1.25.0
|
|
10
|
+
|
|
11
|
+
_28 mar 2025_
|
|
12
|
+
|
|
13
|
+
- Fixed issue when same effect type is used in `effects` attribute
|
|
14
|
+
- Added ability to enable / disable announcer via launch setting as well as runtime
|
|
15
|
+
|
|
3
16
|
## v1.24.0
|
|
4
17
|
|
|
5
18
|
_26 mar 2025_
|
|
@@ -46,3 +46,15 @@ Blits.Component('MyComponent', {
|
|
|
46
46
|
}
|
|
47
47
|
})
|
|
48
48
|
```
|
|
49
|
+
|
|
50
|
+
## Enabling / disabling the announcer
|
|
51
|
+
|
|
52
|
+
By default the announcer is disabled. This mean that whenever you call `this.$announcer.speak()` there will actually not be anything spoken out via the Text To Speech engine.
|
|
53
|
+
|
|
54
|
+
In order to enable utterances being spoken out, you can set the Blits launch setting `announcer` to `true` in the index.js.
|
|
55
|
+
|
|
56
|
+
Alternatively the announcer can be enabled or disabled run time by using one of the following methods on the Announcer pluging:
|
|
57
|
+
|
|
58
|
+
- `this.$announcer.enable()` - activates the announcer
|
|
59
|
+
- `this.$announcer.disable()` - deactivates the announcer
|
|
60
|
+
- `this.$announcer.disable(true/false)` - turns the announcer or on off
|
package/index.d.ts
CHANGED
|
@@ -929,7 +929,22 @@ declare module '@lightningjs/blits' {
|
|
|
929
929
|
*
|
|
930
930
|
* @important if you dont know what you're doing here, you probably shouldn't be doing it!
|
|
931
931
|
*/
|
|
932
|
-
advanced?: Partial<RendererMainSettings
|
|
932
|
+
advanced?: Partial<RendererMainSettings>,
|
|
933
|
+
/**
|
|
934
|
+
* Whether or not the announcer should be activated on initialization
|
|
935
|
+
*
|
|
936
|
+
* When set to `false` announcements via `this.$annoucer.speak()` will
|
|
937
|
+
* be ignored. When set to `true` announcement will be spoken out via the
|
|
938
|
+
* text to speech API
|
|
939
|
+
*
|
|
940
|
+
* Announcer can be enabled / disabled run time as well via:
|
|
941
|
+
* - this.$announcer.enable()
|
|
942
|
+
* - this.$announcer.disable()
|
|
943
|
+
* - this.$announcer.toggle(true/false)
|
|
944
|
+
*
|
|
945
|
+
* @default false
|
|
946
|
+
*/
|
|
947
|
+
announcer?: boolean
|
|
933
948
|
}
|
|
934
949
|
|
|
935
950
|
interface State {
|
package/package.json
CHANGED
|
@@ -19,7 +19,22 @@ import speechSynthesis from './speechSynthesis.js'
|
|
|
19
19
|
|
|
20
20
|
let debounce
|
|
21
21
|
|
|
22
|
+
let active = false
|
|
23
|
+
|
|
24
|
+
const enable = () => {
|
|
25
|
+
active = true
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const disable = () => {
|
|
29
|
+
active = false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const toggle = (v) => {
|
|
33
|
+
active = v ? true : false
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
const speak = (message, politeness = 'off') => {
|
|
37
|
+
if (active === false) return
|
|
23
38
|
clearTimeout(debounce)
|
|
24
39
|
speechSynthesis.cancel()
|
|
25
40
|
// assertive messages get spoken immediately
|
|
@@ -45,4 +60,7 @@ export default {
|
|
|
45
60
|
polite,
|
|
46
61
|
assertive,
|
|
47
62
|
stop,
|
|
63
|
+
enable,
|
|
64
|
+
disable,
|
|
65
|
+
toggle,
|
|
48
66
|
}
|
package/src/application.js
CHANGED
|
@@ -54,6 +54,8 @@ const Application = (config) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
config.hooks[symbols.init] = function () {
|
|
57
|
+
// set the initial activation state of the announcer based on launch setting
|
|
58
|
+
this.$announcer.toggle(Settings.get('announcer', false))
|
|
57
59
|
const keyMap = { ...defaultKeyMap, ...Settings.get('keymap', {}) }
|
|
58
60
|
|
|
59
61
|
keyDownHandler = async (e) => {
|
|
@@ -59,6 +59,8 @@ export default {
|
|
|
59
59
|
deleteChildren(this[symbols.children])
|
|
60
60
|
removeGlobalEffects(this[symbols.effects])
|
|
61
61
|
Log.debug(`Destroyed component ${this.componentId}`)
|
|
62
|
+
this[symbols.state] = {}
|
|
63
|
+
this[symbols.props] = {}
|
|
62
64
|
},
|
|
63
65
|
writable: false,
|
|
64
66
|
enumerable: true,
|
|
@@ -328,24 +328,29 @@ const propsTransformer = {
|
|
|
328
328
|
v[i].props.color = colors.normalize(v[i].props.color)
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
|
|
331
|
+
const effectNames = {}
|
|
332
332
|
if (this.element.node === undefined) {
|
|
333
|
+
this.element.effectNames = []
|
|
333
334
|
this.props['shader'] = renderer.createShader('DynamicShader', {
|
|
334
335
|
effects: v.map((effect) => {
|
|
336
|
+
let name = effect.type
|
|
337
|
+
if (effectNames[name] !== undefined) {
|
|
338
|
+
name += ++effectNames[name]
|
|
339
|
+
} else {
|
|
340
|
+
effectNames[name] = 1
|
|
341
|
+
}
|
|
342
|
+
name += this.element.counter
|
|
343
|
+
this.element.effectNames.push(name)
|
|
335
344
|
// temporary add counter to work around shader caching issues
|
|
336
|
-
return renderer.createEffect(
|
|
337
|
-
effect.type,
|
|
338
|
-
effect.props,
|
|
339
|
-
effect.type + this.element.counter
|
|
340
|
-
)
|
|
345
|
+
return renderer.createEffect(effect.type, effect.props, name)
|
|
341
346
|
}),
|
|
342
347
|
})
|
|
343
348
|
} else {
|
|
344
349
|
for (let i = 0; i < v.length; i++) {
|
|
350
|
+
const name = this.element.effectNames[i]
|
|
345
351
|
// temporary add counter to work around shader caching issues
|
|
346
|
-
const target = this.element.node.shader.props[
|
|
352
|
+
const target = this.element.node.shader.props[name]
|
|
347
353
|
const props = Object.keys(v[i].props)
|
|
348
|
-
|
|
349
354
|
if (target == undefined) continue
|
|
350
355
|
for (let j = 0; j < props.length; j++) {
|
|
351
356
|
target[props[j]] = v[i].props[props[j]]
|
|
@@ -651,6 +656,7 @@ export default (config, component) => {
|
|
|
651
656
|
scheduledTransitions: {},
|
|
652
657
|
config,
|
|
653
658
|
component,
|
|
659
|
+
effectNames: [],
|
|
654
660
|
counter: counter++,
|
|
655
661
|
})
|
|
656
662
|
}
|
|
@@ -551,10 +551,6 @@ test('Element - Set `show` property as false', (assert) => {
|
|
|
551
551
|
|
|
552
552
|
assert.equal(el.node['alpha'], 0, 'Node alpha parameter should set to 0')
|
|
553
553
|
assert.equal(el.props.props['alpha'], 0, 'Props alpha parameter should set')
|
|
554
|
-
assert.equal(el.node['width'], 0, 'Node width parameter should set to 0')
|
|
555
|
-
assert.equal(el.props.props['width'], 0, 'props width parameter should set to 0')
|
|
556
|
-
assert.equal(el.node['height'], 0, 'Node height parameter should set to 0')
|
|
557
|
-
assert.equal(el.props.props['height'], 0, 'props height parameter should set to 0')
|
|
558
554
|
|
|
559
555
|
assert.end()
|
|
560
556
|
})
|
|
@@ -567,9 +563,7 @@ test('Element - Set `show` property as false', (assert) => {
|
|
|
567
563
|
assert.equal(el.node['alpha'], 1, 'Node alpha parameter should be set')
|
|
568
564
|
assert.equal(el.props.props['alpha'], 1, 'Props alpha parameter should be set')
|
|
569
565
|
assert.equal(el.node['width'], 960, 'Node width parameter should be set')
|
|
570
|
-
assert.equal(el.props.props['width'], 960, 'props width parameter should be set')
|
|
571
566
|
assert.equal(el.node['height'], 540, 'Node height parameter should be set')
|
|
572
|
-
assert.equal(el.props.props['height'], 540, 'props height parameter should be set')
|
|
573
567
|
|
|
574
568
|
assert.end()
|
|
575
569
|
})
|