storybook 10.2.0 → 10.2.1

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.
Files changed (59) hide show
  1. package/dist/_node-chunks/{builder-manager-C463DWQN.js → builder-manager-Y7WDBY2S.js} +12 -12
  2. package/dist/_node-chunks/{camelcase-Y5LTSISE.js → camelcase-LCSBROGS.js} +7 -7
  3. package/dist/_node-chunks/chunk-5U7A7FRD.js +23 -0
  4. package/dist/_node-chunks/{chunk-4QVBTE7M.js → chunk-632PAV7G.js} +7 -7
  5. package/dist/_node-chunks/{chunk-REM65RTQ.js → chunk-6L4XZTSD.js} +6 -6
  6. package/dist/_node-chunks/{chunk-RJMXG4OO.js → chunk-AQXSSPXS.js} +6 -6
  7. package/dist/_node-chunks/{chunk-TRMGP5US.js → chunk-B66GDH5E.js} +7 -7
  8. package/dist/_node-chunks/{chunk-K53Q6JM5.js → chunk-EC6HAISG.js} +6 -6
  9. package/dist/_node-chunks/{chunk-OWZ2VX4F.js → chunk-F5VZNTJU.js} +7 -7
  10. package/dist/_node-chunks/{chunk-7LLBURFX.js → chunk-FFXDUKTP.js} +12 -12
  11. package/dist/_node-chunks/{chunk-7MGQ6XJD.js → chunk-FLT5MUVI.js} +9 -9
  12. package/dist/_node-chunks/chunk-GNB7JDQ6.js +61 -0
  13. package/dist/_node-chunks/{chunk-WGJXF6UC.js → chunk-HOWS7AD5.js} +7 -7
  14. package/dist/_node-chunks/{chunk-VYJ27OHZ.js → chunk-J3J4PSPT.js} +8 -8
  15. package/dist/_node-chunks/chunk-KMYEEIKB.js +18 -0
  16. package/dist/_node-chunks/{chunk-5T2PCIM6.js → chunk-KNMEGL7N.js} +16 -16
  17. package/dist/_node-chunks/{chunk-OXJURHEN.js → chunk-KYZVFZ4V.js} +7 -7
  18. package/dist/_node-chunks/{chunk-VONTSCH6.js → chunk-PZLHWGHT.js} +6 -6
  19. package/dist/_node-chunks/{chunk-GFKN7CEI.js → chunk-QBODOFYE.js} +10 -10
  20. package/dist/_node-chunks/{chunk-6QCIDOPJ.js → chunk-R3KAQRS5.js} +20 -20
  21. package/dist/_node-chunks/{chunk-P4K3OTNT.js → chunk-SEEMWADK.js} +6 -6
  22. package/dist/_node-chunks/{chunk-PDICEGYJ.js → chunk-T2BOJQA5.js} +6 -6
  23. package/dist/_node-chunks/{chunk-IMMBMNP7.js → chunk-TWGRJVH3.js} +7 -7
  24. package/dist/_node-chunks/{chunk-QA7GCRBP.js → chunk-ULROOZH7.js} +6 -6
  25. package/dist/_node-chunks/{chunk-YV4PGYQV.js → chunk-UYNE5BST.js} +13 -13
  26. package/dist/_node-chunks/{chunk-WJUD5QGU.js → chunk-V4QQTJHD.js} +6 -6
  27. package/dist/_node-chunks/{chunk-7FKTXNX7.js → chunk-V5SFXULX.js} +9 -9
  28. package/dist/_node-chunks/{chunk-JU7MZIRN.js → chunk-VNWEGP4S.js} +8 -8
  29. package/dist/_node-chunks/{chunk-HK3SJFH5.js → chunk-YNBNXSYI.js} +7 -7
  30. package/dist/_node-chunks/{chunk-ICMT47BJ.js → chunk-YRVTTAPQ.js} +7 -7
  31. package/dist/_node-chunks/{globby-PJBFMKYG.js → globby-MKVLNYKA.js} +9 -9
  32. package/dist/_node-chunks/{lib-JFMIKKXD.js → lib-LLKM6LMW.js} +7 -7
  33. package/dist/_node-chunks/{mdx-N42X6CFJ-BYGXNYNQ.js → mdx-N42X6CFJ-CLZ7QIRS.js} +8 -8
  34. package/dist/_node-chunks/{p-limit-VUZZ7QLP.js → p-limit-IAOFNB4G.js} +7 -7
  35. package/dist/babel/index.js +10 -10
  36. package/dist/bin/core.js +12 -12
  37. package/dist/bin/dispatcher.js +11 -11
  38. package/dist/bin/loader.js +9 -9
  39. package/dist/cli/index.js +18 -18
  40. package/dist/common/index.js +19 -19
  41. package/dist/core-server/index.js +35 -35
  42. package/dist/core-server/presets/common-override-preset.js +9 -9
  43. package/dist/core-server/presets/common-preset.js +25 -25
  44. package/dist/csf-tools/index.js +9 -9
  45. package/dist/manager/globals-runtime.js +1 -1
  46. package/dist/manager-api/index.d.ts +1 -1
  47. package/dist/manager-api/index.js +1 -1
  48. package/dist/mocking-utils/index.d.ts +7 -1
  49. package/dist/mocking-utils/index.js +161 -29
  50. package/dist/mocking-utils/mocker-runtime.js +1254 -0
  51. package/dist/node-logger/index.js +9 -9
  52. package/dist/preview-api/index.d.ts +68 -67
  53. package/dist/server-errors.js +11 -11
  54. package/dist/telemetry/index.js +23 -23
  55. package/package.json +3 -1
  56. package/assets/server/mocker-runtime.template.js +0 -89
  57. package/dist/_node-chunks/chunk-7DTTLDGY.js +0 -23
  58. package/dist/_node-chunks/chunk-QX2UDUQ6.js +0 -18
  59. package/dist/_node-chunks/chunk-TJR5UAMR.js +0 -61
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3ym3gv1txoi from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3ym3gv1txoi from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3ym3gv1txoi from "node:module";
1
+ import CJS_COMPAT_NODE_URL_jgrudkhi9dn from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_jgrudkhi9dn from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_jgrudkhi9dn from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3ym3gv1txoi.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3ym3gv1txoi.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3ym3gv1txoi.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_jgrudkhi9dn.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_jgrudkhi9dn.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_jgrudkhi9dn.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -16,8 +16,8 @@ import {
16
16
  join,
17
17
  normalize,
18
18
  resolve
19
- } from "../_node-chunks/chunk-VONTSCH6.js";
20
- import "../_node-chunks/chunk-P4K3OTNT.js";
19
+ } from "../_node-chunks/chunk-PZLHWGHT.js";
20
+ import "../_node-chunks/chunk-SEEMWADK.js";
21
21
 
22
22
  // ../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
23
23
  var comma = 44, semicolon = 59, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);
@@ -1031,8 +1031,8 @@ function getIsExternal(path, importer) {
1031
1031
  return !1;
1032
1032
  }
1033
1033
  }
1034
- function resolveMock(path, root, importer, findMockRedirect) {
1035
- let isExternal2 = getIsExternal(path, root), externalPath = isExternal2 ? path : null, absolutePath = isExternal2 ? resolveExternalModule(path, root) : require2.resolve(path, { paths: [dirname(importer)] }), normalizedAbsolutePath = resolve(absolutePath), redirectPath = findMockRedirect(root, normalizedAbsolutePath, externalPath);
1034
+ function resolveMock(path, root, importer, findMockRedirect2) {
1035
+ let isExternal2 = getIsExternal(path, root), externalPath = isExternal2 ? path : null, absolutePath = isExternal2 ? resolveExternalModule(path, root) : require2.resolve(path, { paths: [dirname(importer)] }), normalizedAbsolutePath = resolve(absolutePath), redirectPath = findMockRedirect2(root, normalizedAbsolutePath, externalPath);
1036
1036
  return {
1037
1037
  absolutePath: normalizedAbsolutePath,
1038
1038
  redirectPath
@@ -1084,7 +1084,7 @@ function rewriteSbMockImportCalls(code) {
1084
1084
  }
1085
1085
  }), generate(ast, {}, code);
1086
1086
  }
1087
- function extractMockCalls(options, parse, root, findMockRedirect) {
1087
+ function extractMockCalls(options, parse, root, findMockRedirect2) {
1088
1088
  try {
1089
1089
  let hasSpyTrue2 = function(objectExpression) {
1090
1090
  if (!objectExpression || !objectExpression.properties)
@@ -1112,7 +1112,7 @@ function extractMockCalls(options, parse, root, findMockRedirect) {
1112
1112
  path,
1113
1113
  root,
1114
1114
  options.previewConfigPath,
1115
- findMockRedirect
1115
+ findMockRedirect2
1116
1116
  ), pathWithoutExtension = path.replace(/\.[^/.]+$/, ""), basenameAbsolutePath = basename(absolutePath), basenamePath = basename(path), pathWithoutExtensionAndBasename = basenameAbsolutePath === basenamePath ? pathWithoutExtension : path;
1117
1117
  mocks.push({
1118
1118
  path: pathWithoutExtensionAndBasename,
@@ -1136,24 +1136,155 @@ function extractMockCalls(options, parse, root, findMockRedirect) {
1136
1136
  }
1137
1137
 
1138
1138
  // src/mocking-utils/runtime.ts
1139
- import { resolvePackageDir } from "storybook/internal/common";
1140
- import { buildSync } from "esbuild";
1141
- var runtimeTemplatePath = join(
1142
- resolvePackageDir("storybook"),
1143
- "assets",
1144
- "server",
1145
- "mocker-runtime.template.js"
1146
- );
1139
+ import { readFileSync as readFileSync3 } from "node:fs";
1140
+ import { fileURLToPath } from "node:url";
1147
1141
  function getMockerRuntime() {
1148
- return buildSync({
1149
- entryPoints: [runtimeTemplatePath],
1150
- bundle: !0,
1151
- write: !1,
1152
- // Return the result in memory instead of writing to disk
1153
- format: "esm",
1154
- target: "es2020",
1155
- external: ["msw/browser", "msw/core/http"]
1156
- }).outputFiles[0].text;
1142
+ return readFileSync3(
1143
+ fileURLToPath(import.meta.resolve("storybook/internal/mocking-utils/mocker-runtime")),
1144
+ "utf-8"
1145
+ );
1146
+ }
1147
+
1148
+ // ../../node_modules/@vitest/mocker/dist/redirect.js
1149
+ import fs from "node:fs";
1150
+ import { builtinModules } from "node:module";
1151
+
1152
+ // ../../node_modules/@vitest/mocker/dist/chunk-pathe.M-eThtNZ.js
1153
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
1154
+ function normalizeWindowsPath(input = "") {
1155
+ return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r2) => r2.toUpperCase());
1156
+ }
1157
+ var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _EXTNAME_RE = /.(\.[^./]+|\.)$/, normalize2 = function(path) {
1158
+ if (path.length === 0)
1159
+ return ".";
1160
+ path = normalizeWindowsPath(path);
1161
+ let isUNCPath = path.match(_UNC_REGEX), isPathAbsolute = isAbsolute2(path), trailingSeparator = path[path.length - 1] === "/";
1162
+ return path = normalizeString(path, !isPathAbsolute), path.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path += "/"), _DRIVE_LETTER_RE.test(path) && (path += "/"), isUNCPath ? isPathAbsolute ? `//${path}` : `//./${path}` : isPathAbsolute && !isAbsolute2(path) ? `/${path}` : path);
1163
+ }, join2 = function(...segments) {
1164
+ let path = "";
1165
+ for (let seg of segments)
1166
+ if (seg)
1167
+ if (path.length > 0) {
1168
+ let pathTrailing = path[path.length - 1] === "/", segLeading = seg[0] === "/";
1169
+ pathTrailing && segLeading ? path += seg.slice(1) : path += pathTrailing || segLeading ? seg : `/${seg}`;
1170
+ } else
1171
+ path += seg;
1172
+ return normalize2(path);
1173
+ };
1174
+ function cwd() {
1175
+ return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
1176
+ }
1177
+ var resolve2 = function(...arguments_) {
1178
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
1179
+ let resolvedPath = "", resolvedAbsolute = !1;
1180
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
1181
+ let path = index >= 0 ? arguments_[index] : cwd();
1182
+ !path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute2(path));
1183
+ }
1184
+ return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute2(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
1185
+ };
1186
+ function normalizeString(path, allowAboveRoot) {
1187
+ let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
1188
+ for (let index = 0; index <= path.length; ++index) {
1189
+ if (index < path.length)
1190
+ char = path[index];
1191
+ else {
1192
+ if (char === "/")
1193
+ break;
1194
+ char = "/";
1195
+ }
1196
+ if (char === "/") {
1197
+ if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
1198
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
1199
+ if (res.length > 2) {
1200
+ let lastSlashIndex = res.lastIndexOf("/");
1201
+ lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
1202
+ continue;
1203
+ } else if (res.length > 0) {
1204
+ res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
1205
+ continue;
1206
+ }
1207
+ }
1208
+ allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
1209
+ } else
1210
+ res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
1211
+ lastSlash = index, dots = 0;
1212
+ } else char === "." && dots !== -1 ? ++dots : dots = -1;
1213
+ }
1214
+ return res;
1215
+ }
1216
+ var isAbsolute2 = function(p) {
1217
+ return _IS_ABSOLUTE_RE.test(p);
1218
+ }, extname = function(p) {
1219
+ if (p === "..") return "";
1220
+ let match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
1221
+ return match && match[1] || "";
1222
+ }, dirname2 = function(p) {
1223
+ let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
1224
+ return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute2(p) ? "/" : ".");
1225
+ }, basename2 = function(p, extension) {
1226
+ let segments = normalizeWindowsPath(p).split("/"), lastSegment = "";
1227
+ for (let i = segments.length - 1; i >= 0; i--) {
1228
+ let val = segments[i];
1229
+ if (val) {
1230
+ lastSegment = val;
1231
+ break;
1232
+ }
1233
+ }
1234
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
1235
+ };
1236
+
1237
+ // ../../node_modules/@vitest/mocker/dist/redirect.js
1238
+ var { existsSync, readdirSync, statSync } = fs;
1239
+ function findMockRedirect(root, mockPath, external) {
1240
+ let path = external || mockPath;
1241
+ if (external || isNodeBuiltin(mockPath) || !existsSync(mockPath)) {
1242
+ let findFile = function(mockFolder2, baseOriginal2) {
1243
+ let files = readdirSync(mockFolder2);
1244
+ for (let file of files)
1245
+ if (basename2(file, extname(file)) === baseOriginal2) {
1246
+ let path2 = resolve2(mockFolder2, file);
1247
+ if (statSync(path2).isFile())
1248
+ return path2;
1249
+ {
1250
+ let indexFile = findFile(path2, "index");
1251
+ if (indexFile)
1252
+ return indexFile;
1253
+ }
1254
+ }
1255
+ return null;
1256
+ }, mockDirname = dirname2(path), mockFolder = join2(root, "__mocks__", mockDirname);
1257
+ if (!existsSync(mockFolder))
1258
+ return null;
1259
+ let baseOriginal = basename2(path);
1260
+ return findFile(mockFolder, baseOriginal);
1261
+ }
1262
+ let dir = dirname2(path), baseId = basename2(path), fullPath = resolve2(dir, "__mocks__", baseId);
1263
+ return existsSync(fullPath) ? fullPath : null;
1264
+ }
1265
+ var builtins = /* @__PURE__ */ new Set([
1266
+ ...builtinModules,
1267
+ "assert/strict",
1268
+ "diagnostics_channel",
1269
+ "dns/promises",
1270
+ "fs/promises",
1271
+ "path/posix",
1272
+ "path/win32",
1273
+ "readline/promises",
1274
+ "stream/consumers",
1275
+ "stream/promises",
1276
+ "stream/web",
1277
+ "timers/promises",
1278
+ "util/types",
1279
+ "wasi"
1280
+ ]), prefixedBuiltins = /* @__PURE__ */ new Set([
1281
+ "node:sea",
1282
+ "node:sqlite",
1283
+ "node:test",
1284
+ "node:test/reporters"
1285
+ ]), NODE_BUILTIN_NAMESPACE = "node:";
1286
+ function isNodeBuiltin(id) {
1287
+ return prefixedBuiltins.has(id) ? !0 : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
1157
1288
  }
1158
1289
  export {
1159
1290
  __STORYBOOK_GLOBAL_THIS_ACCESSOR__,
@@ -1161,6 +1292,7 @@ export {
1161
1292
  babelParser,
1162
1293
  esmWalker,
1163
1294
  extractMockCalls,
1295
+ findMockRedirect,
1164
1296
  getArbitraryModuleIdentifier,
1165
1297
  getAutomockCode,
1166
1298
  getIsExternal,