git ssb

1+

Daan Patchwork / patchwork



Commit a40d71e4d68bf04bb03d8040fbf7614880514dc8

Do window content loading without remote

We were literally sending over a bunch of javascript code, and using
remote to execute it. Now it's done via a handler.
Daan Wynen committed on 3/6/2021, 10:11:18 PM
Parent: 809d3903e0c5c12da6a0c16b9bee86f7c03df6e6

Files changed

assets/base.htmlchanged
lib/window.jschanged
assets/base.htmlView
@@ -32,7 +32,29 @@
3232 e.preventDefault()
3333 console.log(e)
3434 console.error(e.error?.stack || 'Uncaught ' + e.error)
3535 })
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 +
3658 </script>
3759 </body>
3860 </html>
lib/window.jsView
@@ -21,27 +21,14 @@
2121 })
2222 electron.ipcMain.on('ready-to-show', handleReadyToShow)
2323
2424 window.webContents.on('dom-ready', function () {
25- window.webContents.executeJavaScript(`
26- var electron = require('electron')
27- var rootView = require(${JSON.stringify(path)})
28- var h = require('mutant/h')
29-
30- electron.webFrame.setVisualZoomLevelLimits(1, 1)
31-
32- var config = ${JSON.stringify(config)}
33- var data = ${JSON.stringify(opts.data)}
34- var title = ${JSON.stringify(opts.title || 'Patchwork')}
35-
36- document.documentElement.querySelector('head').appendChild(
37- h('title', title)
38- )
39-
40- document.documentElement.replaceChild(h('body', [
41- rootView(config, data)
42- ]), document.body)
43- `)
25 + window.webContents.send('window-setup', {
26 + rootPath: path,
27 + config: config,
28 + data: opts.data || '',
29 + title: opts.title || 'Patchwork',
30 + })
4431 })
4532
4633 // setTimeout(function () {
4734 // window.show()

Built with git-ssb-web