braid-text 0.0.15 → 0.0.17

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
@@ -514,8 +514,9 @@ braid_text.put = async (key, options) => {
514
514
  }
515
515
  } else {
516
516
  if (resource.simpleton_clients.size) {
517
+ let version = resource.doc.getRemoteVersion().map((x) => x.join("-"))
517
518
  patches = get_xf_patches(resource.doc, v_before)
518
- let x = { version: [og_v], parents, patches }
519
+ let x = { version, parents, patches }
519
520
  console.log(`sending: ${JSON.stringify(x)}`)
520
521
  for (let client of resource.simpleton_clients) {
521
522
  if (client.my_timeout) continue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Library for collaborative text over http using braid.",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braidjs",
@@ -24,6 +24,7 @@ function simpleton_client(url, { apply_remote_update, generate_local_diff_update
24
24
  var char_counter = -1
25
25
  var outstanding_changes = 0
26
26
  var max_outstanding_changes = 10
27
+ var ac = new AbortController()
27
28
 
28
29
  braid_fetch_wrapper(url, {
29
30
  headers: { "Merge-Type": "simpleton",
@@ -31,7 +32,8 @@ function simpleton_client(url, { apply_remote_update, generate_local_diff_update
31
32
  subscribe: true,
32
33
  retry: true,
33
34
  parents: () => current_version.length ? current_version : null,
34
- peer
35
+ peer,
36
+ signal: ac.signal
35
37
  }).then(res =>
36
38
  res.subscribe(update => {
37
39
  // Only accept the update if its parents == our current version
@@ -69,6 +71,9 @@ function simpleton_client(url, { apply_remote_update, generate_local_diff_update
69
71
  )
70
72
 
71
73
  return {
74
+ stop: async () => {
75
+ ac.abort()
76
+ },
72
77
  changed: async () => {
73
78
  if (outstanding_changes >= max_outstanding_changes) return
74
79
  while (true) {
@@ -141,6 +146,7 @@ async function braid_fetch_wrapper(url, params) {
141
146
  var subscribe_handler = null
142
147
  connect()
143
148
  async function connect() {
149
+ if (params.signal?.aborted) return
144
150
  try {
145
151
  var c = await braid_fetch(url, { ...params, parents: params.parents?.() })
146
152
  c.subscribe((...args) => subscribe_handler?.(...args), on_error)