braid-text 0.2.59 → 0.2.61
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/README.md +10 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/test/test.html +1 -1
package/README.md
CHANGED
|
@@ -135,6 +135,14 @@ This design prevents network congestion and handles disconnections gracefully. F
|
|
|
135
135
|
|
|
136
136
|
For better performance and control, you can work with patches instead of full text:
|
|
137
137
|
|
|
138
|
+
#### Patch Format
|
|
139
|
+
|
|
140
|
+
Each patch is an object with two properties:
|
|
141
|
+
- `range`: `[start, end]` - The range of characters to delete
|
|
142
|
+
- `content`: The text to insert at that position
|
|
143
|
+
|
|
144
|
+
Patches in an array each have positions which refer to the **original text** before any other patches are applied.
|
|
145
|
+
|
|
138
146
|
#### Receiving Patches
|
|
139
147
|
|
|
140
148
|
Instead of receiving complete text updates, you can process individual changes:
|
|
@@ -213,6 +221,8 @@ Creates a new Simpleton client that synchronizes with a Braid-Text server.
|
|
|
213
221
|
```
|
|
214
222
|
If not provided, uses a simple prefix/suffix diff algorithm.
|
|
215
223
|
|
|
224
|
+
**Note:** All patches must reference positions in the original text before any patches are applied.
|
|
225
|
+
|
|
216
226
|
#### Additional Options
|
|
217
227
|
|
|
218
228
|
- `content_type`: <small style="color:lightgrey">[optional]</small> MIME type for `Accept` and `Content-Type` headers
|
package/index.js
CHANGED
|
@@ -81,7 +81,7 @@ braid_text.serve = async (req, res, options = {}) => {
|
|
|
81
81
|
unknowns.push(event)
|
|
82
82
|
}
|
|
83
83
|
if (unknowns.length)
|
|
84
|
-
return my_end(309, '', "Version Unknown", {
|
|
84
|
+
return my_end(309, '', "Version Unknown Here", {
|
|
85
85
|
Version: ascii_ify(unknowns.map(e => JSON.stringify(e)).join(', '))
|
|
86
86
|
})
|
|
87
87
|
|
package/package.json
CHANGED
package/test/test.html
CHANGED
|
@@ -1276,7 +1276,7 @@ runTest(
|
|
|
1276
1276
|
version: ['hi-5']
|
|
1277
1277
|
})
|
|
1278
1278
|
if (r.status !== 309) throw 'expected 309, got: ' + r.status
|
|
1279
|
-
if (r.statusText !== 'Version Unknown') throw 'unexpected status text: ' + r.statusText
|
|
1279
|
+
if (r.statusText !== 'Version Unknown Here') throw 'unexpected status text: ' + r.statusText
|
|
1280
1280
|
if (r.ok) throw 'found version we should not have found'
|
|
1281
1281
|
|
|
1282
1282
|
var r = await braid_fetch(`/${key}`, {
|