Files: 2c11a9dc2541a07740f246f2ab4dd2d8e0b679fb / assets / base.html
1661 bytesRaw
1 | |
2 | <html> |
3 | <head></head> |
4 | <body> |
5 | <script> |
6 | // redirect console to main process |
7 | var electron = require('electron') |
8 | var localLog = console.log |
9 | var localError = console.error |
10 | var remoteLog = function (o) { |
11 | const payload = JSON.parse(JSON.stringify(o, null, 2)) |
12 | electron.ipcRenderer.invoke('consoleLog', `${payload}`) |
13 | } |
14 | var remoteError = function (o) { |
15 | const payload = JSON.parse(JSON.stringify(o, null, 2)) |
16 | electron.ipcRenderer.invoke('consoleError', `${payload}`) |
17 | } |
18 | |
19 | console.log = function (...args) { |
20 | localLog.apply(console, args) |
21 | remoteLog(...args) |
22 | } |
23 | |
24 | console.error = function (...args) { |
25 | localError.apply(console, args) |
26 | remoteError(...args) |
27 | } |
28 | |
29 | process.exit = function(status) {electron.ipcRenderer.sendSync('exit')} |
30 | // redirect errors to stderr |
31 | window.addEventListener('error', function (e) { |
32 | e.preventDefault() |
33 | console.log(e) |
34 | console.error(e.error?.stack || 'Uncaught ' + e.error) |
35 | }) |
36 | |
37 | electron.ipcRenderer.once('window-setup', (event, msg) => { |
38 | const { |
39 | config, |
40 | rootPath, |
41 | data, |
42 | title, |
43 | } = msg |
44 | var rootView = require(rootPath) |
45 | var h = require('mutant/h') |
46 | |
47 | electron.webFrame.setVisualZoomLevelLimits(1, 1) |
48 | |
49 | document.documentElement.querySelector('head').appendChild( |
50 | h('title', title) |
51 | ) |
52 | |
53 | document.documentElement.replaceChild(h('body', [ |
54 | rootView(config, data) |
55 | ]), document.body) |
56 | }) |
57 | |
58 | </script> |
59 | </body> |
60 | </html> |
61 |
Built with git-ssb-web