@lightningtv/core
Advanced tools
Comparing version 1.5.0-rc to 1.5.0-rc1
@@ -5,3 +5,3 @@ import { createShader } from './lightningInit.js'; | ||
import States, { type NodeStates } from './states.js'; | ||
import type { RendererMain, INode, INodeAnimateProps, INodeProps, Dimensions, AnimationSettings, IAnimationController } from '@lightningjs/renderer'; | ||
import type { RendererMain, INode, INodeAnimateProps, INodeProps, AnimationSettings, IAnimationController } from '@lightningjs/renderer'; | ||
export type Styles = { | ||
@@ -84,6 +84,7 @@ [key: string]: NodeStyles | TextStyles | undefined; | ||
get autofocus(): any; | ||
requiresLayout(): true | ((this: ElementNode, target: ElementNode, child?: ElementNode, dimensions?: Dimensions) => boolean | void) | undefined; | ||
requiresLayout(): true | ((this: ElementNode, target: ElementNode) => boolean | void) | undefined; | ||
set updateLayoutOn(v: any); | ||
get updateLayoutOn(): any; | ||
updateLayout(child?: ElementNode, dimensions?: Dimensions): void; | ||
queueLayout(): void; | ||
updateLayout(): void; | ||
_stateChanged(): void; | ||
@@ -90,0 +91,0 @@ render(): void; |
@@ -252,6 +252,3 @@ import { renderer, createShader } from './lightningInit.js'; | ||
_layoutOnLoad() { | ||
this.lng.on('loaded', (_node, loadedPayload) => { | ||
const { dimensions } = loadedPayload; | ||
this.parent.updateLayout(this, dimensions); | ||
}); | ||
this.lng.on('loaded', this.parent.queueLayout); | ||
} | ||
@@ -268,3 +265,3 @@ getText() { | ||
this.lng.destroy(); | ||
if (this.parent && this.parent.requiresLayout()) { | ||
if (this.parent?.requiresLayout()) { | ||
this.parent.updateLayout(); | ||
@@ -360,9 +357,25 @@ } | ||
} | ||
updateLayout(child, dimensions) { | ||
if (!layoutQueue.has(this) && this.hasChildren) { | ||
queueLayout() { | ||
if (layoutQueue.has(this)) { | ||
return; | ||
} | ||
layoutQueue.add(this); | ||
if (queueLayout) { | ||
queueLayout = false; | ||
queueMicrotask(() => { | ||
queueLayout = true; | ||
const queue = [...layoutQueue]; | ||
layoutQueue.clear(); | ||
for (let i = queue.length - 1; i >= 0; i--) { | ||
queue[i].updateLayout(); | ||
} | ||
}); | ||
} | ||
} | ||
updateLayout() { | ||
if (this.hasChildren) { | ||
log('Layout: ', this); | ||
let changedLayout = false; | ||
if (isFunc(this.onBeforeLayout)) { | ||
changedLayout = | ||
this.onBeforeLayout.call(this, this, child, dimensions) || false; | ||
changedLayout = this.onBeforeLayout.call(this, this) || false; | ||
} | ||
@@ -377,4 +390,3 @@ if (this.display === 'flex') { | ||
} | ||
isFunc(this.onLayout) && | ||
this.onLayout.call(this, this, child, dimensions); | ||
isFunc(this.onLayout) && this.onLayout.call(this, this); | ||
} | ||
@@ -435,17 +447,4 @@ } | ||
} | ||
if (!layoutQueue.has(parent) && | ||
parent._containsTextNodes && | ||
parent.requiresLayout()) { | ||
layoutQueue.add(parent); | ||
if (queueLayout) { | ||
queueLayout = false; | ||
queueMicrotask(() => { | ||
queueLayout = true; | ||
const queue = [...layoutQueue]; | ||
layoutQueue.clear(); | ||
for (let i = queue.length - 1; i >= 0; i--) { | ||
queue[i].updateLayout(); | ||
} | ||
}); | ||
} | ||
if (parent.requiresLayout()) { | ||
parent.queueLayout(); | ||
} | ||
@@ -452,0 +451,0 @@ if (this.rendered) { |
@@ -1,2 +0,2 @@ | ||
import { type IAnimationController, type AnimationSettings, type Dimensions, type FadeOutEffectProps, type GlitchEffectProps, type GrayscaleEffectProps, type INode, type ITextNodeProps, type LinearGradientEffectProps, type NodeFailedPayload, type NodeLoadedPayload, type RadialGradientEffectProps, type RadialProgressEffectProps, INodeProps } from '@lightningjs/renderer'; | ||
import { type IAnimationController, type AnimationSettings, type FadeOutEffectProps, type GlitchEffectProps, type GrayscaleEffectProps, type INode, type ITextNodeProps, type LinearGradientEffectProps, type NodeFailedPayload, type NodeLoadedPayload, type RadialGradientEffectProps, type RadialProgressEffectProps, INodeProps } from '@lightningjs/renderer'; | ||
import { type ElementNode } from './elementNode.js'; | ||
@@ -66,4 +66,4 @@ import { type NodeStates } from './states.js'; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
onBeforeLayout?: (this: ElementNode, target: ElementNode, child?: ElementNode, dimensions?: Dimensions) => boolean | void; | ||
onLayout?: (this: ElementNode, target: ElementNode, child?: ElementNode, dimensions?: Dimensions) => void; | ||
onBeforeLayout?: (this: ElementNode, target: ElementNode) => boolean | void; | ||
onLayout?: (this: ElementNode, target: ElementNode) => void; | ||
onAnimationStarted?: (controller: IAnimationController, propKey: string, endValue: number) => void; | ||
@@ -70,0 +70,0 @@ onAnimationFinished?: (controller: IAnimationController, propKey: string, endValue: number) => void; |
{ | ||
"name": "@lightningtv/core", | ||
"version": "1.5.0-rc", | ||
"version": "1.5.0-rc1", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -33,5 +33,3 @@ import { renderer, createShader } from './lightningInit.js'; | ||
INodeProps, | ||
Dimensions, | ||
AnimationSettings, | ||
NodeLoadedPayload, | ||
LinearGradientEffectProps, | ||
@@ -400,9 +398,3 @@ ITextNodeProps, | ||
_layoutOnLoad() { | ||
(this.lng as INode).on( | ||
'loaded', | ||
(_node: INode, loadedPayload: NodeLoadedPayload) => { | ||
const { dimensions } = loadedPayload; | ||
this.parent!.updateLayout(this, dimensions); | ||
}, | ||
); | ||
(this.lng as INode).on('loaded', this.parent!.queueLayout); | ||
} | ||
@@ -421,3 +413,3 @@ | ||
this.lng.destroy(); | ||
if (this.parent && this.parent.requiresLayout()) { | ||
if (this.parent?.requiresLayout()) { | ||
this.parent.updateLayout(); | ||
@@ -535,9 +527,27 @@ } | ||
updateLayout(child?: ElementNode, dimensions?: Dimensions) { | ||
if (!layoutQueue.has(this) && this.hasChildren) { | ||
queueLayout() { | ||
if (layoutQueue.has(this)) { | ||
return; | ||
} | ||
layoutQueue.add(this); | ||
if (queueLayout) { | ||
queueLayout = false; | ||
queueMicrotask(() => { | ||
queueLayout = true; | ||
const queue = [...layoutQueue]; | ||
layoutQueue.clear(); | ||
for (let i = queue.length - 1; i >= 0; i--) { | ||
queue[i]!.updateLayout(); | ||
} | ||
}); | ||
} | ||
} | ||
updateLayout() { | ||
if (this.hasChildren) { | ||
log('Layout: ', this); | ||
let changedLayout = false; | ||
if (isFunc(this.onBeforeLayout)) { | ||
changedLayout = | ||
this.onBeforeLayout.call(this, this, child, dimensions) || false; | ||
changedLayout = this.onBeforeLayout.call(this, this) || false; | ||
} | ||
@@ -553,4 +563,3 @@ | ||
isFunc(this.onLayout) && | ||
this.onLayout.call(this, this, child, dimensions); | ||
isFunc(this.onLayout) && this.onLayout.call(this, this); | ||
} | ||
@@ -625,19 +634,4 @@ } | ||
if ( | ||
!layoutQueue.has(parent) && | ||
parent._containsTextNodes && | ||
parent.requiresLayout() | ||
) { | ||
layoutQueue.add(parent); | ||
if (queueLayout) { | ||
queueLayout = false; | ||
queueMicrotask(() => { | ||
queueLayout = true; | ||
const queue = [...layoutQueue]; | ||
layoutQueue.clear(); | ||
for (let i = queue.length - 1; i >= 0; i--) { | ||
queue[i]!.updateLayout(); | ||
} | ||
}); | ||
} | ||
if (parent.requiresLayout()) { | ||
parent.queueLayout(); | ||
} | ||
@@ -644,0 +638,0 @@ |
@@ -121,14 +121,4 @@ import { | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
onBeforeLayout?: ( | ||
this: ElementNode, | ||
target: ElementNode, | ||
child?: ElementNode, | ||
dimensions?: Dimensions, | ||
) => boolean | void; | ||
onLayout?: ( | ||
this: ElementNode, | ||
target: ElementNode, | ||
child?: ElementNode, | ||
dimensions?: Dimensions, | ||
) => void; | ||
onBeforeLayout?: (this: ElementNode, target: ElementNode) => boolean | void; | ||
onLayout?: (this: ElementNode, target: ElementNode) => void; | ||
onAnimationStarted?: ( | ||
@@ -135,0 +125,0 @@ controller: IAnimationController, |
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
218513
3207