Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { RepoBackend, DocUrl } from 'hypermerge'
import { ToBackendRepoMsg } from 'hypermerge/dist/RepoMsg'
import { Socket } from 'net'
// import Client from 'discovery-cloud'
import ipc from '../ipc'
import { HYPERMERGE_PATH, FILE_SERVER_PATH } from '../renderer/constants'
import Root from './components/Root'
import { ToSystemMsg } from '../renderer/System'
window._debug = {}
const back = new RepoBackend({ path: HYPERMERGE_PATH })
// const cloud = new Client({ url: 'wss://pushpin-relay.herokuapp.com' })
const swarm = Hyperswarm({
queue: {
multiplex: true,
},
})
back.addSwarm(swarm)
// back.addSwarm(cloud)
back.startFileServer(FILE_SERVER_PATH)
window._debug.repo = back
window._debug.swarm = swarm
ipc.config.id = 'background'
ipc.serve(() => {
ipc.server.on('repo.msg', (msg: ToBackendRepoMsg) => {
import { Repo, DocUrl } from '../src'
import Hyperswarm from 'hyperswarm'
const url = process.argv[2] as DocUrl
if (url === undefined) {
console.log('Usage: cat ')
process.exit()
}
const repo = new Repo({ memory: true })
repo.setSwarm(Hyperswarm())
console.log('Watching document:', url)
repo.watch(url, (doc) => {
console.log(doc)
})