storybook 9.0.0-alpha.9 → 9.0.0-beta.1

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 (140) hide show
  1. package/assets/docs/addon-backgrounds.gif +0 -0
  2. package/assets/docs/addon-controls-args-annotated.png +0 -0
  3. package/assets/docs/addon-controls-args-background-color.png +0 -0
  4. package/assets/docs/addon-controls-args-background-string.png +0 -0
  5. package/assets/docs/addon-controls-args-docs.png +0 -0
  6. package/assets/docs/addon-controls-args-logging.png +0 -0
  7. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  8. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  9. package/assets/docs/addon-controls-args-reflow.png +0 -0
  10. package/assets/docs/addon-controls-args-template.png +0 -0
  11. package/assets/docs/addon-controls-expanded.png +0 -0
  12. package/assets/docs/addon-controls-hero.gif +0 -0
  13. package/assets/docs/addon-controls-install.png +0 -0
  14. package/assets/docs/hero.gif +0 -0
  15. package/assets/docs/highlight.png +0 -0
  16. package/assets/docs/viewport.png +0 -0
  17. package/assets/server/base-preview-head.html +1 -3
  18. package/bin/index.cjs +2 -2
  19. package/dist/actions/decorator.js +67 -72
  20. package/dist/actions/index.cjs +27 -31
  21. package/dist/actions/index.d.ts +0 -3
  22. package/dist/actions/index.js +27 -31
  23. package/dist/actions/preview.cjs +23 -27
  24. package/dist/actions/preview.d.ts +0 -1
  25. package/dist/actions/preview.js +19 -23
  26. package/dist/babel/index.cjs +822 -816
  27. package/dist/babel/index.js +822 -816
  28. package/dist/backgrounds/index.cjs +148 -0
  29. package/dist/backgrounds/index.d.ts +91 -0
  30. package/dist/backgrounds/index.js +130 -0
  31. package/dist/backgrounds/preview.cjs +143 -0
  32. package/dist/backgrounds/preview.d.ts +54 -0
  33. package/dist/backgrounds/preview.js +127 -0
  34. package/dist/bin/index.cjs +73 -92
  35. package/dist/bin/index.js +66 -85
  36. package/dist/builder-manager/index.cjs +316 -296
  37. package/dist/builder-manager/index.js +567 -547
  38. package/dist/channels/index.cjs +1020 -950
  39. package/dist/channels/index.js +1256 -1201
  40. package/dist/cli/bin/index.cjs +198 -198
  41. package/dist/cli/bin/index.js +204 -204
  42. package/dist/cli/index.cjs +61735 -7589
  43. package/dist/cli/index.d.ts +24 -20
  44. package/dist/cli/index.js +61776 -7630
  45. package/dist/common/index.cjs +16133 -9095
  46. package/dist/common/index.d.ts +32 -24
  47. package/dist/common/index.js +16227 -9183
  48. package/dist/component-testing/index.cjs +23 -0
  49. package/dist/component-testing/index.d.ts +3 -0
  50. package/dist/component-testing/index.js +5 -0
  51. package/dist/component-testing/preview.cjs +40 -0
  52. package/dist/component-testing/preview.d.ts +5 -0
  53. package/dist/component-testing/preview.js +25 -0
  54. package/dist/components/index.cjs +6479 -13005
  55. package/dist/components/index.d.ts +8 -257
  56. package/dist/components/index.js +6160 -18689
  57. package/dist/controls/decorator.d.ts +5 -0
  58. package/dist/controls/decorator.js +8 -0
  59. package/dist/controls/index.cjs +26 -0
  60. package/dist/controls/index.d.ts +39 -0
  61. package/dist/controls/index.js +6 -0
  62. package/dist/controls/preview.cjs +26 -0
  63. package/dist/controls/preview.d.ts +54 -0
  64. package/dist/controls/preview.js +9 -0
  65. package/dist/core-events/index.cjs +91 -106
  66. package/dist/core-events/index.d.ts +2 -80
  67. package/dist/core-events/index.js +79 -94
  68. package/dist/core-server/index.cjs +12409 -12231
  69. package/dist/core-server/index.d.ts +32 -23
  70. package/dist/core-server/index.js +12567 -12389
  71. package/dist/core-server/presets/common-manager.css +170 -0
  72. package/dist/core-server/presets/common-manager.js +12153 -12
  73. package/dist/core-server/presets/common-preset.cjs +3004 -3151
  74. package/dist/core-server/presets/common-preset.js +2833 -2981
  75. package/dist/csf/index.d.ts +1 -3
  76. package/dist/csf-tools/index.cjs +412 -403
  77. package/dist/csf-tools/index.d.ts +0 -4
  78. package/dist/csf-tools/index.js +410 -401
  79. package/dist/docs-tools/index.cjs +2569 -575
  80. package/dist/docs-tools/index.js +2565 -564
  81. package/dist/highlight/index.cjs +27 -0
  82. package/dist/highlight/index.d.ts +61 -0
  83. package/dist/highlight/index.js +7 -0
  84. package/dist/highlight/preview.cjs +535 -0
  85. package/dist/highlight/preview.d.ts +54 -0
  86. package/dist/highlight/preview.js +519 -0
  87. package/dist/instrumenter/index.cjs +1411 -1758
  88. package/dist/instrumenter/index.d.ts +8 -7
  89. package/dist/instrumenter/index.js +1325 -1663
  90. package/dist/manager/globals-module-info.cjs +22 -33
  91. package/dist/manager/globals-module-info.js +7 -18
  92. package/dist/manager/globals-runtime.js +45452 -49541
  93. package/dist/manager/runtime.js +4392 -3774
  94. package/dist/manager-api/index.cjs +2622 -2529
  95. package/dist/manager-api/index.d.ts +109 -114
  96. package/dist/manager-api/index.js +2603 -2475
  97. package/dist/manager-errors.js +41 -37
  98. package/dist/measure/index.cjs +476 -0
  99. package/dist/measure/index.d.ts +66 -0
  100. package/dist/measure/index.js +464 -0
  101. package/dist/measure/preview.cjs +466 -0
  102. package/dist/measure/preview.d.ts +59 -0
  103. package/dist/measure/preview.js +450 -0
  104. package/dist/outline/index.cjs +528 -0
  105. package/dist/outline/index.d.ts +66 -0
  106. package/dist/outline/index.js +500 -0
  107. package/dist/outline/preview.cjs +518 -0
  108. package/dist/outline/preview.d.ts +59 -0
  109. package/dist/outline/preview.js +486 -0
  110. package/dist/preview/runtime.js +41973 -38159
  111. package/dist/preview-api/index.cjs +1204 -1293
  112. package/dist/preview-api/index.d.ts +126 -178
  113. package/dist/preview-api/index.js +1614 -1685
  114. package/dist/preview-errors.cjs +65 -51
  115. package/dist/preview-errors.d.ts +6 -2
  116. package/dist/preview-errors.js +176 -142
  117. package/dist/server-errors.cjs +160 -113
  118. package/dist/server-errors.d.ts +12 -2
  119. package/dist/server-errors.js +157 -110
  120. package/dist/telemetry/index.cjs +374 -370
  121. package/dist/telemetry/index.d.ts +1 -1
  122. package/dist/telemetry/index.js +460 -456
  123. package/dist/test/index.cjs +1553 -1552
  124. package/dist/test/index.js +9603 -9514
  125. package/dist/test/preview.cjs +1906 -1905
  126. package/dist/test/preview.d.ts +0 -6
  127. package/dist/test/preview.js +3664 -3603
  128. package/dist/test/spy.cjs +65 -64
  129. package/dist/test/spy.js +59 -58
  130. package/dist/types/index.cjs +11 -12
  131. package/dist/types/index.d.ts +601 -334
  132. package/dist/types/index.js +1 -2
  133. package/dist/viewport/index.cjs +310 -0
  134. package/dist/viewport/index.d.ts +320 -0
  135. package/dist/viewport/index.js +290 -0
  136. package/dist/viewport/preview.cjs +35 -0
  137. package/dist/viewport/preview.d.ts +68 -0
  138. package/dist/viewport/preview.js +19 -0
  139. package/package.json +207 -12
  140. package/dist/actions/manager.js +0 -1196
@@ -1,12 +1,208 @@
1
1
  import { StoryId, StoryName, ComponentTitle, Tag as Tag$1, Parameters, Args, ArgTypes, ComponentId, StoryKind, Globals, GlobalTypes, InputType, StoryContext, PartialStoryFn, LegacyStoryFn, ArgsStoryFn, StoryFn, DecoratorFunction, LoaderFunction, Renderer as Renderer$1, ViewMode as ViewMode$1, StoryIdentifier, ProjectAnnotations as ProjectAnnotations$1, StrictArgTypes, StrictGlobalTypes, StepRunner, BeforeAll, ComponentAnnotations, StoryAnnotations, StoryContextForEnhancers, CleanupCallback, Canvas, StoryAnnotationsOrFn, AnnotatedStoryFn } from 'storybook/internal/csf';
2
2
  export { AfterEach, AnnotatedStoryFn, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, ProjectAnnotations as BaseProjectAnnotations, BeforeAll, BeforeEach, Canvas, CleanupCallback, ComponentAnnotations, ComponentId, ComponentTitle, Conditional, DecoratorApplicator, DecoratorFunction, GlobalTypes, Globals, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoaderFunction, Parameters, PartialStoryFn, PlayFunction, PlayFunctionContext, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryKind, StoryName, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, Tag } from 'storybook/internal/csf';
3
3
  import { ReactElement, FC, ReactNode, PropsWithChildren } from 'react';
4
- import { Addon_TestProviderType as Addon_TestProviderType$1, NormalizedProjectAnnotations as NormalizedProjectAnnotations$1, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn as ComposedStoryFn$1 } from 'storybook/internal/types';
5
4
  import { FileSystemCache } from 'storybook/internal/common';
6
5
  import { Server, IncomingMessage, ServerResponse } from 'http';
7
6
  import { Server as Server$1 } from 'net';
7
+ import { NormalizedProjectAnnotations as NormalizedProjectAnnotations$1, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn as ComposedStoryFn$1 } from 'storybook/internal/types';
8
8
  import { Channel as Channel$1 } from 'storybook/internal/channels';
9
9
 
10
+ /**
11
+ * A URL pathname, beginning with a /.
12
+ *
13
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
14
+ */
15
+ declare type Pathname = string;
16
+ /**
17
+ * A URL search string, beginning with a ?.
18
+ *
19
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
20
+ */
21
+ declare type Search = string;
22
+ /**
23
+ * A URL fragment identifier, beginning with a #.
24
+ *
25
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
26
+ */
27
+ declare type Hash = string;
28
+ /**
29
+ * A unique string associated with a location. May be used to safely store
30
+ * and retrieve data in some other storage API, like `localStorage`.
31
+ *
32
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
33
+ */
34
+ declare type Key = string;
35
+ /**
36
+ * The pathname, search, and hash values of a URL.
37
+ */
38
+ interface Path$1 {
39
+ /**
40
+ * A URL pathname, beginning with a /.
41
+ *
42
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
43
+ */
44
+ pathname: Pathname;
45
+ /**
46
+ * A URL search string, beginning with a ?.
47
+ *
48
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
49
+ */
50
+ search: Search;
51
+ /**
52
+ * A URL fragment identifier, beginning with a #.
53
+ *
54
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
55
+ */
56
+ hash: Hash;
57
+ }
58
+ /**
59
+ * An entry in a history stack. A location contains information about the
60
+ * URL path, as well as possibly some arbitrary state and a key.
61
+ *
62
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location
63
+ */
64
+ interface Location extends Path$1 {
65
+ /**
66
+ * A value of arbitrary data associated with this location.
67
+ *
68
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.state
69
+ */
70
+ state: unknown;
71
+ /**
72
+ * A unique string associated with this location. May be used to safely store
73
+ * and retrieve data in some other storage API, like `localStorage`.
74
+ *
75
+ * Note: This value is always "default" on the initial location.
76
+ *
77
+ * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
78
+ */
79
+ key: Key;
80
+ }
81
+ /**
82
+ * Describes a location that is the destination of some navigation, either via
83
+ * `history.push` or `history.replace`. May be either a URL or the pieces of a
84
+ * URL path.
85
+ */
86
+ declare type To = string | Partial<Path$1>;
87
+
88
+ interface NavigateOptions$1 {
89
+ replace?: boolean;
90
+ state?: any;
91
+ }
92
+
93
+ interface StoryData {
94
+ viewMode?: string;
95
+ storyId?: string;
96
+ refId?: string;
97
+ }
98
+
99
+ interface Other extends StoryData {
100
+ path: string;
101
+ singleStory?: boolean;
102
+ }
103
+ type NavigateOptions = NavigateOptions$1 & {
104
+ plain?: boolean;
105
+ };
106
+ type NavigateFunction = (to: To | number, options?: NavigateOptions) => void;
107
+ type RouterData = {
108
+ location: Partial<Location>;
109
+ navigate: NavigateFunction;
110
+ } & Other;
111
+ type RenderData = Pick<RouterData, 'location'> & Other;
112
+
113
+ interface ThemeVars extends ThemeVarsBase, ThemeVarsColors {
114
+ }
115
+ interface ThemeVarsBase {
116
+ base: 'light' | 'dark';
117
+ }
118
+ interface ThemeVarsColors {
119
+ colorPrimary: string;
120
+ colorSecondary: string;
121
+ appBg: string;
122
+ appContentBg: string;
123
+ appPreviewBg: string;
124
+ appBorderColor: string;
125
+ appBorderRadius: number;
126
+ fontBase: string;
127
+ fontCode: string;
128
+ textColor: string;
129
+ textInverseColor: string;
130
+ textMutedColor: string;
131
+ barTextColor: string;
132
+ barHoverColor: string;
133
+ barSelectedColor: string;
134
+ barBg: string;
135
+ buttonBg: string;
136
+ buttonBorder: string;
137
+ booleanBg: string;
138
+ booleanSelectedBg: string;
139
+ inputBg: string;
140
+ inputBorder: string;
141
+ inputTextColor: string;
142
+ inputBorderRadius: number;
143
+ brandTitle?: string;
144
+ brandUrl?: string;
145
+ brandImage?: string;
146
+ brandTarget?: string;
147
+ gridCellSize?: number;
148
+ }
149
+
150
+ type ChannelHandler = (event: ChannelEvent) => void;
151
+ interface ChannelTransport {
152
+ send(event: ChannelEvent, options?: any): void;
153
+ setHandler(handler: ChannelHandler): void;
154
+ }
155
+ interface ChannelEvent {
156
+ type: string;
157
+ from: string;
158
+ args: any[];
159
+ }
160
+ interface Listener$1 {
161
+ (...args: any[]): void;
162
+ }
163
+ interface ChannelArgsSingle {
164
+ transport?: ChannelTransport;
165
+ async?: boolean;
166
+ }
167
+ interface ChannelArgsMulti {
168
+ transports: ChannelTransport[];
169
+ async?: boolean;
170
+ }
171
+
172
+ declare class Channel {
173
+ readonly isAsync: boolean;
174
+ private sender;
175
+ private events;
176
+ private data;
177
+ private readonly transports;
178
+ constructor(input: ChannelArgsMulti);
179
+ constructor(input: ChannelArgsSingle);
180
+ get hasTransport(): boolean;
181
+ addListener(eventName: string, listener: Listener$1): void;
182
+ emit(eventName: string, ...args: any): void;
183
+ last(eventName: string): any;
184
+ eventNames(): string[];
185
+ listenerCount(eventName: string): number;
186
+ listeners(eventName: string): Listener$1[] | undefined;
187
+ once(eventName: string, listener: Listener$1): void;
188
+ removeAllListeners(eventName?: string): void;
189
+ removeListener(eventName: string, listener: Listener$1): void;
190
+ on(eventName: string, listener: Listener$1): void;
191
+ off(eventName: string, listener: Listener$1): void;
192
+ private handleEvent;
193
+ private onceListener;
194
+ }
195
+
196
+ interface Options$1 {
197
+ allowRegExp: boolean;
198
+ allowSymbol: boolean;
199
+ allowDate: boolean;
200
+ allowUndefined: boolean;
201
+ allowError: boolean;
202
+ maxDepth: number;
203
+ space: number | undefined;
204
+ }
205
+
10
206
  /**
11
207
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
12
208
 
@@ -690,250 +886,39 @@ declare namespace PackageJson$1 {
690
886
  */
691
887
  [additionalProperties: string]: unknown;
692
888
 
693
- /**
694
- When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
695
- */
696
- access?: 'public' | 'restricted';
697
-
698
- /**
699
- The base URL of the npm registry.
700
-
701
- Default: `'https://registry.npmjs.org/'`
702
- */
703
- registry?: string;
704
-
705
- /**
706
- The tag to publish the package under.
707
-
708
- Default: `'latest'`
709
- */
710
- tag?: string;
711
- }
712
- }
713
-
714
- /**
715
- Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
716
-
717
- @category File
718
- */
719
- type PackageJson$1 =
720
- PackageJson$1.PackageJsonStandard &
721
- PackageJson$1.NonStandardEntryPoints &
722
- PackageJson$1.TypeScriptConfiguration &
723
- PackageJson$1.YarnConfiguration &
724
- PackageJson$1.JSPMConfiguration;
725
-
726
- type DateNow = number;
727
- type TestProviderConfig = Addon_TestProviderType$1;
728
- type TestingModuleProgressReportProgress = {
729
- startedAt: DateNow;
730
- finishedAt?: DateNow;
731
- numTotalTests?: number;
732
- numPassedTests?: number;
733
- numFailedTests?: number;
734
- numPendingTests?: number;
735
- percentageCompleted?: number;
736
- };
737
-
738
- /**
739
- * A URL pathname, beginning with a /.
740
- *
741
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
742
- */
743
- declare type Pathname = string;
744
- /**
745
- * A URL search string, beginning with a ?.
746
- *
747
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
748
- */
749
- declare type Search = string;
750
- /**
751
- * A URL fragment identifier, beginning with a #.
752
- *
753
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
754
- */
755
- declare type Hash = string;
756
- /**
757
- * A unique string associated with a location. May be used to safely store
758
- * and retrieve data in some other storage API, like `localStorage`.
759
- *
760
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
761
- */
762
- declare type Key = string;
763
- /**
764
- * The pathname, search, and hash values of a URL.
765
- */
766
- interface Path$1 {
767
- /**
768
- * A URL pathname, beginning with a /.
769
- *
770
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
771
- */
772
- pathname: Pathname;
773
- /**
774
- * A URL search string, beginning with a ?.
775
- *
776
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
777
- */
778
- search: Search;
779
- /**
780
- * A URL fragment identifier, beginning with a #.
781
- *
782
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
783
- */
784
- hash: Hash;
785
- }
786
- /**
787
- * An entry in a history stack. A location contains information about the
788
- * URL path, as well as possibly some arbitrary state and a key.
789
- *
790
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location
791
- */
792
- interface Location extends Path$1 {
793
- /**
794
- * A value of arbitrary data associated with this location.
795
- *
796
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.state
797
- */
798
- state: unknown;
799
- /**
800
- * A unique string associated with this location. May be used to safely store
801
- * and retrieve data in some other storage API, like `localStorage`.
802
- *
803
- * Note: This value is always "default" on the initial location.
804
- *
805
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
806
- */
807
- key: Key;
808
- }
809
- /**
810
- * Describes a location that is the destination of some navigation, either via
811
- * `history.push` or `history.replace`. May be either a URL or the pieces of a
812
- * URL path.
813
- */
814
- declare type To = string | Partial<Path$1>;
815
-
816
- interface NavigateOptions$1 {
817
- replace?: boolean;
818
- state?: any;
819
- }
820
-
821
- interface StoryData {
822
- viewMode?: string;
823
- storyId?: string;
824
- refId?: string;
825
- }
826
-
827
- interface Other extends StoryData {
828
- path: string;
829
- singleStory?: boolean;
830
- }
831
- type NavigateOptions = NavigateOptions$1 & {
832
- plain?: boolean;
833
- };
834
- type NavigateFunction = (to: To | number, options?: NavigateOptions) => void;
835
- type RouterData = {
836
- location: Partial<Location>;
837
- navigate: NavigateFunction;
838
- } & Other;
839
- type RenderData = Pick<RouterData, 'location'> & Other;
840
-
841
- interface ThemeVars extends ThemeVarsBase, ThemeVarsColors {
842
- }
843
- interface ThemeVarsBase {
844
- base: 'light' | 'dark';
845
- }
846
- interface ThemeVarsColors {
847
- colorPrimary: string;
848
- colorSecondary: string;
849
- appBg: string;
850
- appContentBg: string;
851
- appPreviewBg: string;
852
- appBorderColor: string;
853
- appBorderRadius: number;
854
- fontBase: string;
855
- fontCode: string;
856
- textColor: string;
857
- textInverseColor: string;
858
- textMutedColor: string;
859
- barTextColor: string;
860
- barHoverColor: string;
861
- barSelectedColor: string;
862
- barBg: string;
863
- buttonBg: string;
864
- buttonBorder: string;
865
- booleanBg: string;
866
- booleanSelectedBg: string;
867
- inputBg: string;
868
- inputBorder: string;
869
- inputTextColor: string;
870
- inputBorderRadius: number;
871
- brandTitle?: string;
872
- brandUrl?: string;
873
- brandImage?: string;
874
- brandTarget?: string;
875
- gridCellSize?: number;
876
- }
889
+ /**
890
+ When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
891
+ */
892
+ access?: 'public' | 'restricted';
877
893
 
878
- type ChannelHandler = (event: ChannelEvent) => void;
879
- interface ChannelTransport {
880
- send(event: ChannelEvent, options?: any): void;
881
- setHandler(handler: ChannelHandler): void;
882
- }
883
- interface ChannelEvent {
884
- type: string;
885
- from: string;
886
- args: any[];
887
- }
888
- interface Listener {
889
- (...args: any[]): void;
890
- }
891
- interface ChannelArgsSingle {
892
- transport?: ChannelTransport;
893
- async?: boolean;
894
- }
895
- interface ChannelArgsMulti {
896
- transports: ChannelTransport[];
897
- async?: boolean;
898
- }
894
+ /**
895
+ The base URL of the npm registry.
899
896
 
900
- declare class Channel {
901
- readonly isAsync: boolean;
902
- private sender;
903
- private events;
904
- private data;
905
- private readonly transports;
906
- constructor(input: ChannelArgsMulti);
907
- constructor(input: ChannelArgsSingle);
908
- get hasTransport(): boolean;
909
- addListener(eventName: string, listener: Listener): void;
910
- emit(eventName: string, ...args: any): void;
911
- last(eventName: string): any;
912
- eventNames(): string[];
913
- listenerCount(eventName: string): number;
914
- listeners(eventName: string): Listener[] | undefined;
915
- once(eventName: string, listener: Listener): void;
916
- removeAllListeners(eventName?: string): void;
917
- removeListener(eventName: string, listener: Listener): void;
918
- on(eventName: string, listener: Listener): void;
919
- off(eventName: string, listener: Listener): void;
920
- private handleEvent;
921
- private onceListener;
922
- }
897
+ Default: `'https://registry.npmjs.org/'`
898
+ */
899
+ registry?: string;
923
900
 
924
- interface Options$1 {
925
- allowRegExp: boolean;
926
- allowFunction: boolean;
927
- allowSymbol: boolean;
928
- allowDate: boolean;
929
- allowUndefined: boolean;
930
- allowClass: boolean;
931
- allowError: boolean;
932
- maxDepth: number;
933
- space: number | undefined;
934
- lazyEval: boolean;
901
+ /**
902
+ The tag to publish the package under.
903
+
904
+ Default: `'latest'`
905
+ */
906
+ tag?: string;
907
+ }
935
908
  }
936
909
 
910
+ /**
911
+ Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
912
+
913
+ @category File
914
+ */
915
+ type PackageJson$1 =
916
+ PackageJson$1.PackageJsonStandard &
917
+ PackageJson$1.NonStandardEntryPoints &
918
+ PackageJson$1.TypeScriptConfiguration &
919
+ PackageJson$1.YarnConfiguration &
920
+ PackageJson$1.JSPMConfiguration;
921
+
937
922
  type ExportName = string;
938
923
  type MetaId = string;
939
924
  interface StoriesSpecifier {
@@ -1272,13 +1257,13 @@ interface TypescriptOptions {
1272
1257
  /**
1273
1258
  * Enables type checking within Storybook.
1274
1259
  *
1275
- * @default `false`
1260
+ * @default false
1276
1261
  */
1277
1262
  check: boolean;
1278
1263
  /**
1279
1264
  * Disable parsing TypeScript files through compiler.
1280
1265
  *
1281
- * @default `false`
1266
+ * @default false
1282
1267
  */
1283
1268
  skipCompiler: boolean;
1284
1269
  }
@@ -1298,13 +1283,6 @@ type CoreCommon_StorybookRefs = Record<string, {
1298
1283
  type DocsOptions = {
1299
1284
  /** What should we call the generated docs entries? */
1300
1285
  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
1286
  /** Only show doc entries in the side bar (usually set with the `--docs` CLI flag) */
1309
1287
  docsMode?: boolean;
1310
1288
  };
@@ -1358,19 +1336,85 @@ interface StorybookConfigRaw {
1358
1336
  staticDirs?: (DirectoryMapping | string)[];
1359
1337
  logLevel?: string;
1360
1338
  features?: {
1361
- /** Filter args with a "target" on the type from the render function (EXPERIMENTAL) */
1339
+ /**
1340
+ * Enable the integrated viewport addon
1341
+ *
1342
+ * @default true
1343
+ */
1344
+ viewport?: boolean;
1345
+ /**
1346
+ * Enable the integrated highlight addon
1347
+ *
1348
+ * @default true
1349
+ */
1350
+ highlight?: boolean;
1351
+ /**
1352
+ * Enable the integrated backgrounds addon
1353
+ *
1354
+ * @default true
1355
+ */
1356
+ backgrounds?: boolean;
1357
+ /**
1358
+ * Enable the integrated measure addon
1359
+ *
1360
+ * @default true
1361
+ */
1362
+ measure?: boolean;
1363
+ /**
1364
+ * Enable the integrated outline addon
1365
+ *
1366
+ * @default true
1367
+ */
1368
+ outline?: boolean;
1369
+ /**
1370
+ * Enable the integrated controls addon
1371
+ *
1372
+ * @default true
1373
+ */
1374
+ controls?: boolean;
1375
+ /**
1376
+ * Enable the integrated interactions addon
1377
+ *
1378
+ * @default true
1379
+ */
1380
+ interactions?: boolean;
1381
+ /**
1382
+ * Enable the integrated actions addon
1383
+ *
1384
+ * @default true
1385
+ */
1386
+ actions?: boolean;
1387
+ /**
1388
+ * @temporary This feature flag is a migration assistant, and is scheduled to be removed.
1389
+ *
1390
+ * Filter args with a "target" on the type from the render function (EXPERIMENTAL)
1391
+ */
1362
1392
  argTypeTargetsV7?: boolean;
1363
- /** Apply decorators from preview.js before decorators from addons or frameworks */
1393
+ /**
1394
+ * @temporary This feature flag is a migration assistant, and is scheduled to be removed.
1395
+ *
1396
+ * Apply decorators from preview.js before decorators from addons or frameworks
1397
+ */
1364
1398
  legacyDecoratorFileOrder?: boolean;
1365
1399
  /**
1400
+ * @temporary This feature flag is a migration assistant, and is scheduled to be removed.
1401
+ *
1366
1402
  * Disallow implicit actions during rendering. This will be the default in Storybook 8.
1367
1403
  *
1368
1404
  * This will make sure that your story renders the same no matter if docgen is enabled or not.
1369
1405
  */
1370
1406
  disallowImplicitActionsInRenderV8?: boolean;
1371
- /** Enable asynchronous component rendering in React renderer */
1407
+ /**
1408
+ * @temporary This feature flag is a migration assistant, and is scheduled to be removed.
1409
+ *
1410
+ * Enable asynchronous component rendering in React renderer
1411
+ */
1372
1412
  experimentalRSC?: boolean;
1373
- /** Set NODE_ENV to development in built Storybooks for better testability and debuggability */
1413
+ /**
1414
+ * @temporary This feature flag is a migration assistant, and is scheduled to be removed.
1415
+ *
1416
+ * Set NODE_ENV to development in built Storybooks for better testability and debuggability
1417
+ */
1374
1418
  developmentModeForBuild?: boolean;
1375
1419
  };
1376
1420
  build?: TestBuildConfig;
@@ -1711,8 +1755,6 @@ interface API_ProviderData<API> {
1711
1755
  }
1712
1756
  interface API_Provider<API> {
1713
1757
  channel?: Channel;
1714
- /** @deprecated Will be removed in 8.0, please use channel instead */
1715
- serverChannel?: Channel;
1716
1758
  renderPreview?: API_IframeRenderer;
1717
1759
  handleAPI(api: API): void;
1718
1760
  getConfig(): {
@@ -1751,8 +1793,6 @@ interface API_Layout {
1751
1793
  panelPosition: API_PanelPositions;
1752
1794
  showTabs: boolean;
1753
1795
  showToolbar: boolean;
1754
- /** @deprecated, will be removed in 8.0 - this API no longer works */
1755
- isToolshown?: boolean;
1756
1796
  }
1757
1797
  interface API_UI {
1758
1798
  name?: string;
@@ -1777,14 +1817,6 @@ interface OnClickOptions {
1777
1817
  /** Function to dismiss the notification. */
1778
1818
  onDismiss: () => void;
1779
1819
  }
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
1820
  interface API_Notification {
1789
1821
  id: string;
1790
1822
  content: {
@@ -1793,7 +1825,7 @@ interface API_Notification {
1793
1825
  };
1794
1826
  duration?: number;
1795
1827
  link?: string;
1796
- icon?: React.ReactNode | DeprecatedIconType;
1828
+ icon?: React.ReactNode;
1797
1829
  onClear?: (options: OnClearOptions) => void;
1798
1830
  onClick?: (options: OnClickOptions) => void;
1799
1831
  }
@@ -1827,7 +1859,7 @@ type API_Refs = Record<string, API_ComposedRef>;
1827
1859
  type API_RefId = string;
1828
1860
  type API_RefUrl = string;
1829
1861
 
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>;
1862
+ type Addon_Types = Exclude<Addon_TypesEnum, Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
1831
1863
  interface Addon_ArgType<TArg = unknown> extends InputType {
1832
1864
  defaultValue?: TArg;
1833
1865
  }
@@ -2018,7 +2050,6 @@ interface Addon_BaseMeta<ComponentType> {
2018
2050
  *
2019
2051
  * Used by addons for automatic prop table generation and display of other component metadata.
2020
2052
  *
2021
- * @deprecated
2022
2053
  * @example
2023
2054
  *
2024
2055
  * ```ts
@@ -2044,7 +2075,7 @@ type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnRetur
2044
2075
  interface Addon_RenderOptions {
2045
2076
  active: boolean;
2046
2077
  }
2047
- type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_SidebarBottomType | Addon_SidebarTopType | Addon_TestProviderType<Addon_TestProviderState>;
2078
+ type Addon_Type = Addon_BaseType | Addon_PageType | Addon_WrapperType | Addon_TestProviderType;
2048
2079
  interface Addon_BaseType {
2049
2080
  /**
2050
2081
  * The title of the addon. This can be a simple string, but it can also be a
@@ -2060,7 +2091,7 @@ interface Addon_BaseType {
2060
2091
  * Addon_TypesEnum.PANEL;
2061
2092
  * ```
2062
2093
  */
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>;
2094
+ type: Exclude<Addon_Types, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2064
2095
  /**
2065
2096
  * The unique id of the addon.
2066
2097
  *
@@ -2147,63 +2178,20 @@ interface Addon_WrapperType {
2147
2178
  storyId: StoryId;
2148
2179
  }>>;
2149
2180
  }
2150
- /** @deprecated This doesn't do anything anymore and will be removed in Storybook 9.0. */
2151
- interface Addon_SidebarBottomType {
2152
- type: Addon_TypesEnum.experimental_SIDEBAR_BOTTOM;
2153
- /** The unique id of the tool. */
2154
- id: string;
2155
- /** A React.FunctionComponent. */
2156
- render: FC;
2157
- }
2158
- /** @deprecated This will be removed in Storybook 9.0. */
2159
- interface Addon_SidebarTopType {
2160
- type: Addon_TypesEnum.experimental_SIDEBAR_TOP;
2161
- /** The unique id of the tool. */
2162
- id: string;
2163
- /** A React.FunctionComponent. */
2164
- render: FC;
2165
- }
2166
- interface Addon_TestProviderType<Details extends {
2167
- [key: string]: any;
2168
- } = NonNullable<unknown>> {
2181
+ interface Addon_TestProviderType {
2169
2182
  type: Addon_TypesEnum.experimental_TEST_PROVIDER;
2170
2183
  /** The unique id of the test provider. */
2171
2184
  id: string;
2172
- name: string;
2173
- /** @deprecated Use render instead */
2174
- title?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
2175
- /** @deprecated Use render instead */
2176
- description?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
2177
- render?: (state: TestProviderConfig & Addon_TestProviderState<Details>) => ReactNode;
2185
+ render: () => ReactNode;
2178
2186
  sidebarContextMenu?: (options: {
2179
2187
  context: API_HashEntry;
2180
- state: TestProviderConfig & Addon_TestProviderState<Details>;
2181
2188
  }) => ReactNode;
2182
- stateUpdater?: (state: TestProviderConfig & Addon_TestProviderState<Details>, update: Partial<Addon_TestProviderState<Details>>) => void | Partial<TestProviderConfig & Addon_TestProviderState<Details>>;
2183
- runnable?: boolean;
2184
2189
  }
2185
- type Addon_TestProviderState<Details extends {
2186
- [key: string]: any;
2187
- } = NonNullable<unknown>> = Pick<Addon_TestProviderType, 'runnable'> & {
2188
- progress?: TestingModuleProgressReportProgress;
2189
- details: Details;
2190
- cancellable: boolean;
2191
- cancelling: boolean;
2192
- running: boolean;
2193
- failed: boolean;
2194
- crashed: boolean;
2195
- error?: {
2196
- name: string;
2197
- message?: string;
2198
- };
2199
- };
2200
- type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_SIDEBAR_BOTTOM | Addon_TypesEnum.experimental_SIDEBAR_TOP | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2190
+ type Addon_TypeBaseNames = Exclude<Addon_TypesEnum, Addon_TypesEnum.PREVIEW | Addon_TypesEnum.experimental_PAGE | Addon_TypesEnum.experimental_TEST_PROVIDER>;
2201
2191
  interface Addon_TypesMapping extends Record<Addon_TypeBaseNames, Addon_BaseType> {
2202
2192
  [Addon_TypesEnum.PREVIEW]: Addon_WrapperType;
2203
2193
  [Addon_TypesEnum.experimental_PAGE]: Addon_PageType;
2204
- [Addon_TypesEnum.experimental_SIDEBAR_BOTTOM]: Addon_SidebarBottomType;
2205
- [Addon_TypesEnum.experimental_SIDEBAR_TOP]: Addon_SidebarTopType;
2206
- [Addon_TypesEnum.experimental_TEST_PROVIDER]: Addon_TestProviderType<Addon_TestProviderState>;
2194
+ [Addon_TypesEnum.experimental_TEST_PROVIDER]: Addon_TestProviderType;
2207
2195
  }
2208
2196
  type Addon_Loader<API> = (api: API) => void;
2209
2197
  interface Addon_Loaders<API> {
@@ -2252,18 +2240,6 @@ declare enum Addon_TypesEnum {
2252
2240
  * @unstable
2253
2241
  */
2254
2242
  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
2243
  /** This adds items to the Testing Module in the sidebar. */
2268
2244
  experimental_TEST_PROVIDER = "test-provider"
2269
2245
  }
@@ -2304,7 +2280,6 @@ interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotati
2304
2280
  unmount: () => void;
2305
2281
  };
2306
2282
  renderToCanvas?: RenderToCanvas<TRenderer>;
2307
- renderToDOM?: RenderToCanvas<TRenderer>;
2308
2283
  }
2309
2284
  type NamedExportsOrDefault<TExport> = TExport | {
2310
2285
  default: TExport;
@@ -2330,7 +2305,7 @@ type NormalizedStoryAnnotations<TRenderer extends Renderer = Renderer> = Omit<St
2330
2305
  id: StoryId;
2331
2306
  argTypes?: StrictArgTypes;
2332
2307
  name: StoryName;
2333
- userStoryFn?: StoryFn<TRenderer>;
2308
+ userStoryFn?: ArgsStoryFn<TRenderer>;
2334
2309
  decorators?: DecoratorFunction<TRenderer>[];
2335
2310
  loaders?: LoaderFunction<TRenderer>[];
2336
2311
  };
@@ -2342,7 +2317,7 @@ type CSFFile<TRenderer extends Renderer = Renderer> = {
2342
2317
  };
2343
2318
  type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhancers<TRenderer> & {
2344
2319
  moduleExport: ModuleExport;
2345
- originalStoryFn: StoryFn<TRenderer>;
2320
+ originalStoryFn: ArgsStoryFn<TRenderer>;
2346
2321
  undecoratedStoryFn: LegacyStoryFn<TRenderer>;
2347
2322
  unboundStoryFn: LegacyStoryFn<TRenderer>;
2348
2323
  applyLoaders: (context: StoryContext<TRenderer>) => Promise<StoryContext<TRenderer>['loaded']>;
@@ -2519,10 +2494,250 @@ interface ComposeStoryFn<TRenderer extends Renderer$1 = Renderer$1, TArgs extend
2519
2494
  (storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations$1<TRenderer>, exportsName?: string): ComposedStoryFn;
2520
2495
  }
2521
2496
 
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';
2497
+ type SupportedFrameworks = 'angular' | 'ember' | 'html-vite' | 'nextjs' | 'nextjs-vite' | 'preact-vite' | 'react-native-web-vite' | 'react-vite' | 'react-webpack5' | 'server-webpack5' | 'svelte-vite' | 'sveltekit' | 'vue3-vite' | 'web-components-vite' | 'qwik' | 'solid' | 'nuxt' | 'react-rsbuild' | 'vue3-rsbuild';
2523
2498
 
2524
2499
  type SupportedRenderers = 'react' | 'react-native' | 'vue3' | 'angular' | 'ember' | 'preact' | 'svelte' | 'qwik' | 'html' | 'web-components' | 'server' | 'solid' | 'nuxt';
2525
2500
 
2501
+ type EnvironmentType = (typeof UniversalStore.Environment)[keyof typeof UniversalStore.Environment];
2502
+ type StatusType = (typeof UniversalStore.Status)[keyof typeof UniversalStore.Status];
2503
+ type StateUpdater<TState> = (prevState: TState) => TState;
2504
+ type Actor = {
2505
+ id: string;
2506
+ type: (typeof UniversalStore.ActorType)[keyof typeof UniversalStore.ActorType];
2507
+ environment: EnvironmentType;
2508
+ };
2509
+ type EventInfo = {
2510
+ actor: Actor;
2511
+ forwardingActor?: Actor;
2512
+ };
2513
+ type Listener<TEvent> = (event: TEvent, eventInfo: EventInfo) => void;
2514
+ type BaseEvent = {
2515
+ type: string;
2516
+ payload?: any;
2517
+ };
2518
+ interface SetStateEvent<TState> extends BaseEvent {
2519
+ type: typeof UniversalStore.InternalEventType.SET_STATE;
2520
+ payload: {
2521
+ state: TState;
2522
+ previousState: TState;
2523
+ };
2524
+ }
2525
+ interface ExistingStateRequestEvent extends BaseEvent {
2526
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_REQUEST;
2527
+ payload: never;
2528
+ }
2529
+ interface ExistingStateResponseEvent<TState> extends BaseEvent {
2530
+ type: typeof UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE;
2531
+ payload: TState;
2532
+ }
2533
+ interface LeaderCreatedEvent extends BaseEvent {
2534
+ type: typeof UniversalStore.InternalEventType.LEADER_CREATED;
2535
+ payload: never;
2536
+ }
2537
+ interface FollowerCreatedEvent extends BaseEvent {
2538
+ type: typeof UniversalStore.InternalEventType.FOLLOWER_CREATED;
2539
+ payload: never;
2540
+ }
2541
+ type InternalEvent<TState> = SetStateEvent<TState> | ExistingStateRequestEvent | ExistingStateResponseEvent<TState> | FollowerCreatedEvent | LeaderCreatedEvent;
2542
+ type Event<TState, TEvent extends BaseEvent> = TEvent | InternalEvent<TState>;
2543
+ type ChannelLike = Pick<Channel$1, 'on' | 'off' | 'emit'>;
2544
+ type StoreOptions<TState> = {
2545
+ id: string;
2546
+ leader?: boolean;
2547
+ initialState?: TState;
2548
+ debug?: boolean;
2549
+ };
2550
+ type EnvironmentOverrides = {
2551
+ channel: ChannelLike;
2552
+ environment: EnvironmentType;
2553
+ };
2554
+
2555
+ /**
2556
+ * A universal store implementation that synchronizes state across different environments using a
2557
+ * channel-based communication.
2558
+ *
2559
+ * The store follows a leader-follower pattern where:
2560
+ *
2561
+ * - Leader: The main store instance that owns and manages the state
2562
+ * - Follower: Store instances that mirror the leader's state
2563
+ *
2564
+ * Features:
2565
+ *
2566
+ * - State synchronization across environments
2567
+ * - Event-based communication
2568
+ * - Type-safe state and custom events
2569
+ * - Subscription system for state changes and custom events
2570
+ *
2571
+ * @remarks
2572
+ * - The store must be created using the static `create()` method, not the constructor
2573
+ * - Follower stores will automatically sync with their leader's state. If they have initial state, it
2574
+ * will be replaced immediately when it has synced with the leader.
2575
+ *
2576
+ * @example
2577
+ *
2578
+ * ```typescript
2579
+ * interface MyState {
2580
+ * count: number;
2581
+ * }
2582
+ * interface MyCustomEvent {
2583
+ * type: 'INCREMENT';
2584
+ * payload: number;
2585
+ * }
2586
+ *
2587
+ * // Create a leader store
2588
+ * const leaderStore = UniversalStore.create<MyState, MyCustomEvent>({
2589
+ * id: 'my-store',
2590
+ * leader: true,
2591
+ * initialState: { count: 0 },
2592
+ * });
2593
+ *
2594
+ * // Create a follower store
2595
+ * const followerStore = UniversalStore.create<MyState, MyCustomEvent>({
2596
+ * id: 'my-store',
2597
+ * leader: false,
2598
+ * });
2599
+ * ```
2600
+ *
2601
+ * @template State - The type of state managed by the store
2602
+ * @template CustomEvent - Custom events that can be sent through the store. Must have a `type`
2603
+ * string and optional `payload`
2604
+ * @throws {Error} If constructed directly instead of using `create()`
2605
+ * @throws {Error} If created without setting a channel first
2606
+ * @throws {Error} If a follower is created with initial state
2607
+ * @throws {Error} If a follower cannot find its leader within 1 second
2608
+ */
2609
+ declare class UniversalStore<State, CustomEvent extends {
2610
+ type: string;
2611
+ payload?: any;
2612
+ } = {
2613
+ type: string;
2614
+ payload?: any;
2615
+ }> {
2616
+ /**
2617
+ * Defines the possible actor types in the store system
2618
+ *
2619
+ * @readonly
2620
+ */
2621
+ static readonly ActorType: {
2622
+ readonly LEADER: "LEADER";
2623
+ readonly FOLLOWER: "FOLLOWER";
2624
+ };
2625
+ /**
2626
+ * Defines the possible environments the store can run in
2627
+ *
2628
+ * @readonly
2629
+ */
2630
+ static readonly Environment: {
2631
+ readonly SERVER: "SERVER";
2632
+ readonly MANAGER: "MANAGER";
2633
+ readonly PREVIEW: "PREVIEW";
2634
+ readonly UNKNOWN: "UNKNOWN";
2635
+ readonly MOCK: "MOCK";
2636
+ };
2637
+ /**
2638
+ * Internal event types used for store synchronization
2639
+ *
2640
+ * @readonly
2641
+ */
2642
+ static readonly InternalEventType: {
2643
+ readonly EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST";
2644
+ readonly EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE";
2645
+ readonly SET_STATE: "__SET_STATE";
2646
+ readonly LEADER_CREATED: "__LEADER_CREATED";
2647
+ readonly FOLLOWER_CREATED: "__FOLLOWER_CREATED";
2648
+ };
2649
+ static readonly Status: {
2650
+ readonly UNPREPARED: "UNPREPARED";
2651
+ readonly SYNCING: "SYNCING";
2652
+ readonly READY: "READY";
2653
+ readonly ERROR: "ERROR";
2654
+ };
2655
+ protected static isInternalConstructing: boolean;
2656
+ /**
2657
+ * The preparation construct is used to keep track of all store's preparation state the promise is
2658
+ * resolved when the store is prepared with the static __prepare() method which will also change
2659
+ * the state from PENDING to RESOLVED
2660
+ */
2661
+ private static preparation;
2662
+ private static setupPreparationPromise;
2663
+ /** Enable debug logs for this store */
2664
+ debugging: boolean;
2665
+ /** The actor object representing the store instance with a unique ID and a type */
2666
+ get actor(): Actor;
2667
+ /**
2668
+ * The current state of the store, that signals both if the store is prepared by Storybook and
2669
+ * also - in the case of a follower - if the state has been synced with the leader's state.
2670
+ */
2671
+ get status(): StatusType;
2672
+ /**
2673
+ * A promise that resolves when the store is fully ready. A leader will be ready when the store
2674
+ * has been prepared by Storybook, which is almost instantly.
2675
+ *
2676
+ * A follower will be ready when the state has been synced with the leader's state, within a few
2677
+ * hundred milliseconds.
2678
+ */
2679
+ untilReady(): Promise<[{
2680
+ channel: ChannelLike;
2681
+ environment: EnvironmentType;
2682
+ }, void | undefined]>;
2683
+ /**
2684
+ * The syncing construct is used to keep track of if the instance's state has been synced with the
2685
+ * other instances. A leader will immediately have the promise resolved. A follower will initially
2686
+ * be in a PENDING state, and resolve the the leader has sent the existing state, or reject if no
2687
+ * leader has responded before the timeout.
2688
+ */
2689
+ private syncing?;
2690
+ private channelEventName;
2691
+ private state;
2692
+ private channel?;
2693
+ private environment?;
2694
+ private listeners;
2695
+ private id;
2696
+ private actorId;
2697
+ private actorType;
2698
+ protected constructor(options: StoreOptions<State>, environmentOverrides?: EnvironmentOverrides);
2699
+ /** Creates a new instance of UniversalStore */
2700
+ static create<State = any, CustomEvent extends {
2701
+ type: string;
2702
+ payload?: any;
2703
+ } = {
2704
+ type: string;
2705
+ payload?: any;
2706
+ }>(options: StoreOptions<State>): UniversalStore<State, CustomEvent>;
2707
+ /** Gets the current state */
2708
+ getState: () => State;
2709
+ /**
2710
+ * Updates the store's state
2711
+ *
2712
+ * Either a new state or a state updater function can be passed to the method.
2713
+ */
2714
+ setState(updater: State | StateUpdater<State>): void;
2715
+ /**
2716
+ * Subscribes to store events
2717
+ *
2718
+ * @returns A function to unsubscribe
2719
+ */
2720
+ subscribe: {
2721
+ (listener: Listener<Event<State, CustomEvent>>): () => void;
2722
+ <EventType extends Event<State, CustomEvent>['type']>(eventType: EventType, listener: Listener<Extract<Event<State, CustomEvent>, {
2723
+ type: EventType;
2724
+ }>>): () => void;
2725
+ };
2726
+ /**
2727
+ * Subscribes to state changes
2728
+ *
2729
+ * @returns Unsubscribe function
2730
+ */
2731
+ onStateChange(listener: (state: State, previousState: State, eventInfo: EventInfo) => void): () => void;
2732
+ /** Sends a custom event to the other stores */
2733
+ send: (event: CustomEvent) => void;
2734
+ private emitToChannel;
2735
+ private prepareThis;
2736
+ private emitToListeners;
2737
+ private handleChannelEvents;
2738
+ private debug;
2739
+ }
2740
+
2526
2741
  type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
2527
2742
  type StatusTypeId = string;
2528
2743
  type StatusByTypeId = Record<StatusTypeId, Status>;
@@ -2792,4 +3007,56 @@ type UseTestProviderStore = <T = TestProviderStateByProviderId>(
2792
3007
  */
2793
3008
  selector?: (state: TestProviderStateByProviderId) => T) => T;
2794
3009
 
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 };
3010
+ /**
3011
+ * A mock universal store that can be used when testing code that relies on a universal store. It
3012
+ * functions exactly like a normal universal store, with a few exceptions:
3013
+ *
3014
+ * - It is fully isolated, meaning that it doesn't interact with any channel, and it is always a
3015
+ * leader.
3016
+ *
3017
+ * If the second testUtils argument is provided, all the public methods are spied on, so they can be
3018
+ * asserted.
3019
+ *
3020
+ * When a mock store is re-used across tests (eg. in stories), you manually need to reset the state
3021
+ * after each test.
3022
+ *
3023
+ * @example
3024
+ *
3025
+ * ```ts
3026
+ * import * as testUtils from 'storybook/test'; // in stories
3027
+ * import { vi as testUtils } from 'vitest'; // ... or in Vitest tests
3028
+ *
3029
+ * const initialState = { ... };
3030
+ * const store = new MockUniversalStore({ initialState }, testUtils);
3031
+ *
3032
+ * export default {
3033
+ * title: 'My story',
3034
+ * beforeEach: () => {
3035
+ * return () => {
3036
+ * store.setState(initialState);
3037
+ * };
3038
+ * }
3039
+ * }
3040
+ * ```
3041
+ */
3042
+ declare class MockUniversalStore<State, CustomEvent extends {
3043
+ type: string;
3044
+ payload?: any;
3045
+ } = {
3046
+ type: string;
3047
+ payload?: any;
3048
+ }> extends UniversalStore<State, CustomEvent> {
3049
+ private testUtils;
3050
+ constructor(options: StoreOptions<State>, testUtils?: any);
3051
+ /** Create a mock universal store. This is just an alias for the constructor */
3052
+ static create<State = any, CustomEvent extends {
3053
+ type: string;
3054
+ payload?: any;
3055
+ } = {
3056
+ type: string;
3057
+ payload?: any;
3058
+ }>(options: StoreOptions<State>, testUtils?: any): MockUniversalStore<State, CustomEvent>;
3059
+ unsubscribeAll(): void;
3060
+ }
3061
+
3062
+ export { type API_ActiveTabsType, type API_BaseEntry, type API_ComponentEntry, type API_ComposedRef, type API_ComposedRefUpdate, type API_DocsEntry, type API_FilterFunction, type API_GroupEntry, type API_HashEntry, type API_IframeRenderer, type API_IndexHash, type API_Layout, type API_LeafEntry, type API_LoadedRefData, type API_MatchOptions, type API_Notification, type API_OptionsData, type API_PanelPositions, type API_PreparedIndexEntry, type API_PreparedStoryIndex, type API_Provider, type API_ProviderData, type API_RefId, type API_RefUrl, type API_Refs, type API_ReleaseNotes, type API_RenderOptions, type API_RootEntry, type API_RouteOptions, type API_SetRefData, type API_Settings, type API_SidebarOptions, type API_StateMerger, type API_StoryEntry, type API_StoryMapper, type API_UI, type API_UIOptions, type API_UnknownEntries, type API_Version, type API_Versions$1 as API_Versions, type API_ViewMode, type Actor, type Addon_AddStoryArgs, type Addon_Annotations, type Addon_ArgType, type Addon_ArgsStoryFn, type Addon_BaseAnnotations, type Addon_BaseDecorators, type Addon_BaseMeta, type Addon_BaseStoryFn, type Addon_BaseStoryObject, type Addon_BaseType, type Addon_ClientApiAddon, type Addon_ClientApiAddons, type Addon_ClientApiReturnFn, type Addon_ClientStoryApi, type Addon_Collection, type Addon_Comparator, type Addon_Config, type Addon_DecoratorFunction, type Addon_Elements, type Addon_LegacyStoryFn, type Addon_LoadFn, type Addon_Loadable, type Addon_Loader, type Addon_LoaderFunction, type Addon_Loaders, type Addon_MakeDecoratorResult, type Addon_OptionsParameter, type Addon_OptionsParameterV7, type Addon_PageType, type Addon_PartialStoryFn, type Addon_RenderOptions, type Addon_RequireContext, type Addon_StoryApi, type Addon_StoryContext, type Addon_StoryContextUpdate, type Addon_StoryFn, type Addon_StorySortComparator, type Addon_StorySortComparatorV7, type Addon_StorySortMethod, type Addon_StorySortObjectParameter, type Addon_StorySortParameter, type Addon_StorySortParameterV7, type Addon_StoryWrapper, type Addon_TestProviderType, type Addon_ToolbarConfig, type Addon_Type, type Addon_Types, Addon_TypesEnum, type Addon_TypesMapping, type Addon_WrapperSettings, type Addon_WrapperType, type Addons_ArgTypes, type BaseIndexEntry, type BaseIndexInput, type BaseStory, type BoundStory, type Builder, type BuilderName, type BuilderOptions, type BuilderResult, type BuilderStats, type Builder_EnvsRaw, type Builder_Unpromise, type Builder_WithRequiredProperty, type CLIBaseOptions, type CLIOptions, type CSFFile, type CompatibleString, type ComposeStoryFn, type ComposedStoryFn, type CoreCommon_AddonEntry, type CoreCommon_AddonInfo, type CoreCommon_OptionsEntry, type CoreCommon_ResolvedAddonPreset, type CoreCommon_ResolvedAddonVirtual, type CoreCommon_StorybookInfo, type CoreConfig, type DocsContextProps, type DocsIndexEntry, type DocsIndexInput, type DocsOptions, type DocsPreparedPayload, type DocsRenderFunction, type Entry, type Event, type EventInfo, type GlobalsUpdatedPayload, type IndexEntry, type IndexEntryLegacy, type IndexInput, type IndexInputStats, type IndexedCSFFile, type IndexedStory, type Indexer, type IndexerOptions, type LoadOptions, type LoadedPreset, type Middleware, MockUniversalStore, type ModuleExport, type ModuleExports, type ModuleImportFn, type NamedOrDefaultProjectAnnotations, type NormalizedComponentAnnotations, type NormalizedProjectAnnotations, type NormalizedStoriesSpecifier, type NormalizedStoryAnnotations, type Options, type PackageJson, type PartialArgsStoryFn, type Path, type PreparedMeta, type PreparedStory, type Preset, type PresetConfig, type PresetProperty, type PresetPropertyFn, type PresetValue, type Presets, type PreviewAnnotation, type ProjectAnnotations, type Ref, type RenderContext, type RenderContextCallbacks, type RenderToCanvas, type Renderer, type RendererName, type ResolvedModuleExport, type ResolvedModuleExportFromType, type ResolvedModuleExportType, type SetGlobalsPayload, type SetStoriesPayload, type SetStoriesStory, type SetStoriesStoryData, type Stats, type Status, type StatusByTypeId, type StatusStore, type StatusStoreByTypeId, type StatusTypeId, type StatusValue, type StatusesByStoryIdAndTypeId, type StoreOptions, type Store_CSFExports, type StoriesEntry, type StoriesSpecifier, type StoriesWithPartialProps, type StoryIndex, type StoryIndexEntry, type StoryIndexInput, type StoryIndexV2, type StoryIndexV3, type StoryPreparedPayload, type StoryRenderOptions, type StorybookConfig, type StorybookConfigOptions, type StorybookConfigRaw, type StorybookInternalParameters, type StorybookParameters, type SupportedFrameworks, type SupportedRenderers, type TagOptions, type TagsOptions, type TeardownRenderToCanvas, type TestBuildConfig, type TestBuildFlags, type TestProviderId, type TestProviderState, type TestProviderStateByProviderId, type TestProviderStoreById, type TypescriptOptions, UniversalStore, type UseStatusStore, type UseTestProviderStore, type V3CompatIndexEntry, type VersionCheck, type ViewMode, type WebRenderer };