@noldova/code.editor.diff 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +21 -2
- package/api/index.d.ts +678 -0
- package/api/index.js +18 -0
- package/api/index.js.map +1 -0
- package/enums/diff-side.js +13 -0
- package/enums/diff-side.js.map +1 -0
- package/models/change-ranges.js +16 -0
- package/models/change-ranges.js.map +1 -0
- package/models/line-change.js +35 -0
- package/models/line-change.js.map +1 -0
- package/models/line-diff-input.js +16 -0
- package/models/line-diff-input.js.map +1 -0
- package/models/unchanged-region.js +18 -0
- package/models/unchanged-region.js.map +1 -0
- package/package.json +31 -4
- package/resources.js +26 -0
- package/resources.js.map +1 -0
- package/services/change-mapper.js +67 -0
- package/services/change-mapper.js.map +1 -0
- package/services/default-diff-algorithm.js +20 -0
- package/services/default-diff-algorithm.js.map +1 -0
- package/services/diff-contribution.js +19 -0
- package/services/diff-contribution.js.map +1 -0
- package/services/document-diff.js +209 -0
- package/services/document-diff.js.map +1 -0
- package/services/line-change-codec.js +33 -0
- package/services/line-change-codec.js.map +1 -0
- package/services/line-diff-job.js +30 -0
- package/services/line-diff-job.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @noldova/code.editor.diff
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The code editor's framework-free comparison of two documents. `DocumentDiff` finds the changed lines, the changed characters inside each change, and the unchanged regions a view can fold. While a comparison runs, its last changes move through each edit, so the marks stay on their lines while a person types.
|
|
4
|
+
It edits nothing, has no DOM, and runs in a page, a worker or Node.
|
|
5
|
+
`@noldova/code.editor.diff.angular` shows it.
|
|
6
|
+
[documents/ARCHITECTURE.md](../../documents/ARCHITECTURE.md) says how its parts fit together.
|
|
7
|
+
|
|
8
|
+
## The algorithm
|
|
9
|
+
|
|
10
|
+
The line and character diffs come from an `IDiffAlgorithm`, which has two calls, `lines` and `characters`. `DefaultDiffAlgorithm`, over `@noldova/diff`, is the default. A host can give its own algorithm to `DocumentDiff`.
|
|
11
|
+
|
|
12
|
+
## Where the diff runs
|
|
13
|
+
|
|
14
|
+
Every comparison goes through an `IBackgroundRunner` from `@noldova/code.editor`, as a `LineDiffJob`.
|
|
15
|
+
- In the browser, `@noldova/code.editor.diff.angular`'s diff editor uses a worker. That is the default path, so the page never waits for the diff.
|
|
16
|
+
- Without a worker, as in tests and server rendering, the default `SlicedRunner` runs the job on the calling thread, a slice at a time. The slices fall around the algorithm's single `lines` call, not inside it, so one large diff still holds the thread for its whole time. noldova-com/diff#8 asks for a resumable diff that would let the slices reach inside the diff too.
|
|
17
|
+
|
|
18
|
+
A worker runs the default algorithm's job. For a host's own algorithm, its worker script must serve a `LineDiffJob` of that algorithm, or the job runs on the calling thread instead.
|
|
19
|
+
|
|
20
|
+
## Settings
|
|
21
|
+
|
|
22
|
+
The diff editor reads three settings for the diff and passes them in: `diff.contextLines`, the unchanged lines kept next to a change (3); `diff.minimumHiddenLines`, the fewest lines a fold hides (3); and `diff.characterDiffLimit`, the most characters of a change compared by character (20,000), which is `DocumentDiff.characterDiffLimit`.
|