admin08077/Githubgemini
0
1import{r as s,j as e}from"./react-DKy9e2uO.js";import{H as j,A as y,M as g}from"./index-Ykf-MVva.js";import{f as b}from"./geminiService-D2PWX7SA.js";import{L as p}from"./LoadingSpinner-B20BJ_HS.js";import{d as w}from"./fileUtils-Bw7t6Hrv.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./@google-D80DdW2m.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const k=`// main.js2const worker = new Worker('worker.js');3 4// This object is sent back and forth.5// A race condition can occur because both threads6// read the counter, increment it, and send it back.7// The final value depends on which thread's message8// is processed last.9const data = { counter: 0 };10 11worker.onmessage = function(e) {12 // Main thread reads and updates13 data.counter = e.data.counter;14 console.log('Main received:', data.counter);15 data.counter++;16 worker.postMessage(data);17};18 19// Start the process20console.log('Main starting with:', data.counter);21data.counter++;22worker.postMessage(data);23 24 25// worker.js26// onmessage = function(e) {27// // Worker reads and updates28// let receivedCounter = e.data.counter;29// console.log('Worker received:', receivedCounter);30// receivedCounter++;31// postMessage({ counter: receivedCounter });32// }33`,F=({codeInput:t})=>{const[m,x]=s.useState(t||k),[a,u]=s.useState(""),[r,f]=s.useState(!1),[l,d]=s.useState(""),i=s.useCallback(async o=>{if(!o.trim()){d("Please paste some code to analyze.");return}f(!0),d(""),u("");try{const n=b(o);let c="";for await(const h of n)c+=h,u(c)}catch(n){const c=n instanceof Error?n.message:"An unknown error occurred.";d(`Failed to analyze code: ${c}`)}finally{f(!1)}},[]);return s.useEffect(()=>{t&&(x(t),i(t))},[t,i]),e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(j,{}),e.jsx("span",{className:"ml-3",children:"AI Concurrency Analyzer"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Analyze JavaScript code for potential Web Worker concurrency issues."})]}),e.jsxs("div",{className:"flex-grow flex flex-col gap-4 min-h-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsx("label",{htmlFor:"code-input",className:"text-sm font-medium text-text-secondary mb-2",children:"JavaScript Code"}),e.jsx("textarea",{id:"code-input",value:m,onChange:o=>x(o.target.value),placeholder:"Paste your worker-related JS code here...",className:"flex-grow p-4 bg-surface border border-border rounded-md resize-none font-mono text-sm"})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("button",{onClick:()=>i(m),disabled:r,className:"btn-primary w-full max-w-xs mx-auto flex items-center justify-center px-6 py-3",children:r?e.jsx(p,{}):"Analyze Code"})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-text-secondary",children:"AI Analysis"}),a&&!r&&e.jsxs("button",{onClick:()=>w(a,"analysis.md","text/markdown"),className:"flex items-center gap-1 px-3 py-1 bg-gray-100 text-xs rounded-md hover:bg-gray-200",children:[e.jsx(y,{className:"w-4 h-4"})," Download"]})]}),e.jsxs("div",{className:"flex-grow p-4 bg-background border border-border rounded-md overflow-y-auto",children:[r&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(p,{})}),l&&e.jsx("p",{className:"text-red-500",children:l}),a&&!r&&e.jsx(g,{content:a}),!r&&!a&&!l&&e.jsx("div",{className:"text-text-secondary h-full flex items-center justify-center",children:"Analysis will appear here."})]})]})]})]})};export{F as WorkerThreadDebugger};34//# sourceMappingURL=WorkerThreadDebugger-BL_1c1sl.js.map35 