@storybook/nextjs 9.2.0-alpha.3 → 10.0.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 (85) hide show
  1. package/README.md +3 -1
  2. package/dist/_browser-chunks/chunk-I5RFHXDS.js +40 -0
  3. package/dist/_browser-chunks/chunk-JOMP7DUK.js +261 -0
  4. package/dist/_browser-chunks/chunk-L5NVL7MD.js +37 -0
  5. package/dist/_browser-chunks/react-18-G7Q4PNHD.js +71 -0
  6. package/dist/_node-chunks/chunk-254AWWVV.js +95 -0
  7. package/dist/_node-chunks/chunk-4Q3WLK5D.js +167 -0
  8. package/dist/_node-chunks/chunk-DF7TGUJT.js +17 -0
  9. package/dist/_node-chunks/chunk-N47GZ6ZF.js +74 -0
  10. package/dist/_node-chunks/configureNextFont-YCA4Y2MY.js +36 -0
  11. package/dist/_node-chunks/loader-BMOR26K7.js +64 -0
  12. package/dist/_node-chunks/loader-W6JNOWKU.js +51 -0
  13. package/dist/_node-chunks/utils-TOBNY3XG.js +31 -0
  14. package/dist/_node-chunks/webpack-422IPQRP.js +38 -0
  15. package/dist/_node-chunks/webpack-7CTFG24J.js +107 -0
  16. package/dist/_node-chunks/webpack-AGJ2TY75.js +29 -0
  17. package/dist/_node-chunks/webpack-E2SJEFJM.js +27 -0
  18. package/dist/_node-chunks/webpack-GIA2WMBH.js +77 -0
  19. package/dist/_node-chunks/webpack-MCDIAAFL.js +43 -0
  20. package/dist/_node-chunks/webpack-UPXNFNSK.js +26 -0
  21. package/dist/_node-chunks/webpack-WWJ5TQDG.js +30 -0
  22. package/dist/compatibility/draft-mode.compat.js +7 -1
  23. package/dist/export-mocks/cache/index.d.ts +309 -1
  24. package/dist/export-mocks/cache/index.js +22 -1
  25. package/dist/export-mocks/headers/index.d.ts +309 -1
  26. package/dist/export-mocks/headers/index.js +77 -1
  27. package/dist/export-mocks/index.js +20 -1
  28. package/dist/export-mocks/navigation/index.js +88 -1
  29. package/dist/export-mocks/router/index.d.ts +2 -2
  30. package/dist/export-mocks/router/index.js +97 -1
  31. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +201 -14
  32. package/dist/image-context.js +8 -1
  33. package/dist/images/next-image.js +35 -1
  34. package/dist/images/next-legacy-image.js +21 -1
  35. package/dist/index.d.ts +53 -8
  36. package/dist/index.js +20237 -45
  37. package/dist/next-image-loader-stub.js +33 -1
  38. package/dist/node/index.d.ts +27 -6
  39. package/dist/node/index.js +23 -1
  40. package/dist/preset.js +830 -1
  41. package/dist/preview.d.ts +3 -18
  42. package/dist/preview.d.tsx +18 -0
  43. package/dist/preview.js +11 -1
  44. package/dist/rsc/server-only.js +7 -1
  45. package/dist/swc/next-swc-loader-patch.js +136 -1
  46. package/package.json +41 -122
  47. package/preset.js +1 -1
  48. package/template/cli/js/Configure.mdx +11 -11
  49. package/template/cli/ts/Configure.mdx +11 -11
  50. package/dist/chunk-2TZKD6A5.mjs +0 -20
  51. package/dist/chunk-ETFXNGLC.mjs +0 -3
  52. package/dist/chunk-L66KIASX.mjs +0 -3
  53. package/dist/chunk-NQ32RFK2.mjs +0 -6
  54. package/dist/compatibility/draft-mode.compat.d.ts +0 -1
  55. package/dist/compatibility/draft-mode.compat.mjs +0 -2
  56. package/dist/export-mocks/cache/index.mjs +0 -10
  57. package/dist/export-mocks/headers/index.mjs +0 -12
  58. package/dist/export-mocks/index.d.ts +0 -7
  59. package/dist/export-mocks/index.mjs +0 -11
  60. package/dist/export-mocks/navigation/index.mjs +0 -11
  61. package/dist/export-mocks/router/index.mjs +0 -10
  62. package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +0 -3
  63. package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +0 -56
  64. package/dist/image-context.d.ts +0 -13
  65. package/dist/image-context.mjs +0 -6
  66. package/dist/images/decorator.d.ts +0 -6
  67. package/dist/images/decorator.js +0 -1
  68. package/dist/images/decorator.mjs +0 -2
  69. package/dist/images/next-image.d.ts +0 -28
  70. package/dist/images/next-image.mjs +0 -9
  71. package/dist/images/next-legacy-image.d.ts +0 -6
  72. package/dist/images/next-legacy-image.mjs +0 -9
  73. package/dist/index.d-ff220430.d.ts +0 -310
  74. package/dist/index.mjs +0 -58
  75. package/dist/next-image-loader-stub.d.ts +0 -10
  76. package/dist/next-image-loader-stub.mjs +0 -7
  77. package/dist/node/index.mjs +0 -5
  78. package/dist/preset.d.ts +0 -14
  79. package/dist/preview.mjs +0 -3
  80. package/dist/react-18-WSPZ3BUV.mjs +0 -7
  81. package/dist/rsc/server-only.d.ts +0 -3
  82. package/dist/rsc/server-only.mjs +0 -5
  83. package/dist/swc/next-swc-loader-patch.d.ts +0 -21
  84. package/dist/swc/next-swc-loader-patch.mjs +0 -8
  85. package/dist/types-f6ea2c09.d.ts +0 -54
@@ -1,10 +0,0 @@
1
- import { NextConfig } from 'next';
2
- import { RawLoaderDefinition } from 'webpack';
3
-
4
- interface LoaderOptions {
5
- filename: string;
6
- nextConfig: NextConfig;
7
- }
8
- declare const nextImageLoaderStub: RawLoaderDefinition<LoaderOptions>;
9
-
10
- export { nextImageLoaderStub as default };
@@ -1,7 +0,0 @@
1
- import { __commonJS } from './chunk-L66KIASX.mjs';
2
- import { imageSize } from 'image-size';
3
- import { interpolateName } from 'loader-utils';
4
-
5
- var require_next_image_loader_stub=__commonJS({"src/next-image-loader-stub.ts"(exports,module){var nextImageLoaderStub=async function(content){let{filename,nextConfig}=this.getOptions(),opts={context:this.rootContext,content},outputPath=interpolateName(this,filename.replace("[ext]",".[ext]"),opts);if(this.emitFile(outputPath,content),nextConfig.images?.disableStaticImages)return `const src = '${outputPath}'; export default src;`;let{width,height}=imageSize(content);return `export default ${JSON.stringify({src:outputPath,height,width,blurDataURL:outputPath})};`};nextImageLoaderStub.raw=!0;module.exports=nextImageLoaderStub;}});var nextImageLoaderStub = require_next_image_loader_stub();
6
-
7
- export { nextImageLoaderStub as default };
@@ -1,5 +0,0 @@
1
- import '../chunk-L66KIASX.mjs';
2
-
3
- function defineMain(config){return config}
4
-
5
- export { defineMain };
package/dist/preset.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { PresetProperty } from 'storybook/internal/types';
2
- import { S as StorybookConfig } from './types-f6ea2c09.js';
3
- import '@storybook/builder-webpack5';
4
- import '@storybook/preset-react-webpack';
5
- import 'next/image';
6
- import 'next/router';
7
-
8
- declare const addons: PresetProperty<'addons'>;
9
- declare const core: PresetProperty<'core'>;
10
- declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
11
- declare const babel: PresetProperty<'babel'>;
12
- declare const webpackFinal: StorybookConfig['webpackFinal'];
13
-
14
- export { addons, babel, core, previewAnnotations, webpackFinal };
package/dist/preview.mjs DELETED
@@ -1,3 +0,0 @@
1
- export { decorators, loaders, parameters } from './chunk-2TZKD6A5.mjs';
2
- import './chunk-NQ32RFK2.mjs';
3
- import './chunk-L66KIASX.mjs';
@@ -1,7 +0,0 @@
1
- import './chunk-L66KIASX.mjs';
2
- import * as React from 'react';
3
- import * as ReactDOM from 'react-dom/client';
4
-
5
- var nodes=new Map;function getIsReactActEnvironment(){return globalThis.IS_REACT_ACT_ENVIRONMENT}var WithCallback=({callback,children})=>{let once=React.useRef();return React.useLayoutEffect(()=>{once.current!==callback&&(once.current=callback,callback());},[callback]),children};typeof Promise.withResolvers>"u"&&(Promise.withResolvers=()=>{let resolve=null,reject=null;return {promise:new Promise((res,rej)=>{resolve=res,reject=rej;}),resolve,reject}});var renderElement=async(node,el,rootOptions)=>{let root=await getReactRoot(el,rootOptions);if(getIsReactActEnvironment()){root.render(node);return}let{promise,resolve}=Promise.withResolvers();return root.render(React.createElement(WithCallback,{callback:resolve},node)),promise},unmountElement=(el,shouldUseNewRootApi)=>{let root=nodes.get(el);root&&(root.unmount(),nodes.delete(el));},getReactRoot=async(el,rootOptions)=>{let root=nodes.get(el);return root||(root=ReactDOM.createRoot(el,rootOptions),nodes.set(el,root)),root};
6
-
7
- export { renderElement, unmountElement };
@@ -1,3 +0,0 @@
1
- declare const _default: {};
2
-
3
- export { _default as default };
@@ -1,5 +0,0 @@
1
- import '../chunk-L66KIASX.mjs';
2
-
3
- var server_only_default={};
4
-
5
- export { server_only_default as default };
@@ -1,21 +0,0 @@
1
- import { NextConfig } from 'next';
2
-
3
- interface SWCLoaderOptions {
4
- rootDir: string;
5
- isServer: boolean;
6
- pagesDir?: string;
7
- appDir?: string;
8
- hasReactRefresh: boolean;
9
- optimizeServerReact?: boolean;
10
- nextConfig: NextConfig;
11
- jsConfig: any;
12
- supportedBrowsers: string[] | undefined;
13
- swcCacheDir: string;
14
- serverComponents?: boolean;
15
- isReactServerLayer?: boolean;
16
- }
17
- declare function pitch(this: any): void;
18
- declare function swcLoader(this: any, inputSource: string, inputSourceMap: any): void;
19
- declare const raw = true;
20
-
21
- export { SWCLoaderOptions, swcLoader as default, pitch, raw };
@@ -1,8 +0,0 @@
1
- import '../chunk-L66KIASX.mjs';
2
- import { isAbsolute, relative } from 'node:path';
3
- import { isWasm, transform } from 'next/dist/build/swc';
4
- import { getLoaderSWCOptions } from 'next/dist/build/swc/options';
5
-
6
- var mockCurrentTraceSpan={traceChild:name=>mockCurrentTraceSpan,traceAsyncFn:async fn=>fn()};async function loaderTransform(parentTrace,source,inputSourceMap){let filename=this.resourcePath,loaderOptions=this.getOptions()||{},{isServer,rootDir,pagesDir,appDir,hasReactRefresh,nextConfig,jsConfig,supportedBrowsers,swcCacheDir,serverComponents,isReactServerLayer}=loaderOptions,isPageFile=filename.startsWith(pagesDir),relativeFilePathFromRoot=relative(rootDir,filename),programmaticOptions={...getLoaderSWCOptions({pagesDir,appDir,filename,isServer,isPageFile,development:this.mode==="development",hasReactRefresh,modularizeImports:nextConfig?.modularizeImports,optimizePackageImports:nextConfig?.experimental?.optimizePackageImports,swcPlugins:nextConfig?.experimental?.swcPlugins,compilerOptions:nextConfig?.compiler,optimizeServerReact:nextConfig?.experimental?.optimizeServerReact,jsConfig,supportedBrowsers,swcCacheDir,relativeFilePathFromRoot,serverComponents,isReactServerLayer}),filename,inputSourceMap:inputSourceMap&&typeof inputSourceMap=="object"?JSON.stringify(inputSourceMap):void 0,sourceMaps:this.sourceMap,inlineSourcesContent:this.sourceMap,sourceFileName:filename};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(()=>transform(source,programmaticOptions).then(output=>{if(output.eliminatedPackages&&this.eliminatedPackages)for(let pkg of JSON.parse(output.eliminatedPackages))this.eliminatedPackages.add(pkg);return [output.code,output.map?JSON.parse(output.map):void 0]}))}var EXCLUDED_PATHS=/[\\/](cache[\\/][^\\/]+\.zip[\\/]node_modules|__virtual__)[\\/]/g;function pitch(){let callback=this.async();(async()=>{if(!process.versions.pnp&&!EXCLUDED_PATHS.test(this.resourcePath)&&this.loaders.length-1===this.loaderIndex&&isAbsolute(this.resourcePath)&&!await isWasm()){let loaderSpan=mockCurrentTraceSpan.traceChild("next-swc-loader");return this.addDependency(this.resourcePath),loaderSpan.traceAsyncFn(()=>loaderTransform.call(this,loaderSpan))}return null})().then(r=>r?callback(null,...r):(callback(),null),callback);}function swcLoader(inputSource,inputSourceMap){let loaderSpan=mockCurrentTraceSpan.traceChild("next-swc-loader"),callback=this.async();loaderSpan.traceAsyncFn(()=>loaderTransform.call(this,loaderSpan,inputSource,inputSourceMap)).then(([transformedSource,outputSourceMap])=>{callback(null,transformedSource,outputSourceMap||inputSourceMap);},err=>{callback(err);});}var raw=!0;
7
-
8
- export { swcLoader as default, pitch, raw };
@@ -1,54 +0,0 @@
1
- import { CompatibleString } from 'storybook/internal/types';
2
- import { BuilderOptions, StorybookConfigWebpack, TypescriptOptions } from '@storybook/builder-webpack5';
3
- import { ReactOptions, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1 } from '@storybook/preset-react-webpack';
4
- import * as _NextImage from 'next/image';
5
- import { NextRouter } from 'next/router';
6
-
7
- type FrameworkName = CompatibleString<'@storybook/nextjs'>;
8
- type BuilderName = CompatibleString<'@storybook/builder-webpack5'>;
9
- type FrameworkOptions = ReactOptions & {
10
- nextConfigPath?: string;
11
- image?: Partial<_NextImage.ImageProps>;
12
- builder?: BuilderOptions;
13
- };
14
- type StorybookConfigFramework = {
15
- framework: FrameworkName | {
16
- name: FrameworkName;
17
- options: FrameworkOptions;
18
- };
19
- core?: StorybookConfig$1['core'] & {
20
- builder?: BuilderName | {
21
- name: BuilderName;
22
- options: BuilderOptions;
23
- };
24
- };
25
- typescript?: Partial<TypescriptOptions & TypescriptOptions$1> & StorybookConfig$1['typescript'];
26
- };
27
- /** The interface for Storybook configuration in `main.ts` files. */
28
- type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
29
- interface NextJsParameters {
30
- /**
31
- * Next.js framework configuration
32
- *
33
- * @see https://storybook.js.org/docs/get-started/frameworks/nextjs
34
- */
35
- nextjs?: {
36
- /**
37
- * Enable App Directory features If your story imports components that use next/navigation, you
38
- * need to set this parameter to true
39
- */
40
- appDirectory?: boolean;
41
- /**
42
- * Next.js navigation configuration when using `next/navigation`. Please note that it can only
43
- * be used in components/pages in the app directory.
44
- */
45
- navigation?: Partial<NextRouter>;
46
- /** Next.js router configuration */
47
- router?: Partial<NextRouter>;
48
- };
49
- }
50
- interface NextJsTypes {
51
- parameters: NextJsParameters;
52
- }
53
-
54
- export { FrameworkOptions as F, NextJsTypes as N, StorybookConfig as S, NextJsParameters as a };