@storybook/nextjs 9.2.0-alpha.3 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/_browser-chunks/chunk-I5RFHXDS.js +40 -0
- package/dist/_browser-chunks/chunk-JOMP7DUK.js +261 -0
- package/dist/_browser-chunks/chunk-L5NVL7MD.js +37 -0
- package/dist/_browser-chunks/react-18-G7Q4PNHD.js +71 -0
- package/dist/_node-chunks/chunk-254AWWVV.js +95 -0
- package/dist/_node-chunks/chunk-4Q3WLK5D.js +167 -0
- package/dist/_node-chunks/chunk-DF7TGUJT.js +17 -0
- package/dist/_node-chunks/chunk-N47GZ6ZF.js +74 -0
- package/dist/_node-chunks/configureNextFont-YCA4Y2MY.js +36 -0
- package/dist/_node-chunks/loader-BMOR26K7.js +64 -0
- package/dist/_node-chunks/loader-W6JNOWKU.js +51 -0
- package/dist/_node-chunks/utils-TOBNY3XG.js +31 -0
- package/dist/_node-chunks/webpack-422IPQRP.js +38 -0
- package/dist/_node-chunks/webpack-7CTFG24J.js +107 -0
- package/dist/_node-chunks/webpack-AGJ2TY75.js +29 -0
- package/dist/_node-chunks/webpack-E2SJEFJM.js +27 -0
- package/dist/_node-chunks/webpack-GIA2WMBH.js +77 -0
- package/dist/_node-chunks/webpack-MCDIAAFL.js +43 -0
- package/dist/_node-chunks/webpack-UPXNFNSK.js +26 -0
- package/dist/_node-chunks/webpack-WWJ5TQDG.js +30 -0
- package/dist/compatibility/draft-mode.compat.js +7 -1
- package/dist/export-mocks/cache/index.d.ts +309 -1
- package/dist/export-mocks/cache/index.js +22 -1
- package/dist/export-mocks/headers/index.d.ts +309 -1
- package/dist/export-mocks/headers/index.js +77 -1
- package/dist/export-mocks/index.js +20 -1
- package/dist/export-mocks/navigation/index.js +88 -1
- package/dist/export-mocks/router/index.d.ts +2 -2
- package/dist/export-mocks/router/index.js +97 -1
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +201 -14
- package/dist/image-context.js +8 -1
- package/dist/images/next-image.js +35 -1
- package/dist/images/next-legacy-image.js +21 -1
- package/dist/index.d.ts +53 -8
- package/dist/index.js +20237 -45
- package/dist/next-image-loader-stub.js +33 -1
- package/dist/node/index.d.ts +27 -6
- package/dist/node/index.js +23 -1
- package/dist/preset.js +830 -1
- package/dist/preview.d.ts +3 -18
- package/dist/preview.d.tsx +18 -0
- package/dist/preview.js +11 -1
- package/dist/rsc/server-only.js +7 -1
- package/dist/swc/next-swc-loader-patch.js +136 -1
- package/package.json +41 -122
- package/preset.js +1 -1
- package/template/cli/js/Configure.mdx +11 -11
- package/template/cli/ts/Configure.mdx +11 -11
- package/dist/chunk-2TZKD6A5.mjs +0 -20
- package/dist/chunk-ETFXNGLC.mjs +0 -3
- package/dist/chunk-L66KIASX.mjs +0 -3
- package/dist/chunk-NQ32RFK2.mjs +0 -6
- package/dist/compatibility/draft-mode.compat.d.ts +0 -1
- package/dist/compatibility/draft-mode.compat.mjs +0 -2
- package/dist/export-mocks/cache/index.mjs +0 -10
- package/dist/export-mocks/headers/index.mjs +0 -12
- package/dist/export-mocks/index.d.ts +0 -7
- package/dist/export-mocks/index.mjs +0 -11
- package/dist/export-mocks/navigation/index.mjs +0 -11
- package/dist/export-mocks/router/index.mjs +0 -10
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +0 -3
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +0 -56
- package/dist/image-context.d.ts +0 -13
- package/dist/image-context.mjs +0 -6
- package/dist/images/decorator.d.ts +0 -6
- package/dist/images/decorator.js +0 -1
- package/dist/images/decorator.mjs +0 -2
- package/dist/images/next-image.d.ts +0 -28
- package/dist/images/next-image.mjs +0 -9
- package/dist/images/next-legacy-image.d.ts +0 -6
- package/dist/images/next-legacy-image.mjs +0 -9
- package/dist/index.d-ff220430.d.ts +0 -310
- package/dist/index.mjs +0 -58
- package/dist/next-image-loader-stub.d.ts +0 -10
- package/dist/next-image-loader-stub.mjs +0 -7
- package/dist/node/index.mjs +0 -5
- package/dist/preset.d.ts +0 -14
- package/dist/preview.mjs +0 -3
- package/dist/react-18-WSPZ3BUV.mjs +0 -7
- package/dist/rsc/server-only.d.ts +0 -3
- package/dist/rsc/server-only.mjs +0 -5
- package/dist/swc/next-swc-loader-patch.d.ts +0 -21
- package/dist/swc/next-swc-loader-patch.mjs +0 -8
- package/dist/types-f6ea2c09.d.ts +0 -54
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Storybook for Next.js
|
|
2
2
|
|
|
3
|
-
See [documentation](https://storybook.js.org/docs/get-started/frameworks/nextjs?renderer=react) for installation instructions, usage examples, APIs, and more.
|
|
3
|
+
See [documentation](https://storybook.js.org/docs/get-started/frameworks/nextjs?renderer=react&ref=readme) for installation instructions, usage examples, APIs, and more.
|
|
4
4
|
|
|
5
5
|
## Acknowledgements
|
|
6
6
|
|
|
@@ -8,3 +8,5 @@ This framework borrows heavily from these Storybook addons:
|
|
|
8
8
|
|
|
9
9
|
- [storybook-addon-next](https://github.com/RyanClementsHax/storybook-addon-next) by [RyanClementsHax](https://github.com/RyanClementsHax/)
|
|
10
10
|
- [storybook-addon-next-router](https://github.com/lifeiscontent/storybook-addon-next-router) by [lifeiscontent](https://github.com/lifeiscontent)
|
|
11
|
+
|
|
12
|
+
Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-L5NVL7MD.js";
|
|
4
|
+
|
|
5
|
+
// src/images/next-image-default-loader.tsx
|
|
6
|
+
var defaultLoader = /* @__PURE__ */ __name(({ src, width, quality = 75 }) => {
|
|
7
|
+
const missingValues = [];
|
|
8
|
+
if (!src) {
|
|
9
|
+
missingValues.push("src");
|
|
10
|
+
}
|
|
11
|
+
if (!width) {
|
|
12
|
+
missingValues.push("width");
|
|
13
|
+
}
|
|
14
|
+
if (missingValues.length > 0) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Next Image Optimization requires ${missingValues.join(
|
|
17
|
+
", "
|
|
18
|
+
)} to be provided. Make sure you pass them as props to the \`next/image\` component. Received: ${JSON.stringify(
|
|
19
|
+
{
|
|
20
|
+
src,
|
|
21
|
+
width,
|
|
22
|
+
quality
|
|
23
|
+
}
|
|
24
|
+
)}`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const url = new URL(src, window.location.href);
|
|
28
|
+
if (!url.searchParams.has("w") && !url.searchParams.has("q")) {
|
|
29
|
+
url.searchParams.set("w", width.toString());
|
|
30
|
+
url.searchParams.set("q", quality.toString());
|
|
31
|
+
}
|
|
32
|
+
if (!src.startsWith("http://") && !src.startsWith("https://")) {
|
|
33
|
+
return url.toString().slice(url.origin.length);
|
|
34
|
+
}
|
|
35
|
+
return url.toString();
|
|
36
|
+
}, "defaultLoader");
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
defaultLoader
|
|
40
|
+
};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export,
|
|
3
|
+
__name
|
|
4
|
+
} from "./chunk-L5NVL7MD.js";
|
|
5
|
+
|
|
6
|
+
// src/preview.tsx
|
|
7
|
+
var preview_exports = {};
|
|
8
|
+
__export(preview_exports, {
|
|
9
|
+
decorators: () => decorators,
|
|
10
|
+
loaders: () => loaders,
|
|
11
|
+
parameters: () => parameters
|
|
12
|
+
});
|
|
13
|
+
import { createNavigation } from "@storybook/nextjs/navigation.mock";
|
|
14
|
+
import { createRouter } from "@storybook/nextjs/router.mock";
|
|
15
|
+
import { isNextRouterError } from "next/dist/client/components/is-next-router-error";
|
|
16
|
+
|
|
17
|
+
// src/config/preview.ts
|
|
18
|
+
import { setConfig } from "next/config";
|
|
19
|
+
setConfig(process.env.__NEXT_RUNTIME_CONFIG);
|
|
20
|
+
|
|
21
|
+
// src/head-manager/decorator.tsx
|
|
22
|
+
import * as React2 from "react";
|
|
23
|
+
|
|
24
|
+
// src/head-manager/head-manager-provider.tsx
|
|
25
|
+
import React, { useMemo } from "react";
|
|
26
|
+
import initHeadManager from "next/dist/client/head-manager";
|
|
27
|
+
import { HeadManagerContext } from "next/dist/shared/lib/head-manager-context.shared-runtime";
|
|
28
|
+
var HeadManagerProvider = /* @__PURE__ */ __name(({ children }) => {
|
|
29
|
+
const headManager = useMemo(initHeadManager, []);
|
|
30
|
+
headManager.getIsSsr = () => false;
|
|
31
|
+
return React.createElement(HeadManagerContext.Provider, { value: headManager }, children);
|
|
32
|
+
}, "HeadManagerProvider");
|
|
33
|
+
var head_manager_provider_default = HeadManagerProvider;
|
|
34
|
+
|
|
35
|
+
// src/head-manager/decorator.tsx
|
|
36
|
+
var HeadManagerDecorator = /* @__PURE__ */ __name((Story) => {
|
|
37
|
+
return React2.createElement(head_manager_provider_default, null, React2.createElement(Story, null));
|
|
38
|
+
}, "HeadManagerDecorator");
|
|
39
|
+
|
|
40
|
+
// src/images/decorator.tsx
|
|
41
|
+
import * as React3 from "react";
|
|
42
|
+
import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-context";
|
|
43
|
+
var ImageContext = ImageContextValue;
|
|
44
|
+
var ImageDecorator = /* @__PURE__ */ __name((Story, { parameters: parameters2 }) => {
|
|
45
|
+
if (!parameters2.nextjs?.image) {
|
|
46
|
+
return React3.createElement(Story, null);
|
|
47
|
+
}
|
|
48
|
+
return React3.createElement(ImageContext.Provider, { value: parameters2.nextjs.image }, React3.createElement(Story, null));
|
|
49
|
+
}, "ImageDecorator");
|
|
50
|
+
|
|
51
|
+
// src/routing/decorator.tsx
|
|
52
|
+
import * as React6 from "react";
|
|
53
|
+
import { RedirectBoundary } from "next/dist/client/components/redirect-boundary";
|
|
54
|
+
|
|
55
|
+
// src/routing/app-router-provider.tsx
|
|
56
|
+
import React4, { useMemo as useMemo2 } from "react";
|
|
57
|
+
import { getRouter } from "@storybook/nextjs/navigation.mock";
|
|
58
|
+
import {
|
|
59
|
+
AppRouterContext,
|
|
60
|
+
GlobalLayoutRouterContext,
|
|
61
|
+
LayoutRouterContext
|
|
62
|
+
} from "next/dist/shared/lib/app-router-context.shared-runtime";
|
|
63
|
+
import {
|
|
64
|
+
PathParamsContext,
|
|
65
|
+
PathnameContext,
|
|
66
|
+
SearchParamsContext
|
|
67
|
+
} from "next/dist/shared/lib/hooks-client-context.shared-runtime";
|
|
68
|
+
import { PAGE_SEGMENT_KEY } from "next/dist/shared/lib/segment";
|
|
69
|
+
var getParallelRoutes = /* @__PURE__ */ __name((segmentsList) => {
|
|
70
|
+
const segment = segmentsList.shift();
|
|
71
|
+
if (segment) {
|
|
72
|
+
return [segment, { children: getParallelRoutes(segmentsList) }];
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}, "getParallelRoutes");
|
|
76
|
+
var AppRouterProvider = /* @__PURE__ */ __name(({
|
|
77
|
+
children,
|
|
78
|
+
routeParams
|
|
79
|
+
}) => {
|
|
80
|
+
const { pathname, query, segments = [] } = routeParams;
|
|
81
|
+
const tree = [pathname, { children: getParallelRoutes([...segments]) }];
|
|
82
|
+
const pathParams = useMemo2(() => {
|
|
83
|
+
const params = {};
|
|
84
|
+
const currentSegments = routeParams.segments;
|
|
85
|
+
if (currentSegments) {
|
|
86
|
+
if (Array.isArray(currentSegments)) {
|
|
87
|
+
for (const segmentEntry of currentSegments) {
|
|
88
|
+
if (Array.isArray(segmentEntry) && segmentEntry.length === 2 && typeof segmentEntry[0] === "string") {
|
|
89
|
+
const key = segmentEntry[0];
|
|
90
|
+
const value = segmentEntry[1];
|
|
91
|
+
params[key] = value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} else if (typeof currentSegments === "object" && !Array.isArray(currentSegments)) {
|
|
95
|
+
const segmentObject = currentSegments;
|
|
96
|
+
for (const key in segmentObject) {
|
|
97
|
+
if (Object.prototype.hasOwnProperty.call(segmentObject, key)) {
|
|
98
|
+
params[key] = segmentObject[key];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return params;
|
|
104
|
+
}, [routeParams.segments]);
|
|
105
|
+
const newLazyCacheNode = {
|
|
106
|
+
lazyData: null,
|
|
107
|
+
rsc: null,
|
|
108
|
+
prefetchRsc: null,
|
|
109
|
+
head: null,
|
|
110
|
+
prefetchHead: null,
|
|
111
|
+
parallelRoutes: /* @__PURE__ */ new Map(),
|
|
112
|
+
loading: null
|
|
113
|
+
};
|
|
114
|
+
return React4.createElement(PathParamsContext.Provider, { value: pathParams }, React4.createElement(PathnameContext.Provider, { value: pathname }, React4.createElement(SearchParamsContext.Provider, { value: new URLSearchParams(query) }, React4.createElement(
|
|
115
|
+
GlobalLayoutRouterContext.Provider,
|
|
116
|
+
{
|
|
117
|
+
value: {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
119
|
+
// @ts-ignore (Only available in Next.js >= v15.1.1)
|
|
120
|
+
changeByServerResponse() {
|
|
121
|
+
},
|
|
122
|
+
buildId: "storybook",
|
|
123
|
+
tree,
|
|
124
|
+
focusAndScrollRef: {
|
|
125
|
+
apply: false,
|
|
126
|
+
hashFragment: null,
|
|
127
|
+
segmentPaths: [tree],
|
|
128
|
+
onlyHashChange: false
|
|
129
|
+
},
|
|
130
|
+
nextUrl: pathname
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
React4.createElement(AppRouterContext.Provider, { value: getRouter() }, React4.createElement(
|
|
134
|
+
LayoutRouterContext.Provider,
|
|
135
|
+
{
|
|
136
|
+
value: {
|
|
137
|
+
// TODO Remove when dropping Next.js < v15.1.1
|
|
138
|
+
childNodes: /* @__PURE__ */ new Map(),
|
|
139
|
+
tree,
|
|
140
|
+
// TODO END
|
|
141
|
+
// START Next.js v15.2 support
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
143
|
+
// @ts-ignore Only available in Next.js >= v15.1.1
|
|
144
|
+
parentTree: tree,
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
|
+
// @ts-ignore Only available in Next.js >= v15.1.1
|
|
147
|
+
parentCacheNode: newLazyCacheNode,
|
|
148
|
+
// END
|
|
149
|
+
url: pathname,
|
|
150
|
+
loading: null
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
children
|
|
154
|
+
))
|
|
155
|
+
))));
|
|
156
|
+
}, "AppRouterProvider");
|
|
157
|
+
|
|
158
|
+
// src/routing/page-router-provider.tsx
|
|
159
|
+
import React5 from "react";
|
|
160
|
+
import { getRouter as getRouter2 } from "@storybook/nextjs/router.mock";
|
|
161
|
+
import { RouterContext } from "next/dist/shared/lib/router-context.shared-runtime";
|
|
162
|
+
var PageRouterProvider = /* @__PURE__ */ __name(({ children }) => React5.createElement(RouterContext.Provider, { value: getRouter2() }, children), "PageRouterProvider");
|
|
163
|
+
|
|
164
|
+
// src/routing/decorator.tsx
|
|
165
|
+
var defaultRouterParams = {
|
|
166
|
+
pathname: "/",
|
|
167
|
+
query: {}
|
|
168
|
+
};
|
|
169
|
+
var RouterDecorator = /* @__PURE__ */ __name((Story, { parameters: parameters2 }) => {
|
|
170
|
+
const nextAppDirectory = parameters2.nextjs?.appDirectory ?? false;
|
|
171
|
+
if (nextAppDirectory) {
|
|
172
|
+
if (!AppRouterProvider) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return React6.createElement(
|
|
176
|
+
AppRouterProvider,
|
|
177
|
+
{
|
|
178
|
+
routeParams: {
|
|
179
|
+
...defaultRouterParams,
|
|
180
|
+
...parameters2.nextjs?.navigation
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
React6.createElement(RedirectBoundary, null, React6.createElement(Story, null))
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return React6.createElement(PageRouterProvider, null, React6.createElement(Story, null));
|
|
187
|
+
}, "RouterDecorator");
|
|
188
|
+
|
|
189
|
+
// src/styledJsx/decorator.tsx
|
|
190
|
+
import * as React7 from "react";
|
|
191
|
+
import { StyleRegistry } from "styled-jsx";
|
|
192
|
+
var StyledJsxDecorator = /* @__PURE__ */ __name((Story) => React7.createElement(StyleRegistry, null, React7.createElement(Story, null)), "StyledJsxDecorator");
|
|
193
|
+
|
|
194
|
+
// src/preview.tsx
|
|
195
|
+
function addNextHeadCount() {
|
|
196
|
+
const meta = document.createElement("meta");
|
|
197
|
+
meta.name = "next-head-count";
|
|
198
|
+
meta.content = "0";
|
|
199
|
+
document.head.appendChild(meta);
|
|
200
|
+
}
|
|
201
|
+
__name(addNextHeadCount, "addNextHeadCount");
|
|
202
|
+
function isAsyncClientComponentError(error) {
|
|
203
|
+
return typeof error === "string" && (error.includes("Only Server Components can be async at the moment.") || error.includes("A component was suspended by an uncached promise.") || error.includes("async/await is not yet supported in Client Components"));
|
|
204
|
+
}
|
|
205
|
+
__name(isAsyncClientComponentError, "isAsyncClientComponentError");
|
|
206
|
+
addNextHeadCount();
|
|
207
|
+
var origConsoleError = globalThis.console.error;
|
|
208
|
+
globalThis.console.error = (...args) => {
|
|
209
|
+
const error = args[0];
|
|
210
|
+
if (isNextRouterError(error) || isAsyncClientComponentError(error)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
origConsoleError.apply(globalThis.console, args);
|
|
214
|
+
};
|
|
215
|
+
globalThis.addEventListener("error", (ev) => {
|
|
216
|
+
if (isNextRouterError(ev.error) || isAsyncClientComponentError(ev.error)) {
|
|
217
|
+
ev.preventDefault();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
var decorators = [
|
|
222
|
+
StyledJsxDecorator,
|
|
223
|
+
ImageDecorator,
|
|
224
|
+
RouterDecorator,
|
|
225
|
+
HeadManagerDecorator
|
|
226
|
+
];
|
|
227
|
+
var loaders = /* @__PURE__ */ __name(async ({ globals, parameters: parameters2 }) => {
|
|
228
|
+
const { router, appDirectory } = parameters2.nextjs ?? {};
|
|
229
|
+
if (appDirectory) {
|
|
230
|
+
createNavigation(router);
|
|
231
|
+
} else {
|
|
232
|
+
createRouter({
|
|
233
|
+
locale: globals.locale,
|
|
234
|
+
...router
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}, "loaders");
|
|
238
|
+
var parameters = {
|
|
239
|
+
docs: {
|
|
240
|
+
source: {
|
|
241
|
+
excludeDecorators: true
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
react: {
|
|
245
|
+
rootOptions: {
|
|
246
|
+
onCaughtError(error) {
|
|
247
|
+
if (isNextRouterError(error)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
console.error(error);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export {
|
|
257
|
+
decorators,
|
|
258
|
+
loaders,
|
|
259
|
+
parameters,
|
|
260
|
+
preview_exports
|
|
261
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
__name,
|
|
34
|
+
__commonJS,
|
|
35
|
+
__export,
|
|
36
|
+
__toESM
|
|
37
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-L5NVL7MD.js";
|
|
4
|
+
|
|
5
|
+
// ../../lib/react-dom-shim/dist/_browser-chunks/chunk-JK72E6FR.js
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", { value, configurable: true }), "__name");
|
|
8
|
+
|
|
9
|
+
// ../../lib/react-dom-shim/dist/react-18.js
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import * as ReactDOM from "react-dom/client";
|
|
12
|
+
var nodes = /* @__PURE__ */ new Map();
|
|
13
|
+
function getIsReactActEnvironment() {
|
|
14
|
+
return globalThis.IS_REACT_ACT_ENVIRONMENT;
|
|
15
|
+
}
|
|
16
|
+
__name(getIsReactActEnvironment, "getIsReactActEnvironment");
|
|
17
|
+
__name2(getIsReactActEnvironment, "getIsReactActEnvironment");
|
|
18
|
+
var WithCallback = __name2(({
|
|
19
|
+
callback,
|
|
20
|
+
children
|
|
21
|
+
}) => {
|
|
22
|
+
const once = React.useRef();
|
|
23
|
+
React.useLayoutEffect(() => {
|
|
24
|
+
if (once.current === callback) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
once.current = callback;
|
|
28
|
+
callback();
|
|
29
|
+
}, [callback]);
|
|
30
|
+
return children;
|
|
31
|
+
}, "WithCallback");
|
|
32
|
+
if (typeof Promise.withResolvers === "undefined") {
|
|
33
|
+
Promise.withResolvers = () => {
|
|
34
|
+
let resolve = null;
|
|
35
|
+
let reject = null;
|
|
36
|
+
const promise = new Promise((res, rej) => {
|
|
37
|
+
resolve = res;
|
|
38
|
+
reject = rej;
|
|
39
|
+
});
|
|
40
|
+
return { promise, resolve, reject };
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var renderElement = __name2(async (node, el, rootOptions) => {
|
|
44
|
+
const root = await getReactRoot(el, rootOptions);
|
|
45
|
+
if (getIsReactActEnvironment()) {
|
|
46
|
+
root.render(node);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
50
|
+
root.render(React.createElement(WithCallback, { callback: resolve }, node));
|
|
51
|
+
return promise;
|
|
52
|
+
}, "renderElement");
|
|
53
|
+
var unmountElement = __name2((el, shouldUseNewRootApi) => {
|
|
54
|
+
const root = nodes.get(el);
|
|
55
|
+
if (root) {
|
|
56
|
+
root.unmount();
|
|
57
|
+
nodes.delete(el);
|
|
58
|
+
}
|
|
59
|
+
}, "unmountElement");
|
|
60
|
+
var getReactRoot = __name2(async (el, rootOptions) => {
|
|
61
|
+
let root = nodes.get(el);
|
|
62
|
+
if (!root) {
|
|
63
|
+
root = ReactDOM.createRoot(el, rootOptions);
|
|
64
|
+
nodes.set(el, root);
|
|
65
|
+
}
|
|
66
|
+
return root;
|
|
67
|
+
}, "getReactRoot");
|
|
68
|
+
export {
|
|
69
|
+
renderElement,
|
|
70
|
+
unmountElement
|
|
71
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_nafzxsaqn from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_nafzxsaqn from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_nafzxsaqn from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_nafzxsaqn.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_nafzxsaqn.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_nafzxsaqn.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
resolvePackageDir
|
|
14
|
+
} from "./chunk-4Q3WLK5D.js";
|
|
15
|
+
import {
|
|
16
|
+
__name
|
|
17
|
+
} from "./chunk-DF7TGUJT.js";
|
|
18
|
+
|
|
19
|
+
// src/utils.ts
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
import { dirname, join, sep } from "node:path";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { getProjectRoot } from "storybook/internal/common";
|
|
24
|
+
import { WebpackDefinePlugin } from "@storybook/builder-webpack5";
|
|
25
|
+
import { PHASE_DEVELOPMENT_SERVER } from "next/constants.js";
|
|
26
|
+
import nextJsLoadConfigModule from "next/dist/server/config.js";
|
|
27
|
+
var configureRuntimeNextjsVersionResolution = /* @__PURE__ */ __name((baseConfig) => {
|
|
28
|
+
baseConfig.plugins?.push(
|
|
29
|
+
new WebpackDefinePlugin({
|
|
30
|
+
"process.env.__NEXT_VERSION": JSON.stringify(getNextjsVersion())
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
}, "configureRuntimeNextjsVersionResolution");
|
|
34
|
+
var getNextjsVersion = /* @__PURE__ */ __name(() => JSON.parse(readFileSync(join(resolvePackageDir("next"), "package.json"), "utf8")).version, "getNextjsVersion");
|
|
35
|
+
var resolveNextConfig = /* @__PURE__ */ __name(async ({
|
|
36
|
+
nextConfigPath
|
|
37
|
+
}) => {
|
|
38
|
+
const dir = nextConfigPath ? dirname(nextConfigPath) : getProjectRoot();
|
|
39
|
+
const loadConfig = nextJsLoadConfigModule.default ?? nextJsLoadConfigModule;
|
|
40
|
+
const nextPrivateRenderWorker = process.env.__NEXT_PRIVATE_RENDER_WORKER;
|
|
41
|
+
process.env.__NEXT_PRIVATE_RENDER_WORKER = "defined";
|
|
42
|
+
const config = loadConfig(PHASE_DEVELOPMENT_SERVER, dir, void 0);
|
|
43
|
+
if (typeof nextPrivateRenderWorker === "undefined") {
|
|
44
|
+
delete process.env.__NEXT_PRIVATE_RENDER_WORKER;
|
|
45
|
+
} else {
|
|
46
|
+
process.env.__NEXT_PRIVATE_RENDER_WORKER = nextPrivateRenderWorker;
|
|
47
|
+
}
|
|
48
|
+
return config;
|
|
49
|
+
}, "resolveNextConfig");
|
|
50
|
+
function setAlias(baseConfig, name, alias) {
|
|
51
|
+
baseConfig.resolve ??= {};
|
|
52
|
+
baseConfig.resolve.alias ??= {};
|
|
53
|
+
const aliasConfig = baseConfig.resolve.alias;
|
|
54
|
+
if (Array.isArray(aliasConfig)) {
|
|
55
|
+
aliasConfig.push({
|
|
56
|
+
name,
|
|
57
|
+
alias
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
aliasConfig[name] = alias;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
__name(setAlias, "setAlias");
|
|
64
|
+
var addScopedAlias = /* @__PURE__ */ __name((baseConfig, name, alias) => {
|
|
65
|
+
const scopedAlias = scopedResolve(`${alias ?? name}`);
|
|
66
|
+
setAlias(baseConfig, name, scopedAlias);
|
|
67
|
+
}, "addScopedAlias");
|
|
68
|
+
var scopedResolve = /* @__PURE__ */ __name((id) => {
|
|
69
|
+
const scopedModulePath = fileURLToPath(import.meta.resolve(id));
|
|
70
|
+
const idWithNativePathSep = id.replace(/\//g, sep);
|
|
71
|
+
if (scopedModulePath.endsWith(idWithNativePathSep)) {
|
|
72
|
+
return scopedModulePath;
|
|
73
|
+
}
|
|
74
|
+
const moduleFolderStrPosition = scopedModulePath.lastIndexOf(idWithNativePathSep);
|
|
75
|
+
const beginningOfMainScriptPath = moduleFolderStrPosition + id.length;
|
|
76
|
+
return scopedModulePath.substring(0, beginningOfMainScriptPath);
|
|
77
|
+
}, "scopedResolve");
|
|
78
|
+
function getNodeModulesExcludeRegex(transpilePackages) {
|
|
79
|
+
if (!transpilePackages || transpilePackages.length === 0) {
|
|
80
|
+
return /node_modules/;
|
|
81
|
+
}
|
|
82
|
+
const escaped = transpilePackages.map((pkg) => pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
83
|
+
return new RegExp(`node_modules/(?!(${escaped})/)`);
|
|
84
|
+
}
|
|
85
|
+
__name(getNodeModulesExcludeRegex, "getNodeModulesExcludeRegex");
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
configureRuntimeNextjsVersionResolution,
|
|
89
|
+
getNextjsVersion,
|
|
90
|
+
resolveNextConfig,
|
|
91
|
+
setAlias,
|
|
92
|
+
addScopedAlias,
|
|
93
|
+
scopedResolve,
|
|
94
|
+
getNodeModulesExcludeRegex
|
|
95
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_nafzxsaqn from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_nafzxsaqn from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_nafzxsaqn from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_nafzxsaqn.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_nafzxsaqn.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_nafzxsaqn.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "./chunk-DF7TGUJT.js";
|
|
15
|
+
|
|
16
|
+
// ../../core/src/shared/utils/module.ts
|
|
17
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
18
|
+
|
|
19
|
+
// ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
20
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
21
|
+
function normalizeWindowsPath(input = "") {
|
|
22
|
+
if (!input) {
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
26
|
+
}
|
|
27
|
+
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
28
|
+
var _UNC_REGEX = /^[/\\]{2}/;
|
|
29
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
30
|
+
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
31
|
+
var normalize = /* @__PURE__ */ __name(function(path2) {
|
|
32
|
+
if (path2.length === 0) {
|
|
33
|
+
return ".";
|
|
34
|
+
}
|
|
35
|
+
path2 = normalizeWindowsPath(path2);
|
|
36
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
37
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
38
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
39
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
40
|
+
if (path2.length === 0) {
|
|
41
|
+
if (isPathAbsolute) {
|
|
42
|
+
return "/";
|
|
43
|
+
}
|
|
44
|
+
return trailingSeparator ? "./" : ".";
|
|
45
|
+
}
|
|
46
|
+
if (trailingSeparator) {
|
|
47
|
+
path2 += "/";
|
|
48
|
+
}
|
|
49
|
+
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
50
|
+
path2 += "/";
|
|
51
|
+
}
|
|
52
|
+
if (isUNCPath) {
|
|
53
|
+
if (!isPathAbsolute) {
|
|
54
|
+
return `//./${path2}`;
|
|
55
|
+
}
|
|
56
|
+
return `//${path2}`;
|
|
57
|
+
}
|
|
58
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
59
|
+
}, "normalize");
|
|
60
|
+
var join = /* @__PURE__ */ __name(function(...arguments_) {
|
|
61
|
+
if (arguments_.length === 0) {
|
|
62
|
+
return ".";
|
|
63
|
+
}
|
|
64
|
+
let joined;
|
|
65
|
+
for (const argument of arguments_) {
|
|
66
|
+
if (argument && argument.length > 0) {
|
|
67
|
+
if (joined === void 0) {
|
|
68
|
+
joined = argument;
|
|
69
|
+
} else {
|
|
70
|
+
joined += `/${argument}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (joined === void 0) {
|
|
75
|
+
return ".";
|
|
76
|
+
}
|
|
77
|
+
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
78
|
+
}, "join");
|
|
79
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
80
|
+
let res = "";
|
|
81
|
+
let lastSegmentLength = 0;
|
|
82
|
+
let lastSlash = -1;
|
|
83
|
+
let dots = 0;
|
|
84
|
+
let char = null;
|
|
85
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
86
|
+
if (index < path2.length) {
|
|
87
|
+
char = path2[index];
|
|
88
|
+
} else if (char === "/") {
|
|
89
|
+
break;
|
|
90
|
+
} else {
|
|
91
|
+
char = "/";
|
|
92
|
+
}
|
|
93
|
+
if (char === "/") {
|
|
94
|
+
if (lastSlash === index - 1 || dots === 1) ;
|
|
95
|
+
else if (dots === 2) {
|
|
96
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
97
|
+
if (res.length > 2) {
|
|
98
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
99
|
+
if (lastSlashIndex === -1) {
|
|
100
|
+
res = "";
|
|
101
|
+
lastSegmentLength = 0;
|
|
102
|
+
} else {
|
|
103
|
+
res = res.slice(0, lastSlashIndex);
|
|
104
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
105
|
+
}
|
|
106
|
+
lastSlash = index;
|
|
107
|
+
dots = 0;
|
|
108
|
+
continue;
|
|
109
|
+
} else if (res.length > 0) {
|
|
110
|
+
res = "";
|
|
111
|
+
lastSegmentLength = 0;
|
|
112
|
+
lastSlash = index;
|
|
113
|
+
dots = 0;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (allowAboveRoot) {
|
|
118
|
+
res += res.length > 0 ? "/.." : "..";
|
|
119
|
+
lastSegmentLength = 2;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
if (res.length > 0) {
|
|
123
|
+
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
124
|
+
} else {
|
|
125
|
+
res = path2.slice(lastSlash + 1, index);
|
|
126
|
+
}
|
|
127
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
128
|
+
}
|
|
129
|
+
lastSlash = index;
|
|
130
|
+
dots = 0;
|
|
131
|
+
} else if (char === "." && dots !== -1) {
|
|
132
|
+
++dots;
|
|
133
|
+
} else {
|
|
134
|
+
dots = -1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return res;
|
|
138
|
+
}
|
|
139
|
+
__name(normalizeString, "normalizeString");
|
|
140
|
+
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
141
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
142
|
+
}, "isAbsolute");
|
|
143
|
+
var dirname = /* @__PURE__ */ __name(function(p) {
|
|
144
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
145
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
146
|
+
segments[0] += "/";
|
|
147
|
+
}
|
|
148
|
+
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
149
|
+
}, "dirname");
|
|
150
|
+
|
|
151
|
+
// ../../core/src/shared/utils/module.ts
|
|
152
|
+
var importMetaResolve = /* @__PURE__ */ __name((...args) => {
|
|
153
|
+
if (typeof import.meta.resolve !== "function" && process.env.VITEST === "true") {
|
|
154
|
+
console.warn(
|
|
155
|
+
"importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
|
|
156
|
+
);
|
|
157
|
+
return pathToFileURL(args[0]).href;
|
|
158
|
+
}
|
|
159
|
+
return import.meta.resolve(...args);
|
|
160
|
+
}, "importMetaResolve");
|
|
161
|
+
var resolvePackageDir = /* @__PURE__ */ __name((pkg, parent) => {
|
|
162
|
+
return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
|
|
163
|
+
}, "resolvePackageDir");
|
|
164
|
+
|
|
165
|
+
export {
|
|
166
|
+
resolvePackageDir
|
|
167
|
+
};
|