@solidtv/solid 1.5.2 → 1.6.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.
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 +8 -9
  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 +10 -0
  17. package/dist/src/primitives/LazyImport.js +107 -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 +9 -16
  33. package/src/core/intrinsicTypes.ts +2 -4
  34. package/src/primitives/FadeInOut.tsx +0 -1
  35. package/src/primitives/LazyImport.ts +119 -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.1",
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
  }
@@ -1067,8 +1060,9 @@ export class ElementNode {
1067
1060
  props: Partial<INodeAnimateProps<CoreShaderNode>>,
1068
1061
  animationSettings?: AnimationSettings,
1069
1062
  ): IAnimationController {
1070
- if (isDev) {
1071
- assertTruthy(this.rendered, 'Node must be rendered before animating');
1063
+ if (!this.rendered) {
1064
+ if (isDev) console.log('NOT RENDERED! CANNOT ANIMATE');
1065
+ return {} as IAnimationController;
1072
1066
  }
1073
1067
  return (this.lng as IRendererNode).animate(
1074
1068
  props,
@@ -1256,7 +1250,10 @@ export class ElementNode {
1256
1250
  }
1257
1251
 
1258
1252
  get src(): string | null | undefined {
1259
- return this.lng.src;
1253
+ // Renderer 1.8 widened `src` to `string | Blob | ImageData`. The solid
1254
+ // `src` prop only ever assigns strings (see the setter above), so the
1255
+ // non-string arms are unreachable through this path.
1256
+ return this.lng.src as string | null | undefined;
1260
1257
  }
1261
1258
 
1262
1259
  getChildById(id: string) {
@@ -1701,10 +1698,6 @@ export class ElementNode {
1701
1698
  node._calcHeight = true;
1702
1699
  }
1703
1700
 
1704
- if (props.rtt && !props.color) {
1705
- props.color = 0xffffffff;
1706
- }
1707
-
1708
1701
  if (!props.color && !props.src) {
1709
1702
  // Default color to transparent - If you later set a src, you'll need
1710
1703
  // 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,127 @@ import {
8
8
  sharedConfig,
9
9
  } from 'solid-js';
10
10
 
11
+ // Native ESM's failure message, and ONLY native ESM's. It names exactly one
12
+ // module, and that module is always the one handed to `import()` — never one of
13
+ // its dependencies. Chrome says `Failed to fetch dynamically imported module:
14
+ // <url>` and Firefox `error loading dynamically imported module: <url>`; both
15
+ // carry the phrase this matches on.
16
+ //
17
+ // SystemJS is deliberately NOT matched here. Its message is
18
+ // `<failedUrl>, <parentUrl> (SystemJS …)`, and when the failure is a dependency
19
+ // of the requested chunk the FIRST url is that dependency. Cache-busting it
20
+ // would re-import the wrong module, and `lazy` would then read `.default` off
21
+ // it — a blank route, or worse, someone else's component. SystemJS needs no
22
+ // cache-buster anyway: it drops the failed load from its registry, so simply
23
+ // calling `fn` again re-fetches.
24
+ const NATIVE_ESM_CHUNK =
25
+ /dynamically imported module:?\s*(https?:\/\/\S+?\.js)/i;
26
+
27
+ /**
28
+ * The chunk URL to retry under a cache-buster, or `undefined` when the failure
29
+ * is one where re-running the loader is the right move instead.
30
+ *
31
+ * @internal Exported for tests. The primitives barrel re-exports `lazy` by
32
+ * name, so this stays out of the package's public API.
33
+ */
34
+ export const cacheBustableUrl = (error: unknown): string | undefined =>
35
+ NATIVE_ESM_CHUNK.exec(
36
+ error instanceof Error ? error.message : String(error),
37
+ )?.[1];
38
+
39
+ /** @internal Exported for tests — see `cacheBustableUrl`. */
40
+ export const cacheBust = (url: string): string =>
41
+ `${url}${url.indexOf('?') === -1 ? '?' : '&'}chunkRetry=1`;
42
+
43
+ /**
44
+ * A dynamic `import()`, built at runtime instead of written inline.
45
+ *
46
+ * This is not a style choice, and it must not be "simplified" back to a literal
47
+ * `import(url)`. The token has to stay inside a string, because this file is
48
+ * bundled into apps that cannot parse it:
49
+ *
50
+ * A TV app targeting an old engine may build with no SystemJS transform at all
51
+ * — plain `iife` output plus a syntax-only `build.target`. Rollup cannot rewrite
52
+ * a dynamic import in that format, and a `\/* @vite-ignore *\/` one is invisible
53
+ * to Vite's analysis by design, so the literal survives into the bundle. Dynamic
54
+ * `import()` arrived in Chrome 63; on anything older the whole script fails to
55
+ * *parse*, and the app never boots. That is not hypothetical: it shipped, and it
56
+ * took every Samsung Tizen 4.0 set (Chrome 56) offline until it was rolled back.
57
+ *
58
+ * Inside a `Function` body the token is just text until it is compiled, and that
59
+ * compilation is what the `try` guards. Old engines throw a SyntaxError here and
60
+ * a CSP without `unsafe-eval` throws an EvalError; either way we return `null`
61
+ * and the caller re-runs the loader instead — the same fallback every SystemJS
62
+ * failure already takes. Resolved once and cached, including the `null`.
63
+ */
64
+ let nativeImport: ((url: string) => Promise<unknown>) | null | undefined;
65
+
66
+ const getNativeImport = (): ((url: string) => Promise<unknown>) | null => {
67
+ if (nativeImport === undefined) {
68
+ try {
69
+ nativeImport = new Function('u', 'return import(u)') as (
70
+ url: string,
71
+ ) => Promise<unknown>;
72
+ } catch {
73
+ nativeImport = null;
74
+ }
75
+ }
76
+ return nativeImport;
77
+ };
78
+
11
79
  // lazy load a function component asynchronously
12
80
  export function lazy<T extends Component<any>>(
13
81
  fn: () => Promise<{ default: T }>,
14
82
  ): T & { preload: () => Promise<{ default: T }> } {
15
83
  let comp: () => T | undefined;
16
84
  let p: Promise<{ default: T }> | undefined;
85
+
86
+ // Retry the import exactly once before giving up. On a TV the chunk fetch is
87
+ // the fragile part — a brief dropout as the viewer presses OK on a rail
88
+ // rejects the import, and because `p` memoises the promise that single
89
+ // rejection is replayed for the rest of the session: the route never renders
90
+ // again, not even on a later navigation. One retry turns the common transient
91
+ // failure into a marginally slower navigation.
92
+ //
93
+ // How it retries depends on which module system failed, because the two need
94
+ // opposite things.
95
+ //
96
+ // SystemJS — the `@vitejs/plugin-legacy` output older TV browsers run — drops
97
+ // the failed load from its registry, so re-running `fn` genuinely re-fetches.
98
+ // That is also the ONLY safe option there: its message names the failed
99
+ // dependency before the chunk that pulled it in, so a URL lifted out of it is
100
+ // frequently not the module we asked for.
101
+ //
102
+ // Native ESM does the opposite. The module map memoises the *failure*, so a
103
+ // second `import()` of the same specifier resolves straight to the cached
104
+ // rejection without ever touching the network — the retry is a no-op exactly
105
+ // where it is needed. It also names one module and only one, the one handed to
106
+ // `import()`, so a cache-busted re-import of it is both safe and necessary: a
107
+ // distinct URL gets a fresh module-map entry and really re-fetches.
108
+ //
109
+ // The cost there is a duplicate module record for this one chunk. Its own
110
+ // imports are unaffected — they resolve to their normal, already-cached URLs —
111
+ // so the duplication does not spread, and it only happens on a retry that
112
+ // would otherwise have left the route dead.
113
+ const load = (): Promise<{ default: T }> =>
114
+ fn().catch((error: unknown) => {
115
+ const url = cacheBustableUrl(error);
116
+ if (url === undefined) return fn();
117
+ // Null when this engine cannot compile a dynamic import, or a CSP forbids
118
+ // compiling one — see `getNativeImport`. Re-running the loader is then the
119
+ // best available retry, exactly as it is for every SystemJS failure.
120
+ const importer = getNativeImport();
121
+ if (importer === null) return fn();
122
+ return importer(cacheBust(url)) as Promise<{ default: T }>;
123
+ });
124
+
17
125
  const wrap: T & { preload?: () => void } = ((props: any) => {
18
126
  const ctx = sharedConfig.context;
19
127
  if (ctx) {
20
128
  const [s, set] = createSignal<T>();
21
129
  sharedConfig.count || (sharedConfig.count = 0);
22
130
  sharedConfig.count++;
23
- (p || (p = fn()))
131
+ (p || (p = load()))
24
132
  .then((mod) => {
25
133
  !sharedConfig.done && (sharedConfig.context = ctx);
26
134
  sharedConfig.count!--;
@@ -31,7 +139,7 @@ export function lazy<T extends Component<any>>(
31
139
  comp = s;
32
140
  } else if (!comp) {
33
141
  const [s] = createResource<T>(() =>
34
- (p || (p = fn())).then((mod) => mod.default),
142
+ (p || (p = load())).then((mod) => mod.default),
35
143
  );
36
144
  comp = s;
37
145
  }
@@ -50,7 +158,15 @@ export function lazy<T extends Component<any>>(
50
158
  : null;
51
159
  }) as unknown as JSX.Element;
52
160
  }) as T;
161
+ // The `.then` here is a fire-and-forget side effect (it caches the resolved
162
+ // component); `p` is what the caller gets back. Without the `.catch` that
163
+ // side-effect promise has no rejection handler of its own, so a failed
164
+ // preload raises an unhandledrejection even when the caller dutifully catches
165
+ // the promise it was handed — a warmed route that fails to fetch would report
166
+ // as an uncaught exception. Mirrors the `.catch(() => {})` on the hydration
167
+ // path above; the real failure still reaches the caller through `p`.
53
168
  wrap.preload = () =>
54
- p || ((p = fn()).then((mod) => (comp = () => mod.default)), p);
169
+ p ||
170
+ ((p = load()).then((mod) => (comp = () => mod.default)).catch(() => {}), p);
55
171
  return wrap as T & { preload: () => Promise<{ default: T }> };
56
172
  }
@@ -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"}