Lint & fix typos

This commit is contained in:
Andras Schmelczer 2025-07-10 22:39:41 +01:00
commit 12c367db21
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 50 additions and 40 deletions

View file

@ -13,7 +13,7 @@ import wasmBytes from 'reconcile-text/reconcile_text_bg.wasm';
/**
* Represents a text document with associated cursor positions.
*
*
* This interface is used both as input to reconcile functions (to specify where
* cursors are positioned in the original documents) and as output (with cursors
* automatically repositioned after merging).
@ -21,7 +21,7 @@ import wasmBytes from 'reconcile-text/reconcile_text_bg.wasm';
export interface TextWithCursors {
/** The document's entire content as a string */
text: string;
/**
/**
* Array of cursor positions within the text. Can be null, undefined, or empty
* if there are no cursors to track. Each cursor has a unique ID and position.
*/
@ -30,7 +30,7 @@ export interface TextWithCursors {
/**
* Represents a cursor position within a text document.
*
*
* Cursors are automatically repositioned during text merging to maintain their
* relative positions as text is inserted, deleted, or modified around them.
*/
@ -43,7 +43,7 @@ export interface CursorPosition {
/**
* Represents a merged text document with cursor positions and detailed change history.
*
*
* This is the return type of `reconcileWithHistory()` and provides complete information
* about how the merge was performed, including which parts of the final text came from
* which source documents.
@ -51,12 +51,12 @@ export interface CursorPosition {
export interface TextWithCursorsAndHistory {
/** The merged document's entire content */
text: string;
/**
/**
* Array of cursor positions within the merged text. Can be null, undefined, or empty
* if there are no cursors to track. All cursors are automatically repositioned.
*/
cursors: null | undefined | CursorPosition[];
/**
/**
* Detailed provenance information showing the origin of each text span in the result.
* Each span indicates whether it was unchanged, added from left, added from right, etc.
*/
@ -65,7 +65,7 @@ export interface TextWithCursorsAndHistory {
/**
* Represents a span of text in the merged result with its change history.
*
*
* This shows exactly which source document contributed each piece of text to the
* final merged result. Useful for understanding merge decisions and creating
* visualisations of how documents were combined.
@ -73,8 +73,8 @@ export interface TextWithCursorsAndHistory {
export interface SpanWithHistory {
/** The text content of this span */
text: string;
/**
* The origin of this text span: "Unchanged" (from original), "AddedFromLeft",
/**
* The origin of this text span: "Unchanged" (from original), "AddedFromLeft",
* "AddedFromRight", "RemovedFromLeft", or "RemovedFromRight"
*/
history: History;
@ -82,7 +82,7 @@ export interface SpanWithHistory {
/**
* Tokenisation strategies for text merging.
*
*
* - "Word": Splits text on word boundaries (recommended for prose and most text)
* - "Character": Splits text into individual characters (fine-grained control)
* - "Line": Splits text into lines (similar to git merge or diff3)
@ -98,7 +98,7 @@ const UNSUPPORTED_TOKENIZER_ERROR = `Unsupported tokenizer. Only ${TOKENIZERS.jo
/**
* Merges three versions of text using intelligent conflict resolution.
*
*
* This is the primary function for 3-way text merging. Unlike traditional merge tools
* that produce conflict markers, this function automatically resolves conflicts by
* applying both sets of changes where possible.
@ -106,16 +106,16 @@ const UNSUPPORTED_TOKENIZER_ERROR = `Unsupported tokenizer. Only ${TOKENIZERS.jo
* @param original - The original/base version of the text that both sides diverged from
* @param left - The left version of the text (either string or TextWithCursors with cursor positions)
* @param right - The right version of the text (either string or TextWithCursors with cursor positions)
* @param tokenizer - The tokenisation strategy: "Word" (default, recommended for prose),
* @param tokenizer - The tokenisation strategy: "Word" (default, recommended for prose),
* "Character" (fine-grained), or "Line" (similar to git merge)
* @returns The reconciled text with automatically repositioned cursor positions
*
*
* @example
* ```typescript
* const original = "Hello world";
* const left = "Hello beautiful world"; // Added "beautiful"
* const right = "Hi world"; // Changed "Hello" to "Hi"
*
*
* const result = reconcile(original, left, right);
* console.log(result.text); // "Hi beautiful world"
* ```
@ -148,27 +148,27 @@ export function reconcile(
/**
* Merges three versions of text and returns detailed provenance information.
*
*
* This function behaves identically to `reconcile()` but additionally provides
* detailed historical information about the origin of each text span in the result.
* This is valuable for understanding how the merge was performed and which changes
* came from which source.
*
*
* Note: Computing the history is computationally more expensive than the basic merge.
*
* @param original - The original/base version of the text that both sides diverged from
* @param left - The left version of the text (either string or TextWithCursors with cursor positions)
* @param right - The right version of the text (either string or TextWithCursors with cursor positions)
* @param tokenizer - The tokenisation strategy: "Word" (default, recommended for prose),
* @param tokenizer - The tokenisation strategy: "Word" (default, recommended for prose),
* "Character" (fine-grained), or "Line" (similar to git merge)
* @returns The reconciled text with cursor positions and detailed change history
*
*
* @example
* ```typescript
* const original = "Hello world";
* const left = "Hello beautiful world";
* const right = "Hi world";
*
*
* const result = reconcileWithHistory(original, left, right);
* console.log(result.text); // "Hi beautiful world"
* console.log(result.history); // Array of SpanWithHistory objects showing change origins
@ -218,7 +218,7 @@ function init() {
}
function toWasmTextWithCursors(text: string | TextWithCursors): wasmTextWithCursors {
const isInputString = typeof text == 'string';
const isInputString = typeof text === 'string';
const leftText = isInputString ? text : text.text;
const leftCursors = isInputString ? [] : (text.cursors ?? []);