@storybook/react 11.0.0-beta.0 → 11.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/_browser-chunks/{chunk-2TQVKMJE.js → chunk-EA5DV32Q.js} +36 -1
  2. package/dist/_browser-chunks/{chunk-EZD3TIPB.js → chunk-I62VTYU3.js} +17 -4
  3. package/dist/_browser-chunks/{chunk-7QIM3PHH.js → chunk-U7XUEUFQ.js} +3 -3
  4. package/dist/_browser-chunks/{chunk-LGSTPTL6.js → chunk-WWHCZJWM.js} +10 -9
  5. package/dist/_node-chunks/{chunk-27VFNEPI.js → chunk-2DNUEB5U.js} +6798 -15258
  6. package/dist/_node-chunks/chunk-ASUAJQT5.js +63 -0
  7. package/dist/_node-chunks/chunk-BWU7O3KC.js +61 -0
  8. package/dist/_node-chunks/chunk-DW2HJ23M.js +1674 -0
  9. package/dist/_node-chunks/chunk-PXKXGEPO.js +6643 -0
  10. package/dist/_node-chunks/chunk-QRCEILHM.js +93 -0
  11. package/dist/_node-chunks/chunk-TP7UUO2M.js +18 -0
  12. package/dist/_node-chunks/chunk-VQBUQHU3.js +33 -0
  13. package/dist/_node-chunks/chunk-XIFLZILW.js +65 -0
  14. package/dist/_node-chunks/chunk-XQPV7U3R.js +1395 -0
  15. package/dist/_node-chunks/extractArgTypesFromComponentFile-PKEIPQGN.js +44 -0
  16. package/dist/_node-chunks/extractReactDocgenInfo-J6CKNSQN.js +59 -0
  17. package/dist/_node-chunks/extractReactTypescriptDocgenInfo-AJTC3KA3.js +105 -0
  18. package/dist/_node-chunks/reactDocgen-YAGNM6ZQ.js +26 -0
  19. package/dist/builder-docgen.d.ts +51 -0
  20. package/dist/builder-docgen.js +25 -0
  21. package/dist/{chunk-DwM7QKaD.d.ts → chunk-6b3AvPEC.d.ts} +66 -1
  22. package/dist/docgen/docgen-worker.js +23 -87
  23. package/dist/entry-preview-argtypes.js +1 -1
  24. package/dist/entry-preview-docs.js +1 -1
  25. package/dist/entry-preview.js +1 -1
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +4 -4
  28. package/dist/preset.js +79 -1363
  29. package/dist/preview.d.ts +1 -1
  30. package/dist/preview.js +4 -4
  31. package/package.json +21 -6
  32. package/template/cli/js/Button.stories.js +11 -10
  33. package/template/cli/js/Header.stories.js +6 -5
  34. package/template/cli/js/Page.stories.js +6 -5
  35. package/template/cli/ts/Button.stories.ts +11 -14
  36. package/template/cli/ts/Header.stories.ts +6 -9
  37. package/template/cli/ts/Page.stories.ts +6 -9
@@ -0,0 +1,44 @@
1
+ import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ getSharedComponentMetaManager
14
+ } from "./chunk-VQBUQHU3.js";
15
+ import {
16
+ extractArgTypesFromComponentMeta
17
+ } from "./chunk-QRCEILHM.js";
18
+ import "./chunk-PXKXGEPO.js";
19
+ import "./chunk-TP7UUO2M.js";
20
+ import "./chunk-DW2HJ23M.js";
21
+ import "./chunk-2DNUEB5U.js";
22
+ import "./chunk-BWU7O3KC.js";
23
+ import "./chunk-ASUAJQT5.js";
24
+
25
+ // src/docgen/extractArgTypesFromComponentFile.ts
26
+ async function extractArgTypesFromComponentFile({
27
+ componentFilePath,
28
+ componentExportName = "default",
29
+ typeScriptSpecifier
30
+ }) {
31
+ let manager = await getSharedComponentMetaManager(typeScriptSpecifier);
32
+ if (!manager)
33
+ return null;
34
+ let component = {
35
+ componentName: componentExportName,
36
+ importName: componentExportName,
37
+ path: componentFilePath,
38
+ isPackage: !1
39
+ };
40
+ return manager.batchExtract([{ storyPath: componentFilePath, component }]), extractArgTypesFromComponentMeta(component.reactComponentMeta) ?? null;
41
+ }
42
+ export {
43
+ extractArgTypesFromComponentFile
44
+ };
@@ -0,0 +1,59 @@
1
+ import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ parseWithReactDocgen
14
+ } from "./chunk-XQPV7U3R.js";
15
+ import {
16
+ cachedReadFileSync
17
+ } from "./chunk-DW2HJ23M.js";
18
+ import {
19
+ extractArgTypes
20
+ } from "./chunk-2DNUEB5U.js";
21
+ import "./chunk-BWU7O3KC.js";
22
+ import "./chunk-ASUAJQT5.js";
23
+
24
+ // src/componentManifest/reactDocgen/extractReactDocgenInfo.ts
25
+ import { logger } from "storybook/internal/node-logger";
26
+ function getComponentDocgen(filePath, componentName) {
27
+ try {
28
+ let code = cachedReadFileSync(filePath, "utf-8"), docgens = parseWithReactDocgen(code, filePath);
29
+ if (docgens.length === 0)
30
+ return null;
31
+ if (componentName) {
32
+ let matchingDocgen = docgens.find(
33
+ (docgen) => docgen.actualName === componentName || docgen.displayName === componentName || docgen.exportName === componentName
34
+ );
35
+ return matchingDocgen ? {
36
+ componentName: matchingDocgen.actualName || matchingDocgen.displayName || componentName,
37
+ reactDocgen: { type: "success", data: matchingDocgen }
38
+ } : null;
39
+ }
40
+ let firstDocgen = docgens[0];
41
+ return {
42
+ componentName: firstDocgen.actualName || firstDocgen.displayName || "Unknown",
43
+ reactDocgen: { type: "success", data: firstDocgen }
44
+ };
45
+ } catch (error) {
46
+ return logger.debug(`Error parsing component file for docgen ${filePath}: ${error}`), null;
47
+ }
48
+ }
49
+ var extractArgTypesFromDocgen = ({
50
+ componentFilePath,
51
+ componentExportName
52
+ }) => {
53
+ let docgen = getComponentDocgen(componentFilePath, componentExportName);
54
+ return !docgen || docgen.reactDocgen.type !== "success" ? null : extractArgTypes({ __docgenInfo: docgen.reactDocgen.data }) ?? {};
55
+ };
56
+ export {
57
+ extractArgTypesFromDocgen,
58
+ getComponentDocgen
59
+ };
@@ -0,0 +1,105 @@
1
+ import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ extractArgTypes
14
+ } from "./chunk-2DNUEB5U.js";
15
+ import "./chunk-BWU7O3KC.js";
16
+ import "./chunk-ASUAJQT5.js";
17
+
18
+ // src/componentManifest/reactDocgen/extractReactTypescriptDocgenInfo.ts
19
+ import { logger } from "storybook/internal/node-logger";
20
+
21
+ // src/componentManifest/reactDocgen/utils.ts
22
+ import { findTsconfigPathForFile } from "storybook/internal/common";
23
+ import { dirname } from "node:path";
24
+ var REACT_NODE_TYPES = /* @__PURE__ */ new Set([
25
+ "JSX.Element",
26
+ "ComponentType",
27
+ "ReactComponentType",
28
+ "ReactElement",
29
+ "ReactReactElement",
30
+ "ElementType",
31
+ "ReactElementType",
32
+ "ReactNode",
33
+ "ReactReactNode"
34
+ ]), KNOWN_TYPE_NAMES = /* @__PURE__ */ new Set([
35
+ "boolean",
36
+ "string",
37
+ "number",
38
+ "Date",
39
+ ...REACT_NODE_TYPES,
40
+ "signature",
41
+ "union",
42
+ "Array",
43
+ "tuple",
44
+ "literal",
45
+ "null",
46
+ "void",
47
+ "any",
48
+ "unknown"
49
+ ]);
50
+ var getTsConfig = async (componentFilePath) => {
51
+ try {
52
+ let imported = await import("typescript"), ts = imported.default ?? imported, tsconfigPath = componentFilePath ? findTsconfigPathForFile(dirname(componentFilePath), componentFilePath) : ts.findConfigFile(process.cwd(), ts.sys.fileExists);
53
+ if (tsconfigPath === void 0)
54
+ return {};
55
+ let basePath = dirname(tsconfigPath), { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
56
+ return error ? {} : ts.parseJsonConfigFileContent(config, ts.sys, basePath, {}, tsconfigPath).options;
57
+ } catch {
58
+ return {};
59
+ }
60
+ };
61
+
62
+ // src/componentManifest/reactDocgen/extractReactTypescriptDocgenInfo.ts
63
+ var extractArgTypesFromDocgenTypescript = async ({
64
+ componentFilePath,
65
+ componentExportName,
66
+ reactDocgenTypescriptOptions
67
+ }) => {
68
+ try {
69
+ let { withCompilerOptions } = (await import("react-docgen-typescript")).default, defaultOptions = {
70
+ shouldExtractLiteralValuesFromEnum: !0,
71
+ shouldRemoveUndefinedFromOptional: !0,
72
+ propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
73
+ // We *need* this set so that RDT returns default values in the same format as react-docgen
74
+ savePropValueAsString: !0
75
+ }, tsConfig = await getTsConfig(componentFilePath), mergedOptions = {
76
+ ...defaultOptions,
77
+ ...reactDocgenTypescriptOptions,
78
+ // Always ensure savePropValueAsString is true for consistency
79
+ savePropValueAsString: !0
80
+ }, docgens = withCompilerOptions(
81
+ { ...tsConfig, noErrorTruncation: !0, strict: !0 },
82
+ mergedOptions
83
+ ).parse(componentFilePath);
84
+ if (!docgens || docgens.length === 0)
85
+ return null;
86
+ let targetDocgen = docgens[0];
87
+ if (componentExportName) {
88
+ let match = docgens.find(
89
+ (d) => d.displayName === componentExportName || d.filePath?.includes(componentExportName)
90
+ );
91
+ if (match)
92
+ targetDocgen = match;
93
+ else
94
+ return null;
95
+ }
96
+ return extractArgTypes({ __docgenInfo: targetDocgen }) ?? {};
97
+ } catch (error) {
98
+ return logger.debug(
99
+ `Error parsing component file with react-docgen-typescript ${componentFilePath}: ${error}`
100
+ ), null;
101
+ }
102
+ };
103
+ export {
104
+ extractArgTypesFromDocgenTypescript
105
+ };
@@ -0,0 +1,26 @@
1
+ import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ getMatchingDocgen,
14
+ getReactDocgen,
15
+ getReactDocgenImporter,
16
+ parseWithReactDocgen
17
+ } from "./chunk-XQPV7U3R.js";
18
+ import "./chunk-DW2HJ23M.js";
19
+ import "./chunk-BWU7O3KC.js";
20
+ import "./chunk-ASUAJQT5.js";
21
+ export {
22
+ getMatchingDocgen,
23
+ getReactDocgen,
24
+ getReactDocgenImporter,
25
+ parseWithReactDocgen
26
+ };
@@ -0,0 +1,51 @@
1
+ import { Options } from "storybook/internal/types";
2
+
3
+ //#region code/renderers/react/.dts-emit/code/renderers/react/src/componentManifest/reactDocgen/utils.d.ts
4
+ type ReactDocgenConfig = 'react-docgen' | 'react-docgen-typescript' | false;
5
+ //#endregion
6
+ //#region code/renderers/react/.dts-emit/code/renderers/react/src/builder-docgen.d.ts
7
+ /**
8
+ * Packages that only React's deprecated builder docgen (`features.docgenServer: false`) uses, with
9
+ * the version range Storybook supports. `@storybook/react`, `@storybook/react-vite`,
10
+ * `@storybook/preset-react-webpack` and the React frameworks declare them as optional peer
11
+ * dependencies with these ranges, which a test checks.
12
+ */
13
+ declare const REACT_BUILDER_DOCGEN_PACKAGES: {
14
+ readonly 'react-docgen': '^8.0.2';
15
+ readonly 'react-docgen-typescript': '^2.2.2';
16
+ readonly '@joshwooding/vite-plugin-react-docgen-typescript': '^0.7.0';
17
+ readonly '@storybook/react-docgen-typescript-plugin': '1.0.6--canary.9.0c3f3b7.0';
18
+ };
19
+ type ReactBuilderDocgenPackage = keyof typeof REACT_BUILDER_DOCGEN_PACKAGES;
20
+ /**
21
+ * Return the packages that builder docgen needs for a `typescript.reactDocgen` mode.
22
+ *
23
+ * `react-docgen-typescript` mode needs the builder plugin and `react-docgen-typescript` itself,
24
+ * which `@storybook/react` loads for the components manifest. In that mode the `react-docgen` pass
25
+ * over JavaScript files is optional.
26
+ */
27
+ declare function getReactBuilderDocgenPackages(reactDocgen: ReactDocgenConfig | undefined, builder: 'vite' | 'webpack'): ReactBuilderDocgenPackage[];
28
+ /** Return whether a builder docgen package resolves in a version Storybook supports. */
29
+ declare const isReactBuilderDocgenPackageInstalled: (resolve: (specifier: string) => string, packageName: ReactBuilderDocgenPackage) => boolean;
30
+ /**
31
+ * Decide which `typescript.reactDocgen` mode builder docgen runs in, check that its packages are
32
+ * installed, and report it when they are not. Call it from a framework preset once builder docgen
33
+ * is active.
34
+ *
35
+ * @returns The mode builder docgen runs in, or `undefined` when it must not run.
36
+ * @throws {BuilderDocgenPackagesMissingError} When the main config sets `features.docgenServer:
37
+ * false` and packages are missing.
38
+ */
39
+ declare function prepareReactBuilderDocgen({
40
+ reactDocgen,
41
+ builder,
42
+ resolve,
43
+ options
44
+ }: {
45
+ reactDocgen: Exclude<ReactDocgenConfig, false>;
46
+ builder: 'vite' | 'webpack'; /** Resolve from the framework package, which declares the packages as optional peers. */
47
+ resolve: (specifier: string) => string;
48
+ options: Pick<Options, 'configDir' | 'presets'>;
49
+ }): Promise<Exclude<ReactDocgenConfig, false> | undefined>;
50
+ //#endregion
51
+ export { REACT_BUILDER_DOCGEN_PACKAGES, ReactBuilderDocgenPackage, getReactBuilderDocgenPackages, isReactBuilderDocgenPackageInstalled, prepareReactBuilderDocgen };
@@ -0,0 +1,25 @@
1
+ import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ REACT_BUILDER_DOCGEN_PACKAGES,
14
+ getReactBuilderDocgenPackages,
15
+ isReactBuilderDocgenPackageInstalled,
16
+ prepareReactBuilderDocgen
17
+ } from "./_node-chunks/chunk-XIFLZILW.js";
18
+ import "./_node-chunks/chunk-TP7UUO2M.js";
19
+ import "./_node-chunks/chunk-ASUAJQT5.js";
20
+ export {
21
+ REACT_BUILDER_DOCGEN_PACKAGES,
22
+ getReactBuilderDocgenPackages,
23
+ isReactBuilderDocgenPackageInstalled,
24
+ prepareReactBuilderDocgen
25
+ };
@@ -86,6 +86,71 @@ interface ReactTypes extends ReactRenderer {
86
86
  parameters: ReactParameters;
87
87
  }
88
88
  type StoryFnReactReturnType = JSX.Element;
89
+ /**
90
+ * A prop as `react-docgen-typescript` passes it to a `propFilter` function.
91
+ *
92
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
93
+ */
94
+ interface ReactDocgenTypescriptPropItem {
95
+ name: string;
96
+ required: boolean;
97
+ type: {
98
+ name: string;
99
+ value?: any;
100
+ raw?: string;
101
+ };
102
+ description: string;
103
+ defaultValue: any;
104
+ parent?: {
105
+ name: string;
106
+ fileName: string;
107
+ };
108
+ declarations?: {
109
+ name: string;
110
+ fileName: string;
111
+ }[];
112
+ tags?: object;
113
+ }
114
+ /**
115
+ * The `react-docgen-typescript` parser options, which the deprecated builder docgen plugins of
116
+ * `@storybook/react-vite` and `@storybook/preset-react-webpack` accept.
117
+ *
118
+ * Copied from `react-docgen-typescript`'s declarations instead of imported: it is an optional peer
119
+ * dependency, and a `.d.ts` import of a missing package fails `tsc` without `skipLibCheck`. The
120
+ * TypeScript symbol and source file are typed structurally, because the TypeScript 7 `typescript`
121
+ * package has no compiler API types. Type tests in the frameworks keep this assignable both ways
122
+ * with the originals.
123
+ *
124
+ * @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
125
+ */
126
+ interface ReactDocgenTypescriptParserOptions {
127
+ propFilter?: {
128
+ skipPropsWithName?: string[] | string;
129
+ skipPropsWithoutDoc?: boolean;
130
+ } | {
131
+ bivarianceHack(prop: ReactDocgenTypescriptPropItem, component: {
132
+ name: string;
133
+ }): boolean;
134
+ }['bivarianceHack'];
135
+ componentNameResolver?: {
136
+ bivarianceHack(symbol: {
137
+ readonly name: string;
138
+ getName(): string;
139
+ }, source: {
140
+ readonly fileName: string;
141
+ readonly text: string;
142
+ }): string | undefined | null | false;
143
+ }['bivarianceHack'];
144
+ shouldExtractLiteralValuesFromEnum?: boolean;
145
+ shouldRemoveUndefinedFromOptional?: boolean;
146
+ shouldExtractValuesFromUnion?: boolean;
147
+ shouldSortUnions?: boolean;
148
+ skipChildrenPropWithoutDoc?: boolean;
149
+ savePropValueAsString?: boolean;
150
+ shouldIncludePropTagMap?: boolean;
151
+ shouldIncludeExpression?: boolean;
152
+ customComponentTypes?: string[];
153
+ }
89
154
  //#endregion
90
155
  //#region code/renderers/react/.dts-emit/code/renderers/react/src/preview.d.ts
91
156
  /**
@@ -236,4 +301,4 @@ interface ReactStory<T extends ReactTypes, TInput extends {
236
301
  Component: ComponentType<Partial<T['args']>>;
237
302
  }
238
303
  //#endregion
239
- export { ReactRenderer as a, __definePreview as i, ReactPreview as n, ReactTypes as o, ReactStory as r, Simplify as s, ReactMeta as t };
304
+ export { ReactDocgenTypescriptParserOptions as a, ReactTypes as c, __definePreview as i, Simplify as l, ReactPreview as n, ReactDocgenTypescriptPropItem as o, ReactStory as r, ReactRenderer as s, ReactMeta as t };
@@ -1,102 +1,38 @@
1
- import CJS_COMPAT_NODE_URL_z12wrn40ro from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_z12wrn40ro from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_z12wrn40ro from "node:module";
1
+ import CJS_COMPAT_NODE_URL_0pbco1v5vos from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_0pbco1v5vos from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_0pbco1v5vos from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_z12wrn40ro.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_z12wrn40ro.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_z12wrn40ro.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_0pbco1v5vos.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_0pbco1v5vos.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_0pbco1v5vos.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
+ import {
13
+ buildDocgenPayload
14
+ } from "../_node-chunks/chunk-QRCEILHM.js";
12
15
  import {
13
16
  ComponentMetaManager,
14
- buildComponentDocgenFromResolved,
15
- extractArgTypes,
16
- posix,
17
- resolveStoryFileComponents
18
- } from "../_node-chunks/chunk-27VFNEPI.js";
17
+ loadDocgenTypeScript
18
+ } from "../_node-chunks/chunk-PXKXGEPO.js";
19
+ import "../_node-chunks/chunk-TP7UUO2M.js";
20
+ import "../_node-chunks/chunk-DW2HJ23M.js";
21
+ import "../_node-chunks/chunk-2DNUEB5U.js";
22
+ import "../_node-chunks/chunk-BWU7O3KC.js";
23
+ import "../_node-chunks/chunk-ASUAJQT5.js";
19
24
 
20
25
  // src/docgen/docgen-worker.ts
21
- import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
26
+ import {
27
+ createLazyDocgenMiddleware
28
+ } from "storybook/internal/common";
22
29
  import { logger } from "storybook/internal/node-logger";
23
-
24
- // src/docgen/buildDocgen.ts
25
- import { getStoryImportPathFromEntry } from "storybook/internal/common";
26
- var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttributes", "ClassAttributes"]);
27
- function isReactAttribute(prop) {
28
- return !!prop.parent && REACT_ATTRIBUTE_INTERFACES.has(prop.parent.name) && /(^|[\\/])node_modules[\\/]/.test(prop.parent.fileName);
29
- }
30
- function extractArgTypesFromComponentMeta(componentMeta) {
31
- if (!componentMeta)
32
- return;
33
- let props = Object.fromEntries(
34
- Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
35
- name,
36
- prop.defaultValue ? { ...prop, defaultValue: { ...prop.defaultValue, computed: !1 } } : prop
37
- ])
38
- );
39
- return extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
40
- }
41
- function addArgTypesFromComponentMeta(payload) {
42
- let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
43
- Object.entries(payload.subcomponents).map(([name, subcomponent]) => [
44
- name,
45
- {
46
- ...subcomponent,
47
- argTypes: extractArgTypesFromComponentMeta(subcomponent.reactComponentMeta)
48
- }
49
- ])
50
- ) : void 0;
51
- return {
52
- ...payload,
53
- ...argTypes ? { argTypes } : {},
54
- ...subcomponents ? { subcomponents } : {}
55
- };
56
- }
57
- async function buildDocgenPayload(input, context) {
58
- let storyFilePath = getStoryImportPathFromEntry(input.entry);
59
- if (!storyFilePath)
60
- return;
61
- let storyPath = (context.resolvePath ?? ((importPath) => posix.join(process.cwd(), importPath)))(storyFilePath), resolved;
62
- try {
63
- resolved = await resolveStoryFileComponents({
64
- storyPath,
65
- title: input.entry.title,
66
- typescriptOptions: context.typescriptOptions,
67
- docgenEngine: "react-component-meta"
68
- });
69
- } catch {
70
- return;
71
- }
72
- let { csf, componentName, component, subcomponents, storyFile } = resolved, usableSubcomponents = subcomponents.filter(
73
- (sub) => sub.component !== void 0
74
- ), storyRefs = [
75
- ...component ? [{ storyPath, component }] : [],
76
- ...usableSubcomponents.map((sub) => ({ storyPath, component: sub.component }))
77
- ];
78
- storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs);
79
- let componentDocgen = buildComponentDocgenFromResolved({
80
- entry: input.entry,
81
- storyPath,
82
- storyFilePath,
83
- storyFile,
84
- csf,
85
- componentName,
86
- component,
87
- subcomponents,
88
- docgenEngine: "react-component-meta"
89
- });
90
- return addArgTypesFromComponentMeta(componentDocgen);
91
- }
92
-
93
- // src/docgen/docgen-worker.ts
94
- var createDocgenProvider = () => createLazyDocgenMiddleware({
30
+ var createDocgenProvider = ({
31
+ typeScriptSpecifier
32
+ } = {}) => createLazyDocgenMiddleware({
95
33
  createManager: async () => {
96
34
  try {
97
- return new ComponentMetaManager(
98
- await loadTypeScriptCompilerApi(() => import("typescript"))
99
- );
35
+ return new ComponentMetaManager(await loadDocgenTypeScript(typeScriptSpecifier));
100
36
  } catch (err) {
101
37
  logger.warn(`React docgen is unavailable. ${err instanceof Error ? err.message : err}`);
102
38
  return;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  argTypesEnhancers,
3
3
  parameters
4
- } from "./_browser-chunks/chunk-LGSTPTL6.js";
4
+ } from "./_browser-chunks/chunk-WWHCZJWM.js";
5
5
  import "./_browser-chunks/chunk-B3FR4PBN.js";
6
6
  import "./_browser-chunks/chunk-UAWMPV5J.js";
7
7
  export {
@@ -2,7 +2,7 @@ import {
2
2
  applyDecorators,
3
3
  decorators,
4
4
  parameters
5
- } from "./_browser-chunks/chunk-2TQVKMJE.js";
5
+ } from "./_browser-chunks/chunk-EA5DV32Q.js";
6
6
  import "./_browser-chunks/chunk-DDIRQRCA.js";
7
7
  import "./_browser-chunks/chunk-B3FR4PBN.js";
8
8
  import "./_browser-chunks/chunk-UAWMPV5J.js";
@@ -5,7 +5,7 @@ import {
5
5
  parameters,
6
6
  render,
7
7
  renderToCanvas
8
- } from "./_browser-chunks/chunk-EZD3TIPB.js";
8
+ } from "./_browser-chunks/chunk-I62VTYU3.js";
9
9
  import {
10
10
  applyDecorators
11
11
  } from "./_browser-chunks/chunk-DDIRQRCA.js";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ReactRenderer, i as __definePreview, n as ReactPreview, o as ReactTypes, r as ReactStory, s as Simplify, t as ReactMeta } from "./chunk-DwM7QKaD.js";
1
+ import { a as ReactDocgenTypescriptParserOptions, c as ReactTypes, i as __definePreview, l as Simplify, n as ReactPreview, o as ReactDocgenTypescriptPropItem, r as ReactStory, s as ReactRenderer, t as ReactMeta } from "./chunk-6b3AvPEC.js";
2
2
  import { ComponentProps, ComponentType } from "react";
3
3
  import { AnnotatedStoryFn, ArgTypes, Args, Args as Args$1, ArgsFromMeta, ArgsStoryFn, ComponentAnnotations, ComposedStoryFn, DecoratorFunction, LoaderFunction, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Parameters as Parameters$1, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext as StoryContext$1, StrictArgs, StrictArgs as StrictArgs$1 } from "storybook/internal/types";
4
4
 
@@ -945,4 +945,4 @@ declare function composeStory<TArgs extends Args$1 = Args$1>(story: StoryAnnotat
945
945
  */
946
946
  declare function composeStories<TModule extends Store_CSFExports<ReactRenderer, any>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactRenderer>): Omit<StoriesWithPartialProps<ReactRenderer, TModule>, keyof Store_CSFExports>;
947
947
  //#endregion
948
- export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters$1 as Parameters, Preview, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };
948
+ export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters$1 as Parameters, Preview, type ReactDocgenTypescriptParserOptions, type ReactDocgenTypescriptPropItem, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-7QIM3PHH.js";
3
+ } from "./_browser-chunks/chunk-U7XUEUFQ.js";
4
4
  import {
5
5
  entry_preview_exports,
6
6
  renderToCanvas
7
- } from "./_browser-chunks/chunk-EZD3TIPB.js";
7
+ } from "./_browser-chunks/chunk-I62VTYU3.js";
8
8
  import {
9
9
  entry_preview_argtypes_exports
10
- } from "./_browser-chunks/chunk-LGSTPTL6.js";
11
- import "./_browser-chunks/chunk-2TQVKMJE.js";
10
+ } from "./_browser-chunks/chunk-WWHCZJWM.js";
11
+ import "./_browser-chunks/chunk-EA5DV32Q.js";
12
12
  import "./_browser-chunks/chunk-DDIRQRCA.js";
13
13
  import "./_browser-chunks/chunk-B3FR4PBN.js";
14
14
  import "./_browser-chunks/chunk-UAWMPV5J.js";