@solidtv/solid 1.6.4 → 1.6.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -48,6 +48,7 @@
48
48
  "sideEffects": false,
49
49
  "scripts": {
50
50
  "start": "pnpm run watch",
51
+ "bench": "node bench/run.mjs",
51
52
  "test": "vitest",
52
53
  "lint": "pnpm run lint:prettier && pnpm run lint:eslint",
53
54
  "lint:fix": "pnpm run lint:fix:prettier && pnpm run lint:fix:eslint",
@@ -56,12 +57,13 @@
56
57
  "lint:eslint": "eslint .",
57
58
  "lint:fix:eslint": "eslint --fix .",
58
59
  "build": "rm -rf dist && pnpm run tsc && cp jsx-runtime.d.ts dist/",
59
- "tsc": "tsc",
60
+ "tsc": "tsc && tsc -p tests/tsconfig.contract.json",
60
61
  "watch": "tsc -w",
61
62
  "prepare": "husky",
62
63
  "prepack": "pnpm run build",
63
64
  "release": "release-it",
64
- "test:browser": "vitest --config=vitest.browser.config.ts"
65
+ "test:browser": "vitest --config=vitest.browser.config.ts",
66
+ "test:webgl": "vitest run --config=vitest.webgl.config.ts"
65
67
  },
66
68
  "keywords": [
67
69
  "lightning",
@@ -80,6 +82,7 @@
80
82
  },
81
83
  "devDependencies": {
82
84
  "@eslint/js": "^9.39.4",
85
+ "@lightningtv/vite-hex-transform": "^1.1.0",
83
86
  "@solid-devtools/debugger": "^0.28.1",
84
87
  "@solidjs/testing-library": "^0.8.10",
85
88
  "@typescript-eslint/eslint-plugin": "^8.59.2",
@@ -92,8 +95,10 @@
92
95
  "husky": "^9.1.7",
93
96
  "jsdom": "^26.1.0",
94
97
  "lint-staged": "^17.0.4",
98
+ "playwright": "1.56.1",
95
99
  "prettier": "^3.8.3",
96
100
  "release-it": "^20.0.1",
101
+ "terser": "^5.51.2",
97
102
  "typescript": "^6.0.3",
98
103
  "typescript-eslint": "^8.59.2",
99
104
  "vite": "^8.0.13",
@@ -109,7 +114,7 @@
109
114
  },
110
115
  "peerDependencies": {
111
116
  "@solidjs/router": "^0.16.1",
112
- "@solidtv/renderer": "^1.9.0",
117
+ "@solidtv/renderer": "^1.10.1",
113
118
  "solid-js": "*"
114
119
  },
115
120
  "peerDependenciesMeta": {},
@@ -1358,6 +1358,8 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1358
1358
 
1359
1359
  preventCleanup = true;
1360
1360
 
1361
+ destroyed = false;
1362
+
1361
1363
  constructor(
1362
1364
  public stage: IRendererStage,
1363
1365
  public props: IRendererNodeProps,
@@ -1380,6 +1382,7 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1380
1382
  }
1381
1383
 
1382
1384
  destroy(): void {
1385
+ this.markDestroyed();
1383
1386
  elMap.delete(this);
1384
1387
  const parent = this.props.parent;
1385
1388
  if (parent instanceof DOMNode) {
@@ -1388,6 +1391,14 @@ export class DOMNode extends EventEmitter implements IRendererNode {
1388
1391
  this.div.parentNode?.removeChild(this.div);
1389
1392
  }
1390
1393
 
1394
+ // Like CoreNode, destroying a node marks its whole subtree destroyed.
1395
+ private markDestroyed() {
1396
+ this.destroyed = true;
1397
+ for (const child of this.children) {
1398
+ child.markDestroyed();
1399
+ }
1400
+ }
1401
+
1391
1402
  get parent() {
1392
1403
  return this.props.parent;
1393
1404
  }
@@ -12,7 +12,7 @@ import {
12
12
  /** Based on {@link lng.CoreRenderer} */
13
13
  export interface IRendererCoreRenderer {
14
14
  mode: 'canvas' | 'webgl' | undefined;
15
- boundsMargin?: number;
15
+ boundsMargin?: number | [number, number, number, number];
16
16
  }
17
17
  /** Based on {@link lng.TrFontManager} */
18
18
  export interface IRendererFontManager {
@@ -148,9 +148,8 @@ export interface DomRendererMainSettings {
148
148
  * Preload margin around the viewport, in logical pixels (default: 200)
149
149
  *
150
150
  * @remarks
151
- * A single number applied to all sides. The `[top, right, bottom, left]`
152
- * array form was dropped in renderer 1.8; it is still tolerated at runtime
153
- * (the largest edge wins, with a warning) but should be replaced.
151
+ * A single number applied to all sides, or a per-side
152
+ * `[top, right, bottom, left]` tuple.
154
153
  */
155
- boundsMargin?: number;
154
+ boundsMargin?: number | [number, number, number, number];
156
155
  }
@@ -222,30 +222,19 @@ export function nodeHasTextureSource(node: DOMNode): boolean {
222
222
  }
223
223
 
224
224
  /**
225
- * Coerce a `boundsMargin` value to the scalar the renderer takes since 1.8.
226
- *
227
- * @remarks
228
- * The `[top, right, bottom, left]` array form was dropped in renderer 1.8. An
229
- * untyped app upgrading from 1.7 can still pass it, so mirror the WebGL
230
- * renderer and take the widest edge rather than letting the margin arithmetic
231
- * go wrong.
225
+ * Normalize a `boundsMargin` value (scalar or per-side tuple) into a
226
+ * `[top, right, bottom, left]` tuple.
232
227
  */
233
228
  export function normalizeBoundsMargin(
234
229
  margin: number | number[] | null | undefined,
235
- ): number {
236
- if (margin == null) return 0;
237
- if (Array.isArray(margin) === false) return margin as number;
238
- const arr = margin as number[];
239
- let max = 0;
240
- for (let i = 0; i < arr.length; i++) {
241
- if (arr[i]! > max) {
242
- max = arr[i]!;
243
- }
230
+ ): [number, number, number, number] {
231
+ if (margin == null) return [0, 0, 0, 0];
232
+ if (Array.isArray(margin) === false) {
233
+ const m = (margin as number) || 0;
234
+ return [m, m, m, m];
244
235
  }
245
- console.warn(
246
- `boundsMargin array form is no longer supported, using the largest edge value: ${max}`,
247
- );
248
- return max;
236
+ const arr = margin as number[];
237
+ return [arr[0] || 0, arr[1] || 0, arr[2] || 0, arr[3] || 0];
249
238
  }
250
239
 
251
240
  export function computeRenderStateForNode(
@@ -273,10 +262,10 @@ export function computeRenderStateForNode(
273
262
  const right = left + width;
274
263
  const bottom = top + height;
275
264
 
276
- const expandedLeft = rootLeft - margin;
277
- const expandedTop = rootTop - margin;
278
- const expandedRight = rootRight + margin;
279
- const expandedBottom = rootBottom + margin;
265
+ const expandedLeft = rootLeft - margin[3];
266
+ const expandedTop = rootTop - margin[0];
267
+ const expandedRight = rootRight + margin[1];
268
+ const expandedBottom = rootBottom + margin[2];
280
269
 
281
270
  const intersectsBounds =
282
271
  right >= expandedLeft &&
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * Functions:
16
16
  * - `storeFocus(element: ElementNode, prevElement?: ElementNode)`: Stores the provided element in the focus stack.
17
- * - `restoreFocus()`: Restores focus to the last stored element and removes it from the stack. Returns `true` if successful, `false` otherwise.
17
+ * - `restoreFocus()`: Restores focus to the last stored element and removes it from the stack, skipping (and removing) destroyed elements. Returns `true` if successful, `false` otherwise.
18
18
  * - `clearFocusStack()`: Empties the focus stack.
19
19
  */
20
20
  import * as s from 'solid-js';
@@ -41,7 +41,11 @@ export function FocusStackProvider(props: { children: s.JSX.Element}) {
41
41
  function restoreFocus(): boolean {
42
42
  let wasFocused = false;
43
43
  setFocusStack((stack) => {
44
- const prevElement = stack.pop();
44
+ let prevElement = stack.pop();
45
+ // Skip elements destroyed since they were stored
46
+ while (prevElement?.destroyed) {
47
+ prevElement = stack.pop();
48
+ }
45
49
  if (prevElement && typeof prevElement.setFocus === 'function') {
46
50
  prevElement.setFocus();
47
51
  wasFocused = true;