@storybook/nextjs 10.1.0-alpha.9 → 10.1.0-beta.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 (51) hide show
  1. package/dist/_browser-chunks/{chunk-KX5HHFXV.js → chunk-2SBZPHE7.js} +50 -100
  2. package/dist/_browser-chunks/chunk-RDMFII4N.js +22 -0
  3. package/dist/_browser-chunks/{chunk-L5NVL7MD.js → chunk-SL3VIQZ3.js} +7 -13
  4. package/dist/_browser-chunks/react-18-PYSEDAWB.js +43 -0
  5. package/dist/_node-chunks/chunk-FDQCPWTU.js +76 -0
  6. package/dist/_node-chunks/chunk-FG42E7V6.js +57 -0
  7. package/dist/_node-chunks/chunk-GP2MEE4L.js +211 -0
  8. package/dist/_node-chunks/configureNextFont-C7CJ3HQC.js +28 -0
  9. package/dist/_node-chunks/{loader-7OJQICYP.js → loader-5F2KS4LJ.js} +15 -25
  10. package/dist/_node-chunks/{loader-OFLGZQCU.js → loader-MSHAULDY.js} +11 -16
  11. package/dist/_node-chunks/{utils-NVB3HGRH.js → utils-CTOPCADU.js} +8 -9
  12. package/dist/_node-chunks/webpack-2BV2ZM4Y.js +23 -0
  13. package/dist/_node-chunks/{webpack-E2OB2ZPW.js → webpack-552M7BUF.js} +13 -19
  14. package/dist/_node-chunks/webpack-L7NHDPNJ.js +30 -0
  15. package/dist/_node-chunks/{webpack-VD3FKUZZ.js → webpack-MROJ5SGY.js} +9 -12
  16. package/dist/_node-chunks/webpack-OJMVAOEH.js +24 -0
  17. package/dist/_node-chunks/webpack-UVPHU4VM.js +23 -0
  18. package/dist/_node-chunks/webpack-VOQXZA35.js +60 -0
  19. package/dist/_node-chunks/webpack-WG2HZDLK.js +97 -0
  20. package/dist/compatibility/draft-mode.compat.js +1 -1
  21. package/dist/export-mocks/cache/index.js +3 -6
  22. package/dist/export-mocks/headers/index.js +6 -29
  23. package/dist/export-mocks/index.js +9 -10
  24. package/dist/export-mocks/navigation/index.js +17 -41
  25. package/dist/export-mocks/router/index.d.ts +4 -7
  26. package/dist/export-mocks/router/index.js +20 -54
  27. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +38 -80
  28. package/dist/image-context.js +1 -1
  29. package/dist/images/next-image.js +5 -11
  30. package/dist/images/next-legacy-image.js +3 -6
  31. package/dist/index.js +2865 -8413
  32. package/dist/next-image-loader-stub.js +9 -16
  33. package/dist/node/index.js +6 -10
  34. package/dist/preset.js +183 -462
  35. package/dist/preview.js +2 -2
  36. package/dist/rsc/server-only.js +1 -1
  37. package/dist/swc/next-swc-loader-patch.js +46 -84
  38. package/package.json +6 -6
  39. package/dist/_browser-chunks/chunk-I5RFHXDS.js +0 -40
  40. package/dist/_browser-chunks/react-18-G7Q4PNHD.js +0 -71
  41. package/dist/_node-chunks/chunk-PWZWGY6W.js +0 -17
  42. package/dist/_node-chunks/chunk-UHO3ELD2.js +0 -475
  43. package/dist/_node-chunks/chunk-WR63XCFA.js +0 -74
  44. package/dist/_node-chunks/chunk-X47EC6DB.js +0 -102
  45. package/dist/_node-chunks/configureNextFont-ZL3UHKQ4.js +0 -36
  46. package/dist/_node-chunks/webpack-3J2WBZ2E.js +0 -30
  47. package/dist/_node-chunks/webpack-7PUWUCNJ.js +0 -27
  48. package/dist/_node-chunks/webpack-JVSODHFI.js +0 -38
  49. package/dist/_node-chunks/webpack-O36IRAFL.js +0 -77
  50. package/dist/_node-chunks/webpack-SNP77BVT.js +0 -107
  51. package/dist/_node-chunks/webpack-THQBX5DA.js +0 -26
package/dist/preview.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  decorators,
3
3
  loaders,
4
4
  parameters
5
- } from "./_browser-chunks/chunk-KX5HHFXV.js";
6
- import "./_browser-chunks/chunk-L5NVL7MD.js";
5
+ } from "./_browser-chunks/chunk-2SBZPHE7.js";
6
+ import "./_browser-chunks/chunk-SL3VIQZ3.js";
7
7
  export {
8
8
  decorators,
9
9
  loaders,
@@ -1,4 +1,4 @@
1
- import "../_browser-chunks/chunk-L5NVL7MD.js";
1
+ import "../_browser-chunks/chunk-SL3VIQZ3.js";
2
2
 
3
3
  // src/rsc/server-only.ts
4
4
  var server_only_default = {};
@@ -1,30 +1,25 @@
1
- import CJS_COMPAT_NODE_URL_mt98813ktw from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_mt98813ktw from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_mt98813ktw from "node:module";
1
+ import CJS_COMPAT_NODE_URL_irqg4lxu6e from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_irqg4lxu6e from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_irqg4lxu6e from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_mt98813ktw.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_mt98813ktw.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_mt98813ktw.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_irqg4lxu6e.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_irqg4lxu6e.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_irqg4lxu6e.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
- __name
14
- } from "../_node-chunks/chunk-PWZWGY6W.js";
15
12
 
16
13
  // src/swc/next-swc-loader-patch.ts
17
14
  import { isAbsolute, relative } from "node:path";
18
15
  import * as nextSwcUtils from "next/dist/build/swc/index.js";
19
16
  import { getLoaderSWCOptions } from "next/dist/build/swc/options.js";
20
17
  var mockCurrentTraceSpan = {
21
- traceChild: /* @__PURE__ */ __name((name) => mockCurrentTraceSpan, "traceChild"),
22
- traceAsyncFn: /* @__PURE__ */ __name(async (fn) => fn(), "traceAsyncFn")
18
+ traceChild: (name) => mockCurrentTraceSpan,
19
+ traceAsyncFn: async (fn) => fn()
23
20
  };
24
21
  async function loaderTransform(parentTrace, source, inputSourceMap) {
25
- const filename = this.resourcePath;
26
- const loaderOptions = this.getOptions() || {};
27
- const {
22
+ let filename = this.resourcePath, loaderOptions = this.getOptions() || {}, {
28
23
  isServer,
29
24
  rootDir,
30
25
  pagesDir,
@@ -36,35 +31,31 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
36
31
  swcCacheDir,
37
32
  serverComponents,
38
33
  isReactServerLayer
39
- } = loaderOptions;
40
- const isPageFile = filename.startsWith(pagesDir);
41
- const relativeFilePathFromRoot = relative(rootDir, filename);
42
- const swcOptions = getLoaderSWCOptions({
43
- pagesDir,
44
- appDir,
34
+ } = loaderOptions, isPageFile = filename.startsWith(pagesDir), relativeFilePathFromRoot = relative(rootDir, filename), programmaticOptions = {
35
+ ...getLoaderSWCOptions({
36
+ pagesDir,
37
+ appDir,
38
+ filename,
39
+ isServer,
40
+ isPageFile,
41
+ development: this.mode === "development",
42
+ hasReactRefresh,
43
+ modularizeImports: nextConfig?.modularizeImports,
44
+ optimizePackageImports: nextConfig?.experimental?.optimizePackageImports,
45
+ swcPlugins: nextConfig?.experimental?.swcPlugins,
46
+ compilerOptions: nextConfig?.compiler,
47
+ optimizeServerReact: nextConfig?.experimental?.optimizeServerReact,
48
+ jsConfig,
49
+ supportedBrowsers,
50
+ swcCacheDir,
51
+ relativeFilePathFromRoot,
52
+ serverComponents,
53
+ // @ts-expect-error Relevant for Next.js < 14.1
54
+ // TODO: Remove this when Next.js < 14.1 is no longer supported
55
+ isReactServerLayer
56
+ }),
45
57
  filename,
46
- isServer,
47
- isPageFile,
48
- development: this.mode === "development",
49
- hasReactRefresh,
50
- modularizeImports: nextConfig?.modularizeImports,
51
- optimizePackageImports: nextConfig?.experimental?.optimizePackageImports,
52
- swcPlugins: nextConfig?.experimental?.swcPlugins,
53
- compilerOptions: nextConfig?.compiler,
54
- optimizeServerReact: nextConfig?.experimental?.optimizeServerReact,
55
- jsConfig,
56
- supportedBrowsers,
57
- swcCacheDir,
58
- relativeFilePathFromRoot,
59
- serverComponents,
60
- // @ts-expect-error Relevant for Next.js < 14.1
61
- // TODO: Remove this when Next.js < 14.1 is no longer supported
62
- isReactServerLayer
63
- });
64
- const programmaticOptions = {
65
- ...swcOptions,
66
- filename,
67
- inputSourceMap: inputSourceMap && typeof inputSourceMap === "object" ? JSON.stringify(inputSourceMap) : void 0,
58
+ inputSourceMap: inputSourceMap && typeof inputSourceMap == "object" ? JSON.stringify(inputSourceMap) : void 0,
68
59
  // Set the default sourcemap behavior based on Webpack's mapping flag,
69
60
  sourceMaps: this.sourceMap,
70
61
  inlineSourcesContent: this.sourceMap,
@@ -73,59 +64,31 @@ async function loaderTransform(parentTrace, source, inputSourceMap) {
73
64
  // modules.
74
65
  sourceFileName: filename
75
66
  };
76
- programmaticOptions.env.bugfixes = true;
77
- if (!programmaticOptions.inputSourceMap) {
78
- delete programmaticOptions.inputSourceMap;
79
- }
80
- if (this.mode && programmaticOptions.jsc && programmaticOptions.jsc.transform && programmaticOptions.jsc.transform.react && !Object.prototype.hasOwnProperty.call(programmaticOptions.jsc.transform.react, "development")) {
81
- programmaticOptions.jsc.transform.react.development = this.mode === "development";
82
- }
83
- const swcSpan = parentTrace.traceChild("next-swc-transform");
84
- return swcSpan.traceAsyncFn(
67
+ return programmaticOptions.env.bugfixes = !0, programmaticOptions.inputSourceMap || delete programmaticOptions.inputSourceMap, this.mode && programmaticOptions.jsc && programmaticOptions.jsc.transform && programmaticOptions.jsc.transform.react && !Object.prototype.hasOwnProperty.call(programmaticOptions.jsc.transform.react, "development") && (programmaticOptions.jsc.transform.react.development = this.mode === "development"), parentTrace.traceChild("next-swc-transform").traceAsyncFn(
85
68
  () => nextSwcUtils.transform(source, programmaticOptions).then((output) => {
86
- if (output.eliminatedPackages && this.eliminatedPackages) {
87
- for (const pkg of JSON.parse(output.eliminatedPackages)) {
69
+ if (output.eliminatedPackages && this.eliminatedPackages)
70
+ for (let pkg of JSON.parse(output.eliminatedPackages))
88
71
  this.eliminatedPackages.add(pkg);
89
- }
90
- }
91
72
  return [output.code, output.map ? JSON.parse(output.map) : void 0];
92
73
  })
93
74
  );
94
75
  }
95
- __name(loaderTransform, "loaderTransform");
96
76
  var EXCLUDED_PATHS = /[\\/](cache[\\/][^\\/]+\.zip[\\/]node_modules|__virtual__)[\\/]/g;
97
77
  function pitch() {
98
- const callback = this.async();
78
+ let callback = this.async();
99
79
  (async () => {
100
- let isWasm2 = false;
101
- if (!!nextSwcUtils.isWasm) {
102
- isWasm2 = await nextSwcUtils.isWasm();
103
- } else if (!!nextSwcUtils.getBindingsSync) {
104
- await nextSwcUtils.loadBindings();
105
- isWasm2 = nextSwcUtils.getBindingsSync().isWasm;
106
- }
107
- if (
108
- // TODO: Evaluate if this is correct after removing pnp compatibility code in SB11
109
- // TODO: investigate swc file reading in PnP mode?
110
- !process.versions.pnp && !EXCLUDED_PATHS.test(this.resourcePath) && this.loaders.length - 1 === this.loaderIndex && isAbsolute(this.resourcePath) && !isWasm2
111
- ) {
112
- const loaderSpan = mockCurrentTraceSpan.traceChild("next-swc-loader");
113
- this.addDependency(this.resourcePath);
114
- return loaderSpan.traceAsyncFn(() => loaderTransform.call(this, loaderSpan));
115
- }
116
- return null;
117
- })().then((r) => {
118
- if (r) {
119
- return callback(null, ...r);
80
+ let isWasm2 = !1;
81
+ if (nextSwcUtils.isWasm ? isWasm2 = await nextSwcUtils.isWasm() : nextSwcUtils.getBindingsSync && (await nextSwcUtils.loadBindings(), isWasm2 = nextSwcUtils.getBindingsSync().isWasm), // TODO: Evaluate if this is correct after removing pnp compatibility code in SB11
82
+ // TODO: investigate swc file reading in PnP mode?
83
+ !process.versions.pnp && !EXCLUDED_PATHS.test(this.resourcePath) && this.loaders.length - 1 === this.loaderIndex && isAbsolute(this.resourcePath) && !isWasm2) {
84
+ let loaderSpan = mockCurrentTraceSpan.traceChild("next-swc-loader");
85
+ return this.addDependency(this.resourcePath), loaderSpan.traceAsyncFn(() => loaderTransform.call(this, loaderSpan));
120
86
  }
121
- callback();
122
87
  return null;
123
- }, callback);
88
+ })().then((r) => r ? callback(null, ...r) : (callback(), null), callback);
124
89
  }
125
- __name(pitch, "pitch");
126
90
  function swcLoader(inputSource, inputSourceMap) {
127
- const loaderSpan = mockCurrentTraceSpan.traceChild("next-swc-loader");
128
- const callback = this.async();
91
+ let loaderSpan = mockCurrentTraceSpan.traceChild("next-swc-loader"), callback = this.async();
129
92
  loaderSpan.traceAsyncFn(() => loaderTransform.call(this, loaderSpan, inputSource, inputSourceMap)).then(
130
93
  ([transformedSource, outputSourceMap]) => {
131
94
  callback(null, transformedSource, outputSourceMap || inputSourceMap);
@@ -135,8 +98,7 @@ function swcLoader(inputSource, inputSourceMap) {
135
98
  }
136
99
  );
137
100
  }
138
- __name(swcLoader, "swcLoader");
139
- var raw = true;
101
+ var raw = !0;
140
102
  export {
141
103
  swcLoader as default,
142
104
  pitch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/nextjs",
3
- "version": "10.1.0-alpha.9",
3
+ "version": "10.1.0-beta.1",
4
4
  "description": "Storybook for Next.js: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -94,9 +94,9 @@
94
94
  "@babel/preset-typescript": "^7.24.1",
95
95
  "@babel/runtime": "^7.24.4",
96
96
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
97
- "@storybook/builder-webpack5": "10.1.0-alpha.9",
98
- "@storybook/preset-react-webpack": "10.1.0-alpha.9",
99
- "@storybook/react": "10.1.0-alpha.9",
97
+ "@storybook/builder-webpack5": "10.1.0-beta.1",
98
+ "@storybook/preset-react-webpack": "10.1.0-beta.1",
99
+ "@storybook/react": "10.1.0-beta.1",
100
100
  "@types/semver": "^7.3.4",
101
101
  "babel-loader": "^9.1.3",
102
102
  "css-loader": "^6.7.3",
@@ -130,7 +130,7 @@
130
130
  "next": "^14.1.0 || ^15.0.0 || ^16.0.0",
131
131
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
132
132
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
133
- "storybook": "^10.1.0-alpha.9",
133
+ "storybook": "^10.1.0-beta.1",
134
134
  "webpack": "^5.0.0"
135
135
  },
136
136
  "peerDependenciesMeta": {
@@ -144,5 +144,5 @@
144
144
  "publishConfig": {
145
145
  "access": "public"
146
146
  },
147
- "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16"
147
+ "gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae1l"
148
148
  }
@@ -1,40 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-L5NVL7MD.js";
4
-
5
- // src/images/next-image-default-loader.tsx
6
- var defaultLoader = /* @__PURE__ */ __name(({ src, width, quality = 75 }) => {
7
- const missingValues = [];
8
- if (!src) {
9
- missingValues.push("src");
10
- }
11
- if (!width) {
12
- missingValues.push("width");
13
- }
14
- if (missingValues.length > 0) {
15
- throw new Error(
16
- `Next Image Optimization requires ${missingValues.join(
17
- ", "
18
- )} to be provided. Make sure you pass them as props to the \`next/image\` component. Received: ${JSON.stringify(
19
- {
20
- src,
21
- width,
22
- quality
23
- }
24
- )}`
25
- );
26
- }
27
- const url = new URL(src, window.location.href);
28
- if (!url.searchParams.has("w") && !url.searchParams.has("q")) {
29
- url.searchParams.set("w", width.toString());
30
- url.searchParams.set("q", quality.toString());
31
- }
32
- if (!src.startsWith("http://") && !src.startsWith("https://")) {
33
- return url.toString().slice(url.origin.length);
34
- }
35
- return url.toString();
36
- }, "defaultLoader");
37
-
38
- export {
39
- defaultLoader
40
- };
@@ -1,71 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-L5NVL7MD.js";
4
-
5
- // ../../lib/react-dom-shim/dist/_browser-chunks/chunk-JK72E6FR.js
6
- var __defProp = Object.defineProperty;
7
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", { value, configurable: true }), "__name");
8
-
9
- // ../../lib/react-dom-shim/dist/react-18.js
10
- import * as React from "react";
11
- import * as ReactDOM from "react-dom/client";
12
- var nodes = /* @__PURE__ */ new Map();
13
- function getIsReactActEnvironment() {
14
- return globalThis.IS_REACT_ACT_ENVIRONMENT;
15
- }
16
- __name(getIsReactActEnvironment, "getIsReactActEnvironment");
17
- __name2(getIsReactActEnvironment, "getIsReactActEnvironment");
18
- var WithCallback = __name2(({
19
- callback,
20
- children
21
- }) => {
22
- const once = React.useRef();
23
- React.useLayoutEffect(() => {
24
- if (once.current === callback) {
25
- return;
26
- }
27
- once.current = callback;
28
- callback();
29
- }, [callback]);
30
- return children;
31
- }, "WithCallback");
32
- if (typeof Promise.withResolvers === "undefined") {
33
- Promise.withResolvers = () => {
34
- let resolve = null;
35
- let reject = null;
36
- const promise = new Promise((res, rej) => {
37
- resolve = res;
38
- reject = rej;
39
- });
40
- return { promise, resolve, reject };
41
- };
42
- }
43
- var renderElement = __name2(async (node, el, rootOptions) => {
44
- const root = await getReactRoot(el, rootOptions);
45
- if (getIsReactActEnvironment()) {
46
- root.render(node);
47
- return;
48
- }
49
- const { promise, resolve } = Promise.withResolvers();
50
- root.render(React.createElement(WithCallback, { callback: resolve }, node));
51
- return promise;
52
- }, "renderElement");
53
- var unmountElement = __name2((el, shouldUseNewRootApi) => {
54
- const root = nodes.get(el);
55
- if (root) {
56
- root.unmount();
57
- nodes.delete(el);
58
- }
59
- }, "unmountElement");
60
- var getReactRoot = __name2(async (el, rootOptions) => {
61
- let root = nodes.get(el);
62
- if (!root) {
63
- root = ReactDOM.createRoot(el, rootOptions);
64
- nodes.set(el, root);
65
- }
66
- return root;
67
- }, "getReactRoot");
68
- export {
69
- renderElement,
70
- unmountElement
71
- };
@@ -1,17 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_mt98813ktw from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_mt98813ktw from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_mt98813ktw from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_mt98813ktw.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_mt98813ktw.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_mt98813ktw.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- var __defProp = Object.defineProperty;
13
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
-
15
- export {
16
- __name
17
- };