storybook 10.2.0-alpha.8 → 10.2.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/dist/_browser-chunks/{Color-E5XDEOX4.js → Color-XESOIGZP.js} +57 -3
- package/dist/_browser-chunks/chunk-AFVOZMXQ.js +23 -0
- package/dist/_browser-chunks/{chunk-3PJE6VLG.js → chunk-ASKQZAOS.js} +1 -12
- package/dist/_browser-chunks/chunk-IYCKG66Y.js +171 -0
- package/dist/_browser-chunks/chunk-LCHBOIHN.js +64 -0
- package/dist/_browser-chunks/{chunk-IPA5A322.js → chunk-MEXTPDJG.js} +1 -1
- package/dist/_browser-chunks/{chunk-54PNNATT.js → chunk-NQJGOFZV.js} +18 -1
- package/dist/_browser-chunks/{chunk-VUZYLZ4B.js → chunk-QOXZ7W26.js} +31 -15
- package/dist/_browser-chunks/{chunk-LOTN4ZCW.js → chunk-SI6AKD4S.js} +2 -2
- package/dist/_browser-chunks/chunk-YK43Z22A.js +263 -0
- package/dist/_node-chunks/{builder-manager-2XASU3VS.js → builder-manager-JEJE63VV.js} +15 -12
- package/dist/_node-chunks/camelcase-HALRJETF.js +62 -0
- package/dist/_node-chunks/{chunk-5GRHJJHD.js → chunk-3SKE4CCB.js} +9 -9
- package/dist/_node-chunks/chunk-4UYAC7Y2.js +18 -0
- package/dist/_node-chunks/{chunk-S7FIFCTX.js → chunk-6UAQEBJX.js} +10 -10
- package/dist/_node-chunks/{chunk-ZKB7MQRR.js → chunk-72K4WVI5.js} +18 -14
- package/dist/_node-chunks/{chunk-6TJUL42C.js → chunk-7ZX5CX6B.js} +15 -69
- package/dist/_node-chunks/{chunk-LEZENLG7.js → chunk-ADTWC7QJ.js} +7 -7
- package/dist/_node-chunks/{chunk-2OC7H5MZ.js → chunk-APUXGW3Y.js} +7 -7
- package/dist/_node-chunks/{chunk-5WQXPM6D.js → chunk-AXDM43NU.js} +6 -6
- package/dist/_node-chunks/{chunk-LOXLI4XT.js → chunk-B422K4XV.js} +6 -6
- package/dist/_node-chunks/{chunk-3K6P75SS.js → chunk-BJOXVTWM.js} +12 -571
- package/dist/_node-chunks/{chunk-TTGXODEY.js → chunk-BLGRU6F5.js} +7 -7
- package/dist/_node-chunks/{chunk-2KSITKBI.js → chunk-CG47ALAV.js} +7 -7
- package/dist/_node-chunks/chunk-FH4FRUMP.js +23 -0
- package/dist/_node-chunks/{chunk-DTM4A3DJ.js → chunk-GBZ23FIZ.js} +125 -73
- package/dist/_node-chunks/{chunk-IJ34563N.js → chunk-IZ3ATSWZ.js} +5262 -1480
- package/dist/_node-chunks/{chunk-JWL5NLJU.js → chunk-IZFEBWVB.js} +6 -6
- package/dist/_node-chunks/{chunk-5BRYY6XB.js → chunk-KL5CKFPT.js} +9 -9
- package/dist/_node-chunks/{chunk-COGO4JMD.js → chunk-MLXCYULR.js} +7 -7
- package/dist/_node-chunks/{chunk-7B4JYHGV.js → chunk-MV2QM7P3.js} +6 -6
- package/dist/_node-chunks/chunk-PHX5XNP7.js +144 -0
- package/dist/_node-chunks/{chunk-VJFHZL2T.js → chunk-QL6L57W7.js} +533 -144
- package/dist/_node-chunks/{chunk-Q6WPGVIW.js → chunk-RPBXVPRB.js} +6 -6
- package/dist/_node-chunks/{chunk-DYQ6QR45.js → chunk-UH2GWMFP.js} +260 -162
- package/dist/_node-chunks/chunk-WNGL2VRJ.js +126 -0
- package/dist/_node-chunks/{chunk-WKC523P7.js → chunk-XAL452XB.js} +36 -14
- package/dist/_node-chunks/{chunk-UNHOAAXU.js → chunk-YVXXMWQO.js} +7 -7
- package/dist/_node-chunks/chunk-YYDL7JOC.js +61 -0
- package/dist/_node-chunks/{chunk-MLYPMYG5.js → chunk-Z7FLE2TR.js} +6 -6
- package/dist/_node-chunks/{globby-FWMT4OOQ.js → globby-4D4NBVG7.js} +11 -20
- package/dist/_node-chunks/{lib-YCGXIMW5.js → lib-RM2DWHZQ.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-CRGM5LTU.js → mdx-N42X6CFJ-RAL72UTP.js} +8 -8
- package/dist/_node-chunks/{p-limit-UJIYI4QT.js → p-limit-6PUJQL5X.js} +18 -14
- 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.d.ts +1504 -424
- package/dist/cli/index.js +18 -18
- package/dist/common/index.d.ts +1319 -271
- package/dist/common/index.js +22 -22
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.js +228 -227
- package/dist/core-events/index.d.ts +23 -7
- package/dist/core-events/index.js +5 -1
- package/dist/core-server/index.d.ts +108 -4
- package/dist/core-server/index.js +3459 -3086
- package/dist/core-server/presets/common-manager.js +208 -160
- package/dist/core-server/presets/common-override-preset.js +11 -11
- package/dist/core-server/presets/common-preset.js +576 -4536
- package/dist/csf/index.d.ts +147 -15
- package/dist/csf/index.js +52 -23
- package/dist/csf-tools/index.d.ts +19 -1
- package/dist/csf-tools/index.js +11 -9
- package/dist/docs-tools/index.d.ts +2 -2
- package/dist/docs-tools/index.js +4 -5
- package/dist/manager/globals-runtime.js +2749 -6907
- package/dist/manager/runtime.js +2939 -2295
- package/dist/manager-api/index.d.ts +89 -21
- package/dist/manager-api/index.js +82 -23
- package/dist/mocking-utils/index.js +8 -8
- package/dist/node-logger/index.d.ts +1453 -108
- package/dist/node-logger/index.js +9 -9
- package/dist/preview/runtime.js +784 -5059
- package/dist/preview-api/index.d.ts +26 -1
- package/dist/preview-api/index.js +11 -8
- package/dist/router/index.js +5 -4
- 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.d.ts +5 -5
- package/dist/theming/index.js +21 -2
- package/dist/types/index.d.ts +24 -11
- package/dist/viewport/index.d.ts +5 -3
- package/dist/viewport/index.js +12 -3
- package/package.json +27 -26
- package/dist/_browser-chunks/chunk-2NDLAB5X.js +0 -363
- package/dist/_browser-chunks/chunk-CLSHX4VX.js +0 -4140
- package/dist/_browser-chunks/chunk-HPYUT3WS.js +0 -199
- package/dist/_browser-chunks/chunk-XCZK5QUJ.js +0 -0
- package/dist/_node-chunks/camelcase-KIWRHB2G.js +0 -37
- package/dist/_node-chunks/chunk-2ANLCK4Y.js +0 -18
- package/dist/_node-chunks/chunk-3TW66YXG.js +0 -70
- package/dist/_node-chunks/chunk-UFXCGC4W.js +0 -23
- package/dist/_node-chunks/chunk-X4YDIHYE.js +0 -61
- package/dist/_node-chunks/dist-GICI6ZHU.js +0 -121
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_phceqgr585q from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_phceqgr585q from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_phceqgr585q from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_phceqgr585q.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_phceqgr585q.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_phceqgr585q.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,35 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_phceqgr585q from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_phceqgr585q from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_phceqgr585q from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_phceqgr585q.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_phceqgr585q.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_phceqgr585q.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-ADTWC7QJ.js";
|
|
15
15
|
import {
|
|
16
16
|
StorybookError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-RPBXVPRB.js";
|
|
18
|
+
import {
|
|
19
|
+
up
|
|
20
|
+
} from "./chunk-WNGL2VRJ.js";
|
|
18
21
|
import {
|
|
19
22
|
resolvePackageDir
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-APUXGW3Y.js";
|
|
21
24
|
import {
|
|
22
25
|
relative
|
|
23
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-MV2QM7P3.js";
|
|
27
|
+
import {
|
|
28
|
+
STORYBOOK_FN_PLACEHOLDER,
|
|
29
|
+
generateDummyArgsFromArgTypes,
|
|
30
|
+
loadConfig,
|
|
31
|
+
printConfig
|
|
32
|
+
} from "./chunk-QL6L57W7.js";
|
|
24
33
|
import {
|
|
25
34
|
require_dist
|
|
26
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-BLGRU6F5.js";
|
|
27
36
|
import {
|
|
28
37
|
require_picocolors
|
|
29
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-CG47ALAV.js";
|
|
30
39
|
import {
|
|
31
40
|
__toESM
|
|
32
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-AXDM43NU.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-HALRJETF.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 = () => {
|
|
@@ -240,7 +473,7 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
|
240
473
|
}, cancel = () => {
|
|
241
474
|
cancelTimer(), pendingThis = void 0, pendingArgs = null;
|
|
242
475
|
}, flush = () => {
|
|
243
|
-
|
|
476
|
+
invoke();
|
|
244
477
|
}, debounced = function(...args) {
|
|
245
478
|
if (signal?.aborted)
|
|
246
479
|
return;
|
|
@@ -253,83 +486,18 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
|
253
486
|
|
|
254
487
|
// ../../node_modules/es-toolkit/dist/function/throttle.mjs
|
|
255
488
|
function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
|
|
256
|
-
let pendingAt = null, debounced = debounce(
|
|
257
|
-
pendingAt
|
|
489
|
+
let pendingAt = null, debounced = debounce(function(...args) {
|
|
490
|
+
pendingAt = Date.now(), func.apply(this, args);
|
|
491
|
+
}, throttleMs, { signal, edges }), throttled = function(...args) {
|
|
492
|
+
if (pendingAt == null && (pendingAt = Date.now()), Date.now() - pendingAt >= throttleMs) {
|
|
493
|
+
pendingAt = Date.now(), func.apply(this, args), debounced.cancel(), debounced.schedule();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
debounced.apply(this, args);
|
|
258
497
|
};
|
|
259
498
|
return throttled.cancel = debounced.cancel, throttled.flush = debounced.flush, throttled;
|
|
260
499
|
}
|
|
261
500
|
|
|
262
|
-
// ../../node_modules/es-toolkit/dist/function/after.mjs
|
|
263
|
-
function after(n, func) {
|
|
264
|
-
if (!Number.isInteger(n) || n < 0)
|
|
265
|
-
throw new Error("n must be a non-negative integer.");
|
|
266
|
-
let counter = 0;
|
|
267
|
-
return (...args) => {
|
|
268
|
-
if (++counter >= n)
|
|
269
|
-
return func(...args);
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// ../../node_modules/es-toolkit/dist/function/ary.mjs
|
|
274
|
-
function ary(func, n) {
|
|
275
|
-
return function(...args) {
|
|
276
|
-
return func.apply(this, args.slice(0, n));
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ../../node_modules/es-toolkit/dist/function/asyncNoop.mjs
|
|
281
|
-
async function asyncNoop() {
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// ../../node_modules/es-toolkit/dist/function/flow.mjs
|
|
285
|
-
function flow(...funcs) {
|
|
286
|
-
return function(...args) {
|
|
287
|
-
let result = funcs.length ? funcs[0].apply(this, args) : args[0];
|
|
288
|
-
for (let i = 1; i < funcs.length; i++)
|
|
289
|
-
result = funcs[i].call(this, result);
|
|
290
|
-
return result;
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// ../../node_modules/es-toolkit/dist/function/flowRight.mjs
|
|
295
|
-
function flowRight(...funcs) {
|
|
296
|
-
return flow(...funcs.reverse());
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// ../../node_modules/es-toolkit/dist/function/identity.mjs
|
|
300
|
-
function identity(x) {
|
|
301
|
-
return x;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// ../../node_modules/es-toolkit/dist/function/memoize.mjs
|
|
305
|
-
function memoize(fn, options = {}) {
|
|
306
|
-
let { cache: cache2 = /* @__PURE__ */ new Map(), getCacheKey } = options, memoizedFn = function(arg) {
|
|
307
|
-
let key = getCacheKey ? getCacheKey(arg) : arg;
|
|
308
|
-
if (cache2.has(key))
|
|
309
|
-
return cache2.get(key);
|
|
310
|
-
let result = fn.call(this, arg);
|
|
311
|
-
return cache2.set(key, result), result;
|
|
312
|
-
};
|
|
313
|
-
return memoizedFn.cache = cache2, memoizedFn;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// ../../node_modules/es-toolkit/dist/function/negate.mjs
|
|
317
|
-
function negate(func) {
|
|
318
|
-
return ((...args) => !func(...args));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// ../../node_modules/es-toolkit/dist/function/noop.mjs
|
|
322
|
-
function noop() {
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// ../../node_modules/es-toolkit/dist/function/once.mjs
|
|
326
|
-
function once2(func) {
|
|
327
|
-
let called = !1, cache2;
|
|
328
|
-
return function(...args) {
|
|
329
|
-
return called || (called = !0, cache2 = func(...args)), cache2;
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
501
|
// ../../node_modules/es-toolkit/dist/function/partial.mjs
|
|
334
502
|
function partial(func, ...partialArgs) {
|
|
335
503
|
return partialImpl(func, placeholderSymbol, ...partialArgs);
|
|
@@ -358,90 +526,20 @@ function partialRightImpl(func, placeholder, ...partialArgs) {
|
|
|
358
526
|
var placeholderSymbol2 = Symbol("partialRight.placeholder");
|
|
359
527
|
partialRight.placeholder = placeholderSymbol2;
|
|
360
528
|
|
|
361
|
-
// ../../node_modules/es-toolkit/dist/function/rest.mjs
|
|
362
|
-
function rest(func, startIndex = func.length - 1) {
|
|
363
|
-
return function(...args) {
|
|
364
|
-
let rest2 = args.slice(startIndex), params = args.slice(0, startIndex);
|
|
365
|
-
for (; params.length < startIndex; )
|
|
366
|
-
params.push(void 0);
|
|
367
|
-
return func.apply(this, [...params, rest2]);
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// ../../node_modules/es-toolkit/dist/error/AbortError.mjs
|
|
372
|
-
var AbortError = class extends Error {
|
|
373
|
-
constructor(message = "The operation was aborted") {
|
|
374
|
-
super(message), this.name = "AbortError";
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// ../../node_modules/es-toolkit/dist/promise/delay.mjs
|
|
379
|
-
function delay(ms, { signal } = {}) {
|
|
380
|
-
return new Promise((resolve2, reject) => {
|
|
381
|
-
let abortError = () => {
|
|
382
|
-
reject(new AbortError());
|
|
383
|
-
}, abortHandler = () => {
|
|
384
|
-
clearTimeout(timeoutId), abortError();
|
|
385
|
-
};
|
|
386
|
-
if (signal?.aborted)
|
|
387
|
-
return abortError();
|
|
388
|
-
let timeoutId = setTimeout(() => {
|
|
389
|
-
signal?.removeEventListener("abort", abortHandler), resolve2();
|
|
390
|
-
}, ms);
|
|
391
|
-
signal?.addEventListener("abort", abortHandler, { once: !0 });
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
529
|
// ../../node_modules/es-toolkit/dist/function/retry.mjs
|
|
396
|
-
var
|
|
397
|
-
async function retry(func, _options) {
|
|
398
|
-
let delay$1, retries, signal;
|
|
399
|
-
typeof _options == "number" ? (delay$1 = DEFAULT_DELAY, retries = _options, signal = void 0) : (delay$1 = _options?.delay ?? DEFAULT_DELAY, retries = _options?.retries ?? DEFAULT_RETRIES, signal = _options?.signal);
|
|
400
|
-
let error;
|
|
401
|
-
for (let attempts = 0; attempts < retries; attempts++) {
|
|
402
|
-
if (signal?.aborted)
|
|
403
|
-
throw error ?? new Error("The retry operation was aborted due to an abort signal.");
|
|
404
|
-
try {
|
|
405
|
-
return await func();
|
|
406
|
-
} catch (err) {
|
|
407
|
-
error = err;
|
|
408
|
-
let currentDelay = typeof delay$1 == "function" ? delay$1(attempts) : delay$1;
|
|
409
|
-
await delay(currentDelay);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
throw error;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// ../../node_modules/es-toolkit/dist/function/unary.mjs
|
|
416
|
-
function unary(func) {
|
|
417
|
-
return ary(func, 1);
|
|
418
|
-
}
|
|
530
|
+
var DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
|
|
419
531
|
|
|
420
532
|
export {
|
|
421
533
|
useStatics,
|
|
422
534
|
parseStaticDir,
|
|
423
535
|
mapStaticDir,
|
|
424
|
-
after,
|
|
425
|
-
ary,
|
|
426
|
-
asyncNoop,
|
|
427
536
|
debounce,
|
|
428
|
-
flow,
|
|
429
|
-
flowRight,
|
|
430
|
-
identity,
|
|
431
|
-
memoize,
|
|
432
|
-
negate,
|
|
433
|
-
noop,
|
|
434
|
-
once2 as once,
|
|
435
|
-
partialImpl,
|
|
436
|
-
partialRightImpl,
|
|
437
|
-
rest,
|
|
438
|
-
AbortError,
|
|
439
|
-
delay,
|
|
440
|
-
retry,
|
|
441
537
|
throttle,
|
|
442
|
-
unary,
|
|
443
538
|
getErrorLevel,
|
|
444
539
|
sendTelemetryError,
|
|
445
540
|
isTelemetryEnabled,
|
|
446
|
-
withTelemetry
|
|
541
|
+
withTelemetry,
|
|
542
|
+
getStoryMetadata,
|
|
543
|
+
doesStoryFileExist,
|
|
544
|
+
generateStoryFile
|
|
447
545
|
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_phceqgr585q from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_phceqgr585q from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_phceqgr585q from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_phceqgr585q.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_phceqgr585q.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_phceqgr585q.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
14
|
+
var isProduction = process.env.NODE_ENV === "production", prefix = "Invariant failed";
|
|
15
|
+
function invariant(condition, message) {
|
|
16
|
+
if (!condition) {
|
|
17
|
+
if (isProduction)
|
|
18
|
+
throw new Error(prefix);
|
|
19
|
+
var provided = typeof message == "function" ? message() : message, value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
20
|
+
throw new Error(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ../../node_modules/empathic/resolve.mjs
|
|
25
|
+
import { createRequire } from "node:module";
|
|
26
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
28
|
+
function absolute(input, root) {
|
|
29
|
+
return isAbsolute(input) ? input : resolve(root || ".", input);
|
|
30
|
+
}
|
|
31
|
+
function from(root, ident, silent) {
|
|
32
|
+
try {
|
|
33
|
+
let r = root instanceof URL || root.startsWith("file://") ? join(fileURLToPath(root), "noop.js") : join(absolute(root), "noop.js");
|
|
34
|
+
return createRequire(r).resolve(ident);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
if (!silent) throw err;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ../../node_modules/empathic/walk.mjs
|
|
41
|
+
import { dirname } from "node:path";
|
|
42
|
+
function up(base, options) {
|
|
43
|
+
let { last, cwd } = options || {}, tmp = absolute(base, cwd), root = absolute(last || "/", cwd), prev, arr = [];
|
|
44
|
+
for (; prev !== root && (arr.push(tmp), tmp = dirname(prev = tmp), tmp !== prev); )
|
|
45
|
+
;
|
|
46
|
+
return arr;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ../../node_modules/empathic/find.mjs
|
|
50
|
+
import { join as join2 } from "node:path";
|
|
51
|
+
import { existsSync, statSync } from "node:fs";
|
|
52
|
+
function up2(name, options) {
|
|
53
|
+
let dir, tmp, start = options && options.cwd || "";
|
|
54
|
+
for (dir of up(start, options))
|
|
55
|
+
if (tmp = join2(dir, name), existsSync(tmp)) return tmp;
|
|
56
|
+
}
|
|
57
|
+
function any(names, options) {
|
|
58
|
+
let dir, start = options && options.cwd || "", j = 0, len = names.length, tmp;
|
|
59
|
+
for (dir of up(start, options))
|
|
60
|
+
for (j = 0; j < len; j++)
|
|
61
|
+
if (tmp = join2(dir, names[j]), existsSync(tmp)) return tmp;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ../../node_modules/detect-indent/index.js
|
|
65
|
+
var INDENT_REGEX = /^(?:( )+|\t+)/, INDENT_TYPE_SPACE = "space";
|
|
66
|
+
function makeIndentsMap(string, ignoreSingleSpaces) {
|
|
67
|
+
let indents = /* @__PURE__ */ new Map(), previousSize = 0, previousIndentType, key;
|
|
68
|
+
for (let line of string.split(/\n/g)) {
|
|
69
|
+
if (!line)
|
|
70
|
+
continue;
|
|
71
|
+
let indent, indentType, use, weight, entry, matches = line.match(INDENT_REGEX);
|
|
72
|
+
if (matches === null)
|
|
73
|
+
previousSize = 0, previousIndentType = "";
|
|
74
|
+
else {
|
|
75
|
+
if (indent = matches[0].length, indentType = matches[1] ? INDENT_TYPE_SPACE : "tab", ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1)
|
|
76
|
+
continue;
|
|
77
|
+
indentType !== previousIndentType && (previousSize = 0), previousIndentType = indentType, use = 1, weight = 0;
|
|
78
|
+
let indentDifference = indent - previousSize;
|
|
79
|
+
if (previousSize = indent, indentDifference === 0)
|
|
80
|
+
use = 0, weight = 1;
|
|
81
|
+
else {
|
|
82
|
+
let absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
|
|
83
|
+
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
84
|
+
}
|
|
85
|
+
entry = indents.get(key), entry = entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight], indents.set(key, entry);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return indents;
|
|
89
|
+
}
|
|
90
|
+
function encodeIndentsKey(indentType, indentAmount) {
|
|
91
|
+
return (indentType === INDENT_TYPE_SPACE ? "s" : "t") + String(indentAmount);
|
|
92
|
+
}
|
|
93
|
+
function decodeIndentsKey(indentsKey) {
|
|
94
|
+
let type = indentsKey[0] === "s" ? INDENT_TYPE_SPACE : "tab", amount = Number(indentsKey.slice(1));
|
|
95
|
+
return { type, amount };
|
|
96
|
+
}
|
|
97
|
+
function getMostUsedKey(indents) {
|
|
98
|
+
let result, maxUsed = 0, maxWeight = 0;
|
|
99
|
+
for (let [key, [usedCount, weight]] of indents)
|
|
100
|
+
(usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) && (maxUsed = usedCount, maxWeight = weight, result = key);
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
function makeIndentString(type, amount) {
|
|
104
|
+
return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount);
|
|
105
|
+
}
|
|
106
|
+
function detectIndent(string) {
|
|
107
|
+
if (typeof string != "string")
|
|
108
|
+
throw new TypeError("Expected a string");
|
|
109
|
+
let indents = makeIndentsMap(string, !0);
|
|
110
|
+
indents.size === 0 && (indents = makeIndentsMap(string, !1));
|
|
111
|
+
let keyOfMostUsedIndent = getMostUsedKey(indents), type, amount = 0, indent = "";
|
|
112
|
+
return keyOfMostUsedIndent !== void 0 && ({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent), indent = makeIndentString(type, amount)), {
|
|
113
|
+
amount,
|
|
114
|
+
type,
|
|
115
|
+
indent
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
invariant,
|
|
121
|
+
from,
|
|
122
|
+
up,
|
|
123
|
+
up2,
|
|
124
|
+
any,
|
|
125
|
+
detectIndent
|
|
126
|
+
};
|