storybook 10.1.0-alpha.12 → 10.1.0-alpha.13

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 (87) hide show
  1. package/dist/_browser-chunks/{chunk-74YHFU5B.js → chunk-2XZMBGTA.js} +1 -1
  2. package/dist/_browser-chunks/{chunk-EBHB6RPS.js → chunk-FQ7SLVLR.js} +6 -1
  3. package/dist/_browser-chunks/{chunk-X3DUQ5RA.js → chunk-GFY5R5EY.js} +1 -1
  4. package/dist/_node-chunks/{builder-manager-YUOHSIUB.js → builder-manager-DWDUVXZM.js} +27 -22
  5. package/dist/_node-chunks/{chunk-B6JWY6PC.js → camelcase-EETCRTJX.js} +8 -8
  6. package/dist/_node-chunks/{chunk-CZ5GHJCC.js → chunk-2W4GZCLE.js} +7 -7
  7. package/dist/_node-chunks/{chunk-E5FJS66Z.js → chunk-447655DM.js} +6 -6
  8. package/dist/_node-chunks/{chunk-WFLWJO24.js → chunk-4EJUC2SD.js} +4998 -1685
  9. package/dist/_node-chunks/chunk-4ZJOH2UN.js +61 -0
  10. package/dist/_node-chunks/chunk-654SJIMS.js +23 -0
  11. package/dist/_node-chunks/{chunk-2DMESZFJ.js → chunk-7IAVT2FU.js} +7 -7
  12. package/dist/_node-chunks/{chunk-5KLIDWFN.js → chunk-7KFHRNOT.js} +7 -7
  13. package/dist/_node-chunks/{chunk-XXPJ7XR3.js → chunk-AZIPBEBK.js} +6 -6
  14. package/dist/_node-chunks/{chunk-WUXQMQCB.js → chunk-B76FDKVB.js} +6 -6
  15. package/dist/_node-chunks/chunk-B7PGKETD.js +3781 -0
  16. package/dist/_node-chunks/{chunk-EZWWR7AR.js → chunk-CLUBH2LP.js} +55 -36
  17. package/dist/_node-chunks/{chunk-DUXPWBOK.js → chunk-CMYD2JNN.js} +7 -7
  18. package/dist/_node-chunks/{chunk-QCO2ZM7F.js → chunk-DIPKXLEP.js} +55 -32
  19. package/dist/_node-chunks/{chunk-DWXTZT3D.js → chunk-DPFYWXEA.js} +6 -6
  20. package/dist/_node-chunks/{chunk-FZLRAH4N.js → chunk-FCVNHU2F.js} +7 -7
  21. package/dist/_node-chunks/{chunk-QYQIZBS6.js → chunk-JQ7RQS5Q.js} +6 -6
  22. package/dist/_node-chunks/chunk-LEL5OSY3.js +18 -0
  23. package/dist/_node-chunks/{chunk-WA6KZQZ2.js → chunk-LPKSBF62.js} +6 -6
  24. package/dist/_node-chunks/chunk-LYEZOJ43.js +78 -0
  25. package/dist/_node-chunks/{chunk-JARUEMEP.js → chunk-MIA5324I.js} +7 -7
  26. package/dist/_node-chunks/{chunk-A4APXFQ2.js → chunk-MJM4TEMP.js} +14 -8
  27. package/dist/_node-chunks/{chunk-NAOYEL54.js → chunk-OVVZIUHS.js} +7 -7
  28. package/dist/_node-chunks/{chunk-5HV3B5OP.js → chunk-RUUNVQ6W.js} +1104 -13
  29. package/dist/_node-chunks/{chunk-2D2IODUU.js → chunk-URLNGLC2.js} +51 -71
  30. package/dist/_node-chunks/{chunk-OP3INKUD.js → chunk-WC2YEQHJ.js} +6 -6
  31. package/dist/_node-chunks/{chunk-4FT2DHGE.js → chunk-XKRVQL2G.js} +8 -8
  32. package/dist/_node-chunks/{chunk-SEMIAAWG.js → chunk-Z2OWEMX3.js} +8 -8
  33. package/dist/_node-chunks/{dist-DS2B5A3J.js → dist-22CLJ4BC.js} +9 -9
  34. package/dist/_node-chunks/{globby-6THB7HVX.js → globby-GR24TGSK.js} +9 -9
  35. package/dist/_node-chunks/{lib-5NKX4YGG.js → lib-G2LGVRPC.js} +7 -7
  36. package/dist/_node-chunks/{mdx-N42X6CFJ-ZLT3QOFF.js → mdx-N42X6CFJ-W6P6IDDW.js} +8 -8
  37. package/dist/_node-chunks/{p-limit-PDMWNG7W.js → p-limit-K4FZHG2F.js} +7 -7
  38. package/dist/babel/index.js +10 -11
  39. package/dist/bin/core.js +32 -26
  40. package/dist/bin/dispatcher.js +31 -20
  41. package/dist/bin/loader.js +10 -13
  42. package/dist/cli/index.d.ts +692 -133
  43. package/dist/cli/index.js +1005 -177
  44. package/dist/common/index.d.ts +139 -62
  45. package/dist/common/index.js +63 -49
  46. package/dist/core-server/index.d.ts +3 -2
  47. package/dist/core-server/index.js +96 -1413
  48. package/dist/core-server/presets/common-override-preset.js +9 -9
  49. package/dist/core-server/presets/common-preset.js +25 -65
  50. package/dist/csf-tools/index.js +9 -9
  51. package/dist/manager/globals-runtime.js +32 -3
  52. package/dist/manager/runtime.js +1 -1
  53. package/dist/manager-api/index.d.ts +1 -1
  54. package/dist/manager-api/index.js +4 -4
  55. package/dist/manager-errors.d.ts +6 -0
  56. package/dist/manager-errors.js +2 -2
  57. package/dist/mocking-utils/index.d.ts +1126 -0
  58. package/dist/{_node-chunks/chunk-ZXSD6L3S.js → mocking-utils/index.js} +441 -16
  59. package/dist/node-logger/index.d.ts +192 -24
  60. package/dist/node-logger/index.js +23 -3148
  61. package/dist/preview/runtime.js +31 -2
  62. package/dist/preview-api/index.d.ts +69 -68
  63. package/dist/preview-errors.d.ts +6 -0
  64. package/dist/preview-errors.js +2 -2
  65. package/dist/server-errors.d.ts +31 -1
  66. package/dist/server-errors.js +17 -10
  67. package/dist/telemetry/index.d.ts +23 -2
  68. package/dist/telemetry/index.js +25 -24
  69. package/dist/types/index.d.ts +71 -8
  70. package/dist/types/index.js +25 -1
  71. package/package.json +7 -9
  72. package/dist/_node-chunks/camelcase-JREIL7NV.js +0 -18
  73. package/dist/_node-chunks/chunk-FDXFVHIL.js +0 -1114
  74. package/dist/_node-chunks/chunk-HZG65SU3.js +0 -34
  75. package/dist/_node-chunks/chunk-IXVYNBMD.js +0 -18
  76. package/dist/_node-chunks/chunk-LIH7MTP7.js +0 -3214
  77. package/dist/_node-chunks/chunk-N5GIRUP5.js +0 -1047
  78. package/dist/_node-chunks/chunk-O5DA7YLO.js +0 -3171
  79. package/dist/_node-chunks/chunk-TS2UUH2J.js +0 -301
  80. package/dist/_node-chunks/chunk-Y4E6IGQF.js +0 -61
  81. package/dist/_node-chunks/chunk-ZL3AFKRX.js +0 -1029
  82. package/dist/_node-chunks/plugin-6XMWOGPO.js +0 -123
  83. package/dist/_node-chunks/plugin-LTOXVT6A.js +0 -109
  84. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +0 -46582
  85. package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +0 -92
  86. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -32
  87. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -28
@@ -1,105 +1,11 @@
1
- import { PackageJsonWithMaybeDeps, JsPackageManager as JsPackageManager$1, PackageJson } from 'storybook/internal/common';
2
- import { SupportedFrameworks, SupportedRenderers, PackageJson as PackageJson$1 } from 'storybook/internal/types';
3
1
  import * as semver from 'semver';
2
+ import { JsPackageManager as JsPackageManager$1, PackageJson } from 'storybook/internal/common';
3
+ import { SupportedFramework as SupportedFramework$1, SupportedRenderer, SupportedLanguage, Feature, PackageJson as PackageJson$1, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
4
4
  import { Buffer } from 'node:buffer';
5
5
  import { ChildProcess } from 'node:child_process';
6
6
  import { Readable, Writable, Stream } from 'node:stream';
7
7
 
8
- /** A list of all frameworks that are supported, but use a package outside the storybook monorepo */
9
- type ExternalFramework = {
10
- name: SupportedFrameworks;
11
- packageName?: string;
12
- frameworks?: string[];
13
- renderer?: string;
14
- };
15
- declare const externalFrameworks: ExternalFramework[];
16
- declare const SUPPORTED_RENDERERS: SupportedRenderers[];
17
- declare enum ProjectType {
18
- UNDETECTED = "UNDETECTED",
19
- UNSUPPORTED = "UNSUPPORTED",
20
- REACT = "REACT",
21
- REACT_SCRIPTS = "REACT_SCRIPTS",
22
- REACT_NATIVE = "REACT_NATIVE",
23
- REACT_NATIVE_WEB = "REACT_NATIVE_WEB",
24
- REACT_NATIVE_AND_RNW = "REACT_NATIVE_AND_RNW",
25
- REACT_PROJECT = "REACT_PROJECT",
26
- WEBPACK_REACT = "WEBPACK_REACT",
27
- NEXTJS = "NEXTJS",
28
- VUE3 = "VUE3",
29
- NUXT = "NUXT",
30
- ANGULAR = "ANGULAR",
31
- EMBER = "EMBER",
32
- WEB_COMPONENTS = "WEB_COMPONENTS",
33
- HTML = "HTML",
34
- QWIK = "QWIK",
35
- PREACT = "PREACT",
36
- SVELTE = "SVELTE",
37
- SVELTEKIT = "SVELTEKIT",
38
- SERVER = "SERVER",
39
- NX = "NX",
40
- SOLID = "SOLID"
41
- }
42
- declare enum CoreBuilder {
43
- Webpack5 = "webpack5",
44
- Vite = "vite"
45
- }
46
- declare enum CoreWebpackCompilers {
47
- Babel = "babel",
48
- SWC = "swc"
49
- }
50
- declare enum CommunityBuilder {
51
- Rsbuild = "rsbuild"
52
- }
53
- declare const compilerNameToCoreCompiler: Record<string, CoreWebpackCompilers>;
54
- declare const builderNameToCoreBuilder: Record<string, CoreBuilder>;
55
- type Builder = CoreBuilder | (string & {});
56
- declare enum SupportedLanguage {
57
- JAVASCRIPT = "javascript",
58
- TYPESCRIPT = "typescript"
59
- }
60
- type TemplateMatcher = {
61
- files?: boolean[];
62
- dependencies?: boolean[];
63
- peerDependencies?: boolean[];
64
- };
65
- type TemplateConfiguration = {
66
- preset: ProjectType;
67
- /** Will be checked both against dependencies and devDependencies */
68
- dependencies?: string[] | {
69
- [dependency: string]: (version: string) => boolean;
70
- };
71
- peerDependencies?: string[] | {
72
- [dependency: string]: (version: string) => boolean;
73
- };
74
- files?: string[];
75
- matcherFunction: (matcher: TemplateMatcher) => boolean;
76
- };
77
- /**
78
- * Configuration to match a storybook preset template.
79
- *
80
- * This has to be an array sorted in order of specificity/priority. Reason: both REACT and
81
- * WEBPACK_REACT have react as dependency, therefore WEBPACK_REACT has to come first, as it's more
82
- * specific.
83
- */
84
- declare const supportedTemplates: TemplateConfiguration[];
85
- declare const unsupportedTemplate: TemplateConfiguration;
86
- declare const installableProjectTypes: string[];
87
-
88
- declare function detectFrameworkPreset(packageJson?: PackageJsonWithMaybeDeps): ProjectType | null;
89
- /**
90
- * Attempts to detect which builder to use, by searching for a vite config file or webpack
91
- * installation. If neither are found it will choose the default builder based on the project type.
92
- *
93
- * @returns CoreBuilder
94
- */
95
- declare function detectBuilder(packageManager: JsPackageManager$1, projectType: ProjectType): Promise<any>;
96
- declare function isStorybookInstantiated(configDir?: string): boolean;
97
8
  declare function detectPnp(): Promise<boolean>;
98
- declare function detectLanguage(packageManager: JsPackageManager$1): Promise<SupportedLanguage>;
99
- declare function detect(packageManager: JsPackageManager$1, options?: {
100
- force?: boolean;
101
- html?: boolean;
102
- }): Promise<ProjectType | null>;
103
9
 
104
10
  declare function readFileAsJson(jsonPath: string, allowComments?: boolean): any;
105
11
  declare const writeFileAsJson: (jsonPath: string, content: unknown) => boolean;
@@ -129,13 +35,12 @@ declare function addToDevDependenciesIfNotPresent(packageJson: PackageJson, name
129
35
  declare function copyTemplate(templateRoot: string, destination?: string): void;
130
36
  type CopyTemplateFilesOptions = {
131
37
  packageManager: JsPackageManager$1;
132
- templateLocation: SupportedFrameworks | SupportedRenderers;
38
+ templateLocation: SupportedFramework$1 | SupportedRenderer;
133
39
  language: SupportedLanguage;
134
40
  commonAssetsDir?: string;
135
41
  destination?: string;
136
- features: string[];
42
+ features: Set<Feature>;
137
43
  };
138
- declare const frameworkToDefaultBuilder: Record<SupportedFrameworks, CoreBuilder | CommunityBuilder>;
139
44
  /**
140
45
  * Return the installed version of a package, or the coerced version specifier from package.json if
141
46
  * it's a dependency but not installed (e.g. in a fresh project)
@@ -144,13 +49,10 @@ declare function getVersionSafe(packageManager: JsPackageManager$1, packageName:
144
49
  declare const cliStoriesTargetPath: () => Promise<"./src/stories" | "./stories">;
145
50
  declare function copyTemplateFiles({ packageManager, templateLocation, language, destination, commonAssetsDir, features, }: CopyTemplateFilesOptions): Promise<void>;
146
51
  declare function adjustTemplate(templatePath: string, templateData: Record<string, any>): Promise<void>;
147
- declare function isNxProject(): Promise<string | undefined>;
148
52
  declare function coerceSemver(version: string): semver.SemVer;
149
53
  declare function hasStorybookDependencies(packageManager: JsPackageManager$1): boolean;
150
54
 
151
55
  declare const ANGULAR_JSON_PATH = "angular.json";
152
- declare const compoDocPreviewPrefix: string;
153
- declare const promptForCompoDocs: () => Promise<boolean>;
154
56
  declare class AngularJSON {
155
57
  json: {
156
58
  projects: Record<string, {
@@ -177,7 +79,7 @@ declare class AngularJSON {
177
79
  projectType: string;
178
80
  architect: Record<string, any>;
179
81
  };
180
- getProjectName(): Promise<any>;
82
+ getProjectName(): Promise<string>;
181
83
  addStorybookEntries({ angularProjectName, storybookFolder, useCompodoc, root, }: {
182
84
  angularProjectName: string;
183
85
  storybookFolder: string;
@@ -187,7 +89,32 @@ declare class AngularJSON {
187
89
  write(): void;
188
90
  }
189
91
 
190
- declare function getRendererDir(packageManager: JsPackageManager$1, renderer: SupportedFrameworks | SupportedRenderers): Promise<string>;
92
+ declare function getRendererDir(packageManager: JsPackageManager$1, renderer: SupportedFramework$1 | SupportedRenderer): Promise<string>;
93
+
94
+ declare enum ProjectType {
95
+ ANGULAR = "angular",
96
+ EMBER = "ember",
97
+ HTML = "html",
98
+ NEXTJS = "nextjs",
99
+ NUXT = "nuxt",
100
+ NX = "nx",
101
+ PREACT = "preact",
102
+ QWIK = "qwik",
103
+ REACT = "react",
104
+ REACT_NATIVE = "react_native",
105
+ REACT_NATIVE_AND_RNW = "react_native_and_rnw",
106
+ REACT_NATIVE_WEB = "react_native_web",
107
+ REACT_PROJECT = "react_project",
108
+ REACT_SCRIPTS = "react_scripts",
109
+ SERVER = "server",
110
+ SOLID = "solid",
111
+ SVELTE = "svelte",
112
+ SVELTEKIT = "sveltekit",
113
+ UNDETECTED = "undetected",
114
+ UNSUPPORTED = "unsupported",
115
+ VUE3 = "vue3",
116
+ WEB_COMPONENTS = "web_components"
117
+ }
191
118
 
192
119
  type StdioOption =
193
120
  | 'pipe'
@@ -664,6 +591,14 @@ type ExecaChildProcess<StdoutStderrType extends StdoutStderrAll = string> = Chil
664
591
  ExecaChildPromise<StdoutStderrType> &
665
592
  Promise<ExecaReturnValue<StdoutStderrType>>;
666
593
 
594
+ type ExecuteCommandOptions = CommonOptions<'utf8'> & {
595
+ command: string;
596
+ args?: string[];
597
+ cwd?: string;
598
+ ignoreError?: boolean;
599
+ env?: Record<string, any>;
600
+ };
601
+
667
602
  type PackageJsonWithDepsAndDevDeps = PackageJson$1 & Required<Pick<PackageJson$1, 'dependencies' | 'devDependencies'>>;
668
603
 
669
604
  type PackageMetadata = {
@@ -678,7 +613,13 @@ type InstallationMetadata = {
678
613
  dedupeCommand: string;
679
614
  };
680
615
 
681
- type PackageManagerName = 'npm' | 'yarn1' | 'yarn2' | 'pnpm' | 'bun';
616
+ declare enum PackageManagerName {
617
+ NPM = "npm",
618
+ YARN1 = "yarn",
619
+ YARN2 = "yarn2",
620
+ PNPM = "pnpm",
621
+ BUN = "bun"
622
+ }
682
623
  interface JsPackageManagerOptions {
683
624
  cwd?: string;
684
625
  configDir?: string;
@@ -707,14 +648,11 @@ declare abstract class JsPackageManager {
707
648
  static readonly latestVersionCache: Map<string, string | null>;
708
649
  /** Cache for installed version results to avoid repeated file system calls. */
709
650
  static readonly installedVersionCache: Map<string, string | null>;
651
+ /** Cache for package.json files to avoid repeated file system calls. */
652
+ static readonly packageJsonCache: Map<string, PackageJsonWithDepsAndDevDeps>;
710
653
  constructor(options?: JsPackageManagerOptions);
711
654
  /** Runs arbitrary package scripts. */
712
655
  abstract getRunCommand(command: string): string;
713
- /**
714
- * Run a command from a local or remote. Fetches a package from the registry without installing it
715
- * as a dependency, hotloads it, and runs whatever default command binary it exposes.
716
- */
717
- abstract getRemoteRunCommand(pkg: string, args: string[], specifier?: string): string;
718
656
  /** Get the package.json file for a given module. */
719
657
  abstract getModulePackageJSON(packageName: string): Promise<PackageJson$1 | null>;
720
658
  isStorybookInMonorepo(): boolean;
@@ -846,33 +784,14 @@ declare abstract class JsPackageManager {
846
784
  protected abstract runGetVersions<T extends boolean>(packageName: string, fetchAllVersions: T): Promise<T extends true ? string[] : string>;
847
785
  abstract getRegistryURL(): Promise<string | undefined>;
848
786
  abstract runInternalCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
849
- abstract runPackageCommand(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): ExecaChildProcess;
850
- abstract runPackageCommandSync(command: string, args: string[], cwd?: string, stdio?: 'inherit' | 'pipe' | 'ignore'): string;
787
+ abstract runPackageCommand(options: Omit<ExecuteCommandOptions, 'command'> & {
788
+ args: string[];
789
+ }): ExecaChildProcess;
851
790
  abstract findInstallations(pattern?: string[]): Promise<InstallationMetadata | undefined>;
852
791
  abstract findInstallations(pattern?: string[], options?: {
853
792
  depth: number;
854
793
  }): Promise<InstallationMetadata | undefined>;
855
794
  abstract parseErrorFromLogs(logs?: string): string;
856
- executeCommandSync({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
857
- command: string;
858
- args: string[];
859
- cwd?: string;
860
- ignoreError?: boolean;
861
- }): string;
862
- /**
863
- * Execute a command asynchronously and return the execa process. This allows you to hook into
864
- * stdout/stderr streams and monitor the process.
865
- *
866
- * @example Const process = packageManager.executeCommand({ command: 'npm', args: ['install'] });
867
- * process.stdout?.on('data', (data) => console.log(data.toString())); const result = await
868
- * process;
869
- */
870
- executeCommand({ command, args, stdio, cwd, ignoreError, env, ...execaOptions }: CommonOptions<'utf8'> & {
871
- command: string;
872
- args: string[];
873
- cwd?: string;
874
- ignoreError?: boolean;
875
- }): ExecaChildProcess;
876
795
  /** Returns the installed (within node_modules or pnp zip) version of a specified package */
877
796
  getInstalledVersion(packageName: string): Promise<string | null>;
878
797
  isPackageInstalled(packageName: string): Promise<boolean>;
@@ -1868,4 +1787,644 @@ declare class Settings {
1868
1787
  save(): Promise<void>;
1869
1788
  }
1870
1789
 
1871
- export { ANGULAR_JSON_PATH, AngularJSON, type Builder, CommunityBuilder, CoreBuilder, CoreWebpackCompilers, type ExternalFramework, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, SUPPORTED_RENDERERS, Settings, SupportedLanguage, type TemplateConfiguration, type TemplateMatcher, _clearGlobalSettings, addToDevDependenciesIfNotPresent, adjustTemplate, builderNameToCoreBuilder, cliStoriesTargetPath, coerceSemver, compilerNameToCoreCompiler, compoDocPreviewPrefix, configureEslintPlugin, configureFlatConfig, copyTemplate, copyTemplateFiles, detect, detectBuilder, detectFrameworkPreset, detectLanguage, detectPnp, externalFrameworks, extractEslintInfo, findEslintFile, frameworkToDefaultBuilder, getBabelDependencies, getRendererDir, getVersionSafe, globalSettings, hasStorybookDependencies, installableProjectTypes, isNxProject, isStorybookInstantiated, normalizeExtends, promptForCompoDocs, readFileAsJson, suggestESLintPlugin, supportedTemplates, unsupportedTemplate, writeFileAsJson };
1790
+ /**
1791
+ * Actions represent the type of change to a location value.
1792
+ */
1793
+ declare enum Action {
1794
+ /**
1795
+ * A POP indicates a change to an arbitrary index in the history stack, such
1796
+ * as a back or forward navigation. It does not describe the direction of the
1797
+ * navigation, only that the current index changed.
1798
+ *
1799
+ * Note: This is the default action for newly created history objects.
1800
+ */
1801
+ Pop = "POP",
1802
+ /**
1803
+ * A PUSH indicates a new entry being added to the history stack, such as when
1804
+ * a link is clicked and a new page loads. When this happens, all subsequent
1805
+ * entries in the stack are lost.
1806
+ */
1807
+ Push = "PUSH",
1808
+ /**
1809
+ * A REPLACE indicates the entry at the current index in the history stack
1810
+ * being replaced by a new one.
1811
+ */
1812
+ Replace = "REPLACE"
1813
+ }
1814
+ /**
1815
+ * The pathname, search, and hash values of a URL.
1816
+ */
1817
+ interface Path {
1818
+ /**
1819
+ * A URL pathname, beginning with a /.
1820
+ */
1821
+ pathname: string;
1822
+ /**
1823
+ * A URL search string, beginning with a ?.
1824
+ */
1825
+ search: string;
1826
+ /**
1827
+ * A URL fragment identifier, beginning with a #.
1828
+ */
1829
+ hash: string;
1830
+ }
1831
+ /**
1832
+ * An entry in a history stack. A location contains information about the
1833
+ * URL path, as well as possibly some arbitrary state and a key.
1834
+ */
1835
+ interface Location extends Path {
1836
+ /**
1837
+ * A value of arbitrary data associated with this location.
1838
+ */
1839
+ state: any;
1840
+ /**
1841
+ * A unique string associated with this location. May be used to safely store
1842
+ * and retrieve data in some other storage API, like `localStorage`.
1843
+ *
1844
+ * Note: This value is always "default" on the initial location.
1845
+ */
1846
+ key: string;
1847
+ }
1848
+
1849
+ /**
1850
+ * Map of routeId -> data returned from a loader/action/error
1851
+ */
1852
+ interface RouteData {
1853
+ [routeId: string]: any;
1854
+ }
1855
+ declare enum ResultType {
1856
+ data = "data",
1857
+ deferred = "deferred",
1858
+ redirect = "redirect",
1859
+ error = "error"
1860
+ }
1861
+ /**
1862
+ * Successful result from a loader or action
1863
+ */
1864
+ interface SuccessResult {
1865
+ type: ResultType.data;
1866
+ data: any;
1867
+ statusCode?: number;
1868
+ headers?: Headers;
1869
+ }
1870
+ /**
1871
+ * Successful defer() result from a loader or action
1872
+ */
1873
+ interface DeferredResult {
1874
+ type: ResultType.deferred;
1875
+ deferredData: DeferredData;
1876
+ statusCode?: number;
1877
+ headers?: Headers;
1878
+ }
1879
+ /**
1880
+ * Redirect result from a loader or action
1881
+ */
1882
+ interface RedirectResult {
1883
+ type: ResultType.redirect;
1884
+ status: number;
1885
+ location: string;
1886
+ revalidate: boolean;
1887
+ reloadDocument?: boolean;
1888
+ }
1889
+ /**
1890
+ * Unsuccessful result from a loader or action
1891
+ */
1892
+ interface ErrorResult {
1893
+ type: ResultType.error;
1894
+ error: any;
1895
+ headers?: Headers;
1896
+ }
1897
+ /**
1898
+ * Result from a loader or action - potentially successful or unsuccessful
1899
+ */
1900
+ type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
1901
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
1902
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
1903
+ /**
1904
+ * Active navigation/fetcher form methods are exposed in lowercase on the
1905
+ * RouterState
1906
+ */
1907
+ type FormMethod = LowerCaseFormMethod;
1908
+ /**
1909
+ * In v7, active navigation/fetcher form methods are exposed in uppercase on the
1910
+ * RouterState. This is to align with the normalization done via fetch().
1911
+ */
1912
+ type V7_FormMethod = UpperCaseFormMethod;
1913
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
1914
+ type JsonObject = {
1915
+ [Key in string]: JsonValue;
1916
+ } & {
1917
+ [Key in string]?: JsonValue | undefined;
1918
+ };
1919
+ type JsonArray = JsonValue[] | readonly JsonValue[];
1920
+ type JsonPrimitive = string | number | boolean | null;
1921
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
1922
+ /**
1923
+ * @private
1924
+ * Internal interface to pass around for action submissions, not intended for
1925
+ * external consumption
1926
+ */
1927
+ type Submission = {
1928
+ formMethod: FormMethod | V7_FormMethod;
1929
+ formAction: string;
1930
+ formEncType: FormEncType;
1931
+ formData: FormData;
1932
+ json: undefined;
1933
+ text: undefined;
1934
+ } | {
1935
+ formMethod: FormMethod | V7_FormMethod;
1936
+ formAction: string;
1937
+ formEncType: FormEncType;
1938
+ formData: undefined;
1939
+ json: JsonValue;
1940
+ text: undefined;
1941
+ } | {
1942
+ formMethod: FormMethod | V7_FormMethod;
1943
+ formAction: string;
1944
+ formEncType: FormEncType;
1945
+ formData: undefined;
1946
+ json: undefined;
1947
+ text: string;
1948
+ };
1949
+ /**
1950
+ * @private
1951
+ * Arguments passed to route loader/action functions. Same for now but we keep
1952
+ * this as a private implementation detail in case they diverge in the future.
1953
+ */
1954
+ interface DataFunctionArgs {
1955
+ request: Request;
1956
+ params: Params;
1957
+ context?: any;
1958
+ }
1959
+ /**
1960
+ * Arguments passed to loader functions
1961
+ */
1962
+ interface LoaderFunctionArgs extends DataFunctionArgs {
1963
+ }
1964
+ /**
1965
+ * Arguments passed to action functions
1966
+ */
1967
+ interface ActionFunctionArgs extends DataFunctionArgs {
1968
+ }
1969
+ /**
1970
+ * Loaders and actions can return anything except `undefined` (`null` is a
1971
+ * valid return value if there is no data to return). Responses are preferred
1972
+ * and will ease any future migration to Remix
1973
+ */
1974
+ type DataFunctionValue = Response | NonNullable<unknown> | null;
1975
+ /**
1976
+ * Route loader function signature
1977
+ */
1978
+ interface LoaderFunction {
1979
+ (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
1980
+ }
1981
+ /**
1982
+ * Route action function signature
1983
+ */
1984
+ interface ActionFunction {
1985
+ (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
1986
+ }
1987
+ /**
1988
+ * Route shouldRevalidate function signature. This runs after any submission
1989
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
1990
+ * onto the arguments. It shouldn't matter whether it came from a navigation
1991
+ * or a fetcher, what really matters is the URLs and the formData since loaders
1992
+ * have to re-run based on the data models that were potentially mutated.
1993
+ */
1994
+ interface ShouldRevalidateFunction {
1995
+ (args: {
1996
+ currentUrl: URL;
1997
+ currentParams: AgnosticDataRouteMatch["params"];
1998
+ nextUrl: URL;
1999
+ nextParams: AgnosticDataRouteMatch["params"];
2000
+ formMethod?: Submission["formMethod"];
2001
+ formAction?: Submission["formAction"];
2002
+ formEncType?: Submission["formEncType"];
2003
+ text?: Submission["text"];
2004
+ formData?: Submission["formData"];
2005
+ json?: Submission["json"];
2006
+ actionResult?: DataResult;
2007
+ defaultShouldRevalidate: boolean;
2008
+ }): boolean;
2009
+ }
2010
+ /**
2011
+ * Keys we cannot change from within a lazy() function. We spread all other keys
2012
+ * onto the route. Either they're meaningful to the router, or they'll get
2013
+ * ignored.
2014
+ */
2015
+ type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
2016
+ type RequireOne<T, Key = keyof T> = Exclude<{
2017
+ [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
2018
+ }[keyof T], undefined>;
2019
+ /**
2020
+ * lazy() function to load a route definition, which can add non-matching
2021
+ * related properties to a route
2022
+ */
2023
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
2024
+ (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
2025
+ }
2026
+ /**
2027
+ * Base RouteObject with common props shared by all types of routes
2028
+ */
2029
+ type AgnosticBaseRouteObject = {
2030
+ caseSensitive?: boolean;
2031
+ path?: string;
2032
+ id?: string;
2033
+ loader?: LoaderFunction;
2034
+ action?: ActionFunction;
2035
+ hasErrorBoundary?: boolean;
2036
+ shouldRevalidate?: ShouldRevalidateFunction;
2037
+ handle?: any;
2038
+ lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
2039
+ };
2040
+ /**
2041
+ * Index routes must not have children
2042
+ */
2043
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
2044
+ children?: undefined;
2045
+ index: true;
2046
+ };
2047
+ /**
2048
+ * Non-index routes may have children, but cannot have index
2049
+ */
2050
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
2051
+ children?: AgnosticRouteObject[];
2052
+ index?: false;
2053
+ };
2054
+ /**
2055
+ * A route object represents a logical route, with (optionally) its child
2056
+ * routes organized in a tree-like structure.
2057
+ */
2058
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
2059
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
2060
+ id: string;
2061
+ };
2062
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
2063
+ children?: AgnosticDataRouteObject[];
2064
+ id: string;
2065
+ };
2066
+ /**
2067
+ * A data route object, which is just a RouteObject with a required unique ID
2068
+ */
2069
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
2070
+ /**
2071
+ * The parameters that were parsed from the URL path.
2072
+ */
2073
+ type Params<Key extends string = string> = {
2074
+ readonly [key in Key]: string | undefined;
2075
+ };
2076
+ /**
2077
+ * A RouteMatch contains info about how a route matched a URL.
2078
+ */
2079
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
2080
+ /**
2081
+ * The names and values of dynamic parameters in the URL.
2082
+ */
2083
+ params: Params<ParamKey>;
2084
+ /**
2085
+ * The portion of the URL pathname that was matched.
2086
+ */
2087
+ pathname: string;
2088
+ /**
2089
+ * The portion of the URL pathname that was matched before child routes.
2090
+ */
2091
+ pathnameBase: string;
2092
+ /**
2093
+ * The route object that was used to match.
2094
+ */
2095
+ route: RouteObjectType;
2096
+ }
2097
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
2098
+ }
2099
+ declare class DeferredData {
2100
+ private pendingKeysSet;
2101
+ private controller;
2102
+ private abortPromise;
2103
+ private unlistenAbortSignal;
2104
+ private subscribers;
2105
+ data: Record<string, unknown>;
2106
+ init?: ResponseInit;
2107
+ deferredKeys: string[];
2108
+ constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
2109
+ private trackPromise;
2110
+ private onSettle;
2111
+ private emit;
2112
+ subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
2113
+ cancel(): void;
2114
+ resolveData(signal: AbortSignal): Promise<boolean>;
2115
+ get done(): boolean;
2116
+ get unwrappedData(): {};
2117
+ get pendingKeys(): string[];
2118
+ }
2119
+
2120
+ /**
2121
+ * State maintained internally by the router. During a navigation, all states
2122
+ * reflect the the "old" location unless otherwise noted.
2123
+ */
2124
+ interface RouterState {
2125
+ /**
2126
+ * The action of the most recent navigation
2127
+ */
2128
+ historyAction: Action;
2129
+ /**
2130
+ * The current location reflected by the router
2131
+ */
2132
+ location: Location;
2133
+ /**
2134
+ * The current set of route matches
2135
+ */
2136
+ matches: AgnosticDataRouteMatch[];
2137
+ /**
2138
+ * Tracks whether we've completed our initial data load
2139
+ */
2140
+ initialized: boolean;
2141
+ /**
2142
+ * Current scroll position we should start at for a new view
2143
+ * - number -> scroll position to restore to
2144
+ * - false -> do not restore scroll at all (used during submissions)
2145
+ * - null -> don't have a saved position, scroll to hash or top of page
2146
+ */
2147
+ restoreScrollPosition: number | false | null;
2148
+ /**
2149
+ * Indicate whether this navigation should skip resetting the scroll position
2150
+ * if we are unable to restore the scroll position
2151
+ */
2152
+ preventScrollReset: boolean;
2153
+ /**
2154
+ * Tracks the state of the current navigation
2155
+ */
2156
+ navigation: Navigation;
2157
+ /**
2158
+ * Tracks any in-progress revalidations
2159
+ */
2160
+ revalidation: RevalidationState;
2161
+ /**
2162
+ * Data from the loaders for the current matches
2163
+ */
2164
+ loaderData: RouteData;
2165
+ /**
2166
+ * Data from the action for the current matches
2167
+ */
2168
+ actionData: RouteData | null;
2169
+ /**
2170
+ * Errors caught from loaders for the current matches
2171
+ */
2172
+ errors: RouteData | null;
2173
+ /**
2174
+ * Map of current fetchers
2175
+ */
2176
+ fetchers: Map<string, Fetcher>;
2177
+ /**
2178
+ * Map of current blockers
2179
+ */
2180
+ blockers: Map<string, Blocker>;
2181
+ }
2182
+ /**
2183
+ * Data that can be passed into hydrate a Router from SSR
2184
+ */
2185
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
2186
+ /**
2187
+ * Potential states for state.navigation
2188
+ */
2189
+ type NavigationStates = {
2190
+ Idle: {
2191
+ state: "idle";
2192
+ location: undefined;
2193
+ formMethod: undefined;
2194
+ formAction: undefined;
2195
+ formEncType: undefined;
2196
+ formData: undefined;
2197
+ json: undefined;
2198
+ text: undefined;
2199
+ };
2200
+ Loading: {
2201
+ state: "loading";
2202
+ location: Location;
2203
+ formMethod: Submission["formMethod"] | undefined;
2204
+ formAction: Submission["formAction"] | undefined;
2205
+ formEncType: Submission["formEncType"] | undefined;
2206
+ formData: Submission["formData"] | undefined;
2207
+ json: Submission["json"] | undefined;
2208
+ text: Submission["text"] | undefined;
2209
+ };
2210
+ Submitting: {
2211
+ state: "submitting";
2212
+ location: Location;
2213
+ formMethod: Submission["formMethod"];
2214
+ formAction: Submission["formAction"];
2215
+ formEncType: Submission["formEncType"];
2216
+ formData: Submission["formData"];
2217
+ json: Submission["json"];
2218
+ text: Submission["text"];
2219
+ };
2220
+ };
2221
+ type Navigation = NavigationStates[keyof NavigationStates];
2222
+ type RevalidationState = "idle" | "loading";
2223
+ /**
2224
+ * Potential states for fetchers
2225
+ */
2226
+ type FetcherStates<TData = any> = {
2227
+ Idle: {
2228
+ state: "idle";
2229
+ formMethod: undefined;
2230
+ formAction: undefined;
2231
+ formEncType: undefined;
2232
+ text: undefined;
2233
+ formData: undefined;
2234
+ json: undefined;
2235
+ data: TData | undefined;
2236
+ " _hasFetcherDoneAnything "?: boolean;
2237
+ };
2238
+ Loading: {
2239
+ state: "loading";
2240
+ formMethod: Submission["formMethod"] | undefined;
2241
+ formAction: Submission["formAction"] | undefined;
2242
+ formEncType: Submission["formEncType"] | undefined;
2243
+ text: Submission["text"] | undefined;
2244
+ formData: Submission["formData"] | undefined;
2245
+ json: Submission["json"] | undefined;
2246
+ data: TData | undefined;
2247
+ " _hasFetcherDoneAnything "?: boolean;
2248
+ };
2249
+ Submitting: {
2250
+ state: "submitting";
2251
+ formMethod: Submission["formMethod"];
2252
+ formAction: Submission["formAction"];
2253
+ formEncType: Submission["formEncType"];
2254
+ text: Submission["text"];
2255
+ formData: Submission["formData"];
2256
+ json: Submission["json"];
2257
+ data: TData | undefined;
2258
+ " _hasFetcherDoneAnything "?: boolean;
2259
+ };
2260
+ };
2261
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
2262
+ interface BlockerBlocked {
2263
+ state: "blocked";
2264
+ reset(): void;
2265
+ proceed(): void;
2266
+ location: Location;
2267
+ }
2268
+ interface BlockerUnblocked {
2269
+ state: "unblocked";
2270
+ reset: undefined;
2271
+ proceed: undefined;
2272
+ location: undefined;
2273
+ }
2274
+ interface BlockerProceeding {
2275
+ state: "proceeding";
2276
+ reset: undefined;
2277
+ proceed: undefined;
2278
+ location: Location;
2279
+ }
2280
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
2281
+
2282
+ /**
2283
+ * NOTE: If you refactor this to split up the modules into separate files,
2284
+ * you'll need to update the rollup config for react-router-dom-v5-compat.
2285
+ */
2286
+
2287
+ declare global {
2288
+ var __staticRouterHydrationData: HydrationState | undefined;
2289
+ }
2290
+
2291
+ declare global {
2292
+ interface SymbolConstructor {
2293
+ readonly observable: symbol;
2294
+ }
2295
+ }
2296
+
2297
+ declare enum SupportedBuilder {
2298
+ WEBPACK5 = "webpack5",
2299
+ VITE = "vite",
2300
+ RSBUILD = "rsbuild"
2301
+ }
2302
+
2303
+ declare enum SupportedFramework {
2304
+ ANGULAR = "angular",
2305
+ EMBER = "ember",
2306
+ HTML_VITE = "html-vite",
2307
+ NEXTJS = "nextjs",
2308
+ NEXTJS_VITE = "nextjs-vite",
2309
+ PREACT_VITE = "preact-vite",
2310
+ REACT_NATIVE_WEB_VITE = "react-native-web-vite",
2311
+ REACT_VITE = "react-vite",
2312
+ REACT_WEBPACK5 = "react-webpack5",
2313
+ SERVER_WEBPACK5 = "server-webpack5",
2314
+ SVELTE_VITE = "svelte-vite",
2315
+ SVELTEKIT = "sveltekit",
2316
+ VUE3_VITE = "vue3-vite",
2317
+ WEB_COMPONENTS_VITE = "web-components-vite",
2318
+ HTML_RSBUILD = "html-rsbuild",
2319
+ NUXT = "nuxt",
2320
+ QWIK = "qwik",
2321
+ REACT_RSBUILD = "react-rsbuild",
2322
+ SOLID = "solid",
2323
+ VUE3_RSBUILD = "vue3-rsbuild",
2324
+ WEB_COMPONENTS_RSBUILD = "web-components-rsbuild"
2325
+ }
2326
+
2327
+ declare global {
2328
+ var globalProjectAnnotations: NormalizedProjectAnnotations<any>;
2329
+ var defaultProjectAnnotations: ProjectAnnotations<any>;
2330
+ }
2331
+ type WrappedStoryRef = {
2332
+ __pw_type: 'jsx';
2333
+ props: Record<string, any>;
2334
+ } | {
2335
+ __pw_type: 'importRef';
2336
+ };
2337
+ type UnwrappedJSXStoryRef = {
2338
+ __pw_type: 'jsx';
2339
+ type: UnwrappedImportStoryRef;
2340
+ };
2341
+ type UnwrappedImportStoryRef = ComposedStoryFn;
2342
+ declare global {
2343
+ function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
2344
+ }
2345
+
2346
+ type Result = {
2347
+ compatible: boolean;
2348
+ reasons?: string[];
2349
+ };
2350
+ interface AddonVitestCompatibilityOptions {
2351
+ packageManager: JsPackageManager$1;
2352
+ builder?: SupportedBuilder;
2353
+ framework?: SupportedFramework | null;
2354
+ projectRoot?: string;
2355
+ }
2356
+ /**
2357
+ * Centralized service for @storybook/addon-vitest dependency collection and compatibility
2358
+ * validation
2359
+ *
2360
+ * This service consolidates logic from:
2361
+ *
2362
+ * - Code/addons/vitest/src/postinstall.ts
2363
+ * - Code/lib/create-storybook/src/addon-dependencies/addon-vitest.ts
2364
+ * - Code/lib/create-storybook/src/services/FeatureCompatibilityService.ts
2365
+ */
2366
+ declare class AddonVitestService {
2367
+ readonly supportedFrameworks: SupportedFramework[];
2368
+ /**
2369
+ * Collect all dependencies needed for @storybook/addon-vitest
2370
+ *
2371
+ * Returns versioned package strings ready for installation:
2372
+ *
2373
+ * - Base packages: vitest, @vitest/browser, playwright
2374
+ * - Next.js specific: @storybook/nextjs-vite
2375
+ * - Coverage reporter: @vitest/coverage-v8
2376
+ */
2377
+ collectDependencies(packageManager: JsPackageManager$1): Promise<string[]>;
2378
+ /**
2379
+ * Install Playwright browser binaries for @storybook/addon-vitest
2380
+ *
2381
+ * Installs Chromium with dependencies via `npx playwright install chromium --with-deps`
2382
+ *
2383
+ * @param packageManager - The package manager to use for installation
2384
+ * @param prompt - The prompt instance for displaying progress
2385
+ * @param logger - The logger instance for displaying messages
2386
+ * @param options - Installation options
2387
+ * @returns Array of error messages if installation fails
2388
+ */
2389
+ installPlaywright(packageManager: JsPackageManager$1, options?: {
2390
+ yes?: boolean;
2391
+ }): Promise<{
2392
+ errors: string[];
2393
+ }>;
2394
+ /**
2395
+ * Validate full compatibility for @storybook/addon-vitest
2396
+ *
2397
+ * Checks:
2398
+ *
2399
+ * - Webpack configuration compatibility
2400
+ * - Builder compatibility (Vite or Next.js)
2401
+ * - Renderer/framework support
2402
+ * - Vitest version (>=3.0.0)
2403
+ * - MSW version (>=2.0.0 if installed)
2404
+ * - Next.js installation (if using @storybook/nextjs)
2405
+ * - Vitest config files (if configDir provided)
2406
+ */
2407
+ validateCompatibility(options: AddonVitestCompatibilityOptions): Promise<Result>;
2408
+ /**
2409
+ * Validate package versions for addon-vitest compatibility Public method to allow early
2410
+ * validation before framework detection
2411
+ */
2412
+ validatePackageVersions(packageManager: JsPackageManager$1): Promise<Result>;
2413
+ /**
2414
+ * Validate vitest config files for addon compatibility
2415
+ *
2416
+ * Public method that can be used by both postinstall and create-storybook flows
2417
+ */
2418
+ validateConfigFiles(directory: string): Promise<Result>;
2419
+ /** Validate workspace config file structure */
2420
+ private isValidWorkspaceConfigFile;
2421
+ /** Validate Vitest config file structure */
2422
+ private isValidVitestConfig;
2423
+ private isWorkspaceConfigArray;
2424
+ private isDefineWorkspaceExpression;
2425
+ private isDefineConfigExpression;
2426
+ private isMergeConfigExpression;
2427
+ private isSafeToExtendWorkspace;
2428
+ }
2429
+
2430
+ export { ANGULAR_JSON_PATH, type AddonVitestCompatibilityOptions, AddonVitestService, AngularJSON, type NpmOptions, ProjectType, SUPPORTED_ESLINT_EXTENSIONS, Settings, _clearGlobalSettings, addToDevDependenciesIfNotPresent, adjustTemplate, cliStoriesTargetPath, coerceSemver, configureEslintPlugin, configureFlatConfig, copyTemplate, copyTemplateFiles, detectPnp, extractEslintInfo, findEslintFile, getBabelDependencies, getRendererDir, getVersionSafe, globalSettings, hasStorybookDependencies, normalizeExtends, readFileAsJson, suggestESLintPlugin, writeFileAsJson };