@yuktishaalaa/yuktai 1.0.1 → 1.0.3

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/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.create;var m=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var i in t)m(e,i,{get:t[i],enumerable:!0})},x=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of _(t))!P.call(e,a)&&a!==i&&m(e,a,{get:()=>t[a],enumerable:!(n=C(t,a))||n.enumerable});return e};var L=(e,t,i)=>(i=e!=null?E(F(e)):{},x(t||!e||!e.__esModule?m(i,"default",{value:e,enumerable:!0}):i,e)),T=e=>x(m({},"__esModule",{value:!0}),e);var q={};I(q,{default:()=>O});module.exports=T(q);var g=class{plugins=new Map;register(t,i){if(!i||typeof i.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,i)}async run(t,i){try{let n=this.plugins.get(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(i)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};var f={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var b={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var A=L(require("tesseract.js"),1),c=null,v=null;function R(e){let t=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(t)?"tel":/[\u0900-\u097F]/.test(t)?"hin":/[\u0B80-\u0BFF]/.test(t)?"tam":/[\u4E00-\u9FFF]/.test(t)?"chi_sim":/[\u3040-\u30FF]/.test(t)?"jpn":/[\u0600-\u06FF]/.test(t)?"ara":/[\u0400-\u04FF]/.test(t)?"rus":"eng"}async function B(e){return c&&v===e||(c&&(await c.terminate(),c=null),c=await A.default.createWorker({langPath:"/tessdata",logger:()=>{}}),await c.loadLanguage(e),await c.initialize(e),v=e),c}var h={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let t=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),i=e.lang||R(await t.arrayBuffer())||"eng",n=await B(i),{data:a}=await n.recognize(t),o=a.text?.trim();return o?{language:i,confidence:Math.round(a.confidence??0),text:o}:"\u26A0\uFE0F No text detected"}catch(t){return console.error("[ocrSmartPlugin]",t),"\u274C OCR failed"}}};var y={name:"ui.a11y.pro",version:"1.0.1",observer:null,async execute(e){if(!e?.enabled)return this.stopObserver(),"yuktai-a11y: disabled";try{let t=this.applyFixes(e);if(e.autoFix&&this.startObserver(e),this.ensureLiveRegion(),this.announce(`Accessibility active. ${t.fixed} fixes applied.`),e.validate){let i=this.validatePage();return{...t,validation:i}}return t}catch(t){return console.error("WCAG Plugin execution error:",t),{fixed:0,scanned:0,errors:[t.message]}}},applyFixes(e){let t={fixed:0,scanned:0,errors:[]};if(typeof document>"u")return t;let i=e.root||document,n=e.skipFixes||[];try{let a=i.querySelectorAll("a,button,input,select,textarea,img,table,[onclick],[tabindex],h1,h2,h3,h4,h5,h6,iframe,video,audio,[role],[aria-label],[aria-labelledby]");t.scanned=a.length;let o=0;if(a.forEach(l=>{try{let r=l,s=r.tagName.toLowerCase();if(!n.includes("headings")&&/^h[1-6]$/.test(s)){let u=parseInt(s[1]);u>o+1&&o!==0&&(r.setAttribute("aria-level",String(o+1)),t.fixed++),o=u}if(!n.includes("buttons")&&(s==="a"||s==="button")&&!r.innerText.trim()&&!r.getAttribute("aria-label")){let u=r.getAttribute("title")||r.getAttribute("aria-label")||"Interactive element";r.setAttribute("aria-label",u),t.fixed++}if(n.includes("clickables")||(r.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(r).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(s)&&(r.getAttribute("role")||(r.setAttribute("role","button"),t.fixed++),r.tabIndex<0&&(r.tabIndex=0,t.fixed++),r._yuktKeyBound||(r.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r.click())}),r._yuktKeyBound=!0)),!n.includes("forms")&&["input","select","textarea"].includes(s)){if(!r.getAttribute("aria-label")&&!r.getAttribute("aria-labelledby")){let u=r.getAttribute("placeholder")||r.getAttribute("name")||r.getAttribute("title")||s;r.setAttribute("aria-label",u),t.fixed++}r.hasAttribute("required")&&!r.getAttribute("aria-required")&&(r.setAttribute("aria-required","true"),t.fixed++)}!n.includes("images")&&s==="img"&&!r.hasAttribute("alt")&&(r.setAttribute("alt",""),r.setAttribute("aria-hidden","true"),t.fixed++),!n.includes("tables")&&s==="table"&&!l.querySelector("th")&&(r.getAttribute("role")||(r.setAttribute("role","grid"),t.fixed++)),!n.includes("media")&&["video","audio"].includes(s)&&(r.hasAttribute("controls")||(r.setAttribute("controls","true"),t.fixed++)),!n.includes("iframes")&&s==="iframe"&&!r.getAttribute("title")&&(r.setAttribute("title","Embedded content"),t.fixed++)}catch(r){t.errors.push(`Error fixing element ${l.tagName}: ${r.message}`)}}),e.highContrast&&(document.documentElement.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(document.documentElement.style.scrollBehavior="auto",!document.getElementById("yukt-reduce-motion"))){let l=document.createElement("style");l.id="yukt-reduce-motion",l.textContent="*, *::before, *::after { transition: none !important; animation: none !important; }",document.head.appendChild(l)}}catch(a){t.errors.push(`General error in applyFixes: ${a.message}`)}return t},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(t=>{clearTimeout(this._mutationTimer),this._mutationTimer=setTimeout(()=>{t.forEach(i=>{i.addedNodes.forEach(n=>{n instanceof HTMLElement&&this.applyFixes({...e,root:n})})})},100)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this._mutationTimer&&clearTimeout(this._mutationTimer)},cleanup(){this.stopObserver(),this.removeLiveRegion();let e=document.getElementById("yukt-reduce-motion");e&&e.remove(),typeof document<"u"&&(document.documentElement.style.filter="",document.documentElement.style.scrollBehavior="")},ensureLiveRegion(){if(typeof document>"u"||document.getElementById("yukt-sr-announcer"))return;let e=document.createElement("div");e.id="yukt-sr-announcer",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e)},removeLiveRegion(){if(typeof document>"u")return;let e=document.getElementById("yukt-sr-announcer");e&&e.remove()},announce(e){if(typeof document>"u")return;let t=document.getElementById("yukt-sr-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50))},checkContrast(e,t,i=4.5){try{return(a=>{let o=document.createElement("div");o.style.color=a,o.style.backgroundColor=t,document.body.appendChild(o);let l=window.getComputedStyle(o).color,r=window.getComputedStyle(o).backgroundColor;o.remove();let s=l.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/),u=r.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!s||!u)return 1;let d=this.rgbToLuminance(parseInt(s[1]),parseInt(s[2]),parseInt(s[3])),p=this.rgbToLuminance(parseInt(u[1]),parseInt(u[2]),parseInt(u[3])),k=Math.max(d,p),w=Math.min(d,p);return(k+.05)/(w+.05)})(e)>=i}catch(n){return console.warn("Contrast check failed:",n),!0}},validatePage(){let e=[],t=[];if(typeof document>"u")return{score:0,issues:["Server-side rendering detected"],recommendations:[]};document.documentElement.getAttribute("lang")||(e.push("Missing lang attribute on html element"),t.push('Add lang attribute to <html> element (e.g., <html lang="en">)')),document.title||(e.push("Missing page title"),t.push("Add a descriptive <title> element")),document.querySelectorAll('a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])').length===0&&(e.push("No keyboard-focusable elements found"),t.push("Ensure interactive elements are keyboard accessible"));let n=document.querySelectorAll("img:not([alt])");n.length>0&&(e.push(`${n.length} images missing alt text`),t.push("Add descriptive alt text to all images"));let a=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")),o=0;return a.forEach((r,s)=>{let u=parseInt(r.tagName[1]);s>0&&u>o+1&&(e.push(`Skipped heading level: ${r.tagName} after h${o}`),t.push("Ensure heading hierarchy is sequential")),o=u}),{score:Math.max(0,100-e.length*10),issues:e,recommendations:t}}};function M(){if(!globalThis.__yuktai_runtime__){let e=new g;e.register(f.name,f),e.register(b.name,b),e.register(h.name,h),e.register(y.name,y),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var S=M(),$={list(){return S.getPlugins()}},O=$;
1
+ "use strict";"use client";var N=Object.create;var v=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var n in t)v(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of O(t))!q.call(e,o)&&o!==n&&v(e,o,{get:()=>t[o],enumerable:!(i=$(t,o))||i.enumerable});return e};var E=(e,t,n)=>(n=e!=null?N(W(e)):{},F(t||!e||!e.__esModule?v(n,"default",{value:e,enumerable:!0}):n,e)),H=e=>F(v({},"__esModule",{value:!0}),e);var U={};D(U,{YuktAI:()=>B,YuktAIWrapper:()=>S,default:()=>V});module.exports=H(U);var k=class{plugins=new Map;register(t,n){if(!n||typeof n.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,n)}use(t){return this.plugins.get(t)}async run(t,n){try{let i=this.use(t);if(!i)throw new Error(`Plugin not found: ${t}`);return await i.execute(n)}catch(i){throw console.error(`[YuktAI Runtime Error in ${t}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};var w={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var C={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};var M=E(require("tesseract.js"),1),b=null,I=null;function z(e){let t=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(t)?"tel":/[\u0900-\u097F]/.test(t)?"hin":/[\u0B80-\u0BFF]/.test(t)?"tam":/[\u4E00-\u9FFF]/.test(t)?"chi_sim":/[\u3040-\u30FF]/.test(t)?"jpn":/[\u0600-\u06FF]/.test(t)?"ara":/[\u0400-\u04FF]/.test(t)?"rus":"eng"}async function Y(e){return b&&I===e||(b&&(await b.terminate(),b=null),b=await M.default.createWorker({langPath:"/tessdata",logger:()=>{}}),await b.loadLanguage(e),await b.initialize(e),I=e),b}var R={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let t=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),n=e.lang||z(await t.arrayBuffer())||"eng",i=await Y(n),{data:o}=await i.recognize(t),a=o.text?.trim();return a?{language:n,confidence:Math.round(o.confidence??0),text:a}:"\u26A0\uFE0F No text detected"}catch(t){return console.error("[ocrSmartPlugin]",t),"\u274C OCR failed"}}};var p={name:"ui.a11y.pro",version:"1.0.1",observer:null,async execute(e){if(!e?.enabled)return this.stopObserver(),"yuktai-a11y: disabled";try{let t=this.applyFixes(e);if(e.autoFix&&this.startObserver(e),this.ensureLiveRegion(),this.announce(`Accessibility active. ${t.fixed} fixes applied.`),e.validate){let n=this.validatePage();return{...t,validation:n}}return t}catch(t){return console.error("WCAG Plugin execution error:",t),{fixed:0,scanned:0,errors:[t.message]}}},applyFixes(e){let t={fixed:0,scanned:0,errors:[]};if(typeof document>"u")return t;let n=e.root||document,i=e.skipFixes||[];try{let o=n.querySelectorAll("a,button,input,select,textarea,img,table,[onclick],[tabindex],h1,h2,h3,h4,h5,h6,iframe,video,audio,[role],[aria-label],[aria-labelledby]");t.scanned=o.length;let a=0;if(o.forEach(m=>{try{let r=m,s=r.tagName.toLowerCase();if(!i.includes("headings")&&/^h[1-6]$/.test(s)){let u=parseInt(s[1]);u>a+1&&a!==0&&(r.setAttribute("aria-level",String(a+1)),t.fixed++),a=u}if(!i.includes("buttons")&&(s==="a"||s==="button")&&!r.innerText.trim()&&!r.getAttribute("aria-label")){let u=r.getAttribute("title")||r.getAttribute("aria-label")||"Interactive element";r.setAttribute("aria-label",u),t.fixed++}if(i.includes("clickables")||(r.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(r).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(s)&&(r.getAttribute("role")||(r.setAttribute("role","button"),t.fixed++),r.tabIndex<0&&(r.tabIndex=0,t.fixed++),r._yuktKeyBound||(r.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),r.click())}),r._yuktKeyBound=!0)),!i.includes("forms")&&["input","select","textarea"].includes(s)){if(!r.getAttribute("aria-label")&&!r.getAttribute("aria-labelledby")){let u=r.getAttribute("placeholder")||r.getAttribute("name")||r.getAttribute("title")||s;r.setAttribute("aria-label",u),t.fixed++}r.hasAttribute("required")&&!r.getAttribute("aria-required")&&(r.setAttribute("aria-required","true"),t.fixed++)}!i.includes("images")&&s==="img"&&!r.hasAttribute("alt")&&(r.setAttribute("alt",""),r.setAttribute("aria-hidden","true"),t.fixed++),!i.includes("tables")&&s==="table"&&!m.querySelector("th")&&(r.getAttribute("role")||(r.setAttribute("role","grid"),t.fixed++)),!i.includes("media")&&["video","audio"].includes(s)&&(r.hasAttribute("controls")||(r.setAttribute("controls","true"),t.fixed++)),!i.includes("iframes")&&s==="iframe"&&!r.getAttribute("title")&&(r.setAttribute("title","Embedded content"),t.fixed++)}catch(r){t.errors.push(`Error fixing element ${m.tagName}: ${r.message}`)}}),e.highContrast&&(document.documentElement.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(document.documentElement.style.scrollBehavior="auto",!document.getElementById("yukt-reduce-motion"))){let m=document.createElement("style");m.id="yukt-reduce-motion",m.textContent="*, *::before, *::after { transition: none !important; animation: none !important; }",document.head.appendChild(m)}}catch(o){t.errors.push(`General error in applyFixes: ${o.message}`)}return t},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(t=>{clearTimeout(this._mutationTimer),this._mutationTimer=setTimeout(()=>{t.forEach(n=>{n.addedNodes.forEach(i=>{i instanceof HTMLElement&&this.applyFixes({...e,root:i})})})},100)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this._mutationTimer&&clearTimeout(this._mutationTimer)},cleanup(){this.stopObserver(),this.removeLiveRegion();let e=document.getElementById("yukt-reduce-motion");e&&e.remove(),typeof document<"u"&&(document.documentElement.style.filter="",document.documentElement.style.scrollBehavior="")},ensureLiveRegion(){if(typeof document>"u"||document.getElementById("yukt-sr-announcer"))return;let e=document.createElement("div");e.id="yukt-sr-announcer",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e)},removeLiveRegion(){if(typeof document>"u")return;let e=document.getElementById("yukt-sr-announcer");e&&e.remove()},announce(e){if(typeof document>"u")return;let t=document.getElementById("yukt-sr-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50))},checkContrast(e,t,n=4.5){try{return(o=>{let a=document.createElement("div");a.style.color=o,a.style.backgroundColor=t,document.body.appendChild(a);let m=window.getComputedStyle(a).color,r=window.getComputedStyle(a).backgroundColor;a.remove();let s=m.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/),u=r.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!s||!u)return 1;let f=this.rgbToLuminance(parseInt(s[1]),parseInt(s[2]),parseInt(s[3])),x=this.rgbToLuminance(parseInt(u[1]),parseInt(u[2]),parseInt(u[3])),c=Math.max(f,x),g=Math.min(f,x);return(c+.05)/(g+.05)})(e)>=n}catch(i){return console.warn("Contrast check failed:",i),!0}},validatePage(){let e=[],t=[];if(typeof document>"u")return{score:0,issues:["Server-side rendering detected"],recommendations:[]};document.documentElement.getAttribute("lang")||(e.push("Missing lang attribute on html element"),t.push('Add lang attribute to <html> element (e.g., <html lang="en">)')),document.title||(e.push("Missing page title"),t.push("Add a descriptive <title> element")),document.querySelectorAll('a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])').length===0&&(e.push("No keyboard-focusable elements found"),t.push("Ensure interactive elements are keyboard accessible"));let i=document.querySelectorAll("img:not([alt])");i.length>0&&(e.push(`${i.length} images missing alt text`),t.push("Add descriptive alt text to all images"));let o=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")),a=0;return o.forEach((r,s)=>{let u=parseInt(r.tagName[1]);s>0&&u>a+1&&(e.push(`Skipped heading level: ${r.tagName} after h${a}`),t.push("Ensure heading hierarchy is sequential")),a=u}),{score:Math.max(0,100-e.length*10),issues:e,recommendations:t}}};var h=E(require("react"),1),T=E(require("react-dom/client"),1),L=require("react/jsx-runtime");function A(e){if(!h.default.isValidElement(e))return e;let t=e,n={...t.props};if((t.type==="input"||t.type==="textarea"||t.type==="select")&&!n["aria-label"]&&!n["aria-labelledby"]&&(n["aria-label"]=n.placeholder||n.name||`${t.type} field`),t.type==="button"&&!n["aria-label"]&&!n.children&&(n["aria-label"]="Interactive button"),t.type==="img"&&(n.alt||(n.alt="",n["aria-hidden"]="true")),(t.type==="div"||t.type==="span")&&n.onClick){n.role="button",n.tabIndex=0;let o=n.onClick;n.onKeyDown=a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),o(a))}}let i=h.default.Children.map(n.children,o=>h.default.isValidElement(o)?A(o):o);return h.default.cloneElement(t,n,i)}function _(e,t){let n=document.querySelector(t);if(!n)throw new Error(`[YuktAI] Target container not found: ${t}`);let i=A(e);T.default.createRoot(n).render((0,L.jsx)(h.default.StrictMode,{children:i}))}var d=require("react");var l=require("react/jsx-runtime"),K={enabled:!0,highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100};function S({children:e}){let t=e?A(e):null,[n,i]=(0,d.useState)(!1),[o,a]=(0,d.useState)(K),[m,r]=(0,d.useState)(!1),s=(0,d.useRef)(null),u=(0,d.useRef)(null),f=(c,g)=>a(y=>({...y,[c]:g}));(0,d.useEffect)(()=>((async()=>(await p.execute({enabled:!0,autoFix:!0}),r(!0)))(),()=>p.stopObserver()),[]),(0,d.useEffect)(()=>{if(!n)return;let c=g=>{s.current&&!s.current.contains(g.target)&&u.current&&!u.current.contains(g.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);let x=(0,d.useCallback)(async()=>{let c={enabled:!0,highContrast:o.highContrast,reduceMotion:o.reduceMotion,autoFix:o.autoFix};await p.execute(c),document.documentElement.style.fontSize=`${o.fontScale}%`;let g=document.getElementById("yuktai-dyslexia");if(o.dyslexiaFont){if(!g){let y=document.createElement("style");y.id="yuktai-dyslexia",y.textContent="body, body * { font-family: 'Georgia', serif !important; letter-spacing: 0.05em !important; line-height: 1.8 !important; }",document.head.appendChild(y)}}else g?.remove();i(!1)},[o]);return(0,l.jsxs)(l.Fragment,{children:[t,(0,l.jsx)("button",{ref:u,onClick:()=>i(!n),style:{position:"fixed",bottom:20,right:20,width:50,height:50,borderRadius:"50%",background:"#0d9488",color:"#fff",border:"none",cursor:"pointer",zIndex:9999,boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:(0,l.jsx)("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"currentColor",children:(0,l.jsx)("path",{d:"M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm9 7h-6v13h-2v-6h-2v6H9V9H3V7h18v2z"})})}),n&&(0,l.jsxs)("div",{ref:s,style:{position:"fixed",bottom:80,right:20,width:280,background:"#fff",borderRadius:12,padding:16,boxShadow:"0 10px 25px rgba(0,0,0,0.1)",zIndex:9999,border:"1px solid #eee"},children:[(0,l.jsx)("h4",{style:{margin:"0 0 15px",color:"#333"},children:"Accessibility Menu"}),(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[(0,l.jsxs)("label",{style:{fontSize:13,display:"flex",justifyContent:"space-between"},children:["High Contrast ",(0,l.jsx)("input",{type:"checkbox",checked:o.highContrast,onChange:c=>f("highContrast",c.target.checked)})]}),(0,l.jsxs)("label",{style:{fontSize:13,display:"flex",justifyContent:"space-between"},children:["Dyslexia Font ",(0,l.jsx)("input",{type:"checkbox",checked:o.dyslexiaFont,onChange:c=>f("dyslexiaFont",c.target.checked)})]}),(0,l.jsx)("button",{onClick:x,style:{marginTop:10,padding:8,background:"#0d9488",color:"#fff",border:"none",borderRadius:4,cursor:"pointer"},children:"Save Settings"})]})]})]})}function G(){if(!globalThis.__yuktai_runtime__){let e=new k;e.register(w.name,w),e.register(C.name,C),e.register(R.name,R),e.register(p.name,p),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var P=G(),B={render:_,list(){return P.getPlugins()},use(e){return P.use(e)}},V=B;0&&(module.exports={YuktAI,YuktAIWrapper});
package/dist/index.d.cts CHANGED
@@ -1,30 +1,43 @@
1
+ import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
1
4
  interface Plugin {
2
5
  name: string;
3
6
  execute(input: any): any | Promise<any>;
4
7
  }
5
8
  declare class Runtime {
6
9
  private plugins;
10
+ register(name: string, plugin: Plugin): void;
7
11
  /**
8
- * 🔹 Register plugin safely
9
- * Ensures the plugin exists and has a valid execute function.
12
+ * 🔹 Direct Plugin Access
13
+ * This is what YuktAI.use(name) calls.
10
14
  */
11
- register(name: string, plugin: Plugin): void;
15
+ use(name: string): Plugin | undefined;
12
16
  /**
13
17
  * 🔹 Run task
14
- * Simplified execution without lifecycle event overhead.
15
18
  */
16
19
  run(task: string, input: unknown): Promise<unknown>;
17
- /**
18
- * 🔹 Safe plugin listing
19
- */
20
20
  getPlugins(): string[];
21
21
  }
22
22
 
23
+ /**
24
+ * Layer 2: Global DOM Renderer
25
+ * Renders React into the DOM with auto-fixes applied.
26
+ */
27
+ declare function render(element: React.ReactNode, selector: string): void;
28
+
29
+ interface YuktAIWrapperProps {
30
+ children?: React.ReactNode;
31
+ }
32
+ declare function YuktAIWrapper({ children }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
33
+
23
34
  declare global {
24
35
  var __yuktai_runtime__: Runtime | undefined;
25
36
  }
26
37
  declare const YuktAI: {
38
+ render: typeof render;
27
39
  list(): string[];
40
+ use(name: string): Plugin | undefined;
28
41
  };
29
42
 
30
- export { YuktAI as default };
43
+ export { YuktAI, YuktAIWrapper, YuktAI as default };
package/dist/index.d.ts CHANGED
@@ -1,30 +1,43 @@
1
+ import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
1
4
  interface Plugin {
2
5
  name: string;
3
6
  execute(input: any): any | Promise<any>;
4
7
  }
5
8
  declare class Runtime {
6
9
  private plugins;
10
+ register(name: string, plugin: Plugin): void;
7
11
  /**
8
- * 🔹 Register plugin safely
9
- * Ensures the plugin exists and has a valid execute function.
12
+ * 🔹 Direct Plugin Access
13
+ * This is what YuktAI.use(name) calls.
10
14
  */
11
- register(name: string, plugin: Plugin): void;
15
+ use(name: string): Plugin | undefined;
12
16
  /**
13
17
  * 🔹 Run task
14
- * Simplified execution without lifecycle event overhead.
15
18
  */
16
19
  run(task: string, input: unknown): Promise<unknown>;
17
- /**
18
- * 🔹 Safe plugin listing
19
- */
20
20
  getPlugins(): string[];
21
21
  }
22
22
 
23
+ /**
24
+ * Layer 2: Global DOM Renderer
25
+ * Renders React into the DOM with auto-fixes applied.
26
+ */
27
+ declare function render(element: React.ReactNode, selector: string): void;
28
+
29
+ interface YuktAIWrapperProps {
30
+ children?: React.ReactNode;
31
+ }
32
+ declare function YuktAIWrapper({ children }: YuktAIWrapperProps): react_jsx_runtime.JSX.Element;
33
+
23
34
  declare global {
24
35
  var __yuktai_runtime__: Runtime | undefined;
25
36
  }
26
37
  declare const YuktAI: {
38
+ render: typeof render;
27
39
  list(): string[];
40
+ use(name: string): Plugin | undefined;
28
41
  };
29
42
 
30
- export { YuktAI as default };
43
+ export { YuktAI, YuktAIWrapper, YuktAI as default };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var m=class{plugins=new Map;register(t,s){if(!s||typeof s.execute!="function")throw new Error(`Invalid plugin: ${t}`);this.plugins.set(t,s)}async run(t,s){try{let n=this.plugins.get(t);if(!n)throw new Error(`Plugin not found: ${t}`);return await n.execute(s)}catch(n){throw console.error(`[YuktAI Runtime Error in ${t}]:`,n),n}}getPlugins(){return Array.from(this.plugins.keys())}};var g={name:"ai.text",async execute(e){return`\u{1F916} YuktAI says: ${e}`}};var f={name:"voice.text",async execute(e){return!e||e.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${e}`}};import A from"tesseract.js";var c=null,p=null;function k(e){let t=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(e.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(t)?"tel":/[\u0900-\u097F]/.test(t)?"hin":/[\u0B80-\u0BFF]/.test(t)?"tam":/[\u4E00-\u9FFF]/.test(t)?"chi_sim":/[\u3040-\u30FF]/.test(t)?"jpn":/[\u0600-\u06FF]/.test(t)?"ara":/[\u0400-\u04FF]/.test(t)?"rus":"eng"}async function w(e){return c&&p===e||(c&&(await c.terminate(),c=null),c=await A.createWorker({langPath:"/tessdata",logger:()=>{}}),await c.loadLanguage(e),await c.initialize(e),p=e),c}var b={name:"image.ocr.smart",async execute(e){try{if(!e?.file)return"\u274C No file provided";let t=e.file instanceof Blob?e.file:new Blob([e.file],{type:e.type??"image/png"}),s=e.lang||k(await t.arrayBuffer())||"eng",n=await w(s),{data:u}=await n.recognize(t),i=u.text?.trim();return i?{language:s,confidence:Math.round(u.confidence??0),text:i}:"\u26A0\uFE0F No text detected"}catch(t){return console.error("[ocrSmartPlugin]",t),"\u274C OCR failed"}}};var h={name:"ui.a11y.pro",version:"1.0.1",observer:null,async execute(e){if(!e?.enabled)return this.stopObserver(),"yuktai-a11y: disabled";try{let t=this.applyFixes(e);if(e.autoFix&&this.startObserver(e),this.ensureLiveRegion(),this.announce(`Accessibility active. ${t.fixed} fixes applied.`),e.validate){let s=this.validatePage();return{...t,validation:s}}return t}catch(t){return console.error("WCAG Plugin execution error:",t),{fixed:0,scanned:0,errors:[t.message]}}},applyFixes(e){let t={fixed:0,scanned:0,errors:[]};if(typeof document>"u")return t;let s=e.root||document,n=e.skipFixes||[];try{let u=s.querySelectorAll("a,button,input,select,textarea,img,table,[onclick],[tabindex],h1,h2,h3,h4,h5,h6,iframe,video,audio,[role],[aria-label],[aria-labelledby]");t.scanned=u.length;let i=0;if(u.forEach(l=>{try{let r=l,o=r.tagName.toLowerCase();if(!n.includes("headings")&&/^h[1-6]$/.test(o)){let a=parseInt(o[1]);a>i+1&&i!==0&&(r.setAttribute("aria-level",String(i+1)),t.fixed++),i=a}if(!n.includes("buttons")&&(o==="a"||o==="button")&&!r.innerText.trim()&&!r.getAttribute("aria-label")){let a=r.getAttribute("title")||r.getAttribute("aria-label")||"Interactive element";r.setAttribute("aria-label",a),t.fixed++}if(n.includes("clickables")||(r.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(r).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(o)&&(r.getAttribute("role")||(r.setAttribute("role","button"),t.fixed++),r.tabIndex<0&&(r.tabIndex=0,t.fixed++),r._yuktKeyBound||(r.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r.click())}),r._yuktKeyBound=!0)),!n.includes("forms")&&["input","select","textarea"].includes(o)){if(!r.getAttribute("aria-label")&&!r.getAttribute("aria-labelledby")){let a=r.getAttribute("placeholder")||r.getAttribute("name")||r.getAttribute("title")||o;r.setAttribute("aria-label",a),t.fixed++}r.hasAttribute("required")&&!r.getAttribute("aria-required")&&(r.setAttribute("aria-required","true"),t.fixed++)}!n.includes("images")&&o==="img"&&!r.hasAttribute("alt")&&(r.setAttribute("alt",""),r.setAttribute("aria-hidden","true"),t.fixed++),!n.includes("tables")&&o==="table"&&!l.querySelector("th")&&(r.getAttribute("role")||(r.setAttribute("role","grid"),t.fixed++)),!n.includes("media")&&["video","audio"].includes(o)&&(r.hasAttribute("controls")||(r.setAttribute("controls","true"),t.fixed++)),!n.includes("iframes")&&o==="iframe"&&!r.getAttribute("title")&&(r.setAttribute("title","Embedded content"),t.fixed++)}catch(r){t.errors.push(`Error fixing element ${l.tagName}: ${r.message}`)}}),e.highContrast&&(document.documentElement.style.filter="contrast(1.15) brightness(1.05)"),e.reduceMotion&&(document.documentElement.style.scrollBehavior="auto",!document.getElementById("yukt-reduce-motion"))){let l=document.createElement("style");l.id="yukt-reduce-motion",l.textContent="*, *::before, *::after { transition: none !important; animation: none !important; }",document.head.appendChild(l)}}catch(u){t.errors.push(`General error in applyFixes: ${u.message}`)}return t},startObserver(e){this.observer||typeof document>"u"||(this.observer=new MutationObserver(t=>{clearTimeout(this._mutationTimer),this._mutationTimer=setTimeout(()=>{t.forEach(s=>{s.addedNodes.forEach(n=>{n instanceof HTMLElement&&this.applyFixes({...e,root:n})})})},100)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this._mutationTimer&&clearTimeout(this._mutationTimer)},cleanup(){this.stopObserver(),this.removeLiveRegion();let e=document.getElementById("yukt-reduce-motion");e&&e.remove(),typeof document<"u"&&(document.documentElement.style.filter="",document.documentElement.style.scrollBehavior="")},ensureLiveRegion(){if(typeof document>"u"||document.getElementById("yukt-sr-announcer"))return;let e=document.createElement("div");e.id="yukt-sr-announcer",e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(e)},removeLiveRegion(){if(typeof document>"u")return;let e=document.getElementById("yukt-sr-announcer");e&&e.remove()},announce(e){if(typeof document>"u")return;let t=document.getElementById("yukt-sr-announcer");t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50))},checkContrast(e,t,s=4.5){try{return(u=>{let i=document.createElement("div");i.style.color=u,i.style.backgroundColor=t,document.body.appendChild(i);let l=window.getComputedStyle(i).color,r=window.getComputedStyle(i).backgroundColor;i.remove();let o=l.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/),a=r.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!o||!a)return 1;let d=this.rgbToLuminance(parseInt(o[1]),parseInt(o[2]),parseInt(o[3])),y=this.rgbToLuminance(parseInt(a[1]),parseInt(a[2]),parseInt(a[3])),x=Math.max(d,y),v=Math.min(d,y);return(x+.05)/(v+.05)})(e)>=s}catch(n){return console.warn("Contrast check failed:",n),!0}},validatePage(){let e=[],t=[];if(typeof document>"u")return{score:0,issues:["Server-side rendering detected"],recommendations:[]};document.documentElement.getAttribute("lang")||(e.push("Missing lang attribute on html element"),t.push('Add lang attribute to <html> element (e.g., <html lang="en">)')),document.title||(e.push("Missing page title"),t.push("Add a descriptive <title> element")),document.querySelectorAll('a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])').length===0&&(e.push("No keyboard-focusable elements found"),t.push("Ensure interactive elements are keyboard accessible"));let n=document.querySelectorAll("img:not([alt])");n.length>0&&(e.push(`${n.length} images missing alt text`),t.push("Add descriptive alt text to all images"));let u=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")),i=0;return u.forEach((r,o)=>{let a=parseInt(r.tagName[1]);o>0&&a>i+1&&(e.push(`Skipped heading level: ${r.tagName} after h${i}`),t.push("Ensure heading hierarchy is sequential")),i=a}),{score:Math.max(0,100-e.length*10),issues:e,recommendations:t}}};function E(){if(!globalThis.__yuktai_runtime__){let e=new m;e.register(g.name,g),e.register(f.name,f),e.register(b.name,b),e.register(h.name,h),globalThis.__yuktai_runtime__=e}return globalThis.__yuktai_runtime__}var C=E(),_={list(){return C.getPlugins()}},q=_;export{q as default};
1
+ "use client";var v=class{plugins=new Map;register(e,n){if(!n||typeof n.execute!="function")throw new Error(`Invalid plugin: ${e}`);this.plugins.set(e,n)}use(e){return this.plugins.get(e)}async run(e,n){try{let i=this.use(e);if(!i)throw new Error(`Plugin not found: ${e}`);return await i.execute(n)}catch(i){throw console.error(`[YuktAI Runtime Error in ${e}]:`,i),i}}getPlugins(){return Array.from(this.plugins.keys())}};var A={name:"ai.text",async execute(t){return`\u{1F916} YuktAI says: ${t}`}};var E={name:"voice.text",async execute(t){return!t||t.trim()===""?"\u{1F3A4} No speech detected":`\u{1F3A4} You said: ${t}`}};import _ from"tesseract.js";var f=null,R=null;function L(t){let e=new TextDecoder("utf-8",{fatal:!1}).decode(new Uint8Array(t.slice(0,2e3)));return/[\u0C00-\u0C7F]/.test(e)?"tel":/[\u0900-\u097F]/.test(e)?"hin":/[\u0B80-\u0BFF]/.test(e)?"tam":/[\u4E00-\u9FFF]/.test(e)?"chi_sim":/[\u3040-\u30FF]/.test(e)?"jpn":/[\u0600-\u06FF]/.test(e)?"ara":/[\u0400-\u04FF]/.test(e)?"rus":"eng"}async function P(t){return f&&R===t||(f&&(await f.terminate(),f=null),f=await _.createWorker({langPath:"/tessdata",logger:()=>{}}),await f.loadLanguage(t),await f.initialize(t),R=t),f}var w={name:"image.ocr.smart",async execute(t){try{if(!t?.file)return"\u274C No file provided";let e=t.file instanceof Blob?t.file:new Blob([t.file],{type:t.type??"image/png"}),n=t.lang||L(await e.arrayBuffer())||"eng",i=await P(n),{data:o}=await i.recognize(e),a=o.text?.trim();return a?{language:n,confidence:Math.round(o.confidence??0),text:a}:"\u26A0\uFE0F No text detected"}catch(e){return console.error("[ocrSmartPlugin]",e),"\u274C OCR failed"}}};var g={name:"ui.a11y.pro",version:"1.0.1",observer:null,async execute(t){if(!t?.enabled)return this.stopObserver(),"yuktai-a11y: disabled";try{let e=this.applyFixes(t);if(t.autoFix&&this.startObserver(t),this.ensureLiveRegion(),this.announce(`Accessibility active. ${e.fixed} fixes applied.`),t.validate){let n=this.validatePage();return{...e,validation:n}}return e}catch(e){return console.error("WCAG Plugin execution error:",e),{fixed:0,scanned:0,errors:[e.message]}}},applyFixes(t){let e={fixed:0,scanned:0,errors:[]};if(typeof document>"u")return e;let n=t.root||document,i=t.skipFixes||[];try{let o=n.querySelectorAll("a,button,input,select,textarea,img,table,[onclick],[tabindex],h1,h2,h3,h4,h5,h6,iframe,video,audio,[role],[aria-label],[aria-labelledby]");e.scanned=o.length;let a=0;if(o.forEach(c=>{try{let r=c,s=r.tagName.toLowerCase();if(!i.includes("headings")&&/^h[1-6]$/.test(s)){let u=parseInt(s[1]);u>a+1&&a!==0&&(r.setAttribute("aria-level",String(a+1)),e.fixed++),a=u}if(!i.includes("buttons")&&(s==="a"||s==="button")&&!r.innerText.trim()&&!r.getAttribute("aria-label")){let u=r.getAttribute("title")||r.getAttribute("aria-label")||"Interactive element";r.setAttribute("aria-label",u),e.fixed++}if(i.includes("clickables")||(r.hasAttribute("onclick")||typeof window<"u"&&window.getComputedStyle(r).cursor==="pointer")&&!["button","a","input","select","textarea"].includes(s)&&(r.getAttribute("role")||(r.setAttribute("role","button"),e.fixed++),r.tabIndex<0&&(r.tabIndex=0,e.fixed++),r._yuktKeyBound||(r.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r.click())}),r._yuktKeyBound=!0)),!i.includes("forms")&&["input","select","textarea"].includes(s)){if(!r.getAttribute("aria-label")&&!r.getAttribute("aria-labelledby")){let u=r.getAttribute("placeholder")||r.getAttribute("name")||r.getAttribute("title")||s;r.setAttribute("aria-label",u),e.fixed++}r.hasAttribute("required")&&!r.getAttribute("aria-required")&&(r.setAttribute("aria-required","true"),e.fixed++)}!i.includes("images")&&s==="img"&&!r.hasAttribute("alt")&&(r.setAttribute("alt",""),r.setAttribute("aria-hidden","true"),e.fixed++),!i.includes("tables")&&s==="table"&&!c.querySelector("th")&&(r.getAttribute("role")||(r.setAttribute("role","grid"),e.fixed++)),!i.includes("media")&&["video","audio"].includes(s)&&(r.hasAttribute("controls")||(r.setAttribute("controls","true"),e.fixed++)),!i.includes("iframes")&&s==="iframe"&&!r.getAttribute("title")&&(r.setAttribute("title","Embedded content"),e.fixed++)}catch(r){e.errors.push(`Error fixing element ${c.tagName}: ${r.message}`)}}),t.highContrast&&(document.documentElement.style.filter="contrast(1.15) brightness(1.05)"),t.reduceMotion&&(document.documentElement.style.scrollBehavior="auto",!document.getElementById("yukt-reduce-motion"))){let c=document.createElement("style");c.id="yukt-reduce-motion",c.textContent="*, *::before, *::after { transition: none !important; animation: none !important; }",document.head.appendChild(c)}}catch(o){e.errors.push(`General error in applyFixes: ${o.message}`)}return e},startObserver(t){this.observer||typeof document>"u"||(this.observer=new MutationObserver(e=>{clearTimeout(this._mutationTimer),this._mutationTimer=setTimeout(()=>{e.forEach(n=>{n.addedNodes.forEach(i=>{i instanceof HTMLElement&&this.applyFixes({...t,root:i})})})},100)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!1}))},stopObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this._mutationTimer&&clearTimeout(this._mutationTimer)},cleanup(){this.stopObserver(),this.removeLiveRegion();let t=document.getElementById("yukt-reduce-motion");t&&t.remove(),typeof document<"u"&&(document.documentElement.style.filter="",document.documentElement.style.scrollBehavior="")},ensureLiveRegion(){if(typeof document>"u"||document.getElementById("yukt-sr-announcer"))return;let t=document.createElement("div");t.id="yukt-sr-announcer",t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;",document.body.appendChild(t)},removeLiveRegion(){if(typeof document>"u")return;let t=document.getElementById("yukt-sr-announcer");t&&t.remove()},announce(t){if(typeof document>"u")return;let e=document.getElementById("yukt-sr-announcer");e&&(e.textContent="",setTimeout(()=>{e.textContent=t},50))},checkContrast(t,e,n=4.5){try{return(o=>{let a=document.createElement("div");a.style.color=o,a.style.backgroundColor=e,document.body.appendChild(a);let c=window.getComputedStyle(a).color,r=window.getComputedStyle(a).backgroundColor;a.remove();let s=c.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/),u=r.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!s||!u)return 1;let d=this.rgbToLuminance(parseInt(s[1]),parseInt(s[2]),parseInt(s[3])),x=this.rgbToLuminance(parseInt(u[1]),parseInt(u[2]),parseInt(u[3])),l=Math.max(d,x),m=Math.min(d,x);return(l+.05)/(m+.05)})(t)>=n}catch(i){return console.warn("Contrast check failed:",i),!0}},validatePage(){let t=[],e=[];if(typeof document>"u")return{score:0,issues:["Server-side rendering detected"],recommendations:[]};document.documentElement.getAttribute("lang")||(t.push("Missing lang attribute on html element"),e.push('Add lang attribute to <html> element (e.g., <html lang="en">)')),document.title||(t.push("Missing page title"),e.push("Add a descriptive <title> element")),document.querySelectorAll('a,button,input,select,textarea,[tabindex]:not([tabindex="-1"])').length===0&&(t.push("No keyboard-focusable elements found"),e.push("Ensure interactive elements are keyboard accessible"));let i=document.querySelectorAll("img:not([alt])");i.length>0&&(t.push(`${i.length} images missing alt text`),e.push("Add descriptive alt text to all images"));let o=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")),a=0;return o.forEach((r,s)=>{let u=parseInt(r.tagName[1]);s>0&&u>a+1&&(t.push(`Skipped heading level: ${r.tagName} after h${a}`),e.push("Ensure heading hierarchy is sequential")),a=u}),{score:Math.max(0,100-t.length*10),issues:t,recommendations:e}}};import h from"react";import B from"react-dom/client";import{jsx as N}from"react/jsx-runtime";function k(t){if(!h.isValidElement(t))return t;let e=t,n={...e.props};if((e.type==="input"||e.type==="textarea"||e.type==="select")&&!n["aria-label"]&&!n["aria-labelledby"]&&(n["aria-label"]=n.placeholder||n.name||`${e.type} field`),e.type==="button"&&!n["aria-label"]&&!n.children&&(n["aria-label"]="Interactive button"),e.type==="img"&&(n.alt||(n.alt="",n["aria-hidden"]="true")),(e.type==="div"||e.type==="span")&&n.onClick){n.role="button",n.tabIndex=0;let o=n.onClick;n.onKeyDown=a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),o(a))}}let i=h.Children.map(n.children,o=>h.isValidElement(o)?k(o):o);return h.cloneElement(e,n,i)}function S(t,e){let n=document.querySelector(e);if(!n)throw new Error(`[YuktAI] Target container not found: ${e}`);let i=k(t);B.createRoot(n).render(N(h.StrictMode,{children:i}))}import{useState as C,useEffect as F,useRef as I,useCallback as $}from"react";import{Fragment as W,jsx as b,jsxs as y}from"react/jsx-runtime";var O={enabled:!0,highContrast:!1,reduceMotion:!1,autoFix:!0,dyslexiaFont:!1,fontScale:100};function M({children:t}){let e=t?k(t):null,[n,i]=C(!1),[o,a]=C(O),[c,r]=C(!1),s=I(null),u=I(null),d=(l,m)=>a(p=>({...p,[l]:m}));F(()=>((async()=>(await g.execute({enabled:!0,autoFix:!0}),r(!0)))(),()=>g.stopObserver()),[]),F(()=>{if(!n)return;let l=m=>{s.current&&!s.current.contains(m.target)&&u.current&&!u.current.contains(m.target)&&i(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[n]);let x=$(async()=>{let l={enabled:!0,highContrast:o.highContrast,reduceMotion:o.reduceMotion,autoFix:o.autoFix};await g.execute(l),document.documentElement.style.fontSize=`${o.fontScale}%`;let m=document.getElementById("yuktai-dyslexia");if(o.dyslexiaFont){if(!m){let p=document.createElement("style");p.id="yuktai-dyslexia",p.textContent="body, body * { font-family: 'Georgia', serif !important; letter-spacing: 0.05em !important; line-height: 1.8 !important; }",document.head.appendChild(p)}}else m?.remove();i(!1)},[o]);return y(W,{children:[e,b("button",{ref:u,onClick:()=>i(!n),style:{position:"fixed",bottom:20,right:20,width:50,height:50,borderRadius:"50%",background:"#0d9488",color:"#fff",border:"none",cursor:"pointer",zIndex:9999,boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:b("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"currentColor",children:b("path",{d:"M12 2c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm9 7h-6v13h-2v-6h-2v6H9V9H3V7h18v2z"})})}),n&&y("div",{ref:s,style:{position:"fixed",bottom:80,right:20,width:280,background:"#fff",borderRadius:12,padding:16,boxShadow:"0 10px 25px rgba(0,0,0,0.1)",zIndex:9999,border:"1px solid #eee"},children:[b("h4",{style:{margin:"0 0 15px",color:"#333"},children:"Accessibility Menu"}),y("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[y("label",{style:{fontSize:13,display:"flex",justifyContent:"space-between"},children:["High Contrast ",b("input",{type:"checkbox",checked:o.highContrast,onChange:l=>d("highContrast",l.target.checked)})]}),y("label",{style:{fontSize:13,display:"flex",justifyContent:"space-between"},children:["Dyslexia Font ",b("input",{type:"checkbox",checked:o.dyslexiaFont,onChange:l=>d("dyslexiaFont",l.target.checked)})]}),b("button",{onClick:x,style:{marginTop:10,padding:8,background:"#0d9488",color:"#fff",border:"none",borderRadius:4,cursor:"pointer"},children:"Save Settings"})]})]})]})}function q(){if(!globalThis.__yuktai_runtime__){let t=new v;t.register(A.name,A),t.register(E.name,E),t.register(w.name,w),t.register(g.name,g),globalThis.__yuktai_runtime__=t}return globalThis.__yuktai_runtime__}var T=q(),D={render:S,list(){return T.getPlugins()},use(t){return T.use(t)}},de=D;export{D as YuktAI,M as YuktAIWrapper,de as default};
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@yuktishaalaa/yuktai",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Privacy-first, offline-first Indic language AI and Web Orchestrator",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js"
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
16
  "publishConfig": {
@@ -21,10 +21,9 @@
21
21
  "dist"
22
22
  ],
23
23
  "scripts": {
24
- "dev": "tsup src/index.ts --format cjs,esm --watch --dts",
25
- "build": "tsup src/index.ts --format cjs,esm --clean --dts --minify",
24
+ "dev": "tsup src/index.ts --format cjs,esm --watch --dts --external react --external react-dom",
25
+ "build": "tsup src/index.ts --format cjs,esm --clean --dts --minify --external react --external react-dom",
26
26
  "lint": "tsc --noEmit",
27
- "test": "echo \"Error: no test specified\" && exit 1",
28
27
  "prepublishOnly": "npm run build"
29
28
  },
30
29
  "repository": {
@@ -41,64 +40,21 @@
41
40
  ],
42
41
  "author": "Sandeep Miriyala",
43
42
  "license": "ISC",
43
+ "peerDependencies": {
44
+ "react": ">=18",
45
+ "react-dom": ">=18"
46
+ },
44
47
  "dependencies": {
45
- "acorn": "^8.16.0",
46
- "any-promise": "^1.3.0",
47
- "bmp-js": "^0.1.0",
48
- "bundle-require": "^5.1.0",
49
- "cac": "^6.7.14",
50
- "chokidar": "^4.0.3",
51
- "commander": "^4.1.1",
52
- "confbox": "^0.1.8",
53
- "consola": "^3.4.2",
54
- "debug": "^4.4.3",
55
- "esbuild": "^0.27.7",
56
- "fdir": "^6.5.0",
57
- "fix-dts-default-cjs-exports": "^1.0.1",
58
48
  "idb-keyval": "^6.2.2",
59
- "is-url": "^1.2.4",
60
- "joycon": "^3.1.1",
61
- "lilconfig": "^3.1.3",
62
- "lines-and-columns": "^1.2.4",
63
- "load-tsconfig": "^0.2.5",
64
- "magic-string": "^0.30.21",
65
- "mlly": "^1.8.2",
66
- "ms": "^2.1.3",
67
- "mz": "^2.7.0",
68
- "node-fetch": "^2.7.0",
69
- "object-assign": "^4.1.1",
70
- "opencollective-postinstall": "^2.0.3",
71
- "pathe": "^2.0.3",
72
- "picocolors": "^1.1.1",
73
- "picomatch": "^4.0.4",
74
- "pirates": "^4.0.7",
75
- "pkg-types": "^1.3.1",
76
- "postcss-load-config": "^6.0.1",
77
- "readdirp": "^4.1.2",
78
- "regenerator-runtime": "^0.13.11",
79
- "resolve-from": "^5.0.0",
80
- "rollup": "^4.60.1",
81
- "source-map": "^0.7.6",
82
- "sucrase": "^3.35.1",
83
49
  "tesseract.js": "^7.0.0",
84
- "tesseract.js-core": "^7.0.0",
85
- "thenify": "^3.3.1",
86
- "thenify-all": "^1.6.0",
87
- "tinyexec": "^0.3.2",
88
- "tinyglobby": "^0.2.16",
89
- "tr46": "^0.0.3",
90
- "tree-kill": "^1.2.2",
91
- "ts-interface-checker": "^0.1.13",
92
- "tsup": "^8.5.1",
93
- "typescript": "^6.0.2",
94
- "ufo": "^1.6.3",
95
- "wasm-feature-detect": "^1.8.0",
96
- "webidl-conversions": "^3.0.1",
97
- "whatwg-url": "^5.0.0",
98
- "zlibjs": "^0.3.1"
50
+ "wasm-feature-detect": "^1.8.0"
99
51
  },
100
- "bugs": {
101
- "url": "https://github.com/sandeepmiriyala03/yuktai/issues"
102
- },
103
- "homepage": "https://github.com/sandeepmiriyala03/yuktai#readme"
52
+ "devDependencies": {
53
+ "@types/react": "^19.0.0",
54
+ "@types/react-dom": "^19.0.0",
55
+ "react": "^19.0.0",
56
+ "react-dom": "^19.0.0",
57
+ "tsup": "^8.5.1",
58
+ "typescript": "^5.0.0"
59
+ }
104
60
  }