Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@storybook/preview-api
Advanced tools
The @storybook/preview-api package is part of the Storybook ecosystem, which is a tool for developing UI components in isolation for React, Vue, Angular, and more. This package provides APIs to interact with the Storybook preview, allowing developers to control the rendering of stories, listen to events, and manipulate the state of the Storybook UI.
Fetching and rendering stories
This feature allows developers to fetch story data by ID and render it using a custom component or utility.
import { useStorybookApi } from '@storybook/api';
function MyComponent() {
const api = useStorybookApi();
const story = api.getData('some-story-id');
return <StoryRenderer story={story} />;
}
Listening to Storybook events
This feature enables components to listen to Storybook-specific events and react accordingly, as well as emit events to the Storybook environment.
import { useEffect } from 'react';
import { useChannel } from '@storybook/api';
function MyComponent() {
const emit = useChannel({
'storybook/my-event': (eventData) => {
console.log('Event data:', eventData);
}
});
useEffect(() => {
emit('storybook/my-event', { payload: 'data' });
}, [emit]);
return <div>Check the console for event data.</div>;
}
Manipulating the Storybook UI
Developers can use this feature to programmatically control the Storybook UI, such as changing the current story displayed.
import { addons } from '@storybook/addons';
addons.setChannel(new Channel({ transport: new PostmsgTransport({ key: 'iframe-key' }) }));
addons.getChannel().emit('setCurrentStory', { storyId: 'some-story-id' });
This package allows developers to create callbacks that appear in the actions panel of the Storybook UI when clicked. It is similar to @storybook/preview-api in that it enhances the Storybook development experience but focuses on actions rather than preview functionality.
This package provides a way to create links between stories. It is similar to @storybook/preview-api in that it interacts with the Storybook UI, but it specifically focuses on linking stories together rather than providing a general API for preview manipulation.
This addon shows the source of the story next to the story itself. While it enhances the Storybook experience by providing source code context, it does not offer an API for controlling the preview like @storybook/preview-api does.
FAQs
Unknown package
The npm package @storybook/preview-api receives a total of 7,749,387 weekly downloads. As such, @storybook/preview-api popularity was classified as popular.
We found that @storybook/preview-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.