@solidtv/solid 1.1.3 → 1.3.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.
Files changed (70) hide show
  1. package/README.md +2 -2
  2. package/dist/src/core/config.d.ts +13 -1
  3. package/dist/src/core/config.js +13 -1
  4. package/dist/src/core/config.js.map +1 -1
  5. package/dist/src/core/dom-renderer/domRenderer.js +1 -0
  6. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  7. package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
  8. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
  9. package/dist/src/core/elementNode.d.ts +10 -4
  10. package/dist/src/core/elementNode.js +60 -49
  11. package/dist/src/core/elementNode.js.map +1 -1
  12. package/dist/src/core/flex.js +124 -52
  13. package/dist/src/core/flex.js.map +1 -1
  14. package/dist/src/core/focusKeyTypes.d.ts +14 -0
  15. package/dist/src/core/focusManager.d.ts +19 -9
  16. package/dist/src/core/focusManager.js +125 -101
  17. package/dist/src/core/focusManager.js.map +1 -1
  18. package/dist/src/core/lightningInit.js +3 -0
  19. package/dist/src/core/lightningInit.js.map +1 -1
  20. package/dist/src/core/shaders.js +10 -10
  21. package/dist/src/core/shaders.js.map +1 -1
  22. package/dist/src/core/utils.d.ts +0 -1
  23. package/dist/src/core/utils.js +0 -1
  24. package/dist/src/core/utils.js.map +1 -1
  25. package/dist/src/index.d.ts +1 -1
  26. package/dist/src/index.js +1 -1
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/src/primitives/FadeInOut.jsx +1 -2
  29. package/dist/src/primitives/FadeInOut.jsx.map +1 -1
  30. package/dist/src/primitives/useFocusManager.d.ts +1 -5
  31. package/dist/src/primitives/useFocusManager.js +1 -20
  32. package/dist/src/primitives/useFocusManager.js.map +1 -1
  33. package/dist/src/primitives/useHold.d.ts +1 -1
  34. package/dist/src/primitives/useHold.js +1 -1
  35. package/dist/src/primitives/useMouse.js +4 -4
  36. package/dist/src/primitives/useMouse.js.map +1 -1
  37. package/dist/src/render.d.ts +6 -0
  38. package/dist/src/render.js +7 -3
  39. package/dist/src/render.js.map +1 -1
  40. package/dist/src/solidOpts.d.ts +1 -1
  41. package/dist/src/solidOpts.js +4 -23
  42. package/dist/src/solidOpts.js.map +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/docs/AI_CODING_GUIDELINES.md +7 -7
  45. package/package.json +2 -2
  46. package/src/core/config.ts +15 -2
  47. package/src/core/dom-renderer/domRenderer.ts +1 -0
  48. package/src/core/dom-renderer/domRendererUtils.ts +2 -2
  49. package/src/core/elementNode.ts +66 -46
  50. package/src/core/flex.ts +135 -56
  51. package/src/core/focusKeyTypes.ts +14 -0
  52. package/src/core/focusManager.ts +183 -139
  53. package/src/core/lightningInit.ts +3 -0
  54. package/src/core/shaders.ts +10 -10
  55. package/src/core/utils.ts +0 -3
  56. package/src/index.ts +1 -1
  57. package/src/primitives/FadeInOut.tsx +2 -2
  58. package/src/primitives/useFocusManager.ts +5 -44
  59. package/src/primitives/useHold.ts +1 -1
  60. package/src/primitives/useMouse.ts +4 -4
  61. package/src/render.ts +7 -3
  62. package/src/solidOpts.ts +4 -25
  63. package/dist/src/activeElement.d.ts +0 -2
  64. package/dist/src/activeElement.js +0 -3
  65. package/dist/src/activeElement.js.map +0 -1
  66. package/dist/src/core/flexLayout.d.ts +0 -2
  67. package/dist/src/core/flexLayout.js +0 -356
  68. package/dist/src/core/flexLayout.js.map +0 -1
  69. package/src/activeElement.ts +0 -5
  70. package/src/core/flexLayout.ts +0 -410
@@ -1,3 +1,4 @@
1
+ import { createSignal, getOwner, onCleanup, runWithOwner } from 'solid-js';
1
2
  import { Config, isDev } from './config.js';
2
3
  import { IRendererNode } from './dom-renderer/domRendererTypes.js';
3
4
  export type * from './focusKeyTypes.js';
@@ -9,6 +10,12 @@ import type {
9
10
  } from './focusKeyTypes.js';
10
11
  import { isFunction } from './utils.js';
11
12
 
13
+ export const [activeElement, setActiveElementSignal] = createSignal<
14
+ ElementNode | undefined
15
+ >(undefined);
16
+
17
+ let _signalWrapper: (cb: () => void) => void = (cb) => cb();
18
+
12
19
  type KeyMapEntries = Record<KeyNameOrKeyCode, string>;
13
20
 
14
21
  const keyMapEntries: KeyMapEntries = {
@@ -197,20 +204,18 @@ export const printFocusHistory = (count: number): void => {
197
204
 
198
205
  // ---------------------------------------------------------------------------
199
206
 
200
- let activeElement: ElementNode | undefined;
201
207
  export const setActiveElement = (elm: ElementNode) => {
202
- if (elm === activeElement) return;
203
- const prev = activeElement;
204
- updateFocusPath(elm, activeElement);
205
- activeElement = elm;
208
+ const prev = activeElement();
209
+ if (elm === prev) return;
210
+ updateFocusPath(elm, prev);
206
211
  recordFocusHistory(elm, prev);
207
212
  // Reset key attribution so programmatic focus changes show '—' for key fields
208
213
  _pendingHistoryKey = { keyPressed: undefined, mappedKey: undefined };
209
- // Callback for libraries to use signals / refs
210
- Config.setActiveElement(elm);
214
+ _signalWrapper(() => setActiveElementSignal(elm));
211
215
  };
212
216
 
213
- let focusPath: ElementNode[] = [];
217
+ export const [focusPath, setFocusPath] = createSignal<ElementNode[]>([]);
218
+
214
219
  const updateFocusPath = (
215
220
  currentFocusedElm: ElementNode,
216
221
  prevFocusedElm: ElementNode | undefined,
@@ -243,7 +248,8 @@ const updateFocusPath = (
243
248
  current = current.parent;
244
249
  }
245
250
 
246
- focusPath.forEach((elm) => {
251
+ const prevFp = focusPath();
252
+ prevFp.forEach((elm) => {
247
253
  if (!fpSet.has(elm)) {
248
254
  elm.states.remove(Config.focusStateKey);
249
255
  elm.onBlur?.call(elm, currentFocusedElm, prevFocusedElm!, elm);
@@ -258,16 +264,139 @@ const updateFocusPath = (
258
264
  });
259
265
 
260
266
  if (Config.focusDebug) {
261
- addFocusDebug(focusPath, fp);
267
+ addFocusDebug(prevFp, fp);
262
268
  }
263
269
 
264
- focusPath = fp;
265
- return fp;
270
+ _signalWrapper(() => setFocusPath(fp));
266
271
  };
267
272
 
268
273
  let lastGlobalKeyPressTime = 0;
269
274
  let lastInputKey: string | number | undefined;
270
275
 
276
+ /**
277
+ * Key-handler consume contract (1.3+):
278
+ *
279
+ * A focus-path handler that runs is considered to have consumed the event.
280
+ * Traversal stops at that element. To opt back into bubbling — for handlers
281
+ * that observe but don't act (logging, analytics, instrumentation) — the
282
+ * handler must explicitly `return false`.
283
+ *
284
+ * - `return false` → not consumed; event bubbles to the next ancestor.
285
+ * - any other return → consumed (default).
286
+ * (`undefined`, `true`, void, etc.)
287
+ *
288
+ * @internal exported for tests. Not part of the public API; signature may
289
+ * change in any minor.
290
+ */
291
+ export const _isHandlerConsumed = (result: unknown): boolean =>
292
+ result !== false;
293
+
294
+ const isElementThrottled = (
295
+ elm: ElementNode,
296
+ sameKey: boolean,
297
+ currentTime: number,
298
+ ): boolean =>
299
+ elm.throttleInput !== undefined &&
300
+ sameKey &&
301
+ elm._lastAnyKeyPressTime !== undefined &&
302
+ currentTime - elm._lastAnyKeyPressTime < elm.throttleInput;
303
+
304
+ // Walk focus path root→leaf. Returns true if a capture handler claimed the
305
+ // event (or an element on the path is currently rate-limited).
306
+ const runCapturePhase = (
307
+ fp: ElementNode[],
308
+ e: KeyboardEvent,
309
+ mappedEvent: string | undefined,
310
+ isUp: boolean,
311
+ sameKey: boolean,
312
+ currentTime: number,
313
+ ): boolean => {
314
+ const finalFocusElm = fp[0]!;
315
+ const keyBase = mappedEvent || e.key;
316
+ const captureEvent = `onCapture${keyBase}${isUp ? 'Release' : ''}`;
317
+ const captureKey = isUp ? 'onCaptureKeyRelease' : 'onCaptureKey';
318
+
319
+ for (let i = fp.length - 1; i >= 0; i--) {
320
+ const elm = fp[i]!;
321
+ if (isElementThrottled(elm, sameKey, currentTime)) return true;
322
+
323
+ const captureHandler = elm[captureEvent] || elm[captureKey];
324
+ if (isFunction(captureHandler)) {
325
+ const result = captureHandler.call(
326
+ elm,
327
+ e,
328
+ elm,
329
+ finalFocusElm,
330
+ mappedEvent,
331
+ );
332
+ if (_isHandlerConsumed(result)) {
333
+ elm._lastAnyKeyPressTime = currentTime;
334
+ return true;
335
+ }
336
+ }
337
+ }
338
+ return false;
339
+ };
340
+
341
+ // Walk focus path leaf→root. Returns whether the event was handled and the
342
+ // last element that had *any* matching handler (for the no-handler debug log).
343
+ const runBubblePhase = (
344
+ fp: ElementNode[],
345
+ e: KeyboardEvent,
346
+ mappedEvent: string | undefined,
347
+ isHold: boolean,
348
+ isUp: boolean,
349
+ sameKey: boolean,
350
+ currentTime: number,
351
+ ): { handled: boolean; lastHandlerSeen: ElementNode | undefined } => {
352
+ const finalFocusElm = fp[0]!;
353
+ const eventHandlerKey = mappedEvent
354
+ ? isUp
355
+ ? `on${mappedEvent}Release`
356
+ : `on${mappedEvent}`
357
+ : undefined;
358
+ const fallbackHandlerKey: 'onKeyHold' | 'onKeyPress' | undefined = isUp
359
+ ? undefined
360
+ : isHold
361
+ ? 'onKeyHold'
362
+ : 'onKeyPress';
363
+
364
+ let lastHandlerSeen: ElementNode | undefined;
365
+
366
+ for (let i = 0; i < fp.length; i++) {
367
+ const elm = fp[i]!;
368
+ if (isElementThrottled(elm, sameKey, currentTime)) {
369
+ return { handled: true, lastHandlerSeen };
370
+ }
371
+
372
+ let handled = false;
373
+ if (eventHandlerKey) {
374
+ const eventHandler = elm[eventHandlerKey];
375
+ if (isFunction(eventHandler)) {
376
+ lastHandlerSeen = elm;
377
+ handled = _isHandlerConsumed(
378
+ eventHandler.call(elm, e, elm, finalFocusElm),
379
+ );
380
+ }
381
+ }
382
+ if (!handled && fallbackHandlerKey) {
383
+ const fallbackHandler = elm[fallbackHandlerKey];
384
+ if (isFunction(fallbackHandler)) {
385
+ lastHandlerSeen = elm;
386
+ handled = _isHandlerConsumed(
387
+ fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm),
388
+ );
389
+ }
390
+ }
391
+
392
+ if (handled) {
393
+ elm._lastAnyKeyPressTime = currentTime;
394
+ return { handled: true, lastHandlerSeen };
395
+ }
396
+ }
397
+ return { handled: false, lastHandlerSeen };
398
+ };
399
+
271
400
  const propagateKeyPress = (
272
401
  e: KeyboardEvent,
273
402
  mappedEvent?: string,
@@ -294,110 +423,35 @@ const propagateKeyPress = (
294
423
  lastGlobalKeyPressTime = currentTime;
295
424
  }
296
425
 
297
- // Record the key for focus-history attribution (keyup presses don't trigger focus changes)
426
+ // Keyup events don't trigger focus changes, so don't record their key.
298
427
  if (!isUp) {
299
428
  _pendingHistoryKey = { keyPressed: key, mappedKey: mappedEvent };
300
429
  }
301
430
 
302
- const numItems = focusPath.length;
303
- if (numItems === 0) return false;
431
+ const fp = focusPath();
432
+ if (fp.length === 0) return false;
304
433
 
305
- let handlerAvailable: ElementNode | undefined;
306
- const finalFocusElm = focusPath[0]!;
307
- const keyBase = mappedEvent || e.key;
308
- const captureEvent = `onCapture${keyBase}${isUp ? 'Release' : ''}`;
309
- const captureKey = isUp ? 'onCaptureKeyRelease' : 'onCaptureKey';
310
-
311
- for (let i = numItems - 1; i >= 0; i--) {
312
- const elm = focusPath[i]!;
313
-
314
- // Check throttle for capture phase
315
- if (elm.throttleInput) {
316
- if (
317
- sameKey &&
318
- elm._lastAnyKeyPressTime !== undefined &&
319
- currentTime - elm._lastAnyKeyPressTime < elm.throttleInput
320
- ) {
321
- return true;
322
- }
323
- }
324
-
325
- const captureHandler = elm[captureEvent] || elm[captureKey];
326
- if (
327
- isFunction(captureHandler) &&
328
- captureHandler.call(elm, e, elm, finalFocusElm, mappedEvent) === true
329
- ) {
330
- elm._lastAnyKeyPressTime = currentTime;
331
- return true;
332
- }
333
- }
334
-
335
- let eventHandlerKey: string | undefined;
336
- let fallbackHandlerKey: 'onKeyHold' | 'onKeyPress' | undefined;
337
-
338
- if (mappedEvent) {
339
- eventHandlerKey = isUp ? `on${mappedEvent}Release` : `on${mappedEvent}`;
434
+ if (runCapturePhase(fp, e, mappedEvent, isUp, sameKey, currentTime)) {
435
+ return true;
340
436
  }
341
437
 
342
- if (!isUp) {
343
- fallbackHandlerKey = isHold ? 'onKeyHold' : 'onKeyPress';
344
- }
345
-
346
- for (let i = 0; i < numItems; i++) {
347
- const elm = focusPath[i]!;
348
-
349
- // Check throttle for bubbling phase
350
- if (elm.throttleInput) {
351
- if (
352
- sameKey &&
353
- elm._lastAnyKeyPressTime !== undefined &&
354
- currentTime - elm._lastAnyKeyPressTime < elm.throttleInput
355
- ) {
356
- return true;
357
- }
358
- }
359
-
360
- let handled = false;
361
-
362
- if (eventHandlerKey) {
363
- const eventHandler = elm[eventHandlerKey];
364
- if (isFunction(eventHandler)) {
365
- handlerAvailable = elm;
366
- if (eventHandler.call(elm, e, elm, finalFocusElm) === true) {
367
- handled = true;
368
- }
369
- }
370
- }
371
-
372
- // Check for the fallback handler if its key is defined and not already handled by specific key handler
373
- if (!handled && fallbackHandlerKey) {
374
- const fallbackHandler = elm[fallbackHandlerKey];
375
- if (isFunction(fallbackHandler)) {
376
- handlerAvailable = elm;
377
- if (
378
- fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) === true
379
- ) {
380
- handled = true;
381
- }
382
- }
383
- }
384
-
385
- if (handled) {
386
- elm._lastAnyKeyPressTime = currentTime;
387
- return true;
388
- }
389
- }
438
+ const { handled, lastHandlerSeen } = runBubblePhase(
439
+ fp,
440
+ e,
441
+ mappedEvent,
442
+ isHold,
443
+ isUp,
444
+ sameKey,
445
+ currentTime,
446
+ );
447
+ if (handled) return true;
390
448
 
391
449
  if (isDev && Config.keyDebug && !isUp) {
392
- if (handlerAvailable) {
393
- console.log(
394
- `Keypress bubbled, key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`,
395
- handlerAvailable,
396
- );
450
+ const detail = `key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`;
451
+ if (lastHandlerSeen) {
452
+ console.log(`Keypress bubbled, ${detail}`, lastHandlerSeen);
397
453
  } else {
398
- console.log(
399
- `No event handler available for keypress: key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`,
400
- );
454
+ console.log(`No event handler available for keypress: ${detail}`);
401
455
  }
402
456
  }
403
457
 
@@ -446,52 +500,42 @@ const handleKeyEvents = (
446
500
  }
447
501
  };
448
502
 
449
- interface FocusManagerOptions {
450
- userKeyMap?: Partial<KeyMap>;
451
- keyHoldOptions?: KeyHoldOptions;
452
- ownerContext?: (cb: () => void) => void;
453
- }
454
-
455
- export const useFocusManager = ({
456
- userKeyMap,
457
- keyHoldOptions,
458
- ownerContext = (cb) => {
459
- cb();
460
- },
461
- }: FocusManagerOptions = {}) => {
503
+ export const useFocusManager = (
504
+ userKeyMap?: Partial<KeyMap>,
505
+ keyHoldOptions?: KeyHoldOptions,
506
+ ) => {
462
507
  if (userKeyMap) {
463
508
  flattenKeyMap(userKeyMap, keyMapEntries);
464
509
  }
465
-
466
510
  if (keyHoldOptions?.userKeyHoldMap) {
467
511
  flattenKeyMap(keyHoldOptions.userKeyHoldMap, keyHoldMapEntries);
468
512
  }
469
513
 
514
+ // Capture the calling owner so signal updates and key-event reactions
515
+ // can run inside it — needed for programmatic .setFocus(), post-mutation
516
+ // focus, and any effect subscribers that rely on onCleanup.
517
+ const owner = getOwner();
518
+ const ownerContext = (cb: () => void) => {
519
+ runWithOwner(owner, cb);
520
+ };
521
+ _signalWrapper = ownerContext;
522
+
470
523
  const delay = keyHoldOptions?.holdThreshold || DEFAULT_KEY_HOLD_THRESHOLD;
471
524
  const runKeyEvent = handleKeyEvents.bind(null, delay);
472
525
 
473
- // Owner context is for frameworks that need effects
474
526
  const keyPressHandler = (event: KeyboardEvent) =>
475
- ownerContext(() => {
476
- runKeyEvent(event, undefined);
477
- });
478
-
527
+ ownerContext(() => runKeyEvent(event, undefined));
479
528
  const keyUpHandler = (event: KeyboardEvent) =>
480
- ownerContext(() => {
481
- runKeyEvent(undefined, event);
482
- });
529
+ ownerContext(() => runKeyEvent(undefined, event));
483
530
 
484
- document.addEventListener('keyup', keyUpHandler);
485
531
  document.addEventListener('keydown', keyPressHandler);
532
+ document.addEventListener('keyup', keyUpHandler);
486
533
 
487
- return {
488
- cleanup: () => {
489
- document.removeEventListener('keydown', keyPressHandler);
490
- document.removeEventListener('keyup', keyUpHandler);
491
- for (const [_, timeout] of Object.entries(keyHoldTimeouts)) {
492
- if (timeout && timeout !== true) clearTimeout(timeout);
493
- }
494
- },
495
- focusPath: () => focusPath,
496
- };
534
+ onCleanup(() => {
535
+ document.removeEventListener('keydown', keyPressHandler);
536
+ document.removeEventListener('keyup', keyUpHandler);
537
+ for (const timeout of Object.values(keyHoldTimeouts)) {
538
+ if (timeout && timeout !== true) clearTimeout(timeout);
539
+ }
540
+ });
497
541
  };
@@ -14,6 +14,8 @@ export function startLightningRenderer(
14
14
  options: lng.RendererMainSettings | DomRendererMainSettings,
15
15
  rootId: string | HTMLElement = 'app',
16
16
  ) {
17
+ // Inlined (not isDomRendererActive()) so bundlers can fold DOM_RENDERING to
18
+ // false and drop the DOMRendererMain branch + import in WebGL builds.
17
19
  const enableDomRenderer = DOM_RENDERING && Config.domRendererEnabled;
18
20
 
19
21
  renderer = enableDomRenderer
@@ -23,6 +25,7 @@ export function startLightningRenderer(
23
25
  }
24
26
 
25
27
  export async function loadFonts(fonts: FontLoadOptions[]) {
28
+ // Inlined so the loadFontToDom branch + import tree-shake in WebGL builds.
26
29
  const enableDomRenderer = DOM_RENDERING && Config.domRendererEnabled;
27
30
  await Promise.all(
28
31
  fonts.map((font) => {
@@ -18,7 +18,7 @@ export {
18
18
  };
19
19
  export { WebGlShader };
20
20
 
21
- import { Config, DOM_RENDERING, SHADERS_ENABLED } from './config.js';
21
+ import { SHADERS_ENABLED, isDomRendererActive } from './config.js';
22
22
  import type { CoreShaderManager } from './intrinsicTypes.js';
23
23
  import { IRendererShaderManager } from './dom-renderer/domRendererTypes.js';
24
24
 
@@ -122,17 +122,17 @@ function toValidVec4(value: unknown): Vec4 {
122
122
  export function registerDefaultShaderRounded(
123
123
  shManager: IRendererShaderManager,
124
124
  ) {
125
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
125
+ if (SHADERS_ENABLED && !isDomRendererActive())
126
126
  shManager.registerShaderType('rounded', defaultShaderRounded);
127
127
  }
128
128
  export function registerDefaultShaderShadow(shManager: CoreShaderManager) {
129
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
129
+ if (SHADERS_ENABLED && !isDomRendererActive())
130
130
  shManager.registerShaderType('shadow', defaultShaderShadow);
131
131
  }
132
132
  export function registerDefaultShaderRoundedWithBorder(
133
133
  shManager: CoreShaderManager,
134
134
  ) {
135
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
135
+ if (SHADERS_ENABLED && !isDomRendererActive())
136
136
  shManager.registerShaderType(
137
137
  'roundedWithBorder',
138
138
  defaultShaderRoundedWithBorder,
@@ -141,7 +141,7 @@ export function registerDefaultShaderRoundedWithBorder(
141
141
  export function registerDefaultShaderRoundedWithShadow(
142
142
  shManager: CoreShaderManager,
143
143
  ) {
144
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
144
+ if (SHADERS_ENABLED && !isDomRendererActive())
145
145
  shManager.registerShaderType(
146
146
  'roundedWithShadow',
147
147
  defaultShaderRoundedWithShadow,
@@ -150,31 +150,31 @@ export function registerDefaultShaderRoundedWithShadow(
150
150
  export function registerDefaultShaderRoundedWithBorderAndShadow(
151
151
  shManager: CoreShaderManager,
152
152
  ) {
153
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
153
+ if (SHADERS_ENABLED && !isDomRendererActive())
154
154
  shManager.registerShaderType(
155
155
  'roundedWithBorderWithShadow',
156
156
  defaultShaderRoundedWithBorderAndShadow,
157
157
  );
158
158
  }
159
159
  export function registerDefaultShaderHolePunch(shManager: CoreShaderManager) {
160
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
160
+ if (SHADERS_ENABLED && !isDomRendererActive())
161
161
  shManager.registerShaderType('holePunch', defaultShaderHolePunch);
162
162
  }
163
163
  export function registerDefaultShaderRadialGradient(
164
164
  shManager: CoreShaderManager,
165
165
  ) {
166
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
166
+ if (SHADERS_ENABLED && !isDomRendererActive())
167
167
  shManager.registerShaderType('radialGradient', defaultShaderRadialGradient);
168
168
  }
169
169
  export function registerDefaultShaderLinearGradient(
170
170
  shManager: CoreShaderManager,
171
171
  ) {
172
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled))
172
+ if (SHADERS_ENABLED && !isDomRendererActive())
173
173
  shManager.registerShaderType('linearGradient', defaultShaderLinearGradient);
174
174
  }
175
175
 
176
176
  export function registerDefaultShaders(shManager: CoreShaderManager) {
177
- if (SHADERS_ENABLED && !(DOM_RENDERING && Config.domRendererEnabled)) {
177
+ if (SHADERS_ENABLED && !isDomRendererActive()) {
178
178
  registerDefaultShaderRounded(shManager);
179
179
  registerDefaultShaderShadow(shManager);
180
180
  registerDefaultShaderRoundedWithBorder(shManager);
package/src/core/utils.ts CHANGED
@@ -20,9 +20,6 @@ export function log(
20
20
  }
21
21
  }
22
22
 
23
- export const isFunc = (obj: unknown): obj is CallableFunction =>
24
- obj instanceof Function;
25
-
26
23
  // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
27
24
  export const isFunction = (obj: unknown): obj is Function =>
28
25
  typeof obj === 'function';
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ 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 * from './activeElement.js';
5
+ export { activeElement, setActiveElement } from './core/focusManager.js';
6
6
  export * from './utils.js';
7
7
  export * from './render.js';
8
8
  export * from './types.js';
@@ -1,4 +1,4 @@
1
- import { ElementNode, NodeProps, View } from '@solidtv/solid';
1
+ import { ElementNode, NodeProps } from '@solidtv/solid';
2
2
  import { Show } from 'solid-js';
3
3
 
4
4
  interface Props {
@@ -52,7 +52,7 @@ export function FadeInOut(props: Props & NodeProps) {
52
52
 
53
53
  return (
54
54
  <Show when={props.when} keyed>
55
- <View {...props} onDestroy={onDestroy} onCreate={onCreate} />
55
+ <view {...props} onDestroy={onDestroy} onCreate={onCreate} />
56
56
  </Show>
57
57
  );
58
58
  }
@@ -1,47 +1,8 @@
1
- import {
2
- createEffect,
3
- on,
4
- createSignal,
5
- onCleanup,
6
- getOwner,
7
- runWithOwner,
8
- } from 'solid-js';
9
- import { Config } from '../core/index.js';
10
- import type { ElementNode } from '../core/index.js';
11
- import {
12
- useFocusManager as useFocusManagerCore,
1
+ export {
2
+ focusPath,
3
+ useFocusManager,
4
+ activeElement,
5
+ setActiveElement,
13
6
  type KeyMap,
14
7
  type KeyHoldOptions,
15
8
  } from '../core/focusManager.js';
16
- import { activeElement, setActiveElement } from '../activeElement.js';
17
-
18
- const [focusPath, setFocusPath] = createSignal<ElementNode[]>([]);
19
- export { focusPath };
20
-
21
- export const useFocusManager = (
22
- userKeyMap?: Partial<KeyMap>,
23
- keyHoldOptions?: KeyHoldOptions,
24
- ) => {
25
- const owner = getOwner();
26
- const ownerContext = runWithOwner.bind(this, owner);
27
- Config.setActiveElement = (activeElm) =>
28
- ownerContext(() => setActiveElement(activeElm));
29
-
30
- const { cleanup, focusPath: focusPathCore } = useFocusManagerCore({
31
- userKeyMap,
32
- keyHoldOptions,
33
- ownerContext,
34
- });
35
-
36
- createEffect(
37
- on(
38
- activeElement,
39
- () => {
40
- setFocusPath([...focusPathCore()]);
41
- },
42
- { defer: true },
43
- ),
44
- );
45
-
46
- onCleanup(cleanup);
47
- };
@@ -18,7 +18,7 @@ export type UseHoldProps = {
18
18
  * performOnEnterImmediately: true
19
19
  * });
20
20
  *
21
- * <View
21
+ * <view
22
22
  * onRight={holdRight}
23
23
  * onRightRelease={releaseRight}
24
24
  * />
@@ -4,7 +4,7 @@ import {
4
4
  ElementNode,
5
5
  activeElement,
6
6
  isElementNode,
7
- isFunc,
7
+ isFunction,
8
8
  rootNode,
9
9
  } from '../index.js';
10
10
  import { makeEventListener } from '@solid-primitives/event-listener';
@@ -128,7 +128,7 @@ function findElementByActiveElement(e: MouseEvent): ElementNode | null {
128
128
  let parent = active?.parent;
129
129
  while (parent) {
130
130
  if (
131
- isFunc(parent.onMouseClick) &&
131
+ isFunction(parent.onMouseClick) &&
132
132
  testCollision(
133
133
  px,
134
134
  py,
@@ -167,10 +167,10 @@ function handleElementClick(
167
167
  pressedElementRef.current = null;
168
168
  }
169
169
 
170
- if (isFunc(clickedElement.onMouseClick)) {
170
+ if (isFunction(clickedElement.onMouseClick)) {
171
171
  clickedElement.onMouseClick(e, clickedElement);
172
172
  return;
173
- } else if (isFunc(clickedElement.onEnter)) {
173
+ } else if (isFunction(clickedElement.onEnter)) {
174
174
  clickedElement.onEnter();
175
175
  return;
176
176
  }
package/src/render.ts CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  type Component,
19
19
  } from 'solid-js';
20
20
  import type { SolidNode } from './types.js';
21
- import { activeElement, setActiveElement } from './activeElement.js';
21
+ import { activeElement } from './core/focusManager.js';
22
22
 
23
23
  const solidRenderer = solidCreateRenderer<SolidNode>(nodeOpts);
24
24
 
@@ -37,8 +37,6 @@ export function createRenderer(
37
37
  const options = rendererOptions || Config.rendererOptions;
38
38
 
39
39
  renderer = startLightningRenderer(options!, node || 'app');
40
- //Prevent this from happening automatically
41
- Config.setActiveElement = setActiveElement;
42
40
  rootNode.lng = renderer.root!;
43
41
  rootNode.rendered = true;
44
42
  renderer.on('idle', () => {
@@ -146,12 +144,18 @@ export function Dynamic<T extends Record<string, any>>(
146
144
  }
147
145
 
148
146
  // Dont use JSX as it creates circular dependencies and causes trouble with the playground.
147
+ /**
148
+ * @deprecated Use the lowercase `<view>` intrinsic element instead. The `View` component will be removed in a future release.
149
+ */
149
150
  export const View = (props: NodeProps) => {
150
151
  const el = createElement('node');
151
152
  spread(el, props, false);
152
153
  return el as unknown as JSXElement;
153
154
  };
154
155
 
156
+ /**
157
+ * @deprecated Use the lowercase `<text>` intrinsic element instead. The `Text` component will be removed in a future release.
158
+ */
155
159
  export const Text = (props: TextProps) => {
156
160
  const el = createElement('text');
157
161
  spread(el, props, false);