@storybook/nextjs 9.2.0-alpha.3 → 10.0.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.
Files changed (85) hide show
  1. package/README.md +3 -1
  2. package/dist/_browser-chunks/chunk-I5RFHXDS.js +40 -0
  3. package/dist/_browser-chunks/chunk-JOMP7DUK.js +261 -0
  4. package/dist/_browser-chunks/chunk-L5NVL7MD.js +37 -0
  5. package/dist/_browser-chunks/react-18-G7Q4PNHD.js +71 -0
  6. package/dist/_node-chunks/chunk-24UYJEDD.js +74 -0
  7. package/dist/_node-chunks/chunk-EZEBG77A.js +88 -0
  8. package/dist/_node-chunks/chunk-WCSGFZKZ.js +17 -0
  9. package/dist/_node-chunks/chunk-YMVPQWBH.js +167 -0
  10. package/dist/_node-chunks/configureNextFont-HBRWHAUG.js +36 -0
  11. package/dist/_node-chunks/loader-KXTZ5PJ5.js +51 -0
  12. package/dist/_node-chunks/loader-Z4IXWF5M.js +64 -0
  13. package/dist/_node-chunks/utils-4LRBHVQD.js +31 -0
  14. package/dist/_node-chunks/webpack-6HAXGE7X.js +38 -0
  15. package/dist/_node-chunks/webpack-AGNCA7HZ.js +77 -0
  16. package/dist/_node-chunks/webpack-CXSD35E6.js +30 -0
  17. package/dist/_node-chunks/webpack-EWT6TRQB.js +26 -0
  18. package/dist/_node-chunks/webpack-K2R3GUFU.js +29 -0
  19. package/dist/_node-chunks/webpack-PD7PIB6X.js +43 -0
  20. package/dist/_node-chunks/webpack-QFTZE3CE.js +27 -0
  21. package/dist/_node-chunks/webpack-SWQY6JJY.js +107 -0
  22. package/dist/compatibility/draft-mode.compat.js +7 -1
  23. package/dist/export-mocks/cache/index.d.ts +309 -1
  24. package/dist/export-mocks/cache/index.js +22 -1
  25. package/dist/export-mocks/headers/index.d.ts +309 -1
  26. package/dist/export-mocks/headers/index.js +77 -1
  27. package/dist/export-mocks/index.js +20 -1
  28. package/dist/export-mocks/navigation/index.js +88 -1
  29. package/dist/export-mocks/router/index.d.ts +2 -2
  30. package/dist/export-mocks/router/index.js +97 -1
  31. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +201 -14
  32. package/dist/image-context.js +8 -1
  33. package/dist/images/next-image.js +35 -1
  34. package/dist/images/next-legacy-image.js +21 -1
  35. package/dist/index.d.ts +53 -8
  36. package/dist/index.js +20237 -45
  37. package/dist/next-image-loader-stub.js +33 -1
  38. package/dist/node/index.d.ts +27 -6
  39. package/dist/node/index.js +23 -1
  40. package/dist/preset.js +830 -1
  41. package/dist/preview.d.ts +3 -18
  42. package/dist/preview.d.tsx +18 -0
  43. package/dist/preview.js +11 -1
  44. package/dist/rsc/server-only.js +7 -1
  45. package/dist/swc/next-swc-loader-patch.js +136 -1
  46. package/package.json +41 -122
  47. package/preset.js +1 -1
  48. package/template/cli/js/Configure.mdx +11 -11
  49. package/template/cli/ts/Configure.mdx +11 -11
  50. package/dist/chunk-2TZKD6A5.mjs +0 -20
  51. package/dist/chunk-ETFXNGLC.mjs +0 -3
  52. package/dist/chunk-L66KIASX.mjs +0 -3
  53. package/dist/chunk-NQ32RFK2.mjs +0 -6
  54. package/dist/compatibility/draft-mode.compat.d.ts +0 -1
  55. package/dist/compatibility/draft-mode.compat.mjs +0 -2
  56. package/dist/export-mocks/cache/index.mjs +0 -10
  57. package/dist/export-mocks/headers/index.mjs +0 -12
  58. package/dist/export-mocks/index.d.ts +0 -7
  59. package/dist/export-mocks/index.mjs +0 -11
  60. package/dist/export-mocks/navigation/index.mjs +0 -11
  61. package/dist/export-mocks/router/index.mjs +0 -10
  62. package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +0 -3
  63. package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +0 -56
  64. package/dist/image-context.d.ts +0 -13
  65. package/dist/image-context.mjs +0 -6
  66. package/dist/images/decorator.d.ts +0 -6
  67. package/dist/images/decorator.js +0 -1
  68. package/dist/images/decorator.mjs +0 -2
  69. package/dist/images/next-image.d.ts +0 -28
  70. package/dist/images/next-image.mjs +0 -9
  71. package/dist/images/next-legacy-image.d.ts +0 -6
  72. package/dist/images/next-legacy-image.mjs +0 -9
  73. package/dist/index.d-ff220430.d.ts +0 -310
  74. package/dist/index.mjs +0 -58
  75. package/dist/next-image-loader-stub.d.ts +0 -10
  76. package/dist/next-image-loader-stub.mjs +0 -7
  77. package/dist/node/index.mjs +0 -5
  78. package/dist/preset.d.ts +0 -14
  79. package/dist/preview.mjs +0 -3
  80. package/dist/react-18-WSPZ3BUV.mjs +0 -7
  81. package/dist/rsc/server-only.d.ts +0 -3
  82. package/dist/rsc/server-only.mjs +0 -5
  83. package/dist/swc/next-swc-loader-patch.d.ts +0 -21
  84. package/dist/swc/next-swc-loader-patch.mjs +0 -8
  85. package/dist/types-f6ea2c09.d.ts +0 -54
@@ -0,0 +1,107 @@
1
+ import CJS_COMPAT_NODE_URL_e3twfmexlgl from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_e3twfmexlgl from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_e3twfmexlgl from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_e3twfmexlgl.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_e3twfmexlgl.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_e3twfmexlgl.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-YMVPQWBH.js";
15
+ import {
16
+ __name
17
+ } from "./chunk-WCSGFZKZ.js";
18
+
19
+ // src/css/webpack.ts
20
+ import { readFileSync } from "node:fs";
21
+ import { join } from "node:path";
22
+ import { fileURLToPath } from "node:url";
23
+ import { cssFileResolve } from "next/dist/build/webpack/config/blocks/css/loaders/file-resolve.js";
24
+ import { getCssModuleLocalIdent } from "next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js";
25
+ import semver from "semver";
26
+ var configureCss = /* @__PURE__ */ __name((baseConfig, nextConfig) => {
27
+ const rules = baseConfig.module?.rules;
28
+ rules?.forEach((rule, i) => {
29
+ if (rule && typeof rule !== "string" && rule.test instanceof RegExp && rule.test.test("test.css")) {
30
+ rules[i] = {
31
+ test: /\.css$/,
32
+ use: [
33
+ fileURLToPath(import.meta.resolve("style-loader")),
34
+ {
35
+ loader: fileURLToPath(import.meta.resolve("css-loader")),
36
+ options: {
37
+ importLoaders: 1,
38
+ ...getImportAndUrlCssLoaderOptions(nextConfig),
39
+ modules: {
40
+ auto: true,
41
+ getLocalIdent: getCssModuleLocalIdent
42
+ }
43
+ }
44
+ },
45
+ fileURLToPath(import.meta.resolve("postcss-loader"))
46
+ ],
47
+ // We transform the "target.css" files from next.js into Javascript
48
+ // for Next.js to support fonts, so it should be ignored by the css-loader.
49
+ exclude: /next(\\|\/|\\\\).*(\\|\/|\\\\)target\.css$/
50
+ };
51
+ }
52
+ });
53
+ rules?.push({
54
+ test: /\.(scss|sass)$/,
55
+ use: [
56
+ fileURLToPath(import.meta.resolve("style-loader")),
57
+ {
58
+ loader: fileURLToPath(import.meta.resolve("css-loader")),
59
+ options: {
60
+ importLoaders: 3,
61
+ ...getImportAndUrlCssLoaderOptions(nextConfig),
62
+ modules: { auto: true, getLocalIdent: getCssModuleLocalIdent }
63
+ }
64
+ },
65
+ fileURLToPath(import.meta.resolve("postcss-loader")),
66
+ fileURLToPath(import.meta.resolve("resolve-url-loader")),
67
+ {
68
+ loader: fileURLToPath(import.meta.resolve("sass-loader")),
69
+ options: {
70
+ sourceMap: true,
71
+ sassOptions: nextConfig.sassOptions,
72
+ additionalData: nextConfig.sassOptions?.prependData || nextConfig.sassOptions?.additionalData
73
+ }
74
+ }
75
+ ]
76
+ });
77
+ }, "configureCss");
78
+ var getImportAndUrlCssLoaderOptions = /* @__PURE__ */ __name((nextConfig) => isCssLoaderV6() ? {
79
+ url: {
80
+ filter: getUrlResolver(nextConfig)
81
+ },
82
+ import: {
83
+ filter: getImportResolver(nextConfig)
84
+ }
85
+ } : {
86
+ url: getUrlResolver(nextConfig),
87
+ import: getImportResolver(nextConfig)
88
+ }, "getImportAndUrlCssLoaderOptions");
89
+ var getUrlResolver = /* @__PURE__ */ __name((nextConfig) => (url, resourcePath) => cssFileResolve(url, resourcePath, nextConfig.experimental?.urlImports), "getUrlResolver");
90
+ var getImportResolver = /* @__PURE__ */ __name((nextConfig) => (url, _, resourcePath) => cssFileResolve(
91
+ typeof url === "string" ? url : url.url,
92
+ resourcePath,
93
+ nextConfig.experimental?.urlImports
94
+ ), "getImportResolver");
95
+ var isCssLoaderV6 = /* @__PURE__ */ __name(() => {
96
+ try {
97
+ const cssLoaderVersion = JSON.parse(
98
+ readFileSync(join(resolvePackageDir("css-loader"), "package.json"), "utf8")
99
+ ).version;
100
+ return semver.gte(cssLoaderVersion, "6.0.0");
101
+ } catch {
102
+ return false;
103
+ }
104
+ }, "isCssLoaderV6");
105
+ export {
106
+ configureCss
107
+ };
@@ -1 +1,7 @@
1
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var draft_mode_compat_exports={};__export(draft_mode_compat_exports,{draftMode:()=>import_headers.draftMode});module.exports=__toCommonJS(draft_mode_compat_exports);var import_headers=require("next/dist/client/components/headers");0&&(module.exports={draftMode});
1
+ import "../_browser-chunks/chunk-L5NVL7MD.js";
2
+
3
+ // src/compatibility/draft-mode.compat.ts
4
+ import { draftMode } from "next/dist/client/components/headers";
5
+ export {
6
+ draftMode
7
+ };
@@ -1,9 +1,317 @@
1
- import { M as Mock } from '../../index.d-ff220430.js';
2
1
  import { unstable_cache } from 'next/dist/server/web/spec-extension/unstable-cache';
3
2
  export { unstable_cache } from 'next/dist/server/web/spec-extension/unstable-cache';
4
3
  import { unstable_noStore } from 'next/dist/server/web/spec-extension/unstable-no-store';
5
4
  export { unstable_noStore } from 'next/dist/server/web/spec-extension/unstable-no-store';
6
5
 
6
+ interface MockResultReturn<T> {
7
+ type: "return";
8
+ /**
9
+ * The value that was returned from the function. If function returned a Promise, then this will be a resolved value.
10
+ */
11
+ value: T;
12
+ }
13
+ interface MockResultIncomplete {
14
+ type: "incomplete";
15
+ value: undefined;
16
+ }
17
+ interface MockResultThrow {
18
+ type: "throw";
19
+ /**
20
+ * An error that was thrown during function execution.
21
+ */
22
+ value: any;
23
+ }
24
+ interface MockSettledResultFulfilled<T> {
25
+ type: "fulfilled";
26
+ value: T;
27
+ }
28
+ interface MockSettledResultRejected {
29
+ type: "rejected";
30
+ value: any;
31
+ }
32
+ type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
33
+ type MockSettledResult<T> = MockSettledResultFulfilled<T> | MockSettledResultRejected;
34
+ interface MockContext<T extends Procedure> {
35
+ /**
36
+ * This is an array containing all arguments for each call. One item of the array is the arguments of that call.
37
+ *
38
+ * @see https://vitest.dev/api/mock#mock-calls
39
+ * @example
40
+ * const fn = vi.fn()
41
+ *
42
+ * fn('arg1', 'arg2')
43
+ * fn('arg3')
44
+ *
45
+ * fn.mock.calls === [
46
+ * ['arg1', 'arg2'], // first call
47
+ * ['arg3'], // second call
48
+ * ]
49
+ */
50
+ calls: Parameters<T>[];
51
+ /**
52
+ * This is an array containing all instances that were instantiated when mock was called with a `new` keyword. Note that this is an actual context (`this`) of the function, not a return value.
53
+ * @see https://vitest.dev/api/mock#mock-instances
54
+ */
55
+ instances: ReturnType<T>[];
56
+ /**
57
+ * An array of `this` values that were used during each call to the mock function.
58
+ * @see https://vitest.dev/api/mock#mock-contexts
59
+ */
60
+ contexts: ThisParameterType<T>[];
61
+ /**
62
+ * The order of mock's execution. This returns an array of numbers which are shared between all defined mocks.
63
+ *
64
+ * @see https://vitest.dev/api/mock#mock-invocationcallorder
65
+ * @example
66
+ * const fn1 = vi.fn()
67
+ * const fn2 = vi.fn()
68
+ *
69
+ * fn1()
70
+ * fn2()
71
+ * fn1()
72
+ *
73
+ * fn1.mock.invocationCallOrder === [1, 3]
74
+ * fn2.mock.invocationCallOrder === [2]
75
+ */
76
+ invocationCallOrder: number[];
77
+ /**
78
+ * This is an array containing all values that were `returned` from the function.
79
+ *
80
+ * The `value` property contains the returned value or thrown error. If the function returned a `Promise`, then `result` will always be `'return'` even if the promise was rejected.
81
+ *
82
+ * @see https://vitest.dev/api/mock#mock-results
83
+ * @example
84
+ * const fn = vi.fn()
85
+ * .mockReturnValueOnce('result')
86
+ * .mockImplementationOnce(() => { throw new Error('thrown error') })
87
+ *
88
+ * const result = fn()
89
+ *
90
+ * try {
91
+ * fn()
92
+ * }
93
+ * catch {}
94
+ *
95
+ * fn.mock.results === [
96
+ * {
97
+ * type: 'return',
98
+ * value: 'result',
99
+ * },
100
+ * {
101
+ * type: 'throw',
102
+ * value: Error,
103
+ * },
104
+ * ]
105
+ */
106
+ results: MockResult<ReturnType<T>>[];
107
+ /**
108
+ * An array containing all values that were `resolved` or `rejected` from the function.
109
+ *
110
+ * This array will be empty if the function was never resolved or rejected.
111
+ *
112
+ * @see https://vitest.dev/api/mock#mock-settledresults
113
+ * @example
114
+ * const fn = vi.fn().mockResolvedValueOnce('result')
115
+ *
116
+ * const result = fn()
117
+ *
118
+ * fn.mock.settledResults === []
119
+ * fn.mock.results === [
120
+ * {
121
+ * type: 'return',
122
+ * value: Promise<'result'>,
123
+ * },
124
+ * ]
125
+ *
126
+ * await result
127
+ *
128
+ * fn.mock.settledResults === [
129
+ * {
130
+ * type: 'fulfilled',
131
+ * value: 'result',
132
+ * },
133
+ * ]
134
+ */
135
+ settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
136
+ /**
137
+ * This contains the arguments of the last call. If spy wasn't called, will return `undefined`.
138
+ * @see https://vitest.dev/api/mock#mock-lastcall
139
+ */
140
+ lastCall: Parameters<T> | undefined;
141
+ }
142
+ type Procedure = (...args: any[]) => any;
143
+ // pick a single function type from function overloads, unions, etc...
144
+ type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
145
+ /*
146
+ cf. https://typescript-eslint.io/rules/method-signature-style/
147
+
148
+ Typescript assignability is different between
149
+ { foo: (f: T) => U } (this is "method-signature-style")
150
+ and
151
+ { foo(f: T): U }
152
+
153
+ Jest uses the latter for `MockInstance.mockImplementation` etc... and it allows assignment such as:
154
+ const boolFn: Jest.Mock<() => boolean> = jest.fn<() => true>(() => true)
155
+ */
156
+ /* eslint-disable ts/method-signature-style */
157
+ interface MockInstance<T extends Procedure = Procedure> extends Disposable {
158
+ /**
159
+ * Use it to return the name assigned to the mock with the `.mockName(name)` method. By default, it will return `vi.fn()`.
160
+ * @see https://vitest.dev/api/mock#getmockname
161
+ */
162
+ getMockName(): string;
163
+ /**
164
+ * Sets the internal mock name. This is useful for identifying the mock when an assertion fails.
165
+ * @see https://vitest.dev/api/mock#mockname
166
+ */
167
+ mockName(name: string): this;
168
+ /**
169
+ * Current context of the mock. It stores information about all invocation calls, instances, and results.
170
+ */
171
+ mock: MockContext<T>;
172
+ /**
173
+ * Clears all information about every call. After calling it, all properties on `.mock` will return to their initial state. This method does not reset implementations. It is useful for cleaning up mocks between different assertions.
174
+ *
175
+ * To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/#clearmocks) setting in the configuration.
176
+ * @see https://vitest.dev/api/mock#mockclear
177
+ */
178
+ mockClear(): this;
179
+ /**
180
+ * Does what `mockClear` does and resets inner implementation to the original function. This also resets all "once" implementations.
181
+ *
182
+ * Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
183
+ * Resetting a mock from `vi.fn(impl)` will set implementation to `impl`. It is useful for completely resetting a mock to its default state.
184
+ *
185
+ * To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/#mockreset) setting in the configuration.
186
+ * @see https://vitest.dev/api/mock#mockreset
187
+ */
188
+ mockReset(): this;
189
+ /**
190
+ * Does what `mockReset` does and restores original descriptors of spied-on objects.
191
+ *
192
+ * Note that restoring mock from `vi.fn()` will set implementation to an empty function that returns `undefined`. Restoring a `vi.fn(impl)` will restore implementation to `impl`.
193
+ * @see https://vitest.dev/api/mock#mockrestore
194
+ */
195
+ mockRestore(): void;
196
+ /**
197
+ * Returns current permanent mock implementation if there is one.
198
+ *
199
+ * If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
200
+ *
201
+ * If mock was created with `vi.spyOn`, it will return `undefined` unless a custom implementation was provided.
202
+ */
203
+ getMockImplementation(): NormalizedProcedure<T> | undefined;
204
+ /**
205
+ * Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function.
206
+ * @see https://vitest.dev/api/mock#mockimplementation
207
+ * @example
208
+ * const increment = vi.fn().mockImplementation(count => count + 1);
209
+ * expect(increment(3)).toBe(4);
210
+ */
211
+ mockImplementation(fn: NormalizedProcedure<T>): this;
212
+ /**
213
+ * Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function. This method can be chained to produce different results for multiple function calls.
214
+ *
215
+ * When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
216
+ * @see https://vitest.dev/api/mock#mockimplementationonce
217
+ * @example
218
+ * const fn = vi.fn(count => count).mockImplementationOnce(count => count + 1);
219
+ * expect(fn(3)).toBe(4);
220
+ * expect(fn(3)).toBe(3);
221
+ */
222
+ mockImplementationOnce(fn: NormalizedProcedure<T>): this;
223
+ /**
224
+ * Overrides the original mock implementation temporarily while the callback is being executed.
225
+ *
226
+ * Note that this method takes precedence over the [`mockImplementationOnce`](https://vitest.dev/api/mock#mockimplementationonce).
227
+ * @see https://vitest.dev/api/mock#withimplementation
228
+ * @example
229
+ * const myMockFn = vi.fn(() => 'original')
230
+ *
231
+ * myMockFn.withImplementation(() => 'temp', () => {
232
+ * myMockFn() // 'temp'
233
+ * })
234
+ *
235
+ * myMockFn() // 'original'
236
+ */
237
+ withImplementation<T2>(fn: NormalizedProcedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
238
+ /**
239
+ * Use this if you need to return the `this` context from the method without invoking the actual implementation.
240
+ * @see https://vitest.dev/api/mock#mockreturnthis
241
+ */
242
+ mockReturnThis(): this;
243
+ /**
244
+ * Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
245
+ * @see https://vitest.dev/api/mock#mockreturnvalue
246
+ * @example
247
+ * const mock = vi.fn()
248
+ * mock.mockReturnValue(42)
249
+ * mock() // 42
250
+ * mock.mockReturnValue(43)
251
+ * mock() // 43
252
+ */
253
+ mockReturnValue(value: ReturnType<T>): this;
254
+ /**
255
+ * Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
256
+ *
257
+ * When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
258
+ * @example
259
+ * const myMockFn = vi
260
+ * .fn()
261
+ * .mockReturnValue('default')
262
+ * .mockReturnValueOnce('first call')
263
+ * .mockReturnValueOnce('second call')
264
+ *
265
+ * // 'first call', 'second call', 'default'
266
+ * console.log(myMockFn(), myMockFn(), myMockFn())
267
+ */
268
+ mockReturnValueOnce(value: ReturnType<T>): this;
269
+ /**
270
+ * Accepts a value that will be resolved when the async function is called. TypeScript will only accept values that match the return type of the original function.
271
+ * @example
272
+ * const asyncMock = vi.fn().mockResolvedValue(42)
273
+ * asyncMock() // Promise<42>
274
+ */
275
+ mockResolvedValue(value: Awaited<ReturnType<T>>): this;
276
+ /**
277
+ * Accepts a value that will be resolved during the next function call. TypeScript will only accept values that match the return type of the original function. If chained, each consecutive call will resolve the specified value.
278
+ * @example
279
+ * const myMockFn = vi
280
+ * .fn()
281
+ * .mockResolvedValue('default')
282
+ * .mockResolvedValueOnce('first call')
283
+ * .mockResolvedValueOnce('second call')
284
+ *
285
+ * // Promise<'first call'>, Promise<'second call'>, Promise<'default'>
286
+ * console.log(myMockFn(), myMockFn(), myMockFn())
287
+ */
288
+ mockResolvedValueOnce(value: Awaited<ReturnType<T>>): this;
289
+ /**
290
+ * Accepts an error that will be rejected when async function is called.
291
+ * @example
292
+ * const asyncMock = vi.fn().mockRejectedValue(new Error('Async error'))
293
+ * await asyncMock() // throws Error<'Async error'>
294
+ */
295
+ mockRejectedValue(error: unknown): this;
296
+ /**
297
+ * Accepts a value that will be rejected during the next function call. If chained, each consecutive call will reject the specified value.
298
+ * @example
299
+ * const asyncMock = vi
300
+ * .fn()
301
+ * .mockResolvedValueOnce('first call')
302
+ * .mockRejectedValueOnce(new Error('Async error'))
303
+ *
304
+ * await asyncMock() // first call
305
+ * await asyncMock() // throws Error<'Async error'>
306
+ */
307
+ mockRejectedValueOnce(error: unknown): this;
308
+ }
309
+ /* eslint-enable ts/method-signature-style */
310
+ interface Mock<T extends Procedure = Procedure> extends MockInstance<T> {
311
+ new (...args: Parameters<T>): ReturnType<T>;
312
+ (...args: Parameters<T>): ReturnType<T>;
313
+ }
314
+
7
315
  declare const revalidatePath: Mock<(...args: any[]) => any>;
8
316
  declare const revalidateTag: Mock<(...args: any[]) => any>;
9
317
  declare const cacheExports: {
@@ -1 +1,22 @@
1
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var cache_exports={};__export(cache_exports,{default:()=>cache_default,revalidatePath:()=>revalidatePath,revalidateTag:()=>revalidateTag,unstable_cache:()=>import_unstable_cache.unstable_cache,unstable_noStore:()=>import_unstable_no_store.unstable_noStore});module.exports=__toCommonJS(cache_exports);var import_unstable_cache=require("next/dist/server/web/spec-extension/unstable-cache"),import_unstable_no_store=require("next/dist/server/web/spec-extension/unstable-no-store"),import_test=require("storybook/test"),revalidatePath=(0,import_test.fn)().mockName("next/cache::revalidatePath"),revalidateTag=(0,import_test.fn)().mockName("next/cache::revalidateTag"),cacheExports={unstable_cache:import_unstable_cache.unstable_cache,revalidateTag,revalidatePath,unstable_noStore:import_unstable_no_store.unstable_noStore},cache_default=cacheExports;0&&(module.exports={revalidatePath,revalidateTag,unstable_cache,unstable_noStore});
1
+ import "../../_browser-chunks/chunk-L5NVL7MD.js";
2
+
3
+ // src/export-mocks/cache/index.ts
4
+ import { unstable_cache } from "next/dist/server/web/spec-extension/unstable-cache";
5
+ import { unstable_noStore } from "next/dist/server/web/spec-extension/unstable-no-store";
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 = {
10
+ unstable_cache,
11
+ revalidateTag,
12
+ revalidatePath,
13
+ unstable_noStore
14
+ };
15
+ var cache_default = cacheExports;
16
+ export {
17
+ cache_default as default,
18
+ revalidatePath,
19
+ revalidateTag,
20
+ unstable_cache,
21
+ unstable_noStore
22
+ };