storybook 10.2.0-alpha.16 → 10.2.0-alpha.18
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/{builder-manager-DQ6DNDHX.js → builder-manager-RC5VXLE2.js} +14 -12
- package/dist/_node-chunks/{camelcase-ILOVTISA.js → camelcase-3YERF6B7.js} +7 -7
- package/dist/_node-chunks/chunk-2H33L3XJ.js +61 -0
- package/dist/_node-chunks/{chunk-47ZRY4XW.js → chunk-2M7TBZBZ.js} +6 -6
- package/dist/_node-chunks/{chunk-TTACLBSG.js → chunk-4HG57EIN.js} +7 -7
- package/dist/_node-chunks/{chunk-CFXIZS6A.js → chunk-4PWGJYBL.js} +7 -7
- package/dist/_node-chunks/{chunk-K6FMM5LS.js → chunk-54FLVGBQ.js} +6 -6
- package/dist/_node-chunks/{chunk-3PMH6BEP.js → chunk-5BYTBW23.js} +6 -6
- package/dist/_node-chunks/{chunk-TDBTCAEB.js → chunk-5QNVOHBZ.js} +125 -73
- package/dist/_node-chunks/{chunk-SWN4HCJE.js → chunk-6TOW3ZMZ.js} +6 -6
- package/dist/_node-chunks/{chunk-FNQ5WLS5.js → chunk-A2364FS2.js} +7 -7
- package/dist/_node-chunks/{chunk-ZN5DGHF3.js → chunk-BWA66NDS.js} +10 -10
- package/dist/_node-chunks/{chunk-RIEIAV32.js → chunk-DIZCVGPK.js} +7 -7
- package/dist/_node-chunks/{chunk-PGYIGHRK.js → chunk-F347QVLI.js} +9 -9
- package/dist/_node-chunks/chunk-GJRLPTXZ.js +144 -0
- package/dist/_node-chunks/{chunk-LOJ73E6E.js → chunk-H4TYBETM.js} +9 -9
- package/dist/_node-chunks/{chunk-IVYTDHSW.js → chunk-HXE2FZ3F.js} +7 -7
- package/dist/_node-chunks/{chunk-KAAWGCHX.js → chunk-IHBEBZVB.js} +12 -12
- package/dist/_node-chunks/chunk-JK62DOZL.js +23 -0
- package/dist/_node-chunks/{chunk-WVXPIXUS.js → chunk-LMYIILVH.js} +7 -7
- package/dist/_node-chunks/{chunk-XWGABQX7.js → chunk-N73BCSUL.js} +6 -6
- package/dist/_node-chunks/{chunk-OKUHCLLJ.js → chunk-OT3P3RDM.js} +9 -9
- package/dist/_node-chunks/{chunk-JXU4P6K3.js → chunk-OZGI27C5.js} +6 -6
- package/dist/_node-chunks/{chunk-6QEWR44T.js → chunk-OZHRGJKY.js} +7 -7
- package/dist/_node-chunks/chunk-Q3WHGQXN.js +18 -0
- package/dist/_node-chunks/{chunk-TLGG6YAX.js → chunk-QNYGS5WG.js} +511 -127
- package/dist/_node-chunks/{chunk-WIOSV6HC.js → chunk-QXDUEJWP.js} +6 -6
- package/dist/_node-chunks/{chunk-M6AUSQA3.js → chunk-USLMTVEL.js} +22 -22
- package/dist/_node-chunks/{chunk-YFUVKP3W.js → chunk-XH6HLMNG.js} +7 -7
- package/dist/_node-chunks/{chunk-XJMJA2L4.js → chunk-ZUTW3EKD.js} +250 -14
- package/dist/_node-chunks/{globby-A35XB3PP.js → globby-IVEL6LAU.js} +9 -9
- package/dist/_node-chunks/{lib-D5I6ETBH.js → lib-IDUN2DHZ.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-DZ4EAFAE.js → mdx-N42X6CFJ-V7NAUWUX.js} +8 -8
- package/dist/_node-chunks/{p-limit-2CRKZRXN.js → p-limit-VA3OYXXM.js} +7 -7
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +12 -12
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +9 -9
- package/dist/cli/index.js +18 -18
- package/dist/common/index.js +19 -19
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +55 -60
- package/dist/core-events/index.d.ts +19 -3
- package/dist/core-events/index.js +5 -1
- package/dist/core-server/index.d.ts +69 -2
- package/dist/core-server/index.js +38 -34
- package/dist/core-server/presets/common-override-preset.js +11 -11
- package/dist/core-server/presets/common-preset.js +519 -234
- package/dist/csf/index.d.ts +15 -3
- package/dist/csf/index.js +37 -13
- package/dist/csf-tools/index.d.ts +19 -1
- package/dist/csf-tools/index.js +11 -10
- package/dist/manager/globals-runtime.js +107 -81
- package/dist/manager/runtime.js +829 -167
- package/dist/manager-api/index.d.ts +2 -0
- package/dist/manager-api/index.js +10 -2
- package/dist/mocking-utils/index.js +8 -8
- package/dist/node-logger/index.js +9 -9
- package/dist/preview/runtime.js +33 -6
- package/dist/preview-api/index.d.ts +68 -67
- package/dist/server-errors.js +11 -11
- package/dist/telemetry/index.d.ts +14 -2
- package/dist/telemetry/index.js +23 -22
- package/dist/theming/index.js +16 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +2 -1
- package/dist/_node-chunks/chunk-5E2HAJXY.js +0 -35
- package/dist/_node-chunks/chunk-DGLVYUKY.js +0 -61
- package/dist/_node-chunks/chunk-MSK3YTQT.js +0 -23
- package/dist/_node-chunks/chunk-SPPXK6CQ.js +0 -18
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
versions_default
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2H33L3XJ.js";
|
|
15
15
|
import {
|
|
16
16
|
require_picomatch,
|
|
17
17
|
toPath,
|
|
18
18
|
traversePathUp
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-4HG57EIN.js";
|
|
20
20
|
import {
|
|
21
21
|
logger
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-OT3P3RDM.js";
|
|
23
23
|
import {
|
|
24
24
|
any,
|
|
25
25
|
detectIndent,
|
|
@@ -27,31 +27,31 @@ import {
|
|
|
27
27
|
invariant,
|
|
28
28
|
up,
|
|
29
29
|
up2
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-OZGI27C5.js";
|
|
31
31
|
import {
|
|
32
32
|
importModule,
|
|
33
33
|
resolveModulePath,
|
|
34
34
|
resolvePackageDir,
|
|
35
35
|
safeResolveModule
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-DIZCVGPK.js";
|
|
37
37
|
import {
|
|
38
38
|
join,
|
|
39
39
|
parse,
|
|
40
40
|
resolve
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-N73BCSUL.js";
|
|
42
|
+
import {
|
|
43
|
+
slash
|
|
44
|
+
} from "./chunk-2M7TBZBZ.js";
|
|
42
45
|
import {
|
|
43
46
|
glob,
|
|
44
47
|
globSync
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import {
|
|
47
|
-
slash
|
|
48
|
-
} from "./chunk-47ZRY4XW.js";
|
|
48
|
+
} from "./chunk-OZHRGJKY.js";
|
|
49
49
|
import {
|
|
50
50
|
require_dist
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-XH6HLMNG.js";
|
|
52
52
|
import {
|
|
53
53
|
require_picocolors
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-A2364FS2.js";
|
|
55
55
|
import {
|
|
56
56
|
__commonJS,
|
|
57
57
|
__esm,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
__require,
|
|
60
60
|
__toCommonJS,
|
|
61
61
|
__toESM
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-5BYTBW23.js";
|
|
63
63
|
|
|
64
64
|
// ../../node_modules/resolve/lib/homedir.js
|
|
65
65
|
var require_homedir = __commonJS({
|
|
@@ -11083,7 +11083,7 @@ function normalizeStoryPath(filename) {
|
|
|
11083
11083
|
|
|
11084
11084
|
// src/common/utils/envs.ts
|
|
11085
11085
|
async function loadEnvs(options = {}) {
|
|
11086
|
-
let { getEnvironment } = await import("./lib-
|
|
11086
|
+
let { getEnvironment } = await import("./lib-IDUN2DHZ.js"), defaultNodeEnv = options.production ? "production" : "development", baseEnv = {
|
|
11087
11087
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
11088
11088
|
NODE_ENV: process.env.NODE_ENV || defaultNodeEnv,
|
|
11089
11089
|
NODE_PATH: process.env.NODE_PATH || "",
|
|
@@ -18552,7 +18552,7 @@ async function scanAndTransformFiles({
|
|
|
18552
18552
|
initialValue: defaultGlob
|
|
18553
18553
|
});
|
|
18554
18554
|
logger15.log("Scanning for affected files...");
|
|
18555
|
-
let globby = (await import("./globby-
|
|
18555
|
+
let globby = (await import("./globby-IVEL6LAU.js")).globby, sourceFiles = await globby([glob2], {
|
|
18556
18556
|
...commonGlobOptions(""),
|
|
18557
18557
|
ignore: ["**/node_modules/**"],
|
|
18558
18558
|
dot: !0,
|
|
@@ -18573,7 +18573,7 @@ function transformImports(source, renamedImports) {
|
|
|
18573
18573
|
return hasChanges ? transformed : null;
|
|
18574
18574
|
}
|
|
18575
18575
|
var transformImportFiles = async (files, renamedImports, dryRun) => {
|
|
18576
|
-
let errors = [], { default: pLimit } = await import("./p-limit-
|
|
18576
|
+
let errors = [], { default: pLimit } = await import("./p-limit-VA3OYXXM.js"), limit = pLimit(10);
|
|
18577
18577
|
return await Promise.all(
|
|
18578
18578
|
files.map(
|
|
18579
18579
|
(file) => limit(async () => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
__commonJS
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-5BYTBW23.js";
|
|
15
15
|
|
|
16
16
|
// ../../node_modules/ts-dedent/dist/index.js
|
|
17
17
|
var require_dist = __commonJS({
|
|
@@ -1,35 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
require_build
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4PWGJYBL.js";
|
|
15
15
|
import {
|
|
16
16
|
StorybookError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-54FLVGBQ.js";
|
|
18
|
+
import {
|
|
19
|
+
up
|
|
20
|
+
} from "./chunk-OZGI27C5.js";
|
|
18
21
|
import {
|
|
19
22
|
resolvePackageDir
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-DIZCVGPK.js";
|
|
21
24
|
import {
|
|
22
25
|
relative
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-N73BCSUL.js";
|
|
27
|
+
import {
|
|
28
|
+
STORYBOOK_FN_PLACEHOLDER,
|
|
29
|
+
generateDummyArgsFromArgTypes,
|
|
30
|
+
loadConfig,
|
|
31
|
+
printConfig
|
|
32
|
+
} from "./chunk-QNYGS5WG.js";
|
|
24
33
|
import {
|
|
25
34
|
require_dist
|
|
26
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XH6HLMNG.js";
|
|
27
36
|
import {
|
|
28
37
|
require_picocolors
|
|
29
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-A2364FS2.js";
|
|
30
39
|
import {
|
|
31
40
|
__toESM
|
|
32
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-5BYTBW23.js";
|
|
33
42
|
|
|
34
43
|
// src/core-server/utils/server-statics.ts
|
|
35
44
|
import { existsSync, statSync } from "node:fs";
|
|
@@ -225,6 +234,230 @@ async function withTelemetry(eventType, options, run) {
|
|
|
225
234
|
}
|
|
226
235
|
}
|
|
227
236
|
|
|
237
|
+
// src/core-server/utils/generate-story.ts
|
|
238
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
239
|
+
import { writeFile } from "node:fs/promises";
|
|
240
|
+
import { relative as relative3 } from "node:path";
|
|
241
|
+
import { getProjectRoot as getProjectRoot3, getStoryId } from "storybook/internal/common";
|
|
242
|
+
|
|
243
|
+
// src/core-server/utils/get-new-story-file.ts
|
|
244
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
245
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
246
|
+
import { basename as basename2, dirname as dirname2, extname, join as join2, relative as relative2 } from "node:path";
|
|
247
|
+
import { types as t, traverse } from "storybook/internal/babel";
|
|
248
|
+
import {
|
|
249
|
+
extractFrameworkPackageName,
|
|
250
|
+
findConfigFile,
|
|
251
|
+
formatFileContent,
|
|
252
|
+
getFrameworkName,
|
|
253
|
+
getProjectRoot as getProjectRoot2
|
|
254
|
+
} from "storybook/internal/common";
|
|
255
|
+
import { isCsfFactoryPreview } from "storybook/internal/csf-tools";
|
|
256
|
+
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
257
|
+
|
|
258
|
+
// src/core-server/utils/new-story-templates/csf-factory-template.ts
|
|
259
|
+
var import_ts_dedent2 = __toESM(require_dist(), 1);
|
|
260
|
+
|
|
261
|
+
// src/core-server/utils/get-component-variable-name.ts
|
|
262
|
+
var getComponentVariableName = async (name) => (await import("./camelcase-3YERF6B7.js")).default(name.replace(/^[^a-zA-Z_$]*/, ""), { pascalCase: !0 }).replace(/[^a-zA-Z_$]+/, "");
|
|
263
|
+
|
|
264
|
+
// src/core-server/utils/new-story-templates/csf-factory-template.ts
|
|
265
|
+
async function getCsfFactoryTemplateForNewStoryFile(data) {
|
|
266
|
+
let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`, previewImport = data.previewImportPath ? `import preview from '${data.previewImportPath}';` : "import preview from '#.storybook/preview';", argsString = data.args && Object.keys(data.args).length > 0 ? `{ args: ${JSON.stringify(data.args, null, 2)} }` : "{}";
|
|
267
|
+
return import_ts_dedent2.dedent`
|
|
268
|
+
${previewImport}
|
|
269
|
+
|
|
270
|
+
${importStatement}
|
|
271
|
+
|
|
272
|
+
const meta = preview.meta({
|
|
273
|
+
component: ${importName},
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
export const ${data.exportedStoryName} = meta.story(${argsString});
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/core-server/utils/new-story-templates/javascript.ts
|
|
281
|
+
var import_ts_dedent3 = __toESM(require_dist(), 1);
|
|
282
|
+
async function getJavaScriptTemplateForNewStoryFile(data) {
|
|
283
|
+
let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`, hasArgs = !!(data.args && Object.keys(data.args).length > 0), argsString = hasArgs ? `args: ${JSON.stringify(data.args, null, 2)},` : "", storyExport = hasArgs ? import_ts_dedent3.dedent`
|
|
284
|
+
export const ${data.exportedStoryName} = {
|
|
285
|
+
${argsString}
|
|
286
|
+
};
|
|
287
|
+
` : `export const ${data.exportedStoryName} = {};`;
|
|
288
|
+
return import_ts_dedent3.dedent`
|
|
289
|
+
${importStatement}
|
|
290
|
+
|
|
291
|
+
const meta = {
|
|
292
|
+
component: ${importName},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export default meta;
|
|
296
|
+
|
|
297
|
+
${storyExport}
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/core-server/utils/new-story-templates/typescript.ts
|
|
302
|
+
var import_ts_dedent4 = __toESM(require_dist(), 1);
|
|
303
|
+
async function getTypeScriptTemplateForNewStoryFile(data) {
|
|
304
|
+
let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}'` : `import { ${importName} } from './${data.basenameWithoutExtension}'`, hasArgs = !!(data.args && Object.keys(data.args).length > 0), argsString = hasArgs ? `args: ${JSON.stringify(data.args, null, 2)},` : "", storyExport = hasArgs ? import_ts_dedent4.dedent`
|
|
305
|
+
export const ${data.exportedStoryName}: Story = {
|
|
306
|
+
${argsString}
|
|
307
|
+
};
|
|
308
|
+
` : `export const ${data.exportedStoryName}: Story = {};`;
|
|
309
|
+
return import_ts_dedent4.dedent`
|
|
310
|
+
import type { Meta, StoryObj } from '${data.frameworkPackage}';
|
|
311
|
+
|
|
312
|
+
${importStatement};
|
|
313
|
+
|
|
314
|
+
const meta = {
|
|
315
|
+
component: ${importName},
|
|
316
|
+
} satisfies Meta<typeof ${importName}>;
|
|
317
|
+
|
|
318
|
+
export default meta;
|
|
319
|
+
|
|
320
|
+
type Story = StoryObj<typeof meta>;
|
|
321
|
+
|
|
322
|
+
${storyExport}
|
|
323
|
+
`;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/core-server/utils/get-new-story-file.ts
|
|
327
|
+
async function getNewStoryFile({
|
|
328
|
+
componentFilePath,
|
|
329
|
+
componentExportName,
|
|
330
|
+
componentIsDefaultExport,
|
|
331
|
+
componentExportCount
|
|
332
|
+
}, options) {
|
|
333
|
+
let frameworkPackageName = await getFrameworkName(options), sanitizedFrameworkPackageName = extractFrameworkPackageName(frameworkPackageName), base = basename2(componentFilePath), extension = extname(componentFilePath), basenameWithoutExtension = base.replace(extension, ""), dir = dirname2(componentFilePath), { storyFileName, isTypescript, storyFileExtension } = getStoryMetadata(componentFilePath), storyFileNameWithExtension = `${storyFileName}.${storyFileExtension}`, alternativeStoryFileNameWithExtension = `${basenameWithoutExtension}.${componentExportName}.stories.${storyFileExtension}`, exportedStoryName = "Default", useCsfFactory = !1, previewConfigPath;
|
|
334
|
+
try {
|
|
335
|
+
let previewConfig = findConfigFile("preview", options.configDir);
|
|
336
|
+
if (previewConfig) {
|
|
337
|
+
let previewContent = await readFile2(previewConfig, "utf-8");
|
|
338
|
+
useCsfFactory = isCsfFactoryPreview(loadConfig(previewContent)), previewConfigPath = previewConfig;
|
|
339
|
+
}
|
|
340
|
+
} catch {
|
|
341
|
+
}
|
|
342
|
+
let args;
|
|
343
|
+
try {
|
|
344
|
+
let argTypes = await options.presets.apply("internal_getArgTypesData", null, {
|
|
345
|
+
...options,
|
|
346
|
+
componentFilePath,
|
|
347
|
+
componentExportName
|
|
348
|
+
});
|
|
349
|
+
if (logger3.debug(`Extracted argTypes for ${componentExportName}: ${JSON.stringify(argTypes)}`), argTypes) {
|
|
350
|
+
let { required } = generateDummyArgsFromArgTypes(argTypes);
|
|
351
|
+
Object.keys(required).length > 0 && (args = required, logger3.debug(
|
|
352
|
+
`Generated dummy data using ArgTypes for ${componentExportName}: ${JSON.stringify(args)}`
|
|
353
|
+
));
|
|
354
|
+
}
|
|
355
|
+
} catch (error) {
|
|
356
|
+
logger3.debug(`Could not generate dummy data for ${componentExportName}: ${error}`);
|
|
357
|
+
}
|
|
358
|
+
let storyFileContent = "";
|
|
359
|
+
if (useCsfFactory) {
|
|
360
|
+
let previewImportPath;
|
|
361
|
+
if (previewConfigPath && !await checkForImportsMap(options.configDir)) {
|
|
362
|
+
let storyFilePath2 = join2(getProjectRoot2(), dir), pathWithoutExt = relative2(storyFilePath2, previewConfigPath).replace(/\.(ts|js|mts|cts|tsx|jsx)$/, "");
|
|
363
|
+
previewImportPath = pathWithoutExt.startsWith(".") ? pathWithoutExt : `./${pathWithoutExt}`;
|
|
364
|
+
}
|
|
365
|
+
storyFileContent = await getCsfFactoryTemplateForNewStoryFile({
|
|
366
|
+
basenameWithoutExtension,
|
|
367
|
+
componentExportName,
|
|
368
|
+
componentIsDefaultExport,
|
|
369
|
+
exportedStoryName,
|
|
370
|
+
previewImportPath,
|
|
371
|
+
args
|
|
372
|
+
});
|
|
373
|
+
} else
|
|
374
|
+
storyFileContent = isTypescript && frameworkPackageName ? await getTypeScriptTemplateForNewStoryFile({
|
|
375
|
+
basenameWithoutExtension,
|
|
376
|
+
componentExportName,
|
|
377
|
+
componentIsDefaultExport,
|
|
378
|
+
frameworkPackage: sanitizedFrameworkPackageName,
|
|
379
|
+
exportedStoryName,
|
|
380
|
+
args
|
|
381
|
+
}) : await getJavaScriptTemplateForNewStoryFile({
|
|
382
|
+
basenameWithoutExtension,
|
|
383
|
+
componentExportName,
|
|
384
|
+
componentIsDefaultExport,
|
|
385
|
+
exportedStoryName,
|
|
386
|
+
args
|
|
387
|
+
});
|
|
388
|
+
storyFileContent = replaceArgsPlaceholders(storyFileContent);
|
|
389
|
+
let storyFilePath = doesStoryFileExist(join2(getProjectRoot2(), dir), storyFileName) && componentExportCount > 1 ? join2(getProjectRoot2(), dir, alternativeStoryFileNameWithExtension) : join2(getProjectRoot2(), dir, storyFileNameWithExtension), formattedStoryFileContent = await formatFileContent(storyFilePath, storyFileContent);
|
|
390
|
+
return {
|
|
391
|
+
storyFilePath,
|
|
392
|
+
exportedStoryName,
|
|
393
|
+
storyFileContent: formattedStoryFileContent,
|
|
394
|
+
dirname: dir
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
var getStoryMetadata = (componentFilePath) => {
|
|
398
|
+
let isTypescript = /\.(ts|tsx|mts|cts)$/.test(componentFilePath), base = basename2(componentFilePath), extension = extname(componentFilePath), basenameWithoutExtension = base.replace(extension, ""), storyFileExtension = isTypescript ? "tsx" : "jsx";
|
|
399
|
+
return {
|
|
400
|
+
storyFileName: `${basenameWithoutExtension}.stories`,
|
|
401
|
+
storyFileExtension,
|
|
402
|
+
isTypescript
|
|
403
|
+
};
|
|
404
|
+
}, doesStoryFileExist = (parentFolder, storyFileName) => existsSync2(join2(parentFolder, `${storyFileName}.ts`)) || existsSync2(join2(parentFolder, `${storyFileName}.tsx`)) || existsSync2(join2(parentFolder, `${storyFileName}.js`)) || existsSync2(join2(parentFolder, `${storyFileName}.jsx`));
|
|
405
|
+
async function checkForImportsMap(configDir) {
|
|
406
|
+
try {
|
|
407
|
+
for (let directory of up(configDir, { last: getProjectRoot2() })) {
|
|
408
|
+
let packageJsonPath = join2(directory, "package.json");
|
|
409
|
+
if (existsSync2(packageJsonPath)) {
|
|
410
|
+
let packageJsonContent = await readFile2(packageJsonPath, "utf-8");
|
|
411
|
+
if (JSON.parse(packageJsonContent).imports)
|
|
412
|
+
return !0;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return !1;
|
|
416
|
+
} catch {
|
|
417
|
+
return !1;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function replaceArgsPlaceholders(storyFileContent) {
|
|
421
|
+
if (!storyFileContent.includes(STORYBOOK_FN_PLACEHOLDER))
|
|
422
|
+
return storyFileContent;
|
|
423
|
+
let storyFile = loadConfig(storyFileContent).parse(), needsFnImport = !1;
|
|
424
|
+
return traverse(storyFile._ast, {
|
|
425
|
+
StringLiteral(path) {
|
|
426
|
+
path.node.value === STORYBOOK_FN_PLACEHOLDER && (needsFnImport = !0, path.replaceWith(t.callExpression(t.identifier("fn"), [])));
|
|
427
|
+
}
|
|
428
|
+
}), needsFnImport && storyFile.setImport(["fn"], "storybook/test"), printConfig(storyFile).code;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/core-server/utils/generate-story.ts
|
|
432
|
+
async function generateStoryFile(payload, options, generateOptions = {}) {
|
|
433
|
+
let { checkFileExists = !0 } = generateOptions;
|
|
434
|
+
try {
|
|
435
|
+
let { storyFilePath, exportedStoryName, storyFileContent } = await getNewStoryFile(
|
|
436
|
+
payload,
|
|
437
|
+
options
|
|
438
|
+
), relativeStoryFilePath = relative3(getProjectRoot3(), storyFilePath), { storyId, kind } = await getStoryId({ storyFilePath, exportedStoryName }, options);
|
|
439
|
+
return checkFileExists && existsSync3(storyFilePath) ? {
|
|
440
|
+
success: !1,
|
|
441
|
+
kind,
|
|
442
|
+
storyFilePath: relativeStoryFilePath,
|
|
443
|
+
error: `A story file already exists at ${relativeStoryFilePath}`,
|
|
444
|
+
errorType: "STORY_FILE_EXISTS"
|
|
445
|
+
} : (await writeFile(storyFilePath, storyFileContent, "utf-8"), {
|
|
446
|
+
success: !0,
|
|
447
|
+
storyId,
|
|
448
|
+
kind,
|
|
449
|
+
storyFilePath: relativeStoryFilePath,
|
|
450
|
+
exportedStoryName
|
|
451
|
+
});
|
|
452
|
+
} catch (e) {
|
|
453
|
+
return {
|
|
454
|
+
success: !1,
|
|
455
|
+
error: e?.message || "Unknown error occurred",
|
|
456
|
+
errorType: "UNKNOWN"
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
228
461
|
// ../../node_modules/es-toolkit/dist/function/debounce.mjs
|
|
229
462
|
function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
230
463
|
let pendingThis, pendingArgs = null, leading = edges != null && edges.includes("leading"), trailing = edges == null || edges.includes("trailing"), invoke = () => {
|
|
@@ -305,5 +538,8 @@ export {
|
|
|
305
538
|
getErrorLevel,
|
|
306
539
|
sendTelemetryError,
|
|
307
540
|
isTelemetryEnabled,
|
|
308
|
-
withTelemetry
|
|
541
|
+
withTelemetry,
|
|
542
|
+
getStoryMetadata,
|
|
543
|
+
doesStoryFileExist,
|
|
544
|
+
generateStoryFile
|
|
309
545
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,15 +13,15 @@ import {
|
|
|
13
13
|
require_picomatch,
|
|
14
14
|
require_utils,
|
|
15
15
|
toPath
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-4HG57EIN.js";
|
|
17
17
|
import {
|
|
18
18
|
slash
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2M7TBZBZ.js";
|
|
20
20
|
import {
|
|
21
21
|
__commonJS,
|
|
22
22
|
__require,
|
|
23
23
|
__toESM
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-5BYTBW23.js";
|
|
25
25
|
|
|
26
26
|
// ../../node_modules/fast-glob/out/utils/array.js
|
|
27
27
|
var require_array = __commonJS({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
__commonJS,
|
|
14
14
|
__require,
|
|
15
15
|
__toESM
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-5BYTBW23.js";
|
|
17
17
|
|
|
18
18
|
// ../../node_modules/app-root-dir/lib/index.js
|
|
19
19
|
var require_lib = __commonJS({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
position,
|
|
22
22
|
start,
|
|
23
23
|
toEstree
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-HXE2FZ3F.js";
|
|
25
|
+
import "./chunk-5BYTBW23.js";
|
|
26
26
|
|
|
27
27
|
// ../../node_modules/@storybook/docs-mdx/dist/mdx-N42X6CFJ.js
|
|
28
28
|
import { default as default2 } from "path";
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.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 "./chunk-
|
|
12
|
+
import "./chunk-5BYTBW23.js";
|
|
13
13
|
|
|
14
14
|
// ../../node_modules/yocto-queue/index.js
|
|
15
15
|
var Node = class {
|
package/dist/babel/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -22,10 +22,10 @@ import {
|
|
|
22
22
|
recast,
|
|
23
23
|
traverse,
|
|
24
24
|
types
|
|
25
|
-
} from "../_node-chunks/chunk-
|
|
26
|
-
import "../_node-chunks/chunk-
|
|
27
|
-
import "../_node-chunks/chunk-
|
|
28
|
-
import "../_node-chunks/chunk-
|
|
25
|
+
} from "../_node-chunks/chunk-F347QVLI.js";
|
|
26
|
+
import "../_node-chunks/chunk-LMYIILVH.js";
|
|
27
|
+
import "../_node-chunks/chunk-A2364FS2.js";
|
|
28
|
+
import "../_node-chunks/chunk-5BYTBW23.js";
|
|
29
29
|
var export_transformSync = import_core.transformSync;
|
|
30
30
|
export {
|
|
31
31
|
BabelFileClass,
|
package/dist/bin/core.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bfa4dw0yocr from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bfa4dw0yocr from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bfa4dw0yocr from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bfa4dw0yocr.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bfa4dw0yocr.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bfa4dw0yocr.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
version
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-Q3WHGQXN.js";
|
|
15
15
|
import {
|
|
16
16
|
globalSettings
|
|
17
|
-
} from "../_node-chunks/chunk-
|
|
18
|
-
import "../_node-chunks/chunk-
|
|
17
|
+
} from "../_node-chunks/chunk-H4TYBETM.js";
|
|
18
|
+
import "../_node-chunks/chunk-6TOW3ZMZ.js";
|
|
19
19
|
import {
|
|
20
20
|
require_dist
|
|
21
|
-
} from "../_node-chunks/chunk-
|
|
21
|
+
} from "../_node-chunks/chunk-XH6HLMNG.js";
|
|
22
22
|
import {
|
|
23
23
|
require_picocolors
|
|
24
|
-
} from "../_node-chunks/chunk-
|
|
24
|
+
} from "../_node-chunks/chunk-A2364FS2.js";
|
|
25
25
|
import {
|
|
26
26
|
__commonJS,
|
|
27
27
|
__require,
|
|
28
28
|
__toESM
|
|
29
|
-
} from "../_node-chunks/chunk-
|
|
29
|
+
} from "../_node-chunks/chunk-5BYTBW23.js";
|
|
30
30
|
|
|
31
31
|
// ../../node_modules/commander/lib/error.js
|
|
32
32
|
var require_error = __commonJS({
|