Rename package
This commit is contained in:
parent
ce4af278ac
commit
7e9ea69a08
41 changed files with 58 additions and 209 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -175,7 +175,7 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "reconcile"
|
||||
name = "reconcile-text"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.1",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "reconcile"
|
||||
name = "reconcile-text"
|
||||
description = "Think diff3 or git merge, but with automated conflict resolution that requires no user intervention"
|
||||
version = "0.4.3"
|
||||
rust-version = "1.85"
|
||||
|
|
@ -16,6 +16,10 @@ exclude = ["reconcile-js", ".*", "examples/website"]
|
|||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[[example]]
|
||||
name = "merge-file"
|
||||
path = "examples/merge-file.rs"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.219", optional = true, features = ["derive"] }
|
||||
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -23,17 +23,17 @@ TODO: add links for crates and npm
|
|||
|
||||
### Rust
|
||||
|
||||
Add `reconcile` to your `Cargo.toml`:
|
||||
Add `reconcile-text` to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
reconcile = "0.4"
|
||||
reconcile-text = "0.4"
|
||||
```
|
||||
|
||||
Then merge away:
|
||||
|
||||
```rust
|
||||
use reconcile::{reconcile, BuiltinTokenizer};
|
||||
use reconcile_text::{reconcile, BuiltinTokenizer};
|
||||
|
||||
// Start with original text
|
||||
let parent = "Hello world";
|
||||
|
|
@ -51,13 +51,13 @@ assert_eq!(result.apply().text(), "Hi beautiful world");
|
|||
Install via npm:
|
||||
|
||||
```bash
|
||||
npm install reconcile
|
||||
npm install reconcile-text
|
||||
```
|
||||
|
||||
Then use in your application:
|
||||
|
||||
```javascript
|
||||
import { init, reconcile } from 'reconcile';
|
||||
import { init, reconcile } from 'reconcile-text';
|
||||
|
||||
// Same example as above
|
||||
const parent = 'Hello world';
|
||||
|
|
@ -85,7 +85,7 @@ Reconcile offers different ways to split text for merging:
|
|||
|
||||
- **Word tokeniser** (`BuiltinTokenizer::Word`) — Splits on word boundaries (recommended for prose)
|
||||
- **Character tokeniser** (`BuiltinTokenizer::Character`) — Individual characters (fine-grained control)
|
||||
- **Line tokeniser** (`BuiltinTokenizer::Line`) — Line-by-line (similar to `git merge`)
|
||||
- **Line tokeniser** (`BuiltinTokenizer::Line`) — Line-by-line (similar to `git merge` or more precisely [`git merge-file`](https://git-scm.com/docs/git-merge-file))
|
||||
- **Custom tokeniser** — Roll your own for specialised use cases
|
||||
|
||||
### Cursor tracking
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use std::{env, fs, process};
|
||||
|
||||
use reconcile_merge::{BuiltinTokenizer, reconcile};
|
||||
use reconcile_text::{BuiltinTokenizer, reconcile};
|
||||
|
||||
/// Merges three versions of a file: mine, base, and theirs.
|
||||
/// Implement a trivial version git merge-file (https://git-scm.com/docs/git-merge-file)
|
||||
/// Implement a trivial version git merge-file (<https://git-scm.com/docs/git-merge-file>)
|
||||
///
|
||||
/// Run it with:
|
||||
/// `cargo run --example merge-file my.txt base.txt their.txt [output_file.txt]`
|
||||
|
|
@ -22,17 +22,17 @@ fn main() {
|
|||
|
||||
// Read files
|
||||
let mine_content = fs::read_to_string(mine_file).unwrap_or_else(|e| {
|
||||
eprintln!("Error reading {}: {}", mine_file, e);
|
||||
eprintln!("Error reading {mine_file}: {e}");
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
let base_content = fs::read_to_string(base_file).unwrap_or_else(|e| {
|
||||
eprintln!("Error reading {}: {}", base_file, e);
|
||||
eprintln!("Error reading {base_file}: {e}");
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
let theirs_content = fs::read_to_string(theirs_file).unwrap_or_else(|e| {
|
||||
eprintln!("Error reading {}: {}", theirs_file, e);
|
||||
eprintln!("Error reading {theirs_file}: {e}");
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
|
|
@ -49,10 +49,10 @@ fn main() {
|
|||
// Write the result
|
||||
if let Some(output_path) = output_file {
|
||||
if let Err(e) = fs::write(output_path, merged_content) {
|
||||
eprintln!("Error writing to {}: {}", output_path, e);
|
||||
eprintln!("Error writing to {output_path}: {e}");
|
||||
process::exit(1);
|
||||
}
|
||||
} else {
|
||||
print!("{}", merged_content);
|
||||
print!("{merged_content}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { reconcileWithHistory } from 'reconcile';
|
||||
import type { Tokenizer } from 'reconcile';
|
||||
import { reconcileWithHistory } from 'reconcile-text';
|
||||
import type { Tokenizer } from 'reconcile-text';
|
||||
import './style.scss';
|
||||
|
||||
const originalTextArea = document.getElementById('original') as HTMLTextAreaElement;
|
||||
|
|
|
|||
25
examples/website/package-lock.json
generated
25
examples/website/package-lock.json
generated
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "portfolio",
|
||||
"name": "reconcile-example-website",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "portfolio",
|
||||
"name": "reconcile-example-website",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"css-loader": "^7.1.2",
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
"inline-source-webpack-plugin": "^3.0.1",
|
||||
"mini-css-extract-plugin": "^2.9.2",
|
||||
"prettier": "^3.6.2",
|
||||
"reconcile": "file:../../reconcile-js",
|
||||
"reconcile-text": "file:../../reconcile-js",
|
||||
"resolve-url-loader": "^5.0.0",
|
||||
"sass": "^1.89.2",
|
||||
"sass-loader": "^16.0.5",
|
||||
|
|
@ -26,19 +26,22 @@
|
|||
}
|
||||
},
|
||||
"../../reconcile-js": {
|
||||
"name": "reconcile",
|
||||
"version": "0.4.0",
|
||||
"name": "reconcile-text",
|
||||
"version": "0.4.3",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.14",
|
||||
"jest": "^29.7.0",
|
||||
"reconcile": "file:../pkg",
|
||||
"ts-jest": "^29.3.4",
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.4",
|
||||
"prettier": "^3.6.2",
|
||||
"reconcile-text": "file:../pkg",
|
||||
"ts-jest": "^29.4.0",
|
||||
"ts-loader": "^9.5.2",
|
||||
"tslib": "2.8.1",
|
||||
"typescript": "5.8.3",
|
||||
"webpack": "^5.99.9",
|
||||
"webpack-cli": "^6.0.1"
|
||||
"webpack-cli": "^6.0.1",
|
||||
"webpack-merge": "^6.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@discoveryjs/json-ext": {
|
||||
|
|
@ -3960,7 +3963,7 @@
|
|||
"node": ">= 10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/reconcile": {
|
||||
"node_modules/reconcile-text": {
|
||||
"resolved": "../../reconcile-js",
|
||||
"link": true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
],
|
||||
"homepage": "https://github.com/schmelczer/reconcile#readme",
|
||||
"devDependencies": {
|
||||
"reconcile": "file:../../reconcile-js",
|
||||
"reconcile-text": "file:../../reconcile-js",
|
||||
"css-loader": "^7.1.2",
|
||||
"html-webpack-plugin": "^5.6.3",
|
||||
"mini-css-extract-plugin": "^2.9.2",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
preset: 'ts-jest/presets/js-with-babel-esm',
|
||||
moduleNameMapper: {
|
||||
'^reconcile/reconcile_bg\\.wasm$': `<rootDir>/__mocks__/wasm.js`,
|
||||
'^reconcile-text/reconcile_bg\\.wasm$': `<rootDir>/__mocks__/wasm.js`,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
13
reconcile-js/package-lock.json
generated
13
reconcile-js/package-lock.json
generated
|
|
@ -1,17 +1,18 @@
|
|||
{
|
||||
"name": "reconcile",
|
||||
"name": "reconcile-text",
|
||||
"version": "0.4.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "reconcile",
|
||||
"name": "reconcile-text",
|
||||
"version": "0.4.3",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.4",
|
||||
"prettier": "^3.6.2",
|
||||
"reconcile": "file:../pkg",
|
||||
"reconcile-text": "file:../pkg",
|
||||
"ts-jest": "^29.4.0",
|
||||
"ts-loader": "^9.5.2",
|
||||
"tslib": "2.8.1",
|
||||
|
|
@ -22,8 +23,8 @@
|
|||
}
|
||||
},
|
||||
"../pkg": {
|
||||
"name": "reconcile",
|
||||
"version": "0.4.0",
|
||||
"name": "reconcile-text",
|
||||
"version": "0.4.3",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
|
@ -4542,7 +4543,7 @@
|
|||
"node": ">= 10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/reconcile": {
|
||||
"node_modules/reconcile-text": {
|
||||
"resolved": "../pkg",
|
||||
"link": true
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "reconcile",
|
||||
"name": "reconcile-text",
|
||||
"version": "0.4.3",
|
||||
"description": "Think diff3 or git merge, but with automated conflict resolution that requires no user intervention",
|
||||
"main": "dist/reconcile.node.js",
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.4",
|
||||
"prettier": "^3.6.2",
|
||||
"reconcile": "file:../pkg",
|
||||
"reconcile-text": "file:../pkg",
|
||||
"ts-jest": "^29.4.0",
|
||||
"ts-loader": "^9.5.2",
|
||||
"tslib": "2.8.1",
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import {
|
|||
reconcileWithHistory as wasmReconcileWithHistory,
|
||||
History,
|
||||
initSync,
|
||||
} from 'reconcile';
|
||||
} from 'reconcile-text';
|
||||
|
||||
import wasmBytes from 'reconcile/reconcile_bg.wasm';
|
||||
import wasmBytes from 'reconcile-text/reconcile_bg.wasm';
|
||||
|
||||
export interface TextWithCursors {
|
||||
/** The document's entire content */
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
//! ✨ **[Try the interactive demo](https://schmelczer.dev/reconcile)** to see it in action!
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, BuiltinTokenizer};
|
||||
//! use reconcile_text::{reconcile, BuiltinTokenizer};
|
||||
//!
|
||||
//! // Start with original text
|
||||
//! let parent = "Merging text is hard!";
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
//! ### Built-in tokenisers
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, BuiltinTokenizer};
|
||||
//! use reconcile_text::{reconcile, BuiltinTokenizer};
|
||||
//!
|
||||
//! let parent = "The quick brown fox\n";
|
||||
//! let left = "The very quick brown fox\n"; // Added "very"
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
//! you can implement custom tokenisation logic:
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, Token, BuiltinTokenizer};
|
||||
//! use reconcile_text::{reconcile, Token, BuiltinTokenizer};
|
||||
//!
|
||||
//! // Example: custom sentence-based tokeniser
|
||||
//! let sentence_tokeniser = |text: &str| {
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
//! cursors and selection ranges during merging:
|
||||
//!
|
||||
//! ```
|
||||
//! use reconcile::{reconcile, BuiltinTokenizer, TextWithCursors, CursorPosition};
|
||||
//! use reconcile_text::{reconcile, BuiltinTokenizer, TextWithCursors, CursorPosition};
|
||||
//!
|
||||
//! let parent = "Hello world";
|
||||
//! let left = TextWithCursors::new(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use crate::{
|
|||
/// granularity of words.
|
||||
///
|
||||
/// ```
|
||||
/// use reconcile::{reconcile, BuiltinTokenizer};
|
||||
/// use reconcile_text::{reconcile, BuiltinTokenizer};
|
||||
///
|
||||
/// let parent = "Merging text is hard!";
|
||||
/// let left = "Merging text is easy!";
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
---
|
||||
source: reconcile/src/operations/edited_text.rs
|
||||
expression: operations
|
||||
snapshot_kind: text
|
||||
---
|
||||
EditedText {
|
||||
text: "hello world! How are you? Adam",
|
||||
operations: [
|
||||
OrderedOperation {
|
||||
order: 0,
|
||||
operation: Insert {
|
||||
index: 0,
|
||||
text: "Hello, my friend! ",
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 0,
|
||||
operation: Delete {
|
||||
index: 18,
|
||||
deleted_character_count: 13,
|
||||
deleted_text: Some(
|
||||
"hello world! ",
|
||||
),
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 21,
|
||||
operation: Delete {
|
||||
index: 26,
|
||||
deleted_character_count: 5,
|
||||
deleted_text: Some(
|
||||
"you? ",
|
||||
),
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 26,
|
||||
operation: Delete {
|
||||
index: 26,
|
||||
deleted_character_count: 5,
|
||||
deleted_text: Some(
|
||||
" Adam",
|
||||
),
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 31,
|
||||
operation: Insert {
|
||||
index: 26,
|
||||
text: "you ",
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 31,
|
||||
operation: Insert {
|
||||
index: 30,
|
||||
text: "doing? Albert",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
---
|
||||
source: reconcile/src/operations/operation_sequence.rs
|
||||
expression: operations
|
||||
snapshot_kind: text
|
||||
---
|
||||
EditedText {
|
||||
operations: [
|
||||
OrderedOperation {
|
||||
order: 0,
|
||||
operation: Insert {
|
||||
index: 0,
|
||||
text: "Hello, my friend! ",
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 0,
|
||||
operation: Delete {
|
||||
index: 18,
|
||||
deleted_character_count: 13,
|
||||
deleted_text: Some(
|
||||
"hello world! ",
|
||||
),
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 21,
|
||||
operation: Delete {
|
||||
index: 26,
|
||||
deleted_character_count: 5,
|
||||
deleted_text: Some(
|
||||
"you? ",
|
||||
),
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 26,
|
||||
operation: Delete {
|
||||
index: 26,
|
||||
deleted_character_count: 5,
|
||||
deleted_text: Some(
|
||||
" Adam",
|
||||
),
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 31,
|
||||
operation: Insert {
|
||||
index: 26,
|
||||
text: "you ",
|
||||
},
|
||||
},
|
||||
OrderedOperation {
|
||||
order: 31,
|
||||
operation: Insert {
|
||||
index: 30,
|
||||
text: "doing? Albert",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
---
|
||||
source: reconcile/src/tokenizer/word_tokenizer.rs
|
||||
expression: "word_tokenizer(\" hello, \\nwhere are you?\")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
[
|
||||
Token {
|
||||
normalised: " ",
|
||||
original: " ",
|
||||
},
|
||||
Token {
|
||||
normalised: "hello,",
|
||||
original: "hello,",
|
||||
},
|
||||
Token {
|
||||
normalised: " \n",
|
||||
original: " \n",
|
||||
},
|
||||
Token {
|
||||
normalised: "where",
|
||||
original: "where",
|
||||
},
|
||||
Token {
|
||||
normalised: " ",
|
||||
original: " ",
|
||||
},
|
||||
Token {
|
||||
normalised: "are",
|
||||
original: "are",
|
||||
},
|
||||
Token {
|
||||
normalised: " ",
|
||||
original: " ",
|
||||
},
|
||||
Token {
|
||||
normalised: "you?",
|
||||
original: "you?",
|
||||
},
|
||||
]
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
source: src/tokenizer/character_tokenizer.rs
|
||||
expression: "character_tokenizer(\"\")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
[]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
source: reconcile/src/tokenizer/word_tokenizer.rs
|
||||
source: src/tokenizer/word_tokenizer.rs
|
||||
expression: "word_tokenizer(\"\")"
|
||||
snapshot_kind: text
|
||||
---
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use pretty_assertions::assert_eq;
|
||||
use reconcile::{CursorPosition, EditedText, TextWithCursors};
|
||||
use reconcile_text::{CursorPosition, EditedText, TextWithCursors};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// `ExampleDocument` represents a test case for the reconciliation process.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ mod example_document;
|
|||
use std::{fs, path::Path};
|
||||
|
||||
use example_document::ExampleDocument;
|
||||
use reconcile::{BuiltinTokenizer, reconcile};
|
||||
use reconcile_text::{BuiltinTokenizer, reconcile};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![cfg(feature = "wasm")]
|
||||
|
||||
use reconcile::{BuiltinTokenizer, CursorPosition, TextWithCursors, wasm::*};
|
||||
use reconcile_text::{BuiltinTokenizer, CursorPosition, TextWithCursors, wasm::*};
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
#[wasm_bindgen_test(unsupported = test)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue