@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 +1,21 @@
1
- "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var next_legacy_image_exports={};__export(next_legacy_image_exports,{default:()=>next_legacy_image_default});module.exports=__toCommonJS(next_legacy_image_exports);var import_react=__toESM(require("react")),import_image_context=require("@storybook/nextjs/dist/image-context"),import_image=__toESM(require("sb-original/next/legacy/image"));var defaultLoader=({src,width,quality=75})=>{let missingValues=[];if(src||missingValues.push("src"),width||missingValues.push("width"),missingValues.length>0)throw new Error(`Next Image Optimization requires ${missingValues.join(", ")} to be provided. Make sure you pass them as props to the \`next/image\` component. Received: ${JSON.stringify({src,width,quality})}`);let url=new URL(src,window.location.href);return!url.searchParams.has("w")&&!url.searchParams.has("q")&&(url.searchParams.set("w",width.toString()),url.searchParams.set("q",quality.toString())),!src.startsWith("http://")&&!src.startsWith("https://")?url.toString().slice(url.origin.length):url.toString()};var ImageContext=import_image_context.ImageContext;function NextLegacyImage({loader,...props}){let imageParameters=import_react.default.useContext(ImageContext);return import_react.default.createElement(import_image.default,{...imageParameters,...props,loader:loader??defaultLoader})}var next_legacy_image_default=NextLegacyImage;
1
+ import {
2
+ defaultLoader
3
+ } from "../_browser-chunks/chunk-I5RFHXDS.js";
4
+ import {
5
+ __name
6
+ } from "../_browser-chunks/chunk-L5NVL7MD.js";
7
+
8
+ // src/images/next-legacy-image.tsx
9
+ import React from "react";
10
+ import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-context";
11
+ import OriginalNextLegacyImage from "sb-original/next/legacy/image";
12
+ var ImageContext = ImageContextValue;
13
+ function NextLegacyImage({ loader, ...props }) {
14
+ const imageParameters = React.useContext(ImageContext);
15
+ return React.createElement(OriginalNextLegacyImage, { ...imageParameters, ...props, loader: loader ?? defaultLoader });
16
+ }
17
+ __name(NextLegacyImage, "NextLegacyImage");
18
+ var next_legacy_image_default = NextLegacyImage;
19
+ export {
20
+ next_legacy_image_default as default
21
+ };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,58 @@
1
1
  import { PreviewAddon, InferTypes, AddonTypes } from 'storybook/internal/csf';
2
- import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Args, StoryAnnotationsOrFn, ProjectAnnotations, ComposedStoryFn, Store_CSFExports, StoriesWithPartialProps } from 'storybook/internal/types';
2
+ import { CompatibleString, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Args, StoryAnnotationsOrFn, ProjectAnnotations, ComposedStoryFn, Store_CSFExports, StoriesWithPartialProps } from 'storybook/internal/types';
3
3
  import { ReactRenderer, Meta, ReactTypes, ReactPreview } from '@storybook/react';
4
4
  export * from '@storybook/react';
5
- import { N as NextJsTypes } from './types-f6ea2c09.js';
6
- export { F as FrameworkOptions, a as NextJsParameters, S as StorybookConfig } from './types-f6ea2c09.js';
7
- import '@storybook/builder-webpack5';
8
- import '@storybook/preset-react-webpack';
9
- import 'next/image';
10
- import 'next/router';
5
+ import { BuilderOptions, StorybookConfigWebpack, TypescriptOptions } from '@storybook/builder-webpack5';
6
+ import { ReactOptions, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1 } from '@storybook/preset-react-webpack';
7
+ import * as NextImage from 'next/image';
8
+ import { NextRouter } from 'next/router';
9
+
10
+ type FrameworkName = CompatibleString<'@storybook/nextjs'>;
11
+ type BuilderName = CompatibleString<'@storybook/builder-webpack5'>;
12
+ type FrameworkOptions = ReactOptions & {
13
+ nextConfigPath?: string;
14
+ image?: Partial<NextImage.ImageProps>;
15
+ builder?: BuilderOptions;
16
+ };
17
+ type StorybookConfigFramework = {
18
+ framework: FrameworkName | {
19
+ name: FrameworkName;
20
+ options: FrameworkOptions;
21
+ };
22
+ core?: StorybookConfig$1['core'] & {
23
+ builder?: BuilderName | {
24
+ name: BuilderName;
25
+ options: BuilderOptions;
26
+ };
27
+ };
28
+ typescript?: Partial<TypescriptOptions & TypescriptOptions$1> & StorybookConfig$1['typescript'];
29
+ };
30
+ /** The interface for Storybook configuration in `main.ts` files. */
31
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
32
+ interface NextJsParameters {
33
+ /**
34
+ * Next.js framework configuration
35
+ *
36
+ * @see https://storybook.js.org/docs/get-started/frameworks/nextjs
37
+ */
38
+ nextjs?: {
39
+ /**
40
+ * Enable App Directory features If your story imports components that use next/navigation, you
41
+ * need to set this parameter to true
42
+ */
43
+ appDirectory?: boolean;
44
+ /**
45
+ * Next.js navigation configuration when using `next/navigation`. Please note that it can only
46
+ * be used in components/pages in the app directory.
47
+ */
48
+ navigation?: Partial<NextRouter>;
49
+ /** Next.js router configuration */
50
+ router?: Partial<NextRouter>;
51
+ };
52
+ }
53
+ interface NextJsTypes {
54
+ parameters: NextJsParameters;
55
+ }
11
56
 
12
57
  /**
13
58
  * Function that sets the globalConfig of your storybook. The global config is the preview module of
@@ -93,4 +138,4 @@ declare function definePreview<Addons extends PreviewAddon<never>[]>(preview: {
93
138
  interface NextPreview<T extends AddonTypes> extends ReactPreview<NextJsTypes & T> {
94
139
  }
95
140
 
96
- export { NextJsTypes, composeStories, composeStory, definePreview, setProjectAnnotations };
141
+ export { type FrameworkOptions, type NextJsParameters, type NextJsTypes, type StorybookConfig, composeStories, composeStory, definePreview, setProjectAnnotations };