braid-text 0.2.89 → 0.2.91
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 +12 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -124,7 +124,8 @@ function create_braid_text() {
|
|
|
124
124
|
var r = await braid_fetch(b.href, {
|
|
125
125
|
signal: ac.signal,
|
|
126
126
|
method: "HEAD",
|
|
127
|
-
version
|
|
127
|
+
version,
|
|
128
|
+
headers: options.headers
|
|
128
129
|
})
|
|
129
130
|
if (!r.ok && r.status !== 309 && r.status !== 500)
|
|
130
131
|
throw new Error(`unexpected HEAD status: ${r.status}`)
|
|
@@ -177,6 +178,7 @@ function create_braid_text() {
|
|
|
177
178
|
update.signal = ac.signal
|
|
178
179
|
update.dont_retry = true
|
|
179
180
|
if (options.peer) update.peer = options.peer
|
|
181
|
+
if (options.headers) update.headers = options.headers
|
|
180
182
|
var x = await braid_text.put(b, update)
|
|
181
183
|
if (x.ok) {
|
|
182
184
|
local_first_put()
|
|
@@ -260,7 +262,7 @@ function create_braid_text() {
|
|
|
260
262
|
var b_ops = {
|
|
261
263
|
signal: ac.signal,
|
|
262
264
|
dont_retry: true,
|
|
263
|
-
headers: { 'Merge-Type': 'dt', 'accept-encoding': 'updates(dt)' },
|
|
265
|
+
headers: { ...options.headers, 'Merge-Type': 'dt', 'accept-encoding': 'updates(dt)' },
|
|
264
266
|
parents: resource.meta.fork_point,
|
|
265
267
|
peer: options.peer,
|
|
266
268
|
heartbeats: 120,
|
|
@@ -268,8 +270,8 @@ function create_braid_text() {
|
|
|
268
270
|
// Wait for remote_res to be available
|
|
269
271
|
await remote_res_promise
|
|
270
272
|
|
|
271
|
-
// Check if this is a dt-encoded update
|
|
272
|
-
if (
|
|
273
|
+
// Check if this is a dt-encoded update
|
|
274
|
+
if (update.extra_headers?.encoding === 'dt') {
|
|
273
275
|
var cv = remote_res.headers.get('current-version')
|
|
274
276
|
await braid_text.put(a, {
|
|
275
277
|
body: update.body,
|
|
@@ -829,7 +831,7 @@ function create_braid_text() {
|
|
|
829
831
|
|
|
830
832
|
if (options.transfer_encoding === 'dt') {
|
|
831
833
|
var start_i = 1 + resource.doc.getLocalVersion().reduce((a, b) => Math.max(a, b), -1)
|
|
832
|
-
|
|
834
|
+
|
|
833
835
|
resource.doc.mergeBytes(body)
|
|
834
836
|
|
|
835
837
|
var end_i = resource.doc.getLocalVersion().reduce((a, b) => Math.max(a, b), -1)
|
|
@@ -842,6 +844,11 @@ function create_braid_text() {
|
|
|
842
844
|
resource.version = resource.doc.getRemoteVersion().map(x => x.join("-")).sort()
|
|
843
845
|
|
|
844
846
|
await resource.db_delta(body)
|
|
847
|
+
|
|
848
|
+
// Notify non-simpleton clients with the dt-encoded update
|
|
849
|
+
var dt_update = { body, encoding: 'dt' }
|
|
850
|
+
await Promise.all([...resource.clients].map(client => client.my_subscribe(dt_update)))
|
|
851
|
+
|
|
845
852
|
return { change_count: end_i - start_i + 1 }
|
|
846
853
|
}
|
|
847
854
|
|