Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lightningtv/solid

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lightningtv/solid - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

dist/source/primitives/useMouse.js

87

dist/esm/index.js

@@ -5,5 +5,7 @@ import { createSignal, mergeProps as mergeProps$1, createRoot, createRenderEffect, createMemo, createComponent as createComponent$1, untrack, splitProps, createEffect, on, createResource, createComputed, batch } from 'solid-js';

export * from '@lightningtv/core';
import { createElement as createElement$1, spread as spread$1, isArray, activeElement as activeElement$1, isFunc, renderer as renderer$1 } from '@lightningtv/solid';
import { createElement as createElement$1, spread as spread$1, isArray, activeElement as activeElement$1, isFunc, renderer as renderer$1, setActiveElement as setActiveElement$1, ElementNode as ElementNode$1 } from '@lightningtv/solid';
import { useKeyDownEvent } from '@solid-primitives/keyboard';
import { debounce } from '@solid-primitives/scheduled';
import { debounce, throttle, createScheduled } from '@solid-primitives/scheduled';
import { makeEventListener } from '@solid-primitives/event-listener';
import { useMousePosition } from '@solid-primitives/mouse';

@@ -570,3 +572,4 @@ const [activeElement, setActiveElement] = createSignal(undefined);

if (size) {
el.width = el.children.reduce((acc, c) => {
el.width = el.children.reduce((acc, child) => {
const c = child;
return acc + (c.width || 0);

@@ -581,3 +584,4 @@ }, 0) + left + right;

let maxHeight = 0;
el.children.forEach(c => {
el.children.forEach(child => {
const c = child;
c.y = top;

@@ -925,3 +929,76 @@ c.marginTop = top;

export { Dynamic, Text, View, activeElement, createComponent, createElement, createInfiniteItems, createSpriteMap, createTextNode, deg2rad, effect, focusPath, hexColor, insert, insertNode, memo, mergeProps, render, renderSync, setActiveElement, setProp, spread, startLightning, use, useAnnouncer, useFocusManager, withPadding };
function createKeyboardEvent(key, keyCode) {
return new KeyboardEvent('keydown', {
key,
keyCode,
which: keyCode,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
bubbles: true
});
}
const handleScroll = throttle(e => {
const deltaY = e.deltaY;
if (deltaY < 0) {
document.dispatchEvent(createKeyboardEvent('ArrowUp', 38));
} else if (deltaY > 0) {
document.dispatchEvent(createKeyboardEvent('ArrowDown', 40));
}
}, 250);
const handleClick = e => {
const active = activeElement$1();
if (active && testCollision(e.clientX, e.clientY, active.lng.coreNode.absX, active.lng.coreNode.absY, active.width, active.height)) {
document.dispatchEvent(createKeyboardEvent('Enter', 13));
}
};
function testCollision(px, py, cx, cy, cw = 0, ch = 0) {
return px >= cx && px <= cx + cw && py >= cy && py <= cy + ch;
}
function getChildrenByPosition(node, x, y) {
let result = [node];
for (let i = 0; i < node.children.length; i++) {
const child = node.children[i];
if (child instanceof ElementNode$1) {
if (child.alpha !== 0 && testCollision(x, y, child.lng.coreNode.absX, child.lng.coreNode.absY, child.width, child.height)) {
// continue searching tree
result = [...result, ...getChildrenByPosition(child, x, y)];
}
}
}
return result;
}
function useMouse(myApp) {
if (!myApp) {
return;
}
const pos = useMousePosition();
const scheduled = createScheduled(fn => throttle(fn, 100));
makeEventListener(window, 'wheel', handleScroll);
makeEventListener(window, 'click', handleClick);
createEffect(() => {
if (scheduled()) {
const result = getChildrenByPosition(myApp, pos.x, pos.y).filter(el => (el.focus || el.onFocus || el.onEnter) && !el.skipFocus).sort((a, b) => (a.zIndex || 0) - (b.zIndex || 0));
if (result.length) {
let activeElm = result[result.length - 1];
while (activeElm) {
const elmParent = activeElm.parent;
if (elmParent?.forwardStates) {
activeElm = activeElm.parent;
} else {
break;
}
}
const activeElmParent = activeElm?.parent;
if (activeElm && activeElmParent?.selected !== undefined) {
activeElmParent.selected = activeElmParent.children.indexOf(activeElm);
}
setActiveElement$1(activeElm);
}
}
});
}
export { Dynamic, Text, View, activeElement, createComponent, createElement, createInfiniteItems, createSpriteMap, createTextNode, deg2rad, effect, focusPath, hexColor, insert, insertNode, memo, mergeProps, render, renderSync, setActiveElement, setProp, spread, startLightning, use, useAnnouncer, useFocusManager, useMouse, withPadding };
//# sourceMappingURL=index.js.map

@@ -6,1 +6,2 @@ export * from './useFocusManager.js';

export * from './createSpriteMap.js';
export * from './useMouse.js';

6

dist/source/primitives/withPadding.js

@@ -26,3 +26,4 @@ // To use with TS import withPadding and then put withPadding; on the next line to prevent tree shaking

el.width =
el.children.reduce((acc, c) => {
el.children.reduce((acc, child) => {
const c = child;
return acc + (c.width || 0);

@@ -39,3 +40,4 @@ }, 0) +

let maxHeight = 0;
el.children.forEach((c) => {
el.children.forEach((child) => {
const c = child;
c.y = top;

@@ -42,0 +44,0 @@ c.marginTop = top;

/* eslint-disable @typescript-eslint/unbound-method */
import { createRenderer } from 'solid-js/universal';
import { Config, startLightningRenderer, } from '@lightningtv/core';
import { Config, startLightningRenderer } from '@lightningtv/core';
import nodeOpts from './solidOpts.js';

@@ -5,0 +5,0 @@ import { splitProps, createMemo, untrack, } from 'solid-js';

@@ -6,1 +6,2 @@ export * from './useFocusManager.js';

export * from './createSpriteMap.js';
export * from './useMouse.js';

@@ -1,2 +0,2 @@

import { type SolidNode } from '@lightningtv/core';
import { type SolidNode } from './solidOpts.js';
import { type JSXElement, type ValidComponent } from 'solid-js';

@@ -3,0 +3,0 @@ import type { RendererMainSettings } from '@lightningjs/renderer';

@@ -1,5 +0,10 @@

import type { SolidNode, TextNode } from '@lightningtv/core';
import { ElementNode } from '@lightningtv/core';
import { ElementNode, type TextNode } from '@lightningtv/core';
import type { createRenderer } from 'solid-js/universal';
export type SolidRendererOptions = Parameters<typeof createRenderer<SolidNode>>[0];
export type SolidNode = ElementNode | TextNode;
declare module '@lightningtv/core' {
interface TextNode {
_queueDelete?: boolean;
}
}
declare const _default: {

@@ -6,0 +11,0 @@ createElement(name: string): ElementNode;

{
"name": "@lightningtv/solid",
"version": "0.0.6",
"version": "0.0.7",
"description": "Lightning Renderer for Solid Universal",

@@ -40,5 +40,7 @@ "type": "module",

"dependencies": {
"@lightningtv/core": "^0.0.6",
"@lightningtv/solid": "file:",
"@lightningtv/core": "^0.0.8",
"@solid-primitives/event-listener": "^2.3.3",
"@solid-primitives/keyboard": "^1.2.8",
"@solid-primitives/mouse": "^2.0.19",
"@solid-primitives/scheduled": "^1.4.3"

@@ -45,0 +47,0 @@ },

@@ -6,1 +6,2 @@ export * from './useFocusManager.js';

export * from './createSpriteMap.js';
export * from './useMouse.js';

@@ -33,3 +33,4 @@ import type { ElementNode } from '@lightningtv/core';

el.width =
el.children.reduce((acc, c) => {
el.children.reduce((acc, child) => {
const c = child as ElementNode;
return acc + (c.width || 0);

@@ -39,3 +40,3 @@ }, 0) +

right;
const firstChild = el.children[0];
const firstChild = el.children[0] as ElementNode;
if (firstChild) {

@@ -48,3 +49,4 @@ // set padding or marginLeft for flex

let maxHeight = 0;
el.children.forEach((c) => {
el.children.forEach((child) => {
const c = child as ElementNode;
c.y = top;

@@ -51,0 +53,0 @@ c.marginTop = top;

/* eslint-disable @typescript-eslint/unbound-method */
import { createRenderer } from 'solid-js/universal';
import { Config, startLightningRenderer } from '@lightningtv/core';
import nodeOpts, { type SolidNode } from './solidOpts.js';
import {
Config,
startLightningRenderer,
type SolidNode,
} from '@lightningtv/core';
import nodeOpts from './solidOpts.js';
import {
splitProps,

@@ -11,0 +7,0 @@ createMemo,

import { assertTruthy } from '@lightningjs/renderer/utils';
import type { SolidNode, TextNode } from '@lightningtv/core';
import { ElementNode, NodeType, log } from '@lightningtv/core';
import { ElementNode, NodeType, log, type TextNode } from '@lightningtv/core';
import type { createRenderer } from 'solid-js/universal';

@@ -10,2 +9,10 @@

export type SolidNode = ElementNode | TextNode;
declare module '@lightningtv/core' {
interface TextNode {
_queueDelete?: boolean;
}
}
export default {

@@ -12,0 +19,0 @@ createElement(name: string): ElementNode {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc