storybook 9.0.0-alpha.2 → 9.0.0-alpha.20

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.
Files changed (159) hide show
  1. package/README.md +1 -1
  2. package/assets/docs/addon-backgrounds.gif +0 -0
  3. package/assets/docs/addon-controls-args-annotated.png +0 -0
  4. package/assets/docs/addon-controls-args-background-color.png +0 -0
  5. package/assets/docs/addon-controls-args-background-string.png +0 -0
  6. package/assets/docs/addon-controls-args-docs.png +0 -0
  7. package/assets/docs/addon-controls-args-logging.png +0 -0
  8. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  9. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  10. package/assets/docs/addon-controls-args-reflow.png +0 -0
  11. package/assets/docs/addon-controls-args-template.png +0 -0
  12. package/assets/docs/addon-controls-expanded.png +0 -0
  13. package/assets/docs/addon-controls-hero.gif +0 -0
  14. package/assets/docs/addon-controls-install.png +0 -0
  15. package/assets/docs/hero.gif +0 -0
  16. package/assets/docs/highlight.png +0 -0
  17. package/assets/docs/viewport.png +0 -0
  18. package/bin/index.cjs +2 -2
  19. package/dist/actions/decorator.d.ts +6 -0
  20. package/dist/actions/decorator.js +138 -0
  21. package/dist/actions/index.cjs +126 -0
  22. package/dist/actions/index.d.ts +102 -0
  23. package/dist/actions/index.js +111 -0
  24. package/dist/actions/preview.cjs +164 -0
  25. package/dist/actions/preview.d.ts +54 -0
  26. package/dist/actions/preview.js +155 -0
  27. package/dist/backgrounds/index.cjs +148 -0
  28. package/dist/backgrounds/index.d.ts +91 -0
  29. package/dist/backgrounds/index.js +130 -0
  30. package/dist/backgrounds/preview.cjs +143 -0
  31. package/dist/backgrounds/preview.d.ts +54 -0
  32. package/dist/backgrounds/preview.js +127 -0
  33. package/dist/bin/index.cjs +66 -89
  34. package/dist/bin/index.js +62 -85
  35. package/dist/builder-manager/index.cjs +523 -540
  36. package/dist/builder-manager/index.js +544 -561
  37. package/dist/channels/index.cjs +1026 -981
  38. package/dist/channels/index.js +1194 -1165
  39. package/dist/cli/bin/index.cjs +483 -483
  40. package/dist/cli/bin/index.js +495 -495
  41. package/dist/cli/index.cjs +2279 -2295
  42. package/dist/cli/index.d.ts +4 -8
  43. package/dist/cli/index.js +740 -756
  44. package/dist/client-logger/index.cjs +56 -88
  45. package/dist/client-logger/index.js +41 -47
  46. package/dist/common/index.cjs +2496 -2480
  47. package/dist/common/index.d.ts +5 -29
  48. package/dist/common/index.js +2679 -2663
  49. package/dist/component-testing/index.cjs +23 -0
  50. package/dist/component-testing/index.d.ts +3 -0
  51. package/dist/component-testing/index.js +5 -0
  52. package/dist/component-testing/preview.cjs +40 -0
  53. package/dist/component-testing/preview.d.ts +5 -0
  54. package/dist/component-testing/preview.js +25 -0
  55. package/dist/components/index.cjs +11709 -20418
  56. package/dist/components/index.d.ts +94 -346
  57. package/dist/components/index.js +5827 -19157
  58. package/dist/controls/decorator.d.ts +5 -0
  59. package/dist/controls/decorator.js +8 -0
  60. package/dist/controls/index.cjs +26 -0
  61. package/dist/controls/index.d.ts +39 -0
  62. package/dist/controls/index.js +6 -0
  63. package/dist/controls/preview.cjs +26 -0
  64. package/dist/controls/preview.d.ts +54 -0
  65. package/dist/controls/preview.js +9 -0
  66. package/dist/core-events/index.cjs +91 -106
  67. package/dist/core-events/index.d.ts +139 -104
  68. package/dist/core-events/index.js +79 -94
  69. package/dist/core-server/index.cjs +14413 -13924
  70. package/dist/core-server/index.d.ts +270 -3
  71. package/dist/core-server/index.js +14003 -13519
  72. package/dist/core-server/presets/common-manager.css +170 -0
  73. package/dist/core-server/presets/common-manager.js +12099 -17
  74. package/dist/core-server/presets/common-preset.cjs +2760 -2914
  75. package/dist/core-server/presets/common-preset.js +2852 -3007
  76. package/dist/csf/index.cjs +76 -120
  77. package/dist/csf/index.d.ts +2 -6
  78. package/dist/csf/index.js +69 -113
  79. package/dist/csf-tools/index.cjs +412 -403
  80. package/dist/csf-tools/index.d.ts +0 -4
  81. package/dist/csf-tools/index.js +410 -401
  82. package/dist/docs-tools/index.cjs +2569 -575
  83. package/dist/docs-tools/index.d.ts +2 -2
  84. package/dist/docs-tools/index.js +2557 -564
  85. package/dist/highlight/index.cjs +27 -0
  86. package/dist/highlight/index.d.ts +17 -0
  87. package/dist/highlight/index.js +7 -0
  88. package/dist/highlight/preview.cjs +81 -0
  89. package/dist/highlight/preview.d.ts +54 -0
  90. package/dist/highlight/preview.js +67 -0
  91. package/dist/instrumenter/index.cjs +2207 -2342
  92. package/dist/instrumenter/index.d.ts +8 -7
  93. package/dist/instrumenter/index.js +2438 -2620
  94. package/dist/manager/globals-module-info.cjs +290 -151
  95. package/dist/manager/globals-module-info.d.ts +1 -1
  96. package/dist/manager/globals-module-info.js +274 -135
  97. package/dist/manager/globals-runtime.js +60016 -28331
  98. package/dist/manager/globals.cjs +23 -19
  99. package/dist/manager/globals.d.ts +8 -5
  100. package/dist/manager/globals.js +10 -6
  101. package/dist/manager/runtime.js +4645 -3946
  102. package/dist/manager-api/index.cjs +4228 -3833
  103. package/dist/manager-api/index.d.ts +398 -102
  104. package/dist/manager-api/index.js +3676 -3291
  105. package/dist/manager-errors.d.ts +25 -1
  106. package/dist/manager-errors.js +42 -26
  107. package/dist/measure/index.cjs +474 -0
  108. package/dist/measure/index.d.ts +66 -0
  109. package/dist/measure/index.js +462 -0
  110. package/dist/measure/preview.cjs +464 -0
  111. package/dist/measure/preview.d.ts +59 -0
  112. package/dist/measure/preview.js +448 -0
  113. package/dist/outline/index.cjs +528 -0
  114. package/dist/outline/index.d.ts +66 -0
  115. package/dist/outline/index.js +500 -0
  116. package/dist/outline/preview.cjs +518 -0
  117. package/dist/outline/preview.d.ts +59 -0
  118. package/dist/outline/preview.js +486 -0
  119. package/dist/preview/globals.cjs +21 -17
  120. package/dist/preview/globals.d.ts +4 -1
  121. package/dist/preview/globals.js +6 -2
  122. package/dist/preview/runtime.js +45697 -6618
  123. package/dist/preview-api/index.cjs +1363 -1898
  124. package/dist/preview-api/index.d.ts +449 -498
  125. package/dist/preview-api/index.js +1622 -2095
  126. package/dist/preview-errors.cjs +99 -82
  127. package/dist/preview-errors.d.ts +25 -1
  128. package/dist/preview-errors.js +110 -94
  129. package/dist/router/index.cjs +847 -871
  130. package/dist/router/index.js +193 -199
  131. package/dist/server-errors.cjs +156 -125
  132. package/dist/server-errors.d.ts +28 -2
  133. package/dist/server-errors.js +150 -119
  134. package/dist/telemetry/index.cjs +1050 -1977
  135. package/dist/telemetry/index.d.ts +26 -5
  136. package/dist/telemetry/index.js +1085 -2008
  137. package/dist/test/index.cjs +35686 -0
  138. package/dist/test/index.d.ts +186 -0
  139. package/dist/test/index.js +33752 -0
  140. package/dist/test/preview.cjs +15870 -0
  141. package/dist/test/preview.d.ts +54 -0
  142. package/dist/test/preview.js +14441 -0
  143. package/dist/test/spy.cjs +258 -0
  144. package/dist/test/spy.d.ts +66 -0
  145. package/dist/test/spy.js +240 -0
  146. package/dist/theming/create.cjs +79 -2269
  147. package/dist/theming/create.js +67 -841
  148. package/dist/theming/index.cjs +1065 -3232
  149. package/dist/theming/index.js +951 -1719
  150. package/dist/types/index.cjs +11 -12
  151. package/dist/types/index.d.ts +612 -157
  152. package/dist/types/index.js +1 -2
  153. package/dist/viewport/index.cjs +310 -0
  154. package/dist/viewport/index.d.ts +320 -0
  155. package/dist/viewport/index.js +290 -0
  156. package/dist/viewport/preview.cjs +35 -0
  157. package/dist/viewport/preview.d.ts +68 -0
  158. package/dist/viewport/preview.js +19 -0
  159. package/package.json +359 -12
@@ -1,51 +1,12 @@
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$2, StrictArgTypes, StrictGlobalTypes, StepRunner, BeforeAll, ComponentAnnotations, StoryAnnotations, StoryContextForEnhancers, CleanupCallback, Canvas, StoryAnnotationsOrFn, AnnotatedStoryFn } from 'storybook/internal/csf';
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
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
3
  import { ReactElement, FC, ReactNode, PropsWithChildren } from 'react';
4
- import { Addon_TestProviderType as Addon_TestProviderType$1, NormalizedProjectAnnotations as NormalizedProjectAnnotations$1, ProjectAnnotations as ProjectAnnotations$1, ComposedStoryFn as ComposedStoryFn$1 } from 'storybook/internal/types';
5
4
  import { FileSystemCache } from 'storybook/internal/common';
6
5
  import { Server, IncomingMessage, ServerResponse } from 'http';
7
6
  import { Server as Server$1 } from 'net';
7
+ import { NormalizedProjectAnnotations as NormalizedProjectAnnotations$1, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn as ComposedStoryFn$1 } from 'storybook/internal/types';
8
8
  import { Channel as Channel$1 } from 'storybook/internal/channels';
9
9
 
10
- type DateNow = number;
11
- type TestProviderConfig = Addon_TestProviderType$1;
12
- type TestingModuleProgressReportProgress = {
13
- startedAt: DateNow;
14
- finishedAt?: DateNow;
15
- numTotalTests?: number;
16
- numPassedTests?: number;
17
- numFailedTests?: number;
18
- numPendingTests?: number;
19
- percentageCompleted?: number;
20
- };
21
-
22
- declare global {
23
- var globalProjectAnnotations: NormalizedProjectAnnotations$1<any>;
24
- var defaultProjectAnnotations: ProjectAnnotations$1<any>;
25
- }
26
- type WrappedStoryRef = {
27
- __pw_type: 'jsx' | 'importRef';
28
- };
29
- type UnwrappedJSXStoryRef = {
30
- __pw_type: 'jsx';
31
- type: UnwrappedImportStoryRef;
32
- };
33
- type UnwrappedImportStoryRef = ComposedStoryFn$1;
34
- declare global {
35
- function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
36
- }
37
-
38
- interface Report<T = unknown> {
39
- type: string;
40
- version?: number;
41
- result: T;
42
- status: 'failed' | 'passed' | 'warning';
43
- }
44
- declare class ReporterAPI {
45
- reports: Report[];
46
- addReport(report: Report): Promise<void>;
47
- }
48
-
49
10
  /**
50
11
  * A URL pathname, beginning with a /.
51
12
  *
@@ -196,7 +157,7 @@ interface ChannelEvent {
196
157
  from: string;
197
158
  args: any[];
198
159
  }
199
- interface Listener {
160
+ interface Listener$1 {
200
161
  (...args: any[]): void;
201
162
  }
202
163
  interface ChannelArgsSingle {
@@ -217,32 +178,29 @@ declare class Channel {
217
178
  constructor(input: ChannelArgsMulti);
218
179
  constructor(input: ChannelArgsSingle);
219
180
  get hasTransport(): boolean;
220
- addListener(eventName: string, listener: Listener): void;
181
+ addListener(eventName: string, listener: Listener$1): void;
221
182
  emit(eventName: string, ...args: any): void;
222
183
  last(eventName: string): any;
223
184
  eventNames(): string[];
224
185
  listenerCount(eventName: string): number;
225
- listeners(eventName: string): Listener[] | undefined;
226
- once(eventName: string, listener: Listener): void;
186
+ listeners(eventName: string): Listener$1[] | undefined;
187
+ once(eventName: string, listener: Listener$1): void;
227
188
  removeAllListeners(eventName?: string): void;
228
- removeListener(eventName: string, listener: Listener): void;
229
- on(eventName: string, listener: Listener): void;
230
- off(eventName: string, listener: Listener): void;
189
+ removeListener(eventName: string, listener: Listener$1): void;
190
+ on(eventName: string, listener: Listener$1): void;
191
+ off(eventName: string, listener: Listener$1): void;
231
192
  private handleEvent;
232
193
  private onceListener;
233
194
  }
234
195
 
235
196
  interface Options$1 {
236
197
  allowRegExp: boolean;
237
- allowFunction: boolean;
238
198
  allowSymbol: boolean;
239
199
  allowDate: boolean;
240
200
  allowUndefined: boolean;
241
- allowClass: boolean;
242
201
  allowError: boolean;
243
202
  maxDepth: number;
244
203
  space: number | undefined;
245
- lazyEval: boolean;
246
204
  }
247
205
 
248
206
  /**
@@ -1325,13 +1283,6 @@ type CoreCommon_StorybookRefs = Record<string, {
1325
1283
  type DocsOptions = {
1326
1284
  /** What should we call the generated docs entries? */
1327
1285
  defaultName?: string;
1328
- /**
1329
- * Should we generate a docs entry per CSF file? Set to 'tag' (the default) to generate an entry
1330
- * for every CSF file with the 'autodocs' tag.
1331
- *
1332
- * @deprecated Use `tags: ['autodocs']` in `.storybook/preview.js` instead
1333
- */
1334
- autodocs?: boolean | 'tag';
1335
1286
  /** Only show doc entries in the side bar (usually set with the `--docs` CLI flag) */
1336
1287
  docsMode?: boolean;
1337
1288
  };
@@ -1397,10 +1348,6 @@ interface StorybookConfigRaw {
1397
1348
  disallowImplicitActionsInRenderV8?: boolean;
1398
1349
  /** Enable asynchronous component rendering in React renderer */
1399
1350
  experimentalRSC?: boolean;
1400
- /** Use globals & globalTypes for configuring the viewport addon */
1401
- viewportStoryGlobals?: boolean;
1402
- /** Use globals & globalTypes for configuring the backgrounds addon */
1403
- backgroundsStoryGlobals?: boolean;
1404
1351
  /** Set NODE_ENV to development in built Storybooks for better testability and debuggability */
1405
1352
  developmentModeForBuild?: boolean;
1406
1353
  };
@@ -1659,19 +1606,8 @@ interface API_Versions$1 {
1659
1606
  next?: API_Version;
1660
1607
  current?: API_Version;
1661
1608
  }
1662
- type API_StatusValue = 'pending' | 'success' | 'error' | 'warn' | 'unknown';
1663
- interface API_StatusObject {
1664
- status: API_StatusValue;
1665
- title: string;
1666
- description: string;
1667
- data?: any;
1668
- onClick?: () => void;
1669
- sidebarContextMenu?: boolean;
1670
- }
1671
- type API_StatusState = Record<StoryId, Record<string, API_StatusObject>>;
1672
- type API_StatusUpdate = Record<StoryId, API_StatusObject | null>;
1673
1609
  type API_FilterFunction = (item: API_PreparedIndexEntry & {
1674
- status: Record<string, API_StatusObject | null>;
1610
+ statuses: StatusByTypeId;
1675
1611
  }) => boolean;
1676
1612
 
1677
1613
  interface SetStoriesStory {
@@ -1753,8 +1689,6 @@ interface API_ProviderData<API> {
1753
1689
  }
1754
1690
  interface API_Provider<API> {
1755
1691
  channel?: Channel;
1756
- /** @deprecated Will be removed in 8.0, please use channel instead */
1757
- serverChannel?: Channel;
1758
1692
  renderPreview?: API_IframeRenderer;
1759
1693
  handleAPI(api: API): void;
1760
1694
  getConfig(): {
@@ -1793,8 +1727,6 @@ interface API_Layout {
1793
1727
  panelPosition: API_PanelPositions;
1794
1728
  showTabs: boolean;
1795
1729
  showToolbar: boolean;
1796
- /** @deprecated, will be removed in 8.0 - this API no longer works */
1797
- isToolshown?: boolean;
1798
1730
  }
1799
1731
  interface API_UI {
1800
1732
  name?: string;
@@ -1819,14 +1751,6 @@ interface OnClickOptions {
1819
1751
  /** Function to dismiss the notification. */
1820
1752
  onDismiss: () => void;
1821
1753
  }
1822
- /**
1823
- * @deprecated Use ReactNode for the icon instead.
1824
- * @see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated
1825
- */
1826
- interface DeprecatedIconType {
1827
- name: string;
1828
- color?: string;
1829
- }
1830
1754
  interface API_Notification {
1831
1755
  id: string;
1832
1756
  content: {
@@ -1835,7 +1759,7 @@ interface API_Notification {
1835
1759
  };
1836
1760
  duration?: number;
1837
1761
  link?: string;
1838
- icon?: React.ReactNode | DeprecatedIconType;
1762
+ icon?: React.ReactNode;
1839
1763
  onClear?: (options: OnClearOptions) => void;
1840
1764
  onClick?: (options: OnClickOptions) => void;
1841
1765
  }
@@ -1869,7 +1793,7 @@ type API_Refs = Record<string, API_ComposedRef>;
1869
1793
  type API_RefId = string;
1870
1794
  type API_RefUrl = string;
1871
1795
 
1872
- 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>;
1796
+ type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
1873
1797
  interface Addon_ArgType<TArg = unknown> extends InputType {
1874
1798
  defaultValue?: TArg;
1875
1799
  }
@@ -2060,7 +1984,6 @@ interface Addon_BaseMeta<ComponentType> {
2060
1984
  *
2061
1985
  * Used by addons for automatic prop table generation and display of other component metadata.
2062
1986
  *
2063
- * @deprecated
2064
1987
  * @example
2065
1988
  *
2066
1989
  * ```ts
@@ -2086,7 +2009,7 @@ type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnRetur
2086
2009
  interface Addon_RenderOptions {
2087
2010
  active: boolean;
2088
2011
  }
2089
- type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_SidebarBottomType | Addon_SidebarTopType | Addon_TestProviderType<Addon_TestProviderState>;
2012
+ type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_TestProviderType;
2090
2013
  interface Addon_BaseType {
2091
2014
  /**
2092
2015
  * The title of the addon. This can be a simple string, but it can also be a
@@ -2102,7 +2025,7 @@ interface Addon_BaseType {
2102
2025
  * Addon_TypesEnum.PANEL;
2103
2026
  * ```
2104
2027
  */
2105
- 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>;
2028
+ type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2106
2029
  /**
2107
2030
  * The unique id of the addon.
2108
2031
  *
@@ -2189,63 +2112,20 @@ interface Addon_WrapperType {
2189
2112
  storyId: StoryId;
2190
2113
  }>>;
2191
2114
  }
2192
- /** @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0. */
2193
- interface Addon_SidebarBottomType {
2194
- type: Addon_TypesEnum.experimental_SIDEBAR_BOTTOM;
2195
- /** The unique id of the tool. */
2196
- id: string;
2197
- /** A React.FunctionComponent. */
2198
- render: FC;
2199
- }
2200
- /** @deprecated This will be removed in Storybook 9.0. */
2201
- interface Addon_SidebarTopType {
2202
- type: Addon_TypesEnum.experimental_SIDEBAR_TOP;
2203
- /** The unique id of the tool. */
2204
- id: string;
2205
- /** A React.FunctionComponent. */
2206
- render: FC;
2207
- }
2208
- interface Addon_TestProviderType<Details extends {
2209
- [key: string]: any;
2210
- } = NonNullable<unknown>> {
2115
+ interface Addon_TestProviderType {
2211
2116
  type: Addon_TypesEnum.experimental_TEST_PROVIDER;
2212
2117
  /** The unique id of the test provider. */
2213
2118
  id: string;
2214
- name: string;
2215
- /** @deprecated Use render instead */
2216
- title?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
2217
- /** @deprecated Use render instead */
2218
- description?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
2219
- render?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
2119
+ render: () => ReactNode;
2220
2120
  sidebarContextMenu?: (options: {
2221
2121
  context: API_HashEntry;
2222
- state: TestProviderConfig & Addon_TestProviderState<Details>;
2223
2122
  }) => ReactNode;
2224
- stateUpdater?: (state: TestProviderConfig & Addon_TestProviderState<Details>, update: Partial<Addon_TestProviderState<Details>>) => void | Partial<TestProviderConfig & Addon_TestProviderState<Details>>;
2225
- runnable?: boolean;
2226
2123
  }
2227
- type Addon_TestProviderState<Details extends {
2228
- [key: string]: any;
2229
- } = NonNullable<unknown>> = Pick<Addon_TestProviderType, 'runnable'> & {
2230
- progress?: TestingModuleProgressReportProgress;
2231
- details: Details;
2232
- cancellable: boolean;
2233
- cancelling: boolean;
2234
- running: boolean;
2235
- failed: boolean;
2236
- crashed: boolean;
2237
- error?: {
2238
- name: string;
2239
- message?: string;
2240
- };
2241
- };
2242
- 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>;
2124
+ type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2243
2125
  interface Addon_TypesMapping extends Record<Addon_TypeBaseNames, Addon_BaseType> {
2244
2126
  [Addon_TypesEnum.PREVIEW]: Addon_WrapperType;
2245
2127
  [Addon_TypesEnum.experimental_PAGE]: Addon_PageType;
2246
- [Addon_TypesEnum.experimental_SIDEBAR_BOTTOM]: Addon_SidebarBottomType;
2247
- [Addon_TypesEnum.experimental_SIDEBAR_TOP]: Addon_SidebarTopType;
2248
- [Addon_TypesEnum.experimental_TEST_PROVIDER]: Addon_TestProviderType<Addon_TestProviderState>;
2128
+ [Addon_TypesEnum.experimental_TEST_PROVIDER]: Addon_TestProviderType;
2249
2129
  }
2250
2130
  type Addon_Loader<API> = (api: API) => void;
2251
2131
  interface Addon_Loaders<API> {
@@ -2294,18 +2174,6 @@ declare enum Addon_TypesEnum {
2294
2174
  * @unstable
2295
2175
  */
2296
2176
  experimental_PAGE = "page",
2297
- /**
2298
- * This adds items in the bottom of the sidebar.
2299
- *
2300
- * @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0.
2301
- */
2302
- experimental_SIDEBAR_BOTTOM = "sidebar-bottom",
2303
- /**
2304
- * This adds items in the top of the sidebar.
2305
- *
2306
- * @deprecated This will be removed in Storybook 9.0.
2307
- */
2308
- experimental_SIDEBAR_TOP = "sidebar-top",
2309
2177
  /** This adds items to the Testing Module in the sidebar. */
2310
2178
  experimental_TEST_PROVIDER = "test-provider"
2311
2179
  }
@@ -2340,13 +2208,12 @@ type ModuleImportFn = (path: Path) => Promise<ModuleExports>;
2340
2208
  type MaybePromise<T> = Promise<T> | T;
2341
2209
  type TeardownRenderToCanvas = () => MaybePromise<void>;
2342
2210
  type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
2343
- interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotations$2<TRenderer> {
2211
+ interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotations$1<TRenderer> {
2344
2212
  addons?: ProjectAnnotations<TRenderer>[];
2345
2213
  testingLibraryRender?: (...args: never[]) => {
2346
2214
  unmount: () => void;
2347
2215
  };
2348
2216
  renderToCanvas?: RenderToCanvas<TRenderer>;
2349
- renderToDOM?: RenderToCanvas<TRenderer>;
2350
2217
  }
2351
2218
  type NamedExportsOrDefault<TExport> = TExport | {
2352
2219
  default: TExport;
@@ -2372,7 +2239,7 @@ type NormalizedStoryAnnotations<TRenderer extends Renderer = Renderer> = Omit<St
2372
2239
  id: StoryId;
2373
2240
  argTypes?: StrictArgTypes;
2374
2241
  name: StoryName;
2375
- userStoryFn?: StoryFn<TRenderer>;
2242
+ userStoryFn?: ArgsStoryFn<TRenderer>;
2376
2243
  decorators?: DecoratorFunction<TRenderer>[];
2377
2244
  loaders?: LoaderFunction<TRenderer>[];
2378
2245
  };
@@ -2384,7 +2251,7 @@ type CSFFile<TRenderer extends Renderer = Renderer> = {
2384
2251
  };
2385
2252
  type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhancers<TRenderer> & {
2386
2253
  moduleExport: ModuleExport;
2387
- originalStoryFn: StoryFn<TRenderer>;
2254
+ originalStoryFn: ArgsStoryFn<TRenderer>;
2388
2255
  undecoratedStoryFn: LegacyStoryFn<TRenderer>;
2389
2256
  unboundStoryFn: LegacyStoryFn<TRenderer>;
2390
2257
  applyLoaders: (context: StoryContext<TRenderer>) => Promise<StoryContext<TRenderer>['loaded']>;
@@ -2493,6 +2360,33 @@ interface DocsContextProps<TRenderer extends Renderer = Renderer> {
2493
2360
  }
2494
2361
  type DocsRenderFunction<TRenderer extends Renderer> = (docsContext: DocsContextProps<TRenderer>, docsParameters: Parameters, element: HTMLElement) => Promise<void>;
2495
2362
 
2363
+ declare global {
2364
+ var globalProjectAnnotations: NormalizedProjectAnnotations$1<any>;
2365
+ var defaultProjectAnnotations: ProjectAnnotations$2<any>;
2366
+ }
2367
+ type WrappedStoryRef = {
2368
+ __pw_type: 'jsx' | 'importRef';
2369
+ };
2370
+ type UnwrappedJSXStoryRef = {
2371
+ __pw_type: 'jsx';
2372
+ type: UnwrappedImportStoryRef;
2373
+ };
2374
+ type UnwrappedImportStoryRef = ComposedStoryFn$1;
2375
+ declare global {
2376
+ function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
2377
+ }
2378
+
2379
+ interface Report<T = unknown> {
2380
+ type: string;
2381
+ version?: number;
2382
+ result: T;
2383
+ status: 'failed' | 'passed' | 'warning';
2384
+ }
2385
+ declare class ReporterAPI {
2386
+ reports: Report[];
2387
+ addReport(report: Report): Promise<void>;
2388
+ }
2389
+
2496
2390
  type Store_CSFExports<TRenderer extends Renderer$1 = Renderer$1, TArgs extends Args = Args> = {
2497
2391
  default: ComponentAnnotations<TRenderer, TArgs>;
2498
2392
  __esModule?: boolean;
@@ -2531,11 +2425,572 @@ type StoriesWithPartialProps<TRenderer extends Renderer$1, TModule> = {
2531
2425
  * function
2532
2426
  */
2533
2427
  interface ComposeStoryFn<TRenderer extends Renderer$1 = Renderer$1, TArgs extends Args = Args> {
2534
- (storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations$2<TRenderer>, exportsName?: string): ComposedStoryFn;
2428
+ (storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations$1<TRenderer>, exportsName?: string): ComposedStoryFn;
2535
2429
  }
2536
2430
 
2537
- 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';
2431
+ type SupportedFrameworks = 'angular' | 'ember' | 'html-vite' | 'nextjs' | 'nextjs-vite' | 'preact-vite' | 'react-native-web-vite' | 'react-vite' | 'react-webpack5' | 'server-webpack5' | 'svelte-vite' | 'sveltekit' | 'vue3-vite' | 'web-components-vite' | 'qwik' | 'solid' | 'nuxt' | 'react-rsbuild' | 'vue3-rsbuild';
2538
2432
 
2539
2433
  type SupportedRenderers = 'react' | 'react-native' | 'vue3' | 'angular' | 'ember' | 'preact' | 'svelte' | 'qwik' | 'html' | 'web-components' | 'server' | 'solid' | 'nuxt';
2540
2434
 
2541
- 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_StatusObject, type API_StatusState, type API_StatusUpdate, type API_StatusValue, 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 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 TypescriptOptions, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };
2435
+ type EnvironmentType = (typeof UniversalStore.Environment)[keyof typeof UniversalStore.Environment];
2436
+ type StatusType = (typeof UniversalStore.Status)[keyof typeof UniversalStore.Status];
2437
+ type StateUpdater<TState> = (prevState: TState) => TState;
2438
+ type Actor = {
2439
+ id: string;
2440
+ type: (typeof UniversalStore.ActorType)[keyof typeof UniversalStore.ActorType];
2441
+ environment: EnvironmentType;
2442
+ };
2443
+ type EventInfo = {
2444
+ actor: Actor;
2445
+ forwardingActor?: Actor;
2446
+ };
2447
+ type Listener<TEvent> = (event: TEvent, eventInfo: EventInfo) => void;
2448
+ type BaseEvent = {
2449
+ type: string;
2450
+ payload?: any;
2451
+ };
2452
+ interface SetStateEvent<TState> extends BaseEvent {
2453
+ type: typeof UniversalStore.InternalEventType.SET_STATE;
2454
+ payload: {
2455
+ state: TState;
2456
+ previousState: TState;
2457
+ };
2458
+ }
2459
+ interface ExistingStateRequestEvent extends BaseEvent {
2460
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_REQUEST;
2461
+ payload: never;
2462
+ }
2463
+ interface ExistingStateResponseEvent<TState> extends BaseEvent {
2464
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE;
2465
+ payload: TState;
2466
+ }
2467
+ interface LeaderCreatedEvent extends BaseEvent {
2468
+ type: typeof UniversalStore.InternalEventType.LEADER_CREATED;
2469
+ payload: never;
2470
+ }
2471
+ interface FollowerCreatedEvent extends BaseEvent {
2472
+ type: typeof UniversalStore.InternalEventType.FOLLOWER_CREATED;
2473
+ payload: never;
2474
+ }
2475
+ type InternalEvent<TState> = SetStateEvent<TState> | ExistingStateRequestEvent | ExistingStateResponseEvent<TState> | FollowerCreatedEvent | LeaderCreatedEvent;
2476
+ type Event<TState, TEvent extends BaseEvent> = TEvent | InternalEvent<TState>;
2477
+ type ChannelLike = Pick<Channel$1, 'on' | 'off' | 'emit'>;
2478
+ type StoreOptions<TState> = {
2479
+ id: string;
2480
+ leader?: boolean;
2481
+ initialState?: TState;
2482
+ debug?: boolean;
2483
+ };
2484
+ type EnvironmentOverrides = {
2485
+ channel: ChannelLike;
2486
+ environment: EnvironmentType;
2487
+ };
2488
+
2489
+ /**
2490
+ * A universal store implementation that synchronizes state across different environments using a
2491
+ * channel-based communication.
2492
+ *
2493
+ * The store follows a leader-follower pattern where:
2494
+ *
2495
+ * - Leader: The main store instance that owns and manages the state
2496
+ * - Follower: Store instances that mirror the leader's state
2497
+ *
2498
+ * Features:
2499
+ *
2500
+ * - State synchronization across environments
2501
+ * - Event-based communication
2502
+ * - Type-safe state and custom events
2503
+ * - Subscription system for state changes and custom events
2504
+ *
2505
+ * @remarks
2506
+ * - The store must be created using the static `create()` method, not the constructor
2507
+ * - Follower stores will automatically sync with their leader's state. If they have initial state, it
2508
+ * will be replaced immediately when it has synced with the leader.
2509
+ *
2510
+ * @example
2511
+ *
2512
+ * ```typescript
2513
+ * interface MyState {
2514
+ * count: number;
2515
+ * }
2516
+ * interface MyCustomEvent {
2517
+ * type: 'INCREMENT';
2518
+ * payload: number;
2519
+ * }
2520
+ *
2521
+ * // Create a leader store
2522
+ * const leaderStore = UniversalStore.create<MyState, MyCustomEvent>({
2523
+ * id: 'my-store',
2524
+ * leader: true,
2525
+ * initialState: { count: 0 },
2526
+ * });
2527
+ *
2528
+ * // Create a follower store
2529
+ * const followerStore = UniversalStore.create<MyState, MyCustomEvent>({
2530
+ * id: 'my-store',
2531
+ * leader: false,
2532
+ * });
2533
+ * ```
2534
+ *
2535
+ * @template State - The type of state managed by the store
2536
+ * @template CustomEvent - Custom events that can be sent through the store. Must have a `type`
2537
+ * string and optional `payload`
2538
+ * @throws {Error} If constructed directly instead of using `create()`
2539
+ * @throws {Error} If created without setting a channel first
2540
+ * @throws {Error} If a follower is created with initial state
2541
+ * @throws {Error} If a follower cannot find its leader within 1 second
2542
+ */
2543
+ declare class UniversalStore<State, CustomEvent extends {
2544
+ type: string;
2545
+ payload?: any;
2546
+ } = {
2547
+ type: string;
2548
+ payload?: any;
2549
+ }> {
2550
+ /**
2551
+ * Defines the possible actor types in the store system
2552
+ *
2553
+ * @readonly
2554
+ */
2555
+ static readonly ActorType: {
2556
+ readonly LEADER: "LEADER";
2557
+ readonly FOLLOWER: "FOLLOWER";
2558
+ };
2559
+ /**
2560
+ * Defines the possible environments the store can run in
2561
+ *
2562
+ * @readonly
2563
+ */
2564
+ static readonly Environment: {
2565
+ readonly SERVER: "SERVER";
2566
+ readonly MANAGER: "MANAGER";
2567
+ readonly PREVIEW: "PREVIEW";
2568
+ readonly UNKNOWN: "UNKNOWN";
2569
+ readonly MOCK: "MOCK";
2570
+ };
2571
+ /**
2572
+ * Internal event types used for store synchronization
2573
+ *
2574
+ * @readonly
2575
+ */
2576
+ static readonly InternalEventType: {
2577
+ readonly EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST";
2578
+ readonly EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE";
2579
+ readonly SET_STATE: "__SET_STATE";
2580
+ readonly LEADER_CREATED: "__LEADER_CREATED";
2581
+ readonly FOLLOWER_CREATED: "__FOLLOWER_CREATED";
2582
+ };
2583
+ static readonly Status: {
2584
+ readonly UNPREPARED: "UNPREPARED";
2585
+ readonly SYNCING: "SYNCING";
2586
+ readonly READY: "READY";
2587
+ readonly ERROR: "ERROR";
2588
+ };
2589
+ protected static isInternalConstructing: boolean;
2590
+ /**
2591
+ * The preparation construct is used to keep track of all store's preparation state the promise is
2592
+ * resolved when the store is prepared with the static __prepare() method which will also change
2593
+ * the state from PENDING to RESOLVED
2594
+ */
2595
+ private static preparation;
2596
+ private static setupPreparationPromise;
2597
+ /** Enable debug logs for this store */
2598
+ debugging: boolean;
2599
+ /** The actor object representing the store instance with a unique ID and a type */
2600
+ get actor(): Actor;
2601
+ /**
2602
+ * The current state of the store, that signals both if the store is prepared by Storybook and
2603
+ * also - in the case of a follower - if the state has been synced with the leader's state.
2604
+ */
2605
+ get status(): StatusType;
2606
+ /**
2607
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
2608
+ * has been prepared by Storybook, which is almost instantly.
2609
+ *
2610
+ * A follower will be ready when the state has been synced with the leader's state, within a few
2611
+ * hundred milliseconds.
2612
+ */
2613
+ untilReady(): Promise<[{
2614
+ channel: ChannelLike;
2615
+ environment: EnvironmentType;
2616
+ }, void | undefined]>;
2617
+ /**
2618
+ * The syncing construct is used to keep track of if the instance's state has been synced with the
2619
+ * other instances. A leader will immediately have the promise resolved. A follower will initially
2620
+ * be in a PENDING state, and resolve the the leader has sent the existing state, or reject if no
2621
+ * leader has responded before the timeout.
2622
+ */
2623
+ private syncing?;
2624
+ private channelEventName;
2625
+ private state;
2626
+ private channel?;
2627
+ private environment?;
2628
+ private listeners;
2629
+ private id;
2630
+ private actorId;
2631
+ private actorType;
2632
+ protected constructor(options: StoreOptions<State>, environmentOverrides?: EnvironmentOverrides);
2633
+ /** Creates a new instance of UniversalStore */
2634
+ static create<State = any, CustomEvent extends {
2635
+ type: string;
2636
+ payload?: any;
2637
+ } = {
2638
+ type: string;
2639
+ payload?: any;
2640
+ }>(options: StoreOptions<State>): UniversalStore<State, CustomEvent>;
2641
+ /** Gets the current state */
2642
+ getState: () => State;
2643
+ /**
2644
+ * Updates the store's state
2645
+ *
2646
+ * Either a new state or a state updater function can be passed to the method.
2647
+ */
2648
+ setState(updater: State | StateUpdater<State>): void;
2649
+ /**
2650
+ * Subscribes to store events
2651
+ *
2652
+ * @returns A function to unsubscribe
2653
+ */
2654
+ subscribe: {
2655
+ (listener: Listener<Event<State, CustomEvent>>): () => void;
2656
+ <EventType extends Event<State, CustomEvent>['type']>(eventType: EventType, listener: Listener<Extract<Event<State, CustomEvent>, {
2657
+ type: EventType;
2658
+ }>>): () => void;
2659
+ };
2660
+ /**
2661
+ * Subscribes to state changes
2662
+ *
2663
+ * @returns Unsubscribe function
2664
+ */
2665
+ onStateChange(listener: (state: State, previousState: State, eventInfo: EventInfo) => void): () => void;
2666
+ /** Sends a custom event to the other stores */
2667
+ send: (event: CustomEvent) => void;
2668
+ private emitToChannel;
2669
+ private prepareThis;
2670
+ private emitToListeners;
2671
+ private handleChannelEvents;
2672
+ private debug;
2673
+ }
2674
+
2675
+ type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
2676
+ type StatusTypeId = string;
2677
+ type StatusByTypeId = Record<StatusTypeId, Status>;
2678
+ type StatusesByStoryIdAndTypeId = Record<StoryId, StatusByTypeId>;
2679
+ interface Status {
2680
+ value: StatusValue;
2681
+ typeId: StatusTypeId;
2682
+ storyId: StoryId;
2683
+ title: string;
2684
+ description: string;
2685
+ data?: any;
2686
+ sidebarContextMenu?: boolean;
2687
+ }
2688
+ type StatusStore = {
2689
+ getAll: () => StatusesByStoryIdAndTypeId;
2690
+ set: (statuses: Status[]) => void;
2691
+ onAllStatusChange: (listener: (statuses: StatusesByStoryIdAndTypeId, previousStatuses: StatusesByStoryIdAndTypeId) => void) => () => void;
2692
+ onSelect: (listener: (selectedStatuses: Status[]) => void) => () => void;
2693
+ unset: (storyIds?: StoryId[]) => void;
2694
+ };
2695
+ type StatusStoreByTypeId = StatusStore & {
2696
+ typeId: StatusTypeId;
2697
+ };
2698
+ type UseStatusStore = <T = StatusesByStoryIdAndTypeId>(selector?: (statuses: StatusesByStoryIdAndTypeId) => T) => T;
2699
+
2700
+ type TestProviderState = 'test-provider-state:pending' | 'test-provider-state:running' | 'test-provider-state:succeeded' | 'test-provider-state:crashed';
2701
+ type TestProviderId = string;
2702
+ type TestProviderStateByProviderId = Record<TestProviderId, TestProviderState>;
2703
+ type BaseTestProviderStore = {
2704
+ /**
2705
+ * Notifies all listeners that settings have changed for test providers. The Storybook UI will
2706
+ * highlight the test providers to tell the user that settings has changed.
2707
+ */
2708
+ settingsChanged: () => void;
2709
+ /**
2710
+ * Subscribe to clicks on the "Run All" button, that is supposed to trigger all test providers to
2711
+ * run. Your test provider should do the "main thing" when this happens, similar to when the user
2712
+ * triggers your test provider specifically.
2713
+ *
2714
+ * @example
2715
+ *
2716
+ * ```typescript
2717
+ * // Subscribe to run-all events
2718
+ * const unsubscribe = myTestProviderStore.onRunAll(() => {
2719
+ * await runAllMyTests();
2720
+ * });
2721
+ * ```
2722
+ */
2723
+ onRunAll: (listener: () => void) => () => void;
2724
+ /**
2725
+ * Subscribe to clicks on the "Clear All" button, that is supposed to clear all state from test
2726
+ * providers. Storybook already clears all statuses, but if your test provider has more
2727
+ * non-status-based state, you can use this to clear that here.
2728
+ *
2729
+ * @remarks
2730
+ * The purpose of this is _not_ to clear your test provider's settings, only the test results.
2731
+ * @example
2732
+ *
2733
+ * ```typescript
2734
+ * // Subscribe to clear-all events
2735
+ * const unsubscribe = myTestProviderStore.onClearAll(() => {
2736
+ * clearMyTestResults();
2737
+ * });
2738
+ *
2739
+ * // Later, when no longer needed
2740
+ * unsubscribe();
2741
+ * ```
2742
+ */
2743
+ onClearAll: (listener: () => void) => () => void;
2744
+ };
2745
+ /**
2746
+ * Represents a store for a specific test provider, identified by its unique ID. This store provides
2747
+ * methods to manage the state of an individual test provider, including getting and setting its
2748
+ * state, running operations with automatic state management, and accessing its unique identifier.
2749
+ *
2750
+ * Each test provider has its own instance of this store, allowing for independent state management
2751
+ * across different test providers in the application.
2752
+ *
2753
+ * @example
2754
+ *
2755
+ * ```typescript
2756
+ * // Get a store for a specific test provider
2757
+ * const grammarStore = getTestProviderStoreById('addon-grammar');
2758
+ *
2759
+ * // Check the current state
2760
+ * if (grammarStore.getState() === 'test-provider-state:pending') {
2761
+ * console.log('Grammar tests are ready to run');
2762
+ * }
2763
+ *
2764
+ * // Run tests with automatic state management
2765
+ * grammarStore.runWithState(async () => {
2766
+ * await runGrammarTests();
2767
+ * });
2768
+ * ```
2769
+ *
2770
+ * @see {@link TestProviderState} for possible state values
2771
+ * @see {@link BaseTestProviderStore} for methods inherited from the base store
2772
+ */
2773
+ type TestProviderStoreById = BaseTestProviderStore & {
2774
+ /**
2775
+ * Gets the current state of this specific test provider
2776
+ *
2777
+ * The state represents the current execution status of the test provider, which can be one of the
2778
+ * following:
2779
+ *
2780
+ * - 'test-provider-state:pending': Tests have not been run yet
2781
+ * - 'test-provider-state:running': Tests are currently running
2782
+ * - 'test-provider-state:succeeded': Tests completed successfully
2783
+ * - 'test-provider-state:crashed': Running tests failed or encountered an error
2784
+ *
2785
+ * Storybook UI will use this state to determine what to show in the UI.
2786
+ *
2787
+ * @remarks
2788
+ * The 'test-provider-state:crashed' is meant to signify that the test run as a whole failed to
2789
+ * execute for some reason. It should _not_ be set just because a number of tests failed, use
2790
+ * statuses and the status store for that. See {@link TestStatusStore} for managing individual test
2791
+ * statuses.
2792
+ * @example
2793
+ *
2794
+ * ```typescript
2795
+ * // Get the current state of a specific test provider
2796
+ * const state = testProviderStore.getState();
2797
+ *
2798
+ * // Conditionally render UI based on the state
2799
+ * const TestStatus = () => {
2800
+ * const state = testProviderStore.getState();
2801
+ *
2802
+ * if (state === 'test-provider-state:running') {
2803
+ * return <Spinner />;
2804
+ * } else if (state === 'test-provider-state:succeeded') {
2805
+ * return <SuccessIcon />;
2806
+ * } else if (state === 'test-provider-state:crashed') {
2807
+ * return <ErrorIcon />;
2808
+ * }
2809
+ *
2810
+ * return <PendingIcon />;
2811
+ * };
2812
+ * ```
2813
+ */
2814
+ getState: () => TestProviderState;
2815
+ /**
2816
+ * Sets the state of this specific test provider
2817
+ *
2818
+ * This method allows you to manually update the execution state of the test provider. It's
2819
+ * typically used when you need to reflect the current status of test execution in the UI or when
2820
+ * you want to programmatically control the test provider's state.
2821
+ *
2822
+ * Common use cases include:
2823
+ *
2824
+ * - Setting to 'running' when tests start
2825
+ * - Setting to 'succeeded' when tests complete successfully
2826
+ * - Setting to 'crashed' when tests fail or encounter errors
2827
+ * - Setting to 'pending' to reset the state
2828
+ *
2829
+ * The state represents the current execution status of the test provider, which can be one of the
2830
+ * following:
2831
+ *
2832
+ * - 'test-provider-state:pending': Tests have not been run yet
2833
+ * - 'test-provider-state:running': Tests are currently running
2834
+ * - 'test-provider-state:succeeded': Tests completed successfully
2835
+ * - 'test-provider-state:crashed': Running tests failed or encountered an error
2836
+ *
2837
+ * Storybook UI will use this state to determine what to show in the UI.
2838
+ *
2839
+ * @remarks
2840
+ * The 'test-provider-state:crashed' is meant to signify that the test run as a whole failed to
2841
+ * execute for some reason. It should _not_ be set just because a number of tests failed, use
2842
+ * statuses and the status store for that. See {@link TestStatusStore} for managing individual test
2843
+ * statuses.
2844
+ *
2845
+ * For most use cases, consider using {@link runWithState} instead, which provides automatic state
2846
+ * management and error handling during test execution.
2847
+ * @example
2848
+ *
2849
+ * ```typescript
2850
+ * // Update the state when tests start running
2851
+ * const startTests = async () => {
2852
+ * testProviderStore.setState('test-provider-state:running');
2853
+ * ... run tests ...
2854
+ * };
2855
+ * ```
2856
+ */
2857
+ setState: (state: TestProviderState) => void;
2858
+ /**
2859
+ * Runs a callback and automatically updates the test provider's state with running, succeeded or
2860
+ * crashed, depending on the end result.
2861
+ *
2862
+ * - Immediately changes the state to 'running'
2863
+ * - If the callback returns/resolves, change the state to 'succeeded'.
2864
+ * - If the callback throws an error/rejects, change the state to 'crashed'.
2865
+ *
2866
+ * This approach helps prevent state inconsistencies that might occur if exceptions are thrown
2867
+ * during test execution.
2868
+ *
2869
+ * @example
2870
+ *
2871
+ * ```typescript
2872
+ * // Run tests with automatic state management
2873
+ * const runTests = () => {
2874
+ * testProviderStore.runWithState(async () => {
2875
+ * // The state is automatically set to 'running' before this callback
2876
+ *
2877
+ * // Run tests here...
2878
+ * const results = await executeTests();
2879
+ * });
2880
+ * };
2881
+ * ```
2882
+ */
2883
+ runWithState: (callback: () => void | Promise<void>) => Promise<void>;
2884
+ /** The unique identifier for this test provider */
2885
+ testProviderId: TestProviderId;
2886
+ };
2887
+ /**
2888
+ * React OR preview hook for accessing the state of _all_ test providers. This hook will only
2889
+ * trigger a re-render when the state changes. It is recommended to pass the optional selector, to
2890
+ * get more fine-grained control of re-renders.
2891
+ *
2892
+ * @example
2893
+ *
2894
+ * ```typescript
2895
+ * const TestStatus = () => {
2896
+ * const state = useTestProviderStore((state) => state['my-test-provider']);
2897
+ * };
2898
+ * ```
2899
+ */
2900
+ type UseTestProviderStore = <T = TestProviderStateByProviderId>(
2901
+ /**
2902
+ * Optional selector function to extract or transform specific parts of the state
2903
+ *
2904
+ * @example
2905
+ *
2906
+ * ```typescript
2907
+ * // Use the entire state
2908
+ * const allProviderStates = useTestProviderStore();
2909
+ *
2910
+ * // Get state for a specific provider
2911
+ * const myProviderState = useTestProviderStore((state) => state['my-test-provider']);
2912
+ *
2913
+ * // Get a count of providers in each state
2914
+ * const statusCounts = useTestProviderStore((state) => {
2915
+ * const counts = {
2916
+ * pending: 0,
2917
+ * running: 0,
2918
+ * succeeded: 0,
2919
+ * crashed: 0,
2920
+ * };
2921
+ *
2922
+ * Object.values(state).forEach((status) => {
2923
+ * if (status === 'test-provider-state:pending') counts.pending++;
2924
+ * else if (status === 'test-provider-state:running') counts.running++;
2925
+ * else if (status === 'test-provider-state:succeeded') counts.succeeded++;
2926
+ * else if (status === 'test-provider-state:crashed') counts.crashed++;
2927
+ * });
2928
+ *
2929
+ * return counts;
2930
+ * });
2931
+ *
2932
+ * // Check if all tests have completed
2933
+ * const allTestsCompleted = useTestProviderStore((state) => {
2934
+ * return Object.values(state).every(
2935
+ * (status) =>
2936
+ * status === 'test-provider-state:succeeded' ||
2937
+ * status === 'test-provider-state:crashed'
2938
+ * );
2939
+ * });
2940
+ * ```
2941
+ */
2942
+ selector?: (state: TestProviderStateByProviderId) => T) => T;
2943
+
2944
+ /**
2945
+ * A mock universal store that can be used when testing code that relies on a universal store. It
2946
+ * functions exactly like a normal universal store, with a few exceptions:
2947
+ *
2948
+ * - It is fully isolated, meaning that it doesn't interact with any channel, and it is always a
2949
+ * leader.
2950
+ *
2951
+ * If the second testUtils argument is provided, all the public methods are spied on, so they can be
2952
+ * asserted.
2953
+ *
2954
+ * When a mock store is re-used across tests (eg. in stories), you manually need to reset the state
2955
+ * after each test.
2956
+ *
2957
+ * @example
2958
+ *
2959
+ * ```ts
2960
+ * import * as testUtils from 'storybook/test'; // in stories
2961
+ * import { vi as testUtils } from 'vitest'; // ... or in Vitest tests
2962
+ *
2963
+ * const initialState = { ... };
2964
+ * const store = new MockUniversalStore({ initialState }, testUtils);
2965
+ *
2966
+ * export default {
2967
+ * title: 'My story',
2968
+ * beforeEach: () => {
2969
+ * return () => {
2970
+ * store.setState(initialState);
2971
+ * };
2972
+ * }
2973
+ * }
2974
+ * ```
2975
+ */
2976
+ declare class MockUniversalStore<State, CustomEvent extends {
2977
+ type: string;
2978
+ payload?: any;
2979
+ } = {
2980
+ type: string;
2981
+ payload?: any;
2982
+ }> extends UniversalStore<State, CustomEvent> {
2983
+ private testUtils;
2984
+ constructor(options: StoreOptions<State>, testUtils?: any);
2985
+ /** Create a mock universal store. This is just an alias for the constructor */
2986
+ static create<State = any, CustomEvent extends {
2987
+ type: string;
2988
+ payload?: any;
2989
+ } = {
2990
+ type: string;
2991
+ payload?: any;
2992
+ }>(options: StoreOptions<State>, testUtils?: any): MockUniversalStore<State, CustomEvent>;
2993
+ unsubscribeAll(): void;
2994
+ }
2995
+
2996
+ 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 Actor, 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_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_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 Event, type EventInfo, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, MockUniversalStore, 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 StoreOptions, 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 TestProviderStateByProviderId, type TestProviderStoreById, type TypescriptOptions, UniversalStore, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };