@lightningjs/solid
Advanced tools
Comparing version 0.6.9 to 0.6.10
@@ -1,5 +0,4 @@ | ||
import { createSignal, createEffect } from 'solid-js'; | ||
import { createSignal, createEffect, mergeProps as mergeProps$1, createRoot, createRenderEffect, createMemo, createComponent as createComponent$1, untrack } from 'solid-js'; | ||
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch } from 'solid-js'; | ||
import { MainRenderDriver, ThreadXRenderDriver, RendererMain } from '@lightningjs/renderer'; | ||
import { createRenderer } from 'solid-js/universal'; | ||
import { createElement as createElement$1, spread as spread$1, use as use$1, setProp as setProp$1, insert as insert$1 } from '@lightningjs/solid'; | ||
@@ -190,2 +189,3 @@ | ||
get selected() { | ||
// For selected Elements should always be an ElementNode | ||
return this[this._parent.selected || 0]; | ||
@@ -523,4 +523,10 @@ } | ||
const LightningRendererNonAnimatingProps = ['clipping', 'contain', 'fontFamily', 'src', 'text', 'textAlign', 'texture']; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging | ||
class ElementNode extends Object { | ||
lng = null; | ||
selected = null; | ||
_parent = null; | ||
@@ -657,3 +663,3 @@ // Public but uses _ prefix | ||
if (isArray(value)) { | ||
return this.animate({ | ||
return this.createAnimation({ | ||
[name]: value[0] | ||
@@ -663,3 +669,3 @@ }, value[1]).start(); | ||
if (this._animate) { | ||
return this.animate({ | ||
return this.createAnimation({ | ||
[name]: value | ||
@@ -684,3 +690,3 @@ }).start(); | ||
} | ||
animate(props, animationSettings) { | ||
createAnimation(props, animationSettings) { | ||
assertTruthy(this.lng, 'Node must be rendered before animating'); | ||
@@ -913,2 +919,239 @@ return this.lng.animate(props, animationSettings || this.animationSettings); | ||
function createRenderer$1({ | ||
createElement, | ||
createTextNode, | ||
isTextNode, | ||
replaceText, | ||
insertNode, | ||
removeNode, | ||
setProperty, | ||
getParentNode, | ||
getFirstChild, | ||
getNextSibling | ||
}) { | ||
function insert(parent, accessor, marker, initial) { | ||
if (marker !== undefined && !initial) initial = []; | ||
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker); | ||
createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial); | ||
} | ||
function insertExpression(parent, value, current, marker, unwrapArray) { | ||
while (typeof current === "function") current = current(); | ||
if (value === current) return current; | ||
const t = typeof value, | ||
multi = marker !== undefined; | ||
if (t === "string" || t === "number") { | ||
if (t === "number") value = value.toString(); | ||
if (multi) { | ||
let node = current[0]; | ||
if (node && isTextNode(node)) { | ||
replaceText(node, value); | ||
} else node = createTextNode(value); | ||
current = cleanChildren(parent, current, marker, node); | ||
} else { | ||
if (current !== "" && typeof current === "string") { | ||
replaceText(getFirstChild(parent), current = value); | ||
} else { | ||
cleanChildren(parent, current, marker, createTextNode(value)); | ||
current = value; | ||
} | ||
} | ||
} else if (value == null || t === "boolean") { | ||
current = cleanChildren(parent, current, marker); | ||
} else if (t === "function") { | ||
createRenderEffect(() => { | ||
let v = value(); | ||
while (typeof v === "function") v = v(); | ||
current = insertExpression(parent, v, current, marker); | ||
}); | ||
return () => current; | ||
} else if (Array.isArray(value)) { | ||
const array = []; | ||
if (normalizeIncomingArray(array, value, unwrapArray)) { | ||
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true)); | ||
return () => current; | ||
} | ||
if (array.length === 0) { | ||
const replacement = cleanChildren(parent, current, marker); | ||
if (multi) return current = replacement; | ||
} else { | ||
if (Array.isArray(current)) { | ||
if (current.length === 0) { | ||
appendNodes(parent, array, marker); | ||
} else reconcileArrays(parent, current, array); | ||
} else if (current == null || current === "") { | ||
appendNodes(parent, array); | ||
} else { | ||
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array); | ||
} | ||
} | ||
current = array; | ||
} else { | ||
if (Array.isArray(current)) { | ||
if (multi) return current = cleanChildren(parent, current, marker, value); | ||
cleanChildren(parent, current, null, value); | ||
} else if (current == null || current === "" || !getFirstChild(parent)) { | ||
insertNode(parent, value); | ||
} else replaceNode(parent, value, getFirstChild(parent)); | ||
current = value; | ||
} | ||
return current; | ||
} | ||
function normalizeIncomingArray(normalized, array, unwrap) { | ||
let dynamic = false; | ||
for (let i = 0, len = array.length; i < len; i++) { | ||
let item = array[i], | ||
t; | ||
if (item == null || item === true || item === false) ;else if (Array.isArray(item)) { | ||
dynamic = normalizeIncomingArray(normalized, item) || dynamic; | ||
} else if ((t = typeof item) === "string" || t === "number") { | ||
normalized.push(createTextNode(item)); | ||
} else if (t === "function") { | ||
if (unwrap) { | ||
while (typeof item === "function") item = item(); | ||
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic; | ||
} else { | ||
normalized.push(item); | ||
dynamic = true; | ||
} | ||
} else normalized.push(item); | ||
} | ||
return dynamic; | ||
} | ||
function reconcileArrays(parentNode, a, b) { | ||
let bLength = b.length, | ||
aEnd = a.length, | ||
bEnd = bLength, | ||
aStart = 0, | ||
bStart = 0, | ||
after = getNextSibling(a[aEnd - 1]), | ||
map = null; | ||
while (aStart < aEnd || bStart < bEnd) { | ||
if (a[aStart] === b[bStart]) { | ||
aStart++; | ||
bStart++; | ||
continue; | ||
} | ||
while (a[aEnd - 1] === b[bEnd - 1]) { | ||
aEnd--; | ||
bEnd--; | ||
} | ||
if (aEnd === aStart) { | ||
const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after; | ||
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node); | ||
} else if (bEnd === bStart) { | ||
while (aStart < aEnd) { | ||
if (!map || !map.has(a[aStart])) removeNode(parentNode, a[aStart]); | ||
aStart++; | ||
} | ||
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) { | ||
const node = getNextSibling(a[--aEnd]); | ||
insertNode(parentNode, b[bStart++], getNextSibling(a[aStart++])); | ||
insertNode(parentNode, b[--bEnd], node); | ||
a[aEnd] = b[bEnd]; | ||
} else { | ||
if (!map) { | ||
map = new Map(); | ||
let i = bStart; | ||
while (i < bEnd) map.set(b[i], i++); | ||
} | ||
const index = map.get(a[aStart]); | ||
if (index != null) { | ||
if (bStart < index && index < bEnd) { | ||
let i = aStart, | ||
sequence = 1, | ||
t; | ||
while (++i < aEnd && i < bEnd) { | ||
if ((t = map.get(a[i])) == null || t !== index + sequence) break; | ||
sequence++; | ||
} | ||
if (sequence > index - bStart) { | ||
const node = a[aStart]; | ||
while (bStart < index) insertNode(parentNode, b[bStart++], node); | ||
} else replaceNode(parentNode, b[bStart++], a[aStart++]); | ||
} else aStart++; | ||
} else removeNode(parentNode, a[aStart++]); | ||
} | ||
} | ||
} | ||
function cleanChildren(parent, current, marker, replacement) { | ||
if (marker === undefined) { | ||
let removed; | ||
while (removed = getFirstChild(parent)) removeNode(parent, removed); | ||
replacement && insertNode(parent, replacement); | ||
return ""; | ||
} | ||
const node = replacement || createTextNode(""); | ||
if (current.length) { | ||
let inserted = false; | ||
for (let i = current.length - 1; i >= 0; i--) { | ||
const el = current[i]; | ||
if (node !== el) { | ||
const isParent = getParentNode(el) === parent; | ||
if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);else isParent && removeNode(parent, el); | ||
} else inserted = true; | ||
} | ||
} else insertNode(parent, node, marker); | ||
return [node]; | ||
} | ||
function appendNodes(parent, array, marker) { | ||
for (let i = 0, len = array.length; i < len; i++) insertNode(parent, array[i], marker); | ||
} | ||
function replaceNode(parent, newNode, oldNode) { | ||
insertNode(parent, newNode, oldNode); | ||
removeNode(parent, oldNode); | ||
} | ||
function spreadExpression(node, props, prevProps = {}, skipChildren) { | ||
props || (props = {}); | ||
if (!skipChildren) { | ||
createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children)); | ||
} | ||
createRenderEffect(() => props.ref && props.ref(node)); | ||
createRenderEffect(() => { | ||
for (const prop in props) { | ||
if (prop === "children" || prop === "ref") continue; | ||
const value = props[prop]; | ||
if (value === prevProps[prop]) continue; | ||
setProperty(node, prop, value, prevProps[prop]); | ||
prevProps[prop] = value; | ||
} | ||
}); | ||
return prevProps; | ||
} | ||
return { | ||
render(code, element) { | ||
let disposer; | ||
createRoot(dispose => { | ||
disposer = dispose; | ||
insert(element, code()); | ||
}); | ||
return disposer; | ||
}, | ||
insert, | ||
spread(node, accessor, skipChildren) { | ||
if (typeof accessor === "function") { | ||
createRenderEffect(current => spreadExpression(node, accessor(), current, skipChildren)); | ||
} else spreadExpression(node, accessor, undefined, skipChildren); | ||
}, | ||
createElement, | ||
createTextNode, | ||
insertNode, | ||
setProp(node, name, value, prev) { | ||
setProperty(node, name, value, prev); | ||
return value; | ||
}, | ||
mergeProps: mergeProps$1, | ||
effect: createRenderEffect, | ||
memo: createMemo, | ||
createComponent: createComponent$1, | ||
use(fn, element, arg) { | ||
return untrack(() => fn(element, arg)); | ||
} | ||
}; | ||
} | ||
function createRenderer(options) { | ||
const renderer = createRenderer$1(options); | ||
renderer.mergeProps = mergeProps$1; | ||
return renderer; | ||
} | ||
/* | ||
@@ -940,3 +1183,4 @@ * Copyright 2023 Comcast Cable Communications Management, LLC | ||
name: 'TextNode', | ||
text | ||
text, | ||
parent: null | ||
}; | ||
@@ -984,3 +1228,3 @@ }, | ||
getParentNode(node) { | ||
return node.parent; | ||
return node.parent ?? undefined; | ||
}, | ||
@@ -1175,3 +1419,3 @@ getFirstChild(node) { | ||
export { Canvas, config as Config, Text, View, activeElement, createComponent, createElement, createShader, createTextNode, effect, insert, insertNode, memo, mergeProps, render, renderer, setActiveElement, setProp, spread, startLightningRenderer, use }; | ||
export { Canvas, config as Config, ElementNode, Text, View, activeElement, createComponent, createElement, createShader, createTextNode, effect, insert, insertNode, memo, mergeProps, render, renderer, setActiveElement, setProp, spread, startLightningRenderer, use }; | ||
//# sourceMappingURL=index.js.map |
@@ -27,2 +27,3 @@ /* | ||
get selected() { | ||
// For selected Elements should always be an ElementNode | ||
return this[this._parent.selected || 0]; | ||
@@ -29,0 +30,0 @@ } |
@@ -95,31 +95,12 @@ /* | ||
]; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging | ||
export class ElementNode extends Object { | ||
name; | ||
lng = null; | ||
selected = null; | ||
rendered; | ||
autofocus; | ||
id; | ||
clipping; | ||
zIndex; | ||
selected; | ||
flexDirection; | ||
x; | ||
y; | ||
width; | ||
height; | ||
gap; | ||
justifyContent; | ||
marginLeft; | ||
marginRight; | ||
marginTop; | ||
marginBottom; | ||
text; | ||
display; | ||
forwardStates; | ||
onLoad; | ||
onLayout; | ||
_undoStates; | ||
_renderProps; | ||
_effects; | ||
_parent; | ||
_parent = null; | ||
_shader; | ||
@@ -261,6 +242,6 @@ _style; | ||
if (isArray(value)) { | ||
return this.animate({ [name]: value[0] }, value[1]).start(); | ||
return this.createAnimation({ [name]: value[0] }, value[1]).start(); | ||
} | ||
if (this._animate) { | ||
return this.animate({ [name]: value }).start(); | ||
return this.createAnimation({ [name]: value }).start(); | ||
} | ||
@@ -285,3 +266,3 @@ this.lng[name] = value; | ||
} | ||
animate(props, animationSettings) { | ||
createAnimation(props, animationSettings) { | ||
assertTruthy(this.lng, 'Node must be rendered before animating'); | ||
@@ -288,0 +269,0 @@ return this.lng.animate(props, animationSettings || this.animationSettings); |
@@ -30,3 +30,3 @@ /* | ||
// A text node is just a string - not the <text> node | ||
return { name: 'TextNode', text }; | ||
return { name: 'TextNode', text, parent: null }; | ||
}, | ||
@@ -73,3 +73,3 @@ replaceText(node, value) { | ||
getParentNode(node) { | ||
return node.parent; | ||
return node.parent ?? undefined; | ||
}, | ||
@@ -76,0 +76,0 @@ getFirstChild(node) { |
@@ -17,2 +17,3 @@ /* | ||
*/ | ||
import './jsx-runtime.js'; | ||
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, } from 'solid-js'; | ||
@@ -24,1 +25,3 @@ export * from './core/activeElement.js'; | ||
export { config as Config } from './config.js'; | ||
export * from './core/node/index.js'; | ||
export * from './intrinsicTypes.js'; |
@@ -8,3 +8,3 @@ import type { ElementNode, SolidNode } from './index.js'; | ||
constructor(node: ElementNode); | ||
get selected(): SolidNode; | ||
get selected(): ElementNode | undefined; | ||
get firstChild(): SolidNode; | ||
@@ -11,0 +11,0 @@ insert(node: SolidNode, beforeNode: SolidNode): void; |
import { createShader } from '../renderer/index.js'; | ||
import { type IntrinsicTextProps } from '../../index.js'; | ||
import Children from './children.js'; | ||
@@ -6,5 +7,5 @@ import States from './states.js'; | ||
export interface TextNode { | ||
name: 'TextNode'; | ||
name: string; | ||
text: string; | ||
parent?: ElementNode; | ||
parent: ElementNode | null; | ||
zIndex?: number; | ||
@@ -26,31 +27,13 @@ states?: States; | ||
export type SolidNode = ElementNode | TextNode; | ||
export interface ElementNode extends IntrinsicTextProps { | ||
} | ||
export declare class ElementNode extends Object { | ||
name: string; | ||
lng: INode | null; | ||
selected: number | null; | ||
rendered: boolean; | ||
autofocus?: boolean; | ||
id?: string; | ||
clipping?: boolean; | ||
zIndex?: number; | ||
selected?: number; | ||
flexDirection?: 'row' | 'column'; | ||
x?: number; | ||
y?: number; | ||
width?: number; | ||
height?: number; | ||
gap?: number; | ||
justifyContent?: 'flexStart' | 'flexEnd' | 'center' | 'spaceBetween' | 'spaceEvenly'; | ||
marginLeft?: number; | ||
marginRight?: number; | ||
marginTop?: number; | ||
marginBottom?: number; | ||
text?: string; | ||
display?: 'flex'; | ||
forwardStates?: boolean; | ||
onLoad?: (target: INode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
private _undoStates?; | ||
private _renderProps; | ||
private _effects; | ||
private _parent?; | ||
private _parent; | ||
private _shader?; | ||
@@ -86,3 +69,3 @@ private _style?; | ||
_sendToLightning(name: string, value: unknown): void; | ||
animate(props: Partial<INodeAnimatableProps>, animationSettings?: any): any; | ||
createAnimation(props: Partial<INodeAnimatableProps>, animationSettings?: any): any; | ||
setFocus(): void; | ||
@@ -89,0 +72,0 @@ isTextNode(): boolean; |
@@ -5,3 +5,3 @@ import type { ElementNode, SolidNode, TextNode } from '../node/index.js'; | ||
createElement(name: string): ElementNode; | ||
setProperty(node: ElementNode, name: string, value?: any): void; | ||
setProperty<T>(node: ElementNode, name: string, value?: any): void; | ||
createTextNode(text: string): TextNode; | ||
@@ -8,0 +8,0 @@ replaceText(textNode: TextNode, value: string): void; |
import { ElementNode, type SolidNode, type TextNode } from '../node/index.js'; | ||
import type { createRenderer } from 'solid-js/universal'; | ||
export type SolidRendererOptions = Parameters<typeof createRenderer<SolidNode>>[0]; | ||
declare const _default: { | ||
@@ -6,3 +8,3 @@ createElement(name: string): ElementNode; | ||
replaceText(node: TextNode, value: string): void; | ||
setProperty(node: ElementNode, name: string, value?: any): void; | ||
setProperty<T>(node: ElementNode, name: string, value?: any): void; | ||
insertNode(parent: ElementNode, node: SolidNode, anchor: SolidNode): void; | ||
@@ -9,0 +11,0 @@ isTextNode(node: ElementNode): boolean; |
@@ -0,1 +1,2 @@ | ||
import './jsx-runtime.js'; | ||
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, } from 'solid-js'; | ||
@@ -7,1 +8,3 @@ export * from './core/activeElement.js'; | ||
export { config as Config } from './config.js'; | ||
export * from './core/node/index.js'; | ||
export * from './intrinsicTypes.js'; |
@@ -1,14 +0,27 @@ | ||
import { type INodeWritableProps, type ITextNodeWritableProps } from '@lightningjs/renderer'; | ||
import { type ElementNode, type TextNode } from './core/node/index.js'; | ||
interface IntrinsicCommonProps { | ||
onFocus?: () => void; | ||
onBlur?: () => void; | ||
import { type Dimensions, type INode, type INodeWritableProps, type ITextNodeWritableProps } from '@lightningjs/renderer'; | ||
import { type ElementNode } from './core/node/index.js'; | ||
export interface IntrinsicCommonProps { | ||
ref?: any; | ||
children?: any; | ||
animate?: boolean; | ||
gap?: number; | ||
justifyContent?: 'flexStart' | 'flexEnd' | 'center' | 'spaceBetween' | 'spaceEvenly'; | ||
marginLeft?: number; | ||
marginRight?: number; | ||
marginTop?: number; | ||
marginBottom?: number; | ||
display?: 'flex'; | ||
forwardStates?: boolean; | ||
onLoad?: (target: INode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
autofocus?: boolean; | ||
id?: string; | ||
flexDirection?: 'row' | 'column'; | ||
selected?: number | null; | ||
} | ||
export interface IntrinsicTextProps extends Partial<Omit<ITextNodeWritableProps, 'text' | 'parent'>>, TextNode, IntrinsicCommonProps { | ||
export interface IntrinsicTextProps extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>, IntrinsicCommonProps { | ||
style?: Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>; | ||
} | ||
export interface IntrinsicNodeProps extends Partial<Omit<INodeWritableProps, 'animate' | 'parent' | 'shader'>>, Partial<Omit<ElementNode, 'children' | 'animate'>>, IntrinsicCommonProps { | ||
animate?: boolean; | ||
export interface IntrinsicNodeProps extends Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>, IntrinsicCommonProps { | ||
style?: Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>; | ||
} | ||
export {}; |
{ | ||
"name": "@lightningjs/solid", | ||
"version": "0.6.9", | ||
"version": "0.6.10", | ||
"description": "Lightning renderer for solid universal", | ||
@@ -16,24 +16,5 @@ "type": "module", | ||
"browser": "./dist/esm/index.js" | ||
}, | ||
"./jsx-runtime": { | ||
"types": "./jsx-runtime.d.ts" | ||
} | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"start": "npm run dev", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"lint": "npm run lint:prettier && npm run lint:eslint", | ||
"lint:fix": "npm run lint:fix:prettier && npm run lint:fix:eslint", | ||
"lint:prettier": "prettier --check \"**/*.{ts,js,cjs,md}\"", | ||
"lint:fix:prettier": "prettier --write \"**/*.{ts,js,cjs,md}\"", | ||
"lint:eslint": "eslint .", | ||
"lint:fix:eslint": "eslint --fix .", | ||
"build": "rollup -c", | ||
"watch": "tsc -w", | ||
"dev": "concurrently -c \"auto\" \"npm:watch\" \"npm:vite\"", | ||
"vite": "vite --open \"/test/index.html\" --host", | ||
"prepare": "husky install", | ||
"prepack": "npm run build" | ||
}, | ||
"keywords": [ | ||
@@ -88,3 +69,18 @@ "lightning", | ||
"README.md" | ||
] | ||
} | ||
], | ||
"scripts": { | ||
"start": "npm run dev", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"lint": "npm run lint:prettier && npm run lint:eslint", | ||
"lint:fix": "npm run lint:fix:prettier && npm run lint:fix:eslint", | ||
"lint:prettier": "prettier --check \"**/*.{ts,js,cjs,md}\"", | ||
"lint:fix:prettier": "prettier --write \"**/*.{ts,js,cjs,md}\"", | ||
"lint:eslint": "eslint .", | ||
"lint:fix:eslint": "eslint --fix .", | ||
"build": "rollup -c", | ||
"tsc": "tsc", | ||
"watch": "tsc -w", | ||
"dev": "concurrently -c \"auto\" \"npm:watch\" \"npm:vite\"", | ||
"vite": "vite --open \"/test/index.html\" --host" | ||
} | ||
} |
@@ -31,4 +31,5 @@ /* | ||
get selected() { | ||
return this[this._parent.selected || 0]; | ||
get selected(): ElementNode | undefined { | ||
// For selected Elements should always be an ElementNode | ||
return this[this._parent.selected || 0] as ElementNode | undefined; | ||
} | ||
@@ -35,0 +36,0 @@ |
@@ -19,2 +19,3 @@ /* | ||
import { renderer, createShader } from '../renderer/index.js'; | ||
import { type IntrinsicTextProps } from '../../index.js'; | ||
import Children from './children.js'; | ||
@@ -124,5 +125,5 @@ import States from './states.js'; | ||
export interface TextNode { | ||
name: 'TextNode'; | ||
name: string; | ||
text: string; | ||
parent?: ElementNode; | ||
parent: ElementNode | null; | ||
zIndex?: number; | ||
@@ -146,36 +147,16 @@ states?: States; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging | ||
export interface ElementNode extends IntrinsicTextProps {} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging | ||
export class ElementNode extends Object { | ||
name: string; | ||
lng: INode | null = null; | ||
selected: number | null = null; | ||
rendered: boolean; | ||
autofocus?: boolean; | ||
id?: string; | ||
clipping?: boolean; | ||
zIndex?: number; | ||
selected?: number; | ||
flexDirection?: 'row' | 'column'; | ||
x?: number; | ||
y?: number; | ||
width?: number; | ||
height?: number; | ||
gap?: number; | ||
justifyContent?: | ||
| 'flexStart' | ||
| 'flexEnd' | ||
| 'center' | ||
| 'spaceBetween' | ||
| 'spaceEvenly'; | ||
marginLeft?: number; | ||
marginRight?: number; | ||
marginTop?: number; | ||
marginBottom?: number; | ||
text?: string; | ||
display?: 'flex'; | ||
forwardStates?: boolean; | ||
onLoad?: (target: INode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
private _undoStates?: Record<string, any>; | ||
private _renderProps: any; | ||
private _effects: any; | ||
private _parent?: ElementNode; | ||
private _parent: ElementNode | null = null; | ||
private _shader?: ShaderRef; | ||
@@ -333,7 +314,7 @@ private _style?: any; | ||
if (isArray(value)) { | ||
return this.animate({ [name]: value[0] }, value[1]).start(); | ||
return this.createAnimation({ [name]: value[0] }, value[1]).start(); | ||
} | ||
if (this._animate) { | ||
return this.animate({ [name]: value }).start(); | ||
return this.createAnimation({ [name]: value }).start(); | ||
} | ||
@@ -359,3 +340,6 @@ | ||
animate(props: Partial<INodeAnimatableProps>, animationSettings?: any) { | ||
createAnimation( | ||
props: Partial<INodeAnimatableProps>, | ||
animationSettings?: any, | ||
) { | ||
assertTruthy(this.lng, 'Node must be rendered before animating'); | ||
@@ -362,0 +346,0 @@ return this.lng.animate(props, animationSettings || this.animationSettings); |
@@ -18,3 +18,3 @@ /* | ||
import universalLightning from './lightning.js'; | ||
import universalLightning, { type SolidRendererOptions } from './lightning.js'; | ||
import { renderer } from '../renderer/index.js'; | ||
@@ -145,2 +145,2 @@ import type { ElementNode, SolidNode, TextNode } from '../node/index.js'; | ||
}, | ||
}; | ||
} satisfies SolidRendererOptions; |
@@ -22,3 +22,8 @@ /* | ||
import { ElementNode, type SolidNode, type TextNode } from '../node/index.js'; | ||
import type { createRenderer } from 'solid-js/universal'; | ||
export type SolidRendererOptions = Parameters< | ||
typeof createRenderer<SolidNode> | ||
>[0]; | ||
export default { | ||
@@ -32,3 +37,3 @@ createElement(name: string): ElementNode { | ||
// A text node is just a string - not the <text> node | ||
return { name: 'TextNode', text }; | ||
return { name: 'TextNode', text, parent: null }; | ||
}, | ||
@@ -78,3 +83,3 @@ replaceText(node: TextNode, value: string): void { | ||
getParentNode(node: SolidNode): ElementNode | undefined { | ||
return node.parent; | ||
return node.parent ?? undefined; | ||
}, | ||
@@ -94,2 +99,2 @@ getFirstChild(node: ElementNode): SolidNode | undefined { | ||
}, | ||
}; | ||
} satisfies SolidRendererOptions; |
@@ -17,3 +17,3 @@ /* | ||
*/ | ||
import './jsx-runtime.js'; | ||
export { | ||
@@ -34,1 +34,3 @@ For, | ||
export { config as Config } from './config.js'; | ||
export * from './core/node/index.js'; | ||
export * from './intrinsicTypes.js'; |
import { | ||
type Dimensions, | ||
type INode, | ||
type INodeWritableProps, | ||
@@ -7,19 +9,37 @@ type ITextNodeWritableProps, | ||
interface IntrinsicCommonProps { | ||
onFocus?: () => void; | ||
onBlur?: () => void; | ||
export interface IntrinsicCommonProps { | ||
ref?: any; | ||
children?: any; | ||
animate?: boolean; | ||
gap?: number; | ||
justifyContent?: | ||
| 'flexStart' | ||
| 'flexEnd' | ||
| 'center' | ||
| 'spaceBetween' | ||
| 'spaceEvenly'; | ||
marginLeft?: number; | ||
marginRight?: number; | ||
marginTop?: number; | ||
marginBottom?: number; | ||
display?: 'flex'; | ||
forwardStates?: boolean; | ||
onLoad?: (target: INode, dimensions: Dimensions) => void; | ||
onLayout?: (child: ElementNode, dimensions: Dimensions) => void; | ||
autofocus?: boolean; | ||
id?: string; | ||
flexDirection?: 'row' | 'column'; | ||
selected?: number | null; | ||
} | ||
export interface IntrinsicTextProps | ||
extends Partial<Omit<ITextNodeWritableProps, 'text' | 'parent'>>, | ||
TextNode, | ||
IntrinsicCommonProps {} | ||
extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>, | ||
IntrinsicCommonProps { | ||
style?: Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>; | ||
} | ||
export interface IntrinsicNodeProps | ||
extends Partial<Omit<INodeWritableProps, 'animate' | 'parent' | 'shader'>>, | ||
Partial<Omit<ElementNode, 'children' | 'animate'>>, | ||
extends Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>, | ||
IntrinsicCommonProps { | ||
animate?: boolean; | ||
style?: Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>; | ||
} |
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
268975
62
4228