Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
- Remove middleware reference from Gitea Traefik labels (caused routing issues) - Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s) - Add explicit service reference in Traefik labels - Fix intermittent 504 timeouts by improving PostgreSQL connection handling Fixes Gitea unreachability via git.michaelschiemer.de
125 lines
3.1 KiB
JavaScript
125 lines
3.1 KiB
JavaScript
/**
|
|
* Shared Configuration between PHP and JavaScript
|
|
*
|
|
* Provides unified configuration management for LiveComponents
|
|
* that can be synchronized between server and client.
|
|
*/
|
|
|
|
export class SharedConfig {
|
|
constructor() {
|
|
this.config = {
|
|
// Request settings
|
|
requestTimeout: 30000, // 30 seconds
|
|
retryAttempts: 3,
|
|
retryDelays: [1000, 2000, 5000], // Progressive backoff
|
|
|
|
// State settings
|
|
stateVersioning: true,
|
|
stateValidation: true,
|
|
|
|
// Performance settings
|
|
requestDeduplication: true,
|
|
requestCacheTimeout: 1000, // 1 second
|
|
batchFlushDelay: 50, // 50ms
|
|
|
|
// Error handling
|
|
errorBoundary: true,
|
|
autoRetry: true,
|
|
showErrorUI: true,
|
|
|
|
// DevTools
|
|
devToolsEnabled: false
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Load configuration from server
|
|
*
|
|
* @param {Object} serverConfig - Configuration from server
|
|
*/
|
|
loadFromServer(serverConfig) {
|
|
if (serverConfig && typeof serverConfig === 'object') {
|
|
this.config = {
|
|
...this.config,
|
|
...serverConfig
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Load configuration from DOM
|
|
*
|
|
* Looks for data-livecomponent-config attribute on document or body
|
|
*/
|
|
loadFromDOM() {
|
|
const configElement = document.querySelector('[data-livecomponent-config]') || document.body;
|
|
const configJson = configElement.dataset.livecomponentConfig;
|
|
|
|
if (configJson) {
|
|
try {
|
|
const parsed = JSON.parse(configJson);
|
|
this.loadFromServer(parsed);
|
|
} catch (error) {
|
|
console.warn('[SharedConfig] Failed to parse config from DOM:', error);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get configuration value
|
|
*
|
|
* @param {string} key - Configuration key
|
|
* @param {*} defaultValue - Default value if key not found
|
|
* @returns {*} Configuration value
|
|
*/
|
|
get(key, defaultValue = null) {
|
|
return this.config[key] ?? defaultValue;
|
|
}
|
|
|
|
/**
|
|
* Set configuration value
|
|
*
|
|
* @param {string} key - Configuration key
|
|
* @param {*} value - Configuration value
|
|
*/
|
|
set(key, value) {
|
|
this.config[key] = value;
|
|
}
|
|
|
|
/**
|
|
* Get all configuration
|
|
*
|
|
* @returns {Object} Full configuration object
|
|
*/
|
|
getAll() {
|
|
return { ...this.config };
|
|
}
|
|
|
|
/**
|
|
* Merge configuration
|
|
*
|
|
* @param {Object} newConfig - Configuration to merge
|
|
*/
|
|
merge(newConfig) {
|
|
this.config = {
|
|
...this.config,
|
|
...newConfig
|
|
};
|
|
}
|
|
}
|
|
|
|
// Create singleton instance
|
|
export const sharedConfig = new SharedConfig();
|
|
|
|
// Auto-load from DOM on initialization
|
|
if (typeof document !== 'undefined') {
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
sharedConfig.loadFromDOM();
|
|
});
|
|
} else {
|
|
sharedConfig.loadFromDOM();
|
|
}
|
|
}
|
|
|