@storybook/nextjs 10.1.0-alpha.9 → 10.1.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/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-FDQCPWTU.js +76 -0
- package/dist/_node-chunks/chunk-FG42E7V6.js +57 -0
- package/dist/_node-chunks/chunk-GP2MEE4L.js +211 -0
- package/dist/_node-chunks/configureNextFont-C7CJ3HQC.js +28 -0
- package/dist/_node-chunks/{loader-7OJQICYP.js → loader-5F2KS4LJ.js} +15 -25
- package/dist/_node-chunks/{loader-OFLGZQCU.js → loader-MSHAULDY.js} +11 -16
- package/dist/_node-chunks/{utils-NVB3HGRH.js → utils-CTOPCADU.js} +8 -9
- package/dist/_node-chunks/webpack-2BV2ZM4Y.js +23 -0
- package/dist/_node-chunks/{webpack-E2OB2ZPW.js → webpack-552M7BUF.js} +13 -19
- package/dist/_node-chunks/webpack-L7NHDPNJ.js +30 -0
- package/dist/_node-chunks/{webpack-VD3FKUZZ.js → webpack-MROJ5SGY.js} +9 -12
- package/dist/_node-chunks/webpack-OJMVAOEH.js +24 -0
- package/dist/_node-chunks/webpack-UVPHU4VM.js +23 -0
- package/dist/_node-chunks/webpack-VOQXZA35.js +60 -0
- package/dist/_node-chunks/webpack-WG2HZDLK.js +97 -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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_irqg4lxu6e from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_irqg4lxu6e from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_irqg4lxu6e from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_irqg4lxu6e.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_irqg4lxu6e.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_irqg4lxu6e.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
getNextjsVersion
|
|
14
|
+
} from "./chunk-FDQCPWTU.js";
|
|
15
|
+
import "./chunk-GP2MEE4L.js";
|
|
16
|
+
|
|
17
|
+
// src/images/webpack.ts
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
import semver from "semver";
|
|
20
|
+
var configureImages = (baseConfig, nextConfig) => {
|
|
21
|
+
configureStaticImageImport(baseConfig, nextConfig), configureImageDefaults(baseConfig);
|
|
22
|
+
}, fallbackFilename = "static/media/[path][name][ext]", configureImageDefaults = (baseConfig) => {
|
|
23
|
+
let version = getNextjsVersion(), resolve = baseConfig.resolve ?? {};
|
|
24
|
+
resolve.alias = {
|
|
25
|
+
...resolve.alias,
|
|
26
|
+
"sb-original/next/image": fileURLToPath(import.meta.resolve("next/image")),
|
|
27
|
+
"next/image": "@storybook/nextjs/images/next-image"
|
|
28
|
+
}, semver.satisfies(version, ">=13.0.0") && (resolve.alias = {
|
|
29
|
+
...resolve.alias,
|
|
30
|
+
"sb-original/next/legacy/image": fileURLToPath(import.meta.resolve("next/legacy/image")),
|
|
31
|
+
"next/legacy/image": "@storybook/nextjs/images/next-legacy-image"
|
|
32
|
+
});
|
|
33
|
+
}, configureStaticImageImport = (baseConfig, nextConfig) => {
|
|
34
|
+
let rules = baseConfig.module?.rules, assetRule = rules?.find(
|
|
35
|
+
(rule) => rule && typeof rule != "string" && rule.test instanceof RegExp && rule.test.test("test.jpg")
|
|
36
|
+
);
|
|
37
|
+
assetRule && (assetRule.test = /\.(apng|eot|otf|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/, rules?.push({
|
|
38
|
+
test: /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,
|
|
39
|
+
issuer: { not: /\.(css|scss|sass)$/ },
|
|
40
|
+
use: [
|
|
41
|
+
{
|
|
42
|
+
loader: fileURLToPath(import.meta.resolve("@storybook/nextjs/next-image-loader-stub")),
|
|
43
|
+
options: {
|
|
44
|
+
filename: assetRule.generator?.filename ?? fallbackFilename,
|
|
45
|
+
nextConfig
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}), rules?.push({
|
|
50
|
+
test: /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i,
|
|
51
|
+
issuer: /\.(css|scss|sass)$/,
|
|
52
|
+
type: "asset/resource",
|
|
53
|
+
generator: {
|
|
54
|
+
filename: assetRule.generator?.filename ?? fallbackFilename
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
configureImages
|
|
60
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_irqg4lxu6e from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_irqg4lxu6e from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_irqg4lxu6e from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_irqg4lxu6e.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_irqg4lxu6e.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_irqg4lxu6e.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-GP2MEE4L.js";
|
|
15
|
+
|
|
16
|
+
// src/css/webpack.ts
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
import { cssFileResolve } from "next/dist/build/webpack/config/blocks/css/loaders/file-resolve.js";
|
|
21
|
+
import { getCssModuleLocalIdent } from "next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js";
|
|
22
|
+
import semver from "semver";
|
|
23
|
+
var configureCss = (baseConfig, nextConfig) => {
|
|
24
|
+
let rules = baseConfig.module?.rules;
|
|
25
|
+
rules?.forEach((rule, i) => {
|
|
26
|
+
rule && typeof rule != "string" && rule.test instanceof RegExp && rule.test.test("test.css") && (rules[i] = {
|
|
27
|
+
test: /\.css$/,
|
|
28
|
+
use: [
|
|
29
|
+
fileURLToPath(import.meta.resolve("style-loader")),
|
|
30
|
+
{
|
|
31
|
+
loader: fileURLToPath(import.meta.resolve("css-loader")),
|
|
32
|
+
options: {
|
|
33
|
+
importLoaders: 1,
|
|
34
|
+
...getImportAndUrlCssLoaderOptions(nextConfig),
|
|
35
|
+
modules: {
|
|
36
|
+
auto: !0,
|
|
37
|
+
getLocalIdent: getCssModuleLocalIdent
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
fileURLToPath(import.meta.resolve("postcss-loader"))
|
|
42
|
+
],
|
|
43
|
+
// We transform the "target.css" files from next.js into Javascript
|
|
44
|
+
// for Next.js to support fonts, so it should be ignored by the css-loader.
|
|
45
|
+
exclude: /next(\\|\/|\\\\).*(\\|\/|\\\\)target\.css$/
|
|
46
|
+
});
|
|
47
|
+
}), rules?.push({
|
|
48
|
+
test: /\.(scss|sass)$/,
|
|
49
|
+
use: [
|
|
50
|
+
fileURLToPath(import.meta.resolve("style-loader")),
|
|
51
|
+
{
|
|
52
|
+
loader: fileURLToPath(import.meta.resolve("css-loader")),
|
|
53
|
+
options: {
|
|
54
|
+
importLoaders: 3,
|
|
55
|
+
...getImportAndUrlCssLoaderOptions(nextConfig),
|
|
56
|
+
modules: { auto: !0, getLocalIdent: getCssModuleLocalIdent }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
fileURLToPath(import.meta.resolve("postcss-loader")),
|
|
60
|
+
fileURLToPath(import.meta.resolve("resolve-url-loader")),
|
|
61
|
+
{
|
|
62
|
+
loader: fileURLToPath(import.meta.resolve("sass-loader")),
|
|
63
|
+
options: {
|
|
64
|
+
sourceMap: !0,
|
|
65
|
+
sassOptions: nextConfig.sassOptions,
|
|
66
|
+
additionalData: nextConfig.sassOptions?.prependData || nextConfig.sassOptions?.additionalData
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}, getImportAndUrlCssLoaderOptions = (nextConfig) => isCssLoaderV6() ? {
|
|
72
|
+
url: {
|
|
73
|
+
filter: getUrlResolver(nextConfig)
|
|
74
|
+
},
|
|
75
|
+
import: {
|
|
76
|
+
filter: getImportResolver(nextConfig)
|
|
77
|
+
}
|
|
78
|
+
} : {
|
|
79
|
+
url: getUrlResolver(nextConfig),
|
|
80
|
+
import: getImportResolver(nextConfig)
|
|
81
|
+
}, getUrlResolver = (nextConfig) => (url, resourcePath) => cssFileResolve(url, resourcePath, nextConfig.experimental?.urlImports), getImportResolver = (nextConfig) => (url, _, resourcePath) => cssFileResolve(
|
|
82
|
+
typeof url == "string" ? url : url.url,
|
|
83
|
+
resourcePath,
|
|
84
|
+
nextConfig.experimental?.urlImports
|
|
85
|
+
), isCssLoaderV6 = () => {
|
|
86
|
+
try {
|
|
87
|
+
let cssLoaderVersion = JSON.parse(
|
|
88
|
+
readFileSync(join(resolvePackageDir("css-loader"), "package.json"), "utf8")
|
|
89
|
+
).version;
|
|
90
|
+
return semver.gte(cssLoaderVersion, "6.0.0");
|
|
91
|
+
} catch {
|
|
92
|
+
return !1;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
configureCss
|
|
97
|
+
};
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import "../../_browser-chunks/chunk-
|
|
1
|
+
import "../../_browser-chunks/chunk-SL3VIQZ3.js";
|
|
2
2
|
|
|
3
3
|
// src/export-mocks/cache/index.ts
|
|
4
4
|
import { unstable_cache } from "next/dist/server/web/spec-extension/unstable-cache";
|
|
5
5
|
import { unstable_noStore } from "next/dist/server/web/spec-extension/unstable-no-store";
|
|
6
6
|
import { fn } from "storybook/test";
|
|
7
|
-
var revalidatePath = fn().mockName("next/cache::revalidatePath")
|
|
8
|
-
var revalidateTag = fn().mockName("next/cache::revalidateTag");
|
|
9
|
-
var cacheExports = {
|
|
7
|
+
var revalidatePath = fn().mockName("next/cache::revalidatePath"), revalidateTag = fn().mockName("next/cache::revalidateTag"), cacheExports = {
|
|
10
8
|
unstable_cache,
|
|
11
9
|
revalidateTag,
|
|
12
10
|
revalidatePath,
|
|
13
11
|
unstable_noStore
|
|
14
|
-
};
|
|
15
|
-
var cache_default = cacheExports;
|
|
12
|
+
}, cache_default = cacheExports;
|
|
16
13
|
export {
|
|
17
14
|
cache_default as default,
|
|
18
15
|
revalidatePath,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
__name
|
|
3
|
-
} from "../../_browser-chunks/chunk-L5NVL7MD.js";
|
|
1
|
+
import "../../_browser-chunks/chunk-SL3VIQZ3.js";
|
|
4
2
|
|
|
5
3
|
// src/export-mocks/headers/index.ts
|
|
6
4
|
import { draftMode as originalDraftMode } from "next/dist/server/request/draft-mode";
|
|
@@ -11,7 +9,7 @@ export * from "next/dist/server/request/headers";
|
|
|
11
9
|
// src/export-mocks/headers/headers.ts
|
|
12
10
|
import { HeadersAdapter } from "next/dist/server/web/spec-extension/adapters/headers";
|
|
13
11
|
import { fn } from "storybook/test";
|
|
14
|
-
var
|
|
12
|
+
var HeadersAdapterMock = class extends HeadersAdapter {
|
|
15
13
|
constructor() {
|
|
16
14
|
super({});
|
|
17
15
|
this.append = fn(super.append.bind(this)).mockName("next/headers::headers().append");
|
|
@@ -24,16 +22,7 @@ var _HeadersAdapterMock = class _HeadersAdapterMock extends HeadersAdapter {
|
|
|
24
22
|
this.keys = fn(super.keys.bind(this)).mockName("next/headers::headers().keys");
|
|
25
23
|
this.values = fn(super.values.bind(this)).mockName("next/headers::headers().values");
|
|
26
24
|
}
|
|
27
|
-
};
|
|
28
|
-
__name(_HeadersAdapterMock, "HeadersAdapterMock");
|
|
29
|
-
var HeadersAdapterMock = _HeadersAdapterMock;
|
|
30
|
-
var headersAdapterMock;
|
|
31
|
-
var headers = /* @__PURE__ */ __name(() => {
|
|
32
|
-
if (!headersAdapterMock) {
|
|
33
|
-
headersAdapterMock = new HeadersAdapterMock();
|
|
34
|
-
}
|
|
35
|
-
return headersAdapterMock;
|
|
36
|
-
}, "headers");
|
|
25
|
+
}, headersAdapterMock, headers = () => (headersAdapterMock || (headersAdapterMock = new HeadersAdapterMock()), headersAdapterMock);
|
|
37
26
|
headers.mockRestore = () => {
|
|
38
27
|
headersAdapterMock = new HeadersAdapterMock();
|
|
39
28
|
};
|
|
@@ -42,7 +31,7 @@ headers.mockRestore = () => {
|
|
|
42
31
|
import { headers as headers2 } from "@storybook/nextjs/headers.mock";
|
|
43
32
|
import { RequestCookies } from "next/dist/compiled/@edge-runtime/cookies";
|
|
44
33
|
import { fn as fn2 } from "storybook/test";
|
|
45
|
-
var
|
|
34
|
+
var RequestCookiesMock = class extends RequestCookies {
|
|
46
35
|
constructor() {
|
|
47
36
|
super(...arguments);
|
|
48
37
|
this.get = fn2(super.get.bind(this)).mockName("next/headers::cookies().get");
|
|
@@ -51,21 +40,9 @@ var _RequestCookiesMock = class _RequestCookiesMock extends RequestCookies {
|
|
|
51
40
|
this.set = fn2(super.set.bind(this)).mockName("next/headers::cookies().set");
|
|
52
41
|
this.delete = fn2(super.delete.bind(this)).mockName("next/headers::cookies().delete");
|
|
53
42
|
}
|
|
54
|
-
};
|
|
55
|
-
__name(_RequestCookiesMock, "RequestCookiesMock");
|
|
56
|
-
var RequestCookiesMock = _RequestCookiesMock;
|
|
57
|
-
var requestCookiesMock;
|
|
58
|
-
var cookies = fn2(() => {
|
|
59
|
-
if (!requestCookiesMock) {
|
|
60
|
-
requestCookiesMock = new RequestCookiesMock(headers2());
|
|
61
|
-
}
|
|
62
|
-
return requestCookiesMock;
|
|
63
|
-
}).mockName("next/headers::cookies()");
|
|
64
|
-
var originalRestore = cookies.mockRestore.bind(null);
|
|
43
|
+
}, requestCookiesMock, cookies = fn2(() => (requestCookiesMock || (requestCookiesMock = new RequestCookiesMock(headers2())), requestCookiesMock)).mockName("next/headers::cookies()"), originalRestore = cookies.mockRestore.bind(null);
|
|
65
44
|
cookies.mockRestore = () => {
|
|
66
|
-
originalRestore();
|
|
67
|
-
headers2.mockRestore();
|
|
68
|
-
requestCookiesMock = new RequestCookiesMock(headers2());
|
|
45
|
+
originalRestore(), headers2.mockRestore(), requestCookiesMock = new RequestCookiesMock(headers2());
|
|
69
46
|
};
|
|
70
47
|
|
|
71
48
|
// src/export-mocks/headers/index.ts
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_irqg4lxu6e from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_irqg4lxu6e from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_irqg4lxu6e from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_irqg4lxu6e.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_irqg4lxu6e.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_irqg4lxu6e.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
getPackageAliases
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
15
|
-
import "../_node-chunks/chunk-
|
|
16
|
-
import "../_node-chunks/chunk-
|
|
17
|
-
import "../_node-chunks/chunk-PWZWGY6W.js";
|
|
14
|
+
} from "../_node-chunks/chunk-FG42E7V6.js";
|
|
15
|
+
import "../_node-chunks/chunk-FDQCPWTU.js";
|
|
16
|
+
import "../_node-chunks/chunk-GP2MEE4L.js";
|
|
18
17
|
export {
|
|
19
18
|
getPackageAliases
|
|
20
19
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
__name
|
|
3
|
-
} from "../../_browser-chunks/chunk-L5NVL7MD.js";
|
|
1
|
+
import "../../_browser-chunks/chunk-SL3VIQZ3.js";
|
|
4
2
|
|
|
5
3
|
// src/export-mocks/navigation/index.ts
|
|
6
4
|
import { NextjsRouterMocksNotAvailable } from "storybook/internal/preview-errors";
|
|
@@ -9,9 +7,8 @@ import { getRedirectError } from "next/dist/client/components/redirect";
|
|
|
9
7
|
import { RedirectStatusCode } from "next/dist/client/components/redirect-status-code";
|
|
10
8
|
import { fn } from "storybook/test";
|
|
11
9
|
export * from "next/dist/client/components/navigation";
|
|
12
|
-
var navigationAPI
|
|
13
|
-
|
|
14
|
-
const navigationActions = {
|
|
10
|
+
var navigationAPI, createNavigation = (overrides) => {
|
|
11
|
+
let navigationActions = {
|
|
15
12
|
push: fn().mockName("next/navigation::useRouter().push"),
|
|
16
13
|
replace: fn().mockName("next/navigation::useRouter().replace"),
|
|
17
14
|
forward: fn().mockName("next/navigation::useRouter().forward"),
|
|
@@ -19,59 +16,38 @@ var createNavigation = /* @__PURE__ */ __name((overrides) => {
|
|
|
19
16
|
prefetch: fn().mockName("next/navigation::useRouter().prefetch"),
|
|
20
17
|
refresh: fn().mockName("next/navigation::useRouter().refresh")
|
|
21
18
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}).mockName(`useRouter().${key}`);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
navigationAPI = navigationActions;
|
|
32
|
-
return navigationAPI;
|
|
33
|
-
}, "createNavigation");
|
|
34
|
-
var getRouter = /* @__PURE__ */ __name(() => {
|
|
35
|
-
if (!navigationAPI) {
|
|
19
|
+
return overrides && Object.keys(navigationActions).forEach((key) => {
|
|
20
|
+
key in overrides && (navigationActions[key] = fn((...args) => overrides[key](...args)).mockName(`useRouter().${key}`));
|
|
21
|
+
}), navigationAPI = navigationActions, navigationAPI;
|
|
22
|
+
}, getRouter = () => {
|
|
23
|
+
if (!navigationAPI)
|
|
36
24
|
throw new NextjsRouterMocksNotAvailable({
|
|
37
25
|
importType: "next/navigation"
|
|
38
26
|
});
|
|
39
|
-
}
|
|
40
27
|
return navigationAPI;
|
|
41
|
-
},
|
|
42
|
-
var redirect = fn(
|
|
28
|
+
}, redirect = fn(
|
|
43
29
|
(url, type = actual.RedirectType.push) => {
|
|
44
30
|
throw getRedirectError(url, type, RedirectStatusCode.SeeOther);
|
|
45
31
|
}
|
|
46
|
-
).mockName("next/navigation::redirect")
|
|
47
|
-
var permanentRedirect = fn(
|
|
32
|
+
).mockName("next/navigation::redirect"), permanentRedirect = fn(
|
|
48
33
|
(url, type = actual.RedirectType.push) => {
|
|
49
34
|
throw getRedirectError(url, type, RedirectStatusCode.SeeOther);
|
|
50
35
|
}
|
|
51
|
-
).mockName("next/navigation::permanentRedirect")
|
|
52
|
-
var useSearchParams2 = fn(actual.useSearchParams).mockName(
|
|
36
|
+
).mockName("next/navigation::permanentRedirect"), useSearchParams2 = fn(actual.useSearchParams).mockName(
|
|
53
37
|
"next/navigation::useSearchParams"
|
|
54
|
-
)
|
|
55
|
-
var usePathname2 = fn(actual.usePathname).mockName("next/navigation::usePathname");
|
|
56
|
-
var useSelectedLayoutSegment2 = fn(actual.useSelectedLayoutSegment).mockName(
|
|
38
|
+
), usePathname2 = fn(actual.usePathname).mockName("next/navigation::usePathname"), useSelectedLayoutSegment2 = fn(actual.useSelectedLayoutSegment).mockName(
|
|
57
39
|
"next/navigation::useSelectedLayoutSegment"
|
|
58
|
-
)
|
|
59
|
-
var useSelectedLayoutSegments2 = fn(actual.useSelectedLayoutSegments).mockName(
|
|
40
|
+
), useSelectedLayoutSegments2 = fn(actual.useSelectedLayoutSegments).mockName(
|
|
60
41
|
"next/navigation::useSelectedLayoutSegments"
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
if (!navigationAPI) {
|
|
42
|
+
), useRouter = fn(() => {
|
|
43
|
+
if (!navigationAPI)
|
|
64
44
|
throw new NextjsRouterMocksNotAvailable({
|
|
65
45
|
importType: "next/navigation"
|
|
66
46
|
});
|
|
67
|
-
}
|
|
68
47
|
return navigationAPI;
|
|
69
|
-
}).mockName("next/navigation::useRouter")
|
|
70
|
-
var useServerInsertedHTML2 = fn(actual.useServerInsertedHTML).mockName(
|
|
48
|
+
}).mockName("next/navigation::useRouter"), useServerInsertedHTML2 = fn(actual.useServerInsertedHTML).mockName(
|
|
71
49
|
"next/navigation::useServerInsertedHTML"
|
|
72
|
-
);
|
|
73
|
-
var notFound2 = fn(actual.notFound).mockName("next/navigation::notFound");
|
|
74
|
-
var useParams2 = fn(actual.useParams).mockName("next/navigation::useParams");
|
|
50
|
+
), notFound2 = fn(actual.notFound).mockName("next/navigation::notFound"), useParams2 = fn(actual.useParams).mockName("next/navigation::useParams");
|
|
75
51
|
export {
|
|
76
52
|
createNavigation,
|
|
77
53
|
getRouter,
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import * as next from 'next';
|
|
4
|
-
import * as singletonRouter from 'next/dist/client/router';
|
|
5
|
-
import singletonRouter__default from 'next/dist/client/router';
|
|
1
|
+
import * as originalRouter from 'next/dist/client/router';
|
|
2
|
+
import originalRouter__default from 'next/dist/client/router';
|
|
6
3
|
export * from 'next/dist/client/router';
|
|
7
4
|
export { default } from 'next/dist/client/router';
|
|
8
5
|
import { NextRouter } from 'next/router';
|
|
@@ -40,7 +37,7 @@ declare const getRouter: () => {
|
|
|
40
37
|
isPreview: boolean;
|
|
41
38
|
};
|
|
42
39
|
|
|
43
|
-
declare const useRouter: Mock<typeof
|
|
44
|
-
declare const withRouter: Mock<
|
|
40
|
+
declare const useRouter: Mock<typeof originalRouter.useRouter>;
|
|
41
|
+
declare const withRouter: Mock<typeof originalRouter.withRouter>;
|
|
45
42
|
|
|
46
43
|
export { createRouter, getRouter, useRouter, withRouter };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
__name
|
|
3
|
-
} from "../../_browser-chunks/chunk-L5NVL7MD.js";
|
|
1
|
+
import "../../_browser-chunks/chunk-SL3VIQZ3.js";
|
|
4
2
|
|
|
5
3
|
// src/export-mocks/router/index.ts
|
|
6
4
|
import { NextjsRouterMocksNotAvailable } from "storybook/internal/preview-errors";
|
|
@@ -13,33 +11,24 @@ var defaultRouterState = {
|
|
|
13
11
|
basePath: "/",
|
|
14
12
|
pathname: "/",
|
|
15
13
|
query: {},
|
|
16
|
-
isFallback:
|
|
17
|
-
isLocaleDomain:
|
|
18
|
-
isReady:
|
|
19
|
-
isPreview:
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
push: fn((..._args) => {
|
|
25
|
-
return Promise.resolve(true);
|
|
26
|
-
}).mockName("next/router::useRouter().push"),
|
|
27
|
-
replace: fn((..._args) => {
|
|
28
|
-
return Promise.resolve(true);
|
|
29
|
-
}).mockName("next/router::useRouter().replace"),
|
|
14
|
+
isFallback: !1,
|
|
15
|
+
isLocaleDomain: !1,
|
|
16
|
+
isReady: !0,
|
|
17
|
+
isPreview: !1
|
|
18
|
+
}, routerAPI, createRouter = (overrides) => {
|
|
19
|
+
let routerActions = {
|
|
20
|
+
push: fn((..._args) => Promise.resolve(!0)).mockName("next/router::useRouter().push"),
|
|
21
|
+
replace: fn((..._args) => Promise.resolve(!0)).mockName("next/router::useRouter().replace"),
|
|
30
22
|
reload: fn((..._args) => {
|
|
31
23
|
}).mockName("next/router::useRouter().reload"),
|
|
32
24
|
back: fn((..._args) => {
|
|
33
25
|
}).mockName("next/router::useRouter().back"),
|
|
34
26
|
forward: fn(() => {
|
|
35
27
|
}).mockName("next/router::useRouter().forward"),
|
|
36
|
-
prefetch: fn((..._args) =>
|
|
37
|
-
return Promise.resolve();
|
|
38
|
-
}).mockName("next/router::useRouter().prefetch"),
|
|
28
|
+
prefetch: fn((..._args) => Promise.resolve()).mockName("next/router::useRouter().prefetch"),
|
|
39
29
|
beforePopState: fn((..._args) => {
|
|
40
30
|
}).mockName("next/router::useRouter().beforePopState")
|
|
41
|
-
}
|
|
42
|
-
const routerEvents = {
|
|
31
|
+
}, routerEvents = {
|
|
43
32
|
on: fn((..._args) => {
|
|
44
33
|
}).mockName("next/router::useRouter().events.on"),
|
|
45
34
|
off: fn((..._args) => {
|
|
@@ -47,47 +36,24 @@ var createRouter = /* @__PURE__ */ __name((overrides) => {
|
|
|
47
36
|
emit: fn((..._args) => {
|
|
48
37
|
}).mockName("next/router::useRouter().events.emit")
|
|
49
38
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}).mockName(`useRouter().${key}`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (overrides?.events) {
|
|
60
|
-
Object.keys(routerEvents).forEach((key) => {
|
|
61
|
-
if (key in routerEvents) {
|
|
62
|
-
routerEvents[key] = fn((...args) => {
|
|
63
|
-
return overrides.events[key](...args);
|
|
64
|
-
}).mockName(`useRouter().events.${key}`);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
routerAPI = {
|
|
39
|
+
return overrides && Object.keys(routerActions).forEach((key) => {
|
|
40
|
+
key in overrides && (routerActions[key] = fn((...args) => overrides[key](...args)).mockName(`useRouter().${key}`));
|
|
41
|
+
}), overrides?.events && Object.keys(routerEvents).forEach((key) => {
|
|
42
|
+
key in routerEvents && (routerEvents[key] = fn((...args) => overrides.events[key](...args)).mockName(`useRouter().events.${key}`));
|
|
43
|
+
}), routerAPI = {
|
|
69
44
|
...defaultRouterState,
|
|
70
45
|
...overrides,
|
|
71
46
|
...routerActions,
|
|
72
47
|
// @ts-expect-error TODO improve typings
|
|
73
48
|
events: routerEvents
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
singletonRouter.readyCallbacks = [];
|
|
78
|
-
return routerAPI;
|
|
79
|
-
}, "createRouter");
|
|
80
|
-
var getRouter = /* @__PURE__ */ __name(() => {
|
|
81
|
-
if (!routerAPI) {
|
|
49
|
+
}, singletonRouter.router = routerAPI, singletonRouter.readyCallbacks.forEach((cb) => cb()), singletonRouter.readyCallbacks = [], routerAPI;
|
|
50
|
+
}, getRouter = () => {
|
|
51
|
+
if (!routerAPI)
|
|
82
52
|
throw new NextjsRouterMocksNotAvailable({
|
|
83
53
|
importType: "next/router"
|
|
84
54
|
});
|
|
85
|
-
}
|
|
86
55
|
return routerAPI;
|
|
87
|
-
}, "
|
|
88
|
-
var router_default = singletonRouter;
|
|
89
|
-
var useRouter2 = fn(originalRouter.useRouter).mockName("next/router::useRouter");
|
|
90
|
-
var withRouter2 = fn(originalRouter.withRouter).mockName("next/router::withRouter");
|
|
56
|
+
}, router_default = singletonRouter, useRouter2 = fn(originalRouter.useRouter).mockName("next/router::useRouter"), withRouter2 = fn(originalRouter.withRouter).mockName("next/router::withRouter");
|
|
91
57
|
export {
|
|
92
58
|
createRouter,
|
|
93
59
|
router_default as default,
|