braid-text 0.2.107 → 0.2.109
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 +7 -2
- package/package.json +12 -2
- package/.claude/settings.local.json +0 -9
- package/test/fuzz-test.js +0 -643
- package/test/test.html +0 -118
- package/test/test.js +0 -321
- package/test/tests.js +0 -2899
package/index.js
CHANGED
|
@@ -927,7 +927,12 @@ function create_braid_text() {
|
|
|
927
927
|
let og_patches = patches
|
|
928
928
|
patches = patches.map((p) => ({
|
|
929
929
|
...p,
|
|
930
|
-
range: p.range.match(
|
|
930
|
+
range: p.range.match(/-?\d+/g).map((x) => {
|
|
931
|
+
let n = parseInt(x)
|
|
932
|
+
// Handle negative indices (including -0) as offsets from max_pos
|
|
933
|
+
if (Object.is(n, -0) || n < 0) return max_pos + n
|
|
934
|
+
return n
|
|
935
|
+
}),
|
|
931
936
|
content_codepoints: [...p.content],
|
|
932
937
|
})).sort((a, b) => a.range[0] - b.range[0])
|
|
933
938
|
|
|
@@ -2530,7 +2535,7 @@ function create_braid_text() {
|
|
|
2530
2535
|
if (typeof x != 'object') throw new Error(`invalid patch: not an object`)
|
|
2531
2536
|
if (x.unit && x.unit !== 'text') throw new Error(`invalid patch unit '${x.unit}': only 'text' supported`)
|
|
2532
2537
|
if (typeof x.range !== 'string') throw new Error(`invalid patch range: must be a string`)
|
|
2533
|
-
if (!x.range.match(/^\s*\[\s
|
|
2538
|
+
if (!x.range.match(/^\s*\[\s*-?\d+\s*:\s*-?\d+\s*\]\s*$/)) throw new Error(`invalid patch range: ${x.range}`)
|
|
2534
2539
|
if (typeof x.content !== 'string') throw new Error(`invalid patch content: must be a string`)
|
|
2535
2540
|
}
|
|
2536
2541
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braid-text",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.109",
|
|
4
4
|
"description": "Library for collaborative text over http using braid.",
|
|
5
5
|
"author": "Braid Working Group",
|
|
6
6
|
"repository": "braid-org/braid-text",
|
|
7
7
|
"homepage": "https://braid.org",
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"simpleton-client.js",
|
|
11
|
+
"web-utils.js",
|
|
12
|
+
"README.md",
|
|
13
|
+
"AI-README.md",
|
|
14
|
+
"editor.html",
|
|
15
|
+
"markdown-editor.html",
|
|
16
|
+
"server-demo.js"
|
|
17
|
+
],
|
|
8
18
|
"dependencies": {
|
|
9
19
|
"@braid.org/diamond-types-node": "^2.0.0",
|
|
10
|
-
"braid-http": "~1.3.
|
|
20
|
+
"braid-http": "~1.3.89"
|
|
11
21
|
}
|
|
12
22
|
}
|