@storybook/nextjs 10.1.0-alpha.10 → 10.1.0-alpha.11
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-KG2CEDQ6.js +76 -0
- package/dist/_node-chunks/chunk-NVSKNSJK.js +205 -0
- package/dist/_node-chunks/chunk-XVBKFOBF.js +57 -0
- package/dist/_node-chunks/configureNextFont-QR356EAI.js +28 -0
- package/dist/_node-chunks/{loader-WPDBQYKQ.js → loader-GUPXITUF.js} +11 -16
- package/dist/_node-chunks/{loader-UJGK53PP.js → loader-VIIL5HSY.js} +15 -25
- package/dist/_node-chunks/{utils-G77XBOCW.js → utils-GFLYVHHC.js} +8 -9
- package/dist/_node-chunks/webpack-A6CKSXQU.js +24 -0
- package/dist/_node-chunks/webpack-HDYOTQDH.js +23 -0
- package/dist/_node-chunks/{webpack-AIYB3HRJ.js → webpack-K7FNPCWL.js} +13 -19
- package/dist/_node-chunks/webpack-KEI74OHK.js +30 -0
- package/dist/_node-chunks/{webpack-QCUACIS6.js → webpack-O4VJM34G.js} +9 -12
- package/dist/_node-chunks/webpack-S3SWBOVU.js +97 -0
- package/dist/_node-chunks/webpack-YFKESEJQ.js +60 -0
- package/dist/_node-chunks/webpack-YOXZVRLP.js +23 -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.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-2ADK3PCH.js +0 -74
- package/dist/_node-chunks/chunk-EVMWO5FG.js +0 -102
- package/dist/_node-chunks/chunk-RSBRC6AY.js +0 -475
- package/dist/_node-chunks/chunk-Z2RESD5M.js +0 -17
- package/dist/_node-chunks/configureNextFont-ZETH4V45.js +0 -36
- package/dist/_node-chunks/webpack-4ZO2PLAG.js +0 -107
- package/dist/_node-chunks/webpack-6QTUYRFB.js +0 -30
- package/dist/_node-chunks/webpack-KRJ4EWQZ.js +0 -27
- package/dist/_node-chunks/webpack-L5YFG573.js +0 -38
- package/dist/_node-chunks/webpack-QPCUFYIY.js +0 -77
- package/dist/_node-chunks/webpack-R5RMXZWI.js +0 -26
|
@@ -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_h9mxauk5xyo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_h9mxauk5xyo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_h9mxauk5xyo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_h9mxauk5xyo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_h9mxauk5xyo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_h9mxauk5xyo.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-Z2RESD5M.js";
|
|
14
|
+
} from "../_node-chunks/chunk-XVBKFOBF.js";
|
|
15
|
+
import "../_node-chunks/chunk-KG2CEDQ6.js";
|
|
16
|
+
import "../_node-chunks/chunk-NVSKNSJK.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,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,
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_h9mxauk5xyo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_h9mxauk5xyo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_h9mxauk5xyo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_h9mxauk5xyo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_h9mxauk5xyo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_h9mxauk5xyo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__name
|
|
14
|
-
} from "../../../_node-chunks/chunk-Z2RESD5M.js";
|
|
15
12
|
|
|
16
13
|
// src/font/webpack/loader/storybook-nextjs-font-loader.ts
|
|
17
14
|
import { sep } from "node:path";
|
|
@@ -28,23 +25,14 @@ import { validateGoogleFontFunctionCall } from "next/dist/compiled/@next/font/di
|
|
|
28
25
|
import loaderUtils from "next/dist/compiled/loader-utils3/index.js";
|
|
29
26
|
var cssCache = /* @__PURE__ */ new Map();
|
|
30
27
|
async function getFontFaceDeclarations(options) {
|
|
31
|
-
|
|
32
|
-
const fontAxes = getFontAxes(fontFamily, weights, styles, selectedVariableAxes);
|
|
33
|
-
const url = getGoogleFontsUrl(fontFamily, fontAxes, display);
|
|
28
|
+
let { fontFamily, weights, styles, selectedVariableAxes, display, variable } = validateGoogleFontFunctionCall(options.fontFamily, options.props), fontAxes = getFontAxes(fontFamily, weights, styles, selectedVariableAxes), url = getGoogleFontsUrl(fontFamily, fontAxes, display);
|
|
34
29
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!hasCachedCSS) {
|
|
38
|
-
cssCache.set(url, fontFaceCSS);
|
|
39
|
-
} else {
|
|
40
|
-
cssCache.delete(url);
|
|
41
|
-
}
|
|
42
|
-
if (fontFaceCSS === null) {
|
|
30
|
+
let hasCachedCSS = cssCache.has(url), fontFaceCSS = hasCachedCSS ? cssCache.get(url) : await fetchCSSFromGoogleFonts(url, fontFamily, !0).catch(() => null);
|
|
31
|
+
if (hasCachedCSS ? cssCache.delete(url) : cssCache.set(url, fontFaceCSS), fontFaceCSS === null)
|
|
43
32
|
throw new GoogleFontsDownloadError({
|
|
44
33
|
fontFamily,
|
|
45
34
|
url
|
|
46
35
|
});
|
|
47
|
-
}
|
|
48
36
|
return {
|
|
49
37
|
id: loaderUtils.getHashDigest(url, "md5", "hex", 6),
|
|
50
38
|
fontFamily,
|
|
@@ -57,7 +45,6 @@ async function getFontFaceDeclarations(options) {
|
|
|
57
45
|
throw new GoogleFontsLoadingError({ error, url });
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
|
-
__name(getFontFaceDeclarations, "getFontFaceDeclarations");
|
|
61
48
|
|
|
62
49
|
// src/font/webpack/loader/local/get-font-face-declarations.ts
|
|
63
50
|
import { dirname, join } from "node:path";
|
|
@@ -65,58 +52,50 @@ import { getProjectRoot } from "storybook/internal/common";
|
|
|
65
52
|
import { validateLocalFontFunctionCall } from "next/dist/compiled/@next/font/dist/local/validate-local-font-function-call.js";
|
|
66
53
|
import loaderUtils2 from "next/dist/compiled/loader-utils3/index.js";
|
|
67
54
|
async function getFontFaceDeclarations2(options, rootContext, swcMode) {
|
|
68
|
-
|
|
69
|
-
const parentFolder = swcMode ? dirname(join(getProjectRoot(), options.filename)).replace(rootContext, "") : dirname(options.filename).replace(rootContext, "");
|
|
70
|
-
const {
|
|
55
|
+
let localFontSrc = options.props.src, parentFolder = swcMode ? dirname(join(getProjectRoot(), options.filename)).replace(rootContext, "") : dirname(options.filename).replace(rootContext, ""), {
|
|
71
56
|
weight,
|
|
72
57
|
style,
|
|
73
58
|
variable,
|
|
74
59
|
declarations = []
|
|
75
|
-
} = validateLocalFontFunctionCall("", options.props)
|
|
76
|
-
const id = `font-${loaderUtils2.getHashDigest(
|
|
60
|
+
} = validateLocalFontFunctionCall("", options.props), id = `font-${loaderUtils2.getHashDigest(
|
|
77
61
|
Buffer.from(JSON.stringify(localFontSrc)),
|
|
78
62
|
"md5",
|
|
79
63
|
"hex",
|
|
80
64
|
6
|
|
81
|
-
)}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
)}`, fontDeclarations = declarations.map(({ prop, value }) => `${prop}: ${value};`).join(`
|
|
66
|
+
`);
|
|
67
|
+
return {
|
|
68
|
+
id,
|
|
69
|
+
fontFamily: id,
|
|
70
|
+
fontFaceCSS: (() => {
|
|
71
|
+
if (typeof localFontSrc == "string") {
|
|
72
|
+
let localFontPath = join(parentFolder, localFontSrc).replaceAll("\\", "/");
|
|
73
|
+
return `@font-face {
|
|
87
74
|
font-family: ${id};
|
|
88
75
|
src: url(.${localFontPath});
|
|
89
76
|
${fontDeclarations}
|
|
90
77
|
}`;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
}
|
|
79
|
+
return localFontSrc.map((font) => {
|
|
80
|
+
let localFontPath = join(parentFolder, font.path).replaceAll("\\", "/");
|
|
81
|
+
return `@font-face {
|
|
95
82
|
font-family: ${id};
|
|
96
83
|
src: url(.${localFontPath});
|
|
97
84
|
${font.weight ? `font-weight: ${font.weight};` : ""}
|
|
98
85
|
${font.style ? `font-style: ${font.style};` : ""}
|
|
99
86
|
${fontDeclarations}
|
|
100
87
|
}`;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
id,
|
|
105
|
-
fontFamily: id,
|
|
106
|
-
fontFaceCSS: getFontFaceCSS(),
|
|
88
|
+
}).join("");
|
|
89
|
+
})(),
|
|
107
90
|
weights: weight ? [weight] : [],
|
|
108
91
|
styles: style ? [style] : [],
|
|
109
92
|
variable
|
|
110
93
|
};
|
|
111
94
|
}
|
|
112
|
-
__name(getFontFaceDeclarations2, "getFontFaceDeclarations");
|
|
113
95
|
|
|
114
96
|
// src/font/webpack/loader/utils/get-css-meta.ts
|
|
115
97
|
function getCSSMeta(options) {
|
|
116
|
-
|
|
117
|
-
const style = getStylesObj(options);
|
|
118
|
-
const variableClassName = `__variable_${className}`;
|
|
119
|
-
const classNamesCSS = `
|
|
98
|
+
let className = getClassName(options), style = getStylesObj(options), variableClassName = `__variable_${className}`, classNamesCSS = `
|
|
120
99
|
.${className} {
|
|
121
100
|
font-family: ${options.fontFamily};
|
|
122
101
|
${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ""}
|
|
@@ -124,8 +103,7 @@ function getCSSMeta(options) {
|
|
|
124
103
|
}
|
|
125
104
|
|
|
126
105
|
${options.variable ? `.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }` : ""}
|
|
127
|
-
`;
|
|
128
|
-
const fontFaceCSS = `${changeFontDisplayToSwap(options.fontFaceCSS)}`;
|
|
106
|
+
`, fontFaceCSS = `${changeFontDisplayToSwap(options.fontFaceCSS)}`;
|
|
129
107
|
return {
|
|
130
108
|
className,
|
|
131
109
|
fontFaceCSS,
|
|
@@ -134,14 +112,10 @@ function getCSSMeta(options) {
|
|
|
134
112
|
...options.variable ? { variableClassName } : {}
|
|
135
113
|
};
|
|
136
114
|
}
|
|
137
|
-
__name(getCSSMeta, "getCSSMeta");
|
|
138
115
|
function getClassName({ styles, weights, fontFamily }) {
|
|
139
|
-
|
|
140
|
-
const style = isNextCSSPropertyValid(styles) ? styles[0] : null;
|
|
141
|
-
const weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
|
|
116
|
+
let font = fontFamily.replaceAll(" ", "-").toLowerCase(), style = isNextCSSPropertyValid(styles) ? styles[0] : null, weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
|
|
142
117
|
return `${font}${style ? `-${style}` : ""}${weight ? `-${weight}` : ""}`;
|
|
143
118
|
}
|
|
144
|
-
__name(getClassName, "getClassName");
|
|
145
119
|
function getStylesObj({ styles, weights, fontFamily }) {
|
|
146
120
|
return {
|
|
147
121
|
fontFamily,
|
|
@@ -149,15 +123,12 @@ function getStylesObj({ styles, weights, fontFamily }) {
|
|
|
149
123
|
...isNextCSSPropertyValid(weights) ? { fontWeight: weights[0] } : {}
|
|
150
124
|
};
|
|
151
125
|
}
|
|
152
|
-
__name(getStylesObj, "getStylesObj");
|
|
153
126
|
function isNextCSSPropertyValid(prop) {
|
|
154
127
|
return prop.length === 1 && prop[0] !== "variable";
|
|
155
128
|
}
|
|
156
|
-
__name(isNextCSSPropertyValid, "isNextCSSPropertyValid");
|
|
157
129
|
function changeFontDisplayToSwap(css) {
|
|
158
130
|
return css.replaceAll("font-display: optional;", "font-display: block;");
|
|
159
131
|
}
|
|
160
|
-
__name(changeFontDisplayToSwap, "changeFontDisplayToSwap");
|
|
161
132
|
|
|
162
133
|
// src/font/webpack/loader/utils/set-font-declarations-in-head.ts
|
|
163
134
|
function setFontDeclarationsInHead({ id, fontFaceCSS, classNamesCSS }) {
|
|
@@ -178,36 +149,24 @@ function setFontDeclarationsInHead({ id, fontFaceCSS, classNamesCSS }) {
|
|
|
178
149
|
}
|
|
179
150
|
`;
|
|
180
151
|
}
|
|
181
|
-
__name(setFontDeclarationsInHead, "setFontDeclarationsInHead");
|
|
182
152
|
|
|
183
153
|
// src/font/webpack/loader/storybook-nextjs-font-loader.ts
|
|
184
154
|
async function storybookNextjsFontLoader() {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
let options;
|
|
188
|
-
if (Object.keys(loaderOptions).length > 0) {
|
|
155
|
+
let loaderOptions = this.getOptions(), swcMode = !1, options;
|
|
156
|
+
if (Object.keys(loaderOptions).length > 0)
|
|
189
157
|
options = loaderOptions;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
swcMode =
|
|
193
|
-
options = {
|
|
158
|
+
else {
|
|
159
|
+
let importQuery = JSON.parse(this.resourceQuery.slice(1));
|
|
160
|
+
swcMode = !0, options = {
|
|
194
161
|
filename: importQuery.path,
|
|
195
162
|
fontFamily: importQuery.import,
|
|
196
163
|
props: importQuery.arguments[0],
|
|
197
164
|
source: this.context.replace(this.rootContext, "")
|
|
198
165
|
};
|
|
199
166
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (options.source.endsWith(`next${pathSep}font${pathSep}google`) || options.source.endsWith(`@next${pathSep}font${pathSep}google`)) {
|
|
204
|
-
fontFaceDeclaration = await getFontFaceDeclarations(options);
|
|
205
|
-
}
|
|
206
|
-
if (options.source.endsWith(`next${pathSep}font${pathSep}local`) || options.source.endsWith(`@next${pathSep}font${pathSep}local`)) {
|
|
207
|
-
fontFaceDeclaration = await getFontFaceDeclarations2(options, rootCtx, swcMode);
|
|
208
|
-
}
|
|
209
|
-
if (typeof fontFaceDeclaration !== "undefined") {
|
|
210
|
-
const cssMeta = getCSSMeta(fontFaceDeclaration);
|
|
167
|
+
let rootCtx = this.rootContext, fontFaceDeclaration, pathSep = sep;
|
|
168
|
+
if ((options.source.endsWith(`next${pathSep}font${pathSep}google`) || options.source.endsWith(`@next${pathSep}font${pathSep}google`)) && (fontFaceDeclaration = await getFontFaceDeclarations(options)), (options.source.endsWith(`next${pathSep}font${pathSep}local`) || options.source.endsWith(`@next${pathSep}font${pathSep}local`)) && (fontFaceDeclaration = await getFontFaceDeclarations2(options, rootCtx, swcMode)), typeof fontFaceDeclaration < "u") {
|
|
169
|
+
let cssMeta = getCSSMeta(fontFaceDeclaration);
|
|
211
170
|
return `
|
|
212
171
|
${setFontDeclarationsInHead({
|
|
213
172
|
fontFaceCSS: cssMeta.fontFaceCSS,
|
|
@@ -222,9 +181,8 @@ async function storybookNextjsFontLoader() {
|
|
|
222
181
|
}
|
|
223
182
|
`;
|
|
224
183
|
}
|
|
225
|
-
return
|
|
184
|
+
return "module.exports = {}";
|
|
226
185
|
}
|
|
227
|
-
__name(storybookNextjsFontLoader, "storybookNextjsFontLoader");
|
|
228
186
|
export {
|
|
229
187
|
storybookNextjsFontLoader as default
|
|
230
188
|
};
|
package/dist/image-context.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultLoader
|
|
3
|
-
} from "../_browser-chunks/chunk-
|
|
4
|
-
import
|
|
5
|
-
__name
|
|
6
|
-
} from "../_browser-chunks/chunk-L5NVL7MD.js";
|
|
3
|
+
} from "../_browser-chunks/chunk-RDMFII4N.js";
|
|
4
|
+
import "../_browser-chunks/chunk-SL3VIQZ3.js";
|
|
7
5
|
|
|
8
6
|
// src/images/next-image.tsx
|
|
9
7
|
import React from "react";
|
|
10
8
|
import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-context";
|
|
11
9
|
import * as NextImageNamespace from "sb-original/next/image";
|
|
12
|
-
var OriginalNextImage = NextImageNamespace.default
|
|
13
|
-
var { getImageProps: originalGetImageProps } = NextImageNamespace;
|
|
14
|
-
var ImageContext = ImageContextValue;
|
|
15
|
-
var MockedNextImage = React.forwardRef(
|
|
10
|
+
var OriginalNextImage = NextImageNamespace.default, { getImageProps: originalGetImageProps } = NextImageNamespace, ImageContext = ImageContextValue, MockedNextImage = React.forwardRef(
|
|
16
11
|
({ loader, ...props }, ref) => {
|
|
17
|
-
|
|
12
|
+
let imageParameters = React.useContext(ImageContext);
|
|
18
13
|
return React.createElement(
|
|
19
14
|
OriginalNextImage,
|
|
20
15
|
{
|
|
@@ -27,8 +22,7 @@ var MockedNextImage = React.forwardRef(
|
|
|
27
22
|
}
|
|
28
23
|
);
|
|
29
24
|
MockedNextImage.displayName = "NextImage";
|
|
30
|
-
var getImageProps =
|
|
31
|
-
var next_image_default = MockedNextImage;
|
|
25
|
+
var getImageProps = (props) => originalGetImageProps?.({ loader: defaultLoader, ...props }), next_image_default = MockedNextImage;
|
|
32
26
|
export {
|
|
33
27
|
next_image_default as default,
|
|
34
28
|
getImageProps
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultLoader
|
|
3
|
-
} from "../_browser-chunks/chunk-
|
|
4
|
-
import
|
|
5
|
-
__name
|
|
6
|
-
} from "../_browser-chunks/chunk-L5NVL7MD.js";
|
|
3
|
+
} from "../_browser-chunks/chunk-RDMFII4N.js";
|
|
4
|
+
import "../_browser-chunks/chunk-SL3VIQZ3.js";
|
|
7
5
|
|
|
8
6
|
// src/images/next-legacy-image.tsx
|
|
9
7
|
import React from "react";
|
|
@@ -11,10 +9,9 @@ import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-conte
|
|
|
11
9
|
import OriginalNextLegacyImage from "sb-original/next/legacy/image";
|
|
12
10
|
var ImageContext = ImageContextValue;
|
|
13
11
|
function NextLegacyImage({ loader, ...props }) {
|
|
14
|
-
|
|
12
|
+
let imageParameters = React.useContext(ImageContext);
|
|
15
13
|
return React.createElement(OriginalNextLegacyImage, { ...imageParameters, ...props, loader: loader ?? defaultLoader });
|
|
16
14
|
}
|
|
17
|
-
__name(NextLegacyImage, "NextLegacyImage");
|
|
18
15
|
var next_legacy_image_default = NextLegacyImage;
|
|
19
16
|
export {
|
|
20
17
|
next_legacy_image_default as default
|