braid-text 0.2.80 → 0.2.82
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 +1 -1
- package/package.json +2 -2
- package/test/tests.js +44 -0
package/index.js
CHANGED
|
@@ -997,7 +997,7 @@ function create_braid_text() {
|
|
|
997
997
|
|
|
998
998
|
await resource.db_delta(resource.doc.getPatchSince(v_before))
|
|
999
999
|
|
|
1000
|
-
|
|
1000
|
+
await Promise.all(post_commit_updates.map(([client, x]) => client.my_subscribe(x)))
|
|
1001
1001
|
|
|
1002
1002
|
return { change_count }
|
|
1003
1003
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braid-text",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.82",
|
|
4
4
|
"description": "Library for collaborative text over http using braid.",
|
|
5
5
|
"author": "Braid Working Group",
|
|
6
6
|
"repository": "braid-org/braid-text",
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@braid.org/diamond-types-node": "^2.0.0",
|
|
10
10
|
"braid-http": "~1.3.83",
|
|
11
|
-
"url-file-db": "^0.0.
|
|
11
|
+
"url-file-db": "^0.0.23"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/test/tests.js
CHANGED
|
@@ -1144,6 +1144,50 @@ runTest(
|
|
|
1144
1144
|
'x'
|
|
1145
1145
|
)
|
|
1146
1146
|
|
|
1147
|
+
runTest(
|
|
1148
|
+
"test put awaits subscriber callbacks",
|
|
1149
|
+
async () => {
|
|
1150
|
+
var key = 'test-' + Math.random().toString(36).slice(2)
|
|
1151
|
+
|
|
1152
|
+
var r = await braid_fetch(`/eval`, {
|
|
1153
|
+
method: 'PUT',
|
|
1154
|
+
body: `void (async () => {
|
|
1155
|
+
var order = []
|
|
1156
|
+
|
|
1157
|
+
// Subscribe with an async callback that takes some time
|
|
1158
|
+
braid_text.get('/${key}', {
|
|
1159
|
+
subscribe: async (update) => {
|
|
1160
|
+
if (update.version?.[0]?.startsWith('test-v')) {
|
|
1161
|
+
order.push('subscriber-start')
|
|
1162
|
+
await new Promise(done => setTimeout(done, 50))
|
|
1163
|
+
order.push('subscriber-end')
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
})
|
|
1167
|
+
|
|
1168
|
+
// Wait for subscription to be established
|
|
1169
|
+
await new Promise(done => setTimeout(done, 50))
|
|
1170
|
+
|
|
1171
|
+
// Put should await the subscriber callback
|
|
1172
|
+
await braid_text.put('/${key}', {
|
|
1173
|
+
version: ['test-v-0'],
|
|
1174
|
+
parents: [],
|
|
1175
|
+
body: 'hello'
|
|
1176
|
+
})
|
|
1177
|
+
order.push('put-done')
|
|
1178
|
+
|
|
1179
|
+
// If put properly awaited, order should be: subscriber-start, subscriber-end, put-done
|
|
1180
|
+
// If put didn't await, order would be: subscriber-start, put-done, subscriber-end
|
|
1181
|
+
res.end(order.join(','))
|
|
1182
|
+
})()`
|
|
1183
|
+
})
|
|
1184
|
+
if (!r.ok) return 'eval failed: ' + r.status
|
|
1185
|
+
|
|
1186
|
+
return await r.text()
|
|
1187
|
+
},
|
|
1188
|
+
'subscriber-start,subscriber-end,put-done'
|
|
1189
|
+
)
|
|
1190
|
+
|
|
1147
1191
|
runTest(
|
|
1148
1192
|
"test out-of-order PUTs",
|
|
1149
1193
|
async () => {
|