| … | … | @@ -8,6 +8,9 @@ |
| 8 | 8 | require('bare-node-runtime/global') |
| 9 | 9 | require('bare-node-runtime/imports') |
| 10 | 10 | |
| 11 | const fs = require('bare-fs') |
| 12 | const path = require('bare-path') |
| 13 | |
| 11 | 14 | const Runtime = require('pear-electron') |
| 12 | 15 | const Bridge = require('pear-bridge') |
| 13 | 16 | const http = require('bare-http1') |
| … | … | @@ -15,6 +18,25 @@ const http = require('bare-http1') |
| 15 | 18 | // Import the wallet server |
| 16 | 19 | const { startServer } = require('./wallet-server.cjs') |
| 17 | 20 | |
| 21 | // Initialize pear-runtime for P2P OTA updates (non-blocking) |
| 22 | try { |
| 23 | const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8')) |
| 24 | if (pkg.upgrade) { |
| 25 | import('pear-runtime').then(({ default: PearRuntime }) => { |
| 26 | const os = require('bare-os') |
| 27 | const p = os.platform() |
| 28 | const name = 'hyper-wallet-desktop' |
| 29 | let dir |
| 30 | if (p === 'darwin') dir = path.join(os.homedir(), 'Library', 'Application Support', name) |
| 31 | else if (p === 'win32') dir = path.join(os.homedir(), 'AppData', 'Roaming', name) |
| 32 | else dir = path.join(os.homedir(), '.config', name) |
| 33 | |
| 34 | const runtime = new PearRuntime({ dir, app: __dirname, version: pkg.version || '1.1.0', upgrade: pkg.upgrade }) |
| 35 | runtime.on('updated', () => { runtime.applyUpdate().catch(() => {}) }) |
| 36 | }).catch(() => {}) |
| 37 | } |
| 38 | } catch {} |
| 39 | |
| 18 | 40 | async function main() { |
| 19 | 41 | console.log('🚀 Hyper Wallet Desktop starting...') |
| 20 | 42 | |