twd-js 1.3.0 → 1.3.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.
- package/README.md +9 -2
- package/dist/bundled.es.js +801 -46108
- package/dist/bundled.umd.js +2 -307
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +1081 -1081
- package/dist/mock-sw.js +1 -1
- package/package.json +5 -3
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.3.
|
|
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.3.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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Test While Developing (TWD) - in-browser testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BRIKEV",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"node": ">=16"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
|
-
"build": "vite build && vite build -c vite.sw.config.js && vite build -c vite.bundle.config.ts && cp src/cli/installsw.js dist/cli.js",
|
|
63
|
+
"build": "vite build && vite build -c vite.sw.config.js && NODE_ENV=production vite build -c vite.bundle.config.ts && cp src/cli/installsw.js dist/cli.js",
|
|
64
64
|
"test": "vitest",
|
|
65
65
|
"test:ci": "vitest --run --coverage",
|
|
66
66
|
"conventional-changelog": "conventional-changelog -i CHANGELOG.md",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"react-dom": ">=17.0.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
+
"@preact/preset-vite": "^2.10.2",
|
|
77
78
|
"@testing-library/jest-dom": "^6.9.1",
|
|
78
79
|
"@testing-library/react": "^16.3.0",
|
|
79
80
|
"@types/react": "^19.2.7",
|
|
@@ -102,6 +103,7 @@
|
|
|
102
103
|
"@testing-library/dom": "^10.4.1",
|
|
103
104
|
"@testing-library/user-event": "^14.6.1",
|
|
104
105
|
"@types/chai": "^5.2.3",
|
|
105
|
-
"chai": "^6.2.1"
|
|
106
|
+
"chai": "^6.2.1",
|
|
107
|
+
"preact": "^10.28.0"
|
|
106
108
|
}
|
|
107
109
|
}
|