Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@lightningjs/solid-primitives
Advanced tools
Solid-Lightning-Primitives are a collection of primitives to get the most out of Lightning Solid.
> npm i @lightningjs/solid-primitives
useFocusManager
adds key handling, focusPath tracking, and focus and blur events on components. You can do this once in your App component. It returns a signal, focusPath which is an array of elements that currently have focus. When activeElement
changes, the focusPath will be recalculated. During which all elements in focus will have a focus
state added and onFocus(currentFocusedElm, prevFocusedElm) event called. Elements losing focus will have focus
state removed and onBlur(currentFocusedElm, prevFocusedElm) called.
import { useFocusManager } from "@lightningjs/solid-primitives";
const App = () => {
// Only need to do this once in Application, but you can call it anywhere
// if you need to get the focusPath signal
const focusPath = useFocusManager(keyMap);
return ...
}
The calculated focusPath is used for handling key events. When a key is pressed, the keyMap
looks for the keyName and corresponding value to call on${key}
then onKeyPress
on each element until one handles the event.
import { useFocusManager } from '@lightningjs/solid-primitives';
useFocusManager({
Menu: 'm',
Text: 't',
Buttons: 'b',
});
<View
onText={() => navigate('/text')}
onButtons={() => navigate('/buttons')}
onMenu={() => navigate('/')}
/>;
When keys m, t, b are pressed - onMenu, onText, onButtons will be called respectively.
withPadding
is a directive to set padding when a child text node loads. It follows css by taking a single padding value or Array [top, bottom | left, right ] or [top | right, left | bottom ] or [top | right | bottom | left]
import { Text } from '@lightningjs/solid';
import { withPadding } from '@lightningjs/solid-primitives';
const Badge = (props) => {
return (
<node
use:withPadding={[10, 15]}
{...props}
style={{
color: '#00000099',
borderRadius: 8,
border: { width: 2, color: '#ffffff' },
}}
>
<Text
style={{
fontSize: 20,
lineHeight: 20,
}}
>
{props.children}
</Text>
</node>
);
};
<Badge>HD</Badge>;
createSpriteMap
allows you to take a sprite and use different positions of the texture
for different icons. This loads a texture once and allows it to be reused for performance and memory savings.
import { View } from '@lightningjs/solid';
import { createSpriteMap } from '@lightningjs/solid-primitives';
const icons = [
{ name: 'dolby', width: 39, height: 40, x: 0, y: 0 },
{ name: 'ellipse', width: 56, height: 56, x: 40, y: 0 },
{ name: 'ellipse1', width: 56, height: 56, x: 96, y: 0 },
];
export default function Icon(props) {
const sprite = createSpriteMap('/assets/icons/spritesheet.png', icons);
return (
<View
{...props}
texture={sprite[props.name]}
width={sprite[props.name].props.width}
height={sprite[props.name].props.height}
x={(56 - sprite[props.name].props.width) / 2}
y={(56 - sprite[props.name].props.height) / 2}
></View>
);
}
For Lightning apps it's really important to lazy load rows and items as much as possible.
const [items, { setPage }] = createInfiniteItems(paginatedAPI);
setPage(1); // load the first page - default no pages are loaded.
const onSelectedChanged = (column, elm, index) => {
if (index < 5) {
return;
} else {
const page = Math.ceil((index - 4) / 10) + 1;
column.setPage(page);
}
};
<Column
ref={column}
{...props}
onFocus={onFocus}
onSelectedChanged={onSelectedChanged}
>
<For each={props.items()}>{(item) => <Button>{item.title}</Button>}</For>
</Column>;
FAQs
Lightning Primitives for Solid Lightning
The npm package @lightningjs/solid-primitives receives a total of 4 weekly downloads. As such, @lightningjs/solid-primitives popularity was classified as not popular.
We found that @lightningjs/solid-primitives demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.