@storybook/preset-react-webpack 9.2.0-alpha.3 → 10.0.0-beta.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.
- package/README.md +4 -2
- package/dist/_node-chunks/chunk-7NG2ZLPP.js +17 -0
- package/dist/framework-preset-cra.js +106 -1
- package/dist/framework-preset-react-docs.js +79 -1
- package/dist/index.d.ts +35 -3
- package/dist/index.js +22 -1
- package/dist/loaders/react-docgen-loader.js +466 -1
- package/package.json +15 -49
- package/preset.js +1 -1
- package/dist/chunk-MXFP7CYD.mjs +0 -3
- package/dist/framework-preset-cra.d.ts +0 -5
- package/dist/framework-preset-react-docs.d.ts +0 -7
- package/dist/index.mjs +0 -5
- package/dist/loaders/react-docgen-loader.d.ts +0 -10
- package/dist/loaders/react-docgen-loader.mjs +0 -13
- package/dist/types-147216d5.d.ts +0 -36
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Storybook Webpack preset for React
|
|
2
2
|
|
|
3
|
-
This package is a [preset](https://storybook.js.org/docs/addons/writing-presets?renderer=react) that configures Storybook's webpack settings for handling React.
|
|
3
|
+
This package is a [preset](https://storybook.js.org/docs/addons/writing-presets?renderer=react&ref=readme) that configures Storybook's webpack settings for handling React.
|
|
4
4
|
It's an internal package that's not intended to be used directly by users.
|
|
5
5
|
|
|
6
|
-
- More info on [Storybook for React](https://storybook.js.org/docs/get-started/install?renderer=react)
|
|
6
|
+
- More info on [Storybook for React](https://storybook.js.org/docs/get-started/install?renderer=react&ref=readme)
|
|
7
|
+
|
|
8
|
+
Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k9voiyizho from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k9voiyizho from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k9voiyizho from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k9voiyizho.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k9voiyizho.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k9voiyizho.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
__name
|
|
17
|
+
};
|
|
@@ -1 +1,106 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k9voiyizho from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k9voiyizho from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k9voiyizho from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k9voiyizho.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k9voiyizho.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k9voiyizho.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "./_node-chunks/chunk-7NG2ZLPP.js";
|
|
15
|
+
|
|
16
|
+
// src/framework-preset-cra.ts
|
|
17
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
18
|
+
|
|
19
|
+
// src/cra-config.ts
|
|
20
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
import { pathToFileURL } from "node:url";
|
|
23
|
+
import { logger } from "storybook/internal/node-logger";
|
|
24
|
+
import semver from "semver";
|
|
25
|
+
var appDirectory = realpathSync(process.cwd());
|
|
26
|
+
var reactScriptsPath;
|
|
27
|
+
function getReactScriptsPath({ noCache } = {}) {
|
|
28
|
+
if (reactScriptsPath && !noCache) {
|
|
29
|
+
return reactScriptsPath;
|
|
30
|
+
}
|
|
31
|
+
let reactScriptsScriptPath = realpathSync(join(appDirectory, "/node_modules/.bin/react-scripts"));
|
|
32
|
+
try {
|
|
33
|
+
const pathIsNotResolved = /node_modules[\\/]\.bin[\\/]react-scripts/i.test(
|
|
34
|
+
reactScriptsScriptPath
|
|
35
|
+
);
|
|
36
|
+
if (pathIsNotResolved) {
|
|
37
|
+
const content = readFileSync(reactScriptsScriptPath, "utf8");
|
|
38
|
+
const packagePathMatch = content.match(
|
|
39
|
+
/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i
|
|
40
|
+
);
|
|
41
|
+
if (packagePathMatch && packagePathMatch.length > 1) {
|
|
42
|
+
reactScriptsScriptPath = join(appDirectory, "/node_modules/.bin/", packagePathMatch[1]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (e) {
|
|
46
|
+
logger.warn(`Error occurred during react-scripts package path resolving: ${e}`);
|
|
47
|
+
}
|
|
48
|
+
reactScriptsPath = join(reactScriptsScriptPath, "../..");
|
|
49
|
+
const scriptsPkgJson = join(reactScriptsPath, "package.json");
|
|
50
|
+
if (!existsSync(scriptsPkgJson)) {
|
|
51
|
+
reactScriptsPath = "react-scripts";
|
|
52
|
+
}
|
|
53
|
+
return reactScriptsPath;
|
|
54
|
+
}
|
|
55
|
+
__name(getReactScriptsPath, "getReactScriptsPath");
|
|
56
|
+
async function isReactScriptsInstalled(minimumVersion = "2.0.0") {
|
|
57
|
+
try {
|
|
58
|
+
const { default: reactScriptsJson } = await import(pathToFileURL(join(getReactScriptsPath(), "package.json")).href, {
|
|
59
|
+
with: { type: "json" }
|
|
60
|
+
});
|
|
61
|
+
return !semver.gtr(minimumVersion, reactScriptsJson.version);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
__name(isReactScriptsInstalled, "isReactScriptsInstalled");
|
|
67
|
+
|
|
68
|
+
// src/framework-preset-cra.ts
|
|
69
|
+
var checkForNewPreset = /* @__PURE__ */ __name((presetsList) => {
|
|
70
|
+
const hasNewPreset = presetsList.some((preset) => {
|
|
71
|
+
const presetName = typeof preset === "string" ? preset : preset.name;
|
|
72
|
+
return /@storybook(\/|\\)preset-create-react-app/.test(presetName);
|
|
73
|
+
});
|
|
74
|
+
if (!hasNewPreset) {
|
|
75
|
+
logger2.warn("Storybook support for Create React App is now a separate preset.");
|
|
76
|
+
logger2.warn(
|
|
77
|
+
"To use the new preset, install `@storybook/preset-create-react-app` and add it to the list of `addons` in your `.storybook/main.js` config file."
|
|
78
|
+
);
|
|
79
|
+
logger2.warn("The built-in preset has been disabled in Storybook 6.0.");
|
|
80
|
+
}
|
|
81
|
+
}, "checkForNewPreset");
|
|
82
|
+
var webpackFinal = /* @__PURE__ */ __name(async (config, { presetsList }) => {
|
|
83
|
+
if (await isReactScriptsInstalled()) {
|
|
84
|
+
if (presetsList) {
|
|
85
|
+
checkForNewPreset(presetsList);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
config.module?.rules?.push(
|
|
89
|
+
...[
|
|
90
|
+
{
|
|
91
|
+
test: /\.m?js$/,
|
|
92
|
+
type: "javascript/auto"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
test: /\.m?js$/,
|
|
96
|
+
resolve: {
|
|
97
|
+
fullySpecified: false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
);
|
|
102
|
+
return config;
|
|
103
|
+
}, "webpackFinal");
|
|
104
|
+
export {
|
|
105
|
+
webpackFinal
|
|
106
|
+
};
|
|
@@ -1 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k9voiyizho from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k9voiyizho from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k9voiyizho from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k9voiyizho.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k9voiyizho.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k9voiyizho.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "./_node-chunks/chunk-7NG2ZLPP.js";
|
|
15
|
+
|
|
16
|
+
// src/framework-preset-react-docs.ts
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
var webpackFinal = /* @__PURE__ */ __name(async (config, options) => {
|
|
19
|
+
const typescriptOptions = await options.presets.apply("typescript", {});
|
|
20
|
+
const debug = options.loglevel === "debug";
|
|
21
|
+
const { reactDocgen, reactDocgenTypescriptOptions } = typescriptOptions || {};
|
|
22
|
+
if (typeof reactDocgen !== "string") {
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
25
|
+
if (reactDocgen !== "react-docgen-typescript") {
|
|
26
|
+
return {
|
|
27
|
+
...config,
|
|
28
|
+
module: {
|
|
29
|
+
...config.module ?? {},
|
|
30
|
+
rules: [
|
|
31
|
+
...config.module?.rules ?? [],
|
|
32
|
+
{
|
|
33
|
+
test: /\.(cjs|mjs|tsx?|jsx?)$/,
|
|
34
|
+
enforce: "pre",
|
|
35
|
+
loader: fileURLToPath(
|
|
36
|
+
import.meta.resolve("@storybook/preset-react-webpack/react-docgen-loader")
|
|
37
|
+
),
|
|
38
|
+
options: {
|
|
39
|
+
debug
|
|
40
|
+
},
|
|
41
|
+
exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const { ReactDocgenTypeScriptPlugin } = await import("@storybook/react-docgen-typescript-plugin");
|
|
48
|
+
return {
|
|
49
|
+
...config,
|
|
50
|
+
module: {
|
|
51
|
+
...config.module ?? {},
|
|
52
|
+
rules: [
|
|
53
|
+
...config.module?.rules ?? [],
|
|
54
|
+
{
|
|
55
|
+
test: /\.(cjs|mjs|jsx?)$/,
|
|
56
|
+
enforce: "pre",
|
|
57
|
+
loader: fileURLToPath(
|
|
58
|
+
import.meta.resolve("@storybook/preset-react-webpack/react-docgen-loader")
|
|
59
|
+
),
|
|
60
|
+
options: {
|
|
61
|
+
debug
|
|
62
|
+
},
|
|
63
|
+
exclude: /(\.(stories|story)\.(js|jsx|ts|tsx))|(node_modules)/
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
plugins: [
|
|
68
|
+
...config.plugins || [],
|
|
69
|
+
new ReactDocgenTypeScriptPlugin({
|
|
70
|
+
...reactDocgenTypescriptOptions,
|
|
71
|
+
// We *need* this set so that RDT returns default values in the same format as react-docgen
|
|
72
|
+
savePropValueAsString: true
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
}, "webpackFinal");
|
|
77
|
+
export {
|
|
78
|
+
webpackFinal
|
|
79
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
import { PresetProperty } from 'storybook/internal/types';
|
|
2
|
-
|
|
2
|
+
import { TypescriptOptions as TypescriptOptions$1, WebpackConfiguration, StorybookConfig as StorybookConfig$1 } from '@storybook/core-webpack';
|
|
3
3
|
export { BuilderResult } from '@storybook/core-webpack';
|
|
4
|
-
import '@storybook/react-docgen-typescript-plugin';
|
|
4
|
+
import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
|
|
5
|
+
|
|
6
|
+
interface ReactOptions {
|
|
7
|
+
strictMode?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Use React's legacy root API to mount components
|
|
10
|
+
*
|
|
11
|
+
* React has introduced a new root API with React 18.x to enable a whole set of new features (e.g.
|
|
12
|
+
* concurrent features) If this flag is true, the legacy Root API is used to mount components to
|
|
13
|
+
* make it easier to migrate step by step to React 18.
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
legacyRootApi?: boolean;
|
|
18
|
+
}
|
|
19
|
+
type TypescriptOptions = TypescriptOptions$1 & {
|
|
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 StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1<TWebpackConfiguration> & {
|
|
35
|
+
typescript?: Partial<TypescriptOptions>;
|
|
36
|
+
};
|
|
5
37
|
|
|
6
38
|
declare const addons: PresetProperty<'addons'>;
|
|
7
39
|
|
|
8
|
-
export { addons };
|
|
40
|
+
export { type ReactOptions, type StorybookConfig, type TypescriptOptions, addons };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k9voiyizho from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k9voiyizho from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k9voiyizho from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k9voiyizho.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k9voiyizho.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k9voiyizho.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import "./_node-chunks/chunk-7NG2ZLPP.js";
|
|
13
|
+
|
|
14
|
+
// src/index.ts
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
var addons = [
|
|
17
|
+
fileURLToPath(import.meta.resolve("@storybook/preset-react-webpack/preset-cra")),
|
|
18
|
+
fileURLToPath(import.meta.resolve("@storybook/preset-react-webpack/preset-react-docs"))
|
|
19
|
+
];
|
|
20
|
+
export {
|
|
21
|
+
addons
|
|
22
|
+
};
|
|
@@ -1 +1,466 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_k9voiyizho from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_k9voiyizho from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_k9voiyizho from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_k9voiyizho.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_k9voiyizho.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_k9voiyizho.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "../_node-chunks/chunk-7NG2ZLPP.js";
|
|
15
|
+
|
|
16
|
+
// src/loaders/react-docgen-loader.ts
|
|
17
|
+
import { getProjectRoot } from "storybook/internal/common";
|
|
18
|
+
import { logger } from "storybook/internal/node-logger";
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/find-up/index.js
|
|
21
|
+
import path2 from "node:path";
|
|
22
|
+
|
|
23
|
+
// ../../node_modules/locate-path/index.js
|
|
24
|
+
import process2 from "node:process";
|
|
25
|
+
import path from "node:path";
|
|
26
|
+
import fs, { promises as fsPromises } from "node:fs";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/yocto-queue/index.js
|
|
30
|
+
var Node = class {
|
|
31
|
+
static {
|
|
32
|
+
__name(this, "Node");
|
|
33
|
+
}
|
|
34
|
+
value;
|
|
35
|
+
next;
|
|
36
|
+
constructor(value) {
|
|
37
|
+
this.value = value;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var Queue = class {
|
|
41
|
+
static {
|
|
42
|
+
__name(this, "Queue");
|
|
43
|
+
}
|
|
44
|
+
#head;
|
|
45
|
+
#tail;
|
|
46
|
+
#size;
|
|
47
|
+
constructor() {
|
|
48
|
+
this.clear();
|
|
49
|
+
}
|
|
50
|
+
enqueue(value) {
|
|
51
|
+
const node = new Node(value);
|
|
52
|
+
if (this.#head) {
|
|
53
|
+
this.#tail.next = node;
|
|
54
|
+
this.#tail = node;
|
|
55
|
+
} else {
|
|
56
|
+
this.#head = node;
|
|
57
|
+
this.#tail = node;
|
|
58
|
+
}
|
|
59
|
+
this.#size++;
|
|
60
|
+
}
|
|
61
|
+
dequeue() {
|
|
62
|
+
const current = this.#head;
|
|
63
|
+
if (!current) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.#head = this.#head.next;
|
|
67
|
+
this.#size--;
|
|
68
|
+
return current.value;
|
|
69
|
+
}
|
|
70
|
+
peek() {
|
|
71
|
+
if (!this.#head) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
return this.#head.value;
|
|
75
|
+
}
|
|
76
|
+
clear() {
|
|
77
|
+
this.#head = void 0;
|
|
78
|
+
this.#tail = void 0;
|
|
79
|
+
this.#size = 0;
|
|
80
|
+
}
|
|
81
|
+
get size() {
|
|
82
|
+
return this.#size;
|
|
83
|
+
}
|
|
84
|
+
*[Symbol.iterator]() {
|
|
85
|
+
let current = this.#head;
|
|
86
|
+
while (current) {
|
|
87
|
+
yield current.value;
|
|
88
|
+
current = current.next;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
*drain() {
|
|
92
|
+
while (this.#head) {
|
|
93
|
+
yield this.dequeue();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// ../../node_modules/locate-path/node_modules/p-limit/index.js
|
|
99
|
+
function pLimit(concurrency) {
|
|
100
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
101
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
102
|
+
}
|
|
103
|
+
const queue = new Queue();
|
|
104
|
+
let activeCount = 0;
|
|
105
|
+
const next = /* @__PURE__ */ __name(() => {
|
|
106
|
+
activeCount--;
|
|
107
|
+
if (queue.size > 0) {
|
|
108
|
+
queue.dequeue()();
|
|
109
|
+
}
|
|
110
|
+
}, "next");
|
|
111
|
+
const run = /* @__PURE__ */ __name(async (fn, resolve2, args) => {
|
|
112
|
+
activeCount++;
|
|
113
|
+
const result = (async () => fn(...args))();
|
|
114
|
+
resolve2(result);
|
|
115
|
+
try {
|
|
116
|
+
await result;
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
next();
|
|
120
|
+
}, "run");
|
|
121
|
+
const enqueue = /* @__PURE__ */ __name((fn, resolve2, args) => {
|
|
122
|
+
queue.enqueue(run.bind(void 0, fn, resolve2, args));
|
|
123
|
+
(async () => {
|
|
124
|
+
await Promise.resolve();
|
|
125
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
126
|
+
queue.dequeue()();
|
|
127
|
+
}
|
|
128
|
+
})();
|
|
129
|
+
}, "enqueue");
|
|
130
|
+
const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve2) => {
|
|
131
|
+
enqueue(fn, resolve2, args);
|
|
132
|
+
}), "generator");
|
|
133
|
+
Object.defineProperties(generator, {
|
|
134
|
+
activeCount: {
|
|
135
|
+
get: /* @__PURE__ */ __name(() => activeCount, "get")
|
|
136
|
+
},
|
|
137
|
+
pendingCount: {
|
|
138
|
+
get: /* @__PURE__ */ __name(() => queue.size, "get")
|
|
139
|
+
},
|
|
140
|
+
clearQueue: {
|
|
141
|
+
value: /* @__PURE__ */ __name(() => {
|
|
142
|
+
queue.clear();
|
|
143
|
+
}, "value")
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return generator;
|
|
147
|
+
}
|
|
148
|
+
__name(pLimit, "pLimit");
|
|
149
|
+
|
|
150
|
+
// ../../node_modules/locate-path/node_modules/p-locate/index.js
|
|
151
|
+
var EndError = class extends Error {
|
|
152
|
+
static {
|
|
153
|
+
__name(this, "EndError");
|
|
154
|
+
}
|
|
155
|
+
constructor(value) {
|
|
156
|
+
super();
|
|
157
|
+
this.value = value;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var testElement = /* @__PURE__ */ __name(async (element, tester) => tester(await element), "testElement");
|
|
161
|
+
var finder = /* @__PURE__ */ __name(async (element) => {
|
|
162
|
+
const values = await Promise.all(element);
|
|
163
|
+
if (values[1] === true) {
|
|
164
|
+
throw new EndError(values[0]);
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}, "finder");
|
|
168
|
+
async function pLocate(iterable, tester, {
|
|
169
|
+
concurrency = Number.POSITIVE_INFINITY,
|
|
170
|
+
preserveOrder = true
|
|
171
|
+
} = {}) {
|
|
172
|
+
const limit = pLimit(concurrency);
|
|
173
|
+
const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
|
|
174
|
+
const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
|
|
175
|
+
try {
|
|
176
|
+
await Promise.all(items.map((element) => checkLimit(finder, element)));
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (error instanceof EndError) {
|
|
179
|
+
return error.value;
|
|
180
|
+
}
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
__name(pLocate, "pLocate");
|
|
185
|
+
|
|
186
|
+
// ../../node_modules/locate-path/index.js
|
|
187
|
+
var typeMappings = {
|
|
188
|
+
directory: "isDirectory",
|
|
189
|
+
file: "isFile"
|
|
190
|
+
};
|
|
191
|
+
function checkType(type) {
|
|
192
|
+
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
throw new Error(`Invalid type specified: ${type}`);
|
|
196
|
+
}
|
|
197
|
+
__name(checkType, "checkType");
|
|
198
|
+
var matchType = /* @__PURE__ */ __name((type, stat) => stat[typeMappings[type]](), "matchType");
|
|
199
|
+
var toPath = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
|
|
200
|
+
async function locatePath(paths, {
|
|
201
|
+
cwd = process2.cwd(),
|
|
202
|
+
type = "file",
|
|
203
|
+
allowSymlinks = true,
|
|
204
|
+
concurrency,
|
|
205
|
+
preserveOrder
|
|
206
|
+
} = {}) {
|
|
207
|
+
checkType(type);
|
|
208
|
+
cwd = toPath(cwd);
|
|
209
|
+
const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
|
|
210
|
+
return pLocate(paths, async (path_) => {
|
|
211
|
+
try {
|
|
212
|
+
const stat = await statFunction(path.resolve(cwd, path_));
|
|
213
|
+
return matchType(type, stat);
|
|
214
|
+
} catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}, { concurrency, preserveOrder });
|
|
218
|
+
}
|
|
219
|
+
__name(locatePath, "locatePath");
|
|
220
|
+
|
|
221
|
+
// ../../node_modules/find-up/node_modules/unicorn-magic/node.js
|
|
222
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
223
|
+
function toPath2(urlOrPath) {
|
|
224
|
+
return urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
|
|
225
|
+
}
|
|
226
|
+
__name(toPath2, "toPath");
|
|
227
|
+
|
|
228
|
+
// ../../node_modules/find-up/index.js
|
|
229
|
+
var findUpStop = Symbol("findUpStop");
|
|
230
|
+
async function findUpMultiple(name, options = {}) {
|
|
231
|
+
let directory = path2.resolve(toPath2(options.cwd) ?? "");
|
|
232
|
+
const { root } = path2.parse(directory);
|
|
233
|
+
const stopAt = path2.resolve(directory, toPath2(options.stopAt ?? root));
|
|
234
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
235
|
+
const paths = [name].flat();
|
|
236
|
+
const runMatcher = /* @__PURE__ */ __name(async (locateOptions) => {
|
|
237
|
+
if (typeof name !== "function") {
|
|
238
|
+
return locatePath(paths, locateOptions);
|
|
239
|
+
}
|
|
240
|
+
const foundPath = await name(locateOptions.cwd);
|
|
241
|
+
if (typeof foundPath === "string") {
|
|
242
|
+
return locatePath([foundPath], locateOptions);
|
|
243
|
+
}
|
|
244
|
+
return foundPath;
|
|
245
|
+
}, "runMatcher");
|
|
246
|
+
const matches = [];
|
|
247
|
+
while (true) {
|
|
248
|
+
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
249
|
+
if (foundPath === findUpStop) {
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
if (foundPath) {
|
|
253
|
+
matches.push(path2.resolve(directory, foundPath));
|
|
254
|
+
}
|
|
255
|
+
if (directory === stopAt || matches.length >= limit) {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
directory = path2.dirname(directory);
|
|
259
|
+
}
|
|
260
|
+
return matches;
|
|
261
|
+
}
|
|
262
|
+
__name(findUpMultiple, "findUpMultiple");
|
|
263
|
+
async function findUp(name, options = {}) {
|
|
264
|
+
const matches = await findUpMultiple(name, { ...options, limit: 1 });
|
|
265
|
+
return matches[0];
|
|
266
|
+
}
|
|
267
|
+
__name(findUp, "findUp");
|
|
268
|
+
|
|
269
|
+
// src/loaders/react-docgen-loader.ts
|
|
270
|
+
import MagicString from "magic-string";
|
|
271
|
+
import {
|
|
272
|
+
ERROR_CODES,
|
|
273
|
+
builtinHandlers as docgenHandlers,
|
|
274
|
+
builtinResolvers as docgenResolver,
|
|
275
|
+
makeFsImporter,
|
|
276
|
+
parse,
|
|
277
|
+
utils
|
|
278
|
+
} from "react-docgen";
|
|
279
|
+
import * as TsconfigPaths from "tsconfig-paths";
|
|
280
|
+
|
|
281
|
+
// src/loaders/docgen-resolver.ts
|
|
282
|
+
import { extname } from "node:path";
|
|
283
|
+
import resolve from "resolve";
|
|
284
|
+
var ReactDocgenResolveError = class extends Error {
|
|
285
|
+
constructor(filename) {
|
|
286
|
+
super(`'${filename}' was ignored by react-docgen.`);
|
|
287
|
+
// the magic string that react-docgen uses to check if a module is ignored
|
|
288
|
+
this.code = "MODULE_NOT_FOUND";
|
|
289
|
+
}
|
|
290
|
+
static {
|
|
291
|
+
__name(this, "ReactDocgenResolveError");
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
var RESOLVE_EXTENSIONS = [
|
|
295
|
+
".js",
|
|
296
|
+
".cts",
|
|
297
|
+
// These were originally not in the code, I added them
|
|
298
|
+
".mts",
|
|
299
|
+
// These were originally not in the code, I added them
|
|
300
|
+
".ctsx",
|
|
301
|
+
// These were originally not in the code, I added them
|
|
302
|
+
".mtsx",
|
|
303
|
+
// These were originally not in the code, I added them
|
|
304
|
+
".ts",
|
|
305
|
+
".tsx",
|
|
306
|
+
".mjs",
|
|
307
|
+
".cjs",
|
|
308
|
+
".mts",
|
|
309
|
+
".cts",
|
|
310
|
+
".jsx"
|
|
311
|
+
];
|
|
312
|
+
function defaultLookupModule(filename, basedir) {
|
|
313
|
+
const resolveOptions = {
|
|
314
|
+
basedir,
|
|
315
|
+
extensions: RESOLVE_EXTENSIONS,
|
|
316
|
+
// we do not need to check core modules as we cannot import them anyway
|
|
317
|
+
includeCoreModules: false
|
|
318
|
+
};
|
|
319
|
+
try {
|
|
320
|
+
return resolve.sync(filename, resolveOptions);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const ext = extname(filename);
|
|
323
|
+
let newFilename;
|
|
324
|
+
switch (ext) {
|
|
325
|
+
case ".js":
|
|
326
|
+
case ".mjs":
|
|
327
|
+
case ".cjs":
|
|
328
|
+
newFilename = `${filename.slice(0, -2)}ts`;
|
|
329
|
+
break;
|
|
330
|
+
case ".jsx":
|
|
331
|
+
newFilename = `${filename.slice(0, -3)}tsx`;
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
throw error;
|
|
335
|
+
}
|
|
336
|
+
return resolve.sync(newFilename, {
|
|
337
|
+
...resolveOptions,
|
|
338
|
+
// we already know that there is an extension at this point, so no need to check other extensions
|
|
339
|
+
extensions: []
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
__name(defaultLookupModule, "defaultLookupModule");
|
|
344
|
+
|
|
345
|
+
// src/loaders/react-docgen-loader.ts
|
|
346
|
+
var { getNameOrValue, isReactForwardRefCall } = utils;
|
|
347
|
+
var actualNameHandler = /* @__PURE__ */ __name(function actualNameHandler2(documentation, componentDefinition) {
|
|
348
|
+
documentation.set("definedInFile", componentDefinition.hub.file.opts.filename);
|
|
349
|
+
if ((componentDefinition.isClassDeclaration() || componentDefinition.isFunctionDeclaration()) && componentDefinition.has("id")) {
|
|
350
|
+
documentation.set(
|
|
351
|
+
"actualName",
|
|
352
|
+
getNameOrValue(componentDefinition.get("id"))
|
|
353
|
+
);
|
|
354
|
+
} else if (componentDefinition.isArrowFunctionExpression() || componentDefinition.isFunctionExpression() || isReactForwardRefCall(componentDefinition)) {
|
|
355
|
+
let currentPath = componentDefinition;
|
|
356
|
+
while (currentPath.parentPath) {
|
|
357
|
+
if (currentPath.parentPath.isVariableDeclarator()) {
|
|
358
|
+
documentation.set("actualName", getNameOrValue(currentPath.parentPath.get("id")));
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (currentPath.parentPath.isAssignmentExpression()) {
|
|
362
|
+
const leftPath = currentPath.parentPath.get("left");
|
|
363
|
+
if (leftPath.isIdentifier() || leftPath.isLiteral()) {
|
|
364
|
+
documentation.set("actualName", getNameOrValue(leftPath));
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
currentPath = currentPath.parentPath;
|
|
369
|
+
}
|
|
370
|
+
documentation.set("actualName", "");
|
|
371
|
+
}
|
|
372
|
+
}, "actualNameHandler");
|
|
373
|
+
var defaultHandlers = Object.values(docgenHandlers).map((handler) => handler);
|
|
374
|
+
var defaultResolver = new docgenResolver.FindExportedDefinitionsResolver();
|
|
375
|
+
var handlers = [...defaultHandlers, actualNameHandler];
|
|
376
|
+
var tsconfigPathsInitialized = false;
|
|
377
|
+
var matchPath;
|
|
378
|
+
async function reactDocgenLoader(source, map) {
|
|
379
|
+
const callback = this.async();
|
|
380
|
+
const options = this.getOptions() || {};
|
|
381
|
+
const { debug = false } = options;
|
|
382
|
+
if (!tsconfigPathsInitialized) {
|
|
383
|
+
const tsconfigPath = await findUp("tsconfig.json", {
|
|
384
|
+
cwd: process.cwd(),
|
|
385
|
+
stopAt: getProjectRoot()
|
|
386
|
+
});
|
|
387
|
+
const tsconfig = TsconfigPaths.loadConfig(tsconfigPath);
|
|
388
|
+
if (tsconfig.resultType === "success") {
|
|
389
|
+
logger.info("Using tsconfig paths for react-docgen");
|
|
390
|
+
matchPath = TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
|
|
391
|
+
"browser",
|
|
392
|
+
"module",
|
|
393
|
+
"main"
|
|
394
|
+
]);
|
|
395
|
+
}
|
|
396
|
+
tsconfigPathsInitialized = true;
|
|
397
|
+
}
|
|
398
|
+
try {
|
|
399
|
+
const docgenResults = parse(source, {
|
|
400
|
+
filename: this.resourcePath,
|
|
401
|
+
resolver: defaultResolver,
|
|
402
|
+
handlers,
|
|
403
|
+
importer: getReactDocgenImporter(matchPath),
|
|
404
|
+
babelOptions: {
|
|
405
|
+
babelrc: false,
|
|
406
|
+
configFile: false
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
const magicString = new MagicString(source);
|
|
410
|
+
docgenResults.forEach((info) => {
|
|
411
|
+
const { actualName, definedInFile, ...docgenInfo } = info;
|
|
412
|
+
if (actualName && definedInFile == this.resourcePath) {
|
|
413
|
+
const docNode = JSON.stringify(docgenInfo);
|
|
414
|
+
magicString.append(`;${actualName}.__docgenInfo=${docNode}`);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
callback(
|
|
418
|
+
null,
|
|
419
|
+
magicString.toString(),
|
|
420
|
+
map ?? magicString.generateMap({
|
|
421
|
+
hires: true,
|
|
422
|
+
source: this.resourcePath,
|
|
423
|
+
includeContent: true
|
|
424
|
+
})
|
|
425
|
+
);
|
|
426
|
+
} catch (error) {
|
|
427
|
+
if (error.code === ERROR_CODES.MISSING_DEFINITION) {
|
|
428
|
+
callback(null, source);
|
|
429
|
+
} else {
|
|
430
|
+
if (!debug) {
|
|
431
|
+
logger.warn(
|
|
432
|
+
`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`
|
|
433
|
+
);
|
|
434
|
+
} else {
|
|
435
|
+
logger.warn(
|
|
436
|
+
`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`
|
|
437
|
+
);
|
|
438
|
+
logger.error(error);
|
|
439
|
+
}
|
|
440
|
+
callback(null, source);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
__name(reactDocgenLoader, "reactDocgenLoader");
|
|
445
|
+
function getReactDocgenImporter(matchingPath) {
|
|
446
|
+
return makeFsImporter((filename, basedir) => {
|
|
447
|
+
const mappedFilenameByPaths = (() => {
|
|
448
|
+
if (matchingPath) {
|
|
449
|
+
const match = matchingPath(filename);
|
|
450
|
+
return match || filename;
|
|
451
|
+
} else {
|
|
452
|
+
return filename;
|
|
453
|
+
}
|
|
454
|
+
})();
|
|
455
|
+
const result = defaultLookupModule(mappedFilenameByPaths, basedir);
|
|
456
|
+
if (RESOLVE_EXTENSIONS.find((ext) => result.endsWith(ext))) {
|
|
457
|
+
return result;
|
|
458
|
+
}
|
|
459
|
+
throw new ReactDocgenResolveError(filename);
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
__name(getReactDocgenImporter, "getReactDocgenImporter");
|
|
463
|
+
export {
|
|
464
|
+
reactDocgenLoader as default,
|
|
465
|
+
getReactDocgenImporter
|
|
466
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/preset-react-webpack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-beta.0",
|
|
4
4
|
"description": "Storybook for React: Develop React Component in isolation with Hot Reloading",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -19,39 +19,17 @@
|
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
+
"type": "module",
|
|
22
23
|
"exports": {
|
|
23
24
|
".": {
|
|
24
25
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"
|
|
26
|
-
"import": "./dist/index.mjs",
|
|
27
|
-
"require": "./dist/index.js"
|
|
26
|
+
"default": "./dist/index.js"
|
|
28
27
|
},
|
|
29
|
-
"./
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"require": "./dist/index.js"
|
|
34
|
-
},
|
|
35
|
-
"./dist/framework-preset-cra": {
|
|
36
|
-
"types": "./dist/framework-preset-cra.d.ts",
|
|
37
|
-
"import": "./dist/framework-preset-cra.mjs",
|
|
38
|
-
"require": "./dist/framework-preset-cra.js"
|
|
39
|
-
},
|
|
40
|
-
"./dist/framework-preset-react-docs": {
|
|
41
|
-
"types": "./dist/framework-preset-react-docs.d.ts",
|
|
42
|
-
"import": "./dist/framework-preset-react-docs.mjs",
|
|
43
|
-
"require": "./dist/framework-preset-react-docs.js"
|
|
44
|
-
},
|
|
45
|
-
"./dist/loaders/react-docgen-loader": {
|
|
46
|
-
"types": "./dist/loaders/react-docgen-loader.d.ts",
|
|
47
|
-
"import": "./dist/loaders/react-docgen-loader.mjs",
|
|
48
|
-
"require": "./dist/loaders/react-docgen-loader.js"
|
|
49
|
-
},
|
|
50
|
-
"./package.json": "./package.json"
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./preset-cra": "./dist/framework-preset-cra.js",
|
|
30
|
+
"./preset-react-docs": "./dist/framework-preset-react-docs.js",
|
|
31
|
+
"./react-docgen-loader": "./dist/loaders/react-docgen-loader.js"
|
|
51
32
|
},
|
|
52
|
-
"main": "dist/index.js",
|
|
53
|
-
"module": "dist/index.mjs",
|
|
54
|
-
"types": "dist/index.d.ts",
|
|
55
33
|
"files": [
|
|
56
34
|
"dist/**/*",
|
|
57
35
|
"README.md",
|
|
@@ -60,14 +38,13 @@
|
|
|
60
38
|
"!src/**/*"
|
|
61
39
|
],
|
|
62
40
|
"scripts": {
|
|
63
|
-
"check": "jiti ../../../scripts/
|
|
64
|
-
"prep": "jiti ../../../scripts/
|
|
41
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
42
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
65
43
|
},
|
|
66
44
|
"dependencies": {
|
|
67
|
-
"@storybook/core-webpack": "
|
|
45
|
+
"@storybook/core-webpack": "10.0.0-beta.0",
|
|
68
46
|
"@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.0c3f3b7.0",
|
|
69
47
|
"@types/semver": "^7.3.4",
|
|
70
|
-
"find-up": "^7.0.0",
|
|
71
48
|
"magic-string": "^0.30.5",
|
|
72
49
|
"react-docgen": "^7.1.1",
|
|
73
50
|
"resolve": "^1.22.8",
|
|
@@ -77,32 +54,21 @@
|
|
|
77
54
|
},
|
|
78
55
|
"devDependencies": {
|
|
79
56
|
"@types/node": "^22.0.0",
|
|
57
|
+
"find-up": "^7.0.0",
|
|
80
58
|
"typescript": "^5.8.3"
|
|
81
59
|
},
|
|
82
60
|
"peerDependencies": {
|
|
83
|
-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
84
|
-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
85
|
-
"storybook": "^
|
|
61
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
62
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
63
|
+
"storybook": "^10.0.0-beta.0"
|
|
86
64
|
},
|
|
87
65
|
"peerDependenciesMeta": {
|
|
88
66
|
"typescript": {
|
|
89
67
|
"optional": true
|
|
90
68
|
}
|
|
91
69
|
},
|
|
92
|
-
"engines": {
|
|
93
|
-
"node": ">=20.0.0"
|
|
94
|
-
},
|
|
95
70
|
"publishConfig": {
|
|
96
71
|
"access": "public"
|
|
97
72
|
},
|
|
98
|
-
"
|
|
99
|
-
"entries": [
|
|
100
|
-
"./src/index.ts",
|
|
101
|
-
"./src/framework-preset-cra.ts",
|
|
102
|
-
"./src/framework-preset-react-docs.ts",
|
|
103
|
-
"./src/loaders/react-docgen-loader.ts"
|
|
104
|
-
],
|
|
105
|
-
"platform": "node"
|
|
106
|
-
},
|
|
107
|
-
"gitHead": "ce6a1e4a8d5ad69c699021a0b183df89cfc7b684"
|
|
73
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16"
|
|
108
74
|
}
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './src/index.js';
|
package/dist/chunk-MXFP7CYD.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});
|
|
2
|
-
|
|
3
|
-
export { __require };
|
package/dist/index.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react_docgen from 'react-docgen';
|
|
2
|
-
import * as TsconfigPaths from 'tsconfig-paths';
|
|
3
|
-
import { LoaderContext } from 'webpack';
|
|
4
|
-
|
|
5
|
-
declare function reactDocgenLoader(this: LoaderContext<{
|
|
6
|
-
debug: boolean;
|
|
7
|
-
}>, source: string, map: any): Promise<void>;
|
|
8
|
-
declare function getReactDocgenImporter(matchingPath: TsconfigPaths.MatchPath | undefined): react_docgen.Importer;
|
|
9
|
-
|
|
10
|
-
export { reactDocgenLoader as default, getReactDocgenImporter };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import '../chunk-MXFP7CYD.mjs';
|
|
2
|
-
import { getProjectRoot } from 'storybook/internal/common';
|
|
3
|
-
import { logger } from 'storybook/internal/node-logger';
|
|
4
|
-
import { findUp } from 'find-up';
|
|
5
|
-
import MagicString from 'magic-string';
|
|
6
|
-
import { builtinHandlers, builtinResolvers, parse, ERROR_CODES, makeFsImporter, utils } from 'react-docgen';
|
|
7
|
-
import * as TsconfigPaths from 'tsconfig-paths';
|
|
8
|
-
import { extname } from 'node:path';
|
|
9
|
-
import resolve from 'resolve';
|
|
10
|
-
|
|
11
|
-
var ReactDocgenResolveError=class extends Error{constructor(filename){super(`'${filename}' was ignored by react-docgen.`);this.code="MODULE_NOT_FOUND";}},RESOLVE_EXTENSIONS=[".js",".cts",".mts",".ctsx",".mtsx",".ts",".tsx",".mjs",".cjs",".mts",".cts",".jsx"];function defaultLookupModule(filename,basedir){let resolveOptions={basedir,extensions:RESOLVE_EXTENSIONS,includeCoreModules:!1};try{return resolve.sync(filename,resolveOptions)}catch(error){let ext=extname(filename),newFilename;switch(ext){case".js":case".mjs":case".cjs":newFilename=`${filename.slice(0,-2)}ts`;break;case".jsx":newFilename=`${filename.slice(0,-3)}tsx`;break;default:throw error}return resolve.sync(newFilename,{...resolveOptions,extensions:[]})}}var{getNameOrValue,isReactForwardRefCall}=utils,actualNameHandler=function(documentation,componentDefinition){if(documentation.set("definedInFile",componentDefinition.hub.file.opts.filename),(componentDefinition.isClassDeclaration()||componentDefinition.isFunctionDeclaration())&&componentDefinition.has("id"))documentation.set("actualName",getNameOrValue(componentDefinition.get("id")));else if(componentDefinition.isArrowFunctionExpression()||componentDefinition.isFunctionExpression()||isReactForwardRefCall(componentDefinition)){let currentPath=componentDefinition;for(;currentPath.parentPath;){if(currentPath.parentPath.isVariableDeclarator()){documentation.set("actualName",getNameOrValue(currentPath.parentPath.get("id")));return}if(currentPath.parentPath.isAssignmentExpression()){let leftPath=currentPath.parentPath.get("left");if(leftPath.isIdentifier()||leftPath.isLiteral()){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parentPath;}documentation.set("actualName","");}},defaultHandlers=Object.values(builtinHandlers).map(handler=>handler),defaultResolver=new builtinResolvers.FindExportedDefinitionsResolver,handlers=[...defaultHandlers,actualNameHandler],tsconfigPathsInitialized=!1,matchPath;async function reactDocgenLoader(source,map){let callback=this.async(),options=this.getOptions()||{},{debug=!1}=options;if(!tsconfigPathsInitialized){let tsconfigPath=await findUp("tsconfig.json",{cwd:process.cwd(),stopAt:getProjectRoot()}),tsconfig=TsconfigPaths.loadConfig(tsconfigPath);tsconfig.resultType==="success"&&(logger.info("Using tsconfig paths for react-docgen"),matchPath=TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl,tsconfig.paths,["browser","module","main"])),tsconfigPathsInitialized=!0;}try{let docgenResults=parse(source,{filename:this.resourcePath,resolver:defaultResolver,handlers,importer:getReactDocgenImporter(matchPath),babelOptions:{babelrc:!1,configFile:!1}}),magicString=new MagicString(source);docgenResults.forEach(info=>{let{actualName,definedInFile,...docgenInfo}=info;if(actualName&&definedInFile==this.resourcePath){let docNode=JSON.stringify(docgenInfo);magicString.append(`;${actualName}.__docgenInfo=${docNode}`);}}),callback(null,magicString.toString(),map??magicString.generateMap({hires:!0,source:this.resourcePath,includeContent:!0}));}catch(error){error.code===ERROR_CODES.MISSING_DEFINITION||(debug?(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`),logger.error(error)):logger.warn(`Failed to parse ${this.resourcePath} with react-docgen. Rerun Storybook with --loglevel=debug to get more info.`)),callback(null,source);}}function getReactDocgenImporter(matchingPath){return makeFsImporter((filename,basedir)=>{let mappedFilenameByPaths=matchingPath&&matchingPath(filename)||filename,result=defaultLookupModule(mappedFilenameByPaths,basedir);if(RESOLVE_EXTENSIONS.find(ext=>result.endsWith(ext)))return result;throw new ReactDocgenResolveError(filename)})}
|
|
12
|
-
|
|
13
|
-
export { reactDocgenLoader as default, getReactDocgenImporter };
|
package/dist/types-147216d5.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { TypescriptOptions as TypescriptOptions$1, WebpackConfiguration, StorybookConfig as StorybookConfig$1 } from '@storybook/core-webpack';
|
|
2
|
-
import { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
|
|
3
|
-
|
|
4
|
-
interface ReactOptions {
|
|
5
|
-
strictMode?: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Use React's legacy root API to mount components
|
|
8
|
-
*
|
|
9
|
-
* React has introduced a new root API with React 18.x to enable a whole set of new features (e.g.
|
|
10
|
-
* concurrent features) If this flag is true, the legacy Root API is used to mount components to
|
|
11
|
-
* make it easier to migrate step by step to React 18.
|
|
12
|
-
*
|
|
13
|
-
* @default false
|
|
14
|
-
*/
|
|
15
|
-
legacyRootApi?: boolean;
|
|
16
|
-
}
|
|
17
|
-
type TypescriptOptions = TypescriptOptions$1 & {
|
|
18
|
-
/**
|
|
19
|
-
* Sets the type of Docgen when working with React and TypeScript
|
|
20
|
-
*
|
|
21
|
-
* @default `'react-docgen'`
|
|
22
|
-
*/
|
|
23
|
-
reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false;
|
|
24
|
-
/**
|
|
25
|
-
* Configures `react-docgen-typescript-plugin`
|
|
26
|
-
*
|
|
27
|
-
* @default
|
|
28
|
-
* @see https://github.com/storybookjs/storybook/blob/next/code/builders/builder-webpack5/src/config/defaults.js#L4-L6
|
|
29
|
-
*/
|
|
30
|
-
reactDocgenTypescriptOptions: PluginOptions;
|
|
31
|
-
};
|
|
32
|
-
type StorybookConfig<TWebpackConfiguration = WebpackConfiguration> = StorybookConfig$1<TWebpackConfiguration> & {
|
|
33
|
-
typescript?: Partial<TypescriptOptions>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { ReactOptions as R, StorybookConfig as S, TypescriptOptions as T };
|