@recursica/adapter-tester 2.0.1 → 2.0.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.
package/README.md CHANGED
@@ -40,7 +40,7 @@ Both boot Storybooks themselves — nothing needs to be running beforehand.
40
40
 
41
41
  ## Interactive Dev Mode
42
42
 
43
- The **Dev Mode** is a powerful visual auditing tool that syncs the source-of-truth and target Storybooks in real-time. When you interact with controls (like toggling 'disabled' or changing 'size') in the left pane, Dev Mode instantly updates the right pane to match that exact state.
43
+ The **Dev Mode** is a powerful visual auditing tool that syncs the target adapter's and source-of-truth's Storybooks in real-time. The left pane is this project's own Storybook (with its full nav sidebar) and drives the sync; when you interact with controls (like toggling 'disabled' or changing 'size') there, Dev Mode instantly updates the right pane — the source of truth — to match that exact state.
44
44
 
45
45
  ### How to Start
46
46
 
package/dist/cli.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  "use strict";const Lt=require("node:child_process"),ge=require("node:fs"),se=require("node:path"),Kt=require("node:url"),Tn=require("node:net"),jn=require("express"),In=require("http-proxy-middleware"),qn=require("./mantineSourceOfTruth-D6tezfE1.cjs");var Re=typeof document<"u"?document.currentScript:null;const Yt=se.dirname(Kt.fileURLToPath(typeof document>"u"?require("url").pathToFileURL(__filename).href:Re&&Re.tagName.toUpperCase()==="SCRIPT"&&Re.src||new URL("cli.cjs",document.baseURI).href));function zt(e){return new Promise(t=>{const m=new Tn.Socket;m.setTimeout(200),m.once("connect",()=>{m.destroy(),t(!0)}),m.once("timeout",()=>{m.destroy(),t(!1)}),m.once("error",()=>{m.destroy(),t(!1)}),m.connect(e,"127.0.0.1")})}async function Zt(e,t=6e4){const m=Date.now();for(;Date.now()-m<t;){if(await zt(e))return!0;await new Promise(c=>setTimeout(c,500))}return!1}function Qt(e){return Number(new URL(e).port)}function Xt(e,t){var c,b;console.log(`[Dev Launcher] Port ${t.port} is inactive. Launching Storybook for ${e}...`);const m=Lt.spawn(t.command,{cwd:t.cwd,stdio:"pipe",shell:!0});return(c=m.stdout)==null||c.on("data",s=>{for(const l of s.toString().split(`
3
3
  `))l.trim()&&console.log(`[${e} SB] ${l.trim()}`)}),(b=m.stderr)==null||b.on("data",s=>{for(const l of s.toString().split(`
4
4
  `))l.trim()&&console.error(`[${e} SB ERROR] ${l.trim()}`)}),m.on("error",s=>{console.error(`[${e} SB ERROR] Failed to start process:`,s)}),m}function Cn(e){const t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";console.log(`[Dev Launcher] Auto-launching browser: ${e}`),Lt.spawn(t,[e],{shell:process.platform==="win32"}).on("error",m=>{console.error("[Dev Launcher] Failed to auto-launch browser:",m)})}function Dn(e,t,m={}){const[c,b]=e.targets,[s,l]=t;if(!(c!=null&&c.sourceOfTruth)||!b||b.sourceOfTruth||!s||!l)throw new Error("adapter-tester dev mode requires exactly two targets: [sourceOfTruth, target] — check adapter-tester.config.json.");const u=m.port??6010,h=Qt(c.url),$=Qt(b.url),_=jn(),P=se.join(Yt,"../public"),v=se.join(Yt,"../report-header.txt");_.get("/",(a,i,r)=>{if(a.query.path){r();return}const o=ge.readFileSync(se.join(P,"index.html"),"utf8").replace("<head>",`<head>
5
- <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({sourceOfTruthName:c.name,targetName:b.name,targetPort:$})};<\/script>`);i.send(o)}),_.get("/report-header.txt",(a,i)=>{try{i.type("text/plain").send(ge.readFileSync(v,"utf8"))}catch{i.status(500).send("Error loading report-header.txt")}}),_.use("/",In.createProxyMiddleware({target:`http://localhost:${h}`,changeOrigin:!0,ws:!0}));const y=[];let g=!1;const w=()=>{if(!g){g=!0,console.log(`
5
+ <script>window.__ADAPTER_TESTER__ = ${JSON.stringify({ownName:b.name,sourceOfTruthName:c.name,sourceOfTruthPort:h})};<\/script>`);i.send(o)}),_.get("/report-header.txt",(a,i)=>{try{i.type("text/plain").send(ge.readFileSync(v,"utf8"))}catch{i.status(500).send("Error loading report-header.txt")}}),_.use("/",In.createProxyMiddleware({target:`http://localhost:${$}`,changeOrigin:!0,ws:!0}));const y=[];let g=!1;const w=()=>{if(!g){g=!0,console.log(`
6
6
  [Dev Launcher] Shutting down Dev Mode server and spawned Storybooks...`);for(const a of y)a.kill("SIGINT");process.exit(0)}};process.on("SIGINT",w),process.on("SIGTERM",w),_.listen(u,async()=>{console.log(`
7
7
  ====================================================
8
8
  🚀 Adapter Dev Mode proxy running at: