storybook 9.0.0-alpha.10 → 9.0.0-alpha.12

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 (59) hide show
  1. package/bin/index.cjs +2 -2
  2. package/dist/actions/manager.js +150 -151
  3. package/dist/actions/preview.d.ts +0 -1
  4. package/dist/bin/index.cjs +66 -71
  5. package/dist/bin/index.js +59 -64
  6. package/dist/channels/index.cjs +17 -17
  7. package/dist/channels/index.js +3 -3
  8. package/dist/cli/bin/index.cjs +80 -80
  9. package/dist/cli/bin/index.js +83 -83
  10. package/dist/cli/index.cjs +1904 -1907
  11. package/dist/cli/index.d.ts +3 -7
  12. package/dist/cli/index.js +734 -737
  13. package/dist/common/index.cjs +59 -68
  14. package/dist/common/index.d.ts +1 -6
  15. package/dist/common/index.js +91 -100
  16. package/dist/component-testing/index.cjs +23 -0
  17. package/dist/component-testing/index.d.ts +3 -0
  18. package/dist/component-testing/index.js +5 -0
  19. package/dist/component-testing/manager.css +170 -0
  20. package/dist/component-testing/manager.js +3126 -0
  21. package/dist/component-testing/preview.cjs +40 -0
  22. package/dist/component-testing/preview.d.ts +5 -0
  23. package/dist/component-testing/preview.js +25 -0
  24. package/dist/components/index.cjs +5515 -5781
  25. package/dist/components/index.d.ts +3 -254
  26. package/dist/components/index.js +7296 -13770
  27. package/dist/controls/manager.js +989 -941
  28. package/dist/controls/preview.d.ts +0 -1
  29. package/dist/core-events/index.cjs +42 -45
  30. package/dist/core-events/index.d.ts +1 -4
  31. package/dist/core-events/index.js +38 -41
  32. package/dist/core-server/index.cjs +2730 -2721
  33. package/dist/core-server/index.d.ts +32 -23
  34. package/dist/core-server/index.js +822 -813
  35. package/dist/core-server/presets/common-preset.cjs +1754 -1730
  36. package/dist/core-server/presets/common-preset.js +1852 -1828
  37. package/dist/csf/index.d.ts +0 -2
  38. package/dist/csf-tools/index.cjs +0 -8
  39. package/dist/csf-tools/index.d.ts +0 -4
  40. package/dist/csf-tools/index.js +0 -8
  41. package/dist/instrumenter/index.cjs +475 -468
  42. package/dist/instrumenter/index.js +949 -950
  43. package/dist/manager/globals-module-info.cjs +15 -17
  44. package/dist/manager/globals-module-info.js +4 -6
  45. package/dist/manager/globals-runtime.js +56352 -50867
  46. package/dist/manager/runtime.js +4958 -4440
  47. package/dist/manager-api/index.cjs +1153 -1136
  48. package/dist/manager-api/index.d.ts +106 -97
  49. package/dist/manager-api/index.js +810 -795
  50. package/dist/preview/runtime.js +38453 -37289
  51. package/dist/preview-api/index.cjs +1098 -1211
  52. package/dist/preview-api/index.d.ts +10 -23
  53. package/dist/preview-api/index.js +1457 -1571
  54. package/dist/telemetry/index.d.ts +1 -1
  55. package/dist/types/index.cjs +14 -15
  56. package/dist/types/index.d.ts +306 -65
  57. package/dist/types/index.js +1 -2
  58. package/dist/viewport/preview.d.ts +0 -1
  59. package/package.json +25 -4
@@ -32,7 +32,7 @@ declare const monorepoConfigs: {
32
32
  };
33
33
  type MonorepoType = keyof typeof monorepoConfigs | 'Workspaces' | undefined;
34
34
 
35
- type EventType = 'boot' | 'dev' | 'build' | 'index' | 'upgrade' | 'init' | 'scaffolded-empty' | 'browser' | 'canceled' | 'error' | 'error-metadata' | 'version-update' | 'core-config' | 'remove' | 'save-story' | 'create-new-story-file' | 'create-new-story-file-search' | 'testing-module-watch-mode' | 'testing-module-completed-report' | 'testing-module-crash-report';
35
+ type EventType = 'boot' | 'dev' | 'build' | 'index' | 'upgrade' | 'init' | 'scaffolded-empty' | 'browser' | 'canceled' | 'error' | 'error-metadata' | 'version-update' | 'core-config' | 'remove' | 'save-story' | 'create-new-story-file' | 'create-new-story-file-search' | 'testing-module-watch-mode' | 'testing-module-completed-report' | 'testing-module-crash-report' | 'addon-test';
36
36
  interface Dependency {
37
37
  version: string | undefined;
38
38
  versionSpecifier?: string;
@@ -1,27 +1,26 @@
1
1
  "use strict";
2
2
  var d = Object.defineProperty;
3
3
  var y = Object.getOwnPropertyDescriptor;
4
- var i = Object.getOwnPropertyNames;
5
- var s = Object.prototype.hasOwnProperty;
6
- var A = (t, e) => {
4
+ var s = Object.getOwnPropertyNames;
5
+ var i = Object.prototype.hasOwnProperty;
6
+ var A = (r, e) => {
7
7
  for (var n in e)
8
- d(t, n, { get: e[n], enumerable: !0 });
9
- }, T = (t, e, n, a) => {
8
+ d(r, n, { get: e[n], enumerable: !0 });
9
+ }, T = (r, e, n, a) => {
10
10
  if (e && typeof e == "object" || typeof e == "function")
11
- for (let o of i(e))
12
- !s.call(t, o) && o !== n && d(t, o, { get: () => e[o], enumerable: !(a = y(e, o)) || a.enumerable });
13
- return t;
11
+ for (let o of s(e))
12
+ !i.call(r, o) && o !== n && d(r, o, { get: () => e[o], enumerable: !(a = y(e, o)) || a.enumerable });
13
+ return r;
14
14
  };
15
- var _ = (t) => T(d({}, "__esModule", { value: !0 }), t);
15
+ var _ = (r) => T(d({}, "__esModule", { value: !0 }), r);
16
16
 
17
17
  // src/types/index.ts
18
- var m = {};
19
- A(m, {
18
+ var S = {};
19
+ A(S, {
20
20
  Addon_TypesEnum: () => p
21
21
  });
22
- module.exports = _(m);
22
+ module.exports = _(S);
23
23
 
24
24
  // src/types/modules/addons.ts
25
- var p = /* @__PURE__ */ ((r) => (r.TAB = "tab", r.PANEL = "panel", r.TOOL = "tool", r.TOOLEXTRA = "toolextra", r.PREVIEW = "preview", r.experimental_PAGE =
26
- "page", r.experimental_SIDEBAR_BOTTOM = "sidebar-bottom", r.experimental_SIDEBAR_TOP = "sidebar-top", r.experimental_TEST_PROVIDER = "test-p\
27
- rovider", r))(p || {});
25
+ var p = /* @__PURE__ */ ((t) => (t.TAB = "tab", t.PANEL = "panel", t.TOOL = "tool", t.TOOLEXTRA = "toolextra", t.PREVIEW = "preview", t.experimental_PAGE =
26
+ "page", t.experimental_TEST_PROVIDER = "test-provider", t))(p || {});
@@ -885,7 +885,7 @@ interface ChannelEvent {
885
885
  from: string;
886
886
  args: any[];
887
887
  }
888
- interface Listener {
888
+ interface Listener$1 {
889
889
  (...args: any[]): void;
890
890
  }
891
891
  interface ChannelArgsSingle {
@@ -906,17 +906,17 @@ declare class Channel {
906
906
  constructor(input: ChannelArgsMulti);
907
907
  constructor(input: ChannelArgsSingle);
908
908
  get hasTransport(): boolean;
909
- addListener(eventName: string, listener: Listener): void;
909
+ addListener(eventName: string, listener: Listener$1): void;
910
910
  emit(eventName: string, ...args: any): void;
911
911
  last(eventName: string): any;
912
912
  eventNames(): string[];
913
913
  listenerCount(eventName: string): number;
914
- listeners(eventName: string): Listener[] | undefined;
915
- once(eventName: string, listener: Listener): void;
914
+ listeners(eventName: string): Listener$1[] | undefined;
915
+ once(eventName: string, listener: Listener$1): void;
916
916
  removeAllListeners(eventName?: string): void;
917
- removeListener(eventName: string, listener: Listener): void;
918
- on(eventName: string, listener: Listener): void;
919
- off(eventName: string, listener: Listener): void;
917
+ removeListener(eventName: string, listener: Listener$1): void;
918
+ on(eventName: string, listener: Listener$1): void;
919
+ off(eventName: string, listener: Listener$1): void;
920
920
  private handleEvent;
921
921
  private onceListener;
922
922
  }
@@ -1298,13 +1298,6 @@ type CoreCommon_StorybookRefs = Record<string, {
1298
1298
  type DocsOptions = {
1299
1299
  /** What should we call the generated docs entries? */
1300
1300
  defaultName?: string;
1301
- /**
1302
- * Should we generate a docs entry per CSF file? Set to 'tag' (the default) to generate an entry
1303
- * for every CSF file with the 'autodocs' tag.
1304
- *
1305
- * @deprecated Use `tags: ['autodocs']` in `.storybook/preview.js` instead
1306
- */
1307
- autodocs?: boolean | 'tag';
1308
1301
  /** Only show doc entries in the side bar (usually set with the `--docs` CLI flag) */
1309
1302
  docsMode?: boolean;
1310
1303
  };
@@ -1711,8 +1704,6 @@ interface API_ProviderData<API> {
1711
1704
  }
1712
1705
  interface API_Provider<API> {
1713
1706
  channel?: Channel;
1714
- /** @deprecated Will be removed in 8.0, please use channel instead */
1715
- serverChannel?: Channel;
1716
1707
  renderPreview?: API_IframeRenderer;
1717
1708
  handleAPI(api: API): void;
1718
1709
  getConfig(): {
@@ -1751,8 +1742,6 @@ interface API_Layout {
1751
1742
  panelPosition: API_PanelPositions;
1752
1743
  showTabs: boolean;
1753
1744
  showToolbar: boolean;
1754
- /** @deprecated, will be removed in 8.0 - this API no longer works */
1755
- isToolshown?: boolean;
1756
1745
  }
1757
1746
  interface API_UI {
1758
1747
  name?: string;
@@ -1777,14 +1766,6 @@ interface OnClickOptions {
1777
1766
  /** Function to dismiss the notification. */
1778
1767
  onDismiss: () => void;
1779
1768
  }
1780
- /**
1781
- * @deprecated Use ReactNode for the icon instead.
1782
- * @see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#icons-is-deprecated
1783
- */
1784
- interface DeprecatedIconType {
1785
- name: string;
1786
- color?: string;
1787
- }
1788
1769
  interface API_Notification {
1789
1770
  id: string;
1790
1771
  content: {
@@ -1793,7 +1774,7 @@ interface API_Notification {
1793
1774
  };
1794
1775
  duration?: number;
1795
1776
  link?: string;
1796
- icon?: React.ReactNode | DeprecatedIconType;
1777
+ icon?: React.ReactNode;
1797
1778
  onClear?: (options: OnClearOptions) => void;
1798
1779
  onClick?: (options: OnClickOptions) => void;
1799
1780
  }
@@ -1827,7 +1808,7 @@ type API_Refs = Record<string, API_ComposedRef>;
1827
1808
  type API_RefId = string;
1828
1809
  type API_RefUrl = string;
1829
1810
 
1830
- type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_TEST_PROVIDER | Addon_TypesEnum.experimental_SIDEBAR_TOP>;
1811
+ type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
1831
1812
  interface Addon_ArgType<TArg = unknown> extends InputType {
1832
1813
  defaultValue?: TArg;
1833
1814
  }
@@ -2018,7 +1999,6 @@ interface Addon_BaseMeta<ComponentType> {
2018
1999
  *
2019
2000
  * Used by addons for automatic prop table generation and display of other component metadata.
2020
2001
  *
2021
- * @deprecated
2022
2002
  * @example
2023
2003
  *
2024
2004
  * ```ts
@@ -2044,7 +2024,7 @@ type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnRetur
2044
2024
  interface Addon_RenderOptions {
2045
2025
  active: boolean;
2046
2026
  }
2047
- type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_SidebarBottomType | Addon_SidebarTopType | Addon_TestProviderType<Addon_TestProviderState>;
2027
+ type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_TestProviderType<Addon_TestProviderState>;
2048
2028
  interface Addon_BaseType {
2049
2029
  /**
2050
2030
  * The title of the addon. This can be a simple string, but it can also be a
@@ -2060,7 +2040,7 @@ interface Addon_BaseType {
2060
2040
  * Addon_TypesEnum.PANEL;
2061
2041
  * ```
2062
2042
  */
2063
- type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2043
+ type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2064
2044
  /**
2065
2045
  * The unique id of the addon.
2066
2046
  *
@@ -2147,22 +2127,6 @@ interface Addon_WrapperType {
2147
2127
  storyId: StoryId;
2148
2128
  }>>;
2149
2129
  }
2150
- /** @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0. */
2151
- interface Addon_SidebarBottomType {
2152
- type: Addon_TypesEnum.experimental_SIDEBAR_BOTTOM;
2153
- /** The unique id of the tool. */
2154
- id: string;
2155
- /** A React.FunctionComponent. */
2156
- render: FC;
2157
- }
2158
- /** @deprecated This will be removed in Storybook 9.0. */
2159
- interface Addon_SidebarTopType {
2160
- type: Addon_TypesEnum.experimental_SIDEBAR_TOP;
2161
- /** The unique id of the tool. */
2162
- id: string;
2163
- /** A React.FunctionComponent. */
2164
- render: FC;
2165
- }
2166
2130
  interface Addon_TestProviderType<Details extends {
2167
2131
  [key: string]: any;
2168
2132
  } = NonNullable<unknown>> {
@@ -2197,12 +2161,10 @@ type Addon_TestProviderState<Details extends {
2197
2161
  message?: string;
2198
2162
  };
2199
2163
  };
2200
- type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2164
+ type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2201
2165
  interface Addon_TypesMapping extends Record<Addon_TypeBaseNames, Addon_BaseType> {
2202
2166
  [Addon_TypesEnum.PREVIEW]: Addon_WrapperType;
2203
2167
  [Addon_TypesEnum.experimental_PAGE]: Addon_PageType;
2204
- [Addon_TypesEnum.experimental_SIDEBAR_BOTTOM]: Addon_SidebarBottomType;
2205
- [Addon_TypesEnum.experimental_SIDEBAR_TOP]: Addon_SidebarTopType;
2206
2168
  [Addon_TypesEnum.experimental_TEST_PROVIDER]: Addon_TestProviderType<Addon_TestProviderState>;
2207
2169
  }
2208
2170
  type Addon_Loader<API> = (api: API) => void;
@@ -2252,18 +2214,6 @@ declare enum Addon_TypesEnum {
2252
2214
  * @unstable
2253
2215
  */
2254
2216
  experimental_PAGE = "page",
2255
- /**
2256
- * This adds items in the bottom of the sidebar.
2257
- *
2258
- * @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0.
2259
- */
2260
- experimental_SIDEBAR_BOTTOM = "sidebar-bottom",
2261
- /**
2262
- * This adds items in the top of the sidebar.
2263
- *
2264
- * @deprecated This will be removed in Storybook 9.0.
2265
- */
2266
- experimental_SIDEBAR_TOP = "sidebar-top",
2267
2217
  /** This adds items to the Testing Module in the sidebar. */
2268
2218
  experimental_TEST_PROVIDER = "test-provider"
2269
2219
  }
@@ -2304,7 +2254,6 @@ interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotati
2304
2254
  unmount: () => void;
2305
2255
  };
2306
2256
  renderToCanvas?: RenderToCanvas<TRenderer>;
2307
- renderToDOM?: RenderToCanvas<TRenderer>;
2308
2257
  }
2309
2258
  type NamedExportsOrDefault<TExport> = TExport | {
2310
2259
  default: TExport;
@@ -2519,10 +2468,250 @@ interface ComposeStoryFn<TRenderer extends Renderer$1 = Renderer$1, TArgs extend
2519
2468
  (storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations$1<TRenderer>, exportsName?: string): ComposedStoryFn;
2520
2469
  }
2521
2470
 
2522
- type SupportedFrameworks = 'angular' | 'ember' | 'experimental-nextjs-vite' | 'html-vite' | 'html-webpack5' | 'nextjs' | 'preact-vite' | 'preact-webpack5' | 'react-native-web-vite' | 'react-vite' | 'react-webpack5' | 'server-webpack5' | 'svelte-vite' | 'svelte-webpack5' | 'sveltekit' | 'vue3-vite' | 'vue3-webpack5' | 'web-components-vite' | 'web-components-webpack5' | 'qwik' | 'solid' | 'nuxt' | 'react-rsbuild' | 'vue3-rsbuild';
2471
+ type SupportedFrameworks = 'angular' | 'ember' | 'html-vite' | 'html-webpack5' | 'nextjs' | 'nextjs-vite' | 'preact-vite' | 'react-native-web-vite' | 'react-vite' | 'react-webpack5' | 'server-webpack5' | 'svelte-vite' | 'svelte-webpack5' | 'sveltekit' | 'vue3-vite' | 'web-components-vite' | 'web-components-webpack5' | 'qwik' | 'solid' | 'nuxt' | 'react-rsbuild' | 'vue3-rsbuild';
2523
2472
 
2524
2473
  type SupportedRenderers = 'react' | 'react-native' | 'vue3' | 'angular' | 'ember' | 'preact' | 'svelte' | 'qwik' | 'html' | 'web-components' | 'server' | 'solid' | 'nuxt';
2525
2474
 
2475
+ type EnvironmentType = (typeof UniversalStore.Environment)[keyof typeof UniversalStore.Environment];
2476
+ type StatusType = (typeof UniversalStore.Status)[keyof typeof UniversalStore.Status];
2477
+ type StateUpdater<TState> = (prevState: TState) => TState;
2478
+ type Actor = {
2479
+ id: string;
2480
+ type: (typeof UniversalStore.ActorType)[keyof typeof UniversalStore.ActorType];
2481
+ environment: EnvironmentType;
2482
+ };
2483
+ type EventInfo = {
2484
+ actor: Actor;
2485
+ forwardingActor?: Actor;
2486
+ };
2487
+ type Listener<TEvent> = (event: TEvent, eventInfo: EventInfo) => void;
2488
+ type BaseEvent = {
2489
+ type: string;
2490
+ payload?: any;
2491
+ };
2492
+ interface SetStateEvent<TState> extends BaseEvent {
2493
+ type: typeof UniversalStore.InternalEventType.SET_STATE;
2494
+ payload: {
2495
+ state: TState;
2496
+ previousState: TState;
2497
+ };
2498
+ }
2499
+ interface ExistingStateRequestEvent extends BaseEvent {
2500
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_REQUEST;
2501
+ payload: never;
2502
+ }
2503
+ interface ExistingStateResponseEvent<TState> extends BaseEvent {
2504
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE;
2505
+ payload: TState;
2506
+ }
2507
+ interface LeaderCreatedEvent extends BaseEvent {
2508
+ type: typeof UniversalStore.InternalEventType.LEADER_CREATED;
2509
+ payload: never;
2510
+ }
2511
+ interface FollowerCreatedEvent extends BaseEvent {
2512
+ type: typeof UniversalStore.InternalEventType.FOLLOWER_CREATED;
2513
+ payload: never;
2514
+ }
2515
+ type InternalEvent<TState> = SetStateEvent<TState> | ExistingStateRequestEvent | ExistingStateResponseEvent<TState> | FollowerCreatedEvent | LeaderCreatedEvent;
2516
+ type Event<TState, TEvent extends BaseEvent> = TEvent | InternalEvent<TState>;
2517
+ type ChannelLike = Pick<Channel$1, 'on' | 'off' | 'emit'>;
2518
+ type StoreOptions<TState> = {
2519
+ id: string;
2520
+ leader?: boolean;
2521
+ initialState?: TState;
2522
+ debug?: boolean;
2523
+ };
2524
+ type EnvironmentOverrides = {
2525
+ channel: ChannelLike;
2526
+ environment: EnvironmentType;
2527
+ };
2528
+
2529
+ /**
2530
+ * A universal store implementation that synchronizes state across different environments using a
2531
+ * channel-based communication.
2532
+ *
2533
+ * The store follows a leader-follower pattern where:
2534
+ *
2535
+ * - Leader: The main store instance that owns and manages the state
2536
+ * - Follower: Store instances that mirror the leader's state
2537
+ *
2538
+ * Features:
2539
+ *
2540
+ * - State synchronization across environments
2541
+ * - Event-based communication
2542
+ * - Type-safe state and custom events
2543
+ * - Subscription system for state changes and custom events
2544
+ *
2545
+ * @remarks
2546
+ * - The store must be created using the static `create()` method, not the constructor
2547
+ * - Follower stores will automatically sync with their leader's state. If they have initial state, it
2548
+ * will be replaced immediately when it has synced with the leader.
2549
+ *
2550
+ * @example
2551
+ *
2552
+ * ```typescript
2553
+ * interface MyState {
2554
+ * count: number;
2555
+ * }
2556
+ * interface MyCustomEvent {
2557
+ * type: 'INCREMENT';
2558
+ * payload: number;
2559
+ * }
2560
+ *
2561
+ * // Create a leader store
2562
+ * const leaderStore = UniversalStore.create<MyState, MyCustomEvent>({
2563
+ * id: 'my-store',
2564
+ * leader: true,
2565
+ * initialState: { count: 0 },
2566
+ * });
2567
+ *
2568
+ * // Create a follower store
2569
+ * const followerStore = UniversalStore.create<MyState, MyCustomEvent>({
2570
+ * id: 'my-store',
2571
+ * leader: false,
2572
+ * });
2573
+ * ```
2574
+ *
2575
+ * @template State - The type of state managed by the store
2576
+ * @template CustomEvent - Custom events that can be sent through the store. Must have a `type`
2577
+ * string and optional `payload`
2578
+ * @throws {Error} If constructed directly instead of using `create()`
2579
+ * @throws {Error} If created without setting a channel first
2580
+ * @throws {Error} If a follower is created with initial state
2581
+ * @throws {Error} If a follower cannot find its leader within 1 second
2582
+ */
2583
+ declare class UniversalStore<State, CustomEvent extends {
2584
+ type: string;
2585
+ payload?: any;
2586
+ } = {
2587
+ type: string;
2588
+ payload?: any;
2589
+ }> {
2590
+ /**
2591
+ * Defines the possible actor types in the store system
2592
+ *
2593
+ * @readonly
2594
+ */
2595
+ static readonly ActorType: {
2596
+ readonly LEADER: "LEADER";
2597
+ readonly FOLLOWER: "FOLLOWER";
2598
+ };
2599
+ /**
2600
+ * Defines the possible environments the store can run in
2601
+ *
2602
+ * @readonly
2603
+ */
2604
+ static readonly Environment: {
2605
+ readonly SERVER: "SERVER";
2606
+ readonly MANAGER: "MANAGER";
2607
+ readonly PREVIEW: "PREVIEW";
2608
+ readonly UNKNOWN: "UNKNOWN";
2609
+ readonly MOCK: "MOCK";
2610
+ };
2611
+ /**
2612
+ * Internal event types used for store synchronization
2613
+ *
2614
+ * @readonly
2615
+ */
2616
+ static readonly InternalEventType: {
2617
+ readonly EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST";
2618
+ readonly EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE";
2619
+ readonly SET_STATE: "__SET_STATE";
2620
+ readonly LEADER_CREATED: "__LEADER_CREATED";
2621
+ readonly FOLLOWER_CREATED: "__FOLLOWER_CREATED";
2622
+ };
2623
+ static readonly Status: {
2624
+ readonly UNPREPARED: "UNPREPARED";
2625
+ readonly SYNCING: "SYNCING";
2626
+ readonly READY: "READY";
2627
+ readonly ERROR: "ERROR";
2628
+ };
2629
+ protected static isInternalConstructing: boolean;
2630
+ /**
2631
+ * The preparation construct is used to keep track of all store's preparation state the promise is
2632
+ * resolved when the store is prepared with the static __prepare() method which will also change
2633
+ * the state from PENDING to RESOLVED
2634
+ */
2635
+ private static preparation;
2636
+ private static setupPreparationPromise;
2637
+ /** Enable debug logs for this store */
2638
+ debugging: boolean;
2639
+ /** The actor object representing the store instance with a unique ID and a type */
2640
+ get actor(): Actor;
2641
+ /**
2642
+ * The current state of the store, that signals both if the store is prepared by Storybook and
2643
+ * also - in the case of a follower - if the state has been synced with the leader's state.
2644
+ */
2645
+ get status(): StatusType;
2646
+ /**
2647
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
2648
+ * has been prepared by Storybook, which is almost instantly.
2649
+ *
2650
+ * A follower will be ready when the state has been synced with the leader's state, within a few
2651
+ * hundred milliseconds.
2652
+ */
2653
+ untilReady(): Promise<[{
2654
+ channel: ChannelLike;
2655
+ environment: EnvironmentType;
2656
+ }, void | undefined]>;
2657
+ /**
2658
+ * The syncing construct is used to keep track of if the instance's state has been synced with the
2659
+ * other instances. A leader will immediately have the promise resolved. A follower will initially
2660
+ * be in a PENDING state, and resolve the the leader has sent the existing state, or reject if no
2661
+ * leader has responded before the timeout.
2662
+ */
2663
+ private syncing?;
2664
+ private channelEventName;
2665
+ private state;
2666
+ private channel?;
2667
+ private environment?;
2668
+ private listeners;
2669
+ private id;
2670
+ private actorId;
2671
+ private actorType;
2672
+ protected constructor(options: StoreOptions<State>, environmentOverrides?: EnvironmentOverrides);
2673
+ /** Creates a new instance of UniversalStore */
2674
+ static create<State = any, CustomEvent extends {
2675
+ type: string;
2676
+ payload?: any;
2677
+ } = {
2678
+ type: string;
2679
+ payload?: any;
2680
+ }>(options: StoreOptions<State>): UniversalStore<State, CustomEvent>;
2681
+ /** Gets the current state */
2682
+ getState: () => State;
2683
+ /**
2684
+ * Updates the store's state
2685
+ *
2686
+ * Either a new state or a state updater function can be passed to the method.
2687
+ */
2688
+ setState(updater: State | StateUpdater<State>): void;
2689
+ /**
2690
+ * Subscribes to store events
2691
+ *
2692
+ * @returns A function to unsubscribe
2693
+ */
2694
+ subscribe: {
2695
+ (listener: Listener<Event<State, CustomEvent>>): () => void;
2696
+ <EventType extends Event<State, CustomEvent>['type']>(eventType: EventType, listener: Listener<Extract<Event<State, CustomEvent>, {
2697
+ type: EventType;
2698
+ }>>): () => void;
2699
+ };
2700
+ /**
2701
+ * Subscribes to state changes
2702
+ *
2703
+ * @returns Unsubscribe function
2704
+ */
2705
+ onStateChange(listener: (state: State, previousState: State, eventInfo: EventInfo) => void): () => void;
2706
+ /** Sends a custom event to the other stores */
2707
+ send: (event: CustomEvent) => void;
2708
+ private emitToChannel;
2709
+ private prepareThis;
2710
+ private emitToListeners;
2711
+ private handleChannelEvents;
2712
+ private debug;
2713
+ }
2714
+
2526
2715
  type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
2527
2716
  type StatusTypeId = string;
2528
2717
  type StatusByTypeId = Record<StatusTypeId, Status>;
@@ -2792,4 +2981,56 @@ type UseTestProviderStore = <T = TestProviderStateByProviderId>(
2792
2981
  */
2793
2982
  selector?: (state: TestProviderStateByProviderId) => T) => T;
2794
2983
 
2795
- export { type API_ActiveTabsType, type API_BaseEntry, type API_ComponentEntry, type API_ComposedRef, type API_ComposedRefUpdate, type API_DocsEntry, type API_FilterFunction, type API_GroupEntry, type API_HashEntry, type API_IframeRenderer, type API_IndexHash, type API_Layout, type API_LeafEntry, type API_LoadedRefData, type API_MatchOptions, type API_Notification, type API_OptionsData, type API_PanelPositions, type API_PreparedIndexEntry, type API_PreparedStoryIndex, type API_Provider, type API_ProviderData, type API_RefId, type API_RefUrl, type API_Refs, type API_ReleaseNotes, type API_RenderOptions, type API_RootEntry, type API_RouteOptions, type API_SetRefData, type API_Settings, type API_SidebarOptions, type API_StateMerger, type API_StoryEntry, type API_StoryMapper, type API_UI, type API_UIOptions, type API_UnknownEntries, type API_Version, type API_Versions$1 as API_Versions, type API_ViewMode, type Addon_AddStoryArgs, type Addon_Annotations, type Addon_ArgType, type Addon_ArgsStoryFn, type Addon_BaseAnnotations, type Addon_BaseDecorators, type Addon_BaseMeta, type Addon_BaseStoryFn, type Addon_BaseStoryObject, type Addon_BaseType, type Addon_ClientApiAddon, type Addon_ClientApiAddons, type Addon_ClientApiReturnFn, type Addon_ClientStoryApi, type Addon_Collection, type Addon_Comparator, type Addon_Config, type Addon_DecoratorFunction, type Addon_Elements, type Addon_LegacyStoryFn, type Addon_LoadFn, type Addon_Loadable, type Addon_Loader, type Addon_LoaderFunction, type Addon_Loaders, type Addon_MakeDecoratorResult, type Addon_OptionsParameter, type Addon_OptionsParameterV7, type Addon_PageType, type Addon_PartialStoryFn, type Addon_RenderOptions, type Addon_RequireContext, type Addon_SidebarBottomType, type Addon_SidebarTopType, type Addon_StoryApi, type Addon_StoryContext, type Addon_StoryContextUpdate, type Addon_StoryFn, type Addon_StorySortComparator, type Addon_StorySortComparatorV7, type Addon_StorySortMethod, type Addon_StorySortObjectParameter, type Addon_StorySortParameter, type Addon_StorySortParameterV7, type Addon_StoryWrapper, type Addon_TestProviderState, type Addon_TestProviderType, type Addon_ToolbarConfig, type Addon_Type, type Addon_Types, Addon_TypesEnum, type Addon_TypesMapping, type Addon_WrapperSettings, type Addon_WrapperType, type Addons_ArgTypes, type BaseIndexEntry, type BaseIndexInput, type BaseStory, type BoundStory, type Builder, type BuilderName, type BuilderOptions, type BuilderResult, type BuilderStats, type Builder_EnvsRaw, type Builder_Unpromise, type Builder_WithRequiredProperty, type CLIBaseOptions, type CLIOptions, type CSFFile, type CompatibleString, type ComposeStoryFn, type ComposedStoryFn, type CoreCommon_AddonEntry, type CoreCommon_AddonInfo, type CoreCommon_OptionsEntry, type CoreCommon_ResolvedAddonPreset, type CoreCommon_ResolvedAddonVirtual, type CoreCommon_StorybookInfo, type CoreConfig, type DocsContextProps, type DocsIndexEntry, type DocsIndexInput, type DocsOptions, type DocsPreparedPayload, type DocsRenderFunction, type Entry, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, type ModuleExport, type ModuleExports, type ModuleImportFn, type NamedOrDefaultProjectAnnotations, type NormalizedComponentAnnotations, type NormalizedProjectAnnotations, type NormalizedStoriesSpecifier, type NormalizedStoryAnnotations, type Options, type PackageJson, type PartialArgsStoryFn, type Path, type PreparedMeta, type PreparedStory, type Preset, type PresetConfig, type PresetProperty, type PresetPropertyFn, type PresetValue, type Presets, type PreviewAnnotation, type ProjectAnnotations, type Ref, type RenderContext, type RenderContextCallbacks, type RenderToCanvas, type Renderer, type RendererName, type ResolvedModuleExport, type ResolvedModuleExportFromType, type ResolvedModuleExportType, type SetGlobalsPayload, type SetStoriesPayload, type SetStoriesStory, type SetStoriesStoryData, type Stats, type Status, type StatusByTypeId, type StatusStore, type StatusStoreByTypeId, type StatusTypeId, type StatusValue, type StatusesByStoryIdAndTypeId, type Store_CSFExports, type StoriesEntry, type StoriesSpecifier, type StoriesWithPartialProps, type StoryIndex, type StoryIndexEntry, type StoryIndexInput, type StoryIndexV2, type StoryIndexV3, type StoryPreparedPayload, type StoryRenderOptions, type StorybookConfig, type StorybookConfigOptions, type StorybookConfigRaw, type StorybookInternalParameters, type StorybookParameters, type SupportedFrameworks, type SupportedRenderers, type TagOptions, type TagsOptions, type TeardownRenderToCanvas, type TestBuildConfig, type TestBuildFlags, type TestProviderId, type TestProviderState, type TestProviderStoreById, type TypescriptOptions, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };
2984
+ /**
2985
+ * A mock universal store that can be used when testing code that relies on a universal store. It
2986
+ * functions exactly like a normal universal store, with a few exceptions:
2987
+ *
2988
+ * - It is fully isolated, meaning that it doesn't interact with any channel, and it is always a
2989
+ * leader.
2990
+ *
2991
+ * If the second testUtils argument is provided, all the public methods are spied on, so they can be
2992
+ * asserted.
2993
+ *
2994
+ * When a mock store is re-used across tests (eg. in stories), you manually need to reset the state
2995
+ * after each test.
2996
+ *
2997
+ * @example
2998
+ *
2999
+ * ```ts
3000
+ * import * as testUtils from 'storybook/test'; // in stories
3001
+ * import { vi as testUtils } from 'vitest'; // ... or in Vitest tests
3002
+ *
3003
+ * const initialState = { ... };
3004
+ * const store = new MockUniversalStore({ initialState }, testUtils);
3005
+ *
3006
+ * export default {
3007
+ * title: 'My story',
3008
+ * beforeEach: () => {
3009
+ * return () => {
3010
+ * store.setState(initialState);
3011
+ * };
3012
+ * }
3013
+ * }
3014
+ * ```
3015
+ */
3016
+ declare class MockUniversalStore<State, CustomEvent extends {
3017
+ type: string;
3018
+ payload?: any;
3019
+ } = {
3020
+ type: string;
3021
+ payload?: any;
3022
+ }> extends UniversalStore<State, CustomEvent> {
3023
+ private testUtils;
3024
+ constructor(options: StoreOptions<State>, testUtils?: any);
3025
+ /** Create a mock universal store. This is just an alias for the constructor */
3026
+ static create<State = any, CustomEvent extends {
3027
+ type: string;
3028
+ payload?: any;
3029
+ } = {
3030
+ type: string;
3031
+ payload?: any;
3032
+ }>(options: StoreOptions<State>, testUtils?: any): MockUniversalStore<State, CustomEvent>;
3033
+ unsubscribeAll(): void;
3034
+ }
3035
+
3036
+ export { type API_ActiveTabsType, type API_BaseEntry, type API_ComponentEntry, type API_ComposedRef, type API_ComposedRefUpdate, type API_DocsEntry, type API_FilterFunction, type API_GroupEntry, type API_HashEntry, type API_IframeRenderer, type API_IndexHash, type API_Layout, type API_LeafEntry, type API_LoadedRefData, type API_MatchOptions, type API_Notification, type API_OptionsData, type API_PanelPositions, type API_PreparedIndexEntry, type API_PreparedStoryIndex, type API_Provider, type API_ProviderData, type API_RefId, type API_RefUrl, type API_Refs, type API_ReleaseNotes, type API_RenderOptions, type API_RootEntry, type API_RouteOptions, type API_SetRefData, type API_Settings, type API_SidebarOptions, type API_StateMerger, type API_StoryEntry, type API_StoryMapper, type API_UI, type API_UIOptions, type API_UnknownEntries, type API_Version, type API_Versions$1 as API_Versions, type API_ViewMode, type Actor, type Addon_AddStoryArgs, type Addon_Annotations, type Addon_ArgType, type Addon_ArgsStoryFn, type Addon_BaseAnnotations, type Addon_BaseDecorators, type Addon_BaseMeta, type Addon_BaseStoryFn, type Addon_BaseStoryObject, type Addon_BaseType, type Addon_ClientApiAddon, type Addon_ClientApiAddons, type Addon_ClientApiReturnFn, type Addon_ClientStoryApi, type Addon_Collection, type Addon_Comparator, type Addon_Config, type Addon_DecoratorFunction, type Addon_Elements, type Addon_LegacyStoryFn, type Addon_LoadFn, type Addon_Loadable, type Addon_Loader, type Addon_LoaderFunction, type Addon_Loaders, type Addon_MakeDecoratorResult, type Addon_OptionsParameter, type Addon_OptionsParameterV7, type Addon_PageType, type Addon_PartialStoryFn, type Addon_RenderOptions, type Addon_RequireContext, type Addon_StoryApi, type Addon_StoryContext, type Addon_StoryContextUpdate, type Addon_StoryFn, type Addon_StorySortComparator, type Addon_StorySortComparatorV7, type Addon_StorySortMethod, type Addon_StorySortObjectParameter, type Addon_StorySortParameter, type Addon_StorySortParameterV7, type Addon_StoryWrapper, type Addon_TestProviderState, type Addon_TestProviderType, type Addon_ToolbarConfig, type Addon_Type, type Addon_Types, Addon_TypesEnum, type Addon_TypesMapping, type Addon_WrapperSettings, type Addon_WrapperType, type Addons_ArgTypes, type BaseIndexEntry, type BaseIndexInput, type BaseStory, type BoundStory, type Builder, type BuilderName, type BuilderOptions, type BuilderResult, type BuilderStats, type Builder_EnvsRaw, type Builder_Unpromise, type Builder_WithRequiredProperty, type CLIBaseOptions, type CLIOptions, type CSFFile, type CompatibleString, type ComposeStoryFn, type ComposedStoryFn, type CoreCommon_AddonEntry, type CoreCommon_AddonInfo, type CoreCommon_OptionsEntry, type CoreCommon_ResolvedAddonPreset, type CoreCommon_ResolvedAddonVirtual, type CoreCommon_StorybookInfo, type CoreConfig, type DocsContextProps, type DocsIndexEntry, type DocsIndexInput, type DocsOptions, type DocsPreparedPayload, type DocsRenderFunction, type Entry, type Event, type EventInfo, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, MockUniversalStore, type ModuleExport, type ModuleExports, type ModuleImportFn, type NamedOrDefaultProjectAnnotations, type NormalizedComponentAnnotations, type NormalizedProjectAnnotations, type NormalizedStoriesSpecifier, type NormalizedStoryAnnotations, type Options, type PackageJson, type PartialArgsStoryFn, type Path, type PreparedMeta, type PreparedStory, type Preset, type PresetConfig, type PresetProperty, type PresetPropertyFn, type PresetValue, type Presets, type PreviewAnnotation, type ProjectAnnotations, type Ref, type RenderContext, type RenderContextCallbacks, type RenderToCanvas, type Renderer, type RendererName, type ResolvedModuleExport, type ResolvedModuleExportFromType, type ResolvedModuleExportType, type SetGlobalsPayload, type SetStoriesPayload, type SetStoriesStory, type SetStoriesStoryData, type Stats, type Status, type StatusByTypeId, type StatusStore, type StatusStoreByTypeId, type StatusTypeId, type StatusValue, type StatusesByStoryIdAndTypeId, type StoreOptions, type Store_CSFExports, type StoriesEntry, type StoriesSpecifier, type StoriesWithPartialProps, type StoryIndex, type StoryIndexEntry, type StoryIndexInput, type StoryIndexV2, type StoryIndexV3, type StoryPreparedPayload, type StoryRenderOptions, type StorybookConfig, type StorybookConfigOptions, type StorybookConfigRaw, type StorybookInternalParameters, type StorybookParameters, type SupportedFrameworks, type SupportedRenderers, type TagOptions, type TagsOptions, type TeardownRenderToCanvas, type TestBuildConfig, type TestBuildFlags, type TestProviderId, type TestProviderState, type TestProviderStateByProviderId, type TestProviderStoreById, type TypescriptOptions, UniversalStore, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };
@@ -1,7 +1,6 @@
1
1
  // src/types/modules/addons.ts
2
2
  var r = /* @__PURE__ */ ((e) => (e.TAB = "tab", e.PANEL = "panel", e.TOOL = "tool", e.TOOLEXTRA = "toolextra", e.PREVIEW = "preview", e.experimental_PAGE =
3
- "page", e.experimental_SIDEBAR_BOTTOM = "sidebar-bottom", e.experimental_SIDEBAR_TOP = "sidebar-top", e.experimental_TEST_PROVIDER = "test-p\
4
- rovider", e))(r || {});
3
+ "page", e.experimental_TEST_PROVIDER = "test-provider", e))(r || {});
5
4
  export {
6
5
  r as Addon_TypesEnum
7
6
  };
@@ -19,7 +19,6 @@ interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotati
19
19
  unmount: () => void;
20
20
  };
21
21
  renderToCanvas?: RenderToCanvas<TRenderer>;
22
- renderToDOM?: RenderToCanvas<TRenderer>;
23
22
  }
24
23
  declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
25
24
  showMain: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook",
3
- "version": "9.0.0-alpha.10",
3
+ "version": "9.0.0-alpha.12",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -22,9 +22,9 @@
22
22
  "sideEffects": false,
23
23
  "type": "module",
24
24
  "imports": {
25
- "#manager-status-store": {
26
- "storybook": "./src/manager/status-store.mock.ts",
27
- "default": "./src/manager/status-store.ts"
25
+ "#manager-stores": {
26
+ "storybook": "./src/manager/manager-stores.mock.ts",
27
+ "default": "./src/manager/manager-stores.ts"
28
28
  },
29
29
  "#utils": {
30
30
  "storybook": "./template/stories/utils.mock.ts",
@@ -117,6 +117,19 @@
117
117
  "types": "./dist/actions/decorator.d.ts",
118
118
  "import": "./dist/actions/decorator.js"
119
119
  },
120
+ "./internal/component-testing": {
121
+ "types": "./dist/component-testing/index.d.ts",
122
+ "import": "./dist/component-testing/index.js",
123
+ "require": "./dist/component-testing/index.cjs"
124
+ },
125
+ "./internal/component-testing/preview": {
126
+ "types": "./dist/component-testing/preview.d.ts",
127
+ "import": "./dist/component-testing/preview.js",
128
+ "require": "./dist/component-testing/preview.cjs"
129
+ },
130
+ "./internal/component-testing/manager": {
131
+ "import": "./dist/component-testing/manager.js"
132
+ },
120
133
  "./internal/viewport": {
121
134
  "types": "./dist/viewport/index.d.ts",
122
135
  "import": "./dist/viewport/index.js",
@@ -370,6 +383,12 @@
370
383
  "actions/decorator": [
371
384
  "./dist/actions/decorator.d.ts"
372
385
  ],
386
+ "internal/component-testing": [
387
+ "./dist/component-testing/index.d.ts"
388
+ ],
389
+ "internal/component-testing/preview": [
390
+ "./dist/component-testing/preview.d.ts"
391
+ ],
373
392
  "internal/viewport": [
374
393
  "./dist/viewport/index.d.ts"
375
394
  ],
@@ -525,6 +544,7 @@
525
544
  "@babel/preset-react": "^7.26.3",
526
545
  "@babel/traverse": "^7.26.9",
527
546
  "@babel/types": "^7.26.8",
547
+ "@devtools-ds/object-inspector": "^1.1.2",
528
548
  "@discoveryjs/json-ext": "^0.5.3",
529
549
  "@emotion/cache": "^11.14.0",
530
550
  "@emotion/is-prop-valid": "^1.3.1",
@@ -633,6 +653,7 @@
633
653
  "slash": "^5.0.0",
634
654
  "source-map": "^0.7.4",
635
655
  "store2": "^2.14.2",
656
+ "strip-ansi": "^7.1.0",
636
657
  "strip-json-comments": "^5.0.1",
637
658
  "telejson": "^7.2.0",
638
659
  "tiny-invariant": "^1.3.1",