braid-text 0.5.9 → 0.5.10
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/client/simpleton.js +2 -2
- package/package.json +1 -1
- package/server.js +16 -17
package/client/simpleton.js
CHANGED
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -408,8 +408,8 @@ function create_braid_text() {
|
|
|
408
408
|
Version: ascii_ify(unknowns.map(e => JSON.stringify(e)).join(', '))
|
|
409
409
|
})
|
|
410
410
|
|
|
411
|
-
var has_parents =
|
|
412
|
-
var has_version =
|
|
411
|
+
var has_parents = Array.isArray(req.parents)
|
|
412
|
+
var has_version = Array.isArray(req.version)
|
|
413
413
|
|
|
414
414
|
if (req.subscribe && has_version)
|
|
415
415
|
return my_end(400, 'Version header is not allowed with Subscribe — use Parents instead')
|
|
@@ -685,8 +685,8 @@ function create_braid_text() {
|
|
|
685
685
|
var version = resource.version
|
|
686
686
|
var merge_type = options.range_unit === 'yjs-text' ? 'yjs'
|
|
687
687
|
: (options.merge_type || 'simpleton')
|
|
688
|
-
var has_parents =
|
|
689
|
-
var has_version =
|
|
688
|
+
var has_parents = Array.isArray(options.parents)
|
|
689
|
+
var has_version = Array.isArray(options.version)
|
|
690
690
|
|
|
691
691
|
if (options.subscribe && has_version)
|
|
692
692
|
throw new Error('version is not allowed with subscribe — use parents instead')
|
|
@@ -704,21 +704,9 @@ function create_braid_text() {
|
|
|
704
704
|
}
|
|
705
705
|
getting.single_snapshot = !getting.subscribe && !getting.history
|
|
706
706
|
|
|
707
|
-
// Single snapshot: return the text (optionally at a specific version)
|
|
708
|
-
if (getting.single_snapshot) {
|
|
709
|
-
if (has_version) {
|
|
710
|
-
await ensure_dt_exists(resource)
|
|
711
|
-
return options.full_response
|
|
712
|
-
? { version: options.version, body: dt_get_string(resource.dt.doc, options.version) }
|
|
713
|
-
: dt_get_string(resource.dt.doc, options.version)
|
|
714
|
-
}
|
|
715
|
-
return options.full_response ? { version, body: resource.val } : resource.val
|
|
716
|
-
}
|
|
717
|
-
|
|
718
707
|
// DT binary encoding: a transport optimization usable by any merge type.
|
|
719
708
|
// Returns raw DT bytes instead of text.
|
|
720
|
-
if (
|
|
721
|
-
// TODO: move this into the dt/simpleton merge_type cases below
|
|
709
|
+
if (!getting.subscribe && getting.transfer_encoding === 'dt') {
|
|
722
710
|
await ensure_dt_exists(resource)
|
|
723
711
|
// If requesting the current version, skip the version lookup
|
|
724
712
|
// (faster than asking DT about a version we already have)
|
|
@@ -742,6 +730,17 @@ function create_braid_text() {
|
|
|
742
730
|
return { body: bytes }
|
|
743
731
|
}
|
|
744
732
|
|
|
733
|
+
// Single snapshot: return the text (optionally at a specific version)
|
|
734
|
+
if (getting.single_snapshot) {
|
|
735
|
+
if (has_version) {
|
|
736
|
+
await ensure_dt_exists(resource)
|
|
737
|
+
return options.full_response
|
|
738
|
+
? { version: options.version, body: dt_get_string(resource.dt.doc, options.version) }
|
|
739
|
+
: dt_get_string(resource.dt.doc, options.version)
|
|
740
|
+
}
|
|
741
|
+
return options.full_response ? { version, body: resource.val } : resource.val
|
|
742
|
+
}
|
|
743
|
+
|
|
745
744
|
// Each merge-type has a different way of getting history
|
|
746
745
|
switch (merge_type) {
|
|
747
746
|
|