reconcile-text 0.4.6

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.
@@ -0,0 +1,50 @@
1
+ import { BuiltinTokenizer, History } from 'reconcile-text';
2
+ export interface TextWithCursors {
3
+ /** The document's entire content */
4
+ text: string;
5
+ /** List of cursor positions, can be null or undefined if there are no cursors */
6
+ cursors: null | undefined | CursorPosition[];
7
+ }
8
+ export interface CursorPosition {
9
+ /** Unique identifier for the cursor */
10
+ id: number;
11
+ /** Character position in the text, 0-based */
12
+ position: number;
13
+ }
14
+ export interface TextWithCursorsAndHistory {
15
+ /** The document's entire content */
16
+ text: string;
17
+ /** List of cursor positions, can be null or undefined if there are no cursors */
18
+ cursors: null | undefined | CursorPosition[];
19
+ /** List of operations leading to `text` from the 3 ancestors */
20
+ history: SpanWithHistory[];
21
+ }
22
+ export interface SpanWithHistory {
23
+ /** Span of text associated with the historical opearion */
24
+ text: string;
25
+ /** Origin of the `text` span */
26
+ history: History;
27
+ }
28
+ export type Tokenizer = 'Line' | 'Word' | 'Character';
29
+ /**
30
+ * Merges three versions of text (original, left, right) and cursor positions.
31
+ *
32
+ * @param original - The original/base version of the text
33
+ * @param left - The left version of the text, either as string or TextWithCursors
34
+ * @param right - The right version of the text, either as string or TextWithCursors
35
+ * @param tokenizer - The tokenization strategy to use (default: "Word")
36
+ * @returns The reconciled text with merged cursor positions
37
+ */
38
+ export declare function reconcile(original: string, left: string | TextWithCursors, right: string | TextWithCursors, tokenizer?: BuiltinTokenizer): TextWithCursors;
39
+ /**
40
+ * Merges three versions of text and returns the result with historical information.
41
+ *
42
+ * Calculating the `history` is somewhat more expensive, otherwise this function behaves like `reconcile`.
43
+ *
44
+ * @param original - The original/base version of the text
45
+ * @param left - The left version of the text, either as string or TextWithCursors
46
+ * @param right - The right version of the text, either as string or TextWithCursors
47
+ * @param tokenizer - The tokenization strategy to use (default: "Word")
48
+ * @returns The reconciled text with cursor positions and history of changes
49
+ */
50
+ export declare function reconcileWithHistory(original: string, left: string | TextWithCursors, right: string | TextWithCursors, tokenizer?: BuiltinTokenizer): TextWithCursorsAndHistory;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "reconcile-text",
3
+ "version": "0.4.6",
4
+ "description": "Think diff3 or git merge, but with automated conflict resolution that requires no user intervention",
5
+ "main": "dist/reconcile.node.js",
6
+ "browser": "dist/reconcile.web.js",
7
+ "keywords": [
8
+ "text editing",
9
+ "sync",
10
+ "collaborative editing",
11
+ "3-way",
12
+ "merge",
13
+ "conflict resolution",
14
+ "OT",
15
+ "operational transformation",
16
+ "CRDT"
17
+ ],
18
+ "homepage": "https://schmelczer.dev/reconcile/",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/schmelczer/reconcile.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/schmelczer/reconcile/issues",
25
+ "email": "andras@schmelczer.dev"
26
+ },
27
+ "author": "András Schmelczer",
28
+ "license": "MIT",
29
+ "types": "dist/types/index.d.ts",
30
+ "files": [
31
+ "dist/**/*"
32
+ ],
33
+ "scripts": {
34
+ "build": "webpack --mode production",
35
+ "format": "prettier --write \"./**/*.(ts|scss|json|html)\"",
36
+ "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
37
+ },
38
+ "devDependencies": {
39
+ "@types/jest": "^30.0.0",
40
+ "jest": "^30.0.4",
41
+ "prettier": "^3.6.2",
42
+ "reconcile-text": "file:../pkg",
43
+ "ts-jest": "^29.4.0",
44
+ "ts-loader": "^9.5.2",
45
+ "tslib": "2.8.1",
46
+ "typescript": "5.8.3",
47
+ "webpack": "^5.99.9",
48
+ "webpack-cli": "^6.0.1",
49
+ "webpack-merge": "^6.0.1"
50
+ }
51
+ }