handler-playable-sdk 1.0.95 → 1.0.100
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/dist/{ConfigOverride-2HOZGV6G.js → ConfigOverride-LXAXXQFN.js} +1 -1
- package/dist/chunk-IPD3J7SW.js +1 -0
- package/dist/chunk-KICIZV5O.js +1 -0
- package/dist/{chunk-LWADIFXM.js → chunk-Z5ZUUE46.js} +124 -121
- package/dist/cli/brand-dna.mjs +1 -1
- package/dist/cli/canva-import.mjs +1 -1
- package/dist/cli/cleanup-assets.mjs +1 -1
- package/dist/cli/fix-scales.mjs +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/screen-helper.mjs +1 -1
- package/dist/cli/setup-library.mjs +1 -1
- package/dist/cli/student-helper/add-logic.mjs +1 -1
- package/dist/cli/student-helper/add-object.mjs +1 -1
- package/dist/cli/student-helper/arg-parsing.mjs +1 -1
- package/dist/cli/student-helper/asset-registry.mjs +1 -1
- package/dist/cli/student-helper/bullet-system.mjs +1 -1
- package/dist/cli/student-helper/collectable-system.mjs +1 -1
- package/dist/cli/student-helper/constants.mjs +1 -1
- package/dist/cli/student-helper/drag-snap-couples.mjs +1 -1
- package/dist/cli/student-helper/endgame-screen.mjs +1 -1
- package/dist/cli/student-helper/fs-io.mjs +1 -1
- package/dist/cli/student-helper/logic-defaults.mjs +1 -1
- package/dist/cli/student-helper/print-help.mjs +1 -1
- package/dist/cli/student-helper/prompts.mjs +1 -1
- package/dist/cli/student-helper/scratch-card.mjs +1 -1
- package/dist/cli/student-helper/screen-utils.mjs +1 -1
- package/dist/cli/student-helper/snippets.mjs +1 -1
- package/dist/cli/student-helper/start-screen.mjs +1 -1
- package/dist/cli/student-helper/swerve-collect.mjs +1 -1
- package/dist/cli/student-helper/tap-destroy.mjs +1 -1
- package/dist/cli/student-helper/template-packs.mjs +1 -1
- package/dist/cli/student-helper.mjs +1 -1
- package/dist/cli/sync-screens.mjs +1 -1
- package/dist/cli/validate-assets.mjs +1 -1
- package/dist/cli/validate.mjs +1 -1
- package/dist/{config-VJNOXXCC.js → config-ZZMHC7I4.js} +1 -1
- package/dist/index.cjs +151 -148
- package/dist/index.d.cts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/pixi/index.cjs +12 -12
- package/dist/pixi/index.js +1 -1
- package/dist/three/index.cjs +22 -22
- package/dist/three/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5IRAZMOA.js +0 -1
- package/dist/chunk-SDFKEAA5.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunk-IPD3J7SW.js";import"./chunk-JXBG6UFL.js";export{c as applyConfigOverride,d as applyConfigOverrides,q as applyConfigsToDisk,e as clearConfigOverrides,f as clearConfigOverridesForObject,i as configOverrideManager,n as deepClone,o as exportConfigsAsJSON,h as getConfigOverrides,p as getConfigStateSummary,a as getOverrideMode,k as redoLastConfigChange,g as removeConfigOverride,r as resetToApplied,s as resetToOriginal,b as setOverrideMode,l as trackObjectCreation,m as trackObjectDeletion,j as undoLastConfigChange};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function y(){return typeof window=="undefined"?null:window.__editableConfig||null}function j(){return typeof window=="undefined"?null:window.__editableConfigBaseline||null}function v(n,e){var t,a;if(!n)return null;try{if(n instanceof Map)return(t=n.get(e))!=null?t:null;if(typeof n=="object")return(a=n[e])!=null?a:null}catch{}return null}function D(n,e,t){if(n){if(n instanceof Map){n.set(e,t);return}typeof n=="object"&&(n[e]=t)}}function G(n,e){for(let t of e)p(n,t.path,t.value)}function C(n){var o;if(typeof window=="undefined")return;let e=y();if(!e)return;let t=j(),a=(o=t?v(t.objects,n):null)!=null?o:v(e.objects,n);if(!a)return;let i=f(a),r=g().filter(c=>c.objectId===n);try{G(i,r)}catch(c){console.error("[CONFIG] Failed to reapply overrides for object",n,c);return}D(e.objects,n,i);let s=window.applyEditableObjectConfig;if(typeof s=="function")try{s(n,i)}catch{}}function O(){var i;if(typeof window=="undefined")return;let n=y();if(!(n!=null&&n.engine))return;let e=j(),t=f(((i=e==null?void 0:e.engine)!=null?i:n.engine)||{}),a=g().filter(r=>!r.objectId&&!r.sceneId);try{G(t,a)}catch(r){console.error("[CONFIG] Failed to reapply engine overrides",r);return}try{let r=n.engine;for(let s of Object.keys(r))s in t||delete r[s];for(let[s,o]of Object.entries(t))r[s]=o}catch{n.engine=t}}function A(){if(typeof window=="undefined")return"unknown";let n=window;return typeof n.__HANDLER_PROJECT_ID=="string"?n.__HANDLER_PROJECT_ID:"handler-default"}function I(){return`handler_preview_config_overrides::${A()}`}var R="handler_preview_override_mode";if(typeof window!="undefined"){let n=window.localStorage.getItem(R);window.__enableConfigOverrides=n===null?!0:n==="true"}function P(){if(typeof window=="undefined")return[];try{let n=window.localStorage.getItem(I());if(!n)return[];let e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function b(n){if(typeof window!="undefined")try{window.localStorage.setItem(I(),JSON.stringify(n))}catch{}}function $(){return typeof window=="undefined"?!1:window.__enableConfigOverrides===!0}var m=500;function M(n){if(typeof window!="undefined"){window.__enableConfigOverrides=n;try{window.localStorage.setItem(R,n?"true":"false")}catch{}}}function E(n,e={}){var w,T;let{objectId:t,path:a,value:i}=n,{silent:r=!1,persist:s=!0,emitEvent:o=!0}=e,c=y();if(!c){console.warn("[CONFIG] applyConfigOverride: No editable config found in window.__editableConfig");return}let u=t?(T=(w=c.objects)==null?void 0:w.get)==null?void 0:T.call(w,t):c.engine;if(!u){console.warn("[CONFIG] applyConfigOverride: Override target not found:",{objectId:t,path:a,hasObjects:!!c.objects});return}r||console.log("[CONFIG] applyConfigOverride: Target found, applying...",{objectId:t,path:a,value:i});let _;try{_=k(u,a),p(u,a,i)}catch(d){console.error("[CONFIG] applyConfigOverride failed:",{objectId:t,path:a,value:i},d);return}if(e.trackHistory!==!1){window.__configChanges=window.__configChanges||[];let d=window.__configChanges;d.push({objectId:t,path:a,oldValue:_,newValue:i,ts:Date.now()}),d.length>m&&d.shift(),window.__configChangeRedo=[]}if(s){let d=g(),h=d.findIndex(l=>l.objectId===t&&l.sceneId===n.sceneId&&l.path===a);h>=0?(console.log(`[CONFIG] Updating existing override at index ${h}:`,{objectId:t,path:a,oldValue:d[h].value,newValue:i}),d[h].value=i):(console.log("[CONFIG] Adding new override:",{objectId:t,path:a,value:typeof i=="string"?i.substring(0,50):i}),d.push(n)),window.__configOverrides=d,b(d);let V=I(),F=typeof window!="undefined"?window.localStorage.getItem(V):null;if(F){let l=JSON.parse(F);l.find(S=>S.objectId===t&&S.path===a)?console.log(`[CONFIG] \u2705 Override persisted to localStorage successfully. Total overrides: ${l.length}`):console.error("[CONFIG] \u274C Override NOT found in localStorage after persist!")}else console.error(`[CONFIG] \u274C localStorage key ${V} is empty after persist!`);$()||(console.log("[CONFIG] Override mode was disabled, enabling it now to ensure overrides apply on reload"),M(!0))}r||console.log("[CONFIG] Applied override:",n),o&&typeof window!="undefined"&&window.dispatchEvent(new CustomEvent("config:changed",{detail:{...n,oldValue:_}}))}function L(n,e={}){let t=e.emitEvent!==!1,a=[];for(let i of n)i!=null&&i.objectId&&typeof i.objectId=="string"&&a.push(i.objectId),E(i,{...e,emitEvent:!1});if(t&&typeof window!="undefined"){let i=Array.from(new Set(a));window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"batch",objectIds:i,count:n.length}}))}}function N(){window.__configOverrides=[],window.__configChanges=[],window.__configChangeRedo=[],b([]),console.log("[CONFIG] Cleared all overrides")}function K(n){let e=g().filter(a=>a.objectId!==n);window.__configOverrides=e,b(e);let t=window.__configChanges||[];window.__configChanges=t.filter(a=>a.objectId!==n),C(n),window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"clear_object",objectId:n}}))}function J(n,e){let t=g().filter(i=>i.objectId!==n||i.path!==e);window.__configOverrides=t,b(t);let a=window.__configChanges||[];window.__configChanges=a.filter(i=>i.objectId!==n||i.path!==e),n?C(n):O(),window.dispatchEvent(new CustomEvent("config:changed",{detail:{action:"remove",objectId:n,path:e}}))}function g(){return typeof window=="undefined"?[]:(window.__configOverrides||(window.__configOverrides=P()),window.__configOverrides||[])}var W={getCurrentConfig(){return window.__editableConfig||null},getChanges(){return window.__configChanges||[]},clearChanges(){window.__configChanges=[],window.__configChangeRedo=[]}};function q(){var r;if(typeof window=="undefined")return!1;let n=window.__configChanges||[];if(n.length===0)return!1;let e=n.pop();window.__configChangeRedo=window.__configChangeRedo||[];let t=window.__configChangeRedo;if(e.changeType==="object_create"){let{screenId:s}=e.metadata||{};return e.objectId&&s&&fetch("/api/objects/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objectId:e.objectId,screenId:s})}).catch(o=>console.error("[CONFIG] Failed to delete object on undo:",o)),t.push({objectId:e.objectId,path:e.path,oldValue:e.newValue,newValue:e.oldValue,ts:Date.now(),changeType:e.changeType,metadata:e.metadata}),window.dispatchEvent(new CustomEvent("handler:scene-objects-refresh")),window.dispatchEvent(new CustomEvent("inspector:refresh")),console.log("[CONFIG] Undo: Deleted object",e.objectId),!0}if(e.changeType==="object_delete"){let{screenId:s,objectConfigId:o}=e.metadata||{},c=e.oldValue;return e.objectId&&s&&c&&fetch("/api/objects/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenId:s,instanceId:e.objectId,objectConfigId:o||((r=c==null?void 0:c.identity)==null?void 0:r.id),config:c})}).catch(u=>console.error("[CONFIG] Failed to recreate object on undo:",u)),t.push({objectId:e.objectId,path:e.path,oldValue:e.newValue,newValue:e.oldValue,ts:Date.now(),changeType:e.changeType,metadata:e.metadata}),window.dispatchEvent(new CustomEvent("handler:scene-objects-refresh")),window.dispatchEvent(new CustomEvent("inspector:refresh")),console.log("[CONFIG] Undo: Recreated object",e.objectId),!0}t.push({objectId:e.objectId,path:e.path,oldValue:e.newValue,newValue:e.oldValue,ts:Date.now(),changeType:e.changeType});let a=j(),i=!1;if(a){let s=e.objectId?v(a.objects,e.objectId):a.engine;if(s){let o=k(s,e.path);JSON.stringify(o)===JSON.stringify(e.oldValue)&&(i=!0)}}return i?J(e.objectId,e.path):(E({objectId:e.objectId,path:e.path,value:e.oldValue},{trackHistory:!1,persist:!0,emitEvent:!0}),e.objectId?C(e.objectId):O()),console.log("[CONFIG] Undo:",e.path),!0}function X(){var a;if(typeof window=="undefined")return!1;let n=window.__configChangeRedo||[];if(n.length===0)return!1;let e=n.pop();if(e.changeType==="object_create"){let{screenId:i,objectConfigId:r}=e.metadata||{},s=e.newValue;return e.objectId&&i&&s&&fetch("/api/objects/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenId:i,instanceId:e.objectId,objectConfigId:r||((a=s==null?void 0:s.identity)==null?void 0:a.id),config:s})}).catch(c=>console.error("[CONFIG] Failed to recreate object on redo:",c)),window.__configChanges=window.__configChanges||[],window.__configChanges.push({objectId:e.objectId,path:e.path,oldValue:e.newValue,newValue:e.oldValue,ts:Date.now(),changeType:e.changeType,metadata:e.metadata}),window.dispatchEvent(new CustomEvent("handler:scene-objects-refresh")),window.dispatchEvent(new CustomEvent("inspector:refresh")),console.log("[CONFIG] Redo: Recreated object",e.objectId),!0}if(e.changeType==="object_delete"){let{screenId:i}=e.metadata||{};return e.objectId&&i&&fetch("/api/objects/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({objectId:e.objectId,screenId:i})}).catch(s=>console.error("[CONFIG] Failed to delete object on redo:",s)),window.__configChanges=window.__configChanges||[],window.__configChanges.push({objectId:e.objectId,path:e.path,oldValue:e.newValue,newValue:e.oldValue,ts:Date.now(),changeType:e.changeType,metadata:e.metadata}),window.dispatchEvent(new CustomEvent("handler:scene-objects-refresh")),window.dispatchEvent(new CustomEvent("inspector:refresh")),console.log("[CONFIG] Redo: Deleted object",e.objectId),!0}return window.__configChanges=window.__configChanges||[],window.__configChanges.push({objectId:e.objectId,path:e.path,oldValue:e.newValue,newValue:e.oldValue,ts:Date.now(),changeType:e.changeType}),E({objectId:e.objectId,path:e.path,value:e.oldValue},{trackHistory:!1,persist:!0,emitEvent:!0}),e.objectId?C(e.objectId):O(),console.log("[CONFIG] Redo:",e.path),!0}function Y(n,e,t){var i;if(typeof window=="undefined")return;window.__configChanges=window.__configChanges||[];let a=window.__configChanges;a.push({objectId:n,path:"__object_create__",oldValue:null,newValue:t,ts:Date.now(),changeType:"object_create",metadata:{screenId:e,objectConfigId:(i=t==null?void 0:t.identity)==null?void 0:i.id}}),window.__configChangeRedo=[],a.length>m&&a.shift(),console.log("[CONFIG] Tracked object creation:",n)}function z(n,e,t){if(typeof window=="undefined")return;window.__configChanges=window.__configChanges||[];let a=window.__configChanges;a.push({objectId:n,path:"__object_delete__",oldValue:t,newValue:null,ts:Date.now(),changeType:"object_delete",metadata:{screenId:e}}),window.__configChangeRedo=[],a.length>m&&a.shift(),console.log("[CONFIG] Tracked object deletion:",n)}function p(n,e,t){var s;let a=e.split("."),i=a.pop(),r=n;for(let o of a){if(r[o]!==void 0&&typeof r[o]!="object")throw new Error(`Invalid override path: ${e} (hit primitive at ${o})`);r[o]=(s=r[o])!=null?s:{},r=r[o]}r[i]=t}function k(n,e){return e.split(".").reduce((t,a)=>t?t[a]:void 0,n)}function f(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof Set)return new Set([...n].map(t=>f(t)));if(ArrayBuffer.isView(n))return n.slice();if(n instanceof Array)return n.map(t=>f(t));if(n instanceof Map){let t=new Map;return n.forEach((a,i)=>t.set(i,f(a))),t}let e={};for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=f(n[t]));return e}function H(){let n=window.__editableConfigBaseline;if(!n){let e=window.__editableConfig;if(!e)throw new Error("Cannot export: no config loaded");return x(e)}return x(n)}function x(n){let e={objects:{},scenes:{},engine:f(n.engine||{})},t=n.objects;if(t instanceof Map)t.forEach((o,c)=>{e.objects[c]=f(o)});else if(t&&typeof t=="object")for(let o in t)e.objects[o]=f(t[o]);let a=n.scenes;if(a instanceof Map)a.forEach((o,c)=>{e.scenes[c]=f(o)});else if(a&&typeof a=="object")for(let o in a)e.scenes[o]=f(a[o]);let i=g();console.log(`[CONFIG] Export: Applying ${i.length} overrides to baseline`);let r=new Map;for(let o of i){let c=o.objectId||(o.sceneId?`scene:${o.sceneId}`:"__engine__");r.has(c)||r.set(c,[]),r.get(c).push(o)}let s=new Map;for(let o of i)if(o.path==="render.asset.path"&&o.objectId){let c=o.value;s.has(c)||s.set(c,[]),s.get(c).push(o.objectId)}for(let[o,c]of s.entries())c.length>1&&console.log(`[CONFIG] \u26A0\uFE0F Multiple objects sharing same asset: ${o} used by ${c.join(", ")}`);for(let o of i)o.objectId?(e.objects[o.objectId]||(console.warn(`[CONFIG] \u26A0\uFE0F Override references non-existent object: ${o.objectId}`),e.objects[o.objectId]={}),console.log(`[CONFIG] Export: Applying override to ${o.objectId}.${o.path} = ${typeof o.value=="string"?o.value.substring(0,50):o.value}`),p(e.objects[o.objectId],o.path,o.value)):o.sceneId?(e.scenes[o.sceneId]||(e.scenes[o.sceneId]={}),p(e.scenes[o.sceneId],o.path,o.value)):p(e.engine,o.path,o.value);return e}function Q(){let n=g(),e=new Set;for(let t of n)t.objectId?e.add(t.objectId):e.add("__engine__");return{modifiedObjects:Array.from(e),overrideCount:n.length,hasChanges:n.length>0,overrides:n}}async function Z(n){let e=H(),t={};for(let[i,r]of Object.entries(e.objects)){let s=r,o=i;/^(json\.|ui\.|effects\.|engine\.)/.test(o)||(o=`json.${i}`),s&&typeof s=="object"&&(s.identity||(s.identity={}),s.identity.id=o),t[`objects/${o}.json`]=s}e.engine&&(e.engine.runtime&&(t["engine/engine.runtime.json"]=e.engine.runtime),e.engine.assets&&(t["engine/engine.assets.json"]=e.engine.assets),e.engine.splash&&(t["engine/engine.splash.json"]=e.engine.splash),e.engine.loading&&(t["engine/engine.loading.json"]=e.engine.loading),e.engine.start&&(t["engine/engine.start.json"]=e.engine.start),e.engine.tutorial&&(t["engine/engine.tutorial.json"]=e.engine.tutorial),e.engine.endgame&&(t["engine/engine.endgame.json"]=e.engine.endgame),!e.engine.runtime&&!e.engine.assets&&(t["engine/engine.json"]=e.engine));for(let[i,r]of Object.entries(e.scenes)){let s=i.startsWith("scene.")?i:`scene.${i}`;t[`scenes/${s}.json`]=r}let a=await fetch("/api/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({configs:t,assets:{},hadCacheAtApply:g().length>0,versionName:n})});if(!a.ok){let i=await a.json();throw new Error(`Apply failed: ${i.error||"Unknown error"}`)}N();try{let i=y();i&&(window.__editableConfigBaseline=f(i))}catch{}localStorage.setItem("handler_last_applied",Date.now().toString()),console.log("[Config Persistence] \u2705 Applied to disk successfully")}function ee(){N(),window.location.reload()}async function ne(){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 e=await fetch("/api/reset-to-original",{method:"POST"});if(!e.ok){let t=await e.json();throw new Error(`Reset failed: ${t.error||"Unknown error"}`)}N(),window.location.reload()}export{$ as a,M as b,E as c,L as d,N as e,K as f,J as g,g as h,W as i,q as j,X as k,Y as l,z as m,f as n,H as o,Q as p,Z as q,ee as r,ne as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as X,d as K,h as Q}from"./chunk-IPD3J7SW.js";var Y=null,g="dev";if(typeof window!="undefined"){let n=window.__BUILD_SETTINGS__;if(n!=null&&n.buildMode)Y=n,g=n.buildMode,console.log("[CONFIG] Loaded inline build settings:",n,"buildMode:",g);else try{let e=new XMLHttpRequest;if(e.open("GET","./build-settings.json",!1),e.send(),e.status===200&&e.responseText){let t=JSON.parse(e.responseText);Y=t,g=t.buildMode||"dev",console.log("[CONFIG] Loaded build settings:",t,"buildMode:",g)}else console.log("[CONFIG] No build-settings.json found, using default buildMode:",g)}catch(e){console.log("[CONFIG] Failed to load build-settings.json:",e instanceof Error?e.message:String(e))}}console.log("[CONFIG] Final buildMode:",g);var B=new Map,q=g==="dev"||typeof window!="undefined"&&window.location.search.includes("hot-reload");function ie(n,e){try{if(typeof n=="object"&&n!==null)return n;if(typeof n!="string")return null;if(n.startsWith("data:")){let o=n.indexOf(",");if(o===-1)return null;let s=n.slice(0,o);if(!s.includes("application/json")&&!s.includes("text/plain"))return null;let a=n.slice(o+1),i=s.includes("base64")?typeof atob=="function"?atob(a):a:decodeURIComponent(a);return JSON.parse(i)}let t=n.trim();return t.startsWith("{")||t.startsWith("[")?JSON.parse(n):null}catch{return null}}function ae(n){if(typeof window=="undefined"||!window.INLINE_ASSETS)return null;let e=window.INLINE_ASSETS,t=n.replace(/^\.\/+/,""),o=t.split("/").pop()||t,s=[t,o,t.replace(/\.json$/,""),o.replace(/\.json$/,"")];for(let a of s){let i=e[a];if(i){let c=ie(i,a);if(c!==null)return c}}return null}async function T(n){if(B.has(n)&&!q)return console.log(`[CONFIG] Using cached config for: "${n}"`),B.get(n);if(console.log(`[CONFIG] loadConfigFile called with: "${n}", MODE: ${g.toUpperCase()}, CACHE: ${q?"DISABLED":"ENABLED"}`),g==="publish"){let o=ae(n);return o?(console.log(`[CONFIG] \u2713 Loaded ${n} via INLINE_ASSETS`),o):(console.log(`[CONFIG] \u2139\uFE0F Optional config ${n} not in INLINE_ASSETS, skipping fetch in publish mode`),{})}g==="brand"||console.log(`[CONFIG] DEV MODE: Trying nested paths first, then flattened for "${n}"`);let e;g==="brand"?e=[`./${n.split("/").pop()||n}`,`./${n}`,`./${n.replace(/^configs\//,"")}`,`./${n.replace(/^configs\//,"").replace(/\//g,".")}`]:e=[`./${n}`,`./${n.replace(/^configs\//,"")}`,`./${n.replace(/^configs\//,"").replace(/\//g,".")}`],e=Array.from(new Set(e.flatMap(o=>o.startsWith("./")?[o,`/${o.slice(2)}`]:o.startsWith("/")?[o]:[o,`/${o}`]))),console.log("[CONFIG] Will try candidates:",e);let t=(async()=>{let o=q?"no-store":"force-cache";for(let s of e)try{let a=await fetch(s,{cache:o});if(!a.ok)continue;let i=await a.json();return console.log(`[CONFIG] \u2713 Loaded ${n} via ${s}`,i),i}catch(a){console.warn(`[CONFIG] \u2717 Failed to load ${s} (mode: ${g}):`,a)}return console.warn(`[CONFIG] \u2717 All attempts failed for ${n}; using defaults`),{}})();return B.set(n,t),t}async function ee(){console.log("[CONFIG] Loading component schemas...");let n=["components/identity.schema.json","components/transform.schema.json","components/render.schema.json","components/motion.schema.json","components/effects.schema.json","components/interaction.schema.json","components/gameplay.rules.schema.json","components/gameplay.tuning.schema.json","components/visibility.schema.json","components/audio.schema.json","components/physics.schema.json","components/ui.schema.json"],e=new Map;for(let t of n)try{let o=g==="publish"||g==="brand"?t.split("/").pop()||t:`configs/${t}`,s=await T(o);s.component&&(e.set(s.component,s),console.log(`[CONFIG] \u2713 Schema loaded: ${s.component} ${g==="publish"||g==="brand"?"(flattened)":"(nested)"}`))}catch(o){console.warn(`[CONFIG] \u2717 Failed to load schema ${t}:`,o)}return console.log(`[CONFIG] Loaded ${e.size} component schemas`),e}async function A(n){console.log(`[CONFIG] Loading object config: ${n}`);let e=g==="publish"||g==="brand"?`${n}.json`:`configs/objects/${n}.json`;return await T(e)}async function ne(n){let e=new Map;if(n.objects&&Array.isArray(n.objects)){for(let t of n.objects)if(t.enabled&&t.object_config)try{let o=t.instance_id;/^(json\.|ui\.|effects\.|engine\.)/.test(o)||(o=`json.${o}`);let s=await A(o);(!s||Object.keys(s).length===0)&&o!==t.instance_id&&(s=await A(t.instance_id)),!s||Object.keys(s).length===0?(console.log(`[CONFIG] No instance snapshot for ${t.instance_id}, using template ${t.object_config}`),s=await A(t.object_config)):console.log(`[CONFIG] \u2713 Loaded instance snapshot for ${t.instance_id}`),e.set(t.instance_id,{...s,instance_id:t.instance_id,object_config:t.object_config})}catch(o){console.warn(`Failed to load object ${t.object_config}:`,o)}}return e}async function te(){console.log("[CONFIG] Loading engine configs...");let n=["runtime","assets","splash","loading","start","tutorial","endgame"],e=await Promise.all(n.map(o=>{let s=`engine.${o}.json`,a=g==="publish"||g==="brand"?s:`configs/engine/${s}`;return T(a)})),t=Object.fromEntries(n.map((o,s)=>[o,e[s]]));return console.log("[CONFIG] Engine configs loaded:",Object.fromEntries(n.map(o=>{var i;let s=(i=t[o])!=null?i:{},a=Object.keys(s);return[o,a.length>0?a:"empty"]}))),t}async function re(){return await T(g==="publish"||g==="brand"?"game.prompt.json":"configs/engine/game.prompt.json")}async function oe(n="scene.main"){console.log(`[CONFIG] Loading scene config: ${n}`);let e=g==="publish"||g==="brand"?`${n}.json`:`configs/scenes/${n}.json`;return await T(e)}function W(n,e){let t=[];if(!n.identity)return t.push("Missing required identity component"),{valid:!1,errors:t};let o=e.get("identity");if(o)for(let s of o.required||[])n.identity[s]||t.push(`Missing required identity field: ${s}`);for(let[s,a]of Object.entries(n)){if(s==="identity")continue;let i=e.get(s);if(i&&a&&typeof a=="object"){let c=a;for(let d of i.required||[])c[d]===void 0&&t.push(`Missing required field in ${s}: ${d}`);if(i.constraints&&typeof i.constraints=="object")for(let[d,m]of Object.entries(i.constraints)){let C=c[d];if(C!==void 0&&m&&typeof m=="object"){let O=m;typeof C=="number"&&(O.min!==void 0&&C<O.min&&t.push(`${s}.${d} value ${C} is below minimum ${O.min}`),O.max!==void 0&&C>O.max&&t.push(`${s}.${d} value ${C} is above maximum ${O.max}`))}}}}return{valid:t.length===0,errors:t}}function R(n,e){let t={...n},o=["identity","transform","render"];for(let[s,a]of e.entries())a.defaults&&Object.keys(a.defaults).length>0&&(o.includes(s)||t[s])&&(t[s]||(t[s]={}),t[s]={...a.defaults,...t[s]});return t}function _(n,e,t,o){return typeof n!="number"||!Number.isFinite(n)?e:Math.min(Math.max(n,t),o)}function Z(n,e){if(Array.isArray(n))return{x:_(n[0],e.x,-2e3,2e3),y:_(n[1],e.y,-2e3,2e3)};if(!n||typeof n!="object")return e;let{x:t,y:o}=n;return{x:_(t,e.x,-2e3,2e3),y:_(o,e.y,-2e3,2e3)}}function ce(n,e){if(Array.isArray(n))return{x:_(n[0],e.x,0,1),y:_(n[1],e.y,0,1)};if(!n||typeof n!="object")return e;let{x:t,y:o}=n;return{x:_(t,e.x,0,1),y:_(o,e.y,0,1)}}function le(n){if(Array.isArray(n))return{x:_(n[0],.5,-10,10),y:_(n[1],.5,-10,10)};if(n&&typeof n=="object"){let{x:e,y:t}=n;return{x:_(e,.5,-10,10),y:_(t,.5,-10,10)}}return typeof n=="string"?n:null}async function U(n="scene.main",e){var m,C,O,N,$,u,l,h,v,x,j,F,G,M,k,P,L,H;console.log("[CONFIG] ===== Starting Object-Centric Config Load =====");let t=await ee(),o=Q(),s=X();console.log(`[CONFIG] Loader: Found ${o.length} persisted overrides, override mode: ${s}`),o.length>0&&console.log("[CONFIG] Override details:",o.map(b=>({objectId:b.objectId,path:b.path,value:typeof b.value=="string"?b.value.substring(0,50):b.value})));let a=await oe(n);console.log(`[CONFIG] Scene config loaded: ${((m=a.objects)==null?void 0:m.length)||0} objects`);let i=await te();console.log("[CONFIG] Loading object configs...");let c=await ne(a);console.log(`[CONFIG] Loaded ${c.size} object configs:`,Array.from(c.keys()));for(let[b,w]of c.entries()){let p=R(w,t),r=W(p,t);r.valid||console.warn(`Object ${b} validation errors:`,r.errors),(C=p.transform)!=null&&C.position&&(p.transform.position=Z(p.transform.position,{x:0,y:0})),(O=p.transform)!=null&&O.offset&&(p.transform.offset=Z(p.transform.offset,{x:0,y:0})),((N=p.transform)==null?void 0:N.anchor)!==void 0&&(p.transform.anchor=le(p.transform.anchor)),(($=p.transform)==null?void 0:$.position_ratio)!==void 0&&p.transform.position_ratio!==null&&(p.transform.position_ratio=ce(p.transform.position_ratio,{x:.5,y:.5})),c.set(b,p)}if(e){if(e.objects)for(let[b,w]of e.objects.entries())c.set(b,w);e.engine&&(i.runtime={...i.runtime,...e.engine.runtime},i.assets={...i.assets,...e.engine.assets},i.splash={...(u=i.splash)!=null?u:{},...(l=e.engine.splash)!=null?l:{}})}let d={objects:c,engine:i,scene:a,schemas:t,theme:{background_color:"#ffffff",text_color:"#000000",square_color:"#cccccc",cta_background:"#007bff",cta_text:"#ffffff"},gameplay:{}};if(typeof window!="undefined"&&(window.__editableConfig=d,window.__editableConfigBaseline||(window.__editableConfigBaseline=R(d,t))),o.length>0&&s){console.log(`[CONFIG] \u2705 Applying ${o.length} persisted overrides on startup`);let b=new Map;for(let r of o)if(r.path==="render.asset.path"&&r.objectId){let y=r.value;b.has(y)||b.set(y,[]),b.get(y).push(r.objectId)}for(let[r,y]of b.entries())y.length>1&&console.log(`[CONFIG] \u{1F4CB} Multiple objects sharing asset on startup: "${r}" used by: ${y.join(", ")}`);let w=new Map;for(let r of o){let y=r.objectId||"__engine__";w.has(y)||w.set(y,[]),w.get(y).push(r)}console.log("[CONFIG] Override distribution:",{totalOverrides:o.length,objectsWithOverrides:Array.from(w.keys()),overridesPerObject:Array.from(w.entries()).map(([r,y])=>({objectId:r,count:y.length,paths:y.map(S=>S.path)}))}),K(o,{silent:!1,persist:!1});let p=window.__editableConfig;if(p){for(let r of o.slice(0,5))if(r.objectId){let y=((v=(h=p.objects)==null?void 0:h.get)==null?void 0:v.call(h,r.objectId))||((x=p.objects)==null?void 0:x[r.objectId]);if(y){let S=r.path.split(".").reduce((E,D)=>E==null?void 0:E[D],y);S===r.value?console.log(`[CONFIG] \u2705 Verified override applied: ${r.objectId}.${r.path} = ${typeof r.value=="string"?r.value.substring(0,40):"\u2713"}`):console.error(`[CONFIG] \u274C Override NOT applied correctly: ${r.objectId}.${r.path}. Expected: ${r.value}, Got: ${S}`)}else console.error(`[CONFIG] \u274C Object not found after override application: ${r.objectId}`)}}console.log("[CONFIG] \u2705 Overrides applied. Current config state:",{objectCount:((j=d.objects)==null?void 0:j.size)||0,sampleOverrides:o.slice(0,3).map(r=>`${r.objectId||"engine"}.${r.path} = ${typeof r.value=="string"?r.value.substring(0,30):JSON.stringify(r.value).substring(0,30)}`)})}else o.length>0&&!s?console.warn(`[CONFIG] \u26A0\uFE0F Found ${o.length} persisted overrides but override mode is DISABLED. Overrides will NOT be applied.`):o.length===0&&console.log("[CONFIG] No persisted overrides found in localStorage");return console.log("[CONFIG] ===== Object-Centric Config Load Complete ====="),console.log("[CONFIG] Summary:",{schemas:Array.from(t.keys()),objects:Array.from(c.keys()),engine:{runtime:Object.keys((F=i.runtime)!=null?F:{}),assets:Object.keys((G=i.assets)!=null?G:{}),splash:Object.keys((M=i.splash)!=null?M:{}),loading:Object.keys((k=i.loading)!=null?k:{}),start:Object.keys((P=i.start)!=null?P:{}),tutorial:Object.keys((L=i.tutorial)!=null?L:{}),endgame:Object.keys((H=i.endgame)!=null?H:{})},scene:a.scene_id||"unknown"}),d}function fe(n){var t,o,s,a,i,c,d,m,C,O,N,$,u,l,h,v,x,j,F,G,M,k,P,L,H,b,w,p,r,y,S,E,D;let e={gameplay:{},ui:{},theme:{},assets:{}};for(let[se,f]of n.objects.entries()){let I=((t=f.identity)==null?void 0:t.id)||se;I.includes("character")&&(e.gameplay.character_pos=((o=f.transform)==null?void 0:o.position)||{x:0,y:0},e.gameplay.character_scale=((s=f.transform)==null?void 0:s.scale)||1,e.gameplay.character_anim_speed=((i=(a=f.gameplay)==null?void 0:a.tuning)==null?void 0:i.anim_speed)||.003,e.gameplay.character_relief_scale=((d=(c=f.gameplay)==null?void 0:c.tuning)==null?void 0:d.relief_scale)||1.22,e.gameplay.character_relief_speed=((C=(m=f.gameplay)==null?void 0:m.tuning)==null?void 0:C.relief_speed)||.22),(I.includes("gun")||I.includes("flame"))&&(e.gameplay.gun=f.gun||{},e.gameplay.gunmuzzle=((O=f.effects)==null?void 0:O.gunmuzzle)||{},e.gameplay.muzzle_levels=((N=f.effects)==null?void 0:N.muzzle_levels)||{},e.gameplay.flame=(($=f.effects)==null?void 0:$.flame)||{}),I.includes("diamond")&&(e.gameplay.diamond=f),I.includes("ice")&&(e.gameplay.melt=f.melt||{},e.gameplay.melt_anchor=((u=f.transform)==null?void 0:u.melt_anchor)||{x:0,y:0},e.gameplay.melt_pos=((l=f.transform)==null?void 0:l.position)||{x:0,y:0},e.gameplay.hybrid_melting=((h=f.effects)==null?void 0:h.hybrid_melting)||{},e.gameplay.physics_chunks=((v=f.effects)==null?void 0:v.physics_chunks)||{},e.gameplay.melting_particles=((x=f.effects)==null?void 0:x.melting_particles)||{},e.gameplay.hard_ice=f.hard_ice||{}),I.includes("water")&&(e.gameplay.water_drops=f),I.includes("crack")&&(e.gameplay.crack=f),I.includes("hand")&&(e.gameplay.hand=((j=f.gameplay)==null?void 0:j.tuning)||{},e.gameplay.brush_start_pos=((F=f.transform)==null?void 0:F.brush_start_pos)||{x:0,y:-120},e.gameplay.hand_scale=((G=f.transform)==null?void 0:G.scale)||1.5),I.includes("hazard")&&(e.gameplay.hazard=((M=f.gameplay)==null?void 0:M.tuning)||{},e.gameplay.danger_pos=((k=f.transform)==null?void 0:k.danger_pos)||{x:0,y:235},e.gameplay.danger_pulse=((L=(P=f.gameplay)==null?void 0:P.tuning)==null?void 0:L.danger_pulse)||{},e.gameplay.hazard_height=((b=(H=f.gameplay)==null?void 0:H.tuning)==null?void 0:b.hazard_height)||140)}return e.gameplay.timeline=((w=n.engine.runtime)==null?void 0:w.timeline)||{},e.gameplay.drag_surface=((p=n.engine.runtime)==null?void 0:p.drag_surface)||{},e.gameplay.background=((r=n.engine.runtime)==null?void 0:r.background)||{},e.gameplay.ui_styles=((y=n.engine.runtime)==null?void 0:y.ui_styles)||{},e.gameplay.label_pulse=((S=n.engine.runtime)==null?void 0:S.label_pulse)||{},e.ui=((E=n.engine.runtime)==null?void 0:E.ui)||{},e.theme=((D=n.engine.runtime)==null?void 0:D.theme)||{},e.assets=n.engine.assets||{},e}var J=class{shouldFullReload(e){return e.type==="component"||e.type==="scene"}getAffectedObjects(e){return e.type==="object"&&e.objectId?[e.objectId]:[]}},z=class{constructor(e=1e3){this.pollingInterval=null;this.fileHashes=new Map;this.callbacks=new Map;this.intervalMs=e}watch(e,t){this.callbacks.set(e,t),this.pollingInterval===null&&(this.pollingInterval=window.setInterval(()=>{this.checkAllFiles()},this.intervalMs))}async checkAllFiles(){for(let[e,t]of this.callbacks.entries())try{let o=`${e}?t=${Date.now()}&r=${Math.random()}`,s=await fetch(o,{cache:"no-cache",headers:{"Cache-Control":"no-cache"}});if(s.ok){let a=await s.text(),i=this.hashString(a),c=this.fileHashes.get(e);if(c&&c!==i&&console.log(`[HOT-RELOAD] File changed: ${e}`),c&&c!==i){console.log(`[HOT-RELOAD] File changed: ${e}`);let d=this.determineEventType(e);t(d),this.fileHashes.set(e,i)}else c||this.fileHashes.set(e,i)}}catch(o){console.warn(`Failed to check ${e}:`,o)}}determineEventType(e){var t,o;return e.includes("/components/")?{type:"component",path:e,componentName:(t=e.split("/").pop())==null?void 0:t.replace(".schema.json","")}:e.includes("/engine/")?{type:"engine",path:e}:e.includes("/scenes/")?{type:"scene",path:e}:e.includes("/objects/")?{type:"object",path:e,objectId:(o=e.split("/").pop())==null?void 0:o.replace(".json","")}:{type:"object",path:e}}hashString(e){let t=0;for(let o=0;o<e.length;o++){let s=e.charCodeAt(o);t=(t<<5)-t+s,t=t&t}return t.toString()}unwatch(e){this.callbacks.delete(e),this.fileHashes.delete(e)}stop(){this.pollingInterval!==null&&(clearInterval(this.pollingInterval),this.pollingInterval=null),this.callbacks.clear(),this.fileHashes.clear()}};function de(n,e){let t=[];function o(s,a,i=""){if(s!==a){if(typeof s!=typeof a){t.push(`${i}: type changed`);return}if(typeof s=="object"&&s!==null&&a!==null){let c=new Set([...Object.keys(s),...Object.keys(a)]);for(let d of c){let m=i?`${i}.${d}`:d;d in s?d in a?o(s[d],a[d],m):t.push(`${m}: removed`):t.push(`${m}: added`)}}else t.push(`${i}: changed`)}}return o(n,e),t}function ge(n,e,t,o){let s={...t};for(let[a,i]of o.entries())s[a]&&i.defaults&&(s[a]={...i.defaults,...s[a]});return s}var V={};function ue(n){if(typeof window=="undefined")return;let e=typeof V!="undefined"&&!!V.hot,t=window.location.search.includes("hot-reload");if(!(e||t))return;let s=null,a=!1,i=null;if(t){i=new z;let u=window.__configWatcher;u!=null&&u.stop&&u.stop(),window.__configWatcher=i}let c=new Set,d=u=>{var v,x;if(!i)return;let l=new Set;l.add("configs/engine/engine.runtime.json"),l.add("configs/engine/engine.assets.json"),l.add("configs/engine/engine.splash.json"),l.add("configs/scenes/scene.main.json");let h=(x=(v=u.scene)==null?void 0:v.objects)!=null?x:[];for(let j of h)j!=null&&j.object_config&&l.add(`configs/objects/${j.object_config}.json`);for(let j of c)l.has(j)||i.unwatch(j);for(let j of l)c.has(j)||i.watch(j,F=>$(F));c=l},m=new Set,C=!1,O=async u=>{let l=await A(u),h=R(l,n.activeConfig.schemas),v=W(h,n.activeConfig.schemas);v.valid||console.warn(`[HOT-RELOAD] ${u} validation errors:`,v.errors),await n.liveEditBridge.applyObjectConfig(u,h)};async function N(u){if(!a){a=!0;try{if(C||m.size===0){n.audioSystem.destroy();let l=await U("scene.main");n.setActiveConfig(l),n.gameObjectManager.updateConfig(l),n.CustomAssets.updateConfig(l),await n.CustomAssets.ready();let h=n.createAudioSystem(l);n.setAudioSystem(h),window.__audioSystem=h,await h.start(),n.liveEditBridge.rebuildIndexes(),d(l),console.log(`[GAME] Hot-reload complete (${u})`)}else{let l=Array.from(m);m.clear();for(let h of l)await O(h);console.log(`[GAME] Hot-reload updated objects: ${l.join(", ")}`)}}catch(l){console.warn("[GAME] Hot-reload failed:",l)}finally{a=!1,C=!1,m.clear()}}}function $(u){u.type==="object"&&u.objectId?m.add(u.objectId):C=!0,s&&window.clearTimeout(s),s=window.setTimeout(()=>{N(u.type)},120)}e&&V.hot.on("config-change",()=>{$({type:"hmr"})}),t&&(d(n.activeConfig),console.log(`[GAME] Hot-reload watcher enabled (${c.size} files)`))}export{ee as a,A as b,ne as c,te as d,re as e,oe as f,W as g,R as h,U as i,fe as j,J as k,z as l,de as m,ge as n,ue as o};
|