linked-rolls 0.63.0 → 0.64.0
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/README.md +13 -5
- package/lib/analysis/constraints.d.ts +2 -2
- package/lib/analysis/constraints.js +17 -14
- package/lib/analysis/ownPaper.d.ts +3 -3
- package/lib/analysis/ownPaper.js +3 -3
- package/lib/analysis/reservations.d.ts +2 -2
- package/lib/analysis/reservations.js +6 -6
- package/lib/analysis/sigla.d.ts +4 -5
- package/lib/analysis/sigla.js +4 -4
- package/lib/analysis/stemma.d.ts +22 -0
- package/lib/analysis/stemma.js +38 -0
- package/lib/analysis/text.d.ts +31 -0
- package/lib/analysis/text.js +62 -0
- package/lib/analysis/witnesses.d.ts +5 -5
- package/lib/analysis/witnesses.js +22 -20
- package/lib/collation/scatter.d.ts +4 -4
- package/lib/collation/scatter.js +15 -13
- package/lib/emulation/Emulation.d.ts +7 -7
- package/lib/emulation/Emulation.js +29 -27
- package/lib/emulation/negotiation.d.ts +2 -2
- package/lib/emulation/negotiation.js +3 -2
- package/lib/index.d.ts +4 -1
- package/lib/index.js +4 -1
- package/lib/io/asJsonLd.js +11 -1
- package/lib/io/importJsonLd.js +11 -1
- package/lib/lookup/lookup.d.ts +32 -0
- package/lib/lookup/lookup.js +40 -0
- package/lib/lookup/paths.d.ts +11 -0
- package/lib/lookup/paths.js +78 -0
- package/lib/lookup/perState.d.ts +32 -0
- package/lib/lookup/perState.js +63 -0
- package/lib/model/Edit.d.ts +4 -0
- package/lib/model/Version.d.ts +7 -1
- package/lib/ops/beliefs.d.ts +1 -1
- package/lib/ops/beliefs.js +1 -1
- package/lib/ops/collation.d.ts +3 -4
- package/lib/ops/collation.js +25 -23
- package/lib/ops/commands.d.ts +4 -5
- package/lib/ops/commands.js +10 -10
- package/lib/ops/draft.d.ts +12 -12
- package/lib/ops/draft.js +11 -13
- package/lib/ops/edits.d.ts +1 -2
- package/lib/ops/edits.js +13 -10
- package/lib/ops/features.d.ts +2 -2
- package/lib/ops/features.js +3 -2
- package/lib/ops/index.d.ts +1 -1
- package/lib/ops/index.js +6 -0
- package/lib/ops/versions.d.ts +2 -3
- package/lib/ops/versions.js +6 -5
- package/lib/schema.json +2 -2
- package/package.json +1 -1
- package/lib/view/EditionView.d.ts +0 -103
- package/lib/view/EditionView.js +0 -329
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ single undo step.
|
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
import { produce } from 'immer'
|
|
25
|
-
import { alignCopy, asJsonLd, connectVersions, createVersion,
|
|
25
|
+
import { alignCopy, asJsonLd, connectVersions, createVersion, importJsonLd, readFromStanfordAton, snapshotOf } from 'linked-rolls'
|
|
26
26
|
|
|
27
27
|
let edition = importJsonLd(json)
|
|
28
28
|
|
|
@@ -32,13 +32,21 @@ const copy = readFromStanfordAton(aton)
|
|
|
32
32
|
edition = produce(edition, createVersion(copy))
|
|
33
33
|
edition = produce(edition, alignCopy(copy.id))
|
|
34
34
|
|
|
35
|
-
// Collate that version against another one
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
// Collate that version against another one, and read what it shows
|
|
36
|
+
edition = produce(edition, connectVersions(childId, parentId))
|
|
37
|
+
const symbols = snapshotOf(edition, childId)
|
|
38
38
|
|
|
39
39
|
const document = asJsonLd(edition)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
What is read off an edition, such as `snapshotOf`, `placeOf`,
|
|
43
|
+
`versionIn` or `pathIn`, is worked out once for each state of it and
|
|
44
|
+
kept for as long as the state is. Every change through `produce` yields
|
|
45
|
+
a new state, so nothing needs to be told that the edition changed. For
|
|
46
|
+
the same reason an edition is frozen once anything has been asked of it,
|
|
47
|
+
as immer freezes what it produces: change it through an operation, not
|
|
48
|
+
in place. A draft is asked about as `stateOf(draft)`.
|
|
49
|
+
|
|
42
50
|
Within the library every place along the roll is a place on the edition's
|
|
43
51
|
axis, the millimetres of its reference copy. A document holds each copy's
|
|
44
52
|
features at the copy's own places, as they were read, together with the
|
|
@@ -65,7 +73,7 @@ optional peer dependency that you install only if you need playback.
|
|
|
65
73
|
import { emulate, midiOf } from 'linked-rolls'
|
|
66
74
|
import { welteT100System } from 'linked-rolls/welte-t100'
|
|
67
75
|
|
|
68
|
-
const { events, source } = emulate(welteT100System, version,
|
|
76
|
+
const { events, source } = emulate(welteT100System, version, edition)
|
|
69
77
|
const midi = midiOf(events, welteT100System.name, welteT100System.defaultOptions, source)
|
|
70
78
|
```
|
|
71
79
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Edition } from "../model/Edition.js";
|
|
2
2
|
export type ConstraintProblem = {
|
|
3
3
|
version: string;
|
|
4
4
|
symbol: string;
|
|
@@ -14,4 +14,4 @@ export type ConstraintProblem = {
|
|
|
14
14
|
* track that does not say what its symbol says, and a strike that takes
|
|
15
15
|
* nothing out.
|
|
16
16
|
*/
|
|
17
|
-
export declare const constraintProblems: (
|
|
17
|
+
export declare const constraintProblems: (edition: Edition) => ConstraintProblem[];
|
|
@@ -6,6 +6,9 @@ import { keyOf } from "../systems/TrackerBar.js";
|
|
|
6
6
|
import { trackerBarOf } from "../systems/index.js";
|
|
7
7
|
import { barOf } from "../model/RollCopy.js";
|
|
8
8
|
import { deletedBy, insertedBy } from "../model/Version.js";
|
|
9
|
+
import { predecessorOf } from "./stemma.js";
|
|
10
|
+
import { placedCarriersOf, snapshotOf } from "./text.js";
|
|
11
|
+
import { copyOfFeature } from "../lookup/lookup.js";
|
|
9
12
|
const missingReference = {
|
|
10
13
|
alignedWith: 'alignment-reference-missing',
|
|
11
14
|
before: 'before-reference-missing',
|
|
@@ -77,9 +80,9 @@ const typesNotOnTheBar = (version, snapshot) => {
|
|
|
77
80
|
* out says 59. Collation across systems consults only the place, so
|
|
78
81
|
* without this nothing checks the tracks at all.
|
|
79
82
|
*/
|
|
80
|
-
const carriersOffTheirMeaning = (
|
|
83
|
+
const carriersOffTheirMeaning = (edition, version, commands) => {
|
|
81
84
|
const misread = (carrier, symbol) => {
|
|
82
|
-
const copy =
|
|
85
|
+
const copy = copyOfFeature(edition, carrier.id);
|
|
83
86
|
if (!copy)
|
|
84
87
|
return false;
|
|
85
88
|
// A carrier lying across several positions reads as several commands,
|
|
@@ -88,7 +91,7 @@ const carriersOffTheirMeaning = (view, version, commands) => {
|
|
|
88
91
|
.some(meaning => keyOf(meaning) === keyOf(symbol));
|
|
89
92
|
};
|
|
90
93
|
return commands
|
|
91
|
-
.filter(symbol =>
|
|
94
|
+
.filter(symbol => placedCarriersOf(edition, symbol).some(carrier => misread(carrier, symbol)))
|
|
92
95
|
.map(symbol => ({ version, symbol: symbol.id, problem: 'carrier-on-another-track' }));
|
|
93
96
|
};
|
|
94
97
|
/**
|
|
@@ -101,9 +104,9 @@ const carriersOffTheirMeaning = (view, version, commands) => {
|
|
|
101
104
|
* speed, and averaging it in would hide both that and the fact that the
|
|
102
105
|
* playback rests on a guess.
|
|
103
106
|
*/
|
|
104
|
-
const paperDisagreed = (
|
|
105
|
-
const own = new Set(paperOfVersion(
|
|
106
|
-
return alignmentProblems(
|
|
107
|
+
const paperDisagreed = (edition, version) => {
|
|
108
|
+
const own = new Set(paperOfVersion(edition, version)?.copies ?? []);
|
|
109
|
+
return alignmentProblems(edition)
|
|
107
110
|
.some(({ copy, problem }) => problem === 'paper-beyond-its-spread' && own.has(copy))
|
|
108
111
|
? [{ version: version.id, symbol: version.id, problem: 'copies-disagree-on-the-paper' }]
|
|
109
112
|
: [];
|
|
@@ -120,10 +123,10 @@ const paperDisagreed = (view, version) => {
|
|
|
120
123
|
* into the text unstruck. Nothing else in the edition shows it: the
|
|
121
124
|
* counts move, and only by a handful.
|
|
122
125
|
*/
|
|
123
|
-
const strikesBitingNothing = (
|
|
124
|
-
const parent =
|
|
126
|
+
const strikesBitingNothing = (edition, version) => {
|
|
127
|
+
const parent = predecessorOf(edition, version.id);
|
|
125
128
|
const reachable = new Set([
|
|
126
|
-
...(parent ?
|
|
129
|
+
...(parent ? snapshotOf(edition, parent.id).map(symbol => symbol.id) : []),
|
|
127
130
|
...insertedBy(version).map(symbol => symbol.id)
|
|
128
131
|
]);
|
|
129
132
|
return deletedBy(version)
|
|
@@ -140,14 +143,14 @@ const strikesBitingNothing = (view, version) => {
|
|
|
140
143
|
* track that does not say what its symbol says, and a strike that takes
|
|
141
144
|
* nothing out.
|
|
142
145
|
*/
|
|
143
|
-
export const constraintProblems = (
|
|
144
|
-
const snapshot =
|
|
146
|
+
export const constraintProblems = (edition) => edition.versions.flatMap(version => {
|
|
147
|
+
const snapshot = snapshotOf(edition, version.id);
|
|
145
148
|
const commands = snapshot.filter(isCommand);
|
|
146
149
|
return [
|
|
147
150
|
...problemsIn(version.id, commands),
|
|
148
151
|
...typesNotOnTheBar(version, snapshot),
|
|
149
|
-
...carriersOffTheirMeaning(
|
|
150
|
-
...paperDisagreed(
|
|
151
|
-
...strikesBitingNothing(
|
|
152
|
+
...carriersOffTheirMeaning(edition, version.id, commands),
|
|
153
|
+
...paperDisagreed(edition, version),
|
|
154
|
+
...strikesBitingNothing(edition, version)
|
|
152
155
|
];
|
|
153
156
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { EditionView } from "../view/EditionView.js";
|
|
2
1
|
import type { Version } from "../model/Version.js";
|
|
3
2
|
import { PaperOfSystem } from "./paper.js";
|
|
3
|
+
import { Edition } from "../model/Edition.js";
|
|
4
4
|
/** What the alignments say about the paper of the version's own system, where they say anything. */
|
|
5
|
-
export declare const paperOfVersion: (
|
|
5
|
+
export declare const paperOfVersion: (edition: Edition, version: Readonly<Version>) => PaperOfSystem | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* How a place on the edition's shared axis relates to the paper of
|
|
8
8
|
* this version: place × factor = millimetres of its own paper.
|
|
@@ -18,4 +18,4 @@ export declare const paperOfVersion: (view: EditionView, version: Readonly<Versi
|
|
|
18
18
|
* Nothing where no copy of the version's system measures its paper,
|
|
19
19
|
* which leaves the performance on the axis.
|
|
20
20
|
*/
|
|
21
|
-
export declare const toOwnPaperOf: (
|
|
21
|
+
export declare const toOwnPaperOf: (edition: Edition, version: Readonly<Version>) => number | undefined;
|
package/lib/analysis/ownPaper.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defaultTrackerBar, trackerBarOf } from "../systems/index.js";
|
|
2
2
|
import { paperOf } from "./paper.js";
|
|
3
3
|
/** What the alignments say about the paper of the version's own system, where they say anything. */
|
|
4
|
-
export const paperOfVersion = (
|
|
4
|
+
export const paperOfVersion = (edition, version) => {
|
|
5
5
|
const system = (trackerBarOf(version.system) ?? defaultTrackerBar).id;
|
|
6
|
-
return paperOf(
|
|
6
|
+
return paperOf(edition)?.systems.find(paper => paper.system === system);
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* How a place on the edition's shared axis relates to the paper of
|
|
@@ -20,4 +20,4 @@ export const paperOfVersion = (view, version) => {
|
|
|
20
20
|
* Nothing where no copy of the version's system measures its paper,
|
|
21
21
|
* which leaves the performance on the axis.
|
|
22
22
|
*/
|
|
23
|
-
export const toOwnPaperOf = (
|
|
23
|
+
export const toOwnPaperOf = (edition, version) => paperOfVersion(edition, version)?.toOwnPaper;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RollCopy } from "../model/RollCopy.js";
|
|
2
2
|
import { Version } from "../model/Version.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Edition } from "../model/Edition.js";
|
|
4
4
|
export declare const reservationTypes: readonly ['source-not-stated', 'source-undocumented', 'software-not-named', 'instrument-not-named', 'features-interpreted', 'no-physical-evidence', 'measurement-undocumented', 'not-calibrated', 'system-unknown', 'keeper-unknown'];
|
|
5
5
|
export type ReservationType = typeof reservationTypes[number];
|
|
6
6
|
/**
|
|
@@ -27,4 +27,4 @@ export declare const reservationsAbout: (copy: RollCopy) => Reservation[];
|
|
|
27
27
|
export declare const versionReservationTypes: readonly ['text-not-stated', 'witnessed-by-statement-only', 'no-direct-witness'];
|
|
28
28
|
export type VersionReservationType = typeof versionReservationTypes[number];
|
|
29
29
|
/** What the edition cannot vouch for in a version, in the order the checks are listed. */
|
|
30
|
-
export declare const reservationsAboutVersion: (
|
|
30
|
+
export declare const reservationsAboutVersion: (edition: Edition, version: Readonly<Version>) => Reservation<VersionReservationType>[];
|
|
@@ -105,12 +105,12 @@ export const versionReservationTypes = [
|
|
|
105
105
|
'witnessed-by-statement-only',
|
|
106
106
|
'no-direct-witness'
|
|
107
107
|
];
|
|
108
|
-
const textStated = (
|
|
108
|
+
const textStated = (_edition, version) => version.edits ? undefined : {
|
|
109
109
|
type: 'text-not-stated',
|
|
110
110
|
note: 'The version does not state its edits, so it reads as the version it derives from.'
|
|
111
111
|
};
|
|
112
|
-
const witnessedByFeatures = (
|
|
113
|
-
const witnesses = witnessesOf(
|
|
112
|
+
const witnessedByFeatures = (edition, version) => {
|
|
113
|
+
const witnesses = witnessesOf(edition, version.id);
|
|
114
114
|
return witnesses.length > 0 && witnesses.every(({ by }) => by === 'statement') ? {
|
|
115
115
|
type: 'witnessed-by-statement-only',
|
|
116
116
|
note: 'No copy\'s features carry what the version inserts; only copies that state they carry it bear witness to it.'
|
|
@@ -121,8 +121,8 @@ const witnessedByFeatures = (view, version) => {
|
|
|
121
121
|
* Its text is a reconstruction from below, as a lost state's is, and
|
|
122
122
|
* nothing surviving shows it as it stood.
|
|
123
123
|
*/
|
|
124
|
-
const witnessedAtFirstHand = (
|
|
125
|
-
const carriers = witnessesOf(
|
|
124
|
+
const witnessedAtFirstHand = (edition, version) => {
|
|
125
|
+
const carriers = witnessesOf(edition, version.id).filter(({ by }) => by === 'carriers');
|
|
126
126
|
return carriers.length > 0 && carriers.every(({ through }) => through !== undefined) ? {
|
|
127
127
|
type: 'no-direct-witness',
|
|
128
128
|
note: 'No copy carries it at first hand; its text is a reconstruction from the versions derived from it.'
|
|
@@ -130,4 +130,4 @@ const witnessedAtFirstHand = (view, version) => {
|
|
|
130
130
|
};
|
|
131
131
|
const versionChecks = [textStated, witnessedByFeatures, witnessedAtFirstHand];
|
|
132
132
|
/** What the edition cannot vouch for in a version, in the order the checks are listed. */
|
|
133
|
-
export const reservationsAboutVersion = (
|
|
133
|
+
export const reservationsAboutVersion = (edition, version) => versionChecks.flatMap(check => check(edition, version) ?? []);
|
package/lib/analysis/sigla.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Edition } from '../model/Edition.js';
|
|
2
|
-
import { EditionView } from '../view/EditionView.js';
|
|
3
2
|
/**
|
|
4
|
-
* What the sigla are read off: the versions alone, or
|
|
5
|
-
*
|
|
3
|
+
* What the sigla are read off: the versions alone, or the edition, whose
|
|
4
|
+
* copies tell which versions a witness shows.
|
|
6
5
|
*/
|
|
7
|
-
export type Stemma = Pick<Edition, 'versions'> |
|
|
6
|
+
export type Stemma = Pick<Edition, 'versions'> | Edition;
|
|
8
7
|
/**
|
|
9
8
|
* The siglum of every version, as the stemma stands: where it sits
|
|
10
|
-
* (`alongTheStemma`) and, given
|
|
9
|
+
* (`alongTheStemma`) and, given the edition, whether any copy shows it.
|
|
11
10
|
*
|
|
12
11
|
* A version no copy's features carry at first hand is inferred, whether
|
|
13
12
|
* it is reached only through the versions derived from it or a copy does
|
package/lib/analysis/sigla.js
CHANGED
|
@@ -91,7 +91,7 @@ const alongTheStemma = (versions) => {
|
|
|
91
91
|
}
|
|
92
92
|
return sigla;
|
|
93
93
|
};
|
|
94
|
-
const
|
|
94
|
+
const holdsCopies = (stemma) => 'copies' in stemma;
|
|
95
95
|
/**
|
|
96
96
|
* The sigla with the inferred versions in lowercase, as editions mark a
|
|
97
97
|
* state nothing surviving shows. The letter still names the system and
|
|
@@ -100,7 +100,7 @@ const isView = (stemma) => !('versions' in stemma);
|
|
|
100
100
|
const marking = (sigla, attested) => new Map([...sigla].map(([id, siglum]) => [id, attested.has(id) ? siglum : siglum.toLowerCase()]));
|
|
101
101
|
/**
|
|
102
102
|
* The siglum of every version, as the stemma stands: where it sits
|
|
103
|
-
* (`alongTheStemma`) and, given
|
|
103
|
+
* (`alongTheStemma`) and, given the edition, whether any copy shows it.
|
|
104
104
|
*
|
|
105
105
|
* A version no copy's features carry at first hand is inferred, whether
|
|
106
106
|
* it is reached only through the versions derived from it or a copy does
|
|
@@ -112,8 +112,8 @@ const marking = (sigla, attested) => new Map([...sigla].map(([id, siglum]) => [i
|
|
|
112
112
|
* A siglum is computed anew when the stemma or the copies change, so
|
|
113
113
|
* nothing should cite one without saying which state it belongs to.
|
|
114
114
|
*/
|
|
115
|
-
export const siglaOf = (stemma) =>
|
|
116
|
-
? marking(alongTheStemma(stemma.
|
|
115
|
+
export const siglaOf = (stemma) => holdsCopies(stemma)
|
|
116
|
+
? marking(alongTheStemma(stemma.versions), attestedVersions(stemma))
|
|
117
117
|
: alongTheStemma(stemma.versions);
|
|
118
118
|
/** The siglum of one version as the stemma stands, or nothing where the edition holds no such version. */
|
|
119
119
|
export const siglumOf = (stemma, versionId) => siglaOf(stemma).get(versionId);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Walking the stemma of an edition along the principal derivations. */
|
|
2
|
+
import { Edition } from "../model/Edition.js";
|
|
3
|
+
import { Version } from "../model/Version.js";
|
|
4
|
+
/**
|
|
5
|
+
* The version and its ancestors along the principal line, from the
|
|
6
|
+
* version up to the root. A stemma that loops back on itself is walked
|
|
7
|
+
* once round, so that an edition in that state can still be read and
|
|
8
|
+
* repaired.
|
|
9
|
+
*/
|
|
10
|
+
export declare const lineageOf: (edition: Pick<Edition, 'versions'>, versionId: string) => Readonly<Version>[];
|
|
11
|
+
/** The version the given one's text is read against, by its principal derivation. */
|
|
12
|
+
export declare const predecessorOf: (edition: Pick<Edition, 'versions'>, versionId: string) => Readonly<Version> | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Every version with its generation: how many principal derivations
|
|
15
|
+
* lie between it and the root. A version whose parent the edition does
|
|
16
|
+
* not hold counts as a root. In a stemma that loops, the loop is walked
|
|
17
|
+
* once round, as `lineageOf` walks it, so that the stemma of an edition
|
|
18
|
+
* in that state can still be drawn and repaired.
|
|
19
|
+
*/
|
|
20
|
+
export declare const withGenerations: (edition: Pick<Edition, 'versions'>) => Array<Version & {
|
|
21
|
+
generation: number;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { principalDerivationOf } from "../model/Version.js";
|
|
2
|
+
import { idOf } from "../model/Assumption.js";
|
|
3
|
+
import { versionIn } from "../lookup/lookup.js";
|
|
4
|
+
/**
|
|
5
|
+
* The version and its ancestors along the principal line, from the
|
|
6
|
+
* version up to the root. A stemma that loops back on itself is walked
|
|
7
|
+
* once round, so that an edition in that state can still be read and
|
|
8
|
+
* repaired.
|
|
9
|
+
*/
|
|
10
|
+
export const lineageOf = (edition, versionId) => {
|
|
11
|
+
const lineage = [];
|
|
12
|
+
const visited = new Set();
|
|
13
|
+
let v = versionIn(edition, versionId);
|
|
14
|
+
while (v && !visited.has(v.id)) {
|
|
15
|
+
visited.add(v.id);
|
|
16
|
+
lineage.push(v);
|
|
17
|
+
const principal = principalDerivationOf(v);
|
|
18
|
+
v = principal && versionIn(edition, idOf(principal));
|
|
19
|
+
}
|
|
20
|
+
return lineage;
|
|
21
|
+
};
|
|
22
|
+
/** The version the given one's text is read against, by its principal derivation. */
|
|
23
|
+
export const predecessorOf = (edition, versionId) => {
|
|
24
|
+
const v = versionIn(edition, versionId);
|
|
25
|
+
const principal = v && principalDerivationOf(v);
|
|
26
|
+
return principal && versionIn(edition, idOf(principal));
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Every version with its generation: how many principal derivations
|
|
30
|
+
* lie between it and the root. A version whose parent the edition does
|
|
31
|
+
* not hold counts as a root. In a stemma that loops, the loop is walked
|
|
32
|
+
* once round, as `lineageOf` walks it, so that the stemma of an edition
|
|
33
|
+
* in that state can still be drawn and repaired.
|
|
34
|
+
*/
|
|
35
|
+
export const withGenerations = (edition) => edition.versions.map(version => ({
|
|
36
|
+
...version,
|
|
37
|
+
generation: lineageOf(edition, version.id).length - 1
|
|
38
|
+
}));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** What a version shows, and where along the roll its symbols lie. */
|
|
2
|
+
import { Edition } from "../model/Edition.js";
|
|
3
|
+
import { FeatureOrPatch, HorizontalSpan, NestedFeature } from "../model/Feature.js";
|
|
4
|
+
import { AnySymbol } from "../model/Symbol.js";
|
|
5
|
+
import { Millimeters } from "../model/Quantity.js";
|
|
6
|
+
export declare const carriersOf: (edition: Pick<Edition, 'copies'>, symbol: AnySymbol) => Readonly<NestedFeature>[];
|
|
7
|
+
/** The carriers that state a place of their own, which a feature on a patch does not. */
|
|
8
|
+
export declare const placedCarriersOf: (edition: Pick<Edition, 'copies'>, symbol: AnySymbol) => Readonly<FeatureOrPatch>[];
|
|
9
|
+
/**
|
|
10
|
+
* Where along the roll the symbol lies, as its carriers put it, or
|
|
11
|
+
* nothing for a symbol no copy carries.
|
|
12
|
+
*
|
|
13
|
+
* Only the place is measured. Which track the symbol sits on is not
|
|
14
|
+
* a measurement but a question for a tracker bar, since a note of
|
|
15
|
+
* one pitch sits on exactly one position of a given bar: ask
|
|
16
|
+
* `bar.positionOf`. The carriers cannot answer it, because a copy
|
|
17
|
+
* cut for another system numbers its tracks differently, and one
|
|
18
|
+
* symbol may be carried by copies of both — averaging a red carrier
|
|
19
|
+
* on track 47 with a green one on 45 would give 46, a legal
|
|
20
|
+
* position a semitone away on either bar.
|
|
21
|
+
*/
|
|
22
|
+
export declare const placeOf: (edition: Pick<Edition, 'copies'>, symbol: AnySymbol) => Readonly<HorizontalSpan> | undefined;
|
|
23
|
+
/** Where the symbol begins, as the mean onset of its carriers, or nothing for a symbol without a place. */
|
|
24
|
+
export declare const onsetOf: (edition: Pick<Edition, 'copies'>, symbol: AnySymbol) => Millimeters | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The symbols the version shows: what it and its ancestors insert,
|
|
27
|
+
* each version's deletions striking what it or its ancestors inserted.
|
|
28
|
+
* They are worked out once for each state of the edition, and the list
|
|
29
|
+
* is frozen, since everyone who asks is handed the same one.
|
|
30
|
+
*/
|
|
31
|
+
export declare const snapshotOf: (edition: Edition, versionId: string) => readonly Readonly<AnySymbol>[];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isPlaced } from "../model/Feature.js";
|
|
2
|
+
import { deletedBy, insertedBy } from "../model/Version.js";
|
|
3
|
+
import { idsOf } from "../model/Assumption.js";
|
|
4
|
+
import { mean } from "../model/Quantity.js";
|
|
5
|
+
import { featuresIn } from "../lookup/lookup.js";
|
|
6
|
+
import { perState } from "../lookup/perState.js";
|
|
7
|
+
import { lineageOf } from "./stemma.js";
|
|
8
|
+
export const carriersOf = (edition, symbol) => featuresIn(edition, idsOf(symbol.carriers));
|
|
9
|
+
/** The carriers that state a place of their own, which a feature on a patch does not. */
|
|
10
|
+
export const placedCarriersOf = (edition, symbol) => carriersOf(edition, symbol).filter(isPlaced);
|
|
11
|
+
/**
|
|
12
|
+
* Where along the roll the symbol lies, as its carriers put it, or
|
|
13
|
+
* nothing for a symbol no copy carries.
|
|
14
|
+
*
|
|
15
|
+
* Only the place is measured. Which track the symbol sits on is not
|
|
16
|
+
* a measurement but a question for a tracker bar, since a note of
|
|
17
|
+
* one pitch sits on exactly one position of a given bar: ask
|
|
18
|
+
* `bar.positionOf`. The carriers cannot answer it, because a copy
|
|
19
|
+
* cut for another system numbers its tracks differently, and one
|
|
20
|
+
* symbol may be carried by copies of both — averaging a red carrier
|
|
21
|
+
* on track 47 with a green one on 45 would give 46, a legal
|
|
22
|
+
* position a semitone away on either bar.
|
|
23
|
+
*/
|
|
24
|
+
export const placeOf = (edition, symbol) => {
|
|
25
|
+
const carriers = placedCarriersOf(edition, symbol);
|
|
26
|
+
if (carriers.length === 0)
|
|
27
|
+
return;
|
|
28
|
+
return {
|
|
29
|
+
unit: 'mm',
|
|
30
|
+
from: mean(carriers.map(carrier => carrier.horizontal.from)),
|
|
31
|
+
to: mean(carriers.map(carrier => carrier.horizontal.to))
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** Where the symbol begins, as the mean onset of its carriers, or nothing for a symbol without a place. */
|
|
35
|
+
export const onsetOf = (edition, symbol) => placeOf(edition, symbol)?.from;
|
|
36
|
+
/** The symbols by onset, those without a place first; symbols at one place keep their order. */
|
|
37
|
+
const inOrderOfPlace = (edition, symbols) => symbols
|
|
38
|
+
.map(symbol => ({ symbol, at: onsetOf(edition, symbol) || 0 }))
|
|
39
|
+
.sort((a, b) => a.at - b.at)
|
|
40
|
+
.map(({ symbol }) => symbol);
|
|
41
|
+
/** The snapshots of a state asked for so far, by version. */
|
|
42
|
+
const snapshotsIn = perState((_) => new Map());
|
|
43
|
+
/**
|
|
44
|
+
* The symbols the version shows: what it and its ancestors insert,
|
|
45
|
+
* each version's deletions striking what it or its ancestors inserted.
|
|
46
|
+
* They are worked out once for each state of the edition, and the list
|
|
47
|
+
* is frozen, since everyone who asks is handed the same one.
|
|
48
|
+
*/
|
|
49
|
+
export const snapshotOf = (edition, versionId) => {
|
|
50
|
+
const known = snapshotsIn(edition);
|
|
51
|
+
const kept = known.get(versionId);
|
|
52
|
+
if (kept)
|
|
53
|
+
return kept;
|
|
54
|
+
const deleted = new Set();
|
|
55
|
+
const symbols = lineageOf(edition, versionId).flatMap(version => {
|
|
56
|
+
deletedBy(version).forEach(id => deleted.add(id));
|
|
57
|
+
return insertedBy(version).filter(symbol => !deleted.has(symbol.id));
|
|
58
|
+
});
|
|
59
|
+
const snapshot = Object.freeze(inOrderOfPlace(edition, symbols));
|
|
60
|
+
known.set(versionId, snapshot);
|
|
61
|
+
return snapshot;
|
|
62
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Belief, Certainty } from "../model/Assumption.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Edition } from "../model/Edition.js";
|
|
3
3
|
export type WitnessBy = 'carriers' | 'statement';
|
|
4
4
|
/** A copy that bears witness to a version, and how. */
|
|
5
5
|
export interface Witness {
|
|
@@ -25,7 +25,7 @@ export interface Witness {
|
|
|
25
25
|
* the versions derived from it, or is attested by statement alone, and
|
|
26
26
|
* its text is a reconstruction rather than a reading.
|
|
27
27
|
*/
|
|
28
|
-
export declare const attestedVersions: (
|
|
28
|
+
export declare const attestedVersions: (edition: Edition) => ReadonlySet<string>;
|
|
29
29
|
/**
|
|
30
30
|
* The copies that bear witness to the version: those whose features carry
|
|
31
31
|
* a symbol the version's own edits insert, and those that state they carry
|
|
@@ -44,12 +44,12 @@ export declare const attestedVersions: (view: EditionView) => ReadonlySet<string
|
|
|
44
44
|
* reported as it stands. A version whose edits are not stated inserts
|
|
45
45
|
* nothing and is witnessed by statement alone.
|
|
46
46
|
*/
|
|
47
|
-
export declare const witnessesOf: (
|
|
47
|
+
export declare const witnessesOf: (edition: Edition, versionId: string) => Witness[];
|
|
48
48
|
/**
|
|
49
49
|
* The versions the copy bears witness to, each with how, in the order the
|
|
50
50
|
* edition lists its versions.
|
|
51
51
|
*/
|
|
52
|
-
export declare const versionsWitnessedBy: (
|
|
52
|
+
export declare const versionsWitnessedBy: (edition: Edition, copyId: string) => (Witness & {
|
|
53
53
|
version: string;
|
|
54
54
|
})[];
|
|
55
55
|
export type CarriageProblem = {
|
|
@@ -62,4 +62,4 @@ export type CarriageProblem = {
|
|
|
62
62
|
* made although the copy's features carry symbols, which say by
|
|
63
63
|
* themselves what it carries, and one naming a version the edition lacks.
|
|
64
64
|
*/
|
|
65
|
-
export declare const carriageProblems: (
|
|
65
|
+
export declare const carriageProblems: (edition: Edition) => CarriageProblem[];
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { certaintyOf, idOf, idsOf } from "../model/Assumption.js";
|
|
2
2
|
import { insertedBy } from "../model/Version.js";
|
|
3
|
+
import { lineageOf } from "./stemma.js";
|
|
4
|
+
import { copyOfFeature, versionIn } from "../lookup/lookup.js";
|
|
3
5
|
/** The copies whose features carry any of the symbols. */
|
|
4
|
-
const copiesCarrying = (
|
|
6
|
+
const copiesCarrying = (edition, symbols) => new Set(symbols
|
|
5
7
|
.flatMap(symbol => idsOf(symbol.carriers))
|
|
6
8
|
.flatMap(id => {
|
|
7
|
-
const copy =
|
|
9
|
+
const copy = copyOfFeature(edition, id);
|
|
8
10
|
return copy ? [copy.id] : [];
|
|
9
11
|
}));
|
|
10
12
|
/** Every copy carrying what a version inserts, version by version, the copies in the order the edition lists them. */
|
|
11
|
-
const carriagesIn = (
|
|
12
|
-
const carrying = copiesCarrying(
|
|
13
|
-
const depth =
|
|
14
|
-
return
|
|
13
|
+
const carriagesIn = (edition) => edition.versions.flatMap(version => {
|
|
14
|
+
const carrying = copiesCarrying(edition, insertedBy(version));
|
|
15
|
+
const depth = lineageOf(edition, version.id).length;
|
|
16
|
+
return edition.copies
|
|
15
17
|
.filter(copy => carrying.has(copy.id))
|
|
16
18
|
.map((copy) => ({ copy: copy.id, version: version.id, depth }));
|
|
17
19
|
});
|
|
18
|
-
const carriersIn = (
|
|
19
|
-
const carriages = carriagesIn(
|
|
20
|
+
const carriersIn = (edition) => {
|
|
21
|
+
const carriages = carriagesIn(edition);
|
|
20
22
|
return {
|
|
21
|
-
copiesOf: new Map(
|
|
23
|
+
copiesOf: new Map(edition.versions.map(version => [
|
|
22
24
|
version.id,
|
|
23
25
|
carriages.filter(carriage => carriage.version === version.id).map(carriage => carriage.copy)
|
|
24
26
|
])),
|
|
@@ -34,15 +36,15 @@ const carriersIn = (view) => {
|
|
|
34
36
|
* the versions derived from it, or is attested by statement alone, and
|
|
35
37
|
* its text is a reconstruction rather than a reading.
|
|
36
38
|
*/
|
|
37
|
-
export const attestedVersions = (
|
|
38
|
-
const witnessesIn = (carriers,
|
|
39
|
+
export const attestedVersions = (edition) => new Set(carriersIn(edition).latestOf.values());
|
|
40
|
+
const witnessesIn = (carriers, edition, versionId) => {
|
|
39
41
|
const carrying = carriers.copiesOf.get(versionId) ?? [];
|
|
40
42
|
const byCarriers = carrying.map((copy) => {
|
|
41
43
|
const latest = carriers.latestOf.get(copy);
|
|
42
44
|
return { copy, by: 'carriers', ...(latest !== undefined && latest !== versionId && { through: latest }) };
|
|
43
45
|
});
|
|
44
46
|
const carryingIt = new Set(carrying);
|
|
45
|
-
const byStatement =
|
|
47
|
+
const byStatement = edition.copies
|
|
46
48
|
.filter(copy => !carryingIt.has(copy.id))
|
|
47
49
|
.flatMap(copy => (copy.carries ?? [])
|
|
48
50
|
.filter(statement => idOf(statement) === versionId)
|
|
@@ -70,14 +72,14 @@ const witnessesIn = (carriers, view, versionId) => {
|
|
|
70
72
|
* reported as it stands. A version whose edits are not stated inserts
|
|
71
73
|
* nothing and is witnessed by statement alone.
|
|
72
74
|
*/
|
|
73
|
-
export const witnessesOf = (
|
|
75
|
+
export const witnessesOf = (edition, versionId) => versionIn(edition, versionId) ? witnessesIn(carriersIn(edition), edition, versionId) : [];
|
|
74
76
|
/**
|
|
75
77
|
* The versions the copy bears witness to, each with how, in the order the
|
|
76
78
|
* edition lists its versions.
|
|
77
79
|
*/
|
|
78
|
-
export const versionsWitnessedBy = (
|
|
79
|
-
const carriers = carriersIn(
|
|
80
|
-
return
|
|
80
|
+
export const versionsWitnessedBy = (edition, copyId) => {
|
|
81
|
+
const carriers = carriersIn(edition);
|
|
82
|
+
return edition.versions.flatMap(version => witnessesIn(carriers, edition, version.id)
|
|
81
83
|
.filter(witness => witness.copy === copyId)
|
|
82
84
|
.map(witness => ({ ...witness, version: version.id })));
|
|
83
85
|
};
|
|
@@ -86,13 +88,13 @@ export const versionsWitnessedBy = (view, copyId) => {
|
|
|
86
88
|
* made although the copy's features carry symbols, which say by
|
|
87
89
|
* themselves what it carries, and one naming a version the edition lacks.
|
|
88
90
|
*/
|
|
89
|
-
export const carriageProblems = (
|
|
90
|
-
const carrying = copiesCarrying(
|
|
91
|
-
return
|
|
91
|
+
export const carriageProblems = (edition) => {
|
|
92
|
+
const carrying = copiesCarrying(edition, edition.versions.flatMap(insertedBy));
|
|
93
|
+
return edition.copies.flatMap(copy => (copy.carries ?? []).flatMap((statement) => {
|
|
92
94
|
const version = idOf(statement);
|
|
93
95
|
return [
|
|
94
96
|
...(carrying.has(copy.id) ? [{ copy: copy.id, version, problem: 'stated-beside-carriers' }] : []),
|
|
95
|
-
...(
|
|
97
|
+
...(versionIn(edition, version) ? [] : [{ copy: copy.id, version, problem: 'version-missing' }])
|
|
96
98
|
];
|
|
97
99
|
}));
|
|
98
100
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Belief } from "../model/Assumption.js";
|
|
2
2
|
import { BothEnds, CollationTolerance, Displacement } from "./Collation.js";
|
|
3
|
-
import { EditionView } from "../view/EditionView.js";
|
|
4
3
|
import { Millimeters } from "../model/Quantity.js";
|
|
5
4
|
import { Histogram, Spread, Tail } from "./statistics.js";
|
|
6
5
|
import { AnySymbol } from "../model/Symbol.js";
|
|
6
|
+
import { Edition } from "../model/Edition.js";
|
|
7
7
|
/**
|
|
8
8
|
* How far the copies of a roll disagree about where a symbol lies, and
|
|
9
9
|
* the collation tolerance that follows from it.
|
|
@@ -44,7 +44,7 @@ export interface Reading {
|
|
|
44
44
|
* A symbol only one side carries measures nothing and is passed over,
|
|
45
45
|
* which leaves out exactly the insertions and the deletions.
|
|
46
46
|
*/
|
|
47
|
-
export declare const readingsOf: (
|
|
47
|
+
export declare const readingsOf: (edition: Edition, symbols: readonly Readonly<AnySymbol>[], copies: ReadonlySet<string>) => Reading[];
|
|
48
48
|
/**
|
|
49
49
|
* What sample a reading belongs to. Notes and expressions are taken
|
|
50
50
|
* apart by default, since in the present material they scatter
|
|
@@ -166,7 +166,7 @@ export declare const departureThreshold: (n: number) => number;
|
|
|
166
166
|
*/
|
|
167
167
|
export declare const scatterOf: (readings: readonly Reading[], options?: ScatterOptions) => Scatter[];
|
|
168
168
|
/** How one copy's readings of a version's text scatter against the readings of the copies it is collated with. */
|
|
169
|
-
export declare const scatterOfCopy: (
|
|
169
|
+
export declare const scatterOfCopy: (edition: Edition, versionId: string, copyId: string, options?: ScatterOptions) => Scatter[];
|
|
170
170
|
/**
|
|
171
171
|
* Which side of a derivation a measurement was taken over: the version
|
|
172
172
|
* derived, or the version it is read against.
|
|
@@ -256,7 +256,7 @@ export interface Sides {
|
|
|
256
256
|
* neither side, which is the case where the edition has genuinely
|
|
257
257
|
* stopped saying and an editor has to.
|
|
258
258
|
*/
|
|
259
|
-
export declare const sidesOf: (
|
|
259
|
+
export declare const sidesOf: (edition: Edition, versionId: string) => Sides | undefined;
|
|
260
260
|
/**
|
|
261
261
|
* The belief a calculated tolerance rests on, to annotate the
|
|
262
262
|
* derivation's `collationTolerance` with: an inference from the scatter
|