braid-text 0.2.83 → 0.2.85

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
@@ -108,7 +108,7 @@ function create_braid_text() {
108
108
 
109
109
  connect()
110
110
  async function connect() {
111
- if (options.on_connect) options.on_connect()
111
+ if (options.on_pre_connect) await options.on_pre_connect()
112
112
 
113
113
  if (closed) return
114
114
 
@@ -187,7 +187,10 @@ function create_braid_text() {
187
187
  await braid_text.put(a, update)
188
188
  extend_fork_point(update)
189
189
  },
190
- on_error: handle_error
190
+ on_error: e => {
191
+ options.on_disconnect?.()
192
+ handle_error(e)
193
+ }
191
194
  }
192
195
  // Handle case where remote doesn't exist yet - wait for local to create it
193
196
  var remote_result = await braid_text.get(b, b_ops)
@@ -674,6 +677,20 @@ function create_braid_text() {
674
677
  }
675
678
  }
676
679
 
680
+ // Deprecated: Use signal-based abort instead (pass signal in options to get())
681
+ braid_text.forget = async (key, options) => {
682
+ console.warn('braid_text.forget() is deprecated. Use signal-based abort instead.')
683
+ if (!options) throw new Error('options is required')
684
+
685
+ if (key instanceof URL) throw new Error('forget() does not support URLs. Use signal-based abort instead.')
686
+
687
+ let resource = (typeof key == 'string') ? await get_resource(key) : key
688
+
689
+ if (options.merge_type != "dt")
690
+ resource.simpleton_clients.delete(options)
691
+ else resource.clients.delete(options)
692
+ }
693
+
677
694
  braid_text.put = async (key, options) => {
678
695
  if (options.version) {
679
696
  validate_version_array(options.version)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.2.83",
3
+ "version": "0.2.85",
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/tests.js CHANGED
@@ -46,7 +46,7 @@ runTest(
46
46
  var ac = new AbortController()
47
47
  braid_text.sync('/${key}', new URL('http://localhost:8889/have_error'), {
48
48
  signal: ac.signal,
49
- on_connect: () => {
49
+ on_pre_connect: () => {
50
50
  count++
51
51
  if (count === 2) {
52
52
  res.end('it reconnected!')
@@ -198,7 +198,7 @@ runTest(
198
198
  var ac = new AbortController()
199
199
  braid_text.sync('/${key_a}', new URL('http://localhost:8889/have_error'), {
200
200
  signal: ac.signal,
201
- on_connect: () => {
201
+ on_pre_connect: () => {
202
202
  count++
203
203
  if (count === 2) {
204
204
  res.end('it reconnected!')