storybook 9.0.0-alpha.0 → 9.0.0-alpha.10

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 (259) hide show
  1. package/README.md +31 -29
  2. package/assets/browser/favicon.svg +1 -0
  3. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  4. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  5. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  6. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  7. package/assets/docs/addon-controls-args-annotated.png +0 -0
  8. package/assets/docs/addon-controls-args-background-color.png +0 -0
  9. package/assets/docs/addon-controls-args-background-string.png +0 -0
  10. package/assets/docs/addon-controls-args-docs.png +0 -0
  11. package/assets/docs/addon-controls-args-logging.png +0 -0
  12. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  13. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  14. package/assets/docs/addon-controls-args-reflow.png +0 -0
  15. package/assets/docs/addon-controls-args-template.png +0 -0
  16. package/assets/docs/addon-controls-expanded.png +0 -0
  17. package/assets/docs/addon-controls-hero.gif +0 -0
  18. package/assets/docs/addon-controls-install.png +0 -0
  19. package/assets/docs/hero.gif +0 -0
  20. package/assets/docs/message-reference.png +0 -0
  21. package/assets/docs/viewport.png +0 -0
  22. package/assets/server/addon.tsconfig.json +6 -0
  23. package/assets/server/base-preview-body.html +119 -0
  24. package/assets/server/base-preview-head.html +451 -0
  25. package/assets/server/template.ejs +87 -0
  26. package/bin/index.cjs +1 -1
  27. package/dist/actions/decorator.d.ts +6 -0
  28. package/dist/actions/decorator.js +139 -0
  29. package/dist/actions/index.cjs +127 -0
  30. package/dist/actions/index.d.ts +105 -0
  31. package/dist/actions/index.js +112 -0
  32. package/dist/actions/manager.js +1196 -0
  33. package/dist/actions/preview.cjs +165 -0
  34. package/dist/actions/preview.d.ts +55 -0
  35. package/dist/actions/preview.js +156 -0
  36. package/dist/babel/index.cjs +54034 -0
  37. package/dist/babel/index.d.ts +7488 -0
  38. package/dist/babel/index.js +54044 -0
  39. package/dist/bin/index.cjs +119 -0
  40. package/dist/bin/index.js +113 -0
  41. package/dist/builder-manager/index.cjs +2140 -0
  42. package/dist/builder-manager/index.d.ts +19 -0
  43. package/dist/builder-manager/index.js +2162 -0
  44. package/dist/channels/index.cjs +1913 -0
  45. package/dist/channels/index.d.ts +108 -0
  46. package/dist/channels/index.js +1881 -0
  47. package/dist/cli/bin/index.cjs +2687 -0
  48. package/dist/cli/bin/index.d.ts +2 -0
  49. package/dist/cli/bin/index.js +2707 -0
  50. package/dist/cli/index.cjs +17327 -0
  51. package/dist/cli/index.d.ts +209 -0
  52. package/dist/cli/index.js +17349 -0
  53. package/dist/client-logger/index.cjs +80 -0
  54. package/dist/client-logger/index.d.ts +29 -0
  55. package/dist/client-logger/index.js +64 -0
  56. package/dist/common/index.cjs +20569 -0
  57. package/dist/common/index.d.ts +949 -0
  58. package/dist/common/index.js +20654 -0
  59. package/dist/components/index.cjs +27924 -0
  60. package/dist/components/index.d.ts +1423 -0
  61. package/dist/components/index.js +24673 -0
  62. package/dist/controls/decorator.d.ts +5 -0
  63. package/dist/controls/decorator.js +8 -0
  64. package/dist/controls/index.cjs +26 -0
  65. package/dist/controls/index.d.ts +39 -0
  66. package/dist/controls/index.js +6 -0
  67. package/dist/controls/manager.js +5545 -0
  68. package/dist/controls/preview.cjs +26 -0
  69. package/dist/controls/preview.d.ts +55 -0
  70. package/dist/controls/preview.js +9 -0
  71. package/dist/core-events/index.cjs +167 -0
  72. package/dist/core-events/index.d.ts +426 -0
  73. package/dist/core-events/index.js +149 -0
  74. package/dist/core-server/index.cjs +38183 -0
  75. package/dist/core-server/index.d.ts +720 -0
  76. package/dist/core-server/index.js +38272 -0
  77. package/dist/core-server/presets/common-manager.js +20 -0
  78. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  79. package/dist/core-server/presets/common-override-preset.js +4829 -0
  80. package/dist/core-server/presets/common-preset.cjs +10231 -0
  81. package/dist/core-server/presets/common-preset.js +10309 -0
  82. package/dist/csf/index.cjs +179 -0
  83. package/dist/csf/index.d.ts +750 -0
  84. package/dist/csf/index.js +172 -0
  85. package/dist/csf-tools/index.cjs +1422 -0
  86. package/dist/csf-tools/index.d.ts +250 -0
  87. package/dist/csf-tools/index.js +1439 -0
  88. package/dist/docs-tools/index.cjs +2891 -0
  89. package/dist/docs-tools/index.d.ts +162 -0
  90. package/dist/docs-tools/index.js +2876 -0
  91. package/dist/index.cjs +17 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +2 -7
  94. package/dist/instrumenter/index.cjs +3485 -0
  95. package/dist/instrumenter/index.d.ts +104 -0
  96. package/dist/instrumenter/index.js +4965 -0
  97. package/dist/manager/globals-module-info.cjs +817 -0
  98. package/dist/manager/globals-module-info.d.ts +36 -0
  99. package/dist/manager/globals-module-info.js +804 -0
  100. package/dist/manager/globals-runtime.js +77536 -0
  101. package/dist/manager/globals.cjs +47 -0
  102. package/dist/manager/globals.d.ts +24 -0
  103. package/dist/manager/globals.js +34 -0
  104. package/dist/manager/runtime.js +12323 -0
  105. package/dist/manager-api/index.cjs +11074 -0
  106. package/dist/manager-api/index.d.ts +1512 -0
  107. package/dist/manager-api/index.js +4835 -0
  108. package/dist/manager-errors.d.ts +89 -0
  109. package/dist/manager-errors.js +99 -0
  110. package/dist/node-logger/index.cjs +1642 -0
  111. package/dist/node-logger/index.d.ts +117 -0
  112. package/dist/node-logger/index.js +1652 -0
  113. package/dist/preview/globals.cjs +38 -0
  114. package/dist/preview/globals.d.ts +15 -0
  115. package/dist/preview/globals.js +25 -0
  116. package/dist/preview/runtime.js +43629 -0
  117. package/dist/preview-api/index.cjs +5224 -0
  118. package/dist/preview-api/index.d.ts +1093 -0
  119. package/dist/preview-api/index.js +5292 -0
  120. package/dist/preview-errors.cjs +503 -0
  121. package/dist/preview-errors.d.ts +212 -0
  122. package/dist/preview-errors.js +449 -0
  123. package/dist/router/index.cjs +3296 -0
  124. package/dist/router/index.d.ts +385 -0
  125. package/dist/router/index.js +1843 -0
  126. package/dist/server-errors.cjs +727 -0
  127. package/dist/server-errors.d.ts +296 -0
  128. package/dist/server-errors.js +728 -0
  129. package/dist/telemetry/index.cjs +2756 -0
  130. package/dist/telemetry/index.d.ts +133 -0
  131. package/dist/telemetry/index.js +2797 -0
  132. package/dist/test/index.cjs +35685 -0
  133. package/dist/test/index.d.ts +186 -0
  134. package/dist/test/index.js +33751 -0
  135. package/dist/test/preview.cjs +15869 -0
  136. package/dist/test/preview.d.ts +54 -0
  137. package/dist/test/preview.js +14440 -0
  138. package/dist/test/spy.cjs +257 -0
  139. package/dist/test/spy.d.ts +66 -0
  140. package/dist/test/spy.js +239 -0
  141. package/dist/theming/create.cjs +232 -0
  142. package/dist/theming/create.d.ts +50 -0
  143. package/dist/theming/create.js +216 -0
  144. package/dist/theming/index.cjs +2665 -0
  145. package/dist/theming/index.d.ts +11939 -0
  146. package/dist/theming/index.js +2485 -0
  147. package/dist/types/index.cjs +27 -0
  148. package/dist/types/index.d.ts +2795 -0
  149. package/dist/types/index.js +7 -0
  150. package/dist/viewport/index.cjs +310 -0
  151. package/dist/viewport/index.d.ts +320 -0
  152. package/dist/viewport/index.js +290 -0
  153. package/dist/viewport/manager.js +400 -0
  154. package/dist/viewport/preview.cjs +35 -0
  155. package/dist/viewport/preview.d.ts +69 -0
  156. package/dist/viewport/preview.js +19 -0
  157. package/package.json +518 -209
  158. package/.eslintrc.cjs +0 -31
  159. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  160. package/core/babel/index.cjs +0 -1
  161. package/core/babel/index.d.ts +0 -2
  162. package/core/babel/index.js +0 -1
  163. package/core/builder-manager/index.cjs +0 -1
  164. package/core/builder-manager/index.d.ts +0 -2
  165. package/core/builder-manager/index.js +0 -1
  166. package/core/channels/index.cjs +0 -1
  167. package/core/channels/index.d.ts +0 -2
  168. package/core/channels/index.js +0 -1
  169. package/core/cli/bin/index.cjs +0 -1
  170. package/core/cli/bin/index.d.ts +0 -2
  171. package/core/cli/bin/index.js +0 -1
  172. package/core/cli/index.cjs +0 -1
  173. package/core/cli/index.d.ts +0 -2
  174. package/core/cli/index.js +0 -1
  175. package/core/client-logger/index.cjs +0 -1
  176. package/core/client-logger/index.d.ts +0 -2
  177. package/core/client-logger/index.js +0 -1
  178. package/core/common/index.cjs +0 -1
  179. package/core/common/index.d.ts +0 -2
  180. package/core/common/index.js +0 -1
  181. package/core/components/index.cjs +0 -1
  182. package/core/components/index.d.ts +0 -2
  183. package/core/components/index.js +0 -1
  184. package/core/core-events/index.cjs +0 -1
  185. package/core/core-events/index.d.ts +0 -2
  186. package/core/core-events/index.js +0 -1
  187. package/core/core-server/index.cjs +0 -1
  188. package/core/core-server/index.d.ts +0 -2
  189. package/core/core-server/index.js +0 -1
  190. package/core/core-server/presets/common-manager.js +0 -1
  191. package/core/core-server/presets/common-override-preset.cjs +0 -1
  192. package/core/core-server/presets/common-override-preset.js +0 -1
  193. package/core/core-server/presets/common-preset.cjs +0 -1
  194. package/core/core-server/presets/common-preset.js +0 -1
  195. package/core/csf/index.cjs +0 -1
  196. package/core/csf/index.d.ts +0 -2
  197. package/core/csf/index.js +0 -1
  198. package/core/csf-tools/index.cjs +0 -1
  199. package/core/csf-tools/index.d.ts +0 -2
  200. package/core/csf-tools/index.js +0 -1
  201. package/core/docs-tools/index.cjs +0 -1
  202. package/core/docs-tools/index.d.ts +0 -2
  203. package/core/docs-tools/index.js +0 -1
  204. package/core/index.cjs +0 -1
  205. package/core/index.d.ts +0 -2
  206. package/core/index.js +0 -1
  207. package/core/manager/globals-module-info.cjs +0 -1
  208. package/core/manager/globals-module-info.d.ts +0 -2
  209. package/core/manager/globals-module-info.js +0 -1
  210. package/core/manager/globals-runtime.js +0 -1
  211. package/core/manager/globals.cjs +0 -1
  212. package/core/manager/globals.d.ts +0 -2
  213. package/core/manager/globals.js +0 -1
  214. package/core/manager-api/index.cjs +0 -1
  215. package/core/manager-api/index.d.ts +0 -2
  216. package/core/manager-api/index.js +0 -1
  217. package/core/manager-errors.d.ts +0 -2
  218. package/core/manager-errors.js +0 -1
  219. package/core/node-logger/index.cjs +0 -1
  220. package/core/node-logger/index.d.ts +0 -2
  221. package/core/node-logger/index.js +0 -1
  222. package/core/preview/globals.cjs +0 -1
  223. package/core/preview/globals.d.ts +0 -2
  224. package/core/preview/globals.js +0 -1
  225. package/core/preview/runtime.js +0 -1
  226. package/core/preview-api/index.cjs +0 -1
  227. package/core/preview-api/index.d.ts +0 -2
  228. package/core/preview-api/index.js +0 -1
  229. package/core/preview-errors.cjs +0 -1
  230. package/core/preview-errors.d.ts +0 -2
  231. package/core/preview-errors.js +0 -1
  232. package/core/router/index.cjs +0 -1
  233. package/core/router/index.d.ts +0 -2
  234. package/core/router/index.js +0 -1
  235. package/core/server-errors.cjs +0 -1
  236. package/core/server-errors.d.ts +0 -2
  237. package/core/server-errors.js +0 -1
  238. package/core/telemetry/index.cjs +0 -1
  239. package/core/telemetry/index.d.ts +0 -2
  240. package/core/telemetry/index.js +0 -1
  241. package/core/theming/create.cjs +0 -1
  242. package/core/theming/create.d.ts +0 -2
  243. package/core/theming/create.js +0 -1
  244. package/core/theming/index.cjs +0 -1
  245. package/core/theming/index.d.ts +0 -2
  246. package/core/theming/index.js +0 -1
  247. package/core/types/index.cjs +0 -1
  248. package/core/types/index.d.ts +0 -2
  249. package/core/types/index.js +0 -1
  250. package/core.cjs +0 -0
  251. package/core.d.ts +0 -0
  252. package/core.js +0 -1
  253. package/dist/chunk-OWLSIX54.js +0 -8
  254. package/dist/core-path.cjs +0 -1
  255. package/dist/core-path.d.ts +0 -3
  256. package/dist/core-path.js +0 -9
  257. package/dist/proxy.cjs +0 -1
  258. package/dist/proxy.d.ts +0 -2
  259. package/dist/proxy.js +0 -9
@@ -0,0 +1,1512 @@
1
+ import React, { FC, ReactNode, ReactElement, Component } from 'react';
2
+ import { Channel, Listener as Listener$1 } from 'storybook/internal/channels';
3
+ export { Listener as ChannelListener } from 'storybook/internal/channels';
4
+ import { RouterData, NavigateOptions } from 'storybook/internal/router';
5
+ import { Addon_Types, Addon_TypesEnum, Addon_Collection, Addon_TypesMapping, Addon_BaseType, Addon_SidebarTopType, Addon_SidebarBottomType, Addon_TestProviderType, Addon_PageType, Addon_WrapperType, Addon_Config, API_ProviderData, API_StateMerger, API_Provider, StoryId, Globals, GlobalTypes, API_PanelPositions, API_Layout, API_UI, API_Notification, API_IframeRenderer, API_ComposedRef, API_SetRefData, API_ComposedRefUpdate, API_Refs, API_Settings, API_HashEntry, API_ViewMode, API_LeafEntry, API_PreparedStoryIndex, API_StoryEntry, Args, API_IndexHash, API_DocsEntry, API_FilterFunction, API_LoadedRefData, API_Version, API_Versions, API_UnknownEntries, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn, API_OptionsData, Parameters, ArgTypes } from 'storybook/internal/types';
6
+ export { Addon_Type as Addon, API_ComponentEntry as ComponentEntry, API_ComposedRef as ComposedRef, API_DocsEntry as DocsEntry, API_GroupEntry as GroupEntry, API_HashEntry as HashEntry, API_IndexHash as IndexHash, API_LeafEntry as LeafEntry, API_Refs as Refs, API_RootEntry as RootEntry, API_IndexHash as StoriesHash, API_StoryEntry as StoryEntry } from 'storybook/internal/types';
7
+ import { TestProviderState as TestProviderState$1, TestProviderId as TestProviderId$1, TestProviders, WhatsNewData } from 'storybook/internal/core-events';
8
+ import { ThemeVars } from 'storybook/theming';
9
+ import { toId, StoryId as StoryId$1 } from 'storybook/internal/csf';
10
+
11
+ declare function mockChannel(): Channel;
12
+
13
+ declare class AddonStore {
14
+ constructor();
15
+ private loaders;
16
+ private elements;
17
+ private config;
18
+ private channel;
19
+ private promise;
20
+ private resolve;
21
+ getChannel: () => Channel;
22
+ ready: () => Promise<Channel>;
23
+ hasChannel: () => boolean;
24
+ setChannel: (channel: Channel) => void;
25
+ getElements<T extends Addon_Types | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP | Addon_TypesEnum.experimental_TEST_PROVIDER>(type: T): Addon_Collection<Addon_TypesMapping[T]> | any;
26
+ /**
27
+ * Adds an addon to the addon store.
28
+ *
29
+ * @param {string} id - The id of the addon.
30
+ * @param {Addon_Type} addon - The addon to add.
31
+ * @returns {void}
32
+ */
33
+ add(id: string, addon: Addon_BaseType | Omit<Addon_SidebarTopType, 'id'> | Omit<Addon_SidebarBottomType, 'id'> | Omit<Addon_TestProviderType, 'id'> | Omit<Addon_PageType, 'id'> | Omit<Addon_WrapperType, 'id'>): void;
34
+ setConfig: (value: Addon_Config) => void;
35
+ getConfig: () => Addon_Config;
36
+ /**
37
+ * Registers an addon loader function.
38
+ *
39
+ * @param {string} id - The id of the addon loader.
40
+ * @param {(api: API) => void} callback - The function that will be called to register the addon.
41
+ * @returns {void}
42
+ */
43
+ register: (id: string, callback: (api: API) => void) => void;
44
+ loadAddons: (api: any) => void;
45
+ experimental_getRegisteredAddons(): string[];
46
+ }
47
+ declare const addons: AddonStore;
48
+
49
+ type GetState = () => State;
50
+ type SetState = (a: any, b: any) => any;
51
+ interface Upstream {
52
+ getState: GetState;
53
+ setState: SetState;
54
+ }
55
+ type Patch = Partial<State>;
56
+ type InputFnPatch = (s: State) => Patch;
57
+ type InputPatch = Patch | InputFnPatch;
58
+ interface Options {
59
+ persistence: 'none' | 'session' | string;
60
+ }
61
+ type CallBack = (s: State) => void;
62
+ declare class Store {
63
+ upstreamGetState: GetState;
64
+ upstreamSetState: SetState;
65
+ constructor({ setState, getState }: Upstream);
66
+ getInitialState(base: State): any;
67
+ getState(): State;
68
+ setState(inputPatch: InputPatch, options?: Options): Promise<State>;
69
+ setState(inputPatch: InputPatch, callback?: CallBack, options?: Options): Promise<State>;
70
+ }
71
+
72
+ type ModuleFn<APIType = unknown, StateType = unknown> = (m: ModuleArgs, options?: any) => {
73
+ init?: () => void | Promise<void>;
74
+ api: APIType;
75
+ state: StateType;
76
+ };
77
+ type ModuleArgs = RouterData & API_ProviderData<API> & {
78
+ mode?: 'production' | 'development';
79
+ state: State;
80
+ fullAPI: API;
81
+ store: Store;
82
+ };
83
+
84
+ interface SubAPI$d {
85
+ /**
86
+ * Returns a collection of elements of a specific type.
87
+ *
88
+ * @template T - The type of the elements in the collection.
89
+ * @param {Addon_Types | Addon_TypesEnum.experimental_PAGE} type - The type of the elements to
90
+ * retrieve.
91
+ * @returns {Addon_Collection<T>} - A collection of elements of the specified type.
92
+ * @protected This is used internally in storybook's manager.
93
+ */
94
+ getElements: <T extends Addon_Types | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_TEST_PROVIDER | Addon_TypesEnum.experimental_SIDEBAR_TOP = Addon_Types>(type: T) => Addon_Collection<Addon_TypesMapping[T]>;
95
+ /**
96
+ * Returns the id of the currently selected panel.
97
+ *
98
+ * @returns {string} - The ID of the currently selected panel.
99
+ */
100
+ getSelectedPanel: () => string;
101
+ /**
102
+ * Sets the currently selected panel via it's ID.
103
+ *
104
+ * @param {string} panelName - The ID of the panel to select.
105
+ * @returns {void}
106
+ */
107
+ setSelectedPanel: (panelName: string) => void;
108
+ /**
109
+ * Sets the state of an addon with the given ID.
110
+ *
111
+ * @deprecated This API might get dropped, if you are using this, please file an issue.
112
+ * @template S - The type of the addon state.
113
+ * @param {string} addonId - The ID of the addon to set the state for.
114
+ * @param {S | API_StateMerger<S>} newStateOrMerger - The new state to set, or a function which
115
+ * receives the current state and returns the new state.
116
+ * @param {Options} [options] - Optional options for the state update.
117
+ * @returns {Promise<S>} - A promise that resolves with the new state after it has been set.
118
+ */
119
+ setAddonState<S>(addonId: string, newStateOrMerger: S | API_StateMerger<S>, options?: Options): Promise<S>;
120
+ /**
121
+ * Returns the state of an addon with the given ID.
122
+ *
123
+ * @deprecated This API might get dropped, if you are using this, please file an issue.
124
+ * @template S - The type of the addon state.
125
+ * @param {string} addonId - The ID of the addon to get the state for.
126
+ * @returns {S} - The state of the addon with the given ID.
127
+ */
128
+ getAddonState<S>(addonId: string): S;
129
+ }
130
+
131
+ interface SubAPI$c {
132
+ /**
133
+ * Returns the channel object.
134
+ *
135
+ * @protected Please do not use, it's for internal use only.
136
+ */
137
+ getChannel: () => API_Provider<API>['channel'];
138
+ /**
139
+ * Adds a listener to the channel for the given event type. Returns a function that can be called
140
+ * to remove the listener.
141
+ *
142
+ * @param type - The event type to listen for. If using a core event, import it from
143
+ * `storybook/internal/core-events`.
144
+ * @param handler - The callback function to be called when the event is emitted.
145
+ * @returns A function that can be called to remove the listener.
146
+ */
147
+ on: (type: string, handler: Listener$1) => () => void;
148
+ /**
149
+ * Removes a listener from the channel for the given event type.
150
+ *
151
+ * @param type - The event type to remove the listener from. If using a core event, import it from
152
+ * `storybook/internal/core-events`.
153
+ * @param handler - The callback function to be removed.
154
+ */
155
+ off: (type: string, handler: Listener$1) => void;
156
+ /**
157
+ * Emits an event on the channel for the given event type.
158
+ *
159
+ * @param type - The event type to emit. If using a core event, import it from
160
+ * `storybook/internal/core-events`.
161
+ * @param args - The arguments to pass to the event listener.
162
+ */
163
+ emit: (type: string, ...args: any[]) => void;
164
+ /**
165
+ * Adds a one-time listener to the channel for the given event type.
166
+ *
167
+ * @param type - The event type to listen for. If using a core event, import it from
168
+ * `storybook/internal/core-events`.
169
+ * @param handler - The callback function to be called when the event is emitted.
170
+ */
171
+ once: (type: string, handler: Listener$1) => void;
172
+ }
173
+
174
+ type SubState$a = {
175
+ testProviders: TestProviders;
176
+ };
177
+ interface RunOptions {
178
+ entryId?: StoryId;
179
+ }
180
+ type SubAPI$b = {
181
+ getTestProviderState(id: string): TestProviderState$1 | undefined;
182
+ updateTestProviderState(id: TestProviderId$1, update: Partial<TestProviderState$1>): void;
183
+ clearTestProviderState(id: TestProviderId$1): void;
184
+ runTestProvider(id: TestProviderId$1, options?: RunOptions): () => void;
185
+ cancelTestProvider(id: TestProviderId$1): void;
186
+ };
187
+
188
+ interface SubState$9 {
189
+ globals?: Globals;
190
+ userGlobals?: Globals;
191
+ storyGlobals?: Globals;
192
+ globalTypes?: GlobalTypes;
193
+ }
194
+ interface SubAPI$a {
195
+ /**
196
+ * Returns the current globals, which is the user globals overlaid with the story globals
197
+ *
198
+ * @returns {Globals} The current globals.
199
+ */
200
+ getGlobals: () => Globals;
201
+ /**
202
+ * Returns the current globals, as set by the user (a story may have override values)
203
+ *
204
+ * @returns {Globals} The current user globals.
205
+ */
206
+ getUserGlobals: () => Globals /**
207
+ * /** Returns the current globals, as set by the story
208
+ *
209
+ * @returns {Globals} The current story globals.
210
+ */;
211
+ getStoryGlobals: () => Globals /**
212
+ * Returns the globalTypes, as defined at the project level.
213
+ *
214
+ * @returns {GlobalTypes} The globalTypes.
215
+ */;
216
+ getGlobalTypes: () => GlobalTypes;
217
+ /**
218
+ * Updates the current globals with the provided new globals.
219
+ *
220
+ * @param {Globals} newGlobals - The new globals to update with.
221
+ * @returns {void}
222
+ */
223
+ updateGlobals: (newGlobals: Globals) => void;
224
+ }
225
+
226
+ interface SubState$8 {
227
+ layout: API_Layout;
228
+ ui: API_UI;
229
+ selectedPanel: string | undefined;
230
+ theme: ThemeVars;
231
+ }
232
+ interface SubAPI$9 {
233
+ /**
234
+ * Toggles the fullscreen mode of the Storybook UI.
235
+ *
236
+ * @param toggled - Optional boolean value to set the fullscreen mode to. If not provided, it will
237
+ * toggle the current state.
238
+ */
239
+ toggleFullscreen: (toggled?: boolean) => void;
240
+ /**
241
+ * Toggles the visibility of the panel in the Storybook UI.
242
+ *
243
+ * @param toggled - Optional boolean value to set the panel visibility to. If not provided, it
244
+ * will toggle the current state.
245
+ */
246
+ togglePanel: (toggled?: boolean) => void;
247
+ /**
248
+ * Toggles the position of the panel in the Storybook UI.
249
+ *
250
+ * @param position - Optional string value to set the panel position to. If not provided, it will
251
+ * toggle between 'bottom' and 'right'.
252
+ */
253
+ togglePanelPosition: (position?: API_PanelPositions) => void;
254
+ /**
255
+ * Toggles the visibility of the navigation bar in the Storybook UI.
256
+ *
257
+ * @param toggled - Optional boolean value to set the navigation bar visibility to. If not
258
+ * provided, it will toggle the current state.
259
+ */
260
+ toggleNav: (toggled?: boolean) => void;
261
+ /**
262
+ * Toggles the visibility of the toolbar in the Storybook UI.
263
+ *
264
+ * @param toggled - Optional boolean value to set the toolbar visibility to. If not provided, it
265
+ * will toggle the current state.
266
+ */
267
+ toggleToolbar: (toggled?: boolean) => void;
268
+ /**
269
+ * Sets the options for the Storybook UI.
270
+ *
271
+ * @param options - An object containing the options to set.
272
+ */
273
+ setOptions: (options: any) => void;
274
+ /** Sets the sizes of the resizable elements in the layout. */
275
+ setSizes: (options: Partial<Pick<API_Layout, 'navSize' | 'bottomPanelHeight' | 'rightPanelWidth'>>) => void;
276
+ /** GetIsFullscreen - Returns the current fullscreen mode of the Storybook UI. */
277
+ getIsFullscreen: () => boolean;
278
+ /** GetIsPanelShown - Returns the current visibility of the panel in the Storybook UI. */
279
+ getIsPanelShown: () => boolean;
280
+ /** GetIsNavShown - Returns the current visibility of the navigation bar in the Storybook UI. */
281
+ getIsNavShown: () => boolean;
282
+ }
283
+
284
+ interface SubState$7 {
285
+ notifications: API_Notification[];
286
+ }
287
+ /** The API for managing notifications. */
288
+ interface SubAPI$8 {
289
+ /**
290
+ * Adds a new notification to the list of notifications. If a notification with the same ID
291
+ * already exists, it will be replaced.
292
+ *
293
+ * @param notification - The notification to add.
294
+ */
295
+ addNotification: (notification: API_Notification) => void;
296
+ /**
297
+ * Removes a notification from the list of notifications and calls the onClear callback.
298
+ *
299
+ * @param id - The ID of the notification to remove.
300
+ */
301
+ clearNotification: (id: string) => void;
302
+ }
303
+
304
+ interface SubAPI$7 {
305
+ renderPreview?: API_IframeRenderer;
306
+ }
307
+
308
+ interface SubState$6 {
309
+ refs: API_Refs;
310
+ }
311
+ interface SubAPI$6 {
312
+ /**
313
+ * Finds a composed ref by its source.
314
+ *
315
+ * @param {string} source - The source/URL of the composed ref.
316
+ * @returns {API_ComposedRef} - The composed ref object.
317
+ */
318
+ findRef: (source: string) => API_ComposedRef;
319
+ /**
320
+ * Sets a composed ref by its ID and data.
321
+ *
322
+ * @param {string} id - The ID of the composed ref.
323
+ * @param {API_SetRefData} data - The data to set for the composed ref.
324
+ * @param {boolean} [ready] - Whether the composed ref is ready.
325
+ */
326
+ setRef: (id: string, data: API_SetRefData, ready?: boolean) => void;
327
+ /**
328
+ * Updates a composed ref by its ID and update object.
329
+ *
330
+ * @param {string} id - The ID of the composed ref.
331
+ * @param {API_ComposedRefUpdate} ref - The update object for the composed ref.
332
+ */
333
+ updateRef: (id: string, ref: API_ComposedRefUpdate) => Promise<void>;
334
+ /**
335
+ * Gets all composed refs.
336
+ *
337
+ * @returns {API_Refs} - The composed refs object.
338
+ */
339
+ getRefs: () => API_Refs;
340
+ /**
341
+ * Checks if a composed ref is valid.
342
+ *
343
+ * @param {API_SetRefData} ref - The composed ref to check.
344
+ * @returns {Promise<void>} - A promise that resolves when the check is complete.
345
+ */
346
+ checkRef: (ref: API_SetRefData) => Promise<void>;
347
+ /**
348
+ * Changes the version of a composed ref by its ID and URL.
349
+ *
350
+ * @param {string} id - The ID of the composed ref.
351
+ * @param {string} url - The new URL for the composed ref.
352
+ */
353
+ changeRefVersion: (id: string, url: string) => Promise<void>;
354
+ /**
355
+ * Changes the state of a composed ref by its ID and previewInitialized flag.
356
+ *
357
+ * @param {string} id - The ID of the composed ref.
358
+ * @param {boolean} previewInitialized - The new previewInitialized flag for the composed ref.
359
+ */
360
+ changeRefState: (id: string, previewInitialized: boolean) => void;
361
+ }
362
+
363
+ interface SubAPI$5 {
364
+ storeSelection: () => void;
365
+ retrieveSelection: () => StoryId;
366
+ /**
367
+ * Changes the active settings tab.
368
+ *
369
+ * @example
370
+ *
371
+ * ```ts
372
+ * changeSettingsTab(`about`);
373
+ * ```
374
+ *
375
+ * @param path - The path of the settings page to navigate to. The path NOT should include the
376
+ * `/settings` prefix.
377
+ */
378
+ changeSettingsTab: (path: string) => void;
379
+ /** Closes the settings screen and returns to the last tracked story or the first story. */
380
+ closeSettings: () => void;
381
+ /**
382
+ * Checks if the settings screen is currently active.
383
+ *
384
+ * @returns A boolean indicating whether the settings screen is active.
385
+ */
386
+ isSettingsScreenActive: () => boolean;
387
+ }
388
+ interface SubState$5 {
389
+ settings: API_Settings;
390
+ }
391
+
392
+ declare const isMacLike: () => boolean;
393
+ declare const controlOrMetaSymbol: () => "⌘" | "ctrl";
394
+ declare const controlOrMetaKey: () => "meta" | "control";
395
+ declare const optionOrAltSymbol: () => "⌥" | "alt";
396
+ declare const isShortcutTaken: (arr1: string[], arr2: string[]) => boolean;
397
+ type KeyboardEventLike = Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey' | 'key' | 'code' | 'keyCode' | 'preventDefault'>;
398
+ declare const eventToShortcut: (e: KeyboardEventLike) => (string | string[])[] | null;
399
+ declare const shortcutMatchesShortcut: (inputShortcut: (string | string[])[], shortcut: API_KeyCollection) => boolean;
400
+ declare const eventMatchesShortcut: (e: KeyboardEventLike, shortcut: API_KeyCollection) => boolean;
401
+ declare const keyToSymbol: (key: string) => string;
402
+ declare const shortcutToHumanString: (shortcut: API_KeyCollection) => string;
403
+
404
+ interface SubState$4 {
405
+ shortcuts: API_Shortcuts;
406
+ }
407
+ interface SubAPI$4 {
408
+ /** Returns the current shortcuts. */
409
+ getShortcutKeys(): API_Shortcuts;
410
+ /** Returns the default shortcuts. */
411
+ getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults;
412
+ /** Returns the shortcuts for addons. */
413
+ getAddonsShortcuts(): API_AddonShortcuts;
414
+ /** Returns the labels for addon shortcuts. */
415
+ getAddonsShortcutLabels(): API_AddonShortcutLabels;
416
+ /** Returns the default shortcuts for addons. */
417
+ getAddonsShortcutDefaults(): API_AddonShortcutDefaults;
418
+ /**
419
+ * Sets the shortcuts to the given value.
420
+ *
421
+ * @param shortcuts The new shortcuts to set.
422
+ * @returns A promise that resolves to the new shortcuts.
423
+ */
424
+ setShortcuts(shortcuts: API_Shortcuts): Promise<API_Shortcuts>;
425
+ /**
426
+ * Sets the shortcut for the given action to the given value.
427
+ *
428
+ * @param action The action to set the shortcut for.
429
+ * @param value The new shortcut to set.
430
+ * @returns A promise that resolves to the new shortcut.
431
+ */
432
+ setShortcut(action: API_Action, value: API_KeyCollection): Promise<API_KeyCollection>;
433
+ /**
434
+ * Sets the shortcut for the given addon to the given value.
435
+ *
436
+ * @param addon The addon to set the shortcut for.
437
+ * @param shortcut The new shortcut to set.
438
+ * @returns A promise that resolves to the new addon shortcut.
439
+ */
440
+ setAddonShortcut(addon: string, shortcut: API_AddonShortcut): Promise<API_AddonShortcut>;
441
+ /**
442
+ * Restores all default shortcuts.
443
+ *
444
+ * @returns A promise that resolves to the new shortcuts.
445
+ */
446
+ restoreAllDefaultShortcuts(): Promise<API_Shortcuts>;
447
+ /**
448
+ * Restores the default shortcut for the given action.
449
+ *
450
+ * @param action The action to restore the default shortcut for.
451
+ * @returns A promise that resolves to the new shortcut.
452
+ */
453
+ restoreDefaultShortcut(action: API_Action): Promise<API_KeyCollection>;
454
+ /**
455
+ * Handles a keydown event.
456
+ *
457
+ * @param event The event to handle.
458
+ */
459
+ handleKeydownEvent(event: KeyboardEventLike): void;
460
+ /**
461
+ * Handles a shortcut feature.
462
+ *
463
+ * @param feature The feature to handle.
464
+ * @param event The event to handle.
465
+ */
466
+ handleShortcutFeature(feature: API_Action, event: KeyboardEventLike): void;
467
+ }
468
+ type API_KeyCollection = string[];
469
+ interface API_Shortcuts {
470
+ fullScreen: API_KeyCollection;
471
+ togglePanel: API_KeyCollection;
472
+ panelPosition: API_KeyCollection;
473
+ toggleNav: API_KeyCollection;
474
+ toolbar: API_KeyCollection;
475
+ search: API_KeyCollection;
476
+ focusNav: API_KeyCollection;
477
+ focusIframe: API_KeyCollection;
478
+ focusPanel: API_KeyCollection;
479
+ prevComponent: API_KeyCollection;
480
+ nextComponent: API_KeyCollection;
481
+ prevStory: API_KeyCollection;
482
+ nextStory: API_KeyCollection;
483
+ shortcutsPage: API_KeyCollection;
484
+ aboutPage: API_KeyCollection;
485
+ escape: API_KeyCollection;
486
+ collapseAll: API_KeyCollection;
487
+ expandAll: API_KeyCollection;
488
+ remount: API_KeyCollection;
489
+ }
490
+ type API_Action = keyof API_Shortcuts;
491
+ interface API_AddonShortcut {
492
+ label: string;
493
+ defaultShortcut: API_KeyCollection;
494
+ actionName: string;
495
+ showInMenu?: boolean;
496
+ action: (...args: any[]) => any;
497
+ }
498
+ type API_AddonShortcuts = Record<string, API_AddonShortcut>;
499
+ type API_AddonShortcutLabels = Record<string, string>;
500
+ type API_AddonShortcutDefaults = Record<string, API_KeyCollection>;
501
+
502
+ type Direction = -1 | 1;
503
+ type ParameterName = string;
504
+ type StoryUpdate = Partial<Pick<API_StoryEntry, 'prepared' | 'parameters' | 'initialArgs' | 'argTypes' | 'args'>>;
505
+ type DocsUpdate = Partial<Pick<API_DocsEntry, 'prepared' | 'parameters'>>;
506
+ interface SubState$3 extends API_LoadedRefData {
507
+ storyId: StoryId;
508
+ internal_index?: API_PreparedStoryIndex;
509
+ viewMode: API_ViewMode;
510
+ filters: Record<string, API_FilterFunction>;
511
+ }
512
+ interface SubAPI$3 {
513
+ /**
514
+ * The `storyId` method is a reference to the `toId` function from `@storybook/csf`, which is used
515
+ * to generate a unique ID for a story. This ID is used to identify a specific story in the
516
+ * Storybook index.
517
+ *
518
+ * @type {typeof toId}
519
+ */
520
+ storyId: typeof toId;
521
+ /**
522
+ * Resolves a story, docs, component or group ID to its corresponding hash entry in the index.
523
+ *
524
+ * @param {StoryId} storyId - The ID of the story to resolve.
525
+ * @param {string} [refsId] - The ID of the refs to use for resolving the story.
526
+ * @returns {API_HashEntry} - The hash entry corresponding to the given story ID.
527
+ */
528
+ resolveStory: (storyId: StoryId, refsId?: string) => API_HashEntry | undefined;
529
+ /**
530
+ * Selects the first story to display in the Storybook UI.
531
+ *
532
+ * @returns {void}
533
+ */
534
+ selectFirstStory: () => void;
535
+ /**
536
+ * Selects a story to display in the Storybook UI.
537
+ *
538
+ * @param {string} [kindOrId] - The kind or ID of the story to select.
539
+ * @param {StoryId} [story] - The ID of the story to select.
540
+ * @param {Object} [obj] - An optional object containing additional options.
541
+ * @param {string} [obj.ref] - The ref ID of the story to select.
542
+ * @param {API_ViewMode} [obj.viewMode] - The view mode to display the story in.
543
+ * @returns {void}
544
+ */
545
+ selectStory: (kindOrId?: string, story?: StoryId, obj?: {
546
+ ref?: string;
547
+ viewMode?: API_ViewMode;
548
+ }) => void;
549
+ /**
550
+ * Returns the current story's data, including its ID, kind, name, and parameters.
551
+ *
552
+ * @returns {API_LeafEntry} The current story's data.
553
+ */
554
+ getCurrentStoryData: () => API_LeafEntry;
555
+ /**
556
+ * Sets the prepared story index to the given value.
557
+ *
558
+ * @param {API_PreparedStoryIndex} index - The prepared story index to set.
559
+ * @returns {Promise<void>} A promise that resolves when the prepared story index has been set.
560
+ */
561
+ setIndex: (index: API_PreparedStoryIndex) => Promise<void>;
562
+ /**
563
+ * Jumps to the next or previous component in the index.
564
+ *
565
+ * @param {Direction} direction - The direction to jump. Use -1 to jump to the previous component,
566
+ * and 1 to jump to the next component.
567
+ * @returns {void}
568
+ */
569
+ jumpToComponent: (direction: Direction) => void;
570
+ /**
571
+ * Jumps to the next or previous story in the story index.
572
+ *
573
+ * @param {Direction} direction - The direction to jump. Use -1 to jump to the previous story, and
574
+ * 1 to jump to the next story.
575
+ * @returns {void}
576
+ */
577
+ jumpToStory: (direction: Direction) => void;
578
+ /**
579
+ * Returns the data for the given story ID and optional ref ID.
580
+ *
581
+ * @param {StoryId} storyId - The ID of the story to retrieve data for.
582
+ * @param {string} [refId] - The ID of the ref to retrieve data for. If not provided, retrieves
583
+ * data for the default ref.
584
+ * @returns {API_LeafEntry} The data for the given story ID and optional ref ID.
585
+ */
586
+ getData: (storyId: StoryId, refId?: string) => API_LeafEntry;
587
+ /**
588
+ * Returns a boolean indicating whether the given story ID and optional ref ID have been prepared.
589
+ *
590
+ * @param {StoryId} storyId - The ID of the story to check.
591
+ * @param {string} [refId] - The ID of the ref to check. If not provided, checks all refs for the
592
+ * given story ID.
593
+ * @returns {boolean} A boolean indicating whether the given story ID and optional ref ID have
594
+ * been prepared.
595
+ */
596
+ isPrepared: (storyId: StoryId, refId?: string) => boolean;
597
+ /**
598
+ * Returns the parameters for the given story ID and optional ref ID.
599
+ *
600
+ * @param {StoryId | { storyId: StoryId; refId: string }} storyId - The ID of the story to
601
+ * retrieve parameters for, or an object containing the story ID and ref ID.
602
+ * @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not
603
+ * provided, returns all parameters.
604
+ * @returns {API_StoryEntry['parameters'] | any} The parameters for the given story ID and
605
+ * optional ref ID.
606
+ */
607
+ getParameters: (storyId: StoryId | {
608
+ storyId: StoryId;
609
+ refId: string;
610
+ }, parameterName?: ParameterName) => API_StoryEntry['parameters'] | any;
611
+ /**
612
+ * Returns the current value of the specified parameter for the currently selected story.
613
+ *
614
+ * @template S - The type of the parameter value.
615
+ * @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not
616
+ * provided, returns all parameters.
617
+ * @returns {S} The value of the specified parameter for the currently selected story.
618
+ */
619
+ getCurrentParameter<S>(parameterName?: ParameterName): S;
620
+ /**
621
+ * Updates the arguments for the given story with the provided new arguments.
622
+ *
623
+ * @param {API_StoryEntry} story - The story to update the arguments for.
624
+ * @param {Args} newArgs - The new arguments to set for the story.
625
+ * @returns {void}
626
+ */
627
+ updateStoryArgs(story: API_StoryEntry, newArgs: Args): void;
628
+ /**
629
+ * Resets the arguments for the given story to their initial values.
630
+ *
631
+ * @param {API_StoryEntry} story - The story to reset the arguments for.
632
+ * @param {string[]} [argNames] - An optional array of argument names to reset. If not provided,
633
+ * all arguments will be reset.
634
+ * @returns {void}
635
+ */
636
+ resetStoryArgs: (story: API_StoryEntry, argNames?: string[]) => void;
637
+ /**
638
+ * Finds the leaf entry for the given story ID in the given story index.
639
+ *
640
+ * @param {API_IndexHash} index - The story index to search for the leaf entry in.
641
+ * @param {StoryId} storyId - The ID of the story to find the leaf entry for.
642
+ * @returns {API_LeafEntry} The leaf entry for the given story ID, or null if no leaf entry was
643
+ * found.
644
+ */
645
+ findLeafEntry(index: API_IndexHash, storyId: StoryId): API_LeafEntry;
646
+ /**
647
+ * Finds the leaf story ID for the given component or group ID in the given index.
648
+ *
649
+ * @param {API_IndexHash} index - The story index to search for the leaf story ID in.
650
+ * @param {StoryId} storyId - The ID of the story to find the leaf story ID for.
651
+ * @returns {StoryId} The ID of the leaf story, or null if no leaf story was found.
652
+ */
653
+ findLeafStoryId(index: API_IndexHash, storyId: StoryId): StoryId;
654
+ /**
655
+ * Finds the ID of the sibling story in the given direction for the given story ID in the given
656
+ * story index.
657
+ *
658
+ * @param {StoryId} storyId - The ID of the story to find the sibling of.
659
+ * @param {API_IndexHash} index - The story index to search for the sibling in.
660
+ * @param {Direction} direction - The direction to search for the sibling in.
661
+ * @param {boolean} toSiblingGroup - When true, skips over leafs within the same group.
662
+ * @returns {StoryId} The ID of the sibling story, or null if no sibling was found.
663
+ */
664
+ findSiblingStoryId(storyId: StoryId, index: API_IndexHash, direction: Direction, toSiblingGroup: boolean): StoryId;
665
+ /**
666
+ * Fetches the story index from the server.
667
+ *
668
+ * @returns {Promise<void>} A promise that resolves when the index has been fetched.
669
+ */
670
+ fetchIndex: () => Promise<void>;
671
+ /**
672
+ * Updates the story with the given ID with the provided update object.
673
+ *
674
+ * @param {StoryId} storyId - The ID of the story to update.
675
+ * @param {StoryUpdate} update - An object containing the updated story information.
676
+ * @param {API_ComposedRef} [ref] - The composed ref of the story to update.
677
+ * @returns {Promise<void>} A promise that resolves when the story has been updated.
678
+ */
679
+ updateStory: (storyId: StoryId, update: StoryUpdate, ref?: API_ComposedRef) => Promise<void>;
680
+ /**
681
+ * Updates the documentation for the given story ID with the given update object.
682
+ *
683
+ * @param {StoryId} storyId - The ID of the story to update.
684
+ * @param {DocsUpdate} update - An object containing the updated documentation information.
685
+ * @param {API_ComposedRef} [ref] - The composed ref of the story to update.
686
+ * @returns {Promise<void>} A promise that resolves when the documentation has been updated.
687
+ */
688
+ updateDocs: (storyId: StoryId, update: DocsUpdate, ref?: API_ComposedRef) => Promise<void>;
689
+ /**
690
+ * Sets the preview as initialized.
691
+ *
692
+ * @param {ComposedRef} [ref] - The composed ref of the story to set as initialized.
693
+ * @returns {Promise<void>} A promise that resolves when the preview has been set as initialized.
694
+ */
695
+ setPreviewInitialized: (ref?: API_ComposedRef) => Promise<void>;
696
+ /**
697
+ * Updates the filtering of the index.
698
+ *
699
+ * @param {string} addonId - The ID of the addon to update.
700
+ * @param {API_FilterFunction} filterFunction - A function that returns a boolean based on the
701
+ * story, index and status.
702
+ * @returns {Promise<void>} A promise that resolves when the state has been updated.
703
+ */
704
+ experimental_setFilter: (addonId: string, filterFunction: API_FilterFunction) => Promise<void>;
705
+ }
706
+
707
+ interface SubState$2 {
708
+ customQueryParams: QueryParams;
709
+ }
710
+ interface QueryParams {
711
+ [key: string]: string | undefined;
712
+ }
713
+ /** SubAPI for managing URL navigation and state. */
714
+ interface SubAPI$2 {
715
+ /**
716
+ * Navigate to a new URL.
717
+ *
718
+ * @param {string} url - The URL to navigate to.
719
+ * @param {NavigateOptions} options - Options for the navigation.
720
+ * @returns {void}
721
+ */
722
+ navigateUrl: (url: string, options: NavigateOptions) => void;
723
+ /**
724
+ * Get the value of a query parameter from the current URL.
725
+ *
726
+ * @param {string} key - The key of the query parameter to get.
727
+ * @returns {string | undefined} The value of the query parameter, or undefined if it does not
728
+ * exist.
729
+ */
730
+ getQueryParam: (key: string) => string | undefined;
731
+ /**
732
+ * Returns an object containing the current state of the URL.
733
+ *
734
+ * @returns {{
735
+ * queryParams: QueryParams;
736
+ * path: string;
737
+ * viewMode?: string;
738
+ * storyId?: string;
739
+ * url: string;
740
+ * }}
741
+ * An object containing the current state of the URL.
742
+ */
743
+ getUrlState: () => {
744
+ queryParams: QueryParams;
745
+ path: string;
746
+ hash: string;
747
+ viewMode?: string;
748
+ storyId?: string;
749
+ url: string;
750
+ };
751
+ /**
752
+ * Set the query parameters for the current URL.
753
+ *
754
+ * @param {QueryParams} input - An object containing the query parameters to set.
755
+ * @returns {void}
756
+ */
757
+ setQueryParams: (input: QueryParams) => void;
758
+ /**
759
+ * Set the query parameters for the current URL & navigates.
760
+ *
761
+ * @param {QueryParams} input - An object containing the query parameters to set.
762
+ * @param {NavigateOptions} options - Options for the navigation.
763
+ * @returns {void}
764
+ */
765
+ applyQueryParams: (input: QueryParams, options?: NavigateOptions) => void;
766
+ }
767
+
768
+ interface SubState$1 {
769
+ versions: API_Versions & API_UnknownEntries;
770
+ lastVersionCheck: number;
771
+ dismissedVersionNotification: undefined | string;
772
+ }
773
+ interface SubAPI$1 {
774
+ /**
775
+ * Returns the current version of the Storybook Manager.
776
+ *
777
+ * @returns {API_Version} The current version of the Storybook Manager.
778
+ */
779
+ getCurrentVersion: () => API_Version;
780
+ /**
781
+ * Returns the latest version of the Storybook Manager.
782
+ *
783
+ * @returns {API_Version} The latest version of the Storybook Manager.
784
+ */
785
+ getLatestVersion: () => API_Version;
786
+ /**
787
+ * Returns the URL of the Storybook documentation for the current version.
788
+ *
789
+ * @returns {string} The URL of the Storybook Manager documentation.
790
+ */
791
+ getDocsUrl: (options: {
792
+ subpath?: string;
793
+ versioned?: boolean;
794
+ renderer?: boolean;
795
+ }) => string;
796
+ /**
797
+ * Checks if an update is available for the Storybook Manager.
798
+ *
799
+ * @returns {boolean} True if an update is available, false otherwise.
800
+ */
801
+ versionUpdateAvailable: () => boolean;
802
+ }
803
+
804
+ type SubState = {
805
+ whatsNewData?: WhatsNewData;
806
+ };
807
+ type SubAPI = {
808
+ isWhatsNewUnread(): boolean;
809
+ whatsNewHasBeenRead(): void;
810
+ toggleWhatsNewNotifications(): void;
811
+ };
812
+
813
+ declare class RequestResponseError<Payload extends Record<string, any> | void> extends Error {
814
+ payload: Payload | undefined;
815
+ constructor(message: string, payload?: Payload);
816
+ }
817
+ declare const experimental_requestResponse: <RequestPayload, ResponsePayload = void, CreateNewStoryErrorPayload extends Record<string, any> | void = void>(channel: Channel, requestEvent: string, responseEvent: string, payload: RequestPayload, timeout?: number) => Promise<ResponsePayload>;
818
+
819
+ declare const _default: <TObj = any>(a: TObj, ...b: Partial<TObj>[]) => TObj;
820
+
821
+ type EnvironmentType = (typeof UniversalStore.Environment)[keyof typeof UniversalStore.Environment];
822
+ type StatusType = (typeof UniversalStore.Status)[keyof typeof UniversalStore.Status];
823
+ type StateUpdater<TState> = (prevState: TState) => TState;
824
+ type Actor = {
825
+ id: string;
826
+ type: (typeof UniversalStore.ActorType)[keyof typeof UniversalStore.ActorType];
827
+ environment: EnvironmentType;
828
+ };
829
+ type EventInfo = {
830
+ actor: Actor;
831
+ forwardingActor?: Actor;
832
+ };
833
+ type Listener<TEvent> = (event: TEvent, eventInfo: EventInfo) => void;
834
+ type BaseEvent = {
835
+ type: string;
836
+ payload?: any;
837
+ };
838
+ interface SetStateEvent<TState> extends BaseEvent {
839
+ type: typeof UniversalStore.InternalEventType.SET_STATE;
840
+ payload: {
841
+ state: TState;
842
+ previousState: TState;
843
+ };
844
+ }
845
+ interface ExistingStateRequestEvent extends BaseEvent {
846
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_REQUEST;
847
+ payload: never;
848
+ }
849
+ interface ExistingStateResponseEvent<TState> extends BaseEvent {
850
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE;
851
+ payload: TState;
852
+ }
853
+ interface LeaderCreatedEvent extends BaseEvent {
854
+ type: typeof UniversalStore.InternalEventType.LEADER_CREATED;
855
+ payload: never;
856
+ }
857
+ interface FollowerCreatedEvent extends BaseEvent {
858
+ type: typeof UniversalStore.InternalEventType.FOLLOWER_CREATED;
859
+ payload: never;
860
+ }
861
+ type InternalEvent<TState> = SetStateEvent<TState> | ExistingStateRequestEvent | ExistingStateResponseEvent<TState> | FollowerCreatedEvent | LeaderCreatedEvent;
862
+ type Event<TState, TEvent extends BaseEvent> = TEvent | InternalEvent<TState>;
863
+ type ChannelLike = Pick<Channel, 'on' | 'off' | 'emit'>;
864
+ type StoreOptions<TState> = {
865
+ id: string;
866
+ leader?: boolean;
867
+ initialState?: TState;
868
+ debug?: boolean;
869
+ };
870
+ type EnvironmentOverrides = {
871
+ channel: ChannelLike;
872
+ environment: EnvironmentType;
873
+ };
874
+
875
+ /**
876
+ * A universal store implementation that synchronizes state across different environments using a
877
+ * channel-based communication.
878
+ *
879
+ * The store follows a leader-follower pattern where:
880
+ *
881
+ * - Leader: The main store instance that owns and manages the state
882
+ * - Follower: Store instances that mirror the leader's state
883
+ *
884
+ * Features:
885
+ *
886
+ * - State synchronization across environments
887
+ * - Event-based communication
888
+ * - Type-safe state and custom events
889
+ * - Subscription system for state changes and custom events
890
+ *
891
+ * @remarks
892
+ * - The store must be created using the static `create()` method, not the constructor
893
+ * - Follower stores will automatically sync with their leader's state. If they have initial state, it
894
+ * will be replaced immediately when it has synced with the leader.
895
+ *
896
+ * @example
897
+ *
898
+ * ```typescript
899
+ * interface MyState {
900
+ * count: number;
901
+ * }
902
+ * interface MyCustomEvent {
903
+ * type: 'INCREMENT';
904
+ * payload: number;
905
+ * }
906
+ *
907
+ * // Create a leader store
908
+ * const leaderStore = UniversalStore.create<MyState, MyCustomEvent>({
909
+ * id: 'my-store',
910
+ * leader: true,
911
+ * initialState: { count: 0 },
912
+ * });
913
+ *
914
+ * // Create a follower store
915
+ * const followerStore = UniversalStore.create<MyState, MyCustomEvent>({
916
+ * id: 'my-store',
917
+ * leader: false,
918
+ * });
919
+ * ```
920
+ *
921
+ * @template State - The type of state managed by the store
922
+ * @template CustomEvent - Custom events that can be sent through the store. Must have a `type`
923
+ * string and optional `payload`
924
+ * @throws {Error} If constructed directly instead of using `create()`
925
+ * @throws {Error} If created without setting a channel first
926
+ * @throws {Error} If a follower is created with initial state
927
+ * @throws {Error} If a follower cannot find its leader within 1 second
928
+ */
929
+ declare class UniversalStore<State, CustomEvent extends {
930
+ type: string;
931
+ payload?: any;
932
+ } = {
933
+ type: string;
934
+ payload?: any;
935
+ }> {
936
+ /**
937
+ * Defines the possible actor types in the store system
938
+ *
939
+ * @readonly
940
+ */
941
+ static readonly ActorType: {
942
+ readonly LEADER: "LEADER";
943
+ readonly FOLLOWER: "FOLLOWER";
944
+ };
945
+ /**
946
+ * Defines the possible environments the store can run in
947
+ *
948
+ * @readonly
949
+ */
950
+ static readonly Environment: {
951
+ readonly SERVER: "SERVER";
952
+ readonly MANAGER: "MANAGER";
953
+ readonly PREVIEW: "PREVIEW";
954
+ readonly UNKNOWN: "UNKNOWN";
955
+ readonly MOCK: "MOCK";
956
+ };
957
+ /**
958
+ * Internal event types used for store synchronization
959
+ *
960
+ * @readonly
961
+ */
962
+ static readonly InternalEventType: {
963
+ readonly EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST";
964
+ readonly EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE";
965
+ readonly SET_STATE: "__SET_STATE";
966
+ readonly LEADER_CREATED: "__LEADER_CREATED";
967
+ readonly FOLLOWER_CREATED: "__FOLLOWER_CREATED";
968
+ };
969
+ static readonly Status: {
970
+ readonly UNPREPARED: "UNPREPARED";
971
+ readonly SYNCING: "SYNCING";
972
+ readonly READY: "READY";
973
+ readonly ERROR: "ERROR";
974
+ };
975
+ protected static isInternalConstructing: boolean;
976
+ /**
977
+ * The preparation construct is used to keep track of all store's preparation state the promise is
978
+ * resolved when the store is prepared with the static __prepare() method which will also change
979
+ * the state from PENDING to RESOLVED
980
+ */
981
+ private static preparation;
982
+ private static setupPreparationPromise;
983
+ /** Enable debug logs for this store */
984
+ debugging: boolean;
985
+ /** The actor object representing the store instance with a unique ID and a type */
986
+ get actor(): Actor;
987
+ /**
988
+ * The current state of the store, that signals both if the store is prepared by Storybook and
989
+ * also - in the case of a follower - if the state has been synced with the leader's state.
990
+ */
991
+ get status(): StatusType;
992
+ /**
993
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
994
+ * has been prepared by Storybook, which is almost instantly.
995
+ *
996
+ * A follower will be ready when the state has been synced with the leader's state, within a few
997
+ * hundred milliseconds.
998
+ */
999
+ untilReady(): Promise<[{
1000
+ channel: ChannelLike;
1001
+ environment: EnvironmentType;
1002
+ }, void | undefined]>;
1003
+ /**
1004
+ * The syncing construct is used to keep track of if the instance's state has been synced with the
1005
+ * other instances. A leader will immediately have the promise resolved. A follower will initially
1006
+ * be in a PENDING state, and resolve the the leader has sent the existing state, or reject if no
1007
+ * leader has responded before the timeout.
1008
+ */
1009
+ private syncing?;
1010
+ private channelEventName;
1011
+ private state;
1012
+ private channel?;
1013
+ private environment?;
1014
+ private listeners;
1015
+ private id;
1016
+ private actorId;
1017
+ private actorType;
1018
+ protected constructor(options: StoreOptions<State>, environmentOverrides?: EnvironmentOverrides);
1019
+ /** Creates a new instance of UniversalStore */
1020
+ static create<State = any, CustomEvent extends {
1021
+ type: string;
1022
+ payload?: any;
1023
+ } = {
1024
+ type: string;
1025
+ payload?: any;
1026
+ }>(options: StoreOptions<State>): UniversalStore<State, CustomEvent>;
1027
+ /** Gets the current state */
1028
+ getState: () => State;
1029
+ /**
1030
+ * Updates the store's state
1031
+ *
1032
+ * Either a new state or a state updater function can be passed to the method.
1033
+ */
1034
+ setState(updater: State | StateUpdater<State>): void;
1035
+ /**
1036
+ * Subscribes to store events
1037
+ *
1038
+ * @returns A function to unsubscribe
1039
+ */
1040
+ subscribe: {
1041
+ (listener: Listener<Event<State, CustomEvent>>): () => void;
1042
+ <EventType extends Event<State, CustomEvent>['type']>(eventType: EventType, listener: Listener<Extract<Event<State, CustomEvent>, {
1043
+ type: EventType;
1044
+ }>>): () => void;
1045
+ };
1046
+ /**
1047
+ * Subscribes to state changes
1048
+ *
1049
+ * @returns Unsubscribe function
1050
+ */
1051
+ onStateChange(listener: (state: State, previousState: State, eventInfo: EventInfo) => void): () => void;
1052
+ /** Sends a custom event to the other stores */
1053
+ send: (event: CustomEvent) => void;
1054
+ private emitToChannel;
1055
+ private prepareThis;
1056
+ private emitToListeners;
1057
+ private handleChannelEvents;
1058
+ private debug;
1059
+ }
1060
+
1061
+ /**
1062
+ * A hook to use a UniversalStore in the manager UI (eg. in an addon panel). This hook will react to
1063
+ * changes in the store state and re-render when the store changes.
1064
+ *
1065
+ * @param universalStore The UniversalStore instance to use.
1066
+ * @param selector An optional selector function to select a subset of the store state.
1067
+ * @remark This hook is intended for use in the manager UI. For use in the preview, import from
1068
+ * `storybook/preview-api` instead.
1069
+ */
1070
+ declare const useUniversalStore: {
1071
+ <TUniversalStore extends UniversalStore<TState, any>, TState = TUniversalStore extends UniversalStore<infer S, any> ? S : never>(universalStore: TUniversalStore): [TState, TUniversalStore['setState']];
1072
+ <TUniversalStore extends UniversalStore<any, any>, TSelectedState, TState = TUniversalStore extends UniversalStore<infer S, any> ? S : never>(universalStore: TUniversalStore, selector: (state: TState) => TSelectedState): [TSelectedState, TUniversalStore['setState']];
1073
+ };
1074
+
1075
+ /**
1076
+ * A mock universal store that can be used when testing code that relies on a universal store. It
1077
+ * functions exactly like a normal universal store, with a few exceptions:
1078
+ *
1079
+ * - It is fully isolated, meaning that it doesn't interact with any channel, and it is always a
1080
+ * leader.
1081
+ *
1082
+ * If the second testUtils argument is provided, all the public methods are spied on, so they can be
1083
+ * asserted.
1084
+ *
1085
+ * When a mock store is re-used across tests (eg. in stories), you manually need to reset the state
1086
+ * after each test.
1087
+ *
1088
+ * @example
1089
+ *
1090
+ * ```ts
1091
+ * import * as testUtils from 'storybook/test'; // in stories
1092
+ * import { vi as testUtils } from 'vitest'; // ... or in Vitest tests
1093
+ *
1094
+ * const initialState = { ... };
1095
+ * const store = new MockUniversalStore({ initialState }, testUtils);
1096
+ *
1097
+ * export default {
1098
+ * title: 'My story',
1099
+ * beforeEach: () => {
1100
+ * return () => {
1101
+ * store.setState(initialState);
1102
+ * };
1103
+ * }
1104
+ * }
1105
+ * ```
1106
+ */
1107
+ declare class MockUniversalStore<State, CustomEvent extends {
1108
+ type: string;
1109
+ payload?: any;
1110
+ } = {
1111
+ type: string;
1112
+ payload?: any;
1113
+ }> extends UniversalStore<State, CustomEvent> {
1114
+ private testUtils;
1115
+ constructor(options: StoreOptions<State>, testUtils?: any);
1116
+ /** Create a mock universal store. This is just an alias for the constructor */
1117
+ static create<State = any, CustomEvent extends {
1118
+ type: string;
1119
+ payload?: any;
1120
+ } = {
1121
+ type: string;
1122
+ payload?: any;
1123
+ }>(options: StoreOptions<State>, testUtils?: any): MockUniversalStore<State, CustomEvent>;
1124
+ unsubscribeAll(): void;
1125
+ }
1126
+
1127
+ declare global {
1128
+ interface SymbolConstructor {
1129
+ readonly observable: symbol;
1130
+ }
1131
+ }
1132
+
1133
+ declare global {
1134
+ var globalProjectAnnotations: NormalizedProjectAnnotations<any>;
1135
+ var defaultProjectAnnotations: ProjectAnnotations<any>;
1136
+ }
1137
+ type WrappedStoryRef = {
1138
+ __pw_type: 'jsx' | 'importRef';
1139
+ };
1140
+ type UnwrappedJSXStoryRef = {
1141
+ __pw_type: 'jsx';
1142
+ type: UnwrappedImportStoryRef;
1143
+ };
1144
+ type UnwrappedImportStoryRef = ComposedStoryFn;
1145
+ declare global {
1146
+ function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
1147
+ }
1148
+
1149
+ type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
1150
+ type StatusTypeId = string;
1151
+ type StatusByTypeId = Record<StatusTypeId, Status>;
1152
+ type StatusesByStoryIdAndTypeId = Record<StoryId$1, StatusByTypeId>;
1153
+ interface Status {
1154
+ value: StatusValue;
1155
+ typeId: StatusTypeId;
1156
+ storyId: StoryId$1;
1157
+ title: string;
1158
+ description: string;
1159
+ data?: any;
1160
+ sidebarContextMenu?: boolean;
1161
+ }
1162
+ type StatusStore = {
1163
+ getAll: () => StatusesByStoryIdAndTypeId;
1164
+ set: (statuses: Status[]) => void;
1165
+ onAllStatusChange: (listener: (statuses: StatusesByStoryIdAndTypeId, previousStatuses: StatusesByStoryIdAndTypeId) => void) => () => void;
1166
+ onSelect: (listener: (selectedStatuses: Status[]) => void) => () => void;
1167
+ unset: (storyIds?: StoryId$1[]) => void;
1168
+ };
1169
+ type StatusStoreByTypeId = StatusStore & {
1170
+ typeId: StatusTypeId;
1171
+ };
1172
+ type UseStatusStore = <T = StatusesByStoryIdAndTypeId>(selector?: (statuses: StatusesByStoryIdAndTypeId) => T) => T;
1173
+
1174
+ type TestProviderState = 'test-provider-state:pending' | 'test-provider-state:running' | 'test-provider-state:succeeded' | 'test-provider-state:crashed';
1175
+ type TestProviderId = string;
1176
+ type TestProviderStateByProviderId = Record<TestProviderId, TestProviderState>;
1177
+ type TestProviderStoreEventType = 'run-all' | 'clear-all' | 'settings-changed';
1178
+ type TestProviderStoreEvent = BaseEvent & {
1179
+ type: TestProviderStoreEventType;
1180
+ };
1181
+ type BaseTestProviderStore = {
1182
+ /**
1183
+ * Notifies all listeners that settings have changed for test providers. The Storybook UI will
1184
+ * highlight the test providers to tell the user that settings has changed.
1185
+ */
1186
+ settingsChanged: () => void;
1187
+ /**
1188
+ * Subscribe to clicks on the "Run All" button, that is supposed to trigger all test providers to
1189
+ * run. Your test provider should do the "main thing" when this happens, similar to when the user
1190
+ * triggers your test provider specifically.
1191
+ *
1192
+ * @example
1193
+ *
1194
+ * ```typescript
1195
+ * // Subscribe to run-all events
1196
+ * const unsubscribe = myTestProviderStore.onRunAll(() => {
1197
+ * await runAllMyTests();
1198
+ * });
1199
+ * ```
1200
+ */
1201
+ onRunAll: (listener: () => void) => () => void;
1202
+ /**
1203
+ * Subscribe to clicks on the "Clear All" button, that is supposed to clear all state from test
1204
+ * providers. Storybook already clears all statuses, but if your test provider has more
1205
+ * non-status-based state, you can use this to clear that here.
1206
+ *
1207
+ * @remarks
1208
+ * The purpose of this is _not_ to clear your test provider's settings, only the test results.
1209
+ * @example
1210
+ *
1211
+ * ```typescript
1212
+ * // Subscribe to clear-all events
1213
+ * const unsubscribe = myTestProviderStore.onClearAll(() => {
1214
+ * clearMyTestResults();
1215
+ * });
1216
+ *
1217
+ * // Later, when no longer needed
1218
+ * unsubscribe();
1219
+ * ```
1220
+ */
1221
+ onClearAll: (listener: () => void) => () => void;
1222
+ };
1223
+ /**
1224
+ * Represents a store for a specific test provider, identified by its unique ID. This store provides
1225
+ * methods to manage the state of an individual test provider, including getting and setting its
1226
+ * state, running operations with automatic state management, and accessing its unique identifier.
1227
+ *
1228
+ * Each test provider has its own instance of this store, allowing for independent state management
1229
+ * across different test providers in the application.
1230
+ *
1231
+ * @example
1232
+ *
1233
+ * ```typescript
1234
+ * // Get a store for a specific test provider
1235
+ * const grammarStore = getTestProviderStoreById('addon-grammar');
1236
+ *
1237
+ * // Check the current state
1238
+ * if (grammarStore.getState() === 'test-provider-state:pending') {
1239
+ * console.log('Grammar tests are ready to run');
1240
+ * }
1241
+ *
1242
+ * // Run tests with automatic state management
1243
+ * grammarStore.runWithState(async () => {
1244
+ * await runGrammarTests();
1245
+ * });
1246
+ * ```
1247
+ *
1248
+ * @see {@link TestProviderState} for possible state values
1249
+ * @see {@link BaseTestProviderStore} for methods inherited from the base store
1250
+ */
1251
+ type TestProviderStoreById = BaseTestProviderStore & {
1252
+ /**
1253
+ * Gets the current state of this specific test provider
1254
+ *
1255
+ * The state represents the current execution status of the test provider, which can be one of the
1256
+ * following:
1257
+ *
1258
+ * - 'test-provider-state:pending': Tests have not been run yet
1259
+ * - 'test-provider-state:running': Tests are currently running
1260
+ * - 'test-provider-state:succeeded': Tests completed successfully
1261
+ * - 'test-provider-state:crashed': Running tests failed or encountered an error
1262
+ *
1263
+ * Storybook UI will use this state to determine what to show in the UI.
1264
+ *
1265
+ * @remarks
1266
+ * The 'test-provider-state:crashed' is meant to signify that the test run as a whole failed to
1267
+ * execute for some reason. It should _not_ be set just because a number of tests failed, use
1268
+ * statuses and the status store for that. See {@link TestStatusStore} for managing individual test
1269
+ * statuses.
1270
+ * @example
1271
+ *
1272
+ * ```typescript
1273
+ * // Get the current state of a specific test provider
1274
+ * const state = testProviderStore.getState();
1275
+ *
1276
+ * // Conditionally render UI based on the state
1277
+ * const TestStatus = () => {
1278
+ * const state = testProviderStore.getState();
1279
+ *
1280
+ * if (state === 'test-provider-state:running') {
1281
+ * return <Spinner />;
1282
+ * } else if (state === 'test-provider-state:succeeded') {
1283
+ * return <SuccessIcon />;
1284
+ * } else if (state === 'test-provider-state:crashed') {
1285
+ * return <ErrorIcon />;
1286
+ * }
1287
+ *
1288
+ * return <PendingIcon />;
1289
+ * };
1290
+ * ```
1291
+ */
1292
+ getState: () => TestProviderState;
1293
+ /**
1294
+ * Sets the state of this specific test provider
1295
+ *
1296
+ * This method allows you to manually update the execution state of the test provider. It's
1297
+ * typically used when you need to reflect the current status of test execution in the UI or when
1298
+ * you want to programmatically control the test provider's state.
1299
+ *
1300
+ * Common use cases include:
1301
+ *
1302
+ * - Setting to 'running' when tests start
1303
+ * - Setting to 'succeeded' when tests complete successfully
1304
+ * - Setting to 'crashed' when tests fail or encounter errors
1305
+ * - Setting to 'pending' to reset the state
1306
+ *
1307
+ * The state represents the current execution status of the test provider, which can be one of the
1308
+ * following:
1309
+ *
1310
+ * - 'test-provider-state:pending': Tests have not been run yet
1311
+ * - 'test-provider-state:running': Tests are currently running
1312
+ * - 'test-provider-state:succeeded': Tests completed successfully
1313
+ * - 'test-provider-state:crashed': Running tests failed or encountered an error
1314
+ *
1315
+ * Storybook UI will use this state to determine what to show in the UI.
1316
+ *
1317
+ * @remarks
1318
+ * The 'test-provider-state:crashed' is meant to signify that the test run as a whole failed to
1319
+ * execute for some reason. It should _not_ be set just because a number of tests failed, use
1320
+ * statuses and the status store for that. See {@link TestStatusStore} for managing individual test
1321
+ * statuses.
1322
+ *
1323
+ * For most use cases, consider using {@link runWithState} instead, which provides automatic state
1324
+ * management and error handling during test execution.
1325
+ * @example
1326
+ *
1327
+ * ```typescript
1328
+ * // Update the state when tests start running
1329
+ * const startTests = async () => {
1330
+ * testProviderStore.setState('test-provider-state:running');
1331
+ * ... run tests ...
1332
+ * };
1333
+ * ```
1334
+ */
1335
+ setState: (state: TestProviderState) => void;
1336
+ /**
1337
+ * Runs a callback and automatically updates the test provider's state with running, succeeded or
1338
+ * crashed, depending on the end result.
1339
+ *
1340
+ * - Immediately changes the state to 'running'
1341
+ * - If the callback returns/resolves, change the state to 'succeeded'.
1342
+ * - If the callback throws an error/rejects, change the state to 'crashed'.
1343
+ *
1344
+ * This approach helps prevent state inconsistencies that might occur if exceptions are thrown
1345
+ * during test execution.
1346
+ *
1347
+ * @example
1348
+ *
1349
+ * ```typescript
1350
+ * // Run tests with automatic state management
1351
+ * const runTests = () => {
1352
+ * testProviderStore.runWithState(async () => {
1353
+ * // The state is automatically set to 'running' before this callback
1354
+ *
1355
+ * // Run tests here...
1356
+ * const results = await executeTests();
1357
+ * });
1358
+ * };
1359
+ * ```
1360
+ */
1361
+ runWithState: (callback: () => void | Promise<void>) => Promise<void>;
1362
+ /** The unique identifier for this test provider */
1363
+ testProviderId: TestProviderId;
1364
+ };
1365
+ /**
1366
+ * React OR preview hook for accessing the state of _all_ test providers. This hook will only
1367
+ * trigger a re-render when the state changes. It is recommended to pass the optional selector, to
1368
+ * get more fine-grained control of re-renders.
1369
+ *
1370
+ * @example
1371
+ *
1372
+ * ```typescript
1373
+ * const TestStatus = () => {
1374
+ * const state = useTestProviderStore((state) => state['my-test-provider']);
1375
+ * };
1376
+ * ```
1377
+ */
1378
+ type UseTestProviderStore = <T = TestProviderStateByProviderId>(
1379
+ /**
1380
+ * Optional selector function to extract or transform specific parts of the state
1381
+ *
1382
+ * @example
1383
+ *
1384
+ * ```typescript
1385
+ * // Use the entire state
1386
+ * const allProviderStates = useTestProviderStore();
1387
+ *
1388
+ * // Get state for a specific provider
1389
+ * const myProviderState = useTestProviderStore((state) => state['my-test-provider']);
1390
+ *
1391
+ * // Get a count of providers in each state
1392
+ * const statusCounts = useTestProviderStore((state) => {
1393
+ * const counts = {
1394
+ * pending: 0,
1395
+ * running: 0,
1396
+ * succeeded: 0,
1397
+ * crashed: 0,
1398
+ * };
1399
+ *
1400
+ * Object.values(state).forEach((status) => {
1401
+ * if (status === 'test-provider-state:pending') counts.pending++;
1402
+ * else if (status === 'test-provider-state:running') counts.running++;
1403
+ * else if (status === 'test-provider-state:succeeded') counts.succeeded++;
1404
+ * else if (status === 'test-provider-state:crashed') counts.crashed++;
1405
+ * });
1406
+ *
1407
+ * return counts;
1408
+ * });
1409
+ *
1410
+ * // Check if all tests have completed
1411
+ * const allTestsCompleted = useTestProviderStore((state) => {
1412
+ * return Object.values(state).every(
1413
+ * (status) =>
1414
+ * status === 'test-provider-state:succeeded' ||
1415
+ * status === 'test-provider-state:crashed'
1416
+ * );
1417
+ * });
1418
+ * ```
1419
+ */
1420
+ selector?: (state: TestProviderStateByProviderId) => T) => T;
1421
+
1422
+ declare const fullStatusStore: StatusStore & {
1423
+ selectStatuses: (statuses: Status[]) => void;
1424
+ typeId: undefined;
1425
+ };
1426
+ declare const getStatusStoreByTypeId: (typeId: StatusTypeId) => StatusStoreByTypeId;
1427
+ declare const useStatusStore: UseStatusStore;
1428
+
1429
+ declare const fullTestProviderStore: {
1430
+ settingsChanged: () => void;
1431
+ onRunAll: (listener: () => void) => () => void;
1432
+ onClearAll: (listener: () => void) => () => void;
1433
+ } & {
1434
+ getFullState: UniversalStore<TestProviderStateByProviderId, TestProviderStoreEvent>["getState"];
1435
+ setFullState: UniversalStore<TestProviderStateByProviderId, TestProviderStoreEvent>["setState"];
1436
+ onSettingsChanged: (listener: (testProviderId: TestProviderId) => void) => () => void;
1437
+ runAll: () => void;
1438
+ clearAll: () => void;
1439
+ };
1440
+ declare const getTestProviderStoreById: (testProviderId: TestProviderId) => TestProviderStoreById;
1441
+ declare const useTestProviderStore: UseTestProviderStore;
1442
+
1443
+ declare const ActiveTabs: {
1444
+ SIDEBAR: "sidebar";
1445
+ CANVAS: "canvas";
1446
+ ADDONS: "addons";
1447
+ };
1448
+
1449
+ declare const ManagerContext: React.Context<{
1450
+ api: API;
1451
+ state: State;
1452
+ }>;
1453
+ type State = SubState$8 & SubState$3 & SubState$6 & SubState$7 & SubState$a & SubState$1 & SubState$2 & SubState$4 & SubState$5 & SubState$9 & SubState & RouterData & API_OptionsData & DeprecatedState & Other;
1454
+ type API = SubAPI$d & SubAPI$c & SubAPI$7 & SubAPI$3 & SubAPI$6 & SubAPI$a & SubAPI$9 & SubAPI$8 & SubAPI$b & SubAPI$4 & SubAPI$5 & SubAPI$1 & SubAPI$2 & SubAPI & Other;
1455
+ interface DeprecatedState {
1456
+ /** @deprecated Use index */
1457
+ storiesHash: API_IndexHash;
1458
+ /** @deprecated Use previewInitialized */
1459
+ storiesConfigured: boolean;
1460
+ /** @deprecated Use indexError */
1461
+ storiesFailed?: Error;
1462
+ }
1463
+ interface Other {
1464
+ [key: string]: any;
1465
+ }
1466
+ interface Combo {
1467
+ api: API;
1468
+ state: State;
1469
+ }
1470
+ type ManagerProviderProps = RouterData & API_ProviderData<API> & {
1471
+ children: ReactNode | FC<Combo>;
1472
+ };
1473
+ declare const combineParameters: (...parameterSets: Parameters[]) => {};
1474
+ declare class ManagerProvider extends Component<ManagerProviderProps, State> {
1475
+ api: API;
1476
+ modules: ReturnType<ModuleFn>[];
1477
+ static displayName: string;
1478
+ constructor(props: ManagerProviderProps);
1479
+ static getDerivedStateFromProps(props: ManagerProviderProps, state: State): State;
1480
+ shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean;
1481
+ initModules: () => void;
1482
+ render(): React.JSX.Element;
1483
+ }
1484
+ interface ManagerConsumerProps<P = unknown> {
1485
+ filter?: (combo: Combo) => P;
1486
+ children: FC<P> | ReactNode;
1487
+ }
1488
+ declare function ManagerConsumer<P = Combo>({ filter, children, }: ManagerConsumerProps<P>): ReactElement;
1489
+ declare function useStorybookState(): State;
1490
+ declare function useStorybookApi(): API;
1491
+
1492
+ interface API_EventMap {
1493
+ [eventId: string]: Listener$1;
1494
+ }
1495
+ declare const useChannel: (eventMap: API_EventMap, deps?: any[]) => (type: string, ...args: any[]) => void;
1496
+ declare function useStoryPrepared(storyId?: StoryId): boolean;
1497
+ declare function useParameter<S>(parameterKey: string, defaultValue?: S): S;
1498
+ declare function useSharedState<S>(stateId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options) => void];
1499
+ declare function useAddonState<S>(addonId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options) => void];
1500
+ declare function useArgs(): [Args, (newArgs: Args) => void, (argNames?: string[]) => void, Args];
1501
+ declare function useGlobals(): [
1502
+ globals: Globals,
1503
+ updateGlobals: (newGlobals: Globals) => void,
1504
+ storyGlobals: Globals,
1505
+ userGlobals: Globals
1506
+ ];
1507
+ declare function useGlobalTypes(): ArgTypes;
1508
+ declare function useArgTypes(): ArgTypes;
1509
+
1510
+ declare const typesX: typeof Addon_TypesEnum;
1511
+
1512
+ export { type API, type API_EventMap, ActiveTabs, AddonStore, type Combo, ManagerConsumer as Consumer, type KeyboardEventLike, ManagerContext, type ManagerProviderProps, ManagerProvider as Provider, RequestResponseError, type State, type Options as StoreOptions, addons, combineParameters, controlOrMetaKey, controlOrMetaSymbol, eventMatchesShortcut, eventToShortcut, MockUniversalStore as experimental_MockUniversalStore, UniversalStore as experimental_UniversalStore, getStatusStoreByTypeId as experimental_getStatusStore, getTestProviderStoreById as experimental_getTestProviderStore, experimental_requestResponse, useStatusStore as experimental_useStatusStore, useTestProviderStore as experimental_useTestProviderStore, useUniversalStore as experimental_useUniversalStore, fullStatusStore as internal_fullStatusStore, fullTestProviderStore as internal_fullTestProviderStore, isMacLike, isShortcutTaken, keyToSymbol, _default as merge, mockChannel, optionOrAltSymbol, shortcutMatchesShortcut, shortcutToHumanString, typesX as types, useAddonState, useArgTypes, useArgs, useChannel, useGlobalTypes, useGlobals, useParameter, useSharedState, useStoryPrepared, useStorybookApi, useStorybookState };