braid-text 0.3.4 → 0.3.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +11 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
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/server.js CHANGED
@@ -476,16 +476,20 @@ function create_braid_text() {
476
476
  accept_encoding:
477
477
  req.headers['x-accept-encoding'] ??
478
478
  req.headers['accept-encoding'],
479
- subscribe: x => {
479
+ subscribe: update => {
480
480
 
481
481
  // this is a sanity/rhobustness check..
482
482
  // ..this digest is checked on the client..
483
- if (x.version && v_eq(x.version, resource.version))
484
- x["Repr-Digest"] = get_digest(resource.val)
483
+ if (update.version && v_eq(update.version, resource.version))
484
+ update["Repr-Digest"] = get_digest(resource.val)
485
485
 
486
- res.sendVersion(x)
486
+ if (update.patches && update.patches.length === 1) {
487
+ update.patch = update.patches[0]
488
+ delete update.patches
489
+ }
490
+ res.sendVersion(update)
487
491
  },
488
- write: (x) => res.write(x)
492
+ write: (update) => res.write(update)
489
493
  }
490
494
 
491
495
  res.startSubscription({
@@ -3018,11 +3022,11 @@ class cursor_state {
3018
3022
  for (var sub of this.subscribers)
3019
3023
  if (sub.peer !== exclude_peer)
3020
3024
  try { sub.res.sendUpdate({
3021
- patches: [{
3025
+ patch: {
3022
3026
  unit: 'json',
3023
3027
  range: '[' + JSON.stringify(peer_id) + ']',
3024
3028
  content: content
3025
- }]
3029
+ }
3026
3030
  }) } catch (e) {}
3027
3031
  }
3028
3032