@storybook/nextjs-vite 11.0.0-alpha.9 → 11.0.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/_node-chunks/{api-CMIAKUDF.js → api-E65POFWR.js} +8 -8
- package/dist/_node-chunks/{chunk-SW7QVBFX.js → chunk-YJQLOU5Z.js} +6 -6
- package/dist/_node-chunks/{dist-JE4ZIPL6.js → dist-7CPLK2TC.js} +7 -7
- package/dist/_node-chunks/{jiti-DQ4TQNP7.js → jiti-5ZX2MVDQ.js} +7 -7
- package/dist/_node-chunks/{lexer-DQCqS3nf-3G3I33LI.js → lexer-DQCqS3nf-JV373JZG.js} +7 -7
- package/dist/export-mocks/cache/index.d.ts +26 -28
- package/dist/export-mocks/headers/index.d.ts +16 -17
- package/dist/export-mocks/link/index.d.ts +1 -2
- package/dist/index.js +17 -4
- package/dist/node/index.js +7 -7
- package/dist/preset.js +12 -15
- package/dist/vite-plugin/index.js +7 -7
- package/package.json +18 -6
- package/template/cli/js/Button.stories.js +11 -10
- package/template/cli/js/Header.stories.js +7 -6
- package/template/cli/js/Page.stories.js +6 -5
- package/template/cli/ts/Button.stories.ts +11 -14
- package/template/cli/ts/Header.stories.ts +6 -9
- package/template/cli/ts/Page.stories.ts +6 -9
- package/dist/chunk-Crpg_HiB.d.ts +0 -310
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
__esm,
|
|
15
15
|
__require,
|
|
16
16
|
__toESM
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-YJQLOU5Z.js";
|
|
18
18
|
|
|
19
19
|
// ../../../node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs
|
|
20
20
|
import r from "node:path";
|
|
@@ -4830,7 +4830,7 @@ var import_esbuild, Pt, f2, Ne2, Ie2, Yt, Me2, $e2, Ue2, me2, ae2, ee2, nn2, rn2
|
|
|
4830
4830
|
f2(Be, "u");
|
|
4831
4831
|
f2(D, "o");
|
|
4832
4832
|
typeof WebAssembly < "u" && (async () => {
|
|
4833
|
-
let { parse: s4, init: e5 } = await import("./lexer-DQCqS3nf-
|
|
4833
|
+
let { parse: s4, init: e5 } = await import("./lexer-DQCqS3nf-JV373JZG.js");
|
|
4834
4834
|
await e5, Se2 = s4;
|
|
4835
4835
|
})();
|
|
4836
4836
|
Pe2 = f2((s4, e5) => Se2 ? Se2(s4, e5) : fn2(s4, e5), "parseEsm"), gn = f2((s4) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -12,7 +12,7 @@ var require = CJS_COMPAT_NODE_MODULE_ggw9xf4cnfr.createRequire(import.meta.url);
|
|
|
12
12
|
import {
|
|
13
13
|
__commonJS,
|
|
14
14
|
__require
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YJQLOU5Z.js";
|
|
16
16
|
|
|
17
17
|
// ../../../node_modules/yaml/dist/nodes/identity.js
|
|
18
18
|
var require_identity = __commonJS({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
__esm,
|
|
15
15
|
__require,
|
|
16
16
|
__toESM
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-YJQLOU5Z.js";
|
|
18
18
|
|
|
19
19
|
// ../../../node_modules/jiti/dist/jiti.cjs
|
|
20
20
|
var require_jiti = __commonJS({
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.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
|
__esm
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YJQLOU5Z.js";
|
|
15
15
|
|
|
16
16
|
// ../../../node_modules/tsx/dist/lexer-DQCqS3nf.mjs
|
|
17
17
|
function F(A, E = "@") {
|
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
import { t as Mock } from "../../chunk-Crpg_HiB.js";
|
|
2
|
-
|
|
3
1
|
//#region code/frameworks/nextjs-vite/.dts-emit/code/frameworks/nextjs-vite/src/export-mocks/cache/index.d.ts
|
|
4
|
-
declare const revalidatePath: Mock<(
|
|
5
|
-
declare const revalidateTag: Mock<(
|
|
6
|
-
declare const updateTag: Mock<(
|
|
7
|
-
declare const unstable_cache: Mock<(
|
|
8
|
-
declare const unstable_noStore: Mock<(
|
|
9
|
-
declare const refresh: Mock<(
|
|
10
|
-
declare const cacheLife: Mock<(
|
|
11
|
-
declare const cacheTag: Mock<(
|
|
12
|
-
declare const io: Mock<() => Promise<undefined> & {
|
|
2
|
+
declare const revalidatePath: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
3
|
+
declare const revalidateTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
4
|
+
declare const updateTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
5
|
+
declare const unstable_cache: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
6
|
+
declare const unstable_noStore: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
7
|
+
declare const refresh: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
8
|
+
declare const cacheLife: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
9
|
+
declare const cacheTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
10
|
+
declare const io: import("storybook/test").Mock<() => Promise<undefined> & {
|
|
13
11
|
status: 'fulfilled';
|
|
14
12
|
value: undefined;
|
|
15
13
|
}>;
|
|
16
|
-
declare const navigation: Mock<() => Promise<void>>;
|
|
17
|
-
declare const prefetch: Mock<() => Promise<void>>;
|
|
18
|
-
declare const unstable_cacheLife: Mock<(
|
|
19
|
-
declare const unstable_cacheTag: Mock<(
|
|
14
|
+
declare const navigation: import("storybook/test").Mock<() => Promise<void>>;
|
|
15
|
+
declare const prefetch: import("storybook/test").Mock<() => Promise<void>>;
|
|
16
|
+
declare const unstable_cacheLife: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
17
|
+
declare const unstable_cacheTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
20
18
|
declare const cacheExports: {
|
|
21
|
-
unstable_cache: Mock<(
|
|
22
|
-
revalidateTag: Mock<(
|
|
23
|
-
revalidatePath: Mock<(
|
|
24
|
-
updateTag: Mock<(
|
|
25
|
-
refresh: Mock<(
|
|
26
|
-
io: Mock<() => Promise<undefined> & {
|
|
19
|
+
unstable_cache: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
20
|
+
revalidateTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
21
|
+
revalidatePath: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
22
|
+
updateTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
23
|
+
refresh: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
24
|
+
io: import("storybook/test").Mock<() => Promise<undefined> & {
|
|
27
25
|
status: 'fulfilled';
|
|
28
26
|
value: undefined;
|
|
29
27
|
}>;
|
|
30
|
-
navigation: Mock<() => Promise<void>>;
|
|
31
|
-
prefetch: Mock<() => Promise<void>>;
|
|
32
|
-
unstable_noStore: Mock<(
|
|
33
|
-
cacheLife: Mock<(
|
|
34
|
-
cacheTag: Mock<(
|
|
35
|
-
unstable_cacheLife: Mock<(
|
|
36
|
-
unstable_cacheTag: Mock<(
|
|
28
|
+
navigation: import("storybook/test").Mock<() => Promise<void>>;
|
|
29
|
+
prefetch: import("storybook/test").Mock<() => Promise<void>>;
|
|
30
|
+
unstable_noStore: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
31
|
+
cacheLife: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
32
|
+
cacheTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
33
|
+
unstable_cacheLife: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
34
|
+
unstable_cacheTag: import("storybook/test").Mock<import("storybook/test").Procedure>;
|
|
37
35
|
};
|
|
38
36
|
//#endregion
|
|
39
37
|
export { cacheLife, cacheTag, cacheExports as default, io, navigation, prefetch, refresh, revalidatePath, revalidateTag, unstable_cache, unstable_cacheLife, unstable_cacheTag, unstable_noStore, updateTag };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as Mock } from "../../chunk-Crpg_HiB.js";
|
|
2
1
|
import { draftMode as draftMode$1 } from "next/dist/server/request/draft-mode.js";
|
|
3
2
|
import { HeadersAdapter } from "next/dist/server/web/spec-extension/adapters/headers.js";
|
|
4
3
|
import { RequestCookies } from "next/dist/compiled/@edge-runtime/cookies/index.js";
|
|
@@ -7,15 +6,15 @@ export * from "next/dist/server/request/headers.js";
|
|
|
7
6
|
//#region code/frameworks/nextjs-vite/.dts-emit/code/frameworks/nextjs-vite/src/export-mocks/headers/headers.d.ts
|
|
8
7
|
declare class HeadersAdapterMock extends HeadersAdapter {
|
|
9
8
|
constructor();
|
|
10
|
-
append: Mock<(name: string, value: string) => void>;
|
|
11
|
-
delete: Mock<(name: string) => void>;
|
|
12
|
-
get: Mock<(name: string) => string | null>;
|
|
13
|
-
has: Mock<(name: string) => boolean>;
|
|
14
|
-
set: Mock<(name: string, value: string) => void>;
|
|
15
|
-
forEach: Mock<(callbackfn: (value: string, name: string, parent: Headers) => void, thisArg?: any) => void>;
|
|
16
|
-
entries: Mock<() => HeadersIterator<[string, string]>>;
|
|
17
|
-
keys: Mock<() => HeadersIterator<string>>;
|
|
18
|
-
values: Mock<() => HeadersIterator<string>>;
|
|
9
|
+
append: import("storybook/test").Mock<(name: string, value: string) => void>;
|
|
10
|
+
delete: import("storybook/test").Mock<(name: string) => void>;
|
|
11
|
+
get: import("storybook/test").Mock<(name: string) => string | null>;
|
|
12
|
+
has: import("storybook/test").Mock<(name: string) => boolean>;
|
|
13
|
+
set: import("storybook/test").Mock<(name: string, value: string) => void>;
|
|
14
|
+
forEach: import("storybook/test").Mock<(callbackfn: (value: string, name: string, parent: Headers) => void, thisArg?: any) => void>;
|
|
15
|
+
entries: import("storybook/test").Mock<() => HeadersIterator<[string, string]>>;
|
|
16
|
+
keys: import("storybook/test").Mock<() => HeadersIterator<string>>;
|
|
17
|
+
values: import("storybook/test").Mock<() => HeadersIterator<string>>;
|
|
19
18
|
}
|
|
20
19
|
declare function headers(): HeadersAdapterMock;
|
|
21
20
|
declare namespace headers {
|
|
@@ -24,15 +23,15 @@ declare namespace headers {
|
|
|
24
23
|
//#endregion
|
|
25
24
|
//#region code/frameworks/nextjs-vite/.dts-emit/code/frameworks/nextjs-vite/src/export-mocks/headers/cookies.d.ts
|
|
26
25
|
declare class RequestCookiesMock extends RequestCookies {
|
|
27
|
-
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>;
|
|
28
|
-
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[]>;
|
|
29
|
-
has: Mock<(name: string) => boolean>;
|
|
30
|
-
set: Mock<(...args: [key: string, value: string] | [options: import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie]) => this>;
|
|
31
|
-
delete: Mock<(names: string | string[]) => boolean | boolean[]>;
|
|
26
|
+
get: import("storybook/test").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: import("storybook/test").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: import("storybook/test").Mock<(name: string) => boolean>;
|
|
29
|
+
set: import("storybook/test").Mock<(...args: [key: string, value: string] | [options: import("next/dist/compiled/@edge-runtime/cookies/index.js").RequestCookie]) => this>;
|
|
30
|
+
delete: import("storybook/test").Mock<(names: string | string[]) => boolean | boolean[]>;
|
|
32
31
|
}
|
|
33
|
-
declare const cookies: Mock<() => RequestCookiesMock>;
|
|
32
|
+
declare const cookies: import("storybook/test").Mock<() => RequestCookiesMock>;
|
|
34
33
|
//#endregion
|
|
35
34
|
//#region code/frameworks/nextjs-vite/.dts-emit/code/frameworks/nextjs-vite/src/export-mocks/headers/index.d.ts
|
|
36
|
-
declare const draftMode: Mock<typeof draftMode$1>;
|
|
35
|
+
declare const draftMode: import("storybook/test").Mock<typeof draftMode$1>;
|
|
37
36
|
//#endregion
|
|
38
37
|
export { cookies, draftMode, headers };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { t as Mock } from "../../chunk-Crpg_HiB.js";
|
|
2
1
|
import React from "react";
|
|
3
2
|
|
|
4
3
|
//#region code/frameworks/nextjs-vite/.dts-emit/code/frameworks/nextjs-vite/src/export-mocks/link/index.d.ts
|
|
5
4
|
declare const MockLink: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
6
|
-
declare const useLinkStatus: Mock<() => {
|
|
5
|
+
declare const useLinkStatus: import("storybook/test").Mock<() => {
|
|
7
6
|
pending: boolean;
|
|
8
7
|
}>;
|
|
9
8
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -6249,6 +6249,22 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
6249
6249
|
}
|
|
6250
6250
|
};
|
|
6251
6251
|
}
|
|
6252
|
+
function createEventWrapper(act) {
|
|
6253
|
+
let isInsideAct = !1;
|
|
6254
|
+
return (cb) => {
|
|
6255
|
+
if (isInsideAct)
|
|
6256
|
+
return cb();
|
|
6257
|
+
isInsideAct = !0;
|
|
6258
|
+
try {
|
|
6259
|
+
let result;
|
|
6260
|
+
return act(() => {
|
|
6261
|
+
result = cb();
|
|
6262
|
+
}), result;
|
|
6263
|
+
} finally {
|
|
6264
|
+
isInsideAct = !1;
|
|
6265
|
+
}
|
|
6266
|
+
};
|
|
6267
|
+
}
|
|
6252
6268
|
var getAct = async ({ disableAct = !1 } = {}) => {
|
|
6253
6269
|
if (process.env.NODE_ENV === "production" || disableAct)
|
|
6254
6270
|
return (cb) => cb();
|
|
@@ -6389,10 +6405,7 @@ var decorators = [
|
|
|
6389
6405
|
setReactActEnvironment(previousActEnvironment);
|
|
6390
6406
|
}
|
|
6391
6407
|
},
|
|
6392
|
-
eventWrapper: (
|
|
6393
|
-
let result;
|
|
6394
|
-
return act(() => (result = cb(), result)), result;
|
|
6395
|
-
}
|
|
6408
|
+
eventWrapper: createEventWrapper(act)
|
|
6396
6409
|
});
|
|
6397
6410
|
} catch {
|
|
6398
6411
|
}
|
package/dist/node/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.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 "../_node-chunks/chunk-
|
|
12
|
+
import "../_node-chunks/chunk-YJQLOU5Z.js";
|
|
13
13
|
|
|
14
14
|
// src/node/index.ts
|
|
15
15
|
function defineMain(config) {
|
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
__commonJS,
|
|
14
14
|
__require,
|
|
15
15
|
__toESM
|
|
16
|
-
} from "./_node-chunks/chunk-
|
|
16
|
+
} from "./_node-chunks/chunk-YJQLOU5Z.js";
|
|
17
17
|
|
|
18
18
|
// ../../../node_modules/semver/internal/constants.js
|
|
19
19
|
var require_constants = __commonJS({
|
|
@@ -1514,7 +1514,7 @@ var require_req = __commonJS({
|
|
|
1514
1514
|
}
|
|
1515
1515
|
if (tsx === void 0)
|
|
1516
1516
|
try {
|
|
1517
|
-
tsx = await import("./_node-chunks/api-
|
|
1517
|
+
tsx = await import("./_node-chunks/api-E65POFWR.js");
|
|
1518
1518
|
} catch (error) {
|
|
1519
1519
|
importError.push(error);
|
|
1520
1520
|
}
|
|
@@ -1524,7 +1524,7 @@ var require_req = __commonJS({
|
|
|
1524
1524
|
}
|
|
1525
1525
|
if (jiti === void 0)
|
|
1526
1526
|
try {
|
|
1527
|
-
jiti = (await import("./_node-chunks/jiti-
|
|
1527
|
+
jiti = (await import("./_node-chunks/jiti-5ZX2MVDQ.js")).default;
|
|
1528
1528
|
} catch (error) {
|
|
1529
1529
|
importError.push(error);
|
|
1530
1530
|
}
|
|
@@ -1641,7 +1641,7 @@ var require_src2 = __commonJS({
|
|
|
1641
1641
|
async function yamlLoader(_, content) {
|
|
1642
1642
|
if (!yaml)
|
|
1643
1643
|
try {
|
|
1644
|
-
yaml = await import("./_node-chunks/dist-
|
|
1644
|
+
yaml = await import("./_node-chunks/dist-7CPLK2TC.js");
|
|
1645
1645
|
} catch (e) {
|
|
1646
1646
|
throw new Error(
|
|
1647
1647
|
`'yaml' is required for the YAML configuration files. Make sure it is installed
|
|
@@ -1699,7 +1699,7 @@ Error: ${e.message}`
|
|
|
1699
1699
|
});
|
|
1700
1700
|
|
|
1701
1701
|
// src/preset.ts
|
|
1702
|
-
var
|
|
1702
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
1703
1703
|
import { dirname as dirname2 } from "node:path";
|
|
1704
1704
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
1705
1705
|
import { viteFinal as reactViteFinal } from "@storybook/react-vite/preset";
|
|
@@ -1911,9 +1911,6 @@ var hasOwnProperty = {}.hasOwnProperty;
|
|
|
1911
1911
|
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty;
|
|
1912
1912
|
var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
|
|
1913
1913
|
|
|
1914
|
-
// ../../core/src/shared/utils/module.ts
|
|
1915
|
-
var import_semver = __toESM(require_semver2(), 1);
|
|
1916
|
-
|
|
1917
1914
|
// ../../core/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
1918
1915
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
1919
1916
|
function normalizeWindowsPath(input = "") {
|
|
@@ -2000,7 +1997,7 @@ var core = {
|
|
|
2000
1997
|
...entry,
|
|
2001
1998
|
fileURLToPath2(import.meta.resolve("@storybook/nextjs-vite/preview"))
|
|
2002
1999
|
], nextjsVersion = getNextjsVersion();
|
|
2003
|
-
return
|
|
2000
|
+
return import_semver.default.gte(nextjsVersion, "16.0.0") || annotations.push(fileURLToPath2(import.meta.resolve("@storybook/nextjs-vite/config/preview"))), annotations;
|
|
2004
2001
|
}, optimizeViteDeps = [
|
|
2005
2002
|
"@storybook/nextjs-vite/link.mock",
|
|
2006
2003
|
"@storybook/nextjs-vite/navigation.mock",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_oh5fakgezil from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_oh5fakgezil from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_oh5fakgezil from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_oh5fakgezil.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_oh5fakgezil.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_oh5fakgezil.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 "../_node-chunks/chunk-
|
|
12
|
+
import "../_node-chunks/chunk-YJQLOU5Z.js";
|
|
13
13
|
|
|
14
14
|
// src/vite-plugin/index.ts
|
|
15
15
|
import vitePluginStorybookNextjs from "vite-plugin-storybook-nextjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/nextjs-vite",
|
|
3
|
-
"version": "11.0.0-
|
|
3
|
+
"version": "11.0.0-beta.1",
|
|
4
4
|
"description": "Storybook for Next.js and Vite: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
"!src/**/*"
|
|
89
89
|
],
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@storybook/builder-vite": "11.0.0-
|
|
92
|
-
"@storybook/react": "11.0.0-
|
|
93
|
-
"@storybook/react-vite": "11.0.0-
|
|
91
|
+
"@storybook/builder-vite": "11.0.0-beta.1",
|
|
92
|
+
"@storybook/react": "11.0.0-beta.1",
|
|
93
|
+
"@storybook/react-vite": "11.0.0-beta.1",
|
|
94
94
|
"styled-jsx": "5.1.6",
|
|
95
|
-
"vite-plugin-storybook-nextjs": "11.0.0-
|
|
95
|
+
"vite-plugin-storybook-nextjs": "11.0.0-beta.1"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@types/node": "^22.19.1",
|
|
@@ -103,21 +103,33 @@
|
|
|
103
103
|
"typescript": "^6.0.3"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
+
"@joshwooding/vite-plugin-react-docgen-typescript": "^0.7.0 || ^0.8.0 || ^0.9.0",
|
|
106
107
|
"@types/react": "^18.0.0 || ^19.0.0",
|
|
107
108
|
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
|
108
109
|
"next": "^15.0.0 || ^16.0.0",
|
|
109
110
|
"react": "^18.0.0 || ^19.0.0",
|
|
111
|
+
"react-docgen": "^8.0.2",
|
|
112
|
+
"react-docgen-typescript": "^2.2.2",
|
|
110
113
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
111
|
-
"storybook": "^11.0.0-
|
|
114
|
+
"storybook": "^11.0.0-beta.1",
|
|
112
115
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
|
|
113
116
|
"vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
|
|
114
117
|
},
|
|
115
118
|
"peerDependenciesMeta": {
|
|
119
|
+
"@joshwooding/vite-plugin-react-docgen-typescript": {
|
|
120
|
+
"optional": true
|
|
121
|
+
},
|
|
116
122
|
"@types/react": {
|
|
117
123
|
"optional": true
|
|
118
124
|
},
|
|
119
125
|
"@types/react-dom": {
|
|
120
126
|
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"react-docgen": {
|
|
129
|
+
"optional": true
|
|
130
|
+
},
|
|
131
|
+
"react-docgen-typescript": {
|
|
132
|
+
"optional": true
|
|
121
133
|
}
|
|
122
134
|
},
|
|
123
135
|
"publishConfig": {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
1
2
|
import { fn } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import { Button } from './Button';
|
|
4
5
|
|
|
5
6
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
-
|
|
7
|
+
const meta = preview.meta({
|
|
7
8
|
title: 'Example/Button',
|
|
8
9
|
component: Button,
|
|
9
10
|
parameters: {
|
|
@@ -18,32 +19,32 @@ export default {
|
|
|
18
19
|
},
|
|
19
20
|
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
|
|
20
21
|
args: { onClick: fn() },
|
|
21
|
-
};
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
24
|
-
export const Primary = {
|
|
25
|
+
export const Primary = meta.story({
|
|
25
26
|
args: {
|
|
26
27
|
primary: true,
|
|
27
28
|
label: 'Button',
|
|
28
29
|
},
|
|
29
|
-
};
|
|
30
|
+
});
|
|
30
31
|
|
|
31
|
-
export const Secondary = {
|
|
32
|
+
export const Secondary = meta.story({
|
|
32
33
|
args: {
|
|
33
34
|
label: 'Button',
|
|
34
35
|
},
|
|
35
|
-
};
|
|
36
|
+
});
|
|
36
37
|
|
|
37
|
-
export const Large = {
|
|
38
|
+
export const Large = meta.story({
|
|
38
39
|
args: {
|
|
39
40
|
size: 'large',
|
|
40
41
|
label: 'Button',
|
|
41
42
|
},
|
|
42
|
-
};
|
|
43
|
+
});
|
|
43
44
|
|
|
44
|
-
export const Small = {
|
|
45
|
+
export const Small = meta.story({
|
|
45
46
|
args: {
|
|
46
47
|
size: 'small',
|
|
47
48
|
label: 'Button',
|
|
48
49
|
},
|
|
49
|
-
};
|
|
50
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
1
2
|
import { fn } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import { Header } from './Header';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const meta = preview.meta({
|
|
6
7
|
title: 'Example/Header',
|
|
7
8
|
component: Header,
|
|
8
9
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
@@ -16,15 +17,15 @@ export default {
|
|
|
16
17
|
onLogout: fn(),
|
|
17
18
|
onCreateAccount: fn(),
|
|
18
19
|
},
|
|
19
|
-
};
|
|
20
|
-
export const LoggedIn = {
|
|
20
|
+
});
|
|
21
|
+
export const LoggedIn = meta.story({
|
|
21
22
|
args: {
|
|
22
23
|
user: {
|
|
23
24
|
name: 'Jane Doe',
|
|
24
25
|
},
|
|
25
26
|
},
|
|
26
|
-
};
|
|
27
|
+
});
|
|
27
28
|
|
|
28
|
-
export const LoggedOut = {
|
|
29
|
+
export const LoggedOut = meta.story({
|
|
29
30
|
args: {},
|
|
30
|
-
};
|
|
31
|
+
});
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
1
2
|
import { expect, userEvent, within } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import { Page } from './Page';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const meta = preview.meta({
|
|
6
7
|
title: 'Example/Page',
|
|
7
8
|
component: Page,
|
|
8
9
|
parameters: {
|
|
9
10
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
10
11
|
layout: 'fullscreen',
|
|
11
12
|
},
|
|
12
|
-
};
|
|
13
|
+
});
|
|
13
14
|
|
|
14
|
-
export const LoggedOut =
|
|
15
|
+
export const LoggedOut = meta.story();
|
|
15
16
|
|
|
16
17
|
// More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing
|
|
17
|
-
export const LoggedIn = {
|
|
18
|
+
export const LoggedIn = meta.story({
|
|
18
19
|
play: async ({ canvasElement }) => {
|
|
19
20
|
const canvas = within(canvasElement);
|
|
20
21
|
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
@@ -25,4 +26,4 @@ export const LoggedIn = {
|
|
|
25
26
|
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
26
27
|
await expect(logoutButton).toBeInTheDocument();
|
|
27
28
|
},
|
|
28
|
-
};
|
|
29
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
2
2
|
|
|
3
3
|
import { fn } from 'storybook/test';
|
|
4
4
|
|
|
5
5
|
import { Button } from './Button';
|
|
6
6
|
|
|
7
7
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
8
|
-
const meta = {
|
|
8
|
+
const meta = preview.meta({
|
|
9
9
|
title: 'Example/Button',
|
|
10
10
|
component: Button,
|
|
11
11
|
parameters: {
|
|
@@ -20,35 +20,32 @@ const meta = {
|
|
|
20
20
|
},
|
|
21
21
|
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
|
|
22
22
|
args: { onClick: fn() },
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default meta;
|
|
26
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
+
});
|
|
27
24
|
|
|
28
25
|
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
29
|
-
export const Primary
|
|
26
|
+
export const Primary = meta.story({
|
|
30
27
|
args: {
|
|
31
28
|
primary: true,
|
|
32
29
|
label: 'Button',
|
|
33
30
|
},
|
|
34
|
-
};
|
|
31
|
+
});
|
|
35
32
|
|
|
36
|
-
export const Secondary
|
|
33
|
+
export const Secondary = meta.story({
|
|
37
34
|
args: {
|
|
38
35
|
label: 'Button',
|
|
39
36
|
},
|
|
40
|
-
};
|
|
37
|
+
});
|
|
41
38
|
|
|
42
|
-
export const Large
|
|
39
|
+
export const Large = meta.story({
|
|
43
40
|
args: {
|
|
44
41
|
size: 'large',
|
|
45
42
|
label: 'Button',
|
|
46
43
|
},
|
|
47
|
-
};
|
|
44
|
+
});
|
|
48
45
|
|
|
49
|
-
export const Small
|
|
46
|
+
export const Small = meta.story({
|
|
50
47
|
args: {
|
|
51
48
|
size: 'small',
|
|
52
49
|
label: 'Button',
|
|
53
50
|
},
|
|
54
|
-
};
|
|
51
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
2
2
|
|
|
3
3
|
import { fn } from 'storybook/test';
|
|
4
4
|
|
|
5
5
|
import { Header } from './Header';
|
|
6
6
|
|
|
7
|
-
const meta = {
|
|
7
|
+
const meta = preview.meta({
|
|
8
8
|
title: 'Example/Header',
|
|
9
9
|
component: Header,
|
|
10
10
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
@@ -18,17 +18,14 @@ const meta = {
|
|
|
18
18
|
onLogout: fn(),
|
|
19
19
|
onCreateAccount: fn(),
|
|
20
20
|
},
|
|
21
|
-
}
|
|
21
|
+
});
|
|
22
22
|
|
|
23
|
-
export
|
|
24
|
-
type Story = StoryObj<typeof meta>;
|
|
25
|
-
|
|
26
|
-
export const LoggedIn: Story = {
|
|
23
|
+
export const LoggedIn = meta.story({
|
|
27
24
|
args: {
|
|
28
25
|
user: {
|
|
29
26
|
name: 'Jane Doe',
|
|
30
27
|
},
|
|
31
28
|
},
|
|
32
|
-
};
|
|
29
|
+
});
|
|
33
30
|
|
|
34
|
-
export const LoggedOut
|
|
31
|
+
export const LoggedOut = meta.story();
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
2
2
|
|
|
3
3
|
import { expect, userEvent, within } from 'storybook/test';
|
|
4
4
|
|
|
5
5
|
import { Page } from './Page';
|
|
6
6
|
|
|
7
|
-
const meta = {
|
|
7
|
+
const meta = preview.meta({
|
|
8
8
|
title: 'Example/Page',
|
|
9
9
|
component: Page,
|
|
10
10
|
parameters: {
|
|
11
11
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
12
12
|
layout: 'fullscreen',
|
|
13
13
|
},
|
|
14
|
-
}
|
|
14
|
+
});
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
type Story = StoryObj<typeof meta>;
|
|
18
|
-
|
|
19
|
-
export const LoggedOut: Story = {};
|
|
16
|
+
export const LoggedOut = meta.story();
|
|
20
17
|
|
|
21
18
|
// More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing
|
|
22
|
-
export const LoggedIn
|
|
19
|
+
export const LoggedIn = meta.story({
|
|
23
20
|
play: async ({ canvasElement }) => {
|
|
24
21
|
const canvas = within(canvasElement);
|
|
25
22
|
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
@@ -30,4 +27,4 @@ export const LoggedIn: Story = {
|
|
|
30
27
|
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
31
28
|
await expect(logoutButton).toBeInTheDocument();
|
|
32
29
|
},
|
|
33
|
-
};
|
|
30
|
+
});
|
package/dist/chunk-Crpg_HiB.d.ts
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
//#region node_modules/@vitest/spy/dist/index.d.ts
|
|
2
|
-
interface MockResultReturn<T> {
|
|
3
|
-
type: "return";
|
|
4
|
-
/**
|
|
5
|
-
* The value that was returned from the function. If function returned a Promise, then this will be a resolved value.
|
|
6
|
-
*/
|
|
7
|
-
value: T;
|
|
8
|
-
}
|
|
9
|
-
interface MockResultIncomplete {
|
|
10
|
-
type: "incomplete";
|
|
11
|
-
value: undefined;
|
|
12
|
-
}
|
|
13
|
-
interface MockResultThrow {
|
|
14
|
-
type: "throw";
|
|
15
|
-
/**
|
|
16
|
-
* An error that was thrown during function execution.
|
|
17
|
-
*/
|
|
18
|
-
value: any;
|
|
19
|
-
}
|
|
20
|
-
interface MockSettledResultFulfilled<T> {
|
|
21
|
-
type: "fulfilled";
|
|
22
|
-
value: T;
|
|
23
|
-
}
|
|
24
|
-
interface MockSettledResultRejected {
|
|
25
|
-
type: "rejected";
|
|
26
|
-
value: any;
|
|
27
|
-
}
|
|
28
|
-
type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
|
29
|
-
type MockSettledResult<T> = MockSettledResultFulfilled<T> | MockSettledResultRejected;
|
|
30
|
-
interface MockContext<T extends Procedure> {
|
|
31
|
-
/**
|
|
32
|
-
* This is an array containing all arguments for each call. One item of the array is the arguments of that call.
|
|
33
|
-
*
|
|
34
|
-
* @see https://vitest.dev/api/mock#mock-calls
|
|
35
|
-
* @example
|
|
36
|
-
* const fn = vi.fn()
|
|
37
|
-
*
|
|
38
|
-
* fn('arg1', 'arg2')
|
|
39
|
-
* fn('arg3')
|
|
40
|
-
*
|
|
41
|
-
* fn.mock.calls === [
|
|
42
|
-
* ['arg1', 'arg2'], // first call
|
|
43
|
-
* ['arg3'], // second call
|
|
44
|
-
* ]
|
|
45
|
-
*/
|
|
46
|
-
calls: Parameters<T>[];
|
|
47
|
-
/**
|
|
48
|
-
* 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.
|
|
49
|
-
* @see https://vitest.dev/api/mock#mock-instances
|
|
50
|
-
*/
|
|
51
|
-
instances: ReturnType<T>[];
|
|
52
|
-
/**
|
|
53
|
-
* An array of `this` values that were used during each call to the mock function.
|
|
54
|
-
* @see https://vitest.dev/api/mock#mock-contexts
|
|
55
|
-
*/
|
|
56
|
-
contexts: ThisParameterType<T>[];
|
|
57
|
-
/**
|
|
58
|
-
* The order of mock's execution. This returns an array of numbers which are shared between all defined mocks.
|
|
59
|
-
*
|
|
60
|
-
* @see https://vitest.dev/api/mock#mock-invocationcallorder
|
|
61
|
-
* @example
|
|
62
|
-
* const fn1 = vi.fn()
|
|
63
|
-
* const fn2 = vi.fn()
|
|
64
|
-
*
|
|
65
|
-
* fn1()
|
|
66
|
-
* fn2()
|
|
67
|
-
* fn1()
|
|
68
|
-
*
|
|
69
|
-
* fn1.mock.invocationCallOrder === [1, 3]
|
|
70
|
-
* fn2.mock.invocationCallOrder === [2]
|
|
71
|
-
*/
|
|
72
|
-
invocationCallOrder: number[];
|
|
73
|
-
/**
|
|
74
|
-
* This is an array containing all values that were `returned` from the function.
|
|
75
|
-
*
|
|
76
|
-
* 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.
|
|
77
|
-
*
|
|
78
|
-
* @see https://vitest.dev/api/mock#mock-results
|
|
79
|
-
* @example
|
|
80
|
-
* const fn = vi.fn()
|
|
81
|
-
* .mockReturnValueOnce('result')
|
|
82
|
-
* .mockImplementationOnce(() => { throw new Error('thrown error') })
|
|
83
|
-
*
|
|
84
|
-
* const result = fn()
|
|
85
|
-
*
|
|
86
|
-
* try {
|
|
87
|
-
* fn()
|
|
88
|
-
* }
|
|
89
|
-
* catch {}
|
|
90
|
-
*
|
|
91
|
-
* fn.mock.results === [
|
|
92
|
-
* {
|
|
93
|
-
* type: 'return',
|
|
94
|
-
* value: 'result',
|
|
95
|
-
* },
|
|
96
|
-
* {
|
|
97
|
-
* type: 'throw',
|
|
98
|
-
* value: Error,
|
|
99
|
-
* },
|
|
100
|
-
* ]
|
|
101
|
-
*/
|
|
102
|
-
results: MockResult<ReturnType<T>>[];
|
|
103
|
-
/**
|
|
104
|
-
* An array containing all values that were `resolved` or `rejected` from the function.
|
|
105
|
-
*
|
|
106
|
-
* This array will be empty if the function was never resolved or rejected.
|
|
107
|
-
*
|
|
108
|
-
* @see https://vitest.dev/api/mock#mock-settledresults
|
|
109
|
-
* @example
|
|
110
|
-
* const fn = vi.fn().mockResolvedValueOnce('result')
|
|
111
|
-
*
|
|
112
|
-
* const result = fn()
|
|
113
|
-
*
|
|
114
|
-
* fn.mock.settledResults === []
|
|
115
|
-
* fn.mock.results === [
|
|
116
|
-
* {
|
|
117
|
-
* type: 'return',
|
|
118
|
-
* value: Promise<'result'>,
|
|
119
|
-
* },
|
|
120
|
-
* ]
|
|
121
|
-
*
|
|
122
|
-
* await result
|
|
123
|
-
*
|
|
124
|
-
* fn.mock.settledResults === [
|
|
125
|
-
* {
|
|
126
|
-
* type: 'fulfilled',
|
|
127
|
-
* value: 'result',
|
|
128
|
-
* },
|
|
129
|
-
* ]
|
|
130
|
-
*/
|
|
131
|
-
settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
|
|
132
|
-
/**
|
|
133
|
-
* This contains the arguments of the last call. If spy wasn't called, will return `undefined`.
|
|
134
|
-
* @see https://vitest.dev/api/mock#mock-lastcall
|
|
135
|
-
*/
|
|
136
|
-
lastCall: Parameters<T> | undefined;
|
|
137
|
-
}
|
|
138
|
-
type Procedure = (...args: any[]) => any; // pick a single function type from function overloads, unions, etc...
|
|
139
|
-
type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
|
|
140
|
-
/*
|
|
141
|
-
cf. https://typescript-eslint.io/rules/method-signature-style/
|
|
142
|
-
|
|
143
|
-
Typescript assignability is different between
|
|
144
|
-
{ foo: (f: T) => U } (this is "method-signature-style")
|
|
145
|
-
and
|
|
146
|
-
{ foo(f: T): U }
|
|
147
|
-
|
|
148
|
-
Jest uses the latter for `MockInstance.mockImplementation` etc... and it allows assignment such as:
|
|
149
|
-
const boolFn: Jest.Mock<() => boolean> = jest.fn<() => true>(() => true)
|
|
150
|
-
*/
|
|
151
|
-
/* eslint-disable ts/method-signature-style */
|
|
152
|
-
interface MockInstance<T extends Procedure = Procedure> extends Disposable {
|
|
153
|
-
/**
|
|
154
|
-
* Use it to return the name assigned to the mock with the `.mockName(name)` method. By default, it will return `vi.fn()`.
|
|
155
|
-
* @see https://vitest.dev/api/mock#getmockname
|
|
156
|
-
*/
|
|
157
|
-
getMockName(): string;
|
|
158
|
-
/**
|
|
159
|
-
* Sets the internal mock name. This is useful for identifying the mock when an assertion fails.
|
|
160
|
-
* @see https://vitest.dev/api/mock#mockname
|
|
161
|
-
*/
|
|
162
|
-
mockName(name: string): this;
|
|
163
|
-
/**
|
|
164
|
-
* Current context of the mock. It stores information about all invocation calls, instances, and results.
|
|
165
|
-
*/
|
|
166
|
-
mock: MockContext<T>;
|
|
167
|
-
/**
|
|
168
|
-
* 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.
|
|
169
|
-
*
|
|
170
|
-
* To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/#clearmocks) setting in the configuration.
|
|
171
|
-
* @see https://vitest.dev/api/mock#mockclear
|
|
172
|
-
*/
|
|
173
|
-
mockClear(): this;
|
|
174
|
-
/**
|
|
175
|
-
* Does what `mockClear` does and resets inner implementation to the original function. This also resets all "once" implementations.
|
|
176
|
-
*
|
|
177
|
-
* Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
|
|
178
|
-
* Resetting a mock from `vi.fn(impl)` will set implementation to `impl`. It is useful for completely resetting a mock to its default state.
|
|
179
|
-
*
|
|
180
|
-
* To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/#mockreset) setting in the configuration.
|
|
181
|
-
* @see https://vitest.dev/api/mock#mockreset
|
|
182
|
-
*/
|
|
183
|
-
mockReset(): this;
|
|
184
|
-
/**
|
|
185
|
-
* Does what `mockReset` does and restores original descriptors of spied-on objects.
|
|
186
|
-
*
|
|
187
|
-
* 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`.
|
|
188
|
-
* @see https://vitest.dev/api/mock#mockrestore
|
|
189
|
-
*/
|
|
190
|
-
mockRestore(): void;
|
|
191
|
-
/**
|
|
192
|
-
* Returns current permanent mock implementation if there is one.
|
|
193
|
-
*
|
|
194
|
-
* If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
|
|
195
|
-
*
|
|
196
|
-
* If mock was created with `vi.spyOn`, it will return `undefined` unless a custom implementation was provided.
|
|
197
|
-
*/
|
|
198
|
-
getMockImplementation(): NormalizedProcedure<T> | undefined;
|
|
199
|
-
/**
|
|
200
|
-
* Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function.
|
|
201
|
-
* @see https://vitest.dev/api/mock#mockimplementation
|
|
202
|
-
* @example
|
|
203
|
-
* const increment = vi.fn().mockImplementation(count => count + 1);
|
|
204
|
-
* expect(increment(3)).toBe(4);
|
|
205
|
-
*/
|
|
206
|
-
mockImplementation(fn: NormalizedProcedure<T>): this;
|
|
207
|
-
/**
|
|
208
|
-
* 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.
|
|
209
|
-
*
|
|
210
|
-
* 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.
|
|
211
|
-
* @see https://vitest.dev/api/mock#mockimplementationonce
|
|
212
|
-
* @example
|
|
213
|
-
* const fn = vi.fn(count => count).mockImplementationOnce(count => count + 1);
|
|
214
|
-
* expect(fn(3)).toBe(4);
|
|
215
|
-
* expect(fn(3)).toBe(3);
|
|
216
|
-
*/
|
|
217
|
-
mockImplementationOnce(fn: NormalizedProcedure<T>): this;
|
|
218
|
-
/**
|
|
219
|
-
* Overrides the original mock implementation temporarily while the callback is being executed.
|
|
220
|
-
*
|
|
221
|
-
* Note that this method takes precedence over the [`mockImplementationOnce`](https://vitest.dev/api/mock#mockimplementationonce).
|
|
222
|
-
* @see https://vitest.dev/api/mock#withimplementation
|
|
223
|
-
* @example
|
|
224
|
-
* const myMockFn = vi.fn(() => 'original')
|
|
225
|
-
*
|
|
226
|
-
* myMockFn.withImplementation(() => 'temp', () => {
|
|
227
|
-
* myMockFn() // 'temp'
|
|
228
|
-
* })
|
|
229
|
-
*
|
|
230
|
-
* myMockFn() // 'original'
|
|
231
|
-
*/
|
|
232
|
-
withImplementation<T2>(fn: NormalizedProcedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
|
|
233
|
-
/**
|
|
234
|
-
* Use this if you need to return the `this` context from the method without invoking the actual implementation.
|
|
235
|
-
* @see https://vitest.dev/api/mock#mockreturnthis
|
|
236
|
-
*/
|
|
237
|
-
mockReturnThis(): this;
|
|
238
|
-
/**
|
|
239
|
-
* 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.
|
|
240
|
-
* @see https://vitest.dev/api/mock#mockreturnvalue
|
|
241
|
-
* @example
|
|
242
|
-
* const mock = vi.fn()
|
|
243
|
-
* mock.mockReturnValue(42)
|
|
244
|
-
* mock() // 42
|
|
245
|
-
* mock.mockReturnValue(43)
|
|
246
|
-
* mock() // 43
|
|
247
|
-
*/
|
|
248
|
-
mockReturnValue(value: ReturnType<T>): this;
|
|
249
|
-
/**
|
|
250
|
-
* 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.
|
|
251
|
-
*
|
|
252
|
-
* 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.
|
|
253
|
-
* @example
|
|
254
|
-
* const myMockFn = vi
|
|
255
|
-
* .fn()
|
|
256
|
-
* .mockReturnValue('default')
|
|
257
|
-
* .mockReturnValueOnce('first call')
|
|
258
|
-
* .mockReturnValueOnce('second call')
|
|
259
|
-
*
|
|
260
|
-
* // 'first call', 'second call', 'default'
|
|
261
|
-
* console.log(myMockFn(), myMockFn(), myMockFn())
|
|
262
|
-
*/
|
|
263
|
-
mockReturnValueOnce(value: ReturnType<T>): this;
|
|
264
|
-
/**
|
|
265
|
-
* 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.
|
|
266
|
-
* @example
|
|
267
|
-
* const asyncMock = vi.fn().mockResolvedValue(42)
|
|
268
|
-
* asyncMock() // Promise<42>
|
|
269
|
-
*/
|
|
270
|
-
mockResolvedValue(value: Awaited<ReturnType<T>>): this;
|
|
271
|
-
/**
|
|
272
|
-
* 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.
|
|
273
|
-
* @example
|
|
274
|
-
* const myMockFn = vi
|
|
275
|
-
* .fn()
|
|
276
|
-
* .mockResolvedValue('default')
|
|
277
|
-
* .mockResolvedValueOnce('first call')
|
|
278
|
-
* .mockResolvedValueOnce('second call')
|
|
279
|
-
*
|
|
280
|
-
* // Promise<'first call'>, Promise<'second call'>, Promise<'default'>
|
|
281
|
-
* console.log(myMockFn(), myMockFn(), myMockFn())
|
|
282
|
-
*/
|
|
283
|
-
mockResolvedValueOnce(value: Awaited<ReturnType<T>>): this;
|
|
284
|
-
/**
|
|
285
|
-
* Accepts an error that will be rejected when async function is called.
|
|
286
|
-
* @example
|
|
287
|
-
* const asyncMock = vi.fn().mockRejectedValue(new Error('Async error'))
|
|
288
|
-
* await asyncMock() // throws Error<'Async error'>
|
|
289
|
-
*/
|
|
290
|
-
mockRejectedValue(error: unknown): this;
|
|
291
|
-
/**
|
|
292
|
-
* Accepts a value that will be rejected during the next function call. If chained, each consecutive call will reject the specified value.
|
|
293
|
-
* @example
|
|
294
|
-
* const asyncMock = vi
|
|
295
|
-
* .fn()
|
|
296
|
-
* .mockResolvedValueOnce('first call')
|
|
297
|
-
* .mockRejectedValueOnce(new Error('Async error'))
|
|
298
|
-
*
|
|
299
|
-
* await asyncMock() // first call
|
|
300
|
-
* await asyncMock() // throws Error<'Async error'>
|
|
301
|
-
*/
|
|
302
|
-
mockRejectedValueOnce(error: unknown): this;
|
|
303
|
-
}
|
|
304
|
-
/* eslint-enable ts/method-signature-style */
|
|
305
|
-
interface Mock<T extends Procedure = Procedure> extends MockInstance<T> {
|
|
306
|
-
new (...args: Parameters<T>): ReturnType<T>;
|
|
307
|
-
(...args: Parameters<T>): ReturnType<T>;
|
|
308
|
-
}
|
|
309
|
-
//#endregion
|
|
310
|
-
export { Mock as t };
|