storybook 9.0.0-alpha.2 → 9.0.0-alpha.20

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 (159) hide show
  1. package/README.md +1 -1
  2. package/assets/docs/addon-backgrounds.gif +0 -0
  3. package/assets/docs/addon-controls-args-annotated.png +0 -0
  4. package/assets/docs/addon-controls-args-background-color.png +0 -0
  5. package/assets/docs/addon-controls-args-background-string.png +0 -0
  6. package/assets/docs/addon-controls-args-docs.png +0 -0
  7. package/assets/docs/addon-controls-args-logging.png +0 -0
  8. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  9. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  10. package/assets/docs/addon-controls-args-reflow.png +0 -0
  11. package/assets/docs/addon-controls-args-template.png +0 -0
  12. package/assets/docs/addon-controls-expanded.png +0 -0
  13. package/assets/docs/addon-controls-hero.gif +0 -0
  14. package/assets/docs/addon-controls-install.png +0 -0
  15. package/assets/docs/hero.gif +0 -0
  16. package/assets/docs/highlight.png +0 -0
  17. package/assets/docs/viewport.png +0 -0
  18. package/bin/index.cjs +2 -2
  19. package/dist/actions/decorator.d.ts +6 -0
  20. package/dist/actions/decorator.js +138 -0
  21. package/dist/actions/index.cjs +126 -0
  22. package/dist/actions/index.d.ts +102 -0
  23. package/dist/actions/index.js +111 -0
  24. package/dist/actions/preview.cjs +164 -0
  25. package/dist/actions/preview.d.ts +54 -0
  26. package/dist/actions/preview.js +155 -0
  27. package/dist/backgrounds/index.cjs +148 -0
  28. package/dist/backgrounds/index.d.ts +91 -0
  29. package/dist/backgrounds/index.js +130 -0
  30. package/dist/backgrounds/preview.cjs +143 -0
  31. package/dist/backgrounds/preview.d.ts +54 -0
  32. package/dist/backgrounds/preview.js +127 -0
  33. package/dist/bin/index.cjs +66 -89
  34. package/dist/bin/index.js +62 -85
  35. package/dist/builder-manager/index.cjs +523 -540
  36. package/dist/builder-manager/index.js +544 -561
  37. package/dist/channels/index.cjs +1026 -981
  38. package/dist/channels/index.js +1194 -1165
  39. package/dist/cli/bin/index.cjs +483 -483
  40. package/dist/cli/bin/index.js +495 -495
  41. package/dist/cli/index.cjs +2279 -2295
  42. package/dist/cli/index.d.ts +4 -8
  43. package/dist/cli/index.js +740 -756
  44. package/dist/client-logger/index.cjs +56 -88
  45. package/dist/client-logger/index.js +41 -47
  46. package/dist/common/index.cjs +2496 -2480
  47. package/dist/common/index.d.ts +5 -29
  48. package/dist/common/index.js +2679 -2663
  49. package/dist/component-testing/index.cjs +23 -0
  50. package/dist/component-testing/index.d.ts +3 -0
  51. package/dist/component-testing/index.js +5 -0
  52. package/dist/component-testing/preview.cjs +40 -0
  53. package/dist/component-testing/preview.d.ts +5 -0
  54. package/dist/component-testing/preview.js +25 -0
  55. package/dist/components/index.cjs +11709 -20418
  56. package/dist/components/index.d.ts +94 -346
  57. package/dist/components/index.js +5827 -19157
  58. package/dist/controls/decorator.d.ts +5 -0
  59. package/dist/controls/decorator.js +8 -0
  60. package/dist/controls/index.cjs +26 -0
  61. package/dist/controls/index.d.ts +39 -0
  62. package/dist/controls/index.js +6 -0
  63. package/dist/controls/preview.cjs +26 -0
  64. package/dist/controls/preview.d.ts +54 -0
  65. package/dist/controls/preview.js +9 -0
  66. package/dist/core-events/index.cjs +91 -106
  67. package/dist/core-events/index.d.ts +139 -104
  68. package/dist/core-events/index.js +79 -94
  69. package/dist/core-server/index.cjs +14413 -13924
  70. package/dist/core-server/index.d.ts +270 -3
  71. package/dist/core-server/index.js +14003 -13519
  72. package/dist/core-server/presets/common-manager.css +170 -0
  73. package/dist/core-server/presets/common-manager.js +12099 -17
  74. package/dist/core-server/presets/common-preset.cjs +2760 -2914
  75. package/dist/core-server/presets/common-preset.js +2852 -3007
  76. package/dist/csf/index.cjs +76 -120
  77. package/dist/csf/index.d.ts +2 -6
  78. package/dist/csf/index.js +69 -113
  79. package/dist/csf-tools/index.cjs +412 -403
  80. package/dist/csf-tools/index.d.ts +0 -4
  81. package/dist/csf-tools/index.js +410 -401
  82. package/dist/docs-tools/index.cjs +2569 -575
  83. package/dist/docs-tools/index.d.ts +2 -2
  84. package/dist/docs-tools/index.js +2557 -564
  85. package/dist/highlight/index.cjs +27 -0
  86. package/dist/highlight/index.d.ts +17 -0
  87. package/dist/highlight/index.js +7 -0
  88. package/dist/highlight/preview.cjs +81 -0
  89. package/dist/highlight/preview.d.ts +54 -0
  90. package/dist/highlight/preview.js +67 -0
  91. package/dist/instrumenter/index.cjs +2207 -2342
  92. package/dist/instrumenter/index.d.ts +8 -7
  93. package/dist/instrumenter/index.js +2438 -2620
  94. package/dist/manager/globals-module-info.cjs +290 -151
  95. package/dist/manager/globals-module-info.d.ts +1 -1
  96. package/dist/manager/globals-module-info.js +274 -135
  97. package/dist/manager/globals-runtime.js +60016 -28331
  98. package/dist/manager/globals.cjs +23 -19
  99. package/dist/manager/globals.d.ts +8 -5
  100. package/dist/manager/globals.js +10 -6
  101. package/dist/manager/runtime.js +4645 -3946
  102. package/dist/manager-api/index.cjs +4228 -3833
  103. package/dist/manager-api/index.d.ts +398 -102
  104. package/dist/manager-api/index.js +3676 -3291
  105. package/dist/manager-errors.d.ts +25 -1
  106. package/dist/manager-errors.js +42 -26
  107. package/dist/measure/index.cjs +474 -0
  108. package/dist/measure/index.d.ts +66 -0
  109. package/dist/measure/index.js +462 -0
  110. package/dist/measure/preview.cjs +464 -0
  111. package/dist/measure/preview.d.ts +59 -0
  112. package/dist/measure/preview.js +448 -0
  113. package/dist/outline/index.cjs +528 -0
  114. package/dist/outline/index.d.ts +66 -0
  115. package/dist/outline/index.js +500 -0
  116. package/dist/outline/preview.cjs +518 -0
  117. package/dist/outline/preview.d.ts +59 -0
  118. package/dist/outline/preview.js +486 -0
  119. package/dist/preview/globals.cjs +21 -17
  120. package/dist/preview/globals.d.ts +4 -1
  121. package/dist/preview/globals.js +6 -2
  122. package/dist/preview/runtime.js +45697 -6618
  123. package/dist/preview-api/index.cjs +1363 -1898
  124. package/dist/preview-api/index.d.ts +449 -498
  125. package/dist/preview-api/index.js +1622 -2095
  126. package/dist/preview-errors.cjs +99 -82
  127. package/dist/preview-errors.d.ts +25 -1
  128. package/dist/preview-errors.js +110 -94
  129. package/dist/router/index.cjs +847 -871
  130. package/dist/router/index.js +193 -199
  131. package/dist/server-errors.cjs +156 -125
  132. package/dist/server-errors.d.ts +28 -2
  133. package/dist/server-errors.js +150 -119
  134. package/dist/telemetry/index.cjs +1050 -1977
  135. package/dist/telemetry/index.d.ts +26 -5
  136. package/dist/telemetry/index.js +1085 -2008
  137. package/dist/test/index.cjs +35686 -0
  138. package/dist/test/index.d.ts +186 -0
  139. package/dist/test/index.js +33752 -0
  140. package/dist/test/preview.cjs +15870 -0
  141. package/dist/test/preview.d.ts +54 -0
  142. package/dist/test/preview.js +14441 -0
  143. package/dist/test/spy.cjs +258 -0
  144. package/dist/test/spy.d.ts +66 -0
  145. package/dist/test/spy.js +240 -0
  146. package/dist/theming/create.cjs +79 -2269
  147. package/dist/theming/create.js +67 -841
  148. package/dist/theming/index.cjs +1065 -3232
  149. package/dist/theming/index.js +951 -1719
  150. package/dist/types/index.cjs +11 -12
  151. package/dist/types/index.d.ts +612 -157
  152. package/dist/types/index.js +1 -2
  153. package/dist/viewport/index.cjs +310 -0
  154. package/dist/viewport/index.d.ts +320 -0
  155. package/dist/viewport/index.js +290 -0
  156. package/dist/viewport/preview.cjs +35 -0
  157. package/dist/viewport/preview.d.ts +68 -0
  158. package/dist/viewport/preview.js +19 -0
  159. package/package.json +359 -12
@@ -0,0 +1,258 @@
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");
@@ -0,0 +1,66 @@
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 };
@@ -0,0 +1,240 @@
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
+ };