@lightningtv/core
Advanced tools
Comparing version 2.3.4 to 2.4.0
@@ -140,3 +140,3 @@ import { createShader } from './lightningInit.js'; | ||
_destroy(): void; | ||
set style(values: (Styles | undefined)[] | Styles); | ||
set style(values: Styles); | ||
get style(): Styles; | ||
@@ -143,0 +143,0 @@ get hasChildren(): boolean; |
import { renderer, createShader } from './lightningInit.js'; | ||
import States from './states.js'; | ||
import calculateFlex from './flex.js'; | ||
import { log, isArray, isNumber, isFunc, keyExists, flattenStyles, isINode, isElementNode, isElementText, isTextNode, logRenderTree, } from './utils.js'; | ||
import { log, isArray, isNumber, isFunc, keyExists, isINode, isElementNode, isElementText, isTextNode, logRenderTree, } from './utils.js'; | ||
import { Config, isDev } from './config.js'; | ||
@@ -334,17 +334,3 @@ import { assertTruthy } from '@lightningjs/renderer/utils'; | ||
} | ||
if (isArray(values)) { | ||
const v = values.filter(Boolean); | ||
if (v.length === 0) { | ||
return; | ||
} | ||
else if (v.length === 1) { | ||
this._style = isArray(v[0]) ? flattenStyles(v[0]) : v[0]; | ||
} | ||
else { | ||
this._style = flattenStyles(v); | ||
} | ||
} | ||
else { | ||
this._style = values; | ||
} | ||
this._style = values; | ||
// Keys set in JSX are more important | ||
@@ -351,0 +337,0 @@ for (const key in this._style) { |
@@ -101,2 +101,4 @@ import { isTextNode } from './utils.js'; | ||
if (calculatedSize !== node[dimension]) { | ||
// store the original size for Row & Column | ||
node[`preFlex${dimension}`] = node[dimension]; | ||
node[dimension] = calculatedSize; | ||
@@ -103,0 +105,0 @@ return true; |
import { INode } from '@lightningjs/renderer'; | ||
import type { Styles, ElementText, TextNode } from './intrinsicTypes.js'; | ||
import type { ElementText, TextNode } from './intrinsicTypes.js'; | ||
import { ElementNode } from './elementNode.js'; | ||
@@ -16,4 +16,3 @@ export declare function log(msg: string, node: ElementNode | ElementText | TextNode, ...args: any[]): void; | ||
export declare function keyExists(obj: Record<string, unknown>, keys: (string | number | symbol)[]): boolean; | ||
export declare function flattenStyles(obj: Styles | undefined | (Styles | undefined)[], result?: Styles): Styles; | ||
export declare function logRenderTree(node: ElementNode): string; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -50,19 +50,2 @@ import { Config, isDev } from './config.js'; | ||
} | ||
export function flattenStyles(obj, result = {}) { | ||
if (isArray(obj)) { | ||
obj.forEach((item) => { | ||
flattenStyles(item, result); | ||
}); | ||
} | ||
else if (obj) { | ||
// handle the case where the object is not an array | ||
for (const key in obj) { | ||
// be careful of 0 values | ||
if (result[key] === undefined) { | ||
result[key] = obj[key]; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
export function logRenderTree(node) { | ||
@@ -69,0 +52,0 @@ const tree = [node]; |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.3.4", | ||
"version": "2.4.0", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -25,3 +25,2 @@ import { renderer, createShader } from './lightningInit.js'; | ||
keyExists, | ||
flattenStyles, | ||
isINode, | ||
@@ -569,3 +568,3 @@ isElementNode, | ||
set style(values: (Styles | undefined)[] | Styles) { | ||
set style(values: Styles) { | ||
if (isDev && this._style) { | ||
@@ -578,14 +577,3 @@ // Avoid processing style changes again | ||
if (isArray(values)) { | ||
const v = values.filter(Boolean); | ||
if (v.length === 0) { | ||
return; | ||
} else if (v.length === 1) { | ||
this._style = isArray(v[0]) ? flattenStyles(v[0]) : v[0]; | ||
} else { | ||
this._style = flattenStyles(v); | ||
} | ||
} else { | ||
this._style = values; | ||
} | ||
this._style = values; | ||
// Keys set in JSX are more important | ||
@@ -592,0 +580,0 @@ for (const key in this._style) { |
@@ -120,2 +120,4 @@ import { type ElementNode } from './elementNode.js'; | ||
if (calculatedSize !== node[dimension]) { | ||
// store the original size for Row & Column | ||
node[`preFlex${dimension}`] = node[dimension]; | ||
node[dimension] = calculatedSize; | ||
@@ -122,0 +124,0 @@ return true; |
@@ -80,23 +80,2 @@ import { INode } from '@lightningjs/renderer'; | ||
export function flattenStyles( | ||
obj: Styles | undefined | (Styles | undefined)[], | ||
result: Styles = {}, | ||
): Styles { | ||
if (isArray(obj)) { | ||
obj.forEach((item) => { | ||
flattenStyles(item, result); | ||
}); | ||
} else if (obj) { | ||
// handle the case where the object is not an array | ||
for (const key in obj) { | ||
// be careful of 0 values | ||
if (result[key] === undefined) { | ||
result[key as keyof Styles] = obj[key as keyof Styles]!; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
export function logRenderTree(node: ElementNode) { | ||
@@ -103,0 +82,0 @@ const tree = [node]; |
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
Sorry, the diff of this file is not supported yet
222479
3413