Files
michaelschiemer/public/assets/js/core-DP_QFOgY.js
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

2 lines
13 KiB
JavaScript

var e=Object.defineProperty;import{r as t}from"./modules-BxMbsY-5.js";import{a as s}from"./utils-C3Omb0Sg.js";const i=new Map;let n=!1,r=!1;performance.now();const a=document.createElement("div");a.style.position="fixed",a.style.bottom="0",a.style.left="0",a.style.font="12px monospace",a.style.color="#0f0",a.style.background="rgba(0,0,0,0.75)",a.style.padding="0.25rem 0.5rem",a.style.zIndex="9999",a.style.pointerEvents="none",a.style.display="none";const o=`<div style="width:${Math.min(0,100)}%;height:4px;background:#0f0;margin-top:4px;"></div>`;a.innerHTML+=o,a.style.lineHeight="1.4",document.body.appendChild(a);const c=new class{constructor({fps:e=!0}={}){this.fpsEnabled=e,this.fps=0,this.frameCount=0,this.lastTime=performance.now(),this.visible=!1,this.taskTimings=new Map,this.logs=[],this.container=document.createElement("div"),this.container.style.position="fixed",this.container.style.bottom="0",this.container.style.left="0",this.container.style.font="12px Consolas, monospace",this.container.style.color="#0f0",this.container.style.background="rgba(0,0,0,0.75)",this.container.style.padding="0.5rem",this.container.style.zIndex="9999",this.container.style.pointerEvents="none",this.container.style.lineHeight="1.4",this.container.style.whiteSpace="pre",this.container.style.display="none",document.body.appendChild(this.container),window.addEventListener("keydown",e=>{"§"===e.key&&(this.visible=!this.visible,this.container.style.display=this.visible?"block":"none")})}log(e){const t=(new Date).toLocaleTimeString();this.logs.push(`[${t}] ${e}`),this.logs.length>5&&this.logs.shift()}update(e=new Map){this.frameCount++;const t=performance.now();if(t-this.lastTime>=1e3){this.fps=this.frameCount,this.frameCount=0,this.lastTime=t;const s=[];for(const[e,t]of this.taskTimings.entries())s.push(`${e}: ${t.toFixed(2)}ms`);const i=Math.min(2*this.fps,100),n=this.logs.slice().reverse().join("\n");this.container.innerHTML=`\nFPS: ${this.fps} | Tasks: ${e.size}\n${s.join("\n")}\n<div style="width:${i}%;height:4px;background:#0f0;margin-top:4px;"></div>\n${n?"\nLogs:\n"+n:""}\n `}}trackTask(e,t){const s=performance.now();t();const i=performance.now()-s;this.taskTimings.set(e,i)}};function d(e,t,s={}){i.set(e,t),s.autoStart&&!n&&function(){if(n)return;function e(){for(const[e,s]of i)try{r?c.trackTask(e,s):s()}catch(t){u.warn("[Frameloop] Fehler in Task:",t)}r&&c.update(i),requestAnimationFrame(e)}n=!0,requestAnimationFrame(e)}()}function l(e){i.delete(e)}window.addEventListener("keydown",e=>{"§"===e.key&&(r=!r,a.style.display=r?"block":"none")});class u{static log(...e){this._write("log","[LOG]",e)}static warn(...e){this._write("warn","[WARN]",e)}static info(...e){this._write("info","[INFO]",e)}static error(...e){this._write("error","[ERROR]",e)}static _write(e,t,s){if(!this.enabled)return;const i=`${t} [${(new Date).toLocaleTimeString("de-DE")}] ${s.map(e=>{if(e instanceof Error)return`${e.name}: ${e.message}\n${e.stack||""}`;if("object"==typeof e&&null!==e)try{return JSON.stringify(e)}catch(t){return"[Circular Object]"}return e}).join(" ")}`;if(console[e],c&&"function"==typeof c.log)try{c.log(i)}catch(n){}}}var h;((t,s,i)=>{s in t?e(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i})(u,"symbol"!=typeof(h="enabled")?h+"":h,!0);const p=new class{constructor(){this.crashedModules=new Set,this.recoveryAttempts=new Map,this.maxRecoveryAttempts=3,this.recoveryDelay=1e3}wrapModule(e,t){return e&&"object"==typeof e?new Proxy(e,{get:(e,s,i)=>{const n=e[s];if("function"!=typeof n)return n;const r=Object.getOwnPropertyDescriptor(e,s);return r&&!r.configurable?n:(...i)=>{try{const r=n.apply(e,i);return r&&"function"==typeof r.catch?r.catch(e=>(this.handleModuleError(e,t,s,i),this.getRecoveryValue(t,s))):r}catch(r){return this.handleModuleError(r,t,s,i),this.getRecoveryValue(t,s)}}},getOwnPropertyDescriptor:(e,t)=>{const s=Object.getOwnPropertyDescriptor(e,t);return s&&s.configurable,s},has:(e,t)=>t in e,ownKeys:e=>Object.getOwnPropertyNames(e)}):(u.warn(`[ErrorBoundary] Cannot wrap non-object module: ${t}`),e)}handleModuleError(e,t,s,i){const n=`${t}.${s}`;u.error(`[ErrorBoundary] Module ${t} crashed in ${s}():`,e),this.crashedModules.add(t);const r=this.recoveryAttempts.get(n)||0;this.recoveryAttempts.set(n,r+1),window.dispatchEvent(new CustomEvent("module-error",{detail:{moduleName:t,method:s,error:e.message,args:i,attempts:r+1}})),r<this.maxRecoveryAttempts?this.scheduleRecovery(t,s,i):(u.error(`[ErrorBoundary] Module ${t} exceeded recovery attempts. Marking as permanently failed.`),this.markModuleAsPermanentlyFailed(t))}scheduleRecovery(e,t,s){setTimeout(()=>{try{u.info(`[ErrorBoundary] Attempting recovery for ${e}.${t}()`)}catch(s){u.error(`[ErrorBoundary] Recovery failed for ${e}.${t}():`,s)}},this.recoveryDelay)}getRecoveryValue(e,t){switch(t){case"init":case"destroy":case"update":case"render":return Promise.resolve();case"getData":case"getConfig":return{};case"isEnabled":case"isActive":return!1;default:return}}markModuleAsPermanentlyFailed(e){window.dispatchEvent(new CustomEvent("module-permanent-failure",{detail:{moduleName:e}}))}getHealthStatus(){return{totalCrashedModules:this.crashedModules.size,crashedModules:Array.from(this.crashedModules),recoveryAttempts:Object.fromEntries(this.recoveryAttempts),timestamp:(new Date).toISOString()}}resetModule(e){this.crashedModules.delete(e);for(const[t]of this.recoveryAttempts)t.startsWith(`${e}.`)&&this.recoveryAttempts.delete(t);u.info(`[ErrorBoundary] Reset error tracking for module: ${e}`)}reset(){this.crashedModules.clear(),this.recoveryAttempts.clear(),u.info("[ErrorBoundary] Reset all error tracking")}};window.addEventListener("error",e=>{u.error("[Global] Unhandled error:",e.error||e.message)}),window.addEventListener("unhandledrejection",e=>{u.error("[Global] Unhandled promise rejection:",e.reason)});const m=new class{constructor(){this.state=new Map,this.subscribers=new Map,this.stateOwners=new Map,this.defaultValues=new Map,this.currentModule="unknown",this.subscriptionCounter=0}setContext(e){this.currentModule=e}register(e,t,s=this.currentModule){this.state.has(e)?u.warn(`[StateManager] State key '${e}' already registered by ${this.stateOwners.get(e)}`):(this.state.set(e,t),this.defaultValues.set(e,t),this.stateOwners.set(e,s),this.subscribers.set(e,[]),u.info(`[StateManager] Registered '${e}' (owner: ${s})`))}get(e){if(this.state.has(e))return this.state.get(e);u.warn(`[StateManager] Unknown state key: '${e}'`)}set(e,t,s=!1){if(!this.state.has(e))return u.warn(`[StateManager] Cannot set unknown state key: '${e}'`),!1;const i=this.stateOwners.get(e);if(!s&&i!==this.currentModule)return u.warn(`[StateManager] Module '${this.currentModule}' cannot modify '${e}' (owned by ${i})`),!1;const n=this.state.get(e);return n===t||(this.state.set(e,t),this.notifySubscribers(e,t,n),u.info(`[StateManager] Updated '${e}' by ${this.currentModule}`)),!0}subscribe(e,t,s=this.currentModule){if(!this.state.has(e))return u.warn(`[StateManager] Cannot subscribe to unknown state key: '${e}'`),null;const i=`${s}_${++this.subscriptionCounter}`,n={id:i,callback:t,subscriber:s};return this.subscribers.has(e)||this.subscribers.set(e,[]),this.subscribers.get(e).push(n),u.info(`[StateManager] Subscribed '${s}' to '${e}'`),i}unsubscribe(e){for(const[t,s]of this.subscribers.entries()){const i=s.findIndex(t=>t.id===e);if(-1!==i){const e=s[i];return s.splice(i,1),void u.info(`[StateManager] Unsubscribed '${e.subscriber}' from '${t}'`)}}u.warn(`[StateManager] Subscription ID not found: ${e}`)}notifySubscribers(e,t,s){(this.subscribers.get(e)||[]).forEach(i=>{try{i.callback(t,s,e)}catch(n){u.error(`[StateManager] Error in subscriber '${i.subscriber}' for '${e}':`,n)}})}reset(e){if(!this.state.has(e))return u.warn(`[StateManager] Cannot reset unknown state key: '${e}'`),!1;const t=this.defaultValues.get(e);return this.set(e,t,!0)}clearModuleSubscriptions(e){let t=0;for(const[s,i]of this.subscribers.entries()){const n=i.filter(t=>t.subscriber!==e);t+=i.length-n.length,this.subscribers.set(s,n)}t>0&&u.info(`[StateManager] Cleared ${t} subscriptions for module '${e}'`)}getSnapshot(){const e={state:Object.fromEntries(this.state),owners:Object.fromEntries(this.stateOwners),subscriptions:{}};for(const[t,s]of this.subscribers.entries())e.subscriptions[t]=s.map(e=>({id:e.id,subscriber:e.subscriber}));return e}resetAll(){this.state.clear(),this.subscribers.clear(),this.stateOwners.clear(),this.defaultValues.clear(),this.subscriptionCounter=0,u.info("[StateManager] Reset complete")}createScope(e){return{register:(t,s)=>(this.setContext(e),this.register(t,s,e)),get:e=>this.get(e),set:(t,s)=>(this.setContext(e),this.set(t,s)),subscribe:(t,s)=>(this.setContext(e),this.subscribe(t,s,e)),unsubscribe:e=>this.unsubscribe(e),reset:e=>this.reset(e),cleanup:()=>this.clearModuleSubscriptions(e)}}};"undefined"!=typeof window&&(window.stateManager=m,window.stateSnapshot=()=>m.getSnapshot());class f{constructor(){this.modules=new Map,this.dependents=new Map,this.initialized=new Set,this.initializing=new Set,this.initializationOrder=[]}register(e){this.modules.has(e.name)?u.warn(`[DependencyManager] Module '${e.name}' already registered`):this.validateDefinition(e)&&(this.modules.set(e.name,e),e.dependencies.forEach(t=>{this.dependents.has(t.name)||this.dependents.set(t.name,[]),this.dependents.get(t.name).push(e.name)}),u.info(`[DependencyManager] Registered '${e.name}' v${e.version}`))}calculateInitializationOrder(){const e=new Set,t=new Set,s=[],i=n=>{if(t.has(n))throw new Error(`Circular dependency detected involving '${n}'`);if(e.has(n))return;const r=this.modules.get(n);r&&(t.add(n),r.dependencies.forEach(e=>{e.optional&&!this.modules.has(e.name)||i(e.name)}),t.delete(n),e.add(n),s.push(n))};return Array.from(this.modules.entries()).sort(([,e],[,t])=>(t.priority||0)-(e.priority||0)).map(([e])=>e).forEach(t=>{e.has(t)||i(t)}),this.initializationOrder=s,u.info(`[DependencyManager] Initialization order: ${s.join(" → ")}`),s}checkDependencies(e){const t=this.modules.get(e);if(!t)return{satisfied:!1,missing:[],reason:`Module '${e}' not registered`};const s=[],i=[];return t.dependencies.forEach(e=>{this.modules.get(e.name)?this.initialized.has(e.name)||e.optional||s.push(`${e.name} (not initialized)`):e.optional?i.push(e.name):s.push(e.name)}),{satisfied:0===s.length,missing:s,optional:i,reason:s.length>0?`Missing: ${s.join(", ")}`:"OK"}}markInitialized(e){this.initialized.add(e),this.initializing.delete(e),u.info(`[DependencyManager] '${e}' initialized`)}markInitializing(e){this.initializing.add(e)}getDependents(e){return this.dependents.get(e)||[]}getModule(e){return this.modules.get(e)}isReadyToInitialize(e){if(this.initialized.has(e)||this.initializing.has(e))return!1;return this.checkDependencies(e).satisfied}getStatus(){const e=this.modules.size,t=this.initialized.size,s=this.initializing.size;return{total:e,initialized:t,initializing:s,pending:e-t-s,modules:{initialized:Array.from(this.initialized),initializing:Array.from(this.initializing),pending:Array.from(this.modules.keys()).filter(e=>!this.initialized.has(e)&&!this.initializing.has(e))}}}validateDefinition(e){if(!e.name||"string"!=typeof e.name)return u.error("[DependencyManager] Module name is required and must be string"),!1;if(!e.version||"string"!=typeof e.version)return u.error(`[DependencyManager] Version is required for module '${e.name}'`),!1;if(!Array.isArray(e.dependencies))return u.error(`[DependencyManager] Dependencies must be array for module '${e.name}'`),!1;for(const t of e.dependencies)if(!t.name||"string"!=typeof t.name)return u.error(`[DependencyManager] Invalid dependency in module '${e.name}': missing name`),!1;return!0}reset(){this.modules.clear(),this.dependents.clear(),this.initialized.clear(),this.initializing.clear(),this.initializationOrder=[],u.info("[DependencyManager] Reset complete")}static createDefinition(e,t){const s={name:e,version:t,dependencies:[],provides:[],priority:0},i={depends(e,t="*",i=!1){return s.dependencies.push({name:e,version:t,optional:i}),this},provides(...e){return s.provides.push(...e),this},priority(e){return s.priority=e,this},build:()=>s};return Object.setPrototypeOf(i,s),Object.keys(s).forEach(e=>{e in i||Object.defineProperty(i,e,{get:()=>s[e],set(t){s[e]=t},enumerable:!0,configurable:!0})}),i}}const g=new f;"undefined"!=typeof window&&(window.dependencyManager=g,window.depStatus=()=>g.getStatus());const y=new Map,b={add(e,t,s,{module:i="global",options:n=!1}={}){e.addEventListener(t,s,n),y.has(i)||y.set(i,[]),y.get(i).push([e,t,s,n])},removeModule(e){const t=y.get(e);t&&(t.forEach(([e,t,s,i])=>{e.removeEventListener(t,s,i)}),y.delete(e))},clearAll(){for(const[e,t]of y.entries())t.forEach(([e,t,s,i])=>{e.removeEventListener(t,s,i)});y.clear()},debug(){}};function w(e,t,s,i=import.meta,n=!1){var r;const a="string"==typeof i?i:(null==(r=i.url)?void 0:r.split("/").slice(-2,-1)[0])||"unknown";return b.add(e,t,s,{module:a,options:n}),()=>{b.removeModule(a)}}async function M(){await t(),s()}function v(e){Array.isArray(e)&&e.forEach(e=>{b.removeModule(e)})}export{f as D,u as L,w as a,v as b,g as d,M as i,p as m,d as r,m as s,l as u};