@storybook/nextjs 9.1.10 → 9.1.12
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.
- package/dist/chunk-XP5HYGXS.mjs +3 -0
- package/dist/compatibility/draft-mode.compat.js +10 -1
- package/dist/compatibility/draft-mode.compat.mjs +1 -1
- package/dist/config/preview.d.ts +2 -0
- package/dist/config/preview.js +5 -0
- package/dist/config/preview.mjs +3 -0
- package/dist/export-mocks/cache/index.js +21 -1
- package/dist/export-mocks/cache/index.mjs +1 -1
- package/dist/export-mocks/headers/index.js +40 -1
- package/dist/export-mocks/headers/index.mjs +1 -1
- package/dist/export-mocks/index.js +16 -1
- package/dist/export-mocks/navigation/index.js +48 -1
- package/dist/export-mocks/navigation/index.mjs +1 -1
- package/dist/export-mocks/router/index.js +41 -1
- package/dist/export-mocks/router/index.mjs +1 -1
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +24 -6
- package/dist/image-context.js +7 -1
- package/dist/image-context.mjs +1 -1
- package/dist/images/decorator.js +28 -1
- package/dist/images/decorator.mjs +1 -1
- package/dist/images/next-image.js +35 -1
- package/dist/images/next-image.mjs +1 -1
- package/dist/images/next-legacy-image.js +14 -1
- package/dist/images/next-legacy-image.mjs +1 -1
- package/dist/index.d.ts +53 -8
- package/dist/index.js +84 -26
- package/dist/index.mjs +19 -8
- package/dist/next-image-loader-stub.js +8 -1
- package/dist/next-image-loader-stub.mjs +1 -1
- package/dist/node/index.js +5 -1
- package/dist/preset.js +38 -1
- package/dist/preview.js +44 -1
- package/dist/preview.mjs +18 -3
- package/dist/{react-18-WSPZ3BUV.mjs → react-18-IGIL3GJQ.mjs} +1 -1
- package/dist/rsc/server-only.js +5 -1
- package/dist/swc/next-swc-loader-patch.js +13 -1
- package/package.json +23 -16
- package/dist/chunk-2TZKD6A5.mjs +0 -20
- package/dist/chunk-L66KIASX.mjs +0 -3
- package/dist/export-mocks/index.d.ts +0 -7
- package/dist/export-mocks/index.mjs +0 -11
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +0 -3
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +0 -56
- package/dist/node/index.d.ts +0 -10
- package/dist/node/index.mjs +0 -5
- package/dist/preset.d.ts +0 -14
- package/dist/rsc/server-only.d.ts +0 -3
- package/dist/rsc/server-only.mjs +0 -5
- package/dist/swc/next-swc-loader-patch.d.ts +0 -21
- package/dist/swc/next-swc-loader-patch.mjs +0 -8
- package/dist/types-f6ea2c09.d.ts +0 -54
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import '../../../chunk-L66KIASX.mjs';
|
|
2
|
-
import { dirname, join, sep } from 'node:path';
|
|
3
|
-
import { GoogleFontsDownloadError, GoogleFontsLoadingError } from 'storybook/internal/server-errors';
|
|
4
|
-
import { fetchCSSFromGoogleFonts } from 'next/dist/compiled/@next/font/dist/google/fetch-css-from-google-fonts';
|
|
5
|
-
import { getFontAxes } from 'next/dist/compiled/@next/font/dist/google/get-font-axes';
|
|
6
|
-
import { getGoogleFontsUrl } from 'next/dist/compiled/@next/font/dist/google/get-google-fonts-url';
|
|
7
|
-
import { validateGoogleFontFunctionCall } from 'next/dist/compiled/@next/font/dist/google/validate-google-font-function-call';
|
|
8
|
-
import loaderUtils from 'next/dist/compiled/loader-utils3';
|
|
9
|
-
import { getProjectRoot } from 'storybook/internal/common';
|
|
10
|
-
import { validateLocalFontFunctionCall } from 'next/dist/compiled/@next/font/dist/local/validate-local-font-function-call';
|
|
11
|
-
|
|
12
|
-
var cssCache=new Map;async function getFontFaceDeclarations(options){let{fontFamily,weights,styles,selectedVariableAxes,display,variable}=validateGoogleFontFunctionCall(options.fontFamily,options.props),fontAxes=getFontAxes(fontFamily,weights,styles,selectedVariableAxes),url=getGoogleFontsUrl(fontFamily,fontAxes,display);try{let hasCachedCSS=cssCache.has(url),fontFaceCSS=hasCachedCSS?cssCache.get(url):await fetchCSSFromGoogleFonts(url,fontFamily,!0).catch(()=>null);if(hasCachedCSS?cssCache.delete(url):cssCache.set(url,fontFaceCSS),fontFaceCSS===null)throw new GoogleFontsDownloadError({fontFamily,url});return {id:loaderUtils.getHashDigest(url,"md5","hex",6),fontFamily,fontFaceCSS,weights,styles,variable}}catch(error){throw new GoogleFontsLoadingError({error,url})}}async function getFontFaceDeclarations2(options,rootContext,swcMode){let localFontSrc=options.props.src,parentFolder=swcMode?dirname(join(getProjectRoot(),options.filename)).replace(rootContext,""):dirname(options.filename).replace(rootContext,""),{weight,style,variable,declarations=[]}=validateLocalFontFunctionCall("",options.props),id=`font-${loaderUtils.getHashDigest(Buffer.from(JSON.stringify(localFontSrc)),"md5","hex",6)}`,fontDeclarations=declarations.map(({prop,value})=>`${prop}: ${value};`).join(`
|
|
13
|
-
`);return {id,fontFamily:id,fontFaceCSS:(()=>{if(typeof localFontSrc=="string"){let localFontPath=join(parentFolder,localFontSrc).replaceAll("\\","/");return `@font-face {
|
|
14
|
-
font-family: ${id};
|
|
15
|
-
src: url(.${localFontPath});
|
|
16
|
-
${fontDeclarations}
|
|
17
|
-
}`}return localFontSrc.map(font=>{let localFontPath=join(parentFolder,font.path).replaceAll("\\","/");return `@font-face {
|
|
18
|
-
font-family: ${id};
|
|
19
|
-
src: url(.${localFontPath});
|
|
20
|
-
${font.weight?`font-weight: ${font.weight};`:""}
|
|
21
|
-
${font.style?`font-style: ${font.style};`:""}
|
|
22
|
-
${fontDeclarations}
|
|
23
|
-
}`}).join("")})(),weights:weight?[weight]:[],styles:style?[style]:[],variable}}function getCSSMeta(options){let className=getClassName(options),style=getStylesObj(options),variableClassName=`__variable_${className}`,classNamesCSS=`
|
|
24
|
-
.${className} {
|
|
25
|
-
font-family: ${options.fontFamily};
|
|
26
|
-
${isNextCSSPropertyValid(options.styles)?`font-style: ${options.styles[0]};`:""}
|
|
27
|
-
${isNextCSSPropertyValid(options.weights)?`font-weight: ${options.weights[0]};`:""}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
${options.variable?`.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }`:""}
|
|
31
|
-
`,fontFaceCSS=`${changeFontDisplayToSwap(options.fontFaceCSS)}`;return {className,fontFaceCSS,classNamesCSS,style,...options.variable?{variableClassName}:{}}}function getClassName({styles,weights,fontFamily}){let font=fontFamily.replaceAll(" ","-").toLowerCase(),style=isNextCSSPropertyValid(styles)?styles[0]:null,weight=isNextCSSPropertyValid(weights)?weights[0]:null;return `${font}${style?`-${style}`:""}${weight?`-${weight}`:""}`}function getStylesObj({styles,weights,fontFamily}){return {fontFamily,...isNextCSSPropertyValid(styles)?{fontStyle:styles[0]}:{},...isNextCSSPropertyValid(weights)?{fontWeight:weights[0]}:{}}}function isNextCSSPropertyValid(prop){return prop.length===1&&prop[0]!=="variable"}function changeFontDisplayToSwap(css){return css.replaceAll("font-display: optional;","font-display: block;")}function setFontDeclarationsInHead({id,fontFaceCSS,classNamesCSS}){return `
|
|
32
|
-
if (!document.getElementById('id-${id}')) {
|
|
33
|
-
const fontDeclarations = \`${fontFaceCSS}\`;
|
|
34
|
-
const style = document.createElement('style');
|
|
35
|
-
style.setAttribute('id', 'font-face-${id}');
|
|
36
|
-
style.innerHTML = fontDeclarations;
|
|
37
|
-
document.head.appendChild(style);
|
|
38
|
-
|
|
39
|
-
const classNamesCSS = \`${classNamesCSS}\`;
|
|
40
|
-
const classNamesStyle = document.createElement('style');
|
|
41
|
-
classNamesStyle.setAttribute('id', 'classnames-${id}');
|
|
42
|
-
classNamesStyle.innerHTML = classNamesCSS;
|
|
43
|
-
document.head.appendChild(classNamesStyle);
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
`}async function storybookNextjsFontLoader(){let loaderOptions=this.getOptions(),swcMode=!1,options;if(Object.keys(loaderOptions).length>0)options=loaderOptions;else {let importQuery=JSON.parse(this.resourceQuery.slice(1));swcMode=!0,options={filename:importQuery.path,fontFamily:importQuery.import,props:importQuery.arguments[0],source:this.context.replace(this.rootContext,"")};}let rootCtx=this.rootContext,fontFaceDeclaration,pathSep=sep;if((options.source.endsWith(`next${pathSep}font${pathSep}google`)||options.source.endsWith(`@next${pathSep}font${pathSep}google`))&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),(options.source.endsWith(`next${pathSep}font${pathSep}local`)||options.source.endsWith(`@next${pathSep}font${pathSep}local`))&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx,swcMode)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return `
|
|
47
|
-
${setFontDeclarationsInHead({fontFaceCSS:cssMeta.fontFaceCSS,id:fontFaceDeclaration.id,classNamesCSS:cssMeta.classNamesCSS})}
|
|
48
|
-
|
|
49
|
-
module.exports = {
|
|
50
|
-
className: "${cssMeta.className}",
|
|
51
|
-
style: ${JSON.stringify(cssMeta.style)}
|
|
52
|
-
${cssMeta.variableClassName?`, variable: "${cssMeta.variableClassName}"`:""}
|
|
53
|
-
}
|
|
54
|
-
`}return "module.exports = {}"}
|
|
55
|
-
|
|
56
|
-
export { storybookNextjsFontLoader as default };
|
package/dist/node/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { S as StorybookConfig } from '../types-f6ea2c09.js';
|
|
2
|
-
import 'storybook/internal/types';
|
|
3
|
-
import '@storybook/builder-webpack5';
|
|
4
|
-
import '@storybook/preset-react-webpack';
|
|
5
|
-
import 'next/image';
|
|
6
|
-
import 'next/router';
|
|
7
|
-
|
|
8
|
-
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
|
9
|
-
|
|
10
|
-
export { defineMain };
|
package/dist/node/index.mjs
DELETED
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/rsc/server-only.mjs
DELETED
|
@@ -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 };
|
package/dist/types-f6ea2c09.d.ts
DELETED
|
@@ -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 };
|