storybook 9.0.0-alpha.1 → 9.0.0-alpha.10

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 (259) hide show
  1. package/README.md +31 -29
  2. package/assets/browser/favicon.svg +1 -0
  3. package/assets/browser/nunito-sans-bold-italic.woff2 +0 -0
  4. package/assets/browser/nunito-sans-bold.woff2 +0 -0
  5. package/assets/browser/nunito-sans-italic.woff2 +0 -0
  6. package/assets/browser/nunito-sans-regular.woff2 +0 -0
  7. package/assets/docs/addon-controls-args-annotated.png +0 -0
  8. package/assets/docs/addon-controls-args-background-color.png +0 -0
  9. package/assets/docs/addon-controls-args-background-string.png +0 -0
  10. package/assets/docs/addon-controls-args-docs.png +0 -0
  11. package/assets/docs/addon-controls-args-logging.png +0 -0
  12. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  13. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  14. package/assets/docs/addon-controls-args-reflow.png +0 -0
  15. package/assets/docs/addon-controls-args-template.png +0 -0
  16. package/assets/docs/addon-controls-expanded.png +0 -0
  17. package/assets/docs/addon-controls-hero.gif +0 -0
  18. package/assets/docs/addon-controls-install.png +0 -0
  19. package/assets/docs/hero.gif +0 -0
  20. package/assets/docs/message-reference.png +0 -0
  21. package/assets/docs/viewport.png +0 -0
  22. package/assets/server/addon.tsconfig.json +6 -0
  23. package/assets/server/base-preview-body.html +119 -0
  24. package/assets/server/base-preview-head.html +451 -0
  25. package/assets/server/template.ejs +87 -0
  26. package/bin/index.cjs +1 -1
  27. package/dist/actions/decorator.d.ts +6 -0
  28. package/dist/actions/decorator.js +139 -0
  29. package/dist/actions/index.cjs +127 -0
  30. package/dist/actions/index.d.ts +105 -0
  31. package/dist/actions/index.js +112 -0
  32. package/dist/actions/manager.js +1196 -0
  33. package/dist/actions/preview.cjs +165 -0
  34. package/dist/actions/preview.d.ts +55 -0
  35. package/dist/actions/preview.js +156 -0
  36. package/dist/babel/index.cjs +54034 -0
  37. package/dist/babel/index.d.ts +7488 -0
  38. package/dist/babel/index.js +54044 -0
  39. package/dist/bin/index.cjs +119 -0
  40. package/dist/bin/index.js +113 -0
  41. package/dist/builder-manager/index.cjs +2140 -0
  42. package/dist/builder-manager/index.d.ts +19 -0
  43. package/dist/builder-manager/index.js +2162 -0
  44. package/dist/channels/index.cjs +1913 -0
  45. package/dist/channels/index.d.ts +108 -0
  46. package/dist/channels/index.js +1881 -0
  47. package/dist/cli/bin/index.cjs +2687 -0
  48. package/dist/cli/bin/index.d.ts +2 -0
  49. package/dist/cli/bin/index.js +2707 -0
  50. package/dist/cli/index.cjs +17327 -0
  51. package/dist/cli/index.d.ts +209 -0
  52. package/dist/cli/index.js +17349 -0
  53. package/dist/client-logger/index.cjs +80 -0
  54. package/dist/client-logger/index.d.ts +29 -0
  55. package/dist/client-logger/index.js +64 -0
  56. package/dist/common/index.cjs +20569 -0
  57. package/dist/common/index.d.ts +949 -0
  58. package/dist/common/index.js +20654 -0
  59. package/dist/components/index.cjs +27924 -0
  60. package/dist/components/index.d.ts +1423 -0
  61. package/dist/components/index.js +24673 -0
  62. package/dist/controls/decorator.d.ts +5 -0
  63. package/dist/controls/decorator.js +8 -0
  64. package/dist/controls/index.cjs +26 -0
  65. package/dist/controls/index.d.ts +39 -0
  66. package/dist/controls/index.js +6 -0
  67. package/dist/controls/manager.js +5545 -0
  68. package/dist/controls/preview.cjs +26 -0
  69. package/dist/controls/preview.d.ts +55 -0
  70. package/dist/controls/preview.js +9 -0
  71. package/dist/core-events/index.cjs +167 -0
  72. package/dist/core-events/index.d.ts +426 -0
  73. package/dist/core-events/index.js +149 -0
  74. package/dist/core-server/index.cjs +38183 -0
  75. package/dist/core-server/index.d.ts +720 -0
  76. package/dist/core-server/index.js +38272 -0
  77. package/dist/core-server/presets/common-manager.js +20 -0
  78. package/dist/core-server/presets/common-override-preset.cjs +4824 -0
  79. package/dist/core-server/presets/common-override-preset.js +4829 -0
  80. package/dist/core-server/presets/common-preset.cjs +10231 -0
  81. package/dist/core-server/presets/common-preset.js +10309 -0
  82. package/dist/csf/index.cjs +179 -0
  83. package/dist/csf/index.d.ts +750 -0
  84. package/dist/csf/index.js +172 -0
  85. package/dist/csf-tools/index.cjs +1422 -0
  86. package/dist/csf-tools/index.d.ts +250 -0
  87. package/dist/csf-tools/index.js +1439 -0
  88. package/dist/docs-tools/index.cjs +2891 -0
  89. package/dist/docs-tools/index.d.ts +162 -0
  90. package/dist/docs-tools/index.js +2876 -0
  91. package/dist/index.cjs +17 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.js +2 -7
  94. package/dist/instrumenter/index.cjs +3485 -0
  95. package/dist/instrumenter/index.d.ts +104 -0
  96. package/dist/instrumenter/index.js +4965 -0
  97. package/dist/manager/globals-module-info.cjs +817 -0
  98. package/dist/manager/globals-module-info.d.ts +36 -0
  99. package/dist/manager/globals-module-info.js +804 -0
  100. package/dist/manager/globals-runtime.js +77536 -0
  101. package/dist/manager/globals.cjs +47 -0
  102. package/dist/manager/globals.d.ts +24 -0
  103. package/dist/manager/globals.js +34 -0
  104. package/dist/manager/runtime.js +12323 -0
  105. package/dist/manager-api/index.cjs +11074 -0
  106. package/dist/manager-api/index.d.ts +1512 -0
  107. package/dist/manager-api/index.js +4835 -0
  108. package/dist/manager-errors.d.ts +89 -0
  109. package/dist/manager-errors.js +99 -0
  110. package/dist/node-logger/index.cjs +1642 -0
  111. package/dist/node-logger/index.d.ts +117 -0
  112. package/dist/node-logger/index.js +1652 -0
  113. package/dist/preview/globals.cjs +38 -0
  114. package/dist/preview/globals.d.ts +15 -0
  115. package/dist/preview/globals.js +25 -0
  116. package/dist/preview/runtime.js +43629 -0
  117. package/dist/preview-api/index.cjs +5224 -0
  118. package/dist/preview-api/index.d.ts +1093 -0
  119. package/dist/preview-api/index.js +5292 -0
  120. package/dist/preview-errors.cjs +503 -0
  121. package/dist/preview-errors.d.ts +212 -0
  122. package/dist/preview-errors.js +449 -0
  123. package/dist/router/index.cjs +3296 -0
  124. package/dist/router/index.d.ts +385 -0
  125. package/dist/router/index.js +1843 -0
  126. package/dist/server-errors.cjs +727 -0
  127. package/dist/server-errors.d.ts +296 -0
  128. package/dist/server-errors.js +728 -0
  129. package/dist/telemetry/index.cjs +2756 -0
  130. package/dist/telemetry/index.d.ts +133 -0
  131. package/dist/telemetry/index.js +2797 -0
  132. package/dist/test/index.cjs +35685 -0
  133. package/dist/test/index.d.ts +186 -0
  134. package/dist/test/index.js +33751 -0
  135. package/dist/test/preview.cjs +15869 -0
  136. package/dist/test/preview.d.ts +54 -0
  137. package/dist/test/preview.js +14440 -0
  138. package/dist/test/spy.cjs +257 -0
  139. package/dist/test/spy.d.ts +66 -0
  140. package/dist/test/spy.js +239 -0
  141. package/dist/theming/create.cjs +232 -0
  142. package/dist/theming/create.d.ts +50 -0
  143. package/dist/theming/create.js +216 -0
  144. package/dist/theming/index.cjs +2665 -0
  145. package/dist/theming/index.d.ts +11939 -0
  146. package/dist/theming/index.js +2485 -0
  147. package/dist/types/index.cjs +27 -0
  148. package/dist/types/index.d.ts +2795 -0
  149. package/dist/types/index.js +7 -0
  150. package/dist/viewport/index.cjs +310 -0
  151. package/dist/viewport/index.d.ts +320 -0
  152. package/dist/viewport/index.js +290 -0
  153. package/dist/viewport/manager.js +400 -0
  154. package/dist/viewport/preview.cjs +35 -0
  155. package/dist/viewport/preview.d.ts +69 -0
  156. package/dist/viewport/preview.js +19 -0
  157. package/package.json +518 -209
  158. package/.eslintrc.cjs +0 -31
  159. package/__mocks__/@aw-web-design/x-default-browser.js +0 -2
  160. package/core/babel/index.cjs +0 -1
  161. package/core/babel/index.d.ts +0 -2
  162. package/core/babel/index.js +0 -1
  163. package/core/builder-manager/index.cjs +0 -1
  164. package/core/builder-manager/index.d.ts +0 -2
  165. package/core/builder-manager/index.js +0 -1
  166. package/core/channels/index.cjs +0 -1
  167. package/core/channels/index.d.ts +0 -2
  168. package/core/channels/index.js +0 -1
  169. package/core/cli/bin/index.cjs +0 -1
  170. package/core/cli/bin/index.d.ts +0 -2
  171. package/core/cli/bin/index.js +0 -1
  172. package/core/cli/index.cjs +0 -1
  173. package/core/cli/index.d.ts +0 -2
  174. package/core/cli/index.js +0 -1
  175. package/core/client-logger/index.cjs +0 -1
  176. package/core/client-logger/index.d.ts +0 -2
  177. package/core/client-logger/index.js +0 -1
  178. package/core/common/index.cjs +0 -1
  179. package/core/common/index.d.ts +0 -2
  180. package/core/common/index.js +0 -1
  181. package/core/components/index.cjs +0 -1
  182. package/core/components/index.d.ts +0 -2
  183. package/core/components/index.js +0 -1
  184. package/core/core-events/index.cjs +0 -1
  185. package/core/core-events/index.d.ts +0 -2
  186. package/core/core-events/index.js +0 -1
  187. package/core/core-server/index.cjs +0 -1
  188. package/core/core-server/index.d.ts +0 -2
  189. package/core/core-server/index.js +0 -1
  190. package/core/core-server/presets/common-manager.js +0 -1
  191. package/core/core-server/presets/common-override-preset.cjs +0 -1
  192. package/core/core-server/presets/common-override-preset.js +0 -1
  193. package/core/core-server/presets/common-preset.cjs +0 -1
  194. package/core/core-server/presets/common-preset.js +0 -1
  195. package/core/csf/index.cjs +0 -1
  196. package/core/csf/index.d.ts +0 -2
  197. package/core/csf/index.js +0 -1
  198. package/core/csf-tools/index.cjs +0 -1
  199. package/core/csf-tools/index.d.ts +0 -2
  200. package/core/csf-tools/index.js +0 -1
  201. package/core/docs-tools/index.cjs +0 -1
  202. package/core/docs-tools/index.d.ts +0 -2
  203. package/core/docs-tools/index.js +0 -1
  204. package/core/index.cjs +0 -1
  205. package/core/index.d.ts +0 -2
  206. package/core/index.js +0 -1
  207. package/core/manager/globals-module-info.cjs +0 -1
  208. package/core/manager/globals-module-info.d.ts +0 -2
  209. package/core/manager/globals-module-info.js +0 -1
  210. package/core/manager/globals-runtime.js +0 -1
  211. package/core/manager/globals.cjs +0 -1
  212. package/core/manager/globals.d.ts +0 -2
  213. package/core/manager/globals.js +0 -1
  214. package/core/manager-api/index.cjs +0 -1
  215. package/core/manager-api/index.d.ts +0 -2
  216. package/core/manager-api/index.js +0 -1
  217. package/core/manager-errors.d.ts +0 -2
  218. package/core/manager-errors.js +0 -1
  219. package/core/node-logger/index.cjs +0 -1
  220. package/core/node-logger/index.d.ts +0 -2
  221. package/core/node-logger/index.js +0 -1
  222. package/core/preview/globals.cjs +0 -1
  223. package/core/preview/globals.d.ts +0 -2
  224. package/core/preview/globals.js +0 -1
  225. package/core/preview/runtime.js +0 -1
  226. package/core/preview-api/index.cjs +0 -1
  227. package/core/preview-api/index.d.ts +0 -2
  228. package/core/preview-api/index.js +0 -1
  229. package/core/preview-errors.cjs +0 -1
  230. package/core/preview-errors.d.ts +0 -2
  231. package/core/preview-errors.js +0 -1
  232. package/core/router/index.cjs +0 -1
  233. package/core/router/index.d.ts +0 -2
  234. package/core/router/index.js +0 -1
  235. package/core/server-errors.cjs +0 -1
  236. package/core/server-errors.d.ts +0 -2
  237. package/core/server-errors.js +0 -1
  238. package/core/telemetry/index.cjs +0 -1
  239. package/core/telemetry/index.d.ts +0 -2
  240. package/core/telemetry/index.js +0 -1
  241. package/core/theming/create.cjs +0 -1
  242. package/core/theming/create.d.ts +0 -2
  243. package/core/theming/create.js +0 -1
  244. package/core/theming/index.cjs +0 -1
  245. package/core/theming/index.d.ts +0 -2
  246. package/core/theming/index.js +0 -1
  247. package/core/types/index.cjs +0 -1
  248. package/core/types/index.d.ts +0 -2
  249. package/core/types/index.js +0 -1
  250. package/core.cjs +0 -0
  251. package/core.d.ts +0 -0
  252. package/core.js +0 -1
  253. package/dist/chunk-OWLSIX54.js +0 -8
  254. package/dist/core-path.cjs +0 -1
  255. package/dist/core-path.d.ts +0 -3
  256. package/dist/core-path.js +0 -9
  257. package/dist/proxy.cjs +0 -1
  258. package/dist/proxy.d.ts +0 -2
  259. package/dist/proxy.js +0 -9
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ var v = Object.defineProperty;
3
+ var _ = Object.getOwnPropertyDescriptor;
4
+ var N = Object.getOwnPropertyNames;
5
+ var K = Object.prototype.hasOwnProperty;
6
+ var n = (t, e) => v(t, "name", { value: e, configurable: !0 });
7
+ var U = (t, e) => {
8
+ for (var r in e)
9
+ v(t, r, { get: e[r], enumerable: !0 });
10
+ }, W = (t, e, r, l) => {
11
+ if (e && typeof e == "object" || typeof e == "function")
12
+ for (let o of N(e))
13
+ !K.call(t, o) && o !== r && v(t, o, { get: () => e[o], enumerable: !(l = _(e, o)) || l.enumerable });
14
+ return t;
15
+ };
16
+ var Y = (t) => W(v({}, "__esModule", { value: !0 }), t);
17
+
18
+ // src/test/spy.ts
19
+ var oe = {};
20
+ U(oe, {
21
+ clearAllMocks: () => Z,
22
+ fn: () => X,
23
+ isMockFunction: () => E,
24
+ mocked: () => ne,
25
+ mocks: () => T,
26
+ onMockCall: () => J,
27
+ resetAllMocks: () => ee,
28
+ restoreAllMocks: () => te,
29
+ spyOn: () => Q
30
+ });
31
+ module.exports = Y(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 $(t) {
44
+ return t instanceof Promise;
45
+ }
46
+ n($, "w");
47
+ function w(t, e, r) {
48
+ Object.defineProperty(t, e, r);
49
+ }
50
+ n(w, "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"), q = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ n((t) => {
56
+ t.called = !1, t.callCount = 0, t.calls = [], t.results = [], t.resolves = [], t.next = [];
57
+ }, "P"), B = /* @__PURE__ */ n((t) => (w(t, x, { value: { reset: /* @__PURE__ */ n(() => z(t[x]), "reset") } }), t[x]), "K"), h = /* @__PURE__ */ n(
58
+ (t) => t[x] || B(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 = h(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 $(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 = h(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"), j = /* @__PURE__ */ n((t, e) => {
94
+ e != null && typeof e == "function" && e.prototype != null && Object.setPrototypeOf(t.prototype, e.prototype);
95
+ }, "O");
96
+ function R(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: b, ...d } = a || {
125
+ configurable: !0,
126
+ writable: !0
127
+ };
128
+ o !== "value" && delete d.writable, d[o] = k, w(t, l, d);
129
+ }, "g"), I = /* @__PURE__ */ n(() => a ? w(t, l, a) : f(i), "b");
130
+ r || (r = i);
131
+ let s = G(r);
132
+ o === "value" && j(s, i);
133
+ let u = s[x];
134
+ return M(u, "restore", I), M(u, "getOriginal", () => m ? i() : i), M(u, "willCall", (k) => (u.impl = k, s)), f(
135
+ m ? () => (j(s, r), s) : s
136
+ ), q.add(s), s;
137
+ }
138
+ n(R, "C");
139
+
140
+ // ../node_modules/@vitest/spy/dist/index.js
141
+ var T = /* @__PURE__ */ new Set();
142
+ function E(t) {
143
+ return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
144
+ }
145
+ n(E, "isMockFunction");
146
+ function V(t, e, r) {
147
+ let o = r ? { [{
148
+ get: "getter",
149
+ set: "setter"
150
+ }[r]]: e } : e, p = R(t, o);
151
+ return D(p);
152
+ }
153
+ n(V, "spyOn");
154
+ var H = 0;
155
+ function D(t) {
156
+ let e = t, r, l = [], o = [], p = [], c = h(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 I(s, u) {
189
+ let k = r;
190
+ r = s, c.willCall(i), m = !0;
191
+ let b = /* @__PURE__ */ n(() => {
192
+ r = k, m = !1;
193
+ }, "reset"), d = u();
194
+ return d instanceof Promise ? d.then(() => (b(), e)) : (b(), e);
195
+ }
196
+ return n(I, "withImplementation"), e.withImplementation = I, 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), T.add(e), e;
204
+ }
205
+ n(D, "enhanceSpy");
206
+ function P(t) {
207
+ let e = D(R({
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 S = /* @__PURE__ */ new Set();
217
+ function J(t) {
218
+ return S.add(t), () => void S.delete(t);
219
+ }
220
+ n(J, "onMockCall");
221
+ var Q = /* @__PURE__ */ n((...t) => {
222
+ let e = V(...t);
223
+ return L(e);
224
+ }, "spyOn");
225
+ function X(t) {
226
+ let e = t ? P(t) : P();
227
+ return L(e);
228
+ }
229
+ n(X, "fn");
230
+ function L(t) {
231
+ let e = F(t), r = e.mockImplementation.bind(null);
232
+ return e.mockImplementation = (l) => F(r(l)), e;
233
+ }
234
+ n(L, "reactiveMock");
235
+ function F(t) {
236
+ let e = h(t), r = e.impl;
237
+ return e.willCall(function(...l) {
238
+ return S.forEach((o) => o(t, l)), r?.apply(this, l);
239
+ }), t;
240
+ }
241
+ n(F, "listenWhenCalled");
242
+ function Z() {
243
+ T.forEach((t) => t.mockClear());
244
+ }
245
+ n(Z, "clearAllMocks");
246
+ function ee() {
247
+ T.forEach((t) => t.mockReset());
248
+ }
249
+ n(ee, "resetAllMocks");
250
+ function te() {
251
+ T.forEach((t) => t.mockRestore());
252
+ }
253
+ n(te, "restoreAllMocks");
254
+ function ne(t, e = {}) {
255
+ return t;
256
+ }
257
+ 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,239 @@
1
+ var F = Object.defineProperty;
2
+ var n = (t, e) => F(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 L(t) {
15
+ return t instanceof Promise;
16
+ }
17
+ n(L, "w");
18
+ function b(t, e, r) {
19
+ Object.defineProperty(t, e, r);
20
+ }
21
+ n(b, "f");
22
+ function M(t, e, r) {
23
+ Object.defineProperty(t, e, { value: r });
24
+ }
25
+ n(M, "l");
26
+ var T = Symbol.for("tinyspy:spy"), _ = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ n((t) => {
27
+ t.called = !1, t.callCount = 0, t.calls = [], t.results = [], t.resolves = [], t.next = [];
28
+ }, "P"), K = /* @__PURE__ */ n((t) => (b(t, T, { value: { reset: /* @__PURE__ */ n(() => N(t[T]), "reset") } }), t[T]), "K"), h = /* @__PURE__ */ n(
29
+ (t) => t[T] || K(t), "T");
30
+ function U(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 = h(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 L(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 = h(e);
61
+ return r.reset(), r.impl = t, e;
62
+ }
63
+ n(U, "m");
64
+ var S = /* @__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
+ 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 = S(t, l), c = Object.getPrototypeOf(t), y = c && S(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: I, ...d } = a || {
96
+ configurable: !0,
97
+ writable: !0
98
+ };
99
+ s !== "value" && delete d.writable, d[s] = k, b(t, l, d);
100
+ }, "g"), O = /* @__PURE__ */ n(() => a ? b(t, l, a) : f(i), "b");
101
+ r || (r = i);
102
+ let o = U(r);
103
+ s === "value" && C(o, i);
104
+ let u = o[T];
105
+ return M(u, "restore", O), M(u, "getOriginal", () => m ? i() : i), M(u, "willCall", (k) => (u.impl = k, o)), f(
106
+ m ? () => (C(o, r), o) : o
107
+ ), _.add(o), o;
108
+ }
109
+ n(w, "C");
110
+
111
+ // ../node_modules/@vitest/spy/dist/index.js
112
+ var x = /* @__PURE__ */ new Set();
113
+ function W(t) {
114
+ return typeof t == "function" && "_isMockFunction" in t && t._isMockFunction;
115
+ }
116
+ n(W, "isMockFunction");
117
+ function A(t, e, r) {
118
+ let s = r ? { [{
119
+ get: "getter",
120
+ set: "setter"
121
+ }[r]]: e } : e, p = w(t, s);
122
+ return E(p);
123
+ }
124
+ n(A, "spyOn");
125
+ var Y = 0;
126
+ function E(t) {
127
+ let e = t, r, l = [], s = [], p = [], c = h(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(++Y), (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 O(o, u) {
160
+ let k = r;
161
+ r = o, c.willCall(i), m = !0;
162
+ let I = /* @__PURE__ */ n(() => {
163
+ r = k, m = !1;
164
+ }, "reset"), d = u();
165
+ return d instanceof Promise ? d.then(() => (I(), e)) : (I(), e);
166
+ }
167
+ return n(O, "withImplementation"), e.withImplementation = O, 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(E, "enhanceSpy");
177
+ function R(t) {
178
+ let e = E(w({
179
+ spy: t || function() {
180
+ }
181
+ }, "spy"));
182
+ return t && e.mockImplementation(t), e;
183
+ }
184
+ n(R, "fn");
185
+
186
+ // src/test/spy.ts
187
+ var P = /* @__PURE__ */ new Set();
188
+ function H(t) {
189
+ return P.add(t), () => void P.delete(t);
190
+ }
191
+ n(H, "onMockCall");
192
+ var J = /* @__PURE__ */ n((...t) => {
193
+ let e = A(...t);
194
+ return D(e);
195
+ }, "spyOn");
196
+ function Q(t) {
197
+ let e = t ? R(t) : R();
198
+ return D(e);
199
+ }
200
+ n(Q, "fn");
201
+ function D(t) {
202
+ let e = V(t), r = e.mockImplementation.bind(null);
203
+ return e.mockImplementation = (l) => V(r(l)), e;
204
+ }
205
+ n(D, "reactiveMock");
206
+ function V(t) {
207
+ let e = h(t), r = e.impl;
208
+ return e.willCall(function(...l) {
209
+ return P.forEach((s) => s(t, l)), r?.apply(this, l);
210
+ }), t;
211
+ }
212
+ n(V, "listenWhenCalled");
213
+ function X() {
214
+ x.forEach((t) => t.mockClear());
215
+ }
216
+ n(X, "clearAllMocks");
217
+ function Z() {
218
+ x.forEach((t) => t.mockReset());
219
+ }
220
+ n(Z, "resetAllMocks");
221
+ function ee() {
222
+ x.forEach((t) => t.mockRestore());
223
+ }
224
+ n(ee, "restoreAllMocks");
225
+ function te(t, e = {}) {
226
+ return t;
227
+ }
228
+ n(te, "mocked");
229
+ export {
230
+ X as clearAllMocks,
231
+ Q as fn,
232
+ W as isMockFunction,
233
+ te as mocked,
234
+ x as mocks,
235
+ H as onMockCall,
236
+ Z as resetAllMocks,
237
+ ee as restoreAllMocks,
238
+ J as spyOn
239
+ };