mirror of https://codeberg.org/pzp/zooboard.git
Use all pzp named modules
This commit is contained in:
parent
0eb0b354a4
commit
120fa33c77
49
main.js
49
main.js
|
@ -2,7 +2,7 @@ const { app, BrowserWindow, ipcMain, shell, clipboard } = require('electron')
|
||||||
const Path = require('node:path')
|
const Path = require('node:path')
|
||||||
const URL = require('node:url')
|
const URL = require('node:url')
|
||||||
const p = require('node:util').promisify
|
const p = require('node:util').promisify
|
||||||
const Keypair = require('ppppp-keypair')
|
const Keypair = require('pzp-keypair')
|
||||||
const awaitable = require('pull-awaitable')
|
const awaitable = require('pull-awaitable')
|
||||||
|
|
||||||
// WARNING monkey patch! -------------------------------------------------------
|
// WARNING monkey patch! -------------------------------------------------------
|
||||||
|
@ -20,7 +20,7 @@ na.sodium_free = function sodium_free_monkey_patched() {}
|
||||||
|
|
||||||
process.env.ZOOBOARD_DATA ??= Path.join(app.getPath('appData'), 'zooboard')
|
process.env.ZOOBOARD_DATA ??= Path.join(app.getPath('appData'), 'zooboard')
|
||||||
app.setPath('userData', process.env.ZOOBOARD_DATA)
|
app.setPath('userData', process.env.ZOOBOARD_DATA)
|
||||||
const path = process.env.PZP_DIR ?? Path.resolve(app.getPath('userData'), 'ppppp')
|
const path = process.env.PZP_DIR ?? Path.resolve(app.getPath('userData'), 'pzp')
|
||||||
|
|
||||||
const keypairPath = Path.join(path, 'keypair.json')
|
const keypairPath = Path.join(path, 'keypair.json')
|
||||||
const keypair = Keypair.loadOrCreateSync(keypairPath)
|
const keypair = Keypair.loadOrCreateSync(keypairPath)
|
||||||
|
@ -31,20 +31,20 @@ let globalAccountName = null
|
||||||
const peer = require('secret-stack/bare')()
|
const peer = require('secret-stack/bare')()
|
||||||
.use(require('secret-stack/plugins/net'))
|
.use(require('secret-stack/plugins/net'))
|
||||||
.use(require('secret-handshake-ext/secret-stack'))
|
.use(require('secret-handshake-ext/secret-stack'))
|
||||||
.use(require('ppppp-net'))
|
.use(require('pzp-net'))
|
||||||
.use(require('ppppp-db'))
|
.use(require('pzp-db'))
|
||||||
.use(require('ppppp-set'))
|
.use(require('pzp-set'))
|
||||||
.use(require('ppppp-dict'))
|
.use(require('pzp-dict'))
|
||||||
.use(require('ppppp-goals'))
|
.use(require('pzp-goals'))
|
||||||
.use(require('ppppp-sync'))
|
.use(require('pzp-sync'))
|
||||||
.use(require('ppppp-gc'))
|
.use(require('pzp-gc'))
|
||||||
.use(require('ppppp-conductor'))
|
.use(require('pzp-conductor'))
|
||||||
.use(require('ppppp-hub-client'))
|
.use(require('pzp-hub-client'))
|
||||||
.use(require('ppppp-promise'))
|
.use(require('pzp-promise'))
|
||||||
.use(require('ppppp-invite'))
|
.use(require('pzp-invite'))
|
||||||
.call(null, {
|
.call(null, {
|
||||||
shse: {
|
shse: {
|
||||||
caps: require('ppppp-caps'),
|
caps: require('pzp-caps'),
|
||||||
},
|
},
|
||||||
global: {
|
global: {
|
||||||
keypair,
|
keypair,
|
||||||
|
@ -108,7 +108,7 @@ async function loadAccount() {
|
||||||
await p(peer.dict.load)(id)
|
await p(peer.dict.load)(id)
|
||||||
|
|
||||||
// Read profile
|
// Read profile
|
||||||
const profile = peer.dict.read(id, 'profile')
|
const profile = await p(peer.dict.read)(id, 'profile')
|
||||||
const name = profile?.name ?? ''
|
const name = profile?.name ?? ''
|
||||||
globalAccountName = name
|
globalAccountName = name
|
||||||
|
|
||||||
|
@ -210,7 +210,8 @@ async function subscribeToReadElements() {
|
||||||
['profile@dict', 'zooboardElements@newest-100', 'hubs@set'],
|
['profile@dict', 'zooboardElements@newest-100', 'hubs@set'],
|
||||||
['profile@dict', 'zooboardElements@newest-100'],
|
['profile@dict', 'zooboardElements@newest-100'],
|
||||||
],
|
],
|
||||||
64_000
|
64_000,
|
||||||
|
() => {}
|
||||||
)
|
)
|
||||||
}, 32)
|
}, 32)
|
||||||
}
|
}
|
||||||
|
@ -225,15 +226,15 @@ async function subscribeToConnections() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handlePPPPPUri(ev, uri) {
|
async function handlePZPUri(ev, uri) {
|
||||||
if (!globalAccountID) {
|
if (!globalAccountID) {
|
||||||
setTimeout(handlePPPPPUri, 100, null, uri)
|
setTimeout(handlePZPUri, 100, null, uri)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (uri.startsWith("http:") || uri.startsWith("https://")) {
|
if (uri.startsWith("http:") || uri.startsWith("https://")) {
|
||||||
uri = decodeURIComponent(uri.split('/invite#')[1])
|
uri = decodeURIComponent(uri.split('/invite#')[1])
|
||||||
}
|
}
|
||||||
if (!uri.startsWith('ppppp://')) return console.log('Not a ppppp invite URI', uri)
|
if (!uri.startsWith('pzp://')) return console.log('Not a pzp invite URI', uri)
|
||||||
const commands = peer.invite.parse(uri)
|
const commands = peer.invite.parse(uri)
|
||||||
for (const command of commands) {
|
for (const command of commands) {
|
||||||
console.log('Executing command', JSON.stringify(command))
|
console.log('Executing command', JSON.stringify(command))
|
||||||
|
@ -274,12 +275,12 @@ async function handlePPPPPUri(ev, uri) {
|
||||||
|
|
||||||
if (process.defaultApp) {
|
if (process.defaultApp) {
|
||||||
if (process.argv.length >= 2) {
|
if (process.argv.length >= 2) {
|
||||||
app.setAsDefaultProtocolClient('ppppp', process.execPath, [
|
app.setAsDefaultProtocolClient('pzp', process.execPath, [
|
||||||
Path.resolve(process.argv[1]),
|
Path.resolve(process.argv[1]),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.setAsDefaultProtocolClient('ppppp')
|
app.setAsDefaultProtocolClient('pzp')
|
||||||
}
|
}
|
||||||
|
|
||||||
//const hasLock = app.requestSingleInstanceLock()
|
//const hasLock = app.requestSingleInstanceLock()
|
||||||
|
@ -292,7 +293,7 @@ if (process.defaultApp) {
|
||||||
// if (mainWindow.isMinimized()) mainWindow.restore()
|
// if (mainWindow.isMinimized()) mainWindow.restore()
|
||||||
// mainWindow.focus()
|
// mainWindow.focus()
|
||||||
// if (argv.length > 1) {
|
// if (argv.length > 1) {
|
||||||
// handlePPPPPUri(null, argv[argv.length - 1])
|
// handlePZPUri(null, argv[argv.length - 1])
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
@ -303,12 +304,12 @@ if (process.defaultApp) {
|
||||||
ipcMain.handle('createInvite', createInvite)
|
ipcMain.handle('createInvite', createInvite)
|
||||||
ipcMain.handle('copyToClipboard', copyToClipboard)
|
ipcMain.handle('copyToClipboard', copyToClipboard)
|
||||||
ipcMain.handle('writeElements', writeElements)
|
ipcMain.handle('writeElements', writeElements)
|
||||||
ipcMain.handle('consumeInvite', handlePPPPPUri)
|
ipcMain.handle('consumeInvite', handlePZPUri)
|
||||||
ipcMain.handle('subscribeToReadElements', subscribeToReadElements)
|
ipcMain.handle('subscribeToReadElements', subscribeToReadElements)
|
||||||
ipcMain.handle('subscribeToConnections', subscribeToConnections)
|
ipcMain.handle('subscribeToConnections', subscribeToConnections)
|
||||||
createWindow()
|
createWindow()
|
||||||
if (process.argv.length > 1) {
|
if (process.argv.length > 1) {
|
||||||
handlePPPPPUri(null, process.argv[process.argv.length - 1])
|
handlePZPUri(null, process.argv[process.argv.length - 1])
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
|
@ -23,17 +23,17 @@
|
||||||
"debounce": "2.0",
|
"debounce": "2.0",
|
||||||
"pzp-caps": "^1.0.0",
|
"pzp-caps": "^1.0.0",
|
||||||
"pzp-db": "^1.0.1",
|
"pzp-db": "^1.0.1",
|
||||||
"ppppp-dict": "github:staltz/ppppp-dict#c40d51be6cb96982b4fe691a292b3c12b6f49a36",
|
"pzp-dict": "^1.0.0",
|
||||||
"ppppp-gc": "github:staltz/ppppp-gc#9075f983d8fa9a13c18a63451a78bed5912e78d0",
|
"pzp-gc": "^1.0.0",
|
||||||
"ppppp-goals": "github:staltz/ppppp-goals#46a8d8889c668cf291607963fd7301f21aa634b5",
|
"pzp-goals": "^1.0.0",
|
||||||
"pzp-keypair": "^1.0.0",
|
"pzp-keypair": "^1.0.0",
|
||||||
"pzp-set": "^1.0.0",
|
"pzp-set": "^1.0.0",
|
||||||
"ppppp-sync": "github:staltz/ppppp-sync#93f00dbd04267f472fbf2f3ae63495092d3a921e",
|
"pzp-sync": "^1.0.0",
|
||||||
"ppppp-conductor": "github:staltz/ppppp-conductor#8ebeb0fb12de766fac21f8292121307cf7d1bd1e",
|
"pzp-conductor": "^1.0.0",
|
||||||
"ppppp-hub-client": "github:staltz/ppppp-hub-client#6dec9c25291155151051e28b048560038c47ea3f",
|
"pzp-hub-client": "^1.0.0",
|
||||||
"ppppp-invite": "github:staltz/ppppp-invite#745eea3de0b98a4896face25cb31288c9b0c9ed2",
|
"pzp-invite": "^1.0.0",
|
||||||
"ppppp-net": "github:staltz/ppppp-net#5b79b9566bb425e27169f90544bc54b8b418b87c",
|
"pzp-net": "^1.0.0",
|
||||||
"ppppp-promise": "github:staltz/ppppp-promise#e4f559178c35b71fb96ed0029d3d9b839c7d64ff",
|
"pzp-promise": "^1.0.0",
|
||||||
"pull-awaitable": "1.0.0",
|
"pull-awaitable": "1.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
@ -41,6 +41,7 @@
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"secret-handshake-ext": "0.0.11",
|
"secret-handshake-ext": "0.0.11",
|
||||||
"secret-stack": "8.1.0",
|
"secret-stack": "8.1.0",
|
||||||
|
"sodium-native": "4.1.1",
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -16,10 +16,10 @@ function JoinModal({ isOpen, onClose }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} onClose={onClose}>
|
<Modal isOpen={isOpen} onClose={onClose}>
|
||||||
Insert here the ppppp:// or http(s):// invite code you received from your friend.
|
Insert here the pzp:// or http(s):// invite code you received from your friend.
|
||||||
<textarea
|
<textarea
|
||||||
key="input"
|
key="input"
|
||||||
placeholder={'ppppp://... or http(s)://...'}
|
placeholder={'pzp://... or http(s)://...'}
|
||||||
className="border font-mono border-gray-400 resize-none rounded px-1 text-wrap break-all outline-offset-3 outline-2 outline-green-500 my-4 h-64"
|
className="border font-mono border-gray-400 resize-none rounded px-1 text-wrap break-all outline-offset-3 outline-2 outline-green-500 my-4 h-64"
|
||||||
onChange={updateCode}
|
onChange={updateCode}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue