@storybook/vue3 11.0.0-alpha.8 → 11.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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -31,7 +31,7 @@ import {
31
31
  renderPropLikeArg,
32
32
  renderSlotContent,
33
33
  wrapSlotContent
34
- } from "./chunk-KQTNCEDF.js";
34
+ } from "./chunk-OYGQEKHF.js";
35
35
 
36
36
  // src/docgen/story-docs/build-story-docs.ts
37
37
  import { readFile } from "node:fs/promises";
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,17 +1,20 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.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
  indent
14
- } from "./chunk-KQTNCEDF.js";
14
+ } from "./chunk-OYGQEKHF.js";
15
+ import {
16
+ collectComponentMetaSources
17
+ } from "./chunk-NTR7OES7.js";
15
18
 
16
19
  // src/docgen/component-docgen/arg-types/extractArgTypes.ts
17
20
  import { convert, extractComponentProps, hasDocgen } from "storybook/internal/docs-tools";
@@ -325,8 +328,246 @@ function createNamedTypeDetailResolver({
325
328
  };
326
329
  }
327
330
 
331
+ // src/docgen/component-docgen/build-docgen.ts
332
+ import { readFile } from "node:fs/promises";
333
+ import { join } from "node:path";
334
+ import {
335
+ extractComponentDescription,
336
+ extractDescription,
337
+ loadCsf,
338
+ storyShapeError
339
+ } from "storybook/internal/csf-tools";
340
+ import {
341
+ extractDeclaredSubcomponents,
342
+ getComponentIdFromEntry,
343
+ getStoryImportPathFromEntry
344
+ } from "storybook/internal/common";
345
+
346
+ // src/docgen/component-docgen/resolve-component/follow-re-export.ts
347
+ function followReExport(checker, filePath, exportName) {
348
+ let program = checker.getProgram(), sourceFile = program?.getSourceFile(filePath);
349
+ if (!program || !sourceFile)
350
+ return;
351
+ let typeChecker = program.getTypeChecker(), moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
352
+ if (!moduleSymbol)
353
+ return;
354
+ let exported = typeChecker.getExportsOfModule(moduleSymbol).find((symbol) => symbol.name === exportName);
355
+ if (!exported)
356
+ return;
357
+ let target;
358
+ try {
359
+ target = typeChecker.getAliasedSymbol(exported);
360
+ } catch {
361
+ return;
362
+ }
363
+ let declaringPath = target.declarations?.[0]?.getSourceFile().fileName;
364
+ if (!(!declaringPath || declaringPath === filePath))
365
+ return { path: declaringPath, exportName: target.name };
366
+ }
367
+
368
+ // src/docgen/component-docgen/resolve-component/resolve-component.ts
369
+ import { createMetaComponentResolver } from "storybook/internal/common";
370
+ var resolveComponent = createMetaComponentResolver({ extensions: [".vue"] });
371
+ function resolveMetaComponent(csf, storyPath, componentNode) {
372
+ let resolved = resolveComponent(csf, storyPath, componentNode);
373
+ if ("reason" in resolved)
374
+ return resolved;
375
+ let { localName, importId, path, exportName } = resolved.component;
376
+ return !importId || !path ? { reason: "no-component-import" } : { component: { localName, importId, path, exportName } };
377
+ }
378
+
379
+ // src/docgen/component-docgen/build-docgen.ts
380
+ var META_COMPONENT_NAME = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/, NON_COMPONENT_NAMES = /* @__PURE__ */ new Set([
381
+ "null",
382
+ "undefined",
383
+ "true",
384
+ "false",
385
+ "NaN",
386
+ "Infinity",
387
+ "this",
388
+ "import"
389
+ ]), UNRESOLVED_COMPONENT_MESSAGES = {
390
+ "no-meta-component": (subject) => ({
391
+ name: "No component found",
392
+ message: `We could not detect the component from ${subject}. Specify meta.component.`
393
+ }),
394
+ "no-component-import": (subject) => ({
395
+ name: "No component import found",
396
+ message: `No component file found for the component declared in ${subject}. Import it into the story file.`
397
+ }),
398
+ "unreadable-component-expression": (subject) => ({
399
+ name: "No component found",
400
+ message: `We could not follow ${subject} to a component. Storybook follows an imported name, a namespace-import property access, or a chain of property accesses and spreads through modules it can resolve.`
401
+ })
402
+ };
403
+ function unresolvedComponentError(reason, subject) {
404
+ return UNRESOLVED_COMPONENT_MESSAGES[reason](subject);
405
+ }
406
+ function componentNameFromTitle(title) {
407
+ return title.split("/").at(-1).replace(/\s+/g, "");
408
+ }
409
+ function getUsableComponentName(component) {
410
+ let name = component?.trim();
411
+ if (!(!name || NON_COMPONENT_NAMES.has(name.split(".")[0]) || !META_COMPONENT_NAME.test(name)))
412
+ return name;
413
+ }
414
+ async function extractVueComponentDocgen(context, resolvedComponent, { metaJsDoc, errorContext = "" } = {}) {
415
+ let checker = context.getChecker(resolvedComponent.path), declaredExport = followReExport(
416
+ checker,
417
+ resolvedComponent.path,
418
+ resolvedComponent.exportName
419
+ ) ?? {
420
+ path: resolvedComponent.path,
421
+ exportName: resolvedComponent.exportName
422
+ }, componentMeta = (await collectComponentMetaSources(
423
+ checker,
424
+ declaredExport.path,
425
+ context.typescript
426
+ )).find((meta) => meta.exportName === declaredExport.exportName);
427
+ if (!componentMeta)
428
+ return {
429
+ error: {
430
+ name: "No docgen found",
431
+ message: `vue-component-meta extracted no component metadata for the "${declaredExport.exportName}" export of ${declaredExport.path}${errorContext}.`
432
+ }
433
+ };
434
+ let { description, summary, jsDocTags } = extractComponentDescription(
435
+ metaJsDoc,
436
+ componentMeta.description,
437
+ componentMeta.jsDocTags
438
+ ), resolveNamedTypeDetail = createNamedTypeDetailResolver({
439
+ checker,
440
+ typescript: context.typescript,
441
+ componentPath: declaredExport.path
442
+ });
443
+ return {
444
+ path: declaredExport.path,
445
+ componentMeta,
446
+ description,
447
+ summary,
448
+ jsDocTags,
449
+ argTypes: extractArgTypes({ __docgenInfo: componentMeta }, resolveNamedTypeDetail) ?? void 0,
450
+ apiDescription: buildApiDescription(componentMeta)
451
+ };
452
+ }
453
+ async function buildSubcomponentDocgen(csf, storyPath, storyFilePath, declared, context) {
454
+ let failure = (error) => ({
455
+ name: declared.componentName,
456
+ path: storyFilePath,
457
+ jsDocTags: {},
458
+ error
459
+ });
460
+ try {
461
+ let resolved = resolveMetaComponent(csf, storyPath, declared.node);
462
+ if ("reason" in resolved)
463
+ return failure(
464
+ unresolvedComponentError(resolved.reason, `meta.subcomponents.${declared.name}`)
465
+ );
466
+ let extracted = await extractVueComponentDocgen(context, resolved.component, {
467
+ errorContext: ` (subcomponent "${declared.name}")`
468
+ });
469
+ return "error" in extracted ? failure(extracted.error) : {
470
+ name: declared.componentName,
471
+ path: extracted.path,
472
+ description: extracted.description,
473
+ summary: extracted.summary,
474
+ jsDocTags: extracted.jsDocTags,
475
+ argTypes: extracted.argTypes,
476
+ apiDescription: extracted.apiDescription,
477
+ renderer: "vue3"
478
+ };
479
+ } catch (error) {
480
+ return failure({
481
+ name: "Subcomponent extraction failed",
482
+ message: `Extracting docgen for the declared subcomponent "${declared.name}" failed: ${error instanceof Error ? error.message : String(error)}`
483
+ });
484
+ }
485
+ }
486
+ async function buildDocgenPayload(input, context) {
487
+ let storyFilePath = getStoryImportPathFromEntry(input.entry);
488
+ if (!storyFilePath)
489
+ return;
490
+ let storyPath = (context.resolvePath ?? ((importPath) => join(process.cwd(), importPath)))(storyFilePath), storyFile;
491
+ try {
492
+ storyFile = await readFile(storyPath, "utf8");
493
+ } catch (error) {
494
+ if (error.code === "ENOENT")
495
+ return;
496
+ throw error;
497
+ }
498
+ let fallbackName = componentNameFromTitle(input.entry.title), baseFor = (name) => ({
499
+ id: getComponentIdFromEntry(input.entry),
500
+ name,
501
+ path: storyFilePath,
502
+ jsDocTags: {}
503
+ }), csf;
504
+ try {
505
+ csf = loadCsf(storyFile, {
506
+ makeTitle: () => input.entry.title,
507
+ fileName: storyPath
508
+ }).parse();
509
+ } catch (error) {
510
+ return {
511
+ ...baseFor(fallbackName),
512
+ error: {
513
+ name: "Story file could not be parsed",
514
+ message: `${error instanceof Error ? error.message : String(error)}
515
+
516
+ ${input.entry.importPath}:
517
+ ${storyFile}`
518
+ }
519
+ };
520
+ }
521
+ let authoredComponentName = getUsableComponentName(csf._meta?.component), base = baseFor(authoredComponentName ?? fallbackName), resolved = resolveMetaComponent(csf, storyPath);
522
+ if ("reason" in resolved) {
523
+ let error = unresolvedComponentError(
524
+ resolved.reason,
525
+ resolved.reason === "no-meta-component" ? "your story file" : "meta.component"
526
+ );
527
+ return {
528
+ ...base,
529
+ error: {
530
+ name: error.name,
531
+ message: (csf._metaStatement ? storyShapeError(error.message, csf._metaStatement, csf.editor).message : error.message) + `
532
+
533
+ ${input.entry.importPath}:
534
+ ${storyFile}`
535
+ }
536
+ };
537
+ }
538
+ let { component } = resolved, metaJsDoc = extractDescription(csf._metaStatement, csf.editor) || void 0, [primaryDocgen, subcomponentEntries] = await Promise.all([
539
+ extractVueComponentDocgen(context, component, { metaJsDoc }),
540
+ Promise.all(
541
+ extractDeclaredSubcomponents(csf).map(
542
+ async (declaredSubcomponent) => [
543
+ declaredSubcomponent.name,
544
+ await buildSubcomponentDocgen(
545
+ csf,
546
+ storyPath,
547
+ storyFilePath,
548
+ declaredSubcomponent,
549
+ context
550
+ )
551
+ ]
552
+ )
553
+ ).then((entries) => Object.fromEntries(entries))
554
+ ]);
555
+ return "error" in primaryDocgen ? { ...base, error: primaryDocgen.error } : {
556
+ ...baseFor((authoredComponentName ?? primaryDocgen.componentMeta.displayName) || fallbackName),
557
+ description: primaryDocgen.description,
558
+ summary: primaryDocgen.summary,
559
+ jsDocTags: primaryDocgen.jsDocTags,
560
+ vueComponentMeta: primaryDocgen.componentMeta,
561
+ argTypes: primaryDocgen.argTypes,
562
+ apiDescription: primaryDocgen.apiDescription,
563
+ renderer: "vue3",
564
+ ...Object.keys(subcomponentEntries).length > 0 ? { subcomponents: subcomponentEntries } : {}
565
+ };
566
+ }
567
+
328
568
  export {
329
569
  extractArgTypes,
330
570
  buildApiDescription,
331
- createNamedTypeDetailResolver
571
+ createNamedTypeDetailResolver,
572
+ buildDocgenPayload
332
573
  };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -14,7 +14,7 @@ import {
14
14
  applyVueDocgenApiTempFixes,
15
15
  collectComponentMetaSources,
16
16
  createVueComponentMetaChecker
17
- } from "./chunk-K4HJOKKZ.js";
17
+ } from "./chunk-NTR7OES7.js";
18
18
  export {
19
19
  CHECKER_OPTIONS,
20
20
  applyVueDocgenApiTempFixes,
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -0,0 +1,17 @@
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+
13
+ // src/docgen/vue-docgen-api.ts
14
+ import { parse } from "vue-docgen-api";
15
+ export {
16
+ parse
17
+ };
@@ -34,19 +34,19 @@ type VueDocgenInfoEntry<T extends VueDocgenPlugin, TKey extends 'props' | 'event
34
34
  /**
35
35
  * Metadata to configure the stories for a component.
36
36
  *
37
- * @see [Default export](https://storybook.js.org/docs/api/csf#default-export)
37
+ * @see [Meta](https://storybook.js.org/docs/writing-stories/csf#meta)
38
38
  */
39
39
  type Meta<TCmpOrArgs = Args> = ComponentAnnotations<VueRenderer, ComponentPropsOrProps<TCmpOrArgs>>;
40
40
  /**
41
41
  * Story function that represents a CSFv2 component example.
42
42
  *
43
- * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
43
+ * @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
44
44
  */
45
45
  type StoryFn<TCmpOrArgs = Args> = AnnotatedStoryFn<VueRenderer, ComponentPropsOrProps<TCmpOrArgs>>;
46
46
  /**
47
47
  * Story object that represents a CSFv3 component example.
48
48
  *
49
- * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
49
+ * @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
50
50
  */
51
51
  type StoryObj<TMetaOrCmpOrArgs = Args> = TMetaOrCmpOrArgs extends {
52
52
  render?: ArgsStoryFn<VueRenderer, any>;
@@ -1,187 +1,26 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.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
- buildApiDescription,
14
- createNamedTypeDetailResolver,
15
- extractArgTypes
16
- } from "../_node-chunks/chunk-R5GT4RHL.js";
17
- import "../_node-chunks/chunk-KQTNCEDF.js";
13
+ buildDocgenPayload
14
+ } from "../_node-chunks/chunk-XX3DEJSJ.js";
15
+ import "../_node-chunks/chunk-OYGQEKHF.js";
18
16
  import {
19
- CHECKER_OPTIONS,
20
- collectComponentMetaSources
21
- } from "../_node-chunks/chunk-K4HJOKKZ.js";
17
+ CHECKER_OPTIONS
18
+ } from "../_node-chunks/chunk-NTR7OES7.js";
22
19
 
23
20
  // src/docgen/docgen-worker.ts
24
- import { createLazyDocgenMiddleware } from "storybook/internal/common";
21
+ import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
25
22
  import { logger } from "storybook/internal/node-logger";
26
23
 
27
- // src/docgen/component-docgen/build-docgen.ts
28
- import { readFile } from "node:fs/promises";
29
- import { join } from "node:path";
30
- import { getComponentIdFromEntry, getStoryImportPathFromEntry } from "storybook/internal/common";
31
- import {
32
- extractComponentDescription,
33
- extractDescription,
34
- loadCsf,
35
- storyShapeError
36
- } from "storybook/internal/csf-tools";
37
-
38
- // src/docgen/component-docgen/resolve-component/follow-re-export.ts
39
- function followReExport(checker, filePath, exportName) {
40
- let program = checker.getProgram(), sourceFile = program?.getSourceFile(filePath);
41
- if (!program || !sourceFile)
42
- return;
43
- let typeChecker = program.getTypeChecker(), moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
44
- if (!moduleSymbol)
45
- return;
46
- let exported = typeChecker.getExportsOfModule(moduleSymbol).find((symbol) => symbol.name === exportName);
47
- if (!exported)
48
- return;
49
- let target;
50
- try {
51
- target = typeChecker.getAliasedSymbol(exported);
52
- } catch {
53
- return;
54
- }
55
- let declaringPath = target.declarations?.[0]?.getSourceFile().fileName;
56
- if (!(!declaringPath || declaringPath === filePath))
57
- return { path: declaringPath, exportName: target.name };
58
- }
59
-
60
- // src/docgen/component-docgen/resolve-component/resolve-component.ts
61
- import { createMetaComponentResolver } from "storybook/internal/common";
62
- var resolveComponent = createMetaComponentResolver({ extensions: [".vue"] });
63
- function resolveMetaComponent(csf, storyPath) {
64
- let resolved = resolveComponent(csf, storyPath);
65
- if ("reason" in resolved)
66
- return resolved;
67
- let { localName, importId, path, exportName } = resolved.component;
68
- return !importId || !path ? { reason: "no-component-import" } : { component: { localName, importId, path, exportName } };
69
- }
70
-
71
- // src/docgen/component-docgen/build-docgen.ts
72
- var META_COMPONENT_NAME = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$/, NON_COMPONENT_NAMES = /* @__PURE__ */ new Set([
73
- "null",
74
- "undefined",
75
- "true",
76
- "false",
77
- "NaN",
78
- "Infinity",
79
- "this",
80
- "import"
81
- ]), UNRESOLVED_COMPONENT_ERRORS = {
82
- "no-meta-component": {
83
- name: "No component found",
84
- message: "We could not detect the component from your story file. Specify meta.component."
85
- },
86
- "no-component-import": {
87
- name: "No component import found",
88
- message: "No component file found for the component declared in meta.component."
89
- },
90
- "unreadable-component-expression": {
91
- name: "No component found",
92
- message: "We could not follow meta.component to a component. Storybook follows an imported name, a namespace-import property access, or a chain of property accesses and spreads through modules it can resolve."
93
- }
94
- };
95
- function componentNameFromTitle(title) {
96
- return title.split("/").at(-1).replace(/\s+/g, "");
97
- }
98
- function getUsableComponentName(component) {
99
- let name = component?.trim();
100
- if (!(!name || NON_COMPONENT_NAMES.has(name.split(".")[0]) || !META_COMPONENT_NAME.test(name)))
101
- return name;
102
- }
103
- async function buildDocgenPayload(input, context) {
104
- let storyFilePath = getStoryImportPathFromEntry(input.entry);
105
- if (!storyFilePath)
106
- return;
107
- let storyPath = (context.resolvePath ?? ((importPath) => join(process.cwd(), importPath)))(storyFilePath), storyFile;
108
- try {
109
- storyFile = await readFile(storyPath, "utf8");
110
- } catch (error) {
111
- if (error.code === "ENOENT")
112
- return;
113
- throw error;
114
- }
115
- let fallbackName = componentNameFromTitle(input.entry.title), baseFor = (name) => ({
116
- id: getComponentIdFromEntry(input.entry),
117
- name,
118
- path: storyFilePath,
119
- jsDocTags: {}
120
- }), csf;
121
- try {
122
- csf = loadCsf(storyFile, {
123
- makeTitle: () => input.entry.title,
124
- fileName: storyPath
125
- }).parse();
126
- } catch (error) {
127
- return {
128
- ...baseFor(fallbackName),
129
- error: {
130
- name: "Story file could not be parsed",
131
- message: `${error instanceof Error ? error.message : String(error)}
132
-
133
- ${input.entry.importPath}:
134
- ${storyFile}`
135
- }
136
- };
137
- }
138
- let authoredComponentName = getUsableComponentName(csf._meta?.component), base = baseFor(authoredComponentName ?? fallbackName), resolved = resolveMetaComponent(csf, storyPath);
139
- if ("reason" in resolved) {
140
- let error = UNRESOLVED_COMPONENT_ERRORS[resolved.reason];
141
- return {
142
- ...base,
143
- error: {
144
- name: error.name,
145
- message: (csf._metaStatement ? storyShapeError(error.message, csf._metaStatement, csf.editor).message : error.message) + `
146
-
147
- ${input.entry.importPath}:
148
- ${storyFile}`
149
- }
150
- };
151
- }
152
- let { component } = resolved, checker = context.getChecker(component.path), declared = followReExport(checker, component.path, component.exportName) ?? {
153
- path: component.path,
154
- exportName: component.exportName
155
- }, componentMeta = (await collectComponentMetaSources(checker, declared.path, context.typescript)).find((meta) => meta.exportName === declared.exportName);
156
- if (!componentMeta)
157
- return {
158
- ...base,
159
- error: {
160
- name: "No docgen found",
161
- message: `vue-component-meta extracted no component metadata for the "${declared.exportName}" export of ${declared.path}.`
162
- }
163
- };
164
- let metaJsDoc = extractDescription(csf._metaStatement, csf.editor) || void 0, { description, summary, jsDocTags } = extractComponentDescription(
165
- metaJsDoc,
166
- componentMeta.description,
167
- componentMeta.jsDocTags
168
- ), resolveNamedTypeDetail = createNamedTypeDetailResolver({
169
- checker,
170
- typescript: context.typescript,
171
- componentPath: declared.path
172
- });
173
- return {
174
- ...baseFor((authoredComponentName ?? componentMeta.displayName) || fallbackName),
175
- description,
176
- summary,
177
- jsDocTags,
178
- vueComponentMeta: componentMeta,
179
- argTypes: extractArgTypes({ __docgenInfo: componentMeta }, resolveNamedTypeDetail) ?? void 0,
180
- apiDescription: buildApiDescription(componentMeta),
181
- renderer: "vue3"
182
- };
183
- }
184
-
185
24
  // src/docgen/component-docgen/component-meta/vue-project-manager.ts
186
25
  import { readFileSync, statSync } from "node:fs";
187
26
  import { dirname } from "node:path";
@@ -386,7 +225,9 @@ function statMtime(fileName) {
386
225
  var createDocgenProvider = () => createLazyDocgenMiddleware({
387
226
  createManager: async () => {
388
227
  try {
389
- let typescript = await import("typescript"), manager = new VueComponentMetaManager(typescript.default ?? typescript);
228
+ let manager = new VueComponentMetaManager(
229
+ await loadTypeScriptCompilerApi(() => import("typescript"))
230
+ );
390
231
  return manager.startWatching(), manager;
391
232
  } catch (error) {
392
233
  logger.warn(
@@ -1,11 +1,11 @@
1
- import { l as StoryContext$1 } from "../chunk-CeOI_Kon.js";
1
+ import { l as StoryContext$1 } from "../chunk-DIk4dpkW.js";
2
2
  import { i as collectComponentMetaSources, n as MetaSource, r as applyVueDocgenApiTempFixes, t as CHECKER_OPTIONS } from "../chunk-Dka2iJUy.js";
3
- import { StoryDocsPayload, StoryDocsProviderInput, StrictArgTypes } from "storybook/internal/types";
3
+ import { DocgenPayload, DocgenProviderInput, StoryDocsPayload, StoryDocsProviderInput, StrictArgTypes } from "storybook/internal/types";
4
4
  import { ComponentMetaChecker } from "vue-component-meta";
5
5
  import ts from "typescript";
6
6
  import { Component } from "storybook/internal/docs-tools";
7
7
  import { StoryReferenceResolver } from "storybook/internal/csf-tools";
8
- import { DocgenPayload } from "storybook/open-service";
8
+ import { DocgenPayload as DocgenPayload$1 } from "storybook/open-service";
9
9
 
10
10
  //#region code/renderers/vue3/.dts-emit/code/renderers/vue3/src/docgen/component-docgen/arg-types/named-type-detail.d.ts
11
11
  /** Resolves a prop's named type reference to its `table.type.detail` text, or undefined when the type stays flat. */
@@ -46,7 +46,7 @@ interface BuildStoryDocsContext {
46
46
  /** Resolve a CSF import path to an absolute file path. Defaults to `process.cwd()` join. */
47
47
  resolvePath?: (importPath: string) => string;
48
48
  /** Reads docgen for the component id. Defaults to the registered core/docgen service. */
49
- readDocgen?: (id: string) => Promise<DocgenPayload | undefined>;
49
+ readDocgen?: (id: string) => Promise<DocgenPayload$1 | undefined>;
50
50
  /** How args follow a reference out of the story file. Defaults to resolving against disk. */
51
51
  references?: StoryReferenceResolver;
52
52
  }
@@ -55,4 +55,18 @@ interface BuildStoryDocsContext {
55
55
  */
56
56
  declare function buildStoryDocsPayload(input: StoryDocsProviderInput, context?: BuildStoryDocsContext): Promise<StoryDocsPayload | undefined>;
57
57
  //#endregion
58
- export { CHECKER_OPTIONS, applyVueDocgenApiTempFixes, buildApiDescription, buildStoryDocsPayload, collectComponentMetaSources, createNamedTypeDetailResolver, extractArgTypes, generateSourceCode };
58
+ //#region code/renderers/vue3/.dts-emit/code/renderers/vue3/src/docgen/component-docgen/build-docgen.d.ts
59
+ type VueDocgenPayload = DocgenPayload & {
60
+ vueComponentMeta?: MetaSource;
61
+ };
62
+ interface BuildDocgenContext {
63
+ getChecker: (componentFilePath: string) => ComponentMetaChecker;
64
+ resolvePath?: (importPath: string) => string;
65
+ typescript: typeof ts;
66
+ }
67
+ /**
68
+ * Builds a {@link DocgenPayload} for the component one CSF story file documents.
69
+ */
70
+ declare function buildDocgenPayload(input: DocgenProviderInput, context: BuildDocgenContext): Promise<VueDocgenPayload | undefined>;
71
+ //#endregion
72
+ export { type BuildDocgenContext, CHECKER_OPTIONS, applyVueDocgenApiTempFixes, buildApiDescription, buildDocgenPayload, buildStoryDocsPayload, collectComponentMetaSources, createNamedTypeDetailResolver, extractArgTypes, generateSourceCode };
@@ -1,28 +1,29 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.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
  buildStoryDocsPayload
14
- } from "../_node-chunks/chunk-ZYAY4DT5.js";
14
+ } from "../_node-chunks/chunk-LXLV32GL.js";
15
15
  import {
16
16
  buildApiDescription,
17
+ buildDocgenPayload,
17
18
  createNamedTypeDetailResolver,
18
19
  extractArgTypes
19
- } from "../_node-chunks/chunk-R5GT4RHL.js";
20
- import "../_node-chunks/chunk-KQTNCEDF.js";
20
+ } from "../_node-chunks/chunk-XX3DEJSJ.js";
21
+ import "../_node-chunks/chunk-OYGQEKHF.js";
21
22
  import {
22
23
  CHECKER_OPTIONS,
23
24
  applyVueDocgenApiTempFixes,
24
25
  collectComponentMetaSources
25
- } from "../_node-chunks/chunk-K4HJOKKZ.js";
26
+ } from "../_node-chunks/chunk-NTR7OES7.js";
26
27
 
27
28
  // src/docgen/story-docs/source-decorator/sourceDecorator.ts
28
29
  import { SourceType } from "storybook/internal/docs-tools";
@@ -246,6 +247,7 @@ export {
246
247
  CHECKER_OPTIONS,
247
248
  applyVueDocgenApiTempFixes,
248
249
  buildApiDescription,
250
+ buildDocgenPayload,
249
251
  buildStoryDocsPayload,
250
252
  collectComponentMetaSources,
251
253
  createNamedTypeDetailResolver,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as VueTypes, a as Loader, c as Preview, d as StoryObj, f as StrictArgs, g as VueRenderer, h as VueDocgenPlugin, i as Decorator, l as StoryContext, m as VueDocgenInfoEntry, n as Args, o as Meta, p as VueDocgenInfo, r as ComponentPropsAndSlots, s as Parameters, t as ArgTypes, u as StoryFn } from "./chunk-CeOI_Kon.js";
1
+ import { _ as VueTypes, a as Loader, c as Preview, d as StoryObj, f as StrictArgs, g as VueRenderer, h as VueDocgenPlugin, i as Decorator, l as StoryContext, m as VueDocgenInfoEntry, n as Args, o as Meta, p as VueDocgenInfo, r as ComponentPropsAndSlots, s as Parameters, t as ArgTypes, u as StoryFn } from "./chunk-DIk4dpkW.js";
2
2
  import { Args as Args$1, ArgsStoryFn, ComposedStoryFn, DecoratorFunction, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext as StoryContext$1 } from "storybook/internal/types";
3
3
  import { App } from "vue";
4
4
  import { Simplify } from "type-fest";
package/dist/preset.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as createVueComponentMetaChecker, i as collectComponentMetaSources } from "./chunk-Dka2iJUy.js";
2
- import { DocgenProviderDescriptor, IndexEntry, PresetProperty, PresetPropertyFn, StorybookConfigRaw } from "storybook/internal/types";
2
+ import { DocgenProviderDescriptor, IndexEntry, Options, PresetProperty, PresetPropertyFn, StorybookConfigRaw } from "storybook/internal/types";
3
3
  import { parse } from "vue-docgen-api";
4
4
  import { ImportParser } from "storybook/internal/core-server";
5
5
 
@@ -34,7 +34,7 @@ interface VueDocgenEngine {
34
34
  declare const experimental_vueDocgenEngine: () => Promise<VueDocgenEngine>;
35
35
  //#endregion
36
36
  //#region code/renderers/vue3/.dts-emit/code/renderers/vue3/src/preset.d.ts
37
- declare const isDocgenProviderEnabled: () => boolean;
37
+ declare const isDocgenProviderEnabled: (_existing: unknown, options: Options) => Promise<boolean>;
38
38
  declare const features: PresetProperty<'features'>;
39
39
  declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
40
40
  declare const experimental_importParsers: (input?: ImportParser[]) => Promise<ImportParser[]>;
package/dist/preset.js CHANGED
@@ -1,21 +1,22 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_runewszu19k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_runewszu19k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_runewszu19k from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_runewszu19k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_runewszu19k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_runewszu19k.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
  buildStoryDocsPayload
14
- } from "./_node-chunks/chunk-ZYAY4DT5.js";
15
- import "./_node-chunks/chunk-KQTNCEDF.js";
14
+ } from "./_node-chunks/chunk-LXLV32GL.js";
15
+ import "./_node-chunks/chunk-OYGQEKHF.js";
16
16
 
17
17
  // src/preset.ts
18
18
  import { fileURLToPath as fileURLToPath3 } from "node:url";
19
+ import { isTypeScriptReadyForDocgen } from "storybook/internal/common";
19
20
 
20
21
  // src/docgen/preset.ts
21
22
  import { fileURLToPath } from "node:url";
@@ -47,18 +48,12 @@ var experimental_storyDocsProvider = createWorkerGatedStoryDocsProvider({
47
48
 
48
49
  // src/docgen/engine.ts
49
50
  var experimental_vueDocgenEngine = async () => ({
50
- componentMeta: () => import("./_node-chunks/component-meta-ZKYS3FOD.js"),
51
- vueDocgenApi: () => import("./_node-chunks/vue-docgen-api-H7OPORGU.js")
51
+ componentMeta: () => import("./_node-chunks/component-meta-6EEAMRZO.js"),
52
+ vueDocgenApi: () => import("./_node-chunks/vue-docgen-api-S7UZPICT.js")
52
53
  });
53
54
 
54
55
  // src/preset.ts
55
- var isDocgenProviderEnabled = () => {
56
- try {
57
- return import.meta.resolve("typescript"), !0;
58
- } catch {
59
- return !1;
60
- }
61
- }, features = async (existing) => ({
56
+ var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen((specifier) => import.meta.resolve(specifier), options), features = async (existing) => ({
62
57
  ...existing,
63
58
  componentsManifest: !0
64
59
  }), previewAnnotations = async (input = [], options) => {
@@ -67,7 +62,7 @@ var isDocgenProviderEnabled = () => {
67
62
  docsEnabled ? [fileURLToPath3(import.meta.resolve("@storybook/vue3/entry-preview-docs"))] : []
68
63
  );
69
64
  }, experimental_importParsers = async (input = []) => {
70
- let { vueImportParser } = await import("./_node-chunks/parsers-DJDPMLMG.js");
65
+ let { vueImportParser } = await import("./_node-chunks/parsers-LBXFRFRC.js");
71
66
  return [...input, vueImportParser];
72
67
  };
73
68
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/vue3",
3
- "version": "11.0.0-alpha.8",
3
+ "version": "11.0.0-beta.0",
4
4
  "description": "Storybook Vue 3 renderer: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -71,15 +71,10 @@
71
71
  "vue-tsc": "latest"
72
72
  },
73
73
  "peerDependencies": {
74
- "storybook": "^11.0.0-alpha.8",
74
+ "storybook": "^11.0.0-beta.0",
75
75
  "typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
76
76
  "vue": "^3.0.0"
77
77
  },
78
- "peerDependenciesMeta": {
79
- "typescript": {
80
- "optional": true
81
- }
82
- },
83
78
  "publishConfig": {
84
79
  "access": "public"
85
80
  },
@@ -1,17 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_6baiaphk7nk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_6baiaphk7nk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_6baiaphk7nk from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_6baiaphk7nk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_6baiaphk7nk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_6baiaphk7nk.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
-
13
- // src/docgen/vue-docgen-api.ts
14
- import { parse } from "vue-docgen-api";
15
- export {
16
- parse
17
- };