@solidtv/solid 1.2.0 → 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.
- package/README.md +2 -2
- package/dist/src/core/config.d.ts +6 -0
- package/dist/src/core/config.js +6 -0
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/elementNode.js +1 -5
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/flex.js +124 -52
- package/dist/src/core/flex.js.map +1 -1
- package/dist/src/core/focusKeyTypes.d.ts +14 -0
- package/dist/src/core/focusManager.d.ts +16 -0
- package/dist/src/core/focusManager.js +24 -8
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/lightningInit.js +6 -3
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/primitives/FadeInOut.jsx +1 -2
- package/dist/src/primitives/FadeInOut.jsx.map +1 -1
- package/dist/src/primitives/useHold.d.ts +1 -1
- package/dist/src/primitives/useHold.js +1 -1
- package/dist/src/render.d.ts +6 -0
- package/dist/src/render.js +6 -0
- package/dist/src/render.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/AI_CODING_GUIDELINES.md +7 -7
- package/package.json +1 -1
- package/src/core/config.ts +6 -0
- package/src/core/elementNode.ts +1 -6
- package/src/core/flex.ts +135 -56
- package/src/core/focusKeyTypes.ts +14 -0
- package/src/core/focusManager.ts +36 -10
- package/src/core/lightningInit.ts +6 -3
- package/src/primitives/FadeInOut.tsx +2 -2
- package/src/primitives/useHold.ts +1 -1
- package/src/render.ts +6 -0
- package/dist/src/core/flexLayout.d.ts +0 -2
- package/dist/src/core/flexLayout.js +0 -356
- package/dist/src/core/flexLayout.js.map +0 -1
- 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
|
|
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
|
-
<
|
|
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
|
-
<
|
|
88
|
-
</
|
|
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
|
-
<
|
|
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
|
-
<
|
|
107
|
-
</
|
|
106
|
+
<text color="#ffffffff">Hello</text>
|
|
107
|
+
</view>;
|
|
108
108
|
```
|
package/package.json
CHANGED
package/src/core/config.ts
CHANGED
|
@@ -38,6 +38,12 @@ export const SHADERS_ENABLED =
|
|
|
38
38
|
* at runtime (`Config.domRendererEnabled`). `Config.domRendererEnabled` is
|
|
39
39
|
* mutable up until the renderer starts, so this is a function rather than a
|
|
40
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.
|
|
41
47
|
*/
|
|
42
48
|
export const isDomRendererActive = () =>
|
|
43
49
|
DOM_RENDERING && Config.domRendererEnabled;
|
package/src/core/elementNode.ts
CHANGED
|
@@ -16,12 +16,7 @@ import {
|
|
|
16
16
|
type DollarString,
|
|
17
17
|
} from './intrinsicTypes.js';
|
|
18
18
|
import States, { type NodeStates } from './states.js';
|
|
19
|
-
import
|
|
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,
|
package/src/core/flex.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { type ElementNode } from './elementNode.js';
|
|
2
2
|
import { isTextNode, isElementText } from './utils.js';
|
|
3
3
|
|
|
4
|
+
function getArrayValue(
|
|
5
|
+
val: number | number[] | undefined,
|
|
6
|
+
index: number,
|
|
7
|
+
defaultValue: number = 0,
|
|
8
|
+
): number {
|
|
9
|
+
if (val === undefined) return defaultValue;
|
|
10
|
+
if (typeof val === 'number') return val;
|
|
11
|
+
|
|
12
|
+
const len = val.length;
|
|
13
|
+
let result;
|
|
14
|
+
if (len === 2) {
|
|
15
|
+
result = index % 2 === 0 ? val[0] : val[1];
|
|
16
|
+
} else if (len === 3) {
|
|
17
|
+
result = index === 0 ? val[0] : index === 2 ? val[2] : val[1];
|
|
18
|
+
} else {
|
|
19
|
+
result = val[index];
|
|
20
|
+
}
|
|
21
|
+
return result ?? defaultValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
export default function (node: ElementNode): boolean {
|
|
5
25
|
const direction = node.flexDirection || 'row';
|
|
6
26
|
const isRow = direction === 'row' || direction === 'row-reverse';
|
|
@@ -8,10 +28,20 @@ export default function (node: ElementNode): boolean {
|
|
|
8
28
|
direction === 'row-reverse' || direction === 'column-reverse';
|
|
9
29
|
const dimension = isRow ? 'width' : 'height';
|
|
10
30
|
const crossDimension = isRow ? 'height' : 'width';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
31
|
+
|
|
32
|
+
// padding order: Top, Right, Bottom, Left
|
|
33
|
+
const nodePadding = node.padding;
|
|
34
|
+
const paddingTop = node.paddingTop ?? getArrayValue(nodePadding, 0);
|
|
35
|
+
const paddingRight = node.paddingRight ?? getArrayValue(nodePadding, 1);
|
|
36
|
+
const paddingBottom = node.paddingBottom ?? getArrayValue(nodePadding, 2);
|
|
37
|
+
const paddingLeft = node.paddingLeft ?? getArrayValue(nodePadding, 3);
|
|
38
|
+
|
|
39
|
+
const paddingStart = isRow ? paddingLeft : paddingTop;
|
|
40
|
+
const paddingEnd = isRow ? paddingRight : paddingBottom;
|
|
41
|
+
const paddingCrossStart = isRow ? paddingTop : paddingLeft;
|
|
42
|
+
const paddingCrossEnd = isRow ? paddingBottom : paddingRight;
|
|
43
|
+
const nodePaddingTotal = paddingStart + paddingEnd;
|
|
44
|
+
|
|
15
45
|
const minDimension = isRow ? 'minWidth' : 'minHeight';
|
|
16
46
|
const crossMinDimension = isRow ? 'minHeight' : 'minWidth';
|
|
17
47
|
|
|
@@ -22,15 +52,17 @@ export default function (node: ElementNode): boolean {
|
|
|
22
52
|
return false;
|
|
23
53
|
}
|
|
24
54
|
|
|
55
|
+
// Optimize arrays caching
|
|
25
56
|
const processableChildrenIndices: number[] = [];
|
|
26
57
|
let hasOrder = false;
|
|
27
58
|
let totalFlexGrow = 0;
|
|
59
|
+
let totalFlexShrink = 0;
|
|
28
60
|
|
|
29
61
|
for (let i = 0; i < numChildren; i++) {
|
|
30
62
|
const c = children[i]!;
|
|
31
63
|
|
|
32
64
|
if (isElementText(c) && c.text && !(c.width || c.height)) {
|
|
33
|
-
return false;
|
|
65
|
+
return false; // specific text layout constraint
|
|
34
66
|
}
|
|
35
67
|
|
|
36
68
|
if (isTextNode(c) || c.flexItem === false) {
|
|
@@ -42,10 +74,15 @@ export default function (node: ElementNode): boolean {
|
|
|
42
74
|
}
|
|
43
75
|
|
|
44
76
|
const flexGrow = c.flexGrow;
|
|
45
|
-
if (flexGrow !== undefined && flexGrow
|
|
77
|
+
if (flexGrow !== undefined && flexGrow > 0) {
|
|
46
78
|
totalFlexGrow += flexGrow;
|
|
47
79
|
}
|
|
48
80
|
|
|
81
|
+
const flexShrink = c.flexShrink;
|
|
82
|
+
if (flexShrink !== undefined && flexShrink > 0) {
|
|
83
|
+
totalFlexShrink += flexShrink;
|
|
84
|
+
}
|
|
85
|
+
|
|
49
86
|
if (c[minDimension] && (c[dimension] || 0) < c[minDimension]) {
|
|
50
87
|
c[dimension] = c[minDimension]!;
|
|
51
88
|
}
|
|
@@ -68,13 +105,14 @@ export default function (node: ElementNode): boolean {
|
|
|
68
105
|
});
|
|
69
106
|
}
|
|
70
107
|
|
|
108
|
+
// Apply reverse layout ordering
|
|
71
109
|
if (isReverse || node.direction === 'rtl') {
|
|
72
110
|
processableChildrenIndices.reverse();
|
|
73
111
|
}
|
|
74
112
|
|
|
75
113
|
const numProcessedChildren = processableChildrenIndices.length;
|
|
76
114
|
if (numProcessedChildren === 0) {
|
|
77
|
-
return false;
|
|
115
|
+
return false;
|
|
78
116
|
}
|
|
79
117
|
|
|
80
118
|
const prop = isRow ? 'x' : 'y';
|
|
@@ -92,9 +130,10 @@ export default function (node: ElementNode): boolean {
|
|
|
92
130
|
const isWrapReverse = node.flexWrap === 'wrap-reverse';
|
|
93
131
|
const gap = node.gap || 0;
|
|
94
132
|
const justify = node.justifyContent || 'flexStart';
|
|
95
|
-
const
|
|
133
|
+
const align = node.alignItems || (node.flexWrap ? 'flexStart' : undefined);
|
|
96
134
|
let containerUpdated = false;
|
|
97
135
|
|
|
136
|
+
// Resolve sizes matching old processed calculation
|
|
98
137
|
const childMainSizes = new Float32Array(numProcessedChildren);
|
|
99
138
|
const childMarginStarts = new Float32Array(numProcessedChildren);
|
|
100
139
|
const childMarginEnds = new Float32Array(numProcessedChildren);
|
|
@@ -107,41 +146,55 @@ export default function (node: ElementNode): boolean {
|
|
|
107
146
|
|
|
108
147
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
109
148
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
149
|
+
const marginArray = c.margin;
|
|
150
|
+
// index mappings for margins: Top: 0, Right: 1, Bottom: 2, Left: 3
|
|
151
|
+
// if row: main = left/right (3/1),
|
|
152
|
+
const flexBasis = c.flexBasis;
|
|
153
|
+
const isBasisAuto = flexBasis === undefined || flexBasis === 'auto';
|
|
154
|
+
const computedBasis = isBasisAuto
|
|
155
|
+
? c[dimension] || 0
|
|
156
|
+
: (flexBasis as number);
|
|
157
|
+
const baseMainSize = isBasisAuto
|
|
158
|
+
? computedBasis
|
|
159
|
+
: Math.max(computedBasis, c[minDimension] || 0);
|
|
160
|
+
|
|
161
|
+
const marginStart = isRow
|
|
162
|
+
? c.marginLeft || getArrayValue(marginArray, 3)
|
|
163
|
+
: c.marginTop || getArrayValue(marginArray, 0);
|
|
164
|
+
const marginEnd = isRow
|
|
165
|
+
? c.marginRight || getArrayValue(marginArray, 1)
|
|
166
|
+
: c.marginBottom || getArrayValue(marginArray, 2);
|
|
167
|
+
const marginCrossStart = isRow
|
|
168
|
+
? c.marginTop || getArrayValue(marginArray, 0)
|
|
169
|
+
: c.marginLeft || getArrayValue(marginArray, 3);
|
|
170
|
+
const marginCrossEnd = isRow
|
|
171
|
+
? c.marginBottom || getArrayValue(marginArray, 2)
|
|
172
|
+
: c.marginRight || getArrayValue(marginArray, 1);
|
|
114
173
|
|
|
115
174
|
childMainSizes[idx] = baseMainSize;
|
|
116
175
|
childMarginStarts[idx] = marginStart;
|
|
117
176
|
childMarginEnds[idx] = marginEnd;
|
|
118
177
|
childTotalMainSizes[idx] = baseMainSize + marginStart + marginEnd;
|
|
119
|
-
|
|
120
178
|
childCrossSizes[idx] = c[crossDimension] || 0;
|
|
121
|
-
childMarginCrossStarts[idx] =
|
|
122
|
-
childMarginCrossEnds[idx] =
|
|
179
|
+
childMarginCrossStarts[idx] = marginCrossStart;
|
|
180
|
+
childMarginCrossEnds[idx] = marginCrossEnd;
|
|
123
181
|
|
|
124
182
|
sumOfFlexBaseSizesWithMargins += childTotalMainSizes[idx]!;
|
|
125
183
|
}
|
|
126
184
|
|
|
127
|
-
if (totalFlexGrow > 0 && numProcessedChildren > 1) {
|
|
128
|
-
// When flex-grow is used, the container's size is considered fixed for this calculation pass,
|
|
129
|
-
// unless flexBoundary is explicitly set to allow container resizing based on content.
|
|
185
|
+
if ((totalFlexGrow > 0 || totalFlexShrink > 0) && numProcessedChildren > 1) {
|
|
130
186
|
node.flexBoundary = node.flexBoundary || 'fixed';
|
|
131
187
|
|
|
132
|
-
// Calculate the total space occupied by gaps between items.
|
|
133
188
|
const totalGapSpace =
|
|
134
189
|
numProcessedChildren > 0 ? gap * (numProcessedChildren - 1) : 0;
|
|
135
|
-
|
|
136
|
-
// Calculate the available space for flex items to grow into.
|
|
137
190
|
const availableSpace =
|
|
138
191
|
containerSize - sumOfFlexBaseSizesWithMargins - totalGapSpace;
|
|
139
192
|
|
|
140
|
-
if (availableSpace > 0) {
|
|
193
|
+
if (availableSpace > 0 && totalFlexGrow > 0) {
|
|
141
194
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
142
195
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
143
|
-
const flexGrowValue = c.flexGrow;
|
|
144
|
-
if (flexGrowValue
|
|
196
|
+
const flexGrowValue = c.flexGrow || 0;
|
|
197
|
+
if (flexGrowValue > 0) {
|
|
145
198
|
const shareOfSpace = (flexGrowValue / totalFlexGrow) * availableSpace;
|
|
146
199
|
const newMainSize = childMainSizes[idx]! + shareOfSpace;
|
|
147
200
|
c[dimension] = newMainSize;
|
|
@@ -150,16 +203,43 @@ export default function (node: ElementNode): boolean {
|
|
|
150
203
|
newMainSize + childMarginStarts[idx]! + childMarginEnds[idx]!;
|
|
151
204
|
}
|
|
152
205
|
}
|
|
153
|
-
|
|
206
|
+
node._containsFlexGrow = node._containsFlexGrow ? null : true;
|
|
207
|
+
} else if (availableSpace < 0 && totalFlexShrink > 0) {
|
|
208
|
+
// Flex Shrink Phase
|
|
209
|
+
let totalScaledShrinkFactor = 0;
|
|
210
|
+
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
211
|
+
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
212
|
+
const flexShrinkValue = c.flexShrink || 0;
|
|
213
|
+
totalScaledShrinkFactor += flexShrinkValue * childMainSizes[idx]!;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (totalScaledShrinkFactor > 0) {
|
|
217
|
+
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
218
|
+
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
219
|
+
const flexShrinkValue = c.flexShrink || 0;
|
|
220
|
+
if (flexShrinkValue > 0) {
|
|
221
|
+
const shrinkRatio =
|
|
222
|
+
(flexShrinkValue * childMainSizes[idx]!) /
|
|
223
|
+
totalScaledShrinkFactor;
|
|
224
|
+
const sizeReduction = shrinkRatio * Math.abs(availableSpace);
|
|
225
|
+
let newMainSize = childMainSizes[idx]! - sizeReduction;
|
|
226
|
+
|
|
227
|
+
// Constrain by min width/height
|
|
228
|
+
const minBound = c[minDimension] || 0;
|
|
229
|
+
if (newMainSize < minBound) {
|
|
230
|
+
newMainSize = minBound;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
c[dimension] = newMainSize;
|
|
234
|
+
childMainSizes[idx] = newMainSize;
|
|
235
|
+
childTotalMainSizes[idx] =
|
|
236
|
+
newMainSize + childMarginStarts[idx]! + childMarginEnds[idx]!;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
154
240
|
node._containsFlexGrow = node._containsFlexGrow ? null : true;
|
|
155
241
|
} else if (node._containsFlexGrow) {
|
|
156
242
|
node._containsFlexGrow = null;
|
|
157
|
-
} else {
|
|
158
|
-
// No positive space available for items to grow, or items overflow.
|
|
159
|
-
// flex-grow has no effect in this case.
|
|
160
|
-
console.warn(
|
|
161
|
-
'No available space for flex-grow items to expand, or items overflow.',
|
|
162
|
-
);
|
|
163
243
|
}
|
|
164
244
|
}
|
|
165
245
|
|
|
@@ -175,7 +255,6 @@ export default function (node: ElementNode): boolean {
|
|
|
175
255
|
}
|
|
176
256
|
}
|
|
177
257
|
|
|
178
|
-
const align = node.alignItems || (node.flexWrap ? 'flexStart' : undefined);
|
|
179
258
|
const doCrossAlign = containerCrossSize
|
|
180
259
|
? (c: ElementNode, idx: number, crossCurrentPos: number = 0) => {
|
|
181
260
|
const alignSelf = c.alignSelf || align;
|
|
@@ -213,23 +292,23 @@ export default function (node: ElementNode): boolean {
|
|
|
213
292
|
}
|
|
214
293
|
}
|
|
215
294
|
|
|
216
|
-
let currentPos =
|
|
295
|
+
let currentPos = paddingStart;
|
|
217
296
|
if (justify === 'flexStart') {
|
|
218
|
-
if (node.flexWrap === 'wrap'
|
|
297
|
+
if (node.flexWrap === 'wrap') {
|
|
219
298
|
const childCrossSizeVar =
|
|
220
299
|
numProcessedChildren > 0 ? childCrossSizes[0]! : containerCrossSize;
|
|
221
300
|
let crossCurrentPos = isWrapReverse
|
|
222
|
-
? containerCrossSize - childCrossSizeVar
|
|
223
|
-
:
|
|
301
|
+
? containerCrossSize - paddingCrossEnd - childCrossSizeVar
|
|
302
|
+
: paddingCrossStart;
|
|
224
303
|
const crossGap = isRow ? (node.columnGap ?? gap) : (node.rowGap ?? gap);
|
|
225
304
|
|
|
226
305
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
227
306
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
228
307
|
if (
|
|
229
308
|
currentPos + childTotalMainSizes[idx]! > containerSize &&
|
|
230
|
-
currentPos >
|
|
309
|
+
currentPos > paddingStart
|
|
231
310
|
) {
|
|
232
|
-
currentPos =
|
|
311
|
+
currentPos = paddingStart;
|
|
233
312
|
crossCurrentPos += isWrapReverse
|
|
234
313
|
? -(childCrossSizeVar + crossGap)
|
|
235
314
|
: childCrossSizeVar + crossGap;
|
|
@@ -240,8 +319,8 @@ export default function (node: ElementNode): boolean {
|
|
|
240
319
|
}
|
|
241
320
|
|
|
242
321
|
const finalCrossSize = isWrapReverse
|
|
243
|
-
? containerCrossSize - crossCurrentPos
|
|
244
|
-
: crossCurrentPos + childCrossSizeVar;
|
|
322
|
+
? containerCrossSize - crossCurrentPos + paddingCrossStart
|
|
323
|
+
: crossCurrentPos + childCrossSizeVar + paddingCrossEnd;
|
|
245
324
|
|
|
246
325
|
if (node[crossDimension] !== finalCrossSize) {
|
|
247
326
|
node[`preFlex${crossDimension}`] = node[crossDimension];
|
|
@@ -253,77 +332,77 @@ export default function (node: ElementNode): boolean {
|
|
|
253
332
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
254
333
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
255
334
|
currentPos += childTotalMainSizes[idx]! + gap;
|
|
256
|
-
doCrossAlign(c, idx);
|
|
335
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
257
336
|
}
|
|
258
337
|
}
|
|
338
|
+
|
|
259
339
|
// Update container size
|
|
260
340
|
if (node.flexBoundary !== 'fixed' && node.flexWrap !== 'wrap') {
|
|
261
|
-
let calculatedSize = currentPos - gap +
|
|
341
|
+
let calculatedSize = currentPos - gap + paddingEnd;
|
|
262
342
|
const minSize = node[minDimension] || 0;
|
|
263
343
|
if (calculatedSize < minSize) {
|
|
264
344
|
calculatedSize = minSize;
|
|
265
345
|
}
|
|
266
346
|
if (calculatedSize !== (node[dimension] || 0)) {
|
|
267
|
-
// store the original size for Row & Column
|
|
268
347
|
node[`preFlex${dimension}`] = containerSize;
|
|
269
348
|
node[dimension] = calculatedSize;
|
|
270
349
|
return true;
|
|
271
350
|
}
|
|
272
351
|
}
|
|
273
352
|
} else if (justify === 'flexEnd') {
|
|
274
|
-
currentPos = containerSize -
|
|
353
|
+
currentPos = containerSize - paddingEnd;
|
|
275
354
|
for (let idx = numProcessedChildren - 1; idx >= 0; idx--) {
|
|
276
355
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
277
356
|
c[prop] = currentPos - childMainSizes[idx]! - childMarginEnds[idx]!;
|
|
278
357
|
currentPos -= childTotalMainSizes[idx]! + gap;
|
|
279
|
-
doCrossAlign(c, idx);
|
|
358
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
280
359
|
}
|
|
281
360
|
} else if (justify === 'center') {
|
|
282
361
|
currentPos =
|
|
283
362
|
(containerSize - (totalItemSize + gap * (numProcessedChildren - 1))) / 2 +
|
|
284
|
-
|
|
363
|
+
paddingStart;
|
|
285
364
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
286
365
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
287
366
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
288
367
|
currentPos += childTotalMainSizes[idx]! + gap;
|
|
289
|
-
doCrossAlign(c, idx);
|
|
368
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
290
369
|
}
|
|
291
370
|
} else if (justify === 'spaceBetween') {
|
|
292
371
|
const spaceBetween =
|
|
293
372
|
numProcessedChildren > 1
|
|
294
|
-
? (containerSize - totalItemSize -
|
|
373
|
+
? (containerSize - totalItemSize - nodePaddingTotal) /
|
|
295
374
|
(numProcessedChildren - 1)
|
|
296
375
|
: 0;
|
|
297
|
-
currentPos =
|
|
376
|
+
currentPos = paddingStart;
|
|
298
377
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
299
378
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
300
379
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
301
380
|
currentPos += childTotalMainSizes[idx]! + spaceBetween;
|
|
302
|
-
doCrossAlign(c, idx);
|
|
381
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
303
382
|
}
|
|
304
383
|
} else if (justify === 'spaceAround') {
|
|
305
384
|
const spaceAround =
|
|
306
385
|
numProcessedChildren > 0
|
|
307
|
-
? (containerSize - totalItemSize -
|
|
386
|
+
? (containerSize - totalItemSize - nodePaddingTotal) /
|
|
308
387
|
numProcessedChildren
|
|
309
388
|
: 0;
|
|
310
|
-
currentPos =
|
|
389
|
+
currentPos = paddingStart + spaceAround / 2;
|
|
311
390
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
312
391
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
313
392
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
314
393
|
currentPos += childTotalMainSizes[idx]! + spaceAround;
|
|
315
|
-
doCrossAlign(c, idx);
|
|
394
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
316
395
|
}
|
|
317
396
|
} else if (justify === 'spaceEvenly') {
|
|
318
397
|
const spaceEvenly =
|
|
319
|
-
(containerSize - totalItemSize -
|
|
398
|
+
(containerSize - totalItemSize - nodePaddingTotal) /
|
|
320
399
|
(numProcessedChildren + 1);
|
|
321
|
-
currentPos = spaceEvenly +
|
|
400
|
+
currentPos = spaceEvenly + paddingStart;
|
|
322
401
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
323
402
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
324
403
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
325
404
|
currentPos += childTotalMainSizes[idx]! + spaceEvenly;
|
|
326
|
-
doCrossAlign(c, idx);
|
|
405
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
327
406
|
}
|
|
328
407
|
}
|
|
329
408
|
|
|
@@ -69,6 +69,20 @@ export type EventHandlers<Map> = {
|
|
|
69
69
|
|
|
70
70
|
export interface KeyHoldMap extends DefaultKeyHoldMap {}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Return type of key handlers (onEnter, onUp, onKeyPress, onCapture*, etc.).
|
|
74
|
+
*
|
|
75
|
+
* **1.3 contract:** a handler that runs is considered to have consumed the
|
|
76
|
+
* event by default — traversal up the focus path stops at that element. To
|
|
77
|
+
* let the event continue bubbling (for observation-only handlers like
|
|
78
|
+
* logging, analytics, instrumentation), explicitly `return false`.
|
|
79
|
+
*
|
|
80
|
+
* - `return false` → not consumed; bubble to the next ancestor.
|
|
81
|
+
* - any other return → consumed (default).
|
|
82
|
+
*
|
|
83
|
+
* This is a behavior flip from 1.2, where `return true` was required to
|
|
84
|
+
* consume. See `roadmap.md` for migration notes.
|
|
85
|
+
*/
|
|
72
86
|
export type KeyHandlerReturn = boolean | void;
|
|
73
87
|
|
|
74
88
|
export type KeyHandler = (
|
package/src/core/focusManager.ts
CHANGED
|
@@ -273,6 +273,24 @@ const updateFocusPath = (
|
|
|
273
273
|
let lastGlobalKeyPressTime = 0;
|
|
274
274
|
let lastInputKey: string | number | undefined;
|
|
275
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Key-handler consume contract (1.3+):
|
|
278
|
+
*
|
|
279
|
+
* A focus-path handler that runs is considered to have consumed the event.
|
|
280
|
+
* Traversal stops at that element. To opt back into bubbling — for handlers
|
|
281
|
+
* that observe but don't act (logging, analytics, instrumentation) — the
|
|
282
|
+
* handler must explicitly `return false`.
|
|
283
|
+
*
|
|
284
|
+
* - `return false` → not consumed; event bubbles to the next ancestor.
|
|
285
|
+
* - any other return → consumed (default).
|
|
286
|
+
* (`undefined`, `true`, void, etc.)
|
|
287
|
+
*
|
|
288
|
+
* @internal exported for tests. Not part of the public API; signature may
|
|
289
|
+
* change in any minor.
|
|
290
|
+
*/
|
|
291
|
+
export const _isHandlerConsumed = (result: unknown): boolean =>
|
|
292
|
+
result !== false;
|
|
293
|
+
|
|
276
294
|
const isElementThrottled = (
|
|
277
295
|
elm: ElementNode,
|
|
278
296
|
sameKey: boolean,
|
|
@@ -303,12 +321,18 @@ const runCapturePhase = (
|
|
|
303
321
|
if (isElementThrottled(elm, sameKey, currentTime)) return true;
|
|
304
322
|
|
|
305
323
|
const captureHandler = elm[captureEvent] || elm[captureKey];
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
if (isFunction(captureHandler)) {
|
|
325
|
+
const result = captureHandler.call(
|
|
326
|
+
elm,
|
|
327
|
+
e,
|
|
328
|
+
elm,
|
|
329
|
+
finalFocusElm,
|
|
330
|
+
mappedEvent,
|
|
331
|
+
);
|
|
332
|
+
if (_isHandlerConsumed(result)) {
|
|
333
|
+
elm._lastAnyKeyPressTime = currentTime;
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
312
336
|
}
|
|
313
337
|
}
|
|
314
338
|
return false;
|
|
@@ -350,16 +374,18 @@ const runBubblePhase = (
|
|
|
350
374
|
const eventHandler = elm[eventHandlerKey];
|
|
351
375
|
if (isFunction(eventHandler)) {
|
|
352
376
|
lastHandlerSeen = elm;
|
|
353
|
-
handled =
|
|
377
|
+
handled = _isHandlerConsumed(
|
|
378
|
+
eventHandler.call(elm, e, elm, finalFocusElm),
|
|
379
|
+
);
|
|
354
380
|
}
|
|
355
381
|
}
|
|
356
382
|
if (!handled && fallbackHandlerKey) {
|
|
357
383
|
const fallbackHandler = elm[fallbackHandlerKey];
|
|
358
384
|
if (isFunction(fallbackHandler)) {
|
|
359
385
|
lastHandlerSeen = elm;
|
|
360
|
-
handled =
|
|
361
|
-
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm)
|
|
362
|
-
|
|
386
|
+
handled = _isHandlerConsumed(
|
|
387
|
+
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm),
|
|
388
|
+
);
|
|
363
389
|
}
|
|
364
390
|
}
|
|
365
391
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as lng from '@solidtv/renderer';
|
|
2
|
-
import {
|
|
2
|
+
import { Config, DOM_RENDERING } from './config.js';
|
|
3
3
|
import { DOMRendererMain, loadFontToDom } from './dom-renderer/domRenderer.js';
|
|
4
4
|
import { DomRendererMainSettings } from './dom-renderer/domRendererTypes.js';
|
|
5
5
|
import { FontLoadOptions } from './intrinsicTypes.js';
|
|
@@ -14,7 +14,9 @@ export function startLightningRenderer(
|
|
|
14
14
|
options: lng.RendererMainSettings | DomRendererMainSettings,
|
|
15
15
|
rootId: string | HTMLElement = 'app',
|
|
16
16
|
) {
|
|
17
|
-
|
|
17
|
+
// Inlined (not isDomRendererActive()) so bundlers can fold DOM_RENDERING to
|
|
18
|
+
// false and drop the DOMRendererMain branch + import in WebGL builds.
|
|
19
|
+
const enableDomRenderer = DOM_RENDERING && Config.domRendererEnabled;
|
|
18
20
|
|
|
19
21
|
renderer = enableDomRenderer
|
|
20
22
|
? new DOMRendererMain(options, rootId)
|
|
@@ -23,7 +25,8 @@ export function startLightningRenderer(
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export async function loadFonts(fonts: FontLoadOptions[]) {
|
|
26
|
-
|
|
28
|
+
// Inlined so the loadFontToDom branch + import tree-shake in WebGL builds.
|
|
29
|
+
const enableDomRenderer = DOM_RENDERING && Config.domRendererEnabled;
|
|
27
30
|
await Promise.all(
|
|
28
31
|
fonts.map((font) => {
|
|
29
32
|
// WebGL — SDF
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementNode, NodeProps
|
|
1
|
+
import { ElementNode, NodeProps } from '@solidtv/solid';
|
|
2
2
|
import { Show } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
@@ -52,7 +52,7 @@ export function FadeInOut(props: Props & NodeProps) {
|
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
54
|
<Show when={props.when} keyed>
|
|
55
|
-
<
|
|
55
|
+
<view {...props} onDestroy={onDestroy} onCreate={onCreate} />
|
|
56
56
|
</Show>
|
|
57
57
|
);
|
|
58
58
|
}
|
package/src/render.ts
CHANGED
|
@@ -144,12 +144,18 @@ export function Dynamic<T extends Record<string, any>>(
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// Dont use JSX as it creates circular dependencies and causes trouble with the playground.
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Use the lowercase `<view>` intrinsic element instead. The `View` component will be removed in a future release.
|
|
149
|
+
*/
|
|
147
150
|
export const View = (props: NodeProps) => {
|
|
148
151
|
const el = createElement('node');
|
|
149
152
|
spread(el, props, false);
|
|
150
153
|
return el as unknown as JSXElement;
|
|
151
154
|
};
|
|
152
155
|
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated Use the lowercase `<text>` intrinsic element instead. The `Text` component will be removed in a future release.
|
|
158
|
+
*/
|
|
153
159
|
export const Text = (props: TextProps) => {
|
|
154
160
|
const el = createElement('text');
|
|
155
161
|
spread(el, props, false);
|