storybook 9.0.0-alpha.1 → 9.0.0-alpha.2

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 (211) 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/message-reference.png +0 -0
  8. package/assets/server/addon.tsconfig.json +6 -0
  9. package/assets/server/base-preview-body.html +119 -0
  10. package/assets/server/base-preview-head.html +451 -0
  11. package/assets/server/template.ejs +87 -0
  12. package/bin/index.cjs +1 -1
  13. package/dist/babel/index.cjs +54034 -0
  14. package/dist/babel/index.d.ts +7488 -0
  15. package/dist/babel/index.js +54044 -0
  16. package/dist/bin/index.cjs +124 -0
  17. package/dist/bin/index.js +118 -0
  18. package/dist/builder-manager/index.cjs +2167 -0
  19. package/dist/builder-manager/index.d.ts +19 -0
  20. package/dist/builder-manager/index.js +2189 -0
  21. package/dist/channels/index.cjs +1938 -0
  22. package/dist/channels/index.d.ts +108 -0
  23. package/dist/channels/index.js +1885 -0
  24. package/dist/cli/bin/index.cjs +2687 -0
  25. package/dist/cli/bin/index.d.ts +2 -0
  26. package/dist/cli/bin/index.js +2707 -0
  27. package/dist/cli/index.cjs +17327 -0
  28. package/dist/cli/index.d.ts +209 -0
  29. package/dist/cli/index.js +17349 -0
  30. package/dist/client-logger/index.cjs +112 -0
  31. package/dist/client-logger/index.d.ts +29 -0
  32. package/dist/client-logger/index.js +70 -0
  33. package/dist/common/index.cjs +20558 -0
  34. package/dist/common/index.d.ts +955 -0
  35. package/dist/common/index.js +20643 -0
  36. package/dist/components/index.cjs +30056 -0
  37. package/dist/components/index.d.ts +1423 -0
  38. package/dist/components/index.js +25416 -0
  39. package/dist/core-events/index.cjs +167 -0
  40. package/dist/core-events/index.d.ts +313 -0
  41. package/dist/core-events/index.js +149 -0
  42. package/dist/core-server/index.cjs +37872 -0
  43. package/dist/core-server/index.d.ts +462 -0
  44. package/dist/core-server/index.js +37966 -0
  45. package/dist/core-server/presets/common-manager.js +28 -0
  46. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  47. package/dist/core-server/presets/common-override-preset.js +4829 -0
  48. package/dist/core-server/presets/common-preset.cjs +10228 -0
  49. package/dist/core-server/presets/common-preset.js +10306 -0
  50. package/dist/csf/index.cjs +223 -0
  51. package/dist/csf/index.d.ts +752 -0
  52. package/dist/csf/index.js +216 -0
  53. package/dist/csf-tools/index.cjs +1422 -0
  54. package/dist/csf-tools/index.d.ts +250 -0
  55. package/dist/csf-tools/index.js +1439 -0
  56. package/dist/docs-tools/index.cjs +923 -0
  57. package/dist/docs-tools/index.d.ts +162 -0
  58. package/dist/docs-tools/index.js +909 -0
  59. package/dist/index.cjs +17 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +2 -7
  62. package/dist/instrumenter/index.cjs +3273 -0
  63. package/dist/instrumenter/index.d.ts +104 -0
  64. package/dist/instrumenter/index.js +4800 -0
  65. package/dist/manager/globals-module-info.cjs +666 -0
  66. package/dist/manager/globals-module-info.d.ts +36 -0
  67. package/dist/manager/globals-module-info.js +653 -0
  68. package/dist/manager/globals-runtime.js +41567 -0
  69. package/dist/manager/globals.cjs +43 -0
  70. package/dist/manager/globals.d.ts +21 -0
  71. package/dist/manager/globals.js +30 -0
  72. package/dist/manager/runtime.js +12043 -0
  73. package/dist/manager-api/index.cjs +10772 -0
  74. package/dist/manager-api/index.d.ts +1211 -0
  75. package/dist/manager-api/index.js +4547 -0
  76. package/dist/manager-errors.d.ts +65 -0
  77. package/dist/manager-errors.js +83 -0
  78. package/dist/node-logger/index.cjs +1642 -0
  79. package/dist/node-logger/index.d.ts +117 -0
  80. package/dist/node-logger/index.js +1652 -0
  81. package/dist/preview/globals.cjs +34 -0
  82. package/dist/preview/globals.d.ts +12 -0
  83. package/dist/preview/globals.js +21 -0
  84. package/dist/preview/runtime.js +7723 -0
  85. package/dist/preview-api/index.cjs +5658 -0
  86. package/dist/preview-api/index.d.ts +1356 -0
  87. package/dist/preview-api/index.js +5665 -0
  88. package/dist/preview-errors.cjs +486 -0
  89. package/dist/preview-errors.d.ts +188 -0
  90. package/dist/preview-errors.js +433 -0
  91. package/dist/router/index.cjs +3320 -0
  92. package/dist/router/index.d.ts +385 -0
  93. package/dist/router/index.js +1849 -0
  94. package/dist/server-errors.cjs +710 -0
  95. package/dist/server-errors.d.ts +272 -0
  96. package/dist/server-errors.js +711 -0
  97. package/dist/telemetry/index.cjs +3683 -0
  98. package/dist/telemetry/index.d.ts +112 -0
  99. package/dist/telemetry/index.js +3720 -0
  100. package/dist/theming/create.cjs +2422 -0
  101. package/dist/theming/create.d.ts +50 -0
  102. package/dist/theming/create.js +990 -0
  103. package/dist/theming/index.cjs +4832 -0
  104. package/dist/theming/index.d.ts +11939 -0
  105. package/dist/theming/index.js +3253 -0
  106. package/dist/types/index.cjs +27 -0
  107. package/dist/types/index.d.ts +2541 -0
  108. package/dist/types/index.js +7 -0
  109. package/package.json +308 -212
  110. package/.eslintrc.cjs +0 -31
  111. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  112. package/core/babel/index.cjs +0 -1
  113. package/core/babel/index.d.ts +0 -2
  114. package/core/babel/index.js +0 -1
  115. package/core/builder-manager/index.cjs +0 -1
  116. package/core/builder-manager/index.d.ts +0 -2
  117. package/core/builder-manager/index.js +0 -1
  118. package/core/channels/index.cjs +0 -1
  119. package/core/channels/index.d.ts +0 -2
  120. package/core/channels/index.js +0 -1
  121. package/core/cli/bin/index.cjs +0 -1
  122. package/core/cli/bin/index.d.ts +0 -2
  123. package/core/cli/bin/index.js +0 -1
  124. package/core/cli/index.cjs +0 -1
  125. package/core/cli/index.d.ts +0 -2
  126. package/core/cli/index.js +0 -1
  127. package/core/client-logger/index.cjs +0 -1
  128. package/core/client-logger/index.d.ts +0 -2
  129. package/core/client-logger/index.js +0 -1
  130. package/core/common/index.cjs +0 -1
  131. package/core/common/index.d.ts +0 -2
  132. package/core/common/index.js +0 -1
  133. package/core/components/index.cjs +0 -1
  134. package/core/components/index.d.ts +0 -2
  135. package/core/components/index.js +0 -1
  136. package/core/core-events/index.cjs +0 -1
  137. package/core/core-events/index.d.ts +0 -2
  138. package/core/core-events/index.js +0 -1
  139. package/core/core-server/index.cjs +0 -1
  140. package/core/core-server/index.d.ts +0 -2
  141. package/core/core-server/index.js +0 -1
  142. package/core/core-server/presets/common-manager.js +0 -1
  143. package/core/core-server/presets/common-override-preset.cjs +0 -1
  144. package/core/core-server/presets/common-override-preset.js +0 -1
  145. package/core/core-server/presets/common-preset.cjs +0 -1
  146. package/core/core-server/presets/common-preset.js +0 -1
  147. package/core/csf/index.cjs +0 -1
  148. package/core/csf/index.d.ts +0 -2
  149. package/core/csf/index.js +0 -1
  150. package/core/csf-tools/index.cjs +0 -1
  151. package/core/csf-tools/index.d.ts +0 -2
  152. package/core/csf-tools/index.js +0 -1
  153. package/core/docs-tools/index.cjs +0 -1
  154. package/core/docs-tools/index.d.ts +0 -2
  155. package/core/docs-tools/index.js +0 -1
  156. package/core/index.cjs +0 -1
  157. package/core/index.d.ts +0 -2
  158. package/core/index.js +0 -1
  159. package/core/manager/globals-module-info.cjs +0 -1
  160. package/core/manager/globals-module-info.d.ts +0 -2
  161. package/core/manager/globals-module-info.js +0 -1
  162. package/core/manager/globals-runtime.js +0 -1
  163. package/core/manager/globals.cjs +0 -1
  164. package/core/manager/globals.d.ts +0 -2
  165. package/core/manager/globals.js +0 -1
  166. package/core/manager-api/index.cjs +0 -1
  167. package/core/manager-api/index.d.ts +0 -2
  168. package/core/manager-api/index.js +0 -1
  169. package/core/manager-errors.d.ts +0 -2
  170. package/core/manager-errors.js +0 -1
  171. package/core/node-logger/index.cjs +0 -1
  172. package/core/node-logger/index.d.ts +0 -2
  173. package/core/node-logger/index.js +0 -1
  174. package/core/preview/globals.cjs +0 -1
  175. package/core/preview/globals.d.ts +0 -2
  176. package/core/preview/globals.js +0 -1
  177. package/core/preview/runtime.js +0 -1
  178. package/core/preview-api/index.cjs +0 -1
  179. package/core/preview-api/index.d.ts +0 -2
  180. package/core/preview-api/index.js +0 -1
  181. package/core/preview-errors.cjs +0 -1
  182. package/core/preview-errors.d.ts +0 -2
  183. package/core/preview-errors.js +0 -1
  184. package/core/router/index.cjs +0 -1
  185. package/core/router/index.d.ts +0 -2
  186. package/core/router/index.js +0 -1
  187. package/core/server-errors.cjs +0 -1
  188. package/core/server-errors.d.ts +0 -2
  189. package/core/server-errors.js +0 -1
  190. package/core/telemetry/index.cjs +0 -1
  191. package/core/telemetry/index.d.ts +0 -2
  192. package/core/telemetry/index.js +0 -1
  193. package/core/theming/create.cjs +0 -1
  194. package/core/theming/create.d.ts +0 -2
  195. package/core/theming/create.js +0 -1
  196. package/core/theming/index.cjs +0 -1
  197. package/core/theming/index.d.ts +0 -2
  198. package/core/theming/index.js +0 -1
  199. package/core/types/index.cjs +0 -1
  200. package/core/types/index.d.ts +0 -2
  201. package/core/types/index.js +0 -1
  202. package/core.cjs +0 -0
  203. package/core.d.ts +0 -0
  204. package/core.js +0 -1
  205. package/dist/chunk-OWLSIX54.js +0 -8
  206. package/dist/core-path.cjs +0 -1
  207. package/dist/core-path.d.ts +0 -3
  208. package/dist/core-path.js +0 -9
  209. package/dist/proxy.cjs +0 -1
  210. package/dist/proxy.d.ts +0 -2
  211. package/dist/proxy.js +0 -9
@@ -0,0 +1,1211 @@
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_StatusObject, API_StatusUpdate, API_StatusState, API_FilterFunction, API_LoadedRefData, API_Version, API_Versions, API_UnknownEntries, 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, TestProviderId, TestProviders, WhatsNewData } from 'storybook/internal/core-events';
8
+ import { ThemeVars } from 'storybook/internal/theming';
9
+ import { toId } 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 | undefined;
182
+ updateTestProviderState(id: TestProviderId, update: Partial<TestProviderState>): void;
183
+ clearTestProviderState(id: TestProviderId): void;
184
+ runTestProvider(id: TestProviderId, options?: RunOptions): () => void;
185
+ cancelTestProvider(id: TestProviderId): 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: () => "control" | "meta";
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
+ status: API_StatusState;
511
+ filters: Record<string, API_FilterFunction>;
512
+ }
513
+ interface SubAPI$3 {
514
+ /**
515
+ * The `storyId` method is a reference to the `toId` function from `@storybook/csf`, which is used
516
+ * to generate a unique ID for a story. This ID is used to identify a specific story in the
517
+ * Storybook index.
518
+ *
519
+ * @type {typeof toId}
520
+ */
521
+ storyId: typeof toId;
522
+ /**
523
+ * Resolves a story, docs, component or group ID to its corresponding hash entry in the index.
524
+ *
525
+ * @param {StoryId} storyId - The ID of the story to resolve.
526
+ * @param {string} [refsId] - The ID of the refs to use for resolving the story.
527
+ * @returns {API_HashEntry} - The hash entry corresponding to the given story ID.
528
+ */
529
+ resolveStory: (storyId: StoryId, refsId?: string) => API_HashEntry | undefined;
530
+ /**
531
+ * Selects the first story to display in the Storybook UI.
532
+ *
533
+ * @returns {void}
534
+ */
535
+ selectFirstStory: () => void;
536
+ /**
537
+ * Selects a story to display in the Storybook UI.
538
+ *
539
+ * @param {string} [kindOrId] - The kind or ID of the story to select.
540
+ * @param {StoryId} [story] - The ID of the story to select.
541
+ * @param {Object} [obj] - An optional object containing additional options.
542
+ * @param {string} [obj.ref] - The ref ID of the story to select.
543
+ * @param {API_ViewMode} [obj.viewMode] - The view mode to display the story in.
544
+ * @returns {void}
545
+ */
546
+ selectStory: (kindOrId?: string, story?: StoryId, obj?: {
547
+ ref?: string;
548
+ viewMode?: API_ViewMode;
549
+ }) => void;
550
+ /**
551
+ * Returns the current story's data, including its ID, kind, name, and parameters.
552
+ *
553
+ * @returns {API_LeafEntry} The current story's data.
554
+ */
555
+ getCurrentStoryData: () => API_LeafEntry;
556
+ /**
557
+ * Sets the prepared story index to the given value.
558
+ *
559
+ * @param {API_PreparedStoryIndex} index - The prepared story index to set.
560
+ * @returns {Promise<void>} A promise that resolves when the prepared story index has been set.
561
+ */
562
+ setIndex: (index: API_PreparedStoryIndex) => Promise<void>;
563
+ /**
564
+ * Jumps to the next or previous component in the index.
565
+ *
566
+ * @param {Direction} direction - The direction to jump. Use -1 to jump to the previous component,
567
+ * and 1 to jump to the next component.
568
+ * @returns {void}
569
+ */
570
+ jumpToComponent: (direction: Direction) => void;
571
+ /**
572
+ * Jumps to the next or previous story in the story index.
573
+ *
574
+ * @param {Direction} direction - The direction to jump. Use -1 to jump to the previous story, and
575
+ * 1 to jump to the next story.
576
+ * @returns {void}
577
+ */
578
+ jumpToStory: (direction: Direction) => void;
579
+ /**
580
+ * Returns the data for the given story ID and optional ref ID.
581
+ *
582
+ * @param {StoryId} storyId - The ID of the story to retrieve data for.
583
+ * @param {string} [refId] - The ID of the ref to retrieve data for. If not provided, retrieves
584
+ * data for the default ref.
585
+ * @returns {API_LeafEntry} The data for the given story ID and optional ref ID.
586
+ */
587
+ getData: (storyId: StoryId, refId?: string) => API_LeafEntry;
588
+ /**
589
+ * Returns a boolean indicating whether the given story ID and optional ref ID have been prepared.
590
+ *
591
+ * @param {StoryId} storyId - The ID of the story to check.
592
+ * @param {string} [refId] - The ID of the ref to check. If not provided, checks all refs for the
593
+ * given story ID.
594
+ * @returns {boolean} A boolean indicating whether the given story ID and optional ref ID have
595
+ * been prepared.
596
+ */
597
+ isPrepared: (storyId: StoryId, refId?: string) => boolean;
598
+ /**
599
+ * Returns the parameters for the given story ID and optional ref ID.
600
+ *
601
+ * @param {StoryId | { storyId: StoryId; refId: string }} storyId - The ID of the story to
602
+ * retrieve parameters for, or an object containing the story ID and ref ID.
603
+ * @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not
604
+ * provided, returns all parameters.
605
+ * @returns {API_StoryEntry['parameters'] | any} The parameters for the given story ID and
606
+ * optional ref ID.
607
+ */
608
+ getParameters: (storyId: StoryId | {
609
+ storyId: StoryId;
610
+ refId: string;
611
+ }, parameterName?: ParameterName) => API_StoryEntry['parameters'] | any;
612
+ /**
613
+ * Returns the current value of the specified parameter for the currently selected story.
614
+ *
615
+ * @template S - The type of the parameter value.
616
+ * @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not
617
+ * provided, returns all parameters.
618
+ * @returns {S} The value of the specified parameter for the currently selected story.
619
+ */
620
+ getCurrentParameter<S>(parameterName?: ParameterName): S;
621
+ /**
622
+ * Updates the arguments for the given story with the provided new arguments.
623
+ *
624
+ * @param {API_StoryEntry} story - The story to update the arguments for.
625
+ * @param {Args} newArgs - The new arguments to set for the story.
626
+ * @returns {void}
627
+ */
628
+ updateStoryArgs(story: API_StoryEntry, newArgs: Args): void;
629
+ /**
630
+ * Resets the arguments for the given story to their initial values.
631
+ *
632
+ * @param {API_StoryEntry} story - The story to reset the arguments for.
633
+ * @param {string[]} [argNames] - An optional array of argument names to reset. If not provided,
634
+ * all arguments will be reset.
635
+ * @returns {void}
636
+ */
637
+ resetStoryArgs: (story: API_StoryEntry, argNames?: string[]) => void;
638
+ /**
639
+ * Finds the leaf entry for the given story ID in the given story index.
640
+ *
641
+ * @param {API_IndexHash} index - The story index to search for the leaf entry in.
642
+ * @param {StoryId} storyId - The ID of the story to find the leaf entry for.
643
+ * @returns {API_LeafEntry} The leaf entry for the given story ID, or null if no leaf entry was
644
+ * found.
645
+ */
646
+ findLeafEntry(index: API_IndexHash, storyId: StoryId): API_LeafEntry;
647
+ /**
648
+ * Finds the leaf story ID for the given component or group ID in the given index.
649
+ *
650
+ * @param {API_IndexHash} index - The story index to search for the leaf story ID in.
651
+ * @param {StoryId} storyId - The ID of the story to find the leaf story ID for.
652
+ * @returns {StoryId} The ID of the leaf story, or null if no leaf story was found.
653
+ */
654
+ findLeafStoryId(index: API_IndexHash, storyId: StoryId): StoryId;
655
+ /**
656
+ * Finds the ID of the sibling story in the given direction for the given story ID in the given
657
+ * story index.
658
+ *
659
+ * @param {StoryId} storyId - The ID of the story to find the sibling of.
660
+ * @param {API_IndexHash} index - The story index to search for the sibling in.
661
+ * @param {Direction} direction - The direction to search for the sibling in.
662
+ * @param {boolean} toSiblingGroup - When true, skips over leafs within the same group.
663
+ * @returns {StoryId} The ID of the sibling story, or null if no sibling was found.
664
+ */
665
+ findSiblingStoryId(storyId: StoryId, index: API_IndexHash, direction: Direction, toSiblingGroup: boolean): StoryId;
666
+ /**
667
+ * Fetches the story index from the server.
668
+ *
669
+ * @returns {Promise<void>} A promise that resolves when the index has been fetched.
670
+ */
671
+ fetchIndex: () => Promise<void>;
672
+ /**
673
+ * Updates the story with the given ID with the provided update object.
674
+ *
675
+ * @param {StoryId} storyId - The ID of the story to update.
676
+ * @param {StoryUpdate} update - An object containing the updated story information.
677
+ * @param {API_ComposedRef} [ref] - The composed ref of the story to update.
678
+ * @returns {Promise<void>} A promise that resolves when the story has been updated.
679
+ */
680
+ updateStory: (storyId: StoryId, update: StoryUpdate, ref?: API_ComposedRef) => Promise<void>;
681
+ /**
682
+ * Updates the documentation for the given story ID with the given update object.
683
+ *
684
+ * @param {StoryId} storyId - The ID of the story to update.
685
+ * @param {DocsUpdate} update - An object containing the updated documentation information.
686
+ * @param {API_ComposedRef} [ref] - The composed ref of the story to update.
687
+ * @returns {Promise<void>} A promise that resolves when the documentation has been updated.
688
+ */
689
+ updateDocs: (storyId: StoryId, update: DocsUpdate, ref?: API_ComposedRef) => Promise<void>;
690
+ /**
691
+ * Sets the preview as initialized.
692
+ *
693
+ * @param {ComposedRef} [ref] - The composed ref of the story to set as initialized.
694
+ * @returns {Promise<void>} A promise that resolves when the preview has been set as initialized.
695
+ */
696
+ setPreviewInitialized: (ref?: API_ComposedRef) => Promise<void>;
697
+ /**
698
+ * Returns the current status of the stories.
699
+ *
700
+ * @returns {API_StatusState} The current status of the stories.
701
+ */
702
+ getCurrentStoryStatus: () => Record<string, API_StatusObject>;
703
+ /**
704
+ * Updates the status of a collection of stories.
705
+ *
706
+ * @param {string} addonId - The ID of the addon to update.
707
+ * @param {StatusUpdate} update - An object containing the updated status information.
708
+ * @returns {Promise<void>} A promise that resolves when the status has been updated.
709
+ */
710
+ experimental_updateStatus: (addonId: string, update: API_StatusUpdate | ((state: API_StatusState) => API_StatusUpdate)) => Promise<void>;
711
+ /**
712
+ * Updates the filtering of the index.
713
+ *
714
+ * @param {string} addonId - The ID of the addon to update.
715
+ * @param {API_FilterFunction} filterFunction - A function that returns a boolean based on the
716
+ * story, index and status.
717
+ * @returns {Promise<void>} A promise that resolves when the state has been updated.
718
+ */
719
+ experimental_setFilter: (addonId: string, filterFunction: API_FilterFunction) => Promise<void>;
720
+ }
721
+
722
+ interface SubState$2 {
723
+ customQueryParams: QueryParams;
724
+ }
725
+ interface QueryParams {
726
+ [key: string]: string | undefined;
727
+ }
728
+ /** SubAPI for managing URL navigation and state. */
729
+ interface SubAPI$2 {
730
+ /**
731
+ * Navigate to a new URL.
732
+ *
733
+ * @param {string} url - The URL to navigate to.
734
+ * @param {NavigateOptions} options - Options for the navigation.
735
+ * @returns {void}
736
+ */
737
+ navigateUrl: (url: string, options: NavigateOptions) => void;
738
+ /**
739
+ * Get the value of a query parameter from the current URL.
740
+ *
741
+ * @param {string} key - The key of the query parameter to get.
742
+ * @returns {string | undefined} The value of the query parameter, or undefined if it does not
743
+ * exist.
744
+ */
745
+ getQueryParam: (key: string) => string | undefined;
746
+ /**
747
+ * Returns an object containing the current state of the URL.
748
+ *
749
+ * @returns {{
750
+ * queryParams: QueryParams;
751
+ * path: string;
752
+ * viewMode?: string;
753
+ * storyId?: string;
754
+ * url: string;
755
+ * }}
756
+ * An object containing the current state of the URL.
757
+ */
758
+ getUrlState: () => {
759
+ queryParams: QueryParams;
760
+ path: string;
761
+ hash: string;
762
+ viewMode?: string;
763
+ storyId?: string;
764
+ url: string;
765
+ };
766
+ /**
767
+ * Set the query parameters for the current URL.
768
+ *
769
+ * @param {QueryParams} input - An object containing the query parameters to set.
770
+ * @returns {void}
771
+ */
772
+ setQueryParams: (input: QueryParams) => void;
773
+ /**
774
+ * Set the query parameters for the current URL & navigates.
775
+ *
776
+ * @param {QueryParams} input - An object containing the query parameters to set.
777
+ * @param {NavigateOptions} options - Options for the navigation.
778
+ * @returns {void}
779
+ */
780
+ applyQueryParams: (input: QueryParams, options?: NavigateOptions) => void;
781
+ }
782
+
783
+ interface SubState$1 {
784
+ versions: API_Versions & API_UnknownEntries;
785
+ lastVersionCheck: number;
786
+ dismissedVersionNotification: undefined | string;
787
+ }
788
+ interface SubAPI$1 {
789
+ /**
790
+ * Returns the current version of the Storybook Manager.
791
+ *
792
+ * @returns {API_Version} The current version of the Storybook Manager.
793
+ */
794
+ getCurrentVersion: () => API_Version;
795
+ /**
796
+ * Returns the latest version of the Storybook Manager.
797
+ *
798
+ * @returns {API_Version} The latest version of the Storybook Manager.
799
+ */
800
+ getLatestVersion: () => API_Version;
801
+ /**
802
+ * Returns the URL of the Storybook documentation for the current version.
803
+ *
804
+ * @returns {string} The URL of the Storybook Manager documentation.
805
+ */
806
+ getDocsUrl: (options: {
807
+ subpath?: string;
808
+ versioned?: boolean;
809
+ renderer?: boolean;
810
+ }) => string;
811
+ /**
812
+ * Checks if an update is available for the Storybook Manager.
813
+ *
814
+ * @returns {boolean} True if an update is available, false otherwise.
815
+ */
816
+ versionUpdateAvailable: () => boolean;
817
+ }
818
+
819
+ type SubState = {
820
+ whatsNewData?: WhatsNewData;
821
+ };
822
+ type SubAPI = {
823
+ isWhatsNewUnread(): boolean;
824
+ whatsNewHasBeenRead(): void;
825
+ toggleWhatsNewNotifications(): void;
826
+ };
827
+
828
+ declare class RequestResponseError<Payload extends Record<string, any> | void> extends Error {
829
+ payload: Payload | undefined;
830
+ constructor(message: string, payload?: Payload);
831
+ }
832
+ 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>;
833
+
834
+ declare const _default: <TObj = any>(a: TObj, ...b: Partial<TObj>[]) => TObj;
835
+
836
+ type EnvironmentType = (typeof UniversalStore.Environment)[keyof typeof UniversalStore.Environment];
837
+ type StatusType = (typeof UniversalStore.Status)[keyof typeof UniversalStore.Status];
838
+ type StateUpdater<TState> = (prevState: TState) => TState;
839
+ type Actor = {
840
+ id: string;
841
+ type: (typeof UniversalStore.ActorType)[keyof typeof UniversalStore.ActorType];
842
+ environment: EnvironmentType;
843
+ };
844
+ type EventInfo = {
845
+ actor: Actor;
846
+ forwardingActor?: Actor;
847
+ };
848
+ type Listener<TEvent> = (event: TEvent, eventInfo: EventInfo) => void;
849
+ type BaseEvent = {
850
+ type: string;
851
+ payload?: any;
852
+ };
853
+ interface SetStateEvent<TState> extends BaseEvent {
854
+ type: typeof UniversalStore.InternalEventType.SET_STATE;
855
+ payload: {
856
+ state: TState;
857
+ previousState: TState;
858
+ };
859
+ }
860
+ interface ExistingStateRequestEvent extends BaseEvent {
861
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_REQUEST;
862
+ payload: never;
863
+ }
864
+ interface ExistingStateResponseEvent<TState> extends BaseEvent {
865
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE;
866
+ payload: TState;
867
+ }
868
+ interface LeaderCreatedEvent extends BaseEvent {
869
+ type: typeof UniversalStore.InternalEventType.LEADER_CREATED;
870
+ payload: never;
871
+ }
872
+ interface FollowerCreatedEvent extends BaseEvent {
873
+ type: typeof UniversalStore.InternalEventType.FOLLOWER_CREATED;
874
+ payload: never;
875
+ }
876
+ type InternalEvent<TState> = SetStateEvent<TState> | ExistingStateRequestEvent | ExistingStateResponseEvent<TState> | FollowerCreatedEvent | LeaderCreatedEvent;
877
+ type Event<TState, TEvent extends BaseEvent> = TEvent | InternalEvent<TState>;
878
+ type ChannelLike = Pick<Channel, 'on' | 'off' | 'emit'>;
879
+ type StoreOptions<TState> = {
880
+ id: string;
881
+ leader?: boolean;
882
+ initialState?: TState;
883
+ debug?: boolean;
884
+ };
885
+ type EnvironmentOverrides = {
886
+ channel: ChannelLike;
887
+ environment: EnvironmentType;
888
+ };
889
+
890
+ /**
891
+ * A universal store implementation that synchronizes state across different environments using a
892
+ * channel-based communication.
893
+ *
894
+ * The store follows a leader-follower pattern where:
895
+ *
896
+ * - Leader: The main store instance that owns and manages the state
897
+ * - Follower: Store instances that mirror the leader's state
898
+ *
899
+ * Features:
900
+ *
901
+ * - State synchronization across environments
902
+ * - Event-based communication
903
+ * - Type-safe state and custom events
904
+ * - Subscription system for state changes and custom events
905
+ *
906
+ * @remarks
907
+ * - The store must be created using the static `create()` method, not the constructor
908
+ * - Follower stores will automatically sync with their leader's state. If they have initial state, it
909
+ * will be replaced immediately when it has synced with the leader.
910
+ *
911
+ * @example
912
+ *
913
+ * ```typescript
914
+ * interface MyState {
915
+ * count: number;
916
+ * }
917
+ * interface MyCustomEvent {
918
+ * type: 'INCREMENT';
919
+ * payload: number;
920
+ * }
921
+ *
922
+ * // Create a leader store
923
+ * const leaderStore = UniversalStore.create<MyState, MyCustomEvent>({
924
+ * id: 'my-store',
925
+ * leader: true,
926
+ * initialState: { count: 0 },
927
+ * });
928
+ *
929
+ * // Create a follower store
930
+ * const followerStore = UniversalStore.create<MyState, MyCustomEvent>({
931
+ * id: 'my-store',
932
+ * leader: false,
933
+ * });
934
+ * ```
935
+ *
936
+ * @template State - The type of state managed by the store
937
+ * @template CustomEvent - Custom events that can be sent through the store. Must have a `type`
938
+ * string and optional `payload`
939
+ * @throws {Error} If constructed directly instead of using `create()`
940
+ * @throws {Error} If created without setting a channel first
941
+ * @throws {Error} If a follower is created with initial state
942
+ * @throws {Error} If a follower cannot find its leader within 1 second
943
+ */
944
+ declare class UniversalStore<State, CustomEvent extends {
945
+ type: string;
946
+ payload?: any;
947
+ } = {
948
+ type: string;
949
+ payload?: any;
950
+ }> {
951
+ /**
952
+ * Defines the possible actor types in the store system
953
+ *
954
+ * @readonly
955
+ */
956
+ static readonly ActorType: {
957
+ readonly LEADER: "LEADER";
958
+ readonly FOLLOWER: "FOLLOWER";
959
+ };
960
+ /**
961
+ * Defines the possible environments the store can run in
962
+ *
963
+ * @readonly
964
+ */
965
+ static readonly Environment: {
966
+ readonly SERVER: "SERVER";
967
+ readonly MANAGER: "MANAGER";
968
+ readonly PREVIEW: "PREVIEW";
969
+ readonly UNKNOWN: "UNKNOWN";
970
+ readonly MOCK: "MOCK";
971
+ };
972
+ /**
973
+ * Internal event types used for store synchronization
974
+ *
975
+ * @readonly
976
+ */
977
+ static readonly InternalEventType: {
978
+ readonly EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST";
979
+ readonly EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE";
980
+ readonly SET_STATE: "__SET_STATE";
981
+ readonly LEADER_CREATED: "__LEADER_CREATED";
982
+ readonly FOLLOWER_CREATED: "__FOLLOWER_CREATED";
983
+ };
984
+ static readonly Status: {
985
+ readonly UNPREPARED: "UNPREPARED";
986
+ readonly SYNCING: "SYNCING";
987
+ readonly READY: "READY";
988
+ readonly ERROR: "ERROR";
989
+ };
990
+ protected static isInternalConstructing: boolean;
991
+ /**
992
+ * The preparation construct is used to keep track of all store's preparation state the promise is
993
+ * resolved when the store is prepared with the static __prepare() method which will also change
994
+ * the state from PENDING to RESOLVED
995
+ */
996
+ private static preparation;
997
+ private static setupPreparationPromise;
998
+ /** Enable debug logs for this store */
999
+ debugging: boolean;
1000
+ /** The actor object representing the store instance with a unique ID and a type */
1001
+ get actor(): Actor;
1002
+ /**
1003
+ * The current state of the store, that signals both if the store is prepared by Storybook and
1004
+ * also - in the case of a follower - if the state has been synced with the leader's state.
1005
+ */
1006
+ get status(): StatusType;
1007
+ /**
1008
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
1009
+ * has been prepared by Storybook, which is almost instantly.
1010
+ *
1011
+ * A follower will be ready when the state has been synced with the leader's state, within a few
1012
+ * hundred milliseconds.
1013
+ */
1014
+ untilReady(): Promise<[{
1015
+ channel: ChannelLike;
1016
+ environment: EnvironmentType;
1017
+ }, void | undefined]>;
1018
+ /**
1019
+ * The syncing construct is used to keep track of if the instance's state has been synced with the
1020
+ * other instances. A leader will immediately have the promise resolved. A follower will initially
1021
+ * be in a PENDING state, and resolve the the leader has sent the existing state, or reject if no
1022
+ * leader has responded before the timeout.
1023
+ */
1024
+ private syncing?;
1025
+ private channelEventName;
1026
+ private state;
1027
+ private channel?;
1028
+ private environment?;
1029
+ private listeners;
1030
+ private id;
1031
+ private actorId;
1032
+ private actorType;
1033
+ protected constructor(options: StoreOptions<State>, environmentOverrides?: EnvironmentOverrides);
1034
+ /** Creates a new instance of UniversalStore */
1035
+ static create<State = any, CustomEvent extends {
1036
+ type: string;
1037
+ payload?: any;
1038
+ } = {
1039
+ type: string;
1040
+ payload?: any;
1041
+ }>(options: StoreOptions<State>): UniversalStore<State, CustomEvent>;
1042
+ /** Gets the current state */
1043
+ getState: () => State;
1044
+ /**
1045
+ * Updates the store's state
1046
+ *
1047
+ * Either a new state or a state updater function can be passed to the method.
1048
+ */
1049
+ setState(updater: State | StateUpdater<State>): void;
1050
+ /**
1051
+ * Subscribes to store events
1052
+ *
1053
+ * @returns A function to unsubscribe
1054
+ */
1055
+ subscribe: {
1056
+ (listener: Listener<Event<State, CustomEvent>>): () => void;
1057
+ <EventType extends Event<State, CustomEvent>['type']>(eventType: EventType, listener: Listener<Extract<Event<State, CustomEvent>, {
1058
+ type: EventType;
1059
+ }>>): () => void;
1060
+ };
1061
+ /**
1062
+ * Subscribes to state changes
1063
+ *
1064
+ * @returns Unsubscribe function
1065
+ */
1066
+ onStateChange(listener: (state: State, previousState: State, eventInfo: EventInfo) => void): () => void;
1067
+ /** Sends a custom event to the other stores */
1068
+ send: (event: CustomEvent) => void;
1069
+ private emitToChannel;
1070
+ private prepareThis;
1071
+ private emitToListeners;
1072
+ private handleChannelEvents;
1073
+ private debug;
1074
+ }
1075
+
1076
+ /**
1077
+ * A hook to use a UniversalStore in the manager UI (eg. in an addon panel). This hook will react to
1078
+ * changes in the store state and re-render when the store changes.
1079
+ *
1080
+ * @param universalStore The UniversalStore instance to use.
1081
+ * @param selector An optional selector function to select a subset of the store state.
1082
+ * @remark This hook is intended for use in the manager UI. For use in the preview, import from
1083
+ * `storybook/internal/preview-api` instead.
1084
+ */
1085
+ declare const useUniversalStore: {
1086
+ <TUniversalStore extends UniversalStore<TState, any>, TState = TUniversalStore extends UniversalStore<infer S, any> ? S : never>(universalStore: TUniversalStore): [TState, TUniversalStore['setState']];
1087
+ <TUniversalStore extends UniversalStore<any, any>, TSelectedState, TState = TUniversalStore extends UniversalStore<infer S, any> ? S : never>(universalStore: TUniversalStore, selector: (state: TState) => TSelectedState): [TSelectedState, TUniversalStore['setState']];
1088
+ };
1089
+
1090
+ /**
1091
+ * A mock universal store that can be used when testing code that relies on a universal store. It
1092
+ * functions exactly like a normal universal store, with a few exceptions:
1093
+ *
1094
+ * - It is fully isolated, meaning that it doesn't interact with any channel, and it is always a
1095
+ * leader.
1096
+ *
1097
+ * If the second testUtils argument is provided, all the public methods are spied on, so they can be
1098
+ * asserted.
1099
+ *
1100
+ * When a mock store is re-used across tests (eg. in stories), you manually need to reset the state
1101
+ * after each test.
1102
+ *
1103
+ * @example
1104
+ *
1105
+ * ```ts
1106
+ * import * as testUtils from '@storybook/test'; // in stories
1107
+ * import { vi as testUtils } from 'vitest'; // ... or in Vitest tests
1108
+ *
1109
+ * const initialState = { ... };
1110
+ * const store = new MockUniversalStore({ initialState }, testUtils);
1111
+ *
1112
+ * export default {
1113
+ * title: 'My story',
1114
+ * beforeEach: () => {
1115
+ * return () => {
1116
+ * store.setState(initialState);
1117
+ * };
1118
+ * }
1119
+ * }
1120
+ * ```
1121
+ */
1122
+ declare class MockUniversalStore<State, CustomEvent extends {
1123
+ type: string;
1124
+ payload?: any;
1125
+ } = {
1126
+ type: string;
1127
+ payload?: any;
1128
+ }> extends UniversalStore<State, CustomEvent> {
1129
+ private testUtils;
1130
+ constructor(options: StoreOptions<State>, testUtils?: any);
1131
+ /** Create a mock universal store. This is just an alias for the constructor */
1132
+ static create<State = any, CustomEvent extends {
1133
+ type: string;
1134
+ payload?: any;
1135
+ } = {
1136
+ type: string;
1137
+ payload?: any;
1138
+ }>(options: StoreOptions<State>, testUtils?: any): MockUniversalStore<State, CustomEvent>;
1139
+ unsubscribeAll(): void;
1140
+ }
1141
+
1142
+ declare const ActiveTabs: {
1143
+ SIDEBAR: "sidebar";
1144
+ CANVAS: "canvas";
1145
+ ADDONS: "addons";
1146
+ };
1147
+
1148
+ declare const ManagerContext: React.Context<{
1149
+ api: API;
1150
+ state: State;
1151
+ }>;
1152
+ 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;
1153
+ 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;
1154
+ interface DeprecatedState {
1155
+ /** @deprecated Use index */
1156
+ storiesHash: API_IndexHash;
1157
+ /** @deprecated Use previewInitialized */
1158
+ storiesConfigured: boolean;
1159
+ /** @deprecated Use indexError */
1160
+ storiesFailed?: Error;
1161
+ }
1162
+ interface Other {
1163
+ [key: string]: any;
1164
+ }
1165
+ interface Combo {
1166
+ api: API;
1167
+ state: State;
1168
+ }
1169
+ type ManagerProviderProps = RouterData & API_ProviderData<API> & {
1170
+ children: ReactNode | FC<Combo>;
1171
+ };
1172
+ declare const combineParameters: (...parameterSets: Parameters[]) => {};
1173
+ declare class ManagerProvider extends Component<ManagerProviderProps, State> {
1174
+ api: API;
1175
+ modules: ReturnType<ModuleFn>[];
1176
+ static displayName: string;
1177
+ constructor(props: ManagerProviderProps);
1178
+ static getDerivedStateFromProps(props: ManagerProviderProps, state: State): State;
1179
+ shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean;
1180
+ initModules: () => void;
1181
+ render(): React.JSX.Element;
1182
+ }
1183
+ interface ManagerConsumerProps<P = unknown> {
1184
+ filter?: (combo: Combo) => P;
1185
+ children: FC<P> | ReactNode;
1186
+ }
1187
+ declare function ManagerConsumer<P = Combo>({ filter, children, }: ManagerConsumerProps<P>): ReactElement;
1188
+ declare function useStorybookState(): State;
1189
+ declare function useStorybookApi(): API;
1190
+
1191
+ interface API_EventMap {
1192
+ [eventId: string]: Listener$1;
1193
+ }
1194
+ declare const useChannel: (eventMap: API_EventMap, deps?: any[]) => (type: string, ...args: any[]) => void;
1195
+ declare function useStoryPrepared(storyId?: StoryId): boolean;
1196
+ declare function useParameter<S>(parameterKey: string, defaultValue?: S): S;
1197
+ declare function useSharedState<S>(stateId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options) => void];
1198
+ declare function useAddonState<S>(addonId: string, defaultState?: S): [S, (newStateOrMerger: S | API_StateMerger<S>, options?: Options) => void];
1199
+ declare function useArgs(): [Args, (newArgs: Args) => void, (argNames?: string[]) => void, Args];
1200
+ declare function useGlobals(): [
1201
+ globals: Globals,
1202
+ updateGlobals: (newGlobals: Globals) => void,
1203
+ storyGlobals: Globals,
1204
+ userGlobals: Globals
1205
+ ];
1206
+ declare function useGlobalTypes(): ArgTypes;
1207
+ declare function useArgTypes(): ArgTypes;
1208
+
1209
+ declare const typesX: typeof Addon_TypesEnum;
1210
+
1211
+ 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, experimental_requestResponse, useUniversalStore as experimental_useUniversalStore, isMacLike, isShortcutTaken, keyToSymbol, _default as merge, mockChannel, optionOrAltSymbol, shortcutMatchesShortcut, shortcutToHumanString, typesX as types, useAddonState, useArgTypes, useArgs, useChannel, useGlobalTypes, useGlobals, useParameter, useSharedState, useStoryPrepared, useStorybookApi, useStorybookState };