@storybook/nextjs 7.0.7 → 7.0.8
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-YPQDI6HO.mjs +3 -1
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +14 -7
- package/dist/index.d-a81f2015.d.ts +1198 -0
- package/dist/index.mjs +1 -0
- package/dist/next-image-loader-stub.mjs +7 -1
- package/dist/preset.d.ts +9 -1067
- package/dist/preset.js +1 -1
- package/dist/preview.d.ts +5 -3
- package/dist/preview.mjs +12 -1
- package/package.json +17 -18
- package/dist/preset.mjs +0 -1
package/dist/chunk-YPQDI6HO.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};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 __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);
|
|
1
|
+
var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});var __esm=(fn,res)=>function(){return fn&&(res=(0, fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __commonJS=(cb,mod)=>function(){return mod||(0, cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};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 __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);
|
|
2
|
+
|
|
3
|
+
export { __commonJS, __esm, __export, __require, __toCommonJS };
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import{__esm,
|
|
1
|
+
import { __export, __esm, __require, __toCommonJS } from '../../../chunk-YPQDI6HO.mjs';
|
|
2
|
+
import dedent from 'ts-dedent';
|
|
3
|
+
import loaderUtils from 'next/dist/compiled/loader-utils3';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
var google_font_utils_exports={};__export(google_font_utils_exports,{fetchCSSFromGoogleFonts:()=>fetchCSSFromGoogleFonts,getFontAxes:()=>getFontAxes,getUrl:()=>getUrl,validateData:()=>validateData});var validateData,getUrl,getFontAxes,fetchCSSFromGoogleFonts,init_google_font_utils=__esm({"src/font/webpack/loader/utils/google-font-utils.ts"(){try{let fontUtils=__require("@next/font/dist/google/utils");validateData=fontUtils.validateData,getUrl=fontUtils.getUrl,getFontAxes=fontUtils.getFontAxes,fetchCSSFromGoogleFonts=fontUtils.fetchCSSFromGoogleFonts;}catch{try{let fontUtils=__require("next/dist/compiled/@next/font/dist/google/utils");validateData=fontUtils.validateData,getUrl=fontUtils.getUrl,getFontAxes=fontUtils.getFontAxes,fetchCSSFromGoogleFonts=fontUtils.fetchCSSFromGoogleFonts;}catch{try{validateData=(functionName,fontData,config)=>__require("next/dist/compiled/@next/font/dist/google/validate-google-font-function-call").validateGoogleFontFunctionCall(functionName,fontData[0],config),getUrl=__require("next/dist/compiled/@next/font/dist/google/get-google-fonts-url").getGoogleFontsUrl,getFontAxes=__require("next/dist/compiled/@next/font/dist/google/get-font-axes").getFontAxes,fetchCSSFromGoogleFonts=__require("next/dist/compiled/@next/font/dist/google/fetch-css-from-google-fonts").fetchCSSFromGoogleFonts;}catch{throw new Error(dedent`
|
|
2
7
|
We are unable to load the helper functions to use next/font/google.
|
|
3
8
|
Please downgrade Next.js to version 13.2.4 to continue to use next/font/google in Storybook.
|
|
4
9
|
Feel free to open a Github Issue!
|
|
5
|
-
`)}}}}});var local_font_utils_exports={};__export(local_font_utils_exports,{validateData:()=>validateData2});
|
|
10
|
+
`)}}}}});var local_font_utils_exports={};__export(local_font_utils_exports,{validateData:()=>validateData2});var validateData2,init_local_font_utils=__esm({"src/font/webpack/loader/utils/local-font-utils.ts"(){try{validateData2=__require("@next/font/dist/local/utils").validateData;}catch{try{validateData2=__require("next/dist/compiled/@next/font/dist/local/utils").validateData;}catch{try{validateData2=__require("next/dist/compiled/@next/font/dist/local/validate-local-font-function-call").validateLocalFontFunctionCall;}catch{throw new Error(dedent`
|
|
6
11
|
We are unable to load the helper functions to use next/font/local.
|
|
7
12
|
Please downgrade Next.js to version 13.2.4 to continue to use next/font/local in Storybook.
|
|
8
13
|
Feel free to open a Github Issue!
|
|
9
|
-
`)}}}}});
|
|
14
|
+
`)}}}}});var cssCache=new Map;async function getFontFaceDeclarations(options){let{fetchCSSFromGoogleFonts:fetchCSSFromGoogleFonts2,getFontAxes:getFontAxes2,getUrl:getUrl2,validateData:validateData3}=(init_google_font_utils(),__toCommonJS(google_font_utils_exports)),{fontFamily,weights,styles,selectedVariableAxes,display,variable}=validateData3(options.fontFamily,[options.props],null),fontAxes=getFontAxes2(fontFamily,weights,styles,selectedVariableAxes),url=getUrl2(fontFamily,fontAxes,display);try{let hasCachedCSS=cssCache.has(url),fontFaceCSS=hasCachedCSS?cssCache.get(url):await fetchCSSFromGoogleFonts2(url,fontFamily).catch(()=>null);if(hasCachedCSS?cssCache.delete(url):cssCache.set(url,fontFaceCSS),fontFaceCSS===null)throw Error(`Failed to fetch \`${fontFamily}\` from Google Fonts.`);return {id:loaderUtils.getHashDigest(url,"md5","hex",6),fontFamily,fontFaceCSS,weights,styles,variable}}catch{throw new Error("Google Fonts couldn't be loaded.")}}async function getFontFaceDeclarations2(options,rootContext){let localFontSrc=options.props.src,parentFolder=options.filename.split("/").slice(0,-1).join("/").replace(rootContext,""),{validateData:validateData3}=(init_local_font_utils(),__toCommonJS(local_font_utils_exports)),{weight,style,variable}=validateData3("",options.props),id=`font-${loaderUtils.getHashDigest(Buffer.from(JSON.stringify(localFontSrc)),"md5","hex",6)}`;return {id,fontFamily:id,fontFaceCSS:(()=>{if(typeof localFontSrc=="string"){let localFontPath=path.join(parentFolder,localFontSrc);return `@font-face {
|
|
10
15
|
font-family: ${id};
|
|
11
16
|
src: url(${localFontPath});
|
|
12
|
-
}`}return localFontSrc.map(font=>{let localFontPath=path.join(parentFolder,font.path);return`@font-face {
|
|
17
|
+
}`}return localFontSrc.map(font=>{let localFontPath=path.join(parentFolder,font.path);return `@font-face {
|
|
13
18
|
font-family: ${id};
|
|
14
19
|
src: url(${localFontPath});
|
|
15
20
|
${font.weight?`font-weight: ${font.weight};`:""}
|
|
@@ -22,7 +27,7 @@ import{__esm,__export,__require,__toCommonJS}from"../../../chunk-YPQDI6HO.mjs";v
|
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
${options.variable?`.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }`:""}
|
|
25
|
-
`,fontFaceCSS=`${changeFontDisplayToSwap(options.fontFaceCSS)}`;return{className,fontFaceCSS,classNamesCSS,style,...options.variable?{variableClassName}:{}}}function getClassName({styles,weights,fontFamily}){let font=fontFamily.replace(" ","-").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`
|
|
30
|
+
`,fontFaceCSS=`${changeFontDisplayToSwap(options.fontFaceCSS)}`;return {className,fontFaceCSS,classNamesCSS,style,...options.variable?{variableClassName}:{}}}function getClassName({styles,weights,fontFamily}){let font=fontFamily.replace(" ","-").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 `
|
|
26
31
|
if (!document.getElementById('id-${id}')) {
|
|
27
32
|
const fontDeclarations = \`${fontFaceCSS}\`;
|
|
28
33
|
const style = document.createElement('style');
|
|
@@ -37,7 +42,7 @@ import{__esm,__export,__require,__toCommonJS}from"../../../chunk-YPQDI6HO.mjs";v
|
|
|
37
42
|
document.head.appendChild(classNamesStyle);
|
|
38
43
|
|
|
39
44
|
}
|
|
40
|
-
`}async function storybookNextjsFontLoader(){let options=this.getOptions(),rootCtx=this.rootContext,fontFaceDeclaration;if((options.source==="next/font/google"||options.source==="@next/font/google")&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),(options.source==="next/font/local"||options.source==="@next/font/local")&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return`
|
|
45
|
+
`}async function storybookNextjsFontLoader(){let options=this.getOptions(),rootCtx=this.rootContext,fontFaceDeclaration;if((options.source==="next/font/google"||options.source==="@next/font/google")&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),(options.source==="next/font/local"||options.source==="@next/font/local")&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return `
|
|
41
46
|
${setFontDeclarationsInHead({fontFaceCSS:cssMeta.fontFaceCSS,id:fontFaceDeclaration.id,classNamesCSS:cssMeta.classNamesCSS})}
|
|
42
47
|
|
|
43
48
|
module.exports = {
|
|
@@ -45,4 +50,6 @@ import{__esm,__export,__require,__toCommonJS}from"../../../chunk-YPQDI6HO.mjs";v
|
|
|
45
50
|
style: ${JSON.stringify(cssMeta.style)}
|
|
46
51
|
${cssMeta.variableClassName?`, variable: "${cssMeta.variableClassName}"`:""}
|
|
47
52
|
}
|
|
48
|
-
`}return"module.exports = {}"}
|
|
53
|
+
`}return "module.exports = {}"}
|
|
54
|
+
|
|
55
|
+
export { storybookNextjsFontLoader as default };
|