@solidtv/solid 1.1.3 → 1.3.0-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 (70) hide show
  1. package/README.md +2 -2
  2. package/dist/src/core/config.d.ts +13 -1
  3. package/dist/src/core/config.js +13 -1
  4. package/dist/src/core/config.js.map +1 -1
  5. package/dist/src/core/dom-renderer/domRenderer.js +1 -0
  6. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  7. package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
  8. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
  9. package/dist/src/core/elementNode.d.ts +10 -4
  10. package/dist/src/core/elementNode.js +60 -49
  11. package/dist/src/core/elementNode.js.map +1 -1
  12. package/dist/src/core/flex.js +124 -52
  13. package/dist/src/core/flex.js.map +1 -1
  14. package/dist/src/core/focusKeyTypes.d.ts +14 -0
  15. package/dist/src/core/focusManager.d.ts +19 -9
  16. package/dist/src/core/focusManager.js +125 -101
  17. package/dist/src/core/focusManager.js.map +1 -1
  18. package/dist/src/core/lightningInit.js +3 -0
  19. package/dist/src/core/lightningInit.js.map +1 -1
  20. package/dist/src/core/shaders.js +10 -10
  21. package/dist/src/core/shaders.js.map +1 -1
  22. package/dist/src/core/utils.d.ts +0 -1
  23. package/dist/src/core/utils.js +0 -1
  24. package/dist/src/core/utils.js.map +1 -1
  25. package/dist/src/index.d.ts +1 -1
  26. package/dist/src/index.js +1 -1
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/src/primitives/FadeInOut.jsx +1 -2
  29. package/dist/src/primitives/FadeInOut.jsx.map +1 -1
  30. package/dist/src/primitives/useFocusManager.d.ts +1 -5
  31. package/dist/src/primitives/useFocusManager.js +1 -20
  32. package/dist/src/primitives/useFocusManager.js.map +1 -1
  33. package/dist/src/primitives/useHold.d.ts +1 -1
  34. package/dist/src/primitives/useHold.js +1 -1
  35. package/dist/src/primitives/useMouse.js +4 -4
  36. package/dist/src/primitives/useMouse.js.map +1 -1
  37. package/dist/src/render.d.ts +6 -0
  38. package/dist/src/render.js +7 -3
  39. package/dist/src/render.js.map +1 -1
  40. package/dist/src/solidOpts.d.ts +1 -1
  41. package/dist/src/solidOpts.js +4 -23
  42. package/dist/src/solidOpts.js.map +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/docs/AI_CODING_GUIDELINES.md +7 -7
  45. package/package.json +2 -2
  46. package/src/core/config.ts +15 -2
  47. package/src/core/dom-renderer/domRenderer.ts +1 -0
  48. package/src/core/dom-renderer/domRendererUtils.ts +2 -2
  49. package/src/core/elementNode.ts +66 -46
  50. package/src/core/flex.ts +135 -56
  51. package/src/core/focusKeyTypes.ts +14 -0
  52. package/src/core/focusManager.ts +183 -139
  53. package/src/core/lightningInit.ts +3 -0
  54. package/src/core/shaders.ts +10 -10
  55. package/src/core/utils.ts +0 -3
  56. package/src/index.ts +1 -1
  57. package/src/primitives/FadeInOut.tsx +2 -2
  58. package/src/primitives/useFocusManager.ts +5 -44
  59. package/src/primitives/useHold.ts +1 -1
  60. package/src/primitives/useMouse.ts +4 -4
  61. package/src/render.ts +7 -3
  62. package/src/solidOpts.ts +4 -25
  63. package/dist/src/activeElement.d.ts +0 -2
  64. package/dist/src/activeElement.js +0 -3
  65. package/dist/src/activeElement.js.map +0 -1
  66. package/dist/src/core/flexLayout.d.ts +0 -2
  67. package/dist/src/core/flexLayout.js +0 -356
  68. package/dist/src/core/flexLayout.js.map +0 -1
  69. package/src/activeElement.ts +0 -5
  70. package/src/core/flexLayout.ts +0 -410
@@ -6,7 +6,7 @@
6
6
 
7
7
  - **Environment:** TV app development over WebGL (not the DOM). No pointer input; interaction is directional (Up/Down/Left/Right).
8
8
  - **Reactivity:** Uses SolidTV primitives (`createSignal`, `createEffect`, `createMemo`).
9
- - **Primitives:** UI is built using custom components like `<View>`, `<Text>`, `<Row>`, `<Column>`.
9
+ - **Primitives:** UI is built using the intrinsic elements `<view>` and `<text>` (no import needed — they're registered with the renderer) plus layout components like `<Row>` and `<Column>` from `@solidtv/solid/primitives`.
10
10
  - **Patterns:** Always use functional components and modern TypeScript/JSX. Avoid classes.
11
11
  - **Assumption:** Always frame answers within the context of SolidTV + SolidTV TV environment.
12
12
 
@@ -76,7 +76,7 @@
76
76
 
77
77
  ```tsx
78
78
  // Missing dimensions, invalid colors, using styles, directional padding
79
- <View
79
+ <view
80
80
  style={{
81
81
  backgroundColor: 'red',
82
82
  paddingLeft: 20,
@@ -84,8 +84,8 @@
84
84
  display: 'flex',
85
85
  }}
86
86
  >
87
- <Text textColor="white">Hello</Text>
88
- </View>
87
+ <text textColor="white">Hello</text>
88
+ </view>
89
89
  ```
90
90
 
91
91
  **✅ Correct:**
@@ -94,7 +94,7 @@
94
94
  const [focused, setFocused] = createSignal(false);
95
95
 
96
96
  // Uses direct props, hex colors, clear dimensions, and focus tracking
97
- <View
97
+ <view
98
98
  width={400}
99
99
  height={200}
100
100
  color={focused() ? '#ffff00ff' : '#ff0000ff'}
@@ -103,6 +103,6 @@ const [focused, setFocused] = createSignal(false);
103
103
  display="flex"
104
104
  onFocusChanged={setFocused}
105
105
  >
106
- <Text color="#ffffffff">Hello</Text>
107
- </View>;
106
+ <text color="#ffffffff">Hello</text>
107
+ </view>;
108
108
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.1.3",
3
+ "version": "1.3.0-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.1.2",
112
+ "@solidtv/renderer": "^1.2.3",
113
113
  "solid-js": "*"
114
114
  },
115
115
  "peerDependenciesMeta": {},
@@ -33,6 +33,21 @@ export const SHADERS_ENABLED =
33
33
  typeof SOLIDTV_DISABLE_SHADERS === 'undefined' ||
34
34
  SOLIDTV_DISABLE_SHADERS !== true;
35
35
 
36
+ /**
37
+ * True when the DOM renderer is both built in (`DOM_RENDERING`) and turned on
38
+ * at runtime (`Config.domRendererEnabled`). `Config.domRendererEnabled` is
39
+ * mutable up until the renderer starts, so this is a function rather than a
40
+ * constant.
41
+ *
42
+ * NOTE: do not use this to gate code paths whose dead-code elimination matters
43
+ * (e.g. branches that reference DOM-renderer-only modules). Bundlers don't
44
+ * inline this call, so the gated branch — and its imports — stay live. In
45
+ * those spots inline `DOM_RENDERING && Config.domRendererEnabled` so the
46
+ * `DOM_RENDERING` build constant can collapse the branch.
47
+ */
48
+ export const isDomRendererActive = () =>
49
+ DOM_RENDERING && Config.domRendererEnabled;
50
+
36
51
  /**
37
52
  RUNTIME LIGHTNING CONFIGURATION \
38
53
  This configuration can be set at runtime, but it is recommended to set it
@@ -48,7 +63,6 @@ export interface Config {
48
63
  animationsEnabled: boolean;
49
64
  fontSettings: Partial<TextProps>;
50
65
  rendererOptions?: Partial<RendererMainSettings> | DomRendererMainSettings;
51
- setActiveElement: (elm: ElementNode) => void;
52
66
  focusStateKey: DollarString;
53
67
  lockStyles?: boolean;
54
68
  fontWeightAlias?: Record<string, number | string>;
@@ -83,7 +97,6 @@ export const Config: Config = {
83
97
  bold: 700,
84
98
  black: 900,
85
99
  },
86
- setActiveElement: () => {},
87
100
  focusStateKey: '$focus',
88
101
  lockStyles: true,
89
102
  rendererOptions: {},
@@ -1137,6 +1137,7 @@ function updateDOMTextSize(node: DOMText, emitLoaded = true): void {
1137
1137
  w: node.w,
1138
1138
  h: node.h,
1139
1139
  },
1140
+ trimmedHeight: node.h,
1140
1141
  };
1141
1142
  node.emit('loaded', payload);
1142
1143
  node.loaded = true;
@@ -2,7 +2,7 @@
2
2
  import * as lng from '@solidtv/renderer';
3
3
  import { Config } from '../config.js';
4
4
  import { DOMNode } from './domRenderer.js';
5
- import { isFunc } from '../utils.js';
5
+ import { isFunction } from '../utils.js';
6
6
 
7
7
  // #region Color & Gradient Utils
8
8
 
@@ -160,7 +160,7 @@ export function applyEasing(
160
160
  easing: string | lng.TimingFunction,
161
161
  progress: number,
162
162
  ): number {
163
- if (isFunc(easing)) {
163
+ if (isFunction(easing)) {
164
164
  return easing(progress);
165
165
  }
166
166
 
@@ -16,16 +16,10 @@ import {
16
16
  type DollarString,
17
17
  } from './intrinsicTypes.js';
18
18
  import States, { type NodeStates } from './states.js';
19
- import calculateFlexOld from './flex.js';
20
- import calculateFlexNew from './flexLayout.js';
21
-
22
- const calculateFlex = import.meta.env?.VITE_USE_NEW_FLEX
23
- ? calculateFlexNew
24
- : calculateFlexOld;
19
+ import calculateFlex from './flex.js';
25
20
  import {
26
21
  log,
27
22
  isArray,
28
- isFunc,
29
23
  keyExists,
30
24
  isINode,
31
25
  isElementNode,
@@ -34,7 +28,12 @@ import {
34
28
  isFunction,
35
29
  spliceItem,
36
30
  } from './utils.js';
37
- import { Config, DOM_RENDERING, isDev, SHADERS_ENABLED } from './config.js';
31
+ import {
32
+ Config,
33
+ isDev,
34
+ SHADERS_ENABLED,
35
+ isDomRendererActive,
36
+ } from './config.js';
38
37
  import type {
39
38
  RendererMain,
40
39
  INode,
@@ -78,9 +77,20 @@ let postMutationQueued = false;
78
77
  let nextActiveElement: ElementNode | null = null;
79
78
  let deferredFocusElement: ElementNode | null = null;
80
79
  const layoutQueue = new Set<ElementNode>();
81
- export const elementDeleteQueue: ElementNode[] = [];
80
+ const elementDeleteQueue: ElementNode[] = [];
82
81
 
83
- export function schedulePostMutation() {
82
+ export function enqueueDelete(node: ElementNode, n: number): void {
83
+ if (node._queueDelete === undefined) {
84
+ node._queueDelete = n;
85
+ if (elementDeleteQueue.push(node) === 1) {
86
+ schedulePostMutation();
87
+ }
88
+ } else {
89
+ node._queueDelete += n;
90
+ }
91
+ }
92
+
93
+ function schedulePostMutation() {
84
94
  if (postMutationQueued) return;
85
95
  postMutationQueued = true;
86
96
  if ('reprocessUpdates' in renderer.stage && renderer.stage.reprocessUpdates) {
@@ -95,7 +105,7 @@ function runPostMutation() {
95
105
  // Phase 1: delete-flush
96
106
  if (elementDeleteQueue.length > 0) {
97
107
  for (const el of elementDeleteQueue) {
98
- if (Number(el._queueDelete) < 0) {
108
+ if ((el._queueDelete ?? 0) < 0) {
99
109
  el.destroy();
100
110
  }
101
111
  el._queueDelete = undefined;
@@ -153,6 +163,15 @@ function buildFontTemplate() {
153
163
  _fontTemplate = tpl;
154
164
  }
155
165
 
166
+ const EFFECT_SHADER_KEYS = [
167
+ 'border',
168
+ 'borderTop',
169
+ 'borderRight',
170
+ 'borderBottom',
171
+ 'borderLeft',
172
+ 'shadow',
173
+ ] as const satisfies ReadonlyArray<keyof StyleEffects>;
174
+
156
175
  const parseAndAssignShaderProps = (
157
176
  prefix: string,
158
177
  obj: Record<string, unknown>,
@@ -200,7 +219,7 @@ function getPropertyAlias(name: string) {
200
219
  return name;
201
220
  }
202
221
 
203
- export const LightningRendererNumberProps = [
222
+ const LightningRendererNumberProps = [
204
223
  'alpha',
205
224
  'color',
206
225
  'colorTop',
@@ -299,7 +318,6 @@ export interface ElementNode extends RendererNode, FocusNode {
299
318
  // Properties
300
319
  /** @internal for managing series of insertions and deletions */
301
320
  _queueDelete?: number;
302
- preserve?: boolean;
303
321
  _animationQueue?:
304
322
  | Array<{
305
323
  props: Partial<INodeAnimateProps<CoreShaderNode>>;
@@ -806,6 +824,25 @@ export class ElementNode {
806
824
  return this.lng.shader;
807
825
  }
808
826
 
827
+ /**
828
+ * Commit a built shader-props target back to `this.lng.shader`. When the
829
+ * node is already rendered we either convert the props into a real shader
830
+ * (first time) or self-assign so the DOM renderer's setter reapplies style;
831
+ * pre-render we just attach the bag for the upcoming `render()`.
832
+ */
833
+ _writeShaderTarget(target: unknown) {
834
+ if (this.rendered) {
835
+ if (!this.lng.shader) {
836
+ this.lng.shader = Config.convertToShader(this, target as StyleEffects);
837
+ } else if (isDomRendererActive()) {
838
+ // eslint-disable-next-line no-self-assign -- lng.shader is a setter, force style update
839
+ this.lng.shader = this.lng.shader;
840
+ }
841
+ } else {
842
+ this.lng.shader = target;
843
+ }
844
+ }
845
+
809
846
  set effects(v: StyleEffects) {
810
847
  if (!SHADERS_ENABLED) return;
811
848
  let target = this.lng.shader || {};
@@ -814,27 +851,11 @@ export class ElementNode {
814
851
  }
815
852
  if (v.rounded) target.radius = v.rounded.radius;
816
853
  if (v.borderRadius) target.radius = v.borderRadius;
817
- if (v.border) parseAndAssignShaderProps('border', v.border, target);
818
- if (v.borderTop)
819
- parseAndAssignShaderProps('borderTop', v.borderTop, target);
820
- if (v.borderRight)
821
- parseAndAssignShaderProps('borderRight', v.borderRight, target);
822
- if (v.borderBottom)
823
- parseAndAssignShaderProps('borderBottom', v.borderBottom, target);
824
- if (v.borderLeft)
825
- parseAndAssignShaderProps('borderLeft', v.borderLeft, target);
826
- if (v.shadow) parseAndAssignShaderProps('shadow', v.shadow, target);
827
-
828
- if (this.rendered) {
829
- if (!this.lng.shader) {
830
- this.lng.shader = Config.convertToShader(this, target);
831
- } else if (DOM_RENDERING && Config.domRendererEnabled) {
832
- // eslint-disable-next-line no-self-assign -- lng.shader is a setter, force style update
833
- this.lng.shader = this.lng.shader;
834
- }
835
- } else {
836
- this.lng.shader = target;
854
+ for (const k of EFFECT_SHADER_KEYS) {
855
+ if (v[k]) parseAndAssignShaderProps(k, v[k], target);
837
856
  }
857
+
858
+ this._writeShaderTarget(target);
838
859
  }
839
860
 
840
861
  set id(id: string) {
@@ -1094,7 +1115,7 @@ export class ElementNode {
1094
1115
  if (this.rendered) {
1095
1116
  // can be 0
1096
1117
  if (this.forwardFocus !== undefined) {
1097
- if (isFunc(this.forwardFocus)) {
1118
+ if (isFunction(this.forwardFocus)) {
1098
1119
  if (this.forwardFocus.call(this, this) !== false) {
1099
1120
  return;
1100
1121
  }
@@ -1274,6 +1295,14 @@ export class ElementNode {
1274
1295
  return this.alpha === 0;
1275
1296
  }
1276
1297
 
1298
+ get preserve(): boolean {
1299
+ return this._queueDelete === 0;
1300
+ }
1301
+
1302
+ set preserve(v: boolean) {
1303
+ this._queueDelete = v ? 0 : undefined;
1304
+ }
1305
+
1277
1306
  /**
1278
1307
  * Sets the autofocus state of the element.
1279
1308
  * When set to a truthy value, the element will automatically gain focus.
@@ -1352,7 +1381,7 @@ export class ElementNode {
1352
1381
  const flexChanged = this.display === 'flex' && calculateFlex(this);
1353
1382
  layoutQueue.delete(this);
1354
1383
  const onLayoutChanged =
1355
- isFunc(this.onLayout) && this.onLayout.call(this, this);
1384
+ isFunction(this.onLayout) && this.onLayout.call(this, this);
1356
1385
 
1357
1386
  if ((flexChanged || onLayoutChanged) && this.parent) {
1358
1387
  addToLayoutQueue(this.parent);
@@ -1364,7 +1393,7 @@ export class ElementNode {
1364
1393
  if (c.display === 'flex' && isElementNode(c)) {
1365
1394
  // calculating directly to prevent infinite loops recalculating parents
1366
1395
  calculateFlex(c);
1367
- isFunc(c.onLayout) && c.onLayout.call(c, c);
1396
+ isFunction(c.onLayout) && c.onLayout.call(c, c);
1368
1397
  addToLayoutQueue(this);
1369
1398
  }
1370
1399
  });
@@ -1774,16 +1803,7 @@ export function shaderAccessor<T extends Record<string, any> | number>(
1774
1803
  parseAndAssignShaderProps(key, value, target);
1775
1804
  }
1776
1805
 
1777
- if (this.rendered) {
1778
- if (!this.lng.shader) {
1779
- this.lng.shader = Config.convertToShader(this, target);
1780
- } else if (DOM_RENDERING && Config.domRendererEnabled) {
1781
- // eslint-disable-next-line no-self-assign -- lng.shader is a setter, force style update
1782
- this.lng.shader = this.lng.shader;
1783
- }
1784
- } else {
1785
- this.lng.shader = target;
1786
- }
1806
+ this._writeShaderTarget(target);
1787
1807
 
1788
1808
  if (animationSettings) {
1789
1809
  this.animate({ shaderProps: target }, animationSettings).start();