@solidtv/solid 1.6.5 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/src/core/dom-renderer/domRenderer.d.ts +7 -7
  2. package/dist/src/core/dom-renderer/domRenderer.js +1 -9
  3. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  4. package/dist/src/core/dom-renderer/domRendererTypes.d.ts +4 -4
  5. package/dist/src/core/elementNode.d.ts +23 -5
  6. package/dist/src/core/elementNode.js +194 -45
  7. package/dist/src/core/elementNode.js.map +1 -1
  8. package/dist/src/core/flex.js +2 -1
  9. package/dist/src/core/flex.js.map +1 -1
  10. package/dist/src/core/focusManager.js +144 -99
  11. package/dist/src/core/focusManager.js.map +1 -1
  12. package/dist/src/core/index.d.ts +3 -0
  13. package/dist/src/core/index.js +2 -0
  14. package/dist/src/core/index.js.map +1 -1
  15. package/dist/src/core/intrinsicTypes.d.ts +5 -2
  16. package/dist/src/core/lightningInit.d.ts +2 -2
  17. package/dist/src/core/lightningInit.js +71 -32
  18. package/dist/src/core/lightningInit.js.map +1 -1
  19. package/dist/src/core/nodeTypes.d.ts +1 -1
  20. package/dist/src/core/nodeTypes.js +2 -3
  21. package/dist/src/core/nodeTypes.js.map +1 -1
  22. package/dist/src/core/shaders.d.ts +1 -1
  23. package/dist/src/core/states.js +20 -4
  24. package/dist/src/core/states.js.map +1 -1
  25. package/dist/src/primitives/FPSCounter.jsx +3 -3
  26. package/dist/src/primitives/FPSCounter.jsx.map +1 -1
  27. package/dist/src/primitives/Image.jsx +2 -10
  28. package/dist/src/primitives/Image.jsx.map +1 -1
  29. package/dist/src/primitives/Lazy.jsx +7 -1
  30. package/dist/src/primitives/Lazy.jsx.map +1 -1
  31. package/dist/src/primitives/Virtual.d.ts +4 -0
  32. package/dist/src/primitives/Virtual.jsx +192 -106
  33. package/dist/src/primitives/Virtual.jsx.map +1 -1
  34. package/dist/src/primitives/VirtualGrid.jsx +87 -18
  35. package/dist/src/primitives/VirtualGrid.jsx.map +1 -1
  36. package/dist/src/primitives/utils/handleNavigation.js +12 -5
  37. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  38. package/dist/src/primitives/utils/withScrolling.js +63 -57
  39. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  40. package/dist/src/render.d.ts +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +12 -5
  43. package/src/core/dom-renderer/domRenderer.ts +4 -12
  44. package/src/core/dom-renderer/domRendererTypes.ts +4 -4
  45. package/src/core/elementNode.ts +219 -50
  46. package/src/core/flex.ts +2 -1
  47. package/src/core/focusManager.ts +173 -135
  48. package/src/core/index.ts +4 -0
  49. package/src/core/intrinsicTypes.ts +10 -2
  50. package/src/core/lightningInit.ts +85 -35
  51. package/src/core/nodeTypes.ts +6 -3
  52. package/src/core/shaders.ts +1 -1
  53. package/src/core/states.ts +19 -4
  54. package/src/primitives/FPSCounter.tsx +4 -4
  55. package/src/primitives/Image.tsx +2 -9
  56. package/src/primitives/Lazy.tsx +8 -1
  57. package/src/primitives/Virtual.tsx +211 -117
  58. package/src/primitives/VirtualGrid.tsx +98 -21
  59. package/src/primitives/utils/handleNavigation.ts +12 -5
  60. package/src/primitives/utils/withScrolling.ts +63 -62
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.6.5",
3
+ "version": "1.7.0",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,10 +34,17 @@
34
34
  },
35
35
  "./devtools/jsx-locator": "./src/devtools/jsx-locator.js",
36
36
  "./shaders": {
37
- "@solidtv/source": "./src/shaders/index.ts",
37
+ "@solidtv/source": "./src/core/shaders.ts",
38
38
  "import": {
39
- "types": "./dist/src/shaders/index.d.ts",
40
- "default": "./dist/src/shaders/index.js"
39
+ "types": "./dist/src/core/shaders.d.ts",
40
+ "default": "./dist/src/core/shaders.js"
41
+ }
42
+ },
43
+ "./focusManager": {
44
+ "@solidtv/source": "./src/core/focusManager.ts",
45
+ "import": {
46
+ "types": "./dist/src/core/focusManager.d.ts",
47
+ "default": "./dist/src/core/focusManager.js"
41
48
  }
42
49
  },
43
50
  "./jsx-runtime": {
@@ -114,7 +121,7 @@
114
121
  },
115
122
  "peerDependencies": {
116
123
  "@solidjs/router": "^0.16.1",
117
- "@solidtv/renderer": "^1.10.1",
124
+ "@solidtv/renderer": "^2.0.6",
118
125
  "solid-js": "*"
119
126
  },
120
127
  "peerDependenciesMeta": {},
@@ -134,7 +134,7 @@ class AnimationController implements lng.IAnimationController {
134
134
 
135
135
  constructor(
136
136
  public node: DOMNode,
137
- props: Partial<lng.INodeAnimateProps<any>>,
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.INodeAnimateProps<any>>,
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.Stage['loadFont'];
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.CoreShaderNode} */
52
- export interface IRendererShader extends Partial<lng.CoreShaderType> {
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.INodeAnimateProps<any>>,
78
+ props: Partial<lng.AnimateProps>,
79
79
  settings: Partial<lng.AnimationSettings>,
80
80
  ) => lng.IAnimationController;
81
81
  get absX(): number;
@@ -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
- INodeAnimateProps,
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,38 +211,104 @@ 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(obj).forEach(([key, value]) => {
196
- let transformedKey = key === 'width' ? 'w' : key;
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
- // If border side and key is width/w, transform to side (bottom/left/right/top)
199
- if (side && transformedKey === 'w') {
200
- transformedKey = side;
236
+ name = actualPrefix + '-' + transformedKey;
237
+ names[key] = name;
201
238
  }
239
+ props[name] = obj[key];
240
+ }
241
+ };
202
242
 
203
- props[`${actualPrefix}-${transformedKey}`] = value;
204
- });
243
+ const assignEffects = (v: StyleEffects, props: Record<string, unknown>) => {
244
+ if (v.rounded) props.radius = v.rounded.radius;
245
+ if (v.borderRadius) props.radius = v.borderRadius;
246
+ for (const k of EFFECT_SHADER_KEYS) {
247
+ if (v[k]) parseAndAssignShaderProps(k, v[k], props);
248
+ }
249
+ };
250
+
251
+ const assignShaderProp = (
252
+ key: string,
253
+ value: unknown,
254
+ props: Record<string, unknown>,
255
+ ) => {
256
+ if (key === 'rounded' || typeof value === 'number') {
257
+ props.radius = value;
258
+ } else {
259
+ parseAndAssignShaderProps(key, value as Record<string, unknown>, props);
260
+ }
261
+ };
262
+
263
+ // The shader types convertToShader makes, by feature bits.
264
+ const BORDER_FEATURE = 1;
265
+ const SHADOW_FEATURE = 2;
266
+ const ROUNDED_SHADER_TYPES = [
267
+ 'rounded',
268
+ 'roundedWithBorder',
269
+ 'roundedWithShadow',
270
+ 'roundedWithBorderWithShadow',
271
+ ];
272
+
273
+ const BORDER_WIDTH_KEYS = [
274
+ 'border-w',
275
+ 'border-top',
276
+ 'border-right',
277
+ 'border-bottom',
278
+ 'border-left',
279
+ ];
280
+
281
+ // Whether a border width is above 0: read from `change` where it has the
282
+ // key, else from `props`. A border of width 0 needs no border shader.
283
+ const hasBorderWidth = (
284
+ props: Record<string, unknown>,
285
+ change?: Record<string, unknown>,
286
+ ) => {
287
+ for (const key of BORDER_WIDTH_KEYS) {
288
+ const w = change !== undefined && key in change ? change[key] : props[key];
289
+ if (isArray(w)) {
290
+ for (let i = 0; i < w.length; i++) if (w[i] > 0) return true;
291
+ } else if ((w as number) > 0) {
292
+ return true;
293
+ }
294
+ }
295
+ return false;
205
296
  };
206
297
 
207
298
  export function convertToShader(
208
- _node: ElementNode,
299
+ node: ElementNode,
209
300
  v: StyleEffects,
210
301
  ): IRendererShader {
211
- let type = 'rounded';
212
- if (v.border) type += 'WithBorder';
213
- if (v.shadow) type += 'WithShadow';
214
- return renderer.createShader(type, v);
302
+ const props = v as Record<string, unknown>;
303
+ const features =
304
+ (hasBorderWidth(props) ? BORDER_FEATURE : 0) |
305
+ (props.shadow ? SHADOW_FEATURE : 0);
306
+ node._shaderProps = props;
307
+ node._shaderFeatures = features;
308
+ return renderer.createShader(
309
+ ROUNDED_SHADER_TYPES[features]!,
310
+ props,
311
+ ) as IRendererShader;
215
312
  }
216
313
 
217
314
  function getPropertyAlias(name: string) {
@@ -322,7 +419,7 @@ export interface ElementNode extends RendererNode, FocusNode {
322
419
  _queueDelete?: number;
323
420
  _animationQueue?:
324
421
  | Array<{
325
- props: Partial<INodeAnimateProps<CoreShaderNode>>;
422
+ props: Partial<AnimateProps>;
326
423
  animationSettings?: AnimationSettings;
327
424
  }>
328
425
  | undefined;
@@ -333,6 +430,10 @@ export interface ElementNode extends RendererNode, FocusNode {
333
430
  _containsFlexGrow?: boolean | null;
334
431
  _hasRenderedChildren?: boolean;
335
432
  _effects?: Record<string, any>;
433
+ /** The props of a shader convertToShader made, kept to swap its type. */
434
+ _shaderProps?: Record<string, unknown>;
435
+ /** That shader's ROUNDED_SHADER_TYPES index: border 1, shadow 2. */
436
+ _shaderFeatures?: number;
336
437
  _fontFamily?: string;
337
438
  _id: string | undefined;
338
439
  _parent: ElementNode | undefined;
@@ -346,6 +447,8 @@ export interface ElementNode extends RendererNode, FocusNode {
346
447
  _display?: 'flex' | 'block';
347
448
  _onLayout?: (this: ElementNode, target: ElementNode) => void;
348
449
  _requiresLayout: boolean;
450
+ /** @internal the focus manager's generation stamp for the focus-path diff */
451
+ _focusGen: number;
349
452
  autosize?: boolean;
350
453
  /**
351
454
  * Optional component name for inspector / dev tooling — emitted by the
@@ -818,6 +921,8 @@ export class ElementNode {
818
921
  this._containsFlexGrow = undefined;
819
922
  this._hasRenderedChildren = undefined;
820
923
  this._effects = undefined;
924
+ this._shaderProps = undefined;
925
+ this._shaderFeatures = undefined;
821
926
  this._fontFamily = undefined;
822
927
  this._fontWeight = undefined;
823
928
  this._id = undefined;
@@ -830,6 +935,7 @@ export class ElementNode {
830
935
  this._display = undefined;
831
936
  this._onLayout = undefined;
832
937
  this._requiresLayout = false;
938
+ this._focusGen = 0;
833
939
  }
834
940
 
835
941
  get effects(): StyleEffects | undefined {
@@ -855,16 +961,39 @@ export class ElementNode {
855
961
  }
856
962
  }
857
963
 
964
+ /**
965
+ * Swap a shader convertToShader made when its border width moves to or
966
+ * from 0. For an animated write, `change` holds what animates: a border
967
+ * it adds is swapped in before the animation reads its start values, one
968
+ * it removes stays until the animation stops.
969
+ */
970
+ _syncShaderType(change?: Record<string, unknown>) {
971
+ const props = this._shaderProps;
972
+ if (props === undefined || !this.lng.shader) return;
973
+ const features = this._shaderFeatures!;
974
+ let next = features & SHADOW_FEATURE;
975
+ if (hasBorderWidth(props, change)) next |= BORDER_FEATURE;
976
+ else if (change !== undefined) next |= features & BORDER_FEATURE;
977
+ if (next === features) return;
978
+ this._shaderFeatures = next;
979
+ this.lng.shader = renderer.createShader(
980
+ ROUNDED_SHADER_TYPES[next]!,
981
+ props,
982
+ ) as IRendererShader;
983
+ }
984
+
858
985
  set effects(v: StyleEffects) {
859
986
  if (!SHADERS_ENABLED) return;
860
987
  let target = this.lng.shader || {};
861
988
  if (this.lng.shader?.props) {
862
989
  target = this.lng.shader.props;
863
990
  }
864
- if (v.rounded) target.radius = v.rounded.radius;
865
- if (v.borderRadius) target.radius = v.borderRadius;
866
- for (const k of EFFECT_SHADER_KEYS) {
867
- if (v[k]) parseAndAssignShaderProps(k, v[k], target);
991
+ assignEffects(v, target);
992
+
993
+ const props = this._shaderProps;
994
+ if (props !== undefined) {
995
+ if (props !== target) assignEffects(v, props);
996
+ this._syncShaderType();
868
997
  }
869
998
 
870
999
  this._writeShaderTarget(target);
@@ -914,12 +1043,7 @@ export class ElementNode {
914
1043
  }
915
1044
 
916
1045
  this._fontWeight = v;
917
- const weight =
918
- (Config.fontWeightAlias &&
919
- (Config.fontWeightAlias[v as string] as number | string)) ??
920
- v;
921
- (this.lng as ElementNode).fontFamily =
922
- `${this.fontFamily || Config.fontSettings?.fontFamily}${weight}`;
1046
+ this._writeFontFamily();
923
1047
  }
924
1048
 
925
1049
  get fontWeight() {
@@ -928,13 +1052,38 @@ export class ElementNode {
928
1052
 
929
1053
  set fontFamily(v) {
930
1054
  this._fontFamily = v;
931
- (this.lng as ElementNode).fontFamily = v;
1055
+ this._writeFontFamily();
932
1056
  }
933
1057
 
934
1058
  get fontFamily() {
935
1059
  return this._fontFamily;
936
1060
  }
937
1061
 
1062
+ /**
1063
+ * The renderer's family name from `fontFamily` and `fontWeight`, resolved
1064
+ * in one place so either JSX order gives the same name (B17).
1065
+ */
1066
+ _writeFontFamily() {
1067
+ const weight = this._fontWeight as number | string | undefined;
1068
+ if (weight === undefined) {
1069
+ // No family of its own: before render, undefined lets render's font
1070
+ // template fill it in; after render, write what the template gave
1071
+ // (Config.fontSettings' family and weight, read at the first text
1072
+ // render), not undefined, which the renderer takes as its default.
1073
+ const family = this._fontFamily;
1074
+ (this.lng as ElementNode).fontFamily =
1075
+ family === undefined && this.rendered ? _fontFamilyWithWeight : family;
1076
+ return;
1077
+ }
1078
+ const alias = Config.fontWeightAlias;
1079
+ const aliased =
1080
+ alias !== undefined && alias !== null
1081
+ ? (alias[weight] as number | string | undefined)
1082
+ : undefined;
1083
+ (this.lng as ElementNode).fontFamily =
1084
+ `${this._fontFamily || Config.fontSettings?.fontFamily}${aliased ?? weight}`;
1085
+ }
1086
+
938
1087
  insertChild(
939
1088
  node: ElementNode | ElementText | TextNode,
940
1089
  beforeNode?: ElementNode | ElementText | TextNode | null,
@@ -955,8 +1104,16 @@ export class ElementNode {
955
1104
  if (beforeNode) {
956
1105
  // SolidJS can move nodes around in the children array.
957
1106
  // We need to insert following DOM insertBefore which moves elements.
958
- spliceItem(this.children, node as ElementNode, 1);
959
- if (spliceItem(this.children, beforeNode as ElementNode, 0, node) > -1) {
1107
+ const children = this.children;
1108
+ removeItem(children, node as ElementNode);
1109
+ const index = children.indexOf(beforeNode as ElementNode);
1110
+ if (index > -1) {
1111
+ // In front of beforeNode, the rest moved up one: splice(index, 0,
1112
+ // node) without its argument list and result array.
1113
+ for (let i = children.length; i > index; i--) {
1114
+ children[i] = children[i - 1]!;
1115
+ }
1116
+ children[index] = node as ElementNode;
960
1117
  return;
961
1118
  }
962
1119
  }
@@ -965,7 +1122,7 @@ export class ElementNode {
965
1122
  }
966
1123
 
967
1124
  removeChild(node: ElementNode | ElementText | TextNode) {
968
- if (spliceItem(this.children, node, 1) > -1) {
1125
+ if (removeItem(this.children, node as ElementNode) > -1) {
969
1126
  if (isElementNode(node) && node.onRemove) {
970
1127
  node.onRemove.call(node, node);
971
1128
  }
@@ -993,6 +1150,7 @@ export class ElementNode {
993
1150
  set shader(
994
1151
  shaderProps: IRendererShader | [kind: string, props: IRendererShaderProps],
995
1152
  ) {
1153
+ this._shaderProps = undefined;
996
1154
  this.lng.shader = isArray(shaderProps)
997
1155
  ? renderer.createShader(...shaderProps)
998
1156
  : shaderProps;
@@ -1057,7 +1215,7 @@ export class ElementNode {
1057
1215
  }
1058
1216
 
1059
1217
  animate(
1060
- props: Partial<INodeAnimateProps<CoreShaderNode>>,
1218
+ props: Partial<AnimateProps>,
1061
1219
  animationSettings?: AnimationSettings,
1062
1220
  ): IAnimationController {
1063
1221
  if (!this.rendered) {
@@ -1070,10 +1228,7 @@ export class ElementNode {
1070
1228
  );
1071
1229
  }
1072
1230
 
1073
- chain(
1074
- props: Partial<INodeAnimateProps<CoreShaderNode>>,
1075
- animationSettings?: AnimationSettings,
1076
- ) {
1231
+ chain(props: Partial<AnimateProps>, animationSettings?: AnimationSettings) {
1077
1232
  if (this._animationRunning) {
1078
1233
  this._animationQueue = [];
1079
1234
  this._animationRunning = false;
@@ -1714,7 +1869,7 @@ export class ElementNode {
1714
1869
  if (isDev) log('Rendering: ', this, props);
1715
1870
 
1716
1871
  node.lng = renderer.createNode(
1717
- props as Partial<INodeProps<any>> & Partial<IRendererNodeProps>,
1872
+ props as Partial<INodeProps> & Partial<IRendererNodeProps>,
1718
1873
  );
1719
1874
 
1720
1875
  if (node._hasRenderedChildren) {
@@ -1742,7 +1897,11 @@ export class ElementNode {
1742
1897
  this.onRender?.(this);
1743
1898
 
1744
1899
  if (node.onEvent) {
1745
- for (const [name, handler] of Object.entries(node.onEvent)) {
1900
+ const onEvent = node.onEvent;
1901
+ // Own enumerable keys in order, as Object.entries gave them.
1902
+ for (const name in onEvent) {
1903
+ if (!hasOwnProperty.call(onEvent, name)) continue;
1904
+ const handler = onEvent[name as keyof OnEvent]!;
1746
1905
  if (typeof node.lng.on === 'function') {
1747
1906
  node.lng.on(name, (_inode, data) => handler.call(node, node, data));
1748
1907
  }
@@ -1849,16 +2008,26 @@ export function shaderAccessor<T extends Record<string, any> | number>(
1849
2008
  }
1850
2009
  }
1851
2010
 
1852
- if (key === 'rounded' || typeof value === 'number') {
1853
- target.radius = value;
1854
- } else {
1855
- parseAndAssignShaderProps(key, value, target);
2011
+ assignShaderProp(key, value, target);
2012
+
2013
+ const props = this._shaderProps;
2014
+ if (props !== undefined) {
2015
+ const animated = target !== this.lng.shader?.props;
2016
+ if (animated) this._syncShaderType(target);
2017
+ if (props !== target) assignShaderProp(key, value, props);
2018
+ if (!animated) this._syncShaderType();
1856
2019
  }
1857
2020
 
1858
2021
  this._writeShaderTarget(target);
1859
2022
 
1860
2023
  if (animationSettings) {
1861
- this.animate({ shaderProps: target }, animationSettings).start();
2024
+ const animation = this.animate(
2025
+ { shaderProps: target },
2026
+ animationSettings,
2027
+ ).start();
2028
+ if (props !== undefined) {
2029
+ void animation.waitUntilStopped().then(() => this._syncShaderType());
2030
+ }
1862
2031
  }
1863
2032
  },
1864
2033
  get(this: ElementNode) {
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(