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.
Files changed (53) hide show
  1. package/README.md +13 -5
  2. package/lib/analysis/constraints.d.ts +2 -2
  3. package/lib/analysis/constraints.js +17 -14
  4. package/lib/analysis/ownPaper.d.ts +3 -3
  5. package/lib/analysis/ownPaper.js +3 -3
  6. package/lib/analysis/reservations.d.ts +2 -2
  7. package/lib/analysis/reservations.js +6 -6
  8. package/lib/analysis/sigla.d.ts +4 -5
  9. package/lib/analysis/sigla.js +4 -4
  10. package/lib/analysis/stemma.d.ts +22 -0
  11. package/lib/analysis/stemma.js +38 -0
  12. package/lib/analysis/text.d.ts +31 -0
  13. package/lib/analysis/text.js +62 -0
  14. package/lib/analysis/witnesses.d.ts +5 -5
  15. package/lib/analysis/witnesses.js +22 -20
  16. package/lib/collation/scatter.d.ts +4 -4
  17. package/lib/collation/scatter.js +15 -13
  18. package/lib/emulation/Emulation.d.ts +7 -7
  19. package/lib/emulation/Emulation.js +29 -27
  20. package/lib/emulation/negotiation.d.ts +2 -2
  21. package/lib/emulation/negotiation.js +3 -2
  22. package/lib/index.d.ts +4 -1
  23. package/lib/index.js +4 -1
  24. package/lib/io/asJsonLd.js +11 -1
  25. package/lib/io/importJsonLd.js +11 -1
  26. package/lib/lookup/lookup.d.ts +32 -0
  27. package/lib/lookup/lookup.js +40 -0
  28. package/lib/lookup/paths.d.ts +11 -0
  29. package/lib/lookup/paths.js +78 -0
  30. package/lib/lookup/perState.d.ts +32 -0
  31. package/lib/lookup/perState.js +63 -0
  32. package/lib/model/Edit.d.ts +4 -0
  33. package/lib/model/Version.d.ts +7 -1
  34. package/lib/ops/beliefs.d.ts +1 -1
  35. package/lib/ops/beliefs.js +1 -1
  36. package/lib/ops/collation.d.ts +3 -4
  37. package/lib/ops/collation.js +25 -23
  38. package/lib/ops/commands.d.ts +4 -5
  39. package/lib/ops/commands.js +10 -10
  40. package/lib/ops/draft.d.ts +12 -12
  41. package/lib/ops/draft.js +11 -13
  42. package/lib/ops/edits.d.ts +1 -2
  43. package/lib/ops/edits.js +13 -10
  44. package/lib/ops/features.d.ts +2 -2
  45. package/lib/ops/features.js +3 -2
  46. package/lib/ops/index.d.ts +1 -1
  47. package/lib/ops/index.js +6 -0
  48. package/lib/ops/versions.d.ts +2 -3
  49. package/lib/ops/versions.js +6 -5
  50. package/lib/schema.json +2 -2
  51. package/package.json +1 -1
  52. package/lib/view/EditionView.d.ts +0 -103
  53. package/lib/view/EditionView.js +0 -329
@@ -1,4 +1,4 @@
1
- import { Path } from "../view/EditionView.js";
1
+ import { Path } from "../lookup/paths.js";
2
2
  import { AnyArgumentation, Certainty } from "../model/Assumption.js";
3
3
  import { EditionOp } from "./draft.js";
4
4
  /** Annotates the assumption at the path with a belief held true, for reasons to be added. */
@@ -1,5 +1,5 @@
1
1
  import { v4 } from "uuid";
2
- import { getAt } from "../view/EditionView.js";
2
+ import { getAt } from "../lookup/paths.js";
3
3
  const onAssumptionAt = (path, op) => draft => {
4
4
  const assumption = getAt(path, draft);
5
5
  if (assumption)
@@ -1,4 +1,3 @@
1
- import { EditionView } from "../view/EditionView.js";
2
1
  import { CollationTolerance } from "../collation/Collation.js";
3
2
  import { ObjectAssumption } from "../model/Assumption.js";
4
3
  import { EditionOp } from "./draft.js";
@@ -28,13 +27,13 @@ import { EditionOp } from "./draft.js";
28
27
  * statement, since the stemma would loop; asked for that, nothing
29
28
  * changes.
30
29
  */
31
- export declare const connectVersions: (given: EditionView, childId: string, parentId: string, tolerance?: ObjectAssumption<CollationTolerance>) => EditionOp;
30
+ export declare const connectVersions: (childId: string, parentId: string, tolerance?: ObjectAssumption<CollationTolerance>) => EditionOp;
32
31
  /**
33
32
  * Folds the version's own symbols into those it inherits and collates
34
33
  * with: the carriers pass over, and the insertions go. Collates at the
35
34
  * tolerance of the derivation, where the caller names none.
36
35
  */
37
- export declare const collateSymbols: (given: EditionView, versionId: string, symbolIds: readonly string[], tolerance?: CollationTolerance) => EditionOp;
36
+ export declare const collateSymbols: (versionId: string, symbolIds: readonly string[], tolerance?: CollationTolerance) => EditionOp;
38
37
  /**
39
38
  * Takes the named copies' reading of a symbol back out of the symbol it
40
39
  * was collated into: their carriers pass to a new symbol of the
@@ -59,4 +58,4 @@ export declare const collateSymbols: (given: EditionView, versionId: string, sym
59
58
  * keeps its identifier and the edit that speaks for it. Named symbols
60
59
  * narrow the act to those; naming none separates the whole reading.
61
60
  */
62
- export declare const separateReadings: (given: EditionView, versionId: string, copies: ReadonlySet<string>, symbolIds?: readonly string[]) => EditionOp;
61
+ export declare const separateReadings: (versionId: string, copies: ReadonlySet<string>, symbolIds?: readonly string[]) => EditionOp;
@@ -1,5 +1,5 @@
1
1
  import { v4 } from "uuid";
2
- import { getAt } from "../view/EditionView.js";
2
+ import { getAt, pathIn } from "../lookup/paths.js";
3
3
  import { collationsOf, defaultCollationTolerance, isCollationsOwn, unchecked } from "../collation/Collation.js";
4
4
  import { collationToleranceOf, derivesFrom, editsOf, insertedBy, principalDerivationOf } from "../model/Version.js";
5
5
  import { substitutionsBetween } from "../collation/substitution.js";
@@ -7,9 +7,11 @@ import { trackerBarOf } from "../systems/index.js";
7
7
  import { assignReference, idOf } from "../model/Assumption.js";
8
8
  import { noChange, onVersion, stateOf, insertion, deletion, asUnchecked, declaring, insertedIn, dropInsertions, reading } from "./draft.js";
9
9
  import { hypothesesBeside } from "./versions.js";
10
+ import { placeOf, snapshotOf } from "../analysis/text.js";
11
+ import { copyOfFeature, versionIn } from "../lookup/lookup.js";
10
12
  /** The carriers of each collated symbol pass to its counterpart. */
11
- const handOverCarriers = (view, draft, collations) => collations.forEach(({ symbol, counterpart }) => {
12
- const path = view.getPath(counterpart.id);
13
+ const handOverCarriers = (edition, draft, collations) => collations.forEach(({ symbol, counterpart }) => {
14
+ const path = pathIn(edition, counterpart.id);
13
15
  const target = path && getAt(path, draft);
14
16
  target?.carriers.push(...symbol.carriers);
15
17
  });
@@ -59,10 +61,10 @@ const byExchange = (edits) => new Map(edits.map(edit => [exchangeKey((edit.inser
59
61
  * statement, since the stemma would loop; asked for that, nothing
60
62
  * changes.
61
63
  */
62
- export const connectVersions = (given, childId, parentId, tolerance = defaultCollationTolerance) => reading(given, view => {
63
- if (childId === parentId || derivesFrom(view.edition.versions, parentId, childId))
64
+ export const connectVersions = (childId, parentId, tolerance = defaultCollationTolerance) => reading(edition => {
65
+ if (childId === parentId || derivesFrom(edition.versions, parentId, childId))
64
66
  return noChange;
65
- const child = view.version(childId);
67
+ const child = versionIn(edition, childId);
66
68
  const stated = child ? editsOf(child) : [];
67
69
  const established = stated.filter(edit => !isCollationsOwn(edit));
68
70
  const spokenFor = spokenForBy(established);
@@ -71,12 +73,12 @@ export const connectVersions = (given, childId, parentId, tolerance = defaultCol
71
73
  // through: it is neither the child's own symbol nor one it lacks.
72
74
  // Without that, connecting a pair already connected would collate
73
75
  // the inherited symbols with themselves and double their carriers.
74
- const handedDown = view.snapshot(parentId).filter(unspoken);
75
- const shown = new Set(view.snapshot(childId).map(symbol => symbol.id));
76
+ const handedDown = snapshotOf(edition, parentId).filter(unspoken);
77
+ const shown = new Set(snapshotOf(edition, childId).map(symbol => symbol.id));
76
78
  const inheritedIds = new Set(handedDown.map(symbol => symbol.id));
77
79
  const inherited = handedDown.filter(symbol => !shown.has(symbol.id));
78
- const own = view.snapshot(childId).filter(symbol => unspoken(symbol) && !inheritedIds.has(symbol.id));
79
- const locate = (symbol) => view.placeOf(symbol);
80
+ const own = snapshotOf(edition, childId).filter(symbol => unspoken(symbol) && !inheritedIds.has(symbol.id));
81
+ const locate = (symbol) => placeOf(edition, symbol);
80
82
  const collations = collationsOf(own, inherited, locate, tolerance);
81
83
  const collated = new Set(collations.map(({ symbol }) => symbol.id));
82
84
  const matched = new Set(collations.map(({ counterpart }) => counterpart.id));
@@ -87,7 +89,7 @@ export const connectVersions = (given, childId, parentId, tolerance = defaultCol
87
89
  * apart would make the apparatus a list of unexplained losses beside
88
90
  * a list of unexplained gains.
89
91
  */
90
- const substituted = differ(child, view.version(parentId))
92
+ const substituted = differ(child, versionIn(edition, parentId))
91
93
  ? substitutionsBetween(own.filter(symbol => !collated.has(symbol.id)), inherited.filter(symbol => !matched.has(symbol.id)), locate, tolerance)
92
94
  : [];
93
95
  const paired = new Set(substituted.flatMap(({ replaced, by }) => [...by, ...replaced].map(symbol => symbol.id)));
@@ -113,7 +115,7 @@ export const connectVersions = (given, childId, parentId, tolerance = defaultCol
113
115
  .map(symbol => asUnchecked(deletion(symbol.id)))
114
116
  ];
115
117
  return onVersion(childId, (child, draft) => {
116
- handOverCarriers(view, draft, collations);
118
+ handOverCarriers(edition, draft, collations);
117
119
  child.edits = edits;
118
120
  child.motivations = declaring(stateOf(child).motivations, edits);
119
121
  child.basedOn = [
@@ -127,17 +129,17 @@ export const connectVersions = (given, childId, parentId, tolerance = defaultCol
127
129
  * with: the carriers pass over, and the insertions go. Collates at the
128
130
  * tolerance of the derivation, where the caller names none.
129
131
  */
130
- export const collateSymbols = (given, versionId, symbolIds, tolerance) => reading(given, view => {
131
- const version = view.version(versionId);
132
+ export const collateSymbols = (versionId, symbolIds, tolerance) => reading(edition => {
133
+ const version = versionIn(edition, versionId);
132
134
  const principal = version && principalDerivationOf(version);
133
135
  if (!version || !principal)
134
136
  return noChange;
135
137
  const chosen = new Set(symbolIds);
136
138
  const own = insertedIn([version]).filter(symbol => chosen.has(symbol.id));
137
- const collations = collationsOf(own, view.snapshot(idOf(principal)), symbol => view.placeOf(symbol), tolerance ?? collationToleranceOf(principal));
139
+ const collations = collationsOf(own, snapshotOf(edition, idOf(principal)), symbol => placeOf(edition, symbol), tolerance ?? collationToleranceOf(principal));
138
140
  const collated = new Set(collations.map(({ symbol }) => symbol.id));
139
141
  return onVersion(versionId, (version, draft) => {
140
- handOverCarriers(view, draft, collations);
142
+ handOverCarriers(edition, draft, collations);
141
143
  dropInsertions(version, collated);
142
144
  });
143
145
  });
@@ -163,9 +165,9 @@ const readingOf = (symbol, carriers) => {
163
165
  * where the two versions do not disagree and there is nothing to take
164
166
  * apart.
165
167
  */
166
- const sharedWith = (view, symbol, copies) => {
168
+ const sharedWith = (edition, symbol, copies) => {
167
169
  const onNamedCopy = (carrier) => {
168
- const copy = view.copyOf(idOf(carrier));
170
+ const copy = copyOfFeature(edition, idOf(carrier));
169
171
  return copy !== undefined && copies.has(copy.id);
170
172
  };
171
173
  const mine = symbol.carriers.filter(onNamedCopy);
@@ -196,14 +198,14 @@ const sharedWith = (view, symbol, copies) => {
196
198
  * keeps its identifier and the edit that speaks for it. Named symbols
197
199
  * narrow the act to those; naming none separates the whole reading.
198
200
  */
199
- export const separateReadings = (given, versionId, copies, symbolIds) => reading(given, view => {
200
- const version = view.version(versionId);
201
+ export const separateReadings = (versionId, copies, symbolIds) => reading(edition => {
202
+ const version = versionIn(edition, versionId);
201
203
  if (!version)
202
204
  return noChange;
203
205
  const chosen = symbolIds && new Set(symbolIds);
204
- const shared = view.snapshot(versionId)
206
+ const shared = snapshotOf(edition, versionId)
205
207
  .filter(symbol => chosen === undefined || chosen.has(symbol.id))
206
- .flatMap(symbol => sharedWith(view, symbol, copies));
208
+ .flatMap(symbol => sharedWith(edition, symbol, copies));
207
209
  if (shared.length === 0)
208
210
  return noChange;
209
211
  const inserted = new Set(insertedBy(version).map(symbol => symbol.id));
@@ -218,7 +220,7 @@ export const separateReadings = (given, versionId, copies, symbolIds) => reading
218
220
  }));
219
221
  return onVersion(versionId, (version, draft) => {
220
222
  shared.forEach(({ symbol, theirs }) => {
221
- const path = view.getPath(symbol.id);
223
+ const path = pathIn(edition, symbol.id);
222
224
  const target = path && getAt(path, draft);
223
225
  if (target)
224
226
  target.carriers = theirs;
@@ -1,9 +1,8 @@
1
- import { EditionView } from "../view/EditionView.js";
2
1
  import { PlacementRelation } from "../model/Symbol.js";
3
2
  import { EditionOp } from "./draft.js";
4
3
  /** States how the follower is placed relative to the reference, in place of any earlier statement. */
5
- export declare const placeCommand: (view: EditionView, followerId: string, referenceId: string, relation: PlacementRelation) => EditionOp;
6
- export declare const unplaceCommand: (view: EditionView, followerId: string) => EditionOp;
4
+ export declare const placeCommand: (followerId: string, referenceId: string, relation: PlacementRelation) => EditionOp;
5
+ export declare const unplaceCommand: (followerId: string) => EditionOp;
7
6
  /** The pair is stated on `statingId` only, as the format asks. */
8
- export declare const pairCommands: (view: EditionView, statingId: string, partnerId: string) => EditionOp;
9
- export declare const unpairCommand: (view: EditionView, statingId: string) => EditionOp;
7
+ export declare const pairCommands: (statingId: string, partnerId: string) => EditionOp;
8
+ export declare const unpairCommand: (statingId: string) => EditionOp;
@@ -1,29 +1,29 @@
1
- import { getAt } from "../view/EditionView.js";
1
+ import { getAt, pathIn } from "../lookup/paths.js";
2
2
  import { isCommand, placementRelations } from "../model/Symbol.js";
3
3
  import { assignReference } from "../model/Assumption.js";
4
4
  import { reading } from "./draft.js";
5
5
  /**
6
- * Runs the change on the command the view locates by id, in whichever
7
- * version inserted it. A statement made there holds in every version
8
- * that carries the command.
6
+ * Runs the change on the command with the id, in whichever version
7
+ * inserted it. A statement made there holds in every version that
8
+ * carries the command.
9
9
  */
10
- const onCommand = (view, id, op) => reading(view, fresh => draft => {
11
- const path = fresh.getPath(id);
10
+ const onCommand = (id, op) => reading(edition => draft => {
11
+ const path = pathIn(edition, id);
12
12
  const symbol = path && getAt(path, draft);
13
13
  if (isCommand(symbol))
14
14
  op(symbol);
15
15
  });
16
16
  const clearPlacement = (command) => placementRelations.forEach(relation => { delete command[relation]; });
17
17
  /** States how the follower is placed relative to the reference, in place of any earlier statement. */
18
- export const placeCommand = (view, followerId, referenceId, relation) => onCommand(view, followerId, command => {
18
+ export const placeCommand = (followerId, referenceId, relation) => onCommand(followerId, command => {
19
19
  clearPlacement(command);
20
20
  command[relation] = assignReference(referenceId);
21
21
  });
22
- export const unplaceCommand = (view, followerId) => onCommand(view, followerId, clearPlacement);
22
+ export const unplaceCommand = (followerId) => onCommand(followerId, clearPlacement);
23
23
  /** The pair is stated on `statingId` only, as the format asks. */
24
- export const pairCommands = (view, statingId, partnerId) => onCommand(view, statingId, command => {
24
+ export const pairCommands = (statingId, partnerId) => onCommand(statingId, command => {
25
25
  command.pairedWith = assignReference(partnerId);
26
26
  });
27
- export const unpairCommand = (view, statingId) => onCommand(view, statingId, command => {
27
+ export const unpairCommand = (statingId) => onCommand(statingId, command => {
28
28
  delete command.pairedWith;
29
29
  });
@@ -1,4 +1,3 @@
1
- import { EditionView } from "../view/EditionView.js";
2
1
  /** What the operations are built from: the type of an operation, how one finds what it writes to on the draft, and the edits it writes. */
3
2
  import { Draft } from "immer";
4
3
  import { Edition } from "../model/Edition.js";
@@ -12,10 +11,10 @@ import { WithId } from "../shared/utils.js";
12
11
  /**
13
12
  * A change to an edition, written onto an immer draft of it. One
14
13
  * operation is one undo step, so an operation that has to read the
15
- * edition first takes an `EditionView` of the state it will be
16
- * applied to and does all its writing in the one function it returns.
17
- * Where operations run one after another on one draft, the ones after
18
- * the first read a view of the draft as it then stands (`reading`).
14
+ * edition reads it as the draft stands when the operation is applied
15
+ * (`reading`) and does all its writing in the one function it builds
16
+ * from that. Where operations run one after another on one draft, each
17
+ * reads what the ones before it wrote.
19
18
  */
20
19
  export type EditionOp = (draft: Draft<Edition>) => void;
21
20
  export declare const noChange: EditionOp;
@@ -23,16 +22,17 @@ export declare const onCopy: (copyId: string, op: (copy: Draft<RollCopy>, draft:
23
22
  export declare const onVersion: (versionId: string, op: (version: Draft<Version>, draft: Draft<Edition>) => void) => EditionOp;
24
23
  export declare const onFeature: (copyId: string, featureId: string, op: (feature: Draft<FeatureOrPatch>) => void) => EditionOp;
25
24
  /**
26
- * The operation built from a view of the state it is applied to. The
27
- * view given is used where the draft still stands as the view saw it,
28
- * and a fresh one is taken of the draft where an operation run before
29
- * on the same draft has changed it: a path or an index read off the
30
- * view would otherwise name what stood there before.
25
+ * The operation built from the state it is applied to: the draft as it
26
+ * stands, an operation run before on the same draft included. A path
27
+ * or an index read off an earlier state would name what stood there
28
+ * before. What is worked out from a state is kept with it, so a draft
29
+ * nothing has changed yet is read from what is known already.
31
30
  */
32
- export declare const reading: (view: EditionView, build: (view: EditionView) => EditionOp) => EditionOp;
31
+ export declare const reading: (build: (edition: Edition) => EditionOp) => EditionOp;
33
32
  /**
34
33
  * The state a draft stands at, as plain data. Reading a draft proxies
35
- * everything it touches, so what is only read is read from this.
34
+ * everything it touches, so what is only read is read from this, and
35
+ * what is looked up in an edition is looked up in this (`takenOf`).
36
36
  */
37
37
  export declare const stateOf: <T>(draft: Draft<T>) => T;
38
38
  /** The ids of the items the rewriting left out. */
package/lib/ops/draft.js CHANGED
@@ -1,12 +1,12 @@
1
- import { EditionView } from "../view/EditionView.js";
2
1
  /** What the operations are built from: the type of an operation, how one finds what it writes to on the draft, and the edits it writes. */
3
- import { current, isDraft } from "immer";
2
+ import { isDraft } from "immer";
4
3
  import { v4 } from "uuid";
5
4
  import { unchecked, uncheckedMotivation } from "../collation/Collation.js";
6
5
  import { insertedBy } from "../model/Version.js";
7
6
  import { featuresOf } from "../model/RollCopy.js";
8
7
  import { assignReference } from "../model/Assumption.js";
9
8
  import { without, pruned } from "./immutable.js";
9
+ import { takenOf } from "../lookup/perState.js";
10
10
  export const noChange = () => undefined;
11
11
  export const onCopy = (copyId, op) => draft => {
12
12
  const copy = draft.copies.find(c => c.id === copyId);
@@ -24,21 +24,19 @@ export const onFeature = (copyId, featureId, op) => onCopy(copyId, copy => {
24
24
  op(feature);
25
25
  });
26
26
  /**
27
- * The operation built from a view of the state it is applied to. The
28
- * view given is used where the draft still stands as the view saw it,
29
- * and a fresh one is taken of the draft where an operation run before
30
- * on the same draft has changed it: a path or an index read off the
31
- * view would otherwise name what stood there before.
27
+ * The operation built from the state it is applied to: the draft as it
28
+ * stands, an operation run before on the same draft included. A path
29
+ * or an index read off an earlier state would name what stood there
30
+ * before. What is worked out from a state is kept with it, so a draft
31
+ * nothing has changed yet is read from what is known already.
32
32
  */
33
- export const reading = (view, build) => draft => {
34
- const state = stateOf(draft);
35
- build(state === view.edition ? view : new EditionView(state))(draft);
36
- };
33
+ export const reading = (build) => draft => build(stateOf(draft))(draft);
37
34
  /**
38
35
  * The state a draft stands at, as plain data. Reading a draft proxies
39
- * everything it touches, so what is only read is read from this.
36
+ * everything it touches, so what is only read is read from this, and
37
+ * what is looked up in an edition is looked up in this (`takenOf`).
40
38
  */
41
- export const stateOf = (draft) => isDraft(draft) ? current(draft) : draft;
39
+ export const stateOf = (draft) => isDraft(draft) ? takenOf(draft) : draft;
42
40
  /** The ids of the items the rewriting left out. */
43
41
  export const droppedIds = (before, after) => {
44
42
  const kept = new Set(after.map(item => item.id));
@@ -1,10 +1,9 @@
1
- import { EditionView } from "../view/EditionView.js";
2
1
  import { Edit } from "../model/Edit.js";
3
2
  import { EditionOp } from "./draft.js";
4
3
  /**
5
4
  * Replaces the edits with a single one carrying all their insertions
6
5
  * and deletions, classified by a guess at what the exchange does.
7
6
  */
8
- export declare const mergeEdits: (given: EditionView, versionId: string, toMerge: readonly Edit[]) => EditionOp;
7
+ export declare const mergeEdits: (versionId: string, toMerge: readonly Edit[]) => EditionOp;
9
8
  /** Replaces the edit with one edit per inserted and one per deleted symbol. */
10
9
  export declare const splitEdit: (versionId: string, toSplit: Edit) => EditionOp;
package/lib/ops/edits.js CHANGED
@@ -4,6 +4,9 @@ import { editsOf } from "../model/Version.js";
4
4
  import { trackerBarOf } from "../systems/index.js";
5
5
  import { distance, mm, subtract } from "../model/Quantity.js";
6
6
  import { noChange, onVersion, insertion, deletion, reading } from "./draft.js";
7
+ import { predecessorOf } from "../analysis/stemma.js";
8
+ import { placeOf } from "../analysis/text.js";
9
+ import { symbolsIn, versionIn } from "../lookup/lookup.js";
7
10
  const sameSequence = (a, b) => a.length === b.length && a.every((value, i) => value === b[i]);
8
11
  const expressionTypesOf = (symbols) => symbols.filter((symbol) => symbol.type === 'expression').map(symbol => symbol.expressionType);
9
12
  /** The spellings of a single added accent the bar offers, none where no bar is known. */
@@ -12,9 +15,9 @@ const lengthOf = (span) => subtract(span.to, span.from);
12
15
  /** How far apart two onsets may lie for the one symbol to count as a replacement of the other. */
13
16
  const REPLACEMENT_TOLERANCE = mm(5);
14
17
  /** Shorten or prolong, where the inserted symbol starts about where the deleted one did. */
15
- const replacementType = (view, inserted, deleted) => {
16
- const after = view.placeOf(inserted);
17
- const before = view.placeOf(deleted);
18
+ const replacementType = (edition, inserted, deleted) => {
19
+ const after = placeOf(edition, inserted);
20
+ const before = placeOf(edition, deleted);
18
21
  if (!after || !before || distance(after.from, before.from) >= REPLACEMENT_TOLERANCE)
19
22
  return undefined;
20
23
  return lengthOf(after) < lengthOf(before) ? 'shorten' : 'prolong';
@@ -23,13 +26,13 @@ const replacementType = (view, inserted, deleted) => {
23
26
  * A guess at what an edit does, from the symbols it exchanges and from
24
27
  * the systems the version and the one it is based on are coded for.
25
28
  */
26
- const guessEditType = (view, versionId, edit) => {
29
+ const guessEditType = (edition, versionId, edit) => {
27
30
  const inserts = edit.insert ?? [];
28
- const deletes = view.symbols(edit.delete ?? []);
31
+ const deletes = symbolsIn(edition, edit.delete ?? []);
29
32
  const inserted = expressionTypesOf(inserts);
30
33
  const deleted = expressionTypesOf(deletes);
31
- const bar = trackerBarOf(view.version(versionId)?.system);
32
- const parentBar = trackerBarOf(view.predecessorOf(versionId)?.system);
34
+ const bar = trackerBarOf(versionIn(edition, versionId)?.system);
35
+ const parentBar = trackerBarOf(predecessorOf(edition, versionId)?.system);
33
36
  /**
34
37
  * Where the version is coded for another system than its parent,
35
38
  * expression matter changed is the transfer being carried out: a red
@@ -54,14 +57,14 @@ const guessEditType = (view, versionId, edit) => {
54
57
  if (inserted.length === 0 && deleted.length === 1)
55
58
  return 'remove-redundancy';
56
59
  if (inserts.length === 1 && deletes.length === 1)
57
- return replacementType(view, inserts[0], deletes[0]) ?? 'correct-error';
60
+ return replacementType(edition, inserts[0], deletes[0]) ?? 'correct-error';
58
61
  return 'correct-error';
59
62
  };
60
63
  /**
61
64
  * Replaces the edits with a single one carrying all their insertions
62
65
  * and deletions, classified by a guess at what the exchange does.
63
66
  */
64
- export const mergeEdits = (given, versionId, toMerge) => reading(given, view => {
67
+ export const mergeEdits = (versionId, toMerge) => reading(edition => {
65
68
  if (toMerge.length === 0)
66
69
  return noChange;
67
70
  const merged = {
@@ -70,7 +73,7 @@ export const mergeEdits = (given, versionId, toMerge) => reading(given, view =>
70
73
  insert: toMerge.flatMap(edit => edit.insert ?? []),
71
74
  delete: toMerge.flatMap(edit => edit.delete ?? [])
72
75
  };
73
- merged.editType = guessEditType(view, versionId, merged);
76
+ merged.editType = guessEditType(edition, versionId, merged);
74
77
  const mergedIds = new Set(toMerge.map(edit => edit.id));
75
78
  return onVersion(versionId, version => {
76
79
  version.edits = [...editsOf(version).filter(edit => !mergedIds.has(edit.id)), merged];
@@ -1,4 +1,4 @@
1
- import { EditionView } from "../view/EditionView.js";
1
+ import { Edition } from "../model/Edition.js";
2
2
  import { ModificationPurpose } from "../model/RollCopy.js";
3
3
  import { FeatureConditionAssignment, FeatureOrPatch, NestedFeature } from "../model/Feature.js";
4
4
  import { EditionOp } from "./draft.js";
@@ -62,7 +62,7 @@ export declare const mergeObstacle: (features: readonly FeatureOrPatch[]) => Mer
62
62
  * feature is the work of one act, and where the features stand is the
63
63
  * edition's business rather than theirs.
64
64
  */
65
- export declare const mergeObstacleIn: (view: EditionView, featureIds: readonly string[]) => MergeObstacle | undefined;
65
+ export declare const mergeObstacleIn: (edition: Edition, featureIds: readonly string[]) => MergeObstacle | undefined;
66
66
  /**
67
67
  * Replaces the features of the copy with a single one covering them
68
68
  * all, where a scan has split what the editor reads as one feature.
@@ -6,6 +6,7 @@ import { mm } from "../model/Quantity.js";
6
6
  import { onCopy, onFeature, stateOf } from "./draft.js";
7
7
  import { without, mapped, pruned, replacing, isRecord } from "./immutable.js";
8
8
  import { renameReferences, forgetFeatures } from "./forget.js";
9
+ import { copyOfFeature } from "../lookup/lookup.js";
9
10
  /**
10
11
  * Whether the feature's own kind allows a condition of this kind. The
11
12
  * type narrowed to is the weaker statement, holding of a condition any
@@ -209,8 +210,8 @@ const obstacleIn = (copy, featureIds) => {
209
210
  * feature is the work of one act, and where the features stand is the
210
211
  * edition's business rather than theirs.
211
212
  */
212
- export const mergeObstacleIn = (view, featureIds) => {
213
- const copy = featureIds.map(id => view.copyOf(id)).find(copy => copy !== undefined);
213
+ export const mergeObstacleIn = (edition, featureIds) => {
214
+ const copy = featureIds.map(id => copyOfFeature(edition, id)).find(copy => copy !== undefined);
214
215
  return copy ? obstacleIn(copy, featureIds) : 'fewer-than-two';
215
216
  };
216
217
  /** The items with the replacement in the place of the first it stands for, the others dropped. */
@@ -3,7 +3,7 @@
3
3
  * They are grouped by what they change under `ops/`; this module names
4
4
  * the ones the library offers.
5
5
  */
6
- export type { EditionOp } from "./draft.js";
6
+ export { stateOf, type EditionOp } from "./draft.js";
7
7
  export { createVersion, addCopy, alignmentFor, alignCopy, alignCopies, chooseReferenceCopy, unalignCopy, shortenCopy, unshortenCopy, stateSource, clearSource, nameCopy, stateCarriage, clearCarriage, addGeneralCondition, statePaperStretch, addTear, symbolsCarriedOnlyBy, removeCopy } from "./copies.js";
8
8
  export { stateFeatureCondition, addFeature, addBorneFeature, removeFeatures, mergeObstacle, mergeObstacleIn, mergeFeatures, type FeatureAct, type MergeObstacle } from "./features.js";
9
9
  export { detachVersion, removeVersion, removeSymbols, deriveVersion, stateDerivation, clearDerivation } from "./versions.js";
package/lib/ops/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The operations on an edition, each written onto an immer draft of it.
3
+ * They are grouped by what they change under `ops/`; this module names
4
+ * the ones the library offers.
5
+ */
6
+ export { stateOf } from "./draft.js";
1
7
  export { createVersion, addCopy, alignmentFor, alignCopy, alignCopies, chooseReferenceCopy, unalignCopy, shortenCopy, unshortenCopy, stateSource, clearSource, nameCopy, stateCarriage, clearCarriage, addGeneralCondition, statePaperStretch, addTear, symbolsCarriedOnlyBy, removeCopy } from "./copies.js";
2
8
  export { stateFeatureCondition, addFeature, addBorneFeature, removeFeatures, mergeObstacle, mergeObstacleIn, mergeFeatures } from "./features.js";
3
9
  export { detachVersion, removeVersion, removeSymbols, deriveVersion, stateDerivation, clearDerivation } from "./versions.js";
@@ -1,4 +1,3 @@
1
- import { EditionView } from "../view/EditionView.js";
2
1
  import { Derivation, Version } from "../model/Version.js";
3
2
  import { Belief } from "../model/Assumption.js";
4
3
  import { EditionOp } from "./draft.js";
@@ -9,13 +8,13 @@ export declare const hypothesesBeside: (version: Readonly<Version>, parentId: st
9
8
  * own insertions, and its derivations go, the hypotheses among them,
10
9
  * with the motivations that belonged to them.
11
10
  */
12
- export declare const detachVersion: (given: EditionView, versionId: string) => EditionOp;
11
+ export declare const detachVersion: (versionId: string) => EditionOp;
13
12
  /**
14
13
  * Takes the version out. Whatever read its text against it comes to
15
14
  * stand on its own, a hypothesis that something derives from it goes,
16
15
  * and so does a copy's statement that it carries the version.
17
16
  */
18
- export declare const removeVersion: (given: EditionView, versionId: string) => EditionOp;
17
+ export declare const removeVersion: (versionId: string) => EditionOp;
19
18
  /** Takes the symbols out of the version's own insertions, and the edits that had nothing else. */
20
19
  export declare const removeSymbols: (versionId: string, symbolIds: readonly string[]) => EditionOp;
21
20
  /** Moves the edits into a new version based on this one. */
@@ -4,6 +4,7 @@ import { assignReference, idOf } from "../model/Assumption.js";
4
4
  import { onVersion, stateOf, insertion, dropInsertions, referenceHeld, withoutReferences, reading } from "./draft.js";
5
5
  import { without } from "./immutable.js";
6
6
  import { dropStatements } from "./copies.js";
7
+ import { snapshotOf } from "../analysis/text.js";
7
8
  /** Whether the version's text is read against the parent, its principal derivation naming it. */
8
9
  const readsAgainst = (version, parentId) => {
9
10
  const principal = principalDerivationOf(version);
@@ -30,8 +31,8 @@ const dropDerivations = (version, matches) => {
30
31
  * own insertions, and its derivations go, the hypotheses among them,
31
32
  * with the motivations that belonged to them.
32
33
  */
33
- export const detachVersion = (given, versionId) => reading(given, view => {
34
- const edits = view.snapshot(versionId).map(insertion);
34
+ export const detachVersion = (versionId) => reading(edition => {
35
+ const edits = snapshotOf(edition, versionId).map(insertion);
35
36
  return onVersion(versionId, version => {
36
37
  version.edits = edits;
37
38
  delete version.basedOn;
@@ -43,10 +44,10 @@ export const detachVersion = (given, versionId) => reading(given, view => {
43
44
  * stand on its own, a hypothesis that something derives from it goes,
44
45
  * and so does a copy's statement that it carries the version.
45
46
  */
46
- export const removeVersion = (given, versionId) => reading(given, view => {
47
- const detachments = view.edition.versions
47
+ export const removeVersion = (versionId) => reading(edition => {
48
+ const detachments = edition.versions
48
49
  .filter(version => readsAgainst(version, versionId))
49
- .map(version => detachVersion(view, version.id));
50
+ .map(version => detachVersion(version.id));
50
51
  const namesIt = (reference) => idOf(reference) === versionId;
51
52
  return draft => {
52
53
  detachments.forEach(detach => detach(draft));
package/lib/schema.json CHANGED
@@ -523,7 +523,7 @@
523
523
  "type": "string"
524
524
  },
525
525
  "Edit": {
526
- "description": "A set of edits transforms a version of a roll into another version. Edits insert or delete symbols, or both (= replace). Edits may be motivated by a given set of reasons, e.g. to add an additional accent or to correct an error. If an edit is the interpretation of a metamark, such as a pencil mark, this should be made explicit using a meaning comprehension on the `@annotation` field.",
526
+ "description": "A set of edits transforms a version of a roll into another version. Edits insert or delete symbols, or both (= replace). Edits may be motivated by a given set of reasons, e.g. to add an additional accent or to correct an error. If an edit is the interpretation of a metamark, such as a pencil mark, this should be made explicit using a meaning comprehension on the `@annotation` field. An edit states no date. That it ended no later than the act that made a feature carrying a symbol it inserts, a reasoner derives with the axioms of reo.ttl; which of those dates bounds it closest is for a query to pick.",
527
527
  "properties": {
528
528
  "@annotation": {
529
529
  "description": "An optional annotation expressing a belief about this assumption. Uses the JSON-LD-star `@annotation` mechanism to attach epistemic metadata (certainty and reasons) to any triple.",
@@ -3523,7 +3523,7 @@
3523
3523
  },
3524
3524
  "creation": {
3525
3525
  "$ref": "#/definitions/VersionCreation",
3526
- "description": "The act that made this version, where it is known: who carried it out, when, and by what rule.",
3526
+ "description": "The act that made this version, where it is known: who carried it out, when, and by what rule. The export states the act for every version, stating nothing of it where nothing is known, so that the axioms of reo.ttl can place it in time: it started after the recording and the creation of every version it derives from had started, and ended no later than the punching of any copy carrying a symbol it added. A date stated here stands beside those; which of them bounds the act closest is for a query to pick.",
3527
3527
  "ontology": "lrmoo:R17i was created by"
3528
3528
  },
3529
3529
  "edits": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.63.0",
3
+ "version": "0.64.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": {