@lightningtv/solid 3.0.0-20 → 3.0.0-22

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 (134) hide show
  1. package/dist/src/activeElement.d.ts +1 -1
  2. package/dist/src/core/animation.d.ts +35 -0
  3. package/dist/src/core/animation.js +119 -0
  4. package/dist/src/core/animation.js.map +1 -0
  5. package/dist/src/core/config.d.ts +47 -0
  6. package/dist/src/core/config.js +23 -0
  7. package/dist/src/core/config.js.map +1 -0
  8. package/dist/src/core/dom-renderer/domRenderer.d.ts +137 -0
  9. package/dist/src/core/dom-renderer/domRenderer.js +1545 -0
  10. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -0
  11. package/dist/src/core/dom-renderer/domRendererTypes.d.ts +117 -0
  12. package/dist/src/core/dom-renderer/domRendererTypes.js +2 -0
  13. package/dist/src/core/dom-renderer/domRendererTypes.js.map +1 -0
  14. package/dist/src/core/dom-renderer/domRendererUtils.d.ts +16 -0
  15. package/dist/src/core/dom-renderer/domRendererUtils.js +132 -0
  16. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -0
  17. package/dist/src/core/domRenderer.d.ts +117 -0
  18. package/dist/src/core/domRenderer.js +1160 -0
  19. package/dist/src/core/domRenderer.js.map +1 -0
  20. package/dist/src/core/elementNode.d.ts +463 -0
  21. package/dist/src/core/elementNode.js +830 -0
  22. package/dist/src/core/elementNode.js.map +1 -0
  23. package/dist/src/core/flex.d.ts +2 -0
  24. package/dist/src/core/flex.js +243 -0
  25. package/dist/src/core/flex.js.map +1 -0
  26. package/dist/src/core/focusKeyTypes.d.ts +42 -0
  27. package/dist/src/core/focusKeyTypes.js +2 -0
  28. package/dist/src/core/focusKeyTypes.js.map +1 -0
  29. package/dist/src/core/focusManager.d.ts +13 -0
  30. package/dist/src/core/focusManager.js +276 -0
  31. package/dist/src/core/focusManager.js.map +1 -0
  32. package/dist/src/core/index.d.ts +12 -0
  33. package/dist/src/core/index.js +12 -0
  34. package/dist/src/core/index.js.map +1 -0
  35. package/dist/src/core/intrinsicTypes.d.ts +90 -0
  36. package/dist/src/core/intrinsicTypes.js +2 -0
  37. package/dist/src/core/intrinsicTypes.js.map +1 -0
  38. package/dist/src/core/lightningInit.d.ts +89 -0
  39. package/dist/src/core/lightningInit.js +26 -0
  40. package/dist/src/core/lightningInit.js.map +1 -0
  41. package/dist/src/core/nodeTypes.d.ts +6 -0
  42. package/dist/src/core/nodeTypes.js +6 -0
  43. package/dist/src/core/nodeTypes.js.map +1 -0
  44. package/dist/src/core/shaders.d.ts +51 -0
  45. package/dist/src/core/shaders.js +446 -0
  46. package/dist/src/core/shaders.js.map +1 -0
  47. package/dist/src/core/states.d.ts +12 -0
  48. package/dist/src/core/states.js +84 -0
  49. package/dist/src/core/states.js.map +1 -0
  50. package/dist/src/core/timings.d.ts +36 -0
  51. package/dist/src/core/timings.js +199 -0
  52. package/dist/src/core/timings.js.map +1 -0
  53. package/dist/src/core/utils.d.ts +39 -0
  54. package/dist/src/core/utils.js +164 -0
  55. package/dist/src/core/utils.js.map +1 -0
  56. package/dist/src/devtools/index.d.ts +1 -1
  57. package/dist/src/devtools/index.js +1 -1
  58. package/dist/src/devtools/index.js.map +1 -1
  59. package/dist/src/index.d.ts +3 -3
  60. package/dist/src/index.js +1 -1
  61. package/dist/src/index.js.map +1 -1
  62. package/dist/src/primitives/FPSCounter.jsx +14 -1
  63. package/dist/src/primitives/FPSCounter.jsx.map +1 -1
  64. package/dist/src/primitives/Lazy.d.ts +1 -1
  65. package/dist/src/primitives/Lazy.jsx +5 -2
  66. package/dist/src/primitives/Lazy.jsx.map +1 -1
  67. package/dist/src/primitives/Row.jsx.map +1 -1
  68. package/dist/src/primitives/Virtual.jsx +2 -2
  69. package/dist/src/primitives/Virtual.jsx.map +1 -1
  70. package/dist/src/primitives/VirtualGrid.jsx +26 -5
  71. package/dist/src/primitives/VirtualGrid.jsx.map +1 -1
  72. package/dist/src/primitives/index.d.ts +1 -1
  73. package/dist/src/primitives/types.d.ts +2 -2
  74. package/dist/src/primitives/useFocusManager.d.ts +2 -2
  75. package/dist/src/primitives/useFocusManager.js +2 -2
  76. package/dist/src/primitives/useFocusManager.js.map +1 -1
  77. package/dist/src/primitives/useMouse.d.ts +2 -9
  78. package/dist/src/primitives/useMouse.js +30 -12
  79. package/dist/src/primitives/useMouse.js.map +1 -1
  80. package/dist/src/primitives/utils/createSpriteMap.d.ts +1 -1
  81. package/dist/src/primitives/utils/createSpriteMap.js +3 -3
  82. package/dist/src/primitives/utils/createSpriteMap.js.map +1 -1
  83. package/dist/src/primitives/utils/handleNavigation.d.ts +2 -8
  84. package/dist/src/primitives/utils/handleNavigation.js +5 -5
  85. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  86. package/dist/src/primitives/utils/withScrolling.d.ts +8 -3
  87. package/dist/src/primitives/utils/withScrolling.js +43 -3
  88. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  89. package/dist/src/render.d.ts +5 -5
  90. package/dist/src/render.js +1 -1
  91. package/dist/src/render.js.map +1 -1
  92. package/dist/src/solidOpts.d.ts +1 -8
  93. package/dist/src/solidOpts.js +1 -1
  94. package/dist/src/solidOpts.js.map +1 -1
  95. package/dist/src/types.d.ts +1 -13
  96. package/dist/src/utils.d.ts +1 -1
  97. package/dist/src/utils.js +1 -1
  98. package/dist/src/utils.js.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/jsx-runtime.d.ts +1 -1
  101. package/package.json +8 -12
  102. package/src/activeElement.ts +1 -1
  103. package/src/core/animation.ts +185 -0
  104. package/src/core/config.ts +77 -0
  105. package/src/core/domRenderer.ts +1308 -0
  106. package/src/core/elementNode.ts +1449 -0
  107. package/src/core/flex.ts +284 -0
  108. package/src/core/focusKeyTypes.ts +87 -0
  109. package/src/core/focusManager.ts +369 -0
  110. package/src/core/index.ts +13 -0
  111. package/src/core/intrinsicTypes.ts +199 -0
  112. package/src/core/lightningInit.ts +147 -0
  113. package/src/core/nodeTypes.ts +6 -0
  114. package/src/core/shaders.ts +567 -0
  115. package/src/core/states.ts +91 -0
  116. package/src/core/utils.ts +222 -0
  117. package/src/devtools/index.ts +1 -1
  118. package/src/index.ts +3 -3
  119. package/src/primitives/FPSCounter.tsx +15 -1
  120. package/src/primitives/Lazy.tsx +8 -2
  121. package/src/primitives/Row.tsx +3 -3
  122. package/src/primitives/Virtual.tsx +2 -2
  123. package/src/primitives/VirtualGrid.tsx +26 -5
  124. package/src/primitives/index.ts +1 -1
  125. package/src/primitives/types.ts +2 -2
  126. package/src/primitives/useFocusManager.ts +3 -3
  127. package/src/primitives/useMouse.ts +48 -26
  128. package/src/primitives/utils/createSpriteMap.ts +3 -3
  129. package/src/primitives/utils/handleNavigation.ts +6 -13
  130. package/src/primitives/utils/withScrolling.ts +47 -5
  131. package/src/render.ts +1 -1
  132. package/src/solidOpts.ts +1 -9
  133. package/src/types.ts +1 -15
  134. package/src/utils.ts +1 -1
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@lightningtv/solid",
3
- "version": "3.0.0-20",
3
+ "version": "3.0.0-22",
4
4
  "description": "Lightning Renderer for Solid Universal",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
+ "@lightningtv/source": "./src/index.ts",
8
9
  "import": {
9
- "@lightningtv/source": "./src/index.ts",
10
10
  "types": "./dist/src/index.d.ts",
11
11
  "default": "./dist/src/index.js"
12
12
  }
13
13
  },
14
14
  "./primitives": {
15
+ "@lightningtv/source": "./src/primitives/index.ts",
15
16
  "import": {
16
- "@lightningtv/source": "./src/primitives/index.ts",
17
17
  "types": "./dist/src/primitives/index.d.ts",
18
18
  "default": "./dist/src/primitives/index.js"
19
19
  }
20
20
  },
21
21
  "./devtools": {
22
+ "@lightningtv/source": "./src/devtools/index.ts",
22
23
  "import": {
23
- "@lightningtv/source": "./src/devtools/index.ts",
24
24
  "types": "./dist/src/devtools/index.d.ts",
25
25
  "default": "./dist/src/devtools/index.js"
26
26
  }
@@ -42,7 +42,7 @@
42
42
  "watch": "tsc -w",
43
43
  "prepare": "husky",
44
44
  "prepack": "npm run build",
45
- "release": "release-it --only-version",
45
+ "release": "release-it",
46
46
  "test:browser": "vitest --config=vitest.browser.config.ts"
47
47
  },
48
48
  "keywords": [
@@ -55,18 +55,16 @@
55
55
  "author": "Chris Lorenzo",
56
56
  "license": "Apache-2.0",
57
57
  "dependencies": {
58
- "@lightningjs/renderer": "3.0.0-beta16",
59
- "@lightningtv/core": "3.0.0-20",
58
+ "@lightningjs/renderer": "3.0.0-beta18",
60
59
  "@lightningtv/solid": "link:",
61
60
  "@solid-primitives/event-listener": "^2.3.3",
62
- "@solid-primitives/keyed": "^1.5.2",
63
61
  "@solid-primitives/list": "^0.1.2",
64
62
  "@solid-primitives/mouse": "^2.0.20",
65
63
  "@solid-primitives/scheduled": "^1.4.4"
66
64
  },
67
65
  "devDependencies": {
68
66
  "@eslint/js": "^9.16.0",
69
- "@solid-devtools/debugger": "^0.27.0",
67
+ "@solid-devtools/debugger": "^0.28.1",
70
68
  "@solidjs/testing-library": "^0.8.10",
71
69
  "@typescript-eslint/eslint-plugin": "^8.17.0",
72
70
  "@typescript-eslint/parser": "^8.17.0",
@@ -96,9 +94,7 @@
96
94
  "@solidjs/router": "^0.15.1",
97
95
  "solid-js": "*"
98
96
  },
99
- "optionalDependencies": {
100
- "@solid-devtools/debugger": "^0.28.0"
101
- },
97
+ "peerDependenciesMeta": {},
102
98
  "repository": {
103
99
  "type": "git",
104
100
  "url": "git+https://github.com/lightning-tv/solid.git"
@@ -1,5 +1,5 @@
1
1
  import { createSignal } from 'solid-js';
2
- import { type ElementNode } from '@lightningtv/core';
2
+ import { type ElementNode } from './core/index.js';
3
3
  export const [activeElement, setActiveElement] = createSignal<
4
4
  ElementNode | undefined
5
5
  >(undefined);
@@ -0,0 +1,185 @@
1
+ import {
2
+ getTimingFunction,
3
+ mergeColorProgress,
4
+ } from '@lightningjs/renderer/utils';
5
+ import {
6
+ type ElementNode,
7
+ LightningRendererNumberProps,
8
+ } from './elementNode.js';
9
+ import { type IRendererStage } from './lightningInit.js';
10
+ import { TimingFunction } from '@lightningjs/renderer';
11
+ import { isFunc } from './utils.js';
12
+
13
+ /**
14
+ * Simplified Animation Settings
15
+ */
16
+ export interface SimpleAnimationSettings {
17
+ duration?: number;
18
+ delay?: number;
19
+ easing?: string | TimingFunction;
20
+ }
21
+
22
+ /**
23
+ * Properties of a Node used by the SimpleAnimation
24
+ * (Excludes shaderProps)
25
+ */
26
+ export type SimpleAnimationProps =
27
+ (typeof LightningRendererNumberProps)[number];
28
+
29
+ /**
30
+ * Configuration for a single node within a SimpleAnimation
31
+ */
32
+ interface SimpleAnimationNodeConfig {
33
+ node: ElementNode;
34
+ duration: number;
35
+ delay: number;
36
+ easing: string | TimingFunction;
37
+ progress: number;
38
+ delayFor: number;
39
+ timingFunction: (t: number) => number | undefined;
40
+ propName: SimpleAnimationProps;
41
+ startValue: number;
42
+ targetValue: number;
43
+ }
44
+
45
+ export class SimpleAnimation {
46
+ private nodeConfigs: SimpleAnimationNodeConfig[] = [];
47
+ private isRegistered = false;
48
+ private stage: IRendererStage | undefined;
49
+
50
+ register(stage: IRendererStage) {
51
+ if (this.isRegistered) {
52
+ return;
53
+ }
54
+ this.isRegistered = true;
55
+ this.stage = stage;
56
+ stage.animationManager.registerAnimation(this);
57
+ }
58
+
59
+ /**
60
+ * Adds a node and its animation properties to this animation instance.
61
+ * The animation's start values for the specified properties are captured
62
+ * from the node's current state when this method is called.
63
+ *
64
+ * @param node - The CoreNode to animate.
65
+ * @param props - The properties to animate and their target values. Only number properties are supported.
66
+ * @param settings - Animation settings for this specific node animation.
67
+ */
68
+ add(
69
+ node: ElementNode,
70
+ key: SimpleAnimationProps,
71
+ value: number,
72
+ settings: SimpleAnimationSettings,
73
+ ): void {
74
+ const existingConfig = this.nodeConfigs.find(
75
+ (config) => config.node === node && config.propName === key,
76
+ );
77
+
78
+ const duration = settings.duration ?? 0;
79
+ const delay = settings.delay ?? 0;
80
+ const easing = settings.easing || 'linear';
81
+ const timingFunction = isFunc(easing) ? easing : getTimingFunction(easing);
82
+ const targetValue = value;
83
+ const startValue = node[key] as number;
84
+
85
+ if (existingConfig) {
86
+ existingConfig.duration = duration;
87
+ existingConfig.delay = delay;
88
+ existingConfig.easing = easing;
89
+ existingConfig.timingFunction = timingFunction;
90
+ existingConfig.targetValue = targetValue;
91
+ existingConfig.startValue = startValue;
92
+ existingConfig.progress = 0;
93
+ existingConfig.delayFor = delay;
94
+ } else {
95
+ this.nodeConfigs.push({
96
+ node,
97
+ duration,
98
+ delay,
99
+ easing,
100
+ progress: 0,
101
+ delayFor: delay,
102
+ timingFunction,
103
+ propName: key,
104
+ startValue,
105
+ targetValue,
106
+ });
107
+ }
108
+ }
109
+
110
+ update(dt: number) {
111
+ // Iterate backward to safely remove finished animations
112
+ for (let i = this.nodeConfigs.length - 1; i >= 0; i--) {
113
+ const nodeConfig = this.nodeConfigs[i] as SimpleAnimationNodeConfig;
114
+ const {
115
+ node,
116
+ duration,
117
+ timingFunction,
118
+ propName,
119
+ startValue,
120
+ targetValue,
121
+ } = nodeConfig;
122
+ let remainingDt = dt;
123
+
124
+ // 1. Handle Delay
125
+ if (nodeConfig.delayFor > 0) {
126
+ nodeConfig.delayFor -= remainingDt;
127
+ if (nodeConfig.delayFor >= 0) {
128
+ // Still in delay phase for this node, skip applying values this frame
129
+ continue;
130
+ } else {
131
+ // Delay finished this frame, use the remaining time for animation
132
+ remainingDt = -nodeConfig.delayFor;
133
+ nodeConfig.delayFor = 0;
134
+ }
135
+ }
136
+
137
+ // 2. Update Progress (directly on nodeConfig.progress)
138
+ if (duration > 0) {
139
+ nodeConfig.progress += remainingDt / duration;
140
+ // Clamp progress between 0 and 1
141
+ nodeConfig.progress = Math.max(0, Math.min(1, nodeConfig.progress));
142
+ } else if (duration === 0 && nodeConfig.delayFor <= 0) {
143
+ // Duration is 0 and delay is finished or was 0. Animation completes instantly.
144
+ nodeConfig.progress = 1;
145
+ }
146
+
147
+ // 3. Calculate Eased Progress
148
+ const easedProgress =
149
+ timingFunction(nodeConfig.progress) || nodeConfig.progress;
150
+
151
+ // 4. Apply Animated Values to the Node
152
+ let interpolatedValue: number;
153
+ if (nodeConfig.progress === 1) {
154
+ interpolatedValue = targetValue;
155
+ } else {
156
+ if (propName.includes('color')) {
157
+ // Handle color interpolation
158
+ interpolatedValue = mergeColorProgress(
159
+ startValue,
160
+ targetValue,
161
+ easedProgress,
162
+ );
163
+ } else {
164
+ // Handle linear interpolation for other number properties
165
+ interpolatedValue =
166
+ startValue + (targetValue - startValue) * easedProgress;
167
+ }
168
+ }
169
+ // @typescript-eslint/no-explicit-any
170
+ (node.lng as any)[propName] = interpolatedValue; // Cast to any because the properties on CoreNode might have broader types.
171
+
172
+ // 5. Remove Node if Progress is 1
173
+ if (nodeConfig.progress === 1) {
174
+ this.nodeConfigs.splice(i, 1);
175
+ }
176
+ if (this.nodeConfigs.length === 0) {
177
+ this.stage?.animationManager.unregisterAnimation(this);
178
+ this.isRegistered = false;
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ export const simpleAnimation = new SimpleAnimation();
185
+ export default simpleAnimation;
@@ -0,0 +1,77 @@
1
+ import type { RendererMainSettings } from '@lightningjs/renderer';
2
+ import type {
3
+ TextProps,
4
+ AnimationSettings,
5
+ DollarString,
6
+ } from './intrinsicTypes.js';
7
+ import { type ElementNode } from './elementNode.js';
8
+
9
+ /**
10
+ STATIC LIGHTNING CONFIGURATION \
11
+ Replace the values below with in your build system, \
12
+ or set them in the global scope before importing lightning-core.
13
+ */
14
+ declare global {
15
+ /** Whether the DOM renderer should be used instead of `@lightningjs/renderer` */
16
+ var LIGHTNING_DOM_RENDERING: boolean | undefined;
17
+ /** Whether element shaders should be disabled */
18
+ var LIGHTNING_DISABLE_SHADERS: boolean | undefined;
19
+
20
+ /** Could be set by vite or other bundler */
21
+ interface ImportMetaEnv {
22
+ DEV?: unknown;
23
+ }
24
+ interface ImportMeta {
25
+ env?: ImportMetaEnv;
26
+ }
27
+ }
28
+
29
+ export const isDev = !!(import.meta.env && import.meta.env.DEV);
30
+
31
+ /** Whether the DOM renderer is used instead of `@lightningjs/renderer` */
32
+ export const DOM_RENDERING =
33
+ typeof LIGHTNING_DOM_RENDERING === 'boolean' && LIGHTNING_DOM_RENDERING;
34
+
35
+ /** Whether element shaders are enabled */
36
+ export const SHADERS_ENABLED = !(
37
+ typeof LIGHTNING_DISABLE_SHADERS === 'boolean' && LIGHTNING_DISABLE_SHADERS
38
+ );
39
+
40
+ /**
41
+ RUNTIME LIGHTNING CONFIGURATION \
42
+ This configuration can be set at runtime, but it is recommended to set it
43
+ before running any Lightning modules to ensure consistent behavior across the application.
44
+ */
45
+ export interface Config {
46
+ debug: boolean;
47
+ focusDebug: boolean;
48
+ keyDebug: boolean;
49
+ simpleAnimationsEnabled?: boolean;
50
+ animationSettings?: AnimationSettings;
51
+ animationsEnabled: boolean;
52
+ fontSettings: Partial<TextProps>;
53
+ rendererOptions?: Partial<RendererMainSettings>;
54
+ setActiveElement: (elm: ElementNode) => void;
55
+ focusStateKey: DollarString;
56
+ lockStyles?: boolean;
57
+ throttleInput?: number;
58
+ taskDelay?: number;
59
+ }
60
+
61
+ export const Config: Config = {
62
+ debug: false,
63
+ focusDebug: false,
64
+ keyDebug: false,
65
+ animationsEnabled: true,
66
+ animationSettings: {
67
+ duration: 250,
68
+ easing: 'ease-in-out',
69
+ },
70
+ fontSettings: {
71
+ fontFamily: 'Ubuntu',
72
+ fontSize: 100,
73
+ },
74
+ setActiveElement: () => {},
75
+ focusStateKey: '$focus',
76
+ lockStyles: true,
77
+ };