Skip to content

Commit a3de0cb

Browse files
committed
0.1.2 - adds some install instructions, and begins to make install easier
1 parent 4e3c3b5 commit a3de0cb

File tree

7 files changed

+25
-1845
lines changed

7 files changed

+25
-1845
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules/
33
.DS_Store
44
db*
5+
package-lock.json

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ How are we able to prune history? Well, because this algorithm isn't your norma
1111
See the index.html file for an example usage.
1212

1313
If you're curious, you can also read up on our early [hypothesizing](https://stackoverflow.com/a/48652362/440344) about the relationship between version controll systems and OT and CRDT algorithms. This was one of our earliest experiments into finding a universal synchronization algorithm and framework, which has now led to the [CTM theory](https://braid.org/time-machines) and the interoperable [Braid synchronization protocols](https://braid.org).
14+
15+
## Installation Instructions
16+
17+
> npm i
18+
> node server.js
19+
open http://localhost:60607/test in two browser windows, and there should be a collaborative text editor
20+

index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<body>
3-
<script src="./diffsync.js"></script>
3+
<script src="https://invisible-college.github.io/diffsync/diffsync.js"></script>
44
<script>
55

66
var t = document.createElement('textarea')
@@ -9,9 +9,8 @@
99
document.body.append(t)
1010

1111
var ds = diffsync.create_client({
12-
// ws_url : 'ws://localhost:' + diffsync.port,
13-
ws_url : 'wss://invisible.college:' + diffsync.port,
14-
channel : 'goop4',
12+
ws_url : location.origin.replace(/^http/, 'ws'),
13+
channel : location.pathname.slice(1),
1514
get_text : function () {
1615
return t.value
1716
},

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2+
"version": "0.1.2",
23
"dependencies": {
3-
"better-sqlite3": "^4.0.3",
4-
"statebus": "^6.0.44",
4+
"better-sqlite3": "^12.2.0",
5+
"statebus": "^6.0.125",
56
"ws": "^3.1.0"
67
}
78
}

server.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,17 @@ for (var key in bus.cache) {
3030
}
3131

3232
var fs = require('fs')
33-
var web_server = null
34-
var server_type = null
35-
if (fs.existsSync('privkey.pem') && fs.existsSync('fullchain.pem')) {
36-
web_server = require('https').createServer({
37-
key : fs.readFileSync('privkey.pem'),
38-
cert : fs.readFileSync('fullchain.pem')
39-
})
40-
server_type = 'https'
41-
} else {
42-
web_server = require('http').createServer()
43-
server_type = 'http'
44-
}
33+
var server_args = [async (req, res) => {
34+
res.end(await require('fs').promises.readFile(`${__dirname}/index.html`))
35+
}]
36+
var server_type = 'http' +
37+
(fs.existsSync('privkey.pem') && fs.existsSync('fullchain.pem') ? 's' : '')
38+
if (server_type === 'https') server_args.unshift({
39+
key : fs.readFileSync('privkey.pem'),
40+
cert : fs.readFileSync('fullchain.pem')
41+
})
42+
var web_server = require(server_type).createServer(...server_args)
43+
4544
var port = diffsync.port
4645
web_server.listen(port)
4746
console.log('openning ' + server_type + ' server on port ' + port)

0 commit comments

Comments
 (0)