twd-js 1.3.2 → 1.3.4
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 +19 -15
- package/dist/bundled.es.js +2 -2
- package/dist/bundled.umd.js +2 -2
- package/dist/index.cjs.js +28 -28
- package/dist/index.d.ts +31 -0
- package/dist/index.es.js +1920 -1919
- package/dist/{jsx-runtime-DqUUEvWR.mjs → jsx-runtime-BGWd3k7q.mjs} +2 -2
- package/dist/mock-sw.js +1 -1
- package/dist/ui.es.js +1 -1
- package/dist/vite-plugin.cjs.js +1 -1
- package/dist/vite-plugin.d.ts +46 -0
- package/dist/vite-plugin.es.js +21 -5
- package/package.json +9 -9
|
@@ -11,7 +11,7 @@ var F;
|
|
|
11
11
|
function re() {
|
|
12
12
|
if (F) return _;
|
|
13
13
|
F = 1;
|
|
14
|
-
var o = Symbol.for("react.transitional.element"), l = Symbol.for("react.fragment");
|
|
14
|
+
var o = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
15
15
|
function i(f, s, u) {
|
|
16
16
|
var m = null;
|
|
17
17
|
if (u !== void 0 && (m = "" + u), s.key !== void 0 && (m = "" + s.key), "key" in s) {
|
|
@@ -226,7 +226,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
226
226
|
function y(e) {
|
|
227
227
|
return typeof e == "object" && e !== null && e.$$typeof === j;
|
|
228
228
|
}
|
|
229
|
-
var R = ee, j = Symbol.for("react.transitional.element"), W = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), U = Symbol.for("react.strict_mode"), q = Symbol.for("react.profiler"), J = Symbol.for("react.consumer"), V = Symbol.for("react.context"), z = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), X = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), Z = Symbol.for("react.client.reference"), k = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, Q = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
229
|
+
var R = ee, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), W = /* @__PURE__ */ Symbol.for("react.portal"), v = /* @__PURE__ */ Symbol.for("react.fragment"), U = /* @__PURE__ */ Symbol.for("react.strict_mode"), q = /* @__PURE__ */ Symbol.for("react.profiler"), J = /* @__PURE__ */ Symbol.for("react.consumer"), V = /* @__PURE__ */ Symbol.for("react.context"), z = /* @__PURE__ */ Symbol.for("react.forward_ref"), G = /* @__PURE__ */ Symbol.for("react.suspense"), X = /* @__PURE__ */ Symbol.for("react.suspense_list"), B = /* @__PURE__ */ Symbol.for("react.memo"), T = /* @__PURE__ */ Symbol.for("react.lazy"), H = /* @__PURE__ */ Symbol.for("react.activity"), Z = /* @__PURE__ */ Symbol.for("react.client.reference"), k = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, Q = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
230
230
|
return null;
|
|
231
231
|
};
|
|
232
232
|
R = {
|
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.4";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.es.js
CHANGED
package/dist/vite-plugin.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("fs"),c=require("path");function l(){return{name:"remove-mock-sw",apply:"build",closeBundle(){try{n.rmSync(c.resolve("dist/mock-sw.js")),console.log("🧹 Removed mock-sw.js from build")}catch{console.log("🧹 No mock-sw.js found in build")}}}}function i(o={}){const{testFilePattern:e=".twd.test.ts"}=o,r=typeof e=="function"?e:t=>t.endsWith(e);return{name:"twd-hmr",apply:"serve",handleHotUpdate({file:t,server:s}){if(r(t))return s.ws.send({type:"full-reload",path:"*"}),[]}}}exports.removeMockServiceWorker=l;exports.twdHmr=i;
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -18,4 +18,50 @@ import { Plugin as Plugin_2 } from 'vite';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function removeMockServiceWorker(): Plugin_2;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Vite plugin to handle HMR for TWD test files.
|
|
23
|
+
* When a TWD test file is updated, it forces a full page reload to prevent
|
|
24
|
+
* duplicate test entries that occur when HMR reloads test modules.
|
|
25
|
+
*
|
|
26
|
+
* This plugin only runs in development mode (serve) and does not affect Vitest test runs.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Configuration options for the plugin
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { twdHmr } from 'twd-js/vite-plugin';
|
|
32
|
+
*
|
|
33
|
+
* export default defineConfig({
|
|
34
|
+
* plugins: [
|
|
35
|
+
* // ... other plugins
|
|
36
|
+
* twdHmr() // Uses default pattern: .twd.test.ts
|
|
37
|
+
* ]
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // Custom pattern
|
|
43
|
+
* twdHmr({ testFilePattern: '.twd.test.tsx' })
|
|
44
|
+
* ```
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // Custom function
|
|
48
|
+
* twdHmr({
|
|
49
|
+
* testFilePattern: (file) => file.includes('.twd.test.')
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function twdHmr(options?: TwdHmrOptions): Plugin_2;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Options for the TWD HMR plugin.
|
|
57
|
+
*/
|
|
58
|
+
export declare interface TwdHmrOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Pattern to match test files. Defaults to `.twd.test.ts`.
|
|
61
|
+
* Can be a string (checked with `endsWith`) or a function that returns a boolean.
|
|
62
|
+
* @default ".twd.test.ts"
|
|
63
|
+
*/
|
|
64
|
+
testFilePattern?: string | ((file: string) => boolean);
|
|
65
|
+
}
|
|
66
|
+
|
|
21
67
|
export { }
|
package/dist/vite-plugin.es.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import { rmSync as
|
|
2
|
-
import { resolve as
|
|
3
|
-
function
|
|
1
|
+
import { rmSync as s } from "fs";
|
|
2
|
+
import { resolve as l } from "path";
|
|
3
|
+
function i() {
|
|
4
4
|
return {
|
|
5
5
|
name: "remove-mock-sw",
|
|
6
6
|
apply: "build",
|
|
7
7
|
closeBundle() {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
s(l("dist/mock-sw.js")), console.log("🧹 Removed mock-sw.js from build");
|
|
10
10
|
} catch {
|
|
11
11
|
console.log("🧹 No mock-sw.js found in build");
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
+
function d(t = {}) {
|
|
17
|
+
const { testFilePattern: e = ".twd.test.ts" } = t, r = typeof e == "function" ? e : (o) => o.endsWith(e);
|
|
18
|
+
return {
|
|
19
|
+
name: "twd-hmr",
|
|
20
|
+
apply: "serve",
|
|
21
|
+
// Only run in dev mode, not during Vitest test runs
|
|
22
|
+
handleHotUpdate({ file: o, server: n }) {
|
|
23
|
+
if (r(o))
|
|
24
|
+
return n.ws.send({
|
|
25
|
+
type: "full-reload",
|
|
26
|
+
path: "*"
|
|
27
|
+
}), [];
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
16
31
|
export {
|
|
17
|
-
|
|
32
|
+
i as removeMockServiceWorker,
|
|
33
|
+
d as twdHmr
|
|
18
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twd-js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Test While Developing (TWD) - in-browser testing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BRIKEV",
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@preact/preset-vite": "^2.10.2",
|
|
78
78
|
"@testing-library/jest-dom": "^6.9.1",
|
|
79
|
-
"@testing-library/react": "^16.3.
|
|
79
|
+
"@testing-library/react": "^16.3.1",
|
|
80
80
|
"@types/react": "^19.2.7",
|
|
81
81
|
"@types/react-dom": "^19.2.3",
|
|
82
|
-
"@vitejs/plugin-react": "^5.1.
|
|
83
|
-
"@vitest/coverage-v8": "^4.0.
|
|
82
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
83
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
84
84
|
"conventional-changelog": "^7.1.1",
|
|
85
|
-
"jsdom": "^27.
|
|
85
|
+
"jsdom": "^27.4.0",
|
|
86
86
|
"typescript": "^5.9.3",
|
|
87
|
-
"vite": "^7.
|
|
87
|
+
"vite": "^7.3.0",
|
|
88
88
|
"vite-plugin-dts": "^4.5.4",
|
|
89
89
|
"vitepress": "^2.0.0-alpha.12",
|
|
90
|
-
"vitest": "^4.0.
|
|
90
|
+
"vitest": "^4.0.16"
|
|
91
91
|
},
|
|
92
92
|
"keywords": [
|
|
93
93
|
"testing",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@testing-library/dom": "^10.4.1",
|
|
104
104
|
"@testing-library/user-event": "^14.6.1",
|
|
105
105
|
"@types/chai": "^5.2.3",
|
|
106
|
-
"chai": "^6.2.
|
|
107
|
-
"preact": "^10.28.
|
|
106
|
+
"chai": "^6.2.2",
|
|
107
|
+
"preact": "^10.28.1"
|
|
108
108
|
}
|
|
109
109
|
}
|