@lightningtv/core
Advanced tools
Comparing version 2.5.5 to 2.5.6
import { createShader } from './lightningInit.js'; | ||
import { type BorderRadius, type BorderStyle, type StyleEffects, type AnimationSettings, type ElementText, type Styles, type AnimationEvents, type AnimationEventHandler, AddColorString, TextNode, NodeEvents, EventHandler } from './intrinsicTypes.js'; | ||
import { type BorderRadius, type BorderStyle, type StyleEffects, type AnimationSettings, type ElementText, type Styles, type AnimationEvents, type AnimationEventHandler, AddColorString, TextNode, type OnEvent } from './intrinsicTypes.js'; | ||
import States, { type NodeStates } from './states.js'; | ||
import type { RendererMain, INode, INodeAnimateProps, INodeProps, LinearGradientEffectProps, IAnimationController, RadialGradientEffectProps, RadialProgressEffectProps, NodeFailedPayload, NodeLoadedPayload } from '@lightningjs/renderer'; | ||
import type { RendererMain, INode, INodeAnimateProps, INodeProps, LinearGradientEffectProps, IAnimationController, RadialGradientEffectProps, RadialProgressEffectProps } from '@lightningjs/renderer'; | ||
import './focusManager.js'; | ||
@@ -80,6 +80,2 @@ export type RendererNode = AddColorString<Partial<Omit<INodeProps, 'parent' | 'shader' | 'src'>>>; | ||
* | ||
* @typedef {'animating' | 'tick' | 'stopped'} AnimationEvents | ||
* | ||
* @typedef {function(controller: IAnimationController, name: string, endValue: number, props?: any): void} AnimationEventHandler | ||
* | ||
* @type {Partial<Record<AnimationEvents, AnimationEventHandler>>} | ||
@@ -116,6 +112,4 @@ * | ||
*/ | ||
onEvent?: Partial<Record<NodeEvents, EventHandler>>; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
onEvent?: OnEvent; | ||
onLayout?: (this: ElementNode, target: ElementNode) => void; | ||
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void; | ||
} | ||
@@ -156,2 +150,10 @@ export declare class ElementNode extends Object { | ||
get hidden(): boolean; | ||
/** | ||
* Sets the autofocus state of the element. | ||
* When set to a truthy value, the element will automatically gain focus. | ||
* You can also set it to a signal to recalculate | ||
* | ||
* @param val - A value to determine if the element should autofocus. | ||
* A truthy value enables autofocus, otherwise disables it. | ||
*/ | ||
set autofocus(val: any); | ||
@@ -158,0 +160,0 @@ get autofocus(): any; |
@@ -407,2 +407,10 @@ import { renderer, createShader } from './lightningInit.js'; | ||
} | ||
/** | ||
* Sets the autofocus state of the element. | ||
* When set to a truthy value, the element will automatically gain focus. | ||
* You can also set it to a signal to recalculate | ||
* | ||
* @param val - A value to determine if the element should autofocus. | ||
* A truthy value enables autofocus, otherwise disables it. | ||
*/ | ||
set autofocus(val) { | ||
@@ -449,3 +457,3 @@ this._autofocus = val ? true : false; | ||
const states = this.states; | ||
if (this._undoStyles || (this.style && keyExists(this.style, states))) { | ||
if (this._undoStyles || keyExists(this, states)) { | ||
let stylesToUndo; | ||
@@ -471,3 +479,3 @@ if (this._undoStyles && this._undoStyles.length) { | ||
if (numStates === 1) { | ||
newStyles = this.style[states[0]]; | ||
newStyles = this[states[0]]; | ||
newStyles = stylesToUndo | ||
@@ -479,3 +487,3 @@ ? { ...stylesToUndo, ...newStyles } | ||
newStyles = states.reduce((acc, state) => { | ||
const styles = this.style[state]; | ||
const styles = this[state]; | ||
return styles ? { ...acc, ...styles } : acc; | ||
@@ -482,0 +490,0 @@ }, stylesToUndo || {}); |
@@ -1,2 +0,2 @@ | ||
import { type FadeOutEffectProps, type GlitchEffectProps, type GrayscaleEffectProps, type AnimationSettings as RendererAnimationSettings, type LinearGradientEffectProps, type RadialGradientEffectProps, type RadialProgressEffectProps, type ITextNodeProps, type HolePunchEffectProps, type IAnimationController } from '@lightningjs/renderer'; | ||
import { type FadeOutEffectProps, type GlitchEffectProps, type GrayscaleEffectProps, type AnimationSettings as RendererAnimationSettings, type LinearGradientEffectProps, type RadialGradientEffectProps, type RadialProgressEffectProps, type ITextNodeProps, type HolePunchEffectProps, type IAnimationController, NodeLoadedPayload, NodeFailedPayload } from '@lightningjs/renderer'; | ||
import { ElementNode, type RendererNode } from './elementNode.js'; | ||
@@ -47,3 +47,3 @@ import { NodeStates } from './states.js'; | ||
type RendererText = AddColorString<Partial<Omit<ITextNodeProps, 'debug' | 'shader' | 'parent'>>>; | ||
type CleanElementNode = NewOmit<RemoveUnderscoreProps<ElementNode>, 'parent' | 'insertChild' | 'removeChild' | 'selectedNode' | 'shader' | 'animate' | 'chain' | 'start' | 'setFocus' | 'isTextNode' | 'getText' | 'destroy' | 'hasChildren' | 'getChildById' | 'searchChildrenById' | 'states' | 'requiresLayout' | 'updateLayout' | 'render' | 'style'>; | ||
type CleanElementNode = NewOmit<RemoveUnderscoreProps<ElementNode>, 'parent' | 'insertChild' | 'removeChild' | 'selectedNode' | 'shader' | 'animate' | 'chain' | 'start' | 'isTextNode' | 'getText' | 'destroy' | 'hasChildren' | 'getChildById' | 'searchChildrenById' | 'states' | 'requiresLayout' | 'updateLayout' | 'render' | 'style'>; | ||
/** Node text, children of a ElementNode of type TextNode */ | ||
@@ -86,5 +86,17 @@ export interface ElementText extends NewOmit<ElementNode, '_type' | 'parent' | 'children' | 'src'>, NewOmit<RendererText, 'x' | 'y' | 'width' | 'height'> { | ||
export type AnimationEventHandler = (controller: IAnimationController, name: string, endValue: number, props?: any) => void; | ||
export type NodeEvents = 'loaded' | 'failed' | 'freed' | 'inBounds' | 'outOfBounds' | 'inViewport' | 'outOfViewport'; | ||
export type EventHandler = (target: ElementNode, event?: Event) => void; | ||
type EventPayloadMap = { | ||
loaded: NodeLoadedPayload; | ||
failed: NodeFailedPayload; | ||
freed: Event; | ||
inBounds: Event; | ||
outOfBounds: Event; | ||
inViewport: Event; | ||
outOfViewport: Event; | ||
}; | ||
type NodeEvents = keyof EventPayloadMap; | ||
type EventHandler<E extends NodeEvents> = (target: ElementNode, event?: EventPayloadMap[E]) => void; | ||
export type OnEvent = Partial<{ | ||
[K in NodeEvents]: EventHandler<K>; | ||
}>; | ||
export {}; | ||
//# sourceMappingURL=intrinsicTypes.d.ts.map |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.5.5", | ||
"version": "2.5.6", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -45,3 +45,3 @@ "type": "module", | ||
"peerDependencies": { | ||
"@lightningjs/renderer": "^2.4.0" | ||
"@lightningjs/renderer": "^2.0.0" | ||
}, | ||
@@ -48,0 +48,0 @@ "devDependencies": { |
@@ -14,4 +14,4 @@ import { renderer, createShader } from './lightningInit.js'; | ||
TextNode, | ||
NodeEvents, | ||
EventHandler, | ||
type OnEvent, | ||
NodeProps, | ||
} from './intrinsicTypes.js'; | ||
@@ -26,3 +26,2 @@ import States, { type NodeStates } from './states.js'; | ||
keyExists, | ||
flattenStyles, | ||
isINode, | ||
@@ -47,4 +46,2 @@ isElementNode, | ||
RadialProgressEffectProps, | ||
NodeFailedPayload, | ||
NodeLoadedPayload, | ||
} from '@lightningjs/renderer'; | ||
@@ -285,6 +282,2 @@ import { assertTruthy } from '@lightningjs/renderer/utils'; | ||
* | ||
* @typedef {'animating' | 'tick' | 'stopped'} AnimationEvents | ||
* | ||
* @typedef {function(controller: IAnimationController, name: string, endValue: number, props?: any): void} AnimationEventHandler | ||
* | ||
* @type {Partial<Record<AnimationEvents, AnimationEventHandler>>} | ||
@@ -321,6 +314,4 @@ * | ||
*/ | ||
onEvent?: Partial<Record<NodeEvents, EventHandler>>; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
onEvent?: OnEvent; | ||
onLayout?: (this: ElementNode, target: ElementNode) => void; | ||
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void; | ||
} | ||
@@ -670,2 +661,10 @@ | ||
/** | ||
* Sets the autofocus state of the element. | ||
* When set to a truthy value, the element will automatically gain focus. | ||
* You can also set it to a signal to recalculate | ||
* | ||
* @param val - A value to determine if the element should autofocus. | ||
* A truthy value enables autofocus, otherwise disables it. | ||
*/ | ||
set autofocus(val: any) { | ||
@@ -722,3 +721,3 @@ this._autofocus = val ? true : false; | ||
if (this._undoStyles || (this.style && keyExists(this.style, states))) { | ||
if (this._undoStyles || keyExists(this, states)) { | ||
let stylesToUndo: { [key: string]: any } | undefined; | ||
@@ -746,3 +745,3 @@ if (this._undoStyles && this._undoStyles.length) { | ||
if (numStates === 1) { | ||
newStyles = this.style![states[0] as keyof Styles] as Styles; | ||
newStyles = this[states[0] as keyof Styles] as Styles; | ||
newStyles = stylesToUndo | ||
@@ -753,3 +752,3 @@ ? { ...stylesToUndo, ...newStyles } | ||
newStyles = states.reduce((acc, state) => { | ||
const styles = this.style![state]; | ||
const styles = this[state]; | ||
return styles ? { ...acc, ...styles } : acc; | ||
@@ -756,0 +755,0 @@ }, stylesToUndo || {}); |
@@ -12,2 +12,4 @@ import { | ||
type IAnimationController, | ||
NodeLoadedPayload, | ||
NodeFailedPayload, | ||
} from '@lightningjs/renderer'; | ||
@@ -82,3 +84,2 @@ import { ElementNode, type RendererNode } from './elementNode.js'; | ||
| 'start' | ||
| 'setFocus' | ||
| 'isTextNode' | ||
@@ -182,10 +183,22 @@ | 'getText' | ||
) => void; | ||
export type NodeEvents = | ||
| 'loaded' | ||
| 'failed' | ||
| 'freed' | ||
| 'inBounds' | ||
| 'outOfBounds' | ||
| 'inViewport' | ||
| 'outOfViewport'; | ||
export type EventHandler = (target: ElementNode, event?: Event) => void; | ||
type EventPayloadMap = { | ||
loaded: NodeLoadedPayload; | ||
failed: NodeFailedPayload; | ||
freed: Event; | ||
inBounds: Event; | ||
outOfBounds: Event; | ||
inViewport: Event; | ||
outOfViewport: Event; | ||
}; | ||
type NodeEvents = keyof EventPayloadMap; | ||
type EventHandler<E extends NodeEvents> = ( | ||
target: ElementNode, | ||
event?: EventPayloadMap[E], | ||
) => void; | ||
export type OnEvent = Partial<{ | ||
[K in NodeEvents]: EventHandler<K>; | ||
}>; |
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
Sorry, the diff of this file is not supported yet
227614
3512