@solidtv/solid 1.6.5 → 1.7.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/dist/src/core/dom-renderer/domRenderer.d.ts +7 -7
- package/dist/src/core/dom-renderer/domRenderer.js +1 -9
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
- package/dist/src/core/dom-renderer/domRendererTypes.d.ts +4 -4
- package/dist/src/core/elementNode.d.ts +4 -4
- package/dist/src/core/elementNode.js +67 -19
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/flex.js +2 -1
- package/dist/src/core/flex.js.map +1 -1
- package/dist/src/core/focusManager.js +130 -96
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/index.d.ts +3 -0
- package/dist/src/core/index.js +2 -0
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/core/intrinsicTypes.d.ts +5 -2
- package/dist/src/core/lightningInit.d.ts +2 -2
- package/dist/src/core/lightningInit.js +6 -29
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/core/shaders.d.ts +1 -1
- package/dist/src/core/states.js +20 -4
- package/dist/src/core/states.js.map +1 -1
- package/dist/src/primitives/FPSCounter.jsx +3 -3
- package/dist/src/primitives/FPSCounter.jsx.map +1 -1
- package/dist/src/primitives/Image.jsx +2 -10
- package/dist/src/primitives/Image.jsx.map +1 -1
- package/dist/src/render.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/core/dom-renderer/domRenderer.ts +4 -12
- package/src/core/dom-renderer/domRendererTypes.ts +4 -4
- package/src/core/elementNode.ts +79 -31
- package/src/core/flex.ts +2 -1
- package/src/core/focusManager.ts +162 -132
- package/src/core/index.ts +4 -0
- package/src/core/intrinsicTypes.ts +10 -2
- package/src/core/lightningInit.ts +7 -31
- package/src/core/shaders.ts +1 -1
- package/src/core/states.ts +19 -4
- package/src/primitives/FPSCounter.tsx +4 -4
- package/src/primitives/Image.tsx +2 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidtv/solid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-0",
|
|
4
4
|
"description": "SolidTV",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"@solidjs/router": "^0.16.1",
|
|
117
|
-
"@solidtv/renderer": "^
|
|
117
|
+
"@solidtv/renderer": "^2.0.0-alpha.3",
|
|
118
118
|
"solid-js": "*"
|
|
119
119
|
},
|
|
120
120
|
"peerDependenciesMeta": {},
|
|
@@ -134,7 +134,7 @@ class AnimationController implements lng.IAnimationController {
|
|
|
134
134
|
|
|
135
135
|
constructor(
|
|
136
136
|
public node: DOMNode,
|
|
137
|
-
props: Partial<lng.
|
|
137
|
+
props: Partial<lng.AnimateProps>,
|
|
138
138
|
rawSettings: Partial<lng.AnimationSettings>,
|
|
139
139
|
) {
|
|
140
140
|
this.settings = {
|
|
@@ -143,6 +143,7 @@ class AnimationController implements lng.IAnimationController {
|
|
|
143
143
|
easing: rawSettings.easing ?? 'linear',
|
|
144
144
|
loop: rawSettings.loop ?? false,
|
|
145
145
|
repeat: rawSettings.repeat ?? 1,
|
|
146
|
+
repeatDelay: rawSettings.repeatDelay ?? 0,
|
|
146
147
|
stopMethod: false,
|
|
147
148
|
adaptiveDuration: rawSettings.adaptiveDuration ?? false,
|
|
148
149
|
};
|
|
@@ -214,7 +215,7 @@ class AnimationController implements lng.IAnimationController {
|
|
|
214
215
|
|
|
215
216
|
function animate(
|
|
216
217
|
this: DOMNode,
|
|
217
|
-
props: Partial<lng.
|
|
218
|
+
props: Partial<lng.AnimateProps>,
|
|
218
219
|
settings: Partial<lng.AnimationSettings>,
|
|
219
220
|
): lng.IAnimationController {
|
|
220
221
|
return new AnimationController(this, props, settings);
|
|
@@ -1302,7 +1303,6 @@ function resolveTextNodeDefaults(
|
|
|
1302
1303
|
return {
|
|
1303
1304
|
...resolveNodeDefaults(props),
|
|
1304
1305
|
text: props.text ?? '',
|
|
1305
|
-
textRendererOverride: props.textRendererOverride ?? null,
|
|
1306
1306
|
fontSize: props.fontSize ?? 16,
|
|
1307
1307
|
fontFamily: props.fontFamily ?? 'sans-serif',
|
|
1308
1308
|
fontStyle: props.fontStyle ?? 'normal',
|
|
@@ -2020,13 +2020,6 @@ class DOMText extends DOMNode {
|
|
|
2020
2020
|
this.props.verticalAlign = v;
|
|
2021
2021
|
updateNodeStyles(this);
|
|
2022
2022
|
}
|
|
2023
|
-
get textRendererOverride() {
|
|
2024
|
-
return this.props.textRendererOverride;
|
|
2025
|
-
}
|
|
2026
|
-
set textRendererOverride(v) {
|
|
2027
|
-
this.props.textRendererOverride = v;
|
|
2028
|
-
updateNodeStyles(this);
|
|
2029
|
-
}
|
|
2030
2023
|
get offsetY() {
|
|
2031
2024
|
return this.props.offsetY;
|
|
2032
2025
|
}
|
|
@@ -2255,11 +2248,10 @@ export class DOMRendererMain implements IRendererMain {
|
|
|
2255
2248
|
): ReturnType<typeof lng.RendererMain.prototype.createShader> {
|
|
2256
2249
|
const [shaderType, props] = args;
|
|
2257
2250
|
return {
|
|
2258
|
-
// @ts-ignore
|
|
2259
2251
|
shaderType,
|
|
2260
2252
|
props,
|
|
2261
2253
|
program: {},
|
|
2262
|
-
}
|
|
2254
|
+
} as unknown as ReturnType<typeof lng.RendererMain.prototype.createShader>;
|
|
2263
2255
|
}
|
|
2264
2256
|
|
|
2265
2257
|
createTexture<Type extends keyof lng.TextureMap>(
|
|
@@ -27,7 +27,7 @@ export interface IRendererStage {
|
|
|
27
27
|
registerAnimation: (anim: any) => void;
|
|
28
28
|
unregisterAnimation: (anim: any) => void;
|
|
29
29
|
};
|
|
30
|
-
loadFont: lng.
|
|
30
|
+
loadFont: lng.RendererMain['loadFont'];
|
|
31
31
|
reprocessUpdates?: (callback?: () => void) => void;
|
|
32
32
|
requestRender: () => void;
|
|
33
33
|
cleanup(full: boolean): void;
|
|
@@ -48,8 +48,8 @@ export type IRendererShaderProps = Partial<ShaderBorderPrefixedProps> &
|
|
|
48
48
|
Partial<ShaderRadialGradientProps> &
|
|
49
49
|
Partial<ShaderLinearGradientProps>;
|
|
50
50
|
|
|
51
|
-
/** Based on {@link lng.
|
|
52
|
-
export interface IRendererShader extends Partial<lng.
|
|
51
|
+
/** Based on {@link lng.ShaderNode} */
|
|
52
|
+
export interface IRendererShader extends Partial<lng.ShaderType> {
|
|
53
53
|
shaderType: IRendererShaderType;
|
|
54
54
|
props?: IRendererShaderProps;
|
|
55
55
|
program?: {};
|
|
@@ -75,7 +75,7 @@ export interface IRendererNodeShaded extends EventEmitter {
|
|
|
75
75
|
stage: IRendererStage;
|
|
76
76
|
id: number;
|
|
77
77
|
animate: (
|
|
78
|
-
props: Partial<lng.
|
|
78
|
+
props: Partial<lng.AnimateProps>,
|
|
79
79
|
settings: Partial<lng.AnimationSettings>,
|
|
80
80
|
) => lng.IAnimationController;
|
|
81
81
|
get absX(): number;
|
package/src/core/elementNode.ts
CHANGED
|
@@ -31,19 +31,17 @@ import {
|
|
|
31
31
|
isElementText,
|
|
32
32
|
logRenderTree,
|
|
33
33
|
isFunction,
|
|
34
|
-
spliceItem,
|
|
35
34
|
} from './utils.js';
|
|
36
35
|
import { isDev, SHADERS_ENABLED } from './env.js';
|
|
37
36
|
import { Config, isDomRendererActive } from './config.js';
|
|
38
37
|
import type {
|
|
39
38
|
RendererMain,
|
|
40
39
|
INode,
|
|
41
|
-
|
|
40
|
+
AnimateProps,
|
|
42
41
|
IAnimationController,
|
|
43
42
|
LinearGradientProps,
|
|
44
43
|
RadialGradientProps,
|
|
45
44
|
ShadowProps,
|
|
46
|
-
CoreShaderNode,
|
|
47
45
|
ITextNodeProps,
|
|
48
46
|
INodeProps,
|
|
49
47
|
} from '@solidtv/renderer';
|
|
@@ -143,6 +141,23 @@ function addToLayoutQueue(node: ElementNode) {
|
|
|
143
141
|
schedulePostMutation();
|
|
144
142
|
}
|
|
145
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Removes the first `item` from `arr` in place, as `splice(index, 1)` did,
|
|
146
|
+
* without the array of removed items splice returns. Returns its index, or
|
|
147
|
+
* -1 when it is not there.
|
|
148
|
+
*/
|
|
149
|
+
function removeItem<T>(arr: T[], item: T): number {
|
|
150
|
+
const index = arr.indexOf(item);
|
|
151
|
+
if (index > -1) {
|
|
152
|
+
const last = arr.length - 1;
|
|
153
|
+
for (let i = index; i < last; i++) {
|
|
154
|
+
arr[i] = arr[i + 1]!;
|
|
155
|
+
}
|
|
156
|
+
arr.pop();
|
|
157
|
+
}
|
|
158
|
+
return index;
|
|
159
|
+
}
|
|
160
|
+
|
|
146
161
|
// Text-default template, built once on first use. Config.fontSettings is
|
|
147
162
|
// expected to be set at app startup and not change afterwards.
|
|
148
163
|
let _fontTemplate: Array<[string, any]> | undefined;
|
|
@@ -173,6 +188,22 @@ const EFFECT_SHADER_KEYS = [
|
|
|
173
188
|
'shadow',
|
|
174
189
|
] as const satisfies ReadonlyArray<keyof StyleEffects>;
|
|
175
190
|
|
|
191
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
192
|
+
|
|
193
|
+
// Handle individual border sides: transform width/w to bottom/left/right/top
|
|
194
|
+
const borderSideMap: Record<string, string> = {
|
|
195
|
+
borderBottom: 'bottom',
|
|
196
|
+
borderLeft: 'left',
|
|
197
|
+
borderRight: 'right',
|
|
198
|
+
borderTop: 'top',
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// The shader prop each key of a style object writes, per style prefix
|
|
202
|
+
// (`border` + `width` → `border-w`, `borderTop` + `w` → `border-top`): built
|
|
203
|
+
// at a key's first write, so that a write builds no string.
|
|
204
|
+
const shaderPropNames: Record<string, Record<string, string> | undefined> =
|
|
205
|
+
Object.create(null);
|
|
206
|
+
|
|
176
207
|
const parseAndAssignShaderProps = (
|
|
177
208
|
prefix: string,
|
|
178
209
|
obj: Record<string, unknown>,
|
|
@@ -180,28 +211,33 @@ const parseAndAssignShaderProps = (
|
|
|
180
211
|
) => {
|
|
181
212
|
if (!obj) return;
|
|
182
213
|
|
|
183
|
-
// Handle individual border sides: transform width/w to bottom/left/right/top
|
|
184
|
-
const borderSideMap: Record<string, string> = {
|
|
185
|
-
borderBottom: 'bottom',
|
|
186
|
-
borderLeft: 'left',
|
|
187
|
-
borderRight: 'right',
|
|
188
|
-
borderTop: 'top',
|
|
189
|
-
};
|
|
190
|
-
|
|
191
214
|
const side = borderSideMap[prefix];
|
|
192
215
|
const actualPrefix = side ? 'border' : prefix;
|
|
216
|
+
let names = shaderPropNames[prefix];
|
|
217
|
+
if (names === undefined) {
|
|
218
|
+
names = Object.create(null) as Record<string, string>;
|
|
219
|
+
shaderPropNames[prefix] = names;
|
|
220
|
+
}
|
|
193
221
|
|
|
194
222
|
props[actualPrefix] = obj;
|
|
195
|
-
Object.entries
|
|
196
|
-
|
|
223
|
+
// The object's own enumerable keys in order, as Object.entries gave them,
|
|
224
|
+
// without its arrays and closure.
|
|
225
|
+
for (const key in obj) {
|
|
226
|
+
if (!hasOwnProperty.call(obj, key)) continue;
|
|
227
|
+
let name = names[key];
|
|
228
|
+
if (name === undefined) {
|
|
229
|
+
let transformedKey = key === 'width' ? 'w' : key;
|
|
230
|
+
|
|
231
|
+
// If border side and key is width/w, transform to side (bottom/left/right/top)
|
|
232
|
+
if (side && transformedKey === 'w') {
|
|
233
|
+
transformedKey = side;
|
|
234
|
+
}
|
|
197
235
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
transformedKey = side;
|
|
236
|
+
name = actualPrefix + '-' + transformedKey;
|
|
237
|
+
names[key] = name;
|
|
201
238
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
239
|
+
props[name] = obj[key];
|
|
240
|
+
}
|
|
205
241
|
};
|
|
206
242
|
|
|
207
243
|
export function convertToShader(
|
|
@@ -211,7 +247,10 @@ export function convertToShader(
|
|
|
211
247
|
let type = 'rounded';
|
|
212
248
|
if (v.border) type += 'WithBorder';
|
|
213
249
|
if (v.shadow) type += 'WithShadow';
|
|
214
|
-
return renderer.createShader(
|
|
250
|
+
return renderer.createShader(
|
|
251
|
+
type,
|
|
252
|
+
v as Record<string, unknown>,
|
|
253
|
+
) as IRendererShader;
|
|
215
254
|
}
|
|
216
255
|
|
|
217
256
|
function getPropertyAlias(name: string) {
|
|
@@ -322,7 +361,7 @@ export interface ElementNode extends RendererNode, FocusNode {
|
|
|
322
361
|
_queueDelete?: number;
|
|
323
362
|
_animationQueue?:
|
|
324
363
|
| Array<{
|
|
325
|
-
props: Partial<
|
|
364
|
+
props: Partial<AnimateProps>;
|
|
326
365
|
animationSettings?: AnimationSettings;
|
|
327
366
|
}>
|
|
328
367
|
| undefined;
|
|
@@ -955,8 +994,16 @@ export class ElementNode {
|
|
|
955
994
|
if (beforeNode) {
|
|
956
995
|
// SolidJS can move nodes around in the children array.
|
|
957
996
|
// We need to insert following DOM insertBefore which moves elements.
|
|
958
|
-
|
|
959
|
-
|
|
997
|
+
const children = this.children;
|
|
998
|
+
removeItem(children, node as ElementNode);
|
|
999
|
+
const index = children.indexOf(beforeNode as ElementNode);
|
|
1000
|
+
if (index > -1) {
|
|
1001
|
+
// In front of beforeNode, the rest moved up one: splice(index, 0,
|
|
1002
|
+
// node) without its argument list and result array.
|
|
1003
|
+
for (let i = children.length; i > index; i--) {
|
|
1004
|
+
children[i] = children[i - 1]!;
|
|
1005
|
+
}
|
|
1006
|
+
children[index] = node as ElementNode;
|
|
960
1007
|
return;
|
|
961
1008
|
}
|
|
962
1009
|
}
|
|
@@ -965,7 +1012,7 @@ export class ElementNode {
|
|
|
965
1012
|
}
|
|
966
1013
|
|
|
967
1014
|
removeChild(node: ElementNode | ElementText | TextNode) {
|
|
968
|
-
if (
|
|
1015
|
+
if (removeItem(this.children, node as ElementNode) > -1) {
|
|
969
1016
|
if (isElementNode(node) && node.onRemove) {
|
|
970
1017
|
node.onRemove.call(node, node);
|
|
971
1018
|
}
|
|
@@ -1057,7 +1104,7 @@ export class ElementNode {
|
|
|
1057
1104
|
}
|
|
1058
1105
|
|
|
1059
1106
|
animate(
|
|
1060
|
-
props: Partial<
|
|
1107
|
+
props: Partial<AnimateProps>,
|
|
1061
1108
|
animationSettings?: AnimationSettings,
|
|
1062
1109
|
): IAnimationController {
|
|
1063
1110
|
if (!this.rendered) {
|
|
@@ -1070,10 +1117,7 @@ export class ElementNode {
|
|
|
1070
1117
|
);
|
|
1071
1118
|
}
|
|
1072
1119
|
|
|
1073
|
-
chain(
|
|
1074
|
-
props: Partial<INodeAnimateProps<CoreShaderNode>>,
|
|
1075
|
-
animationSettings?: AnimationSettings,
|
|
1076
|
-
) {
|
|
1120
|
+
chain(props: Partial<AnimateProps>, animationSettings?: AnimationSettings) {
|
|
1077
1121
|
if (this._animationRunning) {
|
|
1078
1122
|
this._animationQueue = [];
|
|
1079
1123
|
this._animationRunning = false;
|
|
@@ -1714,7 +1758,7 @@ export class ElementNode {
|
|
|
1714
1758
|
if (isDev) log('Rendering: ', this, props);
|
|
1715
1759
|
|
|
1716
1760
|
node.lng = renderer.createNode(
|
|
1717
|
-
props as Partial<INodeProps
|
|
1761
|
+
props as Partial<INodeProps> & Partial<IRendererNodeProps>,
|
|
1718
1762
|
);
|
|
1719
1763
|
|
|
1720
1764
|
if (node._hasRenderedChildren) {
|
|
@@ -1742,7 +1786,11 @@ export class ElementNode {
|
|
|
1742
1786
|
this.onRender?.(this);
|
|
1743
1787
|
|
|
1744
1788
|
if (node.onEvent) {
|
|
1745
|
-
|
|
1789
|
+
const onEvent = node.onEvent;
|
|
1790
|
+
// Own enumerable keys in order, as Object.entries gave them.
|
|
1791
|
+
for (const name in onEvent) {
|
|
1792
|
+
if (!hasOwnProperty.call(onEvent, name)) continue;
|
|
1793
|
+
const handler = onEvent[name as keyof OnEvent]!;
|
|
1746
1794
|
if (typeof node.lng.on === 'function') {
|
|
1747
1795
|
node.lng.on(name, (_inode, data) => handler.call(node, node, data));
|
|
1748
1796
|
}
|
package/src/core/flex.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ElementNode } from './elementNode.js';
|
|
2
2
|
import { isTextNode, isElementText } from './utils.js';
|
|
3
|
+
import { isDev } from './env.js';
|
|
3
4
|
|
|
4
5
|
export default function (node: ElementNode): boolean {
|
|
5
6
|
const direction = node.flexDirection || 'row';
|
|
@@ -154,7 +155,7 @@ export default function (node: ElementNode): boolean {
|
|
|
154
155
|
node._containsFlexGrow = node._containsFlexGrow ? null : true;
|
|
155
156
|
} else if (node._containsFlexGrow) {
|
|
156
157
|
node._containsFlexGrow = null;
|
|
157
|
-
} else {
|
|
158
|
+
} else if (isDev) {
|
|
158
159
|
// No positive space available for items to grow, or items overflow.
|
|
159
160
|
// flex-grow has no effect in this case.
|
|
160
161
|
console.warn(
|