📜
core_copy.js
Back
📝 Javascript ⚡ Executable Ctrl+S: Save • Ctrl+R: Run • Ctrl+F: Find
// /core/js/core.js // Core framework initialization and storage bridge (function(){ // --- AppCore: main initializer --- window.AppCore = { async init(config = {}) { console.log("[AppCore] Initializing with config:", config); // Initialize AppStorage (file system logic) await AppStorage.init(config.storage || "sftp"); // Optional: Overlay or Editor activation if (config.overlay && window.AppOverlay) { console.log("[AppCore] Overlay enabled"); } console.log("[AppCore] Initialization complete"); return true; } }; // --- AppStorage: abstraction over storage drivers --- window.AppStorage = { driver: null, async init(storageType = "sftp") { try { const { FileDrivers } = await import("/core/js/drivers_files/index.js"); const DriverClass = FileDrivers[storageType]; if (!DriverClass) throw new Error(`Unknown storage driver: ${storageType}`); this.driver = new DriverClass(); console.log(`[AppStorage] Using driver: ${storageType}`); } catch (err) { console.error("[AppStorage] Failed to initialize:", err); } }, // --- Core file operations (universal) --- async create(path, content = "") { if (!this.driver) throw new Error("Storage driver not initialized"); return await this.driver.create(path, content); }, async list(path = "/") { if (!this.driver || !this.driver.list) throw new Error("Driver missing list()"); return await this.driver.list(path); }, async delete(path) { if (!this.driver || !this.driver.trash) throw new Error("Driver missing trash()"); return await this.driver.trash(path); } }; })();