twd-js 1.1.2 → 1.2.1

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 (51) hide show
  1. package/README.md +20 -24
  2. package/dist/_commonjsHelpers-C6fGbg64.mjs +6 -0
  3. package/dist/_commonjsHelpers-DwGv2jUC.js +1 -0
  4. package/dist/index.cjs.js +39 -44
  5. package/dist/index.d.ts +433 -7
  6. package/dist/index.es.js +4670 -4917
  7. package/dist/jsx-runtime-CtyxV31n.mjs +276 -0
  8. package/dist/jsx-runtime-DN5DOl8k.js +6 -0
  9. package/dist/mock-sw.js +1 -1
  10. package/dist/runner-ci.cjs.js +1 -1
  11. package/dist/runner-ci.d.ts +28 -12
  12. package/dist/runner-ci.es.js +32 -22
  13. package/dist/runner.cjs.js +1 -1
  14. package/dist/runner.d.ts +55 -41
  15. package/dist/runner.es.js +127 -70
  16. package/dist/ui.cjs.js +1 -0
  17. package/dist/ui.d.ts +10 -0
  18. package/dist/ui.es.js +11 -0
  19. package/dist/vite-plugin.d.ts +21 -1
  20. package/package.json +15 -10
  21. package/dist/asserts/index.d.ts +0 -2
  22. package/dist/commands/mockBridge.d.ts +0 -73
  23. package/dist/commands/url.d.ts +0 -33
  24. package/dist/commands/visit.d.ts +0 -1
  25. package/dist/constants/version.d.ts +0 -1
  26. package/dist/global.d.ts +0 -8
  27. package/dist/initializers/initSidebar.d.ts +0 -22
  28. package/dist/initializers/initTests.d.ts +0 -31
  29. package/dist/plugin/removeMockServiceWorker.d.ts +0 -18
  30. package/dist/proxies/domMessage.d.ts +0 -1
  31. package/dist/proxies/eventsMessage.d.ts +0 -1
  32. package/dist/proxies/screenDom.d.ts +0 -5
  33. package/dist/proxies/userEvent.d.ts +0 -4
  34. package/dist/twd-types.d.ts +0 -106
  35. package/dist/twd.d.ts +0 -178
  36. package/dist/ui/ClosedSidebar.d.ts +0 -6
  37. package/dist/ui/Icons/BaseIcon.d.ts +0 -7
  38. package/dist/ui/Icons/ChevronDown.d.ts +0 -2
  39. package/dist/ui/Icons/ChevronRight.d.ts +0 -2
  40. package/dist/ui/Icons/Loader.d.ts +0 -2
  41. package/dist/ui/Icons/MockRequestIcon.d.ts +0 -2
  42. package/dist/ui/Icons/Play.d.ts +0 -2
  43. package/dist/ui/MockRulesButton.d.ts +0 -1
  44. package/dist/ui/TWDSidebar.d.ts +0 -16
  45. package/dist/ui/TestList.d.ts +0 -17
  46. package/dist/ui/TestListItem.d.ts +0 -39
  47. package/dist/ui/buildTreeFromHandlers.d.ts +0 -14
  48. package/dist/ui/hooks/useLayout.d.ts +0 -6
  49. package/dist/utils/assertionMessage.d.ts +0 -1
  50. package/dist/utils/log.d.ts +0 -1
  51. package/dist/utils/wait.d.ts +0 -3
@@ -0,0 +1,276 @@
1
+ import re from "react";
2
+ const w = /* @__PURE__ */ new Map(), se = (a, i) => {
3
+ w.set(a, i);
4
+ };
5
+ function ce() {
6
+ w.clear();
7
+ }
8
+ const ue = (a) => w.get(a);
9
+ var p = { exports: {} }, R = {};
10
+ var M;
11
+ function te() {
12
+ if (M) return R;
13
+ M = 1;
14
+ var a = Symbol.for("react.transitional.element"), i = Symbol.for("react.fragment");
15
+ function m(d, s, c) {
16
+ var E = null;
17
+ if (c !== void 0 && (E = "" + c), s.key !== void 0 && (E = "" + s.key), "key" in s) {
18
+ c = {};
19
+ for (var _ in s)
20
+ _ !== "key" && (c[_] = s[_]);
21
+ } else c = s;
22
+ return s = c.ref, {
23
+ $$typeof: a,
24
+ type: d,
25
+ key: E,
26
+ ref: s !== void 0 ? s : null,
27
+ props: c
28
+ };
29
+ }
30
+ return R.Fragment = i, R.jsx = m, R.jsxs = m, R;
31
+ }
32
+ var b = {};
33
+ var $;
34
+ function ne() {
35
+ return $ || ($ = 1, process.env.NODE_ENV !== "production" && (function() {
36
+ function a(e) {
37
+ if (e == null) return null;
38
+ if (typeof e == "function")
39
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
40
+ if (typeof e == "string") return e;
41
+ switch (e) {
42
+ case T:
43
+ return "Fragment";
44
+ case J:
45
+ return "Profiler";
46
+ case q:
47
+ return "StrictMode";
48
+ case X:
49
+ return "Suspense";
50
+ case B:
51
+ return "SuspenseList";
52
+ case Z:
53
+ return "Activity";
54
+ }
55
+ if (typeof e == "object")
56
+ switch (typeof e.tag == "number" && console.error(
57
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
58
+ ), e.$$typeof) {
59
+ case U:
60
+ return "Portal";
61
+ case V:
62
+ return (e.displayName || "Context") + ".Provider";
63
+ case z:
64
+ return (e._context.displayName || "Context") + ".Consumer";
65
+ case G:
66
+ var r = e.render;
67
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
68
+ case H:
69
+ return r = e.displayName || null, r !== null ? r : a(e.type) || "Memo";
70
+ case h:
71
+ r = e._payload, e = e._init;
72
+ try {
73
+ return a(e(r));
74
+ } catch {
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ function i(e) {
80
+ return "" + e;
81
+ }
82
+ function m(e) {
83
+ try {
84
+ i(e);
85
+ var r = !1;
86
+ } catch {
87
+ r = !0;
88
+ }
89
+ if (r) {
90
+ r = console;
91
+ var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
92
+ return t.call(
93
+ r,
94
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
95
+ n
96
+ ), i(e);
97
+ }
98
+ }
99
+ function d(e) {
100
+ if (e === T) return "<>";
101
+ if (typeof e == "object" && e !== null && e.$$typeof === h)
102
+ return "<...>";
103
+ try {
104
+ var r = a(e);
105
+ return r ? "<" + r + ">" : "<...>";
106
+ } catch {
107
+ return "<...>";
108
+ }
109
+ }
110
+ function s() {
111
+ var e = k.A;
112
+ return e === null ? null : e.getOwner();
113
+ }
114
+ function c() {
115
+ return Error("react-stack-top-frame");
116
+ }
117
+ function E(e) {
118
+ if (y.call(e, "key")) {
119
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
120
+ if (r && r.isReactWarning) return !1;
121
+ }
122
+ return e.key !== void 0;
123
+ }
124
+ function _(e, r) {
125
+ function t() {
126
+ N || (N = !0, console.error(
127
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
128
+ r
129
+ ));
130
+ }
131
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
132
+ get: t,
133
+ configurable: !0
134
+ });
135
+ }
136
+ function L() {
137
+ var e = a(this.type);
138
+ return C[e] || (C[e] = !0, console.error(
139
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
140
+ )), e = this.props.ref, e !== void 0 ? e : null;
141
+ }
142
+ function W(e, r, t, n, l, u, A, S) {
143
+ return t = u.ref, e = {
144
+ $$typeof: x,
145
+ type: e,
146
+ key: r,
147
+ props: u,
148
+ _owner: l
149
+ }, (t !== void 0 ? t : null) !== null ? Object.defineProperty(e, "ref", {
150
+ enumerable: !1,
151
+ get: L
152
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
153
+ configurable: !1,
154
+ enumerable: !1,
155
+ writable: !0,
156
+ value: 0
157
+ }), Object.defineProperty(e, "_debugInfo", {
158
+ configurable: !1,
159
+ enumerable: !1,
160
+ writable: !0,
161
+ value: null
162
+ }), Object.defineProperty(e, "_debugStack", {
163
+ configurable: !1,
164
+ enumerable: !1,
165
+ writable: !0,
166
+ value: A
167
+ }), Object.defineProperty(e, "_debugTask", {
168
+ configurable: !1,
169
+ enumerable: !1,
170
+ writable: !0,
171
+ value: S
172
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
173
+ }
174
+ function g(e, r, t, n, l, u, A, S) {
175
+ var o = r.children;
176
+ if (o !== void 0)
177
+ if (n)
178
+ if (K(o)) {
179
+ for (n = 0; n < o.length; n++)
180
+ j(o[n]);
181
+ Object.freeze && Object.freeze(o);
182
+ } else
183
+ console.error(
184
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
185
+ );
186
+ else j(o);
187
+ if (y.call(r, "key")) {
188
+ o = a(e);
189
+ var f = Object.keys(r).filter(function(ee) {
190
+ return ee !== "key";
191
+ });
192
+ n = 0 < f.length ? "{key: someKey, " + f.join(": ..., ") + ": ...}" : "{key: someKey}", I[o + n] || (f = 0 < f.length ? "{" + f.join(": ..., ") + ": ...}" : "{}", console.error(
193
+ `A props object containing a "key" prop is being spread into JSX:
194
+ let props = %s;
195
+ <%s {...props} />
196
+ React keys must be passed directly to JSX without using spread:
197
+ let props = %s;
198
+ <%s key={someKey} {...props} />`,
199
+ n,
200
+ o,
201
+ f,
202
+ o
203
+ ), I[o + n] = !0);
204
+ }
205
+ if (o = null, t !== void 0 && (m(t), o = "" + t), E(r) && (m(r.key), o = "" + r.key), "key" in r) {
206
+ t = {};
207
+ for (var P in r)
208
+ P !== "key" && (t[P] = r[P]);
209
+ } else t = r;
210
+ return o && _(
211
+ t,
212
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
213
+ ), W(
214
+ e,
215
+ o,
216
+ u,
217
+ l,
218
+ s(),
219
+ t,
220
+ A,
221
+ S
222
+ );
223
+ }
224
+ function j(e) {
225
+ typeof e == "object" && e !== null && e.$$typeof === x && e._store && (e._store.validated = 1);
226
+ }
227
+ var v = re, x = Symbol.for("react.transitional.element"), U = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), q = Symbol.for("react.strict_mode"), J = Symbol.for("react.profiler"), z = Symbol.for("react.consumer"), V = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), h = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), Q = Symbol.for("react.client.reference"), k = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, y = Object.prototype.hasOwnProperty, K = Array.isArray, O = console.createTask ? console.createTask : function() {
228
+ return null;
229
+ };
230
+ v = {
231
+ react_stack_bottom_frame: function(e) {
232
+ return e();
233
+ }
234
+ };
235
+ var N, C = {}, Y = v.react_stack_bottom_frame.bind(
236
+ v,
237
+ c
238
+ )(), F = O(d(c)), I = {};
239
+ b.Fragment = T, b.jsx = function(e, r, t, n, l) {
240
+ var u = 1e4 > k.recentlyCreatedOwnerStacks++;
241
+ return g(
242
+ e,
243
+ r,
244
+ t,
245
+ !1,
246
+ n,
247
+ l,
248
+ u ? Error("react-stack-top-frame") : Y,
249
+ u ? O(d(e)) : F
250
+ );
251
+ }, b.jsxs = function(e, r, t, n, l) {
252
+ var u = 1e4 > k.recentlyCreatedOwnerStacks++;
253
+ return g(
254
+ e,
255
+ r,
256
+ t,
257
+ !0,
258
+ n,
259
+ l,
260
+ u ? Error("react-stack-top-frame") : Y,
261
+ u ? O(d(e)) : F
262
+ );
263
+ };
264
+ })()), b;
265
+ }
266
+ var D;
267
+ function oe() {
268
+ return D || (D = 1, process.env.NODE_ENV === "production" ? p.exports = te() : p.exports = ne()), p.exports;
269
+ }
270
+ var le = oe();
271
+ export {
272
+ ce as c,
273
+ ue as g,
274
+ le as j,
275
+ se as m
276
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";const re=require("react"),w=new Map,te=(a,i)=>{w.set(a,i)};function ne(){w.clear()}const oe=a=>w.get(a);var v={exports:{}},_={};var I;function ae(){if(I)return _;I=1;var a=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function m(d,s,c){var E=null;if(c!==void 0&&(E=""+c),s.key!==void 0&&(E=""+s.key),"key"in s){c={};for(var R in s)R!=="key"&&(c[R]=s[R])}else c=s;return s=c.ref,{$$typeof:a,type:d,key:E,ref:s!==void 0?s:null,props:c}}return _.Fragment=i,_.jsx=m,_.jsxs=m,_}var b={};var $;function se(){return $||($=1,process.env.NODE_ENV!=="production"&&(function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case T:return"Fragment";case J:return"Profiler";case q:return"StrictMode";case X:return"Suspense";case B:return"SuspenseList";case Z:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case U:return"Portal";case V:return(e.displayName||"Context")+".Provider";case z:return(e._context.displayName||"Context")+".Consumer";case G:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return r=e.displayName||null,r!==null?r:a(e.type)||"Memo";case h:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function i(e){return""+e}function m(e){try{i(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),i(e)}}function d(e){if(e===T)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===h)return"<...>";try{var r=a(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=k.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function E(e){if(y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function t(){C||(C=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function L(){var e=a(this.type);return N[e]||(N[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function W(e,r,t,n,l,u,A,S){return t=u.ref,e={$$typeof:x,type:e,key:r,props:u,_owner:l},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:L}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,r,t,n,l,u,A,S){var o=r.children;if(o!==void 0)if(n)if(K(o)){for(n=0;n<o.length;n++)j(o[n]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(o);if(y.call(r,"key")){o=a(e);var f=Object.keys(r).filter(function(ee){return ee!=="key"});n=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",F[o+n]||(f=0<f.length?"{"+f.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,n,o,f,o),F[o+n]=!0)}if(o=null,t!==void 0&&(m(t),o=""+t),E(r)&&(m(r.key),o=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return o&&R(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),W(e,o,u,l,s(),t,A,S)}function j(e){typeof e=="object"&&e!==null&&e.$$typeof===x&&e._store&&(e._store.validated=1)}var p=re,x=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),J=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),V=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),k=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,K=Array.isArray,O=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var C,N={},Y=p.react_stack_bottom_frame.bind(p,c)(),M=O(d(c)),F={};b.Fragment=T,b.jsx=function(e,r,t,n,l){var u=1e4>k.recentlyCreatedOwnerStacks++;return g(e,r,t,!1,n,l,u?Error("react-stack-top-frame"):Y,u?O(d(e)):M)},b.jsxs=function(e,r,t,n,l){var u=1e4>k.recentlyCreatedOwnerStacks++;return g(e,r,t,!0,n,l,u?Error("react-stack-top-frame"):Y,u?O(d(e)):M)}})()),b}var D;function ce(){return D||(D=1,process.env.NODE_ENV==="production"?v.exports=ae():v.exports=se()),v.exports}var ue=ce();exports.clearComponentMocks=ne;exports.getMockForComponent=oe;exports.jsxRuntimeExports=ue;exports.mockComponent=te;
package/dist/mock-sw.js CHANGED
@@ -1,4 +1,4 @@
1
- const h=e=>{try{return new RegExp(e),!0}catch{return!1}},u=e=>{const s=e.split("?")[0];return/\.([a-zA-Z0-9]+)$/.test(s)};function f(e,s,n){return n.find(t=>{const o=t.method.toLowerCase()===e.toLowerCase();if(t.urlRegex&&h(t.url)){const a=new RegExp(t.url);return o&&a.test(s)}if(u(t.url))return o&&s.includes(t.url);const l=t.url===s||s.includes(t.url);return o&&l&&!u(s)})}function p(e,s,n){e.forEach(t=>t.postMessage({type:"EXECUTED",alias:s.alias,request:n}))}const y=(e,s,n)=>{const o=![204,205,304].includes(s),i=o?JSON.stringify(e):null;return new Response(i,{status:s,headers:o?n||{"Content-Type":"application/json"}:n||{}})},c="1.1.2";let r=[];const g=async e=>{const{method:s}=e.request,n=e.request.url,t=f(s,n,r);t&&(console.log("[TWD] Mock hit:",t.alias,s,n),e.respondWith((async()=>{let o=null;const i=e.request.headers.get("content-type")||"application/json";if(i.includes("application/json"))try{o=await e.request.clone().json()}catch{}else if(i.includes("form"))try{const l=await e.request.clone().formData();o={},l.forEach((a,d)=>{o[d]=a})}catch{}else if(i.includes("text"))try{o=await e.request.clone().text()}catch{}else if(i.includes("octet-stream"))try{o=await e.request.clone().arrayBuffer()}catch{}else if(i.includes("image"))try{o=await e.request.clone().blob()}catch{}else try{o=await e.request.clone().text()}catch{}return self.clients.matchAll().then(l=>{p(l,t,o)}),y(t.response,t.status??200,t.responseHeaders)})()))},m=e=>{e!==c&&console.warn(`[TWD] ⚠️ Version mismatch detected:
1
+ const h=e=>{try{return new RegExp(e),!0}catch{return!1}},u=e=>{const s=e.split("?")[0];return/\.([a-zA-Z0-9]+)$/.test(s)};function f(e,s,n){return n.find(t=>{const o=t.method.toLowerCase()===e.toLowerCase();if(t.urlRegex&&h(t.url)){const a=new RegExp(t.url);return o&&a.test(s)}if(u(t.url))return o&&s.includes(t.url);const l=t.url===s||s.includes(t.url);return o&&l&&!u(s)})}function p(e,s,n){e.forEach(t=>t.postMessage({type:"EXECUTED",alias:s.alias,request:n}))}const y=(e,s,n)=>{const o=![204,205,304].includes(s),i=o?JSON.stringify(e):null;return new Response(i,{status:s,headers:o?n||{"Content-Type":"application/json"}:n||{}})},c="1.2.1";let r=[];const g=async e=>{const{method:s}=e.request,n=e.request.url,t=f(s,n,r);t&&(console.log("[TWD] Mock hit:",t.alias,s,n),e.respondWith((async()=>{let o=null;const i=e.request.headers.get("content-type")||"application/json";if(i.includes("application/json"))try{o=await e.request.clone().json()}catch{}else if(i.includes("form"))try{const l=await e.request.clone().formData();o={},l.forEach((a,d)=>{o[d]=a})}catch{}else if(i.includes("text"))try{o=await e.request.clone().text()}catch{}else if(i.includes("octet-stream"))try{o=await e.request.clone().arrayBuffer()}catch{}else if(i.includes("image"))try{o=await e.request.clone().blob()}catch{}else try{o=await e.request.clone().text()}catch{}return self.clients.matchAll().then(l=>{p(l,t,o)}),y(t.response,t.status??200,t.responseHeaders)})()))},m=e=>{e!==c&&console.warn(`[TWD] ⚠️ Version mismatch detected:
2
2
  Client version: ${e}
3
3
  Service Worker version: ${c}
4
4
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("chalk"),$=(e,t)=>{const f=[...e].filter(s=>!s.parent),o=(s,r=0)=>{const c=" ".repeat(r),u=t.find(a=>a.id===s.id);let n="",l="";s.type!=="suite"&&(u?.status==="pass"?n=i.green("✓"):u?.status==="fail"?(n=i.red("✗"),l=` - Error: ${u.error}`):n=i.yellow("○"));const p=s.type==="suite"?`${c}${s.name}`:`${c}${n} ${s.name}`;if(console.log(p),l&&console.log(i.red(`${c}${l}`)),s.children)for(const a of s.children){const d=e.find(y=>y.id===a);d&&o(d,r+1)}};for(const s of f)o(s)},g=async()=>{const e=window.__testRunner,t=[],o=await new e({onStart:()=>{},onPass:s=>{t.push({id:s.id,status:"pass"})},onFail:(s,r)=>{t.push({id:s.id,status:"fail",error:r.message})},onSkip:s=>{t.push({id:s.id,status:"skip"})}}).runAll();return{handlers:Array.from(o.values()),testStatus:t}};exports.executeTests=g;exports.reportResults=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./_commonjsHelpers-DwGv2jUC.js");var n={exports:{}},d;function w(){if(d)return n.exports;d=1;var e=String,t=function(){return{isColorSupported:!1,reset:e,bold:e,dim:e,italic:e,underline:e,inverse:e,hidden:e,strikethrough:e,black:e,red:e,green:e,yellow:e,blue:e,magenta:e,cyan:e,white:e,gray:e,bgBlack:e,bgRed:e,bgGreen:e,bgYellow:e,bgBlue:e,bgMagenta:e,bgCyan:e,bgWhite:e,blackBright:e,redBright:e,greenBright:e,yellowBright:e,blueBright:e,magentaBright:e,cyanBright:e,whiteBright:e,bgBlackBright:e,bgRedBright:e,bgGreenBright:e,bgYellowBright:e,bgBlueBright:e,bgMagentaBright:e,bgCyanBright:e,bgWhiteBright:e}};return n.exports=t(),n.exports.createColors=t,n.exports}var y=w();const l=B.getDefaultExportFromCjs(y),m=(e,t)=>{const p=[...e].filter(r=>!r.parent),o=(r,s=0)=>{const a=" ".repeat(s),c=t.find(u=>u.id===r.id);let i="",g="";r.type!=="suite"&&(c?.status==="pass"?i=l.green("✓"):c?.status==="fail"?(i=l.red("✗"),g=` - Error: ${c.error}`):i=l.yellow("○"));const h=r.type==="suite"?`${a}${r.name}`:`${a}${i} ${r.name}`;if(console.log(h),g&&console.log(l.red(`${a}${g}`)),r.children)for(const u of r.children){const b=e.find(f=>f.id===u);b&&o(b,s+1)}};for(const r of p)o(r)},x=async()=>{const e=window.__testRunner,t=[],o=await new e({onStart:()=>{},onPass:r=>{t.push({id:r.id,status:"pass"})},onFail:(r,s)=>{t.push({id:r.id,status:"fail",error:s.message})},onSkip:r=>{t.push({id:r.id,status:"skip"})}}).runAll();return{handlers:Array.from(o.values()),testStatus:t}};exports.executeTests=x;exports.reportResults=m;
@@ -1,12 +1,28 @@
1
- import { Handler } from './runner';
2
- interface TestResult {
3
- id: string;
4
- status: 'pass' | 'fail' | 'skip';
5
- error?: string;
6
- }
7
- export declare const reportResults: (handlers: Handler[], testResults: TestResult[]) => void;
8
- export declare const executeTests: () => Promise<{
9
- handlers: Handler[];
10
- testStatus: TestResult[];
11
- }>;
12
- export {};
1
+ export declare const executeTests: () => Promise<{
2
+ handlers: Handler[];
3
+ testStatus: TestResult[];
4
+ }>;
5
+
6
+ declare interface Handler {
7
+ id: string;
8
+ name: string;
9
+ parent?: string;
10
+ handler: () => void | Promise<void>;
11
+ children?: string[];
12
+ type: 'suite' | 'test';
13
+ status?: 'idle' | 'pass' | 'fail' | 'skip' | 'running';
14
+ logs: string[];
15
+ depth: number;
16
+ only?: boolean;
17
+ skip?: boolean;
18
+ }
19
+
20
+ export declare const reportResults: (handlers: Handler[], testResults: TestResult[]) => void;
21
+
22
+ declare interface TestResult {
23
+ id: string;
24
+ status: 'pass' | 'fail' | 'skip';
25
+ error?: string;
26
+ }
27
+
28
+ export { }
@@ -1,34 +1,44 @@
1
- import i from "chalk";
2
- const y = (e, t) => {
3
- const f = [...e].filter((s) => !s.parent), o = (s, r = 0) => {
4
- const c = " ".repeat(r), a = t.find((u) => u.id === s.id);
5
- let n = "", l = "";
6
- s.type !== "suite" && (a?.status === "pass" ? n = i.green("✓") : a?.status === "fail" ? (n = i.red("✗"), l = ` - Error: ${a.error}`) : n = i.yellow("○"));
7
- const d = s.type === "suite" ? `${c}${s.name}` : `${c}${n} ${s.name}`;
8
- if (console.log(d), l && console.log(i.red(`${c}${l}`)), s.children)
9
- for (const u of s.children) {
10
- const p = e.find(($) => $.id === u);
11
- p && o(p, r + 1);
1
+ import { g as B } from "./_commonjsHelpers-C6fGbg64.mjs";
2
+ var n = { exports: {} }, h;
3
+ function w() {
4
+ if (h) return n.exports;
5
+ h = 1;
6
+ var r = String, t = function() {
7
+ return { isColorSupported: !1, reset: r, bold: r, dim: r, italic: r, underline: r, inverse: r, hidden: r, strikethrough: r, black: r, red: r, green: r, yellow: r, blue: r, magenta: r, cyan: r, white: r, gray: r, bgBlack: r, bgRed: r, bgGreen: r, bgYellow: r, bgBlue: r, bgMagenta: r, bgCyan: r, bgWhite: r, blackBright: r, redBright: r, greenBright: r, yellowBright: r, blueBright: r, magentaBright: r, cyanBright: r, whiteBright: r, bgBlackBright: r, bgRedBright: r, bgGreenBright: r, bgYellowBright: r, bgBlueBright: r, bgMagentaBright: r, bgCyanBright: r, bgWhiteBright: r };
8
+ };
9
+ return n.exports = t(), n.exports.createColors = t, n.exports;
10
+ }
11
+ var y = /* @__PURE__ */ w();
12
+ const a = /* @__PURE__ */ B(y), m = (r, t) => {
13
+ const p = [...r].filter((e) => !e.parent), o = (e, s = 0) => {
14
+ const g = " ".repeat(s), l = t.find((u) => u.id === e.id);
15
+ let i = "", c = "";
16
+ e.type !== "suite" && (l?.status === "pass" ? i = a.green("✓") : l?.status === "fail" ? (i = a.red("✗"), c = ` - Error: ${l.error}`) : i = a.yellow("○"));
17
+ const d = e.type === "suite" ? `${g}${e.name}` : `${g}${i} ${e.name}`;
18
+ if (console.log(d), c && console.log(a.red(`${g}${c}`)), e.children)
19
+ for (const u of e.children) {
20
+ const b = r.find((f) => f.id === u);
21
+ b && o(b, s + 1);
12
22
  }
13
23
  };
14
- for (const s of f) o(s);
15
- }, g = async () => {
16
- const e = window.__testRunner, t = [], o = await new e({
24
+ for (const e of p) o(e);
25
+ }, $ = async () => {
26
+ const r = window.__testRunner, t = [], o = await new r({
17
27
  onStart: () => {
18
28
  },
19
- onPass: (s) => {
20
- t.push({ id: s.id, status: "pass" });
29
+ onPass: (e) => {
30
+ t.push({ id: e.id, status: "pass" });
21
31
  },
22
- onFail: (s, r) => {
23
- t.push({ id: s.id, status: "fail", error: r.message });
32
+ onFail: (e, s) => {
33
+ t.push({ id: e.id, status: "fail", error: s.message });
24
34
  },
25
- onSkip: (s) => {
26
- t.push({ id: s.id, status: "skip" });
35
+ onSkip: (e) => {
36
+ t.push({ id: e.id, status: "skip" });
27
37
  }
28
38
  }).runAll();
29
39
  return { handlers: Array.from(o.values()), testStatus: t };
30
40
  };
31
41
  export {
32
- g as executeTests,
33
- y as reportResults
42
+ $ as executeTests,
43
+ m as reportResults
34
44
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=new Map,i=new Map,c=new Map,a=[],h=()=>Math.random().toString(36).substr(2,9),f=(o,t)=>{const s=h(),e=a.at(-1);r.set(s,{id:s,name:o,type:"suite",children:[],logs:[],depth:a.length,parent:e,handler:t}),e&&r.get(e).children.push(s),a.push(s),t(),a.pop()},l=(o,t)=>{const s=h(),e=a.at(-1),n={id:s,name:o,type:"test",depth:a.length,handler:t,logs:[],parent:e};e&&r.get(e).children.push(s),r.set(s,n)};l.only=(o,t)=>{const s=h(),e=a.at(-1),n={id:s,name:o,type:"test",depth:a.length,handler:t,logs:[],parent:e,only:!0};e&&r.get(e).children.push(s),r.set(s,n)};l.skip=(o,t)=>{const s=h(),e=a.at(-1),n={id:s,name:o,type:"test",depth:a.length,handler:t||(()=>{}),logs:[],parent:e,skip:!0};e&&r.get(e).children.push(s),r.set(s,n)};const p=o=>{const t=a.at(-1);if(!t)throw new Error("beforeEach() must be inside a describe()");i.has(t)||i.set(t,[]),i.get(t).push(o)},d=o=>{const t=a.at(-1);if(!t)throw new Error("afterEach() must be inside a describe()");c.has(t)||c.set(t,[]),c.get(t).push(o)},g=o=>{const t=[],s=[];let e=o;for(;e;)i.has(e)&&t.unshift(...i.get(e)),c.has(e)&&s.push(...c.get(e)),e=r.get(e)?.parent;return{before:t,after:s}},y=()=>{r.clear(),i.clear(),c.clear()};class u{events;constructor(t){this.events=t}async runAll(){const t=Array.from(r.values()).filter(e=>!e.parent&&e.type==="suite"),s=Array.from(r.values()).some(e=>e.only);for(const e of t)await this.runSuite(e,s);return r}async runSingle(t){const s=r.get(t);if(!s||s.type!=="test")return;await this.runTest(s,!1)}async runSuite(t,s){this.events.onSuiteStart?.(t);const e=(t.children||[]).map(n=>r.get(n));for(const n of e)n.type==="suite"?await this.runSuite(n,s):n.type==="test"&&await this.runTest(n,s);this.events.onSuiteEnd?.(t)}async runTest(t,s){if(t.skip){this.events.onSkip(t);return}if(s&&!t.only)return;this.events.onStart?.(t);const e=g(t.parent);try{for(const n of e.before)await n();t.logs=[],await t.handler(),this.events.onPass(t)}catch(n){this.events.onFail(t,n)}finally{for(const n of e.after)await n()}}}window.__testRunner=u;exports.TestRunner=u;exports.afterEach=d;exports.beforeEach=p;exports.clearTests=y;exports.describe=f;exports.handlers=r;exports.it=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=new Map,a=new Map,h=new Map,i=[],l=()=>Math.random().toString(36).substr(2,9),f=(r,t)=>{const e=l(),n=i.at(-1);s.set(e,{id:e,name:r,type:"suite",children:[],logs:[],depth:i.length,parent:n,handler:t}),n&&s.get(n).children.push(e),i.push(e),t(),i.pop()};f.only=(r,t)=>{const e=l(),n=i.at(-1);s.set(e,{id:e,name:r,type:"suite",children:[],logs:[],depth:i.length,parent:n,handler:t,only:!0}),n&&s.get(n).children.push(e),i.push(e),t(),i.pop()};f.skip=(r,t)=>{const e=l(),n=i.at(-1);s.set(e,{id:e,name:r,type:"suite",children:[],logs:[],depth:i.length,parent:n,handler:t,skip:!0}),n&&s.get(n).children.push(e),i.push(e),t(),i.pop()};const d=(r,t)=>{const e=l(),n=i.at(-1),o={id:e,name:r,type:"test",depth:i.length,handler:t,logs:[],parent:n};n&&s.get(n).children.push(e),s.set(e,o)};d.only=(r,t)=>{const e=l(),n=i.at(-1),o={id:e,name:r,type:"test",depth:i.length,handler:t,logs:[],parent:n,only:!0};n&&s.get(n).children.push(e),s.set(e,o)};d.skip=(r,t)=>{const e=l(),n=i.at(-1),o={id:e,name:r,type:"test",depth:i.length,handler:t||(()=>{}),logs:[],parent:n,skip:!0};n&&s.get(n).children.push(e),s.set(e,o)};const S=r=>{const t=i.at(-1);if(!t)throw new Error("beforeEach() must be inside a describe()");a.has(t)||a.set(t,[]),a.get(t).push(r)},k=r=>{const t=i.at(-1);if(!t)throw new Error("afterEach() must be inside a describe()");h.has(t)||h.set(t,[]),h.get(t).push(r)},w=r=>{const t=[],e=[];let n=r;for(;n;)a.has(n)&&t.unshift(...a.get(n)),h.has(n)&&e.push(...h.get(n)),n=s.get(n)?.parent;return{before:t,after:e}},u=r=>{const t=s.get(r);return t?t.only?!0:t.children?t.children.some(e=>u(e)):!1:!1},b=r=>{let t=s.get(r);for(;t?.parent;){const e=s.get(t.parent);if(e?.only)return!0;t=e}return!1},g=r=>{let t=s.get(r);for(;t;){if(t.skip)return!0;if(!t.parent)break;t=s.get(t.parent)}return!1},v=()=>{s.clear(),a.clear(),h.clear()};class y{events;constructor(t){this.events=t}async runAll(){const t=Array.from(s.values()).filter(n=>!n.parent&&n.type==="suite"),e=Array.from(s.values()).some(n=>n.only);for(const n of t)await this.runSuite(n,e);return s}async runSingle(t){const e=s.get(t);if(!e||e.type!=="test")return;await this.runTest(e,!1)}async runSuite(t,e){if(g(t.id)&&!u(t.id)){this.events.onSkip?.(t);return}if(e&&!u(t.id))return;this.events.onSuiteStart?.(t);const o=(t.children||[]).map(c=>s.get(c));for(const c of o)c.type==="suite"?await this.runSuite(c,e):c.type==="test"&&await this.runTest(c,e);this.events.onSuiteEnd?.(t)}async runTest(t,e){if((g(t.id)||t.skip)&&!t.only){this.events.onSkip(t);return}const o=b(t.id);if(e&&!t.only&&!o){this.events.onSkip(t);return}this.events.onStart?.(t);const c=w(t.parent);try{for(const p of c.before)await p();t.logs=[],await t.handler(),this.events.onPass(t)}catch(p){this.events.onFail(t,p)}finally{for(const p of c.after)await p()}}}window.__testRunner=y;exports.TestRunner=y;exports.afterEach=k;exports.beforeEach=S;exports.clearTests=v;exports.describe=f;exports.handlers=s;exports.it=d;
package/dist/runner.d.ts CHANGED
@@ -1,41 +1,55 @@
1
- export interface Handler {
2
- id: string;
3
- name: string;
4
- parent?: string;
5
- handler: () => void | Promise<void>;
6
- children?: string[];
7
- type: 'suite' | 'test';
8
- status?: 'idle' | 'pass' | 'fail' | 'skip' | 'running';
9
- logs: string[];
10
- depth: number;
11
- only?: boolean;
12
- skip?: boolean;
13
- }
14
- type HookFn = () => void | Promise<void>;
15
- export declare const handlers: Map<string, Handler>;
16
- export declare const describe: (name: string, handler: () => void) => void;
17
- export declare const it: {
18
- (name: string, handler: () => void | Promise<void>): void;
19
- only(name: string, handler: () => void | Promise<void>): void;
20
- skip(name: string, handler?: () => void | Promise<void>): void;
21
- };
22
- export declare const beforeEach: (fn: HookFn) => void;
23
- export declare const afterEach: (fn: HookFn) => void;
24
- export declare const clearTests: () => void;
25
- export interface RunnerEvents {
26
- onStart: (test: Handler) => void;
27
- onPass: (test: Handler) => void;
28
- onFail: (test: Handler, error: Error) => void;
29
- onSkip: (test: Handler) => void;
30
- onSuiteStart?: (suite: Handler) => void;
31
- onSuiteEnd?: (suite: Handler) => void;
32
- }
33
- export declare class TestRunner {
34
- private events;
35
- constructor(events: RunnerEvents);
36
- runAll(): Promise<Map<string, Handler>>;
37
- runSingle(id: string): Promise<void>;
38
- private runSuite;
39
- private runTest;
40
- }
41
- export {};
1
+ export declare const afterEach: (fn: HookFn) => void;
2
+
3
+ export declare const beforeEach: (fn: HookFn) => void;
4
+
5
+ export declare const clearTests: () => void;
6
+
7
+ export declare const describe: {
8
+ (name: string, handler: () => void): void;
9
+ only(name: string, handler: () => void): void;
10
+ skip(name: string, handler: () => void): void;
11
+ };
12
+
13
+ export declare interface Handler {
14
+ id: string;
15
+ name: string;
16
+ parent?: string;
17
+ handler: () => void | Promise<void>;
18
+ children?: string[];
19
+ type: 'suite' | 'test';
20
+ status?: 'idle' | 'pass' | 'fail' | 'skip' | 'running';
21
+ logs: string[];
22
+ depth: number;
23
+ only?: boolean;
24
+ skip?: boolean;
25
+ }
26
+
27
+ export declare const handlers: Map<string, Handler>;
28
+
29
+ declare type HookFn = () => void | Promise<void>;
30
+
31
+ export declare const it: {
32
+ (name: string, handler: () => void | Promise<void>): void;
33
+ only(name: string, handler: () => void | Promise<void>): void;
34
+ skip(name: string, handler?: () => void | Promise<void>): void;
35
+ };
36
+
37
+ export declare interface RunnerEvents {
38
+ onStart: (test: Handler) => void;
39
+ onPass: (test: Handler) => void;
40
+ onFail: (test: Handler, error: Error) => void;
41
+ onSkip: (test: Handler) => void;
42
+ onSuiteStart?: (suite: Handler) => void;
43
+ onSuiteEnd?: (suite: Handler) => void;
44
+ }
45
+
46
+ export declare class TestRunner {
47
+ private events;
48
+ constructor(events: RunnerEvents);
49
+ runAll(): Promise<Map<string, Handler>>;
50
+ runSingle(id: string): Promise<void>;
51
+ private runSuite;
52
+ private runTest;
53
+ }
54
+
55
+ export { }