braid-text 0.0.23 → 0.0.25

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/index.js +12 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -210,12 +210,12 @@ braid_text.get = async (key, options) => {
210
210
  if (options.version || options.parents) doc = dt_get(doc, options.version || options.parents)
211
211
 
212
212
  return {
213
- version: doc.getRemoteVersion().map((x) => x.join("-")),
213
+ version: doc.getRemoteVersion().map((x) => x.join("-")).sort(),
214
214
  body: doc.get()
215
215
  }
216
216
  } else {
217
217
  if (options.merge_type != "dt") {
218
- let version = resource.doc.getRemoteVersion().map((x) => x.join("-"))
218
+ let version = resource.doc.getRemoteVersion().map((x) => x.join("-")).sort()
219
219
  let x = { version }
220
220
 
221
221
  if (!options.parents && !options.version) {
@@ -300,7 +300,7 @@ braid_text.put = async (key, options) => {
300
300
 
301
301
  let resource = (typeof key == 'string') ? await get_resource(key) : key
302
302
 
303
- let parents = resource.doc.getRemoteVersion().map((x) => x.join("-"))
303
+ let parents = resource.doc.getRemoteVersion().map((x) => x.join("-")).sort()
304
304
  let og_parents = options_parents || parents
305
305
 
306
306
  let max_pos = count_code_points(v_eq(parents, og_parents) ?
@@ -440,7 +440,7 @@ braid_text.put = async (key, options) => {
440
440
  patches = get_xf_patches(resource.doc, v_before)
441
441
  console.log(JSON.stringify({ patches }))
442
442
 
443
- let version = resource.doc.getRemoteVersion().map((x) => x.join("-"))
443
+ let version = resource.doc.getRemoteVersion().map((x) => x.join("-")).sort()
444
444
 
445
445
  for (let client of resource.simpleton_clients) {
446
446
  if (client.peer == peer) {
@@ -450,7 +450,7 @@ braid_text.put = async (key, options) => {
450
450
  function set_timeout(time_override) {
451
451
  if (client.my_timeout) clearTimeout(client.my_timeout)
452
452
  client.my_timeout = setTimeout(() => {
453
- let version = resource.doc.getRemoteVersion().map((x) => x.join("-"))
453
+ let version = resource.doc.getRemoteVersion().map((x) => x.join("-")).sort()
454
454
  let x = { version }
455
455
  x.parents = client.my_last_seen_version
456
456
 
@@ -513,7 +513,7 @@ braid_text.put = async (key, options) => {
513
513
  }
514
514
  } else {
515
515
  if (resource.simpleton_clients.size) {
516
- let version = resource.doc.getRemoteVersion().map((x) => x.join("-"))
516
+ let version = resource.doc.getRemoteVersion().map((x) => x.join("-")).sort()
517
517
  patches = get_xf_patches(resource.doc, v_before)
518
518
  let x = { version, parents, patches }
519
519
  console.log(`sending: ${JSON.stringify(x)}`)
@@ -836,7 +836,7 @@ function OpLog_get_patches(bytes, op_runs) {
836
836
  let patches = []
837
837
  op_runs.forEach((op_run) => {
838
838
  let version = versions[i].join("-")
839
- let parents = parentss[i].map((x) => x.join("-"))
839
+ let parents = parentss[i].map((x) => x.join("-")).sort()
840
840
  let start = op_run.start
841
841
  let end = start + 1
842
842
  if (op_run.content) op_run.content = [...op_run.content]
@@ -863,7 +863,7 @@ function OpLog_get_patches(bytes, op_runs) {
863
863
  })
864
864
  if (j == len) break
865
865
  version = versions[I].join("-")
866
- parents = parentss[I].map((x) => x.join("-"))
866
+ parents = parentss[I].map((x) => x.join("-")).sort()
867
867
  start = op_run.start + j
868
868
  content = ""
869
869
  }
@@ -1450,6 +1450,7 @@ function decode_filename(encodedFilename) {
1450
1450
 
1451
1451
  function validate_version_array(x) {
1452
1452
  if (!Array.isArray(x)) throw new Error(`invalid version array: not an array`)
1453
+ x.sort()
1453
1454
  for (xx of x) validate_actor_seq(xx)
1454
1455
  }
1455
1456
 
@@ -1490,4 +1491,7 @@ function validate_patch(x) {
1490
1491
  if (typeof x.content !== 'string') throw new Error(`invalid patch content: must be a string`)
1491
1492
  }
1492
1493
 
1494
+ braid_text.encode_filename = encode_filename
1495
+ braid_text.decode_filename = decode_filename
1496
+
1493
1497
  module.exports = braid_text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "Library for collaborative text over http using braid.",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braidjs",