@solidtv/solid 1.5.2 → 1.6.0

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.
Files changed (42) hide show
  1. package/dist/src/core/config.d.ts +7 -1
  2. package/dist/src/core/config.js.map +1 -1
  3. package/dist/src/core/dom-renderer/domRenderer.d.ts +2 -6
  4. package/dist/src/core/dom-renderer/domRenderer.js +14 -25
  5. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  6. package/dist/src/core/dom-renderer/domRendererTypes.d.ts +8 -4
  7. package/dist/src/core/dom-renderer/domRendererUtils.d.ts +10 -1
  8. package/dist/src/core/dom-renderer/domRendererUtils.js +25 -12
  9. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
  10. package/dist/src/core/elementNode.d.ts +1 -3
  11. package/dist/src/core/elementNode.js +4 -7
  12. package/dist/src/core/elementNode.js.map +1 -1
  13. package/dist/src/core/intrinsicTypes.d.ts +2 -4
  14. package/dist/src/primitives/FadeInOut.jsx +0 -1
  15. package/dist/src/primitives/FadeInOut.jsx.map +1 -1
  16. package/dist/src/primitives/LazyImport.d.ts +7 -0
  17. package/dist/src/primitives/LazyImport.js +54 -3
  18. package/dist/src/primitives/LazyImport.js.map +1 -1
  19. package/dist/src/primitives/Marquee.jsx +2 -2
  20. package/dist/src/primitives/Marquee.jsx.map +1 -1
  21. package/dist/src/primitives/announcer/speech.js +52 -5
  22. package/dist/src/primitives/announcer/speech.js.map +1 -1
  23. package/dist/src/primitives/index.d.ts +1 -2
  24. package/dist/src/primitives/index.js +3 -2
  25. package/dist/src/primitives/index.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +2 -2
  28. package/src/core/config.ts +7 -1
  29. package/src/core/dom-renderer/domRenderer.ts +13 -26
  30. package/src/core/dom-renderer/domRendererTypes.ts +8 -4
  31. package/src/core/dom-renderer/domRendererUtils.ts +28 -17
  32. package/src/core/elementNode.ts +6 -14
  33. package/src/core/intrinsicTypes.ts +2 -4
  34. package/src/primitives/FadeInOut.tsx +0 -1
  35. package/src/primitives/LazyImport.ts +63 -3
  36. package/src/primitives/Marquee.tsx +2 -2
  37. package/src/primitives/announcer/speech.ts +60 -7
  38. package/src/primitives/index.ts +3 -2
  39. package/dist/src/primitives/createTag.d.ts +0 -8
  40. package/dist/src/primitives/createTag.jsx +0 -20
  41. package/dist/src/primitives/createTag.jsx.map +0 -1
  42. package/src/primitives/createTag.tsx +0 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -109,7 +109,7 @@
109
109
  },
110
110
  "peerDependencies": {
111
111
  "@solidjs/router": "^0.16.1",
112
- "@solidtv/renderer": "^1.6.3",
112
+ "@solidtv/renderer": "^1.9.0",
113
113
  "solid-js": "*"
114
114
  },
115
115
  "peerDependenciesMeta": {},
@@ -54,7 +54,13 @@ export interface Config {
54
54
  animationSettings?: AnimationSettings;
55
55
  animationsEnabled: boolean;
56
56
  fontSettings: Partial<TextProps>;
57
- rendererOptions?: Partial<RendererMainSettings> | DomRendererMainSettings;
57
+ /**
58
+ * Renderer settings. Typed as an intersection rather than a union so a single
59
+ * config object can be authored without narrowing per renderer: which fields
60
+ * are honored depends on the active renderer (WebGL/Canvas vs DOM), and every
61
+ * field is optional.
62
+ */
63
+ rendererOptions?: Partial<RendererMainSettings> & DomRendererMainSettings;
58
64
  /**
59
65
  * Hook the focus manager calls to publish the active element. Defaults to
60
66
  * writing the {@link activeElement} signal directly; a custom focus manager
@@ -488,7 +488,9 @@ function updateNodeStyles(node: DOMNode | DOMText) {
488
488
  >;
489
489
  srcPos = texture.props;
490
490
  rawImgSrc = (texture.props.texture as any).props.src;
491
- } else if (props.src) {
491
+ } else if (typeof props.src === 'string') {
492
+ // Renderer 1.8 widened `src` to `string | Blob | ImageData`; the DOM
493
+ // renderer only paints string URLs.
492
494
  rawImgSrc = props.src;
493
495
  }
494
496
 
@@ -1256,7 +1258,6 @@ function resolveNodeDefaults(
1256
1258
  alpha: props.alpha ?? 1,
1257
1259
  ignoreParentAlpha: props.ignoreParentAlpha ?? false,
1258
1260
  autosize: props.autosize ?? false,
1259
- boundsMargin: props.boundsMargin ?? null,
1260
1261
  clipping: props.clipping ?? false,
1261
1262
  color,
1262
1263
  colorTop: props.colorTop ?? color,
@@ -1289,7 +1290,6 @@ function resolveNodeDefaults(
1289
1290
  pivotX: props.pivotX ?? props.pivot ?? 0.5,
1290
1291
  pivotY: props.pivotY ?? props.pivot ?? 0.5,
1291
1292
  rotation: props.rotation ?? 0,
1292
- rtt: props.rtt ?? false,
1293
1293
  placeholderColor: props.placeholderColor ?? 0,
1294
1294
  data: {},
1295
1295
  imageType: props.imageType,
@@ -1329,6 +1329,7 @@ const defaultShader: IRendererShader = {
1329
1329
 
1330
1330
  let lastNodeId = 0;
1331
1331
 
1332
+ /** Render-state labels, used for the `data-state` debug attribute only. */
1332
1333
  const CoreNodeRenderStateMap = new Map<number, string>([
1333
1334
  [0, 'init'],
1334
1335
  [2, 'outOfBounds'],
@@ -1436,15 +1437,20 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1436
1437
  if (renderState === this.renderState) return;
1437
1438
  const previous = this.renderState;
1438
1439
  this.renderState = renderState;
1439
- const event = CoreNodeRenderStateMap.get(renderState);
1440
1440
  if (isRenderStateInBounds(renderState)) {
1441
1441
  this.applyPendingImageSrc();
1442
1442
  }
1443
- if (event && event !== 'init') {
1444
- this.emit(event, { previous, current: renderState });
1443
+ // Viewport entry/exit is the whole observable surface, matching CoreNode.
1444
+ // `inBounds` stays internal: it only exists so textures preload ahead of a
1445
+ // node scrolling on screen. Exit fires for InViewport -> InBounds and
1446
+ // InViewport -> OutOfBounds alike.
1447
+ if (renderState === 8 /* InViewport */) {
1448
+ this.emit('inViewport', { previous, current: renderState });
1449
+ } else if (previous === 8 /* InViewport */) {
1450
+ this.emit('outOfViewport', { previous, current: renderState });
1445
1451
  }
1446
1452
  if (this.imgEl) {
1447
- this.imgEl.dataset.state = event;
1453
+ this.imgEl.dataset.state = CoreNodeRenderStateMap.get(renderState);
1448
1454
  }
1449
1455
  }
1450
1456
 
@@ -1763,13 +1769,6 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1763
1769
  this.markChildrenBoundsDirty();
1764
1770
  updateTransformOnly(this);
1765
1771
  }
1766
- get rtt() {
1767
- return this.props.rtt;
1768
- }
1769
- set rtt(v) {
1770
- this.props.rtt = v;
1771
- updateNodeStyles(this);
1772
- }
1773
1772
  get shader() {
1774
1773
  return this.props.shader;
1775
1774
  }
@@ -1817,15 +1816,6 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1817
1816
  this.props.srcY = v;
1818
1817
  }
1819
1818
 
1820
- get boundsMargin(): number | [number, number, number, number] | null {
1821
- return this.props.boundsMargin;
1822
- }
1823
- set boundsMargin(value: number | [number, number, number, number] | null) {
1824
- this.props.boundsMargin = value;
1825
- this.boundsDirty = true;
1826
- this.markChildrenBoundsDirty();
1827
- }
1828
-
1829
1819
  get ignoreParentAlpha(): boolean {
1830
1820
  return this.props.ignoreParentAlpha;
1831
1821
  }
@@ -2279,9 +2269,6 @@ export class DOMRendererMain implements IRendererMain {
2279
2269
  case 'NoiseTexture':
2280
2270
  type = lng.TextureType.noise;
2281
2271
  break;
2282
- case 'RenderTexture':
2283
- type = lng.TextureType.renderToTexture;
2284
- break;
2285
2272
  }
2286
2273
  return { type, props } as InstanceType<lng.TextureMap[Type]>;
2287
2274
  }
@@ -12,7 +12,7 @@ import {
12
12
  /** Based on {@link lng.CoreRenderer} */
13
13
  export interface IRendererCoreRenderer {
14
14
  mode: 'canvas' | 'webgl' | undefined;
15
- boundsMargin?: number | [number, number, number, number];
15
+ boundsMargin?: number;
16
16
  }
17
17
  /** Based on {@link lng.TrFontManager} */
18
18
  export interface IRendererFontManager {
@@ -145,8 +145,12 @@ export interface DomRendererMainSettings {
145
145
  deviceLogicalPixelRatio?: number;
146
146
 
147
147
  /**
148
- * Bounds margin for the renderer
149
- * Can be a single number (applied to all sides) or an array [top, right, bottom, left]
148
+ * Preload margin around the viewport, in logical pixels (default: 200)
149
+ *
150
+ * @remarks
151
+ * A single number applied to all sides. The `[top, right, bottom, left]`
152
+ * array form was dropped in renderer 1.8; it is still tolerated at runtime
153
+ * (the largest edge wins, with a warning) but should be replaced.
150
154
  */
151
- boundsMargin?: number | [number, number, number, number];
155
+ boundsMargin?: number;
152
156
  }
@@ -221,17 +221,31 @@ export function nodeHasTextureSource(node: DOMNode): boolean {
221
221
  );
222
222
  }
223
223
 
224
+ /**
225
+ * Coerce a `boundsMargin` value to the scalar the renderer takes since 1.8.
226
+ *
227
+ * @remarks
228
+ * The `[top, right, bottom, left]` array form was dropped in renderer 1.8. An
229
+ * untyped app upgrading from 1.7 can still pass it, so mirror the WebGL
230
+ * renderer and take the widest edge rather than letting the margin arithmetic
231
+ * go wrong.
232
+ */
224
233
  export function normalizeBoundsMargin(
225
- margin: number | [number, number, number, number] | null | undefined,
226
- ): [number, number, number, number] {
227
- if (margin == null) return [0, 0, 0, 0];
228
- if (typeof margin === 'number') {
229
- return [margin, margin, margin, margin];
230
- }
231
- if (Array.isArray(margin) && margin.length === 4) {
232
- return [margin[0] ?? 0, margin[1] ?? 0, margin[2] ?? 0, margin[3] ?? 0];
234
+ margin: number | number[] | null | undefined,
235
+ ): number {
236
+ if (margin == null) return 0;
237
+ if (Array.isArray(margin) === false) return margin as number;
238
+ const arr = margin as number[];
239
+ let max = 0;
240
+ for (let i = 0; i < arr.length; i++) {
241
+ if (arr[i]! > max) {
242
+ max = arr[i]!;
243
+ }
233
244
  }
234
- return [0, 0, 0, 0];
245
+ console.warn(
246
+ `boundsMargin array form is no longer supported, using the largest edge value: ${max}`,
247
+ );
248
+ return max;
235
249
  }
236
250
 
237
251
  export function computeRenderStateForNode(
@@ -249,10 +263,7 @@ export function computeRenderStateForNode(
249
263
  const rootRight = rootLeft + rootWidth;
250
264
  const rootBottom = rootTop + rootHeight;
251
265
 
252
- const [marginTop, marginRight, marginBottom, marginLeft] =
253
- normalizeBoundsMargin(
254
- node.props.boundsMargin ?? node.stage.renderer.boundsMargin,
255
- );
266
+ const margin = normalizeBoundsMargin(node.stage.renderer.boundsMargin);
256
267
 
257
268
  const width = node.props.w ?? 0;
258
269
  const height = node.props.h ?? 0;
@@ -262,10 +273,10 @@ export function computeRenderStateForNode(
262
273
  const right = left + width;
263
274
  const bottom = top + height;
264
275
 
265
- const expandedLeft = rootLeft - marginLeft;
266
- const expandedTop = rootTop - marginTop;
267
- const expandedRight = rootRight + marginRight;
268
- const expandedBottom = rootBottom + marginBottom;
276
+ const expandedLeft = rootLeft - margin;
277
+ const expandedTop = rootTop - margin;
278
+ const expandedRight = rootRight + margin;
279
+ const expandedBottom = rootBottom + margin;
269
280
 
270
281
  const intersectsBounds =
271
282
  right >= expandedLeft &&
@@ -277,7 +277,6 @@ const LightningRendererNonAnimatingProps = [
277
277
  'overflowSuffix',
278
278
  'placeholderColor',
279
279
  'preventCleanup',
280
- 'rtt',
281
280
  'scrollable',
282
281
  'scrollY',
283
282
  'srcHeight',
@@ -743,12 +742,10 @@ export interface ElementNode extends RendererNode, FocusNode {
743
742
  * - 'loaded'
744
743
  * - 'failed'
745
744
  * - 'freed'
746
- * - 'inBounds'
747
- * - 'outOfBounds'
748
745
  * - 'inViewport'
749
746
  * - 'outOfViewport'
750
747
  *
751
- * @typedef {'loaded' | 'failed' | 'freed' | 'inBounds' | 'outOfBounds' | 'inViewport' | 'outOfViewport'} NodeEvents
748
+ * @typedef {'loaded' | 'failed' | 'freed' | 'inViewport' | 'outOfViewport'} NodeEvents
752
749
  *
753
750
  * @param {Partial<Record<NodeEvents, EventHandler>>} events - An object where the keys are event names from NodeEvents and the values are the respective event handlers.
754
751
  * @returns {void}
@@ -875,11 +872,7 @@ export class ElementNode {
875
872
 
876
873
  set id(id: string) {
877
874
  this._id = id;
878
- if (
879
- Config.rendererOptions &&
880
- 'inspector' in Config.rendererOptions &&
881
- Config.rendererOptions.inspector
882
- ) {
875
+ if (Config.rendererOptions?.inspector) {
883
876
  this.data = { ...this.data, testId: id };
884
877
  }
885
878
  }
@@ -1256,7 +1249,10 @@ export class ElementNode {
1256
1249
  }
1257
1250
 
1258
1251
  get src(): string | null | undefined {
1259
- return this.lng.src;
1252
+ // Renderer 1.8 widened `src` to `string | Blob | ImageData`. The solid
1253
+ // `src` prop only ever assigns strings (see the setter above), so the
1254
+ // non-string arms are unreachable through this path.
1255
+ return this.lng.src as string | null | undefined;
1260
1256
  }
1261
1257
 
1262
1258
  getChildById(id: string) {
@@ -1701,10 +1697,6 @@ export class ElementNode {
1701
1697
  node._calcHeight = true;
1702
1698
  }
1703
1699
 
1704
- if (props.rtt && !props.color) {
1705
- props.color = 0xffffffff;
1706
- }
1707
-
1708
1700
  if (!props.color && !props.src) {
1709
1701
  // Default color to transparent - If you later set a src, you'll need
1710
1702
  // to set color '#ffffffff'
@@ -200,10 +200,8 @@ type EventPayloadMap = {
200
200
  loaded: lngr.NodeLoadedPayload;
201
201
  failed: lngr.NodeFailedPayload;
202
202
  freed: Event;
203
- inBounds: Event;
204
- outOfBounds: Event;
205
- inViewport: Event;
206
- outOfViewport: Event;
203
+ inViewport: lngr.NodeViewportPayload;
204
+ outOfViewport: lngr.NodeViewportPayload;
207
205
  };
208
206
 
209
207
  type NodeEvents = keyof EventPayloadMap;
@@ -40,7 +40,6 @@ export function FadeInOut(props: Props & NodeProps) {
40
40
  }
41
41
 
42
42
  function onDestroy(elm: ElementNode) {
43
- elm.rtt = true;
44
43
  return elm
45
44
  .animate(
46
45
  { alpha: 0 },
@@ -8,19 +8,71 @@ import {
8
8
  sharedConfig,
9
9
  } from 'solid-js';
10
10
 
11
+ // The chunk URL, as named in the failure message by either module system:
12
+ // native ESM reports `Failed to fetch dynamically imported module: <url>`,
13
+ // SystemJS reports `<url>, (SystemJS https://…/errors.md#3)`. The first
14
+ // http(s) URL ending in `.js` is the chunk in both cases — SystemJS's trailing
15
+ // docs link has no `.js` in it, so it cannot be matched by mistake.
16
+ const CHUNK_URL = /https?:\/\/\S+?\.js/;
17
+
18
+ /**
19
+ * @internal Exported for tests. The primitives barrel re-exports `lazy` by
20
+ * name, so this stays out of the package's public API.
21
+ */
22
+ export const chunkUrlFromError = (error: unknown): string | undefined =>
23
+ CHUNK_URL.exec(error instanceof Error ? error.message : String(error))?.[0];
24
+
25
+ /** @internal Exported for tests — see `chunkUrlFromError`. */
26
+ export const cacheBust = (url: string): string =>
27
+ `${url}${url.indexOf('?') === -1 ? '?' : '&'}chunkRetry=1`;
28
+
11
29
  // lazy load a function component asynchronously
12
30
  export function lazy<T extends Component<any>>(
13
31
  fn: () => Promise<{ default: T }>,
14
32
  ): T & { preload: () => Promise<{ default: T }> } {
15
33
  let comp: () => T | undefined;
16
34
  let p: Promise<{ default: T }> | undefined;
35
+
36
+ // Retry the import exactly once before giving up. On a TV the chunk fetch is
37
+ // the fragile part — a brief dropout as the viewer presses OK on a rail
38
+ // rejects the import, and because `p` memoises the promise that single
39
+ // rejection is replayed for the rest of the session: the route never renders
40
+ // again, not even on a later navigation. One retry turns the common transient
41
+ // failure into a marginally slower navigation.
42
+ //
43
+ // The retry re-imports under a cache-busting URL rather than re-running `fn`,
44
+ // because re-running only works on one of the two module systems we ship to.
45
+ // Under SystemJS — the `@vitejs/plugin-legacy` output older TV browsers run —
46
+ // the failed load is dropped from the registry, so calling `fn` again really
47
+ // does re-fetch. Native ESM does the opposite: the module map memoises the
48
+ // *failure*, so a second `import()` of the same specifier resolves straight to
49
+ // the cached rejection without ever touching the network, and the retry is a
50
+ // no-op precisely where it is needed. A distinct URL gets a fresh module-map
51
+ // entry and actually re-fetches.
52
+ //
53
+ // The cost is a duplicate module record for this one chunk. Its own imports
54
+ // are unaffected — they resolve to their normal, already-cached URLs — so the
55
+ // duplication does not spread, and it only happens on a retry that would
56
+ // otherwise have left the route dead.
57
+ //
58
+ // `fn` is still the fallback when the message names no URL: no worse than not
59
+ // retrying, and it keeps non-URL loaders (tests, custom resolvers) working.
60
+ const load = (): Promise<{ default: T }> =>
61
+ fn().catch((error: unknown) => {
62
+ const url = chunkUrlFromError(error);
63
+ if (url === undefined) return fn();
64
+ return import(/* @vite-ignore */ cacheBust(url)) as Promise<{
65
+ default: T;
66
+ }>;
67
+ });
68
+
17
69
  const wrap: T & { preload?: () => void } = ((props: any) => {
18
70
  const ctx = sharedConfig.context;
19
71
  if (ctx) {
20
72
  const [s, set] = createSignal<T>();
21
73
  sharedConfig.count || (sharedConfig.count = 0);
22
74
  sharedConfig.count++;
23
- (p || (p = fn()))
75
+ (p || (p = load()))
24
76
  .then((mod) => {
25
77
  !sharedConfig.done && (sharedConfig.context = ctx);
26
78
  sharedConfig.count!--;
@@ -31,7 +83,7 @@ export function lazy<T extends Component<any>>(
31
83
  comp = s;
32
84
  } else if (!comp) {
33
85
  const [s] = createResource<T>(() =>
34
- (p || (p = fn())).then((mod) => mod.default),
86
+ (p || (p = load())).then((mod) => mod.default),
35
87
  );
36
88
  comp = s;
37
89
  }
@@ -50,7 +102,15 @@ export function lazy<T extends Component<any>>(
50
102
  : null;
51
103
  }) as unknown as JSX.Element;
52
104
  }) as T;
105
+ // The `.then` here is a fire-and-forget side effect (it caches the resolved
106
+ // component); `p` is what the caller gets back. Without the `.catch` that
107
+ // side-effect promise has no rejection handler of its own, so a failed
108
+ // preload raises an unhandledrejection even when the caller dutifully catches
109
+ // the promise it was handed — a warmed route that fails to fetch would report
110
+ // as an uncaught exception. Mirrors the `.catch(() => {})` on the hydration
111
+ // path above; the real failure still reaches the caller through `p`.
53
112
  wrap.preload = () =>
54
- p || ((p = fn()).then((mod) => (comp = () => mod.default)), p);
113
+ p ||
114
+ ((p = load()).then((mod) => (comp = () => mod.default)).catch(() => {}), p);
55
115
  return wrap as T & { preload: () => Promise<{ default: T }> };
56
116
  }
@@ -96,8 +96,8 @@ export function MarqueeText(props: MarqueeTextProps) {
96
96
  return (
97
97
  <>
98
98
  {wasFocusedBefore() && <>
99
- <text {...props} ref={text1} hidden={!shouldScroll()} rtt maxLines={1} onEvent={events} />
100
- <text {...props} ref={text2} hidden={!shouldScroll()} rtt maxLines={1} />
99
+ <text {...props} ref={text1} hidden={!shouldScroll()} maxLines={1} onEvent={events} />
100
+ <text {...props} ref={text2} hidden={!shouldScroll()} maxLines={1} />
101
101
  </>}
102
102
  <text {...props} maxLines={1} hidden={shouldScroll()} contain='width' />
103
103
  </>
@@ -26,6 +26,24 @@ interface SpeechError extends Error {
26
26
  error?: string;
27
27
  }
28
28
 
29
+ // The same caveat applies to the rest of the Web Speech API, and it is not just
30
+ // a typing nicety: webOS (Chrome 53) ships no Web Speech API at all, so it
31
+ // declares neither `window.speechSynthesis` nor the `SpeechSynthesisUtterance`
32
+ // constructor. Merely *evaluating* the bare global throws a ReferenceError —
33
+ // including inside an `instanceof` on a code path that never intends to speak,
34
+ // which is how a webOS app running in aria mode (Announcer.aria = true, speech
35
+ // synthesis never touched) still managed to crash. `typeof` is the only safe
36
+ // probe for a possibly-undeclared global, so every use of the API in this file
37
+ // goes through this guard or through a `SpeechSynthesis | undefined` local.
38
+ function isSpeechSynthesisUtterance(
39
+ phrase: unknown,
40
+ ): phrase is SpeechSynthesisUtterance {
41
+ return (
42
+ typeof SpeechSynthesisUtterance !== 'undefined' &&
43
+ phrase instanceof SpeechSynthesisUtterance
44
+ );
45
+ }
46
+
29
47
  function flattenStrings(series: SpeechType[] = []): SpeechType[] {
30
48
  const flattenedSeries = [];
31
49
 
@@ -142,9 +160,20 @@ function speak(
142
160
  lang = 'en-US',
143
161
  voiceName?: string,
144
162
  ) {
145
- const synth = window.speechSynthesis;
163
+ // TypeScript's DOM lib types `window.speechSynthesis` as always present, but
164
+ // on a TV browser without the Web Speech API it is `undefined` at runtime.
165
+ // Type it honestly so the compiler forces the guard below.
166
+ const synth: SpeechSynthesis | undefined = window.speechSynthesis;
146
167
 
147
168
  return new Promise<void>((resolve, reject) => {
169
+ if (!synth || typeof SpeechSynthesisUtterance === 'undefined') {
170
+ // No speech engine on this device. Resolve rather than reject so the rest
171
+ // of the series still runs and the app degrades to silence instead of
172
+ // throwing a ReferenceError out of the chain.
173
+ resolve();
174
+ return;
175
+ }
176
+
148
177
  let selectedVoice;
149
178
  if (voiceName) {
150
179
  const availableVoices = synth.getVoices();
@@ -180,7 +209,8 @@ function speak(
180
209
  * benign — a newer announcement cancelled or replaced the in-flight one (see
181
210
  * synth.cancel()), which happens constantly during directional navigation — so
182
211
  * we stop retrying without surfacing them. `network` errors back off and retry.
183
- * Anything else is genuinely unexpected and is rethrown.
212
+ * Anything else is a device-level failure of the speech engine: logged, not
213
+ * rethrown.
184
214
  */
185
215
  async function handleSpeechError(
186
216
  e: unknown,
@@ -202,7 +232,16 @@ async function handleSpeechError(
202
232
  return 0; // benign — stop retrying, don't propagate
203
233
  }
204
234
 
205
- throw e;
235
+ // Everything else — "synthesis-failed", "not-allowed", or an error carrying no
236
+ // code at all — is the platform's TTS engine declining to speak, not a
237
+ // programming error. Xumo (Safari 11) and Tizen both report these routinely
238
+ // when the system voice is unavailable or refuses to start unprompted.
239
+ // Rethrowing used to abort the whole remaining series *and* surface as an
240
+ // uncaught exception in the host app, so instead we log it, keep the rest of
241
+ // the phrases going, and stop retrying (a refused engine won't change its
242
+ // mind on the next attempt the way a `network` blip might).
243
+ console.warn(`Speech synthesis failed: ${code || 'no error code'}`);
244
+ return 0;
206
245
  }
207
246
 
208
247
  function speakSeries(
@@ -212,7 +251,8 @@ function speakSeries(
212
251
  voice?: string,
213
252
  root = true,
214
253
  ): SeriesResult {
215
- const synth = window.speechSynthesis;
254
+ // Possibly-undefined on purpose — see isSpeechSynthesisUtterance above.
255
+ const synth: SpeechSynthesis | undefined = window.speechSynthesis;
216
256
  const remainingPhrases = flattenStrings(
217
257
  Array.isArray(series) ? series : [series],
218
258
  );
@@ -255,7 +295,7 @@ function speakSeries(
255
295
  );
256
296
  }
257
297
  }
258
- } else if (phrase instanceof SpeechSynthesisUtterance) {
298
+ } else if (isSpeechSynthesisUtterance(phrase)) {
259
299
  // Handle SpeechSynthesisUtterance objects with retry logic
260
300
  const totalRetries = 3;
261
301
  let retriesLeft = totalRetries;
@@ -298,7 +338,16 @@ function speakSeries(
298
338
  focusElementForAria();
299
339
  }
300
340
  }
301
- })();
341
+ })().catch((e) => {
342
+ // Last line of defence, and the reason the fixes above are not enough on
343
+ // their own: `SeriesResult.series` is handed to callers who usually never
344
+ // await it, so anything escaping this chain lands as an `unhandledrejection`
345
+ // and is reported as an uncaught exception in the host app. A failed
346
+ // announcement must never do that — whatever the cause (a caller-supplied
347
+ // function phrase throwing, a future synthesis error code), log it and let
348
+ // the promise resolve.
349
+ console.warn('Speech series failed:', e);
350
+ });
302
351
 
303
352
  return {
304
353
  series: seriesChain,
@@ -320,7 +369,11 @@ function speakSeries(
320
369
  // screen reader can finish. Just drop any partially accumulated
321
370
  // phrases from this canceled series.
322
371
  ariaLabelPhrases = [];
323
- } else {
372
+ } else if (synth) {
373
+ // Undefined on TV browsers without the Web Speech API. cancel() runs
374
+ // synchronously in the caller (see the default export, which cancels
375
+ // the previous series before starting a new one), so an unguarded
376
+ // call here would throw straight into app code.
324
377
  synth.cancel(); // Cancel all ongoing speech
325
378
  }
326
379
  }
@@ -5,7 +5,9 @@ export * from './borderBox.jsx';
5
5
  export * from './useMouse.js';
6
6
  export * from './portal.jsx';
7
7
  export * from './Lazy.jsx';
8
- export * from './LazyImport.js';
8
+ // Named rather than `export *`: LazyImport also exports internal helpers for
9
+ // its tests, and those must not become part of the public API.
10
+ export { lazy } from './LazyImport.js';
9
11
  export * from './Image.jsx';
10
12
  export * from './Visible.jsx';
11
13
  export * from './Column.jsx';
@@ -21,7 +23,6 @@ export * from './useHold.js';
21
23
  export * from './VirtualGrid.jsx';
22
24
  export * from './Virtual.jsx';
23
25
  export * from './utils/withScrolling.js';
24
- export * from './createTag.jsx';
25
26
  export {
26
27
  type AnyFunction,
27
28
  chainFunctions,
@@ -1,8 +0,0 @@
1
- import * as s from 'solid-js';
2
- import * as lng from '@solidtv/solid';
3
- interface Destroyable {
4
- (props: lng.NodeProps): s.JSX.Element;
5
- destroy: () => void;
6
- }
7
- export declare function createTag(children: s.JSX.Element): Destroyable;
8
- export {};
@@ -1,20 +0,0 @@
1
- import * as s from 'solid-js';
2
- import * as lng from '@solidtv/solid';
3
- export function createTag(children) {
4
- const [texture, setTexture] = s.createSignal(null);
5
- const Tag = (<view x={lng.rootNode.w - 1} y={lng.rootNode.h - 1} display="flex" onLayout={(n) => {
6
- if (n.preFlexwidth && n.width !== n.preFlexwidth) {
7
- n.rtt = true;
8
- setTimeout(() => setTexture(n.texture), 1);
9
- }
10
- }} parent={lng.rootNode} children={children} textureOptions={{
11
- preventCleanup: true,
12
- }}/>);
13
- Tag.render(false);
14
- const TagComponent = (props) => {
15
- return <view color={0xffffffff} autosize {...props} texture={texture()}/>;
16
- };
17
- TagComponent.destroy = () => Tag.destroy();
18
- return TagComponent;
19
- }
20
- //# sourceMappingURL=createTag.jsx.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTag.jsx","sourceRoot":"","sources":["../../../src/primitives/createTag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AAOtC,MAAM,UAAU,SAAS,CAAC,QAAuB;IAC/C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,YAAY,CAC1C,IAAI,CACL,CAAC;IACF,MAAM,GAAG,GAAG,CACV,CAAC,IAAI,CACH,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CACtB,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CACtB,OAAO,CAAC,MAAM,CACd,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;YACd,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,YAAY,EAAE,CAAC;gBACjD,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;gBACb,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC,CACF,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CACrB,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,cAAc,CAAC,CAAC;YACd,cAAc,EAAE,IAAI;SACrB,CAAC,EACF,CAC2B,CAAC;IAChC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,EAAG,CAAC;IAC7E,CAAC,CAAC;IACF,YAAY,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAE3C,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -1,39 +0,0 @@
1
- import * as s from 'solid-js';
2
- import * as lng from '@solidtv/solid';
3
-
4
- interface Destroyable {
5
- (props: lng.NodeProps): s.JSX.Element;
6
- destroy: () => void;
7
- }
8
-
9
- export function createTag(children: s.JSX.Element): Destroyable {
10
- const [texture, setTexture] = s.createSignal<lng.Texture | null | undefined>(
11
- null,
12
- );
13
- const Tag = (
14
- <view
15
- x={lng.rootNode.w - 1}
16
- y={lng.rootNode.h - 1}
17
- display="flex"
18
- onLayout={(n) => {
19
- if (n.preFlexwidth && n.width !== n.preFlexwidth) {
20
- n.rtt = true;
21
- setTimeout(() => setTexture(n.texture), 1);
22
- }
23
- }}
24
- parent={lng.rootNode}
25
- children={children}
26
- textureOptions={{
27
- preventCleanup: true,
28
- }}
29
- />
30
- ) as unknown as lng.ElementNode;
31
- Tag.render(false);
32
-
33
- const TagComponent = (props: lng.NodeProps) => {
34
- return <view color={0xffffffff} autosize {...props} texture={texture()} />;
35
- };
36
- TagComponent.destroy = () => Tag.destroy();
37
-
38
- return TagComponent;
39
- }