linked-rolls 0.75.0 → 0.76.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 +53 -47
- package/lib/collation/Collation.d.ts +12 -46
- package/lib/collation/Collation.js +15 -53
- package/lib/filiation/adoption.d.ts +22 -26
- package/lib/filiation/adoption.js +71 -73
- package/lib/filiation/edits.d.ts +36 -31
- package/lib/filiation/edits.js +70 -85
- package/lib/filiation/index.d.ts +2 -2
- package/lib/filiation/index.js +1 -1
- package/lib/filiation/record.d.ts +14 -44
- package/lib/filiation/record.js +12 -83
- package/lib/io/asJsonLd.d.ts +1 -5
- package/lib/io/asJsonLd.js +17 -36
- package/lib/io/importJsonLd.js +33 -6
- package/lib/io/migrate.d.ts +7 -0
- package/lib/io/migrate.js +167 -2
- package/lib/model/Agent.d.ts +3 -1
- package/lib/model/Assumption.d.ts +9 -85
- package/lib/model/Assumption.js +3 -39
- package/lib/model/Edit.d.ts +75 -20
- package/lib/model/Edit.js +52 -5
- package/lib/model/Edition.d.ts +31 -11
- package/lib/model/Version.d.ts +5 -41
- package/lib/model/Version.js +6 -30
- package/lib/ops/collation.d.ts +8 -4
- package/lib/ops/collation.js +40 -23
- package/lib/ops/copies.js +1 -2
- package/lib/ops/draft.d.ts +1 -9
- package/lib/ops/draft.js +0 -12
- package/lib/ops/edits.d.ts +20 -5
- package/lib/ops/edits.js +29 -21
- package/lib/ops/index.d.ts +1 -1
- package/lib/ops/index.js +1 -1
- package/lib/ops/versions.d.ts +3 -2
- package/lib/ops/versions.js +4 -5
- package/lib/schema.json +121 -140
- package/lib/software.d.ts +7 -6
- package/lib/software.js +7 -6
- package/lib/spec/context.json +8 -11
- package/package.json +1 -1
package/lib/filiation/edits.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Edition } from "../model/Edition.js";
|
|
2
|
-
import {
|
|
2
|
+
import { EditShape } from "../model/Edit.js";
|
|
3
3
|
import { Millimeters } from "../model/Quantity.js";
|
|
4
4
|
import { EditionOp } from "../ops/draft.js";
|
|
5
|
-
import { Run } from "./record.js";
|
|
6
5
|
/**
|
|
7
6
|
* How far a perforation may be put from where it stood for the two to be
|
|
8
7
|
* one move. WM 225 moves commands by up to about 60 mm.
|
|
@@ -70,8 +69,8 @@ export interface ProposedEdit {
|
|
|
70
69
|
insert: string[];
|
|
71
70
|
/** The ids of the symbols it deletes, in the order of their places. */
|
|
72
71
|
delete: string[];
|
|
73
|
-
/** The
|
|
74
|
-
|
|
72
|
+
/** The shape of the change, where it takes one the program knows. */
|
|
73
|
+
shape?: EditShape;
|
|
75
74
|
grouping: EditGrouping;
|
|
76
75
|
}
|
|
77
76
|
/**
|
|
@@ -95,8 +94,8 @@ export interface ProposedEdit {
|
|
|
95
94
|
* punched across three lines or more at one place are one edit, as a
|
|
96
95
|
* cancel row is.
|
|
97
96
|
*
|
|
98
|
-
* The
|
|
99
|
-
* an additional accent, as is a note set off from its chord by a few
|
|
97
|
+
* The shape is read off the group: a pair the bar spells an accent with
|
|
98
|
+
* is an additional accent, as is a note set off from its chord by a few
|
|
100
99
|
* millimetres where the version puts an accent's On; a perforation put
|
|
101
100
|
* elsewhere is a shift, or where it begins about where the other did,
|
|
102
101
|
* shortened or prolonged; a note struck again is shortened, two tied
|
|
@@ -111,35 +110,41 @@ export interface ProposedEdit {
|
|
|
111
110
|
*/
|
|
112
111
|
export declare const proposeEdits: (edition: Edition, versionId: string, options?: EditOptions) => ProposedEdit[];
|
|
113
112
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
113
|
+
* The motivation a program states for each change the version makes,
|
|
114
|
+
* by the id of the symbol it inserts or deletes: the one the shape of
|
|
115
|
+
* the proposed edit it belongs to calls for (`motivationProposedFor`),
|
|
116
|
+
* musical or technical. A version that derives from none makes no
|
|
117
|
+
* change, and its symbols are given none.
|
|
116
118
|
* @category Filiation
|
|
117
119
|
*/
|
|
118
|
-
export declare const
|
|
120
|
+
export declare const proposedMotivations: (edition: Edition, versionId: string, options?: EditOptions) => ReadonlyMap<string, string>;
|
|
119
121
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
122
|
+
* The motivation a program states for an edit making these changes:
|
|
123
|
+
* the generic musical one where any of them is a musical change, or one
|
|
124
|
+
* the proposal does not see, and the technical one where all are
|
|
125
|
+
* technical.
|
|
126
|
+
*/
|
|
127
|
+
export declare const motivationOfChanges: (motivations: ReadonlyMap<string, string>, symbolIds: readonly string[]) => string;
|
|
128
|
+
/**
|
|
129
|
+
* Puts the proposed edits (`proposeEdits`) in place of the program's
|
|
130
|
+
* edits of the versions, every version but the root where none are
|
|
131
|
+
* named: those that say nothing of why they were made, or only that they
|
|
132
|
+
* are musical or technical changes (`isCollationsOwn`). An edit with a
|
|
133
|
+
* motivation of the editor's or held under a belief stays as it is, and
|
|
134
|
+
* what a proposed edit shares with it stands symbol by symbol beside it.
|
|
135
|
+
* An edit stated already over the very same symbols as a proposed one
|
|
136
|
+
* is kept with its id and the kind of change it states, which the
|
|
137
|
+
* editor may have said otherwise than the program read it; the others
|
|
138
|
+
* are new, with ids that adopting again gives again. An edit that
|
|
139
|
+
* states no kind has the motivation its shape calls for
|
|
140
|
+
* (`motivationProposedFor`): the generic musical one for a musical
|
|
141
|
+
* change, whose reason is left to the editor, and the technical one for
|
|
142
|
+
* a technical change.
|
|
130
143
|
*
|
|
131
144
|
* Applied on the same draft after `adoptStemma`, it proposes the edits of
|
|
132
|
-
* the stemma adopted, as one undo step.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* one belief, likely unless the run says otherwise, whose reason is the
|
|
136
|
-
* inference the program drew: it names this library and its release,
|
|
137
|
-
* the versions it read, the rule that keeps an edit at one place and, in
|
|
138
|
-
* its note, the distances it grouped with, and it rests on the beliefs
|
|
139
|
-
* the derivations of the versions are held with. An edit of the set
|
|
140
|
-
* that nobody has motivated is the program's, typed and all, and a
|
|
141
|
-
* later proposal groups it again. The run gives who ran the program and
|
|
142
|
-
* when (`Run`).
|
|
145
|
+
* the stemma adopted, as one undo step. The edition's creation comes to
|
|
146
|
+
* name the rule that keeps an edit at one place among its principles,
|
|
147
|
+
* and this release among its software.
|
|
143
148
|
* @category Operations
|
|
144
149
|
*/
|
|
145
|
-
export declare const adoptEdits: (versionIds?: readonly string[], options?: EditOptions
|
|
150
|
+
export declare const adoptEdits: (versionIds?: readonly string[], options?: EditOptions) => EditionOp;
|
package/lib/filiation/edits.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The edits of a version, proposed from what it inserts and deletes:
|
|
3
|
-
* which of its changes belong together, and what
|
|
4
|
-
*
|
|
3
|
+
* which of its changes belong together, and what shape each group
|
|
4
|
+
* takes, from which the motivation a program can give it follows. Why
|
|
5
|
+
* a musical change was made is left to the editor.
|
|
5
6
|
*/
|
|
6
7
|
import { v5 } from "uuid";
|
|
7
|
-
import {
|
|
8
|
-
import { deletedBy, editsOf, insertedBy
|
|
8
|
+
import { motivationProposedFor, musicalChange, technicalChange } from "../model/Edit.js";
|
|
9
|
+
import { deletedBy, editsOf, insertedBy } from "../model/Version.js";
|
|
9
10
|
import { distance, mm, subtract } from "../model/Quantity.js";
|
|
10
11
|
import { trackerBarOf } from "../systems/index.js";
|
|
11
12
|
import { operationOf, substitutionsBetween } from "../collation/substitution.js";
|
|
12
|
-
import { isCollationsOwn
|
|
13
|
+
import { isCollationsOwn } from "../collation/Collation.js";
|
|
13
14
|
import { predecessorOf } from "../analysis/stemma.js";
|
|
14
15
|
import { placeOf, snapshotOf } from "../analysis/text.js";
|
|
15
16
|
import { symbolsIn, versionIn } from "../lookup/lookup.js";
|
|
16
17
|
import { groupBy } from "../shared/utils.js";
|
|
17
|
-
import {
|
|
18
|
+
import { reading } from "../ops/draft.js";
|
|
18
19
|
import { ineffectiveAmong } from "./presence.js";
|
|
19
20
|
import { reads } from "./readings.js";
|
|
20
|
-
import { editRules,
|
|
21
|
+
import { editRules, madeWith } from "./record.js";
|
|
21
22
|
/**
|
|
22
23
|
* How far a perforation may be put from where it stood for the two to be
|
|
23
24
|
* one move. WM 225 moves commands by up to about 60 mm.
|
|
@@ -280,8 +281,8 @@ const rowsAmong = (groups, within) => {
|
|
|
280
281
|
};
|
|
281
282
|
/** Whether the bar spells an accent with exactly these commands. */
|
|
282
283
|
const spellsAccent = (bar, types) => (bar?.accents ?? []).some(accent => sameSequence(types, accent));
|
|
283
|
-
/**
|
|
284
|
-
const
|
|
284
|
+
/** The shape a group of changes takes, where it is one the program knows. */
|
|
285
|
+
const shapeOfGroup = (group, bar, accentsAt, options) => {
|
|
285
286
|
const inserted = inOrder(ofSide(group.changes, 'insert'));
|
|
286
287
|
const deleted = inOrder(ofSide(group.changes, 'delete'));
|
|
287
288
|
if (group.grouping === 'substitution' || group.changes.some(change => change.foreign))
|
|
@@ -345,8 +346,8 @@ const settingsOf = (options) => ({
|
|
|
345
346
|
* punched across three lines or more at one place are one edit, as a
|
|
346
347
|
* cancel row is.
|
|
347
348
|
*
|
|
348
|
-
* The
|
|
349
|
-
* an additional accent, as is a note set off from its chord by a few
|
|
349
|
+
* The shape is read off the group: a pair the bar spells an accent with
|
|
350
|
+
* is an additional accent, as is a note set off from its chord by a few
|
|
350
351
|
* millimetres where the version puts an accent's On; a perforation put
|
|
351
352
|
* elsewhere is a shift, or where it begins about where the other did,
|
|
352
353
|
* shortened or prolonged; a note struck again is shortened, two tied
|
|
@@ -429,11 +430,11 @@ export const proposeEdits = (edition, versionId, options = {}) => {
|
|
|
429
430
|
const proposed = [...substituted, ...recoded, ...lines, ...rows]
|
|
430
431
|
.sort((a, b) => byPlace(inOrder(a.changes)[0], inOrder(b.changes)[0]))
|
|
431
432
|
.map((group) => {
|
|
432
|
-
const
|
|
433
|
+
const shape = shapeOfGroup(group, bar, accentsAt, settings);
|
|
433
434
|
return {
|
|
434
435
|
insert: inOrder(ofSide(group.changes, 'insert')).map(change => change.symbol.id),
|
|
435
436
|
delete: inOrder(ofSide(group.changes, 'delete')).map(change => change.symbol.id),
|
|
436
|
-
...(
|
|
437
|
+
...(shape && { shape }),
|
|
437
438
|
grouping: group.grouping
|
|
438
439
|
};
|
|
439
440
|
});
|
|
@@ -443,98 +444,102 @@ export const proposeEdits = (edition, versionId, options = {}) => {
|
|
|
443
444
|
const EDITS = '3c9e0f62-1d4b-4a7e-9b55-8e2f7a6d1c04';
|
|
444
445
|
const exchangeKey = (inserted, deleted) => `${[...inserted].sort().join(',')}/${[...deleted].sort().join(',')}`;
|
|
445
446
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
447
|
+
* The motivation a program states for each change the version makes,
|
|
448
|
+
* by the id of the symbol it inserts or deletes: the one the shape of
|
|
449
|
+
* the proposed edit it belongs to calls for (`motivationProposedFor`),
|
|
450
|
+
* musical or technical. A version that derives from none makes no
|
|
451
|
+
* change, and its symbols are given none.
|
|
448
452
|
* @category Filiation
|
|
449
453
|
*/
|
|
450
|
-
export const
|
|
454
|
+
export const proposedMotivations = (edition, versionId, options = {}) => {
|
|
455
|
+
const motivations = new Map();
|
|
456
|
+
if (!predecessorOf(edition, versionId))
|
|
457
|
+
return motivations;
|
|
458
|
+
for (const edit of proposeEdits(edition, versionId, options)) {
|
|
459
|
+
const motivation = motivationProposedFor(edit.shape);
|
|
460
|
+
for (const id of [...edit.insert, ...edit.delete])
|
|
461
|
+
motivations.set(id, motivation);
|
|
462
|
+
}
|
|
463
|
+
return motivations;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* The motivation a program states for an edit making these changes:
|
|
467
|
+
* the generic musical one where any of them is a musical change, or one
|
|
468
|
+
* the proposal does not see, and the technical one where all are
|
|
469
|
+
* technical.
|
|
470
|
+
*/
|
|
471
|
+
export const motivationOfChanges = (motivations, symbolIds) => symbolIds.some(id => (motivations.get(id) ?? musicalChange) === musicalChange) ? musicalChange : technicalChange;
|
|
451
472
|
/**
|
|
452
473
|
* The edits the version comes to state when the proposal is adopted:
|
|
453
474
|
* those it keeps, and those put in place of the rest.
|
|
454
475
|
*/
|
|
455
476
|
const adoptedEditsOf = (edition, version, options) => {
|
|
456
477
|
const edits = editsOf(version);
|
|
457
|
-
const held = edits.filter(edit => !
|
|
478
|
+
const held = edits.filter(edit => !isCollationsOwn(edit));
|
|
458
479
|
const spoken = new Set(held.flatMap(edit => [...(edit.insert ?? []).map(symbol => symbol.id), ...(edit.delete ?? [])]));
|
|
459
480
|
const symbolOf = new Map(insertedBy(version).map(symbol => [symbol.id, symbol]));
|
|
460
481
|
const stated = new Map(edits.map(edit => [exchangeKey((edit.insert ?? []).map(symbol => symbol.id), edit.delete ?? []), edit]));
|
|
461
|
-
const made = (inserted, deleted,
|
|
482
|
+
const made = (inserted, deleted, motivation) => {
|
|
462
483
|
const key = exchangeKey(inserted, deleted);
|
|
463
484
|
const same = stated.get(key);
|
|
485
|
+
// An edit over the same changes stays, with the kind of change it states, which the editor may have said.
|
|
464
486
|
if (same)
|
|
465
|
-
return same.
|
|
487
|
+
return same.motivation === undefined ? { ...same, motivation } : same;
|
|
466
488
|
return {
|
|
467
489
|
type: 'edit',
|
|
468
490
|
id: v5(`edit|${version.id}|${key}`, EDITS),
|
|
469
|
-
|
|
470
|
-
motivation: unchecked,
|
|
491
|
+
motivation,
|
|
471
492
|
...(inserted.length > 0 && { insert: inserted.map(id => symbolOf.get(id)) }),
|
|
472
493
|
...(deleted.length > 0 && { delete: [...deleted] })
|
|
473
494
|
};
|
|
474
495
|
};
|
|
475
496
|
const proposed = proposeEdits(edition, version.id, options).flatMap(edit => {
|
|
497
|
+
const motivation = motivationProposedFor(edit.shape);
|
|
476
498
|
const free = (ids) => ids.filter(id => !spoken.has(id));
|
|
477
499
|
const [inserted, deleted] = [free(edit.insert), free(edit.delete)];
|
|
478
500
|
if (inserted.length === edit.insert.length && deleted.length === edit.delete.length) {
|
|
479
|
-
return [made(inserted, deleted,
|
|
501
|
+
return [made(inserted, deleted, motivation)];
|
|
480
502
|
}
|
|
481
503
|
// What an edit that stays leaves of a proposed one stands symbol by symbol.
|
|
482
|
-
return [...inserted.map(id => made([id], [])), ...deleted.map(id => made([], [id]))];
|
|
504
|
+
return [...inserted.map(id => made([id], [], motivation)), ...deleted.map(id => made([], [id], motivation))];
|
|
483
505
|
});
|
|
484
506
|
return { held, proposed };
|
|
485
507
|
};
|
|
486
508
|
/**
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
* symbol by symbol beside it. An edit stated already over the very same
|
|
502
|
-
* symbols as a proposed one is kept with its id and what was written on
|
|
503
|
-
* it, the proposed type filled in where it states none; the others are
|
|
504
|
-
* new, with ids that adopting again gives again, and marked unchecked,
|
|
505
|
-
* so that what is left to the editor is to say why.
|
|
509
|
+
* Puts the proposed edits (`proposeEdits`) in place of the program's
|
|
510
|
+
* edits of the versions, every version but the root where none are
|
|
511
|
+
* named: those that say nothing of why they were made, or only that they
|
|
512
|
+
* are musical or technical changes (`isCollationsOwn`). An edit with a
|
|
513
|
+
* motivation of the editor's or held under a belief stays as it is, and
|
|
514
|
+
* what a proposed edit shares with it stands symbol by symbol beside it.
|
|
515
|
+
* An edit stated already over the very same symbols as a proposed one
|
|
516
|
+
* is kept with its id and the kind of change it states, which the
|
|
517
|
+
* editor may have said otherwise than the program read it; the others
|
|
518
|
+
* are new, with ids that adopting again gives again. An edit that
|
|
519
|
+
* states no kind has the motivation its shape calls for
|
|
520
|
+
* (`motivationProposedFor`): the generic musical one for a musical
|
|
521
|
+
* change, whose reason is left to the editor, and the technical one for
|
|
522
|
+
* a technical change.
|
|
506
523
|
*
|
|
507
524
|
* Applied on the same draft after `adoptStemma`, it proposes the edits of
|
|
508
|
-
* the stemma adopted, as one undo step.
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
* one belief, likely unless the run says otherwise, whose reason is the
|
|
512
|
-
* inference the program drew: it names this library and its release,
|
|
513
|
-
* the versions it read, the rule that keeps an edit at one place and, in
|
|
514
|
-
* its note, the distances it grouped with, and it rests on the beliefs
|
|
515
|
-
* the derivations of the versions are held with. An edit of the set
|
|
516
|
-
* that nobody has motivated is the program's, typed and all, and a
|
|
517
|
-
* later proposal groups it again. The run gives who ran the program and
|
|
518
|
-
* when (`Run`).
|
|
525
|
+
* the stemma adopted, as one undo step. The edition's creation comes to
|
|
526
|
+
* name the rule that keeps an edit at one place among its principles,
|
|
527
|
+
* and this release among its software.
|
|
519
528
|
* @category Operations
|
|
520
529
|
*/
|
|
521
|
-
export const adoptEdits = (versionIds, options = {}
|
|
530
|
+
export const adoptEdits = (versionIds, options = {}) => reading(edition => {
|
|
522
531
|
const targets = (versionIds ?? edition.versions.map(version => version.id))
|
|
523
532
|
.map(id => versionIn(edition, id))
|
|
524
533
|
.filter((version) => version !== undefined && predecessorOf(edition, version.id) !== undefined);
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
const edits = [...held, ...proposed.map(edit => memberOf(set.id, edit))];
|
|
534
|
+
const adopted = new Map(targets.flatMap(version => {
|
|
535
|
+
const { held, proposed } = adoptedEditsOf(edition, version, options);
|
|
536
|
+
const edits = [...held, ...proposed];
|
|
529
537
|
const stated = editsOf(version);
|
|
530
538
|
if (edits.length === stated.length && edits.every((edit, index) => edit === stated[index]))
|
|
531
539
|
return [];
|
|
532
|
-
return [[version.id, { ...version, edits
|
|
540
|
+
return [[version.id, { ...version, edits }]];
|
|
533
541
|
}));
|
|
534
|
-
const
|
|
535
|
-
...edition,
|
|
536
|
-
versions: edition.versions.map(version => adopted.get(version.id) ?? version)
|
|
537
|
-
}, [set]);
|
|
542
|
+
const creation = madeWith(edition.creation, [editRules.onePlace]);
|
|
538
543
|
// Each version is put in place whole: one that an operation before put
|
|
539
544
|
// on the same draft, as adopting a stemma does, is no draft to write to.
|
|
540
545
|
return draft => {
|
|
@@ -543,27 +548,7 @@ export const adoptEdits = (versionIds, options = {}, run = {}) => reading(editio
|
|
|
543
548
|
if (changed)
|
|
544
549
|
draft.versions[index] = changed;
|
|
545
550
|
});
|
|
546
|
-
if (
|
|
547
|
-
draft.
|
|
548
|
-
else
|
|
549
|
-
delete draft.propositionSets;
|
|
551
|
+
if (adopted.size > 0)
|
|
552
|
+
draft.creation = creation;
|
|
550
553
|
};
|
|
551
554
|
});
|
|
552
|
-
/**
|
|
553
|
-
* The set the run of `proposeEdits` concluded: the edits it proposed for
|
|
554
|
-
* the versions, held with the belief the run gives them. Its premises
|
|
555
|
-
* are the beliefs the derivations of those versions are held with, since
|
|
556
|
-
* what a version changes is read against the version it derives from: a
|
|
557
|
-
* proposed stemma's, where the derivation belongs to one.
|
|
558
|
-
*/
|
|
559
|
-
const editSetOf = (edition, regrouped, options, run) => {
|
|
560
|
-
const settings = settingsOf(options);
|
|
561
|
-
const proposing = regrouped.filter(({ proposed }) => proposed.length > 0);
|
|
562
|
-
const premises = [...new Set(proposing.flatMap(({ version }) => {
|
|
563
|
-
const derivation = principalDerivationOf(version);
|
|
564
|
-
const belief = derivation && beliefIn(edition, derivation);
|
|
565
|
-
return belief ? [belief.id] : [];
|
|
566
|
-
}))];
|
|
567
|
-
const used = [...new Set(proposing.flatMap(({ version }) => [predecessorOf(edition, version.id).id, version.id]))];
|
|
568
|
-
return recorded('edits', [settings, premises, proposing.map(({ version, proposed }) => [version.id, proposed.map(edit => edit.id)])], { note: noteOn(settings), premises, used, applies: [editRules.onePlace] }, run);
|
|
569
|
-
};
|
package/lib/filiation/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { defaultCosts, type Costs, type Scored, type Support } from "./search.js
|
|
|
9
9
|
export { transfersOf, systemAbove } from "./systems.js";
|
|
10
10
|
export { proposeStemma, defaultMovedWithin, type FiliationOptions, type ProposedVersion, type StemmaProposal, type Unpinned } from "./proposal.js";
|
|
11
11
|
export { adoptionOf, adoptStemma, type Adoption } from "./adoption.js";
|
|
12
|
-
export { stemmaRules, editRules
|
|
12
|
+
export { stemmaRules, editRules } from "./record.js";
|
|
13
13
|
export { stemmaChanges, type VersionChange } from "./changes.js";
|
|
14
14
|
export { sharedTexts, differencesBetween, defaultSameText, type SharedText, type KeptApart } from "./texts.js";
|
|
15
|
-
export { proposeEdits, adoptEdits,
|
|
15
|
+
export { proposeEdits, adoptEdits, proposedMotivations, defaultShiftWithin, defaultPairWithin, defaultResizeWithin, defaultSamePlaceWithin, type EditOptions, type EditGrouping, type ProposedEdit } from "./edits.js";
|
package/lib/filiation/index.js
CHANGED
|
@@ -12,4 +12,4 @@ export { adoptionOf, adoptStemma } from "./adoption.js";
|
|
|
12
12
|
export { stemmaRules, editRules } from "./record.js";
|
|
13
13
|
export { stemmaChanges } from "./changes.js";
|
|
14
14
|
export { sharedTexts, differencesBetween, defaultSameText } from "./texts.js";
|
|
15
|
-
export { proposeEdits, adoptEdits,
|
|
15
|
+
export { proposeEdits, adoptEdits, proposedMotivations, defaultShiftWithin, defaultPairWithin, defaultResizeWithin, defaultSamePlaceWithin } from "./edits.js";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* What adopting a proposal records of how it was found: the published
|
|
3
|
+
* rules the proposal follows, among the principles of the edition, and
|
|
4
|
+
* the release of this library, among the software it was made with.
|
|
5
|
+
*/
|
|
6
|
+
import { EditionCreation } from "../model/Edition.js";
|
|
3
7
|
/**
|
|
4
8
|
* The published rules the proposal of a stemma follows, by IRI, each
|
|
5
9
|
* under the cost or the step that carries it out. They are the
|
|
@@ -34,46 +38,12 @@ export declare const editRules: {
|
|
|
34
38
|
readonly onePlace: 'https://welte225.org/rules#one-place';
|
|
35
39
|
};
|
|
36
40
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/** Who ran the program and so holds what it concluded: the editor. */
|
|
45
|
-
actor?: ActorAssignment;
|
|
46
|
-
/** When it ran. */
|
|
47
|
-
date?: TimeSpan;
|
|
48
|
-
/** How firmly what it concluded is held: likely, where nothing else is said. */
|
|
49
|
-
certainty?: Certainty;
|
|
50
|
-
/** The rules it followed, by IRI, in place of those the library names (`stemmaRules`, `editRules`). */
|
|
51
|
-
applies?: string[];
|
|
52
|
-
}
|
|
53
|
-
/** What a recorded run concluded besides its statements: what the inference says of itself. */
|
|
54
|
-
export interface Concluded {
|
|
55
|
-
/** What the run is, and what it was computed with, in words. */
|
|
56
|
-
note: string;
|
|
57
|
-
premises: string[];
|
|
58
|
-
used: string[];
|
|
59
|
-
applies: string[];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* The proposition set of a run, with its belief and the inference it
|
|
63
|
-
* rests on. Its id follows from what it is given, so that recording the
|
|
64
|
-
* same run again gives the same set.
|
|
65
|
-
*/
|
|
66
|
-
export declare const recorded: (kind: string, identity: unknown, concluded: Concluded, run: Run) => PropositionSet;
|
|
67
|
-
/** The statement as one of the set: its annotation names the set, and it carries no belief of its own. */
|
|
68
|
-
export declare const memberOf: <T extends Assumption>(set: string, statement: T) => T;
|
|
69
|
-
/**
|
|
70
|
-
* The sets the edition keeps, with those given added where it holds none
|
|
71
|
-
* with their id: a set already recorded stays as it was recorded, by
|
|
72
|
-
* whom and when it was first concluded. Kept are the sets a statement
|
|
73
|
-
* belongs to, and those whose belief the reasons of another kept
|
|
74
|
-
* statement or set name as a premise. A set nothing names any longer is
|
|
75
|
-
* the record of a run whose conclusions have all been replaced.
|
|
41
|
+
* The edition's creation as adopting a proposal leaves it. Its
|
|
42
|
+
* principles come to name the rules the proposal follows, in place of
|
|
43
|
+
* those given to be replaced, which are the rules of the same kind that
|
|
44
|
+
* it no longer follows; the principles the editor named stay. Its
|
|
45
|
+
* software comes to name this release of the library, in place of any
|
|
46
|
+
* other release of it, so that the release named finds again what the
|
|
47
|
+
* edition states.
|
|
76
48
|
*/
|
|
77
|
-
export declare const
|
|
78
|
-
/** A distance in millimetres as a note gives it. */
|
|
79
|
-
export declare const inMillimetres: (value: number) => string;
|
|
49
|
+
export declare const madeWith: (creation: Readonly<EditionCreation>, rules: readonly string[], replacing?: readonly string[]) => EditionCreation;
|
package/lib/filiation/record.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What adopting a proposal records of the run that made it: the
|
|
3
|
-
* proposition set the statements it concluded belong to, held under one
|
|
4
|
-
* belief, and the reasoning that belief rests on.
|
|
5
|
-
*/
|
|
6
|
-
import { v5 } from "uuid";
|
|
7
1
|
import { linkedRolls } from "../software.js";
|
|
8
|
-
/** The namespace the ids of recorded sets and beliefs are minted in, so that recording the same run again gives them again. */
|
|
9
|
-
const RECORDED = 'b7e2a4d1-5c3f-4e86-9a0b-1d2f3e4c5a67';
|
|
10
2
|
/**
|
|
11
3
|
* The published rules the proposal of a stemma follows, by IRI, each
|
|
12
4
|
* under the cost or the step that carries it out. They are the
|
|
@@ -41,80 +33,17 @@ export const editRules = {
|
|
|
41
33
|
onePlace: 'https://welte225.org/rules#one-place'
|
|
42
34
|
};
|
|
43
35
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
type: 'inference',
|
|
52
|
-
...(run.actor && { actor: run.actor }),
|
|
53
|
-
note: concluded.note,
|
|
54
|
-
premises: concluded.premises,
|
|
55
|
-
...(concluded.used.length > 0 && { used: concluded.used }),
|
|
56
|
-
applies: run.applies ?? concluded.applies,
|
|
57
|
-
software: [linkedRolls],
|
|
58
|
-
...(run.date && { date: run.date })
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
type: 'propositionSet',
|
|
62
|
-
id,
|
|
63
|
-
belief: {
|
|
64
|
-
type: 'belief',
|
|
65
|
-
id: `belief_${v5(id, RECORDED)}`,
|
|
66
|
-
certainty: run.certainty ?? 'likely',
|
|
67
|
-
reasons: [inference]
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
/** The statement as one of the set: its annotation names the set, and it carries no belief of its own. */
|
|
72
|
-
export const memberOf = (set, statement) => statement['@annotation']?.id === set && statement['@annotation'].belief === undefined
|
|
73
|
-
? statement
|
|
74
|
-
: { ...statement, '@annotation': { id: set } };
|
|
75
|
-
/** The ids every annotation of the value names a set by, and every premise names a belief by. */
|
|
76
|
-
const namedIn = (value, names) => {
|
|
77
|
-
if (Array.isArray(value)) {
|
|
78
|
-
value.forEach(item => namedIn(item, names));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (value === null || typeof value !== 'object' || value instanceof Date)
|
|
82
|
-
return;
|
|
83
|
-
const record = value;
|
|
84
|
-
const annotation = record['@annotation'];
|
|
85
|
-
if (annotation?.id !== undefined && annotation.belief === undefined)
|
|
86
|
-
names.add(annotation.id);
|
|
87
|
-
if (Array.isArray(record.premises))
|
|
88
|
-
record.premises.forEach(premise => typeof premise === 'string' && names.add(premise));
|
|
89
|
-
Object.values(record).forEach(child => namedIn(child, names));
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* The sets the edition keeps, with those given added where it holds none
|
|
93
|
-
* with their id: a set already recorded stays as it was recorded, by
|
|
94
|
-
* whom and when it was first concluded. Kept are the sets a statement
|
|
95
|
-
* belongs to, and those whose belief the reasons of another kept
|
|
96
|
-
* statement or set name as a premise. A set nothing names any longer is
|
|
97
|
-
* the record of a run whose conclusions have all been replaced.
|
|
36
|
+
* The edition's creation as adopting a proposal leaves it. Its
|
|
37
|
+
* principles come to name the rules the proposal follows, in place of
|
|
38
|
+
* those given to be replaced, which are the rules of the same kind that
|
|
39
|
+
* it no longer follows; the principles the editor named stay. Its
|
|
40
|
+
* software comes to name this release of the library, in place of any
|
|
41
|
+
* other release of it, so that the release named finds again what the
|
|
42
|
+
* edition states.
|
|
98
43
|
*/
|
|
99
|
-
export const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
namedIn({ ...edition, propositionSets: [] }, named);
|
|
105
|
-
const kept = new Set();
|
|
106
|
-
for (let grown = true; grown;) {
|
|
107
|
-
grown = false;
|
|
108
|
-
for (const set of sets) {
|
|
109
|
-
if (kept.has(set) || !(named.has(set.id) || named.has(set.belief.id)))
|
|
110
|
-
continue;
|
|
111
|
-
kept.add(set);
|
|
112
|
-
namedIn(set.belief, named);
|
|
113
|
-
grown = true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const keeping = sets.filter(set => kept.has(set));
|
|
117
|
-
return keeping.length > 0 ? keeping : undefined;
|
|
44
|
+
export const madeWith = (creation, rules, replacing = []) => {
|
|
45
|
+
const replaced = new Set(replacing);
|
|
46
|
+
const principles = [...new Set([...(creation.principles ?? []).filter(rule => !replaced.has(rule)), ...rules])];
|
|
47
|
+
const software = [...(creation.software ?? []).filter(program => program.name !== linkedRolls.name), linkedRolls];
|
|
48
|
+
return { ...creation, principles, software };
|
|
118
49
|
};
|
|
119
|
-
/** A distance in millimetres as a note gives it. */
|
|
120
|
-
export const inMillimetres = (value) => `${Math.round(value * 100) / 100} mm`;
|
package/lib/io/asJsonLd.d.ts
CHANGED
|
@@ -12,11 +12,7 @@ export declare const exportDate: (date: Date) => string;
|
|
|
12
12
|
* and every version carries the context of its own reproducing system.
|
|
13
13
|
* A reference the edition holds possible, unlikely or false is quoted
|
|
14
14
|
* rather than stated, so that a reader of the RDF does not take it for
|
|
15
|
-
* a fact
|
|
16
|
-
* statement that belongs to a set names the set in its annotation,
|
|
17
|
-
* which in RDF makes the set its reifier, and the set, stated once
|
|
18
|
-
* beside the document, carries the belief. The edition given is not
|
|
19
|
-
* changed.
|
|
15
|
+
* a fact. The edition given is not changed.
|
|
20
16
|
* @category Reading and writing
|
|
21
17
|
*/
|
|
22
18
|
export declare const asJsonLd: (edition: Edition) => any;
|