git ssb

16+

Dominic / patchbay



Commit dc4014e6727a0761732bfc7e6b501c3776ec362a

land ho!

mixmix committed on 3/14/2019, 3:52:24 AM
Parent: f98b0b4d264cb7ab22dbfcdea8353d07fde365be

Files changed

config.jschanged
index.jschanged
package-lock.jsonchanged
package.jsonchanged
ahoy.jsadded
config.jsView
@@ -17,11 +17,14 @@
1717 })
1818
1919 config = addSockets(config)
2020 config = fixLocalhost(config)
21- // config = pubHopSettings(config)
22- // config = torOnly(config)
2321
22+ if (false) { // TODO figure out how to check if this is being run in/ out of electron
23+ config = pubHopSettings(config)
24+ config = torOnly(config)
25+ }
26+
2427 return config
2528 })
2629 }
2730
index.jsView
@@ -3,117 +3,103 @@
33 var electron = require('electron')
44 var Menu = electron.Menu
55 var Path = require('path')
66
7-const ahoy = require('ssb-ahoy')
8-const config = require('./config').create().config.sync.load()
9-const plugins = [
10- 'ssb-server/plugins/unix-socket',
11- 'ssb-server/plugins/no-auth',
12- 'ssb-private',
13- 'ssb-backlinks',
14- 'ssb-about',
15- 'ssb-query',
16- 'ssb-suggest'
17-]
7+var state = {
8+ windows: {},
9+ quitting: false
10+}
1811
19-ahoy(config, plugins, () => {
20- var state = {
21- windows: {},
22- quitting: false
23- }
12+console.log('STARTING patchbay')
13+electron.app.on('ready', () => {
14+ startMenus()
2415
25- console.log('STARTING electron (patchbay)')
26- // mix: disable the on-ready because electron is already ready from ssb-ahoy...
27- // electron.app.on('ready', () => {
28- startMenus()
16+ startBackgroundProcess()
17+ // wait until server has started before opening main window
18+ electron.ipcMain.once('server-started', function (ev, config) {
19+ openMainWindow()
20+ })
2921
30- startBackgroundProcess()
31- // wait until server has started before opening main window
32- electron.ipcMain.once('server-started', function (ev, config) {
33- openMainWindow()
34- })
22+ electron.app.on('before-quit', function () {
23+ state.quitting = true
24+ })
3525
36- electron.app.on('before-quit', function () {
37- state.quitting = true
38- })
26+ electron.app.on('activate', function (e) {
27+ // reopen the app when dock icon clicked on macOS
28+ if (state.windows.main) {
29+ state.windows.main.show()
30+ }
31+ })
3932
40- electron.app.on('activate', function (e) {
41- // reopen the app when dock icon clicked on macOS
42- if (state.windows.main) {
43- state.windows.main.show()
44- }
45- })
33+ // allow inspecting of background process
34+ electron.ipcMain.on('open-background-devtools', function (ev, config) {
35+ if (state.windows.background) {
36+ state.windows.background.webContents.openDevTools({ detach: true })
37+ }
38+ })
39+})
4640
47- // allow inspecting of background process
48- electron.ipcMain.on('open-background-devtools', function (ev, config) {
49- if (state.windows.background) {
50- state.windows.background.webContents.openDevTools({ detach: true })
51- }
52- })
53- // })
41+function startBackgroundProcess () {
42+ if (state.windows.background) return
5443
55- function startBackgroundProcess () {
56- if (state.windows.background) return
44+ state.windows.background = openWindow(Path.join(__dirname, 'server.js'), {
45+ title: 'patchbay-server',
46+ show: false,
47+ connect: false,
48+ width: 150,
49+ height: 150,
50+ center: true,
51+ fullscreen: false,
52+ fullscreenable: false,
53+ maximizable: false,
54+ minimizable: false,
55+ resizable: false,
56+ skipTaskbar: true,
57+ useContentSize: true
58+ })
59+}
5760
58- state.windows.background = openWindow(Path.join(__dirname, 'server.js'), {
59- title: 'patchbay-server',
60- show: false,
61- connect: false,
62- width: 150,
63- height: 150,
64- center: true,
65- fullscreen: false,
66- fullscreenable: false,
67- maximizable: false,
68- minimizable: false,
69- resizable: false,
70- skipTaskbar: true,
71- useContentSize: true
72- })
73- }
61+function openMainWindow () {
62+ if (state.windows.main) return
7463
75- function openMainWindow () {
76- if (state.windows.main) return
64+ var windowState = WindowState({
65+ defaultWidth: 1024,
66+ defaultHeight: 768
67+ })
68+ state.windows.main = openWindow(Path.join(__dirname, 'main.js'), {
69+ title: 'Patchbay',
70+ show: true,
7771
78- var windowState = WindowState({
79- defaultWidth: 1024,
80- defaultHeight: 768
81- })
82- state.windows.main = openWindow(Path.join(__dirname, 'main.js'), {
83- title: 'Patchbay',
84- show: true,
72+ x: windowState.x,
73+ y: windowState.y,
74+ minWidth: 800,
75+ width: windowState.width,
76+ height: windowState.height,
77+ autoHideMenuBar: true,
78+ frame: !process.env.FRAME,
79+ // titleBarStyle: 'hidden',
80+ backgroundColor: '#FFF',
81+ icon: './assets/icon.png'
82+ })
83+ windowState.manage(state.windows.main)
84+ state.windows.main.setSheetOffset(40)
85+ state.windows.main.on('close', function (e) {
86+ if (!state.quitting && process.platform === 'darwin') {
87+ e.preventDefault()
88+ state.windows.main.hide()
89+ }
90+ })
91+ state.windows.main.on('closed', function () {
92+ state.windows.main = null
93+ if (process.platform !== 'darwin') electron.app.quit()
94+ })
95+}
8596
86- x: windowState.x,
87- y: windowState.y,
88- minWidth: 800,
89- width: windowState.width,
90- height: windowState.height,
91- autoHideMenuBar: true,
92- frame: !process.env.FRAME,
93- // titleBarStyle: 'hidden',
94- backgroundColor: '#FFF',
95- icon: './assets/icon.png'
96- })
97- windowState.manage(state.windows.main)
98- state.windows.main.setSheetOffset(40)
99- state.windows.main.on('close', function (e) {
100- if (!state.quitting && process.platform === 'darwin') {
101- e.preventDefault()
102- state.windows.main.hide()
103- }
104- })
105- state.windows.main.on('closed', function () {
106- state.windows.main = null
107- if (process.platform !== 'darwin') electron.app.quit()
108- })
109- }
97+function openWindow (path, opts) {
98+ var window = new electron.BrowserWindow(opts)
11099
111- function openWindow (path, opts) {
112- var window = new electron.BrowserWindow(opts)
113-
114- window.webContents.on('dom-ready', function () {
115- window.webContents.executeJavaScript(`
100+ window.webContents.on('dom-ready', function () {
101+ window.webContents.executeJavaScript(`
116102 var electron = require('electron')
117103 var h = require('mutant/h')
118104 electron.webFrame.setVisualZoomLevelLimits(1, 1)
119105 var title = ${JSON.stringify(opts.title || 'Patchbay')}
@@ -121,67 +107,66 @@
121107 h('title', title)
122108 )
123109 require(${JSON.stringify(path)})
124110 `) // NOTE tried process(electron)
125- })
111+ })
126112
127- window.webContents.on('will-navigate', function (e, url) {
128- e.preventDefault()
129- electron.shell.openExternal(url)
130- })
113+ window.webContents.on('will-navigate', function (e, url) {
114+ e.preventDefault()
115+ electron.shell.openExternal(url)
116+ })
131117
132- window.webContents.on('new-window', function (e, url) {
133- e.preventDefault()
134- electron.shell.openExternal(url)
135- })
118+ window.webContents.on('new-window', function (e, url) {
119+ e.preventDefault()
120+ electron.shell.openExternal(url)
121+ })
136122
137- window.loadURL('file://' + Path.join(__dirname, 'assets', 'base.html'))
138- return window
139- }
123+ window.loadURL('file://' + Path.join(__dirname, 'assets', 'base.html'))
124+ return window
125+}
140126
141- function startMenus () {
142- var menu = defaultMenu(electron.app, electron.shell)
143- var view = menu.find(x => x.label === 'View')
144- view.submenu = [
145- { role: 'reload' },
146- { role: 'toggledevtools' },
147- { type: 'separator' },
148- { role: 'resetzoom' },
149- { role: 'zoomin' },
150- { role: 'zoomout' },
151- { type: 'separator' },
152- { role: 'togglefullscreen' }
153- ]
154- var win = menu.find(x => x.label === 'Window')
155- win.submenu = [
156- { role: 'minimize' },
157- { role: 'zoom' },
158- { role: 'close', label: 'Close Window', accelerator: 'CmdOrCtrl+Shift+W' },
159- { type: 'separator' },
160- {
161- label: 'Close Tab',
162- accelerator: 'CmdOrCtrl+W',
163- click () {
164- state.windows.main.webContents.send('closeTab')
165- }
166- },
167- {
168- label: 'Select Next Tab',
169- accelerator: 'CmdOrCtrl+Shift+]',
170- click () {
171- state.windows.main.webContents.send('nextTab')
172- }
173- },
174- {
175- label: 'Select Previous Tab',
176- accelerator: 'CmdOrCtrl+Shift+[',
177- click () {
178- state.windows.main.webContents.send('previousTab')
179- }
180- },
181- { type: 'separator' },
182- { role: 'front' }
183- ]
127+function startMenus () {
128+ var menu = defaultMenu(electron.app, electron.shell)
129+ var view = menu.find(x => x.label === 'View')
130+ view.submenu = [
131+ { role: 'reload' },
132+ { role: 'toggledevtools' },
133+ { type: 'separator' },
134+ { role: 'resetzoom' },
135+ { role: 'zoomin' },
136+ { role: 'zoomout' },
137+ { type: 'separator' },
138+ { role: 'togglefullscreen' }
139+ ]
140+ var win = menu.find(x => x.label === 'Window')
141+ win.submenu = [
142+ { role: 'minimize' },
143+ { role: 'zoom' },
144+ { role: 'close', label: 'Close Window', accelerator: 'CmdOrCtrl+Shift+W' },
145+ { type: 'separator' },
146+ {
147+ label: 'Close Tab',
148+ accelerator: 'CmdOrCtrl+W',
149+ click () {
150+ state.windows.main.webContents.send('closeTab')
151+ }
152+ },
153+ {
154+ label: 'Select Next Tab',
155+ accelerator: 'CmdOrCtrl+Shift+]',
156+ click () {
157+ state.windows.main.webContents.send('nextTab')
158+ }
159+ },
160+ {
161+ label: 'Select Previous Tab',
162+ accelerator: 'CmdOrCtrl+Shift+[',
163+ click () {
164+ state.windows.main.webContents.send('previousTab')
165+ }
166+ },
167+ { type: 'separator' },
168+ { role: 'front' }
169+ ]
184170
185- Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
186- }
187-})
171+ Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
172+}
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 644605 bytes
New file size: 644233 bytes
package.jsonView
@@ -5,9 +5,9 @@
55 "main": "index.js",
66 "scripts": {
77 "lint": "standard --fix",
88 "rebuild": "cross-script npm rebuild --runtime=electron \"--target=$(electron -v)\" \"--abi=$(electron --abi)\" --disturl=https://atom.io/download/atom-shell",
9- "start": "electron index.js -- --title patchbay",
9+ "start": "electron ahoy.js && electron index.js -- --title patchbay",
1010 "start-frameless": "FRAME=false npm start",
1111 "dev": "echo 'run your own sbot!' && electro main.js -- --title patchbay --icon ./assets/icon.png",
1212 "postinstall": "npm run rebuild",
1313 "test": "standard"
@@ -88,16 +88,16 @@
8888 "scuttle-blog": "^1.0.1",
8989 "scuttle-thread": "^1.0.1",
9090 "setimmediate": "^1.0.5",
9191 "ssb-about": "^2.0.0",
92- "ssb-ahoy": "0.0.1",
92+ "ssb-ahoy": "^0.2.0",
9393 "ssb-backlinks": "^0.7.3",
9494 "ssb-blob-files": "^1.1.3",
9595 "ssb-blobs": "^1.1.12",
9696 "ssb-chess-db": "^1.0.5",
9797 "ssb-chess-mithril": "1.0.10",
9898 "ssb-config": "^3.2.3",
99- "ssb-ebt": "^5.3.11",
99+ "ssb-ebt": "^5.4.3",
100100 "ssb-friend-pub": "^1.0.4",
101101 "ssb-friends": "^3.1.12",
102102 "ssb-gossip": "^1.0.5",
103103 "ssb-invite": "^2.0.3",
ahoy.jsView
@@ -1,0 +1,21 @@
1+const ahoy = require('ssb-ahoy')
2+
3+const config = require('./config').create().config.sync.load()
4+
5+const plugins = [
6+ 'ssb-server/plugins/unix-socket',
7+ 'ssb-server/plugins/no-auth',
8+ 'ssb-about',
9+ 'ssb-backlinks',
10+ 'ssb-private',
11+ 'ssb-query',
12+ 'ssb-suggest',
13+
14+ 'ssb-chess-db',
15+ 'ssb-invite',
16+ 'ssb-friend-pub',
17+ 'ssb-meme',
18+ 'ssb-search'
19+]
20+
21+ahoy({ config, plugins, appPath: __dirname })

Built with git-ssb-web