storybook-react-rsbuild 3.4.2 → 3.6.0

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.
@@ -1,196 +1,170 @@
1
- import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import "../_node-chunks/chunk-TPE2Q567.js";
13
-
14
- // src/loaders/react-docgen-loader.ts
15
- import findUp from "find-up";
16
- import MagicString from "magic-string";
17
- import {
18
- builtinHandlers as docgenHandlers,
19
- builtinResolvers as docgenResolver,
20
- ERROR_CODES,
21
- makeFsImporter,
22
- parse,
23
- utils
24
- } from "react-docgen";
1
+ import "node:module";
2
+ import magic_string from "magic-string";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, extname, sep } from "node:path";
5
+ import { ERROR_CODES, builtinHandlers, builtinResolvers, makeFsImporter, parse, utils } from "react-docgen";
6
+ import { findTsconfigPathForFile, getTsconfigPathsBaseDir } from "storybook/internal/common";
25
7
  import { logger } from "storybook/internal/node-logger";
26
- import * as TsconfigPaths from "tsconfig-paths";
27
-
28
- // src/loaders/docgen-resolver.ts
29
- import { extname } from "node:path";
30
8
  import resolve from "resolve";
31
- var ReactDocgenResolveError = class extends Error {
32
- constructor(filename) {
33
- super(`'${filename}' was ignored by react-docgen.`);
34
- // the magic string that react-docgen uses to check if a module is ignored
35
- this.code = "MODULE_NOT_FOUND";
36
- }
37
- }, RESOLVE_EXTENSIONS = [
38
- ".js",
39
- ".cts",
40
- // These were originally not in the code, I added them
41
- ".mts",
42
- // These were originally not in the code, I added them
43
- ".ctsx",
44
- // These were originally not in the code, I added them
45
- ".mtsx",
46
- // These were originally not in the code, I added them
47
- ".ts",
48
- ".tsx",
49
- ".mjs",
50
- ".cjs",
51
- ".mts",
52
- ".cts",
53
- ".jsx"
9
+ import * as __rspack_external_tsconfig_paths_8d3c5087 from "tsconfig-paths";
10
+ class ReactDocgenResolveError extends Error {
11
+ code = 'MODULE_NOT_FOUND';
12
+ constructor(filename){
13
+ super(`'${filename}' was ignored by react-docgen.`);
14
+ }
15
+ }
16
+ const RESOLVE_EXTENSIONS = [
17
+ '.js',
18
+ '.cts',
19
+ '.mts',
20
+ '.ctsx',
21
+ '.mtsx',
22
+ '.ts',
23
+ '.tsx',
24
+ '.mjs',
25
+ '.cjs',
26
+ '.mts',
27
+ '.cts',
28
+ '.jsx'
54
29
  ];
55
30
  function defaultLookupModule(filename, basedir) {
56
- let resolveOptions = {
57
- basedir,
58
- extensions: RESOLVE_EXTENSIONS,
59
- // we do not need to check core modules as we cannot import them anyway
60
- includeCoreModules: !1
61
- };
62
- try {
63
- return resolve.sync(filename, resolveOptions);
64
- } catch (error) {
65
- let ext = extname(filename), newFilename;
66
- switch (ext) {
67
- case ".js":
68
- case ".mjs":
69
- case ".cjs": {
70
- let tsFilename = `${filename.slice(0, -2)}ts`;
71
- try {
72
- return resolve.sync(tsFilename, {
31
+ const resolveOptions = {
32
+ basedir,
33
+ extensions: RESOLVE_EXTENSIONS,
34
+ includeCoreModules: false
35
+ };
36
+ try {
37
+ return resolve.sync(filename, resolveOptions);
38
+ } catch (error) {
39
+ const ext = extname(filename);
40
+ let newFilename;
41
+ switch(ext){
42
+ case '.js':
43
+ case '.mjs':
44
+ case '.cjs':
45
+ {
46
+ const tsFilename = `${filename.slice(0, -2)}ts`;
47
+ try {
48
+ return resolve.sync(tsFilename, {
49
+ ...resolveOptions,
50
+ extensions: []
51
+ });
52
+ } catch {
53
+ newFilename = `${filename.slice(0, -2)}tsx`;
54
+ }
55
+ break;
56
+ }
57
+ case '.jsx':
58
+ newFilename = `${filename.slice(0, -3)}tsx`;
59
+ break;
60
+ default:
61
+ throw error;
62
+ }
63
+ return resolve.sync(newFilename, {
73
64
  ...resolveOptions,
74
65
  extensions: []
75
- });
76
- } catch {
77
- newFilename = `${filename.slice(0, -2)}tsx`;
78
- }
79
- break;
80
- }
81
- case ".jsx":
82
- newFilename = `${filename.slice(0, -3)}tsx`;
83
- break;
84
- default:
85
- throw error;
66
+ });
86
67
  }
87
- return resolve.sync(newFilename, {
88
- ...resolveOptions,
89
- // we already know that there is an extension at this point, so no need to check other extensions
90
- extensions: []
91
- });
92
- }
93
68
  }
94
-
95
- // src/loaders/react-docgen-loader.ts
96
- var { getNameOrValue, isReactForwardRefCall } = utils, actualNameHandler = function(documentation, componentDefinition) {
97
- if (documentation.set("definedInFile", componentDefinition.hub.file.opts.filename), (componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id"))
98
- documentation.set(
99
- "actualName",
100
- getNameOrValue(componentDefinition.get("id"))
101
- );
102
- else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
103
- let currentPath = componentDefinition;
104
- for (; currentPath.parentPath; ) {
105
- if (currentPath.parentPath.isVariableDeclarator()) {
106
- documentation.set(
107
- "actualName",
108
- getNameOrValue(currentPath.parentPath.get("id"))
109
- );
110
- return;
111
- }
112
- if (currentPath.parentPath.isAssignmentExpression()) {
113
- let leftPath = currentPath.parentPath.get("left");
114
- if (leftPath.isIdentifier() || leftPath.isLiteral()) {
115
- documentation.set("actualName", getNameOrValue(leftPath));
116
- return;
69
+ const { getNameOrValue: getNameOrValue, isReactForwardRefCall: isReactForwardRefCall } = utils;
70
+ const react_docgen_loader_actualNameHandler = function(documentation, componentDefinition) {
71
+ documentation.set('definedInFile', componentDefinition.hub.file.opts.filename);
72
+ if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has('id')) documentation.set('actualName', getNameOrValue(componentDefinition.get('id')));
73
+ else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
74
+ let currentPath = componentDefinition;
75
+ while(currentPath.parentPath){
76
+ if (currentPath.parentPath.isVariableDeclarator()) return void documentation.set('actualName', getNameOrValue(currentPath.parentPath.get('id')));
77
+ if (currentPath.parentPath.isAssignmentExpression()) {
78
+ const leftPath = currentPath.parentPath.get('left');
79
+ if (leftPath.isIdentifier() || leftPath.isLiteral()) return void documentation.set('actualName', getNameOrValue(leftPath));
80
+ }
81
+ currentPath = currentPath.parentPath;
117
82
  }
118
- }
119
- currentPath = currentPath.parentPath;
83
+ documentation.set('actualName', '');
120
84
  }
121
- documentation.set("actualName", "");
122
- }
123
- }, defaultHandlers = Object.values(docgenHandlers).map((handler) => handler), defaultResolver = new docgenResolver.FindExportedDefinitionsResolver(), handlers = [...defaultHandlers, actualNameHandler], tsconfigPathsInitializeStatus = "uninitialized", resolveTsconfigPathsInitialingPromise, tsconfigPathsInitialingPromise = new Promise((resolve2) => {
124
- resolveTsconfigPathsInitialingPromise = resolve2;
125
- }), finishInitialization = () => {
126
- resolveTsconfigPathsInitialingPromise(), tsconfigPathsInitializeStatus = "initialized";
127
- }, matchPath, TSCONFIG_CANDIDATES = [
128
- "tsconfig.json",
129
- "tsconfig.base.json",
130
- "tsconfig.app.json"
131
- ], findTsconfigPath = async (cwd) => {
132
- for (let candidate of TSCONFIG_CANDIDATES) {
133
- let found = await findUp(candidate, { cwd });
134
- if (found)
135
- return found;
136
- }
137
85
  };
86
+ const defaultHandlers = Object.values(builtinHandlers).map((handler)=>handler);
87
+ const defaultResolver = new builtinResolvers.FindExportedDefinitionsResolver();
88
+ const handlers = [
89
+ ...defaultHandlers,
90
+ react_docgen_loader_actualNameHandler
91
+ ];
138
92
  async function reactDocgenLoader(source, map) {
139
- let callback = this.async(), options = this.getOptions() || {}, { debug = !1 } = options;
140
- if (tsconfigPathsInitializeStatus === "uninitialized") {
141
- tsconfigPathsInitializeStatus = "initializing";
142
- let tsconfigPath = await findTsconfigPath(process.cwd()), tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
143
- tsconfig.resultType === "success" && (logger.info("Using tsconfig paths for react-docgen"), matchPath = TsconfigPaths.createMatchPath(
144
- tsconfig.absoluteBaseUrl,
145
- tsconfig.paths,
146
- ["browser", "module", "main"]
147
- )), finishInitialization();
148
- }
149
- tsconfigPathsInitializeStatus === "initializing" && await tsconfigPathsInitialingPromise;
150
- try {
151
- let docgenResults = parse(source, {
152
- filename: this.resourcePath,
153
- resolver: defaultResolver,
154
- handlers,
155
- importer: getReactDocgenImporter(matchPath),
156
- babelOptions: {
157
- babelrc: !1,
158
- configFile: !1
159
- }
160
- }), magicString = new MagicString(source);
161
- for (let info of docgenResults) {
162
- let { actualName, definedInFile, ...docgenInfo } = info;
163
- if (actualName && definedInFile === this.resourcePath) {
164
- let docNode = JSON.stringify(docgenInfo);
165
- magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
166
- }
93
+ const callback = this.async();
94
+ const options = this.getOptions() || {};
95
+ const { debug = false } = options;
96
+ try {
97
+ const matchPath = createTsconfigMatchPath(this.resourcePath);
98
+ const docgenResults = parse(source, {
99
+ filename: this.resourcePath,
100
+ resolver: defaultResolver,
101
+ handlers: handlers,
102
+ importer: getReactDocgenImporter(matchPath),
103
+ babelOptions: {
104
+ babelrc: false,
105
+ configFile: false
106
+ }
107
+ });
108
+ const magicString = new magic_string(source);
109
+ for (const info of docgenResults){
110
+ const { actualName, definedInFile, ...docgenInfo } = info;
111
+ if (actualName && definedInFile === this.resourcePath) {
112
+ const docNode = JSON.stringify(docgenInfo);
113
+ magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
114
+ }
115
+ }
116
+ callback(null, magicString.toString(), map ?? magicString.generateMap({
117
+ hires: true,
118
+ source: this.resourcePath,
119
+ includeContent: true
120
+ }));
121
+ } catch (error) {
122
+ if (error.code === ERROR_CODES.MISSING_DEFINITION) callback(null, source);
123
+ else {
124
+ if (debug) {
125
+ logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`);
126
+ logger.error(error);
127
+ } else logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`);
128
+ callback(null, source);
129
+ }
167
130
  }
168
- callback(
169
- null,
170
- magicString.toString(),
171
- map ?? magicString.generateMap({
172
- hires: !0,
173
- source: this.resourcePath,
174
- includeContent: !0
175
- })
176
- );
177
- } catch (error) {
178
- error.code === ERROR_CODES.MISSING_DEFINITION || (debug ? (logger.warn(
179
- `Failed to parse ${this.resourcePath} with react-docgen. Please use the below error message and the content of the file which causes the error to report the issue to the maintainers of react-docgen. https://github.com/reactjs/react-docgen`
180
- ), logger.error(error)) : logger.warn(
181
- `Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`
182
- )), callback(null, source);
183
- }
184
131
  }
185
132
  function getReactDocgenImporter(matchingPath) {
186
- return makeFsImporter((filename, basedir) => {
187
- let mappedFilenameByPaths = matchingPath && matchingPath(filename) || filename, result = defaultLookupModule(mappedFilenameByPaths, basedir);
188
- if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext)))
189
- return result;
190
- throw new ReactDocgenResolveError(filename);
191
- });
133
+ return makeFsImporter((filename, basedir)=>{
134
+ const mappedFilenameByPaths = (()=>{
135
+ if (matchingPath) {
136
+ const match = matchingPath(filename);
137
+ return match || filename;
138
+ }
139
+ return filename;
140
+ })();
141
+ const result = defaultLookupModule(mappedFilenameByPaths, basedir);
142
+ if (result.includes(`${sep}react-native${sep}index.js`)) {
143
+ const replaced = result.replace(`${sep}react-native${sep}index.js`, `${sep}react-native-web${sep}dist${sep}index.js`);
144
+ if (existsSync(replaced)) {
145
+ if (RESOLVE_EXTENSIONS.find((ext)=>result.endsWith(ext))) return replaced;
146
+ }
147
+ }
148
+ if (RESOLVE_EXTENSIONS.find((ext)=>result.endsWith(ext))) return result;
149
+ throw new ReactDocgenResolveError(filename);
150
+ });
192
151
  }
193
- export {
194
- reactDocgenLoader as default,
195
- getReactDocgenImporter
196
- };
152
+ const matchPathByTsconfigPath = new Map();
153
+ function createTsconfigMatchPath(filePath) {
154
+ const tsconfigPath = findTsconfigPathForFile(dirname(filePath), filePath);
155
+ if (!tsconfigPath) return;
156
+ const cached = matchPathByTsconfigPath.get(tsconfigPath);
157
+ if (cached) return cached;
158
+ const tsconfig = __rspack_external_tsconfig_paths_8d3c5087.loadConfig(tsconfigPath);
159
+ if ('success' !== tsconfig.resultType) return;
160
+ logger.debug('Using tsconfig paths for react-docgen');
161
+ const matchPath = __rspack_external_tsconfig_paths_8d3c5087.createMatchPath(getTsconfigPathsBaseDir(tsconfig.configFileAbsolutePath), tsconfig.paths, [
162
+ 'browser',
163
+ 'module',
164
+ 'main'
165
+ ]);
166
+ matchPathByTsconfigPath.set(tsconfigPath, matchPath);
167
+ return matchPath;
168
+ }
169
+ export default reactDocgenLoader;
170
+ export { getReactDocgenImporter };
@@ -1,55 +1,71 @@
1
- import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
2
- import { StorybookConfig as StorybookConfig$1, CompatibleString, TypescriptOptions } from 'storybook/internal/types';
3
- import { StorybookConfigRsbuild, BuilderOptions, TypescriptOptions as TypescriptOptions$1 } from 'storybook-builder-rsbuild';
4
-
5
- type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
6
- type BuilderName = CompatibleString<'storybook-builder-rsbuild'>;
7
- type FrameworkOptions = {
8
- builder?: BuilderOptions;
9
- strictMode?: boolean;
10
- /**
11
- * Use React's legacy root API to mount components
12
- * @description
13
- * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
14
- * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
15
- * @default false
16
- */
17
- legacyRootApi?: boolean;
18
- };
19
- type TypescriptOptionsReact = {
20
- /**
21
- * Sets the type of Docgen when working with React and TypeScript
22
- *
23
- * @default `'react-docgen'`
24
- */
25
- reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
26
- /**
27
- * Configures `react-docgen-typescript-plugin`
28
- *
29
- * @default
30
- * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
31
- */
32
- reactDocgenTypescriptOptions: PluginOptions;
33
- };
34
- type StorybookConfigFramework = {
35
- framework: FrameworkName | {
36
- name: FrameworkName;
37
- options: FrameworkOptions;
38
- };
39
- core?: StorybookConfig$1['core'] & {
40
- builder?: BuilderName | {
41
- name: BuilderName;
42
- options: BuilderOptions;
43
- };
44
- };
45
- typescript?: Partial<TypescriptOptions & TypescriptOptions$1 & TypescriptOptionsReact>;
46
- };
47
- /**
48
- * The interface for Storybook configuration in `main.ts` files.
49
- */
50
- type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
51
-
52
- declare function defineMain(config: StorybookConfig): StorybookConfig;
53
-
54
- export { defineMain };
55
- export type { StorybookConfig };
1
+ import type { BuilderOptions } from 'storybook-builder-rsbuild';
2
+ import type { CompatibleString } from 'storybook/internal/types';
3
+ import type { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
4
+ import type { StorybookConfig as StorybookConfig_2 } from 'storybook/internal/types';
5
+ import type { StorybookConfigRsbuild } from 'storybook-builder-rsbuild';
6
+ import type { TypescriptOptions } from 'storybook/internal/types';
7
+ import type { TypescriptOptions as TypescriptOptions_2 } from 'storybook-builder-rsbuild';
8
+
9
+ declare type BuilderName = CompatibleString<'storybook-builder-rsbuild'>;
10
+
11
+ export declare function defineMain(config: StorybookConfig): StorybookConfig;
12
+
13
+ declare type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
14
+
15
+ declare type FrameworkOptions = {
16
+ builder?: BuilderOptions;
17
+ strictMode?: boolean;
18
+ /**
19
+ * Use React's legacy root API to mount components
20
+ * @description
21
+ * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
22
+ * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
23
+ * @default false
24
+ */
25
+ legacyRootApi?: boolean;
26
+ };
27
+
28
+ /**
29
+ * The interface for Storybook configuration in `main.ts` files.
30
+ */
31
+ export declare type StorybookConfig = Omit<StorybookConfig_2, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
32
+
33
+ declare type StorybookConfigFramework = {
34
+ framework: FrameworkName | {
35
+ name: FrameworkName;
36
+ options: FrameworkOptions;
37
+ };
38
+ core?: StorybookConfig_2['core'] & {
39
+ builder?: BuilderName | {
40
+ name: BuilderName;
41
+ options: BuilderOptions;
42
+ };
43
+ };
44
+ features?: StorybookConfig_2['features'] & {
45
+ /**
46
+ * Enable the experimental `.test` function in CSF Next
47
+ *
48
+ * @see https://storybook.js.org/docs/api/main-config/main-config-features#experimentaltestsyntax
49
+ */
50
+ experimentalTestSyntax?: boolean;
51
+ };
52
+ typescript?: Partial<TypescriptOptions & TypescriptOptions_2 & TypescriptOptionsReact>;
53
+ };
54
+
55
+ declare type TypescriptOptionsReact = {
56
+ /**
57
+ * Sets the type of Docgen when working with React and TypeScript
58
+ *
59
+ * @default `'react-docgen'`
60
+ */
61
+ reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
62
+ /**
63
+ * Configures `react-docgen-typescript-plugin`
64
+ *
65
+ * @default
66
+ * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
67
+ */
68
+ reactDocgenTypescriptOptions: PluginOptions;
69
+ };
70
+
71
+ export { }
@@ -1,20 +1,5 @@
1
- import CJS_COMPAT_NODE_URL_a0ef041aa6a9c434 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434 from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_a0ef041aa6a9c434.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_a0ef041aa6a9c434.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_a0ef041aa6a9c434.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import "../_node-chunks/chunk-TPE2Q567.js";
13
-
14
- // src/node/index.ts
1
+ import "node:module";
15
2
  function defineMain(config) {
16
- return config;
3
+ return config;
17
4
  }
18
- export {
19
- defineMain
20
- };
5
+ export { defineMain };
package/dist/preset.d.ts CHANGED
@@ -1,55 +1,74 @@
1
- import { StorybookConfig as StorybookConfig$1, CompatibleString, TypescriptOptions, PresetProperty } from 'storybook/internal/types';
2
- import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
3
- import { StorybookConfigRsbuild, BuilderOptions, TypescriptOptions as TypescriptOptions$1 } from 'storybook-builder-rsbuild';
4
-
5
- type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
6
- type BuilderName = CompatibleString<'storybook-builder-rsbuild'>;
7
- type FrameworkOptions = {
8
- builder?: BuilderOptions;
9
- strictMode?: boolean;
10
- /**
11
- * Use React's legacy root API to mount components
12
- * @description
13
- * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
14
- * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
15
- * @default false
16
- */
17
- legacyRootApi?: boolean;
18
- };
19
- type TypescriptOptionsReact = {
20
- /**
21
- * Sets the type of Docgen when working with React and TypeScript
22
- *
23
- * @default `'react-docgen'`
24
- */
25
- reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
26
- /**
27
- * Configures `react-docgen-typescript-plugin`
28
- *
29
- * @default
30
- * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
31
- */
32
- reactDocgenTypescriptOptions: PluginOptions;
33
- };
34
- type StorybookConfigFramework = {
35
- framework: FrameworkName | {
36
- name: FrameworkName;
37
- options: FrameworkOptions;
38
- };
39
- core?: StorybookConfig$1['core'] & {
40
- builder?: BuilderName | {
41
- name: BuilderName;
42
- options: BuilderOptions;
43
- };
44
- };
45
- typescript?: Partial<TypescriptOptions & TypescriptOptions$1 & TypescriptOptionsReact>;
46
- };
47
- /**
48
- * The interface for Storybook configuration in `main.ts` files.
49
- */
50
- type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
51
-
52
- declare const rsbuildFinal: NonNullable<StorybookConfig['rsbuildFinal']>;
53
- declare const core: PresetProperty<'core'>;
54
-
55
- export { core, rsbuildFinal };
1
+ import type { BuilderOptions } from 'storybook-builder-rsbuild';
2
+ import type { CompatibleString } from 'storybook/internal/types';
3
+ import type { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
4
+ import type { PresetProperty } from 'storybook/internal/types';
5
+ import type { StorybookConfig as StorybookConfig_2 } from 'storybook/internal/types';
6
+ import type { StorybookConfigRsbuild } from 'storybook-builder-rsbuild';
7
+ import type { TypescriptOptions } from 'storybook/internal/types';
8
+ import type { TypescriptOptions as TypescriptOptions_2 } from 'storybook-builder-rsbuild';
9
+
10
+ declare type BuilderName = CompatibleString<'storybook-builder-rsbuild'>;
11
+
12
+ export declare const core: PresetProperty<'core'>;
13
+
14
+ declare type FrameworkName = CompatibleString<'storybook-react-rsbuild'>;
15
+
16
+ declare type FrameworkOptions = {
17
+ builder?: BuilderOptions;
18
+ strictMode?: boolean;
19
+ /**
20
+ * Use React's legacy root API to mount components
21
+ * @description
22
+ * React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
23
+ * If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
24
+ * @default false
25
+ */
26
+ legacyRootApi?: boolean;
27
+ };
28
+
29
+ export declare const rsbuildFinal: NonNullable<StorybookConfig['rsbuildFinal']>;
30
+
31
+ /**
32
+ * The interface for Storybook configuration in `main.ts` files.
33
+ */
34
+ declare type StorybookConfig = Omit<StorybookConfig_2, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
35
+
36
+ declare type StorybookConfigFramework = {
37
+ framework: FrameworkName | {
38
+ name: FrameworkName;
39
+ options: FrameworkOptions;
40
+ };
41
+ core?: StorybookConfig_2['core'] & {
42
+ builder?: BuilderName | {
43
+ name: BuilderName;
44
+ options: BuilderOptions;
45
+ };
46
+ };
47
+ features?: StorybookConfig_2['features'] & {
48
+ /**
49
+ * Enable the experimental `.test` function in CSF Next
50
+ *
51
+ * @see https://storybook.js.org/docs/api/main-config/main-config-features#experimentaltestsyntax
52
+ */
53
+ experimentalTestSyntax?: boolean;
54
+ };
55
+ typescript?: Partial<TypescriptOptions & TypescriptOptions_2 & TypescriptOptionsReact>;
56
+ };
57
+
58
+ declare type TypescriptOptionsReact = {
59
+ /**
60
+ * Sets the type of Docgen when working with React and TypeScript
61
+ *
62
+ * @default `'react-docgen'`
63
+ */
64
+ reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
65
+ /**
66
+ * Configures `react-docgen-typescript-plugin`
67
+ *
68
+ * @default
69
+ * @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
70
+ */
71
+ reactDocgenTypescriptOptions: PluginOptions;
72
+ };
73
+
74
+ export { }