+ `).join("")}}).catch(s=>{console.error("Error fetching data:",s)})}function T(t){let s=document.querySelector(`script[src="${t}"]`);s&&s.remove()}function R(t){t.forEach(s=>{let r=document.querySelector(`script[src="${s}"]`);r&&r.remove()})}async function N(t){return new Promise((s,r)=>{if(document.querySelector(`script[src="${t}"]`)){s();return}let o=document.createElement("script");o.src=t,o.onload=s,o.onerror=()=>r(new Error(`Failed to load script: ${t}`)),document.body.appendChild(o)})}async function _(t){return Promise.all(t.map(N))}async function b(t,s){let r={html:{markdown:"libraries/preprocessors/marked.min.js",jade:"libraries/preprocessors/jade.js",pug:"libraries/preprocessors/pug.js"},css:{sass:"libraries/preprocessors/sass.sync.min.js",less:"libraries/preprocessors/less.min.js",stylus:"libraries/preprocessors/stylus.min.js"},javascript:{typescript:"libraries/preprocessors/typescript.min.js",babel:"libraries/preprocessors/babel.min.js",jsxtypescript:["libraries/preprocessors/typescript.min.js","libraries/preprocessors/babel.min.js"]}},i={html:e.html_pre_processor,css:e.css_pre_processor,javascript:e.javascript_pre_processor};try{let o=s!=="html"||s!=="css"||s!=="javascript",n=o?r[t][s]:null;if(i[t]&&o){let a=r[t][i[t]];Array.isArray(a)?R(a):T(a),Array.isArray(n)?await _(n):n&&await N(n)}t==="html"?(e.html_pre_processor=s,window.editorManager.setMode(e.html_pre_processor==="html"?"html":s,editorManager.htmlEditor)):t==="css"?(e.css_pre_processor=s,window.editorManager.setMode(e.css_pre_processor==="css"?"css":s,editorManager.cssEditor)):t==="javascript"&&(e.javascript_pre_processor=s,window.editorManager.setMode(e.javascript_pre_processor==="javascript"?"javascript":s,editorManager.jsEditor))}catch(o){console.error("Error setting preprocessor:",o)}}async function Y(){await Promise.all([b("html",e.html_pre_processor),b("css",e.css_pre_processor),b("javascript",e.javascript_pre_processor)]),dispatchChanges(editorManager.htmlEditor,e.html),dispatchChanges(editorManager.cssEditor,e.css),dispatchChanges(editorManager.jsEditor,e.javascript),w(!0)}async function V(){await _(["libraries/js-beautify/beautify.min.js","libraries/js-beautify/beautify-css.min.js","libraries/js-beautify/beautify-html.min.js"])}async function J(){R(["libraries/js-beautify/beautify.min.js","libraries/js-beautify/beautify-css.min.js","libraries/js-beautify/beautify-html.min.js"])}async function ae(){await V();let t;switch(e.activePanel){case"html":t=html_beautify(e.html,{indent_size:2,max_preserve_newlines:1}),dispatchChanges(editorManager.htmlEditor,t);break;case"css":t=css_beautify(e.css,{indent_size:2,max_preserve_newlines:1}),e.css=t,dispatchChanges(editorManager.cssEditor,t);break;case"javascript":t=beautify(e.javascript,{indent_size:2,max_preserve_newlines:1}),e.javascript=t,dispatchChanges(editorManager.jsEditor,t);break;default:t="Unknown editor panel."}await J()}function le(){let t="";for(;!/^[a-zA-Z]/.test(t);)t=Math.random().toString(36).substr(2,9);return t}function ce(t){d.selectedSize=t,z()}function pe(){let t=document.getElementById("previewElm").firstElementChild;if(t.style.width==="100%")return!1;let s=parseInt(t.style.width),r=parseInt(t.style.height);[s,r]=[r,s];let i=previewElm.clientWidth,o=previewElm.clientHeight,n=Math.min(i/s,o/r);t.style.width=`${s}px`,t.style.height=`${r}px`,t.style.transform=`scale(${n})`,t.style.marginTop=`-${r/2}px`,t.style.marginLeft=`-${s/2}px`,d.selectedSize=s+"x"+r}function F(){let t=document.getElementById("previewElm").firstElementChild;if(t.style.width==="100%")return!1;let s=parseInt(t.style.width),r=parseInt(t.style.height),i=previewElm.clientWidth,o=previewElm.clientHeight,n=Math.min(i/s,o/r);t.style.width=`${s}px`,t.style.height=`${r}px`,t.style.transform=`scale(${n})`,t.style.marginTop=`-${r/2}px`,t.style.marginLeft=`-${s/2}px`}var H;function z(){if(d.selectedSize==="none"){let t=document.getElementById("iframe");d.iframeSize=`${t.clientWidth}px x ${t.clientHeight}px`;let s=document.getElementById("iframeClientSize");s.classList.contains("hidden")&&(H&&clearTimeout(H),s.classList.remove("hidden","opacity-0"),s.classList.add("opacity-100"),H=setTimeout(()=>{s.classList.remove("opacity-100"),s.classList.add("opacity-0"),setTimeout(()=>{s.classList.add("hidden")},300)},2e3))}else F()}async function M(t){try{if(t==="html")switch(e.html_pre_processor){case"markdown":return marked.parse(e.html);case"jade":return jade.render(e.html,{pretty:!0});case"pug":let s=document.getElementById("appScript");return s.hasAttribute("type")&&s.getAttribute("type")==="module"?(console.error("Cannot import pug as script is a module!"),!1):K("pug").compile(e.html)({name:this.name});default:return e.html}if(t==="css")switch(e.css_pre_processor){case"stylus":return stylus.render(e.css);case"less":return new Promise((s,r)=>{less.render(e.css,(i,o)=>i?r(i):s(o.css))});case"sass":return new Promise((s,r)=>{Sass.compile(e.css,i=>i.status===0?s(i.text):r(new Error(i.message)))});default:return e.css}if(t==="javascript")switch(e.javascript_pre_processor){case"babel":return typeof Babel>"u"&&await N("libraries/preprocessors/babel.min.js"),Babel.transform(e.javascript,{presets:["env","react"]}).code;case"typescript":return ts.transpileModule(e.javascript,{compilerOptions:{module:ts.ModuleKind.CommonJS}}).outputText;case"jsxtypescript":let s=ts.transpileModule(e.javascript,{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES5,jsx:ts.JsxEmit.React}}).outputText;return d.compiledJSX=Babel.transform(s,{presets:["env","react"]}).code,d.compiledJSX;default:return e.javascript}}catch(s){console.error("Error compiling code:",s)}}async function de(t){let s=t.target.files[0];if(s)try{let r=await ue(s);e.logo=r}catch(r){console.error("Error converting image to base64:",r)}}function ue(t){return new Promise((s,r)=>{let i=new FileReader;i.readAsDataURL(t),i.onload=()=>s(i.result),i.onerror=o=>r(o)})}function me(t){function s(i){return i.charAt(0).toUpperCase()+i.slice(1)}let r=s(t);b("html","html"),b("css","css"),t!=="typescript"&&b("javascript","javascript"),(t==="typescript"||t==="angular")&&b("javascript","typescript"),e.name=`${r} name`,e.version=.01,e.title=`A Cool ${r} App`,e.description=`A modern ${r} application!`,e.author="kodeWeave",e.url="https://michaelsboost.com/",e.diffing=!1,e.module=!0,t==="angular"&&(e.module=!1),e.pwa=!1,t==="javascript"&&(e.meta="",e.libraries=["https://cdnjs.cloudflare.com/ajax/libs/picocss/2.0.6/pico.min.css","https://michaelsboost.com/TailwindCSSMod/tailwind-mod.min.js"],e.html=`
\u{1F44B} Hello, ${r}! \u{1F30E}
Counter: 0
-
${icons.twitter}
-
+
`;
}
-function openFeed() {
- // Ask user for confirmation
- Modal.render({
- large: true,
- title: "kodeWeave Feed",
- content: `
-
- `
- });
-}
function emptyStorage() {
// Clear local storage
localStorage.removeItem('kodeWeave');
@@ -3290,7 +3281,6 @@ async function renderPreview(forceRun = false) {
// Make functions available in global space
window.Modal = Modal;
-window.openFeed = openFeed;
window.emptyStorage = emptyStorage;
window.addLibrary = addLibrary;
window.fetchSuggestions = fetchSuggestions;