Monorepo for Aesthetic.Computer
aesthetic.computer
1#!/usr/bin/env node
2// kidlisp-dev.mjs - Watch console logs from kidlisp.com in Simple Browser
3
4import { Web } from './web.mjs';
5
6const web = new Web({ verbose: true });
7
8async function main() {
9 console.log('🔍 Looking for kidlisp.com tab...');
10
11 try {
12 await web.connect('kidlisp.com');
13 console.log('✅ Connected to kidlisp.com\n');
14
15 // Enable console logging
16 await web.send('Runtime.enable');
17 await web.send('Console.enable');
18 await web.send('Log.enable');
19
20 // Listen for console messages
21 web.ws.on('message', data => {
22 try {
23 const msg = JSON.parse(data);
24
25 // Runtime.consoleAPICalled - main console.log etc
26 if (msg.method === 'Runtime.consoleAPICalled') {
27 const { type, args } = msg.params;
28 const values = args.map(a => {
29 if (a.type === 'string') return a.value;
30 if (a.type === 'number') return a.value;
31 if (a.type === 'boolean') return a.value;
32 if (a.type === 'undefined') return 'undefined';
33 if (a.type === 'object' && a.preview) {
34 return JSON.stringify(a.preview.properties?.reduce((o, p) => {
35 o[p.name] = p.value;
36 return o;
37 }, {}) || a.preview);
38 }
39 return a.description || a.type;
40 });
41
42 const icon = {
43 log: '📝',
44 warn: '⚠️',
45 error: '❌',
46 info: 'ℹ️',
47 debug: '🐛',
48 }[type] || '📝';
49
50 console.log(`${icon} [${type}]`, values.join(' '));
51 }
52
53 // Runtime.exceptionThrown - uncaught exceptions
54 if (msg.method === 'Runtime.exceptionThrown') {
55 const { exceptionDetails } = msg.params;
56 console.log('💥 [exception]', exceptionDetails.text || exceptionDetails.exception?.description);
57 }
58
59 // Log.entryAdded - browser/network logs
60 if (msg.method === 'Log.entryAdded') {
61 const { entry } = msg.params;
62 console.log(`🌐 [${entry.level}]`, entry.text, entry.url || '');
63 }
64
65 } catch (e) { /* ignore parse errors */ }
66 });
67
68 console.log('📡 Watching console output... (Ctrl+C to stop)\n');
69 console.log('─'.repeat(60) + '\n');
70
71 // Keep alive
72 await new Promise(() => {});
73
74 } catch (e) {
75 console.error('❌ Error:', e.message);
76 console.log('\n💡 Make sure:');
77 console.log(' 1. CDP tunnel is running: ac-cdp-tunnel');
78 console.log(' 2. kidlisp.com is open in VS Code Simple Browser');
79 process.exit(1);
80 }
81}
82
83main();