@storybook/nextjs 10.5.2 → 10.6.0-alpha.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.
Files changed (32) hide show
  1. package/dist/_node-chunks/{chunk-HCWN45RG.js → chunk-3DSP33XS.js} +7 -7
  2. package/dist/_node-chunks/{chunk-ZWDGVEF6.js → chunk-6IXQZKEW.js} +6 -6
  3. package/dist/_node-chunks/{chunk-ZIWU74T4.js → chunk-R5XDZ3OD.js} +7 -7
  4. package/dist/_node-chunks/{configureNextFont-3JCF4ESQ.js → configureNextFont-IQ7LDFD2.js} +6 -6
  5. package/dist/_node-chunks/{loader-TPX2TKPP.js → loader-EV2C2JXT.js} +8 -8
  6. package/dist/_node-chunks/{loader-SGQ5CJNK.js → loader-HOQIBM4M.js} +8 -8
  7. package/dist/_node-chunks/{utils-32MKEQOE.js → utils-V5ZO4OYP.js} +8 -8
  8. package/dist/_node-chunks/{webpack-NFLAIZAJ.js → webpack-3BXPLN5K.js} +9 -9
  9. package/dist/_node-chunks/{webpack-UC23T2DK.js → webpack-BB6I7HFQ.js} +6 -6
  10. package/dist/_node-chunks/{webpack-C3UBOSLW.js → webpack-MWJV4C6H.js} +8 -8
  11. package/dist/_node-chunks/{webpack-MFXPHHPA.js → webpack-MXPGKH4U.js} +6 -6
  12. package/dist/_node-chunks/{webpack-APAF5EWV.js → webpack-OAMBWSBQ.js} +8 -8
  13. package/dist/_node-chunks/{webpack-UPLY3RFO.js → webpack-RYQPYYM2.js} +6 -6
  14. package/dist/_node-chunks/{webpack-O2DTJYVE.js → webpack-YD55Y2J7.js} +6 -6
  15. package/dist/_node-chunks/{webpack-HW5ZT4MM.js → webpack-YHKJOVXC.js} +7 -7
  16. package/dist/chunk-BT78ae2q.d.ts +54 -0
  17. package/dist/chunk-Crpg_HiB.d.ts +310 -0
  18. package/dist/export-mocks/cache/index.d.ts +10 -319
  19. package/dist/export-mocks/headers/index.d.ts +31 -337
  20. package/dist/export-mocks/index.js +9 -9
  21. package/dist/export-mocks/link/index.d.ts +6 -314
  22. package/dist/export-mocks/navigation/index.d.ts +19 -33
  23. package/dist/export-mocks/router/index.d.ts +28 -37
  24. package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +6 -6
  25. package/dist/index.d.ts +12 -62
  26. package/dist/index.js +7 -7
  27. package/dist/node/index.d.ts +4 -27
  28. package/dist/node/index.js +6 -6
  29. package/dist/preset.js +9 -9
  30. package/dist/preview.d.ts +12 -11
  31. package/dist/swc/next-swc-loader-patch.js +6 -6
  32. package/package.json +6 -6
@@ -1,343 +1,37 @@
1
- export * from 'next/dist/server/request/headers.js';
2
- import { HeadersAdapter } from 'next/dist/server/web/spec-extension/adapters/headers.js';
3
- import * as next_dist_compiled__edge_runtime_cookies_index_js from 'next/dist/compiled/@edge-runtime/cookies/index.js';
4
- import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies/index.js';
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
- }
1
+ import { t as Mock } from "../../chunk-Crpg_HiB.js";
2
+ import { HeadersAdapter } from "next/dist/server/web/spec-extension/adapters/headers.js";
3
+ import { RequestCookies } from "next/dist/compiled/@edge-runtime/cookies/index.js";
4
+ export * from "next/dist/server/request/headers.js";
314
5
 
6
+ //#region code/frameworks/nextjs/.dts-emit/code/frameworks/nextjs/src/export-mocks/headers/headers.d.ts
315
7
  declare class HeadersAdapterMock extends HeadersAdapter {
316
- constructor();
317
- append: Mock<(name: string, value: string) => void>;
318
- delete: Mock<(name: string) => void>;
319
- get: Mock<(name: string) => string | null>;
320
- has: Mock<(name: string) => boolean>;
321
- set: Mock<(name: string, value: string) => void>;
322
- forEach: Mock<(callbackfn: (value: string, name: string, parent: Headers) => void, thisArg?: any) => void>;
323
- entries: Mock<() => HeadersIterator<[string, string]>>;
324
- keys: Mock<() => HeadersIterator<string>>;
325
- values: Mock<() => HeadersIterator<string>>;
326
- }
327
- declare const headers: {
328
- (): HeadersAdapterMock;
329
- mockRestore(): void;
330
- };
331
-
8
+ constructor();
9
+ append: Mock<(name: string, value: string) => void>;
10
+ delete: Mock<(name: string) => void>;
11
+ get: Mock<(name: string) => string | null>;
12
+ has: Mock<(name: string) => boolean>;
13
+ set: Mock<(name: string, value: string) => void>;
14
+ forEach: Mock<(callbackfn: (value: string, name: string, parent: Headers) => void, thisArg?: any) => void>;
15
+ entries: Mock<() => HeadersIterator<[string, string]>>;
16
+ keys: Mock<() => HeadersIterator<string>>;
17
+ values: Mock<() => HeadersIterator<string>>;
18
+ }
19
+ declare function headers(): HeadersAdapterMock;
20
+ declare namespace headers {
21
+ var mockRestore: () => void;
22
+ }
23
+ //#endregion
24
+ //#region code/frameworks/nextjs/.dts-emit/code/frameworks/nextjs/src/export-mocks/headers/cookies.d.ts
332
25
  declare class RequestCookiesMock extends RequestCookies {
333
- get: Mock<(...args: [name: string] | [next_dist_compiled__edge_runtime_cookies_index_js.RequestCookie]) => next_dist_compiled__edge_runtime_cookies_index_js.RequestCookie | undefined>;
334
- getAll: Mock<(...args: [name: string] | [next_dist_compiled__edge_runtime_cookies_index_js.RequestCookie] | []) => next_dist_compiled__edge_runtime_cookies_index_js.RequestCookie[]>;
335
- has: Mock<(name: string) => boolean>;
336
- set: Mock<(...args: [key: string, value: string] | [options: next_dist_compiled__edge_runtime_cookies_index_js.RequestCookie]) => this>;
337
- delete: Mock<(names: string | string[]) => boolean | boolean[]>;
26
+ get: Mock<(...args: [name: string] | [import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie]) => import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie | undefined>;
27
+ getAll: Mock<(...args: [name: string] | [import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie] | []) => import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie[]>;
28
+ has: Mock<(name: string) => boolean>;
29
+ set: Mock<(...args: [key: string, value: string] | [options: import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie]) => this>;
30
+ delete: Mock<(names: string | string[]) => boolean | boolean[]>;
338
31
  }
339
32
  declare const cookies: Mock<() => RequestCookiesMock>;
340
-
33
+ //#endregion
34
+ //#region code/frameworks/nextjs/.dts-emit/code/frameworks/nextjs/src/export-mocks/headers/index.d.ts
341
35
  declare const draftMode: Mock<any>;
342
-
343
- export { cookies, draftMode, headers };
36
+ //#endregion
37
+ export { cookies, draftMode, headers };
@@ -1,19 +1,19 @@
1
- import CJS_COMPAT_NODE_URL_k6qoz6s1sz from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_k6qoz6s1sz from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_k6qoz6s1sz from "node:module";
1
+ import CJS_COMPAT_NODE_URL_be528syk9c from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_be528syk9c from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_be528syk9c from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_k6qoz6s1sz.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_k6qoz6s1sz.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_k6qoz6s1sz.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_be528syk9c.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_be528syk9c.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_be528syk9c.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-ZIWU74T4.js";
15
- import "../_node-chunks/chunk-HCWN45RG.js";
16
- import "../_node-chunks/chunk-ZWDGVEF6.js";
14
+ } from "../_node-chunks/chunk-R5XDZ3OD.js";
15
+ import "../_node-chunks/chunk-3DSP33XS.js";
16
+ import "../_node-chunks/chunk-6IXQZKEW.js";
17
17
  export {
18
18
  getPackageAliases
19
19
  };