@storybook/core
Advanced tools
Comparing version 8.3.0-alpha.6 to 8.3.0-alpha.7
@@ -58,4 +58,5 @@ interface Config { | ||
/** | ||
* Sends `event` to the associated window. If the window does not yet exist | ||
* the event will be stored in a buffer and sent when the window exists. | ||
* Sends `event` to the associated window. If the window does not yet exist the event will be | ||
* stored in a buffer and sent when the window exists. | ||
* | ||
* @param event | ||
@@ -94,5 +95,7 @@ */ | ||
* Creates a new browser channel instance. | ||
* | ||
* @param {Options} options - The options object. | ||
* @param {Page} options.page - page identifier. | ||
* @param {ChannelTransport[]} [options.extraTransports=[]] - An optional array of extra channel transports. | ||
* @param {Page} options.page - Page identifier. | ||
* @param {ChannelTransport[]} [options.extraTransports=[]] - An optional array of extra channel | ||
* transports. Default is `[]` | ||
* @returns {Channel} - The new channel instance. | ||
@@ -99,0 +102,0 @@ */ |
@@ -1280,4 +1280,5 @@ var Qt = Object.create; | ||
/** | ||
* Sends `event` to the associated window. If the window does not yet exist | ||
* the event will be stored in a buffer and sent when the window exists. | ||
* Sends `event` to the associated window. If the window does not yet exist the event will be | ||
* stored in a buffer and sent when the window exists. | ||
* | ||
* @param event | ||
@@ -1284,0 +1285,0 @@ */ |
@@ -14,5 +14,3 @@ import * as _storybook_core_common from '@storybook/core/common'; | ||
declare const externalFrameworks: ExternalFramework[]; | ||
/** | ||
* @deprecated Please use `SupportedFrameworks` from `@storybook/types` instead | ||
*/ | ||
/** @deprecated Please use `SupportedFrameworks` from `@storybook/types` instead */ | ||
type SupportedRenderers = SupportedRenderers$1; | ||
@@ -50,2 +48,5 @@ declare const SUPPORTED_RENDERERS: SupportedRenderers[]; | ||
} | ||
declare enum CommunityBuilder { | ||
Rsbuild = "rsbuild" | ||
} | ||
declare const compilerNameToCoreCompiler: Record<string, CoreWebpackCompilers>; | ||
@@ -66,3 +67,3 @@ declare const builderNameToCoreBuilder: Record<string, CoreBuilder>; | ||
preset: ProjectType; | ||
/** will be checked both against dependencies and devDependencies */ | ||
/** Will be checked both against dependencies and devDependencies */ | ||
dependencies?: string[] | { | ||
@@ -80,5 +81,5 @@ [dependency: string]: (version: string) => boolean; | ||
* | ||
* This has to be an array sorted in order of specificity/priority. | ||
* Reason: both REACT and WEBPACK_REACT have react as dependency, | ||
* therefore WEBPACK_REACT has to come first, as it's more specific. | ||
* This has to be an array sorted in order of specificity/priority. Reason: both REACT and | ||
* WEBPACK_REACT have react as dependency, therefore WEBPACK_REACT has to come first, as it's more | ||
* specific. | ||
*/ | ||
@@ -91,4 +92,4 @@ declare const supportedTemplates: TemplateConfiguration[]; | ||
/** | ||
* Attempts to detect which builder to use, by searching for a vite config file or webpack installation. | ||
* If neither are found it will choose the default builder based on the project type. | ||
* Attempts to detect which builder to use, by searching for a vite config file or webpack | ||
* installation. If neither are found it will choose the default builder based on the project type. | ||
* | ||
@@ -109,9 +110,13 @@ * @returns CoreBuilder | ||
/** | ||
* Detect if any babel dependencies need to be added to the project | ||
* This is currently used by react-native generator | ||
* @param {Object} packageJson The current package.json so we can inspect its contents | ||
* @returns {Array} Contains the packages and versions that need to be installed | ||
* Detect if any babel dependencies need to be added to the project This is currently used by | ||
* react-native generator | ||
* | ||
* @example | ||
* const babelDependencies = await getBabelDependencies(packageManager, npmOptions, packageJson); | ||
* // you can then spread the result when using installDependencies | ||
* | ||
* ```ts | ||
* const babelDependencies = await getBabelDependencies( | ||
* packageManager, | ||
* npmOptions, | ||
* packageJson | ||
* ); // you can then spread the result when using installDependencies | ||
* installDependencies(npmOptions, [ | ||
@@ -121,2 +126,6 @@ * `@storybook/react@${storybookVersion}`, | ||
* ]); | ||
* ``` | ||
* | ||
* @param {Object} packageJson The current package.json so we can inspect its contents | ||
* @returns {Array} Contains the packages and versions that need to be installed | ||
*/ | ||
@@ -133,7 +142,5 @@ declare function getBabelDependencies(packageManager: JsPackageManager, packageJson: PackageJsonWithDepsAndDevDeps): Promise<string[]>; | ||
}; | ||
/** | ||
* @deprecated Please use `frameworkToRenderer` from `@storybook/core-common` instead | ||
*/ | ||
declare const frameworkToRenderer: Record<"react-native" | "react" | "vue3" | "angular" | "html" | "web-components" | "ember" | "svelte" | "preact" | "server" | "qwik" | "solid" | "experimental-nextjs-vite" | "html-vite" | "html-webpack5" | "nextjs" | "preact-vite" | "preact-webpack5" | "react-vite" | "react-webpack5" | "server-webpack5" | "svelte-vite" | "svelte-webpack5" | "sveltekit" | "vue3-vite" | "vue3-webpack5" | "web-components-vite" | "web-components-webpack5", "vue" | SupportedRenderers$1>; | ||
declare const frameworkToDefaultBuilder: Record<SupportedFrameworks, CoreBuilder>; | ||
/** @deprecated Please use `frameworkToRenderer` from `@storybook/core-common` instead */ | ||
declare const frameworkToRenderer: Record<"react-native" | "react" | "vue3" | "angular" | "html" | "web-components" | "ember" | "svelte" | "preact" | "server" | "qwik" | "solid" | "experimental-nextjs-vite" | "html-vite" | "html-webpack5" | "nextjs" | "preact-vite" | "preact-webpack5" | "react-vite" | "react-webpack5" | "server-webpack5" | "svelte-vite" | "svelte-webpack5" | "sveltekit" | "vue3-vite" | "vue3-webpack5" | "web-components-vite" | "web-components-webpack5" | "react-rsbuild" | "vue3-rsbuild", "vue" | SupportedRenderers$1>; | ||
declare const frameworkToDefaultBuilder: Record<SupportedFrameworks, CoreBuilder | CommunityBuilder>; | ||
declare function copyTemplateFiles({ packageManager, renderer, language, destination, commonAssetsDir, }: CopyTemplateFilesOptions): Promise<void>; | ||
@@ -203,2 +210,2 @@ declare function adjustTemplate(templatePath: string, templateData: Record<string, any>): Promise<void>; | ||
export { ANGULAR_JSON_PATH, AngularJSON, type Builder, CoreBuilder, CoreWebpackCompilers, type ExternalFramework, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, SUPPORTED_RENDERERS, SupportedLanguage, type SupportedRenderers, type TemplateConfiguration, type TemplateMatcher, addToDevDependenciesIfNotPresent, adjustTemplate, builderNameToCoreBuilder, coerceSemver, compilerNameToCoreCompiler, compoDocPreviewPrefix, configureEslintPlugin, copyTemplate, copyTemplateFiles, detect, detectBuilder, detectFrameworkPreset, detectLanguage, detectPnp, externalFrameworks, extractEslintInfo, findEslintFile, frameworkToDefaultBuilder, frameworkToRenderer, getBabelDependencies, getRendererDir, getStorybookVersionSpecifier, hasStorybookDependencies, installableProjectTypes, isNxProject, isStorybookInstantiated, normalizeExtends, promptForCompoDocs, readFileAsJson, suggestESLintPlugin, supportedTemplates, unsupportedTemplate, writeFileAsJson }; | ||
export { ANGULAR_JSON_PATH, AngularJSON, type Builder, CommunityBuilder, CoreBuilder, CoreWebpackCompilers, type ExternalFramework, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, SUPPORTED_RENDERERS, SupportedLanguage, type SupportedRenderers, type TemplateConfiguration, type TemplateMatcher, addToDevDependenciesIfNotPresent, adjustTemplate, builderNameToCoreBuilder, coerceSemver, compilerNameToCoreCompiler, compoDocPreviewPrefix, configureEslintPlugin, copyTemplate, copyTemplateFiles, detect, detectBuilder, detectFrameworkPreset, detectLanguage, detectPnp, externalFrameworks, extractEslintInfo, findEslintFile, frameworkToDefaultBuilder, frameworkToRenderer, getBabelDependencies, getRendererDir, getStorybookVersionSpecifier, hasStorybookDependencies, installableProjectTypes, isNxProject, isStorybookInstantiated, normalizeExtends, promptForCompoDocs, readFileAsJson, suggestESLintPlugin, supportedTemplates, unsupportedTemplate, writeFileAsJson }; |
@@ -103,13 +103,8 @@ import * as _storybook_core_types from '@storybook/core/types'; | ||
* Valid inputs: | ||
* - '@storybook/addon-actions/manager' | ||
* => { type: 'virtual', item } | ||
* | ||
* - '@storybook/addon-docs/preset' | ||
* => { type: 'presets', item } | ||
* | ||
* - '@storybook/addon-docs' | ||
* => { type: 'presets', item: '@storybook/addon-docs/preset' } | ||
* | ||
* - { name: '@storybook/addon-docs(/preset)?', options: { ... } } | ||
* => { type: 'presets', item: { name: '@storybook/addon-docs/preset', options } } | ||
* - `'@storybook/addon-actions/manager' => { type: 'virtual', item }` | ||
* - `'@storybook/addon-docs/preset' => { type: 'presets', item }` | ||
* - `'@storybook/addon-docs' => { type: 'presets', item: '@storybook/addon-docs/preset' }` | ||
* - `{ name: '@storybook/addon-docs(/preset)?', options: { } } => { type: 'presets', item: { name: | ||
* '@storybook/addon-docs/preset', options } }` | ||
*/ | ||
@@ -510,3 +505,3 @@ declare const resolveAddonName: (configDir: string, name: string, options: any) => CoreCommon_ResolvedAddonPreset | CoreCommon_ResolvedAddonVirtual | undefined; | ||
* @param pkg A string like `@storybook/cli`, `react` or `react@^16` | ||
* @return A tuple of 2 elements: [packageName, packageVersion] | ||
* @returns A tuple of 2 elements: [packageName, packageVersion] | ||
*/ | ||
@@ -524,15 +519,13 @@ declare function getPackageDetails(pkg: string): [string, string?]; | ||
abstract getPackageJSON(packageName: string, basePath?: string): Promise<PackageJson | null>; | ||
/** | ||
* Get the INSTALLED version of a package from the package.json file | ||
*/ | ||
/** Get the INSTALLED version of a package from the package.json file */ | ||
getPackageVersion(packageName: string, basePath?: string | undefined): Promise<string | null>; | ||
constructor(options?: JsPackageManagerOptions); | ||
/** Detect whether Storybook gets initialized in a monorepository/workspace environment | ||
* The cwd doesn't have to be the root of the monorepo, it can be a subdirectory | ||
* @returns true, if Storybook is initialized inside a monorepository/workspace | ||
/** | ||
* Detect whether Storybook gets initialized in a mono-repository/workspace environment The cwd | ||
* doesn't have to be the root of the monorepo, it can be a subdirectory | ||
* | ||
* @returns `true`, if Storybook is initialized inside a mono-repository/workspace | ||
*/ | ||
isStorybookInMonorepo(): boolean; | ||
/** | ||
* Install dependencies listed in `package.json` | ||
*/ | ||
/** Install dependencies listed in `package.json` */ | ||
installDependencies(): Promise<void>; | ||
@@ -543,4 +536,4 @@ packageJsonPath(): string; | ||
/** | ||
* Read the `package.json` file available in the directory the command was call from | ||
* If there is no `package.json` it will create one. | ||
* Read the `package.json` file available in the directory the command was call from If there is | ||
* no `package.json` it will create one. | ||
*/ | ||
@@ -552,5 +545,5 @@ retrievePackageJson(): Promise<PackageJsonWithDepsAndDevDeps>; | ||
* | ||
* @param {Object} options contains `skipInstall`, `packageJson` and `installAsDevDependencies` which we use to determine how we install packages. | ||
* @param {Array} dependencies contains a list of packages to add. | ||
* @example | ||
* | ||
* ```ts | ||
* addDependencies(options, [ | ||
@@ -562,2 +555,7 @@ * `@storybook/react@${storybookVersion}`, | ||
* ]); | ||
* ``` | ||
* | ||
* @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies` | ||
* which we use to determine how we install packages. | ||
* @param {Array} dependencies Contains a list of packages to add. | ||
*/ | ||
@@ -572,9 +570,11 @@ addDependencies(options: { | ||
* | ||
* @param {Object} options contains `skipInstall`, `packageJson` and `installAsDevDependencies` which we use to determine how we install packages. | ||
* @param {Array} dependencies contains a list of packages to remove. | ||
* @example | ||
* removeDependencies(options, [ | ||
* `@storybook/react`, | ||
* `@storybook/addon-actions`, | ||
* ]); | ||
* | ||
* ```ts | ||
* removeDependencies(options, [`@storybook/react`, `@storybook/addon-actions`]); | ||
* ``` | ||
* | ||
* @param {Object} options Contains `skipInstall`, `packageJson` and `installAsDevDependencies` | ||
* which we use to determine how we install packages. | ||
* @param {Array} dependencies Contains a list of packages to remove. | ||
*/ | ||
@@ -588,6 +588,7 @@ removeDependencies(options: { | ||
* | ||
* For packages in the storybook monorepo, when the latest version is equal to the version of the current CLI | ||
* the version is not added to the string. | ||
* For packages in the storybook monorepo, when the latest version is equal to the version of the | ||
* current CLI the version is not added to the string. | ||
* | ||
* When a package is in the monorepo, and the version is not equal to the CLI version, the version is taken from the versions.ts file and added to the string. | ||
* When a package is in the monorepo, and the version is not equal to the CLI version, the version | ||
* is taken from the versions.ts file and added to the string. | ||
* | ||
@@ -598,4 +599,4 @@ * @param packages | ||
/** | ||
* Return an array of string standing for the latest version of the input packages. | ||
* To be able to identify which version goes with which package the order of the input array is keep. | ||
* Return an array of string standing for the latest version of the input packages. To be able to | ||
* identify which version goes with which package the order of the input array is keep. | ||
* | ||
@@ -606,6 +607,7 @@ * @param packageNames | ||
/** | ||
* Return the latest version of the input package available on npmjs registry. | ||
* If constraint are provided it return the latest version matching the constraints. | ||
* Return the latest version of the input package available on npmjs registry. If constraint are | ||
* provided it return the latest version matching the constraints. | ||
* | ||
* For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file directly | ||
* For `@storybook/*` packages the latest version is retrieved from `cli/src/versions.json` file | ||
* directly | ||
* | ||
@@ -617,4 +619,4 @@ * @param packageName The name of the package | ||
/** | ||
* Get the latest version of the package available on npmjs.com. | ||
* If constraint is set then it returns a version satisfying it, otherwise the latest version available is returned. | ||
* Get the latest version of the package available on npmjs.com. If constraint is set then it | ||
* returns a version satisfying it, otherwise the latest version available is returned. | ||
* | ||
@@ -656,5 +658,3 @@ * @param packageName Name of the package | ||
}): string; | ||
/** | ||
* Returns the installed (within node_modules or pnp zip) version of a specified package | ||
*/ | ||
/** Returns the installed (within node_modules or pnp zip) version of a specified package */ | ||
getInstalledVersion(packageName: string): Promise<string | null>; | ||
@@ -673,9 +673,7 @@ executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & { | ||
}, cwd?: string): JsPackageManager; | ||
/** | ||
* Look up map of package manager proxies by name | ||
*/ | ||
/** Look up map of package manager proxies by name */ | ||
private static PROXY_MAP; | ||
/** | ||
* Infer the package manager based on the command the user is running. | ||
* Each package manager sets the `npm_config_user_agent` environment variable with its name and version e.g. "npm/7.24.0" | ||
* Infer the package manager based on the command the user is running. Each package manager sets | ||
* the `npm_config_user_agent` environment variable with its name and version e.g. "npm/7.24.0" | ||
* Which is really useful when invoking commands via npx/pnpx/yarn create/etc. | ||
@@ -691,17 +689,17 @@ */ | ||
/** | ||
File extension. | ||
Mutually exclusive with the `name` option. | ||
_You usually won't need this option. Specify it only when actually needed._ | ||
*/ | ||
* File extension. | ||
* | ||
* Mutually exclusive with the `name` option. | ||
* | ||
* _You usually won't need this option. Specify it only when actually needed._ | ||
*/ | ||
readonly extension?: string; | ||
}, { | ||
/** | ||
Filename. | ||
Mutually exclusive with the `extension` option. | ||
_You usually won't need this option. Specify it only when actually needed._ | ||
*/ | ||
* Filename. | ||
* | ||
* Mutually exclusive with the `extension` option. | ||
* | ||
* _You usually won't need this option. Specify it only when actually needed._ | ||
*/ | ||
readonly name?: string; | ||
@@ -712,6 +710,6 @@ }>; | ||
/** | ||
* Given a package manager, returns the coerced version of Storybook. | ||
* It tries to find renderer packages in the project and returns the coerced version of the first one found. | ||
* Example: | ||
* If @storybook/react version 8.0.0-alpha.14 is installed, it returns the coerced version 8.0.0 | ||
* Given a package manager, returns the coerced version of Storybook. It tries to find renderer | ||
* packages in the project and returns the coerced version of the first one found. Example: If | ||
* | ||
* @storybook/react version 8.0.0-alpha.14 is installed, it returns the coerced version 8.0.0 | ||
*/ | ||
@@ -721,33 +719,34 @@ declare function getCoercedStorybookVersion(packageManager: JsPackageManager): Promise<string | null>; | ||
/** | ||
* Given a file name, creates an object with utilities to manage a log file. | ||
* It creates a temporary log file which you can manage with the returned functions. | ||
* You can then decide whether to move the log file to the users project, or remove it. | ||
* Given a file name, creates an object with utilities to manage a log file. It creates a temporary | ||
* log file which you can manage with the returned functions. You can then decide whether to move | ||
* the log file to the users project, or remove it. | ||
* | ||
* @example | ||
* ``` | ||
* const { logStream, moveLogFile, removeLogFile, clearLogFile, readLogFile } = await createLogStream('my-log-file.log'); | ||
* | ||
* // SCENARIO 1: | ||
* // you can write custom messages to generate a log file | ||
* logStream.write('my log message'); | ||
* await moveLogFile(); | ||
* ```ts | ||
* const { logStream, moveLogFile, removeLogFile, clearLogFile, readLogFile } = | ||
* await createLogStream('my-log-file.log'); | ||
* | ||
* // SCENARIO 2: | ||
* // or you can pass it to stdio and capture the output of that command | ||
* try { | ||
* await this.executeCommand({ | ||
* command: 'pnpm', | ||
* args: ['info', packageName, ...args], | ||
* // do not output to the user, and send stdio and stderr to log file | ||
* stdio: ['ignore', logStream, logStream] | ||
* }); | ||
* } catch (err) { | ||
* // do something with the log file content | ||
* const output = await readLogFile(); | ||
* // move the log file to the users project | ||
* await moveLogFile(); | ||
* } | ||
* // success, no need to keep the log file | ||
* await removeLogFile(); | ||
* // SCENARIO 1: | ||
* // you can write custom messages to generate a log file | ||
* logStream.write('my log message'); | ||
* await moveLogFile(); | ||
* | ||
* // SCENARIO 2: | ||
* // or you can pass it to stdio and capture the output of that command | ||
* try { | ||
* await this.executeCommand({ | ||
* command: 'pnpm', | ||
* args: ['info', packageName, ...args], | ||
* // do not output to the user, and send stdio and stderr to log file | ||
* stdio: ['ignore', logStream, logStream], | ||
* }); | ||
* } catch (err) { | ||
* // do something with the log file content | ||
* const output = await readLogFile(); | ||
* // move the log file to the users project | ||
* await moveLogFile(); | ||
* } | ||
* // success, no need to keep the log file | ||
* await removeLogFile(); | ||
* ``` | ||
@@ -795,12 +794,14 @@ */ | ||
/** | ||
* Framework can be a string or an object. This utility always returns the string name. | ||
*/ | ||
/** Framework can be a string or an object. This utility always returns the string name. */ | ||
declare function getFrameworkName(options: Options$2): Promise<string>; | ||
/** | ||
* Extracts the proper framework name from the given framework field. | ||
* The framework field can be the framework package name or a path to the framework package. | ||
* Extracts the proper framework name from the given framework field. The framework field can be the | ||
* framework package name or a path to the framework package. | ||
* | ||
* @example | ||
* extractProperFrameworkName('/path/to/@storybook/angular') // => '@storybook/angular' | ||
* extractProperFrameworkName('@third-party/framework') // => '@third-party/framework' | ||
* | ||
* ```ts | ||
* ExtractProperFrameworkName('/path/to/@storybook/angular'); // => '@storybook/angular' | ||
* extractProperFrameworkName('@third-party/framework'); // => '@third-party/framework' | ||
* ``` | ||
*/ | ||
@@ -810,4 +811,4 @@ declare const extractProperFrameworkName: (framework: string) => string; | ||
/** | ||
* Render is set as a string on core. It must be set by the framework | ||
* It falls back to the framework name if not set | ||
* Render is set as a string on core. It must be set by the framework It falls back to the framework | ||
* name if not set | ||
*/ | ||
@@ -817,8 +818,13 @@ declare function getRendererName(options: Options$2): Promise<string>; | ||
* Extracts the proper renderer name from the given framework name. | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* extractProperRendererNameFromFramework('@storybook/react'); // => 'react' | ||
* extractProperRendererNameFromFramework('@storybook/angular'); // => 'angular' | ||
* extractProperRendererNameFromFramework('@third-party/framework'); // => null | ||
* ``` | ||
* | ||
* @param frameworkName The name of the framework. | ||
* @returns The name of the renderer. | ||
* @example | ||
* extractProperRendererNameFromFramework('@storybook/react') // => 'react' | ||
* extractProperRendererNameFromFramework('@storybook/angular') // => 'angular' | ||
* extractProperRendererNameFromFramework('@third-party/framework') // => null | ||
*/ | ||
@@ -854,7 +860,8 @@ declare function extractProperRendererNameFromFramework(frameworkName: string): Promise<_storybook_core_types.SupportedRenderers | "vue" | null>; | ||
/** | ||
* Return a string corresponding to template filled with bindings using following pattern: | ||
* For each (key, value) of `bindings` replace, in template, `{{key}}` by escaped version of `value` | ||
* Return a string corresponding to template filled with bindings using following pattern: For each | ||
* (key, value) of `bindings` replace, in template, `{{key}}` by escaped version of `value` | ||
* | ||
* @param template {String} Template with `{{binding}}` | ||
* @param bindings {Object} key-value object use to fill the template, `{{key}}` will be replaced by `escaped(value)` | ||
* @param bindings {Object} key-value object use to fill the template, `{{key}}` will be replaced by | ||
* `escaped(value)` | ||
* @returns {String} Filled template | ||
@@ -912,5 +919,3 @@ */ | ||
declare const nodePathsToArray: (nodePath: string) => string[]; | ||
/** | ||
* Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` | ||
*/ | ||
/** Ensures that a path starts with `./` or `../`, or is entirely `.` or `..` */ | ||
declare function normalizeStoryPath(filename: string): string; | ||
@@ -923,4 +928,7 @@ | ||
* | ||
* Usage: | ||
* - sb remove @storybook/addon-links | ||
* @example | ||
* | ||
* ```sh | ||
* sb remove @storybook/addon-links | ||
* ``` | ||
*/ | ||
@@ -933,7 +941,8 @@ declare function removeAddon(addon: string, options?: { | ||
* Get the path of the file or directory with input name inside the Storybook cache directory: | ||
* - `node_modules/.cache/storybook/{directoryName}` in a Node.js project or npm package | ||
* - `.cache/storybook/{directoryName}` otherwise | ||
* | ||
* - `node_modules/.cache/storybook/{directoryName}` in a Node.js project or npm package | ||
* - `.cache/storybook/{directoryName}` otherwise | ||
* | ||
* @param fileOrDirectoryName {string} Name of the file or directory | ||
* @return {string} Absolute path to the file or directory | ||
* @returns {string} Absolute path to the file or directory | ||
*/ | ||
@@ -951,5 +960,3 @@ declare function resolvePathInStorybookCache(fileOrDirectoryName: string, sub?: string): string; | ||
/** | ||
* Mimicking the satisfies operator until we can upgrade to TS4.9 | ||
*/ | ||
/** Mimicking the satisfies operator until we can upgrade to TS4.9 */ | ||
declare function satisfies<A>(): <T extends A>(x: T) => T; | ||
@@ -960,4 +967,5 @@ | ||
/** | ||
* Format the content of a file using prettier. | ||
* If prettier is not available in the user's project, it will fallback to use editorconfig settings if available and formats the file by a prettier-fallback. | ||
* Format the content of a file using prettier. If prettier is not available in the user's project, | ||
* it will fallback to use editorconfig settings if available and formats the file by a | ||
* prettier-fallback. | ||
*/ | ||
@@ -983,5 +991,3 @@ declare function formatFileContent(filePath: string, content: string): Promise<string>; | ||
/** | ||
* Replaces the path separator with forward slashes | ||
*/ | ||
/** Replaces the path separator with forward slashes */ | ||
declare const posix: (localPath: string, seperator?: string) => string; | ||
@@ -988,0 +994,0 @@ |
@@ -635,5 +635,5 @@ import * as React$1 from 'react'; | ||
/** | ||
* these types are copied from `react-textarea-autosize`. | ||
* I copied them because of https://github.com/storybookjs/storybook/issues/18734 | ||
* Maybe there's some bug in `tsup` or `react-textarea-autosize`? | ||
* These types are copied from `react-textarea-autosize`. I copied them because of | ||
* https://github.com/storybookjs/storybook/issues/18734 Maybe there's some bug in `tsup` or | ||
* `react-textarea-autosize`? | ||
*/ | ||
@@ -957,2 +957,3 @@ type TextareaPropsRaw = React__default.TextareaHTMLAttributes<HTMLTextAreaElement>; | ||
* If `true`, a click outside the trigger element closes the tooltip | ||
* | ||
* @default false | ||
@@ -1093,6 +1094,3 @@ */ | ||
} & TabButtonProps, {}, {}>; | ||
/** | ||
* @deprecated | ||
* This component will be removed in Storybook 9.0 | ||
* */ | ||
/** @deprecated This component will be removed in Storybook 9.0 */ | ||
declare const IconButtonSkeleton: () => React__default.JSX.Element; | ||
@@ -1145,5 +1143,5 @@ | ||
/** | ||
* @deprecated No longer used, will be removed in Storybook 9.0 | ||
* Please use the `@storybook/icons` package instead. | ||
* */ | ||
* @deprecated No longer used, will be removed in Storybook 9.0 Please use the `@storybook/icons` | ||
* package instead. | ||
*/ | ||
declare const Icons: ({ icon, useSymbol, __suppressDeprecationWarning, ...props }: IconsProps) => React__default.JSX.Element | null; | ||
@@ -1154,5 +1152,5 @@ interface SymbolsProps { | ||
/** | ||
* @deprecated No longer used, will be removed in Storybook 9.0 | ||
* Please use the `@storybook/icons` package instead. | ||
* */ | ||
* @deprecated No longer used, will be removed in Storybook 9.0 Please use the `@storybook/icons` | ||
* package instead. | ||
*/ | ||
declare const Symbols: React__default.NamedExoticComponent<SymbolsProps>; | ||
@@ -1400,5 +1398,4 @@ declare const icons: { | ||
* | ||
* We can't style individual elements (e.g. h1, h2, etc.) in here | ||
* because the CSS specificity is too high, so those styles can too | ||
* easily override child elements that are not expecting it. | ||
* We can't style individual elements (e.g. h1, h2, etc.) in here because the CSS specificity is too | ||
* high, so those styles can too easily override child elements that are not expecting it. | ||
*/ | ||
@@ -1405,0 +1402,0 @@ declare const ResetWrapper: _storybook_core_theming.StyledComponent<{ |
@@ -147,15 +147,12 @@ import { StrictArgTypes, Renderer, StoryContextForEnhancers, Options } from '@storybook/core/types'; | ||
* Use the CODE logic if: | ||
* - the user has set a custom source snippet in `docs.source.code` story parameter | ||
* - the story is not an args-based story | ||
* | ||
* - The user has set a custom source snippet in `docs.source.code` story parameter | ||
* - The story is not an args-based story | ||
* | ||
* Use the DYNAMIC rendered snippet if the story is an args story | ||
*/ | ||
AUTO = "auto", | ||
/** | ||
* Render the code extracted by source-loader | ||
*/ | ||
/** Render the code extracted by source-loader */ | ||
CODE = "code", | ||
/** | ||
* Render dynamically-rendered source snippet from the story's virtual DOM (currently React only) | ||
*/ | ||
/** Render dynamically-rendered source snippet from the story's virtual DOM (currently React only) */ | ||
DYNAMIC = "dynamic" | ||
@@ -162,0 +159,0 @@ } |
@@ -28,2 +28,3 @@ import React, { ReactNode, FC, Component, ReactElement } from 'react'; | ||
* Adds an addon to the addon store. | ||
* | ||
* @param {string} id - The id of the addon. | ||
@@ -86,6 +87,8 @@ * @param {Addon_Type} addon - The addon to add. | ||
* Returns a collection of elements of a specific type. | ||
* @protected This is used internally in storybook's manager. | ||
* | ||
* @template T - The type of the elements in the collection. | ||
* @param {Addon_Types | Addon_TypesEnum.experimental_PAGE} type - The type of the elements to retrieve. | ||
* @param {Addon_Types | Addon_TypesEnum.experimental_PAGE} type - The type of the elements to | ||
* retrieve. | ||
* @returns {Addon_Collection<T>} - A collection of elements of the specified type. | ||
* @protected This is used internally in storybook's manager. | ||
*/ | ||
@@ -95,2 +98,3 @@ getElements: <T extends Addon_Types | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP = Addon_Types>(type: T) => Addon_Collection<Addon_TypesMapping[T]>; | ||
* Returns the id of the currently selected panel. | ||
* | ||
* @returns {string} - The ID of the currently selected panel. | ||
@@ -101,2 +105,3 @@ */ | ||
* Sets the currently selected panel via it's ID. | ||
* | ||
* @param {string} panelName - The ID of the panel to select. | ||
@@ -108,7 +113,9 @@ * @returns {void} | ||
* Sets the state of an addon with the given ID. | ||
* | ||
* @deprecated This API might get dropped, if you are using this, please file an issue. | ||
* @template S - The type of the addon state. | ||
* @param {string} addonId - The ID of the addon to set the state for. | ||
* @param {S | API_StateMerger<S>} newStateOrMerger - The new state to set, or a function which receives the current state and returns the new state. | ||
* @param {S | API_StateMerger<S>} newStateOrMerger - The new state to set, or a function which | ||
* receives the current state and returns the new state. | ||
* @param {Options} [options] - Optional options for the state update. | ||
* @deprecated This API might get dropped, if you are using this, please file an issue. | ||
* @returns {Promise<S>} - A promise that resolves with the new state after it has been set. | ||
@@ -119,5 +126,6 @@ */ | ||
* Returns the state of an addon with the given ID. | ||
* | ||
* @deprecated This API might get dropped, if you are using this, please file an issue. | ||
* @template S - The type of the addon state. | ||
* @param {string} addonId - The ID of the addon to get the state for. | ||
* @deprecated This API might get dropped, if you are using this, please file an issue. | ||
* @returns {S} - The state of the addon with the given ID. | ||
@@ -131,2 +139,3 @@ */ | ||
* Returns the channel object. | ||
* | ||
* @protected Please do not use, it's for internal use only. | ||
@@ -136,5 +145,7 @@ */ | ||
/** | ||
* Adds a listener to the channel for the given event type. | ||
* Returns a function that can be called to remove the listener. | ||
* @param type - The event type to listen for. If using a core event, import it from `@storybook/core-events`. | ||
* Adds a listener to the channel for the given event type. Returns a function that can be called | ||
* to remove the listener. | ||
* | ||
* @param type - The event type to listen for. If using a core event, import it from | ||
* `@storybook/core-events`. | ||
* @param handler - The callback function to be called when the event is emitted. | ||
@@ -146,3 +157,5 @@ * @returns A function that can be called to remove the listener. | ||
* Removes a listener from the channel for the given event type. | ||
* @param type - The event type to remove the listener from. If using a core event, import it from `@storybook/core-events`. | ||
* | ||
* @param type - The event type to remove the listener from. If using a core event, import it from | ||
* `@storybook/core-events`. | ||
* @param handler - The callback function to be removed. | ||
@@ -153,3 +166,5 @@ */ | ||
* Emits an event on the channel for the given event type. | ||
* @param type - The event type to emit. If using a core event, import it from `@storybook/core-events`. | ||
* | ||
* @param type - The event type to emit. If using a core event, import it from | ||
* `@storybook/core-events`. | ||
* @param args - The arguments to pass to the event listener. | ||
@@ -160,3 +175,5 @@ */ | ||
* Adds a one-time listener to the channel for the given event type. | ||
* @param type - The event type to listen for. If using a core event, import it from `@storybook/core-events`. | ||
* | ||
* @param type - The event type to listen for. If using a core event, import it from | ||
* `@storybook/core-events`. | ||
* @param handler - The callback function to be called when the event is emitted. | ||
@@ -176,2 +193,3 @@ */ | ||
* Returns the current globals, which is the user globals overlaid with the story globals | ||
* | ||
* @returns {Globals} The current globals. | ||
@@ -182,7 +200,8 @@ */ | ||
* Returns the current globals, as set by the user (a story may have override values) | ||
* | ||
* @returns {Globals} The current user globals. | ||
*/ | ||
getUserGlobals: () => Globals /** | ||
/** | ||
* Returns the current globals, as set by the story | ||
* /** Returns the current globals, as set by the story | ||
* | ||
* @returns {Globals} The current story globals. | ||
@@ -192,2 +211,3 @@ */; | ||
* Returns the globalTypes, as defined at the project level. | ||
* | ||
* @returns {GlobalTypes} The globalTypes. | ||
@@ -198,2 +218,3 @@ */; | ||
* Updates the current globals with the provided new globals. | ||
* | ||
* @param {Globals} newGlobals - The new globals to update with. | ||
@@ -214,3 +235,5 @@ * @returns {void} | ||
* Toggles the fullscreen mode of the Storybook UI. | ||
* @param toggled - Optional boolean value to set the fullscreen mode to. If not provided, it will toggle the current state. | ||
* | ||
* @param toggled - Optional boolean value to set the fullscreen mode to. If not provided, it will | ||
* toggle the current state. | ||
*/ | ||
@@ -220,3 +243,5 @@ toggleFullscreen: (toggled?: boolean) => void; | ||
* Toggles the visibility of the panel in the Storybook UI. | ||
* @param toggled - Optional boolean value to set the panel visibility to. If not provided, it will toggle the current state. | ||
* | ||
* @param toggled - Optional boolean value to set the panel visibility to. If not provided, it | ||
* will toggle the current state. | ||
*/ | ||
@@ -226,3 +251,5 @@ togglePanel: (toggled?: boolean) => void; | ||
* Toggles the position of the panel in the Storybook UI. | ||
* @param position - Optional string value to set the panel position to. If not provided, it will toggle between 'bottom' and 'right'. | ||
* | ||
* @param position - Optional string value to set the panel position to. If not provided, it will | ||
* toggle between 'bottom' and 'right'. | ||
*/ | ||
@@ -232,3 +259,5 @@ togglePanelPosition: (position?: API_PanelPositions) => void; | ||
* Toggles the visibility of the navigation bar in the Storybook UI. | ||
* @param toggled - Optional boolean value to set the navigation bar visibility to. If not provided, it will toggle the current state. | ||
* | ||
* @param toggled - Optional boolean value to set the navigation bar visibility to. If not | ||
* provided, it will toggle the current state. | ||
*/ | ||
@@ -238,3 +267,5 @@ toggleNav: (toggled?: boolean) => void; | ||
* Toggles the visibility of the toolbar in the Storybook UI. | ||
* @param toggled - Optional boolean value to set the toolbar visibility to. If not provided, it will toggle the current state. | ||
* | ||
* @param toggled - Optional boolean value to set the toolbar visibility to. If not provided, it | ||
* will toggle the current state. | ||
*/ | ||
@@ -244,20 +275,13 @@ toggleToolbar: (toggled?: boolean) => void; | ||
* Sets the options for the Storybook UI. | ||
* | ||
* @param options - An object containing the options to set. | ||
*/ | ||
setOptions: (options: any) => void; | ||
/** | ||
* Sets the sizes of the resizable elements in the layout. | ||
*/ | ||
/** Sets the sizes of the resizable elements in the layout. */ | ||
setSizes: (options: Partial<Pick<API_Layout, 'navSize' | 'bottomPanelHeight' | 'rightPanelWidth'>>) => void; | ||
/** | ||
* getIsFullscreen - Returns the current fullscreen mode of the Storybook UI. | ||
*/ | ||
/** GetIsFullscreen - Returns the current fullscreen mode of the Storybook UI. */ | ||
getIsFullscreen: () => boolean; | ||
/** | ||
* getIsPanelShown - Returns the current visibility of the panel in the Storybook UI. | ||
*/ | ||
/** GetIsPanelShown - Returns the current visibility of the panel in the Storybook UI. */ | ||
getIsPanelShown: () => boolean; | ||
/** | ||
* getIsNavShown - Returns the current visibility of the navigation bar in the Storybook UI. | ||
*/ | ||
/** GetIsNavShown - Returns the current visibility of the navigation bar in the Storybook UI. */ | ||
getIsNavShown: () => boolean; | ||
@@ -269,9 +293,8 @@ } | ||
} | ||
/** | ||
* The API for managing notifications. | ||
*/ | ||
/** The API for managing notifications. */ | ||
interface SubAPI$8 { | ||
/** | ||
* Adds a new notification to the list of notifications. | ||
* If a notification with the same ID already exists, it will be replaced. | ||
* Adds a new notification to the list of notifications. If a notification with the same ID | ||
* already exists, it will be replaced. | ||
* | ||
* @param notification - The notification to add. | ||
@@ -282,2 +305,3 @@ */ | ||
* Removes a notification from the list of notifications and calls the onClear callback. | ||
* | ||
* @param id - The ID of the notification to remove. | ||
@@ -298,2 +322,3 @@ */ | ||
* Finds a composed ref by its source. | ||
* | ||
* @param {string} source - The source/URL of the composed ref. | ||
@@ -305,2 +330,3 @@ * @returns {API_ComposedRef} - The composed ref object. | ||
* Sets a composed ref by its ID and data. | ||
* | ||
* @param {string} id - The ID of the composed ref. | ||
@@ -313,2 +339,3 @@ * @param {API_SetRefData} data - The data to set for the composed ref. | ||
* Updates a composed ref by its ID and update object. | ||
* | ||
* @param {string} id - The ID of the composed ref. | ||
@@ -320,2 +347,3 @@ * @param {API_ComposedRefUpdate} ref - The update object for the composed ref. | ||
* Gets all composed refs. | ||
* | ||
* @returns {API_Refs} - The composed refs object. | ||
@@ -326,2 +354,3 @@ */ | ||
* Checks if a composed ref is valid. | ||
* | ||
* @param {API_SetRefData} ref - The composed ref to check. | ||
@@ -333,2 +362,3 @@ * @returns {Promise<void>} - A promise that resolves when the check is complete. | ||
* Changes the version of a composed ref by its ID and URL. | ||
* | ||
* @param {string} id - The ID of the composed ref. | ||
@@ -340,2 +370,3 @@ * @param {string} url - The new URL for the composed ref. | ||
* Changes the state of a composed ref by its ID and previewInitialized flag. | ||
* | ||
* @param {string} id - The ID of the composed ref. | ||
@@ -352,12 +383,18 @@ * @param {boolean} previewInitialized - The new previewInitialized flag for the composed ref. | ||
* Changes the active settings tab. | ||
* @param path - The path of the settings page to navigate to. The path NOT should include the `/settings` prefix. | ||
* @example changeSettingsTab(`about`). | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* changeSettingsTab(`about`); | ||
* ``` | ||
* | ||
* @param path - The path of the settings page to navigate to. The path NOT should include the | ||
* `/settings` prefix. | ||
*/ | ||
changeSettingsTab: (path: string) => void; | ||
/** | ||
* Closes the settings screen and returns to the last tracked story or the first story. | ||
*/ | ||
/** Closes the settings screen and returns to the last tracked story or the first story. */ | ||
closeSettings: () => void; | ||
/** | ||
* Checks if the settings screen is currently active. | ||
* | ||
* @returns A boolean indicating whether the settings screen is active. | ||
@@ -387,24 +424,15 @@ */ | ||
interface SubAPI$4 { | ||
/** | ||
* Returns the current shortcuts. | ||
*/ | ||
/** Returns the current shortcuts. */ | ||
getShortcutKeys(): API_Shortcuts; | ||
/** | ||
* Returns the default shortcuts. | ||
*/ | ||
/** Returns the default shortcuts. */ | ||
getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults; | ||
/** | ||
* Returns the shortcuts for addons. | ||
*/ | ||
/** Returns the shortcuts for addons. */ | ||
getAddonsShortcuts(): API_AddonShortcuts; | ||
/** | ||
* Returns the labels for addon shortcuts. | ||
*/ | ||
/** Returns the labels for addon shortcuts. */ | ||
getAddonsShortcutLabels(): API_AddonShortcutLabels; | ||
/** | ||
* Returns the default shortcuts for addons. | ||
*/ | ||
/** Returns the default shortcuts for addons. */ | ||
getAddonsShortcutDefaults(): API_AddonShortcutDefaults; | ||
/** | ||
* Sets the shortcuts to the given value. | ||
* | ||
* @param shortcuts The new shortcuts to set. | ||
@@ -416,2 +444,3 @@ * @returns A promise that resolves to the new shortcuts. | ||
* Sets the shortcut for the given action to the given value. | ||
* | ||
* @param action The action to set the shortcut for. | ||
@@ -424,2 +453,3 @@ * @param value The new shortcut to set. | ||
* Sets the shortcut for the given addon to the given value. | ||
* | ||
* @param addon The addon to set the shortcut for. | ||
@@ -432,2 +462,3 @@ * @param shortcut The new shortcut to set. | ||
* Restores all default shortcuts. | ||
* | ||
* @returns A promise that resolves to the new shortcuts. | ||
@@ -438,2 +469,3 @@ */ | ||
* Restores the default shortcut for the given action. | ||
* | ||
* @param action The action to restore the default shortcut for. | ||
@@ -445,2 +477,3 @@ * @returns A promise that resolves to the new shortcut. | ||
* Handles a keydown event. | ||
* | ||
* @param event The event to handle. | ||
@@ -451,2 +484,3 @@ */ | ||
* Handles a shortcut feature. | ||
* | ||
* @param feature The feature to handle. | ||
@@ -504,4 +538,5 @@ * @param event The event to handle. | ||
/** | ||
* The `storyId` method is a reference to the `toId` function from `@storybook/csf`, which is used to generate a unique ID for a story. | ||
* This ID is used to identify a specific story in the Storybook index. | ||
* The `storyId` method is a reference to the `toId` function from `@storybook/csf`, which is used | ||
* to generate a unique ID for a story. This ID is used to identify a specific story in the | ||
* Storybook index. | ||
* | ||
@@ -555,3 +590,4 @@ * @type {typeof toId} | ||
* | ||
* @param {Direction} direction - The direction to jump. Use -1 to jump to the previous component, and 1 to jump to the next component. | ||
* @param {Direction} direction - The direction to jump. Use -1 to jump to the previous component, | ||
* and 1 to jump to the next component. | ||
* @returns {void} | ||
@@ -563,3 +599,4 @@ */ | ||
* | ||
* @param {Direction} direction - The direction to jump. Use -1 to jump to the previous story, and 1 to jump to the next story. | ||
* @param {Direction} direction - The direction to jump. Use -1 to jump to the previous story, and | ||
* 1 to jump to the next story. | ||
* @returns {void} | ||
@@ -572,3 +609,4 @@ */ | ||
* @param {StoryId} storyId - The ID of the story to retrieve data for. | ||
* @param {string} [refId] - The ID of the ref to retrieve data for. If not provided, retrieves data for the default ref. | ||
* @param {string} [refId] - The ID of the ref to retrieve data for. If not provided, retrieves | ||
* data for the default ref. | ||
* @returns {API_LeafEntry} The data for the given story ID and optional ref ID. | ||
@@ -581,4 +619,6 @@ */ | ||
* @param {StoryId} storyId - The ID of the story to check. | ||
* @param {string} [refId] - The ID of the ref to check. If not provided, checks all refs for the given story ID. | ||
* @returns {boolean} A boolean indicating whether the given story ID and optional ref ID have been prepared. | ||
* @param {string} [refId] - The ID of the ref to check. If not provided, checks all refs for the | ||
* given story ID. | ||
* @returns {boolean} A boolean indicating whether the given story ID and optional ref ID have | ||
* been prepared. | ||
*/ | ||
@@ -589,5 +629,8 @@ isPrepared: (storyId: StoryId, refId?: string) => boolean; | ||
* | ||
* @param {StoryId | { storyId: StoryId; refId: string }} storyId - The ID of the story to retrieve parameters for, or an object containing the story ID and ref ID. | ||
* @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not provided, returns all parameters. | ||
* @returns {API_StoryEntry['parameters'] | any} The parameters for the given story ID and optional ref ID. | ||
* @param {StoryId | { storyId: StoryId; refId: string }} storyId - The ID of the story to | ||
* retrieve parameters for, or an object containing the story ID and ref ID. | ||
* @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not | ||
* provided, returns all parameters. | ||
* @returns {API_StoryEntry['parameters'] | any} The parameters for the given story ID and | ||
* optional ref ID. | ||
*/ | ||
@@ -602,3 +645,4 @@ getParameters: (storyId: StoryId | { | ||
* @template S - The type of the parameter value. | ||
* @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not provided, returns all parameters. | ||
* @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not | ||
* provided, returns all parameters. | ||
* @returns {S} The value of the specified parameter for the currently selected story. | ||
@@ -619,3 +663,4 @@ */ | ||
* @param {API_StoryEntry} story - The story to reset the arguments for. | ||
* @param {string[]} [argNames] - An optional array of argument names to reset. If not provided, all arguments will be reset. | ||
* @param {string[]} [argNames] - An optional array of argument names to reset. If not provided, | ||
* all arguments will be reset. | ||
* @returns {void} | ||
@@ -629,3 +674,4 @@ */ | ||
* @param {StoryId} storyId - The ID of the story to find the leaf entry for. | ||
* @returns {API_LeafEntry} The leaf entry for the given story ID, or null if no leaf entry was found. | ||
* @returns {API_LeafEntry} The leaf entry for the given story ID, or null if no leaf entry was | ||
* found. | ||
*/ | ||
@@ -642,3 +688,4 @@ findLeafEntry(index: API_IndexHash, storyId: StoryId): API_LeafEntry; | ||
/** | ||
* Finds the ID of the sibling story in the given direction for the given story ID in the given story index. | ||
* Finds the ID of the sibling story in the given direction for the given story ID in the given | ||
* story index. | ||
* | ||
@@ -695,3 +742,4 @@ * @param {StoryId} storyId - The ID of the story to find the sibling of. | ||
* @param {string} addonId - The ID of the addon to update. | ||
* @param {API_FilterFunction} filterFunction - A function that returns a boolean based on the story, index and status. | ||
* @param {API_FilterFunction} filterFunction - A function that returns a boolean based on the | ||
* story, index and status. | ||
* @returns {Promise<void>} A promise that resolves when the state has been updated. | ||
@@ -708,8 +756,7 @@ */ | ||
} | ||
/** | ||
* SubAPI for managing URL navigation and state. | ||
*/ | ||
/** SubAPI for managing URL navigation and state. */ | ||
interface SubAPI$2 { | ||
/** | ||
* Navigate to a new URL. | ||
* | ||
* @param {string} url - The URL to navigate to. | ||
@@ -722,4 +769,6 @@ * @param {NavigateOptions} options - Options for the navigation. | ||
* Get the value of a query parameter from the current URL. | ||
* | ||
* @param {string} key - The key of the query parameter to get. | ||
* @returns {string | undefined} The value of the query parameter, or undefined if it does not exist. | ||
* @returns {string | undefined} The value of the query parameter, or undefined if it does not | ||
* exist. | ||
*/ | ||
@@ -729,9 +778,11 @@ getQueryParam: (key: string) => string | undefined; | ||
* Returns an object containing the current state of the URL. | ||
* | ||
* @returns {{ | ||
* queryParams: QueryParams, | ||
* path: string, | ||
* viewMode?: string, | ||
* storyId?: string, | ||
* url: string | ||
* }} An object containing the current state of the URL. | ||
* queryParams: QueryParams; | ||
* path: string; | ||
* viewMode?: string; | ||
* storyId?: string; | ||
* url: string; | ||
* }} | ||
* An object containing the current state of the URL. | ||
*/ | ||
@@ -747,2 +798,3 @@ getUrlState: () => { | ||
* Set the query parameters for the current URL. | ||
* | ||
* @param {QueryParams} input - An object containing the query parameters to set. | ||
@@ -754,2 +806,3 @@ * @returns {void} | ||
* Set the query parameters for the current URL & navigates. | ||
* | ||
* @param {QueryParams} input - An object containing the query parameters to set. | ||
@@ -827,13 +880,7 @@ * @returns {void} | ||
interface DeprecatedState { | ||
/** | ||
* @deprecated use index | ||
*/ | ||
/** @deprecated Use index */ | ||
storiesHash: API_IndexHash; | ||
/** | ||
* @deprecated use previewInitialized | ||
*/ | ||
/** @deprecated Use previewInitialized */ | ||
storiesConfigured: boolean; | ||
/** | ||
* @deprecated use indexError | ||
*/ | ||
/** @deprecated Use indexError */ | ||
storiesFailed?: Error; | ||
@@ -840,0 +887,0 @@ } |
declare abstract class StorybookError extends Error { | ||
/** | ||
* Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. | ||
*/ | ||
/** Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. */ | ||
readonly category: string; | ||
/** | ||
* Code representing the error. Used to uniquely identify the error, e.g., 1. | ||
*/ | ||
/** Code representing the error. Used to uniquely identify the error, e.g., 1. */ | ||
readonly code: number; | ||
/** | ||
* Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. | ||
* Data associated with the error. Used to provide additional information in the error message or | ||
* to be passed to telemetry. | ||
*/ | ||
@@ -16,3 +13,5 @@ readonly data: {}; | ||
* Specifies the documentation for the error. | ||
* - If `true`, links to a documentation page on the Storybook website (make sure it exists before enabling) – This is not implemented yet. | ||
* | ||
* - If `true`, links to a documentation page on the Storybook website (make sure it exists before | ||
* enabling) – This is not implemented yet. | ||
* - If a string, uses the provided URL for documentation (external or FAQ links). | ||
@@ -22,10 +21,6 @@ * - If `false` (default), no documentation link is added. | ||
readonly documentation: boolean | string | string[]; | ||
/** | ||
* Flag used to easily determine if the error originates from Storybook. | ||
*/ | ||
/** Flag used to easily determine if the error originates from Storybook. */ | ||
readonly fromStorybook: true; | ||
get fullErrorCode(): `SB_${string}_${string}`; | ||
/** | ||
* Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. | ||
*/ | ||
/** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ | ||
get name(): string; | ||
@@ -38,5 +33,3 @@ constructor(props: { | ||
}); | ||
/** | ||
* Generates the error message along with additional documentation link (if applicable). | ||
*/ | ||
/** Generates the error message along with additional documentation link (if applicable). */ | ||
static getFullMessage({ documentation, code, category, message, }: ConstructorParameters<typeof StorybookError>[0]): string; | ||
@@ -46,9 +39,8 @@ } | ||
/** | ||
* If you can't find a suitable category for your error, create one | ||
* based on the package name/file path of which the error is thrown. | ||
* For instance: | ||
* If it's from @storybook/client-logger, then MANAGER_CLIENT-LOGGER | ||
* If you can't find a suitable category for your error, create one based on the package name/file | ||
* path of which the error is thrown. For instance: If it's from `@storybook/client-logger`, then | ||
* MANAGER_CLIENT-LOGGER | ||
* | ||
* Categories are prefixed by a logical grouping, e.g. MANAGER_ | ||
* to prevent manager and preview errors from having the same category and error code. | ||
* Categories are prefixed by a logical grouping, e.g. MANAGER_ to prevent manager and preview | ||
* errors from having the same category and error code. | ||
*/ | ||
@@ -55,0 +47,0 @@ declare enum Category { |
@@ -17,8 +17,7 @@ var g = Object.defineProperty; | ||
/** | ||
* Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. | ||
* Data associated with the error. Used to provide additional information in the error message or | ||
* to be passed to telemetry. | ||
*/ | ||
this.data = {}; | ||
/** | ||
* Flag used to easily determine if the error originates from Storybook. | ||
*/ | ||
/** Flag used to easily determine if the error originates from Storybook. */ | ||
this.fromStorybook = !0; | ||
@@ -30,5 +29,3 @@ this.category = e.category, this.documentation = e.documentation ?? !1, this.code = e.code; | ||
} | ||
/** | ||
* Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. | ||
*/ | ||
/** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ | ||
get name() { | ||
@@ -38,5 +35,3 @@ let e = this.constructor.name; | ||
} | ||
/** | ||
* Generates the error message along with additional documentation link (if applicable). | ||
*/ | ||
/** Generates the error message along with additional documentation link (if applicable). */ | ||
static getFullMessage({ | ||
@@ -43,0 +38,0 @@ documentation: e, |
@@ -54,26 +54,34 @@ import { Channel } from '@storybook/core/channels'; | ||
* Returns a memoized value. | ||
* @template T The type of the memoized value. | ||
* @param {() => T} nextCreate A function that returns the memoized value. | ||
* @param {any[]} [deps] An optional array of dependencies. If any of the dependencies change, the memoized value will be recomputed. | ||
* @returns {T} The memoized value. | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* const memoizedValue = useMemo(() => { | ||
* return doExpensiveCalculation(a, b); | ||
* }, [a, b]); | ||
* ``` | ||
* | ||
* @template T The type of the memoized value. | ||
* @param {() => T} nextCreate A function that returns the memoized value. | ||
* @param {any[]} [deps] An optional array of dependencies. If any of the dependencies change, the | ||
* memoized value will be recomputed. | ||
* @returns {T} The memoized value. | ||
*/ | ||
declare function useMemo<T>(nextCreate: () => T, deps?: any[]): T; | ||
/** Returns a memoized callback. | ||
/** | ||
* Returns a memoized callback. | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* const memoizedCallback = useCallback(() => { | ||
* doSomething(a, b); | ||
* }, [a, b]); | ||
* ``` | ||
* | ||
* @template T The type of the callback function. | ||
* @param {T} callback The callback function to memoize. | ||
* @param {any[]} [deps] An optional array of dependencies. If any of the dependencies change, the memoized callback will be recomputed. | ||
* @param {any[]} [deps] An optional array of dependencies. If any of the dependencies change, the | ||
* memoized callback will be recomputed. | ||
* @returns {T} The memoized callback. | ||
* | ||
* @example | ||
* const memoizedCallback = useCallback( | ||
* () => { | ||
* doSomething(a, b); | ||
* }, | ||
* [a, b], | ||
* ); | ||
*/ | ||
@@ -84,9 +92,12 @@ declare function useCallback<T>(callback: T, deps?: any[]): T; | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* const ref = useRef(0); | ||
* ref.current = 1; | ||
* ``` | ||
* | ||
* @template T The type of the ref object. | ||
* @param {T} initialValue The initial value of the ref object. | ||
* @returns {{ current: T }} The mutable ref object. | ||
* | ||
* @example | ||
* const ref = useRef(0); | ||
* ref.current = 1; | ||
*/ | ||
@@ -99,45 +110,48 @@ declare function useRef<T>(initialValue: T): { | ||
* | ||
* @template S The type of the state. | ||
* @param {(() => S) | S} initialState The initial state value or a function that returns the initial state value. | ||
* @returns {[S, (update: ((prevState: S) => S) | S) => void]} An array containing the current state value and a function to update it. | ||
* @example | ||
* | ||
* @example | ||
* ```ts | ||
* const [count, setCount] = useState(0); | ||
* setCount(count + 1); | ||
* ``` | ||
* | ||
* @template S The type of the state. | ||
* @param {(() => S) | S} initialState The initial state value or a function that returns the | ||
* initial state value. | ||
* @returns {[S, (update: ((prevState: S) => S) | S) => void]} An array containing the current state | ||
* value and a function to update it. | ||
*/ | ||
declare function useState<S>(initialState: (() => S) | S): [S, (update: ((prevState: S) => S) | S) => void]; | ||
/** | ||
* A redux-like alternative to useState. | ||
* Given a file name, creates an object with utilities to manage a log file. It creates a temporary | ||
* log file which you can manage with the returned functions. You can then decide whether to move | ||
* the log file to the users project, or remove it. | ||
* | ||
* @template S The type of the state. | ||
* @template A The type of the action. | ||
* @param {(state: S, action: A) => S} reducer The reducer function that returns the new state. | ||
* @param {S | I} initialArg The initial state value or the initial argument for the init function. | ||
* @param {(initialArg: I) => S} [init] An optional function that returns the initial state value. | ||
* @returns {[S, (action: A) => void]} An array containing the current state value and a function to dispatch actions. | ||
* | ||
* @example | ||
* const initialState = { count: 0 }; | ||
* | ||
* function reducer(state, action) { | ||
* switch (action.type) { | ||
* case 'increment': | ||
* return { count: state.count + 1 }; | ||
* case 'decrement': | ||
* return { count: state.count - 1 }; | ||
* default: | ||
* throw new Error(); | ||
* ```tsx | ||
* const initialState = { count: 0 }; | ||
* | ||
* function reducer(state, action) { | ||
* switch (action.type) { | ||
* case 'increment': | ||
* return { count: state.count + 1 }; | ||
* case 'decrement': | ||
* return { count: state.count - 1 }; | ||
* default: | ||
* throw new Error(); | ||
* } | ||
* } | ||
* } | ||
* } | ||
* | ||
* function Counter() { | ||
* const [state, dispatch] = useReducer(reducer, initialState); | ||
* return ( | ||
* <> | ||
* Count: {state.count} | ||
* <button onClick={() => dispatch({ type: 'increment' })}>+</button> | ||
* <button onClick={() => dispatch({ type: 'decrement' })}>-</button> | ||
* </> | ||
* ); | ||
* } | ||
* function Counter() { | ||
* const [state, dispatch] = useReducer(reducer, initialState); | ||
* return ( | ||
* <> | ||
* Count: {state.count} | ||
* <button onClick={() => dispatch({ type: 'increment' })}>+</button> | ||
* <button onClick={() => dispatch({ type: 'decrement' })}>-</button> | ||
* </> | ||
* ); | ||
* } | ||
* ``` | ||
*/ | ||
@@ -147,10 +161,8 @@ declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [S, (action: A) => void]; | ||
/** | ||
* Triggers a side effect, see https://reactjs.org/docs/hooks-reference.html#usestate | ||
* Effects are triggered synchronously after rendering the story | ||
* Triggers a side effect, see https://reactjs.org/docs/hooks-reference.html#usestate Effects are | ||
* triggered synchronously after rendering the story | ||
* | ||
* @param {() => (() => void) | void} create A function that creates the effect. It should return a cleanup function, or nothing. | ||
* @param {any[]} [deps] An optional array of dependencies. If any of the dependencies change, the effect will be re-run. | ||
* @returns {void} | ||
* @example | ||
* | ||
* @example | ||
* ```ts | ||
* useEffect(() => { | ||
@@ -162,2 +174,9 @@ * // Do something after rendering the story | ||
* }, [dependency1, dependency2]); | ||
* ``` | ||
* | ||
* @param {() => (() => void) | void} create A function that creates the effect. It should return a | ||
* cleanup function, or nothing. | ||
* @param {any[]} [deps] An optional array of dependencies. If any of the dependencies change, the | ||
* effect will be re-run. | ||
* @returns {void} | ||
*/ | ||
@@ -174,10 +193,14 @@ declare function useEffect(create: () => (() => void) | void, deps?: any[]): void; | ||
* | ||
* @param {EventMap} eventMap A map of event listeners to subscribe to. | ||
* @param {any[]} [deps=[]] An optional array of dependencies. If any of the dependencies change, the event listeners will be re-subscribed. | ||
* @returns {(...args: any[]) => void} A function to emit events to the Storybook channel. | ||
* @example | ||
* | ||
* @example | ||
* ```ts | ||
* // Subscribe to an event and emit it | ||
* const emit = useChannel({ 'my-event': (arg1, arg2) => console.log(arg1, arg2) }); | ||
* emit('my-event', 'Hello', 'world!'); | ||
* ``` | ||
* | ||
* @param {EventMap} eventMap A map of event listeners to subscribe to. | ||
* @param {any[]} [deps=[]] An optional array of dependencies. If any of the dependencies change, | ||
* the event listeners will be re-subscribed. Default is `[]` | ||
* @returns {(...args: any[]) => void} A function to emit events to the Storybook channel. | ||
*/ | ||
@@ -188,24 +211,32 @@ declare function useChannel(eventMap: EventMap, deps?: any[]): (eventName: string, ...args: any) => void; | ||
* | ||
* @template TRenderer The type of the story's renderer. | ||
* @template TArgs The type of the story's args. | ||
* @returns {StoryContext<TRenderer>} The current story context. | ||
* @example | ||
* | ||
* @example | ||
* ```ts | ||
* const { id, parameters } = useStoryContext(); | ||
* console.log(`Current story ID: ${id}`); | ||
* console.log(`Current story parameters: ${JSON.stringify(parameters)}`); | ||
* ``` | ||
* | ||
* @template TRenderer The type of the story's renderer. | ||
* @template TArgs The type of the story's args. | ||
* @returns {StoryContext<TRenderer>} The current story context. | ||
*/ | ||
declare function useStoryContext<TRenderer extends Renderer, TArgs extends Args = Args>(): StoryContext<TRenderer>; | ||
/** | ||
* Returns the value of a specific parameter for the current story, or a default value if the parameter is not set. | ||
* Returns the value of a specific parameter for the current story, or a default value if the | ||
* parameter is not set. | ||
* | ||
* @template S The type of the parameter value. | ||
* @param {string} parameterKey The key of the parameter to retrieve. | ||
* @param {S} [defaultValue] An optional default value to return if the parameter is not set. | ||
* @returns {S | undefined} The value of the parameter, or the default value if the parameter is not set. | ||
* @example | ||
* | ||
* @example | ||
* ```ts | ||
* // Retrieve the value of a parameter named "myParam" | ||
* const myParamValue = useParameter<string>('myParam', 'default value'); | ||
* console.log(`The value of myParam is: ${myParamValue}`); | ||
* ``` | ||
* | ||
* @template S The type of the parameter value. | ||
* @param {string} parameterKey The key of the parameter to retrieve. | ||
* @param {S} [defaultValue] An optional default value to return if the parameter is not set. | ||
* @returns {S | undefined} The value of the parameter, or the default value if the parameter is not | ||
* set. | ||
*/ | ||
@@ -216,10 +247,14 @@ declare function useParameter<S>(parameterKey: string, defaultValue?: S): S | undefined; | ||
* | ||
* @template TArgs The type of the story's args. | ||
* @returns {[TArgs, (newArgs: Partial<TArgs>) => void, (argNames?: (keyof TArgs)[]) => void]} An array containing the current args, a function to update them, and a function to reset them. | ||
* @example | ||
* | ||
* @example | ||
* const [args, updateArgs, resetArgs] = useArgs<{ name: string, age: number }>(); | ||
* ```ts | ||
* const [args, updateArgs, resetArgs] = useArgs<{ name: string; age: number }>(); | ||
* console.log(`Current args: ${JSON.stringify(args)}`); | ||
* updateArgs({ name: 'John' }); | ||
* resetArgs(['name']); | ||
* ``` | ||
* | ||
* @template TArgs The type of the story's args. | ||
* @returns {[TArgs, (newArgs: Partial<TArgs>) => void, (argNames?: (keyof TArgs)[]) => void]} An | ||
* array containing the current args, a function to update them, and a function to reset them. | ||
*/ | ||
@@ -234,8 +269,12 @@ declare function useArgs<TArgs extends Args = Args>(): [ | ||
* | ||
* @returns {[Args, (newGlobals: Args) => void]} An array containing the current global args, and a function to update them. | ||
* @example | ||
* | ||
* @example | ||
* ```ts | ||
* const [globals, updateGlobals] = useGlobals(); | ||
* console.log(`Current globals: ${JSON.stringify(globals)}`); | ||
* updateGlobals({ theme: 'dark' }); | ||
* ``` | ||
* | ||
* @returns {[Args, (newGlobals: Args) => void]} An array containing the current global args, and a | ||
* function to update them. | ||
*/ | ||
@@ -252,12 +291,8 @@ declare function useGlobals(): [Args, (newGlobals: Args) => void]; | ||
/** | ||
* Creates a Storybook decorator function that can be used to wrap stories with additional functionality. | ||
* Creates a Storybook decorator function that can be used to wrap stories with additional | ||
* functionality. | ||
* | ||
* @param {MakeDecoratorOptions} options - The options for the decorator. | ||
* @param {string} options.name - The name of the decorator. | ||
* @param {string} options.parameterName - The name of the parameter that will be used to pass options to the decorator. | ||
* @param {Addon_StoryWrapper} options.wrapper - The function that will be used to wrap the story. | ||
* @param {boolean} [options.skipIfNoParametersOrOptions=false] - Whether to skip the decorator if no options or parameters are provided. | ||
* @returns {MakeDecoratorResult} A function that can be used as a Storybook decorator. | ||
* @example | ||
* | ||
* @example | ||
* ```jsx | ||
* const myDecorator = makeDecorator({ | ||
@@ -268,3 +303,3 @@ * name: 'My Decorator', | ||
* const { myOption } = options; | ||
* return <div style={{ backgroundColor: myOption }}>{storyFn()}</div>; | ||
* <div style={{ backgroundColor: myOption }}>{storyFn()}</div>; | ||
* }, | ||
@@ -274,2 +309,12 @@ * }); | ||
* export const decorators = [myDecorator]; | ||
* ``` | ||
* | ||
* @param {MakeDecoratorOptions} options - The options for the decorator. | ||
* @param {string} options.name - The name of the decorator. | ||
* @param {string} options.parameterName - The name of the parameter that will be used to pass | ||
* options to the decorator. | ||
* @param {Addon_StoryWrapper} options.wrapper - The function that will be used to wrap the story. | ||
* @param {boolean} [options.skipIfNoParametersOrOptions=false] - Whether to skip the decorator if | ||
* no options or parameters are provided. Default is `false` | ||
* @returns {MakeDecoratorResult} A function that can be used as a Storybook decorator. | ||
*/ | ||
@@ -332,7 +377,13 @@ declare const makeDecorator: ({ name, parameterName, wrapper, skipIfNoParametersOrOptions, }: MakeDecoratorOptions) => MakeDecoratorResult; | ||
* | ||
* A step runner is a function that takes a defined step: `step('label', () => { ... })` | ||
* and runs it. The prototypical example is from `@storybook/addon-interactions` where the | ||
* step runner will decorate all instrumented code inside the step with information about the | ||
* label. | ||
* A step runner is a function that takes a defined step: | ||
* | ||
* @example | ||
* | ||
* ```ts | ||
* step('label', () => {}); | ||
* ``` | ||
* | ||
* ...and runs it. The prototypical example is from `@storybook/addon-interactions` where the step | ||
* runner will decorate all instrumented code inside the step with information about the label. | ||
* | ||
* In theory it is possible to have more than one addon that wants to run steps; they can be | ||
@@ -342,7 +393,7 @@ * composed together in a similar fashion to decorators. In some ways step runners are like | ||
* | ||
* The basic implementation of a step runner is `async (label, play, context) => play(context)` | ||
* -- in fact this is what `composeStepRunners([])` will do. | ||
* The basic implementation of a step runner is `async (label, play, context) => play(context)` -- | ||
* in fact this is what `composeStepRunners([])` will do. | ||
* | ||
* @param stepRunners an array of StepRunner | ||
* @returns a StepRunner that is the composition of the arguments | ||
* @param stepRunners An array of StepRunner | ||
* @returns A StepRunner that is the composition of the arguments | ||
*/ | ||
@@ -472,6 +523,5 @@ declare function composeStepRunners<TRenderer extends Renderer>(stepRunners: StepRunner<TRenderer>[]): StepRunner<TRenderer>; | ||
/** | ||
* Safely combine parameters recursively. Only copy objects when needed. | ||
* Algorithm = always overwrite the existing value UNLESS both values | ||
* are plain objects. In this case flag the key as "special" and handle | ||
* it with a heuristic. | ||
* Safely combine parameters recursively. Only copy objects when needed. Algorithm = always | ||
* overwrite the existing value UNLESS both values are plain objects. In this case flag the key as | ||
* "special" and handle it with a heuristic. | ||
*/ | ||
@@ -487,4 +537,4 @@ declare const combineParameters: (...parameterSets: (Parameters | undefined)[]) => Parameters; | ||
/** | ||
* Currently StoryContextUpdates are allowed to have any key in the type. | ||
* However, you cannot overwrite any of the build-it "static" keys. | ||
* Currently StoryContextUpdates are allowed to have any key in the type. However, you cannot | ||
* overwrite any of the build-it "static" keys. | ||
* | ||
@@ -581,4 +631,5 @@ * @param inputContextUpdate StoryContextUpdate | ||
* The implementations of render are used for two key purposes: | ||
* - Tracking the state of the rendering as it moves between preparing, rendering and tearing down. | ||
* - Tracking what is rendered to know if a change requires re-rendering or teardown + recreation. | ||
* | ||
* - Tracking the state of the rendering as it moves between preparing, rendering and tearing down. | ||
* - Tracking what is rendered to know if a change requires re-rendering or teardown + recreation. | ||
*/ | ||
@@ -601,8 +652,9 @@ interface Render<TRenderer extends Renderer> { | ||
* | ||
* The expectation is the primary CSF file which is the `importPath` for the entry will | ||
* define a story which may contain the actual rendered JSX code for the template in the | ||
* `docs.page` parameter. | ||
* The expectation is the primary CSF file which is the `importPath` for the entry will define a | ||
* story which may contain the actual rendered JSX code for the template in the `docs.page` | ||
* parameter. | ||
* | ||
* Use cases: | ||
* - Autodocs, where there is no story, and we fall back to the globally defined template. | ||
* | ||
* - Autodocs, where there is no story, and we fall back to the globally defined template. | ||
*/ | ||
@@ -638,4 +690,4 @@ declare class CsfDocsRender<TRenderer extends Renderer> implements Render<TRenderer> { | ||
/** | ||
* A MdxDocsRender is a render of a docs entry that comes from a true MDX file, | ||
* that is a `.mdx` file that doesn't get compiled to a CSF file. | ||
* A MdxDocsRender is a render of a docs entry that comes from a true MDX file, that is a `.mdx` | ||
* file that doesn't get compiled to a CSF file. | ||
* | ||
@@ -645,3 +697,4 @@ * A MDX render can reference (import) zero or more CSF files that contain stories. | ||
* Use cases: | ||
* - *.mdx file that may or may not reference a specific CSF file with `<Meta of={} />` | ||
* | ||
* - *.mdx file that may or may not reference a specific CSF file with `<Meta of={} />` | ||
*/ | ||
@@ -711,7 +764,6 @@ declare class MdxDocsRender<TRenderer extends Renderer> implements Render<TRenderer> { | ||
/** | ||
* Rerender the story. | ||
* If the story is currently pending (loading/rendering), the rerender will be enqueued, | ||
* and will be executed after the current render is completed. | ||
* Rerendering while playing will not be enqueued, and will be executed immediately, to support | ||
* rendering args changes while playing. | ||
* Rerender the story. If the story is currently pending (loading/rendering), the rerender will be | ||
* enqueued, and will be executed after the current render is completed. Rerendering while playing | ||
* will not be enqueued, and will be executed immediately, to support rendering args changes while | ||
* playing. | ||
*/ | ||
@@ -729,5 +781,3 @@ rerender(): Promise<void>; | ||
protected channel: Channel; | ||
/** | ||
* @deprecated will be removed in 8.0, please use channel instead | ||
*/ | ||
/** @deprecated Will be removed in 8.0, please use channel instead */ | ||
serverChannel?: Channel; | ||
@@ -734,0 +784,0 @@ protected storyStoreValue?: StoryStore<TRenderer>; |
declare abstract class StorybookError extends Error { | ||
/** | ||
* Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. | ||
*/ | ||
/** Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. */ | ||
readonly category: string; | ||
/** | ||
* Code representing the error. Used to uniquely identify the error, e.g., 1. | ||
*/ | ||
/** Code representing the error. Used to uniquely identify the error, e.g., 1. */ | ||
readonly code: number; | ||
/** | ||
* Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. | ||
* Data associated with the error. Used to provide additional information in the error message or | ||
* to be passed to telemetry. | ||
*/ | ||
@@ -16,3 +13,5 @@ readonly data: {}; | ||
* Specifies the documentation for the error. | ||
* - If `true`, links to a documentation page on the Storybook website (make sure it exists before enabling) – This is not implemented yet. | ||
* | ||
* - If `true`, links to a documentation page on the Storybook website (make sure it exists before | ||
* enabling) – This is not implemented yet. | ||
* - If a string, uses the provided URL for documentation (external or FAQ links). | ||
@@ -22,10 +21,6 @@ * - If `false` (default), no documentation link is added. | ||
readonly documentation: boolean | string | string[]; | ||
/** | ||
* Flag used to easily determine if the error originates from Storybook. | ||
*/ | ||
/** Flag used to easily determine if the error originates from Storybook. */ | ||
readonly fromStorybook: true; | ||
get fullErrorCode(): `SB_${string}_${string}`; | ||
/** | ||
* Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. | ||
*/ | ||
/** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ | ||
get name(): string; | ||
@@ -38,5 +33,3 @@ constructor(props: { | ||
}); | ||
/** | ||
* Generates the error message along with additional documentation link (if applicable). | ||
*/ | ||
/** Generates the error message along with additional documentation link (if applicable). */ | ||
static getFullMessage({ documentation, code, category, message, }: ConstructorParameters<typeof StorybookError>[0]): string; | ||
@@ -46,9 +39,8 @@ } | ||
/** | ||
* If you can't find a suitable category for your error, create one | ||
* based on the package name/file path of which the error is thrown. | ||
* For instance: | ||
* If it's from @storybook/client-logger, then CLIENT-LOGGER | ||
* If you can't find a suitable category for your error, create one based on the package name/file | ||
* path of which the error is thrown. For instance: If it's from `@storybook/client-logger`, then | ||
* CLIENT-LOGGER | ||
* | ||
* Categories are prefixed by a logical grouping, e.g. PREVIEW_ or FRAMEWORK_ | ||
* to prevent manager and preview errors from having the same category and error code. | ||
* Categories are prefixed by a logical grouping, e.g. PREVIEW_ or FRAMEWORK_ to prevent manager and | ||
* preview errors from having the same category and error code. | ||
*/ | ||
@@ -55,0 +47,0 @@ declare enum Category { |
@@ -52,8 +52,7 @@ var ee = Object.defineProperty; | ||
/** | ||
* Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. | ||
* Data associated with the error. Used to provide additional information in the error message or | ||
* to be passed to telemetry. | ||
*/ | ||
this.data = {}; | ||
/** | ||
* Flag used to easily determine if the error originates from Storybook. | ||
*/ | ||
/** Flag used to easily determine if the error originates from Storybook. */ | ||
this.fromStorybook = !0; | ||
@@ -65,5 +64,3 @@ this.category = e.category, this.documentation = e.documentation ?? !1, this.code = e.code; | ||
} | ||
/** | ||
* Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. | ||
*/ | ||
/** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ | ||
get name() { | ||
@@ -73,5 +70,3 @@ let e = this.constructor.name; | ||
} | ||
/** | ||
* Generates the error message along with additional documentation link (if applicable). | ||
*/ | ||
/** Generates the error message along with additional documentation link (if applicable). */ | ||
static getFullMessage({ | ||
@@ -78,0 +73,0 @@ documentation: e, |
@@ -353,5 +353,3 @@ import * as React from 'react'; | ||
declare const useNavigate: () => (to: To | number, { plain, ...options }?: NavigateOptions) => void; | ||
/** | ||
* A component that will navigate to a new location/path when clicked | ||
*/ | ||
/** A component that will navigate to a new location/path when clicked */ | ||
declare const Link: { | ||
@@ -362,4 +360,4 @@ ({ to, children, ...rest }: LinkProps): React__default.JSX.Element; | ||
/** | ||
* A render-prop component where children is called with a location | ||
* and will be called whenever it changes when it changes | ||
* A render-prop component where children is called with a location and will be called whenever it | ||
* changes when it changes | ||
*/ | ||
@@ -371,5 +369,5 @@ declare const Location$1: { | ||
/** | ||
* A render-prop component for rendering when a certain path is hit. | ||
* It's immensely similar to `Location` but it receives an addition data property: `match`. | ||
* match has a truthy value when the path is hit. | ||
* A render-prop component for rendering when a certain path is hit. It's immensely similar to | ||
* `Location` but it receives an addition data property: `match`. match has a truthy value when the | ||
* path is hit. | ||
*/ | ||
@@ -381,5 +379,3 @@ declare function Match(props: MatchPropsStartsWith): ReactElement; | ||
} | ||
/** | ||
* A component to conditionally render children based on matching a target path | ||
*/ | ||
/** A component to conditionally render children based on matching a target path */ | ||
declare function Route(props: RoutePropsDefault): ReactElement; | ||
@@ -386,0 +382,0 @@ declare function Route(props: RoutePropsStartsWith): ReactElement; |
declare abstract class StorybookError extends Error { | ||
/** | ||
* Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. | ||
*/ | ||
/** Category of the error. Used to classify the type of error, e.g., 'PREVIEW_API'. */ | ||
readonly category: string; | ||
/** | ||
* Code representing the error. Used to uniquely identify the error, e.g., 1. | ||
*/ | ||
/** Code representing the error. Used to uniquely identify the error, e.g., 1. */ | ||
readonly code: number; | ||
/** | ||
* Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. | ||
* Data associated with the error. Used to provide additional information in the error message or | ||
* to be passed to telemetry. | ||
*/ | ||
@@ -16,3 +13,5 @@ readonly data: {}; | ||
* Specifies the documentation for the error. | ||
* - If `true`, links to a documentation page on the Storybook website (make sure it exists before enabling) – This is not implemented yet. | ||
* | ||
* - If `true`, links to a documentation page on the Storybook website (make sure it exists before | ||
* enabling) – This is not implemented yet. | ||
* - If a string, uses the provided URL for documentation (external or FAQ links). | ||
@@ -22,10 +21,6 @@ * - If `false` (default), no documentation link is added. | ||
readonly documentation: boolean | string | string[]; | ||
/** | ||
* Flag used to easily determine if the error originates from Storybook. | ||
*/ | ||
/** Flag used to easily determine if the error originates from Storybook. */ | ||
readonly fromStorybook: true; | ||
get fullErrorCode(): `SB_${string}_${string}`; | ||
/** | ||
* Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. | ||
*/ | ||
/** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ | ||
get name(): string; | ||
@@ -38,5 +33,3 @@ constructor(props: { | ||
}); | ||
/** | ||
* Generates the error message along with additional documentation link (if applicable). | ||
*/ | ||
/** Generates the error message along with additional documentation link (if applicable). */ | ||
static getFullMessage({ documentation, code, category, message, }: ConstructorParameters<typeof StorybookError>[0]): string; | ||
@@ -46,7 +39,6 @@ } | ||
/** | ||
* If you can't find a suitable category for your error, create one | ||
* based on the package name/file path of which the error is thrown. | ||
* For instance: | ||
* If it's from @storybook/node-logger, then NODE-LOGGER | ||
* If it's from a package that is too broad, e.g. @storybook/cli in the init command, then use a combination like CLI_INIT | ||
* If you can't find a suitable category for your error, create one based on the package name/file | ||
* path of which the error is thrown. For instance: If it's from `@storybook/node-logger`, then | ||
* NODE-LOGGER If it's from a package that is too broad, e.g. @storybook/cli in the init command, | ||
* then use a combination like CLI_INIT | ||
*/ | ||
@@ -53,0 +45,0 @@ declare enum Category { |
@@ -439,8 +439,7 @@ import ESM_COMPAT_Module from "node:module"; | ||
/** | ||
* Data associated with the error. Used to provide additional information in the error message or to be passed to telemetry. | ||
* Data associated with the error. Used to provide additional information in the error message or | ||
* to be passed to telemetry. | ||
*/ | ||
this.data = {}; | ||
/** | ||
* Flag used to easily determine if the error originates from Storybook. | ||
*/ | ||
/** Flag used to easily determine if the error originates from Storybook. */ | ||
this.fromStorybook = !0; | ||
@@ -455,5 +454,3 @@ this.category = e.category, this.documentation = e.documentation ?? !1, this.code = e.code; | ||
} | ||
/** | ||
* Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. | ||
*/ | ||
/** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */ | ||
get name() { | ||
@@ -463,5 +460,3 @@ let e = this.constructor.name; | ||
} | ||
/** | ||
* Generates the error message along with additional documentation link (if applicable). | ||
*/ | ||
/** Generates the error message along with additional documentation link (if applicable). */ | ||
static getFullMessage({ | ||
@@ -468,0 +463,0 @@ documentation: e, |
@@ -95,6 +95,3 @@ import { TypescriptOptions, StorybookConfig, PackageJson } from '@storybook/core/types'; | ||
/** | ||
* Is this story part of the CLI generated examples, | ||
* including user-created stories in those files | ||
*/ | ||
/** Is this story part of the CLI generated examples, including user-created stories in those files */ | ||
declare const isExampleStoryId: (storyId: string) => boolean; | ||
@@ -101,0 +98,0 @@ declare const telemetry: (eventType: EventType, payload?: Payload, options?: Partial<Options>) => Promise<void>; |
{ | ||
"name": "@storybook/core", | ||
"version": "8.3.0-alpha.6", | ||
"version": "8.3.0-alpha.7", | ||
"description": "Storybook framework-agnostic API", | ||
@@ -309,2 +309,3 @@ "keywords": [ | ||
"@types/compression": "^1.7.0", | ||
"@types/cross-spawn": "^6.0.2", | ||
"@types/detect-port": "^1.3.0", | ||
@@ -311,0 +312,0 @@ "@types/diff": "^5.0.9", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
40358077
743102
131