@solidtv/solid 1.2.1 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidtv/solid",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "SolidTV",
5
5
  "type": "module",
6
6
  "exports": {
@@ -5,17 +5,20 @@ import type { ElementNode } from './elementNode.js';
5
5
  * Generic active-element signal — intentionally decoupled from the focus
6
6
  * manager so consumers can drive focus from their own focus-management logic.
7
7
  *
8
- * `setActiveElementSignal` is the *raw* signal setter: it only updates the
9
- * reactive value. It does NOT move focus state, fire `onFocus`/`onBlur`, or
10
- * touch the focus path — that is the focus manager's job.
8
+ * `setActiveElement` is the *raw* signal setter: it only updates the reactive
9
+ * value. It does NOT move focus state, fire `onFocus`/`onBlur`, or touch the
10
+ * focus path — that is the focus manager's job (`setActiveElementCore` in
11
+ * {@link ./focusManager.ts}).
11
12
  *
12
- * The built-in focus manager applies focus via `setActiveElement`
13
- * (see {@link ./focusManager.ts}) and publishes the result through
14
- * `Config.setActiveElement`, which defaults to this setter. A library shipping
15
- * its own focus manager can read {@link activeElement}, reassign
16
- * `Config.setActiveElement` (e.g. to inject a Solid owner context), or call
17
- * `setActiveElementSignal` directly — without depending on `focusManager.ts`.
13
+ * The built-in focus manager applies focus via `setActiveElementCore` and
14
+ * publishes the result through `Config.setActiveElement`, which defaults to
15
+ * this setter. A library shipping its own focus manager can read
16
+ * {@link activeElement}, reassign `Config.setActiveElement` (e.g. to inject a
17
+ * Solid owner context), or call `setActiveElement` directly — without depending
18
+ * on `focusManager.ts`. Because it is a terminal signal write (it never calls
19
+ * back into the focus manager), wiring it into `Config.setActiveElement` cannot
20
+ * recurse.
18
21
  */
19
- export const [activeElement, setActiveElementSignal] = createSignal<
22
+ export const [activeElement, setActiveElement] = createSignal<
20
23
  ElementNode | undefined
21
24
  >(undefined);
@@ -9,7 +9,7 @@ import {
9
9
  type ElementNode,
10
10
  convertToShader as defaultConvertToShader,
11
11
  } from './elementNode.js';
12
- import { setActiveElementSignal } from './activeElement.js';
12
+ import { setActiveElement as setActiveElementSignal } from './activeElement.js';
13
13
  import {
14
14
  DomRendererMainSettings,
15
15
  IRendererShader,
@@ -55,7 +55,7 @@ import { assertTruthy } from '@solidtv/renderer/utils';
55
55
  import { NodeType, TextNode } from './nodeTypes.js';
56
56
  import {
57
57
  ForwardFocusHandler,
58
- setActiveElement,
58
+ setActiveElementCore,
59
59
  FocusNode,
60
60
  } from './focusManager.js';
61
61
  import { initClickInspector } from './clickInspector.js';
@@ -130,7 +130,7 @@ function runPostMutation() {
130
130
 
131
131
  // Phase 3: focus. setFocus() may have evaluated forwardFocus pre-render
132
132
  // (when no children existed yet); deferredFocusElement re-runs setFocus
133
- // here once the subtree has rendered, then setActiveElement is applied.
133
+ // here once the subtree has rendered, then setActiveElementCore is applied.
134
134
  if (deferredFocusElement !== null) {
135
135
  const el = deferredFocusElement;
136
136
  deferredFocusElement = null;
@@ -138,7 +138,7 @@ function runPostMutation() {
138
138
  } else if (nextActiveElement !== null) {
139
139
  const element = nextActiveElement;
140
140
  nextActiveElement = null;
141
- setActiveElement(element);
141
+ setActiveElementCore(element);
142
142
  }
143
143
  }
144
144
 
@@ -9,7 +9,10 @@ import type {
9
9
  KeyMap,
10
10
  } from './focusKeyTypes.js';
11
11
  import { isFunction } from './utils.js';
12
- import { activeElement, setActiveElementSignal } from './activeElement.js';
12
+ import {
13
+ activeElement,
14
+ setActiveElement as setActiveElementSignal,
15
+ } from './activeElement.js';
13
16
 
14
17
  let _signalWrapper: (cb: () => void) => void = (cb) => cb();
15
18
 
@@ -201,7 +204,18 @@ export const printFocusHistory = (count: number): void => {
201
204
 
202
205
  // ---------------------------------------------------------------------------
203
206
 
204
- export const setActiveElement = (elm: ElementNode) => {
207
+ /**
208
+ * Built-in "apply focus" routine: diffs the focus path, fires
209
+ * `onFocus`/`onBlur`/`onFocusChanged`, records history, then publishes the
210
+ * active element through the `Config.setActiveElement` hook.
211
+ *
212
+ * This is what `ElementNode.setFocus()` ultimately invokes. It is intentionally
213
+ * *not* the public `setActiveElement` export — that name is the raw signal
214
+ * setter (see {@link ./activeElement.ts}). Keeping them separate is what stops
215
+ * a custom `Config.setActiveElement` (wired to a setter) from recursing back
216
+ * through the focus-path logic.
217
+ */
218
+ export const setActiveElementCore = (elm: ElementNode) => {
205
219
  const prev = activeElement();
206
220
  if (elm === prev) return;
207
221
  updateFocusPath(elm, prev);
package/src/index.ts CHANGED
@@ -2,8 +2,8 @@ export type * from '@solidtv/solid/jsx-runtime';
2
2
  export * from './core/index.js';
3
3
  export type * from './core/index.js';
4
4
  export type { KeyHandler, KeyMap } from './core/focusManager.js';
5
- export { activeElement, setActiveElementSignal } from './core/activeElement.js';
6
- export { setActiveElement } from './core/focusManager.js';
5
+ export { activeElement, setActiveElement } from './core/activeElement.js';
6
+ export { setActiveElementCore } from './core/focusManager.js';
7
7
  export * from './utils.js';
8
8
  export * from './render.js';
9
9
  export * from './types.js';
@@ -1,11 +1,8 @@
1
1
  export {
2
2
  focusPath,
3
3
  useFocusManager,
4
- setActiveElement,
4
+ setActiveElementCore,
5
5
  type KeyMap,
6
6
  type KeyHoldOptions,
7
7
  } from '../core/focusManager.js';
8
- export {
9
- activeElement,
10
- setActiveElementSignal,
11
- } from '../core/activeElement.js';
8
+ export { activeElement, setActiveElement } from '../core/activeElement.js';