braid-text 0.2.31 → 0.2.33

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 (3) hide show
  1. package/index.js +13 -11
  2. package/package.json +1 -1
  3. package/test/test.html +3 -3
package/index.js CHANGED
@@ -180,7 +180,10 @@ braid_text.serve = async (req, res, options = {}) => {
180
180
  // we want to send some kind of error that gives the client faith,
181
181
  // that resending this request later may work,
182
182
  // hopefully after we've received the necessary parents.
183
- return done_my_turn(309, e.message, 'Missing Parents', { 'Retry-After': '1' })
183
+ return done_my_turn(309, e.message, 'Version Unknown', {
184
+ Parents: req.headers.parents,
185
+ 'Retry-After': '1'
186
+ })
184
187
  } else {
185
188
  return done_my_turn(500, "The server failed to apply this version. The error generated was: " + e)
186
189
  }
@@ -911,23 +914,18 @@ function dt_get_patches(doc, version = null) {
911
914
  if (version && v_eq(version,
912
915
  doc.getRemoteVersion().map((x) => x.join("-")).sort())) {
913
916
  // they want everything past the end, which is nothing
914
- } else if (version) {
917
+ } else if (version?.length) {
915
918
  let frontier = {}
916
919
  version.forEach((x) => frontier[x] = true)
917
920
  let local_version = []
918
921
  for (let i = 0; i < versions.length; i++)
919
922
  if (frontier[versions[i].join("-")]) local_version.push(i)
920
- let after_bytes = doc.getPatchSince(new Uint32Array(local_version))
921
-
922
- ;[_agents, versions, parentss] = dt_parse([...after_bytes])
923
-
924
- let before_doc = dt_get(doc, version)
925
- let before_doc_frontier = before_doc.getLocalVersion()
926
923
 
927
- before_doc.mergeBytes(after_bytes)
928
- op_runs = before_doc.getOpsSince(before_doc_frontier)
924
+ local_version = new Uint32Array(local_version)
929
925
 
930
- before_doc.free()
926
+ let after_bytes = doc.getPatchSince(local_version)
927
+ ;[_agents, versions, parentss] = dt_parse([...after_bytes])
928
+ op_runs = doc.getOpsSince(local_version)
931
929
  } else op_runs = doc.getOpsSince([])
932
930
 
933
931
  doc.free()
@@ -1868,6 +1866,10 @@ class RangeSet {
1868
1866
  }
1869
1867
  }
1870
1868
 
1869
+ function ascii_ify(s) {
1870
+ return s.replace(/[^\x20-\x7E]/g, c => '\\u' + c.charCodeAt(0).toString(16).padStart(4, '0'))
1871
+ }
1872
+
1871
1873
  braid_text.get_resource = get_resource
1872
1874
 
1873
1875
  braid_text.encode_filename = encode_filename
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.2.31",
3
+ "version": "0.2.33",
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/test.html CHANGED
@@ -68,12 +68,12 @@ runTest(
68
68
  let r = await braid_fetch(`/${key}`, {
69
69
  method: 'PUT',
70
70
  version: ['hi-1'],
71
- parents: ['missing-0'],
71
+ parents: ['missing-0', 'y😀-0'],
72
72
  body: 'xx'
73
73
  })
74
- return r.status + ' ' + r.ok
74
+ return r.status + ' ' + r.ok + ' ' + r.statusText + ' ' + r.headers.get('Parents')
75
75
  },
76
- '309 false'
76
+ '309 false Version Unknown "missing-0", "y\\ud83d\\ude00-0"'
77
77
  )
78
78
 
79
79
  runTest(