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

@lightningjs/solid

Package Overview
Dependencies
Maintainers
7
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lightningjs/solid - npm Package Compare versions

Comparing version 0.8.4 to 0.8.5

179

dist/esm/index.js

@@ -42,48 +42,2 @@ import { createSignal, createEffect, mergeProps as mergeProps$1, createRoot, createRenderEffect, createMemo, createComponent as createComponent$1, untrack } from 'solid-js';

const Text = props => (() => {
const _el$ = createElement$1("text");
spread$1(_el$, props, false);
return _el$;
})();
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
const View = props => (() => {
const _el$ = createElement$1("node");
spread$1(_el$, props, false);
return _el$;
})();
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
let renderer;

@@ -118,38 +72,2 @@ let createShader;

/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Asserts a condition is truthy, otherwise throws an error
*
* @remarks
* Useful at the top of functions to ensure certain conditions, arguments and
* properties are set/met before continuing. When using this function,
* TypeScript will narrow away falsy types from the condition.
*
* @param condition
* @param message
* @returns
*/
function assertTruthy(condition, message) {
if (!condition) {
throw new Error(message || 'Assertion failed');
}
}
/*
* Copyright 2023 Comcast Cable Communications Management, LLC

@@ -287,2 +205,5 @@ * Licensed under the Apache License, Version 2.0 (the "License");

}
function getAnimatableValue(value) {
return isArray(value) ? value[0] : value;
}

@@ -307,3 +228,3 @@ /*

class States extends Array {
constructor(callback, initialState = []) {
constructor(callback, initialState = {}) {
if (isArray(initialState)) {

@@ -346,2 +267,38 @@ super(...initialState);

/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Asserts a condition is truthy, otherwise throws an error
*
* @remarks
* Useful at the top of functions to ensure certain conditions, arguments and
* properties are set/met before continuing. When using this function,
* TypeScript will narrow away falsy types from the condition.
*
* @param condition
* @param message
* @returns
*/
function assertTruthy(condition, message) {
if (!condition) {
throw new Error(message || 'Assertion failed');
}
}
/*
* Copyright 2023 Comcast Cable Communications Management, LLC

@@ -524,3 +481,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

set(v) {
this[`_${key}`] = v;
this[`_${key}`] = getAnimatableValue(v);
this._sendToLightningAnimatable(key, v);

@@ -690,4 +647,4 @@ }

}
set states(v) {
this._states = new States(this._stateChanged.bind(this), v);
set states(states) {
this._states = new States(this._stateChanged.bind(this), states);
if (this.rendered) {

@@ -704,4 +661,4 @@ this._stateChanged();

}
set animationSettings(v) {
this._animationSettings = v;
set animationSettings(animationSettings) {
this._animationSettings = animationSettings;
}

@@ -853,2 +810,48 @@ get updateLayoutOn() {

/*
* Copyright 2023 Comcast Cable Communications Management, LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
const Text = props => (() => {
const _el$ = createElement$1("text");
spread$1(_el$, props, false);
return _el$;
})();
/*
* Copyright 2023 Comcast Cable Communications Management, LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
const View = props => (() => {
const _el$ = createElement$1("node");
spread$1(_el$, props, false);
return _el$;
})();
function renderTopDown(node) {

@@ -855,0 +858,0 @@ if (node.name === 'TextNode') {

@@ -21,3 +21,3 @@ /*

import calculateFlex from '../flex.js';
import { log, isArray, isNumber, isFunc, keyExists } from '../utils.js';
import { log, isArray, isNumber, isFunc, keyExists, getAnimatableValue, } from '../utils.js';
import { config } from '../../config.js';

@@ -97,2 +97,3 @@ import { setActiveElement } from '../activeElement.js';

rendered;
autofocus;
_undoStates;

@@ -137,3 +138,3 @@ _renderProps;

set(v) {
this[`_${key}`] = v;
this[`_${key}`] = getAnimatableValue(v);
this._sendToLightningAnimatable(key, v);

@@ -294,4 +295,4 @@ },

}
set states(v) {
this._states = new States(this._stateChanged.bind(this), v);
set states(states) {
this._states = new States(this._stateChanged.bind(this), states);
if (this.rendered) {

@@ -308,4 +309,4 @@ this._stateChanged();

}
set animationSettings(v) {
this._animationSettings = v;
set animationSettings(animationSettings) {
this._animationSettings = animationSettings;
}

@@ -312,0 +313,0 @@ get updateLayoutOn() {

@@ -20,3 +20,3 @@ /*

onChange;
constructor(callback, initialState = []) {
constructor(callback, initialState = {}) {
if (isArray(initialState)) {

@@ -23,0 +23,0 @@ super(...initialState);

@@ -53,1 +53,4 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

}
export function getAnimatableValue(value) {
return isArray(value) ? value[0] : value;
}

@@ -20,2 +20,3 @@ /*

export * from './core/activeElement.js';
export * from './core/node/index.js';
export * from './components/index.js';

@@ -25,5 +26,4 @@ export * from './core/renderer/index.js';

export { config as Config } from './config.js';
export * from './core/node/index.js';
export * from './intrinsicTypes.js';
export * from './utils.js';
export * as Types from './intrinsicTypes.js';
import { createShader } from '../renderer/index.js';
import { type IntrinsicNodeProps } from '../../index.js';
import { type AnimatableNumberProp, type IntrinsicCommonProps } from '../../index.js';
import Children from './children.js';
import States from './states.js';
import type { INode, INodeAnimatableProps, ShaderRef, Dimensions, AnimationSettings } from '@lightningjs/renderer';
import States, { type NodeStates } from './states.js';
import type { INode, INodeAnimatableProps, INodeWritableProps, ShaderRef, Dimensions, AnimationSettings } from '@lightningjs/renderer';
export interface TextNode {

@@ -26,3 +26,3 @@ name: string;

export type SolidNode = ElementNode | TextNode;
export interface ElementNode extends Omit<IntrinsicNodeProps, 'children'> {
export interface ElementNode extends Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>, IntrinsicCommonProps {
}

@@ -34,2 +34,3 @@ export declare class ElementNode extends Object {

rendered: boolean;
autofocus: boolean;
private _undoStates?;

@@ -68,5 +69,5 @@ private _renderProps;

set shader(v: Parameters<typeof createShader> | ShaderRef | undefined);
_sendToLightningAnimatable(name: string, value: [value: number | string, settings: AnimationSettings] | number | string): any;
_sendToLightningAnimatable(name: string, value: AnimatableNumberProp | number | string): any;
_sendToLightning(name: string, value: unknown): void;
createAnimation(props: Partial<INodeAnimatableProps>, animationSettings?: any): any;
createAnimation(props: Partial<INodeAnimatableProps>, animationSettings?: Partial<AnimationSettings>): any;
setFocus(): void;

@@ -80,6 +81,6 @@ isTextNode(): boolean;

get hasChildren(): boolean;
set states(v: States);
set states(states: NodeStates);
get states(): States;
get animationSettings(): any;
set animationSettings(v: any);
get animationSettings(): Partial<AnimationSettings>;
set animationSettings(animationSettings: Partial<AnimationSettings>);
get updateLayoutOn(): any;

@@ -86,0 +87,0 @@ set updateLayoutOn(v: any);

@@ -0,4 +1,5 @@

export type NodeStates = string[] | string | Record<string, boolean>;
export default class States extends Array<string> {
private onChange;
constructor(callback: () => void, initialState?: string[] | string | Record<string, boolean>);
constructor(callback: () => void, initialState?: NodeStates);
has(state: string): boolean;

@@ -5,0 +6,0 @@ is(state: string): boolean;

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

import type { AnimatableNumberProp } from '../index.js';
import type { SolidNode } from './node/index.js';

@@ -10,1 +11,2 @@ export declare function log(msg: string, node: SolidNode, ...args: any[]): void;

export declare function keyExists(obj: Record<string | number | symbol, unknown>, keys: (string | number | symbol)[]): boolean;
export declare function getAnimatableValue(value: number | AnimatableNumberProp | undefined): number | undefined;
import './jsx-runtime.js';
export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, } from 'solid-js';
export * from './core/activeElement.js';
export * from './core/node/index.js';
export * from './components/index.js';

@@ -8,5 +9,4 @@ export * from './core/renderer/index.js';

export { config as Config } from './config.js';
export * from './core/node/index.js';
export * from './intrinsicTypes.js';
export * from './utils.js';
export * as Types from './intrinsicTypes.js';

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

import { type AnimationSettings, type Dimensions, type INode, type INodeWritableProps, type ITextNodeWritableProps } from '@lightningjs/renderer';
import { type AnimationSettings, type Dimensions, type INode, type INodeAnimatableProps, type INodeWritableProps, type ITextNodeWritableProps, type NodeFailedPayload, type NodeLoadedPayload } from '@lightningjs/renderer';
import { type JSX } from 'solid-js';
import { type ElementNode } from './core/node/index.js';
import type States from './core/node/states.js';
import type { NodeStates } from './core/node/states.js';
export interface BorderStyleObject {

@@ -13,3 +13,3 @@ width: number;

animate?: boolean;
animationSettings?: AnimationSettings;
animationSettings?: Partial<AnimationSettings>;
autofocus?: boolean;

@@ -33,11 +33,21 @@ border?: BorderStyle;

onBeforeLayout?: (child: ElementNode, dimensions: Dimensions) => void;
onFail?: (target: INode, error: Error) => void;
onLayout?: (child: ElementNode, dimensions: Dimensions) => void;
onLoad?: (target: INode, dimensions: Dimensions) => void;
ref?: ElementNode | ((node: ElementNode | null) => void) | null;
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void;
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void;
ref?: ElementNode | ((node: ElementNode | null) => void) | null | undefined;
selected?: number;
states?: States;
states?: NodeStates;
text?: string;
}
export interface IntrinsicNodeStyleProps extends Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>, IntrinsicCommonProps {
export type AnimatableNumberProp = [
value: number,
settings: Partial<AnimationSettings>
];
type TransformAnimatableNumberProps<T> = {
[K in keyof T]?: number extends T[K] ? number | AnimatableNumberProp : T[K];
};
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;
}

@@ -52,3 +62,3 @@ export interface IntrinsicTextNodeStyleProps extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>, IntrinsicCommonProps {

style?: IntrinsicTextNodeStyleProps;
children: string;
children: string | string[];
}

@@ -59,1 +69,2 @@ export type NodeStyles = IntrinsicNodeStyleProps;

export type TextProps = IntrinsicTextProps;
export {};
{
"name": "@lightningjs/solid",
"version": "0.8.4",
"version": "0.8.5",
"description": "Lightning renderer for solid universal",

@@ -5,0 +5,0 @@ "type": "module",

@@ -202,3 +202,3 @@ <p>

Adding an `animate` attribute to a <View> component will cause any property changes (after initial render) to be animated. This is useful for simple animations where you want to resize, move, or change alpha of a component. You can set `animationSettings` with an object to control the duration and timing function of property changes.
Adding an `animate` attribute to a <View> component will cause any property changes (after initial render) to be animated. This is useful for simple animations where you want to resize, move, or change alpha of a component. You can set `animationSettings` with an object to control the duration and easing function of property changes.

@@ -332,3 +332,3 @@ ```jsx

scale: 1.2,
alpha: [1, { duration: 1500, delay: 200, timing: 'easy-in' }],
alpha: [1, { duration: 1500, delay: 200, easing: 'easy-in' }],
},

@@ -335,0 +335,0 @@ };

@@ -20,9 +20,18 @@ /*

import {
type AnimatableNumberProp,
type BorderStyleObject,
type IntrinsicNodeProps,
type IntrinsicCommonProps,
type IntrinsicNodeStyleProps,
} from '../../index.js';
import Children from './children.js';
import States from './states.js';
import States, { type NodeStates } from './states.js';
import calculateFlex from '../flex.js';
import { log, isArray, isNumber, isFunc, keyExists } from '../utils.js';
import {
log,
isArray,
isNumber,
isFunc,
keyExists,
getAnimatableValue,
} from '../utils.js';
import { config } from '../../config.js';

@@ -139,3 +148,5 @@ import { setActiveElement } from '../activeElement.js';

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export interface ElementNode extends Omit<IntrinsicNodeProps, 'children'> {}
export interface ElementNode
extends Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>,
IntrinsicCommonProps {}

@@ -148,2 +159,3 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging

rendered: boolean;
autofocus: boolean;

@@ -157,3 +169,3 @@ private _undoStates?: Record<string, any>;

private _states?: States;
private _animationSettings?: any;
private _animationSettings?: Partial<AnimationSettings>;
private _updateLayoutOn?: any;

@@ -188,7 +200,7 @@ private _width?: number;

Object.defineProperty(this, key, {
get() {
get(): number {
return this[`_${key}`] || (this.lng && this.lng[key]);
},
set(v: number) {
this[`_${key}`] = v;
set(v: number | AnimatableNumberProp) {
this[`_${key}`] = getAnimatableValue(v);
this._sendToLightningAnimatable(key, v);

@@ -283,6 +295,3 @@ },

name: string,
value:
| [value: number | string, settings: AnimationSettings]
| number
| string,
value: AnimatableNumberProp | number | string,
) {

@@ -318,3 +327,3 @@ if (this.rendered && this.lng) {

props: Partial<INodeAnimatableProps>,
animationSettings?: any,
animationSettings?: Partial<AnimationSettings>,
) {

@@ -370,3 +379,3 @@ assertTruthy(this.lng, 'Node must be rendered before animating');

if (!this[key as keyof this]) {
this[key as keyof this] = value[key as keyof ElementNode];
this[key as keyof this] = value[key as keyof IntrinsicNodeStyleProps];
}

@@ -378,3 +387,3 @@ }

get style() {
get style(): any {
return this._style;

@@ -387,4 +396,4 @@ }

set states(v) {
this._states = new States(this._stateChanged.bind(this), v);
set states(states: NodeStates) {
this._states = new States(this._stateChanged.bind(this), states);
if (this.rendered) {

@@ -395,3 +404,3 @@ this._stateChanged();

get states() {
get states(): States {
this._states = this._states || new States(this._stateChanged.bind(this));

@@ -401,8 +410,8 @@ return this._states;

get animationSettings() {
get animationSettings(): Partial<AnimationSettings> {
return this._animationSettings || defaultAnimationSettings;
}
set animationSettings(v) {
this._animationSettings = v;
set animationSettings(animationSettings: Partial<AnimationSettings>) {
this._animationSettings = animationSettings;
}

@@ -409,0 +418,0 @@

@@ -19,9 +19,9 @@ /*

import { isArray, isString } from '../utils.js';
export type NodeStates = string[] | string | Record<string, boolean>;
export default class States extends Array<string> {
private onChange: () => void;
constructor(
callback: () => void,
initialState: string[] | string | Record<string, boolean> = [],
) {
constructor(callback: () => void, initialState: NodeStates = {}) {
if (isArray(initialState)) {

@@ -28,0 +28,0 @@ super(...initialState);

@@ -20,2 +20,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

import { config } from '../config.js';
import type { AnimatableNumberProp } from '../index.js';
import type { SolidNode } from './node/index.js';

@@ -69,1 +70,7 @@

}
export function getAnimatableValue(
value: number | AnimatableNumberProp | undefined,
): number | undefined {
return isArray(value) ? (value as AnimatableNumberProp)[0] : value;
}

@@ -29,2 +29,3 @@ /*

export * from './core/activeElement.js';
export * from './core/node/index.js';
export * from './components/index.js';

@@ -34,5 +35,4 @@ export * from './core/renderer/index.js';

export { config as Config } from './config.js';
export * from './core/node/index.js';
export * from './intrinsicTypes.js';
export * from './utils.js';
export * as Types from './intrinsicTypes.js';

@@ -22,8 +22,11 @@ /*

type INode,
type INodeAnimatableProps,
type INodeWritableProps,
type ITextNodeWritableProps,
type NodeFailedPayload,
type NodeLoadedPayload,
} from '@lightningjs/renderer';
import { type JSX } from 'solid-js';
import { type ElementNode } from './core/node/index.js';
import type States from './core/node/states.js';
import type { NodeStates } from './core/node/states.js';

@@ -40,3 +43,3 @@ export interface BorderStyleObject {

animate?: boolean;
animationSettings?: AnimationSettings;
animationSettings?: Partial<AnimationSettings>;
autofocus?: boolean;

@@ -65,11 +68,15 @@ border?: BorderStyle;

onBeforeLayout?: (child: ElementNode, dimensions: Dimensions) => void;
onFail?: (target: INode, error: Error) => void;
onLayout?: (child: ElementNode, dimensions: Dimensions) => void;
onLoad?: (target: INode, dimensions: Dimensions) => void;
ref?: ElementNode | ((node: ElementNode | null) => void) | null;
onLoad?: (target: INode, nodeLoadedPayload: NodeLoadedPayload) => void;
onFail?: (target: INode, nodeFailedPayload: NodeFailedPayload) => void;
ref?: ElementNode | ((node: ElementNode | null) => void) | null | undefined;
selected?: number;
states?: States;
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

@@ -79,10 +86,23 @@ // 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 | [value: number, settings: AnimationSettings]) : T[K];
// };
type TransformAnimatableNumberProps<T> = {
[K in keyof T]?: number extends T[K] ? number | AnimatableNumberProp : T[K];
};
export interface IntrinsicNodeStyleProps
extends Partial<Omit<INodeWritableProps, 'parent' | 'shader'>>,
IntrinsicCommonProps {}
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; // Should be EffectMap
}
export interface IntrinsicTextNodeStyleProps

@@ -99,3 +119,3 @@ extends Partial<Omit<ITextNodeWritableProps, 'parent' | 'shader'>>,

style?: IntrinsicTextNodeStyleProps;
children: string;
children: string | string[];
}

@@ -102,0 +122,0 @@

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