twd-js 1.2.0 → 1.2.2

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.
@@ -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.2.0";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.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:
2
2
  Client version: ${e}
3
3
  Service Worker version: ${c}
4
4
 
package/dist/ui.cjs.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./jsx-runtime-DN5DOl8k.js");function r({name:n,children:o}){const e=t.getMockForComponent(n);return e?t.jsxRuntimeExports.jsx(e,{...o.props}):o}exports.MockedComponent=r;
package/dist/ui.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+
3
+ export declare function MockedComponent<TProps extends Record<string, any>>({ name, children, }: MockedComponentProps<TProps>): JSX.Element;
4
+
5
+ declare interface MockedComponentProps<TProps = any> {
6
+ name: string;
7
+ children: React.ReactElement<TProps>;
8
+ }
9
+
10
+ export { }
package/dist/ui.es.js ADDED
@@ -0,0 +1,11 @@
1
+ import { g as r, j as e } from "./jsx-runtime-CtyxV31n.mjs";
2
+ function s({
3
+ name: n,
4
+ children: o
5
+ }) {
6
+ const t = r(n);
7
+ return t ? /* @__PURE__ */ e.jsx(t, { ...o.props }) : o;
8
+ }
9
+ export {
10
+ s as MockedComponent
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twd-js",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Test While Developing (TWD) - in-browser testing",
5
5
  "license": "MIT",
6
6
  "author": "BRIKEV",
@@ -38,6 +38,11 @@
38
38
  "types": "./dist/runner-ci.d.ts",
39
39
  "import": "./dist/runner-ci.es.js",
40
40
  "require": "./dist/runner-ci.cjs.js"
41
+ },
42
+ "./ui": {
43
+ "types": "./dist/ui.d.ts",
44
+ "import": "./dist/ui.es.js",
45
+ "require": "./dist/ui.cjs.js"
41
46
  }
42
47
  },
43
48
  "files": [