New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lightningtv/core

Package Overview
Dependencies
Maintainers
3
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lightningtv/core - npm Package Compare versions

Comparing version 2.6.2 to 2.7.0-0

dist/src/groups.d.ts

3

dist/src/focusManager.d.ts

@@ -14,6 +14,5 @@ export type * from './focusKeyTypes.js';

keyHoldOptions?: KeyHoldOptions;
propagatedUpKeys?: string[];
ownerContext?: (cb: () => void) => void;
}
export declare const useFocusManager: ({ userKeyMap, propagatedUpKeys, keyHoldOptions, ownerContext, }?: FocusManagerOptions) => {
export declare const useFocusManager: ({ userKeyMap, keyHoldOptions, ownerContext, }?: FocusManagerOptions) => {
cleanup: () => void;

@@ -20,0 +19,0 @@ focusPath: () => ElementNode[];

@@ -106,18 +106,8 @@ import { Config } from './config.js';

};
const propagateKeyPress = (e, mappedEvent, isHold, propagatedUpKeys = []) => {
const propagateKeyPress = (e, mappedEvent, isHold = false, isUp = false) => {
let finalFocusElm = undefined;
const isUp = e.type === 'keyup';
const propagateKeyUp = Boolean(mappedEvent && propagatedUpKeys.includes(mappedEvent));
if (mappedEvent) {
for (const elm of focusPath) {
finalFocusElm = finalFocusElm || elm;
const keyEvent = elm[`on${mappedEvent}`];
const keyUpEvent = elm[`on${mappedEvent}Up`];
const keyDownEvent = elm[`on${mappedEvent}Down`];
const skipDown = !isUp && propagateKeyUp && !keyDownEvent;
const skipUp = isUp && !isHold && !propagateKeyUp && !keyUpEvent;
if (skipDown || skipUp) {
continue;
}
const onKeyHandler = (isUp ? keyUpEvent : keyDownEvent) || keyEvent;
const onKeyHandler = (isUp ? elm[`on${mappedEvent}Release`] : elm[`on${mappedEvent}`]);
if (isFunction(onKeyHandler) &&

@@ -127,5 +117,2 @@ onKeyHandler.call(elm, e, elm, finalFocusElm) === true) {

}
if (isUp && !isHold) {
continue;
}
const fallbackFunction = isHold ? elm.onKeyHold : elm.onKeyPress;

@@ -143,3 +130,3 @@ if (isFunction(fallbackFunction) &&

};
const DEFAULT_KEY_HOLD_THRESHOLD = 200; // ms
const DEFAULT_KEY_HOLD_THRESHOLD = 500; // ms
const keyHoldTimeouts = {};

@@ -149,3 +136,3 @@ const keyHoldCallback = (e, mappedKeyHoldEvent) => {

};
const handleKeyEvents = (delay, propagatedUpKeys, keydown, keyup) => {
const handleKeyEvents = (delay, keydown, keyup) => {
if (keydown) {

@@ -157,6 +144,10 @@ const key = keydown.key || keydown.keyCode;

if (!keyHoldTimeouts[key]) {
keyHoldTimeouts[key] = window.setTimeout(() => keyHoldCallback(keydown, mappedKeyHoldEvent), delay);
keyHoldTimeouts[key] = window.setTimeout(() => {
keyHoldCallback(keydown, mappedKeyHoldEvent);
keyHoldTimeouts[key] = true;
}, delay);
}
return;
}
propagateKeyPress(keydown, mappedKeyEvent, false, propagatedUpKeys);
propagateKeyPress(keydown, mappedKeyEvent, false);
}

@@ -166,10 +157,12 @@ else if (keyup) {

const mappedKeyEvent = keyMapEntries[keyup.key] || keyMapEntries[keyup.keyCode];
if (keyHoldTimeouts[key]) {
if (keyHoldTimeouts[key] && keyHoldTimeouts[key] !== true) {
clearTimeout(keyHoldTimeouts[key]);
delete keyHoldTimeouts[key];
// trigger key down event when hold didn't finish
propagateKeyPress(keyup, mappedKeyEvent, false);
}
propagateKeyPress(keyup, mappedKeyEvent, false, propagatedUpKeys);
delete keyHoldTimeouts[key];
propagateKeyPress(keyup, mappedKeyEvent, false, true);
}
};
export const useFocusManager = ({ userKeyMap, propagatedUpKeys = [], keyHoldOptions, ownerContext = (cb) => {
export const useFocusManager = ({ userKeyMap, keyHoldOptions, ownerContext = (cb) => {
cb();

@@ -184,3 +177,3 @@ }, } = {}) => {

const delay = keyHoldOptions?.holdThreshold || DEFAULT_KEY_HOLD_THRESHOLD;
const runKeyEvent = handleKeyEvents.bind(null, delay, propagatedUpKeys);
const runKeyEvent = handleKeyEvents.bind(null, delay);
// Owner context is for frameworks that need effects

@@ -200,3 +193,3 @@ const keyPressHandler = (event) => ownerContext(() => {

for (const [_, timeout] of Object.entries(keyHoldTimeouts)) {
if (timeout)
if (timeout && timeout !== true)
clearTimeout(timeout);

@@ -203,0 +196,0 @@ }

{
"name": "@lightningtv/core",
"version": "2.6.2",
"version": "2.7.0-0",
"description": "Lightning TV Core for Universal Renderers",

@@ -5,0 +5,0 @@ "type": "module",

@@ -145,10 +145,6 @@ import { Config } from './config.js';

mappedEvent: string | undefined,
isHold: boolean,
propagatedUpKeys: string[] = [],
isHold: boolean = false,
isUp: boolean = false,
) => {
let finalFocusElm: ElementNode | undefined = undefined;
const isUp = e.type === 'keyup';
const propagateKeyUp = Boolean(
mappedEvent && propagatedUpKeys.includes(mappedEvent),
);

@@ -158,15 +154,6 @@ if (mappedEvent) {

finalFocusElm = finalFocusElm || elm;
const keyEvent = elm[`on${mappedEvent}`] as unknown;
const keyUpEvent = elm[`on${mappedEvent}Up`] as unknown;
const keyDownEvent = elm[`on${mappedEvent}Down`] as unknown;
const onKeyHandler = (
isUp ? elm[`on${mappedEvent}Release`] : elm[`on${mappedEvent}`]
) as unknown;
const skipDown = !isUp && propagateKeyUp && !keyDownEvent;
const skipUp = isUp && !isHold && !propagateKeyUp && !keyUpEvent;
if (skipDown || skipUp) {
continue;
}
const onKeyHandler = (isUp ? keyUpEvent : keyDownEvent) || keyEvent;
if (

@@ -179,6 +166,2 @@ isFunction(onKeyHandler) &&

if (isUp && !isHold) {
continue;
}
const fallbackFunction = isHold ? elm.onKeyHold : elm.onKeyPress;

@@ -199,4 +182,4 @@ if (

const DEFAULT_KEY_HOLD_THRESHOLD = 200; // ms
const keyHoldTimeouts: { [key: KeyNameOrKeyCode]: number } = {};
const DEFAULT_KEY_HOLD_THRESHOLD = 500; // ms
const keyHoldTimeouts: { [key: KeyNameOrKeyCode]: number | true } = {};

@@ -212,3 +195,2 @@ const keyHoldCallback = (

delay: number,
propagatedUpKeys: string[],
keydown?: KeyboardEvent,

@@ -225,10 +207,11 @@ keyup?: KeyboardEvent,

if (!keyHoldTimeouts[key]) {
keyHoldTimeouts[key] = window.setTimeout(
() => keyHoldCallback(keydown, mappedKeyHoldEvent),
delay,
);
keyHoldTimeouts[key] = window.setTimeout(() => {
keyHoldCallback(keydown, mappedKeyHoldEvent);
keyHoldTimeouts[key] = true;
}, delay);
}
return;
}
propagateKeyPress(keydown, mappedKeyEvent, false, propagatedUpKeys);
propagateKeyPress(keydown, mappedKeyEvent, false);
} else if (keyup) {

@@ -238,8 +221,9 @@ const key: KeyNameOrKeyCode = keyup.key || keyup.keyCode;

keyMapEntries[keyup.key] || keyMapEntries[keyup.keyCode];
if (keyHoldTimeouts[key]) {
if (keyHoldTimeouts[key] && keyHoldTimeouts[key] !== true) {
clearTimeout(keyHoldTimeouts[key]);
delete keyHoldTimeouts[key];
// trigger key down event when hold didn't finish
propagateKeyPress(keyup, mappedKeyEvent, false);
}
propagateKeyPress(keyup, mappedKeyEvent, false, propagatedUpKeys);
delete keyHoldTimeouts[key];
propagateKeyPress(keyup, mappedKeyEvent, false, true);
}

@@ -251,3 +235,2 @@ };

keyHoldOptions?: KeyHoldOptions;
propagatedUpKeys?: string[];
ownerContext?: (cb: () => void) => void;

@@ -258,3 +241,2 @@ }

userKeyMap,
propagatedUpKeys = [],
keyHoldOptions,

@@ -274,3 +256,3 @@ ownerContext = (cb) => {

const delay = keyHoldOptions?.holdThreshold || DEFAULT_KEY_HOLD_THRESHOLD;
const runKeyEvent = handleKeyEvents.bind(null, delay, propagatedUpKeys);
const runKeyEvent = handleKeyEvents.bind(null, delay);

@@ -296,3 +278,3 @@ // Owner context is for frameworks that need effects

for (const [_, timeout] of Object.entries(keyHoldTimeouts)) {
if (timeout) clearTimeout(timeout);
if (timeout && timeout !== true) clearTimeout(timeout);
}

@@ -299,0 +281,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc