@solidtv/solid 1.1.3 → 1.2.1
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/README.md +2 -2
- package/dist/src/core/activeElement.d.ts +17 -0
- package/dist/src/core/activeElement.js +18 -0
- package/dist/src/core/activeElement.js.map +1 -0
- package/dist/src/core/config.d.ts +20 -0
- package/dist/src/core/config.js +15 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/dom-renderer/domRenderer.d.ts +2 -2
- package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
- package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
- package/dist/src/core/elementNode.d.ts +10 -4
- package/dist/src/core/elementNode.js +59 -44
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/focusManager.d.ts +2 -9
- package/dist/src/core/focusManager.js +111 -97
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/lightningInit.js +3 -0
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/core/shaders.js +10 -10
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/core/utils.d.ts +0 -1
- package/dist/src/core/utils.js +0 -1
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/primitives/FadeInOut.jsx +1 -2
- package/dist/src/primitives/FadeInOut.jsx.map +1 -1
- package/dist/src/primitives/Rail.d.ts +27 -0
- package/dist/src/primitives/Rail.jsx +322 -0
- package/dist/src/primitives/Rail.jsx.map +1 -0
- package/dist/src/primitives/index.d.ts +1 -0
- package/dist/src/primitives/useFocusManager.d.ts +2 -5
- package/dist/src/primitives/useFocusManager.js +2 -20
- package/dist/src/primitives/useFocusManager.js.map +1 -1
- package/dist/src/primitives/useHold.d.ts +1 -1
- package/dist/src/primitives/useHold.js +1 -1
- package/dist/src/primitives/useMouse.js +4 -4
- package/dist/src/primitives/useMouse.js.map +1 -1
- package/dist/src/render.d.ts +6 -0
- package/dist/src/render.js +7 -3
- package/dist/src/render.js.map +1 -1
- package/dist/src/solidOpts.d.ts +1 -1
- package/dist/src/solidOpts.js +4 -23
- package/dist/src/solidOpts.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/AI_CODING_GUIDELINES.md +7 -7
- package/package.json +2 -2
- package/src/core/activeElement.ts +21 -0
- package/src/core/config.ts +24 -1
- package/src/core/dom-renderer/domRendererUtils.ts +2 -2
- package/src/core/elementNode.ts +65 -40
- package/src/core/focusManager.ts +158 -136
- package/src/core/lightningInit.ts +3 -0
- package/src/core/shaders.ts +10 -10
- package/src/core/utils.ts +0 -3
- package/src/index.ts +2 -1
- package/src/primitives/FadeInOut.tsx +2 -2
- package/src/primitives/Rail.tsx +401 -0
- package/src/primitives/index.ts +1 -0
- package/src/primitives/useFocusManager.ts +8 -44
- package/src/primitives/useHold.ts +1 -1
- package/src/primitives/useMouse.ts +4 -4
- package/src/render.ts +7 -3
- package/src/solidOpts.ts +4 -25
- package/dist/src/activeElement.d.ts +0 -2
- package/dist/src/activeElement.js +0 -3
- package/dist/src/activeElement.js.map +0 -1
- package/src/activeElement.ts +0 -5
package/src/core/focusManager.ts
CHANGED
|
@@ -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';
|
|
@@ -8,6 +9,9 @@ import type {
|
|
|
8
9
|
KeyMap,
|
|
9
10
|
} from './focusKeyTypes.js';
|
|
10
11
|
import { isFunction } from './utils.js';
|
|
12
|
+
import { activeElement, setActiveElementSignal } from './activeElement.js';
|
|
13
|
+
|
|
14
|
+
let _signalWrapper: (cb: () => void) => void = (cb) => cb();
|
|
11
15
|
|
|
12
16
|
type KeyMapEntries = Record<KeyNameOrKeyCode, string>;
|
|
13
17
|
|
|
@@ -197,20 +201,20 @@ export const printFocusHistory = (count: number): void => {
|
|
|
197
201
|
|
|
198
202
|
// ---------------------------------------------------------------------------
|
|
199
203
|
|
|
200
|
-
let activeElement: ElementNode | undefined;
|
|
201
204
|
export const setActiveElement = (elm: ElementNode) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
updateFocusPath(elm,
|
|
205
|
-
activeElement = elm;
|
|
205
|
+
const prev = activeElement();
|
|
206
|
+
if (elm === prev) return;
|
|
207
|
+
updateFocusPath(elm, prev);
|
|
206
208
|
recordFocusHistory(elm, prev);
|
|
207
209
|
// Reset key attribution so programmatic focus changes show '—' for key fields
|
|
208
210
|
_pendingHistoryKey = { keyPressed: undefined, mappedKey: undefined };
|
|
209
|
-
//
|
|
211
|
+
// Publish through the swappable hook rather than writing the signal directly,
|
|
212
|
+
// so the active-element signal stays decoupled from this focus manager.
|
|
210
213
|
Config.setActiveElement(elm);
|
|
211
214
|
};
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
export const [focusPath, setFocusPath] = createSignal<ElementNode[]>([]);
|
|
217
|
+
|
|
214
218
|
const updateFocusPath = (
|
|
215
219
|
currentFocusedElm: ElementNode,
|
|
216
220
|
prevFocusedElm: ElementNode | undefined,
|
|
@@ -243,7 +247,8 @@ const updateFocusPath = (
|
|
|
243
247
|
current = current.parent;
|
|
244
248
|
}
|
|
245
249
|
|
|
246
|
-
focusPath
|
|
250
|
+
const prevFp = focusPath();
|
|
251
|
+
prevFp.forEach((elm) => {
|
|
247
252
|
if (!fpSet.has(elm)) {
|
|
248
253
|
elm.states.remove(Config.focusStateKey);
|
|
249
254
|
elm.onBlur?.call(elm, currentFocusedElm, prevFocusedElm!, elm);
|
|
@@ -258,69 +263,43 @@ const updateFocusPath = (
|
|
|
258
263
|
});
|
|
259
264
|
|
|
260
265
|
if (Config.focusDebug) {
|
|
261
|
-
addFocusDebug(
|
|
266
|
+
addFocusDebug(prevFp, fp);
|
|
262
267
|
}
|
|
263
268
|
|
|
264
|
-
|
|
265
|
-
return fp;
|
|
269
|
+
_signalWrapper(() => setFocusPath(fp));
|
|
266
270
|
};
|
|
267
271
|
|
|
268
272
|
let lastGlobalKeyPressTime = 0;
|
|
269
273
|
let lastInputKey: string | number | undefined;
|
|
270
274
|
|
|
271
|
-
const
|
|
275
|
+
const isElementThrottled = (
|
|
276
|
+
elm: ElementNode,
|
|
277
|
+
sameKey: boolean,
|
|
278
|
+
currentTime: number,
|
|
279
|
+
): boolean =>
|
|
280
|
+
elm.throttleInput !== undefined &&
|
|
281
|
+
sameKey &&
|
|
282
|
+
elm._lastAnyKeyPressTime !== undefined &&
|
|
283
|
+
currentTime - elm._lastAnyKeyPressTime < elm.throttleInput;
|
|
284
|
+
|
|
285
|
+
// Walk focus path root→leaf. Returns true if a capture handler claimed the
|
|
286
|
+
// event (or an element on the path is currently rate-limited).
|
|
287
|
+
const runCapturePhase = (
|
|
288
|
+
fp: ElementNode[],
|
|
272
289
|
e: KeyboardEvent,
|
|
273
|
-
mappedEvent
|
|
274
|
-
|
|
275
|
-
|
|
290
|
+
mappedEvent: string | undefined,
|
|
291
|
+
isUp: boolean,
|
|
292
|
+
sameKey: boolean,
|
|
293
|
+
currentTime: number,
|
|
276
294
|
): boolean => {
|
|
277
|
-
const
|
|
278
|
-
const key = e.key || e.keyCode;
|
|
279
|
-
const sameKey = lastInputKey === key;
|
|
280
|
-
lastInputKey = key;
|
|
281
|
-
|
|
282
|
-
if (!isUp && Config.throttleInput) {
|
|
283
|
-
if (
|
|
284
|
-
sameKey &&
|
|
285
|
-
currentTime - lastGlobalKeyPressTime < Config.throttleInput
|
|
286
|
-
) {
|
|
287
|
-
if (isDev && Config.keyDebug) {
|
|
288
|
-
console.log(
|
|
289
|
-
`Keypress throttled by global Config.throttleInput: ${Config.throttleInput}ms`,
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
lastGlobalKeyPressTime = currentTime;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Record the key for focus-history attribution (keyup presses don't trigger focus changes)
|
|
298
|
-
if (!isUp) {
|
|
299
|
-
_pendingHistoryKey = { keyPressed: key, mappedKey: mappedEvent };
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const numItems = focusPath.length;
|
|
303
|
-
if (numItems === 0) return false;
|
|
304
|
-
|
|
305
|
-
let handlerAvailable: ElementNode | undefined;
|
|
306
|
-
const finalFocusElm = focusPath[0]!;
|
|
295
|
+
const finalFocusElm = fp[0]!;
|
|
307
296
|
const keyBase = mappedEvent || e.key;
|
|
308
297
|
const captureEvent = `onCapture${keyBase}${isUp ? 'Release' : ''}`;
|
|
309
298
|
const captureKey = isUp ? 'onCaptureKeyRelease' : 'onCaptureKey';
|
|
310
299
|
|
|
311
|
-
for (let i =
|
|
312
|
-
const elm =
|
|
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
|
-
}
|
|
300
|
+
for (let i = fp.length - 1; i >= 0; i--) {
|
|
301
|
+
const elm = fp[i]!;
|
|
302
|
+
if (isElementThrottled(elm, sameKey, currentTime)) return true;
|
|
324
303
|
|
|
325
304
|
const captureHandler = elm[captureEvent] || elm[captureKey];
|
|
326
305
|
if (
|
|
@@ -331,73 +310,121 @@ const propagateKeyPress = (
|
|
|
331
310
|
return true;
|
|
332
311
|
}
|
|
333
312
|
}
|
|
313
|
+
return false;
|
|
314
|
+
};
|
|
334
315
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
316
|
+
// Walk focus path leaf→root. Returns whether the event was handled and the
|
|
317
|
+
// last element that had *any* matching handler (for the no-handler debug log).
|
|
318
|
+
const runBubblePhase = (
|
|
319
|
+
fp: ElementNode[],
|
|
320
|
+
e: KeyboardEvent,
|
|
321
|
+
mappedEvent: string | undefined,
|
|
322
|
+
isHold: boolean,
|
|
323
|
+
isUp: boolean,
|
|
324
|
+
sameKey: boolean,
|
|
325
|
+
currentTime: number,
|
|
326
|
+
): { handled: boolean; lastHandlerSeen: ElementNode | undefined } => {
|
|
327
|
+
const finalFocusElm = fp[0]!;
|
|
328
|
+
const eventHandlerKey = mappedEvent
|
|
329
|
+
? isUp
|
|
330
|
+
? `on${mappedEvent}Release`
|
|
331
|
+
: `on${mappedEvent}`
|
|
332
|
+
: undefined;
|
|
333
|
+
const fallbackHandlerKey: 'onKeyHold' | 'onKeyPress' | undefined = isUp
|
|
334
|
+
? undefined
|
|
335
|
+
: isHold
|
|
336
|
+
? 'onKeyHold'
|
|
337
|
+
: 'onKeyPress';
|
|
338
|
+
|
|
339
|
+
let lastHandlerSeen: ElementNode | undefined;
|
|
340
|
+
|
|
341
|
+
for (let i = 0; i < fp.length; i++) {
|
|
342
|
+
const elm = fp[i]!;
|
|
343
|
+
if (isElementThrottled(elm, sameKey, currentTime)) {
|
|
344
|
+
return { handled: true, lastHandlerSeen };
|
|
358
345
|
}
|
|
359
346
|
|
|
360
347
|
let handled = false;
|
|
361
|
-
|
|
362
348
|
if (eventHandlerKey) {
|
|
363
349
|
const eventHandler = elm[eventHandlerKey];
|
|
364
350
|
if (isFunction(eventHandler)) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
handled = true;
|
|
368
|
-
}
|
|
351
|
+
lastHandlerSeen = elm;
|
|
352
|
+
handled = eventHandler.call(elm, e, elm, finalFocusElm) === true;
|
|
369
353
|
}
|
|
370
354
|
}
|
|
371
|
-
|
|
372
|
-
// Check for the fallback handler if its key is defined and not already handled by specific key handler
|
|
373
355
|
if (!handled && fallbackHandlerKey) {
|
|
374
356
|
const fallbackHandler = elm[fallbackHandlerKey];
|
|
375
357
|
if (isFunction(fallbackHandler)) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) ===
|
|
379
|
-
|
|
380
|
-
handled = true;
|
|
381
|
-
}
|
|
358
|
+
lastHandlerSeen = elm;
|
|
359
|
+
handled =
|
|
360
|
+
fallbackHandler.call(elm, e, mappedEvent, elm, finalFocusElm) ===
|
|
361
|
+
true;
|
|
382
362
|
}
|
|
383
363
|
}
|
|
384
364
|
|
|
385
365
|
if (handled) {
|
|
386
366
|
elm._lastAnyKeyPressTime = currentTime;
|
|
387
|
-
return true;
|
|
367
|
+
return { handled: true, lastHandlerSeen };
|
|
388
368
|
}
|
|
389
369
|
}
|
|
370
|
+
return { handled: false, lastHandlerSeen };
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const propagateKeyPress = (
|
|
374
|
+
e: KeyboardEvent,
|
|
375
|
+
mappedEvent?: string,
|
|
376
|
+
isHold: boolean = false,
|
|
377
|
+
isUp: boolean = false,
|
|
378
|
+
): boolean => {
|
|
379
|
+
const currentTime = performance.now();
|
|
380
|
+
const key = e.key || e.keyCode;
|
|
381
|
+
const sameKey = lastInputKey === key;
|
|
382
|
+
lastInputKey = key;
|
|
383
|
+
|
|
384
|
+
if (!isUp && Config.throttleInput) {
|
|
385
|
+
if (
|
|
386
|
+
sameKey &&
|
|
387
|
+
currentTime - lastGlobalKeyPressTime < Config.throttleInput
|
|
388
|
+
) {
|
|
389
|
+
if (isDev && Config.keyDebug) {
|
|
390
|
+
console.log(
|
|
391
|
+
`Keypress throttled by global Config.throttleInput: ${Config.throttleInput}ms`,
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
lastGlobalKeyPressTime = currentTime;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Keyup events don't trigger focus changes, so don't record their key.
|
|
400
|
+
if (!isUp) {
|
|
401
|
+
_pendingHistoryKey = { keyPressed: key, mappedKey: mappedEvent };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const fp = focusPath();
|
|
405
|
+
if (fp.length === 0) return false;
|
|
406
|
+
|
|
407
|
+
if (runCapturePhase(fp, e, mappedEvent, isUp, sameKey, currentTime)) {
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const { handled, lastHandlerSeen } = runBubblePhase(
|
|
412
|
+
fp,
|
|
413
|
+
e,
|
|
414
|
+
mappedEvent,
|
|
415
|
+
isHold,
|
|
416
|
+
isUp,
|
|
417
|
+
sameKey,
|
|
418
|
+
currentTime,
|
|
419
|
+
);
|
|
420
|
+
if (handled) return true;
|
|
390
421
|
|
|
391
422
|
if (isDev && Config.keyDebug && !isUp) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
handlerAvailable,
|
|
396
|
-
);
|
|
423
|
+
const detail = `key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`;
|
|
424
|
+
if (lastHandlerSeen) {
|
|
425
|
+
console.log(`Keypress bubbled, ${detail}`, lastHandlerSeen);
|
|
397
426
|
} else {
|
|
398
|
-
console.log(
|
|
399
|
-
`No event handler available for keypress: key="${e.key}", mappedEvent=${mappedEvent}, isHold=${isHold}, isUp=${isUp}`,
|
|
400
|
-
);
|
|
427
|
+
console.log(`No event handler available for keypress: ${detail}`);
|
|
401
428
|
}
|
|
402
429
|
}
|
|
403
430
|
|
|
@@ -446,52 +473,47 @@ const handleKeyEvents = (
|
|
|
446
473
|
}
|
|
447
474
|
};
|
|
448
475
|
|
|
449
|
-
|
|
450
|
-
userKeyMap?: Partial<KeyMap
|
|
451
|
-
keyHoldOptions?: KeyHoldOptions
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
export const useFocusManager = ({
|
|
456
|
-
userKeyMap,
|
|
457
|
-
keyHoldOptions,
|
|
458
|
-
ownerContext = (cb) => {
|
|
459
|
-
cb();
|
|
460
|
-
},
|
|
461
|
-
}: FocusManagerOptions = {}) => {
|
|
476
|
+
export const useFocusManager = (
|
|
477
|
+
userKeyMap?: Partial<KeyMap>,
|
|
478
|
+
keyHoldOptions?: KeyHoldOptions,
|
|
479
|
+
) => {
|
|
462
480
|
if (userKeyMap) {
|
|
463
481
|
flattenKeyMap(userKeyMap, keyMapEntries);
|
|
464
482
|
}
|
|
465
|
-
|
|
466
483
|
if (keyHoldOptions?.userKeyHoldMap) {
|
|
467
484
|
flattenKeyMap(keyHoldOptions.userKeyHoldMap, keyHoldMapEntries);
|
|
468
485
|
}
|
|
469
486
|
|
|
487
|
+
// Capture the calling owner so signal updates and key-event reactions
|
|
488
|
+
// can run inside it — needed for programmatic .setFocus(), post-mutation
|
|
489
|
+
// focus, and any effect subscribers that rely on onCleanup.
|
|
490
|
+
const owner = getOwner();
|
|
491
|
+
const ownerContext = (cb: () => void) => {
|
|
492
|
+
runWithOwner(owner, cb);
|
|
493
|
+
};
|
|
494
|
+
_signalWrapper = ownerContext;
|
|
495
|
+
// Drive the active-element signal inside this owner so its effect subscribers
|
|
496
|
+
// have a parent for cleanup. Consumers replacing the focus manager can wire
|
|
497
|
+
// Config.setActiveElement themselves instead of calling useFocusManager.
|
|
498
|
+
Config.setActiveElement = (elm) =>
|
|
499
|
+
ownerContext(() => setActiveElementSignal(elm));
|
|
500
|
+
|
|
470
501
|
const delay = keyHoldOptions?.holdThreshold || DEFAULT_KEY_HOLD_THRESHOLD;
|
|
471
502
|
const runKeyEvent = handleKeyEvents.bind(null, delay);
|
|
472
503
|
|
|
473
|
-
// Owner context is for frameworks that need effects
|
|
474
504
|
const keyPressHandler = (event: KeyboardEvent) =>
|
|
475
|
-
ownerContext(() =>
|
|
476
|
-
runKeyEvent(event, undefined);
|
|
477
|
-
});
|
|
478
|
-
|
|
505
|
+
ownerContext(() => runKeyEvent(event, undefined));
|
|
479
506
|
const keyUpHandler = (event: KeyboardEvent) =>
|
|
480
|
-
ownerContext(() =>
|
|
481
|
-
runKeyEvent(undefined, event);
|
|
482
|
-
});
|
|
507
|
+
ownerContext(() => runKeyEvent(undefined, event));
|
|
483
508
|
|
|
484
|
-
document.addEventListener('keyup', keyUpHandler);
|
|
485
509
|
document.addEventListener('keydown', keyPressHandler);
|
|
510
|
+
document.addEventListener('keyup', keyUpHandler);
|
|
486
511
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
},
|
|
495
|
-
focusPath: () => focusPath,
|
|
496
|
-
};
|
|
512
|
+
onCleanup(() => {
|
|
513
|
+
document.removeEventListener('keydown', keyPressHandler);
|
|
514
|
+
document.removeEventListener('keyup', keyUpHandler);
|
|
515
|
+
for (const timeout of Object.values(keyHoldTimeouts)) {
|
|
516
|
+
if (timeout && timeout !== true) clearTimeout(timeout);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
497
519
|
};
|
|
@@ -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) => {
|
package/src/core/shaders.ts
CHANGED
|
@@ -18,7 +18,7 @@ export {
|
|
|
18
18
|
};
|
|
19
19
|
export { WebGlShader };
|
|
20
20
|
|
|
21
|
-
import {
|
|
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 && !(
|
|
125
|
+
if (SHADERS_ENABLED && !isDomRendererActive())
|
|
126
126
|
shManager.registerShaderType('rounded', defaultShaderRounded);
|
|
127
127
|
}
|
|
128
128
|
export function registerDefaultShaderShadow(shManager: CoreShaderManager) {
|
|
129
|
-
if (SHADERS_ENABLED && !(
|
|
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 && !(
|
|
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 && !(
|
|
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 && !(
|
|
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 && !(
|
|
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 && !(
|
|
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 && !(
|
|
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 && !(
|
|
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,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
|
|
5
|
+
export { activeElement, setActiveElementSignal } from './core/activeElement.js';
|
|
6
|
+
export { setActiveElement } from './core/focusManager.js';
|
|
6
7
|
export * from './utils.js';
|
|
7
8
|
export * from './render.js';
|
|
8
9
|
export * from './types.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementNode, NodeProps
|
|
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
|
-
<
|
|
55
|
+
<view {...props} onDestroy={onDestroy} onCreate={onCreate} />
|
|
56
56
|
</Show>
|
|
57
57
|
);
|
|
58
58
|
}
|