linked-rolls 0.33.0 → 0.35.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/lib/notes.d.ts CHANGED
@@ -4,6 +4,7 @@ export type NotePart = {
4
4
  } | {
5
5
  type: 'reference';
6
6
  id: string;
7
+ label?: string;
7
8
  };
8
9
  /** The note in the pieces it is shown in: stretches of text and what they refer to. */
9
10
  export declare const partsOfNote: (note: string) => NotePart[];
@@ -11,7 +12,8 @@ export declare const partsOfNote: (note: string) => NotePart[];
11
12
  export declare const referencesInNote: (note: string) => string[];
12
13
  /**
13
14
  * The note as it reads, with every reference resolved to the name the
14
- * edition gives that entity. A reference nothing answers to keeps its id,
15
- * so that the gap is visible rather than silent.
15
+ * edition gives that entity, or to the words the note puts in its place.
16
+ * A reference nothing answers to keeps its id, so that the gap is visible
17
+ * rather than silent.
16
18
  */
17
19
  export declare const resolveNote: (note: string, nameOf: (id: string) => string | undefined) => string;
package/lib/notes.js CHANGED
@@ -1,10 +1,15 @@
1
1
  /**
2
- * A note refers to a version or a copy instead of naming it, so that a
3
- * label the stemma decides is never written into the prose. A reference
4
- * reads `{{<id>}}`, where the id is the entity's, and is resolved when
5
- * the note is shown.
2
+ * A note refers to an entity instead of naming it, so that a label the
3
+ * stemma decides is never written into the prose. A reference reads
4
+ * `{{<id>}}`, where the id is the entity's, and is resolved when the note
5
+ * is shown.
6
+ *
7
+ * An entity the edition gives no name to, a perforation or an edit, needs
8
+ * the note's own words to stand in the sentence: `{{<id>|die Stanzung bei
9
+ * 7364,7 mm}}`. The name wins where the edition has one, so a siglum
10
+ * still follows the stemma and a written-out label cannot freeze it.
6
11
  */
7
- const reference = /\{\{\s*([^{}\s]+)\s*\}\}/g;
12
+ const reference = /\{\{\s*([^{}|\s]+)\s*(?:\|([^{}]*))?\}\}/g;
8
13
  /** The note in the pieces it is shown in: stretches of text and what they refer to. */
9
14
  export const partsOfNote = (note) => {
10
15
  const parts = [];
@@ -13,7 +18,8 @@ export const partsOfNote = (note) => {
13
18
  const at = match.index ?? 0;
14
19
  if (at > read)
15
20
  parts.push({ type: 'text', text: note.slice(read, at) });
16
- parts.push({ type: 'reference', id: match[1] });
21
+ const label = match[2]?.trim();
22
+ parts.push({ type: 'reference', id: match[1], ...(label && { label }) });
17
23
  read = at + match[0].length;
18
24
  }
19
25
  if (read < note.length)
@@ -24,9 +30,10 @@ export const partsOfNote = (note) => {
24
30
  export const referencesInNote = (note) => partsOfNote(note).flatMap(part => part.type === 'reference' ? [part.id] : []);
25
31
  /**
26
32
  * The note as it reads, with every reference resolved to the name the
27
- * edition gives that entity. A reference nothing answers to keeps its id,
28
- * so that the gap is visible rather than silent.
33
+ * edition gives that entity, or to the words the note puts in its place.
34
+ * A reference nothing answers to keeps its id, so that the gap is visible
35
+ * rather than silent.
29
36
  */
30
37
  export const resolveNote = (note, nameOf) => partsOfNote(note)
31
- .map(part => part.type === 'text' ? part.text : nameOf(part.id) ?? part.id)
38
+ .map(part => part.type === 'text' ? part.text : nameOf(part.id) ?? part.label ?? part.id)
32
39
  .join('');
@@ -24,7 +24,7 @@ export interface Reservation<T extends string = ReservationType> {
24
24
  * the measurement leaves open, then who holds it.
25
25
  */
26
26
  export declare const reservationsAbout: (copy: RollCopy) => Reservation[];
27
- export declare const versionReservationTypes: readonly ['text-not-stated', 'witnessed-by-statement-only'];
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
30
  export declare const reservationsAboutVersion: (view: EditionView, version: Readonly<Version>) => Reservation<VersionReservationType>[];
@@ -102,7 +102,8 @@ const checks = [
102
102
  export const reservationsAbout = (copy) => checks.flatMap(check => check(copy) ?? []);
103
103
  export const versionReservationTypes = [
104
104
  'text-not-stated',
105
- 'witnessed-by-statement-only'
105
+ 'witnessed-by-statement-only',
106
+ 'no-direct-witness'
106
107
  ];
107
108
  const textStated = (_view, version) => version.edits ? undefined : {
108
109
  type: 'text-not-stated',
@@ -115,6 +116,18 @@ const witnessedByFeatures = (view, version) => {
115
116
  note: 'No copy\'s features carry what the version inserts; only copies that state they carry it bear witness to it.'
116
117
  } : undefined;
117
118
  };
118
- const versionChecks = [textStated, witnessedByFeatures];
119
+ /**
120
+ * A version every copy reaches only through a version derived from it.
121
+ * Its text is a reconstruction from below, as a lost state's is, and
122
+ * nothing surviving shows it as it stood.
123
+ */
124
+ const witnessedAtFirstHand = (view, version) => {
125
+ const carriers = witnessesOf(view, version.id).filter(({ by }) => by === 'carriers');
126
+ return carriers.length > 0 && carriers.every(({ through }) => through !== undefined) ? {
127
+ type: 'no-direct-witness',
128
+ note: 'No copy carries it at first hand; it is attested only through the versions derived from it.'
129
+ } : undefined;
130
+ };
131
+ const versionChecks = [textStated, witnessedByFeatures, witnessedAtFirstHand];
119
132
  /** What the edition cannot vouch for in a version, in the order the checks are listed. */
120
133
  export const reservationsAboutVersion = (view, version) => versionChecks.flatMap(check => check(view, version) ?? []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "Digital editions of piano rolls: import, collation, editorial assumptions, JSON-LD export, and emulation through a reproducing system",
5
5
  "license": "MIT",
6
6
  "repository": {