vultus-core 0.5.7 → 0.5.8

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.
Files changed (65) hide show
  1. package/README.md +191 -5
  2. package/dist/Components.d.ts +41 -0
  3. package/dist/Components.d.ts.map +1 -1
  4. package/dist/Components.js.map +1 -1
  5. package/dist/changes/ChangeMark.d.ts +85 -0
  6. package/dist/changes/ChangeMark.d.ts.map +1 -0
  7. package/dist/changes/ChangeMark.js +113 -0
  8. package/dist/changes/ChangeMark.js.map +1 -0
  9. package/dist/changes/ChangingText.d.ts +20 -0
  10. package/dist/changes/ChangingText.d.ts.map +1 -0
  11. package/dist/changes/ChangingText.js +31 -0
  12. package/dist/changes/ChangingText.js.map +1 -0
  13. package/dist/changes/FallbackMark.d.ts +20 -0
  14. package/dist/changes/FallbackMark.d.ts.map +1 -0
  15. package/dist/changes/FallbackMark.js +53 -0
  16. package/dist/changes/FallbackMark.js.map +1 -0
  17. package/dist/changes/blocks.d.ts +15 -0
  18. package/dist/changes/blocks.d.ts.map +1 -0
  19. package/dist/changes/blocks.js +24 -0
  20. package/dist/changes/blocks.js.map +1 -0
  21. package/dist/changes/changeDurations.d.ts +21 -0
  22. package/dist/changes/changeDurations.d.ts.map +1 -0
  23. package/dist/changes/changeDurations.js +18 -0
  24. package/dist/changes/changeDurations.js.map +1 -0
  25. package/dist/changes/changesIn.d.ts +88 -0
  26. package/dist/changes/changesIn.d.ts.map +1 -0
  27. package/dist/changes/changesIn.js +470 -0
  28. package/dist/changes/changesIn.js.map +1 -0
  29. package/dist/changes/readText.d.ts +45 -0
  30. package/dist/changes/readText.d.ts.map +1 -0
  31. package/dist/changes/readText.js +99 -0
  32. package/dist/changes/readText.js.map +1 -0
  33. package/dist/changes/rehypeChanges.d.ts +81 -0
  34. package/dist/changes/rehypeChanges.d.ts.map +1 -0
  35. package/dist/changes/rehypeChanges.js +268 -0
  36. package/dist/changes/rehypeChanges.js.map +1 -0
  37. package/dist/changes/useTextChanges.d.ts +93 -0
  38. package/dist/changes/useTextChanges.d.ts.map +1 -0
  39. package/dist/changes/useTextChanges.js +154 -0
  40. package/dist/changes/useTextChanges.js.map +1 -0
  41. package/dist/changes/visibleBlocks.d.ts +42 -0
  42. package/dist/changes/visibleBlocks.d.ts.map +1 -0
  43. package/dist/changes/visibleBlocks.js +104 -0
  44. package/dist/changes/visibleBlocks.js.map +1 -0
  45. package/dist/changes.d.ts +9 -0
  46. package/dist/changes.d.ts.map +1 -0
  47. package/dist/changes.js +10 -0
  48. package/dist/changes.js.map +1 -0
  49. package/dist/index.d.ts +3 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js.map +1 -1
  52. package/package.json +13 -1
  53. package/src/Components.tsx +45 -0
  54. package/src/changes/ChangeMark.tsx +165 -0
  55. package/src/changes/ChangingText.tsx +46 -0
  56. package/src/changes/FallbackMark.tsx +59 -0
  57. package/src/changes/blocks.ts +25 -0
  58. package/src/changes/changeDurations.ts +31 -0
  59. package/src/changes/changesIn.ts +479 -0
  60. package/src/changes/readText.ts +123 -0
  61. package/src/changes/rehypeChanges.ts +302 -0
  62. package/src/changes/useTextChanges.ts +239 -0
  63. package/src/changes/visibleBlocks.ts +121 -0
  64. package/src/changes.ts +14 -0
  65. package/src/index.ts +4 -0
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, version } from 'react';
3
+ /** The fallback's colours: fixed, whatever the theme, and translucent, so they read on a light and
4
+ * a dark background alike (GitHub's diff green and red). */
5
+ const ADDED = 'rgba(46, 160, 67, 0.3)';
6
+ const REMOVED = 'rgba(248, 81, 73, 0.3)';
7
+ /** Each variant's inline style. Every one sets the colour and the background, so a `mark`'s own
8
+ * (the browser's `Mark` and `MarkText`) never show: a word and its letters in it add up, the
9
+ * letters the stronger. */
10
+ const STYLES = {
11
+ change: { color: 'inherit', backgroundColor: ADDED },
12
+ 'change-strong': { color: 'inherit', backgroundColor: ADDED },
13
+ 'change-added': { color: 'inherit', backgroundColor: ADDED },
14
+ 'change-removed': {
15
+ color: 'inherit', backgroundColor: REMOVED, textDecoration: 'line-through', WebkitUserSelect: 'none', userSelect: 'none',
16
+ },
17
+ 'change-replaced': { color: 'inherit', backgroundColor: 'transparent' },
18
+ };
19
+ /** Removed letters inside a replacement: not displayed, the replacement drawn as its new letters. */
20
+ const HIDDEN = { ...STYLES['change-removed'], display: 'none' };
21
+ /** Whether a mark is inside a replacement (`change-replaced`). */
22
+ const InReplacement = createContext(false);
23
+ /**
24
+ * `inert` as a React of `reactVersion` takes it: a boolean from 19 on; 18 drops a boolean (with a
25
+ * warning) and needs the empty string, which 19 reads as false. Exported for its test only.
26
+ */
27
+ export function inertProps(reactVersion) {
28
+ const props = Number.parseInt(reactVersion, 10) >= 19 ? { inert: true } : { inert: '' };
29
+ return props;
30
+ }
31
+ const inert = inertProps(version);
32
+ /**
33
+ * vultus's change mark, for a page that lends none (`VultusComponents`' `ChangeMark`): static marks
34
+ * in inline styles, no stylesheet and no animation (`timeline` and `speed` change nothing; its
35
+ * timings are vultus's defaults, `changeDurations`). A `mark` carrying `data-change`:
36
+ * - `change`, `change-strong` and `change-added`, a translucent green background;
37
+ * - `change-removed`, a translucent red background, struck through; hidden from assistive
38
+ * technology, the tab order and a selection (`aria-hidden`, `inert`, `user-select: none`): the
39
+ * old letters are not the page's text;
40
+ * - `change-replaced`, drawn as its new letters: no background of its own, the old letters in it
41
+ * not displayed.
42
+ */
43
+ export function FallbackMark({ variant, 'data-change': change, children }) {
44
+ const replacing = useContext(InReplacement);
45
+ if (variant === 'change-replaced') {
46
+ return _jsx("mark", { "data-change": change, style: STYLES[variant], children: _jsx(InReplacement.Provider, { value: true, children: children }) });
47
+ }
48
+ if (variant === 'change-removed') {
49
+ return _jsx("mark", { "data-change": change, style: replacing ? HIDDEN : STYLES[variant], "aria-hidden": "true", ...inert, children: children });
50
+ }
51
+ return _jsx("mark", { "data-change": change, style: STYLES[variant], children: children });
52
+ }
53
+ //# sourceMappingURL=FallbackMark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackMark.js","sourceRoot":"","sources":["../../src/changes/FallbackMark.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAA8D,MAAM,OAAO,CAAC;AAGvH;6DAC6D;AAC7D,MAAM,KAAK,GAAG,wBAAwB,CAAC;AACvC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAEzC;;4BAE4B;AAC5B,MAAM,MAAM,GAAuD;IACjE,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE;IACpD,eAAe,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE;IAC7D,cAAc,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE;IAC5D,gBAAgB,EAAE;QAChB,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;KACzH;IACD,iBAAiB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE;CACxE,CAAC;AAEF,qGAAqG;AACrG,MAAM,MAAM,GAAkB,EAAE,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAE/E,kEAAkE;AAClE,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE3C;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,YAAoB;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACxF,OAAO,KAA8D,CAAC;AACxE,CAAC;AAED,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;AAElC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAmB;IACxF,MAAM,SAAS,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC5C,IAAI,OAAO,KAAK,iBAAiB,EAAE,CAAC;QAClC,OAAO,8BAAmB,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,YAAE,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,kBAAE,QAAQ,GAA0B,GAAO,CAAC;IACrI,CAAC;IACD,IAAI,OAAO,KAAK,gBAAgB,EAAE,CAAC;QACjC,OAAO,8BAAmB,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAc,MAAM,KAAK,KAAK,YAAG,QAAQ,GAAQ,CAAC;IACjI,CAAC;IACD,OAAO,8BAAmB,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,YAAG,QAAQ,GAAQ,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The block elements: a hard feed before and after each in the reading (`readText`), so that no
3
+ * change runs across one's edge.
4
+ */
5
+ export declare const BLOCK_ELEMENTS: ReadonlySet<string>;
6
+ /** Elements holding blocks, not text: the white space among their children (remark-rehype's line
7
+ * ends) is never marked (a mark there would draw an empty line). */
8
+ export declare const HOLDS_BLOCKS: ReadonlySet<string>;
9
+ /**
10
+ * The blocks the changes plugin numbers by default (`data-vultus-block`, pre-order from 1), which a
11
+ * near set names: what the reader's eye rests on. A quote and the paragraph in it, a list item and
12
+ * a nested item, are each one.
13
+ */
14
+ export declare const NUMBERED_BLOCKS: ReadonlySet<string>;
15
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/changes/blocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAK7C,CAAC;AAEH;qEACqE;AACrE,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAE3C,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAE9C,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The block elements: a hard feed before and after each in the reading (`readText`), so that no
3
+ * change runs across one's edge.
4
+ */
5
+ export const BLOCK_ELEMENTS = new Set([
6
+ 'address', 'article', 'aside', 'blockquote', 'caption', 'dd', 'details', 'div', 'dl', 'dt', 'fieldset',
7
+ 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr',
8
+ 'li', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'summary', 'table', 'tbody', 'td', 'tfoot', 'th',
9
+ 'thead', 'tr', 'ul',
10
+ ]);
11
+ /** Elements holding blocks, not text: the white space among their children (remark-rehype's line
12
+ * ends) is never marked (a mark there would draw an empty line). */
13
+ export const HOLDS_BLOCKS = new Set([
14
+ 'blockquote', 'ul', 'ol', 'table', 'thead', 'tbody', 'tfoot', 'tr', 'section', 'div',
15
+ ]);
16
+ /**
17
+ * The blocks the changes plugin numbers by default (`data-vultus-block`, pre-order from 1), which a
18
+ * near set names: what the reader's eye rests on. A quote and the paragraph in it, a list item and
19
+ * a nested item, are each one.
20
+ */
21
+ export const NUMBERED_BLOCKS = new Set([
22
+ 'p', 'li', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'td', 'th',
23
+ ]);
24
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/changes/blocks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IACzD,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU;IACtG,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI;IACtG,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI;IAClG,OAAO,EAAE,IAAI,EAAE,IAAI;CACpB,CAAC,CAAC;AAEH;qEACqE;AACrE,MAAM,CAAC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IACvD,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK;CACrF,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IAC1D,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI;CAC/E,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ChangeMarkComponent } from '../Components.js';
2
+ /** How fast a switch's marks run (the lent mark's `speed`, `useTextChanges`' `speed`): `normal` by
3
+ * default. What each speed's times are is the lent mark's: its look, and its `durations`. */
4
+ export type ChangeSpeed = 'slow' | 'normal' | 'fast';
5
+ /** When a switch's marks may go, in ms from the commit that shows the new text: on the `plain`
6
+ * timeline (no removed letters) and on `removals`. */
7
+ export interface ChangeDurations {
8
+ plain: number;
9
+ removals: number;
10
+ }
11
+ /**
12
+ * When a switch's marks may go: the lent mark's (`mark`, the `ChangeMark` an app lends through
13
+ * `VultusComponents`) `durations(element, speed)`, the timings of its look, read at `element` (the
14
+ * near container, else none) at `speed` (`normal` by default).
15
+ *
16
+ * Without a mark, or one that gives no `durations`, vultus's defaults: 1.55 s on the plain timeline
17
+ * and 2.3 s on removals, at every speed, so a page without a look still ends a switch and its marks
18
+ * go. A new object each call.
19
+ */
20
+ export declare function changeDurations(element?: Element, speed?: ChangeSpeed, mark?: ChangeMarkComponent): ChangeDurations;
21
+ //# sourceMappingURL=changeDurations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeDurations.d.ts","sourceRoot":"","sources":["../../src/changes/changeDurations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D;8FAC8F;AAC9F,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErD;uDACuD;AACvD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAQD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,GAAE,WAAsB,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,eAAe,CAE7H"}
@@ -0,0 +1,18 @@
1
+ /** vultus's timings, in ms, for a page whose mark gives none: a change highlight's at normal
2
+ * speed, as a style library's lent mark runs it, the end of its timeline plus 0.5 s. `plain`:
3
+ * hold 0.3 s and fade 0.75 s; `removals`: remove-hold 0.15 s, squeeze 0.3 s and grow 0.3 s before
4
+ * them. */
5
+ const DEFAULTS = { plain: 1550, removals: 2300 };
6
+ /**
7
+ * When a switch's marks may go: the lent mark's (`mark`, the `ChangeMark` an app lends through
8
+ * `VultusComponents`) `durations(element, speed)`, the timings of its look, read at `element` (the
9
+ * near container, else none) at `speed` (`normal` by default).
10
+ *
11
+ * Without a mark, or one that gives no `durations`, vultus's defaults: 1.55 s on the plain timeline
12
+ * and 2.3 s on removals, at every speed, so a page without a look still ends a switch and its marks
13
+ * go. A new object each call.
14
+ */
15
+ export function changeDurations(element, speed = 'normal', mark) {
16
+ return mark?.durations ? mark.durations(element, speed) : { ...DEFAULTS };
17
+ }
18
+ //# sourceMappingURL=changeDurations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changeDurations.js","sourceRoot":"","sources":["../../src/changes/changeDurations.ts"],"names":[],"mappings":"AAaA;;;YAGY;AACZ,MAAM,QAAQ,GAA8B,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,OAAiB,EAAE,QAAqB,QAAQ,EAAE,IAA0B;IAC1G,OAAO,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,88 @@
1
+ /** How much of a change is marked: the changed word whole, or only its changed letters; or the
2
+ * old letters that went (`removed`), at their place. And, a mark's alone (`rehypeChanges`'s; no
3
+ * `Change` has it), a replacement (`replaced`): the old letters and the new ones that took their
4
+ * place, in one mark around the two. */
5
+ export type ChangeLevel = 'word' | 'letters' | 'removed' | 'replaced';
6
+ /** A span of the new text (UTF-16 offsets, `end` exclusive) that differs from the old one; a
7
+ * `removed` one has no width (`start === end`), its place in the new text. */
8
+ export interface Change {
9
+ start: number;
10
+ end: number;
11
+ level: ChangeLevel;
12
+ /** The old letters that went at this place: a `removed` change's alone. */
13
+ text?: string;
14
+ }
15
+ /** A word, or one punctuation character, of a text, by its offsets. */
16
+ export interface Token {
17
+ start: number;
18
+ end: number;
19
+ word: boolean;
20
+ }
21
+ /**
22
+ * Splits a text into the units the comparison works on: a word is a run of letters, combining
23
+ * marks and digits, every other run of non-space characters is punctuation, one token per
24
+ * character, white space is no token. So "napról-napra" is a word, a hyphen and a word, and the
25
+ * hyphen's going is a change of its own that marks no word.
26
+ */
27
+ export declare function tokens(text: string): Token[];
28
+ /**
29
+ * Whether the character at an offset of `text` is white space that ends a line: each character of
30
+ * a white-space run holding '\n' or '\r' (a hard boundary, `changesIn`). Computed once per text.
31
+ */
32
+ export declare function lineEnds(text: string): (at: number) => boolean;
33
+ /**
34
+ * What changed between two versions of a text, as spans of the new one at two levels (GitHub-diff
35
+ * style): `word` spans, the changed words whole, never overlapping; and inside them `letters`
36
+ * spans, the changed letters. Compared word by word (each distinct token one character of an
37
+ * alphabet, so diff-match-patch's line-of-characters speed carries over to words), then, per
38
+ * change, letter by letter. A change that only inserts marks its words at both levels; one that
39
+ * replaces words is compared letter by letter, only the letters that differ marked ("Ferencz" to
40
+ * "Ferenc": the "z" removed and nothing lit).
41
+ * A change replaced whole (`WHOLE_WORD_SHARE` of the new run's letters put in, or of the old
42
+ * run's removed: "t. i." to "tudniillik" and back) is one span, its new run lit whole and the old
43
+ * one removed whole before it, when short (`WHOLE_RUN_LENGTH`); otherwise a word more than
44
+ * `WHOLE_WORD_SHARE` of whose letters are new is marked whole at the letter level, the old text it
45
+ * stands for removed before it. A split, one old word become several ("jóhirű" to "jó
46
+ * hírű": a space put in between two old letters), is one `word` span over the new run, the space
47
+ * among its letters, growing in as they do. Punctuation alone is never
48
+ * marked: a change of punctuation alone marks nothing ("napról-napra" to "napról napra").
49
+ *
50
+ * A changed word's `word` span runs from white space to white space, on every switch: the
51
+ * punctuation touching it (a comma, an opening quote)
52
+ * is inside its mark, lit lightly with it ("hivei," to "hívei,": "hívei,"), never at the letter
53
+ * level; a line may break around the lent mark's removal pieces, so a comma outside the mark could
54
+ * start the next line. The changed words of one run of non-space characters share one span. A new
55
+ * word in place of nothing (put in, or marked whole with no old text before it) holds one space
56
+ * beside it in both its spans, the one between it and the next token (at the end, the one between
57
+ * the token before and it: "a b" to "a b új", " új"), so that growing in from no width it leaves
58
+ * one space between its neighbours, not two.
59
+ *
60
+ * A line feed in `to` is a hard boundary (`lineEnds`: every character of a white-space run holding
61
+ * '\n' or '\r'). The reading (`readText`) puts one exactly where a line really ends: between
62
+ * blocks, at a `br`, at a code line's end. A line feed in a mark would be written as a space and
63
+ * join the lines, so a new word takes no such space, and neither a split nor a run replaced whole
64
+ * is one span across one (the run is lit word by word, as a long one is). Only hard boundaries
65
+ * moved (a paragraph split or joined) is no change: white space is no token.
66
+ *
67
+ * And what went: the old letters each change removed, as `removed` changes of no width at their
68
+ * place in the new text, carrying them (`text`, its white space collapsed: never a line feed,
69
+ * which the lent mark's pieces may keep as a break). Inside a changed word, before the letters
70
+ * that replaced them ("hivei" to "hívei": the "i" before the "í"; "katholikus" to "katolikus": the
71
+ * "h" between "t" and "o"), white space and punctuation too (a space joined away: "szent
72
+ * áldozásban" to "szentáldozásban"), never between a letter and its combining mark; at a word
73
+ * marked whole, the old text it replaced, whole, before it ("t. i." before "tudniillik"). What
74
+ * went outside every word's span is not shown. A change that removed
75
+ * words and put in none (a word removed altogether) gets a `word` span of no width at the start
76
+ * of the token after it (past the last one, at the end of the text), holding the run with the
77
+ * space that separated it: after it ("a b c" to "a c": "b "), or before it where nothing separates
78
+ * the place from the token before it (at the end: "a b c" to "a b", " c"; before punctuation:
79
+ * "mondta ő, hogy" to "mondta, hogy", " ő"), so it sits between its neighbours as it did. A run
80
+ * that touched the token before it (punctuation first) goes at that token's end instead, with no
81
+ * space after it ("Péter, a halász, mondta" to "Péter mondta": ", a halász,"). So does a run that
82
+ * ended its line, where the new text keeps that line end, with the space before it: a word removed
83
+ * at a paragraph's end stays in that paragraph ("a b\nc d" to "a\nc d": " b"); a line end only the
84
+ * old text had places nothing ("a b\nc d" to "a d": "b c "). More distinct tokens than there are
85
+ * code units to stand for them gives `[]`: no marks rather than a wrong or a slow diff.
86
+ */
87
+ export declare function changesIn(from: string, to: string): Change[];
88
+ //# sourceMappingURL=changesIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changesIn.d.ts","sourceRoot":"","sources":["../../src/changes/changesIn.ts"],"names":[],"mappings":"AAEA;;;yCAGyC;AACzC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAEtE;+EAC+E;AAC/E,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,WAAW,CAAC;IACnB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,uEAAuE;AACvE,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACf;AA2BD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,CAM5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAO9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CA+D5D"}