shinygen 4.6.6-rc.1 → 4.6.6
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 +1 -1
- package/index.pck +0 -0
- package/index.wasm.br +0 -0
- package/package.json +1 -1
- package/shinygen.js +1 -1
- package/standalone/index.pck +0 -0
- package/standalone/index.wasm.br +0 -0
- package/standalone/webgl/index.wasm.br +0 -0
- package/webgl/index.wasm.br +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ by default, with a WebGL2 engine included for browsers without WebGPU.
|
|
|
10
10
|
<!doctype html>
|
|
11
11
|
<canvas id="canvas"></canvas>
|
|
12
12
|
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/shinygen@4.6.6
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/shinygen@4.6.6/shinygen.js"></script>
|
|
14
14
|
<script type="text/gdscript" name="Main">
|
|
15
15
|
extends Node3D
|
|
16
16
|
|
package/index.pck
CHANGED
|
Binary file
|
package/index.wasm.br
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinygen",
|
|
3
|
-
"version": "4.6.6
|
|
3
|
+
"version": "4.6.6",
|
|
4
4
|
"description": "Shiny Gen Engine \u2014 a WebGPU game engine for the browser, with a WebGL2 fallback engine. One script tag; ShinyGen.start() boots the engine on your canvas and runs inline gds scripts.",
|
|
5
5
|
"main": "shinygen.js",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
package/shinygen.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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.6-rc.1";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}();
|
|
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.6";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}();
|
package/standalone/index.pck
CHANGED
|
Binary file
|
package/standalone/index.wasm.br
CHANGED
|
Binary file
|
|
Binary file
|
package/webgl/index.wasm.br
CHANGED
|
Binary file
|