@lightningtv/core
Advanced tools
Comparing version 2.5.8-beta1 to 2.5.8-beta2
import { createShader } from './lightningInit.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 { type BorderRadius, type BorderStyle, type StyleEffects, type AnimationSettings, type ElementText, type Styles, type AnimationEvents, type AnimationEventHandler, AddColorString, TextNode, type OnEvent, NewOmit } from './intrinsicTypes.js'; | ||
import States, { type NodeStates } from './states.js'; | ||
import type { RendererMain, INode, INodeAnimateProps, INodeProps, LinearGradientEffectProps, IAnimationController, RadialGradientEffectProps, RadialProgressEffectProps } from '@lightningjs/renderer'; | ||
import type { RendererMain, INode, INodeAnimateProps, LinearGradientEffectProps, IAnimationController, RadialGradientEffectProps, RadialProgressEffectProps } from '@lightningjs/renderer'; | ||
import './focusManager.js'; | ||
export type RendererNode = AddColorString<Partial<Omit<INodeProps, 'parent' | 'shader' | 'src'>>>; | ||
export type RendererNode = AddColorString<Partial<NewOmit<INode, 'parent' | 'shader' | 'src' | 'children' | 'id'>>>; | ||
export interface ElementNode extends RendererNode { | ||
@@ -50,2 +50,5 @@ [key: string]: unknown; | ||
borderTop?: BorderStyle; | ||
center?: boolean; | ||
centerX?: boolean; | ||
centerY?: boolean; | ||
display?: 'flex' | 'block'; | ||
@@ -52,0 +55,0 @@ flexBoundary?: 'contain' | 'fixed'; |
@@ -434,11 +434,7 @@ import { renderer, createShader } from './lightningInit.js'; | ||
log('Layout: ', this); | ||
let changedLayout = false; | ||
if (this.display === 'flex') { | ||
if (calculateFlex(this) || changedLayout) { | ||
if (calculateFlex(this)) { | ||
this.parent?.updateLayout(); | ||
} | ||
} | ||
else if (changedLayout) { | ||
this.parent?.updateLayout(); | ||
} | ||
isFunc(this.onLayout) && this.onLayout.call(this, this); | ||
@@ -536,2 +532,13 @@ } | ||
} | ||
if (this.center) { | ||
this.centerX = this.centerY = true; | ||
} | ||
if (this.centerX) { | ||
props.x = (parent.width || 0) / 2; | ||
props.mountX = 0.5; | ||
} | ||
if (this.centerY) { | ||
props.y = (parent.height || 0) / 2; | ||
props.mountY = 0.5; | ||
} | ||
props.x = props.x || 0; | ||
@@ -538,0 +545,0 @@ props.y = props.y || 0; |
@@ -32,3 +32,5 @@ import { isTextNode, isElementText } from './utils.js'; | ||
const marginOne = isRow ? 'marginLeft' : 'marginTop'; | ||
const crossMarginOne = isRow ? 'marginTop' : 'marginLeft'; | ||
const marginTwo = isRow ? 'marginRight' : 'marginBottom'; | ||
const crossMarginTwo = isRow ? 'marginBottom' : 'marginRight'; | ||
const prop = isRow ? 'x' : 'y'; | ||
@@ -62,9 +64,14 @@ const crossProp = isRow ? 'y' : 'x'; | ||
if (align === 'flexStart') { | ||
c[crossProp] = 0; | ||
c[crossProp] = c[crossMarginOne] || 0; | ||
} | ||
else if (align === 'center') { | ||
c[crossProp] = (containerCrossSize - (c[crossDimension] || 0)) / 2; | ||
c[crossProp] = | ||
(containerCrossSize - (c[crossDimension] || 0)) / 2 + | ||
(c[crossMarginOne] || 0); | ||
} | ||
else if (align === 'flexEnd') { | ||
c[crossProp] = containerCrossSize - (c[crossDimension] || 0); | ||
c[crossProp] = | ||
containerCrossSize - | ||
(c[crossDimension] || 0) - | ||
(c[crossMarginTwo] || 0); | ||
} | ||
@@ -71,0 +78,0 @@ } |
@@ -50,3 +50,3 @@ 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'; | ||
/** Node text, children of a ElementNode of type TextNode */ | ||
export interface ElementText extends NewOmit<ElementNode, '_type' | 'parent' | 'children' | 'src'>, NewOmit<RendererText, 'x' | 'y' | 'width' | 'height'> { | ||
export interface ElementText extends NewOmit<ElementNode, '_type' | 'parent' | 'children' | 'src' | 'scale'>, NewOmit<RendererText, 'x' | 'y' | 'width' | 'height'> { | ||
_type: 'textNode'; | ||
@@ -71,3 +71,3 @@ parent?: ElementNode; | ||
} | ||
export interface TextProps extends RendererText, Partial<NewOmit<CleanElementNode, 'lng' | 'rendered' | 'renderer' | 'alignItems' | 'autosize' | 'children' | 'data' | 'display' | 'flexBoundary' | 'flexDirection' | 'gap' | 'justifyContent' | 'forwardFocus' | 'forwardStates' | 'linearGradient' | 'src' | 'texture' | 'textureOptions'>> { | ||
export interface TextProps extends RendererText, Partial<NewOmit<CleanElementNode, 'lng' | 'rendered' | 'renderer' | 'alignItems' | 'autosize' | 'children' | 'data' | 'display' | 'flexBoundary' | 'flexDirection' | 'gap' | 'justifyContent' | 'forwardFocus' | 'forwardStates' | 'linearGradient' | 'src' | 'scale' | 'texture' | 'textureOptions'>> { | ||
states?: NodeStates; | ||
@@ -74,0 +74,0 @@ style?: TextStyles; |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.5.8-beta1", | ||
"version": "2.5.8-beta2", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -15,3 +15,3 @@ import { renderer, createShader } from './lightningInit.js'; | ||
type OnEvent, | ||
NodeProps, | ||
NewOmit, | ||
} from './intrinsicTypes.js'; | ||
@@ -195,3 +195,3 @@ import States, { type NodeStates } from './states.js'; | ||
export type RendererNode = AddColorString< | ||
Partial<Omit<INodeProps, 'parent' | 'shader' | 'src'>> | ||
Partial<NewOmit<INode, 'parent' | 'shader' | 'src' | 'children' | 'id'>> | ||
>; | ||
@@ -248,2 +248,5 @@ export interface ElementNode extends RendererNode { | ||
borderTop?: BorderStyle; | ||
center?: boolean; | ||
centerX?: boolean; | ||
centerY?: boolean; | ||
display?: 'flex' | 'block'; | ||
@@ -692,10 +695,7 @@ flexBoundary?: 'contain' | 'fixed'; | ||
log('Layout: ', this); | ||
let changedLayout = false; | ||
if (this.display === 'flex') { | ||
if (calculateFlex(this) || changedLayout) { | ||
if (calculateFlex(this)) { | ||
this.parent?.updateLayout(); | ||
} | ||
} else if (changedLayout) { | ||
this.parent?.updateLayout(); | ||
} | ||
@@ -800,2 +800,3 @@ | ||
const props = node.lng; | ||
if (this.right || this.right === 0) { | ||
@@ -805,2 +806,3 @@ props.x = (parent.width || 0) - this.right; | ||
} | ||
if (this.bottom || this.bottom === 0) { | ||
@@ -811,2 +813,16 @@ props.y = (parent.height || 0) - this.bottom; | ||
if (this.center) { | ||
this.centerX = this.centerY = true; | ||
} | ||
if (this.centerX) { | ||
props.x = (parent.width || 0) / 2; | ||
props.mountX = 0.5; | ||
} | ||
if (this.centerY) { | ||
props.y = (parent.height || 0) / 2; | ||
props.mountY = 0.5; | ||
} | ||
props.x = props.x || 0; | ||
@@ -813,0 +829,0 @@ props.y = props.y || 0; |
import { type ElementNode } from './elementNode.js'; | ||
import { isTextNode, isElementText } from './utils.js'; | ||
import { ElementText } from './intrinsicTypes.js'; | ||
@@ -42,3 +41,5 @@ export default function (node: ElementNode): boolean { | ||
const marginOne = isRow ? 'marginLeft' : 'marginTop'; | ||
const crossMarginOne = isRow ? 'marginTop' : 'marginLeft'; | ||
const marginTwo = isRow ? 'marginRight' : 'marginBottom'; | ||
const crossMarginTwo = isRow ? 'marginBottom' : 'marginRight'; | ||
const prop = isRow ? 'x' : 'y'; | ||
@@ -85,7 +86,12 @@ const crossProp = isRow ? 'y' : 'x'; | ||
if (align === 'flexStart') { | ||
c[crossProp] = 0; | ||
c[crossProp] = c[crossMarginOne] || 0; | ||
} else if (align === 'center') { | ||
c[crossProp] = (containerCrossSize - (c[crossDimension] || 0)) / 2; | ||
c[crossProp] = | ||
(containerCrossSize - (c[crossDimension] || 0)) / 2 + | ||
(c[crossMarginOne] || 0); | ||
} else if (align === 'flexEnd') { | ||
c[crossProp] = containerCrossSize - (c[crossDimension] || 0); | ||
c[crossProp] = | ||
containerCrossSize - | ||
(c[crossDimension] || 0) - | ||
(c[crossMarginTwo] || 0); | ||
} | ||
@@ -92,0 +98,0 @@ } |
@@ -98,3 +98,6 @@ import { | ||
export interface ElementText | ||
extends NewOmit<ElementNode, '_type' | 'parent' | 'children' | 'src'>, | ||
extends NewOmit< | ||
ElementNode, | ||
'_type' | 'parent' | 'children' | 'src' | 'scale' | ||
>, | ||
NewOmit<RendererText, 'x' | 'y' | 'width' | 'height'> { | ||
@@ -157,2 +160,3 @@ _type: 'textNode'; | ||
| 'src' | ||
| 'scale' | ||
| 'texture' | ||
@@ -159,0 +163,0 @@ | 'textureOptions' |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
230251
3570