class MyModule { constructor() { this.commands = {}; this.terminal = null; this.userData = {}; try { const d = localStorage.getItem('webx11_my_data'); if (d) this.userData = JSON.parse(d); } catch (e) {} } getHelpInfo() { return { 'my': 'my — Show module info and stored key count', 'my-set': 'my-set — Store a key-value pair', 'my-get': 'my-get — Retrieve a stored value by key', 'my-list': 'my-list — List all stored keys', 'my-export': 'my-export — Export all stored data as JSON', 'my-import': 'my-import — Import data from JSON string', 'my-clear': 'my-clear — Clear all stored data' }; } _save() { try { localStorage.setItem('webx11_my_data', JSON.stringify(this.userData)); } catch (e) {} } registerCommands() { this.commands['my'] = () => this.showInfo(); this.commands['my-set'] = (args) => this.setData(args); this.commands['my-get'] = (args) => this.getData(args); this.commands['my-list'] = () => this.listData(); this.commands['my-export'] = () => this.exportData(); this.commands['my-import'] = (args) => this.importData(args); this.commands['my-clear'] = () => this.clearData(); } showInfo() { this.terminal.print("=== My Module v2.0 ===", "info"); this.terminal.print("Personal workspace for custom commands"); this.terminal.print(`Stored keys: ${Object.keys(this.userData).length}`, "success"); } setData(args) { if (args.length < 2) { this.terminal.print("Usage: my-set ", "warning"); return; } const key = args[0], value = args.slice(1).join(' '); this.userData[key] = { value, timestamp: new Date().toISOString() }; this._save(); this.terminal.print(`Saved: ${key} = ${value}`, "success"); } getData(args) { if (!args[0]) { this.terminal.print("Usage: my-get ", "warning"); return; } if (this.userData[args[0]]) { this.terminal.print(`${args[0]}: ${this.userData[args[0]].value}`, "info"); } else { this.terminal.print(`Key '${args[0]}' not found`, "error"); } } listData() { const keys = Object.keys(this.userData); if (!keys.length) return this.terminal.print('No data stored.', 'info'); this.terminal.print('=== My Data ===', 'info'); keys.forEach(k => { const v = this.userData[k]; const type = typeof v.value; this.terminal.print(` ${k} (${type}): ${String(v.value).substring(0, 40)}`); }); } exportData() { this.terminal.print(JSON.stringify(this.userData, null, 2)); } importData(args) { if (!args[0]) return this.terminal.print('Usage: my-import ', 'warning'); try { const data = JSON.parse(args.join(' ')); Object.assign(this.userData, data); this._save(); this.terminal.print(`Imported ${Object.keys(data).length} keys`, 'success'); } catch (e) { this.terminal.print('Invalid JSON: ' + e.message, 'error'); } } clearData() { this.userData = {}; localStorage.removeItem('webx11_my_data'); this.terminal.print("Personal data cleared", "success"); } }