storybook 9.0.0-beta.6 → 9.0.0-beta.8

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 (39) hide show
  1. package/dist/bin/index.cjs +44 -44
  2. package/dist/bin/index.js +44 -44
  3. package/dist/cli/bin/index.cjs +4184 -737
  4. package/dist/cli/bin/index.js +4198 -749
  5. package/dist/cli/index.cjs +25090 -21638
  6. package/dist/cli/index.d.ts +974 -1
  7. package/dist/cli/index.js +25330 -21876
  8. package/dist/common/index.cjs +4518 -4511
  9. package/dist/common/index.d.ts +7 -2
  10. package/dist/common/index.js +4528 -4521
  11. package/dist/core-server/index.cjs +3240 -3235
  12. package/dist/core-server/index.d.ts +22 -22
  13. package/dist/core-server/index.js +1288 -1283
  14. package/dist/core-server/presets/common-preset.cjs +1445 -1444
  15. package/dist/core-server/presets/common-preset.js +418 -417
  16. package/dist/manager/globals-runtime.js +8188 -8165
  17. package/dist/manager/runtime.js +1151 -1149
  18. package/dist/manager-api/index.cjs +1046 -1023
  19. package/dist/manager-api/index.d.ts +12 -1
  20. package/dist/manager-api/index.js +649 -626
  21. package/dist/preview/runtime.js +5389 -5388
  22. package/dist/preview-api/index.cjs +615 -614
  23. package/dist/preview-api/index.js +532 -531
  24. package/dist/server-errors.cjs +186 -171
  25. package/dist/server-errors.d.ts +11 -1
  26. package/dist/server-errors.js +167 -152
  27. package/dist/telemetry/index.cjs +4887 -1403
  28. package/dist/telemetry/index.d.ts +2 -1
  29. package/dist/telemetry/index.js +4923 -1437
  30. package/dist/test/index.d.ts +2 -6
  31. package/dist/test/index.js +2818 -2818
  32. package/dist/test/preview.cjs +648 -648
  33. package/dist/test/preview.js +837 -837
  34. package/dist/test/spy.cjs +112 -112
  35. package/dist/test/spy.d.ts +2 -6
  36. package/dist/test/spy.js +104 -104
  37. package/dist/types/index.cjs +4 -4
  38. package/dist/types/index.d.ts +2687 -2594
  39. package/package.json +3 -2
package/dist/test/spy.cjs CHANGED
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
- var v = Object.defineProperty;
3
- var L = Object.getOwnPropertyDescriptor;
2
+ var T = Object.defineProperty;
3
+ var A = Object.getOwnPropertyDescriptor;
4
4
  var Y = Object.getOwnPropertyNames;
5
5
  var N = Object.prototype.hasOwnProperty;
6
- var n = (t, e) => v(t, "name", { value: e, configurable: !0 });
6
+ var n = (t, e) => T(t, "name", { value: e, configurable: !0 });
7
7
  var K = (t, e) => {
8
8
  for (var r in e)
9
- v(t, r, { get: e[r], enumerable: !0 });
10
- }, B = (t, e, r, l) => {
9
+ T(t, r, { get: e[r], enumerable: !0 });
10
+ }, B = (t, e, r, s) => {
11
11
  if (e && typeof e == "object" || typeof e == "function")
12
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 });
13
+ !N.call(t, o) && o !== r && T(t, o, { get: () => e[o], enumerable: !(s = A(e, o)) || s.enumerable });
14
14
  return t;
15
15
  };
16
- var U = (t) => B(v({}, "__esModule", { value: !0 }), t);
16
+ var U = (t) => B(T({}, "__esModule", { value: !0 }), t);
17
17
 
18
18
  // src/test/spy.ts
19
19
  var oe = {};
@@ -22,7 +22,7 @@ K(oe, {
22
22
  fn: () => X,
23
23
  isMockFunction: () => j,
24
24
  mocked: () => ne,
25
- mocks: () => h,
25
+ mocks: () => O,
26
26
  onMockCall: () => J,
27
27
  resetAllMocks: () => ee,
28
28
  restoreAllMocks: () => te,
@@ -31,11 +31,11 @@ K(oe, {
31
31
  module.exports = U(oe);
32
32
 
33
33
  // ../node_modules/tinyspy/dist/index.js
34
- function O(t, e) {
34
+ function I(t, e) {
35
35
  if (!t)
36
36
  throw new Error(e);
37
37
  }
38
- n(O, "d");
38
+ n(I, "d");
39
39
  function g(t, e) {
40
40
  return typeof e === t;
41
41
  }
@@ -44,64 +44,64 @@ function W(t) {
44
44
  return t instanceof Promise;
45
45
  }
46
46
  n(W, "w");
47
- function S(t, e, r) {
47
+ function w(t, e, r) {
48
48
  Object.defineProperty(t, e, r);
49
49
  }
50
- n(S, "f");
51
- function M(t, e, r) {
50
+ n(w, "f");
51
+ function h(t, e, r) {
52
52
  Object.defineProperty(t, e, { value: r });
53
53
  }
54
- n(M, "l");
55
- var x = Symbol.for("tinyspy:spy"), $ = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ n((t) => {
54
+ n(h, "l");
55
+ var v = Symbol.for("tinyspy:spy"), $ = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ n((t) => {
56
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");
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
59
  function G(t) {
60
- O(
60
+ I(
61
61
  g("function", t) || g("undefined", t),
62
62
  "cannot spy on a non-function value"
63
63
  );
64
- let e = /* @__PURE__ */ n(function(...l) {
65
- let o = T(e);
66
- o.called = !0, o.callCount++, o.calls.push(l);
64
+ let e = /* @__PURE__ */ n(function(...s) {
65
+ let o = M(e);
66
+ o.called = !0, o.callCount++, o.calls.push(s);
67
67
  let p = o.next.shift();
68
68
  if (p) {
69
69
  o.results.push(p);
70
- let [i, f] = p;
71
- if (i === "ok")
72
- return f;
73
- throw f;
70
+ let [c, y] = p;
71
+ if (c === "ok")
72
+ return y;
73
+ throw y;
74
74
  }
75
- let c, y = "ok", a = o.results.length;
75
+ let i, f = "ok", a = o.results.length;
76
76
  if (o.impl)
77
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;
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
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;
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
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);
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
90
  return r.reset(), r.impl = t, e;
91
91
  }
92
92
  n(G, "m");
93
93
  var C = /* @__PURE__ */ n((t, e) => Object.getOwnPropertyDescriptor(t, e), "k"), _ = /* @__PURE__ */ n((t, e) => {
94
94
  e != null && typeof e == "function" && e.prototype != null && Object.setPrototypeOf(t.prototype, e.prototype);
95
95
  }, "O");
96
- function w(t, e, r) {
97
- O(
96
+ function P(t, e, r) {
97
+ I(
98
98
  !g("undefined", t),
99
99
  "spyOn could not find an object to spy upon"
100
- ), O(
100
+ ), I(
101
101
  g("object", t) || g("function", t),
102
102
  "cannot spyOn on a primitive value"
103
103
  );
104
- let [l, o] = (() => {
104
+ let [s, o] = (() => {
105
105
  if (!g("object", e))
106
106
  return [e, "value"];
107
107
  if ("getter" in e && "setter" in e)
@@ -111,145 +111,145 @@ function w(t, e, r) {
111
111
  if ("setter" in e)
112
112
  return [e.setter, "set"];
113
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`
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
118
  );
119
119
  let m = !1;
120
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 || {
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
125
  configurable: !0,
126
126
  writable: !0
127
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;
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
137
  }
138
- n(w, "C");
138
+ n(P, "C");
139
139
 
140
140
  // ../node_modules/@vitest/spy/dist/index.js
141
- var h = /* @__PURE__ */ new Set();
141
+ var O = /* @__PURE__ */ new Set();
142
142
  function j(t) {
143
143
  return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
144
144
  }
145
145
  n(j, "isMockFunction");
146
- function A(t, e, r) {
146
+ function D(t, e, r) {
147
147
  let o = r ? { [{
148
148
  get: "getter",
149
149
  set: "setter"
150
- }[r]]: e } : e, p = w(t, o);
151
- return V(p);
150
+ }[r]]: e } : e, p = P(t, o);
151
+ return F(p);
152
152
  }
153
- n(A, "spyOn");
153
+ n(D, "spyOn");
154
154
  var H = 0;
155
- function V(t) {
156
- let e = t, r, l = [], o = [], p = [], c = T(t), y = {
155
+ function F(t) {
156
+ let e = t, r, s = [], o = [], p = [], i = M(t), f = {
157
157
  get calls() {
158
- return c.calls;
158
+ return i.calls;
159
159
  },
160
160
  get contexts() {
161
161
  return o;
162
162
  },
163
163
  get instances() {
164
- return l;
164
+ return s;
165
165
  },
166
166
  get invocationCallOrder() {
167
167
  return p;
168
168
  },
169
169
  get results() {
170
- return c.results.map(([s, u]) => ({ type: s === "error" ? "throw" : "return", value: u }));
170
+ return i.results.map(([l, u]) => ({ type: l === "error" ? "throw" : "return", value: u }));
171
171
  },
172
172
  get settledResults() {
173
- return c.resolves.map(([s, u]) => ({ type: s === "error" ? "rejected" : "fulfilled", value: u }));
173
+ return i.resolves.map(([l, u]) => ({ type: l === "error" ? "rejected" : "fulfilled", value: u }));
174
174
  },
175
175
  get lastCall() {
176
- return c.calls[c.calls.length - 1];
176
+ return i.calls[i.calls.length - 1];
177
177
  }
178
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);
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
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) {
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
189
  let k = r;
190
- r = s, c.willCall(i), m = !0;
191
- let R = /* @__PURE__ */ n(() => {
190
+ r = l, i.willCall(c), m = !0;
191
+ let S = /* @__PURE__ */ n(() => {
192
192
  r = k, m = !1;
193
193
  }, "reset"), d = u();
194
- return d instanceof Promise ? d.then(() => (R(), e)) : (R(), e);
194
+ return d instanceof Promise ? d.then(() => (S(), e)) : (S(), e);
195
195
  }
196
- return n(b, "withImplementation"), e.withImplementation = b, e.mockReturnThis = () => e.mockImplementation(function() {
196
+ return n(x, "withImplementation"), e.withImplementation = x, e.mockReturnThis = () => e.mockImplementation(function() {
197
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;
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
204
  }
205
- n(V, "enhanceSpy");
206
- function P(t) {
207
- let e = V(w({
205
+ n(F, "enhanceSpy");
206
+ function R(t) {
207
+ let e = F(P({
208
208
  spy: t || function() {
209
209
  }
210
210
  }, "spy"));
211
211
  return t && e.mockImplementation(t), e;
212
212
  }
213
- n(P, "fn");
213
+ n(R, "fn");
214
214
 
215
215
  // src/test/spy.ts
216
- var I = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
217
- globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = I;
216
+ var b = globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ || /* @__PURE__ */ new Set();
217
+ globalThis.__STORYBOOK_TEST_SPY_LISTENERS__ = b;
218
218
  function J(t) {
219
- return I.add(t), () => void I.delete(t);
219
+ return b.add(t), () => void b.delete(t);
220
220
  }
221
221
  n(J, "onMockCall");
222
222
  var Q = /* @__PURE__ */ n((...t) => {
223
- let e = A(...t);
224
- return F(e);
223
+ let e = D(...t);
224
+ return V(e);
225
225
  }, "spyOn");
226
226
  function X(t) {
227
- let e = t ? P(t) : P();
228
- return F(e);
227
+ let e = t ? R(t) : R();
228
+ return V(e);
229
229
  }
230
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;
231
+ function V(t) {
232
+ let e = L(t), r = e.mockImplementation.bind(null);
233
+ return e.mockImplementation = (s) => L(r(s)), e;
234
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);
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
240
  }), t;
241
241
  }
242
- n(D, "listenWhenCalled");
242
+ n(L, "listenWhenCalled");
243
243
  function Z() {
244
- h.forEach((t) => t.mockClear());
244
+ O.forEach((t) => t.mockClear());
245
245
  }
246
246
  n(Z, "clearAllMocks");
247
247
  function ee() {
248
- h.forEach((t) => t.mockReset());
248
+ O.forEach((t) => t.mockReset());
249
249
  }
250
250
  n(ee, "resetAllMocks");
251
251
  function te() {
252
- h.forEach((t) => t.mockRestore());
252
+ O.forEach((t) => t.mockRestore());
253
253
  }
254
254
  n(te, "restoreAllMocks");
255
255
  function ne(t, e = {}) {
@@ -1,4 +1,4 @@
1
- import { MockInstance, spyOn as spyOn$1, Mock as Mock$1, MaybeMocked, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep } from '@vitest/spy';
1
+ import { MockInstance, spyOn as spyOn$1, Mock, MaybeMocked, MaybeMockedDeep, MaybePartiallyMocked, MaybePartiallyMockedDeep } from '@vitest/spy';
2
2
  export * from '@vitest/spy';
3
3
  export { isMockFunction, mocks } from '@vitest/spy';
4
4
 
@@ -6,11 +6,7 @@ type Listener = (mock: MockInstance, args: unknown[]) => void;
6
6
  declare function onMockCall(callback: Listener): () => void;
7
7
  declare const spyOn: typeof spyOn$1;
8
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
9
  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
10
  /**
15
11
  * Calls [`.mockClear()`](https://vitest.dev/api/mock#mockclear) on every mocked function. This will
16
12
  * only empty `.mock` state, it will not reset implementation.
@@ -63,4 +59,4 @@ declare function mocked<T>(item: T, options: {
63
59
  }): MaybePartiallyMockedDeep<T>;
64
60
  declare function mocked<T>(item: T): MaybeMocked<T>;
65
61
 
66
- export { type Mock, clearAllMocks, fn, mocked, onMockCall, resetAllMocks, restoreAllMocks, spyOn };
62
+ export { clearAllMocks, fn, mocked, onMockCall, resetAllMocks, restoreAllMocks, spyOn };