@lightningtv/solid
Advanced tools
Comparing version 1.0.0-rc0 to 1.0.0-rc1
import { type IntrinsicNodeProps, type IntrinsicTextProps } from '@lightningtv/core'; | ||
import { type JSXElement, type ValidComponent } from 'solid-js'; | ||
import type { RendererMain } from '@lightningjs/renderer'; | ||
import { SolidNode } from './types.js'; | ||
export declare const rootNode: import("@lightningtv/core").ElementNode; | ||
export declare const render: (code: () => JSXElement, node?: HTMLElement | string) => Promise<() => void>; | ||
export declare function createRenderer(rendererOptions?: Partial<import("@lightningjs/renderer").RendererMainSettings> | undefined, node?: HTMLElement | string): { | ||
renderer: RendererMain; | ||
rootNode: import("@lightningtv/core").ElementNode; | ||
render: (code: () => JSXElement, node?: HTMLElement | string) => () => void; | ||
}; | ||
export declare const effect: <T>(fn: (prev?: T) => T, init?: T) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, createComponent: <T>(Comp: (props: T) => SolidNode, props: T) => SolidNode, createElement: (tag: string) => SolidNode, createTextNode: (value: string) => SolidNode, insertNode: (parent: SolidNode, node: SolidNode, anchor?: SolidNode | undefined) => void, insert: <T>(parent: any, accessor: T | (() => T), marker?: any | null) => SolidNode, spread: <T>(node: any, accessor: (() => T) | T, skipChildren?: Boolean) => void, setProp: <T>(node: SolidNode, name: string, value: T, prev?: T | undefined) => T, mergeProps: (...sources: unknown[]) => unknown, use: <A, T>(fn: (element: SolidNode, arg: A) => T, element: SolidNode, arg: A) => T; | ||
@@ -7,0 +12,0 @@ /** |
@@ -1,15 +0,22 @@ | ||
import { createRenderer } from 'solid-js/universal'; | ||
import { createRenderer as solidCreateRenderer } from 'solid-js/universal'; | ||
import { Config, startLightningRenderer, } from '@lightningtv/core'; | ||
import nodeOpts from './solidOpts.js'; | ||
import { splitProps, createMemo, untrack, } from 'solid-js'; | ||
const solidRenderer = createRenderer(nodeOpts); | ||
const solidRenderer = solidCreateRenderer(nodeOpts); | ||
let renderer; | ||
export const rootNode = nodeOpts.createElement('App'); | ||
export const render = async function (code, node) { | ||
renderer = startLightningRenderer(Config.rendererOptions, node || 'app'); | ||
rootNode.lng = renderer.root; | ||
rootNode.rendered = true; | ||
const render = function (code, node) { | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
return solidRenderer.render(code, rootNode); | ||
}; | ||
export function createRenderer(rendererOptions = Config.rendererOptions, node) { | ||
renderer = startLightningRenderer(rendererOptions, node || 'app'); | ||
rootNode.lng = renderer.root; | ||
rootNode.rendered = true; | ||
return { | ||
renderer, | ||
rootNode, | ||
render, | ||
}; | ||
} | ||
export const { effect, memo, createComponent, createElement, createTextNode, insertNode, insert, spread, setProp, mergeProps, use, } = solidRenderer; | ||
@@ -16,0 +23,0 @@ /** |
{ | ||
"name": "@lightningtv/solid", | ||
"version": "1.0.0-rc0", | ||
"version": "1.0.0-rc1", | ||
"description": "Lightning Renderer for Solid Universal", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,2 +0,2 @@ | ||
import { createRenderer } from 'solid-js/universal'; | ||
import { createRenderer as solidCreateRenderer } from 'solid-js/universal'; | ||
import { | ||
@@ -19,3 +19,3 @@ Config, | ||
const solidRenderer = createRenderer<SolidNode>(nodeOpts); | ||
const solidRenderer = solidCreateRenderer<SolidNode>(nodeOpts); | ||
@@ -25,12 +25,20 @@ let renderer: RendererMain; | ||
export const render = async function ( | ||
code: () => JSXElement, | ||
const render = function (code: () => JSXElement, node?: HTMLElement | string) { | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
return solidRenderer.render(code, rootNode); | ||
}; | ||
export function createRenderer( | ||
rendererOptions = Config.rendererOptions, | ||
node?: HTMLElement | string, | ||
) { | ||
renderer = startLightningRenderer(Config.rendererOptions, node || 'app'); | ||
renderer = startLightningRenderer(rendererOptions, node || 'app'); | ||
rootNode.lng = renderer.root!; | ||
rootNode.rendered = true; | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
return solidRenderer.render(code, rootNode); | ||
}; | ||
return { | ||
renderer, | ||
rootNode, | ||
render, | ||
}; | ||
} | ||
@@ -37,0 +45,0 @@ export const { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
152073
1877