23 lines
1.9 KiB
Markdown
23 lines
1.9 KiB
Markdown
# Architecture
|
|
|
|
Diff Tools is a static React application with a relocatable `./` build. Its comparison pipeline is deliberately separated from the view:
|
|
|
|
1. The workbench captures strings or decodes a selected file as strict UTF-8 after a byte-size check.
|
|
2. A fresh module worker receives a plain comparison request. Changing input cancels and terminates the preceding worker; the last successful result remains on screen until a replacement succeeds.
|
|
3. A mode-specific pure comparator produces display rows and diagnostics. Normalized rows are first-class output, not discarded state.
|
|
4. The orchestrator adds exact input metadata, a bounded unified patch and a schema-labelled portable report.
|
|
5. React renders values as text. The app never consumes or inserts HTML produced by a diff or parser library.
|
|
|
|
When `Worker` is unavailable, such as in unit tests, the same pure comparator runs asynchronously on the calling thread.
|
|
|
|
## Comparators
|
|
|
|
- Text tokenizes lines without losing delimiters, or uses `Intl.Segmenter` for words and graphemes with bounded fallbacks. `diff` aligns token arrays.
|
|
- JSON uses `lossless-json`, rejects duplicate and prototype-affecting keys, and compares numbers without converting to IEEE-754. Object member order is semantically ignored but reported.
|
|
- XML rejects active declaration/include syntax and preflights structure before `@xmldom/xmldom` builds an inert DOM. Elements and attributes compare by expanded name when selected.
|
|
- CSV/TSV uses Papa Parse in string mode. Unique composite keys align rows; no spreadsheet type inference is performed.
|
|
|
|
All report and patch formats are generated locally. `de.add-ideas.diff-tools.report.v1` is the portable report schema identifier.
|
|
|
|
The planned shared `@add-ideas/toolbox-helpers` package is not yet published at a compatible version, so v0.1 keeps its bounded domain functions inside `src/core`. They can be extracted without changing the worker protocol or report schema.
|