@storybook/react 10.5.0-alpha.7 → 10.5.0-alpha.9

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.
@@ -129,7 +129,7 @@ var applyDecorators2 = (storyFn, decorators2) => {
129
129
  };
130
130
 
131
131
  // src/entry-preview-docs.ts
132
- var decorators = "FEATURES" in globalThis && globalThis?.FEATURES?.experimentalCodeExamples ? [] : [jsxDecorator], parameters = {
132
+ var useStaticServiceSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.experimentalDocgenServer, useCompileTimeSnippets = "FEATURES" in globalThis && globalThis?.FEATURES?.experimentalCodeExamples, decorators = useStaticServiceSnippets || useCompileTimeSnippets ? [] : [jsxDecorator], parameters = {
133
133
  docs: {
134
134
  story: { inline: !0 }
135
135
  }
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-5GZAZJC7.js";
7
7
  import {
8
8
  entry_preview_docs_exports
9
- } from "./chunk-WP3KE75H.js";
9
+ } from "./chunk-I4YGNZB3.js";
10
10
 
11
11
  // src/preview.tsx
12
12
  import { definePreview as definePreviewBase } from "storybook/internal/csf";
@@ -2,7 +2,7 @@ import {
2
2
  applyDecorators,
3
3
  decorators,
4
4
  parameters
5
- } from "./_browser-chunks/chunk-WP3KE75H.js";
5
+ } from "./_browser-chunks/chunk-I4YGNZB3.js";
6
6
  import "./_browser-chunks/chunk-DDIRQRCA.js";
7
7
  import "./_browser-chunks/chunk-B3FR4PBN.js";
8
8
  import "./_browser-chunks/chunk-UAWMPV5J.js";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-4GJ4IH3W.js";
3
+ } from "./_browser-chunks/chunk-IRIPKPOF.js";
4
4
  import {
5
5
  entry_preview_exports,
6
6
  renderToCanvas
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  entry_preview_argtypes_exports
10
10
  } from "./_browser-chunks/chunk-5GZAZJC7.js";
11
- import "./_browser-chunks/chunk-WP3KE75H.js";
11
+ import "./_browser-chunks/chunk-I4YGNZB3.js";
12
12
  import "./_browser-chunks/chunk-DDIRQRCA.js";
13
13
  import "./_browser-chunks/chunk-B3FR4PBN.js";
14
14
  import "./_browser-chunks/chunk-UAWMPV5J.js";
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_k4x5zyjr6vp from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_k4x5zyjr6vp from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_k4x5zyjr6vp from "node:module";
1
+ import CJS_COMPAT_NODE_URL_dux1x5a8df8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_dux1x5a8df8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_dux1x5a8df8 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_k4x5zyjr6vp.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_k4x5zyjr6vp.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_k4x5zyjr6vp.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_dux1x5a8df8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_dux1x5a8df8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_dux1x5a8df8.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -8741,21 +8741,31 @@ var require_homedir = __commonJS({
8741
8741
  var os = __require("os");
8742
8742
  module.exports = os.homedir || function() {
8743
8743
  var home = process.env.HOME, user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME;
8744
- return process.platform === "win32" ? process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || home || null : process.platform === "darwin" ? home || (user ? "/Users/" + user : null) : process.platform === "linux" ? home || (process.getuid() === 0 ? "/root" : user ? "/home/" + user : null) : home || null;
8744
+ return process.platform === "win32" ? process.env.USERPROFILE || process.env.HOMEDRIVE && process.env.HOMEPATH && process.env.HOMEDRIVE + process.env.HOMEPATH || home || null : process.platform === "darwin" ? home || (user ? "/Users/" + user : null) : process.platform === "linux" ? home || (process.getuid() === 0 ? "/root" : user ? "/home/" + user : null) : home || null;
8745
8745
  };
8746
8746
  }
8747
8747
  });
8748
8748
 
8749
+ // ../../../node_modules/es-errors/index.js
8750
+ var require_es_errors = __commonJS({
8751
+ "../../../node_modules/es-errors/index.js"(exports, module) {
8752
+ "use strict";
8753
+ module.exports = Error;
8754
+ }
8755
+ });
8756
+
8749
8757
  // ../../../node_modules/resolve/lib/caller.js
8750
8758
  var require_caller = __commonJS({
8751
8759
  "../../../node_modules/resolve/lib/caller.js"(exports, module) {
8760
+ "use strict";
8761
+ var $Error = require_es_errors();
8752
8762
  module.exports = function() {
8753
- var origPrepareStackTrace = Error.prepareStackTrace;
8754
- Error.prepareStackTrace = function(_, stack2) {
8763
+ var origPrepareStackTrace = $Error.prepareStackTrace;
8764
+ $Error.prepareStackTrace = function(_, stack2) {
8755
8765
  return stack2;
8756
8766
  };
8757
- var stack = new Error().stack;
8758
- return Error.prepareStackTrace = origPrepareStackTrace, stack[2].getFileName();
8767
+ var stack = new $Error().stack;
8768
+ return $Error.prepareStackTrace = origPrepareStackTrace, stack[2].getFileName();
8759
8769
  };
8760
8770
  }
8761
8771
  });
@@ -8813,7 +8823,8 @@ var require_path_parse = __commonJS({
8813
8823
  // ../../../node_modules/resolve/lib/node-modules-paths.js
8814
8824
  var require_node_modules_paths = __commonJS({
8815
8825
  "../../../node_modules/resolve/lib/node-modules-paths.js"(exports, module) {
8816
- var path5 = __require("path"), parse8 = path5.parse || require_path_parse(), driveLetterRegex = /^([A-Za-z]:)/, uncPathRegex = /^\\\\/, getNodeModulesDirs = function(absoluteStart, modules) {
8826
+ var path5 = __require("path"), parse8 = path5.parse || require_path_parse(), driveLetterRegex = /^([A-Za-z]:)/, uncPathRegex = /^\\\\/;
8827
+ function getNodeModulesDirs(absoluteStart, modules) {
8817
8828
  var prefix = "/";
8818
8829
  driveLetterRegex.test(absoluteStart) ? prefix = "" : uncPathRegex.test(absoluteStart) && (prefix = "\\\\");
8819
8830
  for (var paths = [absoluteStart], parsed = parse8(absoluteStart); parsed.dir !== paths[paths.length - 1]; )
@@ -8823,7 +8834,7 @@ var require_node_modules_paths = __commonJS({
8823
8834
  return path5.resolve(prefix, aPath, moduleDir);
8824
8835
  }));
8825
8836
  }, []);
8826
- };
8837
+ }
8827
8838
  module.exports = function(start, opts, request) {
8828
8839
  var modules = opts && opts.moduleDirectory ? [].concat(opts.moduleDirectory) : ["node_modules"];
8829
8840
  if (opts && typeof opts.paths == "function")
@@ -9173,15 +9184,25 @@ var require_is_core_module = __commonJS({
9173
9184
  }
9174
9185
  });
9175
9186
 
9187
+ // ../../../node_modules/es-errors/type.js
9188
+ var require_type = __commonJS({
9189
+ "../../../node_modules/es-errors/type.js"(exports, module) {
9190
+ "use strict";
9191
+ module.exports = TypeError;
9192
+ }
9193
+ });
9194
+
9176
9195
  // ../../../node_modules/resolve/lib/async.js
9177
9196
  var require_async = __commonJS({
9178
9197
  "../../../node_modules/resolve/lib/async.js"(exports, module) {
9179
- var fs = __require("fs"), getHomedir = require_homedir(), path5 = __require("path"), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions = require_normalize_options(), isCore = require_is_core_module(), realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native == "function" ? fs.realpath.native : fs.realpath, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir(), defaultPaths = function() {
9180
- return [
9198
+ var fs = __require("fs"), getHomedir = require_homedir(), path5 = __require("path"), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions = require_normalize_options(), isCore = require_is_core_module(), $Error = require_es_errors(), $TypeError = require_type(), realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native == "function" ? fs.realpath.native : fs.realpath, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir();
9199
+ function defaultPaths() {
9200
+ return homedir ? [
9181
9201
  path5.join(homedir, ".node_modules"),
9182
9202
  path5.join(homedir, ".node_libraries")
9183
- ];
9184
- }, defaultIsFile = function(file, cb) {
9203
+ ] : [];
9204
+ }
9205
+ var defaultIsFile = function(file, cb) {
9185
9206
  fs.stat(file, function(err, stat) {
9186
9207
  return err ? err.code === "ENOENT" || err.code === "ENOTDIR" ? cb(null, !1) : cb(err) : cb(null, stat.isFile() || stat.isFIFO());
9187
9208
  });
@@ -9193,9 +9214,11 @@ var require_async = __commonJS({
9193
9214
  realpathFS(x, function(realpathErr, realPath) {
9194
9215
  realpathErr && realpathErr.code !== "ENOENT" ? cb(realpathErr) : cb(null, realpathErr ? x : realPath);
9195
9216
  });
9196
- }, maybeRealpath = function(realpath, x, opts, cb) {
9217
+ };
9218
+ function maybeRealpath(realpath, x, opts, cb) {
9197
9219
  opts && opts.preserveSymlinks === !1 ? realpath(x, cb) : cb(null, x);
9198
- }, defaultReadPackage = function(readFile, pkgfile, cb) {
9220
+ }
9221
+ function defaultReadPackage(readFile, pkgfile, cb) {
9199
9222
  readFile(pkgfile, function(readFileErr, body) {
9200
9223
  if (readFileErr) cb(readFileErr);
9201
9224
  else
@@ -9206,15 +9229,16 @@ var require_async = __commonJS({
9206
9229
  cb(null);
9207
9230
  }
9208
9231
  });
9209
- }, getPackageCandidates = function(x, start, opts) {
9232
+ }
9233
+ function getPackageCandidates(x, start, opts) {
9210
9234
  for (var dirs = nodeModulesPaths(start, opts, x), i2 = 0; i2 < dirs.length; i2++)
9211
9235
  dirs[i2] = path5.join(dirs[i2], x);
9212
9236
  return dirs;
9213
- };
9237
+ }
9214
9238
  module.exports = function(x, options, callback) {
9215
9239
  var cb = callback, opts = options;
9216
9240
  if (typeof options == "function" && (cb = opts, opts = {}), typeof x != "string") {
9217
- var err = new TypeError("Path must be a string.");
9241
+ var err = new $TypeError("Path must be a string.");
9218
9242
  return process.nextTick(function() {
9219
9243
  cb(err);
9220
9244
  });
@@ -9222,7 +9246,7 @@ var require_async = __commonJS({
9222
9246
  opts = normalizeOptions(x, opts);
9223
9247
  var isFile2 = opts.isFile || defaultIsFile, isDirectory = opts.isDirectory || defaultIsDir, readFile = opts.readFile || fs.readFile, realpath = opts.realpath || defaultRealpath, readPackage = opts.readPackage || defaultReadPackage;
9224
9248
  if (opts.readFile && opts.readPackage) {
9225
- var conflictErr = new TypeError("`readFile` and `readPackage` are mutually exclusive.");
9249
+ var conflictErr = new $TypeError("`readFile` and `readPackage` are mutually exclusive.");
9226
9250
  return process.nextTick(function() {
9227
9251
  cb(conflictErr);
9228
9252
  });
@@ -9252,7 +9276,7 @@ var require_async = __commonJS({
9252
9276
  return maybeRealpath(realpath, n, opts, function(err3, realN) {
9253
9277
  err3 ? cb(err3) : cb(null, realN, pkg);
9254
9278
  });
9255
- var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
9279
+ var moduleError = new $Error("Cannot find module '" + x + "' from '" + parent + "'");
9256
9280
  moduleError.code = "MODULE_NOT_FOUND", cb(moduleError);
9257
9281
  }
9258
9282
  });
@@ -9266,7 +9290,7 @@ var require_async = __commonJS({
9266
9290
  err4 ? cb(err4) : cb(null, realD, pkg2);
9267
9291
  });
9268
9292
  else {
9269
- var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
9293
+ var moduleError = new $Error("Cannot find module '" + x + "' from '" + parent + "'");
9270
9294
  moduleError.code = "MODULE_NOT_FOUND", cb(moduleError);
9271
9295
  }
9272
9296
  });
@@ -9285,7 +9309,7 @@ var require_async = __commonJS({
9285
9309
  if (dir && pkg && opts.pathFilter) {
9286
9310
  var rfile = path5.relative(dir, file), rel = rfile.slice(0, rfile.length - exts2[0].length), r = opts.pathFilter(pkg, x3, rel);
9287
9311
  if (r) return load(
9288
- [""].concat(extensions.slice()),
9312
+ [""].concat(extensions),
9289
9313
  path5.resolve(dir, r),
9290
9314
  pkg
9291
9315
  );
@@ -9307,7 +9331,8 @@ var require_async = __commonJS({
9307
9331
  isFile2(pkgfile, function(err2, ex) {
9308
9332
  if (!ex) return loadpkg(path5.dirname(dir), cb2);
9309
9333
  readPackage(readFile, pkgfile, function(err3, pkgParam) {
9310
- err3 && cb2(err3);
9334
+ if (err3)
9335
+ return cb2(err3);
9311
9336
  var pkg = pkgParam;
9312
9337
  pkg && opts.packageFilter && (pkg = opts.packageFilter(pkg, pkgfile)), cb2(null, pkg, dir);
9313
9338
  });
@@ -9327,7 +9352,7 @@ var require_async = __commonJS({
9327
9352
  var pkg = pkgParam;
9328
9353
  if (pkg && opts.packageFilter && (pkg = opts.packageFilter(pkg, pkgfile)), pkg && pkg.main) {
9329
9354
  if (typeof pkg.main != "string") {
9330
- var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
9355
+ var mainError = new $TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
9331
9356
  return mainError.code = "INVALID_PACKAGE_MAIN", cb2(mainError);
9332
9357
  }
9333
9358
  (pkg.main === "." || pkg.main === "./") && (pkg.main = "index"), loadAsFile(path5.resolve(x2, pkg.main), pkg, function(err4, m, pkg2) {
@@ -9574,12 +9599,14 @@ var require_is_core = __commonJS({
9574
9599
  // ../../../node_modules/resolve/lib/sync.js
9575
9600
  var require_sync = __commonJS({
9576
9601
  "../../../node_modules/resolve/lib/sync.js"(exports, module) {
9577
- var isCore = require_is_core_module(), fs = __require("fs"), path5 = __require("path"), getHomedir = require_homedir(), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions = require_normalize_options(), realpathFS = process.platform !== "win32" && fs.realpathSync && typeof fs.realpathSync.native == "function" ? fs.realpathSync.native : fs.realpathSync, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir(), defaultPaths = function() {
9578
- return [
9602
+ var isCore = require_is_core_module(), fs = __require("fs"), path5 = __require("path"), $Error = require_es_errors(), $TypeError = require_type(), getHomedir = require_homedir(), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions = require_normalize_options(), realpathFS = process.platform !== "win32" && fs.realpathSync && typeof fs.realpathSync.native == "function" ? fs.realpathSync.native : fs.realpathSync, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir();
9603
+ function defaultPaths() {
9604
+ return homedir ? [
9579
9605
  path5.join(homedir, ".node_modules"),
9580
9606
  path5.join(homedir, ".node_libraries")
9581
- ];
9582
- }, defaultIsFile = function(file) {
9607
+ ] : [];
9608
+ }
9609
+ var defaultIsFile = function(file) {
9583
9610
  try {
9584
9611
  var stat = fs.statSync(file, { throwIfNoEntry: !1 });
9585
9612
  } catch (e) {
@@ -9603,26 +9630,29 @@ var require_sync = __commonJS({
9603
9630
  throw realpathErr;
9604
9631
  }
9605
9632
  return x;
9606
- }, maybeRealpathSync = function(realpathSync, x, opts) {
9633
+ };
9634
+ function maybeRealpathSync(realpathSync, x, opts) {
9607
9635
  return opts && opts.preserveSymlinks === !1 ? realpathSync(x) : x;
9608
- }, defaultReadPackageSync = function(readFileSync2, pkgfile) {
9636
+ }
9637
+ function defaultReadPackageSync(readFileSync2, pkgfile) {
9609
9638
  var body = readFileSync2(pkgfile);
9610
9639
  try {
9611
9640
  var pkg = JSON.parse(body);
9612
9641
  return pkg;
9613
9642
  } catch {
9614
9643
  }
9615
- }, getPackageCandidates = function(x, start, opts) {
9644
+ }
9645
+ function getPackageCandidates(x, start, opts) {
9616
9646
  for (var dirs = nodeModulesPaths(start, opts, x), i2 = 0; i2 < dirs.length; i2++)
9617
9647
  dirs[i2] = path5.join(dirs[i2], x);
9618
9648
  return dirs;
9619
- };
9649
+ }
9620
9650
  module.exports = function(x, options) {
9621
9651
  if (typeof x != "string")
9622
- throw new TypeError("Path must be a string.");
9652
+ throw new $TypeError("Path must be a string.");
9623
9653
  var opts = normalizeOptions(x, options), isFile2 = opts.isFile || defaultIsFile, readFileSync2 = opts.readFileSync || fs.readFileSync, isDirectory = opts.isDirectory || defaultIsDir, realpathSync = opts.realpathSync || defaultRealpathSync, readPackageSync = opts.readPackageSync || defaultReadPackageSync;
9624
9654
  if (opts.readFileSync && opts.readPackageSync)
9625
- throw new TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");
9655
+ throw new $TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");
9626
9656
  var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir || path5.dirname(caller()), parent = opts.filename || basedir;
9627
9657
  opts.paths = opts.paths || defaultPaths();
9628
9658
  var absoluteStart = maybeRealpathSync(realpathSync, path5.resolve(basedir), opts);
@@ -9637,7 +9667,7 @@ var require_sync = __commonJS({
9637
9667
  var n = loadNodeModulesSync(x, absoluteStart);
9638
9668
  if (n) return maybeRealpathSync(realpathSync, n, opts);
9639
9669
  }
9640
- var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
9670
+ var err = new $Error("Cannot find module '" + x + "' from '" + parent + "'");
9641
9671
  throw err.code = "MODULE_NOT_FOUND", err;
9642
9672
  function loadAsFileSync(x2) {
9643
9673
  var pkg = loadpkg(path5.dirname(x2));
@@ -9679,7 +9709,7 @@ var require_sync = __commonJS({
9679
9709
  x2
9680
9710
  )), pkg && pkg.main) {
9681
9711
  if (typeof pkg.main != "string") {
9682
- var mainError = new TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
9712
+ var mainError = new $TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
9683
9713
  throw mainError.code = "INVALID_PACKAGE_MAIN", mainError;
9684
9714
  }
9685
9715
  (pkg.main === "." || pkg.main === "./") && (pkg.main = "index");
@@ -14748,7 +14778,7 @@ function parse6(source, options = {}) {
14748
14778
  var stringify = getStringifier();
14749
14779
 
14750
14780
  // src/componentManifest/utils.ts
14751
- import { readFileSync } from "node:fs";
14781
+ import { readFileSync, statSync as statSync2 } from "node:fs";
14752
14782
  import { getProjectRoot, resolveImport } from "storybook/internal/common";
14753
14783
  import { logger } from "storybook/internal/node-logger";
14754
14784
 
@@ -14797,7 +14827,7 @@ function invariant(condition, message) {
14797
14827
  if (!condition)
14798
14828
  throw new Error((typeof message == "function" ? message() : message) ?? "Invariant failed");
14799
14829
  }
14800
- var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */ new WeakMap(), cached = (fn, opts = {}) => {
14830
+ var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */ new WeakMap(), textFileCache = /* @__PURE__ */ new Map(), cached = (fn, opts = {}) => {
14801
14831
  let keyOf2 = opts.key ?? ((...args) => {
14802
14832
  try {
14803
14833
  return JSON.stringify(args);
@@ -14832,11 +14862,22 @@ var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */
14832
14862
  return store.set(k, pending), pending;
14833
14863
  };
14834
14864
  }, invalidateCache = () => {
14835
- memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */ new WeakMap();
14836
- }, cachedReadFileSync = cached(readFileSync, { name: "cachedReadFile" }), cachedReadTextFileSync = cached(
14837
- (filePath) => readFileSync(filePath, "utf-8"),
14838
- { name: "cachedReadTextFile" }
14839
- ), cachedFindUp = cached(up2, { name: "findUp" }), cachedResolveImport = cached(resolveImport, {
14865
+ memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */ new WeakMap(), textFileCache = /* @__PURE__ */ new Map();
14866
+ }, cachedReadFileSync = cached(readFileSync, { name: "cachedReadFile" }), cachedReadTextFileSync = (filePath) => {
14867
+ let mtimeMs;
14868
+ try {
14869
+ mtimeMs = statSync2(filePath).mtimeMs;
14870
+ } catch {
14871
+ mtimeMs = void 0;
14872
+ }
14873
+ if (mtimeMs !== void 0) {
14874
+ let entry = textFileCache.get(filePath);
14875
+ if (entry && entry.mtimeMs === mtimeMs)
14876
+ return entry.content;
14877
+ }
14878
+ let content = readFileSync(filePath, "utf-8");
14879
+ return mtimeMs !== void 0 && textFileCache.set(filePath, { mtimeMs, content }), content;
14880
+ }, cachedFindUp = cached(up2, { name: "findUp" }), cachedResolveImport = cached(resolveImport, {
14840
14881
  name: "resolveImport"
14841
14882
  }), TSCONFIG_CANDIDATES = ["tsconfig.json", "tsconfig.base.json", "tsconfig.app.json"], findTsconfigPath = cached(
14842
14883
  (cwd2) => {
@@ -16271,26 +16312,41 @@ function createSubcomponentDocgen({
16271
16312
  })
16272
16313
  };
16273
16314
  }
16274
- function buildReactComponentDocgenFromResolved({
16315
+ function buildStoryDocsFromResolved({
16275
16316
  entry,
16276
16317
  storyPath,
16277
16318
  storyFilePath,
16278
- storyFile,
16279
16319
  csf,
16280
16320
  componentName,
16281
16321
  component,
16282
16322
  allComponents,
16283
- subcomponents,
16284
- docgenEngine,
16285
16323
  filterStoryIds
16286
16324
  }) {
16287
16325
  let id = getComponentIdFromEntry(entry), title = entry.title.split("/").at(-1).replace(/\s+/g, ""), packageName = getPackageInfo(component?.path, storyPath), fallbackImport = getFallbackImport(packageName, componentName), imports = getImports({ components: allComponents, packageName }).join(`
16288
- `).trim() || fallbackImport, stories = extractStorySnippets(csf, component?.componentName, filterStoryIds), base2 = {
16326
+ `).trim() || fallbackImport, storyEntries = extractStorySnippets(csf, component?.componentName, filterStoryIds);
16327
+ return {
16328
+ id,
16329
+ name: componentName ?? title,
16330
+ path: storyFilePath,
16331
+ ...imports ? { import: imports } : {},
16332
+ stories: Object.fromEntries(storyEntries.map((story) => [story.id, story]))
16333
+ };
16334
+ }
16335
+ function buildComponentDocgenFromResolved({
16336
+ entry,
16337
+ storyPath,
16338
+ storyFilePath,
16339
+ storyFile,
16340
+ csf,
16341
+ componentName,
16342
+ component,
16343
+ subcomponents,
16344
+ docgenEngine
16345
+ }) {
16346
+ let id = getComponentIdFromEntry(entry), title = entry.title.split("/").at(-1).replace(/\s+/g, ""), packageName = getPackageInfo(component?.path, storyPath), base2 = {
16289
16347
  id,
16290
16348
  name: componentName ?? title,
16291
16349
  path: storyFilePath,
16292
- stories,
16293
- import: imports || void 0,
16294
16350
  jsDocTags: {}
16295
16351
  }, {
16296
16352
  reactDocgen,
@@ -16340,7 +16396,6 @@ ${storyFile}`
16340
16396
  ...base2,
16341
16397
  description,
16342
16398
  summary,
16343
- import: imports || void 0,
16344
16399
  reactDocgen,
16345
16400
  reactDocgenTypescript,
16346
16401
  reactComponentMeta,
@@ -16349,6 +16404,46 @@ ${storyFile}`
16349
16404
  error: docgenError
16350
16405
  };
16351
16406
  }
16407
+ function buildReactComponentDocgenFromResolved({
16408
+ entry,
16409
+ storyPath,
16410
+ storyFilePath,
16411
+ storyFile,
16412
+ csf,
16413
+ componentName,
16414
+ component,
16415
+ allComponents,
16416
+ subcomponents,
16417
+ docgenEngine,
16418
+ filterStoryIds
16419
+ }) {
16420
+ let storyDocs = buildStoryDocsFromResolved({
16421
+ entry,
16422
+ storyPath,
16423
+ storyFilePath,
16424
+ csf,
16425
+ componentName,
16426
+ component,
16427
+ allComponents,
16428
+ filterStoryIds
16429
+ });
16430
+ return {
16431
+ ...buildComponentDocgenFromResolved({
16432
+ entry,
16433
+ storyPath,
16434
+ storyFilePath,
16435
+ storyFile,
16436
+ csf,
16437
+ componentName,
16438
+ component,
16439
+ subcomponents,
16440
+ docgenEngine
16441
+ }),
16442
+ // Legacy inline manifests keep CSF-ordered arrays; story-docs open-service payloads use Records.
16443
+ stories: Object.values(storyDocs.stories),
16444
+ ...storyDocs.import ? { import: storyDocs.import } : {}
16445
+ };
16446
+ }
16352
16447
 
16353
16448
  // src/componentManifest/componentMetaManagerSingleton.ts
16354
16449
  import { logger as logger8 } from "storybook/internal/node-logger";
@@ -17750,7 +17845,8 @@ var manifests = async (existingManifests = {}, options) => {
17750
17845
  import { recast as recast3, types as t5 } from "storybook/internal/babel";
17751
17846
  import { getPrettier } from "storybook/internal/common";
17752
17847
  var enrichCsf = async (input, options) => {
17753
- if ((await options.presets.apply("features")).experimentalCodeExamples)
17848
+ let features = await options.presets.apply("features");
17849
+ if (!(!features.experimentalCodeExamples || features.experimentalDocgenServer))
17754
17850
  return async (csf, csfSource) => {
17755
17851
  let promises = Object.keys(csf._stories).map(async (key) => {
17756
17852
  if (!csfSource._meta?.component)
@@ -17858,14 +17954,14 @@ async function buildDocgenPayload(input, context) {
17858
17954
  } catch {
17859
17955
  return;
17860
17956
  }
17861
- let { csf, componentName, component, allComponents, subcomponents, storyFile } = resolved, usableSubcomponents = subcomponents.filter(
17957
+ let { csf, componentName, component, subcomponents, storyFile } = resolved, usableSubcomponents = subcomponents.filter(
17862
17958
  (sub) => sub.component !== void 0
17863
17959
  ), storyRefs = [
17864
17960
  ...component ? [{ storyPath, component }] : [],
17865
17961
  ...usableSubcomponents.map((sub) => ({ storyPath, component: sub.component }))
17866
17962
  ];
17867
17963
  storyRefs.length > 0 && context.componentMetaManager.batchExtract(storyRefs);
17868
- let componentDocgen = buildReactComponentDocgenFromResolved({
17964
+ let componentDocgen = buildComponentDocgenFromResolved({
17869
17965
  entry: input.entry,
17870
17966
  storyPath,
17871
17967
  storyFilePath,
@@ -17873,7 +17969,6 @@ async function buildDocgenPayload(input, context) {
17873
17969
  csf,
17874
17970
  componentName,
17875
17971
  component,
17876
- allComponents,
17877
17972
  subcomponents,
17878
17973
  docgenEngine: "react-component-meta"
17879
17974
  });
@@ -17901,6 +17996,55 @@ var experimental_docgenProvider = async (nextDocgen, options) => {
17901
17996
  };
17902
17997
  };
17903
17998
 
17999
+ // src/docgen/story-docs-preset.ts
18000
+ import { STORY_FILE_TEST_REGEXP as STORY_FILE_TEST_REGEXP2, getStoryImportPathFromEntry as getStoryImportPathFromEntry5 } from "storybook/internal/common";
18001
+
18002
+ // src/docgen/build-story-docs.ts
18003
+ import { getStoryImportPathFromEntry as getStoryImportPathFromEntry4 } from "storybook/internal/common";
18004
+ async function buildStoryDocsPayload(input, context) {
18005
+ let storyFilePath = getStoryImportPathFromEntry4(input.entry);
18006
+ if (!storyFilePath)
18007
+ return;
18008
+ let storyPath = (context.resolvePath ?? ((importPath) => path.join(process.cwd(), importPath)))(storyFilePath), resolved;
18009
+ try {
18010
+ resolved = await resolveStoryFileComponents({
18011
+ storyPath,
18012
+ title: input.entry.title,
18013
+ typescriptOptions: context.typescriptOptions,
18014
+ docgenEngine: "react-component-meta"
18015
+ });
18016
+ } catch {
18017
+ return;
18018
+ }
18019
+ let { csf, componentName, component, allComponents } = resolved;
18020
+ return buildStoryDocsFromResolved({
18021
+ entry: input.entry,
18022
+ storyPath,
18023
+ storyFilePath,
18024
+ csf,
18025
+ componentName,
18026
+ component,
18027
+ allComponents
18028
+ });
18029
+ }
18030
+
18031
+ // src/docgen/story-docs-preset.ts
18032
+ var experimental_storyDocsProvider = async (nextStoryDocs, options) => {
18033
+ let typescriptOptionsPromise = options.presets?.apply(
18034
+ "typescript",
18035
+ {}
18036
+ ) ?? Promise.resolve({});
18037
+ return async (input) => {
18038
+ let storyImportPath = getStoryImportPathFromEntry5(input.entry);
18039
+ if (!storyImportPath || !STORY_FILE_TEST_REGEXP2.test(storyImportPath))
18040
+ return nextStoryDocs(input);
18041
+ let ours = await buildStoryDocsPayload(input, {
18042
+ typescriptOptions: await typescriptOptionsPromise
18043
+ });
18044
+ return ours ? { ...await nextStoryDocs(input), ...ours } : nextStoryDocs(input);
18045
+ };
18046
+ };
18047
+
17904
18048
  // src/preset.ts
17905
18049
  var addons = [
17906
18050
  import.meta.resolve("@storybook/react-dom-shim/preset")
@@ -17957,6 +18101,7 @@ export {
17957
18101
  experimental_docgenProvider,
17958
18102
  enrichCsf as experimental_enrichCsf,
17959
18103
  manifests as experimental_manifests,
18104
+ experimental_storyDocsProvider,
17960
18105
  internal_getArgTypesData,
17961
18106
  optimizeViteDeps,
17962
18107
  previewAnnotations,
package/dist/preview.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-4GJ4IH3W.js";
3
+ } from "./_browser-chunks/chunk-IRIPKPOF.js";
4
4
  import "./_browser-chunks/chunk-3HUEQMBJ.js";
5
5
  import "./_browser-chunks/chunk-5GZAZJC7.js";
6
- import "./_browser-chunks/chunk-WP3KE75H.js";
6
+ import "./_browser-chunks/chunk-I4YGNZB3.js";
7
7
  import "./_browser-chunks/chunk-DDIRQRCA.js";
8
8
  import "./_browser-chunks/chunk-B3FR4PBN.js";
9
9
  import "./_browser-chunks/chunk-UAWMPV5J.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "10.5.0-alpha.7",
3
+ "version": "10.5.0-alpha.9",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@storybook/global": "^5.0.0",
56
- "@storybook/react-dom-shim": "10.5.0-alpha.7",
56
+ "@storybook/react-dom-shim": "10.5.0-alpha.9",
57
57
  "react-docgen": "^8.0.2",
58
58
  "react-docgen-typescript": "^2.2.2"
59
59
  },
@@ -86,7 +86,7 @@
86
86
  "@types/react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
87
87
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
88
88
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
89
- "storybook": "^10.5.0-alpha.7",
89
+ "storybook": "^10.5.0-alpha.9",
90
90
  "typescript": ">= 4.9.x"
91
91
  },
92
92
  "peerDependenciesMeta": {