@lightningtv/solid
Advanced tools
Comparing version 0.1.3 to 1.0.0-rc0
@@ -28,2 +28,3 @@ import { type Accessor } from 'solid-js'; | ||
onFocus?: (currentFocusedElm: ElementNode | undefined, prevFocusedElm: ElementNode | undefined) => void; | ||
onFocusChanged?: (hasFocus: boolean, currentFocusedElm: ElementNode | undefined, prevFocusedElm: ElementNode | undefined) => void; | ||
onBlur?: (currentFocusedElm: ElementNode | undefined, prevFocusedElm: ElementNode | undefined) => void; | ||
@@ -30,0 +31,0 @@ onKeyPress?: (this: ElementNode, e: KeyboardEvent, mappedKeyEvent: string | undefined, handlerElm: ElementNode, currentFocusedElm: ElementNode) => KeyHandlerReturn; |
@@ -41,2 +41,4 @@ import { createEffect, on, createSignal, untrack, } from 'solid-js'; | ||
current.onFocus.call(current, currentFocusedElm, prevFocusedElm); | ||
isFunc(current.onFocusChanged) && | ||
current.onFocusChanged.call(current, true, currentFocusedElm, prevFocusedElm); | ||
newFocusedElms.push(current); | ||
@@ -52,2 +54,4 @@ } | ||
elm.onBlur.call(elm, currentFocusedElm, prevFocusedElm); | ||
isFunc(elm.onFocusChanged) && | ||
elm.onFocusChanged.call(elm, false, currentFocusedElm, prevFocusedElm); | ||
} | ||
@@ -54,0 +58,0 @@ }); |
@@ -31,3 +31,3 @@ import { activeElement, setActiveElement, rootNode, Config, } from '@lightningtv/solid'; | ||
if (active && | ||
testCollision(e.clientX, e.clientY, active.lng.coreNode.absX * precision, active.lng.coreNode.absY * precision, active.width * precision, active.height * precision)) { | ||
testCollision(e.clientX, e.clientY, active.lng.absX * precision, active.lng.absY * precision, active.width * precision, active.height * precision)) { | ||
document.dispatchEvent(createKeyboardEvent('Enter', 13)); | ||
@@ -49,3 +49,3 @@ } | ||
if (currentNode.alpha !== 0 && | ||
testCollision(x, y, currentNode.lng.coreNode.absX * precision, currentNode.lng.coreNode.absY * precision, currentNode.width * precision, currentNode.height * precision)) { | ||
testCollision(x, y, currentNode.lng.absX * precision, currentNode.lng.absY * precision, currentNode.width * precision, currentNode.height * precision)) { | ||
currentLevelNodes.push(currentNode); | ||
@@ -52,0 +52,0 @@ } |
import { type IntrinsicNodeProps, type IntrinsicTextProps } from '@lightningtv/core'; | ||
import { type JSXElement, type ValidComponent } from 'solid-js'; | ||
import type { RendererMain, RendererMainSettings } from '@lightningjs/renderer'; | ||
import { SolidNode } from './types.js'; | ||
export declare const rootNode: import("@lightningtv/core").ElementNode; | ||
export declare function startLightning(options?: Partial<RendererMainSettings>, rootId?: string | HTMLElement): Promise<void>; | ||
export declare const render: (code: () => JSXElement, node?: HTMLElement | string) => Promise<{ | ||
dispose: () => void; | ||
rootNode: import("@lightningtv/core").ElementNode; | ||
renderer: RendererMain; | ||
}>; | ||
export declare const renderSync: (code: () => JSXElement) => () => void; | ||
export declare const render: (code: () => JSXElement, node?: HTMLElement | string) => Promise<() => 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; | ||
@@ -14,0 +7,0 @@ /** |
@@ -8,22 +8,7 @@ import { createRenderer } from 'solid-js/universal'; | ||
export const rootNode = nodeOpts.createElement('App'); | ||
export async function startLightning(options, rootId) { | ||
renderer = startLightningRenderer(options || Config.rendererOptions, rootId || 'app'); | ||
return await renderer.init(); | ||
} | ||
export const render = async function (code, node) { | ||
await startLightning(undefined, node); | ||
renderer = startLightningRenderer(Config.rendererOptions, node || 'app'); | ||
rootNode.lng = renderer.root; | ||
rootNode.rendered = true; | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
const dispose = solidRenderer.render(code, rootNode); | ||
return { | ||
dispose, | ||
rootNode, | ||
renderer, | ||
}; | ||
}; | ||
// used for playground - must be sync so user must await startLightning | ||
export const renderSync = function (code) { | ||
rootNode.lng = renderer.root; | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
return solidRenderer.render(code, rootNode); | ||
@@ -30,0 +15,0 @@ }; |
@@ -9,3 +9,3 @@ import { assertTruthy } from '@lightningjs/renderer/utils'; | ||
// A text node is just a string - not the <text> node | ||
return { type: NodeType.Text, text, parent: undefined }; | ||
return { _type: NodeType.Text, text, parent: undefined }; | ||
}, | ||
@@ -12,0 +12,0 @@ replaceText(node, value) { |
{ | ||
"name": "@lightningtv/solid", | ||
"version": "0.1.3", | ||
"version": "1.0.0-rc0", | ||
"description": "Lightning Renderer for Solid Universal", | ||
@@ -45,3 +45,3 @@ "type": "module", | ||
"dependencies": { | ||
"@lightningtv/core": "^0.1.3", | ||
"@lightningtv/core": "1.0.0-rc1.2", | ||
"@solid-primitives/event-listener": "^2.3.3", | ||
@@ -75,3 +75,3 @@ "@solid-primitives/keyboard": "^1.2.8", | ||
"peerDependencies": { | ||
"@lightningjs/renderer": "^0.9.3", | ||
"@lightningjs/renderer": "^1.0.0-rc.1", | ||
"solid-js": "*" | ||
@@ -78,0 +78,0 @@ }, |
@@ -53,2 +53,7 @@ import { | ||
) => void; | ||
onFocusChanged?: ( | ||
hasFocus: boolean, | ||
currentFocusedElm: ElementNode | undefined, | ||
prevFocusedElm: ElementNode | undefined, | ||
) => void; | ||
onBlur?: ( | ||
@@ -136,3 +141,9 @@ currentFocusedElm: ElementNode | undefined, | ||
current.onFocus.call(current, currentFocusedElm, prevFocusedElm); | ||
isFunc(current.onFocusChanged) && | ||
current.onFocusChanged.call( | ||
current, | ||
true, | ||
currentFocusedElm, | ||
prevFocusedElm, | ||
); | ||
newFocusedElms.push(current); | ||
@@ -149,2 +160,9 @@ } | ||
elm.onBlur.call(elm, currentFocusedElm, prevFocusedElm); | ||
isFunc(elm.onFocusChanged) && | ||
elm.onFocusChanged.call( | ||
elm, | ||
false, | ||
currentFocusedElm, | ||
prevFocusedElm, | ||
); | ||
} | ||
@@ -151,0 +169,0 @@ }); |
@@ -14,9 +14,2 @@ import type { INode } from '@lightningjs/renderer'; | ||
interface MainOnlyNode extends INode { | ||
coreNode: { | ||
absX: number; | ||
absY: number; | ||
}; | ||
} | ||
function createKeyboardEvent(key: string, keyCode: number): KeyboardEvent { | ||
@@ -52,4 +45,4 @@ return new KeyboardEvent('keydown', { | ||
e.clientY, | ||
(active.lng as MainOnlyNode).coreNode.absX * precision, | ||
(active.lng as MainOnlyNode).coreNode.absY * precision, | ||
(active.lng as INode).absX * precision, | ||
(active.lng as INode).absY * precision, | ||
active.width! * precision, | ||
@@ -95,4 +88,4 @@ active.height! * precision, | ||
y, | ||
(currentNode.lng as MainOnlyNode).coreNode.absX * precision, | ||
(currentNode.lng as MainOnlyNode).coreNode.absY * precision, | ||
(currentNode.lng as INode).absX * precision, | ||
(currentNode.lng as INode).absY * precision, | ||
currentNode.width! * precision, | ||
@@ -99,0 +92,0 @@ currentNode.height! * precision, |
@@ -16,3 +16,3 @@ import { createRenderer } from 'solid-js/universal'; | ||
} from 'solid-js'; | ||
import type { RendererMain, RendererMainSettings } from '@lightningjs/renderer'; | ||
import type { RendererMain } from '@lightningjs/renderer'; | ||
import { SolidNode } from './types.js'; | ||
@@ -25,13 +25,2 @@ | ||
export async function startLightning( | ||
options?: Partial<RendererMainSettings>, | ||
rootId?: string | HTMLElement, | ||
) { | ||
renderer = startLightningRenderer( | ||
options || Config.rendererOptions, | ||
rootId || 'app', | ||
); | ||
return await renderer.init(); | ||
} | ||
export const render = async function ( | ||
@@ -41,18 +30,6 @@ code: () => JSXElement, | ||
) { | ||
await startLightning(undefined, node); | ||
renderer = startLightningRenderer(Config.rendererOptions, node || 'app'); | ||
rootNode.lng = renderer.root!; | ||
rootNode.rendered = true; | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
const dispose = solidRenderer.render(code, rootNode); | ||
return { | ||
dispose, | ||
rootNode, | ||
renderer, | ||
}; | ||
}; | ||
// used for playground - must be sync so user must await startLightning | ||
export const renderSync = function (code: () => JSXElement) { | ||
rootNode.lng = renderer.root!; | ||
// @ts-expect-error - code is jsx element and not SolidElement yet | ||
return solidRenderer.render(code, rootNode); | ||
@@ -59,0 +36,0 @@ }; |
@@ -11,3 +11,3 @@ import { assertTruthy } from '@lightningjs/renderer/utils'; | ||
// A text node is just a string - not the <text> node | ||
return { type: NodeType.Text, text, parent: undefined }; | ||
return { _type: NodeType.Text, text, parent: undefined }; | ||
}, | ||
@@ -14,0 +14,0 @@ replaceText(node: ElementText, value: string): void { |
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
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
151365
1858
+ Added@lightningjs/renderer@1.0.1(transitive)
+ Added@lightningtv/core@1.0.0-rc1.2(transitive)
- Removed@lightningjs/renderer@0.9.4(transitive)
- Removed@lightningtv/core@0.1.5(transitive)