handler-playable-sdk 0.3.7 → 0.3.9
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 +19 -1
- package/dist/AssetTextures-TB4XIUX6.js +1 -0
- package/dist/{ConfigOverride-DFTDUTRQ.js → ConfigOverride-QGV5TX37.js} +1 -1
- package/dist/chunk-ES3S33UP.js +1 -0
- package/dist/chunk-OPT6F3HO.js +1398 -0
- package/dist/chunk-RXI7YH7M.js +1 -0
- package/dist/{chunk-J2CL6VOZ.js → chunk-V636YM4S.js} +1 -1
- package/dist/{config-7DI6U2YD.js → config-3INFO7FK.js} +1 -1
- package/dist/index.cjs +125 -52
- package/dist/index.d.cts +28 -5
- package/dist/index.d.ts +28 -5
- package/dist/index.js +1 -1
- package/dist/{loader-object-centric-Ce6MVkQw.d.cts → loader-object-centric-BeVsUAXI.d.cts} +4 -0
- package/dist/{loader-object-centric-Ce6MVkQw.d.ts → loader-object-centric-BeVsUAXI.d.ts} +4 -0
- package/dist/pixi/index.cjs +17 -17
- package/dist/pixi/index.d.cts +30 -2
- package/dist/pixi/index.d.ts +30 -2
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +17 -17
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
- package/dist/AssetTextures-NWHSMZNV.js +0 -1
- package/dist/chunk-BC5GBAMY.js +0 -1325
- package/dist/chunk-DHSGG7NF.js +0 -1
- package/dist/chunk-PWGHKK3J.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function p(){return typeof window=="undefined"?null:window.__editableConfig||null}function m(){return typeof window=="undefined"?null:window.__editableConfigBaseline||null}function b(e,n){var i,t;if(!e)return null;try{if(e instanceof Map)return(i=e.get(n))!=null?i:null;if(typeof e=="object")return(t=e[n])!=null?t:null}catch{}return null}function N(e,n,i){if(e){if(e instanceof Map){e.set(n,i);return}typeof e=="object"&&(e[n]=i)}}function I(e,n){for(let i of n)l(e,i.path,i.value)}function E(e){var a;if(typeof window=="undefined")return;let n=p();if(!n)return;let i=m(),t=(a=i?b(i.objects,e):null)!=null?a:b(n.objects,e);if(!t)return;let r=f(t),o=d().filter(c=>c.objectId===e);try{I(r,o)}catch(c){console.error("[CONFIG] Failed to reapply overrides for object",e,c);return}N(n.objects,e,r);let s=window.applyEditableObjectConfig;if(typeof s=="function")try{s(e,r)}catch{}}function A(){var r;if(typeof window=="undefined")return;let e=p();if(!(e!=null&&e.engine))return;let n=m(),i=f(((r=n==null?void 0:n.engine)!=null?r:e.engine)||{}),t=d().filter(o=>!o.objectId&&!o.sceneId);try{I(i,t)}catch(o){console.error("[CONFIG] Failed to reapply engine overrides",o);return}try{let o=e.engine;for(let s of Object.keys(o))s in i||delete o[s];for(let[s,a]of Object.entries(i))o[s]=a}catch{e.engine=i}}function F(){if(typeof window=="undefined")return"unknown";let e=window;return typeof e.__HANDLER_PROJECT_ID=="string"?e.__HANDLER_PROJECT_ID:"handler-default"}function x(){return`handler_preview_config_overrides::${F()}`}var S="handler_preview_override_mode";if(typeof window!="undefined"){let e=window.localStorage.getItem(S);window.__enableConfigOverrides=e===null?!0:e==="true"}function T(){if(typeof window=="undefined")return[];try{let e=window.localStorage.getItem(x());if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function w(e){if(typeof window!="undefined")try{window.localStorage.setItem(x(),JSON.stringify(e))}catch{}}function D(){return typeof window=="undefined"?!1:window.__enableConfigOverrides===!0}var M=500;function P(e){if(typeof window!="undefined"){window.__enableConfigOverrides=e;try{window.localStorage.setItem(S,e?"true":"false")}catch{}}}function k(e,n={}){var u,O;let{objectId:i,path:t,value:r}=e,{silent:o=!1,persist:s=!0}=n,a=p();if(!a){console.warn("[CONFIG] applyConfigOverride: No editable config found in window.__editableConfig");return}let c=i?(O=(u=a.objects)==null?void 0:u.get)==null?void 0:O.call(u,i):a.engine;if(!c){console.warn("[CONFIG] applyConfigOverride: Override target not found:",{objectId:i,path:t,hasObjects:!!a.objects});return}console.log("[CONFIG] applyConfigOverride: Target found, applying...",{objectId:i,path:t,value:r});let h;try{h=R(c,t),l(c,t,r)}catch(g){console.error("[CONFIG] applyConfigOverride failed:",{objectId:i,path:t,value:r},g);return}window.__configChanges=window.__configChanges||[];let y=window.__configChanges;if(y.push({objectId:i,path:t,oldValue:h,newValue:r,ts:Date.now()}),y.length>M&&y.shift(),s){let g=d(),_=g.findIndex(v=>v.objectId===i&&v.sceneId===e.sceneId&&v.path===t);_>=0?g[_].value=r:g.push(e),window.__configOverrides=g,w(g),D()||P(!0)}o||console.log("[CONFIG] Applied override:",e),typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("config:changed",{detail:e}))}function $(e,n={}){e.forEach(i=>k(i,n))}function C(){window.__configOverrides=[],window.__configChanges=[],w([]),console.log("[CONFIG] Cleared all overrides")}function V(e){let n=d().filter(t=>t.objectId!==e);window.__configOverrides=n,w(n);let i=window.__configChanges||[];window.__configChanges=i.filter(t=>t.objectId!==e),E(e),window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"clear_object",objectId:e}}))}function B(e,n){let i=d().filter(r=>r.objectId!==e||r.path!==n);window.__configOverrides=i,w(i);let t=window.__configChanges||[];window.__configChanges=t.filter(r=>r.objectId!==e||r.path!==n),e?E(e):A(),window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"remove",objectId:e,path:n}}))}function d(){return typeof window=="undefined"?[]:(window.__configOverrides||(window.__configOverrides=T()),window.__configOverrides||[])}var J={getCurrentConfig(){return window.__editableConfig||null},getChanges(){return window.__configChanges||[]},clearChanges(){window.__configChanges=[]}};function l(e,n,i){var s;let t=n.split("."),r=t.pop(),o=e;for(let a of t){if(o[a]!==void 0&&typeof o[a]!="object")throw new Error(`Invalid override path: ${n} (hit primitive at ${a})`);o[a]=(s=o[a])!=null?s:{},o=o[a]}o[r]=i}function R(e,n){return n.split(".").reduce((i,t)=>i?i[t]:void 0,e)}function f(e){if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Set)return new Set([...e].map(i=>f(i)));if(ArrayBuffer.isView(e))return e.slice();if(e instanceof Array)return e.map(i=>f(i));if(e instanceof Map){let i=new Map;return e.forEach((t,r)=>i.set(r,f(t))),i}let n={};for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=f(e[i]));return n}function G(){let e=window.__editableConfigBaseline;if(!e){let n=window.__editableConfig;if(!n)throw new Error("Cannot export: no config loaded");return j(n)}return j(e)}function j(e){let n={objects:{},scenes:{},engine:f(e.engine||{})},i=e.objects;if(i instanceof Map)i.forEach((o,s)=>{n.objects[s]=f(o)});else if(i&&typeof i=="object")for(let o in i)n.objects[o]=f(i[o]);let t=e.scenes;if(t instanceof Map)t.forEach((o,s)=>{n.scenes[s]=f(o)});else if(t&&typeof t=="object")for(let o in t)n.scenes[o]=f(t[o]);let r=d();for(let o of r)o.objectId?(n.objects[o.objectId]||(n.objects[o.objectId]={}),l(n.objects[o.objectId],o.path,o.value)):o.sceneId?(n.scenes[o.sceneId]||(n.scenes[o.sceneId]={}),l(n.scenes[o.sceneId],o.path,o.value)):l(n.engine,o.path,o.value);return n}function H(){let e=d(),n=new Set;for(let i of e)i.objectId?n.add(i.objectId):n.add("__engine__");return{modifiedObjects:Array.from(n),overrideCount:e.length,hasChanges:e.length>0,overrides:e}}async function K(e){let n=G(),i={};for(let[r,o]of Object.entries(n.objects)){let s=o,a=r;/^(json\.|ui\.|effects\.|engine\.)/.test(a)||(a=`json.${r}`),s&&typeof s=="object"&&(s.identity||(s.identity={}),s.identity.id=a),i[`objects/${a}.json`]=s}n.engine&&(n.engine.runtime&&(i["engine/engine.runtime.json"]=n.engine.runtime),n.engine.assets&&(i["engine/engine.assets.json"]=n.engine.assets),n.engine.splash&&(i["engine/engine.splash.json"]=n.engine.splash),n.engine.loading&&(i["engine/engine.loading.json"]=n.engine.loading),n.engine.start&&(i["engine/engine.start.json"]=n.engine.start),n.engine.tutorial&&(i["engine/engine.tutorial.json"]=n.engine.tutorial),n.engine.endgame&&(i["engine/engine.endgame.json"]=n.engine.endgame),!n.engine.runtime&&!n.engine.assets&&(i["engine/engine.json"]=n.engine));for(let[r,o]of Object.entries(n.scenes)){let s=r.startsWith("scene.")?r:`scene.${r}`;i[`scenes/${s}.json`]=o}let t=await fetch("/api/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({configs:i,assets:{},hadCacheAtApply:d().length>0,versionName:e})});if(!t.ok){let r=await t.json();throw new Error(`Apply failed: ${r.error||"Unknown error"}`)}C();try{let r=p();r&&(window.__editableConfigBaseline=f(r))}catch{}localStorage.setItem("handler_last_applied",Date.now().toString()),console.log("[Config Persistence] \u2705 Applied to disk successfully")}function L(){C(),window.location.reload()}async function U(){if(!confirm("This will restore all configs to their original state. All uncommitted changes in cache AND applied changes will be lost. Continue?"))return;let n=await fetch("/api/reset-to-original",{method:"POST"});if(!n.ok){let i=await n.json();throw new Error(`Reset failed: ${i.error||"Unknown error"}`)}C(),window.location.reload()}export{D as a,P as b,k as c,$ as d,C as e,V as f,B as g,d as h,J as i,f as j,G as k,H as l,K as m,L as n,U as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Assets as A,Texture as M}from"pixi.js";var p=class{static get(e){var s;return(s=this.store.get(e))==null?void 0:s.data}static set(e,s){this.store.set(e,{data:s})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};p.store=new Map;function O(){var t,e;try{let s=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(t=document.querySelector("script"))==null?void 0:t.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),r=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(s&&!r)}catch{return!1}}async function P(){try{if(typeof window!="undefined"){let t=await fetch("./build-settings.json");if(t.ok){let e=await t.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function _(){try{if(typeof window!="undefined"){let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}var b=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",T=O(),h=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,i=T?"publish":b,u=h==null?void 0:h.assetsInlined;h!=null&&h.buildMode&&(i=h.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${i}`));var y=_();y!=null&&y.buildMode&&(i=y.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${i}`));(y==null?void 0:y.assetsInlined)!==void 0&&(u=y.assetsInlined);P().then(t=>{t!=null&&t.buildMode&&t.buildMode!==i&&(i=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${i}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(u=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${b}, Runtime: ${T?"publish":"dev"}, Effective: ${i}`);var f={},L=null;async function v(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${i}`),Object.keys(f).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(f)),f;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),f={...window.INLINE_ASSETS},f;if(!(i==="publish"&&u!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),f;if(!L){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),L=(async()=>{try{try{let o=await import(e+"?t="+Date.now());if(o.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(o.INLINE_ASSETS)),o.INLINE_ASSETS}catch(o){console.warn("[AssetLoader] ES module import failed, trying text parse:",o)}let s=await fetch(e);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let r=await s.text();console.log("[AssetLoader] Received JS code, length:",r.length);let n=r.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(n)try{let o=n[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let a=new Function("return "+o)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(a)),a}catch(o){return console.warn("[AssetLoader] Failed to parse inline assets:",o),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",r.substring(0,500)),{}}catch(s){return console.warn("[AssetLoader] Failed to load inline assets:",s),{}}})()}return f=await L,console.log("[AssetLoader] Final inline assets cache:",Object.keys(f)),f}var N=new Map;function m(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>m(e))),t}function B(t=64,e=64,s=16711680){let r=document.createElement("canvas");r.width=t,r.height=e;let n=r.getContext("2d");return n.fillStyle=`#${s.toString(16).padStart(6,"0")}`,n.fillRect(0,0,t,e),n.strokeStyle="#000",n.strokeRect(0,0,t,e),n.fillStyle="#fff",n.font="10px sans-serif",n.textAlign="center",n.fillText("MISSING",t/2,e/2),M.from(r)}function x(t,e){N.set(t,e)}var w=class{static async load(e,s,r,n){let o=`${e}:${s.path}`,a=p.get(o);if(a!==void 0)return a;console.log(`[AssetLoader] Loading asset: ${e}, type: ${s.type}, Effective mode: ${i}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let c=await v(),l=c[e];if(!l&&n&&(l=c[n],l&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${n}`)),!l&&s.path){let d=s.path.split("/");if(d.length>=2){let E=d[d.length-1].split(".")[0];c[E]&&(l=c[E],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${E}`))}}if(console.log("[AssetLoader] Inline data for",e,":",l?"FOUND":"NOT FOUND"),i==="publish"&&u!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!l))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${s.path}`);let g=N.get(s.type);if(g)try{let d=await g(s.path,l,e,r);return p.set(o,d),d}catch(d){return this.handleFailure(e,s.type,d)}try{let d;switch(s.type){case"image":d=await this.loadImage(s.path,l);break;case"json":d=await this.loadJSON(s.path,l),d=m(d);break;default:throw new Error(`Unknown asset type: ${s.type}`)}return p.set(o,d),d}catch(d){return this.handleFailure(e,s.type,d)}}static async loadImage(e,s){let r=i==="publish",n=r&&u!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${i}, isPublishMode: ${r}, inlineData: ${s?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!s)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof s!="string"||!s.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof s}`);try{return await A.load(s)}catch(o){throw console.error("[AssetLoader] Failed to load texture from data URI:",o),o}}if(s&&typeof s=="string"&&s.startsWith("data:"))try{return await A.load(s)}catch(o){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",o),await A.load(e)}return await A.load(e)}static async loadJSON(e,s){let r=i==="publish",n=r&&u!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${i}, isPublishMode: ${r}, inlineData: ${s?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!s)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof s=="object"&&s!==null)return s;if(typeof s=="string"&&s.startsWith("data:")){let a=atob(s.split(",")[1]);return JSON.parse(a)}return JSON.parse(s)}if(s){if(typeof s=="object"&&s!==null)return s;if(typeof s=="string"&&s.startsWith("data:")){let a=atob(s.split(",")[1]);return JSON.parse(a)}return JSON.parse(s)}let o=await fetch(e);if(!o.ok)throw new Error(`JSON fetch failed: ${e}`);return o.json()}static handleFailure(e,s,r){if(i==="dev"){let o=s==="image"?B():m({__placeholder:!0,type:s});return p.set(e+":"+((r==null?void 0:r.path)||"missing"),o),o}throw r}};x("image",async(t,e)=>{let s=i==="publish",r=s&&u!==!1,n=i==="brand",o=s&&u===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${i}, isPublishMode: ${s}, isBrandMode: ${n}, inlineData: ${e?"EXISTS":"MISSING"}`),r){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return A.load(e)}let a=t;return(n||o)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(a=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(a=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${a}"`))),A.load(e||a)});x("json",async(t,e)=>{let s=i==="publish",r=s&&u!==!1,n=i==="brand",o=s&&u===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${i}, isPublishMode: ${s}, isBrandMode: ${n}, inlineData: ${e?"EXISTS":"MISSING"}`),r){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let a=t;if((n||o)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(a=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(a=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${a}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let c=await fetch(a);if(!c.ok)throw new Error(`JSON fetch failed: ${t}`);return c.json()});var I=class{constructor(){this.textures=new Map;this.readyPromise=null;this.config=null;this.app=null}init(e,s){this.textures.clear(),this.readyPromise=null,this.config=e,this.app=s,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,s=this.app;return this.readyPromise=(async()=>{var n;console.log("[AssetTextures] Loading all assets...");let r=[];for(let[o,a]of e.objects.entries()){let c=(n=a.render)==null?void 0:n.asset;if(!c)continue;let l=(async()=>{var S;try{let g=(S=a.identity)==null?void 0:S.id;console.log(`[AssetTextures] Loading ${c.type}: ${o} (${g})`);let d=await w.load(o,c,s,g);this.textures.set(o,d),console.log(`[AssetTextures] \u2713 Loaded: ${o}`)}catch(g){console.error(`[AssetTextures] \u2717 Failed to load: ${o}`,g)}})();r.push(l)}await Promise.all(r),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}get(e){return this.textures.get(e)}set(e,s){this.textures.set(e,s),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},$=new I,R=new Proxy($,{get(t,e){return e in t&&typeof t[e]=="function"?t[e].bind(t):t.get(e)},set(t,e,s){return t.set(e,s),!0}});function F(t,e){$.init(t,e),typeof window!="undefined"&&(window.__AssetTextures=R)}export{p as a,x as b,w as c,R as d,F as e};
|
|
1
|
+
import{Assets as A,Texture as M}from"pixi.js";var p=class{static get(e){var s;return(s=this.store.get(e))==null?void 0:s.data}static set(e,s){this.store.set(e,{data:s})}static has(e){return this.store.has(e)}static clear(){this.store.clear()}};p.store=new Map;function v(){var t,e;try{let s=typeof window!="undefined"&&(document.querySelector('script[src*="inline-assets.js"]')||((e=(t=document.querySelector("script"))==null?void 0:t.textContent)==null?void 0:e.includes("inline-assets.js"))||window.INLINE_ASSETS),r=typeof window!="undefined"&&document.querySelector('link[href*="assets/"], script[src*="assets/"]');return!!(s&&!r)}catch{return!1}}async function O(){try{if(typeof window!="undefined"){let t=await fetch("./build-settings.json");if(t.ok){let e=await t.json();return console.log("[AssetLoader] Loaded build settings:",e),e}}}catch{}return null}function _(){try{if(typeof window!="undefined"){let t=new XMLHttpRequest;if(t.open("GET","./build-settings.json",!1),t.send(),t.status===200&&t.responseText){let e=JSON.parse(t.responseText);return console.log("[AssetLoader] Loaded build settings (sync):",e),e}}}catch{}return null}var T=typeof __BUILD_MODE__!="undefined"?__BUILD_MODE__:"undefined",b=v(),h=typeof window!="undefined"?window.__BUILD_SETTINGS__:null,i=b?"publish":T,u=h==null?void 0:h.assetsInlined;h!=null&&h.buildMode&&(i=h.buildMode,console.log(`[AssetLoader] Build mode overridden by inline settings: ${i}`));var g=_();g!=null&&g.buildMode&&(i=g.buildMode,console.log(`[AssetLoader] Build mode overridden by sync settings: ${i}`));(g==null?void 0:g.assetsInlined)!==void 0&&(u=g.assetsInlined);O().then(t=>{t!=null&&t.buildMode&&t.buildMode!==i&&(i=t.buildMode,console.log(`[AssetLoader] Build mode overridden by settings: ${i}`)),(t==null?void 0:t.assetsInlined)!==void 0&&(u=t.assetsInlined)}).catch(()=>{});console.log(`[AssetLoader] MODULE LOADED - Compile: ${T}, Runtime: ${b?"publish":"dev"}, Effective: ${i}`);var f={},L=null;async function R(){if(console.log(`[AssetLoader] getInlineAssets() called - Effective mode: ${i}`),Object.keys(f).length>0)return console.log("[AssetLoader] Returning cached inline assets:",Object.keys(f)),f;if(typeof window!="undefined"&&window.INLINE_ASSETS)return console.log("[AssetLoader] Using pre-loaded INLINE_ASSETS from window:",Object.keys(window.INLINE_ASSETS)),f={...window.INLINE_ASSETS},f;if(!(i==="publish"&&u!==!1))return console.log("[AssetLoader] Inline assets disabled for this build mode."),f;if(!L){let e=typeof window!="undefined"?new URL("inline-assets.js",window.location.href).href:"./inline-assets.js";console.log("[AssetLoader] Loading inline assets from:",e),L=(async()=>{try{try{let o=await import(e+"?t="+Date.now());if(o.INLINE_ASSETS)return console.log("[AssetLoader] Loaded INLINE_ASSETS via ES module:",Object.keys(o.INLINE_ASSETS)),o.INLINE_ASSETS}catch(o){console.warn("[AssetLoader] ES module import failed, trying text parse:",o)}let s=await fetch(e);if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);let r=await s.text();console.log("[AssetLoader] Received JS code, length:",r.length);let n=r.match(/export\s+const\s+INLINE_ASSETS\s*=\s*({[\s\S]*?});?\s*$/m);if(n)try{let o=n[1];console.log("[AssetLoader] Found INLINE_ASSETS export, parsing...");let a=new Function("return "+o)();return console.log("[AssetLoader] Parsed inline assets:",Object.keys(a)),a}catch(o){return console.warn("[AssetLoader] Failed to parse inline assets:",o),{}}else return console.warn("[AssetLoader] INLINE_ASSETS export not found in response"),console.log("[AssetLoader] JS code preview:",r.substring(0,500)),{}}catch(s){return console.warn("[AssetLoader] Failed to load inline assets:",s),{}}})()}return f=await L,console.log("[AssetLoader] Final inline assets cache:",Object.keys(f)),f}var x=new Map;function E(t){return t===null||typeof t!="object"||(Object.freeze(t),Object.values(t).forEach(e=>E(e))),t}function B(t=64,e=64,s=16711680){let r=document.createElement("canvas");r.width=t,r.height=e;let n=r.getContext("2d");return n.fillStyle=`#${s.toString(16).padStart(6,"0")}`,n.fillRect(0,0,t,e),n.strokeStyle="#000",n.strokeRect(0,0,t,e),n.fillStyle="#fff",n.font="10px sans-serif",n.textAlign="center",n.fillText("MISSING",t/2,e/2),M.from(r)}function N(t,e){x.set(t,e)}var m=class{static async load(e,s,r,n){let o=`${e}:${s.path}`,a=p.get(o);if(a!==void 0)return a;console.log(`[AssetLoader] Loading asset: ${e}, type: ${s.type}, Effective mode: ${i}`),console.log(`[AssetLoader] Window defined: ${typeof window!="undefined"}, INLINE_ASSETS exists: ${!!(typeof window!="undefined"&&window.INLINE_ASSETS)}, keys: ${typeof window!="undefined"&&window.INLINE_ASSETS?Object.keys(window.INLINE_ASSETS).length:"N/A"}`);let l=await R(),c=l[e];if(!c&&n&&(c=l[n],c&&console.log(`[AssetLoader] Found inline data for ${e} using configId: ${n}`)),!c&&s.path){let d=s.path.split("/");if(d.length>=2){let y=d[d.length-1].split(".")[0];l[y]&&(c=l[y],console.log(`[AssetLoader] Found inline data for ${e} using assetName: ${y}`))}}if(console.log("[AssetLoader] Inline data for",e,":",c?"FOUND":"NOT FOUND"),i==="publish"&&u!==!1&&(console.log("[AssetLoader] \u26A0\uFE0F PUBLISH MODE DETECTED - inline assets are MANDATORY"),!c))throw new Error(`[AssetLoader] PUBLISH MODE: Inline asset required but NOT FOUND for object: ${e}, path: ${s.path}`);let w=x.get(s.type);if(w)try{let d=await w(s.path,c,e,r);return p.set(o,d),d}catch(d){return this.handleFailure(e,s.type,d)}try{let d;switch(s.type){case"image":d=await this.loadImage(s.path,c);break;case"json":d=await this.loadJSON(s.path,c),d=E(d);break;default:throw new Error(`Unknown asset type: ${s.type}`)}return p.set(o,d),d}catch(d){return this.handleFailure(e,s.type,d)}}static async loadImage(e,s){let r=i==="publish",n=r&&u!==!1;if(console.log(`[AssetLoader] loadImage - Effective mode: ${i}, isPublishMode: ${r}, inlineData: ${s?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!s)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for object. Path: ${e}`);if(typeof s!="string"||!s.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof s}`);try{return await A.load(s)}catch(o){throw console.error("[AssetLoader] Failed to load texture from data URI:",o),o}}if(s&&typeof s=="string"&&s.startsWith("data:"))try{return await A.load(s)}catch(o){return console.error("[AssetLoader] Failed to load texture from data URI, falling back to path:",o),await A.load(e)}return await A.load(e)}static async loadJSON(e,s){let r=i==="publish",n=r&&u!==!1;if(console.log(`[AssetLoader] loadJSON - Effective mode: ${i}, isPublishMode: ${r}, inlineData: ${s?"EXISTS":"MISSING"}`),n){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!s)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${e}`);if(typeof s=="object"&&s!==null)return s;if(typeof s=="string"&&s.startsWith("data:")){let a=atob(s.split(",")[1]);return JSON.parse(a)}return JSON.parse(s)}if(s){if(typeof s=="object"&&s!==null)return s;if(typeof s=="string"&&s.startsWith("data:")){let a=atob(s.split(",")[1]);return JSON.parse(a)}return JSON.parse(s)}let o=await fetch(e);if(!o.ok)throw new Error(`JSON fetch failed: ${e}`);return o.json()}static handleFailure(e,s,r){if(i==="dev"){let o=s==="image"?B():E({__placeholder:!0,type:s});return p.set(e+":"+((r==null?void 0:r.path)||"missing"),o),o}throw r}};N("image",async(t,e)=>{let s=i==="publish",r=s&&u!==!1,n=i==="brand",o=s&&u===!1;if(console.log(`[AssetLoader] registerType('image') - Effective mode: ${i}, isPublishMode: ${s}, isBrandMode: ${n}, inlineData: ${e?"EXISTS":"MISSING"}`),r){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);if(typeof e!="string"||!e.startsWith("data:"))throw new Error(`[AssetLoader] Publish mode: inline asset must be data URI string, got: ${typeof e}`);return A.load(e)}let a=t;return(n||o)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(a=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(a=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${a}"`))),A.load(e||a)});N("json",async(t,e)=>{let s=i==="publish",r=s&&u!==!1,n=i==="brand",o=s&&u===!1;if(console.log(`[AssetLoader] registerType('json') - Effective mode: ${i}, isPublishMode: ${s}, isBrandMode: ${n}, inlineData: ${e?"EXISTS":"MISSING"}`),r){if(console.log("[AssetLoader] PUBLISH MODE ACTIVATED - inline assets are MANDATORY"),!e)throw new Error(`[AssetLoader] Publish mode: inline asset required but not found for path: ${t}`);return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e)}let a=t;if((n||o)&&t&&!t.startsWith("assets/")&&(typeof window!="undefined"&&!document.querySelector('link[href*="assets/"], script[src*="assets/"]')&&!document.querySelector('link[href*="configs/"], script[src*="configs/"]')?(a=t,console.log(`[AssetLoader] BRAND MODE: flattened build, using path "${t}" as-is`)):(a=`assets/${t}`,console.log(`[AssetLoader] BRAND MODE: transformed path "${t}" -> "${a}"`))),e)return typeof e=="object"&&e!==null?e:typeof e=="string"&&e.startsWith("data:")?JSON.parse(atob(e.split(",")[1])):JSON.parse(e);let l=await fetch(a);if(!l.ok)throw new Error(`JSON fetch failed: ${t}`);return l.json()});var I=class{constructor(){this.textures=new Map;this.readyPromise=null;this.priorityReadyPromise=null;this.priorityReadyResolve=null;this.config=null;this.app=null}init(e,s){if(this.config===e&&this.app===s&&this.priorityReadyPromise){console.log("[AssetTextures] init called with same config/app; keeping existing state");return}this.textures.clear(),this.readyPromise=null,this.priorityReadyPromise=null,this.priorityReadyResolve=null,this.priorityReadyPromise=new Promise(r=>{this.priorityReadyResolve=r}),this.config=e,this.app=s,console.log("[AssetTextures] Initialized with config, cleared previous textures")}async ready(){if(this.readyPromise){await this.readyPromise;return}if(!this.config)throw new Error("[AssetTextures] Must call init() before ready() - config is null");if(!this.app)throw new Error("[AssetTextures] Must call init() before ready() - app is null");let e=this.config,s=this.app;return this.readyPromise=(async()=>{var a;console.log("[AssetTextures] Loading all assets...");let r=new Set(["background_loading_1"]),n=[],o=[];for(let[l,c]of e.objects.entries()){let S=(a=c.render)==null?void 0:a.asset;if(!S)continue;let w=async()=>{var d;try{let y=(d=c.identity)==null?void 0:d.id;console.log(`[AssetTextures] Loading ${S.type}: ${l} (${y})`);let $=await m.load(l,S,s,y);this.textures.set(l,$),console.log(`[AssetTextures] \u2713 Loaded: ${l}`)}catch(y){console.error(`[AssetTextures] \u2717 Failed to load: ${l}`,y)}};r.has(l)?n.push(w()):o.push(w())}n.length>0&&(console.log("[AssetTextures] Phase 1: Loading priority assets (loading screen)..."),await Promise.all(n),console.log("[AssetTextures] Phase 1: Priority assets ready")),this.priorityReadyResolve&&this.priorityReadyResolve(),console.log("[AssetTextures] Phase 2: Loading remaining assets..."),await Promise.all(o),console.log("[AssetTextures] All textures loaded:",Array.from(this.textures.keys()))})(),this.readyPromise}async priorityReady(){return this.priorityReadyPromise?this.priorityReadyPromise:Promise.resolve()}get(e){return this.textures.get(e)}set(e,s){this.textures.set(e,s),console.log(`[AssetTextures] Updated texture: ${e}`)}clear(){this.textures.clear(),this.readyPromise=null,console.log("[AssetTextures] Cleared all textures")}getAllIds(){return Array.from(this.textures.keys())}},P=new I,k=new Proxy(P,{get(t,e){return e in t&&typeof t[e]=="function"?t[e].bind(t):t.get(e)},set(t,e,s){return t.set(e,s),!0}});function J(t,e){P.init(t,e),typeof window!="undefined"&&(window.__AssetTextures=k)}export{p as a,N as b,m as c,k as d,J as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-ES3S33UP.js";import"./chunk-RXI7YH7M.js";import"./chunk-Q7FPWOA3.js";export{l as ConfigWatcher,k as DefaultReloadStrategy,h as applyDefaults,m as diffConfigs,c as loadAllObjectConfigs,a as loadComponentSchemas,d as loadEngineConfig,e as loadGamePromptConfig,i as loadObjectCentricConfig,b as loadObjectConfig,f as loadSceneConfig,n as rehydrateObject,o as setupHotReload,j as toLegacyFormat,g as validateObjectConfig};
|