shinygen 4.6.4 → 4.6.5-rc.2
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/README.md +17 -7
- package/index.js +1 -1
- package/index.pck +0 -0
- package/index.wasm.br +0 -0
- package/package.json +4 -2
- package/shiny_gen_ai_radial_gradient.svg +1924 -0
- package/shinygen.js +1 -1
- package/standalone/index.audio.position.worklet.js +66 -0
- package/standalone/index.audio.worklet.js +213 -0
- package/standalone/index.js +1141 -0
- package/standalone/index.pck +0 -0
- package/standalone/index.wasm.br +0 -0
- package/standalone/webgl/index.audio.position.worklet.js +66 -0
- package/standalone/webgl/index.audio.worklet.js +213 -0
- package/standalone/webgl/index.js +1141 -0
- package/standalone/webgl/index.wasm.br +0 -0
- package/webgl/index.js +1 -1
- package/webgl/index.wasm.br +0 -0
package/shinygen.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var e=document.currentScript,t=e?e.src.replace(/[^/]*$/,""):"./";function n(e,t,n){console.error("[ShinyGen] "+e+(t?": "+t:""));var o=document.createElement("div");o.id="shinygen-error",o.style.cssText=["position:fixed","inset:0","z-index:99999","display:flex","align-items:center","justify-content:center","background:rgba(0,0,0,0.92)","color:#e8e8e8",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"padding:2em","text-align:center"].join(";");var i=document.createElement("div");i.style.cssText="max-width:540px;line-height:1.6;";var r=document.createElement("div");if(r.style.cssText="font-size:1.4em;font-weight:600;color:#ff6b6b;margin-bottom:0.8em;",r.textContent=e,i.appendChild(r),t){var a=document.createElement("div");a.style.cssText="font-size:0.95em;color:#ccc;margin-bottom:1em;white-space:pre-wrap;font-family:monospace;text-align:left;background:rgba(255,255,255,0.06);padding:1em;border-radius:6px;max-height:300px;overflow-y:auto;",a.textContent=t,i.appendChild(a)}if(n){var d=document.createElement("div");d.style.cssText="font-size:0.9em;color:#999;margin-top:0.5em;",d.innerHTML=n,i.appendChild(d)}o.appendChild(i);var l=document.getElementById("shinygen-error");l&&l.remove(),document.body.appendChild(o)}var o=null,i=0;function r(e,t,n){var r=o!==e;o=e;var a=document.getElementById("shinygen-loading-bar"),d=document.getElementById("shinygen-loading-label"),l=document.getElementById("shinygen-loading-detail");if(r&&console.log("[ShinyGen] loading stage: "+e),a)if("connect"===e)d.textContent="Preparing...",a.style.width="2%",a.style.opacity="1",l.textContent="";else if("download"===e){d.textContent="Downloading engine...";var s=Date.now();if(!r&&s-i<80&&t!==n)return;i=s,n>0&&t<=n?(a.style.width=(t/n*100).toFixed(1)+"%",a.style.opacity="1",l.textContent=(t/1048576).toFixed(1)+" / "+(n/1048576).toFixed(1)+" MB"):(a.style.width="60%",a.style.opacity="0.5",l.textContent=(t/1048576).toFixed(1)+" MB")}else"decompress"===e?(d.textContent="Decompressing...",a.style.width="100%",a.style.opacity="0.8"):"start"===e&&(d.textContent="Starting engine...",a.style.width="100%",a.style.opacity="0.7",l.textContent="")}function a(e,t){if(!o){var n=document.getElementById("shinygen-loading-bar"),i=document.getElementById("shinygen-loading-label"),r=document.getElementById("shinygen-loading-detail");if(n)if(t>0){var a=Math.min(100,e/t*100);n.style.width=a.toFixed(1)+"%",i.textContent="Loading engine...";var d=(e/1048576).toFixed(1),l=(t/1048576).toFixed(1);r.textContent=d+" / "+l+" MB",console.log("[ShinyGen] Loading: "+d+"/"+l+" MB ("+a.toFixed(0)+"%)")}else{n.style.width="60%",n.style.opacity="0.5",i.textContent="Loading engine...";var s=(e/1048576).toFixed(1);r.textContent=s+" MB downloaded"}}}function d(){var e=document.getElementById("shinygen-loading");e&&(e.style.transition="opacity 0.3s ease",e.style.opacity="0",setTimeout(function(){e.remove()},300));var t=document.getElementById("canvas");t&&(t.style.visibility="visible")}function l(e,t){if(void 0===t.autoFit||t.autoFit){var n=(e.width||1280)/(e.height||720),o=document.createElement("style");o.id="shinygen-autofit-style",o.textContent="#canvas{max-width:100vw!important;max-height:100vh!important;object-fit:contain!important;}",document.head.appendChild(o),a(),window.addEventListener("resize",a),window.visualViewport&&window.visualViewport.addEventListener("resize",a),window.addEventListener("orientationchange",function(){setTimeout(a,100),setTimeout(a,300)});var i=null;"undefined"!=typeof MutationObserver&&(i=new MutationObserver(function(){a()})).observe(e,{attributes:!0,attributeFilter:["width","height"]});var r=Date.now();requestAnimationFrame(function e(){a(),Date.now()-r<2e3&&requestAnimationFrame(e)}),s._fitCanvas=a}function a(){var i=function(){var e=t.container?"string"==typeof t.container?document.querySelector(t.container):t.container:null;if(e)return{w:e.clientWidth,h:e.clientHeight};var n=window.visualViewport,o=Math.min(window.innerWidth,document.documentElement.clientWidth||1/0),i=Math.min(window.innerHeight,document.documentElement.clientHeight||1/0);return n&&(o=Math.min(o,n.width),i=Math.min(i,n.height)),{w:o,h:i}}(),r=i.w,a=r/n;a>i.h&&(r=(a=i.h)*n),r=Math.floor(r),a=Math.floor(a);var d=Math.max(0,Math.floor((i.h-a)/2));Math.max(0,Math.floor((i.w-r)/2));e.style.cssText="display:block!important;width:"+r+"px!important;height:"+a+"px!important;margin:"+d+"px auto 0!important;padding:0!important;touch-action:none!important;max-width:100vw!important;max-height:100vh!important;",o.textContent="#canvas{width:"+r+"px!important;height:"+a+"px!important;max-width:100vw!important;max-height:100vh!important;margin:"+d+"px auto 0!important;display:block!important;touch-action:none!important;}"}}var s={};s._reportError=function(e,t){n(e,t,'Check your <code><script type="text/gdscript"></code> for errors.')},s._pendingReload=null,s._onReloadResult=null,s.reload=function(e,t){return t=t||0,new Promise(function(n,o){s._onReloadResult=function(e,t){s._onReloadResult=null,e?n(t):o(new Error(t))},s._pendingReload={index:t,source:e}})},s._eventHandlers={},s._gdCallback=null,s._setGDCallback=function(e){s._gdCallback=e},s._dispatch=function(e,t){var n=s._eventHandlers[e];if(n)for(var o=0;o<n.length;o++)try{n[o](t)}catch(t){console.error("[ShinyGen] Event handler error ("+e+"):",t)}},s.on=function(e,t){s._eventHandlers[e]||(s._eventHandlers[e]=[]),s._eventHandlers[e].push(t)},s.send=function(e,t){s._gdCallback?s._gdCallback(e,t||""):console.warn('[ShinyGen] Engine not ready — cannot send "'+e+'"')},s.sendJSON=function(e,t){s.send(e,JSON.stringify(t))},s.onJSON=function(e,t){s.on(e,function(n){try{t(JSON.parse(n))}catch(t){console.error("[ShinyGen] JSON parse error ("+e+"):",t)}})};var c=!1,u=null;function h(e,t){if(!c){c=!0;var n=function(e){var t=e+"vendor/brotli/brotli_dec_wasm.js",n=e+"vendor/brotli/brotli_dec_wasm_bg.wasm";return import(t).then(function(e){return Promise.resolve(e.default(n)).then(function(){return e})})}(e),i=window.fetch.bind(window);if(t&&/index$/.test(t)){var a=t+".wasm.br",d=i(a);d.then(function(e){var t=parseInt(e.headers.get("content-length")||"0",10);e.ok&&"connect"===o&&r("download",0,t)},function(){}),u={url:a,promise:d}}var l=function(e){return new Response(e,{status:200,headers:{"Content-Type":"application/wasm"}})},s=function(e){return e.arrayBuffer().then(function(e){var t=new Uint8Array(e);return 0===t[0]&&97===t[1]&&115===t[2]&&109===t[3]?(console.log("[ShinyGen] engine wasm: served pre-decoded ("+(e.byteLength/1048576).toFixed(1)+" MB)"),r("start"),l(e)):n.then(function(n){var o=n.decompress(t);return console.log("[ShinyGen] engine wasm: brotli "+(e.byteLength/1048576).toFixed(1)+" MB → "+(o.byteLength/1048576).toFixed(1)+" MB"),r("start"),l(o)})})};window.fetch=function(e,t){var a="string"==typeof e?e:e&&e.url||"";if(!/index\.wasm($|\?)/.test(a))return i(e,t);var d,c=a.replace(/index\.wasm/,"index.wasm.br"),h=function(n){return console.log("[ShinyGen] engine wasm: "+n+", falling back to raw index.wasm"),o=null,i(e,t)};return u&&u.url===c?(d=u.promise,u=null):d=i(c,t),d.then(function(e){return e.ok?e.body&&"undefined"!=typeof ReadableStream?function(e){var t=parseInt(e.headers.get("content-length")||"0",10)||0,o=0,i=e.body.getReader(),a=function(e){return i.read().then(function(n){if(n.done)return e;r("download",o+=n.value.length,t);var i=n.value;return e&&((i=new Uint8Array(e.length+n.value.length)).set(e,0),i.set(n.value,e.length)),i.length>=4?i:a(i)})};return a(null).then(function(e){if(!e||e.length<4)throw new Error("engine wasm response is empty");return 0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]?l(new ReadableStream({start:function(t){t.enqueue(e),r("download",o,0)},pull:function(e){return i.read().then(function(t){if(t.done)return console.log("[ShinyGen] engine wasm: served pre-decoded ("+(o/1048576).toFixed(1)+" MB, streamed)"),r("start"),void e.close();r("download",o+=t.value.length,0),e.enqueue(t.value)})},cancel:function(e){return i.cancel(e)}})):n.then(function(n){if(!n||"function"!=typeof n.DecompressStream){var a=[e],d=e.length,s=function(){return i.read().then(function(e){if(e.done){var i=new Uint8Array(d),c=0;a.forEach(function(e){i.set(e,c),c+=e.length});var u=n.decompress(i);return console.log("[ShinyGen] engine wasm: brotli "+(d/1048576).toFixed(1)+" MB → "+(u.byteLength/1048576).toFixed(1)+" MB"),r("start"),l(u)}return r("download",o+=e.value.length,t),a.push(e.value),d+=e.value.length,s()})};return s()}var c=new n.DecompressStream,u=new Uint8Array(0),h=e,g=!1,p=!1,m=!1,f=function(){try{c.free()}catch(e){}},y=function(e,t){m=!0,f(),i.cancel().catch(function(){}),e.error(t)},v=function(e){if(!m){if(g||h&&h.length){var n,a,d,l=h&&h.length?h:u;try{var s=c.decompress(l,4194304);n=s.code,a=s.input_offset,d=s.buf,s.free()}catch(t){return void y(e,new Error("brotli decode failed: "+t))}if(l.length&&(h=a<l.length?l.subarray(a):null),g=3===n,d&&d.length&&e.enqueue(d),1===n){m=!0;var b=0;try{b=c.total_out()}catch(e){}return f(),i.cancel().catch(function(){}),console.log("[ShinyGen] engine wasm: brotli "+(o/1048576).toFixed(1)+" MB → "+(b/1048576).toFixed(1)+" MB (streamed)"),r("start"),void e.close()}if(d&&d.length)return;return v(e)}if(!p)return i.read().then(function(n){return n.done?(p=!0,r("decompress"),v(e)):(r("download",o+=n.value.length,t),h=n.value,v(e))},function(t){y(e,t)});y(e,new Error("brotli stream truncated after "+o+" bytes"))}};return l(new ReadableStream({pull:function(e){return v(e)},cancel:function(e){return m=!0,f(),i.cancel(e)}}))})})}(e).catch(function(e){return console.warn("[ShinyGen] engine wasm: streaming decode failed ("+e+"), retrying one-shot"),i(c,t).then(function(e){return e.ok?s(e):h("no .br (HTTP "+e.status+")")},function(e){return h(".br refetch failed ("+e+")")}).catch(function(e){return h("brotli decode unavailable ("+e+")")})}):s(e):h("no .br (HTTP "+e.status+")")},function(e){return h(".br fetch failed ("+e+")")})}}}var g="4.6.4";s.start=async function(e){if(e=e||{},console.log("[ShinyGen] shinygen package "+(0===g.indexOf("__")?"dev (unstamped loader)":"v"+g)+" — the engine banner below reports the ENGINE build, not the package version"),void 0===e.extras||void 0===e.i18n||void 0===e.renderer){var o=document.querySelector('script[type="application/shinygen-project"]');if(o)try{var i=JSON.parse(o.textContent);void 0===e.extras&&(e.extras=!!i.extras),void 0===e.i18n&&(e.i18n=!!i.i18n),void 0===e.renderer&&i.renderer&&(e.renderer=String(i.renderer))}catch(e){}}var c=e.renderer;if("webgl"!==c&&"auto"!==c&&(c="webgpu"),"auto"===c){var u=null;if(navigator.gpu)try{await navigator.gpu.requestAdapter()||(u="no WebGPU adapter")}catch(e){u="adapter request failed: "+(e.message||e)}else u="navigator.gpu is undefined";c=u?"webgl":"webgpu",u&&console.warn("[ShinyGen] WebGPU is not available ("+u+") — running under the WebGL2 engine.")}s.renderer=c;var p="webgl"===c?"webgl/":"",m=e.executable||t+p+"index";if(console.log("[ShinyGen] engine: single build, renderer: "+c+(e.i18n?" + i18n (ICU data)":"")),"webgpu"===c){if(!navigator.gpu){var f=navigator.userAgent;throw n("WebGPU is not available",null,"This app requires WebGPU, which your browser does not currently support.<br><br>"+(-1!==f.indexOf("Firefox")?"Firefox: Open <code>about:config</code> and set <code>dom.webgpu.enabled</code> to <code>true</code>, then restart.":-1!==f.indexOf("Safari")&&-1===f.indexOf("Chrome")?"Safari: Open Settings → Feature Flags and enable <b>WebGPU</b>.":"Try <b>Chrome 113+</b>, <b>Edge 113+</b>, or <b>Opera 99+</b> on desktop.")),new Error("ShinyGen: WebGPU is not available (navigator.gpu is undefined).")}}else{var y=null;try{y=document.createElement("canvas").getContext("webgl2")}catch(e){}if(!y)throw n("WebGL2 is not available",null,"This engine requires WebGL2, which your browser does not currently support.<br><br>WebGL2 ships in all modern browsers — try updating your browser or enabling hardware acceleration."),new Error("ShinyGen: WebGL2 is not available.")}if(function(){var e=document.createElement("div");e.id="shinygen-loading",e.style.cssText=["position:fixed","inset:0","z-index:99998","display:flex","flex-direction:column","align-items:center","justify-content:center","background:#111","color:#e8e8e8",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"will-change:transform"].join(";");var t=document.createElement("div");t.id="shinygen-loading-label",t.style.cssText="font-size:1.1em;margin-bottom:1.2em;color:#ccc;",t.textContent="Initializing engine...",e.appendChild(t);var n=document.createElement("div");n.style.cssText="width:280px;height:4px;background:rgba(255,255,255,0.1);border-radius:2px;overflow:hidden;";var o=document.createElement("div");o.id="shinygen-loading-bar",o.style.cssText="width:0%;height:100%;background:#4a9eff;border-radius:2px;transition:width 0.2s ease;",n.appendChild(o),e.appendChild(n);var i=document.createElement("div");i.id="shinygen-loading-detail",i.style.cssText="font-size:0.8em;color:#666;margin-top:0.8em;",i.textContent="",e.appendChild(i);var r=document.createElement("div");r.id="shinygen-loading-brand",r.style.cssText="position:absolute;bottom:1.6em;font-size:0.72em;color:#555;letter-spacing:0.04em;",r.textContent="Made with Shiny Gen Engine",e.appendChild(r),(document.body||document.documentElement).appendChild(e)}(),!1!==e.brotliWasm&&(r("connect"),h(t,m)),"webgpu"===c)try{if(!await navigator.gpu.requestAdapter())throw d(),n("No WebGPU adapter found",null,"Your browser supports WebGPU but no compatible GPU was found.<br><br>This can happen with unsupported GPUs, outdated drivers, or headless/virtual environments.<br><br>Try updating your GPU drivers, or use a different device."),new Error("ShinyGen: WebGPU adapter not available.")}catch(e){if(-1!==e.message.indexOf("ShinyGen"))throw e;throw d(),n("WebGPU adapter request failed",e.message,"Your browser supports WebGPU but failed to initialize it."),new Error("ShinyGen: WebGPU adapter request failed: "+e.message)}var v=null;e.canvas&&(v="string"==typeof e.canvas?document.querySelector(e.canvas):e.canvas),v&&"canvas"!==v.id&&(v.id="canvas"),v||(v=document.getElementById("canvas")),v||((v=document.createElement("canvas")).id="canvas",v.style.cssText="display:block;margin:0 auto;padding:0;max-width:100vw;max-height:100vh;",document.body.appendChild(v)),v.style.visibility="hidden";var b,w=e.engineJs||t+p+"index.js";try{await(b=w,new Promise(function(e,t){var n=document.createElement("script");n.src=b,n.onload=e,n.onerror=function(){t(new Error("Failed to load: "+b))},document.head.appendChild(n)}))}catch(e){throw d(),n("Failed to load engine",e.message,"Check that the engine files ("+p+"index.js, "+p+"index.wasm) are served relative to shinygen.js."),e}if("undefined"==typeof Engine)throw d(),n("Engine failed to initialize","The Engine class was not found after loading "+w,"The engine JS file may be corrupt or incompatible."),new Error("ShinyGen: Engine class not found after loading "+w);console.log("[ShinyGen] Engine JS loaded");var x=void 0===e.autoFit||e.autoFit?0:2,E=new Engine({args:"webgl"===c?["--rendering-driver","opengl3","--rendering-method","gl_compatibility"]:[],canvasResizePolicy:void 0!==e.canvasResizePolicy?e.canvasResizePolicy:x,executable:m,mainPack:e.mainPack||("webgl"===c?t+"index.pck":null),focusCanvas:!0,renderingDriver:"webgl"===c?"":"webgpu",onProgress:a});e.i18n&&"function"==typeof E.preloadFile&&(E.preloadFile(t+"icudt_godot.dat","icudt_godot.dat"),console.log("[ShinyGen] i18n: ICU data queued → res://icudt_godot.dat")),console.log("[ShinyGen] Starting engine...");try{await E.startGame()}catch(e){d();var C=e.message||String(e),k="The engine failed to start.";throw-1!==C.indexOf("wasm")||-1!==C.indexOf("fetch")||-1!==C.indexOf("Fetch")?k="Check that <code>"+p+"index.wasm</code> is served relative to shinygen.js.":"webgpu"!==c||-1===C.indexOf("WebGPU")&&-1===C.indexOf("gpu")?"webgl"===c&&-1!==C.toLowerCase().indexOf("gl")&&(k="WebGL2 initialization failed. Try updating your browser or enabling hardware acceleration."):k="WebGPU initialization failed. Your GPU or driver may not be supported.",n("Engine failed to start",C,k),e}return d(),function(e){var t=document.querySelector('meta[name="viewport"]');t&&t.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),e.style.touchAction="none",document.body.style.touchAction="none",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden",document.documentElement.style.position="fixed",document.documentElement.style.width="100%",document.documentElement.style.height="100%",document.addEventListener("touchmove",function(t){t.target===e||t.target.closest("#shinygen-touchcontrols")||t.preventDefault()},{passive:!1})}(v),l(v,e),function(e,t){var n=void 0!==t.touchControls?t.touchControls:"auto";if(!1!==n&&"none"!==n&&("auto"!==n||"ontouchstart"in window)){var o=document.createElement("div");o.id="shinygen-touchcontrols",o.style.cssText=["position:fixed","inset:0","z-index:9999","pointer-events:none","user-select:none","-webkit-user-select:none","touch-action:none"].join(";");var i=document.createElement("div");i.style.cssText=["position:absolute","left:16px","bottom:16px","width:140px","height:140px","pointer-events:auto"].join(";"),[{key:"w",label:"▲",x:45,y:0,w:50,h:45},{key:"s",label:"▼",x:45,y:95,w:50,h:45},{key:"a",label:"◀",x:0,y:45,w:45,h:50},{key:"d",label:"▶",x:95,y:45,w:45,h:50}].forEach(function(e){var t=document.createElement("div");t.style.cssText="position:absolute;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.13);border:1.5px solid rgba(255,255,255,0.25);border-radius:8px;color:rgba(255,255,255,0.7);font-size:18px;transition:background 0.08s;-webkit-tap-highlight-color:transparent;left:"+e.x+"px;top:"+e.y+"px;width:"+e.w+"px;height:"+e.h+"px;",t.textContent=e.label,t.dataset.key=e.key,i.appendChild(t)});var r=document.createElement("div");r.style.cssText="position:absolute;left:45px;top:45px;width:50px;height:50px;background:rgba(255,255,255,0.06);border-radius:50%;",i.appendChild(r),o.appendChild(i),[{key:"Enter",label:"A",bottom:60,right:16},{key:"Escape",label:"B",bottom:16,right:72}].forEach(function(e){var t=document.createElement("div");t.style.cssText=["position:absolute","pointer-events:auto","bottom:"+e.bottom+"px","right:"+e.right+"px","width:52px","height:52px","border-radius:50%","display:flex","align-items:center","justify-content:center","background:rgba(255,255,255,0.13)","border:1.5px solid rgba(255,255,255,0.25)","color:rgba(255,255,255,0.7)","font-size:16px","font-weight:bold","font-family:-apple-system,BlinkMacSystemFont,sans-serif","-webkit-tap-highlight-color:transparent"].join(";"),t.textContent=e.label,t.dataset.key=e.key,o.appendChild(t)}),document.body.appendChild(o);var a={};o.addEventListener("touchstart",l,{passive:!1}),o.addEventListener("touchend",l,{passive:!1}),o.addEventListener("touchcancel",l,{passive:!1}),o.addEventListener("touchmove",function(e){e.preventDefault();for(var t={},n=0;n<e.touches.length;n++){var i=e.touches[n],r=document.elementFromPoint(i.clientX,i.clientY);r&&r.dataset&&r.dataset.key&&(t[r.dataset.key]=r)}Object.keys(a).forEach(function(e){t[e]||(delete a[e],o.querySelectorAll('[data-key="'+e+'"]').forEach(function(e){e.style.background="rgba(255,255,255,0.13)"}),d(e,"keyup"))}),Object.keys(t).forEach(function(e){a[e]||(a[e]=!0,t[e].style.background="rgba(255,255,255,0.35)",d(e,"keydown"))})},{passive:!1})}function d(t,n){e.focus();var o=new KeyboardEvent(n,{key:t,code:"Enter"===t?"Enter":"Escape"===t?"Escape":"ArrowUp"===t?"ArrowUp":"ArrowDown"===t?"ArrowDown":"ArrowLeft"===t?"ArrowLeft":"ArrowRight"===t?"ArrowRight":"Key"+t.toUpperCase(),keyCode:"Enter"===t?13:"Escape"===t?27:t.toUpperCase().charCodeAt(0),bubbles:!0,cancelable:!0});e.dispatchEvent(o)}function l(e){e.preventDefault();var t=e.target.closest("[data-key]");if(t){var n=t.dataset.key;"touchstart"===e.type?a[n]||(a[n]=!0,t.style.background="rgba(255,255,255,0.35)",d(n,"keydown")):"touchend"!==e.type&&"touchcancel"!==e.type||a[n]&&(delete a[n],t.style.background="rgba(255,255,255,0.13)",d(n,"keyup"))}}}(v,e),console.log("[ShinyGen] Engine started"),E},window.ShinyGen=s}();
|
|
1
|
+
!function(){"use strict";var e=document.currentScript,t=e?e.src.replace(/[^/]*$/,""):"./";function n(e){e=e||{};const t="shiny-lane-router:219bf71c26c1669f",n="shiny_force_webgl",o="shiny_lane_override",i="shiny_lane_attempts";function r(e,t){try{return window[e].getItem(t)}catch(e){return null}}function a(e,t,n){try{return window[e].setItem(t,n),!0}catch(e){return!1}}function s(e,t){try{window[e].removeItem(t)}catch(e){}}function l(){return r("sessionStorage",n)}function d(){const e=parseInt(r("sessionStorage",i)||"0",10);return isFinite(e)&&e>0?e:0}function c(e){try{const t=new URLSearchParams(window.location.search).get(e);return null===t?null:String(t).trim().toLowerCase()}catch(e){return null}}function u(e,t){return Promise.race([e,new Promise(e=>{setTimeout(()=>e("shiny_timeout"),t)})])}function h(t,n){if("function"==typeof e.beacon)try{e.beacon(t,n)}catch(e){}}function g(t,n){try{if("function"==typeof e.terminal)return void e.terminal(t,n)}catch(e){}console.error("[shiny-router] "+t+" "+JSON.stringify(n))}const f=function(){if("undefined"==typeof navigator)return null;const e=navigator.userAgentData;if(e&&!0===e.mobile)return"userAgentData.mobile";const t=navigator.userAgent||"";if(/Android|iPhone|iPod|IEMobile|BlackBerry|Opera Mini|Windows Phone|webOS/i.test(t))return"user-agent";const n=navigator.platform||"";return(navigator.maxTouchPoints||0)>1&&(/^Mac/i.test(n)||/Macintosh/i.test(t))?"iPadOS (Mac UA + multi-touch)":null}();let p=!1;function m(e,t){if(p)return!0;p=!0;const r=(t&&t.message?t.message:String(t||"")).slice(0,200);return h("fail",{fk:e,err:r.slice(0,120)}),window.SHINY_LANE_FORCED?(g("pinned-failed",{renderer:window.SHINY_RENDERER,msg:r}),!0):"webgpu"!==window.SHINY_RENDERER?(g("webgl-failed",{prior:l(),msg:r}),!0):l()||d()>=1?(g("retry-exhausted",{msg:r}),!0):a("sessionStorage",n,e+": "+r)||a("localStorage",o,"webgl:"+Date.now())?(a("sessionStorage",i,String(d()+1)),console.warn("[shiny-router] webgpu lane "+e+" failure ("+r+") — reloading into the webgl lane"),window.location.reload(),!0):(g("no-storage",{msg:r}),!0)}function w(){return navigator.gpu.requestAdapter()}async function y(){const e=function(){const e=c("lane");if(null!==e){if("webgl"===e||"webgpu"===e)return a("localStorage",o,e+":"+Date.now()),{lane:e,forced:!0,reason:"?lane="+e+" (pinned; clear with ?lane=auto)"};"auto"===e||"clear"===e||"off"===e||""===e?(s("localStorage",o),s("sessionStorage",n),s("sessionStorage",i),console.log("[shiny-router] ?lane="+e+" — cleared the pinned lane and the retry flag")):console.warn("[shiny-router] ignoring unknown ?lane="+e+" (use webgl, webgpu or auto)")}const t=(r("localStorage",o)||"").split(":"),l=t[0];if("webgl"===l||"webgpu"===l){const e=parseInt(t[1]||"0",10);if(!(isFinite(e)&&e>0&&Date.now()-e>2592e6))return{lane:l,forced:!0,reason:"pinned lane "+l+" from an earlier ?lane= (clear with ?lane=auto)"};s("localStorage",o),console.log("[shiny-router] the pinned lane expired — auto-detecting")}return null}();if(e)return e;const t=l();if(t)return{lane:"webgl",reason:"webgpu retry flag set ("+t+")"};if(f)return{lane:"webgl",reason:"mobile browser ["+f+"] — GL lane by policy, WebGPU probe skipped"};if("undefined"==typeof navigator||!navigator.gpu)return{lane:"webgl",reason:"navigator.gpu is undefined"};try{const e=await u(w(),4e3);if("shiny_timeout"===e)return{lane:"webgl",reason:"requestAdapter timed out"};if(!e)return{lane:"webgl",reason:"requestAdapter returned null"};if(e.isFallbackAdapter)return{lane:"webgl",reason:"software (fallback) WebGPU adapter"};const t=await u(e.requestDevice(),4e3);if("shiny_timeout"===t)return{lane:"webgl",reason:"requestDevice timed out"};if(!t)return{lane:"webgl",reason:"requestDevice returned null"};try{t.destroy()}catch(e){}return{lane:"webgpu",reason:"hardware adapter + device OK"}}catch(e){return{lane:"webgl",reason:"probe threw: "+(e&&e.message?e.message:String(e))}}}return{fingerprint:t,mobile:f,pick:async function(){const e=await y();return window.SHINY_RENDERER=e.lane,window.SHINY_LANE_FORCED=!!e.forced,window.SHINY_LANE_REASON=e.reason,window.SHINY_LANE_ROUTER_FP=t,console.log("[shiny-router] lane="+e.lane+" ("+e.reason+")"),function(){const e=window.devicePixelRatio||1;let t=0,n=f?t?"mobile policy":"mobile policy — native dpr":"desktop — native dpr";const o=c("dpr");if(null!==o)if("native"===o||"off"===o||"0"===o)t=0,n="?dpr=native";else{const e=parseFloat(o);isFinite(e)&&e>0&&(t=e,n="?dpr="+e)}if(window.SHINY_DPR_RAW=e,window.SHINY_DPR_CAP=t,window.SHINY_DPR_REASON=n,!t||e<=t)window.SHINY_DPR_USED=e;else{try{Object.defineProperty(window,"devicePixelRatio",{get:function(){return t},configurable:!0})}catch(e){console.warn("[shiny-router] devicePixelRatio is not redefinable — dpr cap skipped")}window.SHINY_DPR_USED=window.devicePixelRatio,console.log("[shiny-router] dpr "+e+" → "+window.SHINY_DPR_USED+" ("+n+")")}}(),e},fallback:m,watchDeviceLoss:function(){window.addEventListener("godot-webgpu-device-lost",function(e){const t=e&&e.detail||{};window.SHINY_DEVICE_LOST=!0,"destroyed"!==t.reason&&m("device-lost",new Error("device lost ("+(t.reason||"unknown")+"): "+(t.message||"")))})},watchGlContextLoss:function(e){try{if(!e)return;e.addEventListener("webglcontextlost",function(){window.SHINY_DEVICE_LOST=!0,h("fail",{fk:"webglcontextlost"}),g("gl-context-lost",{})})}catch(e){}},requestAdapter:w,readAttempts:d,sGet:r,sSet:a}}function o(e,t){d();var n=t&&t.msg||"";"pinned-failed"===e?i("The chosen renderer failed",n,"This page is pinned to the "+t.renderer+" renderer with <code>?lane=</code>. Reload with <code>?lane=auto</code> to let the game choose."):"webgl-failed"===e?i("This game could not start on this device",t.prior?"WebGPU: "+t.prior+"\nWebGL: "+n:n,"Try a different browser, or close other tabs and reload."):"retry-exhausted"===e?i("This game could not start on this device",n,"WebGPU failed after the switch to WebGL was already tried. Close other tabs and reload."):"no-storage"===e?i("This game could not start on this device",n,"WebGPU failed and this browser blocks storage, so the switch to WebGL cannot be remembered. Reload with <code>?lane=webgl</code>."):"gl-context-lost"===e?i("The browser dropped the graphics context",null,"This usually means the device ran out of graphics memory. Close other tabs and reload."):i("This game could not start on this device",n,null)}function i(e,t,n){console.error("[ShinyGen] "+e+(t?": "+t:""));var o=document.createElement("div");o.id="shinygen-error",o.style.cssText=["position:fixed","inset:0","z-index:99999","display:flex","align-items:center","justify-content:center","background:rgba(0,0,0,0.92)","color:#e8e8e8",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"padding:2em","text-align:center"].join(";");var i=document.createElement("div");i.style.cssText="max-width:540px;line-height:1.6;";var r=document.createElement("div");if(r.style.cssText="font-size:1.4em;font-weight:600;color:#ff6b6b;margin-bottom:0.8em;",r.textContent=e,i.appendChild(r),t){var a=document.createElement("div");a.style.cssText="font-size:0.95em;color:#ccc;margin-bottom:1em;white-space:pre-wrap;font-family:monospace;text-align:left;background:rgba(255,255,255,0.06);padding:1em;border-radius:6px;max-height:300px;overflow-y:auto;",a.textContent=t,i.appendChild(a)}if(n){var s=document.createElement("div");s.style.cssText="font-size:0.9em;color:#999;margin-top:0.5em;",s.innerHTML=n,i.appendChild(s)}o.appendChild(i);var l=document.getElementById("shinygen-error");l&&l.remove(),document.body.appendChild(o)}var r=null,a=0;function s(e,t,n){var o=r!==e;r=e;var i=document.getElementById("shinygen-loading-bar"),s=document.getElementById("shinygen-loading-label"),l=document.getElementById("shinygen-loading-detail");if(o&&console.log("[ShinyGen] loading stage: "+e),i)if("connect"===e)s.textContent="Preparing...",i.style.width="2%",i.style.opacity="1",l.textContent="";else if("download"===e){s.textContent="Downloading engine...";var d=Date.now();if(!o&&d-a<80&&t!==n)return;a=d,n>0&&t<=n?(i.style.width=(t/n*100).toFixed(1)+"%",i.style.opacity="1",l.textContent=(t/1048576).toFixed(1)+" / "+(n/1048576).toFixed(1)+" MB"):(i.style.width="60%",i.style.opacity="0.5",l.textContent=(t/1048576).toFixed(1)+" MB")}else"decompress"===e?(s.textContent="Decompressing...",i.style.width="100%",i.style.opacity="0.8"):"start"===e&&(s.textContent="Starting engine...",i.style.width="100%",i.style.opacity="0.7",l.textContent="")}function l(e,t){if(!r){var n=document.getElementById("shinygen-loading-bar"),o=document.getElementById("shinygen-loading-label"),i=document.getElementById("shinygen-loading-detail");if(n)if(t>0){var a=Math.min(100,e/t*100);n.style.width=a.toFixed(1)+"%",o.textContent="Loading engine...";var s=(e/1048576).toFixed(1),l=(t/1048576).toFixed(1);i.textContent=s+" / "+l+" MB",console.log("[ShinyGen] Loading: "+s+"/"+l+" MB ("+a.toFixed(0)+"%)")}else{n.style.width="60%",n.style.opacity="0.5",o.textContent="Loading engine...";var d=(e/1048576).toFixed(1);i.textContent=d+" MB downloaded"}}}function d(){var e=document.getElementById("shinygen-loading");e&&(e.style.transition="opacity 0.3s ease",e.style.opacity="0",setTimeout(function(){e.remove()},300));var t=document.getElementById("canvas");if(t){t.style.visibility="visible";var n=document.activeElement;n&&n!==document.body&&n!==document.documentElement||t.focus({focusVisible:!1,preventScroll:!0})}}function c(e,t){if(void 0===t.autoFit||t.autoFit){var n=(e.width||1280)/(e.height||720),o=document.createElement("style");o.id="shinygen-autofit-style",o.textContent="#canvas{max-width:100vw!important;max-height:100vh!important;object-fit:contain!important;}",document.head.appendChild(o),a(),window.addEventListener("resize",a),window.visualViewport&&window.visualViewport.addEventListener("resize",a),window.addEventListener("orientationchange",function(){setTimeout(a,100),setTimeout(a,300)});var i=null;"undefined"!=typeof MutationObserver&&(i=new MutationObserver(function(){a()})).observe(e,{attributes:!0,attributeFilter:["width","height"]});var r=Date.now();requestAnimationFrame(function e(){a(),Date.now()-r<2e3&&requestAnimationFrame(e)}),h._fitCanvas=a}function a(){var i=function(){var e=t.container?"string"==typeof t.container?document.querySelector(t.container):t.container:null;if(e)return{w:e.clientWidth,h:e.clientHeight};var n=window.visualViewport,o=Math.min(window.innerWidth,document.documentElement.clientWidth||1/0),i=Math.min(window.innerHeight,document.documentElement.clientHeight||1/0);return n&&(o=Math.min(o,n.width),i=Math.min(i,n.height)),{w:o,h:i}}(),r=i.w,a=r/n;a>i.h&&(r=(a=i.h)*n),r=Math.floor(r),a=Math.floor(a);var s=Math.max(0,Math.floor((i.h-a)/2));Math.max(0,Math.floor((i.w-r)/2));e.style.cssText="display:block!important;width:"+r+"px!important;height:"+a+"px!important;margin:"+s+"px auto 0!important;padding:0!important;touch-action:none!important;max-width:100vw!important;max-height:100vh!important;",o.textContent="#canvas{width:"+r+"px!important;height:"+a+"px!important;max-width:100vw!important;max-height:100vh!important;margin:"+s+"px auto 0!important;display:block!important;touch-action:none!important;}"}}function u(e){return new Promise(function(t,n){var o=document.createElement("script");o.src=e,o.onload=t,o.onerror=function(){n(new Error("Failed to load: "+e))},document.head.appendChild(o)})}var h={};h._reportError=function(e,t){i(e,t,'Check your <code><script type="text/gdscript"></code> for errors.')},h._pendingReload=null,h._onReloadResult=null,h.reload=function(e,t){return t=t||0,new Promise(function(n,o){h._onReloadResult=function(e,t){h._onReloadResult=null,e?n(t):o(new Error(t))},h._pendingReload={index:t,source:e}})},h._eventHandlers={},h._gdCallback=null,h._setGDCallback=function(e){h._gdCallback=e},h._dispatch=function(e,t){var n=h._eventHandlers[e];if(n)for(var o=0;o<n.length;o++)try{n[o](t)}catch(t){console.error("[ShinyGen] Event handler error ("+e+"):",t)}},h.on=function(e,t){h._eventHandlers[e]||(h._eventHandlers[e]=[]),h._eventHandlers[e].push(t)},h.send=function(e,t){h._gdCallback?h._gdCallback(e,t||""):console.warn('[ShinyGen] Engine not ready — cannot send "'+e+'"')},h.sendJSON=function(e,t){h.send(e,JSON.stringify(t))},h.onJSON=function(e,t){h.on(e,function(n){try{t(JSON.parse(n))}catch(t){console.error("[ShinyGen] JSON parse error ("+e+"):",t)}})};var g=!1,f=null;function p(e,t){if(!g){g=!0;var n=function(e){var t=e+"vendor/brotli/brotli_dec_wasm_bg.wasm";return import(e+"vendor/brotli/brotli_dec_wasm.js").then(function(e){return Promise.resolve(e.default(t)).then(function(){return e})})}(e),o=window.fetch.bind(window);if(t&&/index$/.test(t)){var i=t+".wasm.br",a=o(i);a.then(function(e){var t=parseInt(e.headers.get("content-length")||"0",10);e.ok&&"connect"===r&&s("download",0,t)},function(){}),f={url:i,promise:a}}var l=function(e){return new Response(e,{status:200,headers:{"Content-Type":"application/wasm"}})},d=function(e){return e.arrayBuffer().then(function(e){var t=new Uint8Array(e);return 0===t[0]&&97===t[1]&&115===t[2]&&109===t[3]?(console.log("[ShinyGen] engine wasm: served pre-decoded ("+(e.byteLength/1048576).toFixed(1)+" MB)"),s("start"),l(e)):n.then(function(n){var o=n.decompress(t);return console.log("[ShinyGen] engine wasm: brotli "+(e.byteLength/1048576).toFixed(1)+" MB → "+(o.byteLength/1048576).toFixed(1)+" MB"),s("start"),l(o)})})};window.fetch=function(e,t){var i="string"==typeof e?e:e&&e.url||"";if(!/index\.wasm($|\?)/.test(i))return o(e,t);var a,c=i.replace(/index\.wasm/,"index.wasm.br"),u=function(n){return console.log("[ShinyGen] engine wasm: "+n+", falling back to raw index.wasm"),r=null,o(e,t)};return f&&f.url===c?(a=f.promise,f=null):a=o(c,t),a.then(function(e){return e.ok?e.body&&"undefined"!=typeof ReadableStream?function(e){var t=parseInt(e.headers.get("content-length")||"0",10)||0,o=0,i=e.body.getReader(),r=function(e){return i.read().then(function(n){if(n.done)return e;s("download",o+=n.value.length,t);var i=n.value;return e&&((i=new Uint8Array(e.length+n.value.length)).set(e,0),i.set(n.value,e.length)),i.length>=4?i:r(i)})};return r(null).then(function(e){if(!e||e.length<4)throw new Error("engine wasm response is empty");return 0===e[0]&&97===e[1]&&115===e[2]&&109===e[3]?l(new ReadableStream({start:function(t){t.enqueue(e),s("download",o,0)},pull:function(e){return i.read().then(function(t){if(t.done)return console.log("[ShinyGen] engine wasm: served pre-decoded ("+(o/1048576).toFixed(1)+" MB, streamed)"),s("start"),void e.close();s("download",o+=t.value.length,0),e.enqueue(t.value)})},cancel:function(e){return i.cancel(e)}})):n.then(function(n){if(!n||"function"!=typeof n.DecompressStream){var r=[e],a=e.length,d=function(){return i.read().then(function(e){if(e.done){var i=new Uint8Array(a),c=0;r.forEach(function(e){i.set(e,c),c+=e.length});var u=n.decompress(i);return console.log("[ShinyGen] engine wasm: brotli "+(a/1048576).toFixed(1)+" MB → "+(u.byteLength/1048576).toFixed(1)+" MB"),s("start"),l(u)}return s("download",o+=e.value.length,t),r.push(e.value),a+=e.value.length,d()})};return d()}var c=new n.DecompressStream,u=new Uint8Array(0),h=e,g=!1,f=!1,p=!1,m=function(){try{c.free()}catch(e){}},w=function(e,t){p=!0,m(),i.cancel().catch(function(){}),e.error(t)},y=function(e){if(!p){if(g||h&&h.length){var n,r,a,l=h&&h.length?h:u;try{var d=c.decompress(l,4194304);n=d.code,r=d.input_offset,a=d.buf,d.free()}catch(t){return void w(e,new Error("brotli decode failed: "+t))}if(l.length&&(h=r<l.length?l.subarray(r):null),g=3===n,a&&a.length&&e.enqueue(a),1===n){p=!0;var b=0;try{b=c.total_out()}catch(e){}return m(),i.cancel().catch(function(){}),console.log("[ShinyGen] engine wasm: brotli "+(o/1048576).toFixed(1)+" MB → "+(b/1048576).toFixed(1)+" MB (streamed)"),s("start"),void e.close()}if(a&&a.length)return;return y(e)}if(!f)return i.read().then(function(n){return n.done?(f=!0,s("decompress"),y(e)):(s("download",o+=n.value.length,t),h=n.value,y(e))},function(t){w(e,t)});w(e,new Error("brotli stream truncated after "+o+" bytes"))}};return l(new ReadableStream({pull:function(e){return y(e)},cancel:function(e){return p=!0,m(),i.cancel(e)}}))})})}(e).catch(function(e){return console.warn("[ShinyGen] engine wasm: streaming decode failed ("+e+"), retrying one-shot"),o(c,t).then(function(e){return e.ok?d(e):u("no .br (HTTP "+e.status+")")},function(e){return u(".br refetch failed ("+e+")")}).catch(function(e){return u("brotli decode unavailable ("+e+")")})}):d(e):u("no .br (HTTP "+e.status+")")},function(e){return u(".br fetch failed ("+e+")")})}}}var m="4.6.5-rc.2";h.start=async function(e){if(e=e||{},console.log("[ShinyGen] shinygen package "+(0===m.indexOf("__")?"dev (unstamped loader)":"v"+m)+" — the engine banner below reports the ENGINE build, not the package version"),void 0===e.extras||void 0===e.i18n||void 0===e.renderer){var r=document.querySelector('script[type="application/shinygen-project"]');if(r)try{var a=JSON.parse(r.textContent);void 0===e.extras&&(e.extras=!!a.extras),void 0===e.i18n&&(e.i18n=!!a.i18n),void 0===e.renderer&&a.renderer&&(e.renderer=String(a.renderer))}catch(e){}}var g=e.renderer;null==g||""===g?g="auto":"webgl"!==g&&"auto"!==g&&(g="webgpu"),void 0===n&&await u(t+"shiny_lane_router.js");var f=n({terminal:o}),w="auto"===g;w&&(f.watchDeviceLoss(),g=(await f.pick()).lane),h.renderer=g;var y=e.engineBase||t,b="webgl"===g?"webgl/":"",v=e.executable||y+b+"index";function x(e,t,n,o){if(d(),w&&f.fallback("boot",o)){var r=new Error("handled by the lane router: "+(o&&o.message?o.message:o));throw r.shinyLaneHandled=!0,r}throw i(e,t,n),o}if(console.log("[ShinyGen] engine: single build, renderer: "+g+(e.i18n?" + i18n (ICU data)":"")),"webgpu"===g){if(!navigator.gpu){var E=navigator.userAgent;x("WebGPU is not available",null,"This app requires WebGPU, which your browser does not currently support.<br><br>"+(-1!==E.indexOf("Firefox")?"Firefox: Open <code>about:config</code> and set <code>dom.webgpu.enabled</code> to <code>true</code>, then restart.":-1!==E.indexOf("Safari")&&-1===E.indexOf("Chrome")?"Safari: Open Settings → Feature Flags and enable <b>WebGPU</b>.":"Try <b>Chrome 113+</b>, <b>Edge 113+</b>, or <b>Opera 99+</b> on desktop."),new Error("ShinyGen: WebGPU is not available (navigator.gpu is undefined)."))}}else{var S=null;try{S=document.createElement("canvas").getContext("webgl2")}catch(e){}S||x("WebGL2 is not available",null,"This engine requires WebGL2, which your browser does not currently support.<br><br>WebGL2 ships in all modern browsers — try updating your browser or enabling hardware acceleration.",new Error("ShinyGen: WebGL2 is not available."))}if(function(){var e=document.createElement("div");e.id="shinygen-loading",e.style.cssText=["position:fixed","inset:0","z-index:99998","display:flex","flex-direction:column","align-items:center","justify-content:center","background:#111","color:#e8e8e8",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"will-change:transform"].join(";");var n=document.createElement("div");n.id="shinygen-loading-label",n.style.cssText="font-size:1.1em;margin-bottom:1.2em;color:#ccc;",n.textContent="Initializing engine...",e.appendChild(n);var o=document.createElement("div");o.style.cssText="width:280px;height:4px;background:rgba(255,255,255,0.1);border-radius:2px;overflow:hidden;";var i=document.createElement("div");i.id="shinygen-loading-bar",i.style.cssText="width:0%;height:100%;background:#4a9eff;border-radius:2px;transition:width 0.2s ease;",o.appendChild(i),e.appendChild(o);var r=document.createElement("div");r.id="shinygen-loading-detail",r.style.cssText="font-size:0.8em;color:#666;margin-top:0.8em;",r.textContent="",e.appendChild(r);var a=document.createElement("div");a.id="shinygen-loading-brand",a.style.cssText="position:absolute;bottom:1.6em;left:0;right:0;display:flex;flex-direction:column;align-items:center;gap:0.6em;font-size:0.72em;color:#777;letter-spacing:0.04em;";var s=document.createElement("div");s.id="shinygen-loading-brand-text",s.textContent="Made with",a.appendChild(s);var l=document.createElement("img");l.id="shinygen-loading-logo",l.alt="Shiny Gen",l.style.cssText="display:block;width:min(220px,46vw);height:auto;visibility:hidden;",l.onload=function(){l.style.visibility="visible"},l.onerror=function(){l.parentNode&&l.parentNode.removeChild(l),s.textContent="Made with Shiny Gen Engine"},a.appendChild(l),l.src=t+"shiny_gen_ai_radial_gradient.svg",e.appendChild(a),(document.body||document.documentElement).appendChild(e)}(),!1!==e.brotliWasm&&(s("connect"),p(t,v)),"webgpu"===g&&!w)try{if(!await f.requestAdapter())throw d(),i("No WebGPU adapter found",null,"Your browser supports WebGPU but no compatible GPU was found.<br><br>This can happen with unsupported GPUs, outdated drivers, or headless/virtual environments.<br><br>Try updating your GPU drivers, or use a different device."),new Error("ShinyGen: WebGPU adapter not available.")}catch(e){if(-1!==e.message.indexOf("ShinyGen"))throw e;throw d(),i("WebGPU adapter request failed",e.message,"Your browser supports WebGPU but failed to initialize it."),new Error("ShinyGen: WebGPU adapter request failed: "+e.message)}var k=null;e.canvas&&(k="string"==typeof e.canvas?document.querySelector(e.canvas):e.canvas),k&&"canvas"!==k.id&&(k.id="canvas"),k||(k=document.getElementById("canvas")),k||((k=document.createElement("canvas")).id="canvas",k.style.cssText="display:block;margin:0 auto;padding:0;max-width:100vw;max-height:100vh;",document.body.appendChild(k)),k.style.visibility="hidden",w&&f.watchGlContextLoss(k);var C=e.engineJs||y+b+"index.js";try{await u(C)}catch(e){x("Failed to load engine",e.message,"Check that the engine files ("+b+"index.js, "+b+"index.wasm) are served relative to shinygen.js.",e)}"undefined"==typeof Engine&&x("Engine failed to initialize","The Engine class was not found after loading "+C,"The engine JS file may be corrupt or incompatible.",new Error("ShinyGen: Engine class not found after loading "+C)),console.log("[ShinyGen] Engine JS loaded");var _=void 0===e.autoFit||e.autoFit?0:2,G=new Engine({args:"webgl"===g?["--rendering-driver","opengl3","--rendering-method","gl_compatibility"]:[],canvasResizePolicy:void 0!==e.canvasResizePolicy?e.canvasResizePolicy:_,executable:v,mainPack:e.mainPack||("webgl"===g?y+"index.pck":null),focusCanvas:!0,renderingDriver:"webgl"===g?"":"webgpu",onProgress:l});e.i18n&&"function"==typeof G.preloadFile&&(G.preloadFile(t+"icudt_godot.dat","icudt_godot.dat"),console.log("[ShinyGen] i18n: ICU data queued → res://icudt_godot.dat")),console.log("[ShinyGen] Starting engine...");try{await G.startGame()}catch(e){var P=e.message||String(e),T="The engine failed to start.";-1!==P.indexOf("wasm")||-1!==P.indexOf("fetch")||-1!==P.indexOf("Fetch")?T="Check that <code>"+b+"index.wasm</code> is served relative to shinygen.js.":"webgpu"!==g||-1===P.indexOf("WebGPU")&&-1===P.indexOf("gpu")?"webgl"===g&&-1!==P.toLowerCase().indexOf("gl")&&(T="WebGL2 initialization failed. Try updating your browser or enabling hardware acceleration."):T="WebGPU initialization failed. Your GPU or driver may not be supported.",x("Engine failed to start",P,T,e)}return d(),function(e){var t=document.querySelector('meta[name="viewport"]');t&&t.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),e.style.touchAction="none",document.body.style.touchAction="none",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%",document.documentElement.style.overflow="hidden",document.documentElement.style.position="fixed",document.documentElement.style.width="100%",document.documentElement.style.height="100%",document.addEventListener("touchmove",function(t){t.target===e||t.target.closest("#shinygen-touchcontrols")||t.preventDefault()},{passive:!1})}(k),c(k,e),function(e,t){var n=void 0!==t.touchControls?t.touchControls:"auto";if(!1!==n&&"none"!==n&&("auto"!==n||"ontouchstart"in window)){var o=document.createElement("div");o.id="shinygen-touchcontrols",o.style.cssText=["position:fixed","inset:0","z-index:9999","pointer-events:none","user-select:none","-webkit-user-select:none","touch-action:none"].join(";");var i=document.createElement("div");i.style.cssText=["position:absolute","left:16px","bottom:16px","width:140px","height:140px","pointer-events:auto"].join(";"),[{key:"w",label:"▲",x:45,y:0,w:50,h:45},{key:"s",label:"▼",x:45,y:95,w:50,h:45},{key:"a",label:"◀",x:0,y:45,w:45,h:50},{key:"d",label:"▶",x:95,y:45,w:45,h:50}].forEach(function(e){var t=document.createElement("div");t.style.cssText="position:absolute;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.13);border:1.5px solid rgba(255,255,255,0.25);border-radius:8px;color:rgba(255,255,255,0.7);font-size:18px;transition:background 0.08s;-webkit-tap-highlight-color:transparent;left:"+e.x+"px;top:"+e.y+"px;width:"+e.w+"px;height:"+e.h+"px;",t.textContent=e.label,t.dataset.key=e.key,i.appendChild(t)});var r=document.createElement("div");r.style.cssText="position:absolute;left:45px;top:45px;width:50px;height:50px;background:rgba(255,255,255,0.06);border-radius:50%;",i.appendChild(r),o.appendChild(i),[{key:"Enter",label:"A",bottom:60,right:16},{key:"Escape",label:"B",bottom:16,right:72}].forEach(function(e){var t=document.createElement("div");t.style.cssText=["position:absolute","pointer-events:auto","bottom:"+e.bottom+"px","right:"+e.right+"px","width:52px","height:52px","border-radius:50%","display:flex","align-items:center","justify-content:center","background:rgba(255,255,255,0.13)","border:1.5px solid rgba(255,255,255,0.25)","color:rgba(255,255,255,0.7)","font-size:16px","font-weight:bold","font-family:-apple-system,BlinkMacSystemFont,sans-serif","-webkit-tap-highlight-color:transparent"].join(";"),t.textContent=e.label,t.dataset.key=e.key,o.appendChild(t)}),document.body.appendChild(o);var a={};o.addEventListener("touchstart",l,{passive:!1}),o.addEventListener("touchend",l,{passive:!1}),o.addEventListener("touchcancel",l,{passive:!1}),o.addEventListener("touchmove",function(e){e.preventDefault();for(var t={},n=0;n<e.touches.length;n++){var i=e.touches[n],r=document.elementFromPoint(i.clientX,i.clientY);r&&r.dataset&&r.dataset.key&&(t[r.dataset.key]=r)}Object.keys(a).forEach(function(e){t[e]||(delete a[e],o.querySelectorAll('[data-key="'+e+'"]').forEach(function(e){e.style.background="rgba(255,255,255,0.13)"}),s(e,"keyup"))}),Object.keys(t).forEach(function(e){a[e]||(a[e]=!0,t[e].style.background="rgba(255,255,255,0.35)",s(e,"keydown"))})},{passive:!1})}function s(t,n){e.focus();var o=new KeyboardEvent(n,{key:t,code:"Enter"===t?"Enter":"Escape"===t?"Escape":"ArrowUp"===t?"ArrowUp":"ArrowDown"===t?"ArrowDown":"ArrowLeft"===t?"ArrowLeft":"ArrowRight"===t?"ArrowRight":"Key"+t.toUpperCase(),keyCode:"Enter"===t?13:"Escape"===t?27:t.toUpperCase().charCodeAt(0),bubbles:!0,cancelable:!0});e.dispatchEvent(o)}function l(e){e.preventDefault();var t=e.target.closest("[data-key]");if(t){var n=t.dataset.key;"touchstart"===e.type?a[n]||(a[n]=!0,t.style.background="rgba(255,255,255,0.35)",s(n,"keydown")):"touchend"!==e.type&&"touchcancel"!==e.type||a[n]&&(delete a[n],t.style.background="rgba(255,255,255,0.13)",s(n,"keyup"))}}}(k,e),console.log("[ShinyGen] Engine started"),G};var w=h.start;h.start=function(e){return w(e).catch(function(e){if(e&&e.shinyLaneHandled)return null;throw e})},window.ShinyGen=h}();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**************************************************************************/
|
|
2
|
+
/* godot.audio.position.worklet.js */
|
|
3
|
+
/**************************************************************************/
|
|
4
|
+
/* This file is part of: */
|
|
5
|
+
/* GODOT ENGINE */
|
|
6
|
+
/* https://godotengine.org */
|
|
7
|
+
/**************************************************************************/
|
|
8
|
+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
9
|
+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
10
|
+
/* */
|
|
11
|
+
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
12
|
+
/* a copy of this software and associated documentation files (the */
|
|
13
|
+
/* "Software"), to deal in the Software without restriction, including */
|
|
14
|
+
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
15
|
+
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
16
|
+
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
17
|
+
/* the following conditions: */
|
|
18
|
+
/* */
|
|
19
|
+
/* The above copyright notice and this permission notice shall be */
|
|
20
|
+
/* included in all copies or substantial portions of the Software. */
|
|
21
|
+
/* */
|
|
22
|
+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
23
|
+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
24
|
+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
25
|
+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
26
|
+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
27
|
+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
28
|
+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
29
|
+
/**************************************************************************/
|
|
30
|
+
|
|
31
|
+
class GodotPositionReportingProcessor extends AudioWorkletProcessor {
|
|
32
|
+
static get parameterDescriptors() {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
name: 'reset',
|
|
36
|
+
defaultValue: 0,
|
|
37
|
+
minValue: 0,
|
|
38
|
+
maxValue: 1,
|
|
39
|
+
automationRate: 'k-rate',
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
this.position = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(inputs, _outputs, parameters) {
|
|
50
|
+
if (parameters['reset'][0] > 0) {
|
|
51
|
+
this.position = 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (inputs.length > 0) {
|
|
55
|
+
const input = inputs[0];
|
|
56
|
+
if (input.length > 0) {
|
|
57
|
+
this.position += input[0].length;
|
|
58
|
+
this.port.postMessage({ type: 'position', data: this.position });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
registerProcessor('godot-position-reporting-processor', GodotPositionReportingProcessor);
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**************************************************************************/
|
|
2
|
+
/* audio.worklet.js */
|
|
3
|
+
/**************************************************************************/
|
|
4
|
+
/* This file is part of: */
|
|
5
|
+
/* GODOT ENGINE */
|
|
6
|
+
/* https://godotengine.org */
|
|
7
|
+
/**************************************************************************/
|
|
8
|
+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
9
|
+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
10
|
+
/* */
|
|
11
|
+
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
12
|
+
/* a copy of this software and associated documentation files (the */
|
|
13
|
+
/* "Software"), to deal in the Software without restriction, including */
|
|
14
|
+
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
15
|
+
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
16
|
+
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
17
|
+
/* the following conditions: */
|
|
18
|
+
/* */
|
|
19
|
+
/* The above copyright notice and this permission notice shall be */
|
|
20
|
+
/* included in all copies or substantial portions of the Software. */
|
|
21
|
+
/* */
|
|
22
|
+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
23
|
+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
24
|
+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
25
|
+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
26
|
+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
27
|
+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
28
|
+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
29
|
+
/**************************************************************************/
|
|
30
|
+
|
|
31
|
+
class RingBuffer {
|
|
32
|
+
constructor(p_buffer, p_state, p_threads) {
|
|
33
|
+
this.buffer = p_buffer;
|
|
34
|
+
this.avail = p_state;
|
|
35
|
+
this.threads = p_threads;
|
|
36
|
+
this.rpos = 0;
|
|
37
|
+
this.wpos = 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
data_left() {
|
|
41
|
+
return this.threads ? Atomics.load(this.avail, 0) : this.avail;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
space_left() {
|
|
45
|
+
return this.buffer.length - this.data_left();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
read(output) {
|
|
49
|
+
const size = this.buffer.length;
|
|
50
|
+
let from = 0;
|
|
51
|
+
let to_write = output.length;
|
|
52
|
+
if (this.rpos + to_write > size) {
|
|
53
|
+
const high = size - this.rpos;
|
|
54
|
+
output.set(this.buffer.subarray(this.rpos, size));
|
|
55
|
+
from = high;
|
|
56
|
+
to_write -= high;
|
|
57
|
+
this.rpos = 0;
|
|
58
|
+
}
|
|
59
|
+
if (to_write) {
|
|
60
|
+
output.set(this.buffer.subarray(this.rpos, this.rpos + to_write), from);
|
|
61
|
+
}
|
|
62
|
+
this.rpos += to_write;
|
|
63
|
+
if (this.threads) {
|
|
64
|
+
Atomics.add(this.avail, 0, -output.length);
|
|
65
|
+
Atomics.notify(this.avail, 0);
|
|
66
|
+
} else {
|
|
67
|
+
this.avail -= output.length;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
write(p_buffer) {
|
|
72
|
+
const to_write = p_buffer.length;
|
|
73
|
+
const mw = this.buffer.length - this.wpos;
|
|
74
|
+
if (mw >= to_write) {
|
|
75
|
+
this.buffer.set(p_buffer, this.wpos);
|
|
76
|
+
this.wpos += to_write;
|
|
77
|
+
if (mw === to_write) {
|
|
78
|
+
this.wpos = 0;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
const high = p_buffer.subarray(0, mw);
|
|
82
|
+
const low = p_buffer.subarray(mw);
|
|
83
|
+
this.buffer.set(high, this.wpos);
|
|
84
|
+
this.buffer.set(low);
|
|
85
|
+
this.wpos = low.length;
|
|
86
|
+
}
|
|
87
|
+
if (this.threads) {
|
|
88
|
+
Atomics.add(this.avail, 0, to_write);
|
|
89
|
+
Atomics.notify(this.avail, 0);
|
|
90
|
+
} else {
|
|
91
|
+
this.avail += to_write;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
class GodotProcessor extends AudioWorkletProcessor {
|
|
97
|
+
constructor() {
|
|
98
|
+
super();
|
|
99
|
+
this.threads = false;
|
|
100
|
+
this.running = true;
|
|
101
|
+
this.lock = null;
|
|
102
|
+
this.notifier = null;
|
|
103
|
+
this.output = null;
|
|
104
|
+
this.output_buffer = new Float32Array();
|
|
105
|
+
this.input = null;
|
|
106
|
+
this.input_buffer = new Float32Array();
|
|
107
|
+
this.port.onmessage = (event) => {
|
|
108
|
+
const cmd = event.data['cmd'];
|
|
109
|
+
const data = event.data['data'];
|
|
110
|
+
this.parse_message(cmd, data);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
process_notify() {
|
|
115
|
+
if (this.notifier) {
|
|
116
|
+
Atomics.add(this.notifier, 0, 1);
|
|
117
|
+
Atomics.notify(this.notifier, 0);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
parse_message(p_cmd, p_data) {
|
|
122
|
+
if (p_cmd === 'start' && p_data) {
|
|
123
|
+
const state = p_data[0];
|
|
124
|
+
let idx = 0;
|
|
125
|
+
this.threads = true;
|
|
126
|
+
this.lock = state.subarray(idx, ++idx);
|
|
127
|
+
this.notifier = state.subarray(idx, ++idx);
|
|
128
|
+
const avail_in = state.subarray(idx, ++idx);
|
|
129
|
+
const avail_out = state.subarray(idx, ++idx);
|
|
130
|
+
this.input = new RingBuffer(p_data[1], avail_in, true);
|
|
131
|
+
this.output = new RingBuffer(p_data[2], avail_out, true);
|
|
132
|
+
} else if (p_cmd === 'stop') {
|
|
133
|
+
this.running = false;
|
|
134
|
+
this.output = null;
|
|
135
|
+
this.input = null;
|
|
136
|
+
this.lock = null;
|
|
137
|
+
this.notifier = null;
|
|
138
|
+
} else if (p_cmd === 'start_nothreads') {
|
|
139
|
+
this.output = new RingBuffer(p_data[0], p_data[0].length, false);
|
|
140
|
+
} else if (p_cmd === 'chunk') {
|
|
141
|
+
this.output.write(p_data);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static array_has_data(arr) {
|
|
146
|
+
return arr.length && arr[0].length && arr[0][0].length;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
process(inputs, outputs, parameters) {
|
|
150
|
+
if (!this.running) {
|
|
151
|
+
return false; // Stop processing.
|
|
152
|
+
}
|
|
153
|
+
if (this.output === null) {
|
|
154
|
+
return true; // Not ready yet, keep processing.
|
|
155
|
+
}
|
|
156
|
+
const process_input = GodotProcessor.array_has_data(inputs);
|
|
157
|
+
if (process_input) {
|
|
158
|
+
const input = inputs[0];
|
|
159
|
+
const chunk = input[0].length * input.length;
|
|
160
|
+
if (this.input_buffer.length !== chunk) {
|
|
161
|
+
this.input_buffer = new Float32Array(chunk);
|
|
162
|
+
}
|
|
163
|
+
if (!this.threads) {
|
|
164
|
+
GodotProcessor.write_input(this.input_buffer, input);
|
|
165
|
+
this.port.postMessage({ 'cmd': 'input', 'data': this.input_buffer });
|
|
166
|
+
} else if (this.input.space_left() >= chunk) {
|
|
167
|
+
GodotProcessor.write_input(this.input_buffer, input);
|
|
168
|
+
this.input.write(this.input_buffer);
|
|
169
|
+
} else {
|
|
170
|
+
// this.port.postMessage('Input buffer is full! Skipping input frame.'); // Uncomment this line to debug input buffer.
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const process_output = GodotProcessor.array_has_data(outputs);
|
|
174
|
+
if (process_output) {
|
|
175
|
+
const output = outputs[0];
|
|
176
|
+
const chunk = output[0].length * output.length;
|
|
177
|
+
if (this.output_buffer.length !== chunk) {
|
|
178
|
+
this.output_buffer = new Float32Array(chunk);
|
|
179
|
+
}
|
|
180
|
+
if (this.output.data_left() >= chunk) {
|
|
181
|
+
this.output.read(this.output_buffer);
|
|
182
|
+
GodotProcessor.write_output(output, this.output_buffer);
|
|
183
|
+
if (!this.threads) {
|
|
184
|
+
this.port.postMessage({ 'cmd': 'read', 'data': chunk });
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
// this.port.postMessage('Output buffer has not enough frames! Skipping output frame.'); // Uncomment this line to debug output buffer.
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
this.process_notify();
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static write_output(dest, source) {
|
|
195
|
+
const channels = dest.length;
|
|
196
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
197
|
+
for (let sample = 0; sample < dest[ch].length; sample++) {
|
|
198
|
+
dest[ch][sample] = source[sample * channels + ch];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static write_input(dest, source) {
|
|
204
|
+
const channels = source.length;
|
|
205
|
+
for (let ch = 0; ch < channels; ch++) {
|
|
206
|
+
for (let sample = 0; sample < source[ch].length; sample++) {
|
|
207
|
+
dest[sample * channels + ch] = source[ch][sample];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
registerProcessor('godot-processor', GodotProcessor);
|