@solidtv/solid 1.1.0 → 1.1.2
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/dist/jsx-runtime.d.ts +0 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/dom-renderer/domRenderer.js +36 -36
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
- package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
- package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
- package/dist/src/core/elementNode.d.ts +19 -14
- package/dist/src/core/elementNode.js +42 -7
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/flex.js +1 -1
- package/dist/src/core/flex.js.map +1 -1
- package/dist/src/core/flexLayout.js +5 -9
- package/dist/src/core/flexLayout.js.map +1 -1
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/nodeTypes.d.ts +1 -1
- package/dist/src/core/nodeTypes.js.map +1 -1
- package/dist/src/core/shaders.js +1 -1
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/core/states.js.map +1 -1
- package/dist/src/core/utils.js +2 -1
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/devtools/index.js +2 -2
- package/dist/src/devtools/index.js.map +1 -1
- package/dist/src/primitives/Column.jsx +1 -1
- package/dist/src/primitives/Column.jsx.map +1 -1
- package/dist/src/primitives/Grid.jsx.map +1 -1
- package/dist/src/primitives/Image.jsx.map +1 -1
- package/dist/src/primitives/KeepAlive.d.ts +4 -3
- package/dist/src/primitives/KeepAlive.jsx +48 -21
- package/dist/src/primitives/KeepAlive.jsx.map +1 -1
- package/dist/src/primitives/Lazy.d.ts +16 -0
- package/dist/src/primitives/Lazy.jsx +82 -38
- package/dist/src/primitives/Lazy.jsx.map +1 -1
- package/dist/src/primitives/LazyImport.js +14 -11
- package/dist/src/primitives/LazyImport.js.map +1 -1
- package/dist/src/primitives/Marquee.jsx +3 -3
- package/dist/src/primitives/Marquee.jsx.map +1 -1
- package/dist/src/primitives/Preserve.jsx +1 -1
- package/dist/src/primitives/Preserve.jsx.map +1 -1
- package/dist/src/primitives/Row.jsx +1 -1
- package/dist/src/primitives/Row.jsx.map +1 -1
- package/dist/src/primitives/Suspense.jsx +1 -1
- package/dist/src/primitives/Suspense.jsx.map +1 -1
- package/dist/src/primitives/Virtual.jsx +7 -6
- package/dist/src/primitives/Virtual.jsx.map +1 -1
- package/dist/src/primitives/borderBox.jsx.map +1 -1
- package/dist/src/primitives/useMouse.js +72 -82
- package/dist/src/primitives/useMouse.js.map +1 -1
- package/dist/src/primitives/utils/createSpriteMap.js.map +1 -1
- package/dist/src/primitives/utils/handleNavigation.js +13 -10
- package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
- package/dist/src/solidOpts.js +1 -1
- package/dist/src/solidOpts.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jsx-runtime.d.ts +0 -1
- package/package.json +2 -1
- package/src/core/config.ts +2 -0
- package/src/core/dom-renderer/domRenderer.ts +46 -46
- package/src/core/dom-renderer/domRendererUtils.ts +2 -2
- package/src/core/elementNode.ts +50 -20
- package/src/core/flex.ts +3 -3
- package/src/core/flexLayout.ts +7 -11
- package/src/core/focusManager.ts +1 -1
- package/src/core/nodeTypes.ts +1 -1
- package/src/core/shaders.ts +1 -1
- package/src/core/states.ts +2 -2
- package/src/core/utils.ts +2 -1
- package/src/devtools/index.ts +2 -2
- package/src/primitives/Column.tsx +0 -1
- package/src/primitives/Grid.tsx +1 -1
- package/src/primitives/Image.tsx +1 -1
- package/src/primitives/KeepAlive.tsx +75 -39
- package/src/primitives/Lazy.tsx +106 -37
- package/src/primitives/LazyImport.ts +5 -4
- package/src/primitives/Marquee.tsx +3 -3
- package/src/primitives/Preserve.tsx +1 -1
- package/src/primitives/Row.tsx +0 -1
- package/src/primitives/Suspense.tsx +1 -1
- package/src/primitives/Virtual.tsx +8 -8
- package/src/primitives/borderBox.tsx +1 -1
- package/src/primitives/useMouse.ts +94 -125
- package/src/primitives/utils/createSpriteMap.ts +1 -1
- package/src/primitives/utils/handleNavigation.ts +20 -11
- package/src/solidOpts.ts +1 -1
|
@@ -49,7 +49,7 @@ const supportsCssMask: boolean = supportsStandardMask || supportsWebkitMask;
|
|
|
49
49
|
Animations
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const animationTasks: AnimationController[] = [];
|
|
53
53
|
let animationFrameRequested = false;
|
|
54
54
|
|
|
55
55
|
function requestAnimationUpdate() {
|
|
@@ -67,10 +67,10 @@ function updateAnimations(time: number) {
|
|
|
67
67
|
so that the later task will override the earlier ones
|
|
68
68
|
*/
|
|
69
69
|
for (let i = 0; i < animationTasks.length; i++) {
|
|
70
|
-
|
|
70
|
+
const task = animationTasks[i]!;
|
|
71
71
|
if (task.pausedTime != null) continue;
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
const elapsed = time - task.timeStart;
|
|
74
74
|
|
|
75
75
|
// Still in delay period
|
|
76
76
|
if (elapsed < task.settings.delay) {
|
|
@@ -78,7 +78,7 @@ function updateAnimations(time: number) {
|
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
const activeTime = elapsed - task.settings.delay;
|
|
82
82
|
|
|
83
83
|
if (activeTime >= task.settings.duration) {
|
|
84
84
|
// Start next iteration
|
|
@@ -106,9 +106,9 @@ function updateAnimations(time: number) {
|
|
|
106
106
|
let t = activeTime / task.settings.duration;
|
|
107
107
|
t = applyEasing(task.settings.easing, t);
|
|
108
108
|
|
|
109
|
-
for (
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
for (const prop in task.propsEnd) {
|
|
110
|
+
const start = task.propsStart[prop]!;
|
|
111
|
+
const end = task.propsEnd[prop]!;
|
|
112
112
|
(task.node.props as any)[prop] = interpolateProp(prop, start, end, t);
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -150,7 +150,7 @@ class AnimationController implements lng.IAnimationController {
|
|
|
150
150
|
this.timeEnd =
|
|
151
151
|
this.timeStart + this.settings.delay + this.settings.duration;
|
|
152
152
|
|
|
153
|
-
for (
|
|
153
|
+
for (const [prop, value] of Object.entries(props)) {
|
|
154
154
|
if (value != null && typeof value === 'number') {
|
|
155
155
|
this.propsStart[prop] = (node.props as any)[prop];
|
|
156
156
|
this.propsEnd[prop] = value;
|
|
@@ -177,7 +177,7 @@ class AnimationController implements lng.IAnimationController {
|
|
|
177
177
|
return this;
|
|
178
178
|
}
|
|
179
179
|
stop() {
|
|
180
|
-
|
|
180
|
+
const index = animationTasks.indexOf(this);
|
|
181
181
|
if (index !== -1) {
|
|
182
182
|
animationTasks.splice(index, 1);
|
|
183
183
|
}
|
|
@@ -224,7 +224,7 @@ function animate(
|
|
|
224
224
|
Node Properties
|
|
225
225
|
*/
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
const elMap = new WeakMap<DOMNode, HTMLElement>();
|
|
228
228
|
|
|
229
229
|
function updateNodeParent(node: DOMNode | DOMText) {
|
|
230
230
|
const parent = node.props.parent;
|
|
@@ -234,7 +234,7 @@ function updateNodeParent(node: DOMNode | DOMText) {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
function updateNodeStyles(node: DOMNode | DOMText) {
|
|
237
|
-
|
|
237
|
+
const { props } = node;
|
|
238
238
|
|
|
239
239
|
let style = `position: absolute; z-index: ${props.zIndex}; opacity: ${props.alpha ?? 1};`;
|
|
240
240
|
|
|
@@ -246,16 +246,16 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
246
246
|
{
|
|
247
247
|
let transform = '';
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
const { x, y } = props;
|
|
250
250
|
|
|
251
251
|
const hasMountX = props.mountX != null && props.mountX !== 0;
|
|
252
252
|
const hasMountY = props.mountY != null && props.mountY !== 0;
|
|
253
253
|
|
|
254
254
|
if (x !== 0) transform += `translateX(${x}px)`;
|
|
255
|
-
if (hasMountX) transform += `translateX(${-props.mountX
|
|
255
|
+
if (hasMountX) transform += `translateX(${-props.mountX * 100}%)`;
|
|
256
256
|
|
|
257
257
|
if (y !== 0) transform += `translateY(${y}px)`;
|
|
258
|
-
if (hasMountY) transform += `translateY(${-props.mountY
|
|
258
|
+
if (hasMountY) transform += `translateY(${-props.mountY * 100}%)`;
|
|
259
259
|
|
|
260
260
|
if (props.rotation !== 0) transform += `rotate(${props.rotation}rad)`;
|
|
261
261
|
|
|
@@ -270,8 +270,8 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
270
270
|
style += `transform: ${transform};`;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
const pivotX = props.pivotX ?? props.pivot ?? 0.5;
|
|
274
|
+
const pivotY = props.pivotY ?? props.pivot ?? 0.5;
|
|
275
275
|
if (pivotX !== 0.5 || pivotY !== 0.5) {
|
|
276
276
|
style += `transform-origin: ${pivotX * 100}% ${pivotY * 100}%;`;
|
|
277
277
|
}
|
|
@@ -279,7 +279,7 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
279
279
|
|
|
280
280
|
// <Text>
|
|
281
281
|
if (node instanceof DOMText) {
|
|
282
|
-
|
|
282
|
+
const textProps = node.props;
|
|
283
283
|
|
|
284
284
|
if (textProps.color != null && textProps.color !== 0) {
|
|
285
285
|
style += `color: ${colorToRgba(textProps.color)};`;
|
|
@@ -324,7 +324,7 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
324
324
|
}
|
|
325
325
|
break;
|
|
326
326
|
case 'both': {
|
|
327
|
-
|
|
327
|
+
const lineHeight = getNodeLineHeight(textProps);
|
|
328
328
|
const widthConstraint =
|
|
329
329
|
textProps.maxWidth && textProps.maxWidth > 0
|
|
330
330
|
? `${textProps.maxWidth}px`
|
|
@@ -391,17 +391,17 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
391
391
|
if (props.w !== 0) style += `width: ${props.w < 0 ? 0 : props.w}px;`;
|
|
392
392
|
if (props.h !== 0) style += `height: ${props.h}px;`;
|
|
393
393
|
|
|
394
|
-
|
|
394
|
+
const vGradient =
|
|
395
395
|
props.colorBottom !== props.colorTop
|
|
396
396
|
? `linear-gradient(to bottom, ${colorToRgba(props.colorTop)}, ${colorToRgba(props.colorBottom)})`
|
|
397
397
|
: null;
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
const hGradient =
|
|
400
400
|
props.colorLeft !== props.colorRight
|
|
401
401
|
? `linear-gradient(to right, ${colorToRgba(props.colorLeft)}, ${colorToRgba(props.colorRight)})`
|
|
402
402
|
: null;
|
|
403
403
|
|
|
404
|
-
|
|
404
|
+
const gradient =
|
|
405
405
|
vGradient && hGradient
|
|
406
406
|
? `${vGradient}, ${hGradient}`
|
|
407
407
|
: vGradient || hGradient;
|
|
@@ -511,13 +511,13 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
if (props.shader?.props != null) {
|
|
514
|
-
|
|
514
|
+
const shaderProps = props.shader.props;
|
|
515
515
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
516
|
+
const borderWidth = shaderProps['border-w'];
|
|
517
|
+
const borderColor = shaderProps['border-color'];
|
|
518
|
+
const borderGap = shaderProps['border-gap'] ?? 0;
|
|
519
|
+
const borderAlign = shaderProps['border-align'] ?? 'inside';
|
|
520
|
+
const radius = shaderProps['radius'];
|
|
521
521
|
|
|
522
522
|
// Border
|
|
523
523
|
const borderWidthIsNumber = typeof borderWidth === 'number';
|
|
@@ -606,11 +606,11 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
606
606
|
const rg = shaderProps.radial as
|
|
607
607
|
| Partial<lng.RadialGradientProps>
|
|
608
608
|
| undefined;
|
|
609
|
-
const colors = Array.isArray(rg?.colors) ? rg
|
|
610
|
-
const stops = Array.isArray(rg?.stops) ? rg
|
|
611
|
-
const pivot = Array.isArray(rg?.pivot) ? rg
|
|
612
|
-
const width = typeof rg?.w === 'number' ? rg
|
|
613
|
-
const height = typeof rg?.h === 'number' ? rg
|
|
609
|
+
const colors = Array.isArray(rg?.colors) ? rg.colors : [];
|
|
610
|
+
const stops = Array.isArray(rg?.stops) ? rg.stops : undefined;
|
|
611
|
+
const pivot = Array.isArray(rg?.pivot) ? rg.pivot : [0.5, 0.5];
|
|
612
|
+
const width = typeof rg?.w === 'number' ? rg.w : props.w || 0;
|
|
613
|
+
const height = typeof rg?.h === 'number' ? rg.h : width;
|
|
614
614
|
|
|
615
615
|
if (colors.length > 0) {
|
|
616
616
|
const gradientStops = buildGradientStops(colors, stops);
|
|
@@ -653,9 +653,9 @@ function updateNodeStyles(node: DOMNode | DOMText) {
|
|
|
653
653
|
const lg = shaderProps.linear as
|
|
654
654
|
| Partial<lng.LinearGradientProps>
|
|
655
655
|
| undefined;
|
|
656
|
-
const colors = Array.isArray(lg?.colors) ? lg
|
|
657
|
-
const stops = Array.isArray(lg?.stops) ? lg
|
|
658
|
-
const angleRad = typeof lg?.angle === 'number' ? lg
|
|
656
|
+
const colors = Array.isArray(lg?.colors) ? lg.colors : [];
|
|
657
|
+
const stops = Array.isArray(lg?.stops) ? lg.stops : undefined;
|
|
658
|
+
const angleRad = typeof lg?.angle === 'number' ? lg.angle : 0; // radians
|
|
659
659
|
|
|
660
660
|
if (colors.length > 0) {
|
|
661
661
|
const gradientStops = buildGradientStops(colors, stops);
|
|
@@ -1028,8 +1028,8 @@ function scheduleUpdateDOMTextMeasurement(node: DOMText) {
|
|
|
1028
1028
|
|
|
1029
1029
|
function updateNodeData(node: DOMNode | DOMText) {
|
|
1030
1030
|
const data = node.data;
|
|
1031
|
-
for (
|
|
1032
|
-
|
|
1031
|
+
for (const key in data) {
|
|
1032
|
+
const keyValue: unknown = data[key];
|
|
1033
1033
|
if (keyValue === undefined) {
|
|
1034
1034
|
node.div.removeAttribute('data-' + key);
|
|
1035
1035
|
} else {
|
|
@@ -1791,16 +1791,16 @@ class DOMText extends DOMNode {
|
|
|
1791
1791
|
}
|
|
1792
1792
|
|
|
1793
1793
|
function updateRootPosition(this: DOMRendererMain) {
|
|
1794
|
-
|
|
1794
|
+
const { canvas, settings } = this;
|
|
1795
1795
|
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1796
|
+
const rect = canvas.getBoundingClientRect();
|
|
1797
|
+
const top = document.documentElement.scrollTop + rect.top;
|
|
1798
|
+
const left = document.documentElement.scrollLeft + rect.left;
|
|
1799
1799
|
|
|
1800
|
-
|
|
1800
|
+
const dpr = settings.deviceLogicalPixelRatio ?? 1;
|
|
1801
1801
|
|
|
1802
|
-
|
|
1803
|
-
|
|
1802
|
+
const height = Math.ceil(settings.appHeight ?? 1080 / dpr);
|
|
1803
|
+
const width = Math.ceil(settings.appWidth ?? 1920 / dpr);
|
|
1804
1804
|
|
|
1805
1805
|
this.root.div.style.left = `${left}px`;
|
|
1806
1806
|
this.root.div.style.top = `${top}px`;
|
|
@@ -1825,7 +1825,7 @@ export class DOMRendererMain implements IRendererMain {
|
|
|
1825
1825
|
) {
|
|
1826
1826
|
let target: HTMLElement;
|
|
1827
1827
|
if (typeof rawTarget === 'string') {
|
|
1828
|
-
|
|
1828
|
+
const result = document.getElementById(rawTarget);
|
|
1829
1829
|
if (result instanceof HTMLElement) {
|
|
1830
1830
|
target = result;
|
|
1831
1831
|
} else {
|
|
@@ -1835,7 +1835,7 @@ export class DOMRendererMain implements IRendererMain {
|
|
|
1835
1835
|
target = rawTarget;
|
|
1836
1836
|
}
|
|
1837
1837
|
|
|
1838
|
-
|
|
1838
|
+
const canvas = document.body.appendChild(document.createElement('canvas'));
|
|
1839
1839
|
canvas.style.position = 'absolute';
|
|
1840
1840
|
canvas.style.top = '0';
|
|
1841
1841
|
canvas.style.left = '0';
|
|
@@ -13,7 +13,7 @@ export function buildGradientStops(colors: number[], stops?: number[]): string {
|
|
|
13
13
|
if (!Array.isArray(colors) || colors.length === 0) return '';
|
|
14
14
|
const positions: number[] = [];
|
|
15
15
|
if (Array.isArray(stops) && stops.length === colors.length) {
|
|
16
|
-
for (
|
|
16
|
+
for (const v of stops) {
|
|
17
17
|
if (typeof v !== 'number' || !isFinite(v)) {
|
|
18
18
|
positions.push(0);
|
|
19
19
|
continue;
|
|
@@ -63,7 +63,7 @@ export function computeLegacyObjectFit(
|
|
|
63
63
|
const containerH = node.props.h || img.naturalHeight;
|
|
64
64
|
const naturalW = img.naturalWidth || 1;
|
|
65
65
|
const naturalH = img.naturalHeight || 1;
|
|
66
|
-
|
|
66
|
+
const fitType = resizeMode?.type || (srcPos ? 'none' : 'fill');
|
|
67
67
|
let drawW = naturalW;
|
|
68
68
|
let drawH = naturalH;
|
|
69
69
|
switch (fitType) {
|
package/src/core/elementNode.ts
CHANGED
|
@@ -91,7 +91,7 @@ function runPostMutation() {
|
|
|
91
91
|
|
|
92
92
|
// Phase 1: delete-flush
|
|
93
93
|
if (elementDeleteQueue.length > 0) {
|
|
94
|
-
for (
|
|
94
|
+
for (const el of elementDeleteQueue) {
|
|
95
95
|
if (Number(el._queueDelete) < 0) {
|
|
96
96
|
el.destroy();
|
|
97
97
|
}
|
|
@@ -317,6 +317,9 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
317
317
|
_lastAnyKeyPressTime?: number;
|
|
318
318
|
_type: 'element' | 'textNode';
|
|
319
319
|
_undoStyles?: string[];
|
|
320
|
+
_display?: 'flex' | 'block';
|
|
321
|
+
_onLayout?: (this: ElementNode, target: ElementNode) => void;
|
|
322
|
+
_requiresLayout: boolean;
|
|
320
323
|
autosize?: boolean;
|
|
321
324
|
/**
|
|
322
325
|
* Optional component name for inspector / dev tooling — emitted by the
|
|
@@ -504,13 +507,6 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
504
507
|
* @see https://lightning-tv.github.io/solid/#/flow/layout?id=flex
|
|
505
508
|
*/
|
|
506
509
|
direction?: 'ltr' | 'rtl';
|
|
507
|
-
/**
|
|
508
|
-
* Specifies the display behavior of an element. 'flex' enables flexbox layout.
|
|
509
|
-
*
|
|
510
|
-
* @default 'block'
|
|
511
|
-
* @see https://lightning-tv.github.io/solid/#/flow/layout?id=flex
|
|
512
|
-
*/
|
|
513
|
-
display?: 'flex' | 'block';
|
|
514
510
|
/**
|
|
515
511
|
* Defines how the flex container's size is determined. 'contain' allows it to grow with its content, 'fixed' keeps it at its specified size.
|
|
516
512
|
*
|
|
@@ -723,13 +719,6 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
723
719
|
*/
|
|
724
720
|
onEvent?: OnEvent;
|
|
725
721
|
|
|
726
|
-
/**
|
|
727
|
-
* Callback run after flex layout is calculated on flex elements
|
|
728
|
-
*
|
|
729
|
-
* @see https://lightning-tv.github.io/solid/#/flow/layout
|
|
730
|
-
*/
|
|
731
|
-
onLayout?: (this: ElementNode, target: ElementNode) => void;
|
|
732
|
-
|
|
733
722
|
/**
|
|
734
723
|
* The individual padding on each side of an element, acting as an override to the `padding` array property.
|
|
735
724
|
* `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft`.
|
|
@@ -790,6 +779,9 @@ export class ElementNode {
|
|
|
790
779
|
this._theme = undefined;
|
|
791
780
|
this._lastAnyKeyPressTime = undefined;
|
|
792
781
|
this._undoStyles = undefined;
|
|
782
|
+
this._display = undefined;
|
|
783
|
+
this._onLayout = undefined;
|
|
784
|
+
this._requiresLayout = false;
|
|
793
785
|
}
|
|
794
786
|
|
|
795
787
|
get effects(): StyleEffects | undefined {
|
|
@@ -819,7 +811,8 @@ export class ElementNode {
|
|
|
819
811
|
if (!this.lng.shader) {
|
|
820
812
|
this.lng.shader = Config.convertToShader(this, target);
|
|
821
813
|
} else if (DOM_RENDERING && Config.domRendererEnabled) {
|
|
822
|
-
|
|
814
|
+
// eslint-disable-next-line no-self-assign -- lng.shader is a setter, force style update
|
|
815
|
+
this.lng.shader = this.lng.shader;
|
|
823
816
|
}
|
|
824
817
|
} else {
|
|
825
818
|
this.lng.shader = target;
|
|
@@ -960,8 +953,8 @@ export class ElementNode {
|
|
|
960
953
|
|
|
961
954
|
_sendToLightningAnimatable(name: string, value: number) {
|
|
962
955
|
if (
|
|
963
|
-
this.transition &&
|
|
964
956
|
this.rendered &&
|
|
957
|
+
this.transition &&
|
|
965
958
|
Config.animationsEnabled &&
|
|
966
959
|
(this.transition === true ||
|
|
967
960
|
this.transition[name] ||
|
|
@@ -1094,8 +1087,11 @@ export class ElementNode {
|
|
|
1094
1087
|
}
|
|
1095
1088
|
|
|
1096
1089
|
getText(this: ElementText) {
|
|
1090
|
+
const len = this.children.length;
|
|
1091
|
+
if (len === 1) return this.children[0]!.text;
|
|
1092
|
+
if (len === 0) return '';
|
|
1097
1093
|
let result = '';
|
|
1098
|
-
for (let i = 0; i <
|
|
1094
|
+
for (let i = 0; i < len; i++) {
|
|
1099
1095
|
result += this.children[i]!.text;
|
|
1100
1096
|
}
|
|
1101
1097
|
return result;
|
|
@@ -1261,8 +1257,41 @@ export class ElementNode {
|
|
|
1261
1257
|
return this._autofocus;
|
|
1262
1258
|
}
|
|
1263
1259
|
|
|
1260
|
+
/**
|
|
1261
|
+
* Specifies the display behavior of an element. 'flex' enables flexbox layout.
|
|
1262
|
+
*
|
|
1263
|
+
* @default 'block'
|
|
1264
|
+
* @see https://lightning-tv.github.io/solid/#/flow/layout?id=flex
|
|
1265
|
+
*/
|
|
1266
|
+
get display(): 'flex' | 'block' | undefined {
|
|
1267
|
+
return this._display;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
set display(v: 'flex' | 'block' | undefined) {
|
|
1271
|
+
this._display = v;
|
|
1272
|
+
this._requiresLayout = v === 'flex' || this._onLayout !== undefined;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Callback run after flex layout is calculated on flex elements.
|
|
1277
|
+
*
|
|
1278
|
+
* @see https://lightning-tv.github.io/solid/#/flow/layout
|
|
1279
|
+
*/
|
|
1280
|
+
get onLayout():
|
|
1281
|
+
| ((this: ElementNode, target: ElementNode) => void)
|
|
1282
|
+
| undefined {
|
|
1283
|
+
return this._onLayout;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
set onLayout(
|
|
1287
|
+
fn: ((this: ElementNode, target: ElementNode) => void) | undefined,
|
|
1288
|
+
) {
|
|
1289
|
+
this._onLayout = fn;
|
|
1290
|
+
this._requiresLayout = this._display === 'flex' || fn !== undefined;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1264
1293
|
requiresLayout() {
|
|
1265
|
-
return this.
|
|
1294
|
+
return this._requiresLayout;
|
|
1266
1295
|
}
|
|
1267
1296
|
|
|
1268
1297
|
set updateLayoutOn(v: any) {
|
|
@@ -1695,7 +1724,8 @@ export function shaderAccessor<T extends Record<string, any> | number>(
|
|
|
1695
1724
|
if (!this.lng.shader) {
|
|
1696
1725
|
this.lng.shader = Config.convertToShader(this, target);
|
|
1697
1726
|
} else if (DOM_RENDERING && Config.domRendererEnabled) {
|
|
1698
|
-
|
|
1727
|
+
// eslint-disable-next-line no-self-assign -- lng.shader is a setter, force style update
|
|
1728
|
+
this.lng.shader = this.lng.shader;
|
|
1699
1729
|
}
|
|
1700
1730
|
} else {
|
|
1701
1731
|
this.lng.shader = target;
|
package/src/core/flex.ts
CHANGED
|
@@ -22,7 +22,7 @@ export default function (node: ElementNode): boolean {
|
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const processableChildrenIndices: number[] = [];
|
|
26
26
|
let hasOrder = false;
|
|
27
27
|
let totalFlexGrow = 0;
|
|
28
28
|
|
|
@@ -46,13 +46,13 @@ export default function (node: ElementNode): boolean {
|
|
|
46
46
|
totalFlexGrow += flexGrow;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
if (c[minDimension] && (c[dimension] || 0) < c[minDimension]
|
|
49
|
+
if (c[minDimension] && (c[dimension] || 0) < c[minDimension]) {
|
|
50
50
|
c[dimension] = c[minDimension]!;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (
|
|
54
54
|
c[crossMinDimension] &&
|
|
55
|
-
(c[crossDimension] || 0) < c[crossMinDimension]
|
|
55
|
+
(c[crossDimension] || 0) < c[crossMinDimension]
|
|
56
56
|
) {
|
|
57
57
|
c[crossDimension] = c[crossMinDimension]!;
|
|
58
58
|
}
|
package/src/core/flexLayout.ts
CHANGED
|
@@ -31,14 +31,10 @@ export default function (node: ElementNode): boolean {
|
|
|
31
31
|
|
|
32
32
|
// padding order: Top, Right, Bottom, Left
|
|
33
33
|
const nodePadding = node.padding;
|
|
34
|
-
const paddingTop =
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const paddingBottom = (node.paddingBottom ??
|
|
39
|
-
getArrayValue(nodePadding, 2)) as number;
|
|
40
|
-
const paddingLeft = (node.paddingLeft ??
|
|
41
|
-
getArrayValue(nodePadding, 3)) as number;
|
|
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);
|
|
42
38
|
|
|
43
39
|
const paddingStart = isRow ? paddingLeft : paddingTop;
|
|
44
40
|
const paddingEnd = isRow ? paddingRight : paddingBottom;
|
|
@@ -57,7 +53,7 @@ export default function (node: ElementNode): boolean {
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
// Optimize arrays caching
|
|
60
|
-
|
|
56
|
+
const processableChildrenIndices: number[] = [];
|
|
61
57
|
let hasOrder = false;
|
|
62
58
|
let totalFlexGrow = 0;
|
|
63
59
|
let totalFlexShrink = 0;
|
|
@@ -87,13 +83,13 @@ export default function (node: ElementNode): boolean {
|
|
|
87
83
|
totalFlexShrink += flexShrink;
|
|
88
84
|
}
|
|
89
85
|
|
|
90
|
-
if (c[minDimension] && (c[dimension] || 0) < c[minDimension]
|
|
86
|
+
if (c[minDimension] && (c[dimension] || 0) < c[minDimension]) {
|
|
91
87
|
c[dimension] = c[minDimension]!;
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
if (
|
|
95
91
|
c[crossMinDimension] &&
|
|
96
|
-
(c[crossDimension] || 0) < c[crossMinDimension]
|
|
92
|
+
(c[crossDimension] || 0) < c[crossMinDimension]
|
|
97
93
|
) {
|
|
98
94
|
c[crossDimension] = c[crossMinDimension]!;
|
|
99
95
|
}
|
package/src/core/focusManager.ts
CHANGED
|
@@ -296,7 +296,7 @@ const propagateKeyPress = (
|
|
|
296
296
|
|
|
297
297
|
let handlerAvailable: ElementNode | undefined;
|
|
298
298
|
const finalFocusElm = focusPath[0]!;
|
|
299
|
-
const keyBase = mappedEvent ||
|
|
299
|
+
const keyBase = mappedEvent || e.key;
|
|
300
300
|
const captureEvent = `onCapture${keyBase}${isUp ? 'Release' : ''}`;
|
|
301
301
|
const captureKey = isUp ? 'onCaptureKeyRelease' : 'onCaptureKey';
|
|
302
302
|
|
package/src/core/nodeTypes.ts
CHANGED
package/src/core/shaders.ts
CHANGED
|
@@ -83,7 +83,7 @@ function calcFactoredRadiusArray(
|
|
|
83
83
|
out: Vec4 = [0, 0, 0, 0],
|
|
84
84
|
): Vec4 {
|
|
85
85
|
[out[0], out[1], out[2], out[3]] = radius;
|
|
86
|
-
|
|
86
|
+
const factor = Math.min(
|
|
87
87
|
width / Math.max(width, radius[0] + radius[1]),
|
|
88
88
|
width / Math.max(width, radius[2] + radius[3]),
|
|
89
89
|
height / Math.max(height, radius[0] + radius[3]),
|
package/src/core/states.ts
CHANGED
|
@@ -12,7 +12,7 @@ export default class States extends Array<DollarString> {
|
|
|
12
12
|
if (isArray(initialState)) {
|
|
13
13
|
super(...initialState);
|
|
14
14
|
} else if (isString(initialState)) {
|
|
15
|
-
super(initialState
|
|
15
|
+
super(initialState); // Assert as DollarString
|
|
16
16
|
} else {
|
|
17
17
|
super(
|
|
18
18
|
...Object.entries(initialState)
|
|
@@ -62,7 +62,7 @@ export default class States extends Array<DollarString> {
|
|
|
62
62
|
this.push(...newStates);
|
|
63
63
|
} else if (isString(newStates)) {
|
|
64
64
|
this.length = 0; // Clear the current states
|
|
65
|
-
this.push(newStates
|
|
65
|
+
this.push(newStates); // Assert as DollarString
|
|
66
66
|
} else {
|
|
67
67
|
for (const state in newStates) {
|
|
68
68
|
const value = newStates[state as DollarString];
|
package/src/core/utils.ts
CHANGED
|
@@ -23,6 +23,7 @@ export function log(
|
|
|
23
23
|
export const isFunc = (obj: unknown): obj is CallableFunction =>
|
|
24
24
|
obj instanceof Function;
|
|
25
25
|
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
26
27
|
export const isFunction = (obj: unknown): obj is Function =>
|
|
27
28
|
typeof obj === 'function';
|
|
28
29
|
|
|
@@ -200,7 +201,7 @@ export function getElementScreenRect(
|
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
if (Config.rendererOptions != null) {
|
|
203
|
-
|
|
204
|
+
const dpr = Config.rendererOptions.deviceLogicalPixelRatio;
|
|
204
205
|
if (dpr != null) {
|
|
205
206
|
out.x *= dpr;
|
|
206
207
|
out.y *= dpr;
|
package/src/devtools/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ export const elementInterface: debug.ElementInterface<
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (lng.Config.rendererOptions != null) {
|
|
55
|
-
|
|
55
|
+
const dpr = lng.Config.rendererOptions.deviceLogicalPixelRatio;
|
|
56
56
|
if (dpr != null) {
|
|
57
57
|
x *= dpr;
|
|
58
58
|
y *= dpr;
|
|
@@ -64,7 +64,7 @@ export const elementInterface: debug.ElementInterface<
|
|
|
64
64
|
return { x, y, width, height };
|
|
65
65
|
},
|
|
66
66
|
getElementAt(e) {
|
|
67
|
-
|
|
67
|
+
const target = e.target as any;
|
|
68
68
|
return target != null && target.element instanceof lng.ElementNode
|
|
69
69
|
? target.element
|
|
70
70
|
: null;
|
|
@@ -34,7 +34,6 @@ export const Column: Component<ColumnProps> = (props) => {
|
|
|
34
34
|
<view
|
|
35
35
|
transitionUp={defaultTransitionUp}
|
|
36
36
|
transitionDown={defaultTransitionDown}
|
|
37
|
-
transition={/* @once */ {}}
|
|
38
37
|
{...props}
|
|
39
38
|
onUp={/* @once */ chainFunctions(props.onUp, onUp)}
|
|
40
39
|
onDown={/* @once */ chainFunctions(props.onDown, onDown)}
|
package/src/primitives/Grid.tsx
CHANGED
|
@@ -33,7 +33,7 @@ export function Grid<T>(props: GridProps<T>): JSX.Element {
|
|
|
33
33
|
const currentIndex = untrack(focusedIndex);
|
|
34
34
|
if (props.selected === currentIndex) return;
|
|
35
35
|
if (props.selected !== undefined && props.items?.length > props.selected) {
|
|
36
|
-
moveFocus(props.selected
|
|
36
|
+
moveFocus(props.selected - currentIndex);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
package/src/primitives/Image.tsx
CHANGED
|
@@ -32,7 +32,7 @@ export const Image: Component<ImageProps> = (props) => {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const srcTexture = renderer.createTexture('ImageTexture', props)
|
|
35
|
+
const srcTexture = renderer.createTexture('ImageTexture', props);
|
|
36
36
|
|
|
37
37
|
if (props.fallback) {
|
|
38
38
|
srcTexture.once('failed', () => {
|