Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@hishprorg/fugit-a
Advanced tools
There're some cases when you can't / don't want / forgot to keep browser console opened. This addon helps you to get all console output in your storybook. In other cases, you might find it difficult to extract the desired information in the information noise issued by the console or to determine which component in what state gives the message. With this addon, you can control what you see and where you see.
We assume the following possible applications:
Mobile devices. You might want to make console output reachable for users when they need to work with your storybook from mobile browsers
Small screens. You can save your screen space keeping browser console closed
To filter your console output. You can independently configure both action logger and real console output in a wide range.
To associate console messages with a specific components/stories. You can see which story emits which message
To output some data into Action Logger from your deep components without importing addon-actions
for that.
try live demo
yarn add -D @hishprorg/fugit-a @storybook/addon-actions
Just import it in your storybook config.js:
// config.js
import '@hishprorg/fugit-a';
That's all. You'll start to receive all console messages, warnings, errors in your action logger panel. Everything except HMR logs.
If you want to enable HMR messages, do the following:
// config.js
import { setConsoleOptions } from '@hishprorg/fugit-a';
const panelExclude = setConsoleOptions({}).panelExclude;
setConsoleOptions({
panelExclude: [...panelExclude, /deprecated/],
});
You'll receive console outputs as a console
, warn
and error
actions in the panel. You might want to know from what
stories they come. In this case, add withConsole
decorator:
// preview.js
import type { Preview } from '@storybook/react';
import { withConsole } from '@hishprorg/fugit-a';
const preview: Preview = {
decorators: [(storyFn, context) => withConsole()(storyFn)(context)],
// ...
};
After that your messages in Action Logger will be prefixed with the story path, like molecules/atoms/electron: ["ComponentDidMount"]
or molecules/atoms/electron error: ["Warning: Failed prop type..."]
. You can setup addon
behavior by passing options to withConsole
or setConsoleOptions
methods, both have the same API.
Addon console don't have own UI panel to output logs, it use addon-console
instead. Make sure that main.js
contains this line:
// main.js
export default {
addons: [
"@storybook/addon-actions/register",
],
};
It handles console.log
, console.warn
, and console.error
methods and not catched errors. By default, it just reflects all console messages in the Action Logger Panel (should be installed as a peerDependency) except [HMR] logs.
addonOptions
function
Object
addonOptions
addonOptions
Set addon options and returns a new one
Kind: static method of @hishprorg/fugit-a
See
Param | Type |
---|---|
optionsOrFn | addonOptions | optionsCallback |
Example
import { setConsoleOptions } from '@hishprorg/fugit-a';
const panelExclude = setConsoleOptions({}).panelExclude;
setConsoleOptions({
panelExclude: [...panelExclude, /deprecated/],
});
function
Wraps your stories with specified addon options.
If you don't pass {log
, warn
, error
} in options argument it'll create them from context for each story individually. Hence you'll see from what exact story you got a log or error. You can log from component's lifecycle methods or within your story.
Kind: static method of @hishprorg/fugit-a
Returns: function
- wrappedStoryFn
See
Param | Type |
---|---|
[optionsOrFn] | addonOptions | optionsCallback |
Example
import type { Meta, StoryObj } from '@storybook/react';
import { withConsole } from '@hishprorg/fugit-a';
const meta: Meta<typeof Button> = {
title: 'Example/Button',
component: Button,
};
export default meta;
type Story = StoryObj<typeof Button>;
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
onClick: () => console.log(['Data:', 1, 3, 4]),
},
};
// Action Logger Panel:
// withConsole/with Log: ["Data:", 1, 3, 4]
Object
This options could be passed to withConsole or setConsoleOptions
Kind: inner typedef of @hishprorg/fugit-a
Properties
Name | Type | Default | Description |
---|---|---|---|
[panelExclude] | [ 'Array' ].<RegExp> | [/[HMR]/] | Optional. Anything matched to at least one of regular expressions will be excluded from output to Action Logger Panel |
[panelInclude] | [ 'Array' ].<RegExp> | [] | Optional. If set, only matched outputs will be shown in Action Logger. Higher priority than panelExclude . |
[consoleExclude] | [ 'Array' ].<RegExp> | [] | Optional. Anything matched to at least one of regular expressions will be excluded from DevTool console output |
[consoleInclude] | [ 'Array' ].<RegExp> | [] | Optional. If set, only matched outputs will be shown in console. Higher priority than consoleExclude . |
[log] | string | "console" | Optional. The marker to display console.log outputs in Action Logger |
[warn] | string | "warn" | Optional. The marker to display warnings in Action Logger |
[error] | string | "error" | Optional. The marker to display errors in Action Logger |
addonOptions
This callback could be passed to setConsoleOptions or withConsole
Kind: inner typedef of @hishprorg/fugit-a
Returns: addonOptions
- - new addonOptions
Param | Type | Description |
---|---|---|
currentOptions | addonOptions | the current addonOptions |
Example
import { withConsole } from `@hishprorg/fugit-a`;
const optionsCallback = (options) => ({panelExclude: [...options.panelExclude, /Warning/]});
export default {
title: 'Button',
decorators: [withConsole(optionsCallback)],
};
yarn storybook
runs example Storybook. Then you can edit source code located in the src
folder and example storybook in
the stories
folder.
Run yarn test
.
Run yarn tdd
.
After running tests you can explore coverage details in .coverage/lcov-report/index.html
If you're using VSCode you can debug tests and source by launching Jest Tests
task from Debug Menu. It allows to set
breakpoints in *.test.js
and *.js
files.
Please, don't edit this README.md
directly. Run yarn dev:docs
and change docs/readme.hbs
and JSDoc comments
withing src
instead.
FAQs
security holding package
The npm package @hishprorg/fugit-a receives a total of 1 weekly downloads. As such, @hishprorg/fugit-a popularity was classified as not popular.
We found that @hishprorg/fugit-a demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.