const fs = require('fs'); const path = require('path'); const APPS = [ 'com.palm.app.settings', 'com.webos.app.notificationcenter', 'com.webos.app.gameoptimizer', ]; const outDir = path.join(__dirname, 'dist'); fs.mkdirSync(outDir, { recursive: true }); for (const app of APPS) { const srcPath = path.join(__dirname, app + '.js'); if (!fs.existsSync(srcPath)) { console.log('SKIP:', app, '(source not found)'); continue; } const code = fs.readFileSync(srcPath, 'utf8'); let minified = code .replace(/\/\/[^\n]*/g, '') .replace(/\/\*[\s\S]*?\*\//g, '') .replace(/\n\s*\n/g, '\n') .replace(/^\s+/gm, '') .replace(/\n/g, '') .replace(/ +/g, ' '); console.log(app + ':'); console.log(' Original:', code.length, 'bytes'); console.log(' Minified:', minified.length, 'bytes'); const minPath = path.join(outDir, app + '.min.js'); fs.writeFileSync(minPath, minified); const b64 = Buffer.from(minified).toString('base64'); const b64Path = path.join(outDir, app + '.b64'); fs.writeFileSync(b64Path, b64); console.log(' Base64: ', b64.length, 'bytes'); }