braid-text 0.2.25 → 0.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -488,6 +488,8 @@ braid_text.put = async (key, options) => {
488
488
 
489
489
  resource.need_defrag = true
490
490
 
491
+ await resource.db_delta(resource.doc.getPatchSince(v_before))
492
+
491
493
  if (options.merge_type != "dt") {
492
494
  patches = get_xf_patches(resource.doc, v_before)
493
495
  if (braid_text.verbose) console.log(JSON.stringify({ patches }))
@@ -588,8 +590,6 @@ braid_text.put = async (key, options) => {
588
590
  for (let client of resource.clients) {
589
591
  if (!peer || client.peer !== peer) client.subscribe(x)
590
592
  }
591
-
592
- await resource.db_delta(resource.doc.getPatchSince(v_before))
593
593
  }
594
594
 
595
595
  braid_text.list = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "Library for collaborative text over http using braid.",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braid-text",
package/test/server.js DELETED
@@ -1,50 +0,0 @@
1
-
2
- var port = process.argv[2] || 8889
3
-
4
- var braid_text = require("../index.js")
5
- braid_text.db_folder = null
6
-
7
- var server = require("http").createServer(async (req, res) => {
8
- console.log(`${req.method} ${req.url}`)
9
-
10
- // Free the CORS
11
- braid_text.free_cors(res)
12
- if (req.method === 'OPTIONS') return
13
-
14
- if (req.url.startsWith('/test.html')) {
15
- let parts = req.url.split(/[\?&=]/g)
16
-
17
- if (parts[1] === 'check') {
18
- res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-cache" })
19
- return res.end(JSON.stringify({
20
- checking: parts[2],
21
- result: (await braid_text.get(parts[2])) != null
22
- }))
23
- } else if (parts[1] === 'dt_create_bytes_big_name') {
24
- try {
25
- braid_text.dt_create_bytes('x'.repeat(1000000) + '-0', [], 0, 0, 'hi')
26
- return res.end(JSON.stringify({ ok: true }))
27
- } catch (e) {
28
- return res.end(JSON.stringify({ ok: false, error: '' + e }))
29
- }
30
- } else if (parts[1] === 'dt_create_bytes_many_names') {
31
- try {
32
- braid_text.dt_create_bytes('hi-0', new Array(1000000).fill(0).map((x, i) => `x${i}-0`), 0, 0, 'hi')
33
- return res.end(JSON.stringify({ ok: true }))
34
- } catch (e) {
35
- return res.end(JSON.stringify({ ok: false, error: '' + e }))
36
- }
37
- }
38
-
39
- res.writeHead(200, { "Content-Type": "text/html", "Cache-Control": "no-cache" })
40
- require("fs").createReadStream(`${__dirname}/test.html`).pipe(res)
41
- return
42
- }
43
-
44
- // Now serve the collaborative text!
45
- braid_text.serve(req, res)
46
- })
47
-
48
- server.listen(port, () => {
49
- console.log(`serving: http://localhost:${port}/test.html`)
50
- })