storybook 10.1.0-alpha.12 → 10.1.0-alpha.13

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 (87) hide show
  1. package/dist/_browser-chunks/{chunk-74YHFU5B.js → chunk-2XZMBGTA.js} +1 -1
  2. package/dist/_browser-chunks/{chunk-EBHB6RPS.js → chunk-FQ7SLVLR.js} +6 -1
  3. package/dist/_browser-chunks/{chunk-X3DUQ5RA.js → chunk-GFY5R5EY.js} +1 -1
  4. package/dist/_node-chunks/{builder-manager-YUOHSIUB.js → builder-manager-DWDUVXZM.js} +27 -22
  5. package/dist/_node-chunks/{chunk-B6JWY6PC.js → camelcase-EETCRTJX.js} +8 -8
  6. package/dist/_node-chunks/{chunk-CZ5GHJCC.js → chunk-2W4GZCLE.js} +7 -7
  7. package/dist/_node-chunks/{chunk-E5FJS66Z.js → chunk-447655DM.js} +6 -6
  8. package/dist/_node-chunks/{chunk-WFLWJO24.js → chunk-4EJUC2SD.js} +4998 -1685
  9. package/dist/_node-chunks/chunk-4ZJOH2UN.js +61 -0
  10. package/dist/_node-chunks/chunk-654SJIMS.js +23 -0
  11. package/dist/_node-chunks/{chunk-2DMESZFJ.js → chunk-7IAVT2FU.js} +7 -7
  12. package/dist/_node-chunks/{chunk-5KLIDWFN.js → chunk-7KFHRNOT.js} +7 -7
  13. package/dist/_node-chunks/{chunk-XXPJ7XR3.js → chunk-AZIPBEBK.js} +6 -6
  14. package/dist/_node-chunks/{chunk-WUXQMQCB.js → chunk-B76FDKVB.js} +6 -6
  15. package/dist/_node-chunks/chunk-B7PGKETD.js +3781 -0
  16. package/dist/_node-chunks/{chunk-EZWWR7AR.js → chunk-CLUBH2LP.js} +55 -36
  17. package/dist/_node-chunks/{chunk-DUXPWBOK.js → chunk-CMYD2JNN.js} +7 -7
  18. package/dist/_node-chunks/{chunk-QCO2ZM7F.js → chunk-DIPKXLEP.js} +55 -32
  19. package/dist/_node-chunks/{chunk-DWXTZT3D.js → chunk-DPFYWXEA.js} +6 -6
  20. package/dist/_node-chunks/{chunk-FZLRAH4N.js → chunk-FCVNHU2F.js} +7 -7
  21. package/dist/_node-chunks/{chunk-QYQIZBS6.js → chunk-JQ7RQS5Q.js} +6 -6
  22. package/dist/_node-chunks/chunk-LEL5OSY3.js +18 -0
  23. package/dist/_node-chunks/{chunk-WA6KZQZ2.js → chunk-LPKSBF62.js} +6 -6
  24. package/dist/_node-chunks/chunk-LYEZOJ43.js +78 -0
  25. package/dist/_node-chunks/{chunk-JARUEMEP.js → chunk-MIA5324I.js} +7 -7
  26. package/dist/_node-chunks/{chunk-A4APXFQ2.js → chunk-MJM4TEMP.js} +14 -8
  27. package/dist/_node-chunks/{chunk-NAOYEL54.js → chunk-OVVZIUHS.js} +7 -7
  28. package/dist/_node-chunks/{chunk-5HV3B5OP.js → chunk-RUUNVQ6W.js} +1104 -13
  29. package/dist/_node-chunks/{chunk-2D2IODUU.js → chunk-URLNGLC2.js} +51 -71
  30. package/dist/_node-chunks/{chunk-OP3INKUD.js → chunk-WC2YEQHJ.js} +6 -6
  31. package/dist/_node-chunks/{chunk-4FT2DHGE.js → chunk-XKRVQL2G.js} +8 -8
  32. package/dist/_node-chunks/{chunk-SEMIAAWG.js → chunk-Z2OWEMX3.js} +8 -8
  33. package/dist/_node-chunks/{dist-DS2B5A3J.js → dist-22CLJ4BC.js} +9 -9
  34. package/dist/_node-chunks/{globby-6THB7HVX.js → globby-GR24TGSK.js} +9 -9
  35. package/dist/_node-chunks/{lib-5NKX4YGG.js → lib-G2LGVRPC.js} +7 -7
  36. package/dist/_node-chunks/{mdx-N42X6CFJ-ZLT3QOFF.js → mdx-N42X6CFJ-W6P6IDDW.js} +8 -8
  37. package/dist/_node-chunks/{p-limit-PDMWNG7W.js → p-limit-K4FZHG2F.js} +7 -7
  38. package/dist/babel/index.js +10 -11
  39. package/dist/bin/core.js +32 -26
  40. package/dist/bin/dispatcher.js +31 -20
  41. package/dist/bin/loader.js +10 -13
  42. package/dist/cli/index.d.ts +692 -133
  43. package/dist/cli/index.js +1005 -177
  44. package/dist/common/index.d.ts +139 -62
  45. package/dist/common/index.js +63 -49
  46. package/dist/core-server/index.d.ts +3 -2
  47. package/dist/core-server/index.js +96 -1413
  48. package/dist/core-server/presets/common-override-preset.js +9 -9
  49. package/dist/core-server/presets/common-preset.js +25 -65
  50. package/dist/csf-tools/index.js +9 -9
  51. package/dist/manager/globals-runtime.js +32 -3
  52. package/dist/manager/runtime.js +1 -1
  53. package/dist/manager-api/index.d.ts +1 -1
  54. package/dist/manager-api/index.js +4 -4
  55. package/dist/manager-errors.d.ts +6 -0
  56. package/dist/manager-errors.js +2 -2
  57. package/dist/mocking-utils/index.d.ts +1126 -0
  58. package/dist/{_node-chunks/chunk-ZXSD6L3S.js → mocking-utils/index.js} +441 -16
  59. package/dist/node-logger/index.d.ts +192 -24
  60. package/dist/node-logger/index.js +23 -3148
  61. package/dist/preview/runtime.js +31 -2
  62. package/dist/preview-api/index.d.ts +69 -68
  63. package/dist/preview-errors.d.ts +6 -0
  64. package/dist/preview-errors.js +2 -2
  65. package/dist/server-errors.d.ts +31 -1
  66. package/dist/server-errors.js +17 -10
  67. package/dist/telemetry/index.d.ts +23 -2
  68. package/dist/telemetry/index.js +25 -24
  69. package/dist/types/index.d.ts +71 -8
  70. package/dist/types/index.js +25 -1
  71. package/package.json +7 -9
  72. package/dist/_node-chunks/camelcase-JREIL7NV.js +0 -18
  73. package/dist/_node-chunks/chunk-FDXFVHIL.js +0 -1114
  74. package/dist/_node-chunks/chunk-HZG65SU3.js +0 -34
  75. package/dist/_node-chunks/chunk-IXVYNBMD.js +0 -18
  76. package/dist/_node-chunks/chunk-LIH7MTP7.js +0 -3214
  77. package/dist/_node-chunks/chunk-N5GIRUP5.js +0 -1047
  78. package/dist/_node-chunks/chunk-O5DA7YLO.js +0 -3171
  79. package/dist/_node-chunks/chunk-TS2UUH2J.js +0 -301
  80. package/dist/_node-chunks/chunk-Y4E6IGQF.js +0 -61
  81. package/dist/_node-chunks/chunk-ZL3AFKRX.js +0 -1029
  82. package/dist/_node-chunks/plugin-6XMWOGPO.js +0 -123
  83. package/dist/_node-chunks/plugin-LTOXVT6A.js +0 -109
  84. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +0 -46582
  85. package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +0 -92
  86. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -32
  87. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -28
@@ -1,123 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- getAutomockCode
14
- } from "./chunk-ZXSD6L3S.js";
15
- import {
16
- babelParser,
17
- extractMockCalls,
18
- getRealPath,
19
- rewriteSbMockImportCalls
20
- } from "./chunk-TS2UUH2J.js";
21
- import {
22
- normalize
23
- } from "./chunk-WA6KZQZ2.js";
24
- import "./chunk-OP3INKUD.js";
25
-
26
- // src/core-server/presets/vitePlugins/vite-mock/plugin.ts
27
- import { readFileSync } from "node:fs";
28
- import { logger } from "storybook/internal/node-logger";
29
-
30
- // src/core-server/presets/vitePlugins/vite-mock/utils.ts
31
- function getCleanId(id) {
32
- return id.replace(/^.*\/deps\//, "").replace(/\.js.*$/, "").replace(/_/g, "/");
33
- }
34
- function invalidateAllRelatedModules(server, absPath, pkgName) {
35
- for (let mod of server.moduleGraph.idToModuleMap.values())
36
- (mod.id === absPath || mod.id && getCleanId(mod.id) === pkgName) && server.moduleGraph.invalidateModule(mod);
37
- }
38
-
39
- // src/core-server/presets/vitePlugins/vite-mock/plugin.ts
40
- function viteMockPlugin(options) {
41
- let viteConfig, mockCalls = [], normalizedPreviewConfigPath = normalize(options.previewConfigPath);
42
- return [
43
- {
44
- name: "storybook:mock-loader",
45
- configResolved(config) {
46
- viteConfig = config;
47
- },
48
- buildStart() {
49
- mockCalls = extractMockCalls(options, babelParser, viteConfig.root);
50
- },
51
- configureServer(server) {
52
- async function invalidateAffectedFiles(file) {
53
- if (file === options.previewConfigPath || file.includes("__mocks__")) {
54
- let oldMockCalls = mockCalls;
55
- mockCalls = extractMockCalls(options, babelParser, viteConfig.root);
56
- let previewMod = server.moduleGraph.getModuleById(options.previewConfigPath);
57
- previewMod && server.moduleGraph.invalidateModule(previewMod);
58
- for (let call of mockCalls)
59
- invalidateAllRelatedModules(server, call.absolutePath, call.path);
60
- let newAbsPaths = new Set(mockCalls.map((c) => c.absolutePath));
61
- for (let oldCall of oldMockCalls)
62
- newAbsPaths.has(oldCall.absolutePath) || invalidateAllRelatedModules(server, oldCall.absolutePath, oldCall.path);
63
- return server.ws.send({ type: "full-reload" }), [];
64
- }
65
- }
66
- server.watcher.on("change", invalidateAffectedFiles), server.watcher.on("add", invalidateAffectedFiles), server.watcher.on("unlink", invalidateAffectedFiles);
67
- },
68
- load: {
69
- order: "pre",
70
- handler(id) {
71
- let preserveSymlinks = viteConfig.resolve.preserveSymlinks, idNorm = getRealPath(id, preserveSymlinks), cleanId = getCleanId(idNorm);
72
- for (let call of mockCalls)
73
- if (!(getRealPath(call.absolutePath, preserveSymlinks) !== idNorm && call.path !== cleanId) && call.redirectPath)
74
- return this.addWatchFile(call.redirectPath), readFileSync(call.redirectPath, "utf-8");
75
- return null;
76
- }
77
- },
78
- transform: {
79
- order: "pre",
80
- handler(code, id) {
81
- for (let call of mockCalls) {
82
- let preserveSymlinks = viteConfig.resolve.preserveSymlinks, idNorm = getRealPath(id, preserveSymlinks), callNorm = getRealPath(call.absolutePath, preserveSymlinks);
83
- if (viteConfig.command !== "serve") {
84
- if (callNorm !== idNorm)
85
- continue;
86
- } else {
87
- let cleanId = getCleanId(idNorm);
88
- if (call.path !== cleanId && callNorm !== idNorm)
89
- continue;
90
- }
91
- try {
92
- if (!call.redirectPath) {
93
- let automockedCode = getAutomockCode(code, call.spy, babelParser);
94
- return {
95
- code: automockedCode.toString(),
96
- map: automockedCode.generateMap()
97
- };
98
- }
99
- } catch (e) {
100
- return logger.error(`Error automocking ${id}: ${e}`), null;
101
- }
102
- }
103
- return null;
104
- }
105
- }
106
- },
107
- {
108
- name: "storybook:mock-loader-preview",
109
- transform(code, id) {
110
- if (id === normalizedPreviewConfigPath)
111
- try {
112
- return rewriteSbMockImportCalls(code);
113
- } catch (e) {
114
- return logger.debug(`Could not transform sb.mock(import(...)) calls in ${id}: ${e}`), null;
115
- }
116
- return null;
117
- }
118
- }
119
- ];
120
- }
121
- export {
122
- viteMockPlugin
123
- };
@@ -1,109 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- resolvePackageDir
14
- } from "./chunk-A4APXFQ2.js";
15
- import "./chunk-WA6KZQZ2.js";
16
- import {
17
- require_dist
18
- } from "./chunk-DUXPWBOK.js";
19
- import {
20
- __toESM
21
- } from "./chunk-OP3INKUD.js";
22
-
23
- // src/core-server/presets/vitePlugins/vite-inject-mocker/plugin.ts
24
- import { readFileSync } from "node:fs";
25
- import { join } from "node:path";
26
- import { fileURLToPath } from "node:url";
27
-
28
- // ../node_modules/@rolldown/pluginutils/dist/index.js
29
- function exactRegex(str, flags) {
30
- return new RegExp(`^${escapeRegex(str)}$`, flags);
31
- }
32
- var escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
33
- function escapeRegex(str) {
34
- return str.replace(escapeRegexRE, "\\$&");
35
- }
36
-
37
- // src/core-server/presets/vitePlugins/vite-inject-mocker/plugin.ts
38
- var import_ts_dedent = __toESM(require_dist(), 1);
39
- var entryPath = "/vite-inject-mocker-entry.js", entryCode = import_ts_dedent.dedent`
40
- <script type="module" src=".${entryPath}"></script>
41
- `, server, viteInjectMockerRuntime = (options) => {
42
- let viteConfig;
43
- return {
44
- name: "vite:storybook-inject-mocker-runtime",
45
- buildStart() {
46
- viteConfig.command === "build" && this.emitFile({
47
- type: "chunk",
48
- id: join(
49
- resolvePackageDir("storybook"),
50
- "assets",
51
- "server",
52
- "mocker-runtime.template.js"
53
- ),
54
- fileName: entryPath.slice(1)
55
- });
56
- },
57
- config() {
58
- return {
59
- optimizeDeps: {
60
- include: ["@vitest/mocker", "@vitest/mocker/browser"]
61
- },
62
- resolve: {
63
- // Aliasing necessary for package managers like pnpm, since resolving modules from a virtual module
64
- // leads to errors, if the imported module is not a dependency of the project.
65
- // By resolving the module to the real path, we can avoid this issue.
66
- alias: {
67
- "@vitest/mocker/browser": fileURLToPath(import.meta.resolve("@vitest/mocker/browser")),
68
- "@vitest/mocker": fileURLToPath(import.meta.resolve("@vitest/mocker"))
69
- }
70
- }
71
- };
72
- },
73
- configResolved(config) {
74
- viteConfig = config;
75
- },
76
- configureServer(server_) {
77
- server = server_, options.previewConfigPath && server.watcher.on("change", (file) => {
78
- file === options.previewConfigPath && server.ws.send({
79
- type: "custom",
80
- event: "invalidate-mocker"
81
- });
82
- });
83
- },
84
- resolveId: {
85
- filter: {
86
- id: [exactRegex(entryPath)]
87
- },
88
- handler(id) {
89
- return exactRegex(id).test(entryPath) ? id : null;
90
- }
91
- },
92
- async load(id) {
93
- return exactRegex(id).test(entryPath) ? readFileSync(
94
- join(resolvePackageDir("storybook"), "assets", "server", "mocker-runtime.template.js"),
95
- "utf-8"
96
- ) : null;
97
- },
98
- transformIndexHtml(html) {
99
- let headTag = html.match(/<head[^>]*>/);
100
- if (headTag) {
101
- let headTagIndex = html.indexOf(headTag[0]);
102
- return html.slice(0, headTagIndex + headTag[0].length) + entryCode + html.slice(headTagIndex + headTag[0].length);
103
- }
104
- }
105
- };
106
- };
107
- export {
108
- viteInjectMockerRuntime
109
- };