@storybook/react 10.3.0-alpha.8 → 10.3.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/preset.js CHANGED
@@ -1,19 +1,42 @@
1
- import CJS_COMPAT_NODE_URL_uwov6adlzc9 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_uwov6adlzc9 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_uwov6adlzc9 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_2m7iyc5vv9a from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_2m7iyc5vv9a from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_2m7iyc5vv9a from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_uwov6adlzc9.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_uwov6adlzc9.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_uwov6adlzc9.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_2m7iyc5vv9a.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_2m7iyc5vv9a.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_2m7iyc5vv9a.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 {
13
- __commonJS,
14
- __require,
15
- __toESM
16
- } from "./_node-chunks/chunk-63BVDLL2.js";
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
18
+ get: (a, b) => (typeof require < "u" ? require : a)[b]
19
+ }) : x)(function(x) {
20
+ if (typeof require < "u") return require.apply(this, arguments);
21
+ throw Error('Dynamic require of "' + x + '" is not supported');
22
+ });
23
+ var __commonJS = (cb, mod) => function() {
24
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from == "object" || typeof from == "function")
28
+ for (let key of __getOwnPropNames(from))
29
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
38
+ mod
39
+ ));
17
40
 
18
41
  // ../../../node_modules/estraverse/estraverse.js
19
42
  var require_estraverse = __commonJS({
@@ -1615,8 +1638,8 @@ var require_source_node = __commonJS({
1615
1638
  };
1616
1639
  SourceNode.prototype.add = function(aChunk) {
1617
1640
  if (Array.isArray(aChunk))
1618
- aChunk.forEach(function(chunk2) {
1619
- this.add(chunk2);
1641
+ aChunk.forEach(function(chunk) {
1642
+ this.add(chunk);
1620
1643
  }, this);
1621
1644
  else if (aChunk[isSourceNode] || typeof aChunk == "string")
1622
1645
  aChunk && this.children.push(aChunk);
@@ -1639,8 +1662,8 @@ var require_source_node = __commonJS({
1639
1662
  return this;
1640
1663
  };
1641
1664
  SourceNode.prototype.walk = function(aFn) {
1642
- for (var chunk2, i = 0, len = this.children.length; i < len; i++)
1643
- chunk2 = this.children[i], chunk2[isSourceNode] ? chunk2.walk(aFn) : chunk2 !== "" && aFn(chunk2, {
1665
+ for (var chunk, i = 0, len = this.children.length; i < len; i++)
1666
+ chunk = this.children[i], chunk[isSourceNode] ? chunk.walk(aFn) : chunk !== "" && aFn(chunk, {
1644
1667
  source: this.source,
1645
1668
  line: this.line,
1646
1669
  column: this.column,
@@ -1671,8 +1694,8 @@ var require_source_node = __commonJS({
1671
1694
  };
1672
1695
  SourceNode.prototype.toString = function() {
1673
1696
  var str = "";
1674
- return this.walk(function(chunk2) {
1675
- str += chunk2;
1697
+ return this.walk(function(chunk) {
1698
+ str += chunk;
1676
1699
  }), str;
1677
1700
  };
1678
1701
  SourceNode.prototype.toStringWithSourceMap = function(aArgs) {
@@ -1681,8 +1704,8 @@ var require_source_node = __commonJS({
1681
1704
  line: 1,
1682
1705
  column: 0
1683
1706
  }, map = new SourceMapGenerator(aArgs), sourceMappingActive = !1, lastOriginalSource = null, lastOriginalLine = null, lastOriginalColumn = null, lastOriginalName = null;
1684
- return this.walk(function(chunk2, original) {
1685
- generated.code += chunk2, original.source !== null && original.line !== null && original.column !== null ? ((lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) && map.addMapping({
1707
+ return this.walk(function(chunk, original) {
1708
+ generated.code += chunk, original.source !== null && original.line !== null && original.column !== null ? ((lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) && map.addMapping({
1686
1709
  source: original.source,
1687
1710
  original: {
1688
1711
  line: original.line,
@@ -1699,8 +1722,8 @@ var require_source_node = __commonJS({
1699
1722
  column: generated.column
1700
1723
  }
1701
1724
  }), lastOriginalSource = null, sourceMappingActive = !1);
1702
- for (var idx = 0, length = chunk2.length; idx < length; idx++)
1703
- chunk2.charCodeAt(idx) === NEWLINE_CODE ? (generated.line++, generated.column = 0, idx + 1 === length ? (lastOriginalSource = null, sourceMappingActive = !1) : sourceMappingActive && map.addMapping({
1725
+ for (var idx = 0, length = chunk.length; idx < length; idx++)
1726
+ chunk.charCodeAt(idx) === NEWLINE_CODE ? (generated.line++, generated.column = 0, idx + 1 === length ? (lastOriginalSource = null, sourceMappingActive = !1) : sourceMappingActive && map.addMapping({
1704
1727
  source: original.source,
1705
1728
  original: {
1706
1729
  line: original.line,
@@ -3129,8 +3152,8 @@ var require_acorn = __commonJS({
3129
3152
  }, Parser2.parse = function(input, options) {
3130
3153
  return new this(options, input).parse();
3131
3154
  }, Parser2.parseExpressionAt = function(input, pos, options) {
3132
- var parser = new this(options, input, pos);
3133
- return parser.nextToken(), parser.parseExpression();
3155
+ var parser2 = new this(options, input, pos);
3156
+ return parser2.nextToken(), parser2.parseExpression();
3134
3157
  }, Parser2.tokenizer = function(input, options) {
3135
3158
  return new this(options, input);
3136
3159
  }, Object.defineProperties(Parser2.prototype, prototypeAccessors);
@@ -3577,8 +3600,8 @@ var require_acorn = __commonJS({
3577
3600
  elt && this.toAssignable(elt, isBinding);
3578
3601
  }
3579
3602
  if (end) {
3580
- var last2 = exprList[end - 1];
3581
- this.options.ecmaVersion === 6 && isBinding && last2 && last2.type === "RestElement" && last2.argument.type !== "Identifier" && this.unexpected(last2.argument.start);
3603
+ var last = exprList[end - 1];
3604
+ this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier" && this.unexpected(last.argument.start);
3582
3605
  }
3583
3606
  return exprList;
3584
3607
  }, pp$2.parseSpread = function(refDestructuringErrors) {
@@ -4097,8 +4120,8 @@ var require_acorn = __commonJS({
4097
4120
  return scope;
4098
4121
  }
4099
4122
  };
4100
- var Node = function(parser, pos, loc) {
4101
- this.type = "", this.start = pos, this.end = 0, parser.options.locations && (this.loc = new SourceLocation(parser, loc)), parser.options.directSourceFile && (this.sourceFile = parser.options.directSourceFile), parser.options.ranges && (this.range = [pos, 0]);
4123
+ var Node = function(parser2, pos, loc) {
4124
+ this.type = "", this.start = pos, this.end = 0, parser2.options.locations && (this.loc = new SourceLocation(parser2, loc)), parser2.options.directSourceFile && (this.sourceFile = parser2.options.directSourceFile), parser2.options.ranges && (this.range = [pos, 0]);
4102
4125
  }, pp$6 = Parser2.prototype;
4103
4126
  pp$6.startNode = function() {
4104
4127
  return new Node(this, this.start, this.startLoc);
@@ -4193,8 +4216,8 @@ var require_acorn = __commonJS({
4193
4216
  d.nonBinary.Script_Extensions = d.nonBinary.Script, d.nonBinary.gc = d.nonBinary.General_Category, d.nonBinary.sc = d.nonBinary.Script, d.nonBinary.scx = d.nonBinary.Script_Extensions;
4194
4217
  }
4195
4218
  buildUnicodeData(9), buildUnicodeData(10), buildUnicodeData(11);
4196
- var pp$8 = Parser2.prototype, RegExpValidationState = function(parser) {
4197
- this.parser = parser, this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : ""), this.unicodeProperties = data[parser.options.ecmaVersion >= 11 ? 11 : parser.options.ecmaVersion], this.source = "", this.flags = "", this.start = 0, this.switchU = !1, this.switchN = !1, this.pos = 0, this.lastIntValue = 0, this.lastStringValue = "", this.lastAssertionIsQuantifiable = !1, this.numCapturingParens = 0, this.maxBackReference = 0, this.groupNames = [], this.backReferenceNames = [];
4219
+ var pp$8 = Parser2.prototype, RegExpValidationState = function(parser2) {
4220
+ this.parser = parser2, this.validFlags = "gim" + (parser2.options.ecmaVersion >= 6 ? "uy" : "") + (parser2.options.ecmaVersion >= 9 ? "s" : ""), this.unicodeProperties = data[parser2.options.ecmaVersion >= 11 ? 11 : parser2.options.ecmaVersion], this.source = "", this.flags = "", this.start = 0, this.switchU = !1, this.switchN = !1, this.pos = 0, this.lastIntValue = 0, this.lastStringValue = "", this.lastAssertionIsQuantifiable = !1, this.numCapturingParens = 0, this.maxBackReference = 0, this.groupNames = [], this.backReferenceNames = [];
4198
4221
  };
4199
4222
  RegExpValidationState.prototype.reset = function(start, pattern, flags) {
4200
4223
  var unicode = flags.indexOf("u") !== -1;
@@ -6268,7 +6291,7 @@ var require_dist2 = __commonJS({
6268
6291
  return "{}";
6269
6292
  seen.push(input);
6270
6293
  var ret = "{" + tokens.newLine + objKeys_1.map(function(el, i) {
6271
- var eol = objKeys_1.length - 1 === i ? tokens.newLine : "," + tokens.newLineOrSpace, isSymbol3 = typeof el == "symbol", isClassic = !isSymbol3 && /^[a-z$_][a-z$_0-9]*$/i.test(el.toString()), key = isSymbol3 || isClassic ? el : prettyPrint2(el, combinedOptions), value = prettyPrint2(input[el], combinedOptions, pad + combinedOptions.indent);
6294
+ var eol = objKeys_1.length - 1 === i ? tokens.newLine : "," + tokens.newLineOrSpace, isSymbol2 = typeof el == "symbol", isClassic = !isSymbol2 && /^[a-z$_][a-z$_0-9]*$/i.test(el.toString()), key = isSymbol2 || isClassic ? el : prettyPrint2(el, combinedOptions), value = prettyPrint2(input[el], combinedOptions, pad + combinedOptions.indent);
6272
6295
  return combinedOptions.transform && (value = combinedOptions.transform(input, el, value)), tokens.indent + String(key) + ": " + value + eol;
6273
6296
  }).join("") + tokens.pad + "}";
6274
6297
  return seen.pop(), expandWhiteSpace(ret);
@@ -7918,7 +7941,7 @@ var require_register = __commonJS({
7918
7941
  }
7919
7942
  return coreModules;
7920
7943
  }
7921
- function register(params) {
7944
+ function register2(params) {
7922
7945
  var cwd2, explicitParams;
7923
7946
  if (params)
7924
7947
  cwd2 = params.cwd, (params.baseUrl || params.paths) && (explicitParams = params);
@@ -7953,7 +7976,7 @@ var require_register = __commonJS({
7953
7976
  Module._resolveFilename = originalResolveFilename;
7954
7977
  };
7955
7978
  }
7956
- exports.register = register;
7979
+ exports.register = register2;
7957
7980
  }
7958
7981
  });
7959
7982
 
@@ -8982,6 +9005,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8982
9005
  import { getProjectRoot as getProjectRoot2 } from "storybook/internal/common";
8983
9006
 
8984
9007
  // ../../core/src/shared/utils/module.ts
9008
+ import { createRequire, register } from "node:module";
8985
9009
  import { fileURLToPath, pathToFileURL } from "node:url";
8986
9010
 
8987
9011
  // ../../../node_modules/exsolve/dist/index.mjs
@@ -9232,7 +9256,12 @@ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" &&
9232
9256
  try {
9233
9257
  return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
9234
9258
  } catch {
9235
- return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"))));
9259
+ try {
9260
+ return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"))));
9261
+ } catch {
9262
+ let req = createRequire(parent ?? import.meta.url);
9263
+ return dirname(req.resolve(join(pkg, "package.json")));
9264
+ }
9236
9265
  }
9237
9266
  };
9238
9267
 
@@ -9274,18 +9303,18 @@ var import_escodegen = __toESM(require_escodegen(), 1), import_ts_dedent = __toE
9274
9303
  }, PRETTY_OPTIONS = {
9275
9304
  ...BASIC_OPTIONS
9276
9305
  };
9277
- function generateCode(ast, compact2 = !1) {
9278
- return (0, import_escodegen.generate)(ast, compact2 ? COMPACT_OPTIONS : PRETTY_OPTIONS);
9306
+ function generateCode(ast, compact = !1) {
9307
+ return (0, import_escodegen.generate)(ast, compact ? COMPACT_OPTIONS : PRETTY_OPTIONS);
9279
9308
  }
9280
- function generateObjectCode(ast, compact2 = !1) {
9281
- return compact2 ? generateCompactObjectCode(ast) : generateCode(ast);
9309
+ function generateObjectCode(ast, compact = !1) {
9310
+ return compact ? generateCompactObjectCode(ast) : generateCode(ast);
9282
9311
  }
9283
9312
  function generateCompactObjectCode(ast) {
9284
9313
  let result = generateCode(ast, !0);
9285
9314
  return result.endsWith(" }") || (result = `${result.slice(0, -1)} }`), result;
9286
9315
  }
9287
- function generateArrayCode(ast, compact2 = !1) {
9288
- return compact2 ? generateCompactArrayCode(ast) : generateMultilineArrayCode(ast);
9316
+ function generateArrayCode(ast, compact = !1) {
9317
+ return compact ? generateCompactArrayCode(ast) : generateMultilineArrayCode(ast);
9289
9318
  }
9290
9319
  function generateMultilineArrayCode(ast) {
9291
9320
  let result = generateCode(ast);
@@ -10076,14 +10105,14 @@ var MAX_FUNC_LENGTH = 150;
10076
10105
  function createTypeDef({
10077
10106
  name,
10078
10107
  short,
10079
- compact: compact2,
10108
+ compact,
10080
10109
  full,
10081
10110
  inferredType
10082
10111
  }) {
10083
10112
  return {
10084
10113
  name,
10085
10114
  short,
10086
- compact: compact2,
10115
+ compact,
10087
10116
  full: full ?? short,
10088
10117
  inferredType
10089
10118
  };
@@ -10094,11 +10123,11 @@ function cleanPropTypes(value) {
10094
10123
  function splitIntoLines(value) {
10095
10124
  return value.split(/\r?\n/);
10096
10125
  }
10097
- function prettyObject(ast, compact2 = !1) {
10098
- return cleanPropTypes(generateObjectCode(ast, compact2));
10126
+ function prettyObject(ast, compact = !1) {
10127
+ return cleanPropTypes(generateObjectCode(ast, compact));
10099
10128
  }
10100
- function prettyArray(ast, compact2 = !1) {
10101
- return cleanPropTypes(generateCode(ast, compact2));
10129
+ function prettyArray(ast, compact = !1) {
10130
+ return cleanPropTypes(generateCode(ast, compact));
10102
10131
  }
10103
10132
  function getCaptionForInspectionType(type) {
10104
10133
  switch (type) {
@@ -10117,35 +10146,35 @@ function getCaptionForInspectionType(type) {
10117
10146
  }
10118
10147
  }
10119
10148
  function generateTypeFromString(value, originalTypeName) {
10120
- let { inferredType, ast } = inspectValue(value), { type } = inferredType, short, compact2, full;
10149
+ let { inferredType, ast } = inspectValue(value), { type } = inferredType, short, compact, full;
10121
10150
  switch (type) {
10122
10151
  case "Identifier" /* IDENTIFIER */:
10123
10152
  case "Literal" /* LITERAL */:
10124
- short = value, compact2 = value;
10153
+ short = value, compact = value;
10125
10154
  break;
10126
10155
  case "Object" /* OBJECT */: {
10127
10156
  let { depth } = inferredType;
10128
- short = OBJECT_CAPTION, compact2 = depth === 1 ? prettyObject(ast, !0) : null, full = prettyObject(ast);
10157
+ short = OBJECT_CAPTION, compact = depth === 1 ? prettyObject(ast, !0) : null, full = prettyObject(ast);
10129
10158
  break;
10130
10159
  }
10131
10160
  case "Element" /* ELEMENT */: {
10132
10161
  let { identifier } = inferredType;
10133
- short = identifier != null && !isHtmlTag(identifier) ? identifier : ELEMENT_CAPTION, compact2 = splitIntoLines(value).length === 1 ? value : null, full = value;
10162
+ short = identifier != null && !isHtmlTag(identifier) ? identifier : ELEMENT_CAPTION, compact = splitIntoLines(value).length === 1 ? value : null, full = value;
10134
10163
  break;
10135
10164
  }
10136
10165
  case "Array" /* ARRAY */: {
10137
10166
  let { depth } = inferredType;
10138
- short = ARRAY_CAPTION, compact2 = depth <= 2 ? prettyArray(ast, !0) : null, full = prettyArray(ast);
10167
+ short = ARRAY_CAPTION, compact = depth <= 2 ? prettyArray(ast, !0) : null, full = prettyArray(ast);
10139
10168
  break;
10140
10169
  }
10141
10170
  default:
10142
- short = getCaptionForInspectionType(type), compact2 = splitIntoLines(value).length === 1 ? value : null, full = value;
10171
+ short = getCaptionForInspectionType(type), compact = splitIntoLines(value).length === 1 ? value : null, full = value;
10143
10172
  break;
10144
10173
  }
10145
10174
  return createTypeDef({
10146
10175
  name: originalTypeName,
10147
10176
  short,
10148
- compact: compact2,
10177
+ compact,
10149
10178
  full,
10150
10179
  inferredType: type
10151
10180
  });
@@ -10185,11 +10214,11 @@ function objectOf(of) {
10185
10214
  return `objectOf(${of})`;
10186
10215
  }
10187
10216
  function generateObjectOf(type, extractedProp) {
10188
- let { short, compact: compact2, full } = generateType(type.value, extractedProp);
10217
+ let { short, compact, full } = generateType(type.value, extractedProp);
10189
10218
  return createTypeDef({
10190
10219
  name: "objectOf" /* OBJECTOF */,
10191
10220
  short: objectOf(short),
10192
- compact: compact2 != null ? objectOf(compact2) : null,
10221
+ compact: compact != null ? objectOf(compact) : null,
10193
10222
  full: full && objectOf(full)
10194
10223
  });
10195
10224
  }
@@ -10197,8 +10226,8 @@ function generateUnion(type, extractedProp) {
10197
10226
  if (Array.isArray(type.value)) {
10198
10227
  let values = type.value.reduce(
10199
10228
  (acc, v) => {
10200
- let { short, compact: compact2, full } = generateType(v, extractedProp);
10201
- return acc.short.push(short), acc.compact.push(compact2), acc.full.push(full), acc;
10229
+ let { short, compact, full } = generateType(v, extractedProp);
10230
+ return acc.short.push(short), acc.compact.push(compact), acc.full.push(full), acc;
10202
10231
  },
10203
10232
  { short: [], compact: [], full: [] }
10204
10233
  );
@@ -10218,8 +10247,8 @@ function generateEnum(type) {
10218
10247
  if (Array.isArray(type.value)) {
10219
10248
  let values = type.value.reduce(
10220
10249
  (acc, v) => {
10221
- let { short, compact: compact2, full } = generateEnumValue(v);
10222
- return acc.short.push(short), acc.compact.push(compact2), acc.full.push(full), acc;
10250
+ let { short, compact, full } = generateEnumValue(v);
10251
+ return acc.short.push(short), acc.compact.push(compact), acc.full.push(full), acc;
10223
10252
  },
10224
10253
  { short: [], compact: [], full: [] }
10225
10254
  );
@@ -10238,21 +10267,21 @@ function braceAfter(of) {
10238
10267
  function braceAround(of) {
10239
10268
  return `[${of}]`;
10240
10269
  }
10241
- function createArrayOfObjectTypeDef(short, compact2, full) {
10270
+ function createArrayOfObjectTypeDef(short, compact, full) {
10242
10271
  return createTypeDef({
10243
10272
  name: "arrayOf" /* ARRAYOF */,
10244
10273
  short: braceAfter(short),
10245
- compact: compact2 != null ? braceAround(compact2) : null,
10274
+ compact: compact != null ? braceAround(compact) : null,
10246
10275
  full: full && braceAround(full)
10247
10276
  });
10248
10277
  }
10249
10278
  function generateArray2(type, extractedProp) {
10250
- let { name, short, compact: compact2, full, inferredType } = generateType(type.value, extractedProp);
10279
+ let { name, short, compact, full, inferredType } = generateType(type.value, extractedProp);
10251
10280
  if (name === "custom" /* CUSTOM */) {
10252
10281
  if (inferredType === "Object" /* OBJECT */)
10253
- return createArrayOfObjectTypeDef(short, compact2, full);
10282
+ return createArrayOfObjectTypeDef(short, compact, full);
10254
10283
  } else if (name === "shape" /* SHAPE */)
10255
- return createArrayOfObjectTypeDef(short, compact2, full);
10284
+ return createArrayOfObjectTypeDef(short, compact, full);
10256
10285
  return createTypeDef({
10257
10286
  name: "arrayOf" /* ARRAYOF */,
10258
10287
  short: braceAfter(short),
@@ -10303,8 +10332,8 @@ function createType(extractedProp) {
10303
10332
  case "union" /* UNION */:
10304
10333
  case "enum" /* ENUM */:
10305
10334
  case "arrayOf" /* ARRAYOF */: {
10306
- let { short, compact: compact2, full } = generateType(type, extractedProp);
10307
- return compact2 != null && !isTooLongForTypeSummary(compact2) ? createSummaryValue5(compact2) : full ? createSummaryValue5(short, full) : createSummaryValue5(short);
10335
+ let { short, compact, full } = generateType(type, extractedProp);
10336
+ return compact != null && !isTooLongForTypeSummary(compact) ? createSummaryValue5(compact) : full ? createSummaryValue5(short, full) : createSummaryValue5(short);
10308
10337
  }
10309
10338
  case "func" /* FUNC */: {
10310
10339
  let { short, full } = generateType(type, extractedProp), summary = short, detail;
@@ -10432,42 +10461,12 @@ var extractArgTypes = (component) => {
10432
10461
  };
10433
10462
 
10434
10463
  // src/componentManifest/reactDocgen.ts
10464
+ var import_ts_dedent2 = __toESM(require_dist(), 1), TsconfigPaths = __toESM(require_lib2(), 1);
10435
10465
  import { existsSync as existsSync2 } from "node:fs";
10436
10466
  import { dirname as dirname3, sep as sep2 } from "node:path";
10437
10467
  import { babelParse, types as t } from "storybook/internal/babel";
10438
- import { getProjectRoot, supportedExtensions as supportedExtensions2 } from "storybook/internal/common";
10468
+ import { supportedExtensions as supportedExtensions2 } from "storybook/internal/common";
10439
10469
  import { logger as logger2 } from "storybook/internal/node-logger";
10440
-
10441
- // ../../../node_modules/empathic/find.mjs
10442
- import { join as join3 } from "node:path";
10443
- import { existsSync, statSync } from "node:fs";
10444
-
10445
- // ../../../node_modules/empathic/walk.mjs
10446
- import { dirname as dirname2 } from "node:path";
10447
-
10448
- // ../../../node_modules/empathic/resolve.mjs
10449
- import { isAbsolute as isAbsolute2, join as join2, resolve as resolve2 } from "node:path";
10450
- function absolute(input, root) {
10451
- return isAbsolute2(input) ? input : resolve2(root || ".", input);
10452
- }
10453
-
10454
- // ../../../node_modules/empathic/walk.mjs
10455
- function up(base2, options) {
10456
- let { last: last2, cwd: cwd2 } = options || {}, tmp = absolute(base2, cwd2), root = absolute(last2 || "/", cwd2), prev, arr = [];
10457
- for (; prev !== root && (arr.push(tmp), tmp = dirname2(prev = tmp), tmp !== prev); )
10458
- ;
10459
- return arr;
10460
- }
10461
-
10462
- // ../../../node_modules/empathic/find.mjs
10463
- function up2(name, options) {
10464
- let dir, tmp, start = options && options.cwd || "";
10465
- for (dir of up(start, options))
10466
- if (tmp = join3(dir, name), existsSync(tmp)) return tmp;
10467
- }
10468
-
10469
- // src/componentManifest/reactDocgen.ts
10470
- var import_ts_dedent2 = __toESM(require_dist(), 1), TsconfigPaths = __toESM(require_lib2(), 1);
10471
10470
  import {
10472
10471
  builtinHandlers as docgenHandlers,
10473
10472
  builtinResolvers as docgenResolver,
@@ -10698,11 +10697,11 @@ function getParser4({ startLine = 0, fence = "```", spacing = "compact", markers
10698
10697
  }
10699
10698
 
10700
10699
  // ../../../node_modules/comment-parser/es6/stringifier/index.js
10701
- function join4(tokens) {
10700
+ function join2(tokens) {
10702
10701
  return tokens.start + tokens.delimiter + tokens.postDelimiter + tokens.tag + tokens.postTag + tokens.type + tokens.postType + tokens.name + tokens.postName + tokens.description + tokens.end + tokens.lineEnd;
10703
10702
  }
10704
10703
  function getStringifier() {
10705
- return (block) => block.source.map(({ tokens }) => join4(tokens)).join(`
10704
+ return (block) => block.source.map(({ tokens }) => join2(tokens)).join(`
10706
10705
  `);
10707
10706
  }
10708
10707
 
@@ -10732,8 +10731,38 @@ var stringify = getStringifier();
10732
10731
 
10733
10732
  // src/componentManifest/utils.ts
10734
10733
  import { readFileSync } from "node:fs";
10735
- import { resolveImport } from "storybook/internal/common";
10734
+ import { getProjectRoot, resolveImport } from "storybook/internal/common";
10736
10735
  import { logger } from "storybook/internal/node-logger";
10736
+
10737
+ // ../../../node_modules/empathic/find.mjs
10738
+ import { join as join4 } from "node:path";
10739
+ import { existsSync, statSync } from "node:fs";
10740
+
10741
+ // ../../../node_modules/empathic/walk.mjs
10742
+ import { dirname as dirname2 } from "node:path";
10743
+
10744
+ // ../../../node_modules/empathic/resolve.mjs
10745
+ import { isAbsolute as isAbsolute2, join as join3, resolve as resolve2 } from "node:path";
10746
+ function absolute(input, root) {
10747
+ return isAbsolute2(input) ? input : resolve2(root || ".", input);
10748
+ }
10749
+
10750
+ // ../../../node_modules/empathic/walk.mjs
10751
+ function up(base2, options) {
10752
+ let { last, cwd: cwd2 } = options || {}, tmp = absolute(base2, cwd2), root = absolute(last || "/", cwd2), prev, arr = [];
10753
+ for (; prev !== root && (arr.push(tmp), tmp = dirname2(prev = tmp), tmp !== prev); )
10754
+ ;
10755
+ return arr;
10756
+ }
10757
+
10758
+ // ../../../node_modules/empathic/find.mjs
10759
+ function up2(name, options) {
10760
+ let dir, tmp, start = options && options.cwd || "";
10761
+ for (dir of up(start, options))
10762
+ if (tmp = join4(dir, name), existsSync(tmp)) return tmp;
10763
+ }
10764
+
10765
+ // src/componentManifest/utils.ts
10737
10766
  var groupBy = (items, keySelector) => items.reduce((acc = {}, item, index) => {
10738
10767
  let key = keySelector(item, index);
10739
10768
  return Array.isArray(acc[key]) || (acc[key] = []), acc[key].push(item), acc;
@@ -10759,7 +10788,10 @@ var memoStore = /* @__PURE__ */ new WeakMap(), cached = (fn, opts = {}) => {
10759
10788
  };
10760
10789
  }, invalidateCache = () => {
10761
10790
  memoStore = /* @__PURE__ */ new WeakMap();
10762
- }, cachedReadFileSync = cached(readFileSync, { name: "cachedReadFile" }), cachedFindUp = cached(up2, { name: "findUp" }), cachedResolveImport = cached(resolveImport, { name: "resolveImport" });
10791
+ }, cachedReadFileSync = cached(readFileSync, { name: "cachedReadFile" }), cachedFindUp = cached(up2, { name: "findUp" }), cachedResolveImport = cached(resolveImport, { name: "resolveImport" }), findTsconfigPath = cached(
10792
+ (cwd2) => up2("tsconfig.json", { cwd: cwd2, last: getProjectRoot() }),
10793
+ { name: "findTsconfigPath" }
10794
+ );
10763
10795
 
10764
10796
  // src/componentManifest/jsdocTags.ts
10765
10797
  function extractJSDocInfo(jsdocComment) {
@@ -10945,7 +10977,7 @@ function matchPath(id, basedir) {
10945
10977
  }
10946
10978
  var getTsConfig = cached(
10947
10979
  (cwd2) => {
10948
- let tsconfigPath = up2("tsconfig.json", { cwd: cwd2, last: getProjectRoot() });
10980
+ let tsconfigPath = findTsconfigPath(cwd2);
10949
10981
  return TsconfigPaths.loadConfig(tsconfigPath);
10950
10982
  },
10951
10983
  { name: "getTsConfig" }
@@ -11176,11 +11208,11 @@ var REACT_NODE_TYPES = /* @__PURE__ */ new Set([
11176
11208
  ]);
11177
11209
  var getTsConfig2 = async () => {
11178
11210
  try {
11179
- let ts = await import("typescript"), tsconfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
11211
+ let ts2 = await import("typescript"), tsconfigPath = ts2.findConfigFile(process.cwd(), ts2.sys.fileExists);
11180
11212
  if (console.log({ tsconfigPath }), tsconfigPath === void 0)
11181
11213
  return {};
11182
- let basePath = dirname4(tsconfigPath), { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
11183
- return error ? {} : ts.parseJsonConfigFileContent(config, ts.sys, basePath, {}, tsconfigPath).options;
11214
+ let basePath = dirname4(tsconfigPath), { config, error } = ts2.readConfigFile(tsconfigPath, ts2.sys.readFile);
11215
+ return error ? {} : ts2.parseJsonConfigFileContent(config, ts2.sys, basePath, {}, tsconfigPath).options;
11184
11216
  } catch {
11185
11217
  return {};
11186
11218
  }
@@ -11193,7 +11225,7 @@ var extractArgTypesFromDocgenTypescript = async ({
11193
11225
  reactDocgenTypescriptOptions
11194
11226
  }) => {
11195
11227
  try {
11196
- let { withCompilerOptions } = (await import("./_node-chunks/lib-BNFWLTPX.js")).default, defaultOptions = {
11228
+ let { withCompilerOptions: withCompilerOptions2 } = (await import("react-docgen-typescript")).default, defaultOptions = {
11197
11229
  shouldExtractLiteralValuesFromEnum: !0,
11198
11230
  shouldRemoveUndefinedFromOptional: !0,
11199
11231
  propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
@@ -11204,7 +11236,7 @@ var extractArgTypesFromDocgenTypescript = async ({
11204
11236
  ...reactDocgenTypescriptOptions,
11205
11237
  // Always ensure savePropValueAsString is true for consistency
11206
11238
  savePropValueAsString: !0
11207
- }, docgens = withCompilerOptions(
11239
+ }, docgens = withCompilerOptions2(
11208
11240
  { ...tsConfig, noErrorTruncation: !0, strict: !0 },
11209
11241
  mergedOptions
11210
11242
  ).parse(componentFilePath);
@@ -11233,17 +11265,6 @@ import { recast as recast2 } from "storybook/internal/babel";
11233
11265
  import { Tag } from "storybook/internal/core-server";
11234
11266
  import { storyNameFromExport } from "storybook/internal/csf";
11235
11267
  import { extractDescription, loadCsf } from "storybook/internal/csf-tools";
11236
- import { logger as logger6 } from "storybook/internal/node-logger";
11237
-
11238
- // ../../../node_modules/es-toolkit/dist/array/uniqBy.mjs
11239
- function uniqBy(arr, mapper) {
11240
- let map = /* @__PURE__ */ new Map();
11241
- for (let i = 0; i < arr.length; i++) {
11242
- let item = arr[i], key = mapper(item);
11243
- map.has(key) || map.set(key, item);
11244
- }
11245
- return Array.from(map.values());
11246
- }
11247
11268
 
11248
11269
  // src/componentManifest/generateCodeSnippet.ts
11249
11270
  import { types as t2 } from "storybook/internal/babel";
@@ -11272,7 +11293,7 @@ function getCodeSnippet(csf, storyName, componentName) {
11272
11293
  if (callee.isMemberExpression()) {
11273
11294
  let obj = callee.get("object"), prop = callee.get("property"), isBind = prop.isIdentifier() && prop.node.name === "bind" || t2.isStringLiteral(prop.node) && prop.node.value === "bind";
11274
11295
  if (obj.isIdentifier() && isBind) {
11275
- let resolved = resolveBindIdentifierInit(storyDeclaration, obj);
11296
+ let resolved = resolveIdentifierInit(storyDeclaration, obj);
11276
11297
  resolved && (normalizedPath = resolved);
11277
11298
  }
11278
11299
  }
@@ -11300,14 +11321,20 @@ function getCodeSnippet(csf, storyName, componentName) {
11300
11321
  "Expected story to be csf factory, function or an object expression"
11301
11322
  );
11302
11323
  let storyProps = normalizedPath.isObjectExpression() ? normalizedPath.get("properties").filter((p) => p.isObjectProperty()) : [], metaPath = pathForNode(csf._file.path, metaObj), metaProps = metaPath?.isObjectExpression() ? metaPath.get("properties").filter((p) => p.isObjectProperty()) : [], getRenderPath = (object) => {
11303
- let renderPath2 = object.find((p) => keyOf(p.node) === "render")?.get("value");
11304
- if (renderPath2?.isIdentifier() && (componentName = renderPath2.node.name), renderPath2 && !(renderPath2.isArrowFunctionExpression() || renderPath2.isFunctionExpression()))
11305
- throw renderPath2.buildCodeFrameError(
11324
+ let renderPath = object.find((p) => keyOf(p.node) === "render")?.get("value");
11325
+ if (!renderPath)
11326
+ return { kind: "missing" };
11327
+ if (renderPath.isIdentifier()) {
11328
+ let resolved = resolveIdentifierInit(storyDeclaration, renderPath);
11329
+ return resolved && (resolved.isArrowFunctionExpression() || resolved.isFunctionExpression() || resolved.isFunctionDeclaration()) ? { kind: "resolved", path: resolved } : { kind: "unresolved" };
11330
+ }
11331
+ if (!(renderPath.isArrowFunctionExpression() || renderPath.isFunctionExpression()))
11332
+ throw renderPath.buildCodeFrameError(
11306
11333
  "Expected render to be an arrow function or function expression"
11307
11334
  );
11308
- return renderPath2;
11309
- }, metaRenderPath = getRenderPath(metaProps), renderPath = getRenderPath(storyProps);
11310
- storyFn ??= renderPath ?? metaRenderPath;
11335
+ return { kind: "resolved", path: renderPath };
11336
+ }, metaRender = getRenderPath(metaProps), storyRender = getRenderPath(storyProps);
11337
+ storyFn || (storyFn = storyRender.kind === "resolved" ? storyRender.path : storyRender.kind === "missing" && metaRender.kind === "resolved" ? metaRender.path : void 0);
11311
11338
  let metaArgs = metaArgsRecord(metaObj ?? null), storyArgsPath = storyProps.filter((p) => keyOf(p.node) === "args").map((p) => p.get("value")).find((v) => v.isObjectExpression()), storyArgs = argsRecordFromObjectPath(storyArgsPath), storyAssignedArgsPath = storyArgsAssignmentPath(csf._file.path, storyName), storyAssignedArgs = argsRecordFromObjectPath(storyAssignedArgsPath), merged = { ...metaArgs, ...storyArgs, ...storyAssignedArgs }, entries = Object.entries(merged).filter(([k]) => k !== "children"), validEntries = entries.filter(([k, v]) => isValidJsxAttrName(k) && v != null), invalidEntries = entries.filter(([k, v]) => !isValidJsxAttrName(k) && v != null), injectedAttrs = validEntries.map(([k, v]) => toAttr(k, v)).filter((a) => a != null);
11312
11339
  if (storyFn) {
11313
11340
  let fn = storyFn.node;
@@ -11331,14 +11358,20 @@ function getCodeSnippet(csf, storyName, componentName) {
11331
11358
  return stmt;
11332
11359
  });
11333
11360
  if (changed)
11334
- return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(fn.id, [], t2.blockStatement(newBody), fn.generator, fn.async) : t2.variableDeclaration("const", [
11361
+ return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(
11362
+ t2.identifier(storyName),
11363
+ [],
11364
+ t2.blockStatement(newBody),
11365
+ fn.generator,
11366
+ fn.async
11367
+ ) : t2.variableDeclaration("const", [
11335
11368
  t2.variableDeclarator(
11336
11369
  t2.identifier(storyName),
11337
11370
  t2.arrowFunctionExpression([], t2.blockStatement(newBody), fn.async)
11338
11371
  )
11339
11372
  ]);
11340
11373
  }
11341
- return t2.isFunctionDeclaration(fn) ? fn : t2.variableDeclaration("const", [t2.variableDeclarator(t2.identifier(storyName), fn)]);
11374
+ return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(t2.identifier(storyName), fn.params, fn.body, fn.generator, fn.async) : t2.variableDeclaration("const", [t2.variableDeclarator(t2.identifier(storyName), fn)]);
11342
11375
  }
11343
11376
  invariant(componentName, "Could not generate snippet without component name.");
11344
11377
  let invalidSpread = buildInvalidSpread(invalidEntries), name = t2.jsxIdentifier(componentName), openingElAttrs = invalidSpread ? [...injectedAttrs, invalidSpread] : injectedAttrs, children = toJsxChildren(merged.children), selfClosing = children.length === 0, arrow = t2.arrowFunctionExpression(
@@ -11482,10 +11515,19 @@ function transformArgsSpreadsInJsx(node, merged) {
11482
11515
  });
11483
11516
  return { node: t2.jsxFragment(node.openingFragment, node.closingFragment, fragChildren), changed };
11484
11517
  }
11485
- function resolveBindIdentifierInit(storyPath, identifier) {
11518
+ function resolveIdentifierInit(storyPath, identifier) {
11486
11519
  let programPath = storyPath.findParent((p) => p.isProgram());
11487
11520
  if (!programPath)
11488
11521
  return null;
11522
+ for (let stmt of programPath.get("body")) {
11523
+ if (stmt.isFunctionDeclaration() && stmt.node.id?.name === identifier.node.name)
11524
+ return stmt;
11525
+ if (stmt.isExportNamedDeclaration()) {
11526
+ let decl = stmt.get("declaration");
11527
+ if (decl.isFunctionDeclaration() && decl.node.id?.name === identifier.node.name)
11528
+ return decl;
11529
+ }
11530
+ }
11489
11531
  let match = programPath.get("body").flatMap((stmt) => {
11490
11532
  if (stmt.isVariableDeclaration())
11491
11533
  return stmt.get("declarations");
@@ -11516,16 +11558,135 @@ function pathForNode(program, target) {
11516
11558
  }
11517
11559
 
11518
11560
  // src/componentManifest/getComponentImports.ts
11519
- import { dirname as dirname5 } from "node:path";
11561
+ import { dirname as dirname6 } from "node:path";
11520
11562
  import { babelParse as babelParse2, recast, types as t3 } from "storybook/internal/babel";
11521
11563
  import { logger as logger5 } from "storybook/internal/node-logger";
11564
+
11565
+ // src/componentManifest/reactDocgenTypescript.ts
11566
+ import { dirname as dirname5 } from "node:path";
11567
+ import {
11568
+ withCompilerOptions
11569
+ } from "react-docgen-typescript";
11570
+ import ts from "typescript";
11571
+ var LARGE_NON_USER_SOURCE_THRESHOLD = 30, getPropSource = (prop) => prop.parent?.fileName ?? prop.declarations?.[0]?.fileName, getLargeNonUserPropSources = (props) => {
11572
+ let countBySource = /* @__PURE__ */ new Map();
11573
+ for (let prop of Object.values(props)) {
11574
+ let source = getPropSource(prop);
11575
+ (source?.includes("node_modules") || source?.endsWith(".d.ts")) && countBySource.set(source, (countBySource.get(source) ?? 0) + 1);
11576
+ }
11577
+ let largeNonUserSources = /* @__PURE__ */ new Set();
11578
+ for (let [source, count] of countBySource)
11579
+ count > LARGE_NON_USER_SOURCE_THRESHOLD && largeNonUserSources.add(source);
11580
+ return largeNonUserSources;
11581
+ };
11582
+ function findDisplayNameAssignment(sourceFile, identifierName) {
11583
+ for (let statement of sourceFile.statements) {
11584
+ if (!ts.isExpressionStatement(statement))
11585
+ continue;
11586
+ let expr = statement.expression;
11587
+ if (ts.isBinaryExpression(expr) && expr.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isPropertyAccessExpression(expr.left) && expr.left.name.text === "displayName" && ts.isIdentifier(expr.left.expression) && expr.left.expression.text === identifierName && ts.isStringLiteral(expr.right))
11588
+ return expr.right.text;
11589
+ }
11590
+ }
11591
+ function getExportNameMap(checker, sourceFile) {
11592
+ let moduleSymbol = checker.getSymbolAtLocation(sourceFile);
11593
+ if (!moduleSymbol)
11594
+ return /* @__PURE__ */ new Map();
11595
+ let result = /* @__PURE__ */ new Map(), fileName = sourceFile.fileName.replace(/.*\//, "").replace(/\.[^.]+$/, "");
11596
+ for (let exportSymbol of checker.getExportsOfModule(moduleSymbol)) {
11597
+ let resolved = exportSymbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(exportSymbol) : exportSymbol, declaration = resolved.valueDeclaration ?? resolved.getDeclarations()?.[0];
11598
+ if (!declaration)
11599
+ continue;
11600
+ let type = checker.getTypeOfSymbolAtLocation(resolved, declaration), isStateless = type.getCallSignatures().some((sig) => {
11601
+ let params = sig.getParameters();
11602
+ return params.length === 1 || params.length > 0 && params[0].getName() === "props";
11603
+ }), isStateful = type.getConstructSignatures().some(
11604
+ (sig) => sig.getReturnType().getProperty("props") !== void 0
11605
+ );
11606
+ if (isStateless || isStateful) {
11607
+ let exportName = exportSymbol.getName(), resolvedName = resolved.getName();
11608
+ result.set(resolvedName, exportName), exportName === "default" && result.set(fileName, "default");
11609
+ let displayNameValue = findDisplayNameAssignment(sourceFile, resolvedName);
11610
+ displayNameValue && result.set(displayNameValue, exportName);
11611
+ }
11612
+ }
11613
+ return result;
11614
+ }
11615
+ var cachedCompilerOptions, cachedFileNames, previousProgram, parser, cachedParserOptionsKey;
11616
+ function invalidateParser() {
11617
+ parser = void 0, cachedCompilerOptions = void 0, cachedFileNames = void 0;
11618
+ }
11619
+ function getParser5(userOptions) {
11620
+ let optionsKey = JSON.stringify(userOptions ?? {});
11621
+ if (parser && cachedParserOptionsKey !== optionsKey && (parser = void 0), !parser) {
11622
+ let configPath = findTsconfigPath(process.cwd());
11623
+ if (cachedCompilerOptions = { noErrorTruncation: !0, strict: !0 }, configPath) {
11624
+ let { config } = ts.readConfigFile(configPath, ts.sys.readFile), parsed = ts.parseJsonConfigFileContent(config, ts.sys, dirname5(configPath));
11625
+ cachedCompilerOptions = { ...parsed.options, noErrorTruncation: !0 }, cachedFileNames = parsed.fileNames;
11626
+ }
11627
+ let program = ts.createProgram(
11628
+ cachedFileNames ?? [],
11629
+ cachedCompilerOptions,
11630
+ void 0,
11631
+ previousProgram
11632
+ );
11633
+ previousProgram = program;
11634
+ let parserOptions = {
11635
+ shouldExtractLiteralValuesFromEnum: !0,
11636
+ shouldRemoveUndefinedFromOptional: !0,
11637
+ ...userOptions,
11638
+ // Always force savePropValueAsString so default values are in a consistent format
11639
+ savePropValueAsString: !0
11640
+ };
11641
+ parser = {
11642
+ program,
11643
+ fileParser: withCompilerOptions(cachedCompilerOptions, parserOptions)
11644
+ }, cachedParserOptionsKey = optionsKey;
11645
+ }
11646
+ return parser;
11647
+ }
11648
+ function matchComponentDoc(docs, {
11649
+ importName,
11650
+ localImportName,
11651
+ componentName
11652
+ }) {
11653
+ if (docs.length !== 0)
11654
+ return docs.length === 1 ? docs[0] : docs.find(
11655
+ (doc) => doc.exportName === importName || doc.exportName === localImportName || doc.displayName === importName || doc.displayName === localImportName || doc.displayName === componentName
11656
+ );
11657
+ }
11658
+ var parseWithReactDocgenTypescript = cached(
11659
+ (filePath, userOptions) => {
11660
+ let { program, fileParser } = getParser5(userOptions), checker = program.getTypeChecker(), sourceFile = program.getSourceFile(filePath), docs = fileParser.parseWithProgramProvider(filePath, () => program), exportNameMap = sourceFile ? getExportNameMap(checker, sourceFile) : /* @__PURE__ */ new Map();
11661
+ return docs.map((doc) => {
11662
+ let largeNonUserSources = getLargeNonUserPropSources(doc.props);
11663
+ return {
11664
+ ...doc,
11665
+ // Use name-based lookup: displayName is the resolved symbol name, so look it up in the
11666
+ // export map to get the public export name. Falls back to displayName when not aliased.
11667
+ exportName: exportNameMap.get(doc.displayName) ?? doc.displayName,
11668
+ // Filter out bulk props from non-user sources (React built-ins, DOM, CSS-in-JS system props)
11669
+ props: Object.fromEntries(
11670
+ Object.entries(doc.props).filter(([, prop]) => {
11671
+ let source = getPropSource(prop);
11672
+ return !source || !largeNonUserSources.has(source);
11673
+ })
11674
+ )
11675
+ };
11676
+ });
11677
+ },
11678
+ { name: "parseWithReactDocgenTypescript" }
11679
+ );
11680
+
11681
+ // src/componentManifest/getComponentImports.ts
11522
11682
  var baseIdentifier = (component) => component.split(".")[0] ?? component, isTypeSpecifier = (s) => t3.isImportSpecifier(s) && s.importKind === "type", importedName = (im) => t3.isIdentifier(im) ? im.name : im.value, addUniqueBy = (arr, item, eq2) => {
11523
11683
  arr.find(eq2) || arr.push(item);
11524
11684
  }, getComponents = ({
11525
11685
  csf,
11526
- storyFilePath
11686
+ storyFilePath,
11687
+ typescriptOptions
11527
11688
  }) => {
11528
- let program = csf._file.path, componentSet = /* @__PURE__ */ new Set(), localToImport = /* @__PURE__ */ new Map();
11689
+ let { reactDocgen = "react-docgen", reactDocgenTypescriptOptions } = typescriptOptions, reactDocgenConfig = reactDocgen || "react-docgen", program = csf._file.path, componentSet = /* @__PURE__ */ new Set(), localToImport = /* @__PURE__ */ new Map();
11529
11690
  program.traverse({
11530
11691
  JSXOpeningElement(p) {
11531
11692
  let n = p.node.name;
@@ -11596,25 +11757,51 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
11596
11757
  }).map((component) => {
11597
11758
  let path3, isPackage = !1;
11598
11759
  try {
11599
- component.importId && storyFilePath && (path3 = cachedResolveImport(matchPath(component.importId, dirname5(storyFilePath)), {
11600
- basedir: dirname5(storyFilePath)
11760
+ component.importId && storyFilePath && (path3 = cachedResolveImport(matchPath(component.importId, dirname6(storyFilePath)), {
11761
+ basedir: dirname6(storyFilePath)
11601
11762
  }));
11602
11763
  } catch (e) {
11603
11764
  logger5.debug(e);
11604
11765
  }
11605
11766
  try {
11606
- component.importId && !component.importId.startsWith(".") && storyFilePath && (cachedResolveImport(component.importId, { basedir: dirname5(storyFilePath) }), isPackage = !0);
11767
+ component.importId && !component.importId.startsWith(".") && storyFilePath && (cachedResolveImport(component.importId, { basedir: dirname6(storyFilePath) }), isPackage = !0);
11607
11768
  } catch {
11608
11769
  }
11609
11770
  let componentWithPackage = { ...component, isPackage };
11610
11771
  if (path3) {
11611
- let reactDocgen = getReactDocgen(path3, componentWithPackage);
11612
- return {
11613
- ...componentWithPackage,
11614
- path: path3,
11615
- reactDocgen,
11616
- importOverride: reactDocgen.type === "success" ? getImportTag(reactDocgen.data) : void 0
11617
- };
11772
+ if (reactDocgenConfig === "react-docgen-typescript") {
11773
+ let reactDocgenTypescript, reactDocgenTypescriptError;
11774
+ try {
11775
+ reactDocgenTypescript = matchComponentDoc(
11776
+ parseWithReactDocgenTypescript(path3, reactDocgenTypescriptOptions),
11777
+ component
11778
+ );
11779
+ } catch (e) {
11780
+ let message = e instanceof Error ? e.message : String(e);
11781
+ logger5.debug(`react-docgen-typescript failed for ${path3}: ${message}`), reactDocgenTypescriptError = {
11782
+ name: "react-docgen-typescript parse error",
11783
+ message: `File: ${path3}
11784
+ ${message}`
11785
+ };
11786
+ }
11787
+ let importOverride = reactDocgenTypescript ? getImportTag(reactDocgenTypescript) : void 0;
11788
+ return {
11789
+ ...componentWithPackage,
11790
+ path: path3,
11791
+ ...reactDocgenTypescript ? { reactDocgenTypescript } : {},
11792
+ ...reactDocgenTypescriptError ? { reactDocgenTypescriptError } : {},
11793
+ importOverride
11794
+ };
11795
+ }
11796
+ if (reactDocgenConfig === "react-docgen") {
11797
+ let reactDocgen2 = getReactDocgen(path3, componentWithPackage);
11798
+ return {
11799
+ ...componentWithPackage,
11800
+ path: path3,
11801
+ reactDocgen: reactDocgen2,
11802
+ importOverride: reactDocgen2.type === "success" ? getImportTag(reactDocgen2.data) : void 0
11803
+ };
11804
+ }
11618
11805
  }
11619
11806
  return componentWithPackage;
11620
11807
  }).sort((a, b) => a.componentName.localeCompare(b.componentName));
@@ -11760,6 +11947,21 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
11760
11947
  };
11761
11948
 
11762
11949
  // src/componentManifest/generator.ts
11950
+ function selectComponentEntries(manifestEntries) {
11951
+ let entriesByComponentId = /* @__PURE__ */ new Map();
11952
+ return manifestEntries.filter(
11953
+ (entry) => entry.type === "story" && entry.subtype === "story" || // Attached docs entries are the only docs entries that can contribute to a
11954
+ // component manifest, because they point back to a story file through storiesImports.
11955
+ entry.type === "docs" && entry.tags?.includes(Tag.ATTACHED_MDX) && entry.storiesImports.length > 0
11956
+ ).forEach((entry) => {
11957
+ let componentId = entry.id.split("--")[0], existingEntry = entriesByComponentId.get(componentId);
11958
+ if (!existingEntry) {
11959
+ entriesByComponentId.set(componentId, entry);
11960
+ return;
11961
+ }
11962
+ existingEntry.type === "docs" && entry.type === "story" && entriesByComponentId.set(componentId, entry);
11963
+ }), [...entriesByComponentId.values()];
11964
+ }
11763
11965
  function findMatchingComponent(components, componentName, trimmedTitle) {
11764
11966
  return components.find(
11765
11967
  (it) => componentName ? [it.componentName, it.localImportName, it.importName].includes(componentName) : trimmedTitle.includes(it.componentName) || it.localImportName && trimmedTitle.includes(it.localImportName) || it.importName && trimmedTitle.includes(it.importName)
@@ -11809,20 +12011,18 @@ function extractComponentDescription(csf, docgen) {
11809
12011
  jsDocTags: tags
11810
12012
  };
11811
12013
  }
11812
- var manifests = async (existingManifests = {}, { manifestEntries }) => {
11813
- invalidateCache();
11814
- let startPerformance = performance.now(), components = uniqBy(
11815
- manifestEntries.filter(
11816
- (entry) => entry.type === "story" && entry.subtype === "story" || // addon-docs will add docs entries to these manifest entries afterwards
11817
- // Docs entries have importPath pointing to MDX file, but storiesImports[0] points to the story file
11818
- entry.type === "docs" && entry.tags?.includes(Tag.ATTACHED_MDX) && entry.storiesImports.length > 0
11819
- ),
11820
- (entry) => entry.id.split("--")[0]
11821
- ).map((entry) => {
12014
+ var manifests = async (existingManifests = {}, options) => {
12015
+ let { manifestEntries, presets } = options, typescriptOptions = await presets?.apply("typescript", {}) ?? {};
12016
+ invalidateCache(), invalidateParser();
12017
+ let startTime = performance.now(), components = selectComponentEntries(manifestEntries).map((entry) => {
11822
12018
  let storyFilePath = entry.type === "story" ? entry.importPath : (
11823
12019
  // For attached docs entries, storiesImports[0] points to the stories file being attached to
11824
12020
  entry.storiesImports[0]
11825
- ), absoluteImportPath = path.join(process.cwd(), storyFilePath), storyFile = cachedReadFileSync(absoluteImportPath, "utf-8"), csf = loadCsf(storyFile, { makeTitle: () => entry.title }).parse(), componentName = csf._meta?.component, id = entry.id.split("--")[0], title = entry.title.split("/").at(-1).replace(/\s+/g, ""), allComponents = getComponents({ csf, storyFilePath: absoluteImportPath }), component = findMatchingComponent(
12021
+ ), absoluteImportPath = path.join(process.cwd(), storyFilePath), storyFile = cachedReadFileSync(absoluteImportPath, "utf-8"), csf = loadCsf(storyFile, { makeTitle: () => entry.title }).parse(), componentName = csf._meta?.component, id = entry.id.split("--")[0], title = entry.title.split("/").at(-1).replace(/\s+/g, ""), allComponents = getComponents({
12022
+ csf,
12023
+ storyFilePath: absoluteImportPath,
12024
+ typescriptOptions
12025
+ }), component = findMatchingComponent(
11826
12026
  allComponents,
11827
12027
  componentName,
11828
12028
  entry.title.replace(/\s+/g, "")
@@ -11835,7 +12035,7 @@ var manifests = async (existingManifests = {}, { manifestEntries }) => {
11835
12035
  import: imports,
11836
12036
  jsDocTags: {}
11837
12037
  };
11838
- if (!component?.reactDocgen) {
12038
+ if (!(component?.reactDocgen || component?.reactDocgenTypescript)) {
11839
12039
  let error = csf._meta?.component ? {
11840
12040
  name: "No component import found",
11841
12041
  message: `No component file found for the "${csf.meta.component}" component.`
@@ -11854,22 +12054,30 @@ ${storyFile}`
11854
12054
  }
11855
12055
  };
11856
12056
  }
11857
- let docgenResult = component.reactDocgen, docgen = docgenResult.type === "success" ? docgenResult.data : void 0, { description, summary, jsDocTags } = extractComponentDescription(csf, docgen);
12057
+ let docgenResult = component.reactDocgen, docgen = docgenResult?.type === "success" ? docgenResult.data : void 0, reactDocgenTypescriptDoc = component.reactDocgenTypescript, docgenDescription = docgen?.description ?? reactDocgenTypescriptDoc?.description, { description, summary, jsDocTags } = extractComponentDescription(
12058
+ csf,
12059
+ docgenDescription ? { description: docgenDescription } : void 0
12060
+ );
11858
12061
  return {
11859
12062
  ...base2,
11860
12063
  description,
11861
12064
  summary,
11862
12065
  import: imports,
11863
- reactDocgen: docgen,
12066
+ ...docgen ? { reactDocgen: docgen } : {},
12067
+ ...reactDocgenTypescriptDoc ? { reactDocgenTypescript: reactDocgenTypescriptDoc } : {},
11864
12068
  jsDocTags,
11865
- error: docgenResult.type === "error" ? docgenResult.error : void 0
12069
+ error: (docgenResult?.type === "error" ? docgenResult.error : void 0) ?? component.reactDocgenTypescriptError
11866
12070
  };
11867
- }).filter((component) => component !== void 0);
11868
- return logger6.verbose(`Component manifest generation took ${performance.now() - startPerformance}ms`), {
12071
+ }).filter((component) => component !== void 0), durationMs = Math.round(performance.now() - startTime);
12072
+ return {
11869
12073
  ...existingManifests,
11870
12074
  components: {
11871
12075
  v: 0,
11872
- components: Object.fromEntries(components.map((component) => [component.id, component]))
12076
+ components: Object.fromEntries(components.map((component) => [component.id, component])),
12077
+ meta: {
12078
+ docgen: typescriptOptions.reactDocgen ?? "react-docgen",
12079
+ durationMs
12080
+ }
11873
12081
  }
11874
12082
  };
11875
12083
  };
@@ -11997,11 +12205,13 @@ async function internal_getArgTypesData(_input, options) {
11997
12205
  componentExportName
11998
12206
  }), argTypesData;
11999
12207
  }
12208
+ var optimizeViteDeps = ["react-dom/test-utils"];
12000
12209
  export {
12001
12210
  addons,
12002
12211
  enrichCsf as experimental_enrichCsf,
12003
12212
  manifests as experimental_manifests,
12004
12213
  internal_getArgTypesData,
12214
+ optimizeViteDeps,
12005
12215
  previewAnnotations,
12006
12216
  resolvedReact
12007
12217
  };