storybook 9.0.0-beta.1 → 9.0.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/assets/server/base-preview-head.html +2 -1
  2. package/dist/actions/decorator.js +49 -52
  3. package/dist/actions/index.cjs +42 -44
  4. package/dist/actions/index.js +37 -40
  5. package/dist/actions/preview.cjs +44 -46
  6. package/dist/actions/preview.d.ts +501 -0
  7. package/dist/actions/preview.js +24 -27
  8. package/dist/babel/index.cjs +15060 -14974
  9. package/dist/babel/index.d.ts +37 -18
  10. package/dist/babel/index.js +15097 -15011
  11. package/dist/backgrounds/index.d.ts +501 -0
  12. package/dist/backgrounds/preview.d.ts +501 -0
  13. package/dist/bin/index.cjs +44 -44
  14. package/dist/bin/index.js +44 -44
  15. package/dist/builder-manager/index.cjs +303 -283
  16. package/dist/builder-manager/index.js +545 -524
  17. package/dist/channels/index.js +919 -941
  18. package/dist/cli/bin/index.cjs +4184 -736
  19. package/dist/cli/bin/index.js +4198 -748
  20. package/dist/cli/index.cjs +36838 -28392
  21. package/dist/cli/index.d.ts +974 -1
  22. package/dist/cli/index.js +41620 -33168
  23. package/dist/client-logger/index.d.ts +2 -1
  24. package/dist/common/index.cjs +4783 -4691
  25. package/dist/common/index.d.ts +8 -2
  26. package/dist/common/index.js +5165 -5069
  27. package/dist/components/index.cjs +7905 -5600
  28. package/dist/components/index.d.ts +12 -12
  29. package/dist/components/index.js +4713 -3786
  30. package/dist/controls/preview.d.ts +501 -0
  31. package/dist/core-server/index.cjs +6799 -6708
  32. package/dist/core-server/index.d.ts +526 -25
  33. package/dist/core-server/index.js +6948 -6851
  34. package/dist/core-server/presets/common-manager.js +4528 -3377
  35. package/dist/core-server/presets/common-override-preset.cjs +10 -12
  36. package/dist/core-server/presets/common-override-preset.js +3 -5
  37. package/dist/core-server/presets/common-preset.cjs +2301 -2238
  38. package/dist/core-server/presets/common-preset.js +2389 -2322
  39. package/dist/docs-tools/index.cjs +484 -464
  40. package/dist/docs-tools/index.js +781 -768
  41. package/dist/highlight/index.cjs +19 -18
  42. package/dist/highlight/index.d.ts +4 -5
  43. package/dist/highlight/index.js +3 -2
  44. package/dist/highlight/preview.cjs +314 -310
  45. package/dist/highlight/preview.d.ts +501 -0
  46. package/dist/highlight/preview.js +296 -292
  47. package/dist/instrumenter/index.cjs +561 -559
  48. package/dist/instrumenter/index.js +1564 -1516
  49. package/dist/manager/globals-module-info.cjs +2 -0
  50. package/dist/manager/globals-module-info.js +2 -0
  51. package/dist/manager/globals-runtime.js +23602 -23339
  52. package/dist/manager/runtime.js +4891 -4650
  53. package/dist/manager-api/index.cjs +2400 -2321
  54. package/dist/manager-api/index.d.ts +513 -1
  55. package/dist/manager-api/index.js +1951 -1903
  56. package/dist/manager-errors.js +37 -41
  57. package/dist/measure/index.d.ts +501 -0
  58. package/dist/measure/preview.d.ts +501 -0
  59. package/dist/node-logger/index.cjs +25 -25
  60. package/dist/node-logger/index.js +25 -25
  61. package/dist/outline/index.d.ts +501 -0
  62. package/dist/outline/preview.d.ts +501 -0
  63. package/dist/preview/runtime.js +35803 -35785
  64. package/dist/preview-api/index.cjs +1287 -1265
  65. package/dist/preview-api/index.d.ts +1 -1
  66. package/dist/preview-api/index.js +1367 -1361
  67. package/dist/preview-errors.js +152 -173
  68. package/dist/router/index.cjs +5674 -2282
  69. package/dist/router/index.d.ts +622 -243
  70. package/dist/router/index.js +1318 -872
  71. package/dist/server-errors.cjs +192 -177
  72. package/dist/server-errors.d.ts +11 -1
  73. package/dist/server-errors.js +173 -158
  74. package/dist/telemetry/index.cjs +4934 -1445
  75. package/dist/telemetry/index.d.ts +2 -1
  76. package/dist/telemetry/index.js +4966 -1475
  77. package/dist/test/index.cjs +1876 -1878
  78. package/dist/test/index.d.ts +1269 -83
  79. package/dist/test/index.js +9157 -9248
  80. package/dist/test/preview.cjs +49 -15862
  81. package/dist/test/preview.d.ts +520 -13
  82. package/dist/test/preview.js +42 -14493
  83. package/dist/theming/create.cjs +2244 -79
  84. package/dist/theming/create.js +951 -67
  85. package/dist/theming/index.cjs +3209 -1067
  86. package/dist/theming/index.js +1816 -947
  87. package/dist/types/index.cjs +4 -4
  88. package/dist/types/index.d.ts +3124 -2596
  89. package/dist/viewport/index.d.ts +502 -3
  90. package/dist/viewport/preview.d.ts +501 -0
  91. package/package.json +14 -38
  92. package/dist/test/spy.cjs +0 -258
  93. package/dist/test/spy.d.ts +0 -66
  94. package/dist/test/spy.js +0 -240
package/dist/test/spy.cjs DELETED
@@ -1,258 +0,0 @@
1
- "use strict";
2
- var v = Object.defineProperty;
3
- var L = Object.getOwnPropertyDescriptor;
4
- var Y = Object.getOwnPropertyNames;
5
- var N = Object.prototype.hasOwnProperty;
6
- var n = (t, e) => v(t, "name", { value: e, configurable: !0 });
7
- var K = (t, e) => {
8
- for (var r in e)
9
- v(t, r, { get: e[r], enumerable: !0 });
10
- }, B = (t, e, r, l) => {
11
- if (e && typeof e == "object" || typeof e == "function")
12
- for (let o of Y(e))
13
- !N.call(t, o) && o !== r && v(t, o, { get: () => e[o], enumerable: !(l = L(e, o)) || l.enumerable });
14
- return t;
15
- };
16
- var U = (t) => B(v({}, "__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: () => h,
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 O(t, e) {
35
- if (!t)
36
- throw new Error(e);
37
- }
38
- n(O, "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 S(t, e, r) {
48
- Object.defineProperty(t, e, r);
49
- }
50
- n(S, "f");
51
- function M(t, e, r) {
52
- Object.defineProperty(t, e, { value: r });
53
- }
54
- n(M, "l");
55
- var x = 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) => (S(t, x, { value: { reset: /* @__PURE__ */ n(() => q(t[x]), "reset") } }), t[x]), "K"), T = /* @__PURE__ */ n(
58
- (t) => t[x] || z(t), "T");
59
- function G(t) {
60
- O(
61
- g("function", t) || g("undefined", t),
62
- "cannot spy on a non-function value"
63
- );
64
- let e = /* @__PURE__ */ n(function(...l) {
65
- let o = T(e);
66
- o.called = !0, o.callCount++, o.calls.push(l);
67
- let p = o.next.shift();
68
- if (p) {
69
- o.results.push(p);
70
- let [i, f] = p;
71
- if (i === "ok")
72
- return f;
73
- throw f;
74
- }
75
- let c, y = "ok", a = o.results.length;
76
- if (o.impl)
77
- try {
78
- new.target ? c = Reflect.construct(o.impl, l, new.target) : c = o.impl.apply(this, l), y = "ok";
79
- } catch (i) {
80
- throw c = i, y = "error", o.results.push([y, i]), i;
81
- }
82
- let m = [y, c];
83
- return W(c) && c.then(
84
- (i) => o.resolves[a] = ["ok", i],
85
- (i) => o.resolves[a] = ["error", i]
86
- ), o.results.push(m), c;
87
- }, "t");
88
- M(e, "_isMockFunction", !0), M(e, "length", t ? t.length : 0), M(e, "name", t && t.name || "spy");
89
- let r = T(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 w(t, e, r) {
97
- O(
98
- !g("undefined", t),
99
- "spyOn could not find an object to spy upon"
100
- ), O(
101
- g("object", t) || g("function", t),
102
- "cannot spyOn on a primitive value"
103
- );
104
- let [l, 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, l), c = Object.getPrototypeOf(t), y = c && C(c, l), a = p || y;
115
- O(
116
- a || l in t,
117
- `${String(l)} 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 i;
122
- a ? i = a[o] : o !== "value" ? i = /* @__PURE__ */ n(() => t[l], "o") : i = t[l];
123
- let f = /* @__PURE__ */ n((k) => {
124
- let { value: R, ...d } = a || {
125
- configurable: !0,
126
- writable: !0
127
- };
128
- o !== "value" && delete d.writable, d[o] = k, S(t, l, d);
129
- }, "g"), b = /* @__PURE__ */ n(() => a ? S(t, l, a) : f(i), "b");
130
- r || (r = i);
131
- let s = G(r);
132
- o === "value" && _(s, i);
133
- let u = s[x];
134
- return M(u, "restore", b), M(u, "getOriginal", () => m ? i() : i), M(u, "willCall", (k) => (u.impl = k, s)), f(
135
- m ? () => (_(s, r), s) : s
136
- ), $.add(s), s;
137
- }
138
- n(w, "C");
139
-
140
- // ../node_modules/@vitest/spy/dist/index.js
141
- var h = /* @__PURE__ */ new Set();
142
- function j(t) {
143
- return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
144
- }
145
- n(j, "isMockFunction");
146
- function A(t, e, r) {
147
- let o = r ? { [{
148
- get: "getter",
149
- set: "setter"
150
- }[r]]: e } : e, p = w(t, o);
151
- return V(p);
152
- }
153
- n(A, "spyOn");
154
- var H = 0;
155
- function V(t) {
156
- let e = t, r, l = [], o = [], p = [], c = T(t), y = {
157
- get calls() {
158
- return c.calls;
159
- },
160
- get contexts() {
161
- return o;
162
- },
163
- get instances() {
164
- return l;
165
- },
166
- get invocationCallOrder() {
167
- return p;
168
- },
169
- get results() {
170
- return c.results.map(([s, u]) => ({ type: s === "error" ? "throw" : "return", value: u }));
171
- },
172
- get settledResults() {
173
- return c.resolves.map(([s, u]) => ({ type: s === "error" ? "rejected" : "fulfilled", value: u }));
174
- },
175
- get lastCall() {
176
- return c.calls[c.calls.length - 1];
177
- }
178
- }, a = [], m = !1;
179
- function i(...s) {
180
- return l.push(this), o.push(this), p.push(++H), (m ? r : a.shift() || r || c.getOriginal() || (() => {
181
- })).apply(this, s);
182
- }
183
- n(i, "mockCall");
184
- let f = e.name;
185
- e.getMockName = () => f || "vi.fn()", e.mockName = (s) => (f = s, e), e.mockClear = () => (c.reset(), l = [], o = [], p = [], e), e.mockReset =
186
- () => (e.mockClear(), r = void 0, a = [], e), e.mockRestore = () => (e.mockReset(), c.restore(), e), e.getMockImplementation = () => m ? r :
187
- a.at(0) || r, e.mockImplementation = (s) => (r = s, c.willCall(i), e), e.mockImplementationOnce = (s) => (a.push(s), e);
188
- function b(s, u) {
189
- let k = r;
190
- r = s, c.willCall(i), m = !0;
191
- let R = /* @__PURE__ */ n(() => {
192
- r = k, m = !1;
193
- }, "reset"), d = u();
194
- return d instanceof Promise ? d.then(() => (R(), e)) : (R(), e);
195
- }
196
- return n(b, "withImplementation"), e.withImplementation = b, e.mockReturnThis = () => e.mockImplementation(function() {
197
- return this;
198
- }), e.mockReturnValue = (s) => e.mockImplementation(() => s), e.mockReturnValueOnce = (s) => e.mockImplementationOnce(() => s), e.mockResolvedValue =
199
- (s) => e.mockImplementation(() => Promise.resolve(s)), e.mockResolvedValueOnce = (s) => e.mockImplementationOnce(() => Promise.resolve(s)),
200
- e.mockRejectedValue = (s) => e.mockImplementation(() => Promise.reject(s)), e.mockRejectedValueOnce = (s) => e.mockImplementationOnce(() => Promise.
201
- reject(s)), Object.defineProperty(e, "mock", {
202
- get: /* @__PURE__ */ n(() => y, "get")
203
- }), c.willCall(i), h.add(e), e;
204
- }
205
- n(V, "enhanceSpy");
206
- function P(t) {
207
- let e = V(w({
208
- spy: t || function() {
209
- }
210
- }, "spy"));
211
- return t && e.mockImplementation(t), e;
212
- }
213
- n(P, "fn");
214
-
215
- // src/test/spy.ts
216
- var I = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
217
- globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = I;
218
- function J(t) {
219
- return I.add(t), () => void I.delete(t);
220
- }
221
- n(J, "onMockCall");
222
- var Q = /* @__PURE__ */ n((...t) => {
223
- let e = A(...t);
224
- return F(e);
225
- }, "spyOn");
226
- function X(t) {
227
- let e = t ? P(t) : P();
228
- return F(e);
229
- }
230
- n(X, "fn");
231
- function F(t) {
232
- let e = D(t), r = e.mockImplementation.bind(null);
233
- return e.mockImplementation = (l) => D(r(l)), e;
234
- }
235
- n(F, "reactiveMock");
236
- function D(t) {
237
- let e = T(t), r = e.impl;
238
- return e.willCall(function(...l) {
239
- return I.forEach((o) => o(t, l)), r?.apply(this, l);
240
- }), t;
241
- }
242
- n(D, "listenWhenCalled");
243
- function Z() {
244
- h.forEach((t) => t.mockClear());
245
- }
246
- n(Z, "clearAllMocks");
247
- function ee() {
248
- h.forEach((t) => t.mockReset());
249
- }
250
- n(ee, "resetAllMocks");
251
- function te() {
252
- h.forEach((t) => t.mockRestore());
253
- }
254
- n(te, "restoreAllMocks");
255
- function ne(t, e = {}) {
256
- return t;
257
- }
258
- n(ne, "mocked");
@@ -1,66 +0,0 @@
1
- import { MockInstance, spyOn as spyOn$1, Mock as Mock$1, 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
- type Mock<T extends Procedure | any[] = any[], R = any> = T extends Procedure ? Mock$1<T> : T extends any[] ? Mock$1<(...args: T) => R> : never;
10
- declare function fn<T extends Procedure = Procedure>(implementation?: T): Mock<T>;
11
- declare function fn<TArgs extends any[] = any, R = any>(): Mock<(...args: TArgs) => R>;
12
- declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<(...args: TArgs) => R>;
13
- declare function fn<TArgs extends any[] = any[], R = any>(implementation?: (...args: TArgs) => R): Mock<(...args: TArgs) => R>;
14
- /**
15
- * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will
16
- * only empty `.mock` state, it will not reset implementation.
17
- *
18
- * It is useful if you need to clean up mock between different assertions.
19
- */
20
- declare function clearAllMocks(): void;
21
- /**
22
- * Calls [`.mockReset()`](https://vitest.dev/api/mock#mockreset) on every mocked function. This will
23
- * empty `.mock` state, reset "once" implementations and force the base implementation to return
24
- * `undefined` when invoked.
25
- *
26
- * This is useful when you want to completely reset a mock to the default state.
27
- */
28
- declare function resetAllMocks(): void;
29
- /**
30
- * Calls [`.mockRestore()`](https://vitest.dev/api/mock#mockrestore) on every mocked function. This
31
- * will restore all original implementations.
32
- */
33
- declare function restoreAllMocks(): void;
34
- /**
35
- * Type helper for TypeScript. Just returns the object that was passed.
36
- *
37
- * When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will
38
- * only make TypeScript believe that the first level values are mocked. You can pass down `{ deep:
39
- * true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually
40
- * is.
41
- *
42
- * @param item Anything that can be mocked
43
- * @param deep If the object is deeply mocked
44
- * @param options If the object is partially or deeply mocked
45
- */
46
- declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
47
- declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
48
- declare function mocked<T>(item: T, options: {
49
- partial?: false;
50
- deep?: false;
51
- }): MaybeMocked<T>;
52
- declare function mocked<T>(item: T, options: {
53
- partial?: false;
54
- deep: true;
55
- }): MaybeMockedDeep<T>;
56
- declare function mocked<T>(item: T, options: {
57
- partial: true;
58
- deep?: false;
59
- }): MaybePartiallyMocked<T>;
60
- declare function mocked<T>(item: T, options: {
61
- partial: true;
62
- deep: true;
63
- }): MaybePartiallyMockedDeep<T>;
64
- declare function mocked<T>(item: T): MaybeMocked<T>;
65
-
66
- export { type Mock, clearAllMocks, fn, mocked, onMockCall, resetAllMocks, restoreAllMocks, spyOn };
package/dist/test/spy.js DELETED
@@ -1,240 +0,0 @@
1
- var D = Object.defineProperty;
2
- var n = (t, e) => D(t, "name", { value: e, configurable: !0 });
3
-
4
- // ../node_modules/tinyspy/dist/index.js
5
- function v(t, e) {
6
- if (!t)
7
- throw new Error(e);
8
- }
9
- n(v, "d");
10
- function g(t, e) {
11
- return typeof e === t;
12
- }
13
- n(g, "y");
14
- function F(t) {
15
- return t instanceof Promise;
16
- }
17
- n(F, "w");
18
- function R(t, e, r) {
19
- Object.defineProperty(t, e, r);
20
- }
21
- n(R, "f");
22
- function M(t, e, r) {
23
- Object.defineProperty(t, e, { value: r });
24
- }
25
- n(M, "l");
26
- var h = Symbol.for("tinyspy:spy"), L = /* @__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) => (R(t, h, { value: { reset: /* @__PURE__ */ n(() => Y(t[h]), "reset") } }), t[h]), "K"), T = /* @__PURE__ */ n(
29
- (t) => t[h] || N(t), "T");
30
- function K(t) {
31
- v(
32
- g("function", t) || g("undefined", t),
33
- "cannot spy on a non-function value"
34
- );
35
- let e = /* @__PURE__ */ n(function(...l) {
36
- let s = T(e);
37
- s.called = !0, s.callCount++, s.calls.push(l);
38
- let p = s.next.shift();
39
- if (p) {
40
- s.results.push(p);
41
- let [i, f] = p;
42
- if (i === "ok")
43
- return f;
44
- throw f;
45
- }
46
- let c, y = "ok", a = s.results.length;
47
- if (s.impl)
48
- try {
49
- new.target ? c = Reflect.construct(s.impl, l, new.target) : c = s.impl.apply(this, l), y = "ok";
50
- } catch (i) {
51
- throw c = i, y = "error", s.results.push([y, i]), i;
52
- }
53
- let m = [y, c];
54
- return F(c) && c.then(
55
- (i) => s.resolves[a] = ["ok", i],
56
- (i) => s.resolves[a] = ["error", i]
57
- ), s.results.push(m), c;
58
- }, "t");
59
- M(e, "_isMockFunction", !0), M(e, "length", t ? t.length : 0), M(e, "name", t && t.name || "spy");
60
- let r = T(e);
61
- return r.reset(), r.impl = t, e;
62
- }
63
- n(K, "m");
64
- var P = /* @__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 S(t, e, r) {
68
- v(
69
- !g("undefined", t),
70
- "spyOn could not find an object to spy upon"
71
- ), v(
72
- g("object", t) || g("function", t),
73
- "cannot spyOn on a primitive value"
74
- );
75
- let [l, s] = (() => {
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 = P(t, l), c = Object.getPrototypeOf(t), y = c && P(c, l), a = p || y;
86
- v(
87
- a || l in t,
88
- `${String(l)} does not exist`
89
- );
90
- let m = !1;
91
- s === "value" && a && !a.value && a.get && (s = "get", m = !0, r = a.get());
92
- let i;
93
- a ? i = a[s] : s !== "value" ? i = /* @__PURE__ */ n(() => t[l], "o") : i = t[l];
94
- let f = /* @__PURE__ */ n((k) => {
95
- let { value: b, ...d } = a || {
96
- configurable: !0,
97
- writable: !0
98
- };
99
- s !== "value" && delete d.writable, d[s] = k, R(t, l, d);
100
- }, "g"), I = /* @__PURE__ */ n(() => a ? R(t, l, a) : f(i), "b");
101
- r || (r = i);
102
- let o = K(r);
103
- s === "value" && C(o, i);
104
- let u = o[h];
105
- return M(u, "restore", I), M(u, "getOriginal", () => m ? i() : i), M(u, "willCall", (k) => (u.impl = k, o)), f(
106
- m ? () => (C(o, r), o) : o
107
- ), L.add(o), o;
108
- }
109
- n(S, "C");
110
-
111
- // ../node_modules/@vitest/spy/dist/index.js
112
- var x = /* @__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 s = r ? { [{
119
- get: "getter",
120
- set: "setter"
121
- }[r]]: e } : e, p = S(t, s);
122
- return j(p);
123
- }
124
- n(E, "spyOn");
125
- var U = 0;
126
- function j(t) {
127
- let e = t, r, l = [], s = [], p = [], c = T(t), y = {
128
- get calls() {
129
- return c.calls;
130
- },
131
- get contexts() {
132
- return s;
133
- },
134
- get instances() {
135
- return l;
136
- },
137
- get invocationCallOrder() {
138
- return p;
139
- },
140
- get results() {
141
- return c.results.map(([o, u]) => ({ type: o === "error" ? "throw" : "return", value: u }));
142
- },
143
- get settledResults() {
144
- return c.resolves.map(([o, u]) => ({ type: o === "error" ? "rejected" : "fulfilled", value: u }));
145
- },
146
- get lastCall() {
147
- return c.calls[c.calls.length - 1];
148
- }
149
- }, a = [], m = !1;
150
- function i(...o) {
151
- return l.push(this), s.push(this), p.push(++U), (m ? r : a.shift() || r || c.getOriginal() || (() => {
152
- })).apply(this, o);
153
- }
154
- n(i, "mockCall");
155
- let f = e.name;
156
- e.getMockName = () => f || "vi.fn()", e.mockName = (o) => (f = o, e), e.mockClear = () => (c.reset(), l = [], s = [], p = [], e), e.mockReset =
157
- () => (e.mockClear(), r = void 0, a = [], e), e.mockRestore = () => (e.mockReset(), c.restore(), e), e.getMockImplementation = () => m ? r :
158
- a.at(0) || r, e.mockImplementation = (o) => (r = o, c.willCall(i), e), e.mockImplementationOnce = (o) => (a.push(o), e);
159
- function I(o, u) {
160
- let k = r;
161
- r = o, c.willCall(i), m = !0;
162
- let b = /* @__PURE__ */ n(() => {
163
- r = k, m = !1;
164
- }, "reset"), d = u();
165
- return d instanceof Promise ? d.then(() => (b(), e)) : (b(), e);
166
- }
167
- return n(I, "withImplementation"), e.withImplementation = I, 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(() => y, "get")
174
- }), c.willCall(i), x.add(e), e;
175
- }
176
- n(j, "enhanceSpy");
177
- function w(t) {
178
- let e = j(S({
179
- spy: t || function() {
180
- }
181
- }, "spy"));
182
- return t && e.mockImplementation(t), e;
183
- }
184
- n(w, "fn");
185
-
186
- // src/test/spy.ts
187
- var O = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
188
- globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = O;
189
- function H(t) {
190
- return O.add(t), () => void O.delete(t);
191
- }
192
- n(H, "onMockCall");
193
- var J = /* @__PURE__ */ n((...t) => {
194
- let e = E(...t);
195
- return V(e);
196
- }, "spyOn");
197
- function Q(t) {
198
- let e = t ? w(t) : w();
199
- return V(e);
200
- }
201
- n(Q, "fn");
202
- function V(t) {
203
- let e = A(t), r = e.mockImplementation.bind(null);
204
- return e.mockImplementation = (l) => A(r(l)), e;
205
- }
206
- n(V, "reactiveMock");
207
- function A(t) {
208
- let e = T(t), r = e.impl;
209
- return e.willCall(function(...l) {
210
- return O.forEach((s) => s(t, l)), r?.apply(this, l);
211
- }), t;
212
- }
213
- n(A, "listenWhenCalled");
214
- function X() {
215
- x.forEach((t) => t.mockClear());
216
- }
217
- n(X, "clearAllMocks");
218
- function Z() {
219
- x.forEach((t) => t.mockReset());
220
- }
221
- n(Z, "resetAllMocks");
222
- function ee() {
223
- x.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
- x as mocks,
236
- H as onMockCall,
237
- Z as resetAllMocks,
238
- ee as restoreAllMocks,
239
- J as spyOn
240
- };