@uicopilot/storybook-addon 0.5.7 → 0.5.9

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/dist/preset.d.mts CHANGED
@@ -27,7 +27,7 @@ declare function experimental_serverChannel(channel: Channel): Channel;
27
27
  declare function viteFinal(config: any): any;
28
28
 
29
29
  /**
30
- * UI Copilot Storybook Addon - Preset
30
+ * UI Parity Storybook Addon - Preset
31
31
  *
32
32
  * This file tells Storybook where to find the addon's manager entry point.
33
33
  * The experimental_serverChannel is re-exported from @uicopilot/storybook-adapter
package/dist/preset.d.ts CHANGED
@@ -27,7 +27,7 @@ declare function experimental_serverChannel(channel: Channel): Channel;
27
27
  declare function viteFinal(config: any): any;
28
28
 
29
29
  /**
30
- * UI Copilot Storybook Addon - Preset
30
+ * UI Parity Storybook Addon - Preset
31
31
  *
32
32
  * This file tells Storybook where to find the addon's manager entry point.
33
33
  * The experimental_serverChannel is re-exported from @uicopilot/storybook-adapter
package/dist/preset.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var Se=Object.create;var $=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var Te=(e,o)=>()=>(e&&(o=e(e=0)),o);var G=(e,o)=>{for(var t in o)$(e,t,{get:o[t],enumerable:!0})},K=(e,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of be(o))!Oe.call(e,r)&&r!==t&&$(e,r,{get:()=>o[r],enumerable:!(s=Ie(o,r))||s.enumerable});return e};var F=(e,o,t)=>(t=e!=null?Se(ve(e)):{},K(o||!e||!e.__esModule?$(t,"default",{value:e,enumerable:!0}):t,e)),Ee=e=>K($({},"__esModule",{value:!0}),e);var ie={};G(ie,{detectFileType:()=>se,formatValidationResult:()=>Le,isValidCode:()=>Me,validateCode:()=>re,validateCodeForFile:()=>ne});function xe(e,o={}){let t=o.minLength??_e;return e.length<t?{code:"CODE_TOO_SHORT",message:`Code is too short (${e.length} chars). Minimum: ${t}. Likely incomplete or a snippet.`,severity:"error"}:null}function $e(e){let o=[/^[+-]{3}\s+[ab]\//m,/^@@\s+-\d+,\d+\s+\+\d+,\d+\s+@@/m,/^diff --git/m,/^index [a-f0-9]+\.\.[a-f0-9]+/m];for(let t of o)if(t.test(e))return{code:"CODE_IS_DIFF",message:"Code appears to be a diff/patch format, not complete file content.",severity:"error"};return null}function Fe(e){let o=e.split(`
2
- `).filter(r=>r.trim()),t=o.filter(r=>r.trim().startsWith("//")||r.trim().startsWith("/*")||r.trim().startsWith("*")||r.trim().startsWith("#"));if(o.length>0&&t.length/o.length>.8)return{code:"CODE_IS_INSTRUCTIONS",message:"Code appears to be mostly comments/instructions, not actual implementation.",severity:"error"};let s=[/^\/\/\s*(Change|Replace|Update|Modify|Add|Remove|Delete)\s+(from|to|this|the)/im,/^\/\/\s*To:/m,/^\/\/\s*From:/m];for(let r of s)if(r.test(e))return{code:"CODE_IS_INSTRUCTIONS",message:'Code contains instruction comments (e.g., "// Change from:" / "// To:") instead of actual code.',severity:"error"};return null}function Re(e){let o={"{":"}","[":"]","(":")"},t=[],s=!1,r="",c=!1;for(let h=0;h<e.length;h++){let i=e[h],u=e[h-1];if((i==='"'||i==="'"||i==="`")&&u!=="\\"){s?i===r&&(s=!1,c=!1):(s=!0,r=i,i==="`"&&(c=!0));continue}if(!s){if(o[i])t.push(o[i]);else if(Object.values(o).includes(i)&&t.pop()!==i)return{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets detected. Found unexpected '${i}'.`,severity:"warning"}}}return t.length>0?{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets. Missing: ${t.reverse().join("")}`,severity:"warning"}:null}function oe(e,o={}){let t=[],s=[];e.includes("import ")||t.push({code:"TSX_MISSING_IMPORTS",message:"Component file missing import statements. A complete file must have imports.",severity:"error"}),e.includes("export ")||t.push({code:"TSX_MISSING_EXPORTS",message:"Component file missing exports. A complete file must export something.",severity:"error"});let r=/import\s+(?:React|\{[^}]*\})\s+from\s+['"]react['"]/.test(e);/<[A-Z][a-zA-Z]*|<[a-z]+[\s/>]/.test(e)&&!r&&s.push({code:"TSX_NO_REACT_IMPORT",message:"JSX detected but no React import. OK for React 17+ with automatic runtime.",severity:"warning"}),/export\s+(default\s+)?function\s+\w+/.test(e)||/export\s+(const|let)\s+\w+\s*[:=]/.test(e)||/export\s+default\s+\w+/.test(e)||/export\s+\{[^}]+\}/.test(e)||s.push({code:"TSX_NO_COMPONENT_DEF",message:"No clear component definition found. Expected function or const export.",severity:"warning"});let i=[{pattern:/\.\.\.\s*$/,message:'Code ends with "..." - likely truncated'},{pattern:/\/\/\s*\.\.\./m,message:'Contains "// ..." - likely incomplete'},{pattern:/{\s*\/\*\s*\.\.\.\s*\*\/\s*}/m,message:'Contains "{/* ... */}" placeholder'}];for(let{pattern:u,message:f}of i)u.test(e)&&t.push({code:"TSX_INCOMPLETE",message:f,severity:"error"});return{errors:t,warnings:s}}function Ue(e,o={}){let t=[],s=[];(e.includes("import ")||e.includes("export "))&&t.push({code:"CSS_HAS_JS_CODE",message:"CSS file contains JavaScript import/export statements. Wrong file type.",severity:"error"}),/[.#\w\[\]]+\s*\{[\s\S]*?:\s*[^;]+;?[\s\S]*?\}/.test(e)||t.push({code:"CSS_INVALID_SYNTAX",message:"No valid CSS syntax found. Expected selector { property: value; } pattern.",severity:"error"});let c=(e.match(/\{[^}]+\}/g)||[]).length;return c===0&&t.push({code:"CSS_NO_RULES",message:"No CSS rules found. File appears empty or malformed.",severity:"error"}),(e.includes("/* ... */")||e.includes("// ..."))&&t.push({code:"CSS_INCOMPLETE",message:"CSS contains placeholder comments (/* ... */) - likely incomplete.",severity:"error"}),c>0&&c<3&&!o.allowPartial&&s.push({code:"CSS_FEW_RULES",message:`Only ${c} CSS rule(s) found. Might be incomplete.`,severity:"warning"}),{errors:t,warnings:s}}function Ne(e,o={}){let t=[],s=[];return e.includes("import ")||t.push({code:"STORIES_MISSING_IMPORTS",message:"Stories file missing import statements.",severity:"error"}),/@storybook\//.test(e)||t.push({code:"STORIES_NO_STORYBOOK_IMPORT",message:"Stories file must import from @storybook/* (e.g., @storybook/react).",severity:"error"}),e.includes("Meta")||e.includes("ComponentMeta")||s.push({code:"STORIES_NO_META_TYPE",message:"Stories file should have Meta type import for type safety.",severity:"warning"}),e.includes("StoryObj")||e.includes("ComponentStory")||e.includes("Story")||s.push({code:"STORIES_NO_STORY_TYPE",message:"Stories file should have StoryObj/Story type for type safety.",severity:"warning"}),e.includes("export default")||t.push({code:"STORIES_NO_DEFAULT_EXPORT",message:"Stories file must have a default export (meta configuration).",severity:"error"}),/export\s+const\s+\w+\s*[:=]/.test(e)||t.push({code:"STORIES_NO_STORY_EXPORTS",message:"Stories file must have at least one named export (story definition).",severity:"error"}),/import\s+\{?\s*\w+\s*\}?\s+from\s+['"]\.\//.test(e)||s.push({code:"STORIES_NO_COMPONENT_IMPORT",message:"Stories file should import the component being documented.",severity:"warning"}),(e.includes("// ... other")||e.includes("/* ... */"))&&t.push({code:"STORIES_INCOMPLETE",message:"Stories file contains placeholder comments - likely incomplete.",severity:"error"}),{errors:t,warnings:s}}function se(e){let o=e.toLowerCase();if(o.includes(".stories."))return"stories";switch(o.split(".").pop()){case"tsx":return"tsx";case"jsx":return"jsx";case"ts":return"ts";case"js":return"js";case"css":return"css";case"scss":return"scss";case"less":return"less";default:return"unknown"}}function re(e,o,t={}){let s={valid:!0,fileType:o,errors:[],warnings:[]},r=xe(e,t);r&&s.errors.push(r);let c=$e(e);c&&s.errors.push(c);let h=Fe(e);h&&s.errors.push(h);let i=Re(e);switch(i&&(t.strict?s.errors.push({...i,severity:"error"}):s.warnings.push(i)),o){case"stories":{let{errors:u,warnings:f}=Ne(e,t);s.errors.push(...u),s.warnings.push(...f);break}case"tsx":case"jsx":{let{errors:u,warnings:f}=oe(e,t);s.errors.push(...u),s.warnings.push(...f);break}case"css":case"scss":case"less":{let{errors:u,warnings:f}=Ue(e,t);s.errors.push(...u),s.warnings.push(...f);break}case"ts":case"js":{let{errors:u,warnings:f}=oe(e,t);s.errors.push(...u),s.warnings.push(...f.filter(n=>!n.code.includes("JSX")));break}default:break}return s.valid=s.errors.length===0,s}function ne(e,o,t={}){let s=se(o);return re(e,s,t)}function Me(e,o,t={}){return ne(e,o,t).valid}function Le(e){if(e.valid&&e.warnings.length===0)return`\u2713 Valid ${e.fileType} code`;let o=[];if(e.valid)o.push(`\u26A0 Valid ${e.fileType} code with warnings`);else{o.push(`\u2717 Invalid ${e.fileType} code`),o.push(""),o.push("Errors:");for(let t of e.errors)o.push(` - [${t.code}] ${t.message}`)}if(e.warnings.length>0){o.push(""),o.push("Warnings:");for(let t of e.warnings)o.push(` - [${t.code}] ${t.message}`)}return o.join(`
3
- `)}var _e,ae=Te(()=>{"use strict";_e=50});var Qe={};G(Qe,{experimental_serverChannel:()=>ge,managerEntries:()=>qe,previewAnnotations:()=>ze,viteFinal:()=>me});module.exports=Ee(Qe);var P=require("path"),X=require("url");var he=F(require("fs/promises")),M=F(require("path")),W=require("glob");var z=require("fs"),Q=require("module"),R=null,E=null,q=!1;async function B(){if(q)return!!R;if(q=!0,process.env.STORYBOOK_UICOPILOT_NO_PUPPETEER==="true")return console.log("[UI Copilot] Puppeteer disabled via STORYBOOK_UICOPILOT_NO_PUPPETEER flag"),!1;let e=(0,Q.createRequire)(process.cwd()+"/");try{return R=e("puppeteer"),console.log("[UI Copilot] Puppeteer loaded \u2014 server-side screenshots enabled"),!0}catch{}try{return R=e("puppeteer-core"),console.log("[UI Copilot] puppeteer-core loaded \u2014 server-side screenshots enabled"),!0}catch{}return console.log("[UI Copilot] Puppeteer not found \u2014 install puppeteer for pixel-perfect screenshots"),!1}function Pe(){let e=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium-browser","/usr/bin/chromium"];for(let o of e)if((0,z.existsSync)(o))return o}async function Z(){if(E&&E.connected)return E;let e=Pe(),o={headless:!0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"],...e?{executablePath:e}:{}};return E=await R.launch(o),console.log("[UI Copilot] Headless Chrome launched for screenshots"),E}async function H(e,o){if(!await B())return null;let r=await(await Z()).newPage();try{await r.setCacheEnabled(!1),await r.setViewport({width:o?.width||800,height:o?.height||600,deviceScaleFactor:1}),await r.goto(e,{waitUntil:"networkidle2",timeout:15e3}),await r.evaluate(()=>document.fonts.ready),await r.waitForSelector("#storybook-root > *",{timeout:1e4}),await r.waitForFunction(()=>new Promise(i=>{let u=document.querySelectorAll("style").length,f=0,n=()=>{let p=document.querySelectorAll("style").length;if(p===u){if(f++,f>=3){i(!0);return}}else f=0,u=p;setTimeout(n,100)};setTimeout(n,200)}),{timeout:5e3}).catch(()=>{}),await new Promise(i=>setTimeout(i,500));let c=await r.evaluate(()=>{let i=document.querySelector("#storybook-root");if(!i)return null;let u=window.innerWidth;function f(g){let a=g.getBoundingClientRect();if(a.width===0||a.height===0)return null;if(a.width<u*.8&&a.height>0)return a;for(let m of Array.from(g.children)){let d=window.getComputedStyle(m);if(d.position==="fixed"||d.position==="absolute"||d.display==="none"||d.visibility==="hidden")continue;let l=f(m);if(l)return l}return null}let n=f(i);if(n)return{x:Math.max(0,n.x-8),y:Math.max(0,n.y-8),width:n.width+16,height:n.height+16};let p=i.firstElementChild;if(p){let g=p.getBoundingClientRect();return{x:g.x,y:g.y,width:g.width,height:g.height}}return null});if(!c)throw new Error("Could not determine component bounds");let h=await r.screenshot({type:"png",clip:c});return Buffer.from(h)}finally{await r.close()}}async function ee(e,o,t,s){if(!await B())return null;let h=await(await Z()).newPage();try{await h.setCacheEnabled(!1),await h.setViewport({width:s?.width||800,height:s?.height||600,deviceScaleFactor:1});let i=s?.storyId||"",u=`${t}/iframe.html?viewMode=story&id=${i}&globals=`;await h.goto(u,{waitUntil:"load",timeout:15e3}),await h.waitForSelector("#storybook-root > *",{timeout:1e4}),await h.evaluate(p=>{let g=document.getElementById("storybook-root");g&&(g.innerHTML=p)},e),await h.evaluate(()=>document.fonts.ready),await new Promise(p=>setTimeout(p,500));let f=await h.evaluate(()=>{let p=document.querySelector("#storybook-root");if(!p)return null;let g=window.innerWidth;function a(l){let y=l.getBoundingClientRect();if(y.width===0||y.height===0)return null;if(y.width<g*.8&&y.height>0)return y;for(let v of Array.from(l.children)){let w=window.getComputedStyle(v);if(w.position==="fixed"||w.position==="absolute"||w.display==="none"||w.visibility==="hidden")continue;let C=a(v);if(C)return C}return null}let m=a(p);if(m)return{x:Math.max(0,m.x-8),y:Math.max(0,m.y-8),width:m.width+16,height:m.height+16};let d=p.firstElementChild;if(d){let l=d.getBoundingClientRect();return{x:l.x,y:l.y,width:l.width,height:l.height}}return null});if(!f)throw new Error("Could not determine component bounds from snapshot");let n=await h.screenshot({type:"png",clip:f});return Buffer.from(n)}finally{await h.close()}}async function U(){return B()}async function te(){E&&(await E.close(),E=null)}var J=null,N=null,le=!1;async function ke(){if(!le){le=!0;try{let e=await Promise.resolve().then(()=>(ae(),ie));J=e.validateCodeForFile,N=e.formatValidationResult,console.log("[UI Copilot] Code validator loaded - fix validation enabled")}catch{console.log("[UI Copilot] Code validator not available - skipping fix validation")}}}var Ae="UICOPILOT/APPLY_FIXES",De="UICOPILOT/FIX_STARTED",je="UICOPILOT/FIX_COMPLETED",Be="UICOPILOT/FIX_FAILED",ce="UICOPILOT/ALL_FIXES_APPLIED",He="UICOPILOT/RELOAD_REQUIRED",de="UICOPILOT/WORKSPACE_PATH",We="UICOPILOT/REQUEST_WORKSPACE_PATH",Je="UICOPILOT/DISCOVER_COMPONENT_FILES",ue="UICOPILOT/COMPONENT_FILES_DISCOVERED";async function pe(e,o){let t=e.toLowerCase(),s=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),r=[`src/**/fui-${t}/fui-${t}.css`,`src/**/fui-${t}/*.css`,`src/**/${t}/${t}.css`,`src/**/${s}/${s}.css`,`src/**/*${t}*.css`,`src/**/*${s}*.css`,`styles/**/*${t}*.css`],c=[`src/**/fui-${t}/fui-${t}.tsx`,`src/**/fui-${t}/*.tsx`,`src/**/${t}/${t}.tsx`,`src/**/${s}/${s}.tsx`,`src/**/*${s}*.tsx`,`src/**/*${s}*.jsx`],h=[],i=[];for(let d of r)try{let l=await(0,W.glob)(d,{cwd:o,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**"]});l.length>0&&h.push(...l)}catch{}for(let d of c)try{let l=await(0,W.glob)(d,{cwd:o,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**","**/*.stories.*","**/*.test.*"]});l.length>0&&i.push(...l)}catch{}let u=[...new Set(h)],f=[...new Set(i)],n=d=>{if(d.length===0)return;let l=d.find(w=>w.includes(`/fui-${t}/`)&&w.endsWith(".css"));if(l)return l;let y=d.find(w=>w.toLowerCase().includes(`/${t}/${t}.css`)||w.includes(`/${s}/${s}.css`));if(y)return y;let v=d.find(w=>w.toLowerCase().endsWith(`/${t}.css`)||w.endsWith(`/${s}.css`));return v||d[0]},p=d=>{if(d.length===0)return;let l=d.filter(C=>!C.includes(".stories.")&&!C.includes(".test."));if(l.length===0)return d[0];let y=l.find(C=>C.includes(`/fui-${t}/`)&&(C.endsWith(".tsx")||C.endsWith(".jsx")));if(y)return y;let v=l.find(C=>C.toLowerCase().includes(`/${t}/${t}.tsx`)||C.includes(`/${s}/${s}.tsx`));if(v)return v;let w=l.find(C=>C.toLowerCase().endsWith(`/${t}.tsx`)||C.endsWith(`/${s}.tsx`));return w||l[0]},g=n(u),a=p(f),m=[...u,...f];return console.log(`[UI Copilot] Discovered files for "${e}":`,{cssFile:g,componentFile:a,totalMatches:m.length}),{cssFile:g,componentFile:a,allMatches:[...new Set(m)]}}var Xe=100;function Ve(e){return new Promise(o=>setTimeout(o,e))}async function Ye(e,o){if(await ke(),!J||!N)return console.log(`[UI Copilot] Skipping validation (validator not available) for ${o}`),{valid:!0};let t=J(e,o);if(!t.valid){let s=t.errors.map(r=>r.message).join("; ");return console.warn(`[UI Copilot] Code validation failed for ${o}:`),console.warn(N(t)),{valid:!1,error:s}}return t.warnings.length>0&&(console.warn(`[UI Copilot] Code validation warnings for ${o}:`),console.warn(N(t))),console.log(`[UI Copilot] Validation passed for ${o}`),{valid:!0}}var fe=!1;function ge(e){if(fe)return e;fe=!0;let o=process.cwd();return console.log("[UI Copilot] Apply fixes initialized"),console.log("[UI Copilot] Workspace:",o),e.emit(de,{path:o}),e.on(We,()=>{console.log("[UI Copilot] Workspace path requested by browser"),console.log("[UI Copilot] Emitting workspace path response:",o),e.emit(de,{path:o})}),e.on(Je,async t=>{let{componentName:s,storyId:r}=t;console.log(`[UI Copilot] Discovering files for component: ${s}`);try{let c=await pe(s,o);e.emit(ue,{componentName:s,storyId:r,...c,workspacePath:o})}catch(c){console.error("[UI Copilot] File discovery error:",c),e.emit(ue,{componentName:s,storyId:r,error:c.message,allMatches:[]})}}),e.on(Ae,t=>{setTimeout(async()=>{try{let{issues:s,storybookRoot:r}=t,c=r||o;console.log(r?`[UI Copilot] Using storybookRoot from API: ${r}`:`[UI Copilot] Using process.cwd(): ${o}`),console.log(`[UI Copilot] Received APPLY_FIXES for ${s.length} issue(s)`);let h=new Map;async function i(n){let p=n.targetFileType||"css",g=n.targetFilePath||n.generatedFix?.filePath,a="",m=n.title?.match(/^(\w+)\s/);if(m&&(a=m[1]),!a&&g){let y=g.match(/\/(\w+)\.(?:css|tsx|jsx)$/i);y&&(a=y[1])}if(!a)return console.log(`[UI Copilot] Could not extract component name, using provided path: ${g}`),g||null;if(!h.has(a)){let y=await pe(a,c);h.set(a,y)}let d=h.get(a),l=p==="css"?d.cssFile:d.componentFile;return l?(console.log(`[UI Copilot] Discovered ${p} path: ${l} (was: ${g})`),l):(console.log(`[UI Copilot] No ${p} file discovered, using provided: ${g}`),g||null)}let u=[];for(let n of s){let{generatedFix:p}=n,g=n.targetFilePath||p?.filePath,a=await i(n)||g;console.log("[UI Copilot] Processing issue:",{id:n.id,type:n.type,targetFileType:n.targetFileType||"css",targetPath:a,providedPath:g!==a?g:"(same)",codeLength:p?.code?.length||0}),e.emit(De,{issueId:n.id});try{if(!p||!p.code||!a)throw new Error("Missing AI-generated fix data (code or filePath)");console.log("[UI Copilot] Code to write (first 200 chars):",p.code.substring(0,200)),console.log(`[UI Copilot] Code length: ${p.code.length} chars`);let m=await Ye(p.code,a);if(!m.valid)throw new Error(`Code validation failed: ${m.error}. Fix was not applied to prevent breaking the file.`);let d=M.isAbsolute(a)?a:M.join(c,a);console.log(`[UI Copilot] Writing to absolute path: ${d}`),await he.writeFile(d,p.code,"utf-8"),await Ve(Xe);let l={success:!0,issueId:n.id,filePath:a,timestamp:new Date};e.emit(je,{issueId:n.id,result:l}),console.log(`[UI Copilot] \u2713 Applied ${n.targetFileType||"css"} fix to: ${a}`),u.push(l)}catch(m){let d=m.message||"Unknown error";e.emit(Be,{issueId:n.id,error:d}),console.error(`[UI Copilot] \u2717 Error: ${d}`),u.push({success:!1,issueId:n.id,error:d,timestamp:new Date})}}let f={total:u.length,succeeded:u.filter(n=>n.success).length,failed:u.filter(n=>!n.success).length};e.emit(ce,{results:u,summary:f}),console.log(`[UI Copilot] Completed: ${f.succeeded}/${f.total} fixes applied`),f.succeeded>0&&e.emit(He,{message:"Fixes applied. If Storybook crashes due to HMR, please restart it.",filesChanged:u.filter(n=>n.success).map(n=>n.filePath)})}catch(s){console.error("[UI Copilot] Fatal error during fix application:",s),e.emit(ce,{results:[],summary:{total:t.issues?.length||0,succeeded:0,failed:t.issues?.length||0}})}},0)}),e}function me(e){let o=process.cwd();return e.plugins=e.plugins||[],e.plugins.push({name:"uicopilot-server-api",configureServer(t){t.middlewares.use("/__uicopilot/health",(s,r)=>{r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({ok:!0,workspacePath:o}))}),t.middlewares.use("/__uicopilot/screenshot",async(s,r)=>{try{if(!await U()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed. Run: npm install puppeteer"}));return}let i=new URL(s.url||"",`http://${s.headers.host}`).searchParams.get("storyId");if(!i){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${s.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${i}&globals=`;console.log(`[UI Copilot] Taking screenshot: ${i}`);let n=await H(f,{selector:"#storybook-root > *"});if(!n){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Screenshot capture failed"}));return}let p=n.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${p}`}))}catch(c){console.error("[UI Copilot] Screenshot error:",c.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:c.message}))}}),t.middlewares.use("/__uicopilot/capture",async(s,r)=>{try{if(!await U()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed"}));return}let i=new URL(s.url||"",`http://${s.headers.host}`).searchParams.get("storyId");if(!i){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${s.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${i}&globals=`;console.log(`[UI Copilot] Full capture: ${i}`);let n=await H(f,{selector:"#storybook-root > *"});if(!n){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Screenshot capture failed"}));return}let p;try{p=(await import("puppeteer")).default}catch{p=(await import("puppeteer-core")).default}let g=await p.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox"]}),a=await g.newPage();try{await a.setCacheEnabled(!1),await a.setViewport({width:800,height:600}),await a.goto(f,{waitUntil:"networkidle2",timeout:15e3}),await a.evaluate(()=>document.fonts.ready),await a.waitForSelector("#storybook-root > *",{timeout:1e4});let m=await a.evaluate(()=>{let l=document.querySelector("#storybook-root > *")||document.querySelector("#root > *"),y={};if(l){let S=window.getComputedStyle(l);for(let O=0;O<S.length;O++)y[S[O]]=S.getPropertyValue(S[O])}let v={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"]};function w(S){return S.replace(/-([a-z])/g,(O,T)=>T.toUpperCase())}function C(S,O){if(O>4)return null;let T=S.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(T))return null;let L=S.className,k=typeof L=="string"?L:L?.baseVal||"",A=S.id||void 0,ye=S.getAttribute("role")||void 0,V;for(let b of Array.from(S.childNodes))if(b.nodeType===3){let I=b.textContent?.trim();if(I){V=I.length>50?I.substring(0,50)+"...":I;break}}let D=T;A?D=`${T}#${A}`:k&&(D=`${T}.${k.split(" ").filter(Boolean).join(".")}`);let we=window.getComputedStyle(S),Ce=["background-color","border","border-radius","box-shadow","opacity","fill","stroke","stroke-width","font-size","font-family","font-weight","line-height","letter-spacing","color","text-align","display","padding","margin","gap","flex-direction","justify-content","align-items","width","height"],j={};for(let b of Ce){let I=we.getPropertyValue(b),x=w(b);I&&!v[x]?.includes(I)&&(j[x]=I)}if(T==="svg"||S.closest("svg"))for(let b of["fill","stroke","stroke-width","viewBox","d","r","cx","cy"]){let I=S.getAttribute(b);I&&(j[w(b)]=I)}let Y=[];for(let b of Array.from(S.children)){let I=window.getComputedStyle(b);if(I.display==="none"||I.visibility==="hidden")continue;let x=C(b,O+1);x&&Y.push(x)}return{selector:D,tagName:T,className:k,id:A,role:ye,textContent:V,styles:j,children:Y}}return{computedStyles:y,domTree:l?C(l,0):null}}),d=n.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${d}`,computedStyles:m.computedStyles,domTree:m.domTree}))}finally{await a.close(),await g.close()}}catch(c){console.error("[UI Copilot] Capture error:",c.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:c.message}))}}),t.middlewares.use("/__uicopilot/screenshot-snapshot",async(s,r)=>{if(s.method!=="POST"){r.writeHead(405,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"POST required"}));return}try{if(!await U()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed"}));return}let h=[];for await(let d of s)h.push(typeof d=="string"?Buffer.from(d):d);let i=JSON.parse(Buffer.concat(h).toString()),{html:u,stylesheetUrls:f,storyId:n}=i;if(!u){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing html in body"}));return}let g=`http://${s.headers.host||"localhost:6006"}`;console.log(`[UI Copilot] Taking snapshot screenshot for ${n||"unknown"}`);let a=await ee(u,f||[],g,{storyId:n});if(!a){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Snapshot screenshot failed"}));return}let m=a.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${m}`}))}catch(c){console.error("[UI Copilot] Snapshot screenshot error:",c.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:c.message}))}}),t.httpServer?.on("close",()=>{te().catch(()=>{})})}}),e}var _={},Ge=()=>{if(typeof _<"u"&&_.url){let e=(0,X.fileURLToPath)(_.url),o=(0,P.dirname)(e);return(0,P.join)(o,"manager.mjs")}return(0,P.join)(__dirname,"manager.mjs")},Ke=()=>{if(typeof _<"u"&&_.url){let e=(0,X.fileURLToPath)(_.url),o=(0,P.dirname)(e);return(0,P.join)(o,"preview.mjs")}return(0,P.join)(__dirname,"preview.mjs")};function qe(e=[]){return[...e,Ge()]}function ze(e=[]){return[...e,Ke()]}0&&(module.exports={experimental_serverChannel,managerEntries,previewAnnotations,viteFinal});
1
+ "use strict";var Pe=Object.create;var $=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var _e=(e,s)=>()=>(e&&(s=e(e=0)),s);var z=(e,s)=>{for(var t in s)$(e,t,{get:s[t],enumerable:!0})},Q=(e,s,t,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of ve(s))!Oe.call(e,n)&&n!==t&&$(e,n,{get:()=>s[n],enumerable:!(o=be(s,n))||o.enumerable});return e};var N=(e,s,t)=>(t=e!=null?Pe(Te(e)):{},Q(s||!e||!e.__esModule?$(t,"default",{value:e,enumerable:!0}):t,e)),Ee=e=>Q($({},"__esModule",{value:!0}),e);var ce={};z(ce,{detectFileType:()=>ne,formatValidationResult:()=>Ae,isValidCode:()=>ke,validateCode:()=>ie,validateCodeForFile:()=>ae});function $e(e,s={}){let t=s.minLength??Re;return e.length<t?{code:"CODE_TOO_SHORT",message:`Code is too short (${e.length} chars). Minimum: ${t}. Likely incomplete or a snippet.`,severity:"error"}:null}function Ne(e){let s=[/^[+-]{3}\s+[ab]\//m,/^@@\s+-\d+,\d+\s+\+\d+,\d+\s+@@/m,/^diff --git/m,/^index [a-f0-9]+\.\.[a-f0-9]+/m];for(let t of s)if(t.test(e))return{code:"CODE_IS_DIFF",message:"Code appears to be a diff/patch format, not complete file content.",severity:"error"};return null}function Fe(e){let s=e.split(`
2
+ `).filter(n=>n.trim()),t=s.filter(n=>n.trim().startsWith("//")||n.trim().startsWith("/*")||n.trim().startsWith("*")||n.trim().startsWith("#"));if(s.length>0&&t.length/s.length>.8)return{code:"CODE_IS_INSTRUCTIONS",message:"Code appears to be mostly comments/instructions, not actual implementation.",severity:"error"};let o=[/^\/\/\s*(Change|Replace|Update|Modify|Add|Remove|Delete)\s+(from|to|this|the)/im,/^\/\/\s*To:/m,/^\/\/\s*From:/m];for(let n of o)if(n.test(e))return{code:"CODE_IS_INSTRUCTIONS",message:'Code contains instruction comments (e.g., "// Change from:" / "// To:") instead of actual code.',severity:"error"};return null}function Ue(e){let s={"{":"}","[":"]","(":")"},t=[],o=!1,n="",i=!1;for(let r=0;r<e.length;r++){let l=e[r],g=e[r-1];if((l==='"'||l==="'"||l==="`")&&g!=="\\"){o?l===n&&(o=!1,i=!1):(o=!0,n=l,l==="`"&&(i=!0));continue}if(!o){if(s[l])t.push(s[l]);else if(Object.values(s).includes(l)&&t.pop()!==l)return{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets detected. Found unexpected '${l}'.`,severity:"warning"}}}return t.length>0?{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets. Missing: ${t.reverse().join("")}`,severity:"warning"}:null}function re(e,s={}){let t=[],o=[];e.includes("import ")||t.push({code:"TSX_MISSING_IMPORTS",message:"Component file missing import statements. A complete file must have imports.",severity:"error"}),e.includes("export ")||t.push({code:"TSX_MISSING_EXPORTS",message:"Component file missing exports. A complete file must export something.",severity:"error"});let n=/import\s+(?:React|\{[^}]*\})\s+from\s+['"]react['"]/.test(e);/<[A-Z][a-zA-Z]*|<[a-z]+[\s/>]/.test(e)&&!n&&o.push({code:"TSX_NO_REACT_IMPORT",message:"JSX detected but no React import. OK for React 17+ with automatic runtime.",severity:"warning"}),/export\s+(default\s+)?function\s+\w+/.test(e)||/export\s+(const|let)\s+\w+\s*[:=]/.test(e)||/export\s+default\s+\w+/.test(e)||/export\s+\{[^}]+\}/.test(e)||o.push({code:"TSX_NO_COMPONENT_DEF",message:"No clear component definition found. Expected function or const export.",severity:"warning"});let l=[{pattern:/\.\.\.\s*$/,message:'Code ends with "..." - likely truncated'},{pattern:/\/\/\s*\.\.\./m,message:'Contains "// ..." - likely incomplete'},{pattern:/{\s*\/\*\s*\.\.\.\s*\*\/\s*}/m,message:'Contains "{/* ... */}" placeholder'}];for(let{pattern:g,message:p}of l)g.test(e)&&t.push({code:"TSX_INCOMPLETE",message:p,severity:"error"});return{errors:t,warnings:o}}function Me(e,s={}){let t=[],o=[];(e.includes("import ")||e.includes("export "))&&t.push({code:"CSS_HAS_JS_CODE",message:"CSS file contains JavaScript import/export statements. Wrong file type.",severity:"error"}),/[.#\w\[\]]+\s*\{[\s\S]*?:\s*[^;]+;?[\s\S]*?\}/.test(e)||t.push({code:"CSS_INVALID_SYNTAX",message:"No valid CSS syntax found. Expected selector { property: value; } pattern.",severity:"error"});let i=(e.match(/\{[^}]+\}/g)||[]).length;return i===0&&t.push({code:"CSS_NO_RULES",message:"No CSS rules found. File appears empty or malformed.",severity:"error"}),(e.includes("/* ... */")||e.includes("// ..."))&&t.push({code:"CSS_INCOMPLETE",message:"CSS contains placeholder comments (/* ... */) - likely incomplete.",severity:"error"}),i>0&&i<3&&!s.allowPartial&&o.push({code:"CSS_FEW_RULES",message:`Only ${i} CSS rule(s) found. Might be incomplete.`,severity:"warning"}),{errors:t,warnings:o}}function Le(e,s={}){let t=[],o=[];return e.includes("import ")||t.push({code:"STORIES_MISSING_IMPORTS",message:"Stories file missing import statements.",severity:"error"}),/@storybook\//.test(e)||t.push({code:"STORIES_NO_STORYBOOK_IMPORT",message:"Stories file must import from @storybook/* (e.g., @storybook/react).",severity:"error"}),e.includes("Meta")||e.includes("ComponentMeta")||o.push({code:"STORIES_NO_META_TYPE",message:"Stories file should have Meta type import for type safety.",severity:"warning"}),e.includes("StoryObj")||e.includes("ComponentStory")||e.includes("Story")||o.push({code:"STORIES_NO_STORY_TYPE",message:"Stories file should have StoryObj/Story type for type safety.",severity:"warning"}),e.includes("export default")||t.push({code:"STORIES_NO_DEFAULT_EXPORT",message:"Stories file must have a default export (meta configuration).",severity:"error"}),/export\s+const\s+\w+\s*[:=]/.test(e)||t.push({code:"STORIES_NO_STORY_EXPORTS",message:"Stories file must have at least one named export (story definition).",severity:"error"}),/import\s+\{?\s*\w+\s*\}?\s+from\s+['"]\.\//.test(e)||o.push({code:"STORIES_NO_COMPONENT_IMPORT",message:"Stories file should import the component being documented.",severity:"warning"}),(e.includes("// ... other")||e.includes("/* ... */"))&&t.push({code:"STORIES_INCOMPLETE",message:"Stories file contains placeholder comments - likely incomplete.",severity:"error"}),{errors:t,warnings:o}}function ne(e){let s=e.toLowerCase();if(s.includes(".stories."))return"stories";switch(s.split(".").pop()){case"tsx":return"tsx";case"jsx":return"jsx";case"ts":return"ts";case"js":return"js";case"css":return"css";case"scss":return"scss";case"less":return"less";default:return"unknown"}}function ie(e,s,t={}){let o={valid:!0,fileType:s,errors:[],warnings:[]},n=$e(e,t);n&&o.errors.push(n);let i=Ne(e);i&&o.errors.push(i);let r=Fe(e);r&&o.errors.push(r);let l=Ue(e);switch(l&&(t.strict?o.errors.push({...l,severity:"error"}):o.warnings.push(l)),s){case"stories":{let{errors:g,warnings:p}=Le(e,t);o.errors.push(...g),o.warnings.push(...p);break}case"tsx":case"jsx":{let{errors:g,warnings:p}=re(e,t);o.errors.push(...g),o.warnings.push(...p);break}case"css":case"scss":case"less":{let{errors:g,warnings:p}=Me(e,t);o.errors.push(...g),o.warnings.push(...p);break}case"ts":case"js":{let{errors:g,warnings:p}=re(e,t);o.errors.push(...g),o.warnings.push(...p.filter(c=>!c.code.includes("JSX")));break}default:break}return o.valid=o.errors.length===0,o}function ae(e,s,t={}){let o=ne(s);return ie(e,o,t)}function ke(e,s,t={}){return ae(e,s,t).valid}function Ae(e){if(e.valid&&e.warnings.length===0)return`\u2713 Valid ${e.fileType} code`;let s=[];if(e.valid)s.push(`\u26A0 Valid ${e.fileType} code with warnings`);else{s.push(`\u2717 Invalid ${e.fileType} code`),s.push(""),s.push("Errors:");for(let t of e.errors)s.push(` - [${t.code}] ${t.message}`)}if(e.warnings.length>0){s.push(""),s.push("Warnings:");for(let t of e.warnings)s.push(` - [${t.code}] ${t.message}`)}return s.join(`
3
+ `)}var Re,le=_e(()=>{"use strict";Re=50});var et={};z(et,{experimental_serverChannel:()=>ye,managerEntries:()=>Qe,previewAnnotations:()=>Ze,viteFinal:()=>we});module.exports=Ee(et);var E=require("path"),G=require("url");var me=N(require("fs/promises")),L=N(require("path")),X=require("glob");var ee=require("fs"),te=require("module"),F=null,_=null,Z=!1;async function H(){if(Z)return!!F;if(Z=!0,process.env.STORYBOOK_UICOPILOT_NO_PUPPETEER==="true")return console.log("[UI Parity] Puppeteer disabled via STORYBOOK_UICOPILOT_NO_PUPPETEER flag"),!1;let e=(0,te.createRequire)(process.cwd()+"/");try{return F=e("puppeteer"),console.log("[UI Parity] Puppeteer loaded \u2014 server-side screenshots enabled"),!0}catch{}try{return F=e("puppeteer-core"),console.log("[UI Parity] puppeteer-core loaded \u2014 server-side screenshots enabled"),!0}catch{}return console.log("[UI Parity] Puppeteer not found \u2014 install puppeteer for pixel-perfect screenshots"),!1}function xe(){let e=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium-browser","/usr/bin/chromium"];for(let s of e)if((0,ee.existsSync)(s))return s}async function se(){if(_&&_.connected)return _;let e=xe(),s={headless:!0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"],...e?{executablePath:e}:{}};return _=await F.launch(s),console.log("[UI Parity] Headless Chrome launched for screenshots"),_}async function W(e,s){if(!await H())return null;let n=await(await se()).newPage();try{await n.setCacheEnabled(!1),await n.setViewport({width:s?.width||800,height:s?.height||600,deviceScaleFactor:1}),await n.goto(e,{waitUntil:"networkidle2",timeout:15e3}),await n.evaluate(()=>document.fonts.ready),await n.waitForSelector("#storybook-root > *",{timeout:1e4}),await n.waitForFunction(()=>new Promise(p=>{let c=document.querySelectorAll("style").length,f=0,h=()=>{let d=document.querySelectorAll("style").length;if(d===c){if(f++,f>=3){p(!0);return}}else f=0,c=d;setTimeout(h,100)};setTimeout(h,200)}),{timeout:5e3}).catch(()=>{}),await new Promise(p=>setTimeout(p,500));let i=await n.evaluate(()=>{let p=document.querySelector("#storybook-root");if(!p)return null;let c=window.innerHeight,f=window.innerWidth,h=1/0,d=0,w=1/0,a=0,u=!1;function S(C){for(let m of Array.from(C.children)){let y=window.getComputedStyle(m);if(y.display==="none"||y.visibility==="hidden"||y.position==="fixed"||y.position==="absolute")continue;let P=m.getBoundingClientRect();if(!(P.height<=0||P.width<=0)){if(P.height>=c*.9&&P.width>=f*.9){S(m);continue}h=Math.min(h,P.top),d=Math.max(d,P.bottom),w=Math.min(w,P.left),a=Math.max(a,P.right),u=!0}}}return S(p),u?{top:h,bottom:d,left:w,right:a}:null}),r=16,l=i?{x:Math.max(0,i.left-r),y:Math.max(0,i.top-r),width:Math.min(i.right-i.left+r*2,800),height:Math.min(i.bottom-i.top+r*2,600)}:void 0,g=await n.screenshot({type:"png",...l?{clip:l}:{fullPage:!1}});return Buffer.from(g)}finally{await n.close()}}async function oe(e,s,t,o){if(!await H())return null;let r=await(await se()).newPage();try{await r.setCacheEnabled(!1),await r.setViewport({width:o?.width||800,height:o?.height||600,deviceScaleFactor:1});let l=o?.storyId||"",g=`${t}/iframe.html?viewMode=story&id=${l}&globals=`;await r.goto(g,{waitUntil:"load",timeout:15e3}),await r.waitForSelector("#storybook-root > *",{timeout:1e4}),await r.evaluate(f=>{let h=document.getElementById("storybook-root");h&&(h.innerHTML=f)},e),await r.evaluate(()=>document.fonts.ready),await new Promise(f=>setTimeout(f,500));let p=await r.evaluate(()=>{let f=document.querySelector("#storybook-root");if(!f)return null;let h=window.innerWidth;function d(u){let S=u.getBoundingClientRect();if(S.width===0||S.height===0)return null;if(S.width<h*.8&&S.height>0)return S;for(let C of Array.from(u.children)){let m=window.getComputedStyle(C);if(m.position==="fixed"||m.position==="absolute"||m.display==="none"||m.visibility==="hidden")continue;let y=d(C);if(y)return y}return null}let w=d(f);if(w)return{x:Math.max(0,w.x-8),y:Math.max(0,w.y-8),width:w.width+16,height:w.height+16};let a=f.firstElementChild;if(a){let u=a.getBoundingClientRect();return{x:u.x,y:u.y,width:u.width,height:u.height}}return null});if(!p)throw new Error("Could not determine component bounds from snapshot");let c=await r.screenshot({type:"png",clip:p});return Buffer.from(c)}finally{await r.close()}}async function U(){return H()}async function J(){_&&(await _.close(),_=null)}var V=null,M=null,ue=!1;async function De(){if(!ue){ue=!0;try{let e=await Promise.resolve().then(()=>(le(),ce));V=e.validateCodeForFile,M=e.formatValidationResult,console.log("[UI Parity] Code validator loaded - fix validation enabled")}catch{console.log("[UI Parity] Code validator not available - skipping fix validation")}}}var je="UICOPILOT/APPLY_FIXES",Be="UICOPILOT/FIX_STARTED",He="UICOPILOT/FIX_COMPLETED",We="UICOPILOT/FIX_FAILED",de="UICOPILOT/ALL_FIXES_APPLIED",Je="UICOPILOT/RELOAD_REQUIRED",pe="UICOPILOT/WORKSPACE_PATH",Xe="UICOPILOT/REQUEST_WORKSPACE_PATH",Ve="UICOPILOT/DISCOVER_COMPONENT_FILES",fe="UICOPILOT/COMPONENT_FILES_DISCOVERED";async function he(e,s){let t=e.toLowerCase(),o=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),n=[`src/**/fui-${t}/fui-${t}.css`,`src/**/fui-${t}/*.css`,`src/**/${t}/${t}.css`,`src/**/${o}/${o}.css`,`src/**/*${t}*.css`,`src/**/*${o}*.css`,`styles/**/*${t}*.css`],i=[`src/**/fui-${t}/fui-${t}.tsx`,`src/**/fui-${t}/*.tsx`,`src/**/${t}/${t}.tsx`,`src/**/${o}/${o}.tsx`,`src/**/*${o}*.tsx`,`src/**/*${o}*.jsx`],r=[],l=[];for(let a of n)try{let u=await(0,X.glob)(a,{cwd:s,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**"]});u.length>0&&r.push(...u)}catch{}for(let a of i)try{let u=await(0,X.glob)(a,{cwd:s,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**","**/*.stories.*","**/*.test.*"]});u.length>0&&l.push(...u)}catch{}let g=[...new Set(r)],p=[...new Set(l)],c=a=>{if(a.length===0)return;let u=a.find(m=>m.includes(`/fui-${t}/`)&&m.endsWith(".css"));if(u)return u;let S=a.find(m=>m.toLowerCase().includes(`/${t}/${t}.css`)||m.includes(`/${o}/${o}.css`));if(S)return S;let C=a.find(m=>m.toLowerCase().endsWith(`/${t}.css`)||m.endsWith(`/${o}.css`));return C||a[0]},f=a=>{if(a.length===0)return;let u=a.filter(y=>!y.includes(".stories.")&&!y.includes(".test."));if(u.length===0)return a[0];let S=u.find(y=>y.includes(`/fui-${t}/`)&&(y.endsWith(".tsx")||y.endsWith(".jsx")));if(S)return S;let C=u.find(y=>y.toLowerCase().includes(`/${t}/${t}.tsx`)||y.includes(`/${o}/${o}.tsx`));if(C)return C;let m=u.find(y=>y.toLowerCase().endsWith(`/${t}.tsx`)||y.endsWith(`/${o}.tsx`));return m||u[0]},h=c(g),d=f(p),w=[...g,...p];return console.log(`[UI Parity] Discovered files for "${e}":`,{cssFile:h,componentFile:d,totalMatches:w.length}),{cssFile:h,componentFile:d,allMatches:[...new Set(w)]}}var Ge=100;function Ye(e){return new Promise(s=>setTimeout(s,e))}async function Ke(e,s){if(await De(),!V||!M)return console.log(`[UI Parity] Skipping validation (validator not available) for ${s}`),{valid:!0};let t=V(e,s);if(!t.valid){let o=t.errors.map(n=>n.message).join("; ");return console.warn(`[UI Parity] Code validation failed for ${s}:`),console.warn(M(t)),{valid:!1,error:o}}return t.warnings.length>0&&(console.warn(`[UI Parity] Code validation warnings for ${s}:`),console.warn(M(t))),console.log(`[UI Parity] Validation passed for ${s}`),{valid:!0}}var ge=!1;function ye(e){if(ge)return e;ge=!0;let s=process.cwd();return console.log("[UI Parity] Apply fixes initialized"),console.log("[UI Parity] Workspace:",s),e.emit(pe,{path:s}),e.on(Xe,()=>{console.log("[UI Parity] Workspace path requested by browser"),console.log("[UI Parity] Emitting workspace path response:",s),e.emit(pe,{path:s})}),e.on(Ve,async t=>{let{componentName:o,storyId:n}=t;console.log(`[UI Parity] Discovering files for component: ${o}`);try{let i=await he(o,s);e.emit(fe,{componentName:o,storyId:n,...i,workspacePath:s})}catch(i){console.error("[UI Parity] File discovery error:",i),e.emit(fe,{componentName:o,storyId:n,error:i.message,allMatches:[]})}}),e.on(je,t=>{setTimeout(async()=>{try{let{issues:o,storybookRoot:n}=t,i=n||s;console.log(n?`[UI Parity] Using storybookRoot from API: ${n}`:`[UI Parity] Using process.cwd(): ${s}`),console.log(`[UI Parity] Received APPLY_FIXES for ${o.length} issue(s)`);let r=new Map;async function l(c){let f=c.targetFileType||"css",h=c.targetFilePath||c.generatedFix?.filePath,d="",w=c.title?.match(/^(\w+)\s/);if(w&&(d=w[1]),!d&&h){let S=h.match(/\/(\w+)\.(?:css|tsx|jsx)$/i);S&&(d=S[1])}if(!d)return console.log(`[UI Parity] Could not extract component name, using provided path: ${h}`),h||null;if(!r.has(d)){let S=await he(d,i);r.set(d,S)}let a=r.get(d),u=f==="css"?a.cssFile:a.componentFile;return u?(console.log(`[UI Parity] Discovered ${f} path: ${u} (was: ${h})`),u):(console.log(`[UI Parity] No ${f} file discovered, using provided: ${h}`),h||null)}let g=[];for(let c of o){let{generatedFix:f}=c,h=c.targetFilePath||f?.filePath,d=await l(c)||h;console.log("[UI Parity] Processing issue:",{id:c.id,type:c.type,targetFileType:c.targetFileType||"css",targetPath:d,providedPath:h!==d?h:"(same)",codeLength:f?.code?.length||0}),e.emit(Be,{issueId:c.id});try{if(!f||!f.code||!d)throw new Error("Missing AI-generated fix data (code or filePath)");console.log("[UI Parity] Code to write (first 200 chars):",f.code.substring(0,200)),console.log(`[UI Parity] Code length: ${f.code.length} chars`);let w=await Ke(f.code,d);if(!w.valid)throw new Error(`Code validation failed: ${w.error}. Fix was not applied to prevent breaking the file.`);let a=L.isAbsolute(d)?d:L.join(i,d);console.log(`[UI Parity] Writing to absolute path: ${a}`),await me.writeFile(a,f.code,"utf-8"),await Ye(Ge);let u={success:!0,issueId:c.id,filePath:d,timestamp:new Date};e.emit(He,{issueId:c.id,result:u}),console.log(`[UI Parity] \u2713 Applied ${c.targetFileType||"css"} fix to: ${d}`),g.push(u)}catch(w){let a=w.message||"Unknown error";e.emit(We,{issueId:c.id,error:a}),console.error(`[UI Parity] \u2717 Error: ${a}`),g.push({success:!1,issueId:c.id,error:a,timestamp:new Date})}}let p={total:g.length,succeeded:g.filter(c=>c.success).length,failed:g.filter(c=>!c.success).length};e.emit(de,{results:g,summary:p}),console.log(`[UI Parity] Completed: ${p.succeeded}/${p.total} fixes applied`),p.succeeded>0&&e.emit(Je,{message:"Fixes applied. If Storybook crashes due to HMR, please restart it.",filesChanged:g.filter(c=>c.success).map(c=>c.filePath)})}catch(o){console.error("[UI Parity] Fatal error during fix application:",o),e.emit(de,{results:[],summary:{total:t.issues?.length||0,succeeded:0,failed:t.issues?.length||0}})}},0)}),e}function we(e){let s=process.cwd();return e.plugins=e.plugins||[],e.plugins.push({name:"uicopilot-server-api",configureServer(t){t.middlewares.use("/__uicopilot/health",(i,r)=>{r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({ok:!0,workspacePath:s}))}),t.middlewares.use("/__uicopilot/screenshot",async(i,r)=>{try{if(!await U()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed. Run: npm install puppeteer"}));return}let p=new URL(i.url||"",`http://${i.headers.host}`).searchParams.get("storyId");if(!p){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${i.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${p}&globals=`;console.log(`[UI Parity] Taking screenshot: ${p}`);let h=await W(f,{selector:"#storybook-root > *"});if(!h){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Screenshot capture failed"}));return}let d=h.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${d}`}))}catch(l){console.error("[UI Parity] Screenshot error:",l.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:l.message}))}}),t.middlewares.use("/__uicopilot/capture",async(i,r)=>{try{if(!await U()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed"}));return}let p=new URL(i.url||"",`http://${i.headers.host}`).searchParams.get("storyId");if(!p){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${i.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${p}&globals=`;console.log(`[UI Parity] Full capture: ${p}`);let h=await W(f,{selector:"#storybook-root > *"});if(!h){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Screenshot capture failed"}));return}let d;try{d=(await import("puppeteer")).default}catch{d=(await import("puppeteer-core")).default}let w=await d.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox"]}),a=await w.newPage();try{await a.setCacheEnabled(!1),await a.setViewport({width:800,height:600}),await a.goto(f,{waitUntil:"networkidle2",timeout:15e3}),await a.evaluate(()=>document.fonts.ready),await a.waitForSelector("#storybook-root > *",{timeout:1e4}),await a.evaluate(()=>new Promise(C=>{let m=setTimeout(C,5e3);try{let y=window.__STORYBOOK_ADDONS_CHANNEL__;if(y){let P=()=>{clearTimeout(m),y.off("storyRendered",P),setTimeout(C,100)};y.on("storyRendered",P)}else clearTimeout(m),setTimeout(C,300)}catch{clearTimeout(m),C()}}));let u=await a.evaluate(()=>{let C=document.querySelector("#storybook-root > *")||document.querySelector("#root > *"),m={};if(C){let I=window.getComputedStyle(C);for(let T=0;T<I.length;T++)m[I[T]]=I.getPropertyValue(I[T])}let y={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"]};function P(I){return I.replace(/-([a-z])/g,(T,O)=>O.toUpperCase())}function Y(I,T){if(T>4)return null;let O=I.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(O))return null;let k=I.className,A=typeof k=="string"?k:k?.baseVal||"",D=I.id||void 0,Se=I.getAttribute("role")||void 0,K;for(let v of Array.from(I.childNodes))if(v.nodeType===3){let b=v.textContent?.trim();if(b){K=b.length>50?b.substring(0,50)+"...":b;break}}let j=O;D?j=`${O}#${D}`:A&&(j=`${O}.${A.split(" ").filter(Boolean).join(".")}`);let Ce=window.getComputedStyle(I),Ie=["background-color","border","border-radius","box-shadow","opacity","fill","stroke","stroke-width","font-size","font-family","font-weight","line-height","letter-spacing","color","text-align","display","padding","margin","gap","flex-direction","justify-content","align-items","width","height"],B={};for(let v of Ie){let b=Ce.getPropertyValue(v),R=P(v);b&&!y[R]?.includes(b)&&(B[R]=b)}if(O==="svg"||I.closest("svg"))for(let v of["fill","stroke","stroke-width","viewBox","d","r","cx","cy"]){let b=I.getAttribute(v);b&&(B[P(v)]=b)}let q=[];for(let v of Array.from(I.children)){let b=window.getComputedStyle(v);if(b.display==="none"||b.visibility==="hidden")continue;let R=Y(v,T+1);R&&q.push(R)}return{selector:j,tagName:O,className:A,id:D,role:Se,textContent:K,styles:B,children:q}}return{computedStyles:m,domTree:C?Y(C,0):null}}),S=h.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${S}`,computedStyles:u.computedStyles,domTree:u.domTree}))}finally{await a.close(),await w.close()}}catch(l){console.error("[UI Parity] Capture error:",l.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:l.message}))}}),t.middlewares.use("/__uicopilot/screenshot-snapshot",async(i,r)=>{if(i.method!=="POST"){r.writeHead(405,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"POST required"}));return}try{if(!await U()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed"}));return}let g=[];for await(let S of i)g.push(typeof S=="string"?Buffer.from(S):S);let p=JSON.parse(Buffer.concat(g).toString()),{html:c,stylesheetUrls:f,storyId:h}=p;if(!c){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing html in body"}));return}let w=`http://${i.headers.host||"localhost:6006"}`;console.log(`[UI Parity] Taking snapshot screenshot for ${h||"unknown"}`);let a=await oe(c,f||[],w,{storyId:h});if(!a){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Snapshot screenshot failed"}));return}let u=a.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${u}`}))}catch(l){console.error("[UI Parity] Snapshot screenshot error:",l.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:l.message}))}}),t.httpServer?.on("close",()=>{J().catch(()=>{})});let o=i=>{J().catch(()=>{}).finally(()=>{process.kill(process.pid,i)})},n=globalThis;n.__uicopilotShutdownRegistered||(n.__uicopilotShutdownRegistered=!0,process.once("SIGINT",()=>o("SIGINT")),process.once("SIGTERM",()=>o("SIGTERM")))}}),e}var x={},qe=()=>{if(typeof x<"u"&&x.url){let e=(0,G.fileURLToPath)(x.url),s=(0,E.dirname)(e);return(0,E.join)(s,"manager.mjs")}return(0,E.join)(__dirname,"manager.mjs")},ze=()=>{if(typeof x<"u"&&x.url){let e=(0,G.fileURLToPath)(x.url),s=(0,E.dirname)(e);return(0,E.join)(s,"preview.mjs")}return(0,E.join)(__dirname,"preview.mjs")};function Qe(e=[]){return[...e,qe()]}function Ze(e=[]){return[...e,ze()]}0&&(module.exports={experimental_serverChannel,managerEntries,previewAnnotations,viteFinal});
package/dist/preset.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var pe=Object.defineProperty;var fe=(e,r)=>()=>(e&&(r=e(e=0)),r);var he=(e,r)=>{for(var t in r)pe(e,t,{get:r[t],enumerable:!0})};var z={};he(z,{detectFileType:()=>G,formatValidationResult:()=>Ee,isValidCode:()=>Te,validateCode:()=>K,validateCodeForFile:()=>q});function Ce(e,r={}){let t=r.minLength??we;return e.length<t?{code:"CODE_TOO_SHORT",message:`Code is too short (${e.length} chars). Minimum: ${t}. Likely incomplete or a snippet.`,severity:"error"}:null}function Se(e){let r=[/^[+-]{3}\s+[ab]\//m,/^@@\s+-\d+,\d+\s+\+\d+,\d+\s+@@/m,/^diff --git/m,/^index [a-f0-9]+\.\.[a-f0-9]+/m];for(let t of r)if(t.test(e))return{code:"CODE_IS_DIFF",message:"Code appears to be a diff/patch format, not complete file content.",severity:"error"};return null}function Ie(e){let r=e.split(`
2
- `).filter(s=>s.trim()),t=r.filter(s=>s.trim().startsWith("//")||s.trim().startsWith("/*")||s.trim().startsWith("*")||s.trim().startsWith("#"));if(r.length>0&&t.length/r.length>.8)return{code:"CODE_IS_INSTRUCTIONS",message:"Code appears to be mostly comments/instructions, not actual implementation.",severity:"error"};let o=[/^\/\/\s*(Change|Replace|Update|Modify|Add|Remove|Delete)\s+(from|to|this|the)/im,/^\/\/\s*To:/m,/^\/\/\s*From:/m];for(let s of o)if(s.test(e))return{code:"CODE_IS_INSTRUCTIONS",message:'Code contains instruction comments (e.g., "// Change from:" / "// To:") instead of actual code.',severity:"error"};return null}function be(e){let r={"{":"}","[":"]","(":")"},t=[],o=!1,s="",c=!1;for(let h=0;h<e.length;h++){let i=e[h],u=e[h-1];if((i==='"'||i==="'"||i==="`")&&u!=="\\"){o?i===s&&(o=!1,c=!1):(o=!0,s=i,i==="`"&&(c=!0));continue}if(!o){if(r[i])t.push(r[i]);else if(Object.values(r).includes(i)&&t.pop()!==i)return{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets detected. Found unexpected '${i}'.`,severity:"warning"}}}return t.length>0?{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets. Missing: ${t.reverse().join("")}`,severity:"warning"}:null}function Y(e,r={}){let t=[],o=[];e.includes("import ")||t.push({code:"TSX_MISSING_IMPORTS",message:"Component file missing import statements. A complete file must have imports.",severity:"error"}),e.includes("export ")||t.push({code:"TSX_MISSING_EXPORTS",message:"Component file missing exports. A complete file must export something.",severity:"error"});let s=/import\s+(?:React|\{[^}]*\})\s+from\s+['"]react['"]/.test(e);/<[A-Z][a-zA-Z]*|<[a-z]+[\s/>]/.test(e)&&!s&&o.push({code:"TSX_NO_REACT_IMPORT",message:"JSX detected but no React import. OK for React 17+ with automatic runtime.",severity:"warning"}),/export\s+(default\s+)?function\s+\w+/.test(e)||/export\s+(const|let)\s+\w+\s*[:=]/.test(e)||/export\s+default\s+\w+/.test(e)||/export\s+\{[^}]+\}/.test(e)||o.push({code:"TSX_NO_COMPONENT_DEF",message:"No clear component definition found. Expected function or const export.",severity:"warning"});let i=[{pattern:/\.\.\.\s*$/,message:'Code ends with "..." - likely truncated'},{pattern:/\/\/\s*\.\.\./m,message:'Contains "// ..." - likely incomplete'},{pattern:/{\s*\/\*\s*\.\.\.\s*\*\/\s*}/m,message:'Contains "{/* ... */}" placeholder'}];for(let{pattern:u,message:f}of i)u.test(e)&&t.push({code:"TSX_INCOMPLETE",message:f,severity:"error"});return{errors:t,warnings:o}}function ve(e,r={}){let t=[],o=[];(e.includes("import ")||e.includes("export "))&&t.push({code:"CSS_HAS_JS_CODE",message:"CSS file contains JavaScript import/export statements. Wrong file type.",severity:"error"}),/[.#\w\[\]]+\s*\{[\s\S]*?:\s*[^;]+;?[\s\S]*?\}/.test(e)||t.push({code:"CSS_INVALID_SYNTAX",message:"No valid CSS syntax found. Expected selector { property: value; } pattern.",severity:"error"});let c=(e.match(/\{[^}]+\}/g)||[]).length;return c===0&&t.push({code:"CSS_NO_RULES",message:"No CSS rules found. File appears empty or malformed.",severity:"error"}),(e.includes("/* ... */")||e.includes("// ..."))&&t.push({code:"CSS_INCOMPLETE",message:"CSS contains placeholder comments (/* ... */) - likely incomplete.",severity:"error"}),c>0&&c<3&&!r.allowPartial&&o.push({code:"CSS_FEW_RULES",message:`Only ${c} CSS rule(s) found. Might be incomplete.`,severity:"warning"}),{errors:t,warnings:o}}function Oe(e,r={}){let t=[],o=[];return e.includes("import ")||t.push({code:"STORIES_MISSING_IMPORTS",message:"Stories file missing import statements.",severity:"error"}),/@storybook\//.test(e)||t.push({code:"STORIES_NO_STORYBOOK_IMPORT",message:"Stories file must import from @storybook/* (e.g., @storybook/react).",severity:"error"}),e.includes("Meta")||e.includes("ComponentMeta")||o.push({code:"STORIES_NO_META_TYPE",message:"Stories file should have Meta type import for type safety.",severity:"warning"}),e.includes("StoryObj")||e.includes("ComponentStory")||e.includes("Story")||o.push({code:"STORIES_NO_STORY_TYPE",message:"Stories file should have StoryObj/Story type for type safety.",severity:"warning"}),e.includes("export default")||t.push({code:"STORIES_NO_DEFAULT_EXPORT",message:"Stories file must have a default export (meta configuration).",severity:"error"}),/export\s+const\s+\w+\s*[:=]/.test(e)||t.push({code:"STORIES_NO_STORY_EXPORTS",message:"Stories file must have at least one named export (story definition).",severity:"error"}),/import\s+\{?\s*\w+\s*\}?\s+from\s+['"]\.\//.test(e)||o.push({code:"STORIES_NO_COMPONENT_IMPORT",message:"Stories file should import the component being documented.",severity:"warning"}),(e.includes("// ... other")||e.includes("/* ... */"))&&t.push({code:"STORIES_INCOMPLETE",message:"Stories file contains placeholder comments - likely incomplete.",severity:"error"}),{errors:t,warnings:o}}function G(e){let r=e.toLowerCase();if(r.includes(".stories."))return"stories";switch(r.split(".").pop()){case"tsx":return"tsx";case"jsx":return"jsx";case"ts":return"ts";case"js":return"js";case"css":return"css";case"scss":return"scss";case"less":return"less";default:return"unknown"}}function K(e,r,t={}){let o={valid:!0,fileType:r,errors:[],warnings:[]},s=Ce(e,t);s&&o.errors.push(s);let c=Se(e);c&&o.errors.push(c);let h=Ie(e);h&&o.errors.push(h);let i=be(e);switch(i&&(t.strict?o.errors.push({...i,severity:"error"}):o.warnings.push(i)),r){case"stories":{let{errors:u,warnings:f}=Oe(e,t);o.errors.push(...u),o.warnings.push(...f);break}case"tsx":case"jsx":{let{errors:u,warnings:f}=Y(e,t);o.errors.push(...u),o.warnings.push(...f);break}case"css":case"scss":case"less":{let{errors:u,warnings:f}=ve(e,t);o.errors.push(...u),o.warnings.push(...f);break}case"ts":case"js":{let{errors:u,warnings:f}=Y(e,t);o.errors.push(...u),o.warnings.push(...f.filter(n=>!n.code.includes("JSX")));break}default:break}return o.valid=o.errors.length===0,o}function q(e,r,t={}){let o=G(r);return K(e,o,t)}function Te(e,r,t={}){return q(e,r,t).valid}function Ee(e){if(e.valid&&e.warnings.length===0)return`\u2713 Valid ${e.fileType} code`;let r=[];if(e.valid)r.push(`\u26A0 Valid ${e.fileType} code with warnings`);else{r.push(`\u2717 Invalid ${e.fileType} code`),r.push(""),r.push("Errors:");for(let t of e.errors)r.push(` - [${t.code}] ${t.message}`)}if(e.warnings.length>0){r.push(""),r.push("Warnings:");for(let t of e.warnings)r.push(` - [${t.code}] ${t.message}`)}return r.join(`
3
- `)}var we,Q=fe(()=>{"use strict";we=50});import{dirname as ae,join as R}from"path";import{fileURLToPath as le}from"url";import*as ie from"fs/promises";import*as F from"path";import{glob as Z}from"glob";import{existsSync as ge}from"fs";import{createRequire as me}from"module";var _=null,E=null,W=!1;async function A(){if(W)return!!_;if(W=!0,process.env.STORYBOOK_UICOPILOT_NO_PUPPETEER==="true")return console.log("[UI Copilot] Puppeteer disabled via STORYBOOK_UICOPILOT_NO_PUPPETEER flag"),!1;let e=me(process.cwd()+"/");try{return _=e("puppeteer"),console.log("[UI Copilot] Puppeteer loaded \u2014 server-side screenshots enabled"),!0}catch{}try{return _=e("puppeteer-core"),console.log("[UI Copilot] puppeteer-core loaded \u2014 server-side screenshots enabled"),!0}catch{}return console.log("[UI Copilot] Puppeteer not found \u2014 install puppeteer for pixel-perfect screenshots"),!1}function ye(){let e=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium-browser","/usr/bin/chromium"];for(let r of e)if(ge(r))return r}async function J(){if(E&&E.connected)return E;let e=ye(),r={headless:!0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"],...e?{executablePath:e}:{}};return E=await _.launch(r),console.log("[UI Copilot] Headless Chrome launched for screenshots"),E}async function D(e,r){if(!await A())return null;let s=await(await J()).newPage();try{await s.setCacheEnabled(!1),await s.setViewport({width:r?.width||800,height:r?.height||600,deviceScaleFactor:1}),await s.goto(e,{waitUntil:"networkidle2",timeout:15e3}),await s.evaluate(()=>document.fonts.ready),await s.waitForSelector("#storybook-root > *",{timeout:1e4}),await s.waitForFunction(()=>new Promise(i=>{let u=document.querySelectorAll("style").length,f=0,n=()=>{let p=document.querySelectorAll("style").length;if(p===u){if(f++,f>=3){i(!0);return}}else f=0,u=p;setTimeout(n,100)};setTimeout(n,200)}),{timeout:5e3}).catch(()=>{}),await new Promise(i=>setTimeout(i,500));let c=await s.evaluate(()=>{let i=document.querySelector("#storybook-root");if(!i)return null;let u=window.innerWidth;function f(g){let a=g.getBoundingClientRect();if(a.width===0||a.height===0)return null;if(a.width<u*.8&&a.height>0)return a;for(let m of Array.from(g.children)){let d=window.getComputedStyle(m);if(d.position==="fixed"||d.position==="absolute"||d.display==="none"||d.visibility==="hidden")continue;let l=f(m);if(l)return l}return null}let n=f(i);if(n)return{x:Math.max(0,n.x-8),y:Math.max(0,n.y-8),width:n.width+16,height:n.height+16};let p=i.firstElementChild;if(p){let g=p.getBoundingClientRect();return{x:g.x,y:g.y,width:g.width,height:g.height}}return null});if(!c)throw new Error("Could not determine component bounds");let h=await s.screenshot({type:"png",clip:c});return Buffer.from(h)}finally{await s.close()}}async function X(e,r,t,o){if(!await A())return null;let h=await(await J()).newPage();try{await h.setCacheEnabled(!1),await h.setViewport({width:o?.width||800,height:o?.height||600,deviceScaleFactor:1});let i=o?.storyId||"",u=`${t}/iframe.html?viewMode=story&id=${i}&globals=`;await h.goto(u,{waitUntil:"load",timeout:15e3}),await h.waitForSelector("#storybook-root > *",{timeout:1e4}),await h.evaluate(p=>{let g=document.getElementById("storybook-root");g&&(g.innerHTML=p)},e),await h.evaluate(()=>document.fonts.ready),await new Promise(p=>setTimeout(p,500));let f=await h.evaluate(()=>{let p=document.querySelector("#storybook-root");if(!p)return null;let g=window.innerWidth;function a(l){let y=l.getBoundingClientRect();if(y.width===0||y.height===0)return null;if(y.width<g*.8&&y.height>0)return y;for(let v of Array.from(l.children)){let w=window.getComputedStyle(v);if(w.position==="fixed"||w.position==="absolute"||w.display==="none"||w.visibility==="hidden")continue;let C=a(v);if(C)return C}return null}let m=a(p);if(m)return{x:Math.max(0,m.x-8),y:Math.max(0,m.y-8),width:m.width+16,height:m.height+16};let d=p.firstElementChild;if(d){let l=d.getBoundingClientRect();return{x:l.x,y:l.y,width:l.width,height:l.height}}return null});if(!f)throw new Error("Could not determine component bounds from snapshot");let n=await h.screenshot({type:"png",clip:f});return Buffer.from(n)}finally{await h.close()}}async function x(){return A()}async function V(){E&&(await E.close(),E=null)}var j=null,$=null,ee=!1;async function Pe(){if(!ee){ee=!0;try{let e=await Promise.resolve().then(()=>(Q(),z));j=e.validateCodeForFile,$=e.formatValidationResult,console.log("[UI Copilot] Code validator loaded - fix validation enabled")}catch{console.log("[UI Copilot] Code validator not available - skipping fix validation")}}}var _e="UICOPILOT/APPLY_FIXES",xe="UICOPILOT/FIX_STARTED",$e="UICOPILOT/FIX_COMPLETED",Fe="UICOPILOT/FIX_FAILED",te="UICOPILOT/ALL_FIXES_APPLIED",Re="UICOPILOT/RELOAD_REQUIRED",oe="UICOPILOT/WORKSPACE_PATH",Ue="UICOPILOT/REQUEST_WORKSPACE_PATH",Ne="UICOPILOT/DISCOVER_COMPONENT_FILES",se="UICOPILOT/COMPONENT_FILES_DISCOVERED";async function re(e,r){let t=e.toLowerCase(),o=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),s=[`src/**/fui-${t}/fui-${t}.css`,`src/**/fui-${t}/*.css`,`src/**/${t}/${t}.css`,`src/**/${o}/${o}.css`,`src/**/*${t}*.css`,`src/**/*${o}*.css`,`styles/**/*${t}*.css`],c=[`src/**/fui-${t}/fui-${t}.tsx`,`src/**/fui-${t}/*.tsx`,`src/**/${t}/${t}.tsx`,`src/**/${o}/${o}.tsx`,`src/**/*${o}*.tsx`,`src/**/*${o}*.jsx`],h=[],i=[];for(let d of s)try{let l=await Z(d,{cwd:r,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**"]});l.length>0&&h.push(...l)}catch{}for(let d of c)try{let l=await Z(d,{cwd:r,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**","**/*.stories.*","**/*.test.*"]});l.length>0&&i.push(...l)}catch{}let u=[...new Set(h)],f=[...new Set(i)],n=d=>{if(d.length===0)return;let l=d.find(w=>w.includes(`/fui-${t}/`)&&w.endsWith(".css"));if(l)return l;let y=d.find(w=>w.toLowerCase().includes(`/${t}/${t}.css`)||w.includes(`/${o}/${o}.css`));if(y)return y;let v=d.find(w=>w.toLowerCase().endsWith(`/${t}.css`)||w.endsWith(`/${o}.css`));return v||d[0]},p=d=>{if(d.length===0)return;let l=d.filter(C=>!C.includes(".stories.")&&!C.includes(".test."));if(l.length===0)return d[0];let y=l.find(C=>C.includes(`/fui-${t}/`)&&(C.endsWith(".tsx")||C.endsWith(".jsx")));if(y)return y;let v=l.find(C=>C.toLowerCase().includes(`/${t}/${t}.tsx`)||C.includes(`/${o}/${o}.tsx`));if(v)return v;let w=l.find(C=>C.toLowerCase().endsWith(`/${t}.tsx`)||C.endsWith(`/${o}.tsx`));return w||l[0]},g=n(u),a=p(f),m=[...u,...f];return console.log(`[UI Copilot] Discovered files for "${e}":`,{cssFile:g,componentFile:a,totalMatches:m.length}),{cssFile:g,componentFile:a,allMatches:[...new Set(m)]}}var Me=100;function Le(e){return new Promise(r=>setTimeout(r,e))}async function ke(e,r){if(await Pe(),!j||!$)return console.log(`[UI Copilot] Skipping validation (validator not available) for ${r}`),{valid:!0};let t=j(e,r);if(!t.valid){let o=t.errors.map(s=>s.message).join("; ");return console.warn(`[UI Copilot] Code validation failed for ${r}:`),console.warn($(t)),{valid:!1,error:o}}return t.warnings.length>0&&(console.warn(`[UI Copilot] Code validation warnings for ${r}:`),console.warn($(t))),console.log(`[UI Copilot] Validation passed for ${r}`),{valid:!0}}var ne=!1;function Ae(e){if(ne)return e;ne=!0;let r=process.cwd();return console.log("[UI Copilot] Apply fixes initialized"),console.log("[UI Copilot] Workspace:",r),e.emit(oe,{path:r}),e.on(Ue,()=>{console.log("[UI Copilot] Workspace path requested by browser"),console.log("[UI Copilot] Emitting workspace path response:",r),e.emit(oe,{path:r})}),e.on(Ne,async t=>{let{componentName:o,storyId:s}=t;console.log(`[UI Copilot] Discovering files for component: ${o}`);try{let c=await re(o,r);e.emit(se,{componentName:o,storyId:s,...c,workspacePath:r})}catch(c){console.error("[UI Copilot] File discovery error:",c),e.emit(se,{componentName:o,storyId:s,error:c.message,allMatches:[]})}}),e.on(_e,t=>{setTimeout(async()=>{try{let{issues:o,storybookRoot:s}=t,c=s||r;console.log(s?`[UI Copilot] Using storybookRoot from API: ${s}`:`[UI Copilot] Using process.cwd(): ${r}`),console.log(`[UI Copilot] Received APPLY_FIXES for ${o.length} issue(s)`);let h=new Map;async function i(n){let p=n.targetFileType||"css",g=n.targetFilePath||n.generatedFix?.filePath,a="",m=n.title?.match(/^(\w+)\s/);if(m&&(a=m[1]),!a&&g){let y=g.match(/\/(\w+)\.(?:css|tsx|jsx)$/i);y&&(a=y[1])}if(!a)return console.log(`[UI Copilot] Could not extract component name, using provided path: ${g}`),g||null;if(!h.has(a)){let y=await re(a,c);h.set(a,y)}let d=h.get(a),l=p==="css"?d.cssFile:d.componentFile;return l?(console.log(`[UI Copilot] Discovered ${p} path: ${l} (was: ${g})`),l):(console.log(`[UI Copilot] No ${p} file discovered, using provided: ${g}`),g||null)}let u=[];for(let n of o){let{generatedFix:p}=n,g=n.targetFilePath||p?.filePath,a=await i(n)||g;console.log("[UI Copilot] Processing issue:",{id:n.id,type:n.type,targetFileType:n.targetFileType||"css",targetPath:a,providedPath:g!==a?g:"(same)",codeLength:p?.code?.length||0}),e.emit(xe,{issueId:n.id});try{if(!p||!p.code||!a)throw new Error("Missing AI-generated fix data (code or filePath)");console.log("[UI Copilot] Code to write (first 200 chars):",p.code.substring(0,200)),console.log(`[UI Copilot] Code length: ${p.code.length} chars`);let m=await ke(p.code,a);if(!m.valid)throw new Error(`Code validation failed: ${m.error}. Fix was not applied to prevent breaking the file.`);let d=F.isAbsolute(a)?a:F.join(c,a);console.log(`[UI Copilot] Writing to absolute path: ${d}`),await ie.writeFile(d,p.code,"utf-8"),await Le(Me);let l={success:!0,issueId:n.id,filePath:a,timestamp:new Date};e.emit($e,{issueId:n.id,result:l}),console.log(`[UI Copilot] \u2713 Applied ${n.targetFileType||"css"} fix to: ${a}`),u.push(l)}catch(m){let d=m.message||"Unknown error";e.emit(Fe,{issueId:n.id,error:d}),console.error(`[UI Copilot] \u2717 Error: ${d}`),u.push({success:!1,issueId:n.id,error:d,timestamp:new Date})}}let f={total:u.length,succeeded:u.filter(n=>n.success).length,failed:u.filter(n=>!n.success).length};e.emit(te,{results:u,summary:f}),console.log(`[UI Copilot] Completed: ${f.succeeded}/${f.total} fixes applied`),f.succeeded>0&&e.emit(Re,{message:"Fixes applied. If Storybook crashes due to HMR, please restart it.",filesChanged:u.filter(n=>n.success).map(n=>n.filePath)})}catch(o){console.error("[UI Copilot] Fatal error during fix application:",o),e.emit(te,{results:[],summary:{total:t.issues?.length||0,succeeded:0,failed:t.issues?.length||0}})}},0)}),e}function De(e){let r=process.cwd();return e.plugins=e.plugins||[],e.plugins.push({name:"uicopilot-server-api",configureServer(t){t.middlewares.use("/__uicopilot/health",(o,s)=>{s.writeHead(200,{"Content-Type":"application/json"}),s.end(JSON.stringify({ok:!0,workspacePath:r}))}),t.middlewares.use("/__uicopilot/screenshot",async(o,s)=>{try{if(!await x()){s.writeHead(501,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Puppeteer not installed. Run: npm install puppeteer"}));return}let i=new URL(o.url||"",`http://${o.headers.host}`).searchParams.get("storyId");if(!i){s.writeHead(400,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${o.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${i}&globals=`;console.log(`[UI Copilot] Taking screenshot: ${i}`);let n=await D(f,{selector:"#storybook-root > *"});if(!n){s.writeHead(500,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Screenshot capture failed"}));return}let p=n.toString("base64");s.writeHead(200,{"Content-Type":"application/json"}),s.end(JSON.stringify({screenshot:`data:image/png;base64,${p}`}))}catch(c){console.error("[UI Copilot] Screenshot error:",c.message),s.writeHead(500,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:c.message}))}}),t.middlewares.use("/__uicopilot/capture",async(o,s)=>{try{if(!await x()){s.writeHead(501,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Puppeteer not installed"}));return}let i=new URL(o.url||"",`http://${o.headers.host}`).searchParams.get("storyId");if(!i){s.writeHead(400,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${o.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${i}&globals=`;console.log(`[UI Copilot] Full capture: ${i}`);let n=await D(f,{selector:"#storybook-root > *"});if(!n){s.writeHead(500,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Screenshot capture failed"}));return}let p;try{p=(await import("puppeteer")).default}catch{p=(await import("puppeteer-core")).default}let g=await p.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox"]}),a=await g.newPage();try{await a.setCacheEnabled(!1),await a.setViewport({width:800,height:600}),await a.goto(f,{waitUntil:"networkidle2",timeout:15e3}),await a.evaluate(()=>document.fonts.ready),await a.waitForSelector("#storybook-root > *",{timeout:1e4});let m=await a.evaluate(()=>{let l=document.querySelector("#storybook-root > *")||document.querySelector("#root > *"),y={};if(l){let S=window.getComputedStyle(l);for(let O=0;O<S.length;O++)y[S[O]]=S.getPropertyValue(S[O])}let v={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"]};function w(S){return S.replace(/-([a-z])/g,(O,T)=>T.toUpperCase())}function C(S,O){if(O>4)return null;let T=S.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(T))return null;let U=S.className,N=typeof U=="string"?U:U?.baseVal||"",M=S.id||void 0,ce=S.getAttribute("role")||void 0,B;for(let b of Array.from(S.childNodes))if(b.nodeType===3){let I=b.textContent?.trim();if(I){B=I.length>50?I.substring(0,50)+"...":I;break}}let L=T;M?L=`${T}#${M}`:N&&(L=`${T}.${N.split(" ").filter(Boolean).join(".")}`);let de=window.getComputedStyle(S),ue=["background-color","border","border-radius","box-shadow","opacity","fill","stroke","stroke-width","font-size","font-family","font-weight","line-height","letter-spacing","color","text-align","display","padding","margin","gap","flex-direction","justify-content","align-items","width","height"],k={};for(let b of ue){let I=de.getPropertyValue(b),P=w(b);I&&!v[P]?.includes(I)&&(k[P]=I)}if(T==="svg"||S.closest("svg"))for(let b of["fill","stroke","stroke-width","viewBox","d","r","cx","cy"]){let I=S.getAttribute(b);I&&(k[w(b)]=I)}let H=[];for(let b of Array.from(S.children)){let I=window.getComputedStyle(b);if(I.display==="none"||I.visibility==="hidden")continue;let P=C(b,O+1);P&&H.push(P)}return{selector:L,tagName:T,className:N,id:M,role:ce,textContent:B,styles:k,children:H}}return{computedStyles:y,domTree:l?C(l,0):null}}),d=n.toString("base64");s.writeHead(200,{"Content-Type":"application/json"}),s.end(JSON.stringify({screenshot:`data:image/png;base64,${d}`,computedStyles:m.computedStyles,domTree:m.domTree}))}finally{await a.close(),await g.close()}}catch(c){console.error("[UI Copilot] Capture error:",c.message),s.writeHead(500,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:c.message}))}}),t.middlewares.use("/__uicopilot/screenshot-snapshot",async(o,s)=>{if(o.method!=="POST"){s.writeHead(405,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"POST required"}));return}try{if(!await x()){s.writeHead(501,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Puppeteer not installed"}));return}let h=[];for await(let d of o)h.push(typeof d=="string"?Buffer.from(d):d);let i=JSON.parse(Buffer.concat(h).toString()),{html:u,stylesheetUrls:f,storyId:n}=i;if(!u){s.writeHead(400,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Missing html in body"}));return}let g=`http://${o.headers.host||"localhost:6006"}`;console.log(`[UI Copilot] Taking snapshot screenshot for ${n||"unknown"}`);let a=await X(u,f||[],g,{storyId:n});if(!a){s.writeHead(500,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:"Snapshot screenshot failed"}));return}let m=a.toString("base64");s.writeHead(200,{"Content-Type":"application/json"}),s.end(JSON.stringify({screenshot:`data:image/png;base64,${m}`}))}catch(c){console.error("[UI Copilot] Snapshot screenshot error:",c.message),s.writeHead(500,{"Content-Type":"application/json"}),s.end(JSON.stringify({error:c.message}))}}),t.httpServer?.on("close",()=>{V().catch(()=>{})})}}),e}var je=()=>{if(typeof import.meta<"u"&&import.meta.url){let e=le(import.meta.url),r=ae(e);return R(r,"manager.mjs")}return R(__dirname,"manager.mjs")},Be=()=>{if(typeof import.meta<"u"&&import.meta.url){let e=le(import.meta.url),r=ae(e);return R(r,"preview.mjs")}return R(__dirname,"preview.mjs")};function ze(e=[]){return[...e,je()]}function Qe(e=[]){return[...e,Be()]}export{Ae as experimental_serverChannel,ze as managerEntries,Qe as previewAnnotations,De as viteFinal};
1
+ var he=Object.defineProperty;var ge=(e,s)=>()=>(e&&(s=e(e=0)),s);var me=(e,s)=>{for(var t in s)he(e,t,{get:s[t],enumerable:!0})};var Z={};me(Z,{detectFileType:()=>q,formatValidationResult:()=>Ee,isValidCode:()=>_e,validateCode:()=>z,validateCodeForFile:()=>Q});function Ie(e,s={}){let t=s.minLength??Ce;return e.length<t?{code:"CODE_TOO_SHORT",message:`Code is too short (${e.length} chars). Minimum: ${t}. Likely incomplete or a snippet.`,severity:"error"}:null}function Pe(e){let s=[/^[+-]{3}\s+[ab]\//m,/^@@\s+-\d+,\d+\s+\+\d+,\d+\s+@@/m,/^diff --git/m,/^index [a-f0-9]+\.\.[a-f0-9]+/m];for(let t of s)if(t.test(e))return{code:"CODE_IS_DIFF",message:"Code appears to be a diff/patch format, not complete file content.",severity:"error"};return null}function be(e){let s=e.split(`
2
+ `).filter(i=>i.trim()),t=s.filter(i=>i.trim().startsWith("//")||i.trim().startsWith("/*")||i.trim().startsWith("*")||i.trim().startsWith("#"));if(s.length>0&&t.length/s.length>.8)return{code:"CODE_IS_INSTRUCTIONS",message:"Code appears to be mostly comments/instructions, not actual implementation.",severity:"error"};let o=[/^\/\/\s*(Change|Replace|Update|Modify|Add|Remove|Delete)\s+(from|to|this|the)/im,/^\/\/\s*To:/m,/^\/\/\s*From:/m];for(let i of o)if(i.test(e))return{code:"CODE_IS_INSTRUCTIONS",message:'Code contains instruction comments (e.g., "// Change from:" / "// To:") instead of actual code.',severity:"error"};return null}function ve(e){let s={"{":"}","[":"]","(":")"},t=[],o=!1,i="",n=!1;for(let r=0;r<e.length;r++){let l=e[r],g=e[r-1];if((l==='"'||l==="'"||l==="`")&&g!=="\\"){o?l===i&&(o=!1,n=!1):(o=!0,i=l,l==="`"&&(n=!0));continue}if(!o){if(s[l])t.push(s[l]);else if(Object.values(s).includes(l)&&t.pop()!==l)return{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets detected. Found unexpected '${l}'.`,severity:"warning"}}}return t.length>0?{code:"UNBALANCED_BRACES",message:`Unbalanced braces/brackets. Missing: ${t.reverse().join("")}`,severity:"warning"}:null}function K(e,s={}){let t=[],o=[];e.includes("import ")||t.push({code:"TSX_MISSING_IMPORTS",message:"Component file missing import statements. A complete file must have imports.",severity:"error"}),e.includes("export ")||t.push({code:"TSX_MISSING_EXPORTS",message:"Component file missing exports. A complete file must export something.",severity:"error"});let i=/import\s+(?:React|\{[^}]*\})\s+from\s+['"]react['"]/.test(e);/<[A-Z][a-zA-Z]*|<[a-z]+[\s/>]/.test(e)&&!i&&o.push({code:"TSX_NO_REACT_IMPORT",message:"JSX detected but no React import. OK for React 17+ with automatic runtime.",severity:"warning"}),/export\s+(default\s+)?function\s+\w+/.test(e)||/export\s+(const|let)\s+\w+\s*[:=]/.test(e)||/export\s+default\s+\w+/.test(e)||/export\s+\{[^}]+\}/.test(e)||o.push({code:"TSX_NO_COMPONENT_DEF",message:"No clear component definition found. Expected function or const export.",severity:"warning"});let l=[{pattern:/\.\.\.\s*$/,message:'Code ends with "..." - likely truncated'},{pattern:/\/\/\s*\.\.\./m,message:'Contains "// ..." - likely incomplete'},{pattern:/{\s*\/\*\s*\.\.\.\s*\*\/\s*}/m,message:'Contains "{/* ... */}" placeholder'}];for(let{pattern:g,message:p}of l)g.test(e)&&t.push({code:"TSX_INCOMPLETE",message:p,severity:"error"});return{errors:t,warnings:o}}function Te(e,s={}){let t=[],o=[];(e.includes("import ")||e.includes("export "))&&t.push({code:"CSS_HAS_JS_CODE",message:"CSS file contains JavaScript import/export statements. Wrong file type.",severity:"error"}),/[.#\w\[\]]+\s*\{[\s\S]*?:\s*[^;]+;?[\s\S]*?\}/.test(e)||t.push({code:"CSS_INVALID_SYNTAX",message:"No valid CSS syntax found. Expected selector { property: value; } pattern.",severity:"error"});let n=(e.match(/\{[^}]+\}/g)||[]).length;return n===0&&t.push({code:"CSS_NO_RULES",message:"No CSS rules found. File appears empty or malformed.",severity:"error"}),(e.includes("/* ... */")||e.includes("// ..."))&&t.push({code:"CSS_INCOMPLETE",message:"CSS contains placeholder comments (/* ... */) - likely incomplete.",severity:"error"}),n>0&&n<3&&!s.allowPartial&&o.push({code:"CSS_FEW_RULES",message:`Only ${n} CSS rule(s) found. Might be incomplete.`,severity:"warning"}),{errors:t,warnings:o}}function Oe(e,s={}){let t=[],o=[];return e.includes("import ")||t.push({code:"STORIES_MISSING_IMPORTS",message:"Stories file missing import statements.",severity:"error"}),/@storybook\//.test(e)||t.push({code:"STORIES_NO_STORYBOOK_IMPORT",message:"Stories file must import from @storybook/* (e.g., @storybook/react).",severity:"error"}),e.includes("Meta")||e.includes("ComponentMeta")||o.push({code:"STORIES_NO_META_TYPE",message:"Stories file should have Meta type import for type safety.",severity:"warning"}),e.includes("StoryObj")||e.includes("ComponentStory")||e.includes("Story")||o.push({code:"STORIES_NO_STORY_TYPE",message:"Stories file should have StoryObj/Story type for type safety.",severity:"warning"}),e.includes("export default")||t.push({code:"STORIES_NO_DEFAULT_EXPORT",message:"Stories file must have a default export (meta configuration).",severity:"error"}),/export\s+const\s+\w+\s*[:=]/.test(e)||t.push({code:"STORIES_NO_STORY_EXPORTS",message:"Stories file must have at least one named export (story definition).",severity:"error"}),/import\s+\{?\s*\w+\s*\}?\s+from\s+['"]\.\//.test(e)||o.push({code:"STORIES_NO_COMPONENT_IMPORT",message:"Stories file should import the component being documented.",severity:"warning"}),(e.includes("// ... other")||e.includes("/* ... */"))&&t.push({code:"STORIES_INCOMPLETE",message:"Stories file contains placeholder comments - likely incomplete.",severity:"error"}),{errors:t,warnings:o}}function q(e){let s=e.toLowerCase();if(s.includes(".stories."))return"stories";switch(s.split(".").pop()){case"tsx":return"tsx";case"jsx":return"jsx";case"ts":return"ts";case"js":return"js";case"css":return"css";case"scss":return"scss";case"less":return"less";default:return"unknown"}}function z(e,s,t={}){let o={valid:!0,fileType:s,errors:[],warnings:[]},i=Ie(e,t);i&&o.errors.push(i);let n=Pe(e);n&&o.errors.push(n);let r=be(e);r&&o.errors.push(r);let l=ve(e);switch(l&&(t.strict?o.errors.push({...l,severity:"error"}):o.warnings.push(l)),s){case"stories":{let{errors:g,warnings:p}=Oe(e,t);o.errors.push(...g),o.warnings.push(...p);break}case"tsx":case"jsx":{let{errors:g,warnings:p}=K(e,t);o.errors.push(...g),o.warnings.push(...p);break}case"css":case"scss":case"less":{let{errors:g,warnings:p}=Te(e,t);o.errors.push(...g),o.warnings.push(...p);break}case"ts":case"js":{let{errors:g,warnings:p}=K(e,t);o.errors.push(...g),o.warnings.push(...p.filter(c=>!c.code.includes("JSX")));break}default:break}return o.valid=o.errors.length===0,o}function Q(e,s,t={}){let o=q(s);return z(e,o,t)}function _e(e,s,t={}){return Q(e,s,t).valid}function Ee(e){if(e.valid&&e.warnings.length===0)return`\u2713 Valid ${e.fileType} code`;let s=[];if(e.valid)s.push(`\u26A0 Valid ${e.fileType} code with warnings`);else{s.push(`\u2717 Invalid ${e.fileType} code`),s.push(""),s.push("Errors:");for(let t of e.errors)s.push(` - [${t.code}] ${t.message}`)}if(e.warnings.length>0){s.push(""),s.push("Warnings:");for(let t of e.warnings)s.push(` - [${t.code}] ${t.message}`)}return s.join(`
3
+ `)}var Ce,ee=ge(()=>{"use strict";Ce=50});import{dirname as le,join as F}from"path";import{fileURLToPath as ue}from"url";import*as ce from"fs/promises";import*as N from"path";import{glob as te}from"glob";import{existsSync as ye}from"fs";import{createRequire as we}from"module";var x=null,_=null,V=!1;async function D(){if(V)return!!x;if(V=!0,process.env.STORYBOOK_UICOPILOT_NO_PUPPETEER==="true")return console.log("[UI Parity] Puppeteer disabled via STORYBOOK_UICOPILOT_NO_PUPPETEER flag"),!1;let e=we(process.cwd()+"/");try{return x=e("puppeteer"),console.log("[UI Parity] Puppeteer loaded \u2014 server-side screenshots enabled"),!0}catch{}try{return x=e("puppeteer-core"),console.log("[UI Parity] puppeteer-core loaded \u2014 server-side screenshots enabled"),!0}catch{}return console.log("[UI Parity] Puppeteer not found \u2014 install puppeteer for pixel-perfect screenshots"),!1}function Se(){let e=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium-browser","/usr/bin/chromium"];for(let s of e)if(ye(s))return s}async function G(){if(_&&_.connected)return _;let e=Se(),s={headless:!0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-dev-shm-usage"],...e?{executablePath:e}:{}};return _=await x.launch(s),console.log("[UI Parity] Headless Chrome launched for screenshots"),_}async function j(e,s){if(!await D())return null;let i=await(await G()).newPage();try{await i.setCacheEnabled(!1),await i.setViewport({width:s?.width||800,height:s?.height||600,deviceScaleFactor:1}),await i.goto(e,{waitUntil:"networkidle2",timeout:15e3}),await i.evaluate(()=>document.fonts.ready),await i.waitForSelector("#storybook-root > *",{timeout:1e4}),await i.waitForFunction(()=>new Promise(p=>{let c=document.querySelectorAll("style").length,f=0,h=()=>{let d=document.querySelectorAll("style").length;if(d===c){if(f++,f>=3){p(!0);return}}else f=0,c=d;setTimeout(h,100)};setTimeout(h,200)}),{timeout:5e3}).catch(()=>{}),await new Promise(p=>setTimeout(p,500));let n=await i.evaluate(()=>{let p=document.querySelector("#storybook-root");if(!p)return null;let c=window.innerHeight,f=window.innerWidth,h=1/0,d=0,w=1/0,a=0,u=!1;function S(C){for(let m of Array.from(C.children)){let y=window.getComputedStyle(m);if(y.display==="none"||y.visibility==="hidden"||y.position==="fixed"||y.position==="absolute")continue;let P=m.getBoundingClientRect();if(!(P.height<=0||P.width<=0)){if(P.height>=c*.9&&P.width>=f*.9){S(m);continue}h=Math.min(h,P.top),d=Math.max(d,P.bottom),w=Math.min(w,P.left),a=Math.max(a,P.right),u=!0}}}return S(p),u?{top:h,bottom:d,left:w,right:a}:null}),r=16,l=n?{x:Math.max(0,n.left-r),y:Math.max(0,n.top-r),width:Math.min(n.right-n.left+r*2,800),height:Math.min(n.bottom-n.top+r*2,600)}:void 0,g=await i.screenshot({type:"png",...l?{clip:l}:{fullPage:!1}});return Buffer.from(g)}finally{await i.close()}}async function Y(e,s,t,o){if(!await D())return null;let r=await(await G()).newPage();try{await r.setCacheEnabled(!1),await r.setViewport({width:o?.width||800,height:o?.height||600,deviceScaleFactor:1});let l=o?.storyId||"",g=`${t}/iframe.html?viewMode=story&id=${l}&globals=`;await r.goto(g,{waitUntil:"load",timeout:15e3}),await r.waitForSelector("#storybook-root > *",{timeout:1e4}),await r.evaluate(f=>{let h=document.getElementById("storybook-root");h&&(h.innerHTML=f)},e),await r.evaluate(()=>document.fonts.ready),await new Promise(f=>setTimeout(f,500));let p=await r.evaluate(()=>{let f=document.querySelector("#storybook-root");if(!f)return null;let h=window.innerWidth;function d(u){let S=u.getBoundingClientRect();if(S.width===0||S.height===0)return null;if(S.width<h*.8&&S.height>0)return S;for(let C of Array.from(u.children)){let m=window.getComputedStyle(C);if(m.position==="fixed"||m.position==="absolute"||m.display==="none"||m.visibility==="hidden")continue;let y=d(C);if(y)return y}return null}let w=d(f);if(w)return{x:Math.max(0,w.x-8),y:Math.max(0,w.y-8),width:w.width+16,height:w.height+16};let a=f.firstElementChild;if(a){let u=a.getBoundingClientRect();return{x:u.x,y:u.y,width:u.width,height:u.height}}return null});if(!p)throw new Error("Could not determine component bounds from snapshot");let c=await r.screenshot({type:"png",clip:p});return Buffer.from(c)}finally{await r.close()}}async function R(){return D()}async function B(){_&&(await _.close(),_=null)}var H=null,$=null,se=!1;async function xe(){if(!se){se=!0;try{let e=await Promise.resolve().then(()=>(ee(),Z));H=e.validateCodeForFile,$=e.formatValidationResult,console.log("[UI Parity] Code validator loaded - fix validation enabled")}catch{console.log("[UI Parity] Code validator not available - skipping fix validation")}}}var Re="UICOPILOT/APPLY_FIXES",$e="UICOPILOT/FIX_STARTED",Ne="UICOPILOT/FIX_COMPLETED",Fe="UICOPILOT/FIX_FAILED",oe="UICOPILOT/ALL_FIXES_APPLIED",Ue="UICOPILOT/RELOAD_REQUIRED",re="UICOPILOT/WORKSPACE_PATH",Me="UICOPILOT/REQUEST_WORKSPACE_PATH",Le="UICOPILOT/DISCOVER_COMPONENT_FILES",ne="UICOPILOT/COMPONENT_FILES_DISCOVERED";async function ie(e,s){let t=e.toLowerCase(),o=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),i=[`src/**/fui-${t}/fui-${t}.css`,`src/**/fui-${t}/*.css`,`src/**/${t}/${t}.css`,`src/**/${o}/${o}.css`,`src/**/*${t}*.css`,`src/**/*${o}*.css`,`styles/**/*${t}*.css`],n=[`src/**/fui-${t}/fui-${t}.tsx`,`src/**/fui-${t}/*.tsx`,`src/**/${t}/${t}.tsx`,`src/**/${o}/${o}.tsx`,`src/**/*${o}*.tsx`,`src/**/*${o}*.jsx`],r=[],l=[];for(let a of i)try{let u=await te(a,{cwd:s,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**"]});u.length>0&&r.push(...u)}catch{}for(let a of n)try{let u=await te(a,{cwd:s,nodir:!0,ignore:["**/node_modules/**","**/dist/**","**/.storybook/**","**/*.stories.*","**/*.test.*"]});u.length>0&&l.push(...u)}catch{}let g=[...new Set(r)],p=[...new Set(l)],c=a=>{if(a.length===0)return;let u=a.find(m=>m.includes(`/fui-${t}/`)&&m.endsWith(".css"));if(u)return u;let S=a.find(m=>m.toLowerCase().includes(`/${t}/${t}.css`)||m.includes(`/${o}/${o}.css`));if(S)return S;let C=a.find(m=>m.toLowerCase().endsWith(`/${t}.css`)||m.endsWith(`/${o}.css`));return C||a[0]},f=a=>{if(a.length===0)return;let u=a.filter(y=>!y.includes(".stories.")&&!y.includes(".test."));if(u.length===0)return a[0];let S=u.find(y=>y.includes(`/fui-${t}/`)&&(y.endsWith(".tsx")||y.endsWith(".jsx")));if(S)return S;let C=u.find(y=>y.toLowerCase().includes(`/${t}/${t}.tsx`)||y.includes(`/${o}/${o}.tsx`));if(C)return C;let m=u.find(y=>y.toLowerCase().endsWith(`/${t}.tsx`)||y.endsWith(`/${o}.tsx`));return m||u[0]},h=c(g),d=f(p),w=[...g,...p];return console.log(`[UI Parity] Discovered files for "${e}":`,{cssFile:h,componentFile:d,totalMatches:w.length}),{cssFile:h,componentFile:d,allMatches:[...new Set(w)]}}var ke=100;function Ae(e){return new Promise(s=>setTimeout(s,e))}async function De(e,s){if(await xe(),!H||!$)return console.log(`[UI Parity] Skipping validation (validator not available) for ${s}`),{valid:!0};let t=H(e,s);if(!t.valid){let o=t.errors.map(i=>i.message).join("; ");return console.warn(`[UI Parity] Code validation failed for ${s}:`),console.warn($(t)),{valid:!1,error:o}}return t.warnings.length>0&&(console.warn(`[UI Parity] Code validation warnings for ${s}:`),console.warn($(t))),console.log(`[UI Parity] Validation passed for ${s}`),{valid:!0}}var ae=!1;function je(e){if(ae)return e;ae=!0;let s=process.cwd();return console.log("[UI Parity] Apply fixes initialized"),console.log("[UI Parity] Workspace:",s),e.emit(re,{path:s}),e.on(Me,()=>{console.log("[UI Parity] Workspace path requested by browser"),console.log("[UI Parity] Emitting workspace path response:",s),e.emit(re,{path:s})}),e.on(Le,async t=>{let{componentName:o,storyId:i}=t;console.log(`[UI Parity] Discovering files for component: ${o}`);try{let n=await ie(o,s);e.emit(ne,{componentName:o,storyId:i,...n,workspacePath:s})}catch(n){console.error("[UI Parity] File discovery error:",n),e.emit(ne,{componentName:o,storyId:i,error:n.message,allMatches:[]})}}),e.on(Re,t=>{setTimeout(async()=>{try{let{issues:o,storybookRoot:i}=t,n=i||s;console.log(i?`[UI Parity] Using storybookRoot from API: ${i}`:`[UI Parity] Using process.cwd(): ${s}`),console.log(`[UI Parity] Received APPLY_FIXES for ${o.length} issue(s)`);let r=new Map;async function l(c){let f=c.targetFileType||"css",h=c.targetFilePath||c.generatedFix?.filePath,d="",w=c.title?.match(/^(\w+)\s/);if(w&&(d=w[1]),!d&&h){let S=h.match(/\/(\w+)\.(?:css|tsx|jsx)$/i);S&&(d=S[1])}if(!d)return console.log(`[UI Parity] Could not extract component name, using provided path: ${h}`),h||null;if(!r.has(d)){let S=await ie(d,n);r.set(d,S)}let a=r.get(d),u=f==="css"?a.cssFile:a.componentFile;return u?(console.log(`[UI Parity] Discovered ${f} path: ${u} (was: ${h})`),u):(console.log(`[UI Parity] No ${f} file discovered, using provided: ${h}`),h||null)}let g=[];for(let c of o){let{generatedFix:f}=c,h=c.targetFilePath||f?.filePath,d=await l(c)||h;console.log("[UI Parity] Processing issue:",{id:c.id,type:c.type,targetFileType:c.targetFileType||"css",targetPath:d,providedPath:h!==d?h:"(same)",codeLength:f?.code?.length||0}),e.emit($e,{issueId:c.id});try{if(!f||!f.code||!d)throw new Error("Missing AI-generated fix data (code or filePath)");console.log("[UI Parity] Code to write (first 200 chars):",f.code.substring(0,200)),console.log(`[UI Parity] Code length: ${f.code.length} chars`);let w=await De(f.code,d);if(!w.valid)throw new Error(`Code validation failed: ${w.error}. Fix was not applied to prevent breaking the file.`);let a=N.isAbsolute(d)?d:N.join(n,d);console.log(`[UI Parity] Writing to absolute path: ${a}`),await ce.writeFile(a,f.code,"utf-8"),await Ae(ke);let u={success:!0,issueId:c.id,filePath:d,timestamp:new Date};e.emit(Ne,{issueId:c.id,result:u}),console.log(`[UI Parity] \u2713 Applied ${c.targetFileType||"css"} fix to: ${d}`),g.push(u)}catch(w){let a=w.message||"Unknown error";e.emit(Fe,{issueId:c.id,error:a}),console.error(`[UI Parity] \u2717 Error: ${a}`),g.push({success:!1,issueId:c.id,error:a,timestamp:new Date})}}let p={total:g.length,succeeded:g.filter(c=>c.success).length,failed:g.filter(c=>!c.success).length};e.emit(oe,{results:g,summary:p}),console.log(`[UI Parity] Completed: ${p.succeeded}/${p.total} fixes applied`),p.succeeded>0&&e.emit(Ue,{message:"Fixes applied. If Storybook crashes due to HMR, please restart it.",filesChanged:g.filter(c=>c.success).map(c=>c.filePath)})}catch(o){console.error("[UI Parity] Fatal error during fix application:",o),e.emit(oe,{results:[],summary:{total:t.issues?.length||0,succeeded:0,failed:t.issues?.length||0}})}},0)}),e}function Be(e){let s=process.cwd();return e.plugins=e.plugins||[],e.plugins.push({name:"uicopilot-server-api",configureServer(t){t.middlewares.use("/__uicopilot/health",(n,r)=>{r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({ok:!0,workspacePath:s}))}),t.middlewares.use("/__uicopilot/screenshot",async(n,r)=>{try{if(!await R()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed. Run: npm install puppeteer"}));return}let p=new URL(n.url||"",`http://${n.headers.host}`).searchParams.get("storyId");if(!p){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${n.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${p}&globals=`;console.log(`[UI Parity] Taking screenshot: ${p}`);let h=await j(f,{selector:"#storybook-root > *"});if(!h){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Screenshot capture failed"}));return}let d=h.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${d}`}))}catch(l){console.error("[UI Parity] Screenshot error:",l.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:l.message}))}}),t.middlewares.use("/__uicopilot/capture",async(n,r)=>{try{if(!await R()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed"}));return}let p=new URL(n.url||"",`http://${n.headers.host}`).searchParams.get("storyId");if(!p){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing storyId parameter"}));return}let f=`http://${n.headers.host||"localhost:6006"}/iframe.html?viewMode=story&id=${p}&globals=`;console.log(`[UI Parity] Full capture: ${p}`);let h=await j(f,{selector:"#storybook-root > *"});if(!h){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Screenshot capture failed"}));return}let d;try{d=(await import("puppeteer")).default}catch{d=(await import("puppeteer-core")).default}let w=await d.launch({headless:!0,args:["--no-sandbox","--disable-setuid-sandbox"]}),a=await w.newPage();try{await a.setCacheEnabled(!1),await a.setViewport({width:800,height:600}),await a.goto(f,{waitUntil:"networkidle2",timeout:15e3}),await a.evaluate(()=>document.fonts.ready),await a.waitForSelector("#storybook-root > *",{timeout:1e4}),await a.evaluate(()=>new Promise(C=>{let m=setTimeout(C,5e3);try{let y=window.__STORYBOOK_ADDONS_CHANNEL__;if(y){let P=()=>{clearTimeout(m),y.off("storyRendered",P),setTimeout(C,100)};y.on("storyRendered",P)}else clearTimeout(m),setTimeout(C,300)}catch{clearTimeout(m),C()}}));let u=await a.evaluate(()=>{let C=document.querySelector("#storybook-root > *")||document.querySelector("#root > *"),m={};if(C){let I=window.getComputedStyle(C);for(let T=0;T<I.length;T++)m[I[T]]=I.getPropertyValue(I[T])}let y={backgroundColor:["transparent","rgba(0, 0, 0, 0)"],border:["none","0px none","0px none rgb(0, 0, 0)"],borderRadius:["0px"],boxShadow:["none"],opacity:["1"]};function P(I){return I.replace(/-([a-z])/g,(T,O)=>O.toUpperCase())}function W(I,T){if(T>4)return null;let O=I.tagName.toLowerCase();if(["script","style","link","meta","br","hr","noscript"].includes(O))return null;let U=I.className,M=typeof U=="string"?U:U?.baseVal||"",L=I.id||void 0,de=I.getAttribute("role")||void 0,J;for(let v of Array.from(I.childNodes))if(v.nodeType===3){let b=v.textContent?.trim();if(b){J=b.length>50?b.substring(0,50)+"...":b;break}}let k=O;L?k=`${O}#${L}`:M&&(k=`${O}.${M.split(" ").filter(Boolean).join(".")}`);let pe=window.getComputedStyle(I),fe=["background-color","border","border-radius","box-shadow","opacity","fill","stroke","stroke-width","font-size","font-family","font-weight","line-height","letter-spacing","color","text-align","display","padding","margin","gap","flex-direction","justify-content","align-items","width","height"],A={};for(let v of fe){let b=pe.getPropertyValue(v),E=P(v);b&&!y[E]?.includes(b)&&(A[E]=b)}if(O==="svg"||I.closest("svg"))for(let v of["fill","stroke","stroke-width","viewBox","d","r","cx","cy"]){let b=I.getAttribute(v);b&&(A[P(v)]=b)}let X=[];for(let v of Array.from(I.children)){let b=window.getComputedStyle(v);if(b.display==="none"||b.visibility==="hidden")continue;let E=W(v,T+1);E&&X.push(E)}return{selector:k,tagName:O,className:M,id:L,role:de,textContent:J,styles:A,children:X}}return{computedStyles:m,domTree:C?W(C,0):null}}),S=h.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${S}`,computedStyles:u.computedStyles,domTree:u.domTree}))}finally{await a.close(),await w.close()}}catch(l){console.error("[UI Parity] Capture error:",l.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:l.message}))}}),t.middlewares.use("/__uicopilot/screenshot-snapshot",async(n,r)=>{if(n.method!=="POST"){r.writeHead(405,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"POST required"}));return}try{if(!await R()){r.writeHead(501,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Puppeteer not installed"}));return}let g=[];for await(let S of n)g.push(typeof S=="string"?Buffer.from(S):S);let p=JSON.parse(Buffer.concat(g).toString()),{html:c,stylesheetUrls:f,storyId:h}=p;if(!c){r.writeHead(400,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Missing html in body"}));return}let w=`http://${n.headers.host||"localhost:6006"}`;console.log(`[UI Parity] Taking snapshot screenshot for ${h||"unknown"}`);let a=await Y(c,f||[],w,{storyId:h});if(!a){r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:"Snapshot screenshot failed"}));return}let u=a.toString("base64");r.writeHead(200,{"Content-Type":"application/json"}),r.end(JSON.stringify({screenshot:`data:image/png;base64,${u}`}))}catch(l){console.error("[UI Parity] Snapshot screenshot error:",l.message),r.writeHead(500,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:l.message}))}}),t.httpServer?.on("close",()=>{B().catch(()=>{})});let o=n=>{B().catch(()=>{}).finally(()=>{process.kill(process.pid,n)})},i=globalThis;i.__uicopilotShutdownRegistered||(i.__uicopilotShutdownRegistered=!0,process.once("SIGINT",()=>o("SIGINT")),process.once("SIGTERM",()=>o("SIGTERM")))}}),e}var He=()=>{if(typeof import.meta<"u"&&import.meta.url){let e=ue(import.meta.url),s=le(e);return F(s,"manager.mjs")}return F(__dirname,"manager.mjs")},We=()=>{if(typeof import.meta<"u"&&import.meta.url){let e=ue(import.meta.url),s=le(e);return F(s,"preview.mjs")}return F(__dirname,"preview.mjs")};function Ze(e=[]){return[...e,He()]}function et(e=[]){return[...e,We()]}export{je as experimental_serverChannel,Ze as managerEntries,et as previewAnnotations,Be as viteFinal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uicopilot/storybook-addon",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "AI-powered Figma comparison for Storybook components",
5
5
  "keywords": [
6
6
  "storybook-addons",
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/eransc/uicopilot",
15
15
  "directory": "packages/storybook-addon"
16
16
  },
17
- "author": "UI Copilot",
17
+ "author": "UI Parity",
18
18
  "license": "MIT",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org",