braid-text 0.3.18 → 0.3.19
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/package.json +1 -1
- package/server.js +8 -29
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -718,7 +718,6 @@ function create_braid_text() {
|
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
-
options.my_last_sent_version = x.version
|
|
722
721
|
resource.simpleton_clients.add(options)
|
|
723
722
|
options.signal?.addEventListener('abort', () =>
|
|
724
723
|
resource.simpleton_clients.delete(options))
|
|
@@ -1015,7 +1014,6 @@ function create_braid_text() {
|
|
|
1015
1014
|
|
|
1016
1015
|
if (braid_text.verbose) console.log(`sending from rebase: ${JSON.stringify(x)}`)
|
|
1017
1016
|
client.my_subscribe(x)
|
|
1018
|
-
client.my_last_sent_version = x.version
|
|
1019
1017
|
|
|
1020
1018
|
delete client.my_timeout
|
|
1021
1019
|
}, time_override ?? Math.min(3000, 23 * Math.pow(1.5, client.my_unused_version_count - 1)))
|
|
@@ -1033,7 +1031,10 @@ function create_braid_text() {
|
|
|
1033
1031
|
|
|
1034
1032
|
let x = { version: resource.version }
|
|
1035
1033
|
if (peer && client.peer === peer) {
|
|
1036
|
-
if (!v_eq(
|
|
1034
|
+
if (!v_eq(resource.version, [version])) {
|
|
1035
|
+
// the resource has other changes beyond this
|
|
1036
|
+
// PUT, so the client is behind — start a
|
|
1037
|
+
// timeout to batch and rebase
|
|
1037
1038
|
client.my_unused_version_count = (client.my_unused_version_count ?? 0) + 1
|
|
1038
1039
|
set_timeout()
|
|
1039
1040
|
continue
|
|
@@ -1041,37 +1042,16 @@ function create_braid_text() {
|
|
|
1041
1042
|
delete client.my_unused_version_count
|
|
1042
1043
|
}
|
|
1043
1044
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
// any version that would cause x.version to
|
|
1049
|
-
// differ from x.parents would have already
|
|
1050
|
-
// updated my_last_sent_version when forwarding
|
|
1051
|
-
// other peers' changes to this client, causing
|
|
1052
|
-
// a mismatch and triggering a timeout instead.
|
|
1053
|
-
//
|
|
1054
|
-
// However, this is the standard rebase path and
|
|
1055
|
-
// is left here for implementations that omit the
|
|
1056
|
-
// timeout optimization — without it, this branch
|
|
1057
|
-
// is needed to rebase the client's version when
|
|
1058
|
-
// concurrent edits have been merged.
|
|
1059
|
-
if (braid_text.verbose) console.log("rebasing..")
|
|
1060
|
-
x.patches = get_xf_patches(resource.doc, OpLog_remote_to_local(resource.doc, x.parents))
|
|
1061
|
-
} else {
|
|
1062
|
-
// this client already has this version,
|
|
1063
|
-
// so let's pretend to send it back, but not
|
|
1064
|
-
if (braid_text.verbose) console.log(`not reflecting back to simpleton`)
|
|
1065
|
-
client.my_last_sent_version = x.version
|
|
1066
|
-
continue
|
|
1067
|
-
}
|
|
1045
|
+
// this client already has this version,
|
|
1046
|
+
// so let's pretend to send it back, but not
|
|
1047
|
+
if (braid_text.verbose) console.log(`not reflecting back to simpleton`)
|
|
1048
|
+
continue
|
|
1068
1049
|
} else {
|
|
1069
1050
|
x.parents = version_before
|
|
1070
1051
|
x.patches = patches
|
|
1071
1052
|
}
|
|
1072
1053
|
if (braid_text.verbose) console.log(`sending: ${JSON.stringify(x)}`)
|
|
1073
1054
|
post_commit_updates.push([client, x])
|
|
1074
|
-
client.my_last_sent_version = x.version
|
|
1075
1055
|
}
|
|
1076
1056
|
} else {
|
|
1077
1057
|
if (resource.simpleton_clients.size) {
|
|
@@ -1084,7 +1064,6 @@ function create_braid_text() {
|
|
|
1084
1064
|
for (let client of resource.simpleton_clients) {
|
|
1085
1065
|
if (client.my_timeout) continue
|
|
1086
1066
|
post_commit_updates.push([client, x])
|
|
1087
|
-
client.my_last_sent_version = x.version
|
|
1088
1067
|
}
|
|
1089
1068
|
}
|
|
1090
1069
|
}
|