storybook-react-rsbuild 2.1.6 → 3.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.
- package/dist/_node-chunks/chunk-XTOIKKJD.js +21 -0
- package/dist/_node-chunks/generate-JLYGGMRJ.js +162 -0
- package/dist/_node-chunks/options-ZJJI6I37.js +24 -0
- package/dist/_node-chunks/react-docgen-typescript-OXGUSE5K.js +114 -0
- package/dist/_node-chunks/typescript-DWWYPH62.js +33 -0
- package/dist/index.d.ts +3 -54
- package/dist/index.js +5 -32
- package/dist/loaders/react-docgen-loader.d.ts +3 -10
- package/dist/loaders/react-docgen-loader.js +69 -125
- package/dist/node/index.d.ts +3 -9
- package/dist/node/index.js +14 -26
- package/dist/preset.js +30 -431
- package/package.json +17 -27
- package/preset.js +1 -1
- package/dist/index.mjs +0 -2
- package/dist/loaders/react-docgen-loader.mjs +0 -195
- package/dist/node/index.mjs +0 -6
- package/dist/preset.d.ts +0 -10
|
@@ -1,56 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import CJS_COMPAT_NODE_URL_5eb028538d2fa676 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_5eb028538d2fa676 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_5eb028538d2fa676 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_5eb028538d2fa676.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_5eb028538d2fa676.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_5eb028538d2fa676.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import "../_node-chunks/chunk-XTOIKKJD.js";
|
|
29
13
|
|
|
30
14
|
// src/loaders/react-docgen-loader.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
15
|
+
import findUp from "find-up";
|
|
16
|
+
import MagicString from "magic-string";
|
|
17
|
+
import {
|
|
18
|
+
ERROR_CODES,
|
|
19
|
+
builtinHandlers as docgenHandlers,
|
|
20
|
+
builtinResolvers as docgenResolver,
|
|
21
|
+
makeFsImporter,
|
|
22
|
+
parse,
|
|
23
|
+
utils
|
|
24
|
+
} from "react-docgen";
|
|
25
|
+
import { logger } from "storybook/internal/node-logger";
|
|
26
|
+
import * as TsconfigPaths from "tsconfig-paths";
|
|
42
27
|
|
|
43
28
|
// src/loaders/docgen-resolver.ts
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
import { extname } from "node:path";
|
|
30
|
+
import resolve from "resolve";
|
|
46
31
|
var ReactDocgenResolveError = class extends Error {
|
|
47
32
|
constructor(filename) {
|
|
48
33
|
super(`'${filename}' was ignored by react-docgen.`);
|
|
49
34
|
// the magic string that react-docgen uses to check if a module is ignored
|
|
50
35
|
this.code = "MODULE_NOT_FOUND";
|
|
51
36
|
}
|
|
52
|
-
}
|
|
53
|
-
var RESOLVE_EXTENSIONS = [
|
|
37
|
+
}, RESOLVE_EXTENSIONS = [
|
|
54
38
|
".js",
|
|
55
39
|
".cts",
|
|
56
40
|
// These were originally not in the code, I added them
|
|
@@ -69,17 +53,16 @@ var RESOLVE_EXTENSIONS = [
|
|
|
69
53
|
".jsx"
|
|
70
54
|
];
|
|
71
55
|
function defaultLookupModule(filename, basedir) {
|
|
72
|
-
|
|
56
|
+
let resolveOptions = {
|
|
73
57
|
basedir,
|
|
74
58
|
extensions: RESOLVE_EXTENSIONS,
|
|
75
59
|
// we do not need to check core modules as we cannot import them anyway
|
|
76
|
-
includeCoreModules:
|
|
60
|
+
includeCoreModules: !1
|
|
77
61
|
};
|
|
78
62
|
try {
|
|
79
|
-
return
|
|
63
|
+
return resolve.sync(filename, resolveOptions);
|
|
80
64
|
} catch (error) {
|
|
81
|
-
|
|
82
|
-
let newFilename;
|
|
65
|
+
let ext = extname(filename), newFilename;
|
|
83
66
|
switch (ext) {
|
|
84
67
|
case ".js":
|
|
85
68
|
case ".mjs":
|
|
@@ -92,7 +75,7 @@ function defaultLookupModule(filename, basedir) {
|
|
|
92
75
|
default:
|
|
93
76
|
throw error;
|
|
94
77
|
}
|
|
95
|
-
return
|
|
78
|
+
return resolve.sync(newFilename, {
|
|
96
79
|
...resolveOptions,
|
|
97
80
|
// we already know that there is an extension at this point, so no need to check other extensions
|
|
98
81
|
extensions: []
|
|
@@ -101,17 +84,15 @@ function defaultLookupModule(filename, basedir) {
|
|
|
101
84
|
}
|
|
102
85
|
|
|
103
86
|
// src/loaders/react-docgen-loader.ts
|
|
104
|
-
var { getNameOrValue, isReactForwardRefCall } =
|
|
105
|
-
|
|
106
|
-
documentation.set("definedInFile", componentDefinition.hub.file.opts.filename);
|
|
107
|
-
if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
|
|
87
|
+
var { getNameOrValue, isReactForwardRefCall } = utils, actualNameHandler = function(documentation, componentDefinition) {
|
|
88
|
+
if (documentation.set("definedInFile", componentDefinition.hub.file.opts.filename), (componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id"))
|
|
108
89
|
documentation.set(
|
|
109
90
|
"actualName",
|
|
110
91
|
getNameOrValue(componentDefinition.get("id"))
|
|
111
92
|
);
|
|
112
|
-
|
|
93
|
+
else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
|
|
113
94
|
let currentPath = componentDefinition;
|
|
114
|
-
|
|
95
|
+
for (; currentPath.parentPath; ) {
|
|
115
96
|
if (currentPath.parentPath.isVariableDeclarator()) {
|
|
116
97
|
documentation.set(
|
|
117
98
|
"actualName",
|
|
@@ -120,7 +101,7 @@ var actualNameHandler = function actualNameHandler2(documentation, componentDefi
|
|
|
120
101
|
return;
|
|
121
102
|
}
|
|
122
103
|
if (currentPath.parentPath.isAssignmentExpression()) {
|
|
123
|
-
|
|
104
|
+
let leftPath = currentPath.parentPath.get("left");
|
|
124
105
|
if (leftPath.isIdentifier() || leftPath.isLiteral()) {
|
|
125
106
|
documentation.set("actualName", getNameOrValue(leftPath));
|
|
126
107
|
return;
|
|
@@ -130,57 +111,38 @@ var actualNameHandler = function actualNameHandler2(documentation, componentDefi
|
|
|
130
111
|
}
|
|
131
112
|
documentation.set("actualName", "");
|
|
132
113
|
}
|
|
133
|
-
}
|
|
134
|
-
var defaultHandlers = Object.values(import_react_docgen.builtinHandlers).map((handler) => handler);
|
|
135
|
-
var defaultResolver = new import_react_docgen.builtinResolvers.FindExportedDefinitionsResolver();
|
|
136
|
-
var handlers = [...defaultHandlers, actualNameHandler];
|
|
137
|
-
var tsconfigPathsInitializeStatus = "uninitialized";
|
|
138
|
-
var resolveTsconfigPathsInitialingPromise;
|
|
139
|
-
var tsconfigPathsInitialingPromise = new Promise((resolve2) => {
|
|
114
|
+
}, defaultHandlers = Object.values(docgenHandlers).map((handler) => handler), defaultResolver = new docgenResolver.FindExportedDefinitionsResolver(), handlers = [...defaultHandlers, actualNameHandler], tsconfigPathsInitializeStatus = "uninitialized", resolveTsconfigPathsInitialingPromise, tsconfigPathsInitialingPromise = new Promise((resolve2) => {
|
|
140
115
|
resolveTsconfigPathsInitialingPromise = resolve2;
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
tsconfigPathsInitializeStatus = "initialized";
|
|
145
|
-
};
|
|
146
|
-
var matchPath;
|
|
116
|
+
}), finishInitialization = () => {
|
|
117
|
+
resolveTsconfigPathsInitialingPromise(), tsconfigPathsInitializeStatus = "initialized";
|
|
118
|
+
}, matchPath;
|
|
147
119
|
async function reactDocgenLoader(source, map) {
|
|
148
|
-
|
|
149
|
-
const options = this.getOptions() || {};
|
|
150
|
-
const { debug = false } = options;
|
|
120
|
+
let callback = this.async(), options = this.getOptions() || {}, { debug = !1 } = options;
|
|
151
121
|
if (tsconfigPathsInitializeStatus === "uninitialized") {
|
|
152
122
|
tsconfigPathsInitializeStatus = "initializing";
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
tsconfig.paths,
|
|
160
|
-
["browser", "module", "main"]
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
finishInitialization();
|
|
164
|
-
}
|
|
165
|
-
if (tsconfigPathsInitializeStatus === "initializing") {
|
|
166
|
-
await tsconfigPathsInitialingPromise;
|
|
123
|
+
let tsconfigPath = await findUp("tsconfig.json", { cwd: process.cwd() }), tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
|
|
124
|
+
tsconfig.resultType === "success" && (logger.info("Using tsconfig paths for react-docgen"), matchPath = TsconfigPaths.createMatchPath(
|
|
125
|
+
tsconfig.absoluteBaseUrl,
|
|
126
|
+
tsconfig.paths,
|
|
127
|
+
["browser", "module", "main"]
|
|
128
|
+
)), finishInitialization();
|
|
167
129
|
}
|
|
130
|
+
tsconfigPathsInitializeStatus === "initializing" && await tsconfigPathsInitialingPromise;
|
|
168
131
|
try {
|
|
169
|
-
|
|
132
|
+
let docgenResults = parse(source, {
|
|
170
133
|
filename: this.resourcePath,
|
|
171
134
|
resolver: defaultResolver,
|
|
172
135
|
handlers,
|
|
173
136
|
importer: getReactDocgenImporter(matchPath),
|
|
174
137
|
babelOptions: {
|
|
175
|
-
babelrc:
|
|
176
|
-
configFile:
|
|
138
|
+
babelrc: !1,
|
|
139
|
+
configFile: !1
|
|
177
140
|
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const { actualName, definedInFile, ...docgenInfo } = info;
|
|
141
|
+
}), magicString = new MagicString(source);
|
|
142
|
+
for (let info of docgenResults) {
|
|
143
|
+
let { actualName, definedInFile, ...docgenInfo } = info;
|
|
182
144
|
if (actualName && definedInFile === this.resourcePath) {
|
|
183
|
-
|
|
145
|
+
let docNode = JSON.stringify(docgenInfo);
|
|
184
146
|
magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
|
|
185
147
|
}
|
|
186
148
|
}
|
|
@@ -188,46 +150,28 @@ async function reactDocgenLoader(source, map) {
|
|
|
188
150
|
null,
|
|
189
151
|
magicString.toString(),
|
|
190
152
|
map ?? magicString.generateMap({
|
|
191
|
-
hires:
|
|
153
|
+
hires: !0,
|
|
192
154
|
source: this.resourcePath,
|
|
193
|
-
includeContent:
|
|
155
|
+
includeContent: !0
|
|
194
156
|
})
|
|
195
157
|
);
|
|
196
158
|
} catch (error) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`
|
|
203
|
-
);
|
|
204
|
-
} else {
|
|
205
|
-
import_node_logger.logger.warn(
|
|
206
|
-
`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`
|
|
207
|
-
);
|
|
208
|
-
import_node_logger.logger.error(error);
|
|
209
|
-
}
|
|
210
|
-
callback(null, source);
|
|
211
|
-
}
|
|
159
|
+
error.code === ERROR_CODES.MISSING_DEFINITION || (debug ? (logger.warn(
|
|
160
|
+
`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`
|
|
161
|
+
), logger.error(error)) : logger.warn(
|
|
162
|
+
`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`
|
|
163
|
+
)), callback(null, source);
|
|
212
164
|
}
|
|
213
165
|
}
|
|
214
166
|
function getReactDocgenImporter(matchingPath) {
|
|
215
|
-
return
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const match = matchingPath(filename);
|
|
219
|
-
return match || filename;
|
|
220
|
-
}
|
|
221
|
-
return filename;
|
|
222
|
-
})();
|
|
223
|
-
const result = defaultLookupModule(mappedFilenameByPaths, basedir);
|
|
224
|
-
if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
|
|
167
|
+
return makeFsImporter((filename, basedir) => {
|
|
168
|
+
let mappedFilenameByPaths = matchingPath && matchingPath(filename) || filename, result = defaultLookupModule(mappedFilenameByPaths, basedir);
|
|
169
|
+
if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext)))
|
|
225
170
|
return result;
|
|
226
|
-
}
|
|
227
171
|
throw new ReactDocgenResolveError(filename);
|
|
228
172
|
});
|
|
229
173
|
}
|
|
230
|
-
|
|
231
|
-
|
|
174
|
+
export {
|
|
175
|
+
reactDocgenLoader as default,
|
|
232
176
|
getReactDocgenImporter
|
|
233
|
-
}
|
|
177
|
+
};
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'storybook-builder-rsbuild';
|
|
5
|
-
import 'storybook/internal/types';
|
|
6
|
-
|
|
7
|
-
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
|
8
|
-
|
|
9
|
-
export { defineMain };
|
|
1
|
+
// auto generated file from file:///Users/bytedance/Projects/storybook-rsbuild/scripts/build/utils/generate-type-mappers.ts, do not edit
|
|
2
|
+
export * from '../../src/node/index.ts';
|
|
3
|
+
export type * from '../../src/node/index.ts';
|
package/dist/node/index.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import CJS_COMPAT_NODE_URL_5eb028538d2fa676 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_5eb028538d2fa676 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_5eb028538d2fa676 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_5eb028538d2fa676.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_5eb028538d2fa676.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_5eb028538d2fa676.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import "../_node-chunks/chunk-XTOIKKJD.js";
|
|
19
13
|
|
|
20
14
|
// src/node/index.ts
|
|
21
|
-
var node_exports = {};
|
|
22
|
-
__export(node_exports, {
|
|
23
|
-
defineMain: () => defineMain
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(node_exports);
|
|
26
15
|
function defineMain(config) {
|
|
27
16
|
return config;
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
0 && (module.exports = {
|
|
18
|
+
export {
|
|
31
19
|
defineMain
|
|
32
|
-
}
|
|
20
|
+
};
|