@storybook/nextjs 10.1.0-alpha.9 → 10.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/{chunk-KX5HHFXV.js → chunk-2SBZPHE7.js} +50 -100
- package/dist/_browser-chunks/chunk-RDMFII4N.js +22 -0
- package/dist/_browser-chunks/{chunk-L5NVL7MD.js → chunk-SL3VIQZ3.js} +7 -13
- package/dist/_browser-chunks/react-18-PYSEDAWB.js +43 -0
- package/dist/_node-chunks/chunk-AU547LNK.js +76 -0
- package/dist/_node-chunks/chunk-EONFLREF.js +57 -0
- package/dist/_node-chunks/chunk-NVHRUSN5.js +211 -0
- package/dist/_node-chunks/configureNextFont-3RPVM2N7.js +28 -0
- package/dist/_node-chunks/{loader-7OJQICYP.js → loader-PBLFQE7I.js} +15 -25
- package/dist/_node-chunks/{loader-OFLGZQCU.js → loader-UX42M74F.js} +11 -16
- package/dist/_node-chunks/{utils-NVB3HGRH.js → utils-MPWEOWV4.js} +8 -9
- package/dist/_node-chunks/webpack-5IZRQF33.js +23 -0
- package/dist/_node-chunks/{webpack-E2OB2ZPW.js → webpack-C4DEBGCG.js} +13 -19
- package/dist/_node-chunks/webpack-EFCFZKO7.js +97 -0
- package/dist/_node-chunks/{webpack-VD3FKUZZ.js → webpack-KW7MEY7C.js} +9 -12
- package/dist/_node-chunks/webpack-TVYIGXMK.js +24 -0
- package/dist/_node-chunks/webpack-UAKFJEYJ.js +30 -0
- package/dist/_node-chunks/webpack-WL4FYVO5.js +23 -0
- package/dist/_node-chunks/webpack-WZC6ZANM.js +60 -0
- package/dist/compatibility/draft-mode.compat.js +1 -1
- package/dist/export-mocks/cache/index.js +3 -6
- package/dist/export-mocks/headers/index.js +6 -29
- package/dist/export-mocks/index.js +9 -10
- package/dist/export-mocks/navigation/index.js +17 -41
- package/dist/export-mocks/router/index.d.ts +4 -7
- package/dist/export-mocks/router/index.js +20 -54
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +38 -80
- package/dist/image-context.js +1 -1
- package/dist/images/next-image.js +5 -11
- package/dist/images/next-legacy-image.js +3 -6
- package/dist/index.js +2865 -8413
- package/dist/next-image-loader-stub.js +9 -16
- package/dist/node/index.js +6 -10
- package/dist/preset.js +183 -462
- package/dist/preview.js +2 -2
- package/dist/rsc/server-only.js +1 -1
- package/dist/swc/next-swc-loader-patch.js +46 -84
- package/package.json +6 -6
- package/dist/_browser-chunks/chunk-I5RFHXDS.js +0 -40
- package/dist/_browser-chunks/react-18-G7Q4PNHD.js +0 -71
- package/dist/_node-chunks/chunk-PWZWGY6W.js +0 -17
- package/dist/_node-chunks/chunk-UHO3ELD2.js +0 -475
- package/dist/_node-chunks/chunk-WR63XCFA.js +0 -74
- package/dist/_node-chunks/chunk-X47EC6DB.js +0 -102
- package/dist/_node-chunks/configureNextFont-ZL3UHKQ4.js +0 -36
- package/dist/_node-chunks/webpack-3J2WBZ2E.js +0 -30
- package/dist/_node-chunks/webpack-7PUWUCNJ.js +0 -27
- package/dist/_node-chunks/webpack-JVSODHFI.js +0 -38
- package/dist/_node-chunks/webpack-O36IRAFL.js +0 -77
- package/dist/_node-chunks/webpack-SNP77BVT.js +0 -107
- package/dist/_node-chunks/webpack-THQBX5DA.js +0 -26
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__export
|
|
3
|
-
|
|
4
|
-
} from "./chunk-L5NVL7MD.js";
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-SL3VIQZ3.js";
|
|
5
4
|
|
|
6
5
|
// src/preview.tsx
|
|
7
6
|
var preview_exports = {};
|
|
@@ -21,28 +20,18 @@ import * as React2 from "react";
|
|
|
21
20
|
import React, { useMemo } from "react";
|
|
22
21
|
import initHeadManager from "next/dist/client/head-manager";
|
|
23
22
|
import { HeadManagerContext } from "next/dist/shared/lib/head-manager-context.shared-runtime";
|
|
24
|
-
var HeadManagerProvider =
|
|
25
|
-
|
|
26
|
-
headManager.getIsSsr = () =>
|
|
27
|
-
|
|
28
|
-
}, "HeadManagerProvider");
|
|
29
|
-
var head_manager_provider_default = HeadManagerProvider;
|
|
23
|
+
var HeadManagerProvider = ({ children }) => {
|
|
24
|
+
let headManager = useMemo(initHeadManager, []);
|
|
25
|
+
return headManager.getIsSsr = () => !1, React.createElement(HeadManagerContext.Provider, { value: headManager }, children);
|
|
26
|
+
}, head_manager_provider_default = HeadManagerProvider;
|
|
30
27
|
|
|
31
28
|
// src/head-manager/decorator.tsx
|
|
32
|
-
var HeadManagerDecorator =
|
|
33
|
-
return React2.createElement(head_manager_provider_default, null, React2.createElement(Story, null));
|
|
34
|
-
}, "HeadManagerDecorator");
|
|
29
|
+
var HeadManagerDecorator = (Story) => React2.createElement(head_manager_provider_default, null, React2.createElement(Story, null));
|
|
35
30
|
|
|
36
31
|
// src/images/decorator.tsx
|
|
37
32
|
import * as React3 from "react";
|
|
38
33
|
import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-context";
|
|
39
|
-
var ImageContext = ImageContextValue;
|
|
40
|
-
var ImageDecorator = /* @__PURE__ */ __name((Story, { parameters: parameters2 }) => {
|
|
41
|
-
if (!parameters2.nextjs?.image) {
|
|
42
|
-
return React3.createElement(Story, null);
|
|
43
|
-
}
|
|
44
|
-
return React3.createElement(ImageContext.Provider, { value: parameters2.nextjs.image }, React3.createElement(Story, null));
|
|
45
|
-
}, "ImageDecorator");
|
|
34
|
+
var ImageContext = ImageContextValue, ImageDecorator = (Story, { parameters: parameters2 }) => parameters2.nextjs?.image ? React3.createElement(ImageContext.Provider, { value: parameters2.nextjs.image }, React3.createElement(Story, null)) : React3.createElement(Story, null);
|
|
46
35
|
|
|
47
36
|
// src/routing/decorator.tsx
|
|
48
37
|
import * as React6 from "react";
|
|
@@ -62,43 +51,30 @@ import {
|
|
|
62
51
|
SearchParamsContext
|
|
63
52
|
} from "next/dist/shared/lib/hooks-client-context.shared-runtime";
|
|
64
53
|
import { PAGE_SEGMENT_KEY } from "next/dist/shared/lib/segment";
|
|
65
|
-
var getParallelRoutes =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
return [];
|
|
71
|
-
}, "getParallelRoutes");
|
|
72
|
-
var AppRouterProvider = /* @__PURE__ */ __name(({
|
|
54
|
+
var getParallelRoutes = (segmentsList) => {
|
|
55
|
+
let segment = segmentsList.shift();
|
|
56
|
+
return segment ? [segment, { children: getParallelRoutes(segmentsList) }] : [];
|
|
57
|
+
}, AppRouterProvider = ({
|
|
73
58
|
children,
|
|
74
59
|
routeParams
|
|
75
60
|
}) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const pathParams = useMemo2(() => {
|
|
79
|
-
const params = {};
|
|
80
|
-
const currentSegments = routeParams.segments;
|
|
61
|
+
let { pathname, query, segments = [] } = routeParams, tree = [pathname, { children: getParallelRoutes([...segments]) }], pathParams = useMemo2(() => {
|
|
62
|
+
let params = {}, currentSegments = routeParams.segments;
|
|
81
63
|
if (currentSegments) {
|
|
82
64
|
if (Array.isArray(currentSegments)) {
|
|
83
|
-
for (
|
|
84
|
-
if (Array.isArray(segmentEntry) && segmentEntry.length === 2 && typeof segmentEntry[0]
|
|
85
|
-
|
|
86
|
-
const value = segmentEntry[1];
|
|
65
|
+
for (let segmentEntry of currentSegments)
|
|
66
|
+
if (Array.isArray(segmentEntry) && segmentEntry.length === 2 && typeof segmentEntry[0] == "string") {
|
|
67
|
+
let key = segmentEntry[0], value = segmentEntry[1];
|
|
87
68
|
params[key] = value;
|
|
88
69
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (Object.prototype.hasOwnProperty.call(segmentObject, key)) {
|
|
94
|
-
params[key] = segmentObject[key];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
70
|
+
} else if (typeof currentSegments == "object" && !Array.isArray(currentSegments)) {
|
|
71
|
+
let segmentObject = currentSegments;
|
|
72
|
+
for (let key in segmentObject)
|
|
73
|
+
Object.prototype.hasOwnProperty.call(segmentObject, key) && (params[key] = segmentObject[key]);
|
|
97
74
|
}
|
|
98
75
|
}
|
|
99
76
|
return params;
|
|
100
|
-
}, [routeParams.segments])
|
|
101
|
-
const newLazyCacheNode = {
|
|
77
|
+
}, [routeParams.segments]), newLazyCacheNode = {
|
|
102
78
|
lazyData: null,
|
|
103
79
|
rsc: null,
|
|
104
80
|
prefetchRsc: null,
|
|
@@ -118,10 +94,10 @@ var AppRouterProvider = /* @__PURE__ */ __name(({
|
|
|
118
94
|
buildId: "storybook",
|
|
119
95
|
tree,
|
|
120
96
|
focusAndScrollRef: {
|
|
121
|
-
apply:
|
|
97
|
+
apply: !1,
|
|
122
98
|
hashFragment: null,
|
|
123
99
|
segmentPaths: [tree],
|
|
124
|
-
onlyHashChange:
|
|
100
|
+
onlyHashChange: !1
|
|
125
101
|
},
|
|
126
102
|
nextUrl: pathname
|
|
127
103
|
}
|
|
@@ -149,64 +125,47 @@ var AppRouterProvider = /* @__PURE__ */ __name(({
|
|
|
149
125
|
children
|
|
150
126
|
))
|
|
151
127
|
))));
|
|
152
|
-
}
|
|
128
|
+
};
|
|
153
129
|
|
|
154
130
|
// src/routing/page-router-provider.tsx
|
|
155
131
|
import React5 from "react";
|
|
156
132
|
import { getRouter as getRouter2 } from "@storybook/nextjs/router.mock";
|
|
157
133
|
import { RouterContext } from "next/dist/shared/lib/router-context.shared-runtime";
|
|
158
|
-
var PageRouterProvider =
|
|
134
|
+
var PageRouterProvider = ({ children }) => React5.createElement(RouterContext.Provider, { value: getRouter2() }, children);
|
|
159
135
|
|
|
160
136
|
// src/routing/decorator.tsx
|
|
161
137
|
var defaultRouterParams = {
|
|
162
138
|
pathname: "/",
|
|
163
139
|
query: {}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
}, RouterDecorator = (Story, { parameters: parameters2 }) => parameters2.nextjs?.appDirectory ?? !1 ? AppRouterProvider ? React6.createElement(
|
|
141
|
+
AppRouterProvider,
|
|
142
|
+
{
|
|
143
|
+
routeParams: {
|
|
144
|
+
...defaultRouterParams,
|
|
145
|
+
...parameters2.nextjs?.navigation
|
|
170
146
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
routeParams: {
|
|
175
|
-
...defaultRouterParams,
|
|
176
|
-
...parameters2.nextjs?.navigation
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
React6.createElement(RedirectBoundary, null, React6.createElement(Story, null))
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
return React6.createElement(PageRouterProvider, null, React6.createElement(Story, null));
|
|
183
|
-
}, "RouterDecorator");
|
|
147
|
+
},
|
|
148
|
+
React6.createElement(RedirectBoundary, null, React6.createElement(Story, null))
|
|
149
|
+
) : null : React6.createElement(PageRouterProvider, null, React6.createElement(Story, null));
|
|
184
150
|
|
|
185
151
|
// src/styledJsx/decorator.tsx
|
|
186
152
|
import * as React7 from "react";
|
|
187
153
|
import { StyleRegistry } from "styled-jsx";
|
|
188
|
-
var StyledJsxDecorator =
|
|
154
|
+
var StyledJsxDecorator = (Story) => React7.createElement(StyleRegistry, null, React7.createElement(Story, null));
|
|
189
155
|
|
|
190
156
|
// src/preview.tsx
|
|
191
157
|
function addNextHeadCount() {
|
|
192
|
-
|
|
193
|
-
meta.name = "next-head-count";
|
|
194
|
-
meta.content = "0";
|
|
195
|
-
document.head.appendChild(meta);
|
|
158
|
+
let meta = document.createElement("meta");
|
|
159
|
+
meta.name = "next-head-count", meta.content = "0", document.head.appendChild(meta);
|
|
196
160
|
}
|
|
197
|
-
__name(addNextHeadCount, "addNextHeadCount");
|
|
198
161
|
function isAsyncClientComponentError(error) {
|
|
199
|
-
return typeof error
|
|
162
|
+
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"));
|
|
200
163
|
}
|
|
201
|
-
__name(isAsyncClientComponentError, "isAsyncClientComponentError");
|
|
202
164
|
addNextHeadCount();
|
|
203
165
|
var origConsoleError = globalThis.console.error;
|
|
204
166
|
globalThis.console.error = (...args) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
origConsoleError.apply(globalThis.console, args);
|
|
167
|
+
let error = args[0];
|
|
168
|
+
isNextRouterError(error) || isAsyncClientComponentError(error) || origConsoleError.apply(globalThis.console, args);
|
|
210
169
|
};
|
|
211
170
|
globalThis.addEventListener("error", (ev) => {
|
|
212
171
|
if (isNextRouterError(ev.error) || isAsyncClientComponentError(ev.error)) {
|
|
@@ -219,31 +178,22 @@ var decorators = [
|
|
|
219
178
|
ImageDecorator,
|
|
220
179
|
RouterDecorator,
|
|
221
180
|
HeadManagerDecorator
|
|
222
|
-
]
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
locale: globals.locale,
|
|
230
|
-
...router
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}, "loaders");
|
|
234
|
-
var parameters = {
|
|
181
|
+
], loaders = async ({ globals, parameters: parameters2 }) => {
|
|
182
|
+
let { router, appDirectory } = parameters2.nextjs ?? {};
|
|
183
|
+
appDirectory ? createNavigation(router) : createRouter({
|
|
184
|
+
locale: globals.locale,
|
|
185
|
+
...router
|
|
186
|
+
});
|
|
187
|
+
}, parameters = {
|
|
235
188
|
docs: {
|
|
236
189
|
source: {
|
|
237
|
-
excludeDecorators:
|
|
190
|
+
excludeDecorators: !0
|
|
238
191
|
}
|
|
239
192
|
},
|
|
240
193
|
react: {
|
|
241
194
|
rootOptions: {
|
|
242
195
|
onCaughtError(error) {
|
|
243
|
-
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
console.error(error);
|
|
196
|
+
isNextRouterError(error) || console.error(error);
|
|
247
197
|
}
|
|
248
198
|
}
|
|
249
199
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/images/next-image-default-loader.tsx
|
|
2
|
+
var defaultLoader = ({ src, width, quality = 75 }) => {
|
|
3
|
+
let missingValues = [];
|
|
4
|
+
if (src || missingValues.push("src"), width || missingValues.push("width"), missingValues.length > 0)
|
|
5
|
+
throw new Error(
|
|
6
|
+
`Next Image Optimization requires ${missingValues.join(
|
|
7
|
+
", "
|
|
8
|
+
)} to be provided. Make sure you pass them as props to the \`next/image\` component. Received: ${JSON.stringify(
|
|
9
|
+
{
|
|
10
|
+
src,
|
|
11
|
+
width,
|
|
12
|
+
quality
|
|
13
|
+
}
|
|
14
|
+
)}`
|
|
15
|
+
);
|
|
16
|
+
let url = new URL(src, window.location.href);
|
|
17
|
+
return !url.searchParams.has("w") && !url.searchParams.has("q") && (url.searchParams.set("w", width.toString()), url.searchParams.set("q", quality.toString())), !src.startsWith("http://") && !src.startsWith("https://") ? url.toString().slice(url.origin.length) : url.toString();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
defaultLoader
|
|
22
|
+
};
|
|
@@ -2,22 +2,17 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var
|
|
7
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __commonJS = (cb, mod) => function() {
|
|
9
7
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
8
|
};
|
|
11
9
|
var __export = (target, all) => {
|
|
12
10
|
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
12
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
17
14
|
for (let key of __getOwnPropNames(from))
|
|
18
|
-
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
15
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
16
|
return to;
|
|
22
17
|
};
|
|
23
18
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -25,12 +20,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
20
|
// file that has been converted to a CommonJS file using a Babel-
|
|
26
21
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
22
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
29
24
|
mod
|
|
30
25
|
));
|
|
31
26
|
|
|
32
27
|
export {
|
|
33
|
-
__name,
|
|
34
28
|
__commonJS,
|
|
35
29
|
__export,
|
|
36
30
|
__toESM
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import "./chunk-SL3VIQZ3.js";
|
|
2
|
+
|
|
3
|
+
// ../../lib/react-dom-shim/dist/react-18.js
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import * as ReactDOM from "react-dom/client";
|
|
6
|
+
var nodes = /* @__PURE__ */ new Map();
|
|
7
|
+
function getIsReactActEnvironment() {
|
|
8
|
+
return globalThis.IS_REACT_ACT_ENVIRONMENT;
|
|
9
|
+
}
|
|
10
|
+
var WithCallback = ({
|
|
11
|
+
callback,
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
let once = React.useRef();
|
|
15
|
+
return React.useLayoutEffect(() => {
|
|
16
|
+
once.current !== callback && (once.current = callback, callback());
|
|
17
|
+
}, [callback]), children;
|
|
18
|
+
};
|
|
19
|
+
typeof Promise.withResolvers > "u" && (Promise.withResolvers = () => {
|
|
20
|
+
let resolve = null, reject = null;
|
|
21
|
+
return { promise: new Promise((res, rej) => {
|
|
22
|
+
resolve = res, reject = rej;
|
|
23
|
+
}), resolve, reject };
|
|
24
|
+
});
|
|
25
|
+
var renderElement = async (node, el, rootOptions) => {
|
|
26
|
+
let root = await getReactRoot(el, rootOptions);
|
|
27
|
+
if (getIsReactActEnvironment()) {
|
|
28
|
+
root.render(node);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let { promise, resolve } = Promise.withResolvers();
|
|
32
|
+
return root.render(React.createElement(WithCallback, { callback: resolve }, node)), promise;
|
|
33
|
+
}, unmountElement = (el, shouldUseNewRootApi) => {
|
|
34
|
+
let root = nodes.get(el);
|
|
35
|
+
root && (root.unmount(), nodes.delete(el));
|
|
36
|
+
}, getReactRoot = async (el, rootOptions) => {
|
|
37
|
+
let root = nodes.get(el);
|
|
38
|
+
return root || (root = ReactDOM.createRoot(el, rootOptions), nodes.set(el, root)), root;
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
renderElement,
|
|
42
|
+
unmountElement
|
|
43
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_kl8x2s4rzz from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_kl8x2s4rzz from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_kl8x2s4rzz from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_kl8x2s4rzz.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_kl8x2s4rzz.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_kl8x2s4rzz.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-NVHRUSN5.js";
|
|
15
|
+
|
|
16
|
+
// src/utils.ts
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import { dirname, join, sep } from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
import { getProjectRoot } from "storybook/internal/common";
|
|
21
|
+
import { WebpackDefinePlugin } from "@storybook/builder-webpack5";
|
|
22
|
+
import { PHASE_DEVELOPMENT_SERVER } from "next/constants.js";
|
|
23
|
+
import nextJsLoadConfigModule from "next/dist/server/config.js";
|
|
24
|
+
import semver from "semver";
|
|
25
|
+
var configureRuntimeNextjsVersionResolution = (baseConfig) => {
|
|
26
|
+
baseConfig.plugins?.push(
|
|
27
|
+
new WebpackDefinePlugin({
|
|
28
|
+
"process.env.__NEXT_VERSION": JSON.stringify(getNextjsVersion())
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}, getNextjsVersion = () => JSON.parse(readFileSync(join(resolvePackageDir("next"), "package.json"), "utf8")).version, isNextVersionGte = (version) => {
|
|
32
|
+
let currentVersion = getNextjsVersion(), coercedVersion = semver.coerce(currentVersion);
|
|
33
|
+
return coercedVersion ? semver.gte(coercedVersion, version) : !1;
|
|
34
|
+
}, resolveNextConfig = async ({
|
|
35
|
+
nextConfigPath
|
|
36
|
+
}) => {
|
|
37
|
+
let dir = nextConfigPath ? dirname(nextConfigPath) : getProjectRoot(), loadConfig = nextJsLoadConfigModule.default ?? nextJsLoadConfigModule, nextPrivateRenderWorker = process.env.__NEXT_PRIVATE_RENDER_WORKER;
|
|
38
|
+
process.env.__NEXT_PRIVATE_RENDER_WORKER = "defined";
|
|
39
|
+
let config = loadConfig(PHASE_DEVELOPMENT_SERVER, dir, void 0);
|
|
40
|
+
return typeof nextPrivateRenderWorker > "u" ? delete process.env.__NEXT_PRIVATE_RENDER_WORKER : process.env.__NEXT_PRIVATE_RENDER_WORKER = nextPrivateRenderWorker, config;
|
|
41
|
+
};
|
|
42
|
+
function setAlias(baseConfig, name, alias) {
|
|
43
|
+
baseConfig.resolve ??= {}, baseConfig.resolve.alias ??= {};
|
|
44
|
+
let aliasConfig = baseConfig.resolve.alias;
|
|
45
|
+
Array.isArray(aliasConfig) ? aliasConfig.push({
|
|
46
|
+
name,
|
|
47
|
+
alias
|
|
48
|
+
}) : aliasConfig[name] = alias;
|
|
49
|
+
}
|
|
50
|
+
var addScopedAlias = (baseConfig, name, alias) => {
|
|
51
|
+
let scopedAlias = scopedResolve(`${alias ?? name}`);
|
|
52
|
+
setAlias(baseConfig, name, scopedAlias);
|
|
53
|
+
}, scopedResolve = (id) => {
|
|
54
|
+
let scopedModulePath = fileURLToPath(import.meta.resolve(id)), idWithNativePathSep = id.replace(/\//g, sep);
|
|
55
|
+
if (scopedModulePath.endsWith(idWithNativePathSep))
|
|
56
|
+
return scopedModulePath;
|
|
57
|
+
let beginningOfMainScriptPath = scopedModulePath.lastIndexOf(idWithNativePathSep) + id.length;
|
|
58
|
+
return scopedModulePath.substring(0, beginningOfMainScriptPath);
|
|
59
|
+
};
|
|
60
|
+
function getNodeModulesExcludeRegex(transpilePackages) {
|
|
61
|
+
if (!transpilePackages || transpilePackages.length === 0)
|
|
62
|
+
return /node_modules/;
|
|
63
|
+
let escaped = transpilePackages.map((pkg) => pkg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
64
|
+
return new RegExp(`node_modules/(?!(${escaped})/)`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
configureRuntimeNextjsVersionResolution,
|
|
69
|
+
getNextjsVersion,
|
|
70
|
+
isNextVersionGte,
|
|
71
|
+
resolveNextConfig,
|
|
72
|
+
setAlias,
|
|
73
|
+
addScopedAlias,
|
|
74
|
+
scopedResolve,
|
|
75
|
+
getNodeModulesExcludeRegex
|
|
76
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_kl8x2s4rzz from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_kl8x2s4rzz from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_kl8x2s4rzz from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_kl8x2s4rzz.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_kl8x2s4rzz.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_kl8x2s4rzz.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
addScopedAlias,
|
|
14
|
+
getNextjsVersion,
|
|
15
|
+
setAlias
|
|
16
|
+
} from "./chunk-AU547LNK.js";
|
|
17
|
+
|
|
18
|
+
// src/compatibility/compatibility-map.ts
|
|
19
|
+
import semver from "semver";
|
|
20
|
+
var mapping = {
|
|
21
|
+
"<15.0.0": {
|
|
22
|
+
"next/dist/server/request/headers": "next/dist/client/components/headers",
|
|
23
|
+
// this path only exists from Next 15 onwards
|
|
24
|
+
"next/dist/server/request/draft-mode": "@storybook/nextjs/compatibility/draft-mode.compat"
|
|
25
|
+
}
|
|
26
|
+
}, getCompatibilityAliases = () => {
|
|
27
|
+
let version = getNextjsVersion(), result = {};
|
|
28
|
+
return Object.keys(mapping).forEach((key) => {
|
|
29
|
+
semver.intersects(version, key) && Object.assign(result, mapping[key]);
|
|
30
|
+
}), result;
|
|
31
|
+
}, configureCompatibilityAliases = (baseConfig) => {
|
|
32
|
+
let aliases = getCompatibilityAliases();
|
|
33
|
+
Object.entries(aliases).forEach(([name, alias]) => {
|
|
34
|
+
typeof alias == "string" ? addScopedAlias(baseConfig, name, alias) : setAlias(baseConfig, name, alias);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/export-mocks/webpack.ts
|
|
39
|
+
var mapping2 = {
|
|
40
|
+
"next/headers": "@storybook/nextjs/headers.mock",
|
|
41
|
+
"next/navigation": "@storybook/nextjs/navigation.mock",
|
|
42
|
+
"next/router": "@storybook/nextjs/router.mock",
|
|
43
|
+
"next/cache": "@storybook/nextjs/cache.mock",
|
|
44
|
+
...getCompatibilityAliases()
|
|
45
|
+
}, getPackageAliases = () => mapping2, configureNextExportMocks = (baseConfig) => {
|
|
46
|
+
let resolve = baseConfig.resolve ?? {};
|
|
47
|
+
resolve.alias = {
|
|
48
|
+
...resolve.alias,
|
|
49
|
+
...mapping2
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
configureCompatibilityAliases,
|
|
55
|
+
getPackageAliases,
|
|
56
|
+
configureNextExportMocks
|
|
57
|
+
};
|