@solidtv/solid 1.7.0-0 → 1.7.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 (55) hide show
  1. package/README.md +4 -30
  2. package/dist/src/core/dom-renderer/domRenderer.d.ts +6 -2
  3. package/dist/src/core/dom-renderer/domRenderer.js +16 -1
  4. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  5. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
  6. package/dist/src/core/elementNode.d.ts +20 -2
  7. package/dist/src/core/elementNode.js +128 -26
  8. package/dist/src/core/elementNode.js.map +1 -1
  9. package/dist/src/core/env.js.map +1 -1
  10. package/dist/src/core/flex.js.map +1 -1
  11. package/dist/src/core/flexLayout.js.map +1 -1
  12. package/dist/src/core/focusManager.js +15 -4
  13. package/dist/src/core/focusManager.js.map +1 -1
  14. package/dist/src/core/lightningInit.d.ts +2 -2
  15. package/dist/src/core/lightningInit.js +65 -3
  16. package/dist/src/core/lightningInit.js.map +1 -1
  17. package/dist/src/core/nodeTypes.d.ts +4 -4
  18. package/dist/src/core/nodeTypes.js +2 -3
  19. package/dist/src/core/nodeTypes.js.map +1 -1
  20. package/dist/src/core/shaders.js.map +1 -1
  21. package/dist/src/core/states.js.map +1 -1
  22. package/dist/src/core/utils.js.map +1 -1
  23. package/dist/src/devtools/hexColorTransform.js.map +1 -1
  24. package/dist/src/devtools/jsx-locator.d.ts +1 -1
  25. package/dist/src/primitives/KeepAlive.d.ts +3 -3
  26. package/dist/src/primitives/Lazy.jsx +7 -1
  27. package/dist/src/primitives/Lazy.jsx.map +1 -1
  28. package/dist/src/primitives/Virtual.d.ts +4 -0
  29. package/dist/src/primitives/Virtual.jsx +192 -106
  30. package/dist/src/primitives/Virtual.jsx.map +1 -1
  31. package/dist/src/primitives/VirtualGrid.jsx +87 -18
  32. package/dist/src/primitives/VirtualGrid.jsx.map +1 -1
  33. package/dist/src/primitives/announcer/announcer.js.map +1 -1
  34. package/dist/src/primitives/announcer/speech.js.map +1 -1
  35. package/dist/src/primitives/useMouse.js.map +1 -1
  36. package/dist/src/primitives/utils/handleNavigation.js +12 -5
  37. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  38. package/dist/src/primitives/utils/withScrolling.js +63 -57
  39. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  40. package/dist/src/render.d.ts +3 -2
  41. package/dist/src/render.js.map +1 -1
  42. package/dist/src/utils.js.map +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/docs/README.md +2 -0
  45. package/package.json +20 -19
  46. package/src/core/dom-renderer/domRenderer.ts +16 -1
  47. package/src/core/elementNode.ts +144 -22
  48. package/src/core/focusManager.ts +12 -4
  49. package/src/core/lightningInit.ts +78 -4
  50. package/src/core/nodeTypes.ts +6 -3
  51. package/src/primitives/Lazy.tsx +8 -1
  52. package/src/primitives/Virtual.tsx +211 -117
  53. package/src/primitives/VirtualGrid.tsx +98 -21
  54. package/src/primitives/utils/handleNavigation.ts +12 -5
  55. package/src/primitives/utils/withScrolling.ts +63 -62
package/docs/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  `@solidtv/solid` is an integration for the [SolidTV Renderer](https://github.com/solid-tv/renderer) built with [SolidJS](https://www.solidjs.com/) [Universal Renderer](https://github.com/solidjs/solid/releases/tag/v1.2.0). It allows you to declaratively construct WebGL nodes with SolidJS reactive primitives. It includes everything you need to rapidly build performant TV Apps.
6
6
 
7
+ ?> **Coming from `@lightningtv/solid`?** The project moved to `@solidtv/solid`. See the [migration guide](/migrate.md).
8
+
7
9
  ?> **Commercial support available.** Support plans, performance audits, migrations to SolidTV, Apple TV ports and team training from the creator of SolidTV. [See support & services](https://solidtv.dev/#services).
8
10
 
9
11
  ## Starter Template
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.7.0-0",
3
+ "version": "1.7.1",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,10 +34,17 @@
34
34
  },
35
35
  "./devtools/jsx-locator": "./src/devtools/jsx-locator.js",
36
36
  "./shaders": {
37
- "@solidtv/source": "./src/shaders/index.ts",
37
+ "@solidtv/source": "./src/core/shaders.ts",
38
38
  "import": {
39
- "types": "./dist/src/shaders/index.d.ts",
40
- "default": "./dist/src/shaders/index.js"
39
+ "types": "./dist/src/core/shaders.d.ts",
40
+ "default": "./dist/src/core/shaders.js"
41
+ }
42
+ },
43
+ "./focusManager": {
44
+ "@solidtv/source": "./src/core/focusManager.ts",
45
+ "import": {
46
+ "types": "./dist/src/core/focusManager.d.ts",
47
+ "default": "./dist/src/core/focusManager.js"
41
48
  }
42
49
  },
43
50
  "./jsx-runtime": {
@@ -50,12 +57,12 @@
50
57
  "start": "pnpm run watch",
51
58
  "bench": "node bench/run.mjs",
52
59
  "test": "vitest",
53
- "lint": "pnpm run lint:prettier && pnpm run lint:eslint",
54
- "lint:fix": "pnpm run lint:fix:prettier && pnpm run lint:fix:eslint",
60
+ "lint": "pnpm run lint:prettier && pnpm run lint:oxlint",
61
+ "lint:fix": "pnpm run lint:fix:prettier && pnpm run lint:fix:oxlint",
55
62
  "lint:prettier": "prettier --check \"**/*.{ts,js,cjs,md}\"",
56
63
  "lint:fix:prettier": "prettier --write \"**/*.{ts,js,cjs,md}\"",
57
- "lint:eslint": "eslint .",
58
- "lint:fix:eslint": "eslint --fix .",
64
+ "lint:oxlint": "oxlint",
65
+ "lint:fix:oxlint": "oxlint --fix",
59
66
  "build": "rm -rf dist && pnpm run tsc && cp jsx-runtime.d.ts dist/",
60
67
  "tsc": "tsc && tsc -p tests/tsconfig.contract.json",
61
68
  "watch": "tsc -w",
@@ -81,26 +88,20 @@
81
88
  "@solid-primitives/scheduled": "^1.5.3"
82
89
  },
83
90
  "devDependencies": {
84
- "@eslint/js": "^9.39.4",
85
91
  "@lightningtv/vite-hex-transform": "^1.1.0",
86
92
  "@solid-devtools/debugger": "^0.28.1",
87
93
  "@solidjs/testing-library": "^0.8.10",
88
- "@typescript-eslint/eslint-plugin": "^8.59.2",
89
- "@typescript-eslint/parser": "^8.59.2",
90
94
  "@vitest/browser-playwright": "^4.1.6",
91
- "eslint": "^9.39.4",
92
- "eslint-config-prettier": "^9.1.2",
93
- "eslint-plugin-prettier": "^5.5.5",
94
- "globals": "^17.6.0",
95
95
  "husky": "^9.1.7",
96
96
  "jsdom": "^26.1.0",
97
97
  "lint-staged": "^17.0.4",
98
+ "oxlint": "^1.88.0",
99
+ "oxlint-tsgolint": "^7.0.2004",
98
100
  "playwright": "1.56.1",
99
101
  "prettier": "^3.8.3",
100
102
  "release-it": "^20.0.1",
101
103
  "terser": "^5.51.2",
102
- "typescript": "^6.0.3",
103
- "typescript-eslint": "^8.59.2",
104
+ "typescript": "^7.0.2",
104
105
  "vite": "^8.0.13",
105
106
  "vite-plugin-solid": "^2.11.12",
106
107
  "vitest": "^4.1.6"
@@ -108,13 +109,13 @@
108
109
  "lint-staged": {
109
110
  "*.ts": [
110
111
  "prettier --write",
111
- "eslint --fix"
112
+ "oxlint --fix"
112
113
  ],
113
114
  "*.{js,cjs,md}": "prettier --write"
114
115
  },
115
116
  "peerDependencies": {
116
117
  "@solidjs/router": "^0.16.1",
117
- "@solidtv/renderer": "^2.0.0-alpha.3",
118
+ "@solidtv/renderer": "^2.0.7",
118
119
  "solid-js": "*"
119
120
  },
120
121
  "peerDependenciesMeta": {},
@@ -1294,6 +1294,8 @@ function resolveNodeDefaults(
1294
1294
  placeholderColor: props.placeholderColor ?? 0,
1295
1295
  data: {},
1296
1296
  imageType: props.imageType,
1297
+ rtl: props.rtl ?? null,
1298
+ atlasGroup: props.atlasGroup,
1297
1299
  };
1298
1300
  }
1299
1301
 
@@ -1366,7 +1368,7 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1366
1368
  ) {
1367
1369
  super();
1368
1370
 
1369
- // @ts-ignore
1371
+ // @ts-expect-error
1370
1372
  this.div._node = this;
1371
1373
  this.div.setAttribute('data-id', String(this.id));
1372
1374
  elMap.set(this, this.div);
@@ -1826,6 +1828,19 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1826
1828
  set srcY(v) {
1827
1829
  this.props.srcY = v;
1828
1830
  }
1831
+ get atlasGroup() {
1832
+ return this.props.atlasGroup;
1833
+ }
1834
+ set atlasGroup(v) {
1835
+ this.props.atlasGroup = v;
1836
+ }
1837
+ // Stored only: the DOM renderer does not mirror rtl layouts.
1838
+ get rtl() {
1839
+ return this.props.rtl;
1840
+ }
1841
+ set rtl(v) {
1842
+ this.props.rtl = v ?? null;
1843
+ }
1829
1844
 
1830
1845
  get ignoreParentAlpha(): boolean {
1831
1846
  return this.props.ignoreParentAlpha;
@@ -240,16 +240,74 @@ const parseAndAssignShaderProps = (
240
240
  }
241
241
  };
242
242
 
243
+ const assignEffects = (v: StyleEffects, props: Record<string, unknown>) => {
244
+ if (v.rounded) props.radius = v.rounded.radius;
245
+ if (v.borderRadius) props.radius = v.borderRadius;
246
+ for (const k of EFFECT_SHADER_KEYS) {
247
+ if (v[k]) parseAndAssignShaderProps(k, v[k], props);
248
+ }
249
+ };
250
+
251
+ const assignShaderProp = (
252
+ key: string,
253
+ value: unknown,
254
+ props: Record<string, unknown>,
255
+ ) => {
256
+ if (key === 'rounded' || typeof value === 'number') {
257
+ props.radius = value;
258
+ } else {
259
+ parseAndAssignShaderProps(key, value as Record<string, unknown>, props);
260
+ }
261
+ };
262
+
263
+ // The shader types convertToShader makes, by feature bits.
264
+ const BORDER_FEATURE = 1;
265
+ const SHADOW_FEATURE = 2;
266
+ const ROUNDED_SHADER_TYPES = [
267
+ 'rounded',
268
+ 'roundedWithBorder',
269
+ 'roundedWithShadow',
270
+ 'roundedWithBorderWithShadow',
271
+ ];
272
+
273
+ const BORDER_WIDTH_KEYS = [
274
+ 'border-w',
275
+ 'border-top',
276
+ 'border-right',
277
+ 'border-bottom',
278
+ 'border-left',
279
+ ];
280
+
281
+ // Whether a border width is above 0: read from `change` where it has the
282
+ // key, else from `props`. A border of width 0 needs no border shader.
283
+ const hasBorderWidth = (
284
+ props: Record<string, unknown>,
285
+ change?: Record<string, unknown>,
286
+ ) => {
287
+ for (const key of BORDER_WIDTH_KEYS) {
288
+ const w = change !== undefined && key in change ? change[key] : props[key];
289
+ if (isArray(w)) {
290
+ for (let i = 0; i < w.length; i++) if (w[i] > 0) return true;
291
+ } else if ((w as number) > 0) {
292
+ return true;
293
+ }
294
+ }
295
+ return false;
296
+ };
297
+
243
298
  export function convertToShader(
244
- _node: ElementNode,
299
+ node: ElementNode,
245
300
  v: StyleEffects,
246
301
  ): IRendererShader {
247
- let type = 'rounded';
248
- if (v.border) type += 'WithBorder';
249
- if (v.shadow) type += 'WithShadow';
302
+ const props = v as Record<string, unknown>;
303
+ const features =
304
+ (hasBorderWidth(props) ? BORDER_FEATURE : 0) |
305
+ (props.shadow ? SHADOW_FEATURE : 0);
306
+ node._shaderProps = props;
307
+ node._shaderFeatures = features;
250
308
  return renderer.createShader(
251
- type,
252
- v as Record<string, unknown>,
309
+ ROUNDED_SHADER_TYPES[features]!,
310
+ props,
253
311
  ) as IRendererShader;
254
312
  }
255
313
 
@@ -295,6 +353,7 @@ const LightningRendererNumberProps = [
295
353
  const LightningRendererNonAnimatingProps = [
296
354
  'absX',
297
355
  'absY',
356
+ 'atlasGroup',
298
357
  'autosize',
299
358
  'clipping',
300
359
  'contain',
@@ -372,6 +431,10 @@ export interface ElementNode extends RendererNode, FocusNode {
372
431
  _containsFlexGrow?: boolean | null;
373
432
  _hasRenderedChildren?: boolean;
374
433
  _effects?: Record<string, any>;
434
+ /** The props of a shader convertToShader made, kept to swap its type. */
435
+ _shaderProps?: Record<string, unknown>;
436
+ /** That shader's ROUNDED_SHADER_TYPES index: border 1, shadow 2. */
437
+ _shaderFeatures?: number;
375
438
  _fontFamily?: string;
376
439
  _id: string | undefined;
377
440
  _parent: ElementNode | undefined;
@@ -385,6 +448,8 @@ export interface ElementNode extends RendererNode, FocusNode {
385
448
  _display?: 'flex' | 'block';
386
449
  _onLayout?: (this: ElementNode, target: ElementNode) => void;
387
450
  _requiresLayout: boolean;
451
+ /** @internal the focus manager's generation stamp for the focus-path diff */
452
+ _focusGen: number;
388
453
  autosize?: boolean;
389
454
  /**
390
455
  * Optional component name for inspector / dev tooling — emitted by the
@@ -857,6 +922,8 @@ export class ElementNode {
857
922
  this._containsFlexGrow = undefined;
858
923
  this._hasRenderedChildren = undefined;
859
924
  this._effects = undefined;
925
+ this._shaderProps = undefined;
926
+ this._shaderFeatures = undefined;
860
927
  this._fontFamily = undefined;
861
928
  this._fontWeight = undefined;
862
929
  this._id = undefined;
@@ -869,6 +936,7 @@ export class ElementNode {
869
936
  this._display = undefined;
870
937
  this._onLayout = undefined;
871
938
  this._requiresLayout = false;
939
+ this._focusGen = 0;
872
940
  }
873
941
 
874
942
  get effects(): StyleEffects | undefined {
@@ -894,16 +962,39 @@ export class ElementNode {
894
962
  }
895
963
  }
896
964
 
965
+ /**
966
+ * Swap a shader convertToShader made when its border width moves to or
967
+ * from 0. For an animated write, `change` holds what animates: a border
968
+ * it adds is swapped in before the animation reads its start values, one
969
+ * it removes stays until the animation stops.
970
+ */
971
+ _syncShaderType(change?: Record<string, unknown>) {
972
+ const props = this._shaderProps;
973
+ if (props === undefined || !this.lng.shader) return;
974
+ const features = this._shaderFeatures!;
975
+ let next = features & SHADOW_FEATURE;
976
+ if (hasBorderWidth(props, change)) next |= BORDER_FEATURE;
977
+ else if (change !== undefined) next |= features & BORDER_FEATURE;
978
+ if (next === features) return;
979
+ this._shaderFeatures = next;
980
+ this.lng.shader = renderer.createShader(
981
+ ROUNDED_SHADER_TYPES[next]!,
982
+ props,
983
+ ) as IRendererShader;
984
+ }
985
+
897
986
  set effects(v: StyleEffects) {
898
987
  if (!SHADERS_ENABLED) return;
899
988
  let target = this.lng.shader || {};
900
989
  if (this.lng.shader?.props) {
901
990
  target = this.lng.shader.props;
902
991
  }
903
- if (v.rounded) target.radius = v.rounded.radius;
904
- if (v.borderRadius) target.radius = v.borderRadius;
905
- for (const k of EFFECT_SHADER_KEYS) {
906
- if (v[k]) parseAndAssignShaderProps(k, v[k], target);
992
+ assignEffects(v, target);
993
+
994
+ const props = this._shaderProps;
995
+ if (props !== undefined) {
996
+ if (props !== target) assignEffects(v, props);
997
+ this._syncShaderType();
907
998
  }
908
999
 
909
1000
  this._writeShaderTarget(target);
@@ -953,12 +1044,7 @@ export class ElementNode {
953
1044
  }
954
1045
 
955
1046
  this._fontWeight = v;
956
- const weight =
957
- (Config.fontWeightAlias &&
958
- (Config.fontWeightAlias[v as string] as number | string)) ??
959
- v;
960
- (this.lng as ElementNode).fontFamily =
961
- `${this.fontFamily || Config.fontSettings?.fontFamily}${weight}`;
1047
+ this._writeFontFamily();
962
1048
  }
963
1049
 
964
1050
  get fontWeight() {
@@ -967,13 +1053,38 @@ export class ElementNode {
967
1053
 
968
1054
  set fontFamily(v) {
969
1055
  this._fontFamily = v;
970
- (this.lng as ElementNode).fontFamily = v;
1056
+ this._writeFontFamily();
971
1057
  }
972
1058
 
973
1059
  get fontFamily() {
974
1060
  return this._fontFamily;
975
1061
  }
976
1062
 
1063
+ /**
1064
+ * The renderer's family name from `fontFamily` and `fontWeight`, resolved
1065
+ * in one place so either JSX order gives the same name (B17).
1066
+ */
1067
+ _writeFontFamily() {
1068
+ const weight = this._fontWeight as number | string | undefined;
1069
+ if (weight === undefined) {
1070
+ // No family of its own: before render, undefined lets render's font
1071
+ // template fill it in; after render, write what the template gave
1072
+ // (Config.fontSettings' family and weight, read at the first text
1073
+ // render), not undefined, which the renderer takes as its default.
1074
+ const family = this._fontFamily;
1075
+ (this.lng as ElementNode).fontFamily =
1076
+ family === undefined && this.rendered ? _fontFamilyWithWeight : family;
1077
+ return;
1078
+ }
1079
+ const alias = Config.fontWeightAlias;
1080
+ const aliased =
1081
+ alias !== undefined && alias !== null
1082
+ ? (alias[weight] as number | string | undefined)
1083
+ : undefined;
1084
+ (this.lng as ElementNode).fontFamily =
1085
+ `${this._fontFamily || Config.fontSettings?.fontFamily}${aliased ?? weight}`;
1086
+ }
1087
+
977
1088
  insertChild(
978
1089
  node: ElementNode | ElementText | TextNode,
979
1090
  beforeNode?: ElementNode | ElementText | TextNode | null,
@@ -1040,6 +1151,7 @@ export class ElementNode {
1040
1151
  set shader(
1041
1152
  shaderProps: IRendererShader | [kind: string, props: IRendererShaderProps],
1042
1153
  ) {
1154
+ this._shaderProps = undefined;
1043
1155
  this.lng.shader = isArray(shaderProps)
1044
1156
  ? renderer.createShader(...shaderProps)
1045
1157
  : shaderProps;
@@ -1897,16 +2009,26 @@ export function shaderAccessor<T extends Record<string, any> | number>(
1897
2009
  }
1898
2010
  }
1899
2011
 
1900
- if (key === 'rounded' || typeof value === 'number') {
1901
- target.radius = value;
1902
- } else {
1903
- parseAndAssignShaderProps(key, value, target);
2012
+ assignShaderProp(key, value, target);
2013
+
2014
+ const props = this._shaderProps;
2015
+ if (props !== undefined) {
2016
+ const animated = target !== this.lng.shader?.props;
2017
+ if (animated) this._syncShaderType(target);
2018
+ if (props !== target) assignShaderProp(key, value, props);
2019
+ if (!animated) this._syncShaderType();
1904
2020
  }
1905
2021
 
1906
2022
  this._writeShaderTarget(target);
1907
2023
 
1908
2024
  if (animationSettings) {
1909
- this.animate({ shaderProps: target }, animationSettings).start();
2025
+ const animation = this.animate(
2026
+ { shaderProps: target },
2027
+ animationSettings,
2028
+ ).start();
2029
+ if (props !== undefined) {
2030
+ void animation.waitUntilStopped().then(() => this._syncShaderType());
2031
+ }
1910
2032
  }
1911
2033
  },
1912
2034
  get(this: ElementNode) {
@@ -37,6 +37,11 @@ const flattenKeyMap = (
37
37
  newTargetMap[v] = key;
38
38
  });
39
39
  } else if (value === null) {
40
+ // Unmap every key mapped to this name, defaults included (B4). The
41
+ // entry keyed by the name itself goes too, as it always did.
42
+ for (const mapped in newTargetMap) {
43
+ if (newTargetMap[mapped] === key) delete newTargetMap[mapped];
44
+ }
40
45
  delete newTargetMap[key];
41
46
  } else {
42
47
  newTargetMap[value as KeyNameOrKeyCode] = key;
@@ -298,6 +303,9 @@ const updateFocusPath = (
298
303
  let lastGlobalKeyPressTime = 0;
299
304
  let lastInputKey: string | number | undefined;
300
305
 
306
+ // Per-element throttleInput applies to key presses only, like the global
307
+ // Config.throttleInput: a release is never dropped and never starts a window
308
+ // (B3).
301
309
  const isElementThrottled = (
302
310
  elm: ElementNode,
303
311
  sameKey: boolean,
@@ -372,14 +380,14 @@ const propagateKeyPress = (
372
380
 
373
381
  for (let i = fp.length - 1; i >= 0; i--) {
374
382
  const elm = fp[i]!;
375
- if (isElementThrottled(elm, sameKey, currentTime)) return true;
383
+ if (!isUp && isElementThrottled(elm, sameKey, currentTime)) return true;
376
384
 
377
385
  const captureHandler = elm[captureEvent] || elm[captureKey];
378
386
  if (
379
387
  isFunction(captureHandler) &&
380
388
  captureHandler.call(elm, e, elm, finalFocusElm, mappedEvent) === true
381
389
  ) {
382
- elm._lastAnyKeyPressTime = currentTime;
390
+ if (!isUp) elm._lastAnyKeyPressTime = currentTime;
383
391
  return true;
384
392
  }
385
393
  }
@@ -393,7 +401,7 @@ const propagateKeyPress = (
393
401
 
394
402
  for (let i = 0; i < fp.length; i++) {
395
403
  const elm = fp[i]!;
396
- if (isElementThrottled(elm, sameKey, currentTime)) return true;
404
+ if (!isUp && isElementThrottled(elm, sameKey, currentTime)) return true;
397
405
 
398
406
  let handled = false;
399
407
  if (eventHandlerKey) {
@@ -414,7 +422,7 @@ const propagateKeyPress = (
414
422
  }
415
423
 
416
424
  if (handled) {
417
- elm._lastAnyKeyPressTime = currentTime;
425
+ if (!isUp) elm._lastAnyKeyPressTime = currentTime;
418
426
  return true;
419
427
  }
420
428
  }
@@ -11,6 +11,71 @@ export let renderer: lng.RendererMain | DOMRendererMain;
11
11
 
12
12
  export const getRenderer = () => renderer;
13
13
 
14
+ // @solidtv/renderer 2.0 has one engine (WebGL) and one text engine (SDF), so
15
+ // these settings are gone; apps written for 1.x still pass them.
16
+ const REMOVED_SETTINGS = ['renderEngine', 'fontEngines'];
17
+
18
+ const warned: { [message: string]: true | undefined } = {};
19
+
20
+ /** `console.warn`, once per page, in every build (not only in dev). */
21
+ function warnOnce(message: string) {
22
+ if (warned[message] !== true) {
23
+ warned[message] = true;
24
+ console.warn(message);
25
+ }
26
+ }
27
+
28
+ /**
29
+ * `options` without the settings 2.0 removed, each warned about once. The
30
+ * app's own object is not touched: the same object is returned when it has
31
+ * none of them, a copy when it does.
32
+ */
33
+ function withoutRemovedSettings<T extends object>(options: T): T {
34
+ const source = options as { [name: string]: unknown };
35
+ let found = false;
36
+ for (let i = 0; i < REMOVED_SETTINGS.length; i++) {
37
+ const name = REMOVED_SETTINGS[i]!;
38
+ if (source[name] !== undefined) {
39
+ found = true;
40
+ warnOnce(
41
+ '[solid] Config.rendererOptions.' +
42
+ name +
43
+ ' was removed in @solidtv/renderer 2.0 and is ignored',
44
+ );
45
+ }
46
+ }
47
+ if (found === false) {
48
+ return options;
49
+ }
50
+
51
+ const copy: { [name: string]: unknown } = {};
52
+ const keys = Object.keys(source);
53
+ for (let i = 0; i < keys.length; i++) {
54
+ const key = keys[i]!;
55
+ if (REMOVED_SETTINGS.indexOf(key) === -1) {
56
+ copy[key] = source[key];
57
+ }
58
+ }
59
+ return copy as T;
60
+ }
61
+
62
+ /**
63
+ * 1.10's `renderer.stage.shManager.registerShaderType(...)`: in 2.0 the stage
64
+ * is the renderer and `registerShaderType` is on it. Defined once, here, as an
65
+ * alias of the renderer; it warns the first time an app reads it.
66
+ */
67
+ function aliasShManager(rendererMain: lng.RendererMain) {
68
+ Object.defineProperty(rendererMain, 'shManager', {
69
+ configurable: true,
70
+ get() {
71
+ warnOnce(
72
+ '[solid] renderer.stage.shManager was removed in @solidtv/renderer 2.0: use renderer.registerShaderType',
73
+ );
74
+ return rendererMain;
75
+ },
76
+ });
77
+ }
78
+
14
79
  export function startLightningRenderer(
15
80
  options: lng.RendererMainSettings | DomRendererMainSettings,
16
81
  rootId: string | HTMLElement = 'app',
@@ -18,10 +83,19 @@ export function startLightningRenderer(
18
83
  // Inlined (not isDomRendererActive()) so bundlers can fold DOM_RENDERING to
19
84
  // false and drop the DOMRendererMain branch + import in WebGL builds.
20
85
  const enableDomRenderer = DOM_RENDERING && Config.domRendererEnabled;
21
-
22
- renderer = enableDomRenderer
23
- ? new DOMRendererMain(options, rootId)
24
- : new lng.RendererMain(options, rootId);
86
+ const settings = withoutRemovedSettings(options);
87
+
88
+ if (enableDomRenderer) {
89
+ // Its stage has its own (inert) shManager.
90
+ renderer = new DOMRendererMain(settings, rootId);
91
+ } else {
92
+ const rendererMain = new lng.RendererMain(
93
+ settings as lng.RendererMainSettings,
94
+ rootId,
95
+ );
96
+ aliasShManager(rendererMain);
97
+ renderer = rendererMain;
98
+ }
25
99
 
26
100
  // A stage now exists, so any fonts requested before this point can finish.
27
101
  flushPendingFonts();
@@ -8,11 +8,14 @@ export const NodeType = {
8
8
  export type NodeTypes = (typeof NodeType)[keyof typeof NodeType];
9
9
 
10
10
  export class TextNode {
11
- readonly _type = 'text' as const;
12
- parent: ElementText | undefined = undefined;
13
- text: string;
11
+ // Assigned in the constructor, not class fields (design 3.6.5).
12
+ declare readonly _type: 'text';
13
+ declare parent: ElementText | undefined;
14
+ declare text: string;
14
15
 
15
16
  constructor(text: string) {
17
+ this._type = 'text';
18
+ this.parent = undefined;
16
19
  this.text = text;
17
20
  }
18
21
  }
@@ -150,11 +150,18 @@ function createLazy<T>(
150
150
  // proximity check must use child units.
151
151
  const rendered = container.children.length;
152
152
 
153
+ // B16: the mount lands only after this press (the key handler's writes
154
+ // are batched), so it has to start while this press's move still has a
155
+ // child to land on: a buffer below 2 acts as 2. With buffer 1 the press
156
+ // that reached the rendered edge found no child and bubbled, so every
157
+ // other press was lost.
158
+ const edge = Math.max(buffer(), 2);
159
+
153
160
  // Already mounted everything (offset is in data units — a diverged child
154
161
  // count must neither stop mounting early nor keep it running forever),
155
162
  // or still far enough from the rendered edge that the buffer covers the
156
163
  // next selection — no work to do.
157
- if (offset() >= maxOffset || selected < rendered - buffer()) return;
164
+ if (offset() >= maxOffset || selected < rendered - edge) return;
158
165
 
159
166
  const bump = () => setOffset((prev) => Math.min(prev + 1, maxOffset));
160
167