storybook 9.0.0-beta.9 → 9.0.0-rc.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 (71) hide show
  1. package/assets/server/base-preview-head.html +21 -0
  2. package/assets/server/template.ejs +4 -4
  3. package/dist/actions/preview.cjs +1 -1
  4. package/dist/actions/preview.d.ts +501 -0
  5. package/dist/actions/preview.js +1 -1
  6. package/dist/backgrounds/index.d.ts +501 -0
  7. package/dist/backgrounds/preview.d.ts +501 -0
  8. package/dist/bin/index.cjs +61 -61
  9. package/dist/bin/index.js +59 -59
  10. package/dist/builder-manager/index.cjs +27 -27
  11. package/dist/builder-manager/index.js +46 -46
  12. package/dist/cli/bin/index.cjs +1032 -1032
  13. package/dist/cli/bin/index.js +1032 -1032
  14. package/dist/cli/index.cjs +33709 -28783
  15. package/dist/cli/index.js +33641 -28711
  16. package/dist/common/index.cjs +2802 -2789
  17. package/dist/common/index.d.ts +2 -1
  18. package/dist/common/index.js +3250 -3237
  19. package/dist/components/index.cjs +711 -711
  20. package/dist/components/index.d.ts +2 -1
  21. package/dist/components/index.js +15 -15
  22. package/dist/controls/preview.d.ts +501 -0
  23. package/dist/core-events/index.cjs +55 -52
  24. package/dist/core-events/index.d.ts +3 -1
  25. package/dist/core-events/index.js +52 -49
  26. package/dist/core-server/index.cjs +12 -12
  27. package/dist/core-server/index.d.ts +512 -11
  28. package/dist/core-server/index.js +12 -12
  29. package/dist/core-server/presets/common-manager.js +4566 -5766
  30. package/dist/core-server/presets/common-override-preset.cjs +10 -12
  31. package/dist/core-server/presets/common-override-preset.js +3 -5
  32. package/dist/core-server/presets/common-preset.cjs +112 -116
  33. package/dist/core-server/presets/common-preset.js +10 -14
  34. package/dist/csf/index.d.ts +1 -1
  35. package/dist/csf-tools/index.cjs +116 -111
  36. package/dist/csf-tools/index.js +33 -28
  37. package/dist/highlight/preview.d.ts +501 -0
  38. package/dist/instrumenter/index.js +1849 -3547
  39. package/dist/manager/globals-module-info.cjs +3 -0
  40. package/dist/manager/globals-module-info.js +3 -0
  41. package/dist/manager/globals-runtime.js +21082 -22647
  42. package/dist/manager/runtime.js +2468 -2449
  43. package/dist/manager-api/index.cjs +2302 -8594
  44. package/dist/manager-api/index.d.ts +501 -0
  45. package/dist/manager-api/index.js +2602 -2631
  46. package/dist/measure/index.d.ts +501 -0
  47. package/dist/measure/preview.d.ts +501 -0
  48. package/dist/outline/index.d.ts +501 -0
  49. package/dist/outline/preview.d.ts +501 -0
  50. package/dist/preview/runtime.js +38420 -40024
  51. package/dist/preview-api/index.cjs +1546 -1459
  52. package/dist/preview-api/index.d.ts +8 -5
  53. package/dist/preview-api/index.js +1267 -1181
  54. package/dist/router/index.cjs +5700 -2327
  55. package/dist/router/index.d.ts +622 -243
  56. package/dist/router/index.js +1297 -870
  57. package/dist/test/index.cjs +1810 -1811
  58. package/dist/test/index.d.ts +53 -5
  59. package/dist/test/index.js +1907 -1908
  60. package/dist/test/preview.cjs +51 -15860
  61. package/dist/test/preview.d.ts +520 -13
  62. package/dist/test/preview.js +44 -14431
  63. package/dist/theming/index.cjs +17 -0
  64. package/dist/theming/index.js +17 -0
  65. package/dist/types/index.d.ts +516 -82
  66. package/dist/viewport/index.d.ts +502 -3
  67. package/dist/viewport/preview.d.ts +501 -0
  68. package/package.json +2 -18
  69. package/dist/test/spy.cjs +0 -258
  70. package/dist/test/spy.d.ts +0 -62
  71. package/dist/test/spy.js +0 -240
package/dist/test/spy.cjs DELETED
@@ -1,258 +0,0 @@
1
- "use strict";
2
- var T = Object.defineProperty;
3
- var A = Object.getOwnPropertyDescriptor;
4
- var Y = Object.getOwnPropertyNames;
5
- var N = Object.prototype.hasOwnProperty;
6
- var n = (t, e) => T(t, "name", { value: e, configurable: !0 });
7
- var K = (t, e) => {
8
- for (var r in e)
9
- T(t, r, { get: e[r], enumerable: !0 });
10
- }, B = (t, e, r, s) => {
11
- if (e && typeof e == "object" || typeof e == "function")
12
- for (let o of Y(e))
13
- !N.call(t, o) && o !== r && T(t, o, { get: () => e[o], enumerable: !(s = A(e, o)) || s.enumerable });
14
- return t;
15
- };
16
- var U = (t) => B(T({}, "__esModule", { value: !0 }), t);
17
-
18
- // src/test/spy.ts
19
- var oe = {};
20
- K(oe, {
21
- clearAllMocks: () => Z,
22
- fn: () => X,
23
- isMockFunction: () => j,
24
- mocked: () => ne,
25
- mocks: () => O,
26
- onMockCall: () => J,
27
- resetAllMocks: () => ee,
28
- restoreAllMocks: () => te,
29
- spyOn: () => Q
30
- });
31
- module.exports = U(oe);
32
-
33
- // ../node_modules/tinyspy/dist/index.js
34
- function I(t, e) {
35
- if (!t)
36
- throw new Error(e);
37
- }
38
- n(I, "d");
39
- function g(t, e) {
40
- return typeof e === t;
41
- }
42
- n(g, "y");
43
- function W(t) {
44
- return t instanceof Promise;
45
- }
46
- n(W, "w");
47
- function w(t, e, r) {
48
- Object.defineProperty(t, e, r);
49
- }
50
- n(w, "f");
51
- function h(t, e, r) {
52
- Object.defineProperty(t, e, { value: r });
53
- }
54
- n(h, "l");
55
- var v = Symbol.for("tinyspy:spy"), $ = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ n((t) => {
56
- t.called = !1, t.callCount = 0, t.calls = [], t.results = [], t.resolves = [], t.next = [];
57
- }, "P"), z = /* @__PURE__ */ n((t) => (w(t, v, { value: { reset: /* @__PURE__ */ n(() => q(t[v]), "reset") } }), t[v]), "K"), M = /* @__PURE__ */ n(
58
- (t) => t[v] || z(t), "T");
59
- function G(t) {
60
- I(
61
- g("function", t) || g("undefined", t),
62
- "cannot spy on a non-function value"
63
- );
64
- let e = /* @__PURE__ */ n(function(...s) {
65
- let o = M(e);
66
- o.called = !0, o.callCount++, o.calls.push(s);
67
- let p = o.next.shift();
68
- if (p) {
69
- o.results.push(p);
70
- let [c, y] = p;
71
- if (c === "ok")
72
- return y;
73
- throw y;
74
- }
75
- let i, f = "ok", a = o.results.length;
76
- if (o.impl)
77
- try {
78
- new.target ? i = Reflect.construct(o.impl, s, new.target) : i = o.impl.apply(this, s), f = "ok";
79
- } catch (c) {
80
- throw i = c, f = "error", o.results.push([f, c]), c;
81
- }
82
- let m = [f, i];
83
- return W(i) && i.then(
84
- (c) => o.resolves[a] = ["ok", c],
85
- (c) => o.resolves[a] = ["error", c]
86
- ), o.results.push(m), i;
87
- }, "t");
88
- h(e, "_isMockFunction", !0), h(e, "length", t ? t.length : 0), h(e, "name", t && t.name || "spy");
89
- let r = M(e);
90
- return r.reset(), r.impl = t, e;
91
- }
92
- n(G, "m");
93
- var C = /* @__PURE__ */ n((t, e) => Object.getOwnPropertyDescriptor(t, e), "k"), _ = /* @__PURE__ */ n((t, e) => {
94
- e != null && typeof e == "function" && e.prototype != null && Object.setPrototypeOf(t.prototype, e.prototype);
95
- }, "O");
96
- function P(t, e, r) {
97
- I(
98
- !g("undefined", t),
99
- "spyOn could not find an object to spy upon"
100
- ), I(
101
- g("object", t) || g("function", t),
102
- "cannot spyOn on a primitive value"
103
- );
104
- let [s, o] = (() => {
105
- if (!g("object", e))
106
- return [e, "value"];
107
- if ("getter" in e && "setter" in e)
108
- throw new Error("cannot spy on both getter and setter");
109
- if ("getter" in e)
110
- return [e.getter, "get"];
111
- if ("setter" in e)
112
- return [e.setter, "set"];
113
- throw new Error("specify getter or setter to spy on");
114
- })(), p = C(t, s), i = Object.getPrototypeOf(t), f = i && C(i, s), a = p || f;
115
- I(
116
- a || s in t,
117
- `${String(s)} does not exist`
118
- );
119
- let m = !1;
120
- o === "value" && a && !a.value && a.get && (o = "get", m = !0, r = a.get());
121
- let c;
122
- a ? c = a[o] : o !== "value" ? c = /* @__PURE__ */ n(() => t[s], "o") : c = t[s];
123
- let y = /* @__PURE__ */ n((k) => {
124
- let { value: S, ...d } = a || {
125
- configurable: !0,
126
- writable: !0
127
- };
128
- o !== "value" && delete d.writable, d[o] = k, w(t, s, d);
129
- }, "g"), x = /* @__PURE__ */ n(() => a ? w(t, s, a) : y(c), "b");
130
- r || (r = c);
131
- let l = G(r);
132
- o === "value" && _(l, c);
133
- let u = l[v];
134
- return h(u, "restore", x), h(u, "getOriginal", () => m ? c() : c), h(u, "willCall", (k) => (u.impl = k, l)), y(
135
- m ? () => (_(l, r), l) : l
136
- ), $.add(l), l;
137
- }
138
- n(P, "C");
139
-
140
- // ../node_modules/@vitest/spy/dist/index.js
141
- var O = /* @__PURE__ */ new Set();
142
- function j(t) {
143
- return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
144
- }
145
- n(j, "isMockFunction");
146
- function D(t, e, r) {
147
- let o = r ? { [{
148
- get: "getter",
149
- set: "setter"
150
- }[r]]: e } : e, p = P(t, o);
151
- return F(p);
152
- }
153
- n(D, "spyOn");
154
- var H = 0;
155
- function F(t) {
156
- let e = t, r, s = [], o = [], p = [], i = M(t), f = {
157
- get calls() {
158
- return i.calls;
159
- },
160
- get contexts() {
161
- return o;
162
- },
163
- get instances() {
164
- return s;
165
- },
166
- get invocationCallOrder() {
167
- return p;
168
- },
169
- get results() {
170
- return i.results.map(([l, u]) => ({ type: l === "error" ? "throw" : "return", value: u }));
171
- },
172
- get settledResults() {
173
- return i.resolves.map(([l, u]) => ({ type: l === "error" ? "rejected" : "fulfilled", value: u }));
174
- },
175
- get lastCall() {
176
- return i.calls[i.calls.length - 1];
177
- }
178
- }, a = [], m = !1;
179
- function c(...l) {
180
- return s.push(this), o.push(this), p.push(++H), (m ? r : a.shift() || r || i.getOriginal() || (() => {
181
- })).apply(this, l);
182
- }
183
- n(c, "mockCall");
184
- let y = e.name;
185
- e.getMockName = () => y || "vi.fn()", e.mockName = (l) => (y = l, e), e.mockClear = () => (i.reset(), s = [], o = [], p = [], e), e.mockReset =
186
- () => (e.mockClear(), r = void 0, a = [], e), e.mockRestore = () => (e.mockReset(), i.restore(), e), e.getMockImplementation = () => m ? r :
187
- a.at(0) || r, e.mockImplementation = (l) => (r = l, i.willCall(c), e), e.mockImplementationOnce = (l) => (a.push(l), e);
188
- function x(l, u) {
189
- let k = r;
190
- r = l, i.willCall(c), m = !0;
191
- let S = /* @__PURE__ */ n(() => {
192
- r = k, m = !1;
193
- }, "reset"), d = u();
194
- return d instanceof Promise ? d.then(() => (S(), e)) : (S(), e);
195
- }
196
- return n(x, "withImplementation"), e.withImplementation = x, e.mockReturnThis = () => e.mockImplementation(function() {
197
- return this;
198
- }), e.mockReturnValue = (l) => e.mockImplementation(() => l), e.mockReturnValueOnce = (l) => e.mockImplementationOnce(() => l), e.mockResolvedValue =
199
- (l) => e.mockImplementation(() => Promise.resolve(l)), e.mockResolvedValueOnce = (l) => e.mockImplementationOnce(() => Promise.resolve(l)),
200
- e.mockRejectedValue = (l) => e.mockImplementation(() => Promise.reject(l)), e.mockRejectedValueOnce = (l) => e.mockImplementationOnce(() => Promise.
201
- reject(l)), Object.defineProperty(e, "mock", {
202
- get: /* @__PURE__ */ n(() => f, "get")
203
- }), i.willCall(c), O.add(e), e;
204
- }
205
- n(F, "enhanceSpy");
206
- function R(t) {
207
- let e = F(P({
208
- spy: t || function() {
209
- }
210
- }, "spy"));
211
- return t && e.mockImplementation(t), e;
212
- }
213
- n(R, "fn");
214
-
215
- // src/test/spy.ts
216
- var b = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
217
- globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = b;
218
- function J(t) {
219
- return b.add(t), () => void b.delete(t);
220
- }
221
- n(J, "onMockCall");
222
- var Q = /* @__PURE__ */ n((...t) => {
223
- let e = D(...t);
224
- return V(e);
225
- }, "spyOn");
226
- function X(t) {
227
- let e = t ? R(t) : R();
228
- return V(e);
229
- }
230
- n(X, "fn");
231
- function V(t) {
232
- let e = L(t), r = e.mockImplementation.bind(null);
233
- return e.mockImplementation = (s) => L(r(s)), e;
234
- }
235
- n(V, "reactiveMock");
236
- function L(t) {
237
- let e = M(t), r = e.impl;
238
- return e.willCall(function(...s) {
239
- return b.forEach((o) => o(t, s)), r?.apply(this, s);
240
- }), t;
241
- }
242
- n(L, "listenWhenCalled");
243
- function Z() {
244
- O.forEach((t) => t.mockClear());
245
- }
246
- n(Z, "clearAllMocks");
247
- function ee() {
248
- O.forEach((t) => t.mockReset());
249
- }
250
- n(ee, "resetAllMocks");
251
- function te() {
252
- O.forEach((t) => t.mockRestore());
253
- }
254
- n(te, "restoreAllMocks");
255
- function ne(t, e = {}) {
256
- return t;
257
- }
258
- n(ne, "mocked");
@@ -1,62 +0,0 @@
1
- import { MockInstance, spyOn as spyOn$1, Mock, MaybeMocked, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep } from '@vitest/spy';
2
- export * from '@vitest/spy';
3
- export { isMockFunction, mocks } from '@vitest/spy';
4
-
5
- type Listener = (mock: MockInstance, args: unknown[]) => void;
6
- declare function onMockCall(callback: Listener): () => void;
7
- declare const spyOn: typeof spyOn$1;
8
- type Procedure = (...args: any[]) => any;
9
- declare function fn<T extends Procedure = Procedure>(implementation?: T): Mock<T>;
10
- /**
11
- * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will
12
- * only empty `.mock` state, it will not reset implementation.
13
- *
14
- * It is useful if you need to clean up mock between different assertions.
15
- */
16
- declare function clearAllMocks(): void;
17
- /**
18
- * Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will
19
- * empty `.mock` state, reset "once" implementations and force the base implementation to return
20
- * `undefined` when invoked.
21
- *
22
- * This is useful when you want to completely reset a mock to the default state.
23
- */
24
- declare function resetAllMocks(): void;
25
- /**
26
- * Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This
27
- * will restore all original implementations.
28
- */
29
- declare function restoreAllMocks(): void;
30
- /**
31
- * Type helper for TypeScript. Just returns the object that was passed.
32
- *
33
- * When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will
34
- * only make TypeScript believe that the first level values are mocked. You can pass down `{ deep:
35
- * true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually
36
- * is.
37
- *
38
- * @param item Anything that can be mocked
39
- * @param deep If the object is deeply mocked
40
- * @param options If the object is partially or deeply mocked
41
- */
42
- declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
43
- declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
44
- declare function mocked<T>(item: T, options: {
45
- partial?: false;
46
- deep?: false;
47
- }): MaybeMocked<T>;
48
- declare function mocked<T>(item: T, options: {
49
- partial?: false;
50
- deep: true;
51
- }): MaybeMockedDeep<T>;
52
- declare function mocked<T>(item: T, options: {
53
- partial: true;
54
- deep?: false;
55
- }): MaybePartiallyMocked<T>;
56
- declare function mocked<T>(item: T, options: {
57
- partial: true;
58
- deep: true;
59
- }): MaybePartiallyMockedDeep<T>;
60
- declare function mocked<T>(item: T): MaybeMocked<T>;
61
-
62
- export { clearAllMocks, fn, mocked, onMockCall, resetAllMocks, restoreAllMocks, spyOn };
package/dist/test/spy.js DELETED
@@ -1,240 +0,0 @@
1
- var L = Object.defineProperty;
2
- var n = (t, e) => L(t, "name", { value: e, configurable: !0 });
3
-
4
- // ../node_modules/tinyspy/dist/index.js
5
- function T(t, e) {
6
- if (!t)
7
- throw new Error(e);
8
- }
9
- n(T, "d");
10
- function g(t, e) {
11
- return typeof e === t;
12
- }
13
- n(g, "y");
14
- function V(t) {
15
- return t instanceof Promise;
16
- }
17
- n(V, "w");
18
- function S(t, e, r) {
19
- Object.defineProperty(t, e, r);
20
- }
21
- n(S, "f");
22
- function h(t, e, r) {
23
- Object.defineProperty(t, e, { value: r });
24
- }
25
- n(h, "l");
26
- var O = Symbol.for("tinyspy:spy"), A = /* @__PURE__ */ new Set(), Y = /* @__PURE__ */ n((t) => {
27
- t.called = !1, t.callCount = 0, t.calls = [], t.results = [], t.resolves = [], t.next = [];
28
- }, "P"), N = /* @__PURE__ */ n((t) => (S(t, O, { value: { reset: /* @__PURE__ */ n(() => Y(t[O]), "reset") } }), t[O]), "K"), M = /* @__PURE__ */ n(
29
- (t) => t[O] || N(t), "T");
30
- function K(t) {
31
- T(
32
- g("function", t) || g("undefined", t),
33
- "cannot spy on a non-function value"
34
- );
35
- let e = /* @__PURE__ */ n(function(...s) {
36
- let l = M(e);
37
- l.called = !0, l.callCount++, l.calls.push(s);
38
- let p = l.next.shift();
39
- if (p) {
40
- l.results.push(p);
41
- let [c, y] = p;
42
- if (c === "ok")
43
- return y;
44
- throw y;
45
- }
46
- let i, f = "ok", a = l.results.length;
47
- if (l.impl)
48
- try {
49
- new.target ? i = Reflect.construct(l.impl, s, new.target) : i = l.impl.apply(this, s), f = "ok";
50
- } catch (c) {
51
- throw i = c, f = "error", l.results.push([f, c]), c;
52
- }
53
- let m = [f, i];
54
- return V(i) && i.then(
55
- (c) => l.resolves[a] = ["ok", c],
56
- (c) => l.resolves[a] = ["error", c]
57
- ), l.results.push(m), i;
58
- }, "t");
59
- h(e, "_isMockFunction", !0), h(e, "length", t ? t.length : 0), h(e, "name", t && t.name || "spy");
60
- let r = M(e);
61
- return r.reset(), r.impl = t, e;
62
- }
63
- n(K, "m");
64
- var R = /* @__PURE__ */ n((t, e) => Object.getOwnPropertyDescriptor(t, e), "k"), C = /* @__PURE__ */ n((t, e) => {
65
- e != null && typeof e == "function" && e.prototype != null && Object.setPrototypeOf(t.prototype, e.prototype);
66
- }, "O");
67
- function w(t, e, r) {
68
- T(
69
- !g("undefined", t),
70
- "spyOn could not find an object to spy upon"
71
- ), T(
72
- g("object", t) || g("function", t),
73
- "cannot spyOn on a primitive value"
74
- );
75
- let [s, l] = (() => {
76
- if (!g("object", e))
77
- return [e, "value"];
78
- if ("getter" in e && "setter" in e)
79
- throw new Error("cannot spy on both getter and setter");
80
- if ("getter" in e)
81
- return [e.getter, "get"];
82
- if ("setter" in e)
83
- return [e.setter, "set"];
84
- throw new Error("specify getter or setter to spy on");
85
- })(), p = R(t, s), i = Object.getPrototypeOf(t), f = i && R(i, s), a = p || f;
86
- T(
87
- a || s in t,
88
- `${String(s)} does not exist`
89
- );
90
- let m = !1;
91
- l === "value" && a && !a.value && a.get && (l = "get", m = !0, r = a.get());
92
- let c;
93
- a ? c = a[l] : l !== "value" ? c = /* @__PURE__ */ n(() => t[s], "o") : c = t[s];
94
- let y = /* @__PURE__ */ n((k) => {
95
- let { value: x, ...d } = a || {
96
- configurable: !0,
97
- writable: !0
98
- };
99
- l !== "value" && delete d.writable, d[l] = k, S(t, s, d);
100
- }, "g"), b = /* @__PURE__ */ n(() => a ? S(t, s, a) : y(c), "b");
101
- r || (r = c);
102
- let o = K(r);
103
- l === "value" && C(o, c);
104
- let u = o[O];
105
- return h(u, "restore", b), h(u, "getOriginal", () => m ? c() : c), h(u, "willCall", (k) => (u.impl = k, o)), y(
106
- m ? () => (C(o, r), o) : o
107
- ), A.add(o), o;
108
- }
109
- n(w, "C");
110
-
111
- // ../node_modules/@vitest/spy/dist/index.js
112
- var v = /* @__PURE__ */ new Set();
113
- function B(t) {
114
- return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
115
- }
116
- n(B, "isMockFunction");
117
- function E(t, e, r) {
118
- let l = r ? { [{
119
- get: "getter",
120
- set: "setter"
121
- }[r]]: e } : e, p = w(t, l);
122
- return j(p);
123
- }
124
- n(E, "spyOn");
125
- var U = 0;
126
- function j(t) {
127
- let e = t, r, s = [], l = [], p = [], i = M(t), f = {
128
- get calls() {
129
- return i.calls;
130
- },
131
- get contexts() {
132
- return l;
133
- },
134
- get instances() {
135
- return s;
136
- },
137
- get invocationCallOrder() {
138
- return p;
139
- },
140
- get results() {
141
- return i.results.map(([o, u]) => ({ type: o === "error" ? "throw" : "return", value: u }));
142
- },
143
- get settledResults() {
144
- return i.resolves.map(([o, u]) => ({ type: o === "error" ? "rejected" : "fulfilled", value: u }));
145
- },
146
- get lastCall() {
147
- return i.calls[i.calls.length - 1];
148
- }
149
- }, a = [], m = !1;
150
- function c(...o) {
151
- return s.push(this), l.push(this), p.push(++U), (m ? r : a.shift() || r || i.getOriginal() || (() => {
152
- })).apply(this, o);
153
- }
154
- n(c, "mockCall");
155
- let y = e.name;
156
- e.getMockName = () => y || "vi.fn()", e.mockName = (o) => (y = o, e), e.mockClear = () => (i.reset(), s = [], l = [], p = [], e), e.mockReset =
157
- () => (e.mockClear(), r = void 0, a = [], e), e.mockRestore = () => (e.mockReset(), i.restore(), e), e.getMockImplementation = () => m ? r :
158
- a.at(0) || r, e.mockImplementation = (o) => (r = o, i.willCall(c), e), e.mockImplementationOnce = (o) => (a.push(o), e);
159
- function b(o, u) {
160
- let k = r;
161
- r = o, i.willCall(c), m = !0;
162
- let x = /* @__PURE__ */ n(() => {
163
- r = k, m = !1;
164
- }, "reset"), d = u();
165
- return d instanceof Promise ? d.then(() => (x(), e)) : (x(), e);
166
- }
167
- return n(b, "withImplementation"), e.withImplementation = b, e.mockReturnThis = () => e.mockImplementation(function() {
168
- return this;
169
- }), e.mockReturnValue = (o) => e.mockImplementation(() => o), e.mockReturnValueOnce = (o) => e.mockImplementationOnce(() => o), e.mockResolvedValue =
170
- (o) => e.mockImplementation(() => Promise.resolve(o)), e.mockResolvedValueOnce = (o) => e.mockImplementationOnce(() => Promise.resolve(o)),
171
- e.mockRejectedValue = (o) => e.mockImplementation(() => Promise.reject(o)), e.mockRejectedValueOnce = (o) => e.mockImplementationOnce(() => Promise.
172
- reject(o)), Object.defineProperty(e, "mock", {
173
- get: /* @__PURE__ */ n(() => f, "get")
174
- }), i.willCall(c), v.add(e), e;
175
- }
176
- n(j, "enhanceSpy");
177
- function P(t) {
178
- let e = j(w({
179
- spy: t || function() {
180
- }
181
- }, "spy"));
182
- return t && e.mockImplementation(t), e;
183
- }
184
- n(P, "fn");
185
-
186
- // src/test/spy.ts
187
- var I = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
188
- globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = I;
189
- function H(t) {
190
- return I.add(t), () => void I.delete(t);
191
- }
192
- n(H, "onMockCall");
193
- var J = /* @__PURE__ */ n((...t) => {
194
- let e = E(...t);
195
- return F(e);
196
- }, "spyOn");
197
- function Q(t) {
198
- let e = t ? P(t) : P();
199
- return F(e);
200
- }
201
- n(Q, "fn");
202
- function F(t) {
203
- let e = D(t), r = e.mockImplementation.bind(null);
204
- return e.mockImplementation = (s) => D(r(s)), e;
205
- }
206
- n(F, "reactiveMock");
207
- function D(t) {
208
- let e = M(t), r = e.impl;
209
- return e.willCall(function(...s) {
210
- return I.forEach((l) => l(t, s)), r?.apply(this, s);
211
- }), t;
212
- }
213
- n(D, "listenWhenCalled");
214
- function X() {
215
- v.forEach((t) => t.mockClear());
216
- }
217
- n(X, "clearAllMocks");
218
- function Z() {
219
- v.forEach((t) => t.mockReset());
220
- }
221
- n(Z, "resetAllMocks");
222
- function ee() {
223
- v.forEach((t) => t.mockRestore());
224
- }
225
- n(ee, "restoreAllMocks");
226
- function te(t, e = {}) {
227
- return t;
228
- }
229
- n(te, "mocked");
230
- export {
231
- X as clearAllMocks,
232
- Q as fn,
233
- B as isMockFunction,
234
- te as mocked,
235
- v as mocks,
236
- H as onMockCall,
237
- Z as resetAllMocks,
238
- ee as restoreAllMocks,
239
- J as spyOn
240
- };