@lightningtv/core
Advanced tools
Comparing version 2.2.2 to 2.2.3-beta.1
@@ -21,2 +21,3 @@ import { createShader } from './lightningInit.js'; | ||
_parent: ElementNode | undefined; | ||
_rendererProps?: any; | ||
_states?: States; | ||
@@ -72,3 +73,3 @@ _style?: Styles; | ||
onBeforeLayout?: (this: ElementNode, target: ElementNode) => boolean | void; | ||
onCreate?: (target: ElementNode) => void; | ||
onCreate?: (this: ElementNode, target: ElementNode) => void; | ||
onDestroy?: (this: ElementNode, elm: ElementNode) => Promise<any> | void; | ||
@@ -75,0 +76,0 @@ onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; |
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, } from './utils.js'; | ||
import { Config } from './config.js'; | ||
import { log, isArray, isNumber, isFunc, keyExists, flattenStyles, isINode, isElementNode, isElementText, isTextNode, logRenderTree, } from './utils.js'; | ||
import { Config, isDev } from './config.js'; | ||
import { assertTruthy } from '@lightningjs/renderer/utils'; | ||
@@ -334,3 +334,3 @@ import { NodeType } from './nodeTypes.js'; | ||
else { | ||
this._style = flattenStyles(values); | ||
this._style = flattenStyles(v); | ||
} | ||
@@ -568,2 +568,6 @@ } | ||
node.rendered = true; | ||
if (isDev) { | ||
// Store props so we can recreate raw renderer code | ||
node._rendererProps = props; | ||
} | ||
if (node.autosize && parent.requiresLayout()) { | ||
@@ -647,2 +651,7 @@ node._layoutOnLoad(); | ||
} | ||
if (isDev) { | ||
ElementNode.prototype.lngTree = function () { | ||
return logRenderTree(this); | ||
}; | ||
} | ||
Object.defineProperties(ElementNode.prototype, { | ||
@@ -649,0 +658,0 @@ border: borderAccessor(), |
@@ -17,2 +17,3 @@ import { INode } from '@lightningjs/renderer'; | ||
export declare function flattenStyles(obj: Styles | undefined | (Styles | undefined)[], result?: Styles): Styles; | ||
export declare function logRenderTree(node: ElementNode): string; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -67,2 +67,22 @@ import { Config, isDev } from './config.js'; | ||
} | ||
export function logRenderTree(node) { | ||
const tree = [node]; | ||
let parent = node.parent; | ||
while (parent) { | ||
tree.push(parent); | ||
parent = parent.parent; | ||
} | ||
tree.reverse(); | ||
let output = ''; | ||
tree.forEach((node, i) => { | ||
const props = JSON.stringify(node._rendererProps, null, 2); | ||
const parent = i === 0 ? 'rootNode' : `node${i - 1}`; | ||
output += ` | ||
const props${i} = ${props}; | ||
props${i}.parent = ${parent}; | ||
const node${i} = renderer.createNode(props${i}); | ||
`; | ||
}); | ||
return output; | ||
} | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@lightningtv/core", | ||
"version": "2.2.2", | ||
"version": "2.2.3-beta.1", | ||
"description": "Lightning TV Core for Universal Renderers", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -27,4 +27,5 @@ import { renderer, createShader } from './lightningInit.js'; | ||
isTextNode, | ||
logRenderTree, | ||
} from './utils.js'; | ||
import { Config } from './config.js'; | ||
import { Config, isDev } from './config.js'; | ||
import type { | ||
@@ -195,2 +196,3 @@ RendererMain, | ||
_parent: ElementNode | undefined; | ||
_rendererProps?: any; | ||
_states?: States; | ||
@@ -264,3 +266,3 @@ _style?: Styles; | ||
onBeforeLayout?: (this: ElementNode, target: ElementNode) => boolean | void; | ||
onCreate?: (target: ElementNode) => void; | ||
onCreate?: (this: ElementNode, target: ElementNode) => void; | ||
onDestroy?: (this: ElementNode, elm: ElementNode) => Promise<any> | void; | ||
@@ -535,3 +537,3 @@ onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
} else { | ||
this._style = flattenStyles(values); | ||
this._style = flattenStyles(v); | ||
} | ||
@@ -814,2 +816,6 @@ } else { | ||
node.rendered = true; | ||
if (isDev) { | ||
// Store props so we can recreate raw renderer code | ||
node._rendererProps = props; | ||
} | ||
@@ -904,2 +910,8 @@ if (node.autosize && parent.requiresLayout()) { | ||
if (isDev) { | ||
ElementNode.prototype.lngTree = function () { | ||
return logRenderTree(this); | ||
}; | ||
} | ||
Object.defineProperties(ElementNode.prototype, { | ||
@@ -906,0 +918,0 @@ border: borderAccessor(), |
@@ -100,1 +100,24 @@ import { INode } from '@lightningjs/renderer'; | ||
} | ||
export function logRenderTree(node: ElementNode) { | ||
const tree = [node]; | ||
let parent = node.parent; | ||
while (parent) { | ||
tree.push(parent); | ||
parent = parent.parent; | ||
} | ||
tree.reverse(); | ||
let output = ''; | ||
tree.forEach((node, i) => { | ||
const props = JSON.stringify(node._rendererProps, null, 2); | ||
const parent = i === 0 ? 'rootNode' : `node${i - 1}`; | ||
output += ` | ||
const props${i} = ${props}; | ||
props${i}.parent = ${parent}; | ||
const node${i} = renderer.createNode(props${i}); | ||
`; | ||
}); | ||
return output; | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
215009
3251
3