experiments in a post-browser web
at main 50 lines 1.2 kB view raw
1<!DOCTYPE html> 2<html> 3<head> 4 <meta charset="utf-8"> 5 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';"> 6 <title>Groups Extension</title> 7</head> 8<body> 9<script type="module"> 10 import extension from './background.js'; 11 12 const api = window.app; 13 const extId = extension.id; 14 15 console.log(`[ext:${extId}] background.html loaded`); 16 17 // Signal ready to main process 18 api.publish('ext:ready', { 19 id: extId, 20 manifest: { 21 id: extension.id, 22 labels: extension.labels, 23 version: '1.0.0' 24 } 25 }, api.scopes.SYSTEM); 26 27 // Initialize extension 28 if (extension.init) { 29 console.log(`[ext:${extId}] calling init()`); 30 extension.init(); 31 } 32 33 // Handle shutdown request from main process 34 api.subscribe('app:shutdown', () => { 35 console.log(`[ext:${extId}] received shutdown`); 36 if (extension.uninit) { 37 extension.uninit(); 38 } 39 }, api.scopes.SYSTEM); 40 41 // Handle extension-specific shutdown 42 api.subscribe(`ext:${extId}:shutdown`, () => { 43 console.log(`[ext:${extId}] received extension shutdown`); 44 if (extension.uninit) { 45 extension.uninit(); 46 } 47 }, api.scopes.SYSTEM); 48</script> 49</body> 50</html>