@lightningjs/solid
Advanced tools
Comparing version 0.8.6 to 0.8.7
@@ -762,4 +762,5 @@ import { createSignal, createEffect, mergeProps as mergeProps$1, createRoot, createRenderEffect, createMemo, createComponent as createComponent$1, untrack } from 'solid-js'; | ||
node.lng = renderer.createTextNode(props); | ||
isFunc(this.onCreate) && this.onCreate.call(this, node); | ||
if (isFunc(node.onLoad)) { | ||
node.lng.once('loaded', node.onLoad); | ||
node.lng.on('loaded', node.onLoad); | ||
} | ||
@@ -784,3 +785,3 @@ if (!node.width || !node.height) { | ||
if (!props.color) { | ||
//Default color to transparent - If you later set a src, you'll need | ||
// Default color to transparent - If you later set a src, you'll need | ||
// to set color '#ffffffff' | ||
@@ -794,7 +795,8 @@ node._color = props.color = 0x00000000; | ||
if (node.onFail) { | ||
node.lng.once('failed', node.onFail); | ||
node.lng.on('failed', node.onFail); | ||
} | ||
if (node.onLoad) { | ||
node.lng.once('loaded', node.onLoad); | ||
node.lng.on('loaded', node.onLoad); | ||
} | ||
isFunc(this.onCreate) && this.onCreate.call(this, node); | ||
} | ||
@@ -801,0 +803,0 @@ node.rendered = true; |
@@ -405,4 +405,5 @@ /* | ||
node.lng = renderer.createTextNode(props); | ||
isFunc(this.onCreate) && this.onCreate.call(this, node); | ||
if (isFunc(node.onLoad)) { | ||
node.lng.once('loaded', node.onLoad); | ||
node.lng.on('loaded', node.onLoad); | ||
} | ||
@@ -428,3 +429,3 @@ if (!node.width || !node.height) { | ||
if (!props.color) { | ||
//Default color to transparent - If you later set a src, you'll need | ||
// Default color to transparent - If you later set a src, you'll need | ||
// to set color '#ffffffff' | ||
@@ -438,7 +439,8 @@ node._color = props.color = 0x00000000; | ||
if (node.onFail) { | ||
node.lng.once('failed', node.onFail); | ||
node.lng.on('failed', node.onFail); | ||
} | ||
if (node.onLoad) { | ||
node.lng.once('loaded', node.onLoad); | ||
node.lng.on('loaded', node.onLoad); | ||
} | ||
isFunc(this.onCreate) && this.onCreate.call(this, node); | ||
} | ||
@@ -445,0 +447,0 @@ node.rendered = true; |
@@ -5,2 +5,12 @@ import { type AnimationSettings, type Dimensions, type INode, type INodeAnimatableProps, type INodeWritableProps, type ITextNodeWritableProps, type NodeFailedPayload, type NodeLoadedPayload } from '@lightningjs/renderer'; | ||
import type { NodeStates } from './core/node/states.js'; | ||
type AddUndefined<T> = { | ||
[K in keyof T]: T[K] | undefined; | ||
}; | ||
type TransformAnimatableNumberProps<T> = { | ||
[K in keyof T]?: number extends T[K] ? number | AnimatableNumberProp : T[K]; | ||
}; | ||
export type AnimatableNumberProp = [ | ||
value: number, | ||
settings: Partial<AnimationSettings> | ||
]; | ||
export interface BorderStyleObject { | ||
@@ -11,7 +21,20 @@ width: number; | ||
export type BorderStyle = number | BorderStyleObject; | ||
export interface IntrinsicCommonProps { | ||
alignItems?: 'flexStart' | 'flexEnd' | 'center'; | ||
export interface IntrinsicNodeCommonProps { | ||
animate?: boolean; | ||
animationSettings?: Partial<AnimationSettings>; | ||
autofocus?: boolean; | ||
forwardStates?: boolean; | ||
id?: string; | ||
onCreate?: (target: ElementNode) => void; | ||
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
onBeforeLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
ref?: ElementNode | ((node: ElementNode | null) => void) | null; | ||
selected?: number; | ||
states?: NodeStates; | ||
text?: string; | ||
} | ||
export interface IntrinsicNodeStyleCommonProps { | ||
alignItems?: 'flexStart' | 'flexEnd' | 'center'; | ||
border?: BorderStyle; | ||
@@ -24,7 +47,7 @@ borderBottom?: BorderStyle; | ||
display?: 'flex'; | ||
effects?: any; | ||
flexDirection?: 'row' | 'column'; | ||
forwardStates?: boolean; | ||
gap?: number; | ||
id?: string; | ||
justifyContent?: 'flexStart' | 'flexEnd' | 'center' | 'spaceBetween' | 'spaceEvenly'; | ||
linearGradient?: any; | ||
marginBottom?: number; | ||
@@ -34,30 +57,20 @@ marginLeft?: number; | ||
marginTop?: number; | ||
onBeforeLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
ref?: ElementNode | ((node: ElementNode | null) => void) | null | undefined; | ||
selected?: number; | ||
states?: NodeStates; | ||
text?: string; | ||
} | ||
export type AnimatableNumberProp = [ | ||
value: number, | ||
settings: Partial<AnimationSettings> | ||
]; | ||
type TransformAnimatableNumberProps<T> = { | ||
[K in keyof T]?: number extends T[K] ? number | AnimatableNumberProp : T[K]; | ||
}; | ||
export interface IntrinsicTextStyleCommonProps { | ||
marginLeft?: number; | ||
marginRight?: number; | ||
marginTop?: number; | ||
marginBottom?: number; | ||
} | ||
export type IntrinsicCommonProps = IntrinsicNodeCommonProps & IntrinsicNodeStyleCommonProps & IntrinsicTextStyleCommonProps; | ||
export type TransformableNodeWritableProps = TransformAnimatableNumberProps<Omit<INodeAnimatableProps, 'zIndex' | 'zIndexLocked'>>; | ||
type INodeStyleProps = Partial<Omit<INodeWritableProps, 'parent' | 'shader' | keyof TransformableNodeWritableProps>> & TransformableNodeWritableProps & IntrinsicCommonProps; | ||
export interface IntrinsicNodeStyleProps extends INodeStyleProps { | ||
effects?: any; | ||
export interface IntrinsicNodeStyleProps extends Partial<Omit<INodeWritableProps, 'parent' | 'shader' | keyof TransformableNodeWritableProps>>, TransformableNodeWritableProps, IntrinsicNodeStyleCommonProps { | ||
} | ||
export interface IntrinsicTextNodeStyleProps extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>, IntrinsicCommonProps { | ||
export interface IntrinsicTextNodeStyleProps extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>, IntrinsicTextStyleCommonProps { | ||
} | ||
export interface IntrinsicNodeProps extends IntrinsicNodeStyleProps { | ||
export interface IntrinsicNodeProps extends AddUndefined<IntrinsicNodeCommonProps & IntrinsicNodeStyleProps> { | ||
style?: IntrinsicNodeStyleProps; | ||
children?: JSX.Element; | ||
} | ||
export interface IntrinsicTextProps extends IntrinsicTextNodeStyleProps { | ||
export interface IntrinsicTextProps extends AddUndefined<IntrinsicNodeCommonProps & IntrinsicTextNodeStyleProps> { | ||
style?: IntrinsicTextNodeStyleProps; | ||
@@ -64,0 +77,0 @@ children: string | string[]; |
{ | ||
"name": "@lightningjs/solid", | ||
"version": "0.8.6", | ||
"version": "0.8.7", | ||
"description": "Lightning renderer for solid universal", | ||
@@ -44,5 +44,5 @@ "type": "module", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^6.3.0", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"eslint": "^8.46.0", | ||
"@typescript-eslint/eslint-plugin": "^6.12.0", | ||
"@typescript-eslint/parser": "^6.12.0", | ||
"eslint": "^8.54.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
@@ -54,3 +54,3 @@ "husky": "^8.0.3", | ||
"rollup-preset-solid": "^2.0.1", | ||
"solid-js": "^1.8.1", | ||
"solid-js": "^1.8.6", | ||
"typescript": "^5.2.2" | ||
@@ -57,0 +57,0 @@ }, |
@@ -357,2 +357,14 @@ <p> | ||
## Events | ||
`View` and `Text` provide a set of event handlers that can be used in various stages of a node creation process. | ||
```jsx | ||
onCreate: (target: ElementNode) | ||
onLoad: (target: INode, nodeLoadedPayload: NodeLoadedPayload) | ||
onFail: (target: INode, nodeFailedPayload: NodeFailedPayload) | ||
onBeforeLayout: (child: ElementNode, dimensions: Dimensions) | ||
onLayout: (child: ElementNode, dimensions: Dimensions) | ||
``` | ||
## Shaders and Effects | ||
@@ -359,0 +371,0 @@ |
@@ -526,4 +526,6 @@ /* | ||
isFunc(this.onCreate) && this.onCreate.call(this, node); | ||
if (isFunc(node.onLoad)) { | ||
node.lng.once('loaded', node.onLoad); | ||
node.lng.on('loaded', node.onLoad); | ||
} | ||
@@ -551,3 +553,3 @@ | ||
if (!props.color) { | ||
//Default color to transparent - If you later set a src, you'll need | ||
// Default color to transparent - If you later set a src, you'll need | ||
// to set color '#ffffffff' | ||
@@ -563,8 +565,10 @@ node._color = props.color = 0x00000000; | ||
if (node.onFail) { | ||
node.lng.once('failed', node.onFail); | ||
node.lng.on('failed', node.onFail); | ||
} | ||
if (node.onLoad) { | ||
node.lng.once('loaded', node.onLoad); | ||
node.lng.on('loaded', node.onLoad); | ||
} | ||
isFunc(this.onCreate) && this.onCreate.call(this, node); | ||
} | ||
@@ -571,0 +575,0 @@ |
@@ -32,2 +32,16 @@ /* | ||
type AddUndefined<T> = { | ||
[K in keyof T]: T[K] | undefined; | ||
}; | ||
// Type that transforms all number typed properties to a tuple | ||
type TransformAnimatableNumberProps<T> = { | ||
[K in keyof T]?: number extends T[K] ? number | AnimatableNumberProp : T[K]; | ||
}; | ||
export type AnimatableNumberProp = [ | ||
value: number, | ||
settings: Partial<AnimationSettings>, | ||
]; | ||
export interface BorderStyleObject { | ||
@@ -40,7 +54,21 @@ width: number; | ||
export interface IntrinsicCommonProps { | ||
alignItems?: 'flexStart' | 'flexEnd' | 'center'; | ||
export interface IntrinsicNodeCommonProps { | ||
animate?: boolean; | ||
animationSettings?: Partial<AnimationSettings>; | ||
autofocus?: boolean; | ||
forwardStates?: boolean; | ||
id?: string; | ||
onCreate?: (target: ElementNode) => void; | ||
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
onBeforeLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
ref?: ElementNode | ((node: ElementNode | null) => void) | null; | ||
selected?: number; | ||
states?: NodeStates; | ||
text?: string; | ||
} | ||
export interface IntrinsicNodeStyleCommonProps { | ||
alignItems?: 'flexStart' | 'flexEnd' | 'center'; | ||
border?: BorderStyle; | ||
@@ -53,6 +81,5 @@ borderBottom?: BorderStyle; | ||
display?: 'flex'; | ||
effects?: any; // Should be EffectMap | ||
flexDirection?: 'row' | 'column'; | ||
forwardStates?: boolean; | ||
gap?: number; | ||
id?: string; | ||
justifyContent?: | ||
@@ -64,2 +91,3 @@ | 'flexStart' | ||
| 'spaceEvenly'; | ||
linearGradient?: any; // Should be typeof LinearGradientEffect | ||
marginBottom?: number; | ||
@@ -69,24 +97,15 @@ marginLeft?: number; | ||
marginTop?: number; | ||
onBeforeLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void; | ||
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void; | ||
ref?: ElementNode | ((node: ElementNode | null) => void) | null | undefined; | ||
selected?: number; | ||
states?: NodeStates; | ||
text?: string; | ||
} | ||
export type AnimatableNumberProp = [ | ||
value: number, | ||
settings: Partial<AnimationSettings>, | ||
]; | ||
// TODO: Add this concept back in and come up with a way to properly type it so it works | ||
// internally and externally. | ||
// | ||
// Type that transforms all number typed properties to a tuple | ||
type TransformAnimatableNumberProps<T> = { | ||
[K in keyof T]?: number extends T[K] ? number | AnimatableNumberProp : T[K]; | ||
}; | ||
export interface IntrinsicTextStyleCommonProps { | ||
marginLeft?: number; | ||
marginRight?: number; | ||
marginTop?: number; | ||
marginBottom?: number; | ||
} | ||
export type IntrinsicCommonProps = IntrinsicNodeCommonProps & | ||
IntrinsicNodeStyleCommonProps & | ||
IntrinsicTextStyleCommonProps; | ||
export type TransformableNodeWritableProps = TransformAnimatableNumberProps< | ||
@@ -96,20 +115,18 @@ Omit<INodeAnimatableProps, 'zIndex' | 'zIndexLocked'> | ||
type INodeStyleProps = Partial< | ||
Omit< | ||
INodeWritableProps, | ||
'parent' | 'shader' | keyof TransformableNodeWritableProps | ||
> | ||
> & | ||
TransformableNodeWritableProps & | ||
IntrinsicCommonProps; | ||
export interface IntrinsicNodeStyleProps | ||
extends Partial< | ||
Omit< | ||
INodeWritableProps, | ||
'parent' | 'shader' | keyof TransformableNodeWritableProps | ||
> | ||
>, | ||
TransformableNodeWritableProps, | ||
IntrinsicNodeStyleCommonProps {} | ||
export interface IntrinsicNodeStyleProps extends INodeStyleProps { | ||
effects?: any; // Should be EffectMap | ||
} | ||
export interface IntrinsicTextNodeStyleProps | ||
extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>, | ||
IntrinsicCommonProps {} | ||
IntrinsicTextStyleCommonProps {} | ||
export interface IntrinsicNodeProps extends IntrinsicNodeStyleProps { | ||
export interface IntrinsicNodeProps | ||
extends AddUndefined<IntrinsicNodeCommonProps & IntrinsicNodeStyleProps> { | ||
style?: IntrinsicNodeStyleProps; | ||
@@ -119,3 +136,4 @@ children?: JSX.Element; | ||
export interface IntrinsicTextProps extends IntrinsicTextNodeStyleProps { | ||
export interface IntrinsicTextProps | ||
extends AddUndefined<IntrinsicNodeCommonProps & IntrinsicTextNodeStyleProps> { | ||
style?: IntrinsicTextNodeStyleProps; | ||
@@ -122,0 +140,0 @@ children: string | string[]; |
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
288250
4502
430