@storybook/nextjs 7.0.0-beta.4 β 7.0.0-beta.40
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/README.md +119 -11
- package/dist/app-router-provider-LIUPULW3.mjs +1 -0
- package/dist/chunk-4MG4OZFL.mjs +1 -0
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +3 -0
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +40 -0
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +40 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +0 -1
- package/dist/next-image-loader-stub.js +1 -1
- package/dist/next-image-loader-stub.mjs +1 -1
- package/dist/preset.d.ts +13 -11
- package/dist/preset.js +1 -5
- package/dist/preset.mjs +1 -5
- package/dist/preview.js +6 -6
- package/dist/preview.mjs +2 -2
- package/package.json +17 -13
- package/template/cli/js/Button.stories.js +1 -1
- package/template/cli/js/Header.stories.js +2 -2
- package/template/cli/ts-legacy/Button.stories.ts +1 -1
- package/template/cli/ts-legacy/Header.stories.ts +2 -2
- package/template/cli/ts-legacy/Page.tsx +1 -1
- package/template/stories/Image.stories.jsx +1 -1
- package/template/stories_12-js/ImageFuture.stories.jsx +1 -1
- package/template/stories_default-js/Font.jsx +64 -0
- package/template/stories_default-js/Font.stories.jsx +23 -0
- package/template/stories_default-js/Head.stories.jsx +34 -0
- package/template/stories_default-js/ImageLegacy.stories.jsx +1 -1
- package/template/stories_default-js/Navigation.stories.jsx +22 -1
- package/template/stories_default-js/fonts/OFL.txt +93 -0
- package/template/stories_default-js/fonts/RubikStorm-Regular.ttf +0 -0
- package/dist/app-router-provider-5WPYJFG6.mjs +0 -1
- package/dist/chunk-LAHENP5R.mjs +0 -1
package/README.md
CHANGED
|
@@ -7,19 +7,31 @@
|
|
|
7
7
|
- [Getting Started](#getting-started)
|
|
8
8
|
- [In a project without Storybook](#in-a-project-without-storybook)
|
|
9
9
|
- [In a project with Storybook](#in-a-project-with-storybook)
|
|
10
|
+
- [Automatic migration](#automatic-migration)
|
|
11
|
+
- [Manual migration](#manual-migration)
|
|
10
12
|
- [Documentation](#documentation)
|
|
11
13
|
- [Options](#options)
|
|
12
14
|
- [Next.js's Image Component](#nextjss-image-component)
|
|
13
15
|
- [Local Images](#local-images)
|
|
14
16
|
- [Remote Images](#remote-images)
|
|
15
|
-
- [Optimization](#optimization)
|
|
16
17
|
- [AVIF](#avif)
|
|
18
|
+
- [Next.js Font Optimization](#nextjs-font-optimization)
|
|
19
|
+
- [@next/font/google](#nextfontgoogle)
|
|
20
|
+
- [@next/font/local](#nextfontlocal)
|
|
21
|
+
- [Not supported features of @next/font](#not-supported-features-of-nextfont)
|
|
17
22
|
- [Next.js Routing](#nextjs-routing)
|
|
18
23
|
- [Overriding defaults](#overriding-defaults)
|
|
19
24
|
- [Global Defaults](#global-defaults)
|
|
20
25
|
- [Default Router](#default-router)
|
|
21
26
|
- [Actions Integration Caveats](#actions-integration-caveats)
|
|
22
27
|
- [Next.js Navigation](#nextjs-navigation)
|
|
28
|
+
- [Set `nextjs.appDirectory` to `true`](#set-nextjsappdirectory-to-true)
|
|
29
|
+
- [Overriding defaults](#overriding-defaults-1)
|
|
30
|
+
- [Global Defaults](#global-defaults-1)
|
|
31
|
+
- [`useSelectedLayoutSegment` and `useSelectedLayoutSegments` hook](#useselectedlayoutsegment-and-useselectedlayoutsegments-hook)
|
|
32
|
+
- [Default Navigation Context](#default-navigation-context)
|
|
33
|
+
- [Actions Integration Caveats](#actions-integration-caveats-1)
|
|
34
|
+
- [Next.js Head](#nextjs-head)
|
|
23
35
|
- [Sass/Scss](#sassscss)
|
|
24
36
|
- [Css/Sass/Scss Modules](#csssassscss-modules)
|
|
25
37
|
- [Styled JSX](#styled-jsx)
|
|
@@ -30,17 +42,21 @@
|
|
|
30
42
|
- [Typescript](#typescript)
|
|
31
43
|
- [Notes for Yarn v2 and v3 users](#notes-for-yarn-v2-and-v3-users)
|
|
32
44
|
- [FAQ](#faq)
|
|
33
|
-
- [Stories for pages](#stories-for-
|
|
45
|
+
- [Stories for pages/components which fetch data](#stories-for-pagescomponents-which-fetch-data)
|
|
34
46
|
- [Statically imported images won't load](#statically-imported-images-wont-load)
|
|
35
|
-
- [Module not found: Error: Can't resolve [package name]](#module-not-found-error-cant-resolve-package-name)
|
|
47
|
+
- [Module not found: Error: Can't resolve \[package name\]](#module-not-found-error-cant-resolve-package-name)
|
|
36
48
|
- [Acknowledgements](#acknowledgements)
|
|
37
49
|
|
|
38
50
|
## Supported Features
|
|
39
51
|
|
|
40
52
|
π [Next.js's Image Component](#nextjss-image-component)
|
|
41
53
|
|
|
54
|
+
π [Next.js Font Optimization](#nextjs-font-optimization)
|
|
55
|
+
|
|
42
56
|
π [Next.js Routing (next/router)](#nextjs-routing)
|
|
43
57
|
|
|
58
|
+
π [Next.js Head (next/head)](#nextjs-head)
|
|
59
|
+
|
|
44
60
|
π [Next.js Navigation (next/navigation)](#nextjs-navigation)
|
|
45
61
|
|
|
46
62
|
π [Sass/Scss](#sassscss)
|
|
@@ -84,17 +100,23 @@ This framework is designed to work with Storybook 7. If youβre not already usi
|
|
|
84
100
|
npx storybook@next upgrade --prerelease
|
|
85
101
|
```
|
|
86
102
|
|
|
103
|
+
#### Automatic migration
|
|
104
|
+
|
|
105
|
+
When running the `upgrade` command above, you should get a prompt asking you to migrate to `@storybook/nextjs`, which should handle everything for you. In case that auto-migration does not work for your project, refer to the manual migration below.
|
|
106
|
+
|
|
107
|
+
#### Manual migration
|
|
108
|
+
|
|
87
109
|
Install the framework:
|
|
88
110
|
|
|
89
111
|
```bash
|
|
90
|
-
yarn
|
|
112
|
+
yarn add --dev @storybook/nextjs@next
|
|
91
113
|
```
|
|
92
114
|
|
|
93
115
|
Update your `main.js` to change the framework property:
|
|
94
116
|
|
|
95
117
|
```js
|
|
96
118
|
// .storybook/main.js
|
|
97
|
-
|
|
119
|
+
export default {
|
|
98
120
|
// ...
|
|
99
121
|
framework: {
|
|
100
122
|
// name: '@storybook/react-webpack5', // Remove this
|
|
@@ -108,7 +130,7 @@ If you were using Storybook plugins to integrate with Next.js, those are no long
|
|
|
108
130
|
|
|
109
131
|
```js
|
|
110
132
|
// .storybook/main.js
|
|
111
|
-
|
|
133
|
+
export default {
|
|
112
134
|
// ...
|
|
113
135
|
addons: [
|
|
114
136
|
// ...
|
|
@@ -129,9 +151,9 @@ For example:
|
|
|
129
151
|
|
|
130
152
|
```js
|
|
131
153
|
// .storybook/main.js
|
|
132
|
-
|
|
154
|
+
import * as path from 'path';
|
|
133
155
|
|
|
134
|
-
|
|
156
|
+
export default {
|
|
135
157
|
// ...
|
|
136
158
|
framework: {
|
|
137
159
|
name: '@storybook/nextjs',
|
|
@@ -196,6 +218,54 @@ export default function Home() {
|
|
|
196
218
|
|
|
197
219
|
This format is not supported by this framework yet. Feel free to [open up an issue](https://github.com/storybookjs/storybook/issues) if this is something you want to see.
|
|
198
220
|
|
|
221
|
+
### Next.js Font Optimization
|
|
222
|
+
|
|
223
|
+
[@next/font](https://nextjs.org/docs/basic-features/font-optimization) is partially supported in Storybook. The packages `@next/font/google` and `@next/font/local` are supported.
|
|
224
|
+
|
|
225
|
+
#### @next/font/google
|
|
226
|
+
|
|
227
|
+
You don't have to do anything. `@next/font/google` is supported out of the box.
|
|
228
|
+
|
|
229
|
+
#### @next/font/local
|
|
230
|
+
|
|
231
|
+
For local fonts you have to define the [src](https://nextjs.org/docs/api-reference/next/font#src) property.
|
|
232
|
+
The path is relative to the directory where the font loader function is called.
|
|
233
|
+
|
|
234
|
+
If the following component defines your localFont like this:
|
|
235
|
+
|
|
236
|
+
```js
|
|
237
|
+
// src/components/MyComponent.js
|
|
238
|
+
import localFont from '@next/font/local';
|
|
239
|
+
|
|
240
|
+
const localRubikStorm = localFont({ src: './fonts/RubikStorm-Regular.ttf' });
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
You have to tell Storybook where the `fonts` directory is located. The `from` value is relative to the `.storybook` directory. The `to` value is relative to the execution context of Storybook. Very likely it is the root of your project.
|
|
244
|
+
|
|
245
|
+
```js
|
|
246
|
+
// .storybook/main.js
|
|
247
|
+
export default {
|
|
248
|
+
...
|
|
249
|
+
"staticDirs": [
|
|
250
|
+
{
|
|
251
|
+
from: '../src/components/fonts',
|
|
252
|
+
to: 'src/components/fonts'
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### Not supported features of @next/font
|
|
259
|
+
|
|
260
|
+
The following features are not supported (yet). Support for these features might be planned for the future:
|
|
261
|
+
|
|
262
|
+
- [Support font loaders configuration in next.config.js](https://nextjs.org/docs/basic-features/font-optimization#specifying-a-subset)
|
|
263
|
+
- [fallback](https://nextjs.org/docs/api-reference/next/font#fallback) option
|
|
264
|
+
- [adjustFontFallback](https://nextjs.org/docs/api-reference/next/font#adjustfontfallback) option
|
|
265
|
+
- [declarations](https://nextjs.org/docs/api-reference/next/font#declarations) option
|
|
266
|
+
- [preload](https://nextjs.org/docs/api-reference/next/font#preload) option gets ignored. Storybook handles Font loading its own way.
|
|
267
|
+
- [display](https://nextjs.org/docs/api-reference/next/font#display) option gets ignored. All fonts are loaded with display set to "block" to make Storybook load the font properly.
|
|
268
|
+
|
|
199
269
|
### Next.js Routing
|
|
200
270
|
|
|
201
271
|
[Next.js's router](https://nextjs.org/docs/routing/introduction) is automatically stubbed for you so that when the router is interacted with, all of its interactions are automatically logged to the Actions ctions panel if you have the [Storybook actions addon](https://storybook.js.org/docs/react/essentials/actions).
|
|
@@ -428,6 +498,40 @@ export const parameters = {
|
|
|
428
498
|
};
|
|
429
499
|
```
|
|
430
500
|
|
|
501
|
+
#### `useSelectedLayoutSegment` and `useSelectedLayoutSegments` hook
|
|
502
|
+
|
|
503
|
+
The `useSelectedLayoutSegment` and `useSelectedLayoutSegments` hooks are supported in Storybook. You have to set the `nextjs.navigation.segments` parameter to return the segments you want to use.
|
|
504
|
+
|
|
505
|
+
```js
|
|
506
|
+
// SomeComponentThatUsesTheNavigation.stories.js
|
|
507
|
+
import SomeComponentThatUsesTheNavigation from './SomeComponentThatUsesTheNavigation';
|
|
508
|
+
|
|
509
|
+
export default {
|
|
510
|
+
component: SomeComponentThatUsesTheNavigation,
|
|
511
|
+
parameters: {
|
|
512
|
+
nextjs: {
|
|
513
|
+
appDirectory: true,
|
|
514
|
+
navigation: {
|
|
515
|
+
segments: ['dashboard', 'analytics']
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
export const Example = {};
|
|
522
|
+
|
|
523
|
+
// SomeComponentThatUsesTheNavigation.js
|
|
524
|
+
import { useSelectedLayoutSegment, useSelectedLayoutSegments } from 'next/navigation';
|
|
525
|
+
|
|
526
|
+
export default function SomeComponentThatUsesTheNavigation() {
|
|
527
|
+
const segment = useSelectedLayoutSegment(); // dashboard
|
|
528
|
+
const segments = useSelectedLayoutSegments(); // ["dashboard", "analytics"]
|
|
529
|
+
...
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
The default value of `nextjs.navigation.segments` is `[]` if not set.
|
|
534
|
+
|
|
431
535
|
#### Default Navigation Context
|
|
432
536
|
|
|
433
537
|
The default values on the stubbed navigation context are as follows:
|
|
@@ -498,6 +602,10 @@ export const parameters = {
|
|
|
498
602
|
};
|
|
499
603
|
```
|
|
500
604
|
|
|
605
|
+
### Next.js Head
|
|
606
|
+
|
|
607
|
+
[next/head](https://nextjs.org/docs/api-reference/next/head) is supported out of the box. You can use it in your stories like you would in your Next.js application. Please keep in mind, that the Head children are placed into the head element of the iframe that Storybook uses to render your stories.
|
|
608
|
+
|
|
501
609
|
### Sass/Scss
|
|
502
610
|
|
|
503
611
|
[Global sass/scss stylesheets](https://nextjs.org/docs/basic-features/built-in-css-support#sass-support) are supported without any additional configuration as well. Just import them into [preview.js](https://storybook.js.org/docs/react/configure/overview#configure-story-rendering)
|
|
@@ -510,9 +618,9 @@ This will automatically include any of your [custom sass configurations](https:/
|
|
|
510
618
|
|
|
511
619
|
```js
|
|
512
620
|
// next.config.js
|
|
513
|
-
|
|
621
|
+
import * as path from 'path';
|
|
514
622
|
|
|
515
|
-
|
|
623
|
+
export default {
|
|
516
624
|
// Any options here are included in Sass compilation for your stories
|
|
517
625
|
sassOptions: {
|
|
518
626
|
includePaths: [path.join(__dirname, 'styles')],
|
|
@@ -676,7 +784,7 @@ Below is an example of how to add svgr support to Storybook with this framework.
|
|
|
676
784
|
|
|
677
785
|
```js
|
|
678
786
|
// .storybook/main.js
|
|
679
|
-
|
|
787
|
+
export default {
|
|
680
788
|
// ...
|
|
681
789
|
webpackFinal: async (config) => {
|
|
682
790
|
// This modifies the existing image rule to exclude .svg files
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-4MG4OZFL.mjs";import React from"react";import{AppRouterContext,LayoutRouterContext}from"next/dist/shared/lib/app-router-context";import{PathnameContext,SearchParamsContext}from"next/dist/shared/lib/hooks-client-context";var getParallelRoutes=segmentsList=>{let segment=segmentsList.shift();return segment?[segment,{children:getParallelRoutes(segmentsList)}]:[]},AppRouterProvider=({children,action,routeParams})=>{let{pathname,query,segments=[],...restRouteParams}=routeParams;return React.createElement(AppRouterContext.Provider,{value:{push(...args){action("nextNavigation.push")(...args)},replace(...args){action("nextNavigation.replace")(...args)},forward(...args){action("nextNavigation.forward")(...args)},back(...args){action("nextNavigation.back")(...args)},prefetch(...args){action("nextNavigation.prefetch")(...args)},refresh:()=>{action("nextNavigation.refresh")()},...restRouteParams}},React.createElement(SearchParamsContext.Provider,{value:new URLSearchParams(query)},React.createElement(LayoutRouterContext.Provider,{value:{childNodes:new Map,tree:[pathname,{children:getParallelRoutes([...segments])}],url:pathname}},React.createElement(PathnameContext.Provider,{value:pathname},children))))},app_router_provider_default=AppRouterProvider;export{app_router_provider_default as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __getOwnPropNames=Object.getOwnPropertyNames;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 __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};export{__require,__commonJS};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 storybook_nextjs_font_loader_exports={};__export(storybook_nextjs_font_loader_exports,{default:()=>storybookNextjsFontLoader});module.exports=__toCommonJS(storybook_nextjs_font_loader_exports);var import_loader_utils3=__toESM(require("next/dist/compiled/loader-utils3")),import_utils=require("@next/font/dist/google/utils"),cssCache=new Map;async function getFontFaceDeclarations(options){let{fontFamily,weights,styles,selectedVariableAxes,display,variable}=(0,import_utils.validateData)(options.fontFamily,[options.props],null),fontAxes=(0,import_utils.getFontAxes)(fontFamily,weights,styles,selectedVariableAxes),url=(0,import_utils.getUrl)(fontFamily,fontAxes,display);try{let hasCachedCSS=cssCache.has(url),fontFaceCSS=hasCachedCSS?cssCache.get(url):await(0,import_utils.fetchCSSFromGoogleFonts)(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:import_loader_utils3.default.getHashDigest(url,"md5","hex",6),fontFamily,fontFaceCSS,weights,styles,variable}}catch{throw new Error("Google Fonts couldn't be loaded.")}}var import_loader_utils32=__toESM(require("next/dist/compiled/loader-utils3")),import_utils2=require("@next/font/dist/local/utils"),import_path=__toESM(require("path"));async function getFontFaceDeclarations2(options,rootContext){let localFontSrc=options.props.src,parentFolder=options.filename.split("/").slice(0,-1).join("/").replace(rootContext,""),{weight,style,variable}=(0,import_utils2.validateData)("",options.props),id=`font-${import_loader_utils32.default.getHashDigest(Buffer.from(JSON.stringify(localFontSrc)),"md5","hex",6)}`;return{id,fontFamily:id,fontFaceCSS:(()=>{if(typeof localFontSrc=="string"){let localFontPath=import_path.default.join(parentFolder,localFontSrc);return`@font-face {
|
|
2
|
+
font-family: ${id};
|
|
3
|
+
src: url(${localFontPath});
|
|
4
|
+
}`}return localFontSrc.map(font=>{let localFontPath=import_path.default.join(parentFolder,font.path);return`@font-face {
|
|
5
|
+
font-family: ${id};
|
|
6
|
+
src: url(${localFontPath});
|
|
7
|
+
${font.weight?`font-weight: ${font.weight};`:""}
|
|
8
|
+
${font.style?`font-style: ${font.style};`:""}
|
|
9
|
+
}`}).join("")})(),weights:weight?[weight]:[],styles:style?[style]:[],variable}}function getCSSMeta(options){let className=getClassName(options),style=getStylesObj(options),variableClassName=`__variable_${className}`,classNamesCSS=`
|
|
10
|
+
.${className} {
|
|
11
|
+
font-family: ${options.fontFamily};
|
|
12
|
+
${isNextCSSPropertyValid(options.styles)?`font-style: ${options.styles[0]};`:""}
|
|
13
|
+
${isNextCSSPropertyValid(options.weights)?`font-weight: ${options.weights[0]};`:""}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
${options.variable?`.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }`:""}
|
|
17
|
+
`,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`
|
|
18
|
+
if (!document.getElementById('id-${id}')) {
|
|
19
|
+
const fontDeclarations = \`${fontFaceCSS}\`;
|
|
20
|
+
const style = document.createElement('style');
|
|
21
|
+
style.setAttribute('id', 'font-face-${id}');
|
|
22
|
+
style.innerHTML = fontDeclarations;
|
|
23
|
+
document.head.appendChild(style);
|
|
24
|
+
|
|
25
|
+
const classNamesCSS = \`${classNamesCSS}\`;
|
|
26
|
+
const classNamesStyle = document.createElement('style');
|
|
27
|
+
classNamesStyle.setAttribute('id', 'classnames-${id}');
|
|
28
|
+
classNamesStyle.innerHTML = classNamesCSS;
|
|
29
|
+
document.head.appendChild(classNamesStyle);
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
`}async function storybookNextjsFontLoader(){let options=this.getOptions(),rootCtx=this.rootContext,fontFaceDeclaration;if(options.source==="@next/font/google"&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),options.source==="@next/font/local"&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return`
|
|
33
|
+
${setFontDeclarationsInHead({fontFaceCSS:cssMeta.fontFaceCSS,id:fontFaceDeclaration.id,classNamesCSS:cssMeta.classNamesCSS})}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
className: "${cssMeta.className}",
|
|
37
|
+
style: ${JSON.stringify(cssMeta.style)}
|
|
38
|
+
${cssMeta.variableClassName?`, variable: "${cssMeta.variableClassName}"`:""}
|
|
39
|
+
}
|
|
40
|
+
`}return"module.exports = {}"}0&&(module.exports={});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import"../../../chunk-4MG4OZFL.mjs";import loaderUtils from"next/dist/compiled/loader-utils3";import{fetchCSSFromGoogleFonts,getFontAxes,getUrl,validateData}from"@next/font/dist/google/utils";var cssCache=new Map;async function getFontFaceDeclarations(options){let{fontFamily,weights,styles,selectedVariableAxes,display,variable}=validateData(options.fontFamily,[options.props],null),fontAxes=getFontAxes(fontFamily,weights,styles,selectedVariableAxes),url=getUrl(fontFamily,fontAxes,display);try{let hasCachedCSS=cssCache.has(url),fontFaceCSS=hasCachedCSS?cssCache.get(url):await fetchCSSFromGoogleFonts(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.")}}import loaderUtils2 from"next/dist/compiled/loader-utils3";import{validateData as validateData2}from"@next/font/dist/local/utils";import path from"path";async function getFontFaceDeclarations2(options,rootContext){let localFontSrc=options.props.src,parentFolder=options.filename.split("/").slice(0,-1).join("/").replace(rootContext,""),{weight,style,variable}=validateData2("",options.props),id=`font-${loaderUtils2.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 {
|
|
2
|
+
font-family: ${id};
|
|
3
|
+
src: url(${localFontPath});
|
|
4
|
+
}`}return localFontSrc.map(font=>{let localFontPath=path.join(parentFolder,font.path);return`@font-face {
|
|
5
|
+
font-family: ${id};
|
|
6
|
+
src: url(${localFontPath});
|
|
7
|
+
${font.weight?`font-weight: ${font.weight};`:""}
|
|
8
|
+
${font.style?`font-style: ${font.style};`:""}
|
|
9
|
+
}`}).join("")})(),weights:weight?[weight]:[],styles:style?[style]:[],variable}}function getCSSMeta(options){let className=getClassName(options),style=getStylesObj(options),variableClassName=`__variable_${className}`,classNamesCSS=`
|
|
10
|
+
.${className} {
|
|
11
|
+
font-family: ${options.fontFamily};
|
|
12
|
+
${isNextCSSPropertyValid(options.styles)?`font-style: ${options.styles[0]};`:""}
|
|
13
|
+
${isNextCSSPropertyValid(options.weights)?`font-weight: ${options.weights[0]};`:""}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
${options.variable?`.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }`:""}
|
|
17
|
+
`,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`
|
|
18
|
+
if (!document.getElementById('id-${id}')) {
|
|
19
|
+
const fontDeclarations = \`${fontFaceCSS}\`;
|
|
20
|
+
const style = document.createElement('style');
|
|
21
|
+
style.setAttribute('id', 'font-face-${id}');
|
|
22
|
+
style.innerHTML = fontDeclarations;
|
|
23
|
+
document.head.appendChild(style);
|
|
24
|
+
|
|
25
|
+
const classNamesCSS = \`${classNamesCSS}\`;
|
|
26
|
+
const classNamesStyle = document.createElement('style');
|
|
27
|
+
classNamesStyle.setAttribute('id', 'classnames-${id}');
|
|
28
|
+
classNamesStyle.innerHTML = classNamesCSS;
|
|
29
|
+
document.head.appendChild(classNamesStyle);
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
`}async function storybookNextjsFontLoader(){let options=this.getOptions(),rootCtx=this.rootContext,fontFaceDeclaration;if(options.source==="@next/font/google"&&(fontFaceDeclaration=await getFontFaceDeclarations(options)),options.source==="@next/font/local"&&(fontFaceDeclaration=await getFontFaceDeclarations2(options,rootCtx)),typeof fontFaceDeclaration<"u"){let cssMeta=getCSSMeta(fontFaceDeclaration);return`
|
|
33
|
+
${setFontDeclarationsInHead({fontFaceCSS:cssMeta.fontFaceCSS,id:fontFaceDeclaration.id,classNamesCSS:cssMeta.classNamesCSS})}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
className: "${cssMeta.className}",
|
|
37
|
+
style: ${JSON.stringify(cssMeta.style)}
|
|
38
|
+
${cssMeta.variableClassName?`, variable: "${cssMeta.variableClassName}"`:""}
|
|
39
|
+
}
|
|
40
|
+
`}return"module.exports = {}"}export{storybookNextjsFontLoader as default};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __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);var src_exports={};module.exports=__toCommonJS(src_exports);
|
package/dist/index.mjs
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"@storybook/react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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 __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));var import_loader_utils=require("loader-utils"),import_image_size=__toESM(require("image-size")),nextImageLoaderStub=function(content){let{filename}=this.getOptions(),outputPath=(0,import_loader_utils.interpolateName)(this,filename.replace("[ext]",".[ext]"),{context:this.rootContext,content});this.emitFile(outputPath,content);let{width,height}=(0,import_image_size.default)(this.resourcePath);return`export default ${JSON.stringify({src:outputPath,height,width,blurDataURL:outputPath})};`};nextImageLoaderStub.raw=!0;module.exports=nextImageLoaderStub;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import{__commonJS}from"./chunk-4MG4OZFL.mjs";import{interpolateName}from"loader-utils";import imageSizeOf from"image-size";var require_next_image_loader_stub=__commonJS({"src/next-image-loader-stub.ts"(exports,module){var nextImageLoaderStub=function(content){let{filename}=this.getOptions(),outputPath=interpolateName(this,filename.replace("[ext]",".[ext]"),{context:this.rootContext,content});this.emitFile(outputPath,content);let{width,height}=imageSizeOf(this.resourcePath);return`export default ${JSON.stringify({src:outputPath,height,width,blurDataURL:outputPath})};`};nextImageLoaderStub.raw=!0;module.exports=nextImageLoaderStub}});export default require_next_image_loader_stub();
|
package/dist/preset.d.ts
CHANGED
|
@@ -876,20 +876,17 @@ interface CLIOptions {
|
|
|
876
876
|
quiet?: boolean;
|
|
877
877
|
versionUpdates?: boolean;
|
|
878
878
|
releaseNotes?: boolean;
|
|
879
|
-
dll?: boolean;
|
|
880
879
|
docs?: boolean;
|
|
881
|
-
docsDll?: boolean;
|
|
882
|
-
uiDll?: boolean;
|
|
883
880
|
debugWebpack?: boolean;
|
|
884
881
|
webpackStatsJson?: string | boolean;
|
|
885
882
|
outputDir?: string;
|
|
886
883
|
}
|
|
887
884
|
interface BuilderOptions {
|
|
888
885
|
configType?: 'DEVELOPMENT' | 'PRODUCTION';
|
|
889
|
-
ignorePreview
|
|
890
|
-
cache
|
|
886
|
+
ignorePreview?: boolean;
|
|
887
|
+
cache?: FileSystemCache;
|
|
891
888
|
configDir: string;
|
|
892
|
-
docsMode
|
|
889
|
+
docsMode?: boolean;
|
|
893
890
|
features?: StorybookConfig['features'];
|
|
894
891
|
versionCheck?: VersionCheck;
|
|
895
892
|
releaseNotesData?: ReleaseNotesData;
|
|
@@ -935,18 +932,19 @@ type CoreCommon_StorybookRefs = Record<string, {
|
|
|
935
932
|
}>;
|
|
936
933
|
type DocsOptions = {
|
|
937
934
|
/**
|
|
938
|
-
* Should we generate docs entries at all under any circumstances? (i.e. can they be rendered)
|
|
935
|
+
* Should we disable generate docs entries at all under any circumstances? (i.e. can they be rendered)
|
|
939
936
|
*/
|
|
940
|
-
|
|
937
|
+
disable?: boolean;
|
|
941
938
|
/**
|
|
942
939
|
* What should we call the generated docs entries?
|
|
943
940
|
*/
|
|
944
941
|
defaultName?: string;
|
|
945
942
|
/**
|
|
946
|
-
* Should we generate a docs entry per CSF file
|
|
947
|
-
* Set to '
|
|
943
|
+
* Should we generate a docs entry per CSF file?
|
|
944
|
+
* Set to 'tag' (the default) to generate an entry for every CSF file with the
|
|
945
|
+
* 'autodocs' tag.
|
|
948
946
|
*/
|
|
949
|
-
|
|
947
|
+
autodocs?: boolean | 'tag';
|
|
950
948
|
/**
|
|
951
949
|
* Only show doc entries in the side bar (usually set with the `--docs` CLI flag)
|
|
952
950
|
*/
|
|
@@ -1002,6 +1000,10 @@ interface StorybookConfig {
|
|
|
1002
1000
|
* Will be removed in 7.0.
|
|
1003
1001
|
*/
|
|
1004
1002
|
warnOnLegacyHierarchySeparator?: boolean;
|
|
1003
|
+
/**
|
|
1004
|
+
* Use legacy MDX1, to help smooth migration to 7.0
|
|
1005
|
+
*/
|
|
1006
|
+
legacyMdx1?: boolean;
|
|
1005
1007
|
};
|
|
1006
1008
|
/**
|
|
1007
1009
|
* Tells Storybook where to find stories.
|
package/dist/preset.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
"use strict";var Z=Object.create;var x=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(e,t)=>{for(var o in t)x(e,o,{get:t[o],enumerable:!0})},h=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!re.call(e,s)&&s!==o&&x(e,s,{get:()=>t[s],enumerable:!(r=ee(t,s))||r.enumerable});return e};var n=(e,t,o)=>(o=e!=null?Z(te(e)):{},h(t||!e||!e.__esModule?x(o,"default",{value:e,enumerable:!0}):o,e)),ie=e=>h(x({},"__esModule",{value:!0}),e);var ye={};se(ye,{addons:()=>me,babel:()=>de,config:()=>ue,core:()=>ge,frameworkOptions:()=>le,webpackFinal:()=>xe});module.exports=ie(ye);var c=require("path"),Q=require("@babel/core"),Y=require("@storybook/core-common");var b=n(require("semver")),V=require("webpack");var k=n(require("path")),R=require("webpack"),j=require("next/constants"),P=n(require("find-up")),E=require("fs-extra"),S=n(require("ts-dedent")),I=require("url"),O=e=>{var t;(t=e.plugins)==null||t.push(new R.DefinePlugin({"process.env.__NEXT_VERSION":JSON.stringify(f())}))},f=()=>require(y("next/package.json")).version,ne=async e=>["mjs","js"].reduce(async(o,r)=>(await o||(o=(0,P.default)(`next.config.${r}`,{cwd:e})),o),Promise.resolve(void 0)),_=async({baseConfig:e={},nextConfigPath:t,configDir:o})=>{let r=t||await ne(o);if(!r||await(0,E.pathExists)(r)===!1)throw new Error(S.default`
|
|
2
|
-
Could not find or resolve your Next config file. Please provide the next config file path as a framework option.
|
|
3
|
-
|
|
4
|
-
More info: https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/README.md#options
|
|
5
|
-
`);let s=await import((0,I.pathToFileURL)(r).href),i=typeof s=="function"?s(j.PHASE_DEVELOPMENT_SERVER,{defaultConfig:e}):s;return i.default||i},p=(e,t,o)=>{e.resolve??={},e.resolve.alias??={};let r=e.resolve.alias,s=y(`${o??t}`);Array.isArray(r)?r.push({name:t,alias:s}):r[t]=s},y=e=>{let t=require.resolve(e,{paths:[k.default.resolve()]}),r=t.lastIndexOf(e.replace(/\//g,k.default.sep))+e.length;return t.substring(0,r)};var A=async({baseConfig:e,nextConfigPath:t,configDir:o})=>{let r=await _({baseConfig:e,nextConfigPath:t,configDir:o});return p(e,"next/config"),pe(e,r),r},W=f(),pe=(e,t)=>{var s,i;let o={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:t.publicRuntimeConfig})},r=(s=t.experimental)==null?void 0:s.newNextLinkBehavior;b.default.gte(W,"13.0.0")&&b.default.lt(W,"13.0.6")&&r!==!1?o["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:o["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=r,(i=e.plugins)==null||i.push(new V.DefinePlugin(o))};var v=require("next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent"),w=require("next/dist/build/webpack/config/blocks/css/loaders/file-resolve"),$=n(require("semver"));var q=(e,t)=>{var r,s,i;let o=(r=e.module)==null?void 0:r.rules;o==null||o.forEach((m,l)=>{typeof m!="string"&&m.test instanceof RegExp&&m.test.test("test.css")&&(o[l]={test:/\.css$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:1,...F(t),modules:{auto:!0,getLocalIdent:v.getCssModuleLocalIdent}}},"postcss-loader"]})}),o==null||o.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...F(t),modules:{auto:!0,getLocalIdent:v.getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:t.sassOptions,additionalData:((s=t.sassOptions)==null?void 0:s.prependData)||((i=t.sassOptions)==null?void 0:i.additionalData)}}]})},F=e=>ae()?{url:{filter:L(e)},import:{filter:T(e)}}:{url:L(e),import:T(e)},L=e=>(t,o)=>{var r;return(0,w.cssFileResolve)(t,o,(r=e.experimental)==null?void 0:r.urlImports)},T=e=>(t,o,r)=>{var s;return(0,w.cssFileResolve)(typeof t=="string"?t:t.url,r,(s=e.experimental)==null?void 0:s.urlImports)},ae=()=>{try{let e=require(y("css-loader/package.json")).version;return $.default.gte(e,"6.0.0")}catch{return!1}};var D=n(require("tsconfig-paths-webpack-plugin")),M=require("tsconfig-paths"),B=e=>{let t=(0,M.loadConfig)();t.resultType==="failed"||!t.baseUrl||(e.resolve??={},e.resolve.plugins??=[],e.resolve.plugins.push(new D.default({configFile:t.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};var U=n(require("semver"));var J=e=>{let t=fe();p(e,t)},fe=()=>{let e=f();return U.default.gte(e,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};var X=n(require("semver"));var H=e=>{let t=f();X.default.gte(t,"12.0.0")?p(e,"styled-jsx"):(p(e,"styled-jsx/babel"),p(e,"styled-jsx/css"),p(e,"styled-jsx/macro"),p(e,"styled-jsx/server"),p(e,"styled-jsx/style"),p(e,"styled-jsx/webpack"))};var K=n(require("semver"));var G=e=>{ce(e),p(e,"next/image")},ce=e=>{var s,i,m;let t=f();if(K.default.lt(t,"11.0.0"))return;let o=(s=e.module)==null?void 0:s.rules,r=o==null?void 0:o.find(l=>typeof l!="string"&&l.test instanceof RegExp&&l.test.test("test.jpg"));!r||(r.test=/\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,o==null||o.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:{not:/\.(css|scss|sass)$/},use:[{loader:require.resolve("@storybook/nextjs/next-image-loader-stub.js"),options:{filename:(i=r.generator)==null?void 0:i.filename}}]}),o==null||o.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:(m=r.generator)==null?void 0:m.filename}}))};var u=n(require("semver")),d=require("webpack");function z(e){let t=f(),o=u.default.satisfies(t,"~12"),r=u.default.satisfies(t,"~13"),s=u.default.lt(t,"12.2.0"),i=u.default.lt(t,"13.0.0");e.plugins=e.plugins??[],r||e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),(!o||s)&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/future\/image$/})),i&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),s&&e.plugins.push(new d.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}var me=[(0,c.dirname)(require.resolve((0,c.join)("@storybook/preset-react-webpack","package.json"))),(0,c.dirname)(require.resolve((0,c.join)("@storybook/builder-webpack5","package.json")))],C={},le=async(e,t)=>{let o=await t.presets.apply("framework");return typeof o=="string"?{name:o,options:C}:typeof o>"u"?{name:require.resolve("@storybook/nextjs"),options:C}:{name:o.name,options:{...C,...o.options}}},ge=async(e,t)=>{let o=await t.presets.apply("framework");return{...e,builder:{name:(0,c.dirname)(require.resolve((0,c.join)("@storybook/builder-webpack5","package.json"))),options:typeof o=="string"?{}:o.options.builder||{}},renderer:(0,c.dirname)(require.resolve((0,c.join)("@storybook/react","package.json")))}},ue=(e=[])=>[...e,require.resolve("@storybook/nextjs/preview.js")],de=async e=>{var m,l,N;let t=(0,Q.loadPartialConfig)({...e,filename:`${(0,Y.getProjectRoot)()}/__fake__.js`}),o=t==null?void 0:t.options,r=a=>typeof a=="object"&&a!==null&&"file"in a;((m=o==null?void 0:o.presets)==null?void 0:m.find(a=>{var g;return Array.isArray(a)&&a[0]==="next/babel"||a==="next/babel"||r(a)&&((g=a.file)==null?void 0:g.request)==="next/babel"}))||(l=o==null?void 0:o.presets)==null||l.push("next/babel");let i=(N=o==null?void 0:o.presets)==null?void 0:N.filter(a=>{var g;return!(r(a)&&((g=a.file)==null?void 0:g.request)===require.resolve("@babel/preset-react"))});return{...o,presets:i,babelrc:!1,configFile:!1}},xe=async(e,t)=>{let o=await t.presets.apply("frameworkOptions"),{options:{nextConfigPath:r}={}}=o,s=await A({baseConfig:e,nextConfigPath:r,configDir:t.configDir});return z(e),O(e),B(e),q(e,s),G(e),J(e),H(e),e};0&&(module.exports={addons,babel,config,core,frameworkOptions,webpackFinal});
|
|
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 preset_exports={};__export(preset_exports,{addons:()=>addons,babel:()=>babel,config:()=>config,core:()=>core,frameworkOptions:()=>frameworkOptions,webpackFinal:()=>webpackFinal});module.exports=__toCommonJS(preset_exports);var import_path2=require("path"),import_core=require("@babel/core"),import_core_common=require("@storybook/core-common");var import_semver=__toESM(require("semver")),import_webpack2=require("webpack");var import_path=__toESM(require("path")),import_webpack=require("webpack"),import_constants=require("next/constants"),import_find_up=__toESM(require("find-up")),import_fs_extra=require("fs-extra"),import_node_url=require("url"),configureRuntimeNextjsVersionResolution=baseConfig=>{var _a;(_a=baseConfig.plugins)==null||_a.push(new import_webpack.DefinePlugin({"process.env.__NEXT_VERSION":JSON.stringify(getNextjsVersion())}))},getNextjsVersion=()=>require(scopedResolve("next/package.json")).version,findNextConfigFile=async configDir=>["mjs","js"].reduce(async(acc,ext)=>(await acc||(acc=(0,import_find_up.default)(`next.config.${ext}`,{cwd:configDir})),acc),Promise.resolve(void 0)),resolveNextConfig=async({baseConfig={},nextConfigPath,configDir})=>{let nextConfigFile=nextConfigPath||await findNextConfigFile(configDir);if(!nextConfigFile||await(0,import_fs_extra.pathExists)(nextConfigFile)===!1)return{};let nextConfigExport=await import((0,import_node_url.pathToFileURL)(nextConfigFile).href),nextConfig=typeof nextConfigExport=="function"?nextConfigExport(import_constants.PHASE_DEVELOPMENT_SERVER,{defaultConfig:baseConfig}):nextConfigExport;return nextConfig.default||nextConfig},addScopedAlias=(baseConfig,name,alias)=>{baseConfig.resolve??={},baseConfig.resolve.alias??={};let aliasConfig=baseConfig.resolve.alias,scopedAlias=scopedResolve(`${alias??name}`);Array.isArray(aliasConfig)?aliasConfig.push({name,alias:scopedAlias}):aliasConfig[name]=scopedAlias},scopedResolve=id=>{let scopedModulePath=require.resolve(id,{paths:[import_path.default.resolve()]}),beginningOfMainScriptPath=scopedModulePath.lastIndexOf(id.replace(/\//g,import_path.default.sep))+id.length;return scopedModulePath.substring(0,beginningOfMainScriptPath)};var configureConfig=async({baseConfig,nextConfigPath,configDir})=>{let nextConfig=await resolveNextConfig({baseConfig,nextConfigPath,configDir});return addScopedAlias(baseConfig,"next/config"),setupRuntimeConfig(baseConfig,nextConfig),nextConfig},version=getNextjsVersion(),setupRuntimeConfig=(baseConfig,nextConfig)=>{var _a,_b;let definePluginConfig={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:nextConfig.publicRuntimeConfig})},newNextLinkBehavior=(_a=nextConfig.experimental)==null?void 0:_a.newNextLinkBehavior;import_semver.default.gte(version,"13.0.0")&&import_semver.default.lt(version,"13.0.6")&&newNextLinkBehavior!==!1?definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=newNextLinkBehavior,(_b=baseConfig.plugins)==null||_b.push(new import_webpack2.DefinePlugin(definePluginConfig))};var import_getCssModuleLocalIdent=require("next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent"),import_file_resolve=require("next/dist/build/webpack/config/blocks/css/loaders/file-resolve"),import_semver2=__toESM(require("semver"));var configureCss=(baseConfig,nextConfig)=>{var _a,_b,_c;let rules=(_a=baseConfig.module)==null?void 0:_a.rules;rules==null||rules.forEach((rule,i)=>{typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.css")&&(rules[i]={test:/\.css$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:1,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:import_getCssModuleLocalIdent.getCssModuleLocalIdent}}},"postcss-loader"]})}),rules==null||rules.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:import_getCssModuleLocalIdent.getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:nextConfig.sassOptions,additionalData:((_b=nextConfig.sassOptions)==null?void 0:_b.prependData)||((_c=nextConfig.sassOptions)==null?void 0:_c.additionalData)}}]})},getImportAndUrlCssLoaderOptions=nextConfig=>isCssLoaderV6()?{url:{filter:getUrlResolver(nextConfig)},import:{filter:getImportResolver(nextConfig)}}:{url:getUrlResolver(nextConfig),import:getImportResolver(nextConfig)},getUrlResolver=nextConfig=>(url,resourcePath)=>{var _a;return(0,import_file_resolve.cssFileResolve)(url,resourcePath,(_a=nextConfig.experimental)==null?void 0:_a.urlImports)},getImportResolver=nextConfig=>(url,_,resourcePath)=>{var _a;return(0,import_file_resolve.cssFileResolve)(typeof url=="string"?url:url.url,resourcePath,(_a=nextConfig.experimental)==null?void 0:_a.urlImports)},isCssLoaderV6=()=>{try{let cssLoaderVersion=require(scopedResolve("css-loader/package.json")).version;return import_semver2.default.gte(cssLoaderVersion,"6.0.0")}catch{return!1}};var import_tsconfig_paths_webpack_plugin=__toESM(require("tsconfig-paths-webpack-plugin")),import_tsconfig_paths=require("tsconfig-paths"),configureImports=baseConfig=>{let configLoadResult=(0,import_tsconfig_paths.loadConfig)();configLoadResult.resultType==="failed"||!configLoadResult.baseUrl||(baseConfig.resolve??={},baseConfig.resolve.plugins??=[],baseConfig.resolve.plugins.push(new import_tsconfig_paths_webpack_plugin.default({configFile:configLoadResult.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};var import_semver3=__toESM(require("semver"));var configureRouting=baseConfig=>{let routerContextPath=getRouterContextPath();addScopedAlias(baseConfig,routerContextPath)},getRouterContextPath=()=>{let version2=getNextjsVersion();return import_semver3.default.gte(version2,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};var import_semver4=__toESM(require("semver"));var configureStyledJsx=baseConfig=>{let version2=getNextjsVersion();import_semver4.default.gte(version2,"12.0.0")?addScopedAlias(baseConfig,"styled-jsx"):(addScopedAlias(baseConfig,"styled-jsx/babel"),addScopedAlias(baseConfig,"styled-jsx/css"),addScopedAlias(baseConfig,"styled-jsx/macro"),addScopedAlias(baseConfig,"styled-jsx/server"),addScopedAlias(baseConfig,"styled-jsx/style"),addScopedAlias(baseConfig,"styled-jsx/webpack"))};var import_semver5=__toESM(require("semver"));var configureImages=baseConfig=>{configureStaticImageImport(baseConfig),addScopedAlias(baseConfig,"next/image")},configureStaticImageImport=baseConfig=>{var _a,_b,_c;let version2=getNextjsVersion();if(import_semver5.default.lt(version2,"11.0.0"))return;let rules=(_a=baseConfig.module)==null?void 0:_a.rules,assetRule=rules==null?void 0:rules.find(rule=>typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.jpg"));assetRule&&(assetRule.test=/\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,rules==null||rules.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:{not:/\.(css|scss|sass)$/},use:[{loader:require.resolve("@storybook/nextjs/next-image-loader-stub.js"),options:{filename:(_b=assetRule.generator)==null?void 0:_b.filename}}]}),rules==null||rules.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:(_c=assetRule.generator)==null?void 0:_c.filename}}))};var import_semver6=__toESM(require("semver")),import_webpack3=require("webpack");function configureNextImport(baseConfig){let nextJSVersion=getNextjsVersion(),isNext12=import_semver6.default.satisfies(nextJSVersion,"~12"),isNext13=import_semver6.default.satisfies(nextJSVersion,"~13"),isNextVersionSmallerThan12dot2=import_semver6.default.lt(nextJSVersion,"12.2.0"),isNextVersionSmallerThan13=import_semver6.default.lt(nextJSVersion,"13.0.0");baseConfig.plugins=baseConfig.plugins??[],isNext13||baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),(!isNext12||isNextVersionSmallerThan12dot2)&&baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/future\/image$/})),isNextVersionSmallerThan13&&baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),isNextVersionSmallerThan12dot2&&baseConfig.plugins.push(new import_webpack3.IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}function convertNodeToJSON(types,node){if(types.isBooleanLiteral(node)||types.isStringLiteral(node)||types.isNumericLiteral(node))return node.value;if(!(node.name==="undefined"&&!node.value))return types.isNullLiteral(node)?null:types.isObjectExpression(node)?computeProps(types,node.properties):types.isArrayExpression(node)?node.elements.reduce((acc,element)=>[...acc,...(element==null?void 0:element.type)==="SpreadElement"?convertNodeToJSON(types,element.argument):[convertNodeToJSON(types,element)]],[]):{}}function computeProps(types,props){return props.reduce((acc,prop)=>{if(prop.type==="SpreadElement")return{...acc,...convertNodeToJSON(types,prop.argument)};if(prop.type!=="ObjectMethod"){let val=convertNodeToJSON(types,prop.value);if(val!==void 0&&types.isIdentifier(prop.key))return{...acc,[prop.key.name]:val}}return acc},{})}function isDefined(value){return value!==void 0}function removeTransformedVariableDeclarations(path2,types,metas){path2.parentPath.traverse({ExportNamedDeclaration(declaratorPath){var _a;(_a=declaratorPath.parentPath)!=null&&_a.isProgram()&&metas.forEach(meta=>{types.isVariableDeclaration(declaratorPath.node.declaration)&&declaratorPath.node.declaration.declarations.length===1&&types.isVariableDeclarator(declaratorPath.node.declaration.declarations[0])&&types.isIdentifier(declaratorPath.node.declaration.declarations[0].id)&&meta.identifierName===declaratorPath.node.declaration.declarations[0].id.name&&declaratorPath.replaceWith(types.exportNamedDeclaration(null,[types.exportSpecifier(types.identifier(meta.identifierName),types.identifier(meta.identifierName))]))})},VariableDeclarator(declaratorPath){var _a;(_a=declaratorPath.parentPath.parentPath)!=null&&_a.isProgram()&&metas.some(meta=>types.isIdentifier(declaratorPath.node.id)&&meta.identifierName===declaratorPath.node.id.name)&&declaratorPath.remove()}})}function replaceImportWithParamterImport(path2,types,source,metas,filename){path2.replaceWithMultiple([...metas.map(meta=>types.importDeclaration([types.importDefaultSpecifier(types.identifier(meta.identifierName))],types.stringLiteral(`storybook-nextjs-font-loader?${JSON.stringify({source:source.value,props:meta.properties,fontFamily:meta.functionName,filename})}!${source.value}`)))])}function getVariableMetasBySpecifier(program,types,specifier){return program.node.body.map(statement=>{if(!types.isVariableDeclaration(statement)&&!types.isExportNamedDeclaration(statement))return;let exportedNamedDeclaration=!types.isVariableDeclaration(statement)&&types.isVariableDeclaration(statement.declaration)&&statement.declaration.declarations.length===1?statement.declaration.declarations[0]:null,declaration=types.isVariableDeclaration(statement)?statement.declarations[0]:exportedNamedDeclaration;if(!declaration||!types.isIdentifier(declaration.id)||!types.isCallExpression(declaration.init)||(!types.isIdentifier(declaration.init.callee)||specifier.type!=="ImportSpecifier"||specifier.imported.type!=="Identifier"||declaration.init.callee.name!==specifier.imported.name)&&(!types.isIdentifier(declaration.init.callee)||specifier.type!=="ImportDefaultSpecifier"||declaration.init.callee.name!==specifier.local.name))return;let options=declaration.init.arguments[0];if(!types.isObjectExpression(options))throw program.buildCodeFrameError("Please pass an options object to the call expression of @next/font functions");options.properties.forEach(property=>{if(types.isSpreadElement(property))throw program.buildCodeFrameError("Please do not use spread elements in the options object in @next/font function calls")});let identifierName=declaration.id.name,properties=convertNodeToJSON(types,options),functionName=declaration.init.callee.name;return{identifierName,properties,functionName}}).filter(isDefined)}function TransformFontImports({types}){return{name:"storybook-nextjs-font-imports",visitor:{ImportDeclaration(path2,state){let{node}=path2,{source}=node,{filename=""}=state;if(source.value==="@next/font/local"){let{specifiers}=node,specifier=specifiers[0];if(!path2.parentPath.isProgram())return;let program=path2.parentPath,variableMetas=getVariableMetasBySpecifier(program,types,specifier);removeTransformedVariableDeclarations(path2,types,variableMetas),replaceImportWithParamterImport(path2,types,source,variableMetas,filename)}if(source.value==="@next/font/google"){let{specifiers}=node,variableMetas=specifiers.flatMap(specifier=>{if(!path2.parentPath.isProgram())return[];let program=path2.parentPath;return getVariableMetasBySpecifier(program,types,specifier)}).filter(isDefined);removeTransformedVariableDeclarations(path2,types,variableMetas),replaceImportWithParamterImport(path2,types,source,variableMetas,filename)}}}}}function configureNextFont(baseConfig){var _a;baseConfig.plugins=[...baseConfig.plugins||[]],baseConfig.resolveLoader={...baseConfig.resolveLoader,alias:{...(_a=baseConfig.resolveLoader)==null?void 0:_a.alias,"storybook-nextjs-font-loader":require.resolve("./font/webpack/loader/storybook-nextjs-font-loader")}}}var addons=[(0,import_path2.dirname)(require.resolve((0,import_path2.join)("@storybook/preset-react-webpack","package.json"))),(0,import_path2.dirname)(require.resolve((0,import_path2.join)("@storybook/builder-webpack5","package.json")))],defaultFrameworkOptions={},frameworkOptions=async(_,options)=>{let config2=await options.presets.apply("framework");return typeof config2=="string"?{name:config2,options:defaultFrameworkOptions}:typeof config2>"u"?{name:require.resolve("@storybook/nextjs"),options:defaultFrameworkOptions}:{name:config2.name,options:{...defaultFrameworkOptions,...config2.options}}},core=async(config2,options)=>{let framework=await options.presets.apply("framework");return{...config2,builder:{name:(0,import_path2.dirname)(require.resolve((0,import_path2.join)("@storybook/builder-webpack5","package.json"))),options:typeof framework=="string"?{}:framework.options.builder||{}},renderer:(0,import_path2.dirname)(require.resolve((0,import_path2.join)("@storybook/react","package.json")))}},config=(entry=[])=>[...entry,require.resolve("@storybook/nextjs/preview.js")],babel=async baseConfig=>{var _a,_b,_c;let configPartial=(0,import_core.loadPartialConfig)({...baseConfig,filename:`${(0,import_core_common.getProjectRoot)()}/__fake__.js`}),options=configPartial==null?void 0:configPartial.options,isPresetConfigItem=preset=>typeof preset=="object"&&preset!==null&&"file"in preset;((_a=options==null?void 0:options.presets)==null?void 0:_a.find(preset=>{var _a2;return Array.isArray(preset)&&preset[0]==="next/babel"||preset==="next/babel"||isPresetConfigItem(preset)&&((_a2=preset.file)==null?void 0:_a2.request)==="next/babel"}))||(_b=options==null?void 0:options.presets)==null||_b.push("next/babel");let presets=(_c=options==null?void 0:options.presets)==null?void 0:_c.filter(preset=>{var _a2;return!(isPresetConfigItem(preset)&&((_a2=preset.file)==null?void 0:_a2.request)===require.resolve("@babel/preset-react"))}),plugins=[...(options==null?void 0:options.plugins)??[],TransformFontImports];return{...options,plugins,presets,babelrc:!1,configFile:!1}},webpackFinal=async(baseConfig,options)=>{let frameworkOptions2=await options.presets.apply("frameworkOptions"),{options:{nextConfigPath}={}}=frameworkOptions2,nextConfig=await configureConfig({baseConfig,nextConfigPath,configDir:options.configDir});return configureNextFont(baseConfig),configureNextImport(baseConfig),configureRuntimeNextjsVersionResolution(baseConfig),configureImports(baseConfig),configureCss(baseConfig,nextConfig),configureImages(baseConfig),configureRouting(baseConfig),configureStyledJsx(baseConfig),baseConfig};0&&(module.exports={addons,babel,config,core,frameworkOptions,webpackFinal});
|
package/dist/preset.mjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import{__require}from"./chunk-LAHENP5R.mjs";import{dirname,join}from"path";import{loadPartialConfig}from"@babel/core";import{getProjectRoot}from"@storybook/core-common";import semver from"semver";import{DefinePlugin as DefinePlugin2}from"webpack";import path from"path";import{DefinePlugin}from"webpack";import{PHASE_DEVELOPMENT_SERVER}from"next/constants";import findUp from"find-up";import{pathExists}from"fs-extra";import dedent from"ts-dedent";import{pathToFileURL}from"url";var configureRuntimeNextjsVersionResolution=baseConfig=>{baseConfig.plugins?.push(new DefinePlugin({"process.env.__NEXT_VERSION":JSON.stringify(getNextjsVersion())}))},getNextjsVersion=()=>__require(scopedResolve("next/package.json")).version,findNextConfigFile=async configDir=>["mjs","js"].reduce(async(acc,ext)=>(await acc||(acc=findUp(`next.config.${ext}`,{cwd:configDir})),acc),Promise.resolve(void 0)),resolveNextConfig=async({baseConfig={},nextConfigPath,configDir})=>{let nextConfigFile=nextConfigPath||await findNextConfigFile(configDir);if(!nextConfigFile||await pathExists(nextConfigFile)===!1)throw new Error(dedent`
|
|
2
|
-
Could not find or resolve your Next config file. Please provide the next config file path as a framework option.
|
|
3
|
-
|
|
4
|
-
More info: https://github.com/storybookjs/storybook/blob/next/code/frameworks/nextjs/README.md#options
|
|
5
|
-
`);let nextConfigExport=await import(pathToFileURL(nextConfigFile).href),nextConfig=typeof nextConfigExport=="function"?nextConfigExport(PHASE_DEVELOPMENT_SERVER,{defaultConfig:baseConfig}):nextConfigExport;return nextConfig.default||nextConfig},addScopedAlias=(baseConfig,name,alias)=>{baseConfig.resolve??={},baseConfig.resolve.alias??={};let aliasConfig=baseConfig.resolve.alias,scopedAlias=scopedResolve(`${alias??name}`);Array.isArray(aliasConfig)?aliasConfig.push({name,alias:scopedAlias}):aliasConfig[name]=scopedAlias},scopedResolve=id=>{let scopedModulePath=__require.resolve(id,{paths:[path.resolve()]}),beginningOfMainScriptPath=scopedModulePath.lastIndexOf(id.replace(/\//g,path.sep))+id.length;return scopedModulePath.substring(0,beginningOfMainScriptPath)};var configureConfig=async({baseConfig,nextConfigPath,configDir})=>{let nextConfig=await resolveNextConfig({baseConfig,nextConfigPath,configDir});return addScopedAlias(baseConfig,"next/config"),setupRuntimeConfig(baseConfig,nextConfig),nextConfig},version=getNextjsVersion(),setupRuntimeConfig=(baseConfig,nextConfig)=>{let definePluginConfig={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:nextConfig.publicRuntimeConfig})},newNextLinkBehavior=nextConfig.experimental?.newNextLinkBehavior;semver.gte(version,"13.0.0")&&semver.lt(version,"13.0.6")&&newNextLinkBehavior!==!1?definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=newNextLinkBehavior,baseConfig.plugins?.push(new DefinePlugin2(definePluginConfig))};import{getCssModuleLocalIdent}from"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent";import{cssFileResolve}from"next/dist/build/webpack/config/blocks/css/loaders/file-resolve";import semver2 from"semver";var configureCss=(baseConfig,nextConfig)=>{let rules=baseConfig.module?.rules;rules?.forEach((rule,i)=>{typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.css")&&(rules[i]={test:/\.css$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:1,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:getCssModuleLocalIdent}}},"postcss-loader"]})}),rules?.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:nextConfig.sassOptions,additionalData:nextConfig.sassOptions?.prependData||nextConfig.sassOptions?.additionalData}}]})},getImportAndUrlCssLoaderOptions=nextConfig=>isCssLoaderV6()?{url:{filter:getUrlResolver(nextConfig)},import:{filter:getImportResolver(nextConfig)}}:{url:getUrlResolver(nextConfig),import:getImportResolver(nextConfig)},getUrlResolver=nextConfig=>(url,resourcePath)=>cssFileResolve(url,resourcePath,nextConfig.experimental?.urlImports),getImportResolver=nextConfig=>(url,_,resourcePath)=>cssFileResolve(typeof url=="string"?url:url.url,resourcePath,nextConfig.experimental?.urlImports),isCssLoaderV6=()=>{try{let cssLoaderVersion=__require(scopedResolve("css-loader/package.json")).version;return semver2.gte(cssLoaderVersion,"6.0.0")}catch{return!1}};import TsconfigPathsPlugin from"tsconfig-paths-webpack-plugin";import{loadConfig}from"tsconfig-paths";var configureImports=baseConfig=>{let configLoadResult=loadConfig();configLoadResult.resultType==="failed"||!configLoadResult.baseUrl||(baseConfig.resolve??={},baseConfig.resolve.plugins??=[],baseConfig.resolve.plugins.push(new TsconfigPathsPlugin({configFile:configLoadResult.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};import semver3 from"semver";var configureRouting=baseConfig=>{let routerContextPath=getRouterContextPath();addScopedAlias(baseConfig,routerContextPath)},getRouterContextPath=()=>{let version2=getNextjsVersion();return semver3.gte(version2,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};import semver4 from"semver";var configureStyledJsx=baseConfig=>{let version2=getNextjsVersion();semver4.gte(version2,"12.0.0")?addScopedAlias(baseConfig,"styled-jsx"):(addScopedAlias(baseConfig,"styled-jsx/babel"),addScopedAlias(baseConfig,"styled-jsx/css"),addScopedAlias(baseConfig,"styled-jsx/macro"),addScopedAlias(baseConfig,"styled-jsx/server"),addScopedAlias(baseConfig,"styled-jsx/style"),addScopedAlias(baseConfig,"styled-jsx/webpack"))};import semver5 from"semver";var configureImages=baseConfig=>{configureStaticImageImport(baseConfig),addScopedAlias(baseConfig,"next/image")},configureStaticImageImport=baseConfig=>{let version2=getNextjsVersion();if(semver5.lt(version2,"11.0.0"))return;let rules=baseConfig.module?.rules,assetRule=rules?.find(rule=>typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.jpg"));!assetRule||(assetRule.test=/\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,rules?.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:{not:/\.(css|scss|sass)$/},use:[{loader:__require.resolve("@storybook/nextjs/next-image-loader-stub.js"),options:{filename:assetRule.generator?.filename}}]}),rules?.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:assetRule.generator?.filename}}))};import semver6 from"semver";import{IgnorePlugin}from"webpack";function configureNextImport(baseConfig){let nextJSVersion=getNextjsVersion(),isNext12=semver6.satisfies(nextJSVersion,"~12"),isNext13=semver6.satisfies(nextJSVersion,"~13"),isNextVersionSmallerThan12dot2=semver6.lt(nextJSVersion,"12.2.0"),isNextVersionSmallerThan13=semver6.lt(nextJSVersion,"13.0.0");baseConfig.plugins=baseConfig.plugins??[],isNext13||baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),(!isNext12||isNextVersionSmallerThan12dot2)&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/future\/image$/})),isNextVersionSmallerThan13&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),isNextVersionSmallerThan12dot2&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}var addons=[dirname(__require.resolve(join("@storybook/preset-react-webpack","package.json"))),dirname(__require.resolve(join("@storybook/builder-webpack5","package.json")))],defaultFrameworkOptions={},frameworkOptions=async(_,options)=>{let config2=await options.presets.apply("framework");return typeof config2=="string"?{name:config2,options:defaultFrameworkOptions}:typeof config2>"u"?{name:__require.resolve("@storybook/nextjs"),options:defaultFrameworkOptions}:{name:config2.name,options:{...defaultFrameworkOptions,...config2.options}}},core=async(config2,options)=>{let framework=await options.presets.apply("framework");return{...config2,builder:{name:dirname(__require.resolve(join("@storybook/builder-webpack5","package.json"))),options:typeof framework=="string"?{}:framework.options.builder||{}},renderer:dirname(__require.resolve(join("@storybook/react","package.json")))}},config=(entry=[])=>[...entry,__require.resolve("@storybook/nextjs/preview.js")],babel=async baseConfig=>{let options=loadPartialConfig({...baseConfig,filename:`${getProjectRoot()}/__fake__.js`})?.options,isPresetConfigItem=preset=>typeof preset=="object"&&preset!==null&&"file"in preset;options?.presets?.find(preset=>Array.isArray(preset)&&preset[0]==="next/babel"||preset==="next/babel"||isPresetConfigItem(preset)&&preset.file?.request==="next/babel")||options?.presets?.push("next/babel");let presets=options?.presets?.filter(preset=>!(isPresetConfigItem(preset)&&preset.file?.request===__require.resolve("@babel/preset-react")));return{...options,presets,babelrc:!1,configFile:!1}},webpackFinal=async(baseConfig,options)=>{let frameworkOptions2=await options.presets.apply("frameworkOptions"),{options:{nextConfigPath}={}}=frameworkOptions2,nextConfig=await configureConfig({baseConfig,nextConfigPath,configDir:options.configDir});return configureNextImport(baseConfig),configureRuntimeNextjsVersionResolution(baseConfig),configureImports(baseConfig),configureCss(baseConfig,nextConfig),configureImages(baseConfig),configureRouting(baseConfig),configureStyledJsx(baseConfig),baseConfig};export{addons,babel,config,core,frameworkOptions,webpackFinal};
|
|
1
|
+
import{__require}from"./chunk-4MG4OZFL.mjs";import{dirname,join}from"path";import{loadPartialConfig}from"@babel/core";import{getProjectRoot}from"@storybook/core-common";import semver from"semver";import{DefinePlugin as DefinePlugin2}from"webpack";import path from"path";import{DefinePlugin}from"webpack";import{PHASE_DEVELOPMENT_SERVER}from"next/constants";import findUp from"find-up";import{pathExists}from"fs-extra";import{pathToFileURL}from"url";var configureRuntimeNextjsVersionResolution=baseConfig=>{baseConfig.plugins?.push(new DefinePlugin({"process.env.__NEXT_VERSION":JSON.stringify(getNextjsVersion())}))},getNextjsVersion=()=>__require(scopedResolve("next/package.json")).version,findNextConfigFile=async configDir=>["mjs","js"].reduce(async(acc,ext)=>(await acc||(acc=findUp(`next.config.${ext}`,{cwd:configDir})),acc),Promise.resolve(void 0)),resolveNextConfig=async({baseConfig={},nextConfigPath,configDir})=>{let nextConfigFile=nextConfigPath||await findNextConfigFile(configDir);if(!nextConfigFile||await pathExists(nextConfigFile)===!1)return{};let nextConfigExport=await import(pathToFileURL(nextConfigFile).href),nextConfig=typeof nextConfigExport=="function"?nextConfigExport(PHASE_DEVELOPMENT_SERVER,{defaultConfig:baseConfig}):nextConfigExport;return nextConfig.default||nextConfig},addScopedAlias=(baseConfig,name,alias)=>{baseConfig.resolve??={},baseConfig.resolve.alias??={};let aliasConfig=baseConfig.resolve.alias,scopedAlias=scopedResolve(`${alias??name}`);Array.isArray(aliasConfig)?aliasConfig.push({name,alias:scopedAlias}):aliasConfig[name]=scopedAlias},scopedResolve=id=>{let scopedModulePath=__require.resolve(id,{paths:[path.resolve()]}),beginningOfMainScriptPath=scopedModulePath.lastIndexOf(id.replace(/\//g,path.sep))+id.length;return scopedModulePath.substring(0,beginningOfMainScriptPath)};var configureConfig=async({baseConfig,nextConfigPath,configDir})=>{let nextConfig=await resolveNextConfig({baseConfig,nextConfigPath,configDir});return addScopedAlias(baseConfig,"next/config"),setupRuntimeConfig(baseConfig,nextConfig),nextConfig},version=getNextjsVersion(),setupRuntimeConfig=(baseConfig,nextConfig)=>{let definePluginConfig={"process.env.__NEXT_RUNTIME_CONFIG":JSON.stringify({serverRuntimeConfig:{},publicRuntimeConfig:nextConfig.publicRuntimeConfig})},newNextLinkBehavior=nextConfig.experimental?.newNextLinkBehavior;semver.gte(version,"13.0.0")&&semver.lt(version,"13.0.6")&&newNextLinkBehavior!==!1?definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=!0:definePluginConfig["process.env.__NEXT_NEW_LINK_BEHAVIOR"]=newNextLinkBehavior,baseConfig.plugins?.push(new DefinePlugin2(definePluginConfig))};import{getCssModuleLocalIdent}from"next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent";import{cssFileResolve}from"next/dist/build/webpack/config/blocks/css/loaders/file-resolve";import semver2 from"semver";var configureCss=(baseConfig,nextConfig)=>{let rules=baseConfig.module?.rules;rules?.forEach((rule,i)=>{typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.css")&&(rules[i]={test:/\.css$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:1,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:getCssModuleLocalIdent}}},"postcss-loader"]})}),rules?.push({test:/\.(scss|sass)$/,use:["style-loader",{loader:"css-loader",options:{importLoaders:3,...getImportAndUrlCssLoaderOptions(nextConfig),modules:{auto:!0,getLocalIdent:getCssModuleLocalIdent}}},"postcss-loader","resolve-url-loader",{loader:"sass-loader",options:{sourceMap:!0,sassOptions:nextConfig.sassOptions,additionalData:nextConfig.sassOptions?.prependData||nextConfig.sassOptions?.additionalData}}]})},getImportAndUrlCssLoaderOptions=nextConfig=>isCssLoaderV6()?{url:{filter:getUrlResolver(nextConfig)},import:{filter:getImportResolver(nextConfig)}}:{url:getUrlResolver(nextConfig),import:getImportResolver(nextConfig)},getUrlResolver=nextConfig=>(url,resourcePath)=>cssFileResolve(url,resourcePath,nextConfig.experimental?.urlImports),getImportResolver=nextConfig=>(url,_,resourcePath)=>cssFileResolve(typeof url=="string"?url:url.url,resourcePath,nextConfig.experimental?.urlImports),isCssLoaderV6=()=>{try{let cssLoaderVersion=__require(scopedResolve("css-loader/package.json")).version;return semver2.gte(cssLoaderVersion,"6.0.0")}catch{return!1}};import TsconfigPathsPlugin from"tsconfig-paths-webpack-plugin";import{loadConfig}from"tsconfig-paths";var configureImports=baseConfig=>{let configLoadResult=loadConfig();configLoadResult.resultType==="failed"||!configLoadResult.baseUrl||(baseConfig.resolve??={},baseConfig.resolve.plugins??=[],baseConfig.resolve.plugins.push(new TsconfigPathsPlugin({configFile:configLoadResult.configFileAbsolutePath,extensions:[".js",".jsx",".ts",".tsx"]})))};import semver3 from"semver";var configureRouting=baseConfig=>{let routerContextPath=getRouterContextPath();addScopedAlias(baseConfig,routerContextPath)},getRouterContextPath=()=>{let version2=getNextjsVersion();return semver3.gte(version2,"11.1.0")?"next/dist/shared/lib/router-context":"next/dist/next-server/lib/router-context"};import semver4 from"semver";var configureStyledJsx=baseConfig=>{let version2=getNextjsVersion();semver4.gte(version2,"12.0.0")?addScopedAlias(baseConfig,"styled-jsx"):(addScopedAlias(baseConfig,"styled-jsx/babel"),addScopedAlias(baseConfig,"styled-jsx/css"),addScopedAlias(baseConfig,"styled-jsx/macro"),addScopedAlias(baseConfig,"styled-jsx/server"),addScopedAlias(baseConfig,"styled-jsx/style"),addScopedAlias(baseConfig,"styled-jsx/webpack"))};import semver5 from"semver";var configureImages=baseConfig=>{configureStaticImageImport(baseConfig),addScopedAlias(baseConfig,"next/image")},configureStaticImageImport=baseConfig=>{let version2=getNextjsVersion();if(semver5.lt(version2,"11.0.0"))return;let rules=baseConfig.module?.rules,assetRule=rules?.find(rule=>typeof rule!="string"&&rule.test instanceof RegExp&&rule.test.test("test.jpg"));assetRule&&(assetRule.test=/\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,rules?.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:{not:/\.(css|scss|sass)$/},use:[{loader:__require.resolve("@storybook/nextjs/next-image-loader-stub.js"),options:{filename:assetRule.generator?.filename}}]}),rules?.push({test:/\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,issuer:/\.(css|scss|sass)$/,type:"asset/resource",generator:{filename:assetRule.generator?.filename}}))};import semver6 from"semver";import{IgnorePlugin}from"webpack";function configureNextImport(baseConfig){let nextJSVersion=getNextjsVersion(),isNext12=semver6.satisfies(nextJSVersion,"~12"),isNext13=semver6.satisfies(nextJSVersion,"~13"),isNextVersionSmallerThan12dot2=semver6.lt(nextJSVersion,"12.2.0"),isNextVersionSmallerThan13=semver6.lt(nextJSVersion,"13.0.0");baseConfig.plugins=baseConfig.plugins??[],isNext13||baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/legacy\/image$/})),(!isNext12||isNextVersionSmallerThan12dot2)&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/future\/image$/})),isNextVersionSmallerThan13&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/hooks-client-context$/})),isNextVersionSmallerThan12dot2&&baseConfig.plugins.push(new IgnorePlugin({resourceRegExp:/next\/dist\/shared\/lib\/app-router-context$/}))}function convertNodeToJSON(types,node){if(types.isBooleanLiteral(node)||types.isStringLiteral(node)||types.isNumericLiteral(node))return node.value;if(!(node.name==="undefined"&&!node.value))return types.isNullLiteral(node)?null:types.isObjectExpression(node)?computeProps(types,node.properties):types.isArrayExpression(node)?node.elements.reduce((acc,element)=>[...acc,...element?.type==="SpreadElement"?convertNodeToJSON(types,element.argument):[convertNodeToJSON(types,element)]],[]):{}}function computeProps(types,props){return props.reduce((acc,prop)=>{if(prop.type==="SpreadElement")return{...acc,...convertNodeToJSON(types,prop.argument)};if(prop.type!=="ObjectMethod"){let val=convertNodeToJSON(types,prop.value);if(val!==void 0&&types.isIdentifier(prop.key))return{...acc,[prop.key.name]:val}}return acc},{})}function isDefined(value){return value!==void 0}function removeTransformedVariableDeclarations(path2,types,metas){path2.parentPath.traverse({ExportNamedDeclaration(declaratorPath){declaratorPath.parentPath?.isProgram()&&metas.forEach(meta=>{types.isVariableDeclaration(declaratorPath.node.declaration)&&declaratorPath.node.declaration.declarations.length===1&&types.isVariableDeclarator(declaratorPath.node.declaration.declarations[0])&&types.isIdentifier(declaratorPath.node.declaration.declarations[0].id)&&meta.identifierName===declaratorPath.node.declaration.declarations[0].id.name&&declaratorPath.replaceWith(types.exportNamedDeclaration(null,[types.exportSpecifier(types.identifier(meta.identifierName),types.identifier(meta.identifierName))]))})},VariableDeclarator(declaratorPath){declaratorPath.parentPath.parentPath?.isProgram()&&metas.some(meta=>types.isIdentifier(declaratorPath.node.id)&&meta.identifierName===declaratorPath.node.id.name)&&declaratorPath.remove()}})}function replaceImportWithParamterImport(path2,types,source,metas,filename){path2.replaceWithMultiple([...metas.map(meta=>types.importDeclaration([types.importDefaultSpecifier(types.identifier(meta.identifierName))],types.stringLiteral(`storybook-nextjs-font-loader?${JSON.stringify({source:source.value,props:meta.properties,fontFamily:meta.functionName,filename})}!${source.value}`)))])}function getVariableMetasBySpecifier(program,types,specifier){return program.node.body.map(statement=>{if(!types.isVariableDeclaration(statement)&&!types.isExportNamedDeclaration(statement))return;let exportedNamedDeclaration=!types.isVariableDeclaration(statement)&&types.isVariableDeclaration(statement.declaration)&&statement.declaration.declarations.length===1?statement.declaration.declarations[0]:null,declaration=types.isVariableDeclaration(statement)?statement.declarations[0]:exportedNamedDeclaration;if(!declaration||!types.isIdentifier(declaration.id)||!types.isCallExpression(declaration.init)||(!types.isIdentifier(declaration.init.callee)||specifier.type!=="ImportSpecifier"||specifier.imported.type!=="Identifier"||declaration.init.callee.name!==specifier.imported.name)&&(!types.isIdentifier(declaration.init.callee)||specifier.type!=="ImportDefaultSpecifier"||declaration.init.callee.name!==specifier.local.name))return;let options=declaration.init.arguments[0];if(!types.isObjectExpression(options))throw program.buildCodeFrameError("Please pass an options object to the call expression of @next/font functions");options.properties.forEach(property=>{if(types.isSpreadElement(property))throw program.buildCodeFrameError("Please do not use spread elements in the options object in @next/font function calls")});let identifierName=declaration.id.name,properties=convertNodeToJSON(types,options),functionName=declaration.init.callee.name;return{identifierName,properties,functionName}}).filter(isDefined)}function TransformFontImports({types}){return{name:"storybook-nextjs-font-imports",visitor:{ImportDeclaration(path2,state){let{node}=path2,{source}=node,{filename=""}=state;if(source.value==="@next/font/local"){let{specifiers}=node,specifier=specifiers[0];if(!path2.parentPath.isProgram())return;let program=path2.parentPath,variableMetas=getVariableMetasBySpecifier(program,types,specifier);removeTransformedVariableDeclarations(path2,types,variableMetas),replaceImportWithParamterImport(path2,types,source,variableMetas,filename)}if(source.value==="@next/font/google"){let{specifiers}=node,variableMetas=specifiers.flatMap(specifier=>{if(!path2.parentPath.isProgram())return[];let program=path2.parentPath;return getVariableMetasBySpecifier(program,types,specifier)}).filter(isDefined);removeTransformedVariableDeclarations(path2,types,variableMetas),replaceImportWithParamterImport(path2,types,source,variableMetas,filename)}}}}}function configureNextFont(baseConfig){baseConfig.plugins=[...baseConfig.plugins||[]],baseConfig.resolveLoader={...baseConfig.resolveLoader,alias:{...baseConfig.resolveLoader?.alias,"storybook-nextjs-font-loader":__require.resolve("./font/webpack/loader/storybook-nextjs-font-loader")}}}var addons=[dirname(__require.resolve(join("@storybook/preset-react-webpack","package.json"))),dirname(__require.resolve(join("@storybook/builder-webpack5","package.json")))],defaultFrameworkOptions={},frameworkOptions=async(_,options)=>{let config2=await options.presets.apply("framework");return typeof config2=="string"?{name:config2,options:defaultFrameworkOptions}:typeof config2>"u"?{name:__require.resolve("@storybook/nextjs"),options:defaultFrameworkOptions}:{name:config2.name,options:{...defaultFrameworkOptions,...config2.options}}},core=async(config2,options)=>{let framework=await options.presets.apply("framework");return{...config2,builder:{name:dirname(__require.resolve(join("@storybook/builder-webpack5","package.json"))),options:typeof framework=="string"?{}:framework.options.builder||{}},renderer:dirname(__require.resolve(join("@storybook/react","package.json")))}},config=(entry=[])=>[...entry,__require.resolve("@storybook/nextjs/preview.js")],babel=async baseConfig=>{let options=loadPartialConfig({...baseConfig,filename:`${getProjectRoot()}/__fake__.js`})?.options,isPresetConfigItem=preset=>typeof preset=="object"&&preset!==null&&"file"in preset;options?.presets?.find(preset=>Array.isArray(preset)&&preset[0]==="next/babel"||preset==="next/babel"||isPresetConfigItem(preset)&&preset.file?.request==="next/babel")||options?.presets?.push("next/babel");let presets=options?.presets?.filter(preset=>!(isPresetConfigItem(preset)&&preset.file?.request===__require.resolve("@babel/preset-react"))),plugins=[...options?.plugins??[],TransformFontImports];return{...options,plugins,presets,babelrc:!1,configFile:!1}},webpackFinal=async(baseConfig,options)=>{let frameworkOptions2=await options.presets.apply("frameworkOptions"),{options:{nextConfigPath}={}}=frameworkOptions2,nextConfig=await configureConfig({baseConfig,nextConfigPath,configDir:options.configDir});return configureNextFont(baseConfig),configureNextImport(baseConfig),configureRuntimeNextjsVersionResolution(baseConfig),configureImports(baseConfig),configureCss(baseConfig,nextConfig),configureImages(baseConfig),configureRouting(baseConfig),configureStyledJsx(baseConfig),baseConfig};export{addons,babel,config,core,frameworkOptions,webpackFinal};
|
package/dist/preview.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var
|
|
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 __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 __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 app_router_provider_exports={};__export(app_router_provider_exports,{default:()=>app_router_provider_default});var import_react2,import_app_router_context,import_hooks_client_context,getParallelRoutes,AppRouterProvider,app_router_provider_default,init_app_router_provider=__esm({"src/routing/app-router-provider.tsx"(){"use strict";import_react2=__toESM(require("react")),import_app_router_context=require("next/dist/shared/lib/app-router-context"),import_hooks_client_context=require("next/dist/shared/lib/hooks-client-context"),getParallelRoutes=segmentsList=>{let segment=segmentsList.shift();return segment?[segment,{children:getParallelRoutes(segmentsList)}]:[]},AppRouterProvider=({children,action:action2,routeParams})=>{let{pathname,query,segments=[],...restRouteParams}=routeParams;return import_react2.default.createElement(import_app_router_context.AppRouterContext.Provider,{value:{push(...args){action2("nextNavigation.push")(...args)},replace(...args){action2("nextNavigation.replace")(...args)},forward(...args){action2("nextNavigation.forward")(...args)},back(...args){action2("nextNavigation.back")(...args)},prefetch(...args){action2("nextNavigation.prefetch")(...args)},refresh:()=>{action2("nextNavigation.refresh")()},...restRouteParams}},import_react2.default.createElement(import_hooks_client_context.SearchParamsContext.Provider,{value:new URLSearchParams(query)},import_react2.default.createElement(import_app_router_context.LayoutRouterContext.Provider,{value:{childNodes:new Map,tree:[pathname,{children:getParallelRoutes([...segments])}],url:pathname}},import_react2.default.createElement(import_hooks_client_context.PathnameContext.Provider,{value:pathname},children))))},app_router_provider_default=AppRouterProvider}});var require_client_only=__commonJS({"../../node_modules/client-only/index.js"(){}});var require_index=__commonJS({"../../node_modules/styled-jsx/dist/index/index.js"(exports){require_client_only();var React8=require("react");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React8);function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}var isProd=typeof process<"u"&&process.env&&process.env.NODE_ENV==="production",isString=function(o){return Object.prototype.toString.call(o)==="[object String]"},StyleSheet=function(){function StyleSheet2(param){var ref=param===void 0?{}:param,_name=ref.name,name=_name===void 0?"stylesheet":_name,_optimizeForSpeed=ref.optimizeForSpeed,optimizeForSpeed=_optimizeForSpeed===void 0?isProd:_optimizeForSpeed;invariant$1(isString(name),"`name` must be a string"),this._name=name,this._deletedRulePlaceholder="#"+name+"-deleted-rule____{}",invariant$1(typeof optimizeForSpeed=="boolean","`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=optimizeForSpeed,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var node=typeof window<"u"&&document.querySelector('meta[property="csp-nonce"]');this._nonce=node?node.getAttribute("content"):null}var _proto=StyleSheet2.prototype;return _proto.setOptimizeForSpeed=function(bool){invariant$1(typeof bool=="boolean","`setOptimizeForSpeed` accepts a boolean"),invariant$1(this._rulesCount===0,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=bool,this.inject()},_proto.isOptimizeForSpeed=function(){return this._optimizeForSpeed},_proto.inject=function(){var _this=this;if(invariant$1(!this._injected,"sheet already injected"),this._injected=!0,typeof window<"u"&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(isProd||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(rule,index){return typeof index=="number"?_this._serverSheet.cssRules[index]={cssText:rule}:_this._serverSheet.cssRules.push({cssText:rule}),index},deleteRule:function(index){_this._serverSheet.cssRules[index]=null}}},_proto.getSheetForTag=function(tag){if(tag.sheet)return tag.sheet;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].ownerNode===tag)return document.styleSheets[i]},_proto.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},_proto.insertRule=function(rule,index){if(invariant$1(isString(rule),"`insertRule` accepts only strings"),typeof window>"u")return typeof index!="number"&&(index=this._serverSheet.cssRules.length),this._serverSheet.insertRule(rule,index),this._rulesCount++;if(this._optimizeForSpeed){var sheet=this.getSheet();typeof index!="number"&&(index=sheet.cssRules.length);try{sheet.insertRule(rule,index)}catch{return isProd||console.warn(`StyleSheet: illegal rule:
|
|
2
2
|
|
|
3
|
-
`+
|
|
3
|
+
`+rule+`
|
|
4
4
|
|
|
5
|
-
See https://stackoverflow.com/q/20007992 for more info`),-1}}else{var
|
|
5
|
+
See https://stackoverflow.com/q/20007992 for more info`),-1}}else{var insertionPoint=this._tags[index];this._tags.push(this.makeStyleTag(this._name,rule,insertionPoint))}return this._rulesCount++},_proto.replaceRule=function(index,rule){if(this._optimizeForSpeed||typeof window>"u"){var sheet=typeof window<"u"?this.getSheet():this._serverSheet;if(rule.trim()||(rule=this._deletedRulePlaceholder),!sheet.cssRules[index])return index;sheet.deleteRule(index);try{sheet.insertRule(rule,index)}catch{isProd||console.warn(`StyleSheet: illegal rule:
|
|
6
6
|
|
|
7
|
-
`+
|
|
7
|
+
`+rule+`
|
|
8
8
|
|
|
9
|
-
See https://stackoverflow.com/q/20007992 for more info`),
|
|
10
|
-
`)]}).filter(function(
|
|
9
|
+
See https://stackoverflow.com/q/20007992 for more info`),sheet.insertRule(this._deletedRulePlaceholder,index)}}else{var tag=this._tags[index];invariant$1(tag,"old rule at index `"+index+"` not found"),tag.textContent=rule}return index},_proto.deleteRule=function(index){if(typeof window>"u"){this._serverSheet.deleteRule(index);return}if(this._optimizeForSpeed)this.replaceRule(index,"");else{var tag=this._tags[index];invariant$1(tag,"rule at index `"+index+"` not found"),tag.parentNode.removeChild(tag),this._tags[index]=null}},_proto.flush=function(){this._injected=!1,this._rulesCount=0,typeof window<"u"?(this._tags.forEach(function(tag){return tag&&tag.parentNode.removeChild(tag)}),this._tags=[]):this._serverSheet.cssRules=[]},_proto.cssRules=function(){var _this=this;return typeof window>"u"?this._serverSheet.cssRules:this._tags.reduce(function(rules,tag){return tag?rules=rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules,function(rule){return rule.cssText===_this._deletedRulePlaceholder?null:rule})):rules.push(null),rules},[])},_proto.makeStyleTag=function(name,cssString,relativeToTag){cssString&&invariant$1(isString(cssString),"makeStyleTag accepts only strings as second parameter");var tag=document.createElement("style");this._nonce&&tag.setAttribute("nonce",this._nonce),tag.type="text/css",tag.setAttribute("data-"+name,""),cssString&&tag.appendChild(document.createTextNode(cssString));var head=document.head||document.getElementsByTagName("head")[0];return relativeToTag?head.insertBefore(tag,relativeToTag):head.appendChild(tag),tag},_createClass(StyleSheet2,[{key:"length",get:function(){return this._rulesCount}}]),StyleSheet2}();function invariant$1(condition,message){if(!condition)throw new Error("StyleSheet: "+message+".")}function hash(str){for(var _$hash=5381,i=str.length;i;)_$hash=_$hash*33^str.charCodeAt(--i);return _$hash>>>0}var stringHash=hash,sanitize=function(rule){return rule.replace(/\/style/gi,"\\/style")},cache={};function computeId(baseId,props){if(!props)return"jsx-"+baseId;var propsToString=String(props),key=baseId+propsToString;return cache[key]||(cache[key]="jsx-"+stringHash(baseId+"-"+propsToString)),cache[key]}function computeSelector(id,css){var selectoPlaceholderRegexp=/__jsx-style-dynamic-selector/g;typeof window>"u"&&(css=sanitize(css));var idcss=id+css;return cache[idcss]||(cache[idcss]=css.replace(selectoPlaceholderRegexp,id)),cache[idcss]}function mapRulesToStyle(cssRules,options){return options===void 0&&(options={}),cssRules.map(function(args){var id=args[0],css=args[1];return React__default.default.createElement("style",{id:"__"+id,key:"__"+id,nonce:options.nonce?options.nonce:void 0,dangerouslySetInnerHTML:{__html:css}})})}var StyleSheetRegistry=function(){function StyleSheetRegistry2(param){var ref=param===void 0?{}:param,_styleSheet=ref.styleSheet,styleSheet=_styleSheet===void 0?null:_styleSheet,_optimizeForSpeed=ref.optimizeForSpeed,optimizeForSpeed=_optimizeForSpeed===void 0?!1:_optimizeForSpeed;this._sheet=styleSheet||new StyleSheet({name:"styled-jsx",optimizeForSpeed}),this._sheet.inject(),styleSheet&&typeof optimizeForSpeed=="boolean"&&(this._sheet.setOptimizeForSpeed(optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var _proto=StyleSheetRegistry2.prototype;return _proto.add=function(props){var _this=this;this._optimizeForSpeed===void 0&&(this._optimizeForSpeed=Array.isArray(props.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),typeof window<"u"&&!this._fromServer&&(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(acc,tagName){return acc[tagName]=0,acc},{}));var ref=this.getIdAndRules(props),styleId=ref.styleId,rules=ref.rules;if(styleId in this._instancesCounts){this._instancesCounts[styleId]+=1;return}var indices=rules.map(function(rule){return _this._sheet.insertRule(rule)}).filter(function(index){return index!==-1});this._indices[styleId]=indices,this._instancesCounts[styleId]=1},_proto.remove=function(props){var _this=this,styleId=this.getIdAndRules(props).styleId;if(invariant(styleId in this._instancesCounts,"styleId: `"+styleId+"` not found"),this._instancesCounts[styleId]-=1,this._instancesCounts[styleId]<1){var tagFromServer=this._fromServer&&this._fromServer[styleId];tagFromServer?(tagFromServer.parentNode.removeChild(tagFromServer),delete this._fromServer[styleId]):(this._indices[styleId].forEach(function(index){return _this._sheet.deleteRule(index)}),delete this._indices[styleId]),delete this._instancesCounts[styleId]}},_proto.update=function(props,nextProps){this.add(nextProps),this.remove(props)},_proto.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},_proto.cssRules=function(){var _this=this,fromServer=this._fromServer?Object.keys(this._fromServer).map(function(styleId){return[styleId,_this._fromServer[styleId]]}):[],cssRules2=this._sheet.cssRules();return fromServer.concat(Object.keys(this._indices).map(function(styleId){return[styleId,_this._indices[styleId].map(function(index){return cssRules2[index].cssText}).join(_this._optimizeForSpeed?"":`
|
|
10
|
+
`)]}).filter(function(rule){return Boolean(rule[1])}))},_proto.styles=function(options){return mapRulesToStyle(this.cssRules(),options)},_proto.getIdAndRules=function(props){var css=props.children,dynamic=props.dynamic,id=props.id;if(dynamic){var styleId=computeId(id,dynamic);return{styleId,rules:Array.isArray(css)?css.map(function(rule){return computeSelector(styleId,rule)}):[computeSelector(styleId,css)]}}return{styleId:computeId(id),rules:Array.isArray(css)?css:[css]}},_proto.selectFromServer=function(){var elements=Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));return elements.reduce(function(acc,element){var id=element.id.slice(2);return acc[id]=element,acc},{})},StyleSheetRegistry2}();function invariant(condition,message){if(!condition)throw new Error("StyleSheetRegistry: "+message+".")}var StyleSheetContext=React8.createContext(null);StyleSheetContext.displayName="StyleSheetContext";function createStyleRegistry(){return new StyleSheetRegistry}function StyleRegistry2(param){var configuredRegistry=param.registry,children=param.children,rootRegistry=React8.useContext(StyleSheetContext),ref=React8.useState(function(){return rootRegistry||configuredRegistry||createStyleRegistry()}),registry=ref[0];return React__default.default.createElement(StyleSheetContext.Provider,{value:registry},children)}function useStyleRegistry(){return React8.useContext(StyleSheetContext)}var useInsertionEffect=React__default.default.useInsertionEffect||React__default.default.useLayoutEffect,defaultRegistry=typeof window<"u"?createStyleRegistry():void 0;function JSXStyle(props){var registry=defaultRegistry||useStyleRegistry();return registry?typeof window>"u"?(registry.add(props),null):(useInsertionEffect(function(){return registry.add(props),function(){registry.remove(props)}},[props.id,String(props.dynamic)]),null):null}JSXStyle.dynamic=function(info){return info.map(function(tagInfo){var baseId=tagInfo[0],props=tagInfo[1];return computeId(baseId,props)}).join(" ")};exports.StyleRegistry=StyleRegistry2;exports.createStyleRegistry=createStyleRegistry;exports.style=JSXStyle;exports.useStyleRegistry=useStyleRegistry}});var require_styled_jsx=__commonJS({"../../node_modules/styled-jsx/index.js"(exports,module2){module2.exports=require_index()}});var preview_exports={};__export(preview_exports,{decorators:()=>decorators});module.exports=__toCommonJS(preview_exports);var import_config=require("next/config");(0,import_config.setConfig)(process.env.__NEXT_RUNTIME_CONFIG);var React3=__toESM(require("react"));var import_router_context=require("next/dist/shared/lib/router-context"),import_react=__toESM(require("react")),PageRouterProvider=({children,action:action2,routeParams,globals})=>import_react.default.createElement(import_router_context.RouterContext.Provider,{value:{push(...args){return action2("nextRouter.push")(...args),Promise.resolve(!0)},replace(...args){return action2("nextRouter.replace")(...args),Promise.resolve(!0)},reload(...args){action2("nextRouter.reload")(...args)},back(...args){action2("nextRouter.back")(...args)},forward(){action2("nextRouter.forward")()},prefetch(...args){return action2("nextRouter.prefetch")(...args),Promise.resolve()},beforePopState(...args){action2("nextRouter.beforePopState")(...args)},events:{on(...args){action2("nextRouter.events.on")(...args)},off(...args){action2("nextRouter.events.off")(...args)},emit(...args){action2("nextRouter.events.emit")(...args)}},locale:globals==null?void 0:globals.locale,route:"/",asPath:"/",basePath:"/",isFallback:!1,isLocaleDomain:!1,isReady:!0,isPreview:!1,...routeParams}},children),page_router_provider_default=PageRouterProvider;var AppRouterProvider2=React3.lazy(()=>Promise.resolve().then(()=>(init_app_router_provider(),app_router_provider_exports))),action;try{action=require("@storybook/addon-actions").action}catch{action=()=>()=>{}}var defaultRouterParams={pathname:"/",query:{}},RouterDecorator=(Story,{globals,parameters})=>{var _a,_b,_c;return((_a=parameters.nextjs)==null?void 0:_a.appDirectory)??!1?React3.createElement(AppRouterProvider2,{action,routeParams:{...defaultRouterParams,...(_b=parameters.nextjs)==null?void 0:_b.navigation}},React3.createElement(Story,null)):React3.createElement(page_router_provider_default,{action,globals,routeParams:{...defaultRouterParams,...(_c=parameters.nextjs)==null?void 0:_c.router}},React3.createElement(Story,null))};var React4=__toESM(require("react")),StyleRegistry;try{StyleRegistry=require_styled_jsx().StyleRegistry}catch{StyleRegistry=React4.Fragment}var StyledJsxDecorator=Story=>React4.createElement(StyleRegistry,null,React4.createElement(Story,null));var React5=__toESM(require("react")),import_semver=__toESM(require("semver")),defaultLoader=({src,width,quality})=>{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})}`);return`${src}?w=${width}&q=${quality??75}`},NextImage=require("next/image"),OriginalNextImage=NextImage.default;Object.defineProperty(NextImage,"default",{configurable:!0,value:props=>React5.createElement(OriginalNextImage,{...props,loader:props.loader??defaultLoader})});if(import_semver.default.satisfies(process.env.__NEXT_VERSION,"^13.0.0")){let OriginalNextLegacyImage=require("next/legacy/image").default;Object.defineProperty(OriginalNextLegacyImage,"default",{configurable:!0,value:props=>React5.createElement(OriginalNextLegacyImage,{...props,loader:props.loader??defaultLoader})})}if(import_semver.default.satisfies(process.env.__NEXT_VERSION,"^12.2.0")){let OriginalNextFutureImage=require("next/future/image").default;Object.defineProperty(OriginalNextFutureImage,"default",{configurable:!0,value:props=>React5.createElement(OriginalNextFutureImage,{...props,loader:props.loader??defaultLoader})})}var React7=__toESM(require("react"));var import_react3=__toESM(require("react")),import_head_manager_context=require("next/dist/shared/lib/head-manager-context"),import_head_manager=__toESM(require("next/dist/client/head-manager")),HeadManagerProvider=({children})=>{let headManager=(0,import_react3.useMemo)(import_head_manager.default,[]);return headManager.getIsSsr=()=>!1,import_react3.default.createElement(import_head_manager_context.HeadManagerContext.Provider,{value:headManager},children)},head_manager_provider_default=HeadManagerProvider;var HeadManagerDecorator=Story=>React7.createElement(head_manager_provider_default,null,React7.createElement(Story,null));function addNextHeadCount(){let meta=document.createElement("meta");meta.name="next-head-count",meta.content="0",document.head.appendChild(meta)}addNextHeadCount();var decorators=[StyledJsxDecorator,RouterDecorator,HeadManagerDecorator];0&&(module.exports={decorators});
|
package/dist/preview.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__commonJS,__require}from"./chunk-
|
|
1
|
+
import{__commonJS,__require}from"./chunk-4MG4OZFL.mjs";var require_client_only=__commonJS({"../../node_modules/client-only/index.js"(){}});var require_index=__commonJS({"../../node_modules/styled-jsx/dist/index/index.js"(exports){require_client_only();var React7=__require("react");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React7);function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}var isProd=typeof process<"u"&&process.env&&process.env.NODE_ENV==="production",isString=function(o){return Object.prototype.toString.call(o)==="[object String]"},StyleSheet=function(){function StyleSheet2(param){var ref=param===void 0?{}:param,_name=ref.name,name=_name===void 0?"stylesheet":_name,_optimizeForSpeed=ref.optimizeForSpeed,optimizeForSpeed=_optimizeForSpeed===void 0?isProd:_optimizeForSpeed;invariant$1(isString(name),"`name` must be a string"),this._name=name,this._deletedRulePlaceholder="#"+name+"-deleted-rule____{}",invariant$1(typeof optimizeForSpeed=="boolean","`optimizeForSpeed` must be a boolean"),this._optimizeForSpeed=optimizeForSpeed,this._serverSheet=void 0,this._tags=[],this._injected=!1,this._rulesCount=0;var node=typeof window<"u"&&document.querySelector('meta[property="csp-nonce"]');this._nonce=node?node.getAttribute("content"):null}var _proto=StyleSheet2.prototype;return _proto.setOptimizeForSpeed=function(bool){invariant$1(typeof bool=="boolean","`setOptimizeForSpeed` accepts a boolean"),invariant$1(this._rulesCount===0,"optimizeForSpeed cannot be when rules have already been inserted"),this.flush(),this._optimizeForSpeed=bool,this.inject()},_proto.isOptimizeForSpeed=function(){return this._optimizeForSpeed},_proto.inject=function(){var _this=this;if(invariant$1(!this._injected,"sheet already injected"),this._injected=!0,typeof window<"u"&&this._optimizeForSpeed){this._tags[0]=this.makeStyleTag(this._name),this._optimizeForSpeed="insertRule"in this.getSheet(),this._optimizeForSpeed||(isProd||console.warn("StyleSheet: optimizeForSpeed mode not supported falling back to standard mode."),this.flush(),this._injected=!0);return}this._serverSheet={cssRules:[],insertRule:function(rule,index){return typeof index=="number"?_this._serverSheet.cssRules[index]={cssText:rule}:_this._serverSheet.cssRules.push({cssText:rule}),index},deleteRule:function(index){_this._serverSheet.cssRules[index]=null}}},_proto.getSheetForTag=function(tag){if(tag.sheet)return tag.sheet;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].ownerNode===tag)return document.styleSheets[i]},_proto.getSheet=function(){return this.getSheetForTag(this._tags[this._tags.length-1])},_proto.insertRule=function(rule,index){if(invariant$1(isString(rule),"`insertRule` accepts only strings"),typeof window>"u")return typeof index!="number"&&(index=this._serverSheet.cssRules.length),this._serverSheet.insertRule(rule,index),this._rulesCount++;if(this._optimizeForSpeed){var sheet=this.getSheet();typeof index!="number"&&(index=sheet.cssRules.length);try{sheet.insertRule(rule,index)}catch{return isProd||console.warn(`StyleSheet: illegal rule:
|
|
2
2
|
|
|
3
3
|
`+rule+`
|
|
4
4
|
|
|
@@ -7,4 +7,4 @@ See https://stackoverflow.com/q/20007992 for more info`),-1}}else{var insertionP
|
|
|
7
7
|
`+rule+`
|
|
8
8
|
|
|
9
9
|
See https://stackoverflow.com/q/20007992 for more info`),sheet.insertRule(this._deletedRulePlaceholder,index)}}else{var tag=this._tags[index];invariant$1(tag,"old rule at index `"+index+"` not found"),tag.textContent=rule}return index},_proto.deleteRule=function(index){if(typeof window>"u"){this._serverSheet.deleteRule(index);return}if(this._optimizeForSpeed)this.replaceRule(index,"");else{var tag=this._tags[index];invariant$1(tag,"rule at index `"+index+"` not found"),tag.parentNode.removeChild(tag),this._tags[index]=null}},_proto.flush=function(){this._injected=!1,this._rulesCount=0,typeof window<"u"?(this._tags.forEach(function(tag){return tag&&tag.parentNode.removeChild(tag)}),this._tags=[]):this._serverSheet.cssRules=[]},_proto.cssRules=function(){var _this=this;return typeof window>"u"?this._serverSheet.cssRules:this._tags.reduce(function(rules,tag){return tag?rules=rules.concat(Array.prototype.map.call(_this.getSheetForTag(tag).cssRules,function(rule){return rule.cssText===_this._deletedRulePlaceholder?null:rule})):rules.push(null),rules},[])},_proto.makeStyleTag=function(name,cssString,relativeToTag){cssString&&invariant$1(isString(cssString),"makeStyleTag accepts only strings as second parameter");var tag=document.createElement("style");this._nonce&&tag.setAttribute("nonce",this._nonce),tag.type="text/css",tag.setAttribute("data-"+name,""),cssString&&tag.appendChild(document.createTextNode(cssString));var head=document.head||document.getElementsByTagName("head")[0];return relativeToTag?head.insertBefore(tag,relativeToTag):head.appendChild(tag),tag},_createClass(StyleSheet2,[{key:"length",get:function(){return this._rulesCount}}]),StyleSheet2}();function invariant$1(condition,message){if(!condition)throw new Error("StyleSheet: "+message+".")}function hash(str){for(var _$hash=5381,i=str.length;i;)_$hash=_$hash*33^str.charCodeAt(--i);return _$hash>>>0}var stringHash=hash,sanitize=function(rule){return rule.replace(/\/style/gi,"\\/style")},cache={};function computeId(baseId,props){if(!props)return"jsx-"+baseId;var propsToString=String(props),key=baseId+propsToString;return cache[key]||(cache[key]="jsx-"+stringHash(baseId+"-"+propsToString)),cache[key]}function computeSelector(id,css){var selectoPlaceholderRegexp=/__jsx-style-dynamic-selector/g;typeof window>"u"&&(css=sanitize(css));var idcss=id+css;return cache[idcss]||(cache[idcss]=css.replace(selectoPlaceholderRegexp,id)),cache[idcss]}function mapRulesToStyle(cssRules,options){return options===void 0&&(options={}),cssRules.map(function(args){var id=args[0],css=args[1];return React__default.default.createElement("style",{id:"__"+id,key:"__"+id,nonce:options.nonce?options.nonce:void 0,dangerouslySetInnerHTML:{__html:css}})})}var StyleSheetRegistry=function(){function StyleSheetRegistry2(param){var ref=param===void 0?{}:param,_styleSheet=ref.styleSheet,styleSheet=_styleSheet===void 0?null:_styleSheet,_optimizeForSpeed=ref.optimizeForSpeed,optimizeForSpeed=_optimizeForSpeed===void 0?!1:_optimizeForSpeed;this._sheet=styleSheet||new StyleSheet({name:"styled-jsx",optimizeForSpeed}),this._sheet.inject(),styleSheet&&typeof optimizeForSpeed=="boolean"&&(this._sheet.setOptimizeForSpeed(optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),this._fromServer=void 0,this._indices={},this._instancesCounts={}}var _proto=StyleSheetRegistry2.prototype;return _proto.add=function(props){var _this=this;this._optimizeForSpeed===void 0&&(this._optimizeForSpeed=Array.isArray(props.children),this._sheet.setOptimizeForSpeed(this._optimizeForSpeed),this._optimizeForSpeed=this._sheet.isOptimizeForSpeed()),typeof window<"u"&&!this._fromServer&&(this._fromServer=this.selectFromServer(),this._instancesCounts=Object.keys(this._fromServer).reduce(function(acc,tagName){return acc[tagName]=0,acc},{}));var ref=this.getIdAndRules(props),styleId=ref.styleId,rules=ref.rules;if(styleId in this._instancesCounts){this._instancesCounts[styleId]+=1;return}var indices=rules.map(function(rule){return _this._sheet.insertRule(rule)}).filter(function(index){return index!==-1});this._indices[styleId]=indices,this._instancesCounts[styleId]=1},_proto.remove=function(props){var _this=this,styleId=this.getIdAndRules(props).styleId;if(invariant(styleId in this._instancesCounts,"styleId: `"+styleId+"` not found"),this._instancesCounts[styleId]-=1,this._instancesCounts[styleId]<1){var tagFromServer=this._fromServer&&this._fromServer[styleId];tagFromServer?(tagFromServer.parentNode.removeChild(tagFromServer),delete this._fromServer[styleId]):(this._indices[styleId].forEach(function(index){return _this._sheet.deleteRule(index)}),delete this._indices[styleId]),delete this._instancesCounts[styleId]}},_proto.update=function(props,nextProps){this.add(nextProps),this.remove(props)},_proto.flush=function(){this._sheet.flush(),this._sheet.inject(),this._fromServer=void 0,this._indices={},this._instancesCounts={}},_proto.cssRules=function(){var _this=this,fromServer=this._fromServer?Object.keys(this._fromServer).map(function(styleId){return[styleId,_this._fromServer[styleId]]}):[],cssRules2=this._sheet.cssRules();return fromServer.concat(Object.keys(this._indices).map(function(styleId){return[styleId,_this._indices[styleId].map(function(index){return cssRules2[index].cssText}).join(_this._optimizeForSpeed?"":`
|
|
10
|
-
`)]}).filter(function(rule){return Boolean(rule[1])}))},_proto.styles=function(options){return mapRulesToStyle(this.cssRules(),options)},_proto.getIdAndRules=function(props){var css=props.children,dynamic=props.dynamic,id=props.id;if(dynamic){var styleId=computeId(id,dynamic);return{styleId,rules:Array.isArray(css)?css.map(function(rule){return computeSelector(styleId,rule)}):[computeSelector(styleId,css)]}}return{styleId:computeId(id),rules:Array.isArray(css)?css:[css]}},_proto.selectFromServer=function(){var elements=Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));return elements.reduce(function(acc,element){var id=element.id.slice(2);return acc[id]=element,acc},{})},StyleSheetRegistry2}();function invariant(condition,message){if(!condition)throw new Error("StyleSheetRegistry: "+message+".")}var StyleSheetContext=
|
|
10
|
+
`)]}).filter(function(rule){return Boolean(rule[1])}))},_proto.styles=function(options){return mapRulesToStyle(this.cssRules(),options)},_proto.getIdAndRules=function(props){var css=props.children,dynamic=props.dynamic,id=props.id;if(dynamic){var styleId=computeId(id,dynamic);return{styleId,rules:Array.isArray(css)?css.map(function(rule){return computeSelector(styleId,rule)}):[computeSelector(styleId,css)]}}return{styleId:computeId(id),rules:Array.isArray(css)?css:[css]}},_proto.selectFromServer=function(){var elements=Array.prototype.slice.call(document.querySelectorAll('[id^="__jsx-"]'));return elements.reduce(function(acc,element){var id=element.id.slice(2);return acc[id]=element,acc},{})},StyleSheetRegistry2}();function invariant(condition,message){if(!condition)throw new Error("StyleSheetRegistry: "+message+".")}var StyleSheetContext=React7.createContext(null);StyleSheetContext.displayName="StyleSheetContext";function createStyleRegistry(){return new StyleSheetRegistry}function StyleRegistry2(param){var configuredRegistry=param.registry,children=param.children,rootRegistry=React7.useContext(StyleSheetContext),ref=React7.useState(function(){return rootRegistry||configuredRegistry||createStyleRegistry()}),registry=ref[0];return React__default.default.createElement(StyleSheetContext.Provider,{value:registry},children)}function useStyleRegistry(){return React7.useContext(StyleSheetContext)}var useInsertionEffect=React__default.default.useInsertionEffect||React__default.default.useLayoutEffect,defaultRegistry=typeof window<"u"?createStyleRegistry():void 0;function JSXStyle(props){var registry=defaultRegistry||useStyleRegistry();return registry?typeof window>"u"?(registry.add(props),null):(useInsertionEffect(function(){return registry.add(props),function(){registry.remove(props)}},[props.id,String(props.dynamic)]),null):null}JSXStyle.dynamic=function(info){return info.map(function(tagInfo){var baseId=tagInfo[0],props=tagInfo[1];return computeId(baseId,props)}).join(" ")};exports.StyleRegistry=StyleRegistry2;exports.createStyleRegistry=createStyleRegistry;exports.style=JSXStyle;exports.useStyleRegistry=useStyleRegistry}});var require_styled_jsx=__commonJS({"../../node_modules/styled-jsx/index.js"(exports,module){module.exports=require_index()}});import{setConfig}from"next/config";setConfig(process.env.__NEXT_RUNTIME_CONFIG);import*as React2 from"react";import{RouterContext}from"next/dist/shared/lib/router-context";import React from"react";var PageRouterProvider=({children,action:action2,routeParams,globals})=>React.createElement(RouterContext.Provider,{value:{push(...args){return action2("nextRouter.push")(...args),Promise.resolve(!0)},replace(...args){return action2("nextRouter.replace")(...args),Promise.resolve(!0)},reload(...args){action2("nextRouter.reload")(...args)},back(...args){action2("nextRouter.back")(...args)},forward(){action2("nextRouter.forward")()},prefetch(...args){return action2("nextRouter.prefetch")(...args),Promise.resolve()},beforePopState(...args){action2("nextRouter.beforePopState")(...args)},events:{on(...args){action2("nextRouter.events.on")(...args)},off(...args){action2("nextRouter.events.off")(...args)},emit(...args){action2("nextRouter.events.emit")(...args)}},locale:globals?.locale,route:"/",asPath:"/",basePath:"/",isFallback:!1,isLocaleDomain:!1,isReady:!0,isPreview:!1,...routeParams}},children),page_router_provider_default=PageRouterProvider;var AppRouterProvider=React2.lazy(()=>import("./app-router-provider-LIUPULW3.mjs")),action;try{action=__require("@storybook/addon-actions").action}catch{action=()=>()=>{}}var defaultRouterParams={pathname:"/",query:{}},RouterDecorator=(Story,{globals,parameters})=>parameters.nextjs?.appDirectory??!1?React2.createElement(AppRouterProvider,{action,routeParams:{...defaultRouterParams,...parameters.nextjs?.navigation}},React2.createElement(Story,null)):React2.createElement(page_router_provider_default,{action,globals,routeParams:{...defaultRouterParams,...parameters.nextjs?.router}},React2.createElement(Story,null));import*as React3 from"react";var StyleRegistry;try{StyleRegistry=require_styled_jsx().StyleRegistry}catch{StyleRegistry=React3.Fragment}var StyledJsxDecorator=Story=>React3.createElement(StyleRegistry,null,React3.createElement(Story,null));import*as React4 from"react";import semver from"semver";var defaultLoader=({src,width,quality})=>{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})}`);return`${src}?w=${width}&q=${quality??75}`},NextImage=__require("next/image"),OriginalNextImage=NextImage.default;Object.defineProperty(NextImage,"default",{configurable:!0,value:props=>React4.createElement(OriginalNextImage,{...props,loader:props.loader??defaultLoader})});if(semver.satisfies(process.env.__NEXT_VERSION,"^13.0.0")){let OriginalNextLegacyImage=__require("next/legacy/image").default;Object.defineProperty(OriginalNextLegacyImage,"default",{configurable:!0,value:props=>React4.createElement(OriginalNextLegacyImage,{...props,loader:props.loader??defaultLoader})})}if(semver.satisfies(process.env.__NEXT_VERSION,"^12.2.0")){let OriginalNextFutureImage=__require("next/future/image").default;Object.defineProperty(OriginalNextFutureImage,"default",{configurable:!0,value:props=>React4.createElement(OriginalNextFutureImage,{...props,loader:props.loader??defaultLoader})})}import*as React6 from"react";import React5,{useMemo}from"react";import{HeadManagerContext}from"next/dist/shared/lib/head-manager-context";import initHeadManager from"next/dist/client/head-manager";var HeadManagerProvider=({children})=>{let headManager=useMemo(initHeadManager,[]);return headManager.getIsSsr=()=>!1,React5.createElement(HeadManagerContext.Provider,{value:headManager},children)},head_manager_provider_default=HeadManagerProvider;var HeadManagerDecorator=Story=>React6.createElement(head_manager_provider_default,null,React6.createElement(Story,null));function addNextHeadCount(){let meta=document.createElement("meta");meta.name="next-head-count",meta.content="0",document.head.appendChild(meta)}addNextHeadCount();var decorators=[StyledJsxDecorator,RouterDecorator,HeadManagerDecorator];export{decorators};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/nextjs",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.40",
|
|
4
4
|
"description": "Storybook for Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"node": "./dist/index.js",
|
|
25
26
|
"require": "./dist/index.js",
|
|
26
27
|
"import": "./dist/index.mjs",
|
|
27
28
|
"types": "./dist/index.d.ts"
|
|
@@ -49,7 +50,6 @@
|
|
|
49
50
|
"files": [
|
|
50
51
|
"dist/**/*",
|
|
51
52
|
"template/**/*",
|
|
52
|
-
"types/**/*",
|
|
53
53
|
"README.md",
|
|
54
54
|
"*.js",
|
|
55
55
|
"*.d.ts"
|
|
@@ -59,15 +59,17 @@
|
|
|
59
59
|
"prep": "../../../scripts/prepare/bundle.ts"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@storybook/
|
|
65
|
-
"@storybook/
|
|
66
|
-
"@storybook/
|
|
67
|
-
"@storybook/react": "7.0.0-beta.
|
|
62
|
+
"@next/font": "^13.0.7",
|
|
63
|
+
"@storybook/addon-actions": "7.0.0-beta.40",
|
|
64
|
+
"@storybook/builder-webpack5": "7.0.0-beta.40",
|
|
65
|
+
"@storybook/core-common": "7.0.0-beta.40",
|
|
66
|
+
"@storybook/node-logger": "7.0.0-beta.40",
|
|
67
|
+
"@storybook/preset-react-webpack": "7.0.0-beta.40",
|
|
68
|
+
"@storybook/preview-api": "7.0.0-beta.40",
|
|
69
|
+
"@storybook/react": "7.0.0-beta.40",
|
|
68
70
|
"@types/node": "^16.0.0",
|
|
69
71
|
"find-up": "^5.0.0",
|
|
70
|
-
"fs-extra": "^
|
|
72
|
+
"fs-extra": "^11.1.0",
|
|
71
73
|
"image-size": "^1.0.0",
|
|
72
74
|
"loader-utils": "^3.2.0",
|
|
73
75
|
"pnp-webpack-plugin": "^1.7.0",
|
|
@@ -80,14 +82,15 @@
|
|
|
80
82
|
"tsconfig-paths-webpack-plugin": "^3.5.2"
|
|
81
83
|
},
|
|
82
84
|
"devDependencies": {
|
|
83
|
-
"@
|
|
85
|
+
"@babel/core": "^7.20.5",
|
|
86
|
+
"@babel/types": "^7.20.5",
|
|
87
|
+
"@types/babel__core": "^7",
|
|
84
88
|
"next": "^13.0.5",
|
|
85
89
|
"typescript": "^4.9.3",
|
|
86
90
|
"webpack": "^5.65.0"
|
|
87
91
|
},
|
|
88
92
|
"peerDependencies": {
|
|
89
93
|
"@babel/core": "^7.11.5",
|
|
90
|
-
"@storybook/addon-actions": "7.0.0-alpha.43",
|
|
91
94
|
"next": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
|
|
92
95
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
93
96
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -115,9 +118,10 @@
|
|
|
115
118
|
"./src/index.ts",
|
|
116
119
|
"./src/preset.ts",
|
|
117
120
|
"./src/preview.tsx",
|
|
118
|
-
"./src/next-image-loader-stub.ts"
|
|
121
|
+
"./src/next-image-loader-stub.ts",
|
|
122
|
+
"./src/font/webpack/loader/storybook-nextjs-font-loader.ts"
|
|
119
123
|
],
|
|
120
124
|
"platform": "node"
|
|
121
125
|
},
|
|
122
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "9c68cc3a66e996e91ccd520d9d0adf0fa7094ad4"
|
|
123
127
|
}
|
|
@@ -3,8 +3,8 @@ import { Header } from './Header';
|
|
|
3
3
|
export default {
|
|
4
4
|
title: 'Example/Header',
|
|
5
5
|
component: Header,
|
|
6
|
-
// This component will have an automatically generated
|
|
7
|
-
tags: ['
|
|
6
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/7.0/react/writing-docs/docs-page
|
|
7
|
+
tags: ['autodocs'],
|
|
8
8
|
parameters: {
|
|
9
9
|
// More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
|
|
10
10
|
layout: 'fullscreen',
|
|
@@ -4,8 +4,8 @@ import { Header } from './Header';
|
|
|
4
4
|
const meta: Meta<typeof Header> = {
|
|
5
5
|
title: 'Example/Header',
|
|
6
6
|
component: Header,
|
|
7
|
-
// This component will have an automatically generated
|
|
8
|
-
tags: ['
|
|
7
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/7.0/react/writing-docs/docs-page
|
|
8
|
+
tags: ['autodocs'],
|
|
9
9
|
parameters: {
|
|
10
10
|
// More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
|
|
11
11
|
layout: 'fullscreen',
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
import { Rubik_Puddles } from '@next/font/google';
|
|
3
|
+
import localFont from '@next/font/local';
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
const rubik = Rubik_Puddles({
|
|
8
|
+
subsets: ['latin'],
|
|
9
|
+
variable: '--font-latin-rubik',
|
|
10
|
+
weight: '400',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const localRubikStorm = localFont({
|
|
14
|
+
src: '/fonts/RubikStorm-Regular.ttf',
|
|
15
|
+
variable: '--font-rubik-storm',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default function Font({ variant }) {
|
|
19
|
+
switch (variant) {
|
|
20
|
+
case 'className':
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<h1 className={rubik.className}>Google Rubik Puddles</h1>
|
|
24
|
+
<h1 className={localRubikStorm.className}>Google Local Rubik Storm</h1>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
case 'style':
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<h1 style={rubik.style}>Google Rubik Puddles</h1>
|
|
31
|
+
<h1 style={localRubikStorm.style}>Google Local Rubik Storm</h1>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
case 'variable':
|
|
35
|
+
return (
|
|
36
|
+
<div>
|
|
37
|
+
<div className={rubik.variable}>
|
|
38
|
+
<h1
|
|
39
|
+
style={{
|
|
40
|
+
fontFamily: 'var(--font-latin-rubik)',
|
|
41
|
+
fontStyle: rubik.style.fontStyle,
|
|
42
|
+
fontWeight: rubik.style.fontWeight,
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
Google Rubik Puddles
|
|
46
|
+
</h1>
|
|
47
|
+
</div>
|
|
48
|
+
<div className={localRubikStorm.variable}>
|
|
49
|
+
<h1
|
|
50
|
+
style={{
|
|
51
|
+
fontFamily: 'var(--font-rubik-storm)',
|
|
52
|
+
fontStyle: localRubikStorm.style.fontStyle,
|
|
53
|
+
fontWeight: localRubikStorm.style.fontWeight,
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
Google Local Rubik Storm
|
|
57
|
+
</h1>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
default:
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Font from './Font';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
component: Font,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const WithClassName = {
|
|
8
|
+
args: {
|
|
9
|
+
variant: 'className',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const WithStyle = {
|
|
14
|
+
args: {
|
|
15
|
+
variant: 'style',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const WithVariable = {
|
|
20
|
+
args: {
|
|
21
|
+
variant: 'variable',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import { expect } from '@storybook/jest';
|
|
3
|
+
import Head from 'next/head';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { within, userEvent, waitFor } from '@storybook/testing-library';
|
|
6
|
+
|
|
7
|
+
function Component() {
|
|
8
|
+
return (
|
|
9
|
+
<div>
|
|
10
|
+
<Head>
|
|
11
|
+
<title>Next.js Head Title</title>
|
|
12
|
+
<meta property="og:title" content="My page title" key="title" />
|
|
13
|
+
</Head>
|
|
14
|
+
<Head>
|
|
15
|
+
<meta property="og:title" content="My new title" key="title" />
|
|
16
|
+
</Head>
|
|
17
|
+
<p>Hello world!</p>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
component: Component,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Default = {
|
|
27
|
+
play: async ({ canvasElement }) => {
|
|
28
|
+
await waitFor(() => expect(document.title).toEqual('Next.js Head Title'));
|
|
29
|
+
await expect(document.querySelectorAll('meta[property="og:title"]')).toHaveLength(1);
|
|
30
|
+
await expect(document.querySelector('meta[property="og:title"]').content).toEqual(
|
|
31
|
+
'My new title'
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useRouter,
|
|
3
|
+
usePathname,
|
|
4
|
+
useSearchParams,
|
|
5
|
+
useSelectedLayoutSegment,
|
|
6
|
+
useSelectedLayoutSegments,
|
|
7
|
+
} from 'next/navigation';
|
|
2
8
|
import React from 'react';
|
|
3
9
|
|
|
4
10
|
function Component() {
|
|
5
11
|
const router = useRouter();
|
|
6
12
|
const pathname = usePathname();
|
|
7
13
|
const searchParams = useSearchParams();
|
|
14
|
+
const segment = useSelectedLayoutSegment();
|
|
15
|
+
const segments = useSelectedLayoutSegments();
|
|
8
16
|
|
|
9
17
|
const searchParamsList = Array.from(searchParams.entries());
|
|
10
18
|
|
|
@@ -38,6 +46,8 @@ function Component() {
|
|
|
38
46
|
return (
|
|
39
47
|
<div>
|
|
40
48
|
<div>pathname: {pathname}</div>
|
|
49
|
+
<div>segment: {segment}</div>
|
|
50
|
+
<div>segments: {segments.join(',')}</div>
|
|
41
51
|
<div>
|
|
42
52
|
searchparams:{' '}
|
|
43
53
|
<ul>
|
|
@@ -75,3 +85,14 @@ export default {
|
|
|
75
85
|
};
|
|
76
86
|
|
|
77
87
|
export const Default = {};
|
|
88
|
+
|
|
89
|
+
export const WithSegmentDefined = {
|
|
90
|
+
parameters: {
|
|
91
|
+
nextjs: {
|
|
92
|
+
appDirectory: true,
|
|
93
|
+
navigation: {
|
|
94
|
+
segments: ['dashboard', 'settings'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2020 The Rubik Filtered Project Authors (https://https://github.com/NaN-xyz/Rubik-Filtered)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-LAHENP5R.mjs";import React from"react";import{AppRouterContext}from"next/dist/shared/lib/app-router-context";import{PathnameContext,SearchParamsContext}from"next/dist/shared/lib/hooks-client-context";var AppRouterProvider=({children,action,routeParams})=>{let{pathname,query,...restRouteParams}=routeParams;return React.createElement(AppRouterContext.Provider,{value:{push(...args){action("nextNavigation.push")(...args)},replace(...args){action("nextNavigation.replace")(...args)},forward(...args){action("nextNavigation.forward")(...args)},back(...args){action("nextNavigation.back")(...args)},prefetch(...args){action("nextNavigation.prefetch")(...args)},refresh:()=>{action("nextNavigation.refresh")()},...restRouteParams}},React.createElement(SearchParamsContext.Provider,{value:new URLSearchParams(query)},React.createElement(PathnameContext.Provider,{value:pathname},children)))},app_router_provider_default=AppRouterProvider;export{app_router_provider_default as default};
|
package/dist/chunk-LAHENP5R.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames=Object.getOwnPropertyNames;var __require=(x=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(x,{get:(a,b)=>(typeof require!="undefined"?require:a)[b]}):x)(function(x){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};export{__require,__commonJS};
|