@solidtv/solid 1.3.1 → 1.3.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/dist/src/core/elementNode.js +15 -1
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/focusKeyTypes.d.ts +8 -8
- package/dist/src/core/lightningInit.js +4 -1
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/primitives/Column.jsx +4 -2
- package/dist/src/primitives/Column.jsx.map +1 -1
- package/dist/src/primitives/Lazy.jsx +2 -2
- package/dist/src/primitives/Lazy.jsx.map +1 -1
- package/dist/src/primitives/Row.jsx +4 -2
- package/dist/src/primitives/Row.jsx.map +1 -1
- package/dist/src/primitives/announcer/speech.js +19 -22
- package/dist/src/primitives/announcer/speech.js.map +1 -1
- package/dist/src/primitives/types.d.ts +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/elementNode.ts +16 -1
- package/src/core/focusKeyTypes.ts +8 -8
- package/src/core/lightningInit.ts +5 -1
- package/src/primitives/Column.tsx +4 -2
- package/src/primitives/Lazy.tsx +2 -2
- package/src/primitives/Row.tsx +4 -2
- package/src/primitives/announcer/speech.ts +20 -26
- package/src/primitives/types.ts +5 -1
package/package.json
CHANGED
package/src/core/elementNode.ts
CHANGED
|
@@ -1640,7 +1640,22 @@ export class ElementNode {
|
|
|
1640
1640
|
if (!props.texture) {
|
|
1641
1641
|
// Set width and height to parent less offset
|
|
1642
1642
|
if (isNaN(props.w as number)) {
|
|
1643
|
-
|
|
1643
|
+
// A flex container that sizes its width to its children (contain on the
|
|
1644
|
+
// main axis) should default to 1 rather than filling its parent, so it
|
|
1645
|
+
// shrinks to fit content once layout runs.
|
|
1646
|
+
let flexFitsWidth = false;
|
|
1647
|
+
if (node.display === 'flex') {
|
|
1648
|
+
const flexDirection = node.flexDirection || 'row';
|
|
1649
|
+
const isFlexRow =
|
|
1650
|
+
flexDirection === 'row' || flexDirection === 'row-reverse';
|
|
1651
|
+
flexFitsWidth = isFlexRow && node.flexBoundary !== 'fixed';
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
if (node.flexGrow || flexFitsWidth) {
|
|
1655
|
+
props.w = 0;
|
|
1656
|
+
} else {
|
|
1657
|
+
props.w = parentWidth - props.x;
|
|
1658
|
+
}
|
|
1644
1659
|
node._calcWidth = true;
|
|
1645
1660
|
}
|
|
1646
1661
|
|
|
@@ -40,20 +40,20 @@ export interface FocusNode {
|
|
|
40
40
|
export type KeyNameOrKeyCode = string | number;
|
|
41
41
|
|
|
42
42
|
export interface DefaultKeyMap {
|
|
43
|
-
Left: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
44
|
-
Right: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
45
|
-
Up: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
46
|
-
Down: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
47
|
-
Enter: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
48
|
-
Last: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
43
|
+
Left: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
44
|
+
Right: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
45
|
+
Up: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
46
|
+
Down: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
47
|
+
Enter: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
48
|
+
Last: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface KeyMap extends DefaultKeyMap {
|
|
52
|
-
[key: string]: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
52
|
+
[key: string]: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export interface DefaultKeyHoldMap {
|
|
56
|
-
EnterHold: KeyNameOrKeyCode | KeyNameOrKeyCode[];
|
|
56
|
+
EnterHold: KeyNameOrKeyCode | KeyNameOrKeyCode[] | null;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export type EventHandlers<Map> = {
|
|
@@ -27,6 +27,10 @@ export function startLightningRenderer(
|
|
|
27
27
|
export async function loadFonts(fonts: FontLoadOptions[]) {
|
|
28
28
|
// Inlined so the loadFontToDom branch + import tree-shake in WebGL builds.
|
|
29
29
|
const enableDomRenderer = DOM_RENDERING && Config.domRendererEnabled;
|
|
30
|
+
const hasCanvas =
|
|
31
|
+
!enableDomRenderer &&
|
|
32
|
+
'textRenderers' in renderer.stage &&
|
|
33
|
+
!!(renderer.stage as lng.Stage).textRenderers.canvas;
|
|
30
34
|
await Promise.all(
|
|
31
35
|
fonts.map((font) => {
|
|
32
36
|
// WebGL — SDF
|
|
@@ -41,7 +45,7 @@ export async function loadFonts(fonts: FontLoadOptions[]) {
|
|
|
41
45
|
if ('fontUrl' in font) {
|
|
42
46
|
if (enableDomRenderer) {
|
|
43
47
|
loadFontToDom(font);
|
|
44
|
-
} else if (
|
|
48
|
+
} else if (hasCanvas) {
|
|
45
49
|
return renderer.stage.loadFont('canvas', font);
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -20,10 +20,12 @@ const ColumnStyles: NodeStyles = {
|
|
|
20
20
|
gap: 30,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
function scrollToIndex(this: ElementNode, index: number) {
|
|
23
|
+
function scrollToIndex(this: ElementNode, index: number, options?: {noFocus?: boolean}) {
|
|
24
24
|
this.selected = index;
|
|
25
25
|
scrollColumn(index, this);
|
|
26
|
-
|
|
26
|
+
if (!options?.noFocus) {
|
|
27
|
+
this.children[index]?.setFocus();
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const onUp = handleNavigation('up');
|
package/src/primitives/Lazy.tsx
CHANGED
|
@@ -136,9 +136,9 @@ function createLazy<T>(
|
|
|
136
136
|
Array.isArray(props.each) ? props.each.slice(0, offset()) : [],
|
|
137
137
|
);
|
|
138
138
|
|
|
139
|
-
function lazyScrollToIndex(this: lngp.NavigableElement, index: number) {
|
|
139
|
+
function lazyScrollToIndex(this: lngp.NavigableElement, index: number, options?: {noFocus?: boolean}) {
|
|
140
140
|
setOffset(Math.max(index, 0) + buffer())
|
|
141
|
-
queueMicrotask(() => viewRef.scrollToIndex(index));
|
|
141
|
+
queueMicrotask(() => viewRef.scrollToIndex(index, options));
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
const updateOffset = (_event: KeyboardEvent, container: lng.ElementNode) => {
|
package/src/primitives/Row.tsx
CHANGED
|
@@ -19,10 +19,12 @@ const RowStyles: NodeStyles = {
|
|
|
19
19
|
gap: 30,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
function scrollToIndex(this: ElementNode, index: number) {
|
|
22
|
+
function scrollToIndex(this: ElementNode, index: number, options?: {noFocus?: boolean}) {
|
|
23
23
|
this.selected = index;
|
|
24
24
|
scrollRow(index, this);
|
|
25
|
-
|
|
25
|
+
if (!options?.noFocus) {
|
|
26
|
+
this.children[index]?.setFocus();
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const onLeft = handleNavigation('left');
|
|
@@ -58,6 +58,12 @@ function addChildrenToAriaDiv(phrase: AriaLabel) {
|
|
|
58
58
|
* @description This function is triggered finally when the speak series is finished and we are to speak the aria labels
|
|
59
59
|
*/
|
|
60
60
|
function focusElementForAria() {
|
|
61
|
+
// Nothing new to announce (e.g. a canceled series). Leave whatever the live
|
|
62
|
+
// region currently holds in place so an in-progress screen reader isn't cut off.
|
|
63
|
+
if (ariaLabelPhrases.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
const element = createAriaElement();
|
|
62
68
|
|
|
63
69
|
if (!element) {
|
|
@@ -65,6 +71,12 @@ function focusElementForAria() {
|
|
|
65
71
|
return;
|
|
66
72
|
}
|
|
67
73
|
|
|
74
|
+
// Replace-on-next-write: drop the previous announcement's nodes, then inject
|
|
75
|
+
// the current label. The label stays in the assertive live region until the
|
|
76
|
+
// *next* announcement replaces it — rather than being torn down on a timer —
|
|
77
|
+
// so on-device TV screen readers have time to finish reading it.
|
|
78
|
+
cleanAriaLabelParent();
|
|
79
|
+
|
|
68
80
|
for (const object of ariaLabelPhrases) {
|
|
69
81
|
const span = document.createElement('span');
|
|
70
82
|
|
|
@@ -74,12 +86,7 @@ function focusElementForAria() {
|
|
|
74
86
|
element.appendChild(span);
|
|
75
87
|
}
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
ariaLabelPhrases = [];
|
|
80
|
-
cleanAriaLabelParent();
|
|
81
|
-
focusCanvas();
|
|
82
|
-
}, 100);
|
|
89
|
+
ariaLabelPhrases = [];
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
/**
|
|
@@ -94,14 +101,6 @@ function cleanAriaLabelParent(): void {
|
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
/**
|
|
98
|
-
* @description Focus the canvas element
|
|
99
|
-
*/
|
|
100
|
-
function focusCanvas(): void {
|
|
101
|
-
const canvas = document.getElementById('app')?.firstChild as HTMLElement;
|
|
102
|
-
canvas?.focus();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
104
|
/**
|
|
106
105
|
* @description Create the aria element in the DOM if it doesn't exist
|
|
107
106
|
* @private For xbox, we may need to create a different element each time we wanna use aria
|
|
@@ -299,19 +298,14 @@ function speakSeries(
|
|
|
299
298
|
|
|
300
299
|
if (root) {
|
|
301
300
|
if (aria) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return;
|
|
301
|
+
// Replace-on-next-write: don't tear down the live region here. The
|
|
302
|
+
// current label stays until the next announcement replaces it, so the
|
|
303
|
+
// screen reader can finish. Just drop any partially accumulated
|
|
304
|
+
// phrases from this canceled series.
|
|
305
|
+
ariaLabelPhrases = [];
|
|
306
|
+
} else {
|
|
307
|
+
synth.cancel(); // Cancel all ongoing speech
|
|
312
308
|
}
|
|
313
|
-
|
|
314
|
-
synth.cancel(); // Cancel all ongoing speech
|
|
315
309
|
}
|
|
316
310
|
nestedSeriesResults.forEach((nestedSeriesResult) => {
|
|
317
311
|
nestedSeriesResult.cancel();
|
package/src/primitives/types.ts
CHANGED
|
@@ -74,7 +74,11 @@ export interface NavigableProps extends NodeProps {
|
|
|
74
74
|
// @ts-expect-error animationSettings is not identical - weird
|
|
75
75
|
export interface NavigableElement extends ElementNode, NavigableProps {
|
|
76
76
|
selected: number;
|
|
77
|
-
scrollToIndex: (
|
|
77
|
+
scrollToIndex: (
|
|
78
|
+
this: NavigableElement,
|
|
79
|
+
index: number,
|
|
80
|
+
options?: { noFocus?: boolean },
|
|
81
|
+
) => void;
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
export interface NavigableStyleProperties {
|