PageSourceSearch

https://basicfusion.org/compiler/buildCommon.js?v=4

js basicfusion.org collected 2026-10-05 03:08:19 UTC 6,106 bytes, 1 lines download raw bytes

1const BUILD_FIELD_SUFFIXES=["Title","Author","Desc","Scaling","ShowViewSwitch","MobileGamepad"];function defaultBuildName(){const e=document.getElementById("sb-filename");return(e?.textContent||"").replace(/\.(bf|bas|txt)$/i,"").trim()||"game"}function countProgramVariables(e){try{const n=e.replace(/"[^"]*"/g,'""').replace(/'[^\n]*/g,"").replace(/(^|:)\s*REM\b[^\n]*/gi,"$1"),t=new Set,i=e=>{if(!e)return;const n=e.trim().match(/^([A-Za-z_][A-Za-z0-9_]*\$?)/);n&&t.add(n[1].toUpperCase())};let a=!1;for(const e of n.split("\n"))if(/^[ \t]*END\s+(TYPE|OBJECT)\b/i.test(e))a=!1;else if(/^[ \t]*(TYPE|OBJECT)\s+[A-Za-z_]/i.test(e))a=!0;else if(!a)for(const n of e.split(":")){const e=n.match(/^[ \t]*(?:DIM|REDIM|STATIC)\s+(?:SHARED\s+)?(.+)$/i);if(e){for(const n of e[1].split(",")){const e=n.trim();/^[A-Za-z_][A-Za-z0-9_]*\$?\s*\(/.test(e)||i(e)}continue}const t=n.match(/^[ \t]*FOR\s+([A-Za-z_][A-Za-z0-9_]*\$?)\s*=/i);if(t){i(t[1]);continue}const a=n.match(/^[ \t]*(?:LET\s+)?([A-Za-z_][A-Za-z0-9_]*\$?)\s*=(?!=)/i);a&&i(a[1])}return t.size}catch(e){return window.__bfDebug,0}}window.ensureBuildAnim=function(){if(document.getElementById("bf-build-anim"))return;const e=document.createElement("style");e.id="bf-build-anim",e.textContent="\n@keyframes bf-spin { to { transform: rotate(360deg); } }\n@keyframes bf-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(360%); } }\n.bf-spin { display:inline-block; width:12px; height:12px; margin-right:6px; vertical-align:-2px; border:2px solid currentColor; border-top-color:transparent; border-radius:50%; animation:bf-spin .7s linear infinite; }\n.bf-bar { margin-top:8px; height:4px; border-radius:2px; background:var(--bg-darker); overflow:hidden; }\n.bf-bar > div { width:40%; height:100%; border-radius:2px; background:var(--accent,#4ec9b0); animation:bf-slide 1.1s ease-in-out infinite; }",document.head.appendChild(e)},window.buildBusyHTML=function(e){return window.ensureBuildAnim(),`<div><span class="bf-spin"></span>${e}</div><div class="bf-bar"><div></div></div>`},window.syncBuildFields=function(e){for(const n of BUILD_FIELD_SUFFIXES){const t=document.getElementById(e+n),i=document.getElementById("build"+n);t&&i&&("checkbox"===t.type?i.checked=t.checked:i.value=t.value)}},window.buildStatsHTML=function(e,n=!0){const t=n=>(e.match(n)??[]).length,i=(e,n,t)=>`<div class="build-stat"><span>${e}</span><b class="${t?"build-stat-flag":""}">${n}</b></div>`,a=e=>e>0?"Yes":"No";return`<div class="build-stats${n?" boxed":""}">\n        ${i("Lines of code",e.split("\n").length)}\n        ${i("Custom Types",t(/^[ \t]*TYPE\s+[A-Za-z_]/gim))}\n        ${i("Objects",t(/^[ \t]*OBJECT\s+[A-Za-z_]/gim))}\n        ${i("Loops",t(/\b(FOR|WHILE|DO)\b/gi))}\n        ${i("Subs & Functions",t(/^[ \t]*(SUB|FUNCTION)\s+[A-Za-z_]/gim))}\n        ${i("Arrays (DIM)",t(/\bDIM\s+[A-Za-z_][A-Za-z0-9_$]*\s*\(/gi))}\n        ${i("Variables",countProgramVariables(e))}\n        ${i("Sprites",t(/\bDEFSPRITE\b/gi))}\n        ${i("Graphics",a(t(/\b(SCREEN|GRAPHICS)\b/gi)),!0)}\n        ${i("Audio/Music",a(t(/\b(PLAY|SOUND|BEEP|NOISE|PLAYMODULE|PLAYMUSIC)\b/gi)),!0)}\n    </div>`},window.createServerBuild=function(e){const n=e=>document.getElementById(e),t={url:null,filename:null,statsHTML:""};function i(i,a,s){const o=n(e.statusId);if(!o)return;o.style.color=a||"";const r=s?window.buildBusyHTML(i):`<div>${i}</div>`;o.innerHTML=r+(t.statsHTML||"")}return{open:function(){window.closeAllModals(),t.url=null,t.filename=null,t.statsHTML="";const i=n(e.statusId);i&&(i.innerHTML="");const a=n(e.dlBtnId);a&&(a.style.display="none");const s=n(e.genBtnId);s&&(s.style.display="inline-block",s.disabled=!1);const o=document.getElementById("codeEditor"),r=window.parseProgramHeader?window.parseProgramHeader(o?o.value:""):{program:"",author:"",version:"",description:""},l=n(e.prefix+"Title");l&&(l.value=r.program||defaultBuildName());const d=n(e.prefix+"Author");d&&(d.value=r.author||"");const c=n(e.prefix+"Desc");c&&(c.value=r.description||""),n(e.modalId)?.classList.add("open")},generate:async function(){const a=n(e.genBtnId),s=n(e.dlBtnId),o=a?a.innerHTML:"";window.ensureBuildAnim(),a&&(a.disabled=!0,a.innerHTML='<span class="bf-spin"></span>Building...'),s&&(s.style.display="none"),t.url=null,t.statsHTML="";try{if(window.syncBuildFields(e.prefix),i("Building...","var(--yellow)",!0),window.standaloneHTMLData=null,await window.generateBuild(),!window.standaloneHTMLData)throw new Error("generateBuild returned no data");const o=await window.standaloneHTMLData.text(),r=67108864,l=new Blob([o]).size;if(l>r)throw new Error("Project too large: "+(l/1048576).toFixed(1)+" MB (limit 64 MB). Remove or shrink embedded assets, or split the project.");const d=n("codeEditor");t.statsHTML=window.buildStatsHTML(d?d.value:"");const c=(n(e.prefix+"Title")?.value||"").trim()||defaultBuildName();t.filename=c.replace(/[^a-zA-Z0-9_\-]/g,"_"),i("Building "+e.label+"...","var(--yellow)",!0);const u=await fetch(e.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:o,filename:t.filename+e.ext,title:c})});let f={};try{f=await u.json()}catch(e){window.__bfDebug}if(!u.ok||!f.downloadUrl)throw new Error(f.error||"Build failed (code "+u.status+")");t.url=f.downloadUrl,i(`<span class="build-status-line"><svg class="bf-ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg> ${e.label} ready! Click Save.</span>`,"var(--green-bright)"),a&&(a.style.display="none"),s&&(s.style.display="inline-block")}catch(e){i('<span class="build-status-line"><svg class="bf-ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.5M12 16.5h.01"/></svg> Error: '+String(e instanceof TypeError?"Build failed. Please try again.":e&&e.message?e.message:e).replace(/[&<>]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;"}[e]))+"</span>","var(--red)")}finally{a&&(a.disabled=!1,a.innerHTML=o)}},download:function(){if(!t.url)return;const n=document.createElement("a");n.href=t.url,n.download=(t.filename||"game")+e.ext,document.body.appendChild(n),n.click(),n.remove()}}};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.