@solidtv/solid 1.3.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -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
- props.w = node.flexGrow ? 0 : parentWidth - props.x;
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
 
@@ -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 (renderer.stage.renderer.mode !== 'webgl') {
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
- this.children[index]?.setFocus();
26
+ if (!options?.noFocus) {
27
+ this.children[index]?.setFocus();
28
+ }
27
29
  }
28
30
 
29
31
  const onUp = handleNavigation('up');
@@ -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) => {
@@ -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
- this.children[index]?.setFocus();
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
- // Cleanup
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
- const element = createAriaElement();
303
-
304
- if (element) {
305
- ariaLabelPhrases = [];
306
- cleanAriaLabelParent();
307
- element.focus();
308
- focusCanvas();
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();
@@ -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: (this: NavigableElement, index: number) => void;
77
+ scrollToIndex: (
78
+ this: NavigableElement,
79
+ index: number,
80
+ options?: { noFocus?: boolean },
81
+ ) => void;
78
82
  }
79
83
 
80
84
  export interface NavigableStyleProperties {