storybook 9.0.0-alpha.1 → 9.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -29
- package/assets/browser/favicon.svg +1 -0
- package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-bold.woff2 +0 -0
- package/assets/browser/nunito-sans-italic.woff2 +0 -0
- package/assets/browser/nunito-sans-regular.woff2 +0 -0
- package/assets/docs/addon-controls-args-annotated.png +0 -0
- package/assets/docs/addon-controls-args-background-color.png +0 -0
- package/assets/docs/addon-controls-args-background-string.png +0 -0
- package/assets/docs/addon-controls-args-docs.png +0 -0
- package/assets/docs/addon-controls-args-logging.png +0 -0
- package/assets/docs/addon-controls-args-no-annotation.png +0 -0
- package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
- package/assets/docs/addon-controls-args-reflow.png +0 -0
- package/assets/docs/addon-controls-args-template.png +0 -0
- package/assets/docs/addon-controls-expanded.png +0 -0
- package/assets/docs/addon-controls-hero.gif +0 -0
- package/assets/docs/addon-controls-install.png +0 -0
- package/assets/docs/hero.gif +0 -0
- package/assets/docs/message-reference.png +0 -0
- package/assets/docs/viewport.png +0 -0
- package/assets/server/addon.tsconfig.json +6 -0
- package/assets/server/base-preview-body.html +119 -0
- package/assets/server/base-preview-head.html +451 -0
- package/assets/server/template.ejs +87 -0
- package/bin/index.cjs +1 -1
- package/dist/actions/decorator.d.ts +6 -0
- package/dist/actions/decorator.js +139 -0
- package/dist/actions/index.cjs +127 -0
- package/dist/actions/index.d.ts +105 -0
- package/dist/actions/index.js +112 -0
- package/dist/actions/manager.js +1196 -0
- package/dist/actions/preview.cjs +165 -0
- package/dist/actions/preview.d.ts +55 -0
- package/dist/actions/preview.js +156 -0
- package/dist/babel/index.cjs +54034 -0
- package/dist/babel/index.d.ts +7488 -0
- package/dist/babel/index.js +54044 -0
- package/dist/bin/index.cjs +118 -0
- package/dist/bin/index.js +112 -0
- package/dist/builder-manager/index.cjs +2140 -0
- package/dist/builder-manager/index.d.ts +19 -0
- package/dist/builder-manager/index.js +2162 -0
- package/dist/channels/index.cjs +1913 -0
- package/dist/channels/index.d.ts +108 -0
- package/dist/channels/index.js +1881 -0
- package/dist/cli/bin/index.cjs +2687 -0
- package/dist/cli/bin/index.d.ts +2 -0
- package/dist/cli/bin/index.js +2707 -0
- package/dist/cli/index.cjs +17327 -0
- package/dist/cli/index.d.ts +209 -0
- package/dist/cli/index.js +17349 -0
- package/dist/client-logger/index.cjs +80 -0
- package/dist/client-logger/index.d.ts +29 -0
- package/dist/client-logger/index.js +64 -0
- package/dist/common/index.cjs +20568 -0
- package/dist/common/index.d.ts +948 -0
- package/dist/common/index.js +20653 -0
- package/dist/component-testing/index.cjs +23 -0
- package/dist/component-testing/index.d.ts +3 -0
- package/dist/component-testing/index.js +5 -0
- package/dist/component-testing/manager.css +170 -0
- package/dist/component-testing/manager.js +3099 -0
- package/dist/component-testing/preview.cjs +40 -0
- package/dist/component-testing/preview.d.ts +5 -0
- package/dist/component-testing/preview.js +25 -0
- package/dist/components/index.cjs +27925 -0
- package/dist/components/index.d.ts +1423 -0
- package/dist/components/index.js +24674 -0
- package/dist/controls/decorator.d.ts +5 -0
- package/dist/controls/decorator.js +8 -0
- package/dist/controls/index.cjs +26 -0
- package/dist/controls/index.d.ts +39 -0
- package/dist/controls/index.js +6 -0
- package/dist/controls/manager.js +5545 -0
- package/dist/controls/preview.cjs +26 -0
- package/dist/controls/preview.d.ts +55 -0
- package/dist/controls/preview.js +9 -0
- package/dist/core-events/index.cjs +167 -0
- package/dist/core-events/index.d.ts +426 -0
- package/dist/core-events/index.js +149 -0
- package/dist/core-server/index.cjs +38183 -0
- package/dist/core-server/index.d.ts +720 -0
- package/dist/core-server/index.js +38272 -0
- package/dist/core-server/presets/common-manager.js +20 -0
- package/dist/core-server/presets/common-override-preset.cjs +4824 -0
- package/dist/core-server/presets/common-override-preset.js +4829 -0
- package/dist/core-server/presets/common-preset.cjs +10231 -0
- package/dist/core-server/presets/common-preset.js +10309 -0
- package/dist/csf/index.cjs +179 -0
- package/dist/csf/index.d.ts +750 -0
- package/dist/csf/index.js +172 -0
- package/dist/csf-tools/index.cjs +1422 -0
- package/dist/csf-tools/index.d.ts +250 -0
- package/dist/csf-tools/index.js +1439 -0
- package/dist/docs-tools/index.cjs +2891 -0
- package/dist/docs-tools/index.d.ts +162 -0
- package/dist/docs-tools/index.js +2876 -0
- package/dist/index.cjs +17 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -7
- package/dist/instrumenter/index.cjs +3492 -0
- package/dist/instrumenter/index.d.ts +104 -0
- package/dist/instrumenter/index.js +4964 -0
- package/dist/manager/globals-module-info.cjs +817 -0
- package/dist/manager/globals-module-info.d.ts +36 -0
- package/dist/manager/globals-module-info.js +804 -0
- package/dist/manager/globals-runtime.js +83389 -0
- package/dist/manager/globals.cjs +47 -0
- package/dist/manager/globals.d.ts +24 -0
- package/dist/manager/globals.js +34 -0
- package/dist/manager/runtime.js +12323 -0
- package/dist/manager-api/index.cjs +11074 -0
- package/dist/manager-api/index.d.ts +1512 -0
- package/dist/manager-api/index.js +4835 -0
- package/dist/manager-errors.d.ts +89 -0
- package/dist/manager-errors.js +99 -0
- package/dist/node-logger/index.cjs +1642 -0
- package/dist/node-logger/index.d.ts +117 -0
- package/dist/node-logger/index.js +1652 -0
- package/dist/preview/globals.cjs +38 -0
- package/dist/preview/globals.d.ts +15 -0
- package/dist/preview/globals.js +25 -0
- package/dist/preview/runtime.js +44921 -0
- package/dist/preview-api/index.cjs +5227 -0
- package/dist/preview-api/index.d.ts +1093 -0
- package/dist/preview-api/index.js +5295 -0
- package/dist/preview-errors.cjs +503 -0
- package/dist/preview-errors.d.ts +212 -0
- package/dist/preview-errors.js +449 -0
- package/dist/router/index.cjs +3296 -0
- package/dist/router/index.d.ts +385 -0
- package/dist/router/index.js +1843 -0
- package/dist/server-errors.cjs +727 -0
- package/dist/server-errors.d.ts +296 -0
- package/dist/server-errors.js +728 -0
- package/dist/telemetry/index.cjs +2756 -0
- package/dist/telemetry/index.d.ts +133 -0
- package/dist/telemetry/index.js +2797 -0
- package/dist/test/index.cjs +35685 -0
- package/dist/test/index.d.ts +186 -0
- package/dist/test/index.js +33751 -0
- package/dist/test/preview.cjs +15869 -0
- package/dist/test/preview.d.ts +54 -0
- package/dist/test/preview.js +14440 -0
- package/dist/test/spy.cjs +257 -0
- package/dist/test/spy.d.ts +66 -0
- package/dist/test/spy.js +239 -0
- package/dist/theming/create.cjs +232 -0
- package/dist/theming/create.d.ts +50 -0
- package/dist/theming/create.js +216 -0
- package/dist/theming/index.cjs +2665 -0
- package/dist/theming/index.d.ts +11939 -0
- package/dist/theming/index.js +2485 -0
- package/dist/types/index.cjs +27 -0
- package/dist/types/index.d.ts +2795 -0
- package/dist/types/index.js +7 -0
- package/dist/viewport/index.cjs +310 -0
- package/dist/viewport/index.d.ts +320 -0
- package/dist/viewport/index.js +290 -0
- package/dist/viewport/manager.js +400 -0
- package/dist/viewport/preview.cjs +35 -0
- package/dist/viewport/preview.d.ts +69 -0
- package/dist/viewport/preview.js +19 -0
- package/package.json +539 -209
- package/.eslintrc.cjs +0 -31
- package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
- package/core/babel/index.cjs +0 -1
- package/core/babel/index.d.ts +0 -2
- package/core/babel/index.js +0 -1
- package/core/builder-manager/index.cjs +0 -1
- package/core/builder-manager/index.d.ts +0 -2
- package/core/builder-manager/index.js +0 -1
- package/core/channels/index.cjs +0 -1
- package/core/channels/index.d.ts +0 -2
- package/core/channels/index.js +0 -1
- package/core/cli/bin/index.cjs +0 -1
- package/core/cli/bin/index.d.ts +0 -2
- package/core/cli/bin/index.js +0 -1
- package/core/cli/index.cjs +0 -1
- package/core/cli/index.d.ts +0 -2
- package/core/cli/index.js +0 -1
- package/core/client-logger/index.cjs +0 -1
- package/core/client-logger/index.d.ts +0 -2
- package/core/client-logger/index.js +0 -1
- package/core/common/index.cjs +0 -1
- package/core/common/index.d.ts +0 -2
- package/core/common/index.js +0 -1
- package/core/components/index.cjs +0 -1
- package/core/components/index.d.ts +0 -2
- package/core/components/index.js +0 -1
- package/core/core-events/index.cjs +0 -1
- package/core/core-events/index.d.ts +0 -2
- package/core/core-events/index.js +0 -1
- package/core/core-server/index.cjs +0 -1
- package/core/core-server/index.d.ts +0 -2
- package/core/core-server/index.js +0 -1
- package/core/core-server/presets/common-manager.js +0 -1
- package/core/core-server/presets/common-override-preset.cjs +0 -1
- package/core/core-server/presets/common-override-preset.js +0 -1
- package/core/core-server/presets/common-preset.cjs +0 -1
- package/core/core-server/presets/common-preset.js +0 -1
- package/core/csf/index.cjs +0 -1
- package/core/csf/index.d.ts +0 -2
- package/core/csf/index.js +0 -1
- package/core/csf-tools/index.cjs +0 -1
- package/core/csf-tools/index.d.ts +0 -2
- package/core/csf-tools/index.js +0 -1
- package/core/docs-tools/index.cjs +0 -1
- package/core/docs-tools/index.d.ts +0 -2
- package/core/docs-tools/index.js +0 -1
- package/core/index.cjs +0 -1
- package/core/index.d.ts +0 -2
- package/core/index.js +0 -1
- package/core/manager/globals-module-info.cjs +0 -1
- package/core/manager/globals-module-info.d.ts +0 -2
- package/core/manager/globals-module-info.js +0 -1
- package/core/manager/globals-runtime.js +0 -1
- package/core/manager/globals.cjs +0 -1
- package/core/manager/globals.d.ts +0 -2
- package/core/manager/globals.js +0 -1
- package/core/manager-api/index.cjs +0 -1
- package/core/manager-api/index.d.ts +0 -2
- package/core/manager-api/index.js +0 -1
- package/core/manager-errors.d.ts +0 -2
- package/core/manager-errors.js +0 -1
- package/core/node-logger/index.cjs +0 -1
- package/core/node-logger/index.d.ts +0 -2
- package/core/node-logger/index.js +0 -1
- package/core/preview/globals.cjs +0 -1
- package/core/preview/globals.d.ts +0 -2
- package/core/preview/globals.js +0 -1
- package/core/preview/runtime.js +0 -1
- package/core/preview-api/index.cjs +0 -1
- package/core/preview-api/index.d.ts +0 -2
- package/core/preview-api/index.js +0 -1
- package/core/preview-errors.cjs +0 -1
- package/core/preview-errors.d.ts +0 -2
- package/core/preview-errors.js +0 -1
- package/core/router/index.cjs +0 -1
- package/core/router/index.d.ts +0 -2
- package/core/router/index.js +0 -1
- package/core/server-errors.cjs +0 -1
- package/core/server-errors.d.ts +0 -2
- package/core/server-errors.js +0 -1
- package/core/telemetry/index.cjs +0 -1
- package/core/telemetry/index.d.ts +0 -2
- package/core/telemetry/index.js +0 -1
- package/core/theming/create.cjs +0 -1
- package/core/theming/create.d.ts +0 -2
- package/core/theming/create.js +0 -1
- package/core/theming/index.cjs +0 -1
- package/core/theming/index.d.ts +0 -2
- package/core/theming/index.js +0 -1
- package/core/types/index.cjs +0 -1
- package/core/types/index.d.ts +0 -2
- package/core/types/index.js +0 -1
- package/core.cjs +0 -0
- package/core.d.ts +0 -0
- package/core.js +0 -1
- package/dist/chunk-OWLSIX54.js +0 -8
- package/dist/core-path.cjs +0 -1
- package/dist/core-path.d.ts +0 -3
- package/dist/core-path.js +0 -9
- package/dist/proxy.cjs +0 -1
- package/dist/proxy.d.ts +0 -2
- package/dist/proxy.js +0 -9
|
@@ -0,0 +1,2795 @@
|
|
|
1
|
+
import { StoryId, StoryName, ComponentTitle, Tag as Tag$1, Parameters, Args, ArgTypes, ComponentId, StoryKind, Globals, GlobalTypes, InputType, StoryContext, PartialStoryFn, LegacyStoryFn, ArgsStoryFn, StoryFn, DecoratorFunction, LoaderFunction, Renderer as Renderer$1, ViewMode as ViewMode$1, StoryIdentifier, ProjectAnnotations as ProjectAnnotations$1, StrictArgTypes, StrictGlobalTypes, StepRunner, BeforeAll, ComponentAnnotations, StoryAnnotations, StoryContextForEnhancers, CleanupCallback, Canvas, StoryAnnotationsOrFn, AnnotatedStoryFn } from 'storybook/internal/csf';
|
|
2
|
+
export { AfterEach, AnnotatedStoryFn, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, ProjectAnnotations as BaseProjectAnnotations, BeforeAll, BeforeEach, Canvas, CleanupCallback, ComponentAnnotations, ComponentId, ComponentTitle, Conditional, DecoratorApplicator, DecoratorFunction, GlobalTypes, Globals, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoaderFunction, Parameters, PartialStoryFn, PlayFunction, PlayFunctionContext, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryKind, StoryName, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, Tag } from 'storybook/internal/csf';
|
|
3
|
+
import { ReactElement, FC, ReactNode, PropsWithChildren } from 'react';
|
|
4
|
+
import { Addon_TestProviderType as Addon_TestProviderType$1, NormalizedProjectAnnotations as NormalizedProjectAnnotations$1, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn as ComposedStoryFn$1 } from 'storybook/internal/types';
|
|
5
|
+
import { FileSystemCache } from 'storybook/internal/common';
|
|
6
|
+
import { Server, IncomingMessage, ServerResponse } from 'http';
|
|
7
|
+
import { Server as Server$1 } from 'net';
|
|
8
|
+
import { Channel as Channel$1 } from 'storybook/internal/channels';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
12
|
+
|
|
13
|
+
@category Type
|
|
14
|
+
*/
|
|
15
|
+
type Primitive =
|
|
16
|
+
| null
|
|
17
|
+
| undefined
|
|
18
|
+
| string
|
|
19
|
+
| number
|
|
20
|
+
| boolean
|
|
21
|
+
| symbol
|
|
22
|
+
| bigint;
|
|
23
|
+
|
|
24
|
+
declare global {
|
|
25
|
+
interface SymbolConstructor {
|
|
26
|
+
readonly observable: symbol;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
32
|
+
|
|
33
|
+
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
34
|
+
|
|
35
|
+
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
36
|
+
|
|
37
|
+
@example
|
|
38
|
+
```
|
|
39
|
+
import type {LiteralUnion} from 'type-fest';
|
|
40
|
+
|
|
41
|
+
// Before
|
|
42
|
+
|
|
43
|
+
type Pet = 'dog' | 'cat' | string;
|
|
44
|
+
|
|
45
|
+
const pet: Pet = '';
|
|
46
|
+
// Start typing in your TypeScript-enabled IDE.
|
|
47
|
+
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
48
|
+
|
|
49
|
+
// After
|
|
50
|
+
|
|
51
|
+
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
52
|
+
|
|
53
|
+
const pet: Pet2 = '';
|
|
54
|
+
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
@category Type
|
|
58
|
+
*/
|
|
59
|
+
type LiteralUnion<
|
|
60
|
+
LiteralType,
|
|
61
|
+
BaseType extends Primitive,
|
|
62
|
+
> = LiteralType | (BaseType & Record<never, never>);
|
|
63
|
+
|
|
64
|
+
declare namespace PackageJson$1 {
|
|
65
|
+
/**
|
|
66
|
+
A person who has been involved in creating or maintaining the package.
|
|
67
|
+
*/
|
|
68
|
+
export type Person =
|
|
69
|
+
| string
|
|
70
|
+
| {
|
|
71
|
+
name: string;
|
|
72
|
+
url?: string;
|
|
73
|
+
email?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type BugsLocation =
|
|
77
|
+
| string
|
|
78
|
+
| {
|
|
79
|
+
/**
|
|
80
|
+
The URL to the package's issue tracker.
|
|
81
|
+
*/
|
|
82
|
+
url?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
The email address to which issues should be reported.
|
|
86
|
+
*/
|
|
87
|
+
email?: string;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export interface DirectoryLocations {
|
|
91
|
+
[directoryType: string]: unknown;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
|
|
95
|
+
*/
|
|
96
|
+
bin?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
Location for Markdown files.
|
|
100
|
+
*/
|
|
101
|
+
doc?: string;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
Location for example scripts.
|
|
105
|
+
*/
|
|
106
|
+
example?: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
Location for the bulk of the library.
|
|
110
|
+
*/
|
|
111
|
+
lib?: string;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
Location for man pages. Sugar to generate a `man` array by walking the folder.
|
|
115
|
+
*/
|
|
116
|
+
man?: string;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
Location for test files.
|
|
120
|
+
*/
|
|
121
|
+
test?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type Scripts = {
|
|
125
|
+
/**
|
|
126
|
+
Run **before** the package is published (Also run on local `npm install` without any arguments).
|
|
127
|
+
*/
|
|
128
|
+
prepublish?: string;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
Run both **before** the package is packed and published, and on local `npm install` without any arguments. This is run **after** `prepublish`, but **before** `prepublishOnly`.
|
|
132
|
+
*/
|
|
133
|
+
prepare?: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
Run **before** the package is prepared and packed, **only** on `npm publish`.
|
|
137
|
+
*/
|
|
138
|
+
prepublishOnly?: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
Run **before** a tarball is packed (on `npm pack`, `npm publish`, and when installing git dependencies).
|
|
142
|
+
*/
|
|
143
|
+
prepack?: string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
Run **after** the tarball has been generated and moved to its final destination.
|
|
147
|
+
*/
|
|
148
|
+
postpack?: string;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
Run **after** the package is published.
|
|
152
|
+
*/
|
|
153
|
+
publish?: string;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
Run **after** the package is published.
|
|
157
|
+
*/
|
|
158
|
+
postpublish?: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
Run **before** the package is installed.
|
|
162
|
+
*/
|
|
163
|
+
preinstall?: string;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
Run **after** the package is installed.
|
|
167
|
+
*/
|
|
168
|
+
install?: string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
Run **after** the package is installed and after `install`.
|
|
172
|
+
*/
|
|
173
|
+
postinstall?: string;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
Run **before** the package is uninstalled and before `uninstall`.
|
|
177
|
+
*/
|
|
178
|
+
preuninstall?: string;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
Run **before** the package is uninstalled.
|
|
182
|
+
*/
|
|
183
|
+
uninstall?: string;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
Run **after** the package is uninstalled.
|
|
187
|
+
*/
|
|
188
|
+
postuninstall?: string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
Run **before** bump the package version and before `version`.
|
|
192
|
+
*/
|
|
193
|
+
preversion?: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
Run **before** bump the package version.
|
|
197
|
+
*/
|
|
198
|
+
version?: string;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
Run **after** bump the package version.
|
|
202
|
+
*/
|
|
203
|
+
postversion?: string;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
Run with the `npm test` command, before `test`.
|
|
207
|
+
*/
|
|
208
|
+
pretest?: string;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
Run with the `npm test` command.
|
|
212
|
+
*/
|
|
213
|
+
test?: string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
Run with the `npm test` command, after `test`.
|
|
217
|
+
*/
|
|
218
|
+
posttest?: string;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
Run with the `npm stop` command, before `stop`.
|
|
222
|
+
*/
|
|
223
|
+
prestop?: string;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
Run with the `npm stop` command.
|
|
227
|
+
*/
|
|
228
|
+
stop?: string;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
Run with the `npm stop` command, after `stop`.
|
|
232
|
+
*/
|
|
233
|
+
poststop?: string;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
Run with the `npm start` command, before `start`.
|
|
237
|
+
*/
|
|
238
|
+
prestart?: string;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
Run with the `npm start` command.
|
|
242
|
+
*/
|
|
243
|
+
start?: string;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
Run with the `npm start` command, after `start`.
|
|
247
|
+
*/
|
|
248
|
+
poststart?: string;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
Run with the `npm restart` command, before `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
|
|
252
|
+
*/
|
|
253
|
+
prerestart?: string;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
Run with the `npm restart` command. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
|
|
257
|
+
*/
|
|
258
|
+
restart?: string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
Run with the `npm restart` command, after `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
|
|
262
|
+
*/
|
|
263
|
+
postrestart?: string;
|
|
264
|
+
} & Partial<Record<string, string>>;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
Dependencies of the package. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or Git URL.
|
|
268
|
+
*/
|
|
269
|
+
export type Dependency = Partial<Record<string, string>>;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
Conditions which provide a way to resolve a package entry point based on the environment.
|
|
273
|
+
*/
|
|
274
|
+
export type ExportCondition = LiteralUnion<
|
|
275
|
+
| 'import'
|
|
276
|
+
| 'require'
|
|
277
|
+
| 'node'
|
|
278
|
+
| 'node-addons'
|
|
279
|
+
| 'deno'
|
|
280
|
+
| 'browser'
|
|
281
|
+
| 'electron'
|
|
282
|
+
| 'react-native'
|
|
283
|
+
| 'default',
|
|
284
|
+
string
|
|
285
|
+
>;
|
|
286
|
+
|
|
287
|
+
type ExportConditions = {[condition in ExportCondition]: Exports};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
Entry points of a module, optionally with conditions and subpath exports.
|
|
291
|
+
*/
|
|
292
|
+
export type Exports =
|
|
293
|
+
| null
|
|
294
|
+
| string
|
|
295
|
+
| Array<string | ExportConditions>
|
|
296
|
+
| ExportConditions
|
|
297
|
+
| {[path: string]: Exports}; // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
Import map entries of a module, optionally with conditions.
|
|
301
|
+
*/
|
|
302
|
+
export type Imports = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
303
|
+
[key: string]: string | {[key in ExportCondition]: Exports};
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export interface NonStandardEntryPoints {
|
|
307
|
+
/**
|
|
308
|
+
An ECMAScript module ID that is the primary entry point to the program.
|
|
309
|
+
*/
|
|
310
|
+
module?: string;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
A module ID with untranspiled code that is the primary entry point to the program.
|
|
314
|
+
*/
|
|
315
|
+
esnext?:
|
|
316
|
+
| string
|
|
317
|
+
| {
|
|
318
|
+
[moduleName: string]: string | undefined;
|
|
319
|
+
main?: string;
|
|
320
|
+
browser?: string;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
A hint to JavaScript bundlers or component tools when packaging modules for client side use.
|
|
325
|
+
*/
|
|
326
|
+
browser?:
|
|
327
|
+
| string
|
|
328
|
+
| Partial<Record<string, string | false>>;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.
|
|
332
|
+
|
|
333
|
+
[Read more.](https://webpack.js.org/guides/tree-shaking/)
|
|
334
|
+
*/
|
|
335
|
+
sideEffects?: boolean | string[];
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface TypeScriptConfiguration {
|
|
339
|
+
/**
|
|
340
|
+
Location of the bundled TypeScript declaration file.
|
|
341
|
+
*/
|
|
342
|
+
types?: string;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
Version selection map of TypeScript.
|
|
346
|
+
*/
|
|
347
|
+
typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
Location of the bundled TypeScript declaration file. Alias of `types`.
|
|
351
|
+
*/
|
|
352
|
+
typings?: string;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
An alternative configuration for Yarn workspaces.
|
|
357
|
+
*/
|
|
358
|
+
export interface WorkspaceConfig {
|
|
359
|
+
/**
|
|
360
|
+
An array of workspace pattern strings which contain the workspace packages.
|
|
361
|
+
*/
|
|
362
|
+
packages?: WorkspacePattern[];
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns.
|
|
366
|
+
|
|
367
|
+
[Read more](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/)
|
|
368
|
+
*/
|
|
369
|
+
nohoist?: WorkspacePattern[];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process.
|
|
374
|
+
|
|
375
|
+
The patterns are handled with [minimatch](https://github.com/isaacs/minimatch).
|
|
376
|
+
|
|
377
|
+
@example
|
|
378
|
+
`docs` → Include the docs directory and install its dependencies.
|
|
379
|
+
`packages/*` → Include all nested directories within the packages directory, like `packages/cli` and `packages/core`.
|
|
380
|
+
*/
|
|
381
|
+
type WorkspacePattern = string;
|
|
382
|
+
|
|
383
|
+
export interface YarnConfiguration {
|
|
384
|
+
/**
|
|
385
|
+
Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
|
|
386
|
+
|
|
387
|
+
Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass.
|
|
388
|
+
|
|
389
|
+
Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
|
|
390
|
+
*/
|
|
391
|
+
workspaces?: WorkspacePattern[] | WorkspaceConfig;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`.
|
|
395
|
+
|
|
396
|
+
Note that if your `package.json` contains `"flat": true` and other packages depend on yours (e.g. you are building a library rather than an app), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line.
|
|
397
|
+
*/
|
|
398
|
+
flat?: boolean;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
|
|
402
|
+
*/
|
|
403
|
+
resolutions?: Dependency;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export interface JSPMConfiguration {
|
|
407
|
+
/**
|
|
408
|
+
JSPM configuration.
|
|
409
|
+
*/
|
|
410
|
+
jspm?: PackageJson$1;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Containing standard npm properties.
|
|
415
|
+
*/
|
|
416
|
+
export interface PackageJsonStandard {
|
|
417
|
+
/**
|
|
418
|
+
The name of the package.
|
|
419
|
+
*/
|
|
420
|
+
name?: string;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
Package version, parseable by [`node-semver`](https://github.com/npm/node-semver).
|
|
424
|
+
*/
|
|
425
|
+
version?: string;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
Package description, listed in `npm search`.
|
|
429
|
+
*/
|
|
430
|
+
description?: string;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
Keywords associated with package, listed in `npm search`.
|
|
434
|
+
*/
|
|
435
|
+
keywords?: string[];
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
The URL to the package's homepage.
|
|
439
|
+
*/
|
|
440
|
+
homepage?: LiteralUnion<'.', string>;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
The URL to the package's issue tracker and/or the email address to which issues should be reported.
|
|
444
|
+
*/
|
|
445
|
+
bugs?: BugsLocation;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
The license for the package.
|
|
449
|
+
*/
|
|
450
|
+
license?: string;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
The licenses for the package.
|
|
454
|
+
*/
|
|
455
|
+
licenses?: Array<{
|
|
456
|
+
type?: string;
|
|
457
|
+
url?: string;
|
|
458
|
+
}>;
|
|
459
|
+
|
|
460
|
+
author?: Person;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
A list of people who contributed to the package.
|
|
464
|
+
*/
|
|
465
|
+
contributors?: Person[];
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
A list of people who maintain the package.
|
|
469
|
+
*/
|
|
470
|
+
maintainers?: Person[];
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
The files included in the package.
|
|
474
|
+
*/
|
|
475
|
+
files?: string[];
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
Resolution algorithm for importing ".js" files from the package's scope.
|
|
479
|
+
|
|
480
|
+
[Read more.](https://nodejs.org/api/esm.html#esm_package_json_type_field)
|
|
481
|
+
*/
|
|
482
|
+
type?: 'module' | 'commonjs';
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
The module ID that is the primary entry point to the program.
|
|
486
|
+
*/
|
|
487
|
+
main?: string;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
Subpath exports to define entry points of the package.
|
|
491
|
+
|
|
492
|
+
[Read more.](https://nodejs.org/api/packages.html#subpath-exports)
|
|
493
|
+
*/
|
|
494
|
+
exports?: Exports;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
Subpath imports to define internal package import maps that only apply to import specifiers from within the package itself.
|
|
498
|
+
|
|
499
|
+
[Read more.](https://nodejs.org/api/packages.html#subpath-imports)
|
|
500
|
+
*/
|
|
501
|
+
imports?: Imports;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
The executable files that should be installed into the `PATH`.
|
|
505
|
+
*/
|
|
506
|
+
bin?:
|
|
507
|
+
| string
|
|
508
|
+
| Partial<Record<string, string>>;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
Filenames to put in place for the `man` program to find.
|
|
512
|
+
*/
|
|
513
|
+
man?: string | string[];
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
Indicates the structure of the package.
|
|
517
|
+
*/
|
|
518
|
+
directories?: DirectoryLocations;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
Location for the code repository.
|
|
522
|
+
*/
|
|
523
|
+
repository?:
|
|
524
|
+
| string
|
|
525
|
+
| {
|
|
526
|
+
type: string;
|
|
527
|
+
url: string;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
Relative path to package.json if it is placed in non-root directory (for example if it is part of a monorepo).
|
|
531
|
+
|
|
532
|
+
[Read more.](https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md)
|
|
533
|
+
*/
|
|
534
|
+
directory?: string;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
Script commands that are run at various times in the lifecycle of the package. The key is the lifecycle event, and the value is the command to run at that point.
|
|
539
|
+
*/
|
|
540
|
+
scripts?: Scripts;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
Is used to set configuration parameters used in package scripts that persist across upgrades.
|
|
544
|
+
*/
|
|
545
|
+
config?: Record<string, unknown>;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
The dependencies of the package.
|
|
549
|
+
*/
|
|
550
|
+
dependencies?: Dependency;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.
|
|
554
|
+
*/
|
|
555
|
+
devDependencies?: Dependency;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
Dependencies that are skipped if they fail to install.
|
|
559
|
+
*/
|
|
560
|
+
optionalDependencies?: Dependency;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
Dependencies that will usually be required by the package user directly or via another dependency.
|
|
564
|
+
*/
|
|
565
|
+
peerDependencies?: Dependency;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
Indicate peer dependencies that are optional.
|
|
569
|
+
*/
|
|
570
|
+
peerDependenciesMeta?: Partial<Record<string, {optional: true}>>;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
Package names that are bundled when the package is published.
|
|
574
|
+
*/
|
|
575
|
+
bundledDependencies?: string[];
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
Alias of `bundledDependencies`.
|
|
579
|
+
*/
|
|
580
|
+
bundleDependencies?: string[];
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
Engines that this package runs on.
|
|
584
|
+
*/
|
|
585
|
+
engines?: {
|
|
586
|
+
[EngineName in 'npm' | 'node' | string]?: string;
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
@deprecated
|
|
591
|
+
*/
|
|
592
|
+
engineStrict?: boolean;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
Operating systems the module runs on.
|
|
596
|
+
*/
|
|
597
|
+
os?: Array<LiteralUnion<
|
|
598
|
+
| 'aix'
|
|
599
|
+
| 'darwin'
|
|
600
|
+
| 'freebsd'
|
|
601
|
+
| 'linux'
|
|
602
|
+
| 'openbsd'
|
|
603
|
+
| 'sunos'
|
|
604
|
+
| 'win32'
|
|
605
|
+
| '!aix'
|
|
606
|
+
| '!darwin'
|
|
607
|
+
| '!freebsd'
|
|
608
|
+
| '!linux'
|
|
609
|
+
| '!openbsd'
|
|
610
|
+
| '!sunos'
|
|
611
|
+
| '!win32',
|
|
612
|
+
string
|
|
613
|
+
>>;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
CPU architectures the module runs on.
|
|
617
|
+
*/
|
|
618
|
+
cpu?: Array<LiteralUnion<
|
|
619
|
+
| 'arm'
|
|
620
|
+
| 'arm64'
|
|
621
|
+
| 'ia32'
|
|
622
|
+
| 'mips'
|
|
623
|
+
| 'mipsel'
|
|
624
|
+
| 'ppc'
|
|
625
|
+
| 'ppc64'
|
|
626
|
+
| 's390'
|
|
627
|
+
| 's390x'
|
|
628
|
+
| 'x32'
|
|
629
|
+
| 'x64'
|
|
630
|
+
| '!arm'
|
|
631
|
+
| '!arm64'
|
|
632
|
+
| '!ia32'
|
|
633
|
+
| '!mips'
|
|
634
|
+
| '!mipsel'
|
|
635
|
+
| '!ppc'
|
|
636
|
+
| '!ppc64'
|
|
637
|
+
| '!s390'
|
|
638
|
+
| '!s390x'
|
|
639
|
+
| '!x32'
|
|
640
|
+
| '!x64',
|
|
641
|
+
string
|
|
642
|
+
>>;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
If set to `true`, a warning will be shown if package is installed locally. Useful if the package is primarily a command-line application that should be installed globally.
|
|
646
|
+
|
|
647
|
+
@deprecated
|
|
648
|
+
*/
|
|
649
|
+
preferGlobal?: boolean;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
If set to `true`, then npm will refuse to publish it.
|
|
653
|
+
*/
|
|
654
|
+
private?: boolean;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default.
|
|
658
|
+
*/
|
|
659
|
+
publishConfig?: PublishConfig;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
Describes and notifies consumers of a package's monetary support information.
|
|
663
|
+
|
|
664
|
+
[Read more.](https://github.com/npm/rfcs/blob/latest/accepted/0017-add-funding-support.md)
|
|
665
|
+
*/
|
|
666
|
+
funding?: string | {
|
|
667
|
+
/**
|
|
668
|
+
The type of funding.
|
|
669
|
+
*/
|
|
670
|
+
type?: LiteralUnion<
|
|
671
|
+
| 'github'
|
|
672
|
+
| 'opencollective'
|
|
673
|
+
| 'patreon'
|
|
674
|
+
| 'individual'
|
|
675
|
+
| 'foundation'
|
|
676
|
+
| 'corporation',
|
|
677
|
+
string
|
|
678
|
+
>;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
The URL to the funding page.
|
|
682
|
+
*/
|
|
683
|
+
url: string;
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export interface PublishConfig {
|
|
688
|
+
/**
|
|
689
|
+
Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
|
|
690
|
+
*/
|
|
691
|
+
[additionalProperties: string]: unknown;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
|
|
695
|
+
*/
|
|
696
|
+
access?: 'public' | 'restricted';
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
The base URL of the npm registry.
|
|
700
|
+
|
|
701
|
+
Default: `'https://registry.npmjs.org/'`
|
|
702
|
+
*/
|
|
703
|
+
registry?: string;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
The tag to publish the package under.
|
|
707
|
+
|
|
708
|
+
Default: `'latest'`
|
|
709
|
+
*/
|
|
710
|
+
tag?: string;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
|
|
716
|
+
|
|
717
|
+
@category File
|
|
718
|
+
*/
|
|
719
|
+
type PackageJson$1 =
|
|
720
|
+
PackageJson$1.PackageJsonStandard &
|
|
721
|
+
PackageJson$1.NonStandardEntryPoints &
|
|
722
|
+
PackageJson$1.TypeScriptConfiguration &
|
|
723
|
+
PackageJson$1.YarnConfiguration &
|
|
724
|
+
PackageJson$1.JSPMConfiguration;
|
|
725
|
+
|
|
726
|
+
type DateNow = number;
|
|
727
|
+
type TestProviderConfig = Addon_TestProviderType$1;
|
|
728
|
+
type TestingModuleProgressReportProgress = {
|
|
729
|
+
startedAt: DateNow;
|
|
730
|
+
finishedAt?: DateNow;
|
|
731
|
+
numTotalTests?: number;
|
|
732
|
+
numPassedTests?: number;
|
|
733
|
+
numFailedTests?: number;
|
|
734
|
+
numPendingTests?: number;
|
|
735
|
+
percentageCompleted?: number;
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* A URL pathname, beginning with a /.
|
|
740
|
+
*
|
|
741
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
|
|
742
|
+
*/
|
|
743
|
+
declare type Pathname = string;
|
|
744
|
+
/**
|
|
745
|
+
* A URL search string, beginning with a ?.
|
|
746
|
+
*
|
|
747
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
|
|
748
|
+
*/
|
|
749
|
+
declare type Search = string;
|
|
750
|
+
/**
|
|
751
|
+
* A URL fragment identifier, beginning with a #.
|
|
752
|
+
*
|
|
753
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
|
|
754
|
+
*/
|
|
755
|
+
declare type Hash = string;
|
|
756
|
+
/**
|
|
757
|
+
* A unique string associated with a location. May be used to safely store
|
|
758
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
759
|
+
*
|
|
760
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
|
|
761
|
+
*/
|
|
762
|
+
declare type Key = string;
|
|
763
|
+
/**
|
|
764
|
+
* The pathname, search, and hash values of a URL.
|
|
765
|
+
*/
|
|
766
|
+
interface Path$1 {
|
|
767
|
+
/**
|
|
768
|
+
* A URL pathname, beginning with a /.
|
|
769
|
+
*
|
|
770
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
|
|
771
|
+
*/
|
|
772
|
+
pathname: Pathname;
|
|
773
|
+
/**
|
|
774
|
+
* A URL search string, beginning with a ?.
|
|
775
|
+
*
|
|
776
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
|
|
777
|
+
*/
|
|
778
|
+
search: Search;
|
|
779
|
+
/**
|
|
780
|
+
* A URL fragment identifier, beginning with a #.
|
|
781
|
+
*
|
|
782
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
|
|
783
|
+
*/
|
|
784
|
+
hash: Hash;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* An entry in a history stack. A location contains information about the
|
|
788
|
+
* URL path, as well as possibly some arbitrary state and a key.
|
|
789
|
+
*
|
|
790
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location
|
|
791
|
+
*/
|
|
792
|
+
interface Location extends Path$1 {
|
|
793
|
+
/**
|
|
794
|
+
* A value of arbitrary data associated with this location.
|
|
795
|
+
*
|
|
796
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.state
|
|
797
|
+
*/
|
|
798
|
+
state: unknown;
|
|
799
|
+
/**
|
|
800
|
+
* A unique string associated with this location. May be used to safely store
|
|
801
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
802
|
+
*
|
|
803
|
+
* Note: This value is always "default" on the initial location.
|
|
804
|
+
*
|
|
805
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
|
|
806
|
+
*/
|
|
807
|
+
key: Key;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Describes a location that is the destination of some navigation, either via
|
|
811
|
+
* `history.push` or `history.replace`. May be either a URL or the pieces of a
|
|
812
|
+
* URL path.
|
|
813
|
+
*/
|
|
814
|
+
declare type To = string | Partial<Path$1>;
|
|
815
|
+
|
|
816
|
+
interface NavigateOptions$1 {
|
|
817
|
+
replace?: boolean;
|
|
818
|
+
state?: any;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
interface StoryData {
|
|
822
|
+
viewMode?: string;
|
|
823
|
+
storyId?: string;
|
|
824
|
+
refId?: string;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
interface Other extends StoryData {
|
|
828
|
+
path: string;
|
|
829
|
+
singleStory?: boolean;
|
|
830
|
+
}
|
|
831
|
+
type NavigateOptions = NavigateOptions$1 & {
|
|
832
|
+
plain?: boolean;
|
|
833
|
+
};
|
|
834
|
+
type NavigateFunction = (to: To | number, options?: NavigateOptions) => void;
|
|
835
|
+
type RouterData = {
|
|
836
|
+
location: Partial<Location>;
|
|
837
|
+
navigate: NavigateFunction;
|
|
838
|
+
} & Other;
|
|
839
|
+
type RenderData = Pick<RouterData, 'location'> & Other;
|
|
840
|
+
|
|
841
|
+
interface ThemeVars extends ThemeVarsBase, ThemeVarsColors {
|
|
842
|
+
}
|
|
843
|
+
interface ThemeVarsBase {
|
|
844
|
+
base: 'light' | 'dark';
|
|
845
|
+
}
|
|
846
|
+
interface ThemeVarsColors {
|
|
847
|
+
colorPrimary: string;
|
|
848
|
+
colorSecondary: string;
|
|
849
|
+
appBg: string;
|
|
850
|
+
appContentBg: string;
|
|
851
|
+
appPreviewBg: string;
|
|
852
|
+
appBorderColor: string;
|
|
853
|
+
appBorderRadius: number;
|
|
854
|
+
fontBase: string;
|
|
855
|
+
fontCode: string;
|
|
856
|
+
textColor: string;
|
|
857
|
+
textInverseColor: string;
|
|
858
|
+
textMutedColor: string;
|
|
859
|
+
barTextColor: string;
|
|
860
|
+
barHoverColor: string;
|
|
861
|
+
barSelectedColor: string;
|
|
862
|
+
barBg: string;
|
|
863
|
+
buttonBg: string;
|
|
864
|
+
buttonBorder: string;
|
|
865
|
+
booleanBg: string;
|
|
866
|
+
booleanSelectedBg: string;
|
|
867
|
+
inputBg: string;
|
|
868
|
+
inputBorder: string;
|
|
869
|
+
inputTextColor: string;
|
|
870
|
+
inputBorderRadius: number;
|
|
871
|
+
brandTitle?: string;
|
|
872
|
+
brandUrl?: string;
|
|
873
|
+
brandImage?: string;
|
|
874
|
+
brandTarget?: string;
|
|
875
|
+
gridCellSize?: number;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
type ChannelHandler = (event: ChannelEvent) => void;
|
|
879
|
+
interface ChannelTransport {
|
|
880
|
+
send(event: ChannelEvent, options?: any): void;
|
|
881
|
+
setHandler(handler: ChannelHandler): void;
|
|
882
|
+
}
|
|
883
|
+
interface ChannelEvent {
|
|
884
|
+
type: string;
|
|
885
|
+
from: string;
|
|
886
|
+
args: any[];
|
|
887
|
+
}
|
|
888
|
+
interface Listener {
|
|
889
|
+
(...args: any[]): void;
|
|
890
|
+
}
|
|
891
|
+
interface ChannelArgsSingle {
|
|
892
|
+
transport?: ChannelTransport;
|
|
893
|
+
async?: boolean;
|
|
894
|
+
}
|
|
895
|
+
interface ChannelArgsMulti {
|
|
896
|
+
transports: ChannelTransport[];
|
|
897
|
+
async?: boolean;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
declare class Channel {
|
|
901
|
+
readonly isAsync: boolean;
|
|
902
|
+
private sender;
|
|
903
|
+
private events;
|
|
904
|
+
private data;
|
|
905
|
+
private readonly transports;
|
|
906
|
+
constructor(input: ChannelArgsMulti);
|
|
907
|
+
constructor(input: ChannelArgsSingle);
|
|
908
|
+
get hasTransport(): boolean;
|
|
909
|
+
addListener(eventName: string, listener: Listener): void;
|
|
910
|
+
emit(eventName: string, ...args: any): void;
|
|
911
|
+
last(eventName: string): any;
|
|
912
|
+
eventNames(): string[];
|
|
913
|
+
listenerCount(eventName: string): number;
|
|
914
|
+
listeners(eventName: string): Listener[] | undefined;
|
|
915
|
+
once(eventName: string, listener: Listener): void;
|
|
916
|
+
removeAllListeners(eventName?: string): void;
|
|
917
|
+
removeListener(eventName: string, listener: Listener): void;
|
|
918
|
+
on(eventName: string, listener: Listener): void;
|
|
919
|
+
off(eventName: string, listener: Listener): void;
|
|
920
|
+
private handleEvent;
|
|
921
|
+
private onceListener;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
interface Options$1 {
|
|
925
|
+
allowRegExp: boolean;
|
|
926
|
+
allowFunction: boolean;
|
|
927
|
+
allowSymbol: boolean;
|
|
928
|
+
allowDate: boolean;
|
|
929
|
+
allowUndefined: boolean;
|
|
930
|
+
allowClass: boolean;
|
|
931
|
+
allowError: boolean;
|
|
932
|
+
maxDepth: number;
|
|
933
|
+
space: number | undefined;
|
|
934
|
+
lazyEval: boolean;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
type ExportName = string;
|
|
938
|
+
type MetaId = string;
|
|
939
|
+
interface StoriesSpecifier {
|
|
940
|
+
/** When auto-titling, what to prefix all generated titles with (default: '') */
|
|
941
|
+
titlePrefix?: string;
|
|
942
|
+
/** Where to start looking for story files */
|
|
943
|
+
directory: string;
|
|
944
|
+
/**
|
|
945
|
+
* What does the filename of a story file look like? (a glob, relative to directory, no leading
|
|
946
|
+
* `./`) If unset, we use `** / *.@(mdx|stories.@(mdx|js|jsx|mjs|ts|tsx))` (no spaces)
|
|
947
|
+
*/
|
|
948
|
+
files?: string;
|
|
949
|
+
}
|
|
950
|
+
type StoriesEntry = string | StoriesSpecifier;
|
|
951
|
+
type NormalizedStoriesSpecifier = Required<StoriesSpecifier> & {
|
|
952
|
+
importPathMatcher: RegExp;
|
|
953
|
+
};
|
|
954
|
+
interface IndexerOptions {
|
|
955
|
+
makeTitle: (userTitle?: string) => string;
|
|
956
|
+
}
|
|
957
|
+
interface IndexedStory {
|
|
958
|
+
id: string;
|
|
959
|
+
name: string;
|
|
960
|
+
tags?: Tag$1[];
|
|
961
|
+
parameters?: Parameters;
|
|
962
|
+
}
|
|
963
|
+
interface IndexedCSFFile {
|
|
964
|
+
meta: {
|
|
965
|
+
id?: string;
|
|
966
|
+
title?: string;
|
|
967
|
+
tags?: Tag$1[];
|
|
968
|
+
};
|
|
969
|
+
stories: IndexedStory[];
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* FIXME: This is a temporary type to allow us to deprecate the old indexer API. We should remove
|
|
973
|
+
* this type and the deprecated indexer API in 8.0.
|
|
974
|
+
*/
|
|
975
|
+
type BaseIndexer = {
|
|
976
|
+
/** A regular expression that should match all files to be handled by this indexer */
|
|
977
|
+
test: RegExp;
|
|
978
|
+
};
|
|
979
|
+
/**
|
|
980
|
+
* An indexer describes which filenames it handles, and how to index each individual file - turning
|
|
981
|
+
* it into an entry in the index.
|
|
982
|
+
*/
|
|
983
|
+
type Indexer = BaseIndexer & {
|
|
984
|
+
/**
|
|
985
|
+
* Indexes a file containing stories or docs.
|
|
986
|
+
*
|
|
987
|
+
* @param fileName The name of the file to index.
|
|
988
|
+
* @param options {@link IndexerOptions} for indexing the file.
|
|
989
|
+
* @returns A promise that resolves to an array of {@link IndexInput} objects.
|
|
990
|
+
*/
|
|
991
|
+
createIndex: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
|
|
992
|
+
};
|
|
993
|
+
interface BaseIndexEntry {
|
|
994
|
+
id: StoryId;
|
|
995
|
+
name: StoryName;
|
|
996
|
+
title: ComponentTitle;
|
|
997
|
+
tags?: Tag$1[];
|
|
998
|
+
importPath: Path;
|
|
999
|
+
}
|
|
1000
|
+
type StoryIndexEntry = BaseIndexEntry & {
|
|
1001
|
+
type: 'story';
|
|
1002
|
+
};
|
|
1003
|
+
type DocsIndexEntry = BaseIndexEntry & {
|
|
1004
|
+
storiesImports: Path[];
|
|
1005
|
+
type: 'docs';
|
|
1006
|
+
};
|
|
1007
|
+
type IndexEntry = StoryIndexEntry | DocsIndexEntry;
|
|
1008
|
+
interface IndexInputStats {
|
|
1009
|
+
loaders?: boolean;
|
|
1010
|
+
play?: boolean;
|
|
1011
|
+
render?: boolean;
|
|
1012
|
+
storyFn?: boolean;
|
|
1013
|
+
mount?: boolean;
|
|
1014
|
+
beforeEach?: boolean;
|
|
1015
|
+
moduleMock?: boolean;
|
|
1016
|
+
globals?: boolean;
|
|
1017
|
+
factory?: boolean;
|
|
1018
|
+
tags?: boolean;
|
|
1019
|
+
}
|
|
1020
|
+
/** The base input for indexing a story or docs entry. */
|
|
1021
|
+
type BaseIndexInput = {
|
|
1022
|
+
/** The file to import from e.g. the story file. */
|
|
1023
|
+
importPath: Path;
|
|
1024
|
+
/** The raw path/package of the file that provides meta.component, if one exists */
|
|
1025
|
+
rawComponentPath?: Path;
|
|
1026
|
+
/** The name of the export to import. */
|
|
1027
|
+
exportName: ExportName;
|
|
1028
|
+
/** The name of the entry, auto-generated from {@link exportName} if unspecified. */
|
|
1029
|
+
name?: StoryName;
|
|
1030
|
+
/** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
|
|
1031
|
+
title?: ComponentTitle;
|
|
1032
|
+
/**
|
|
1033
|
+
* The custom id optionally set at `meta.id` if it needs to differ from the id generated via
|
|
1034
|
+
* {@link title}. If unspecified, the meta id will be auto-generated from {@link title}. If
|
|
1035
|
+
* specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly
|
|
1036
|
+
* matched.
|
|
1037
|
+
*/
|
|
1038
|
+
metaId?: MetaId;
|
|
1039
|
+
/** Tags for filtering entries in Storybook and its tools. */
|
|
1040
|
+
tags?: Tag$1[];
|
|
1041
|
+
/**
|
|
1042
|
+
* The id of the entry, auto-generated from {@link title}/{@link metaId} and {@link exportName} if
|
|
1043
|
+
* unspecified. If specified, the story in the CSF file _must_ have a matching id set at
|
|
1044
|
+
* `parameters.__id`, to be correctly matched. Only use this if you need to override the
|
|
1045
|
+
* auto-generated id.
|
|
1046
|
+
*/
|
|
1047
|
+
__id?: StoryId;
|
|
1048
|
+
/** Stats about language feature usage that the indexer can optionally report */
|
|
1049
|
+
__stats?: IndexInputStats;
|
|
1050
|
+
};
|
|
1051
|
+
/** The input for indexing a story entry. */
|
|
1052
|
+
type StoryIndexInput = BaseIndexInput & {
|
|
1053
|
+
type: 'story';
|
|
1054
|
+
};
|
|
1055
|
+
/** The input for indexing a docs entry. */
|
|
1056
|
+
type DocsIndexInput = BaseIndexInput & {
|
|
1057
|
+
type: 'docs';
|
|
1058
|
+
/** Paths to story files that must be pre-loaded for this docs entry. */
|
|
1059
|
+
storiesImports?: Path[];
|
|
1060
|
+
};
|
|
1061
|
+
type IndexInput = StoryIndexInput | DocsIndexInput;
|
|
1062
|
+
interface V3CompatIndexEntry extends Omit<StoryIndexEntry, 'type' | 'tags'> {
|
|
1063
|
+
kind: ComponentTitle;
|
|
1064
|
+
story: StoryName;
|
|
1065
|
+
parameters: Parameters;
|
|
1066
|
+
}
|
|
1067
|
+
interface StoryIndexV2 {
|
|
1068
|
+
v: number;
|
|
1069
|
+
stories: Record<StoryId, Omit<V3CompatIndexEntry, 'title' | 'name' | 'importPath'> & {
|
|
1070
|
+
name?: StoryName;
|
|
1071
|
+
}>;
|
|
1072
|
+
}
|
|
1073
|
+
interface StoryIndexV3 {
|
|
1074
|
+
v: number;
|
|
1075
|
+
stories: Record<StoryId, V3CompatIndexEntry>;
|
|
1076
|
+
}
|
|
1077
|
+
interface StoryIndex {
|
|
1078
|
+
v: number;
|
|
1079
|
+
entries: Record<StoryId, IndexEntry>;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/** ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now! */
|
|
1083
|
+
type BuilderName = 'webpack5' | '@storybook/builder-webpack5' | string;
|
|
1084
|
+
type RendererName = string;
|
|
1085
|
+
interface ServerChannel {
|
|
1086
|
+
emit(type: string, args?: any): void;
|
|
1087
|
+
}
|
|
1088
|
+
interface CoreConfig {
|
|
1089
|
+
builder?: BuilderName | {
|
|
1090
|
+
name: BuilderName;
|
|
1091
|
+
options?: Record<string, any>;
|
|
1092
|
+
};
|
|
1093
|
+
renderer?: RendererName;
|
|
1094
|
+
disableWebpackDefaults?: boolean;
|
|
1095
|
+
channelOptions?: Partial<Options$1>;
|
|
1096
|
+
/** Disables the generation of project.json, a file containing Storybook metadata */
|
|
1097
|
+
disableProjectJson?: boolean;
|
|
1098
|
+
/**
|
|
1099
|
+
* Disables Storybook telemetry
|
|
1100
|
+
*
|
|
1101
|
+
* @see https://storybook.js.org/telemetry
|
|
1102
|
+
*/
|
|
1103
|
+
disableTelemetry?: boolean;
|
|
1104
|
+
/** Disables notifications for Storybook updates. */
|
|
1105
|
+
disableWhatsNewNotifications?: boolean;
|
|
1106
|
+
/**
|
|
1107
|
+
* Enable crash reports to be sent to Storybook telemetry
|
|
1108
|
+
*
|
|
1109
|
+
* @see https://storybook.js.org/telemetry
|
|
1110
|
+
*/
|
|
1111
|
+
enableCrashReports?: boolean;
|
|
1112
|
+
/**
|
|
1113
|
+
* Enable CORS headings to run document in a "secure context" see:
|
|
1114
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
|
|
1115
|
+
* This enables these headers in development-mode: Cross-Origin-Opener-Policy: same-origin
|
|
1116
|
+
*
|
|
1117
|
+
* ```text
|
|
1118
|
+
* Cross-Origin-Embedder-Policy: require-corp
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
crossOriginIsolated?: boolean;
|
|
1122
|
+
}
|
|
1123
|
+
interface DirectoryMapping {
|
|
1124
|
+
from: string;
|
|
1125
|
+
to: string;
|
|
1126
|
+
}
|
|
1127
|
+
interface Presets {
|
|
1128
|
+
apply(extension: 'typescript', config: TypescriptOptions, args?: Options): Promise<TypescriptOptions>;
|
|
1129
|
+
apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
|
|
1130
|
+
apply(extension: 'babel', config?: {}, args?: any): Promise<any>;
|
|
1131
|
+
apply(extension: 'swc', config?: {}, args?: any): Promise<any>;
|
|
1132
|
+
apply(extension: 'entries', config?: [], args?: any): Promise<unknown>;
|
|
1133
|
+
apply(extension: 'env', config?: {}, args?: any): Promise<any>;
|
|
1134
|
+
apply(extension: 'stories', config?: [], args?: any): Promise<StoriesEntry[]>;
|
|
1135
|
+
apply(extension: 'managerEntries', config: [], args?: any): Promise<string[]>;
|
|
1136
|
+
apply(extension: 'refs', config?: [], args?: any): Promise<StorybookConfigRaw['refs']>;
|
|
1137
|
+
apply(extension: 'core', config?: StorybookConfigRaw['core'], args?: any): Promise<NonNullable<StorybookConfigRaw['core']>>;
|
|
1138
|
+
apply(extension: 'docs', config?: StorybookConfigRaw['docs'], args?: any): Promise<NonNullable<StorybookConfigRaw['docs']>>;
|
|
1139
|
+
apply(extension: 'features', config?: StorybookConfigRaw['features'], args?: any): Promise<NonNullable<StorybookConfigRaw['features']>>;
|
|
1140
|
+
apply(extension: 'typescript', config?: StorybookConfigRaw['typescript'], args?: any): Promise<NonNullable<StorybookConfigRaw['typescript']>>;
|
|
1141
|
+
apply(extension: 'build', config?: StorybookConfigRaw['build'], args?: any): Promise<NonNullable<StorybookConfigRaw['build']>>;
|
|
1142
|
+
apply(extension: 'staticDirs', config?: StorybookConfigRaw['staticDirs'], args?: any): Promise<StorybookConfigRaw['staticDirs']>;
|
|
1143
|
+
apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
|
|
1144
|
+
}
|
|
1145
|
+
interface LoadedPreset {
|
|
1146
|
+
name: string;
|
|
1147
|
+
preset: any;
|
|
1148
|
+
options: any;
|
|
1149
|
+
}
|
|
1150
|
+
type PresetConfig = string | {
|
|
1151
|
+
name: string;
|
|
1152
|
+
options?: unknown;
|
|
1153
|
+
};
|
|
1154
|
+
interface Ref {
|
|
1155
|
+
id: string;
|
|
1156
|
+
url: string;
|
|
1157
|
+
title: string;
|
|
1158
|
+
version: string;
|
|
1159
|
+
type?: string;
|
|
1160
|
+
disable?: boolean;
|
|
1161
|
+
}
|
|
1162
|
+
interface VersionCheck {
|
|
1163
|
+
success: boolean;
|
|
1164
|
+
cached: boolean;
|
|
1165
|
+
data?: any;
|
|
1166
|
+
error?: any;
|
|
1167
|
+
time: number;
|
|
1168
|
+
}
|
|
1169
|
+
interface Stats {
|
|
1170
|
+
toJson: () => any;
|
|
1171
|
+
}
|
|
1172
|
+
interface BuilderResult {
|
|
1173
|
+
totalTime?: ReturnType<typeof process.hrtime>;
|
|
1174
|
+
stats?: Stats;
|
|
1175
|
+
}
|
|
1176
|
+
type PackageJson = PackageJson$1 & Record<string, any>;
|
|
1177
|
+
interface LoadOptions {
|
|
1178
|
+
packageJson?: PackageJson;
|
|
1179
|
+
outputDir?: string;
|
|
1180
|
+
configDir?: string;
|
|
1181
|
+
cacheKey?: string;
|
|
1182
|
+
ignorePreview?: boolean;
|
|
1183
|
+
extendServer?: (server: Server) => void;
|
|
1184
|
+
}
|
|
1185
|
+
interface CLIBaseOptions {
|
|
1186
|
+
disableTelemetry?: boolean;
|
|
1187
|
+
enableCrashReports?: boolean;
|
|
1188
|
+
configDir?: string;
|
|
1189
|
+
loglevel?: string;
|
|
1190
|
+
quiet?: boolean;
|
|
1191
|
+
}
|
|
1192
|
+
interface CLIOptions extends CLIBaseOptions {
|
|
1193
|
+
port?: number;
|
|
1194
|
+
ignorePreview?: boolean;
|
|
1195
|
+
previewUrl?: string;
|
|
1196
|
+
forceBuildPreview?: boolean;
|
|
1197
|
+
host?: string;
|
|
1198
|
+
initialPath?: string;
|
|
1199
|
+
exactPort?: boolean;
|
|
1200
|
+
https?: boolean;
|
|
1201
|
+
sslCa?: string[];
|
|
1202
|
+
sslCert?: string;
|
|
1203
|
+
sslKey?: string;
|
|
1204
|
+
smokeTest?: boolean;
|
|
1205
|
+
managerCache?: boolean;
|
|
1206
|
+
open?: boolean;
|
|
1207
|
+
ci?: boolean;
|
|
1208
|
+
versionUpdates?: boolean;
|
|
1209
|
+
docs?: boolean;
|
|
1210
|
+
test?: boolean;
|
|
1211
|
+
debugWebpack?: boolean;
|
|
1212
|
+
webpackStatsJson?: string | boolean;
|
|
1213
|
+
statsJson?: string | boolean;
|
|
1214
|
+
outputDir?: string;
|
|
1215
|
+
}
|
|
1216
|
+
interface BuilderOptions {
|
|
1217
|
+
configType?: 'DEVELOPMENT' | 'PRODUCTION';
|
|
1218
|
+
ignorePreview?: boolean;
|
|
1219
|
+
cache?: FileSystemCache;
|
|
1220
|
+
configDir: string;
|
|
1221
|
+
docsMode?: boolean;
|
|
1222
|
+
features?: StorybookConfigRaw['features'];
|
|
1223
|
+
versionCheck?: VersionCheck;
|
|
1224
|
+
disableWebpackDefaults?: boolean;
|
|
1225
|
+
serverChannelUrl?: string;
|
|
1226
|
+
}
|
|
1227
|
+
interface StorybookConfigOptions {
|
|
1228
|
+
presets: Presets;
|
|
1229
|
+
presetsList?: LoadedPreset[];
|
|
1230
|
+
}
|
|
1231
|
+
type Options = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions & {
|
|
1232
|
+
build?: TestBuildConfig;
|
|
1233
|
+
};
|
|
1234
|
+
type Middleware<T extends IncomingMessage = IncomingMessage> = (req: T & IncomingMessage, res: ServerResponse, next: (err?: string | Error) => Promise<void> | void) => Promise<void> | void;
|
|
1235
|
+
interface ServerApp<T extends IncomingMessage = IncomingMessage> {
|
|
1236
|
+
server: Server$1;
|
|
1237
|
+
use(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1238
|
+
use(...handlers: Middleware<T>[]): this;
|
|
1239
|
+
get(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1240
|
+
post(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1241
|
+
put(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1242
|
+
patch(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1243
|
+
delete(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1244
|
+
head(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1245
|
+
options(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1246
|
+
connect(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1247
|
+
trace(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
|
|
1248
|
+
}
|
|
1249
|
+
interface Builder<Config, BuilderStats extends Stats = Stats> {
|
|
1250
|
+
getConfig: (options: Options) => Promise<Config>;
|
|
1251
|
+
start: (args: {
|
|
1252
|
+
options: Options;
|
|
1253
|
+
startTime: ReturnType<typeof process.hrtime>;
|
|
1254
|
+
router: ServerApp;
|
|
1255
|
+
server: Server;
|
|
1256
|
+
channel: ServerChannel;
|
|
1257
|
+
}) => Promise<void | {
|
|
1258
|
+
stats?: BuilderStats;
|
|
1259
|
+
totalTime: ReturnType<typeof process.hrtime>;
|
|
1260
|
+
bail: (e?: Error) => Promise<void>;
|
|
1261
|
+
}>;
|
|
1262
|
+
build: (arg: {
|
|
1263
|
+
options: Options;
|
|
1264
|
+
startTime: ReturnType<typeof process.hrtime>;
|
|
1265
|
+
}) => Promise<void | BuilderStats>;
|
|
1266
|
+
bail: (e?: Error) => Promise<void>;
|
|
1267
|
+
corePresets?: string[];
|
|
1268
|
+
overridePresets?: string[];
|
|
1269
|
+
}
|
|
1270
|
+
/** Options for TypeScript usage within Storybook. */
|
|
1271
|
+
interface TypescriptOptions {
|
|
1272
|
+
/**
|
|
1273
|
+
* Enables type checking within Storybook.
|
|
1274
|
+
*
|
|
1275
|
+
* @default `false`
|
|
1276
|
+
*/
|
|
1277
|
+
check: boolean;
|
|
1278
|
+
/**
|
|
1279
|
+
* Disable parsing TypeScript files through compiler.
|
|
1280
|
+
*
|
|
1281
|
+
* @default `false`
|
|
1282
|
+
*/
|
|
1283
|
+
skipCompiler: boolean;
|
|
1284
|
+
}
|
|
1285
|
+
type Preset = string | {
|
|
1286
|
+
name: string;
|
|
1287
|
+
options?: any;
|
|
1288
|
+
};
|
|
1289
|
+
/** An additional script that gets injected into the preview or the manager, */
|
|
1290
|
+
type Entry = string;
|
|
1291
|
+
type CoreCommon_StorybookRefs = Record<string, {
|
|
1292
|
+
title: string;
|
|
1293
|
+
url: string;
|
|
1294
|
+
} | {
|
|
1295
|
+
disable: boolean;
|
|
1296
|
+
expanded?: boolean;
|
|
1297
|
+
}>;
|
|
1298
|
+
type DocsOptions = {
|
|
1299
|
+
/** What should we call the generated docs entries? */
|
|
1300
|
+
defaultName?: string;
|
|
1301
|
+
/**
|
|
1302
|
+
* Should we generate a docs entry per CSF file? Set to 'tag' (the default) to generate an entry
|
|
1303
|
+
* for every CSF file with the 'autodocs' tag.
|
|
1304
|
+
*
|
|
1305
|
+
* @deprecated Use `tags: ['autodocs']` in `.storybook/preview.js` instead
|
|
1306
|
+
*/
|
|
1307
|
+
autodocs?: boolean | 'tag';
|
|
1308
|
+
/** Only show doc entries in the side bar (usually set with the `--docs` CLI flag) */
|
|
1309
|
+
docsMode?: boolean;
|
|
1310
|
+
};
|
|
1311
|
+
interface TestBuildFlags {
|
|
1312
|
+
/**
|
|
1313
|
+
* The package @storybook/blocks will be excluded from the bundle, even when imported in e.g. the
|
|
1314
|
+
* preview.
|
|
1315
|
+
*/
|
|
1316
|
+
disableBlocks?: boolean;
|
|
1317
|
+
/** Disable specific addons */
|
|
1318
|
+
disabledAddons?: string[];
|
|
1319
|
+
/** Filter out .mdx stories entries */
|
|
1320
|
+
disableMDXEntries?: boolean;
|
|
1321
|
+
/** Override autodocs to be disabled */
|
|
1322
|
+
disableAutoDocs?: boolean;
|
|
1323
|
+
/** Override docgen to be disabled. */
|
|
1324
|
+
disableDocgen?: boolean;
|
|
1325
|
+
/** Override sourcemaps generation to be disabled. */
|
|
1326
|
+
disableSourcemaps?: boolean;
|
|
1327
|
+
/** Override tree-shaking (dead code elimination) to be disabled. */
|
|
1328
|
+
disableTreeShaking?: boolean;
|
|
1329
|
+
/** Minify with ESBuild when using webpack. */
|
|
1330
|
+
esbuildMinify?: boolean;
|
|
1331
|
+
}
|
|
1332
|
+
interface TestBuildConfig {
|
|
1333
|
+
test?: TestBuildFlags;
|
|
1334
|
+
}
|
|
1335
|
+
type Tag = string;
|
|
1336
|
+
interface TagOptions {
|
|
1337
|
+
excludeFromSidebar: boolean;
|
|
1338
|
+
excludeFromDocsStories: boolean;
|
|
1339
|
+
}
|
|
1340
|
+
type TagsOptions = Record<Tag, Partial<TagOptions>>;
|
|
1341
|
+
/**
|
|
1342
|
+
* The interface for Storybook configuration used internally in presets The difference is that these
|
|
1343
|
+
* values are the raw values, AKA, not wrapped with `PresetValue<>`
|
|
1344
|
+
*/
|
|
1345
|
+
interface StorybookConfigRaw {
|
|
1346
|
+
/**
|
|
1347
|
+
* Sets the addons you want to use with Storybook.
|
|
1348
|
+
*
|
|
1349
|
+
* @example
|
|
1350
|
+
*
|
|
1351
|
+
* ```ts
|
|
1352
|
+
* addons = ['@storybook/addon-essentials'];
|
|
1353
|
+
* addons = [{ name: '@storybook/addon-essentials', options: { backgrounds: false } }];
|
|
1354
|
+
* ```
|
|
1355
|
+
*/
|
|
1356
|
+
addons?: Preset[];
|
|
1357
|
+
core?: CoreConfig;
|
|
1358
|
+
staticDirs?: (DirectoryMapping | string)[];
|
|
1359
|
+
logLevel?: string;
|
|
1360
|
+
features?: {
|
|
1361
|
+
/** Filter args with a "target" on the type from the render function (EXPERIMENTAL) */
|
|
1362
|
+
argTypeTargetsV7?: boolean;
|
|
1363
|
+
/** Apply decorators from preview.js before decorators from addons or frameworks */
|
|
1364
|
+
legacyDecoratorFileOrder?: boolean;
|
|
1365
|
+
/**
|
|
1366
|
+
* Disallow implicit actions during rendering. This will be the default in Storybook 8.
|
|
1367
|
+
*
|
|
1368
|
+
* This will make sure that your story renders the same no matter if docgen is enabled or not.
|
|
1369
|
+
*/
|
|
1370
|
+
disallowImplicitActionsInRenderV8?: boolean;
|
|
1371
|
+
/** Enable asynchronous component rendering in React renderer */
|
|
1372
|
+
experimentalRSC?: boolean;
|
|
1373
|
+
/** Set NODE_ENV to development in built Storybooks for better testability and debuggability */
|
|
1374
|
+
developmentModeForBuild?: boolean;
|
|
1375
|
+
};
|
|
1376
|
+
build?: TestBuildConfig;
|
|
1377
|
+
stories: StoriesEntry[];
|
|
1378
|
+
framework?: Preset;
|
|
1379
|
+
typescript?: Partial<TypescriptOptions>;
|
|
1380
|
+
refs?: CoreCommon_StorybookRefs;
|
|
1381
|
+
babel?: any;
|
|
1382
|
+
swc?: any;
|
|
1383
|
+
env?: Record<string, string>;
|
|
1384
|
+
babelDefault?: any;
|
|
1385
|
+
previewAnnotations?: Entry[];
|
|
1386
|
+
experimental_indexers?: Indexer[];
|
|
1387
|
+
docs?: DocsOptions;
|
|
1388
|
+
previewHead?: string;
|
|
1389
|
+
previewBody?: string;
|
|
1390
|
+
previewMainTemplate?: string;
|
|
1391
|
+
managerHead?: string;
|
|
1392
|
+
tags?: TagsOptions;
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* The interface for Storybook configuration in `main.ts` files. This interface is public All values
|
|
1396
|
+
* should be wrapped with `PresetValue<>`, though there are a few exceptions: `addons`, `framework`
|
|
1397
|
+
*/
|
|
1398
|
+
interface StorybookConfig {
|
|
1399
|
+
/**
|
|
1400
|
+
* Sets the addons you want to use with Storybook.
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
*
|
|
1404
|
+
* ```
|
|
1405
|
+
* addons = ['@storybook/addon-essentials'];
|
|
1406
|
+
* addons = [{ name: '@storybook/addon-essentials', options: { backgrounds: false } }];
|
|
1407
|
+
* ```
|
|
1408
|
+
*/
|
|
1409
|
+
addons?: StorybookConfigRaw['addons'];
|
|
1410
|
+
core?: PresetValue<StorybookConfigRaw['core']>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Sets a list of directories of static files to be loaded by Storybook server
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
*
|
|
1416
|
+
* ```ts
|
|
1417
|
+
* staticDirs = ['./public'];
|
|
1418
|
+
* staticDirs = [{ from: './public', to: '/assets' }];
|
|
1419
|
+
* ```
|
|
1420
|
+
*/
|
|
1421
|
+
staticDirs?: PresetValue<StorybookConfigRaw['staticDirs']>;
|
|
1422
|
+
logLevel?: PresetValue<StorybookConfigRaw['logLevel']>;
|
|
1423
|
+
features?: PresetValue<StorybookConfigRaw['features']>;
|
|
1424
|
+
build?: PresetValue<StorybookConfigRaw['build']>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Tells Storybook where to find stories.
|
|
1427
|
+
*
|
|
1428
|
+
* @example
|
|
1429
|
+
*
|
|
1430
|
+
* ```ts
|
|
1431
|
+
* stories = ['./src/*.stories.@(j|t)sx?'];
|
|
1432
|
+
* stories = async () => [...(await myCustomStoriesEntryBuilderFunc())];
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
stories: PresetValue<StorybookConfigRaw['stories']>;
|
|
1436
|
+
/** Framework, e.g. '@storybook/react-vite', required in v7 */
|
|
1437
|
+
framework?: StorybookConfigRaw['framework'];
|
|
1438
|
+
/** Controls how Storybook handles TypeScript files. */
|
|
1439
|
+
typescript?: PresetValue<StorybookConfigRaw['typescript']>;
|
|
1440
|
+
/** References external Storybooks */
|
|
1441
|
+
refs?: PresetValue<StorybookConfigRaw['refs']>;
|
|
1442
|
+
/** Modify or return babel config. */
|
|
1443
|
+
babel?: PresetValue<StorybookConfigRaw['babel']>;
|
|
1444
|
+
/** Modify or return swc config. */
|
|
1445
|
+
swc?: PresetValue<StorybookConfigRaw['swc']>;
|
|
1446
|
+
/** Modify or return env config. */
|
|
1447
|
+
env?: PresetValue<StorybookConfigRaw['env']>;
|
|
1448
|
+
/** Modify or return babel config. */
|
|
1449
|
+
babelDefault?: PresetValue<StorybookConfigRaw['babelDefault']>;
|
|
1450
|
+
/** Add additional scripts to run in the preview a la `.storybook/preview.js` */
|
|
1451
|
+
previewAnnotations?: PresetValue<StorybookConfigRaw['previewAnnotations']>;
|
|
1452
|
+
/** Process CSF files for the story index. */
|
|
1453
|
+
experimental_indexers?: PresetValue<StorybookConfigRaw['experimental_indexers']>;
|
|
1454
|
+
/** Docs related features in index generation */
|
|
1455
|
+
docs?: PresetValue<StorybookConfigRaw['docs']>;
|
|
1456
|
+
/**
|
|
1457
|
+
* Programmatically modify the preview head/body HTML. The previewHead and previewBody functions
|
|
1458
|
+
* accept a string, which is the existing head/body, and return a modified string.
|
|
1459
|
+
*/
|
|
1460
|
+
previewHead?: PresetValue<StorybookConfigRaw['previewHead']>;
|
|
1461
|
+
previewBody?: PresetValue<StorybookConfigRaw['previewBody']>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Programmatically override the preview's main page template. This should return a reference to a
|
|
1464
|
+
* file containing an `.ejs` template that will be interpolated with environment variables.
|
|
1465
|
+
*
|
|
1466
|
+
* @example
|
|
1467
|
+
*
|
|
1468
|
+
* ```ts
|
|
1469
|
+
* previewMainTemplate = '.storybook/index.ejs';
|
|
1470
|
+
* ```
|
|
1471
|
+
*/
|
|
1472
|
+
previewMainTemplate?: PresetValue<StorybookConfigRaw['previewMainTemplate']>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Programmatically modify the preview head/body HTML. The managerHead function accept a string,
|
|
1475
|
+
* which is the existing head content, and return a modified string.
|
|
1476
|
+
*/
|
|
1477
|
+
managerHead?: PresetValue<StorybookConfigRaw['managerHead']>;
|
|
1478
|
+
/** Configure non-standard tag behaviors */
|
|
1479
|
+
tags?: PresetValue<StorybookConfigRaw['tags']>;
|
|
1480
|
+
}
|
|
1481
|
+
type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
|
|
1482
|
+
type PresetProperty<K, TStorybookConfig = StorybookConfigRaw> = TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | PresetPropertyFn<K, TStorybookConfig>;
|
|
1483
|
+
type PresetPropertyFn<K, TStorybookConfig = StorybookConfigRaw, TOptions = {}> = (config: TStorybookConfig[K extends keyof TStorybookConfig ? K : never], options: Options & TOptions) => TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | Promise<TStorybookConfig[K extends keyof TStorybookConfig ? K : never]>;
|
|
1484
|
+
interface CoreCommon_ResolvedAddonPreset {
|
|
1485
|
+
type: 'presets';
|
|
1486
|
+
name: string;
|
|
1487
|
+
}
|
|
1488
|
+
type PreviewAnnotation = string | {
|
|
1489
|
+
bare: string;
|
|
1490
|
+
absolute: string;
|
|
1491
|
+
};
|
|
1492
|
+
interface CoreCommon_ResolvedAddonVirtual {
|
|
1493
|
+
type: 'virtual';
|
|
1494
|
+
name: string;
|
|
1495
|
+
managerEntries?: string[];
|
|
1496
|
+
previewAnnotations?: PreviewAnnotation[];
|
|
1497
|
+
presets?: (string | {
|
|
1498
|
+
name: string;
|
|
1499
|
+
options?: any;
|
|
1500
|
+
})[];
|
|
1501
|
+
}
|
|
1502
|
+
type CoreCommon_OptionsEntry = {
|
|
1503
|
+
name: string;
|
|
1504
|
+
};
|
|
1505
|
+
type CoreCommon_AddonEntry = string | CoreCommon_OptionsEntry;
|
|
1506
|
+
type CoreCommon_AddonInfo = {
|
|
1507
|
+
name: string;
|
|
1508
|
+
inEssentials: boolean;
|
|
1509
|
+
};
|
|
1510
|
+
interface CoreCommon_StorybookInfo {
|
|
1511
|
+
version: string;
|
|
1512
|
+
framework: string;
|
|
1513
|
+
frameworkPackage: string;
|
|
1514
|
+
renderer: string;
|
|
1515
|
+
rendererPackage: string;
|
|
1516
|
+
configDir?: string;
|
|
1517
|
+
mainConfig?: string;
|
|
1518
|
+
previewConfig?: string;
|
|
1519
|
+
managerConfig?: string;
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Given a generic string type, returns that type but ensures that a string in general is compatible
|
|
1523
|
+
* with it. We use this construct to ensure that IDEs can provide better autocompletion for string
|
|
1524
|
+
* types. This is, for example, needed for main config fields, where we want to ensure that the user
|
|
1525
|
+
* can provide a custom string, but also a string that is compatible with the type.
|
|
1526
|
+
*
|
|
1527
|
+
* @example
|
|
1528
|
+
*
|
|
1529
|
+
* ```ts
|
|
1530
|
+
* type Framework = CompatibleString<'@storybook/nextjs'>;
|
|
1531
|
+
* const framework: Framework = '@storybook/nextjs'; // valid and will be autocompleted const framework: Framework =
|
|
1532
|
+
* path.dirname(require.resolve(path.join('@storybook/nextjs', 'package.json'))); // valid
|
|
1533
|
+
* ```
|
|
1534
|
+
*/
|
|
1535
|
+
type CompatibleString<T extends string> = T | (string & {});
|
|
1536
|
+
|
|
1537
|
+
interface API_BaseEntry {
|
|
1538
|
+
id: StoryId;
|
|
1539
|
+
depth: number;
|
|
1540
|
+
name: string;
|
|
1541
|
+
tags: Tag$1[];
|
|
1542
|
+
refId?: string;
|
|
1543
|
+
renderLabel?: (item: API_BaseEntry, api: any) => any;
|
|
1544
|
+
}
|
|
1545
|
+
interface API_RootEntry extends API_BaseEntry {
|
|
1546
|
+
type: 'root';
|
|
1547
|
+
startCollapsed?: boolean;
|
|
1548
|
+
children: StoryId[];
|
|
1549
|
+
}
|
|
1550
|
+
interface API_GroupEntry extends API_BaseEntry {
|
|
1551
|
+
type: 'group';
|
|
1552
|
+
parent?: StoryId;
|
|
1553
|
+
children: StoryId[];
|
|
1554
|
+
}
|
|
1555
|
+
interface API_ComponentEntry extends API_BaseEntry {
|
|
1556
|
+
type: 'component';
|
|
1557
|
+
parent?: StoryId;
|
|
1558
|
+
children: StoryId[];
|
|
1559
|
+
}
|
|
1560
|
+
interface API_DocsEntry extends API_BaseEntry {
|
|
1561
|
+
type: 'docs';
|
|
1562
|
+
parent: StoryId;
|
|
1563
|
+
title: ComponentTitle;
|
|
1564
|
+
importPath: Path;
|
|
1565
|
+
prepared: boolean;
|
|
1566
|
+
parameters?: {
|
|
1567
|
+
[parameterName: string]: any;
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
interface API_StoryEntry extends API_BaseEntry {
|
|
1571
|
+
type: 'story';
|
|
1572
|
+
parent: StoryId;
|
|
1573
|
+
title: ComponentTitle;
|
|
1574
|
+
importPath: Path;
|
|
1575
|
+
prepared: boolean;
|
|
1576
|
+
parameters?: {
|
|
1577
|
+
[parameterName: string]: any;
|
|
1578
|
+
};
|
|
1579
|
+
args?: Args;
|
|
1580
|
+
argTypes?: ArgTypes;
|
|
1581
|
+
initialArgs?: Args;
|
|
1582
|
+
}
|
|
1583
|
+
type API_LeafEntry = API_DocsEntry | API_StoryEntry;
|
|
1584
|
+
type API_HashEntry = API_RootEntry | API_GroupEntry | API_ComponentEntry | API_DocsEntry | API_StoryEntry;
|
|
1585
|
+
/**
|
|
1586
|
+
* The `IndexHash` is our manager-side representation of the `StoryIndex`. We create entries in the
|
|
1587
|
+
* hash not only for each story or docs entry, but also for each "group" of the component (split on
|
|
1588
|
+
* '/'), as that's how things are manipulated in the manager (i.e. in the sidebar)
|
|
1589
|
+
*/
|
|
1590
|
+
interface API_IndexHash {
|
|
1591
|
+
[id: string]: API_HashEntry;
|
|
1592
|
+
}
|
|
1593
|
+
type API_PreparedIndexEntry = IndexEntry & {
|
|
1594
|
+
parameters?: Parameters;
|
|
1595
|
+
argTypes?: ArgTypes;
|
|
1596
|
+
args?: Args;
|
|
1597
|
+
initialArgs?: Args;
|
|
1598
|
+
};
|
|
1599
|
+
interface API_PreparedStoryIndex {
|
|
1600
|
+
v: number;
|
|
1601
|
+
entries: Record<StoryId, API_PreparedIndexEntry>;
|
|
1602
|
+
}
|
|
1603
|
+
type API_OptionsData = {
|
|
1604
|
+
docsOptions: DocsOptions;
|
|
1605
|
+
};
|
|
1606
|
+
interface API_ReleaseNotes {
|
|
1607
|
+
success?: boolean;
|
|
1608
|
+
currentVersion?: string;
|
|
1609
|
+
showOnFirstLaunch?: boolean;
|
|
1610
|
+
}
|
|
1611
|
+
interface API_Settings {
|
|
1612
|
+
lastTrackedStoryId: string;
|
|
1613
|
+
}
|
|
1614
|
+
interface API_Version {
|
|
1615
|
+
version: string;
|
|
1616
|
+
info?: {
|
|
1617
|
+
plain: string;
|
|
1618
|
+
};
|
|
1619
|
+
[key: string]: any;
|
|
1620
|
+
}
|
|
1621
|
+
interface API_UnknownEntries {
|
|
1622
|
+
[key: string]: {
|
|
1623
|
+
[key: string]: any;
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
interface API_Versions$1 {
|
|
1627
|
+
latest?: API_Version;
|
|
1628
|
+
next?: API_Version;
|
|
1629
|
+
current?: API_Version;
|
|
1630
|
+
}
|
|
1631
|
+
type API_FilterFunction = (item: API_PreparedIndexEntry & {
|
|
1632
|
+
statuses: StatusByTypeId;
|
|
1633
|
+
}) => boolean;
|
|
1634
|
+
|
|
1635
|
+
interface SetStoriesStory {
|
|
1636
|
+
id: StoryId;
|
|
1637
|
+
name: string;
|
|
1638
|
+
refId?: string;
|
|
1639
|
+
componentId?: ComponentId;
|
|
1640
|
+
kind: StoryKind;
|
|
1641
|
+
parameters: {
|
|
1642
|
+
fileName: string;
|
|
1643
|
+
options: {
|
|
1644
|
+
[optionName: string]: any;
|
|
1645
|
+
};
|
|
1646
|
+
docsOnly?: boolean;
|
|
1647
|
+
viewMode?: API_ViewMode;
|
|
1648
|
+
[parameterName: string]: any;
|
|
1649
|
+
};
|
|
1650
|
+
argTypes?: ArgTypes;
|
|
1651
|
+
args?: Args;
|
|
1652
|
+
initialArgs?: Args;
|
|
1653
|
+
}
|
|
1654
|
+
interface SetStoriesStoryData {
|
|
1655
|
+
[id: string]: SetStoriesStory;
|
|
1656
|
+
}
|
|
1657
|
+
type SetStoriesPayload = {
|
|
1658
|
+
v: 2;
|
|
1659
|
+
error?: Error;
|
|
1660
|
+
globals: Args;
|
|
1661
|
+
globalParameters: Parameters;
|
|
1662
|
+
stories: SetStoriesStoryData;
|
|
1663
|
+
kindParameters: {
|
|
1664
|
+
[kind: string]: Parameters;
|
|
1665
|
+
};
|
|
1666
|
+
} | ({
|
|
1667
|
+
v?: number;
|
|
1668
|
+
stories: SetStoriesStoryData;
|
|
1669
|
+
} & Record<string, never>);
|
|
1670
|
+
interface SetGlobalsPayload {
|
|
1671
|
+
globals: Globals;
|
|
1672
|
+
globalTypes: GlobalTypes;
|
|
1673
|
+
}
|
|
1674
|
+
interface GlobalsUpdatedPayload {
|
|
1675
|
+
initialGlobals: Globals;
|
|
1676
|
+
userGlobals: Globals;
|
|
1677
|
+
storyGlobals: Globals;
|
|
1678
|
+
globals: Globals;
|
|
1679
|
+
}
|
|
1680
|
+
interface StoryPreparedPayload {
|
|
1681
|
+
id: StoryId;
|
|
1682
|
+
parameters: Parameters;
|
|
1683
|
+
argTypes: ArgTypes;
|
|
1684
|
+
initialArgs: Args;
|
|
1685
|
+
args: Args;
|
|
1686
|
+
}
|
|
1687
|
+
interface DocsPreparedPayload {
|
|
1688
|
+
id: StoryId;
|
|
1689
|
+
parameters: Parameters;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
type OrString$1<T extends string> = T | (string & {});
|
|
1693
|
+
type API_ViewMode = OrString$1<'story' | 'docs' | 'settings'> | undefined;
|
|
1694
|
+
type API_RenderOptions = Addon_RenderOptions;
|
|
1695
|
+
interface API_RouteOptions {
|
|
1696
|
+
storyId: string;
|
|
1697
|
+
viewMode: API_ViewMode;
|
|
1698
|
+
location: RenderData['location'];
|
|
1699
|
+
path: string;
|
|
1700
|
+
}
|
|
1701
|
+
interface API_MatchOptions {
|
|
1702
|
+
storyId: string;
|
|
1703
|
+
viewMode: API_ViewMode;
|
|
1704
|
+
location: RenderData['location'];
|
|
1705
|
+
path: string;
|
|
1706
|
+
}
|
|
1707
|
+
type API_StateMerger<S> = (input: S) => S;
|
|
1708
|
+
interface API_ProviderData<API> {
|
|
1709
|
+
provider: API_Provider<API>;
|
|
1710
|
+
docsOptions: DocsOptions;
|
|
1711
|
+
}
|
|
1712
|
+
interface API_Provider<API> {
|
|
1713
|
+
channel?: Channel;
|
|
1714
|
+
/** @deprecated Will be removed in 8.0, please use channel instead */
|
|
1715
|
+
serverChannel?: Channel;
|
|
1716
|
+
renderPreview?: API_IframeRenderer;
|
|
1717
|
+
handleAPI(api: API): void;
|
|
1718
|
+
getConfig(): {
|
|
1719
|
+
sidebar?: API_SidebarOptions<API>;
|
|
1720
|
+
theme?: ThemeVars;
|
|
1721
|
+
StoryMapper?: API_StoryMapper;
|
|
1722
|
+
[k: string]: any;
|
|
1723
|
+
} & Partial<API_UIOptions>;
|
|
1724
|
+
[key: string]: any;
|
|
1725
|
+
}
|
|
1726
|
+
type API_IframeRenderer = (storyId: string, viewMode: API_ViewMode, id: string, baseUrl: string, scale: number, queryParams: Record<string, any>) => ReactElement<any, any> | null;
|
|
1727
|
+
interface API_UIOptions {
|
|
1728
|
+
name?: string;
|
|
1729
|
+
url?: string;
|
|
1730
|
+
goFullScreen: boolean;
|
|
1731
|
+
showStoriesPanel: boolean;
|
|
1732
|
+
showAddonPanel: boolean;
|
|
1733
|
+
addonPanelInRight: boolean;
|
|
1734
|
+
theme?: ThemeVars;
|
|
1735
|
+
selectedPanel?: string;
|
|
1736
|
+
}
|
|
1737
|
+
interface API_Layout {
|
|
1738
|
+
initialActive: API_ActiveTabsType;
|
|
1739
|
+
navSize: number;
|
|
1740
|
+
bottomPanelHeight: number;
|
|
1741
|
+
rightPanelWidth: number;
|
|
1742
|
+
/**
|
|
1743
|
+
* The sizes of the panels when they were last visible used to restore the sizes when the panels
|
|
1744
|
+
* are shown again eg. when toggling fullscreen, panels, etc.
|
|
1745
|
+
*/
|
|
1746
|
+
recentVisibleSizes: {
|
|
1747
|
+
navSize: number;
|
|
1748
|
+
bottomPanelHeight: number;
|
|
1749
|
+
rightPanelWidth: number;
|
|
1750
|
+
};
|
|
1751
|
+
panelPosition: API_PanelPositions;
|
|
1752
|
+
showTabs: boolean;
|
|
1753
|
+
showToolbar: boolean;
|
|
1754
|
+
/** @deprecated, will be removed in 8.0 - this API no longer works */
|
|
1755
|
+
isToolshown?: boolean;
|
|
1756
|
+
}
|
|
1757
|
+
interface API_UI {
|
|
1758
|
+
name?: string;
|
|
1759
|
+
url?: string;
|
|
1760
|
+
enableShortcuts: boolean;
|
|
1761
|
+
}
|
|
1762
|
+
type API_PanelPositions = 'bottom' | 'right';
|
|
1763
|
+
type API_ActiveTabsType = 'sidebar' | 'canvas' | 'addons';
|
|
1764
|
+
interface API_SidebarOptions<API = any> {
|
|
1765
|
+
showRoots?: boolean;
|
|
1766
|
+
filters?: Record<string, API_FilterFunction>;
|
|
1767
|
+
collapsedRoots?: string[];
|
|
1768
|
+
renderLabel?: (item: API_HashEntry, api: API) => any;
|
|
1769
|
+
}
|
|
1770
|
+
interface OnClearOptions {
|
|
1771
|
+
/** `true` when the user manually dismissed the notification. */
|
|
1772
|
+
dismissed: boolean;
|
|
1773
|
+
/** `true` when the notification timed out after the set duration. */
|
|
1774
|
+
timeout: boolean;
|
|
1775
|
+
}
|
|
1776
|
+
interface OnClickOptions {
|
|
1777
|
+
/** Function to dismiss the notification. */
|
|
1778
|
+
onDismiss: () => void;
|
|
1779
|
+
}
|
|
1780
|
+
/**
|
|
1781
|
+
* @deprecated Use ReactNode for the icon instead.
|
|
1782
|
+
* @see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated
|
|
1783
|
+
*/
|
|
1784
|
+
interface DeprecatedIconType {
|
|
1785
|
+
name: string;
|
|
1786
|
+
color?: string;
|
|
1787
|
+
}
|
|
1788
|
+
interface API_Notification {
|
|
1789
|
+
id: string;
|
|
1790
|
+
content: {
|
|
1791
|
+
headline: string;
|
|
1792
|
+
subHeadline?: string | any;
|
|
1793
|
+
};
|
|
1794
|
+
duration?: number;
|
|
1795
|
+
link?: string;
|
|
1796
|
+
icon?: React.ReactNode | DeprecatedIconType;
|
|
1797
|
+
onClear?: (options: OnClearOptions) => void;
|
|
1798
|
+
onClick?: (options: OnClickOptions) => void;
|
|
1799
|
+
}
|
|
1800
|
+
type API_Versions = Record<string, string>;
|
|
1801
|
+
type API_SetRefData = Partial<API_ComposedRef & {
|
|
1802
|
+
setStoriesData: SetStoriesStoryData;
|
|
1803
|
+
storyIndex: StoryIndex;
|
|
1804
|
+
}>;
|
|
1805
|
+
type API_StoryMapper = (ref: API_ComposedRef, story: SetStoriesStory) => SetStoriesStory;
|
|
1806
|
+
interface API_LoadedRefData {
|
|
1807
|
+
index?: API_IndexHash;
|
|
1808
|
+
filteredIndex?: API_IndexHash;
|
|
1809
|
+
indexError?: Error;
|
|
1810
|
+
previewInitialized: boolean;
|
|
1811
|
+
}
|
|
1812
|
+
interface API_ComposedRef extends API_LoadedRefData {
|
|
1813
|
+
id: string;
|
|
1814
|
+
title?: string;
|
|
1815
|
+
url: string;
|
|
1816
|
+
type?: 'auto-inject' | 'unknown' | 'lazy' | 'server-checked';
|
|
1817
|
+
expanded?: boolean;
|
|
1818
|
+
versions?: API_Versions;
|
|
1819
|
+
loginUrl?: string;
|
|
1820
|
+
version?: string;
|
|
1821
|
+
sourceUrl?: string;
|
|
1822
|
+
/** DO NOT USE THIS */
|
|
1823
|
+
internal_index?: StoryIndex;
|
|
1824
|
+
}
|
|
1825
|
+
type API_ComposedRefUpdate = Partial<Pick<API_ComposedRef, 'title' | 'type' | 'expanded' | 'index' | 'filteredIndex' | 'versions' | 'loginUrl' | 'version' | 'indexError' | 'previewInitialized' | 'sourceUrl' | 'internal_index'>>;
|
|
1826
|
+
type API_Refs = Record<string, API_ComposedRef>;
|
|
1827
|
+
type API_RefId = string;
|
|
1828
|
+
type API_RefUrl = string;
|
|
1829
|
+
|
|
1830
|
+
type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_TEST_PROVIDER | Addon_TypesEnum.experimental_SIDEBAR_TOP>;
|
|
1831
|
+
interface Addon_ArgType<TArg = unknown> extends InputType {
|
|
1832
|
+
defaultValue?: TArg;
|
|
1833
|
+
}
|
|
1834
|
+
type Addons_ArgTypes<TArgs = Args> = {
|
|
1835
|
+
[key in keyof Partial<TArgs>]: Addon_ArgType<TArgs[key]>;
|
|
1836
|
+
} & {
|
|
1837
|
+
[key in string]: Addon_ArgType<unknown>;
|
|
1838
|
+
};
|
|
1839
|
+
type Addon_Comparator<T> = ((a: T, b: T) => boolean) | ((a: T, b: T) => number);
|
|
1840
|
+
type Addon_StorySortMethod = 'configure' | 'alphabetical';
|
|
1841
|
+
interface Addon_StorySortObjectParameter {
|
|
1842
|
+
method?: Addon_StorySortMethod;
|
|
1843
|
+
order?: any[];
|
|
1844
|
+
locales?: string;
|
|
1845
|
+
includeNames?: boolean;
|
|
1846
|
+
}
|
|
1847
|
+
type IndexEntryLegacy = [StoryId, any, Parameters, Parameters];
|
|
1848
|
+
type Addon_StorySortComparator = Addon_Comparator<IndexEntryLegacy>;
|
|
1849
|
+
type Addon_StorySortParameter = Addon_StorySortComparator | Addon_StorySortObjectParameter;
|
|
1850
|
+
type Addon_StorySortComparatorV7 = Addon_Comparator<IndexEntry>;
|
|
1851
|
+
type Addon_StorySortParameterV7 = Addon_StorySortComparatorV7 | Addon_StorySortObjectParameter;
|
|
1852
|
+
interface Addon_OptionsParameter extends Object {
|
|
1853
|
+
storySort?: Addon_StorySortParameter;
|
|
1854
|
+
theme?: {
|
|
1855
|
+
base: string;
|
|
1856
|
+
brandTitle?: string;
|
|
1857
|
+
};
|
|
1858
|
+
[key: string]: any;
|
|
1859
|
+
}
|
|
1860
|
+
interface Addon_OptionsParameterV7 extends Object {
|
|
1861
|
+
storySort?: Addon_StorySortParameterV7;
|
|
1862
|
+
theme?: {
|
|
1863
|
+
base: string;
|
|
1864
|
+
brandTitle?: string;
|
|
1865
|
+
};
|
|
1866
|
+
[key: string]: any;
|
|
1867
|
+
}
|
|
1868
|
+
type Addon_StoryContext<TRenderer extends Renderer = Renderer> = StoryContext<TRenderer>;
|
|
1869
|
+
type Addon_StoryContextUpdate = Partial<Addon_StoryContext>;
|
|
1870
|
+
interface Addon_ReturnTypeFramework<ReturnType> extends Renderer {
|
|
1871
|
+
component: any;
|
|
1872
|
+
storyResult: ReturnType;
|
|
1873
|
+
canvasElement: any;
|
|
1874
|
+
}
|
|
1875
|
+
type Addon_PartialStoryFn<ReturnType = unknown> = PartialStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
|
|
1876
|
+
type Addon_LegacyStoryFn<ReturnType = unknown> = LegacyStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
|
|
1877
|
+
type Addon_ArgsStoryFn<ReturnType = unknown> = ArgsStoryFn<Addon_ReturnTypeFramework<ReturnType>>;
|
|
1878
|
+
type Addon_StoryFn<ReturnType = unknown> = StoryFn<Addon_ReturnTypeFramework<ReturnType>>;
|
|
1879
|
+
type Addon_DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunction<Addon_ReturnTypeFramework<StoryFnReturnType>>;
|
|
1880
|
+
type Addon_LoaderFunction = LoaderFunction<Addon_ReturnTypeFramework<unknown>>;
|
|
1881
|
+
interface Addon_WrapperSettings {
|
|
1882
|
+
options: object;
|
|
1883
|
+
parameters: {
|
|
1884
|
+
[key: string]: any;
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
type Addon_StoryWrapper = (storyFn: Addon_LegacyStoryFn, context: Addon_StoryContext, settings: Addon_WrapperSettings) => any;
|
|
1888
|
+
type Addon_MakeDecoratorResult = (...args: any) => any;
|
|
1889
|
+
interface Addon_AddStoryArgs<StoryFnReturnType = unknown> {
|
|
1890
|
+
id: StoryId;
|
|
1891
|
+
kind: StoryKind;
|
|
1892
|
+
name: StoryName;
|
|
1893
|
+
storyFn: Addon_StoryFn<StoryFnReturnType>;
|
|
1894
|
+
parameters: Parameters;
|
|
1895
|
+
}
|
|
1896
|
+
type Addon_ClientApiAddon<StoryFnReturnType = unknown> = Addon_Type & {
|
|
1897
|
+
apply: (a: Addon_StoryApi<StoryFnReturnType>, b: any[]) => any;
|
|
1898
|
+
};
|
|
1899
|
+
interface Addon_ClientApiAddons<StoryFnReturnType> {
|
|
1900
|
+
[key: string]: Addon_ClientApiAddon<StoryFnReturnType>;
|
|
1901
|
+
}
|
|
1902
|
+
type Addon_ClientApiReturnFn<StoryFnReturnType = unknown> = (...args: any[]) => Addon_StoryApi<StoryFnReturnType>;
|
|
1903
|
+
interface Addon_StoryApi<StoryFnReturnType = unknown> {
|
|
1904
|
+
kind: StoryKind;
|
|
1905
|
+
add: (storyName: StoryName, storyFn: Addon_StoryFn<StoryFnReturnType>, parameters?: Parameters) => Addon_StoryApi<StoryFnReturnType>;
|
|
1906
|
+
addDecorator: (decorator: Addon_DecoratorFunction<StoryFnReturnType>) => Addon_StoryApi<StoryFnReturnType>;
|
|
1907
|
+
addLoader: (decorator: Addon_LoaderFunction) => Addon_StoryApi<StoryFnReturnType>;
|
|
1908
|
+
addParameters: (parameters: Parameters) => Addon_StoryApi<StoryFnReturnType>;
|
|
1909
|
+
[k: string]: string | Addon_ClientApiReturnFn<StoryFnReturnType>;
|
|
1910
|
+
}
|
|
1911
|
+
interface Addon_ClientStoryApi<StoryFnReturnType = unknown> {
|
|
1912
|
+
}
|
|
1913
|
+
type Addon_LoadFn = () => any;
|
|
1914
|
+
type Addon_RequireContext = any;
|
|
1915
|
+
type Addon_Loadable = Addon_RequireContext | [Addon_RequireContext] | Addon_LoadFn;
|
|
1916
|
+
type Addon_BaseDecorators<StoryFnReturnType> = Array<(story: () => StoryFnReturnType, context: Addon_StoryContext) => StoryFnReturnType>;
|
|
1917
|
+
interface Addon_BaseAnnotations<TArgs, StoryFnReturnType, TRenderer extends Renderer = Renderer> {
|
|
1918
|
+
/**
|
|
1919
|
+
* Dynamic data that are provided (and possibly updated by) Storybook and its addons.
|
|
1920
|
+
*
|
|
1921
|
+
* @see [Arg story inputs](https://storybook.js.org/docs/api/csf#args-story-inputs)
|
|
1922
|
+
*/
|
|
1923
|
+
args?: Partial<TArgs>;
|
|
1924
|
+
/**
|
|
1925
|
+
* ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an
|
|
1926
|
+
* arg. These get automatically filled in by Storybook Docs.
|
|
1927
|
+
*
|
|
1928
|
+
* @see [Arg types](https://storybook.js.org/docs/api/arg-types)
|
|
1929
|
+
*/
|
|
1930
|
+
argTypes?: Addons_ArgTypes<TArgs>;
|
|
1931
|
+
/**
|
|
1932
|
+
* Custom metadata for a story.
|
|
1933
|
+
*
|
|
1934
|
+
* @see [Parameters](https://storybook.js.org/docs/writing-stories/parameters)
|
|
1935
|
+
*/
|
|
1936
|
+
parameters?: Parameters;
|
|
1937
|
+
/**
|
|
1938
|
+
* Wrapper components or Storybook decorators that wrap a story.
|
|
1939
|
+
*
|
|
1940
|
+
* Decorators defined in Meta will be applied to every story variation.
|
|
1941
|
+
*
|
|
1942
|
+
* @see [Decorators](https://storybook.js.org/docs/writing-stories/decorators)
|
|
1943
|
+
*/
|
|
1944
|
+
decorators?: Addon_BaseDecorators<StoryFnReturnType>;
|
|
1945
|
+
/**
|
|
1946
|
+
* Define a custom render function for the story(ies). If not passed, a default render function by
|
|
1947
|
+
* the framework will be used.
|
|
1948
|
+
*/
|
|
1949
|
+
render?: (args: TArgs, context: Addon_StoryContext<TRenderer>) => StoryFnReturnType;
|
|
1950
|
+
/** Function that is executed after the story is rendered. */
|
|
1951
|
+
play?: (context: Addon_StoryContext<TRenderer>) => Promise<void> | void;
|
|
1952
|
+
}
|
|
1953
|
+
interface Addon_Annotations<TArgs, StoryFnReturnType> extends Addon_BaseAnnotations<TArgs, StoryFnReturnType> {
|
|
1954
|
+
/**
|
|
1955
|
+
* Used to only include certain named exports as stories. Useful when you want to have non-story
|
|
1956
|
+
* exports such as mock data or ignore a few stories.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
*
|
|
1960
|
+
* ```ts
|
|
1961
|
+
* includeStories: ['SimpleStory', 'ComplexStory'];
|
|
1962
|
+
* includeStories: /.*Story$/;
|
|
1963
|
+
* ```
|
|
1964
|
+
*
|
|
1965
|
+
* @see [Non-story exports](https://storybook.js.org/docs/api/csf#non-story-exports)
|
|
1966
|
+
*/
|
|
1967
|
+
includeStories?: string[] | RegExp;
|
|
1968
|
+
/**
|
|
1969
|
+
* Used to exclude certain named exports. Useful when you want to have non-story exports such as
|
|
1970
|
+
* mock data or ignore a few stories.
|
|
1971
|
+
*
|
|
1972
|
+
* @example
|
|
1973
|
+
*
|
|
1974
|
+
* ```ts
|
|
1975
|
+
* excludeStories: ['simpleData', 'complexData'];
|
|
1976
|
+
* excludeStories: /.*Data$/;
|
|
1977
|
+
* ```
|
|
1978
|
+
*
|
|
1979
|
+
* @see [Non-story exports](https://storybook.js.org/docs/api/csf#non-story-exports)
|
|
1980
|
+
*/
|
|
1981
|
+
excludeStories?: string[] | RegExp;
|
|
1982
|
+
}
|
|
1983
|
+
interface Addon_BaseMeta<ComponentType> {
|
|
1984
|
+
/**
|
|
1985
|
+
* Title of the story which will be presented in the navigation. **Should be unique.**
|
|
1986
|
+
*
|
|
1987
|
+
* Stories can be organized in a nested structure using "/" as a separator.
|
|
1988
|
+
*
|
|
1989
|
+
* Since CSF 3.0 this property is optional.
|
|
1990
|
+
*
|
|
1991
|
+
* @example
|
|
1992
|
+
*
|
|
1993
|
+
* ```ts
|
|
1994
|
+
* export default { title: 'Design System/Atoms/Button' };
|
|
1995
|
+
* ```
|
|
1996
|
+
*
|
|
1997
|
+
* @see [Story Hierarchy](https://storybook.js.org/docs/writing-stories/naming-components-and-hierarchy)
|
|
1998
|
+
*/
|
|
1999
|
+
title?: string;
|
|
2000
|
+
/**
|
|
2001
|
+
* Manually set the id of a story, which in particular is useful if you want to rename stories
|
|
2002
|
+
* without breaking permalinks.
|
|
2003
|
+
*
|
|
2004
|
+
* Storybook will prioritize the id over the title for ID generation, if provided, and will
|
|
2005
|
+
* prioritize the story.storyName over the export key for display.
|
|
2006
|
+
*
|
|
2007
|
+
* @see [Sidebar and URLs](https://storybook.js.org/docs/configure/user-interface/sidebar-and-urls#permalink-to-stories)
|
|
2008
|
+
*/
|
|
2009
|
+
id?: string;
|
|
2010
|
+
/**
|
|
2011
|
+
* The primary component for your story.
|
|
2012
|
+
*
|
|
2013
|
+
* Used by addons for automatic prop table generation and display of other component metadata.
|
|
2014
|
+
*/
|
|
2015
|
+
component?: ComponentType;
|
|
2016
|
+
/**
|
|
2017
|
+
* Auxiliary sub-components that are part of the stories.
|
|
2018
|
+
*
|
|
2019
|
+
* Used by addons for automatic prop table generation and display of other component metadata.
|
|
2020
|
+
*
|
|
2021
|
+
* @deprecated
|
|
2022
|
+
* @example
|
|
2023
|
+
*
|
|
2024
|
+
* ```ts
|
|
2025
|
+
* import { Button, ButtonGroup } from './components';
|
|
2026
|
+
*
|
|
2027
|
+
* export default {
|
|
2028
|
+
* subcomponents: { Button, ButtonGroup },
|
|
2029
|
+
* };
|
|
2030
|
+
* ```
|
|
2031
|
+
*
|
|
2032
|
+
* By defining them each component will have its tab in the args table.
|
|
2033
|
+
*/
|
|
2034
|
+
subcomponents?: Record<string, ComponentType>;
|
|
2035
|
+
}
|
|
2036
|
+
type Addon_BaseStoryObject<TArgs, StoryFnReturnType> = {
|
|
2037
|
+
/** Override the display name in the UI */
|
|
2038
|
+
storyName?: string;
|
|
2039
|
+
};
|
|
2040
|
+
type Addon_BaseStoryFn<TArgs, StoryFnReturnType> = {
|
|
2041
|
+
(args: TArgs, context: Addon_StoryContext): StoryFnReturnType;
|
|
2042
|
+
} & Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
|
|
2043
|
+
type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnReturnType> | Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
|
|
2044
|
+
interface Addon_RenderOptions {
|
|
2045
|
+
active: boolean;
|
|
2046
|
+
}
|
|
2047
|
+
type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_SidebarBottomType | Addon_SidebarTopType | Addon_TestProviderType<Addon_TestProviderState>;
|
|
2048
|
+
interface Addon_BaseType {
|
|
2049
|
+
/**
|
|
2050
|
+
* The title of the addon. This can be a simple string, but it can also be a
|
|
2051
|
+
* React.FunctionComponent or a React.ReactElement.
|
|
2052
|
+
*/
|
|
2053
|
+
title: FC | ReactNode | (() => string);
|
|
2054
|
+
/**
|
|
2055
|
+
* The type of the addon.
|
|
2056
|
+
*
|
|
2057
|
+
* @example
|
|
2058
|
+
*
|
|
2059
|
+
* ```ts
|
|
2060
|
+
* Addon_TypesEnum.PANEL;
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP | Addon_TypesEnum.experimental_TEST_PROVIDER>;
|
|
2064
|
+
/**
|
|
2065
|
+
* The unique id of the addon.
|
|
2066
|
+
*
|
|
2067
|
+
* @example 'my-org-name/my-addon-name';
|
|
2068
|
+
*
|
|
2069
|
+
* @warn This will become non-optional in 8.0
|
|
2070
|
+
*
|
|
2071
|
+
* This needs to be globally unique, so we recommend prefixing it with your org name or npm package name.
|
|
2072
|
+
*
|
|
2073
|
+
* Do not prefix with `storybook`, this is reserved for core storybook feature and core addons.
|
|
2074
|
+
*/
|
|
2075
|
+
id?: string;
|
|
2076
|
+
/**
|
|
2077
|
+
* This component will wrap your `render` function.
|
|
2078
|
+
*
|
|
2079
|
+
* With it you can determine if you want your addon to be rendered or not.
|
|
2080
|
+
*
|
|
2081
|
+
* This is to facilitate addons keeping state, and keep listening for events even when they are
|
|
2082
|
+
* not currently on screen/rendered.
|
|
2083
|
+
*/
|
|
2084
|
+
route?: (routeOptions: RenderData) => string;
|
|
2085
|
+
/** This will determine the value of `active` prop of your render function. */
|
|
2086
|
+
match?: (matchOptions: RenderData & {
|
|
2087
|
+
tabId?: string;
|
|
2088
|
+
}) => boolean;
|
|
2089
|
+
/**
|
|
2090
|
+
* The actual contents of your addon.
|
|
2091
|
+
*
|
|
2092
|
+
* This is called as a function, so if you want to use hooks, your function needs to return a
|
|
2093
|
+
* JSX.Element within which components are rendered
|
|
2094
|
+
*/
|
|
2095
|
+
render: (props: Partial<Addon_RenderOptions>) => ReturnType<FC<Partial<Addon_RenderOptions>>>;
|
|
2096
|
+
/** @unstable */
|
|
2097
|
+
paramKey?: string;
|
|
2098
|
+
/** @unstable */
|
|
2099
|
+
disabled?: boolean | ((parameters: API_StoryEntry['parameters']) => boolean);
|
|
2100
|
+
/** @unstable */
|
|
2101
|
+
hidden?: boolean;
|
|
2102
|
+
}
|
|
2103
|
+
interface Addon_PageType {
|
|
2104
|
+
type: Addon_TypesEnum.experimental_PAGE;
|
|
2105
|
+
/** The unique id of the page. */
|
|
2106
|
+
id: string;
|
|
2107
|
+
/** The URL to navigate to when Storybook needs to navigate to this page. */
|
|
2108
|
+
url: string;
|
|
2109
|
+
/** The title is used in mobile mode to represent the page in the navigation. */
|
|
2110
|
+
title: FC | string | ReactElement | ReactNode;
|
|
2111
|
+
/**
|
|
2112
|
+
* The main content of the addon, a function component without any props. Storybook will render
|
|
2113
|
+
* your component always.
|
|
2114
|
+
*
|
|
2115
|
+
* If you want to render your component only when the URL matches, use the `Route` component.
|
|
2116
|
+
*
|
|
2117
|
+
* @example
|
|
2118
|
+
*
|
|
2119
|
+
* ```jsx
|
|
2120
|
+
* import { Route } from 'storybook/internal/router';
|
|
2121
|
+
*
|
|
2122
|
+
* Render: () => {
|
|
2123
|
+
* return (
|
|
2124
|
+
* <Route path="/my-addon">
|
|
2125
|
+
* {' '}
|
|
2126
|
+
* <MyAddonContent />{' '}
|
|
2127
|
+
* </Route>
|
|
2128
|
+
* );
|
|
2129
|
+
* };
|
|
2130
|
+
* ```
|
|
2131
|
+
*/
|
|
2132
|
+
render: FC;
|
|
2133
|
+
}
|
|
2134
|
+
interface Addon_WrapperType {
|
|
2135
|
+
type: Addon_TypesEnum.PREVIEW;
|
|
2136
|
+
/** The unique id of the page. */
|
|
2137
|
+
id: string;
|
|
2138
|
+
/**
|
|
2139
|
+
* A React.FunctionComponent that wraps the story.
|
|
2140
|
+
*
|
|
2141
|
+
* This component must accept a children prop, and render it.
|
|
2142
|
+
*/
|
|
2143
|
+
render: FC<PropsWithChildren<{
|
|
2144
|
+
index: number;
|
|
2145
|
+
children: ReactNode;
|
|
2146
|
+
id: string;
|
|
2147
|
+
storyId: StoryId;
|
|
2148
|
+
}>>;
|
|
2149
|
+
}
|
|
2150
|
+
/** @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0. */
|
|
2151
|
+
interface Addon_SidebarBottomType {
|
|
2152
|
+
type: Addon_TypesEnum.experimental_SIDEBAR_BOTTOM;
|
|
2153
|
+
/** The unique id of the tool. */
|
|
2154
|
+
id: string;
|
|
2155
|
+
/** A React.FunctionComponent. */
|
|
2156
|
+
render: FC;
|
|
2157
|
+
}
|
|
2158
|
+
/** @deprecated This will be removed in Storybook 9.0. */
|
|
2159
|
+
interface Addon_SidebarTopType {
|
|
2160
|
+
type: Addon_TypesEnum.experimental_SIDEBAR_TOP;
|
|
2161
|
+
/** The unique id of the tool. */
|
|
2162
|
+
id: string;
|
|
2163
|
+
/** A React.FunctionComponent. */
|
|
2164
|
+
render: FC;
|
|
2165
|
+
}
|
|
2166
|
+
interface Addon_TestProviderType<Details extends {
|
|
2167
|
+
[key: string]: any;
|
|
2168
|
+
} = NonNullable<unknown>> {
|
|
2169
|
+
type: Addon_TypesEnum.experimental_TEST_PROVIDER;
|
|
2170
|
+
/** The unique id of the test provider. */
|
|
2171
|
+
id: string;
|
|
2172
|
+
name: string;
|
|
2173
|
+
/** @deprecated Use render instead */
|
|
2174
|
+
title?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
|
|
2175
|
+
/** @deprecated Use render instead */
|
|
2176
|
+
description?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
|
|
2177
|
+
render?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
|
|
2178
|
+
sidebarContextMenu?: (options: {
|
|
2179
|
+
context: API_HashEntry;
|
|
2180
|
+
state: TestProviderConfig & Addon_TestProviderState<Details>;
|
|
2181
|
+
}) => ReactNode;
|
|
2182
|
+
stateUpdater?: (state: TestProviderConfig & Addon_TestProviderState<Details>, update: Partial<Addon_TestProviderState<Details>>) => void | Partial<TestProviderConfig & Addon_TestProviderState<Details>>;
|
|
2183
|
+
runnable?: boolean;
|
|
2184
|
+
}
|
|
2185
|
+
type Addon_TestProviderState<Details extends {
|
|
2186
|
+
[key: string]: any;
|
|
2187
|
+
} = NonNullable<unknown>> = Pick<Addon_TestProviderType, 'runnable'> & {
|
|
2188
|
+
progress?: TestingModuleProgressReportProgress;
|
|
2189
|
+
details: Details;
|
|
2190
|
+
cancellable: boolean;
|
|
2191
|
+
cancelling: boolean;
|
|
2192
|
+
running: boolean;
|
|
2193
|
+
failed: boolean;
|
|
2194
|
+
crashed: boolean;
|
|
2195
|
+
error?: {
|
|
2196
|
+
name: string;
|
|
2197
|
+
message?: string;
|
|
2198
|
+
};
|
|
2199
|
+
};
|
|
2200
|
+
type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP | Addon_TypesEnum.experimental_TEST_PROVIDER>;
|
|
2201
|
+
interface Addon_TypesMapping extends Record<Addon_TypeBaseNames, Addon_BaseType> {
|
|
2202
|
+
[Addon_TypesEnum.PREVIEW]: Addon_WrapperType;
|
|
2203
|
+
[Addon_TypesEnum.experimental_PAGE]: Addon_PageType;
|
|
2204
|
+
[Addon_TypesEnum.experimental_SIDEBAR_BOTTOM]: Addon_SidebarBottomType;
|
|
2205
|
+
[Addon_TypesEnum.experimental_SIDEBAR_TOP]: Addon_SidebarTopType;
|
|
2206
|
+
[Addon_TypesEnum.experimental_TEST_PROVIDER]: Addon_TestProviderType<Addon_TestProviderState>;
|
|
2207
|
+
}
|
|
2208
|
+
type Addon_Loader<API> = (api: API) => void;
|
|
2209
|
+
interface Addon_Loaders<API> {
|
|
2210
|
+
[key: string]: Addon_Loader<API>;
|
|
2211
|
+
}
|
|
2212
|
+
interface Addon_Collection<T = Addon_Type> {
|
|
2213
|
+
[key: string]: T;
|
|
2214
|
+
}
|
|
2215
|
+
interface Addon_Elements {
|
|
2216
|
+
[key: string]: Addon_Collection;
|
|
2217
|
+
}
|
|
2218
|
+
interface Addon_ToolbarConfig {
|
|
2219
|
+
hidden?: boolean;
|
|
2220
|
+
}
|
|
2221
|
+
interface Addon_Config {
|
|
2222
|
+
theme?: ThemeVars;
|
|
2223
|
+
toolbar?: {
|
|
2224
|
+
[id: string]: Addon_ToolbarConfig;
|
|
2225
|
+
};
|
|
2226
|
+
sidebar?: API_SidebarOptions;
|
|
2227
|
+
[key: string]: any;
|
|
2228
|
+
}
|
|
2229
|
+
declare enum Addon_TypesEnum {
|
|
2230
|
+
/**
|
|
2231
|
+
* This API is used to create a tab the toolbar above the canvas, This API might be removed in the
|
|
2232
|
+
* future.
|
|
2233
|
+
*
|
|
2234
|
+
* @unstable
|
|
2235
|
+
*/
|
|
2236
|
+
TAB = "tab",
|
|
2237
|
+
/** This adds panels to the addons side panel. */
|
|
2238
|
+
PANEL = "panel",
|
|
2239
|
+
/** This adds items in the toolbar above the canvas - on the left side. */
|
|
2240
|
+
TOOL = "tool",
|
|
2241
|
+
/** This adds items in the toolbar above the canvas - on the right side. */
|
|
2242
|
+
TOOLEXTRA = "toolextra",
|
|
2243
|
+
/**
|
|
2244
|
+
* This adds wrapper components around the canvas/iframe component storybook renders.
|
|
2245
|
+
*
|
|
2246
|
+
* @unstable this API is not stable yet, and is likely to change in 8.0.
|
|
2247
|
+
*/
|
|
2248
|
+
PREVIEW = "preview",
|
|
2249
|
+
/**
|
|
2250
|
+
* This adds pages that render instead of the canvas.
|
|
2251
|
+
*
|
|
2252
|
+
* @unstable
|
|
2253
|
+
*/
|
|
2254
|
+
experimental_PAGE = "page",
|
|
2255
|
+
/**
|
|
2256
|
+
* This adds items in the bottom of the sidebar.
|
|
2257
|
+
*
|
|
2258
|
+
* @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0.
|
|
2259
|
+
*/
|
|
2260
|
+
experimental_SIDEBAR_BOTTOM = "sidebar-bottom",
|
|
2261
|
+
/**
|
|
2262
|
+
* This adds items in the top of the sidebar.
|
|
2263
|
+
*
|
|
2264
|
+
* @deprecated This will be removed in Storybook 9.0.
|
|
2265
|
+
*/
|
|
2266
|
+
experimental_SIDEBAR_TOP = "sidebar-top",
|
|
2267
|
+
/** This adds items to the Testing Module in the sidebar. */
|
|
2268
|
+
experimental_TEST_PROVIDER = "test-provider"
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
interface Renderer extends Renderer$1 {
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
type OrString<T extends string> = T | (string & {});
|
|
2275
|
+
type ViewMode = OrString<ViewMode$1 | 'settings'> | undefined;
|
|
2276
|
+
type Layout = 'centered' | 'fullscreen' | 'padded' | 'none';
|
|
2277
|
+
interface StorybookParameters {
|
|
2278
|
+
options?: Addon_OptionsParameter;
|
|
2279
|
+
/**
|
|
2280
|
+
* The layout property defines basic styles added to the preview body where the story is rendered.
|
|
2281
|
+
*
|
|
2282
|
+
* If you pass `none`, no styles are applied.
|
|
2283
|
+
*/
|
|
2284
|
+
layout?: Layout;
|
|
2285
|
+
}
|
|
2286
|
+
interface StorybookInternalParameters extends StorybookParameters {
|
|
2287
|
+
fileName?: string;
|
|
2288
|
+
docsOnly?: true;
|
|
2289
|
+
}
|
|
2290
|
+
type Path = string;
|
|
2291
|
+
|
|
2292
|
+
interface WebRenderer extends Renderer {
|
|
2293
|
+
canvasElement: HTMLElement;
|
|
2294
|
+
}
|
|
2295
|
+
type ModuleExport = any;
|
|
2296
|
+
type ModuleExports = Record<string, ModuleExport>;
|
|
2297
|
+
type ModuleImportFn = (path: Path) => Promise<ModuleExports>;
|
|
2298
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
2299
|
+
type TeardownRenderToCanvas = () => MaybePromise<void>;
|
|
2300
|
+
type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
|
|
2301
|
+
interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotations$1<TRenderer> {
|
|
2302
|
+
addons?: ProjectAnnotations<TRenderer>[];
|
|
2303
|
+
testingLibraryRender?: (...args: never[]) => {
|
|
2304
|
+
unmount: () => void;
|
|
2305
|
+
};
|
|
2306
|
+
renderToCanvas?: RenderToCanvas<TRenderer>;
|
|
2307
|
+
renderToDOM?: RenderToCanvas<TRenderer>;
|
|
2308
|
+
}
|
|
2309
|
+
type NamedExportsOrDefault<TExport> = TExport | {
|
|
2310
|
+
default: TExport;
|
|
2311
|
+
};
|
|
2312
|
+
type NamedOrDefaultProjectAnnotations<TRenderer extends Renderer = Renderer> = NamedExportsOrDefault<ProjectAnnotations<TRenderer>>;
|
|
2313
|
+
type NormalizedProjectAnnotations<TRenderer extends Renderer = Renderer> = Omit<ProjectAnnotations<TRenderer>, 'decorators' | 'loaders' | 'runStep' | 'beforeAll'> & {
|
|
2314
|
+
argTypes?: StrictArgTypes;
|
|
2315
|
+
globalTypes?: StrictGlobalTypes;
|
|
2316
|
+
decorators?: DecoratorFunction<TRenderer>[];
|
|
2317
|
+
loaders?: LoaderFunction<TRenderer>[];
|
|
2318
|
+
runStep: StepRunner<TRenderer>;
|
|
2319
|
+
beforeAll: BeforeAll;
|
|
2320
|
+
};
|
|
2321
|
+
type NormalizedComponentAnnotations<TRenderer extends Renderer = Renderer> = Omit<ComponentAnnotations<TRenderer>, 'decorators' | 'loaders'> & {
|
|
2322
|
+
id: ComponentId;
|
|
2323
|
+
title: ComponentTitle;
|
|
2324
|
+
argTypes?: StrictArgTypes;
|
|
2325
|
+
decorators?: DecoratorFunction<TRenderer>[];
|
|
2326
|
+
loaders?: LoaderFunction<TRenderer>[];
|
|
2327
|
+
};
|
|
2328
|
+
type NormalizedStoryAnnotations<TRenderer extends Renderer = Renderer> = Omit<StoryAnnotations<TRenderer>, 'storyName' | 'story' | 'decorators' | 'loaders'> & {
|
|
2329
|
+
moduleExport: ModuleExport;
|
|
2330
|
+
id: StoryId;
|
|
2331
|
+
argTypes?: StrictArgTypes;
|
|
2332
|
+
name: StoryName;
|
|
2333
|
+
userStoryFn?: ArgsStoryFn<TRenderer>;
|
|
2334
|
+
decorators?: DecoratorFunction<TRenderer>[];
|
|
2335
|
+
loaders?: LoaderFunction<TRenderer>[];
|
|
2336
|
+
};
|
|
2337
|
+
type CSFFile<TRenderer extends Renderer = Renderer> = {
|
|
2338
|
+
meta: NormalizedComponentAnnotations<TRenderer>;
|
|
2339
|
+
stories: Record<StoryId, NormalizedStoryAnnotations<TRenderer>>;
|
|
2340
|
+
projectAnnotations?: NormalizedProjectAnnotations<TRenderer>;
|
|
2341
|
+
moduleExports: ModuleExports;
|
|
2342
|
+
};
|
|
2343
|
+
type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhancers<TRenderer> & {
|
|
2344
|
+
moduleExport: ModuleExport;
|
|
2345
|
+
originalStoryFn: ArgsStoryFn<TRenderer>;
|
|
2346
|
+
undecoratedStoryFn: LegacyStoryFn<TRenderer>;
|
|
2347
|
+
unboundStoryFn: LegacyStoryFn<TRenderer>;
|
|
2348
|
+
applyLoaders: (context: StoryContext<TRenderer>) => Promise<StoryContext<TRenderer>['loaded']>;
|
|
2349
|
+
applyBeforeEach: (context: StoryContext<TRenderer>) => Promise<CleanupCallback[]>;
|
|
2350
|
+
applyAfterEach: (context: StoryContext<TRenderer>) => Promise<void>;
|
|
2351
|
+
playFunction?: (context: StoryContext<TRenderer>) => Promise<void> | void;
|
|
2352
|
+
runStep: StepRunner<TRenderer>;
|
|
2353
|
+
mount: (context: StoryContext<TRenderer>) => () => Promise<Canvas>;
|
|
2354
|
+
testingLibraryRender?: (...args: never[]) => unknown;
|
|
2355
|
+
renderToCanvas?: ProjectAnnotations<TRenderer>['renderToCanvas'];
|
|
2356
|
+
usesMount: boolean;
|
|
2357
|
+
storyGlobals: Globals;
|
|
2358
|
+
};
|
|
2359
|
+
type PreparedMeta<TRenderer extends Renderer = Renderer> = Omit<StoryContextForEnhancers<TRenderer>, 'name' | 'story'> & {
|
|
2360
|
+
moduleExport: ModuleExport;
|
|
2361
|
+
};
|
|
2362
|
+
type BoundStory<TRenderer extends Renderer = Renderer> = PreparedStory<TRenderer> & {
|
|
2363
|
+
storyFn: PartialStoryFn<TRenderer>;
|
|
2364
|
+
};
|
|
2365
|
+
declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
|
|
2366
|
+
showMain: () => void;
|
|
2367
|
+
showError: (error: {
|
|
2368
|
+
title: string;
|
|
2369
|
+
description: string;
|
|
2370
|
+
}) => void;
|
|
2371
|
+
showException: (err: Error) => void;
|
|
2372
|
+
forceRemount: boolean;
|
|
2373
|
+
storyContext: StoryContext<TRenderer>;
|
|
2374
|
+
storyFn: PartialStoryFn<TRenderer>;
|
|
2375
|
+
unboundStoryFn: LegacyStoryFn<TRenderer>;
|
|
2376
|
+
};
|
|
2377
|
+
|
|
2378
|
+
interface BuilderStats {
|
|
2379
|
+
toJson: () => any;
|
|
2380
|
+
}
|
|
2381
|
+
type Builder_WithRequiredProperty<Type, Key extends keyof Type> = Type & {
|
|
2382
|
+
[Property in Key]-?: Type[Property];
|
|
2383
|
+
};
|
|
2384
|
+
type Builder_Unpromise<T extends Promise<any>> = T extends Promise<infer U> ? U : never;
|
|
2385
|
+
type Builder_EnvsRaw = Record<string, string>;
|
|
2386
|
+
|
|
2387
|
+
type RenderContextCallbacks<TRenderer extends Renderer> = Pick<RenderContext<TRenderer>, 'showMain' | 'showError' | 'showException'>;
|
|
2388
|
+
type StoryRenderOptions = {
|
|
2389
|
+
autoplay?: boolean;
|
|
2390
|
+
forceInitialArgs?: boolean;
|
|
2391
|
+
};
|
|
2392
|
+
type ResolvedModuleExportType = 'component' | 'meta' | 'story';
|
|
2393
|
+
/**
|
|
2394
|
+
* What do we know about an of={} call?
|
|
2395
|
+
*
|
|
2396
|
+
* Technically, the type names aren't super accurate:
|
|
2397
|
+
*
|
|
2398
|
+
* - Meta === `CSFFile`
|
|
2399
|
+
* - Story === `PreparedStory` But these shorthands capture the idea of what is being talked about
|
|
2400
|
+
*/
|
|
2401
|
+
type ResolvedModuleExportFromType<TType extends ResolvedModuleExportType, TRenderer extends Renderer = Renderer> = TType extends 'component' ? {
|
|
2402
|
+
type: 'component';
|
|
2403
|
+
component: TRenderer['component'];
|
|
2404
|
+
projectAnnotations: NormalizedProjectAnnotations<Renderer>;
|
|
2405
|
+
} : TType extends 'meta' ? {
|
|
2406
|
+
type: 'meta';
|
|
2407
|
+
csfFile: CSFFile<TRenderer>;
|
|
2408
|
+
preparedMeta: PreparedMeta;
|
|
2409
|
+
} : {
|
|
2410
|
+
type: 'story';
|
|
2411
|
+
story: PreparedStory<TRenderer>;
|
|
2412
|
+
};
|
|
2413
|
+
type ResolvedModuleExport<TRenderer extends Renderer = Renderer> = {
|
|
2414
|
+
type: ResolvedModuleExportType;
|
|
2415
|
+
} & (ResolvedModuleExportFromType<'component', TRenderer> | ResolvedModuleExportFromType<'meta', TRenderer> | ResolvedModuleExportFromType<'story', TRenderer>);
|
|
2416
|
+
interface DocsContextProps<TRenderer extends Renderer = Renderer> {
|
|
2417
|
+
/**
|
|
2418
|
+
* Register a CSF file that this docs entry uses. Used by the `<Meta of={} />` block to attach,
|
|
2419
|
+
* and the `<Story meta={} />` bloc to reference
|
|
2420
|
+
*/
|
|
2421
|
+
referenceMeta: (metaExports: ModuleExports, attach: boolean) => void;
|
|
2422
|
+
/**
|
|
2423
|
+
* Find a component, meta or story object from the direct export(s) from the CSF file. This is the
|
|
2424
|
+
* API that drives the `of={}` syntax.
|
|
2425
|
+
*/
|
|
2426
|
+
resolveOf<TType extends ResolvedModuleExportType>(moduleExportOrType: ModuleExport | TType, validTypes?: TType[]): ResolvedModuleExportFromType<TType, TRenderer>;
|
|
2427
|
+
/**
|
|
2428
|
+
* Find a story's id from the name of the story. This is primarily used by the `<Story name={} />
|
|
2429
|
+
* block. Note that the story must be part of the primary CSF file of the docs entry.
|
|
2430
|
+
*/
|
|
2431
|
+
storyIdByName: (storyName: StoryName) => StoryId;
|
|
2432
|
+
/**
|
|
2433
|
+
* Syncronously find a story by id (if the id is not provided, this will look up the primary story
|
|
2434
|
+
* in the CSF file, if such a file exists).
|
|
2435
|
+
*/
|
|
2436
|
+
storyById: (id?: StoryId) => PreparedStory<TRenderer>;
|
|
2437
|
+
/** Syncronously find all stories of the component referenced by the CSF file. */
|
|
2438
|
+
componentStories: () => PreparedStory<TRenderer>[];
|
|
2439
|
+
/** Syncronously find all stories by CSF file. */
|
|
2440
|
+
componentStoriesFromCSFFile: (csfFile: CSFFile<TRenderer>) => PreparedStory<TRenderer>[];
|
|
2441
|
+
/** Get the story context of the referenced story. */
|
|
2442
|
+
getStoryContext: (story: PreparedStory<TRenderer>) => Omit<StoryContext<TRenderer>, 'abortSignal' | 'canvasElement' | 'step' | 'context'>;
|
|
2443
|
+
/** Asyncronously load an arbitrary story by id. */
|
|
2444
|
+
loadStory: (id: StoryId) => Promise<PreparedStory<TRenderer>>;
|
|
2445
|
+
/** Render a story to a given HTML element and keep it up to date across context changes */
|
|
2446
|
+
renderStoryToElement: (story: PreparedStory<TRenderer>, element: HTMLElement, callbacks: RenderContextCallbacks<TRenderer>, options: StoryRenderOptions) => () => Promise<void>;
|
|
2447
|
+
/** Storybook channel -- use for low level event watching/emitting */
|
|
2448
|
+
channel: Channel$1;
|
|
2449
|
+
/** Project annotations -- can be read to get the project's global annotations */
|
|
2450
|
+
projectAnnotations: NormalizedProjectAnnotations<TRenderer>;
|
|
2451
|
+
}
|
|
2452
|
+
type DocsRenderFunction<TRenderer extends Renderer> = (docsContext: DocsContextProps<TRenderer>, docsParameters: Parameters, element: HTMLElement) => Promise<void>;
|
|
2453
|
+
|
|
2454
|
+
declare global {
|
|
2455
|
+
var globalProjectAnnotations: NormalizedProjectAnnotations$1<any>;
|
|
2456
|
+
var defaultProjectAnnotations: ProjectAnnotations$2<any>;
|
|
2457
|
+
}
|
|
2458
|
+
type WrappedStoryRef = {
|
|
2459
|
+
__pw_type: 'jsx' | 'importRef';
|
|
2460
|
+
};
|
|
2461
|
+
type UnwrappedJSXStoryRef = {
|
|
2462
|
+
__pw_type: 'jsx';
|
|
2463
|
+
type: UnwrappedImportStoryRef;
|
|
2464
|
+
};
|
|
2465
|
+
type UnwrappedImportStoryRef = ComposedStoryFn$1;
|
|
2466
|
+
declare global {
|
|
2467
|
+
function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
interface Report<T = unknown> {
|
|
2471
|
+
type: string;
|
|
2472
|
+
version?: number;
|
|
2473
|
+
result: T;
|
|
2474
|
+
status: 'failed' | 'passed' | 'warning';
|
|
2475
|
+
}
|
|
2476
|
+
declare class ReporterAPI {
|
|
2477
|
+
reports: Report[];
|
|
2478
|
+
addReport(report: Report): Promise<void>;
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
type Store_CSFExports<TRenderer extends Renderer$1 = Renderer$1, TArgs extends Args = Args> = {
|
|
2482
|
+
default: ComponentAnnotations<TRenderer, TArgs>;
|
|
2483
|
+
__esModule?: boolean;
|
|
2484
|
+
__namedExportsOrder?: string[];
|
|
2485
|
+
};
|
|
2486
|
+
/** A story function with partial args, used internally by composeStory */
|
|
2487
|
+
type PartialArgsStoryFn<TRenderer extends Renderer$1 = Renderer$1, TArgs = Args> = (args?: TArgs) => (TRenderer & {
|
|
2488
|
+
T: TArgs;
|
|
2489
|
+
})['storyResult'];
|
|
2490
|
+
/**
|
|
2491
|
+
* A story that got recomposed for portable stories, containing all the necessary data to be
|
|
2492
|
+
* rendered in external environments
|
|
2493
|
+
*/
|
|
2494
|
+
type ComposedStoryFn<TRenderer extends Renderer$1 = Renderer$1, TArgs = Args> = PartialArgsStoryFn<TRenderer, TArgs> & {
|
|
2495
|
+
args: TArgs;
|
|
2496
|
+
id: StoryId;
|
|
2497
|
+
play?: (context?: Partial<StoryContext<TRenderer, Partial<TArgs>>>) => Promise<void>;
|
|
2498
|
+
run: (context?: Partial<StoryContext<TRenderer, Partial<TArgs>>>) => Promise<void>;
|
|
2499
|
+
load: () => Promise<void>;
|
|
2500
|
+
storyName: string;
|
|
2501
|
+
parameters: Parameters;
|
|
2502
|
+
argTypes: StrictArgTypes<TArgs>;
|
|
2503
|
+
reporting: ReporterAPI;
|
|
2504
|
+
tags: Tag$1[];
|
|
2505
|
+
globals: Globals;
|
|
2506
|
+
};
|
|
2507
|
+
/**
|
|
2508
|
+
* Based on a module of stories, it returns all stories within it, filtering non-stories Each story
|
|
2509
|
+
* will have partial props, as their props should be handled when composing stories
|
|
2510
|
+
*/
|
|
2511
|
+
type StoriesWithPartialProps<TRenderer extends Renderer$1, TModule> = {
|
|
2512
|
+
[K in keyof TModule as TModule[K] extends StoryAnnotationsOrFn<infer _, infer _TProps> ? K : never]: TModule[K] extends StoryAnnotationsOrFn<infer _, infer TProps> ? ComposedStoryFn<TRenderer, Partial<TProps>> : unknown;
|
|
2513
|
+
};
|
|
2514
|
+
/**
|
|
2515
|
+
* Type used for integrators of portable stories, as reference when creating their own composeStory
|
|
2516
|
+
* function
|
|
2517
|
+
*/
|
|
2518
|
+
interface ComposeStoryFn<TRenderer extends Renderer$1 = Renderer$1, TArgs extends Args = Args> {
|
|
2519
|
+
(storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations$1<TRenderer>, exportsName?: string): ComposedStoryFn;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
type SupportedFrameworks = 'angular' | 'ember' | 'experimental-nextjs-vite' | 'html-vite' | 'html-webpack5' | 'nextjs' | 'preact-vite' | 'preact-webpack5' | 'react-native-web-vite' | 'react-vite' | 'react-webpack5' | 'server-webpack5' | 'svelte-vite' | 'svelte-webpack5' | 'sveltekit' | 'vue3-vite' | 'vue3-webpack5' | 'web-components-vite' | 'web-components-webpack5' | 'qwik' | 'solid' | 'nuxt' | 'react-rsbuild' | 'vue3-rsbuild';
|
|
2523
|
+
|
|
2524
|
+
type SupportedRenderers = 'react' | 'react-native' | 'vue3' | 'angular' | 'ember' | 'preact' | 'svelte' | 'qwik' | 'html' | 'web-components' | 'server' | 'solid' | 'nuxt';
|
|
2525
|
+
|
|
2526
|
+
type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
|
|
2527
|
+
type StatusTypeId = string;
|
|
2528
|
+
type StatusByTypeId = Record<StatusTypeId, Status>;
|
|
2529
|
+
type StatusesByStoryIdAndTypeId = Record<StoryId, StatusByTypeId>;
|
|
2530
|
+
interface Status {
|
|
2531
|
+
value: StatusValue;
|
|
2532
|
+
typeId: StatusTypeId;
|
|
2533
|
+
storyId: StoryId;
|
|
2534
|
+
title: string;
|
|
2535
|
+
description: string;
|
|
2536
|
+
data?: any;
|
|
2537
|
+
sidebarContextMenu?: boolean;
|
|
2538
|
+
}
|
|
2539
|
+
type StatusStore = {
|
|
2540
|
+
getAll: () => StatusesByStoryIdAndTypeId;
|
|
2541
|
+
set: (statuses: Status[]) => void;
|
|
2542
|
+
onAllStatusChange: (listener: (statuses: StatusesByStoryIdAndTypeId, previousStatuses: StatusesByStoryIdAndTypeId) => void) => () => void;
|
|
2543
|
+
onSelect: (listener: (selectedStatuses: Status[]) => void) => () => void;
|
|
2544
|
+
unset: (storyIds?: StoryId[]) => void;
|
|
2545
|
+
};
|
|
2546
|
+
type StatusStoreByTypeId = StatusStore & {
|
|
2547
|
+
typeId: StatusTypeId;
|
|
2548
|
+
};
|
|
2549
|
+
type UseStatusStore = <T = StatusesByStoryIdAndTypeId>(selector?: (statuses: StatusesByStoryIdAndTypeId) => T) => T;
|
|
2550
|
+
|
|
2551
|
+
type TestProviderState = 'test-provider-state:pending' | 'test-provider-state:running' | 'test-provider-state:succeeded' | 'test-provider-state:crashed';
|
|
2552
|
+
type TestProviderId = string;
|
|
2553
|
+
type TestProviderStateByProviderId = Record<TestProviderId, TestProviderState>;
|
|
2554
|
+
type BaseTestProviderStore = {
|
|
2555
|
+
/**
|
|
2556
|
+
* Notifies all listeners that settings have changed for test providers. The Storybook UI will
|
|
2557
|
+
* highlight the test providers to tell the user that settings has changed.
|
|
2558
|
+
*/
|
|
2559
|
+
settingsChanged: () => void;
|
|
2560
|
+
/**
|
|
2561
|
+
* Subscribe to clicks on the "Run All" button, that is supposed to trigger all test providers to
|
|
2562
|
+
* run. Your test provider should do the "main thing" when this happens, similar to when the user
|
|
2563
|
+
* triggers your test provider specifically.
|
|
2564
|
+
*
|
|
2565
|
+
* @example
|
|
2566
|
+
*
|
|
2567
|
+
* ```typescript
|
|
2568
|
+
* // Subscribe to run-all events
|
|
2569
|
+
* const unsubscribe = myTestProviderStore.onRunAll(() => {
|
|
2570
|
+
* await runAllMyTests();
|
|
2571
|
+
* });
|
|
2572
|
+
* ```
|
|
2573
|
+
*/
|
|
2574
|
+
onRunAll: (listener: () => void) => () => void;
|
|
2575
|
+
/**
|
|
2576
|
+
* Subscribe to clicks on the "Clear All" button, that is supposed to clear all state from test
|
|
2577
|
+
* providers. Storybook already clears all statuses, but if your test provider has more
|
|
2578
|
+
* non-status-based state, you can use this to clear that here.
|
|
2579
|
+
*
|
|
2580
|
+
* @remarks
|
|
2581
|
+
* The purpose of this is _not_ to clear your test provider's settings, only the test results.
|
|
2582
|
+
* @example
|
|
2583
|
+
*
|
|
2584
|
+
* ```typescript
|
|
2585
|
+
* // Subscribe to clear-all events
|
|
2586
|
+
* const unsubscribe = myTestProviderStore.onClearAll(() => {
|
|
2587
|
+
* clearMyTestResults();
|
|
2588
|
+
* });
|
|
2589
|
+
*
|
|
2590
|
+
* // Later, when no longer needed
|
|
2591
|
+
* unsubscribe();
|
|
2592
|
+
* ```
|
|
2593
|
+
*/
|
|
2594
|
+
onClearAll: (listener: () => void) => () => void;
|
|
2595
|
+
};
|
|
2596
|
+
/**
|
|
2597
|
+
* Represents a store for a specific test provider, identified by its unique ID. This store provides
|
|
2598
|
+
* methods to manage the state of an individual test provider, including getting and setting its
|
|
2599
|
+
* state, running operations with automatic state management, and accessing its unique identifier.
|
|
2600
|
+
*
|
|
2601
|
+
* Each test provider has its own instance of this store, allowing for independent state management
|
|
2602
|
+
* across different test providers in the application.
|
|
2603
|
+
*
|
|
2604
|
+
* @example
|
|
2605
|
+
*
|
|
2606
|
+
* ```typescript
|
|
2607
|
+
* // Get a store for a specific test provider
|
|
2608
|
+
* const grammarStore = getTestProviderStoreById('addon-grammar');
|
|
2609
|
+
*
|
|
2610
|
+
* // Check the current state
|
|
2611
|
+
* if (grammarStore.getState() === 'test-provider-state:pending') {
|
|
2612
|
+
* console.log('Grammar tests are ready to run');
|
|
2613
|
+
* }
|
|
2614
|
+
*
|
|
2615
|
+
* // Run tests with automatic state management
|
|
2616
|
+
* grammarStore.runWithState(async () => {
|
|
2617
|
+
* await runGrammarTests();
|
|
2618
|
+
* });
|
|
2619
|
+
* ```
|
|
2620
|
+
*
|
|
2621
|
+
* @see {@link TestProviderState} for possible state values
|
|
2622
|
+
* @see {@link BaseTestProviderStore} for methods inherited from the base store
|
|
2623
|
+
*/
|
|
2624
|
+
type TestProviderStoreById = BaseTestProviderStore & {
|
|
2625
|
+
/**
|
|
2626
|
+
* Gets the current state of this specific test provider
|
|
2627
|
+
*
|
|
2628
|
+
* The state represents the current execution status of the test provider, which can be one of the
|
|
2629
|
+
* following:
|
|
2630
|
+
*
|
|
2631
|
+
* - 'test-provider-state:pending': Tests have not been run yet
|
|
2632
|
+
* - 'test-provider-state:running': Tests are currently running
|
|
2633
|
+
* - 'test-provider-state:succeeded': Tests completed successfully
|
|
2634
|
+
* - 'test-provider-state:crashed': Running tests failed or encountered an error
|
|
2635
|
+
*
|
|
2636
|
+
* Storybook UI will use this state to determine what to show in the UI.
|
|
2637
|
+
*
|
|
2638
|
+
* @remarks
|
|
2639
|
+
* The 'test-provider-state:crashed' is meant to signify that the test run as a whole failed to
|
|
2640
|
+
* execute for some reason. It should _not_ be set just because a number of tests failed, use
|
|
2641
|
+
* statuses and the status store for that. See {@link TestStatusStore} for managing individual test
|
|
2642
|
+
* statuses.
|
|
2643
|
+
* @example
|
|
2644
|
+
*
|
|
2645
|
+
* ```typescript
|
|
2646
|
+
* // Get the current state of a specific test provider
|
|
2647
|
+
* const state = testProviderStore.getState();
|
|
2648
|
+
*
|
|
2649
|
+
* // Conditionally render UI based on the state
|
|
2650
|
+
* const TestStatus = () => {
|
|
2651
|
+
* const state = testProviderStore.getState();
|
|
2652
|
+
*
|
|
2653
|
+
* if (state === 'test-provider-state:running') {
|
|
2654
|
+
* return <Spinner />;
|
|
2655
|
+
* } else if (state === 'test-provider-state:succeeded') {
|
|
2656
|
+
* return <SuccessIcon />;
|
|
2657
|
+
* } else if (state === 'test-provider-state:crashed') {
|
|
2658
|
+
* return <ErrorIcon />;
|
|
2659
|
+
* }
|
|
2660
|
+
*
|
|
2661
|
+
* return <PendingIcon />;
|
|
2662
|
+
* };
|
|
2663
|
+
* ```
|
|
2664
|
+
*/
|
|
2665
|
+
getState: () => TestProviderState;
|
|
2666
|
+
/**
|
|
2667
|
+
* Sets the state of this specific test provider
|
|
2668
|
+
*
|
|
2669
|
+
* This method allows you to manually update the execution state of the test provider. It's
|
|
2670
|
+
* typically used when you need to reflect the current status of test execution in the UI or when
|
|
2671
|
+
* you want to programmatically control the test provider's state.
|
|
2672
|
+
*
|
|
2673
|
+
* Common use cases include:
|
|
2674
|
+
*
|
|
2675
|
+
* - Setting to 'running' when tests start
|
|
2676
|
+
* - Setting to 'succeeded' when tests complete successfully
|
|
2677
|
+
* - Setting to 'crashed' when tests fail or encounter errors
|
|
2678
|
+
* - Setting to 'pending' to reset the state
|
|
2679
|
+
*
|
|
2680
|
+
* The state represents the current execution status of the test provider, which can be one of the
|
|
2681
|
+
* following:
|
|
2682
|
+
*
|
|
2683
|
+
* - 'test-provider-state:pending': Tests have not been run yet
|
|
2684
|
+
* - 'test-provider-state:running': Tests are currently running
|
|
2685
|
+
* - 'test-provider-state:succeeded': Tests completed successfully
|
|
2686
|
+
* - 'test-provider-state:crashed': Running tests failed or encountered an error
|
|
2687
|
+
*
|
|
2688
|
+
* Storybook UI will use this state to determine what to show in the UI.
|
|
2689
|
+
*
|
|
2690
|
+
* @remarks
|
|
2691
|
+
* The 'test-provider-state:crashed' is meant to signify that the test run as a whole failed to
|
|
2692
|
+
* execute for some reason. It should _not_ be set just because a number of tests failed, use
|
|
2693
|
+
* statuses and the status store for that. See {@link TestStatusStore} for managing individual test
|
|
2694
|
+
* statuses.
|
|
2695
|
+
*
|
|
2696
|
+
* For most use cases, consider using {@link runWithState} instead, which provides automatic state
|
|
2697
|
+
* management and error handling during test execution.
|
|
2698
|
+
* @example
|
|
2699
|
+
*
|
|
2700
|
+
* ```typescript
|
|
2701
|
+
* // Update the state when tests start running
|
|
2702
|
+
* const startTests = async () => {
|
|
2703
|
+
* testProviderStore.setState('test-provider-state:running');
|
|
2704
|
+
* ... run tests ...
|
|
2705
|
+
* };
|
|
2706
|
+
* ```
|
|
2707
|
+
*/
|
|
2708
|
+
setState: (state: TestProviderState) => void;
|
|
2709
|
+
/**
|
|
2710
|
+
* Runs a callback and automatically updates the test provider's state with running, succeeded or
|
|
2711
|
+
* crashed, depending on the end result.
|
|
2712
|
+
*
|
|
2713
|
+
* - Immediately changes the state to 'running'
|
|
2714
|
+
* - If the callback returns/resolves, change the state to 'succeeded'.
|
|
2715
|
+
* - If the callback throws an error/rejects, change the state to 'crashed'.
|
|
2716
|
+
*
|
|
2717
|
+
* This approach helps prevent state inconsistencies that might occur if exceptions are thrown
|
|
2718
|
+
* during test execution.
|
|
2719
|
+
*
|
|
2720
|
+
* @example
|
|
2721
|
+
*
|
|
2722
|
+
* ```typescript
|
|
2723
|
+
* // Run tests with automatic state management
|
|
2724
|
+
* const runTests = () => {
|
|
2725
|
+
* testProviderStore.runWithState(async () => {
|
|
2726
|
+
* // The state is automatically set to 'running' before this callback
|
|
2727
|
+
*
|
|
2728
|
+
* // Run tests here...
|
|
2729
|
+
* const results = await executeTests();
|
|
2730
|
+
* });
|
|
2731
|
+
* };
|
|
2732
|
+
* ```
|
|
2733
|
+
*/
|
|
2734
|
+
runWithState: (callback: () => void | Promise<void>) => Promise<void>;
|
|
2735
|
+
/** The unique identifier for this test provider */
|
|
2736
|
+
testProviderId: TestProviderId;
|
|
2737
|
+
};
|
|
2738
|
+
/**
|
|
2739
|
+
* React OR preview hook for accessing the state of _all_ test providers. This hook will only
|
|
2740
|
+
* trigger a re-render when the state changes. It is recommended to pass the optional selector, to
|
|
2741
|
+
* get more fine-grained control of re-renders.
|
|
2742
|
+
*
|
|
2743
|
+
* @example
|
|
2744
|
+
*
|
|
2745
|
+
* ```typescript
|
|
2746
|
+
* const TestStatus = () => {
|
|
2747
|
+
* const state = useTestProviderStore((state) => state['my-test-provider']);
|
|
2748
|
+
* };
|
|
2749
|
+
* ```
|
|
2750
|
+
*/
|
|
2751
|
+
type UseTestProviderStore = <T = TestProviderStateByProviderId>(
|
|
2752
|
+
/**
|
|
2753
|
+
* Optional selector function to extract or transform specific parts of the state
|
|
2754
|
+
*
|
|
2755
|
+
* @example
|
|
2756
|
+
*
|
|
2757
|
+
* ```typescript
|
|
2758
|
+
* // Use the entire state
|
|
2759
|
+
* const allProviderStates = useTestProviderStore();
|
|
2760
|
+
*
|
|
2761
|
+
* // Get state for a specific provider
|
|
2762
|
+
* const myProviderState = useTestProviderStore((state) => state['my-test-provider']);
|
|
2763
|
+
*
|
|
2764
|
+
* // Get a count of providers in each state
|
|
2765
|
+
* const statusCounts = useTestProviderStore((state) => {
|
|
2766
|
+
* const counts = {
|
|
2767
|
+
* pending: 0,
|
|
2768
|
+
* running: 0,
|
|
2769
|
+
* succeeded: 0,
|
|
2770
|
+
* crashed: 0,
|
|
2771
|
+
* };
|
|
2772
|
+
*
|
|
2773
|
+
* Object.values(state).forEach((status) => {
|
|
2774
|
+
* if (status === 'test-provider-state:pending') counts.pending++;
|
|
2775
|
+
* else if (status === 'test-provider-state:running') counts.running++;
|
|
2776
|
+
* else if (status === 'test-provider-state:succeeded') counts.succeeded++;
|
|
2777
|
+
* else if (status === 'test-provider-state:crashed') counts.crashed++;
|
|
2778
|
+
* });
|
|
2779
|
+
*
|
|
2780
|
+
* return counts;
|
|
2781
|
+
* });
|
|
2782
|
+
*
|
|
2783
|
+
* // Check if all tests have completed
|
|
2784
|
+
* const allTestsCompleted = useTestProviderStore((state) => {
|
|
2785
|
+
* return Object.values(state).every(
|
|
2786
|
+
* (status) =>
|
|
2787
|
+
* status === 'test-provider-state:succeeded' ||
|
|
2788
|
+
* status === 'test-provider-state:crashed'
|
|
2789
|
+
* );
|
|
2790
|
+
* });
|
|
2791
|
+
* ```
|
|
2792
|
+
*/
|
|
2793
|
+
selector?: (state: TestProviderStateByProviderId) => T) => T;
|
|
2794
|
+
|
|
2795
|
+
export { type API_ActiveTabsType, type API_BaseEntry, type API_ComponentEntry, type API_ComposedRef, type API_ComposedRefUpdate, type API_DocsEntry, type API_FilterFunction, type API_GroupEntry, type API_HashEntry, type API_IframeRenderer, type API_IndexHash, type API_Layout, type API_LeafEntry, type API_LoadedRefData, type API_MatchOptions, type API_Notification, type API_OptionsData, type API_PanelPositions, type API_PreparedIndexEntry, type API_PreparedStoryIndex, type API_Provider, type API_ProviderData, type API_RefId, type API_RefUrl, type API_Refs, type API_ReleaseNotes, type API_RenderOptions, type API_RootEntry, type API_RouteOptions, type API_SetRefData, type API_Settings, type API_SidebarOptions, type API_StateMerger, type API_StoryEntry, type API_StoryMapper, type API_UI, type API_UIOptions, type API_UnknownEntries, type API_Version, type API_Versions$1 as API_Versions, type API_ViewMode, type Addon_AddStoryArgs, type Addon_Annotations, type Addon_ArgType, type Addon_ArgsStoryFn, type Addon_BaseAnnotations, type Addon_BaseDecorators, type Addon_BaseMeta, type Addon_BaseStoryFn, type Addon_BaseStoryObject, type Addon_BaseType, type Addon_ClientApiAddon, type Addon_ClientApiAddons, type Addon_ClientApiReturnFn, type Addon_ClientStoryApi, type Addon_Collection, type Addon_Comparator, type Addon_Config, type Addon_DecoratorFunction, type Addon_Elements, type Addon_LegacyStoryFn, type Addon_LoadFn, type Addon_Loadable, type Addon_Loader, type Addon_LoaderFunction, type Addon_Loaders, type Addon_MakeDecoratorResult, type Addon_OptionsParameter, type Addon_OptionsParameterV7, type Addon_PageType, type Addon_PartialStoryFn, type Addon_RenderOptions, type Addon_RequireContext, type Addon_SidebarBottomType, type Addon_SidebarTopType, type Addon_StoryApi, type Addon_StoryContext, type Addon_StoryContextUpdate, type Addon_StoryFn, type Addon_StorySortComparator, type Addon_StorySortComparatorV7, type Addon_StorySortMethod, type Addon_StorySortObjectParameter, type Addon_StorySortParameter, type Addon_StorySortParameterV7, type Addon_StoryWrapper, type Addon_TestProviderState, type Addon_TestProviderType, type Addon_ToolbarConfig, type Addon_Type, type Addon_Types, Addon_TypesEnum, type Addon_TypesMapping, type Addon_WrapperSettings, type Addon_WrapperType, type Addons_ArgTypes, type BaseIndexEntry, type BaseIndexInput, type BaseStory, type BoundStory, type Builder, type BuilderName, type BuilderOptions, type BuilderResult, type BuilderStats, type Builder_EnvsRaw, type Builder_Unpromise, type Builder_WithRequiredProperty, type CLIBaseOptions, type CLIOptions, type CSFFile, type CompatibleString, type ComposeStoryFn, type ComposedStoryFn, type CoreCommon_AddonEntry, type CoreCommon_AddonInfo, type CoreCommon_OptionsEntry, type CoreCommon_ResolvedAddonPreset, type CoreCommon_ResolvedAddonVirtual, type CoreCommon_StorybookInfo, type CoreConfig, type DocsContextProps, type DocsIndexEntry, type DocsIndexInput, type DocsOptions, type DocsPreparedPayload, type DocsRenderFunction, type Entry, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, type ModuleExport, type ModuleExports, type ModuleImportFn, type NamedOrDefaultProjectAnnotations, type NormalizedComponentAnnotations, type NormalizedProjectAnnotations, type NormalizedStoriesSpecifier, type NormalizedStoryAnnotations, type Options, type PackageJson, type PartialArgsStoryFn, type Path, type PreparedMeta, type PreparedStory, type Preset, type PresetConfig, type PresetProperty, type PresetPropertyFn, type PresetValue, type Presets, type PreviewAnnotation, type ProjectAnnotations, type Ref, type RenderContext, type RenderContextCallbacks, type RenderToCanvas, type Renderer, type RendererName, type ResolvedModuleExport, type ResolvedModuleExportFromType, type ResolvedModuleExportType, type SetGlobalsPayload, type SetStoriesPayload, type SetStoriesStory, type SetStoriesStoryData, type Stats, type Status, type StatusByTypeId, type StatusStore, type StatusStoreByTypeId, type StatusTypeId, type StatusValue, type StatusesByStoryIdAndTypeId, type Store_CSFExports, type StoriesEntry, type StoriesSpecifier, type StoriesWithPartialProps, type StoryIndex, type StoryIndexEntry, type StoryIndexInput, type StoryIndexV2, type StoryIndexV3, type StoryPreparedPayload, type StoryRenderOptions, type StorybookConfig, type StorybookConfigOptions, type StorybookConfigRaw, type StorybookInternalParameters, type StorybookParameters, type SupportedFrameworks, type SupportedRenderers, type TagOptions, type TagsOptions, type TeardownRenderToCanvas, type TestBuildConfig, type TestBuildFlags, type TestProviderId, type TestProviderState, type TestProviderStoreById, type TypescriptOptions, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };
|