linked-rolls 0.70.0 → 0.71.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 (125) hide show
  1. package/README.md +20 -5
  2. package/lib/analysis/constraints.d.ts +7 -0
  3. package/lib/analysis/constraints.js +1 -0
  4. package/lib/analysis/ownPaper.d.ts +5 -1
  5. package/lib/analysis/ownPaper.js +5 -1
  6. package/lib/analysis/paper.d.ts +22 -4
  7. package/lib/analysis/paper.js +6 -0
  8. package/lib/analysis/reservations.d.ts +24 -1
  9. package/lib/analysis/reservations.js +15 -1
  10. package/lib/analysis/sigla.d.ts +6 -1
  11. package/lib/analysis/sigla.js +5 -1
  12. package/lib/analysis/stemma.d.ts +6 -1
  13. package/lib/analysis/stemma.js +6 -1
  14. package/lib/analysis/text.d.ts +16 -2
  15. package/lib/analysis/text.js +16 -2
  16. package/lib/analysis/witnesses.d.ts +20 -1
  17. package/lib/analysis/witnesses.js +4 -0
  18. package/lib/collation/Collation.d.ts +47 -8
  19. package/lib/collation/Collation.js +29 -5
  20. package/lib/collation/alignment.d.ts +16 -3
  21. package/lib/collation/alignment.js +15 -3
  22. package/lib/collation/scatter.d.ts +50 -9
  23. package/lib/collation/scatter.js +11 -1
  24. package/lib/collation/statistics.d.ts +39 -9
  25. package/lib/collation/statistics.js +27 -6
  26. package/lib/collation/substitution.d.ts +5 -0
  27. package/lib/collation/substitution.js +4 -0
  28. package/lib/emulation/Emulation.d.ts +16 -1
  29. package/lib/emulation/Emulation.js +10 -0
  30. package/lib/emulation/negotiation.d.ts +1 -0
  31. package/lib/emulation/negotiation.js +1 -0
  32. package/lib/index.d.ts +33 -2
  33. package/lib/index.js +2 -1
  34. package/lib/io/asJsonLd.d.ts +10 -0
  35. package/lib/io/asJsonLd.js +10 -0
  36. package/lib/io/context.d.ts +16 -2
  37. package/lib/io/context.js +16 -2
  38. package/lib/io/importJsonLd.d.ts +1 -0
  39. package/lib/io/importJsonLd.js +1 -0
  40. package/lib/io/migrate.d.ts +8 -0
  41. package/lib/io/migrate.js +8 -0
  42. package/lib/lookup/lookup.d.ts +29 -5
  43. package/lib/lookup/lookup.js +29 -5
  44. package/lib/lookup/paths.d.ts +23 -3
  45. package/lib/lookup/paths.js +17 -3
  46. package/lib/model/Agent.d.ts +28 -2
  47. package/lib/model/Agent.js +15 -1
  48. package/lib/model/Assumption.d.ts +96 -7
  49. package/lib/model/Assumption.js +65 -7
  50. package/lib/model/ConditionState.d.ts +1 -0
  51. package/lib/model/Edit.d.ts +10 -0
  52. package/lib/model/Edit.js +8 -0
  53. package/lib/model/Edition.d.ts +11 -0
  54. package/lib/model/Edition.js +1 -0
  55. package/lib/model/Feature.d.ts +74 -7
  56. package/lib/model/Feature.js +41 -3
  57. package/lib/model/FeatureSource.d.ts +14 -1
  58. package/lib/model/FeatureSource.js +7 -1
  59. package/lib/model/Perforator.d.ts +10 -0
  60. package/lib/model/Perforator.js +1 -0
  61. package/lib/model/Quantity.d.ts +160 -13
  62. package/lib/model/Quantity.js +110 -6
  63. package/lib/model/RollCopy.d.ts +74 -12
  64. package/lib/model/RollCopy.js +53 -10
  65. package/lib/model/Symbol.d.ts +38 -1
  66. package/lib/model/Symbol.js +16 -0
  67. package/lib/model/TrackCalibration.d.ts +10 -2
  68. package/lib/model/TrackCalibration.js +9 -2
  69. package/lib/model/Version.d.ts +24 -4
  70. package/lib/model/Version.js +19 -4
  71. package/lib/model/notes.d.ts +15 -2
  72. package/lib/model/notes.js +9 -2
  73. package/lib/model/procedures.d.ts +5 -1
  74. package/lib/model/procedures.js +5 -1
  75. package/lib/model/vocabulary.d.ts +6 -1
  76. package/lib/model/vocabulary.js +6 -1
  77. package/lib/ops/beliefs.d.ts +23 -1
  78. package/lib/ops/beliefs.js +23 -1
  79. package/lib/ops/collation.d.ts +3 -0
  80. package/lib/ops/collation.js +3 -0
  81. package/lib/ops/commands.d.ts +17 -2
  82. package/lib/ops/commands.js +17 -2
  83. package/lib/ops/copies.d.ts +37 -6
  84. package/lib/ops/copies.js +37 -6
  85. package/lib/ops/draft.d.ts +2 -0
  86. package/lib/ops/draft.js +1 -0
  87. package/lib/ops/edits.d.ts +5 -1
  88. package/lib/ops/edits.js +5 -1
  89. package/lib/ops/features.d.ts +12 -1
  90. package/lib/ops/features.js +7 -0
  91. package/lib/ops/versions.d.ts +15 -3
  92. package/lib/ops/versions.js +15 -3
  93. package/lib/readers/phillipsEroll.d.ts +12 -1
  94. package/lib/readers/phillipsEroll.js +6 -1
  95. package/lib/readers/spencerBar.d.ts +12 -1
  96. package/lib/readers/spencerBar.js +7 -1
  97. package/lib/readers/stanfordAton.d.ts +15 -0
  98. package/lib/readers/stanfordAton.js +9 -0
  99. package/lib/schema.json +10 -0
  100. package/lib/shared/utils.d.ts +12 -0
  101. package/lib/spec/context.json +4 -0
  102. package/lib/systems/ReproducingSystem.d.ts +46 -3
  103. package/lib/systems/TrackerBar.d.ts +45 -4
  104. package/lib/systems/TrackerBar.js +20 -3
  105. package/lib/systems/index.d.ts +9 -2
  106. package/lib/systems/index.js +9 -2
  107. package/lib/systems/velocity.d.ts +1 -0
  108. package/lib/systems/velocity.js +1 -0
  109. package/lib/systems/welte.d.ts +18 -3
  110. package/lib/systems/welte.js +9 -2
  111. package/lib/systems/welteLicensee/bar.d.ts +1 -0
  112. package/lib/systems/welteLicensee/bar.js +1 -0
  113. package/lib/systems/welteLicensee/system.d.ts +18 -0
  114. package/lib/systems/welteLicensee/system.js +17 -0
  115. package/lib/systems/welteT100/bar.d.ts +8 -0
  116. package/lib/systems/welteT100/bar.js +4 -0
  117. package/lib/systems/welteT100/system.d.ts +46 -5
  118. package/lib/systems/welteT100/system.js +29 -3
  119. package/lib/systems/welteT98/bar.d.ts +6 -0
  120. package/lib/systems/welteT98/bar.js +2 -0
  121. package/lib/systems/welteT98/system.d.ts +58 -5
  122. package/lib/systems/welteT98/system.js +42 -3
  123. package/lib/validate.d.ts +16 -0
  124. package/lib/validate.js +15 -0
  125. package/package.json +2 -1
@@ -9,7 +9,10 @@ import { quantity } from "../model/Quantity.js";
9
9
  * stood out; a median and a median absolute deviation leave them out of
10
10
  * account.
11
11
  */
12
- /** The middle of a sample, the mean of the two middle values where it has an even number of them. */
12
+ /**
13
+ * The middle of a sample, the mean of the two middle values where it has an even number of them.
14
+ * @internal
15
+ */
13
16
  export const medianOf = (values) => {
14
17
  if (values.length === 0)
15
18
  return undefined;
@@ -21,7 +24,10 @@ export const medianOf = (values) => {
21
24
  };
22
25
  /** What the median absolute deviation must be multiplied by to estimate the standard deviation of a normal sample. */
23
26
  const MAD_TO_SIGMA = 1.4826;
24
- /** Where the sample sits and how far it scatters, or nothing for an empty sample. */
27
+ /**
28
+ * Where the sample sits and how far it scatters, or nothing for an empty sample.
29
+ * @internal
30
+ */
25
31
  export const spreadOf = (values) => {
26
32
  const median = medianOf(values);
27
33
  if (median === undefined)
@@ -33,7 +39,10 @@ export const spreadOf = (values) => {
33
39
  sigma: quantity(MAD_TO_SIGMA * (medianOf(deviations) ?? 0))
34
40
  };
35
41
  };
36
- /** How far the value lies from the centre of the spread, in units of its scatter. */
42
+ /**
43
+ * How far the value lies from the centre of the spread, in units of its scatter.
44
+ * @internal
45
+ */
37
46
  export const standardise = (value, spread) => (value - spread.median) / spread.sigma;
38
47
  /** The complementary error function, after Press et al., whose fractional error stays below 1.2e-7. */
39
48
  const erfc = (x) => {
@@ -44,9 +53,15 @@ const erfc = (x) => {
44
53
  t * (-0.82215223 + t * 0.17087277)))))))));
45
54
  return x >= 0 ? tail : 2 - tail;
46
55
  };
47
- /** The share of a normal sample lying below `z` standard deviations. */
56
+ /**
57
+ * The share of a normal sample lying below `z` standard deviations.
58
+ * @internal
59
+ */
48
60
  export const normalBelow = (z) => erfc(-z / Math.SQRT2) / 2;
49
- /** The share of a normal sample lying further than `z` standard deviations from its centre, on either side. */
61
+ /**
62
+ * The share of a normal sample lying further than `z` standard deviations from its centre, on either side.
63
+ * @internal
64
+ */
50
65
  export const normalBeyond = (z) => erfc(z / Math.SQRT2);
51
66
  const horner = (coefficients, x) => coefficients.reduce((total, coefficient) => total * x + coefficient, 0);
52
67
  const CENTRAL_NUMERATOR = [
@@ -74,6 +89,7 @@ const tailQuantile = (share) => {
74
89
  * How many standard deviations out the given share of a normal sample
75
90
  * lies below, after Acklam's rational approximation, whose relative
76
91
  * error stays below 1.15e-9. The inverse of `normalBelow`.
92
+ * @internal
77
93
  */
78
94
  export const normalQuantile = (share) => {
79
95
  if (share <= 0)
@@ -92,9 +108,13 @@ export const normalQuantile = (share) => {
92
108
  * How much heavier the tails of a standardised sample are than a normal
93
109
  * sample's. Zero for a normal shape, positive where more of the sample
94
110
  * lies far out than the curve allows.
111
+ * @internal
95
112
  */
96
113
  export const excessKurtosisOf = (standardised) => standardised.reduce((total, z) => total + z ** 4, 0) / standardised.length - 3;
97
- /** What the sample puts beyond the given distance, against what a normal sample would. */
114
+ /**
115
+ * What the sample puts beyond the given distance, against what a normal sample would.
116
+ * @internal
117
+ */
98
118
  export const tailOf = (standardised, beyond) => ({
99
119
  beyond,
100
120
  observed: standardised.filter(z => Math.abs(z) > beyond).length,
@@ -104,6 +124,7 @@ export const tailOf = (standardised, beyond) => ({
104
124
  * The sample counted into bins of the given width, laid out on
105
125
  * multiples of that width so that two histograms of one width share
106
126
  * their bounds. Nothing for an empty sample or a width of nothing.
127
+ * @internal
107
128
  */
108
129
  export const histogramOf = (values, binWidth) => {
109
130
  if (values.length === 0 || binWidth <= 0)
@@ -8,11 +8,13 @@ export type { Operation, Spelling } from "../systems/TrackerBar.js";
8
8
  * nothing for a word no bar here knows or one without a counterpart in
9
9
  * another scale. The bars share their words where they share a scale,
10
10
  * as the Licensee does the T-100's, so the first that reads it answers.
11
+ * @category Systems and emulation
11
12
  */
12
13
  export declare const operationOf: (expressionType: string) => Operation | undefined;
13
14
  /**
14
15
  * A latched function of the older version and the held command of the
15
16
  * newer one that stands for it.
17
+ * @category Collation and alignment
16
18
  */
17
19
  export interface Substitution {
18
20
  /** The command that turned the function on, and the one that cancelled it. */
@@ -30,6 +32,7 @@ export interface Substitution {
30
32
  * command. The T-98 punches a hold as a chain of round holes on a
31
33
  * 2.66 mm grid with bridges of about a millimetre, so a scan read hole
32
34
  * by hole shows a run where the paper shows one command.
35
+ * @category Collation and alignment
33
36
  */
34
37
  export declare const defaultChainGap: import("../index.js").Quantity<"mm">;
35
38
  /**
@@ -42,6 +45,7 @@ export declare const defaultChainGap: import("../index.js").Quantity<"mm">;
42
45
  * the green bar, so drawing it as a perforation is out of the question,
43
46
  * but an edit still has to be shown somewhere, and the lane the green
44
47
  * scale gives the same function is where it belongs.
48
+ * @internal
45
49
  */
46
50
  export declare const positionOfSameFunction: (bar: TrackerBar, symbol: Expression) => Track | undefined;
47
51
  /**
@@ -54,5 +58,6 @@ export declare const positionOfSameFunction: (bar: TrackerBar, symbol: Expressio
54
58
  * reported and the editor is left to say what happened. Nothing is
55
59
  * invented either: both sides are perforations somebody punched, and all
56
60
  * this asserts is which stands for which.
61
+ * @category Collation and alignment
57
62
  */
58
63
  export declare const substitutionsBetween: (own: readonly AnySymbol[], inherited: readonly AnySymbol[], locate: Locate, tolerance?: CollationTolerance, chainGap?: Millimeters) => Substitution[];
@@ -6,6 +6,7 @@ import { trackerBars } from "../systems/index.js";
6
6
  * nothing for a word no bar here knows or one without a counterpart in
7
7
  * another scale. The bars share their words where they share a scale,
8
8
  * as the Licensee does the T-100's, so the first that reads it answers.
9
+ * @category Systems and emulation
9
10
  */
10
11
  export const operationOf = (expressionType) => {
11
12
  for (const bar of trackerBars) {
@@ -20,6 +21,7 @@ export const operationOf = (expressionType) => {
20
21
  * command. The T-98 punches a hold as a chain of round holes on a
21
22
  * 2.66 mm grid with bridges of about a millimetre, so a scan read hole
22
23
  * by hole shows a run where the paper shows one command.
24
+ * @category Collation and alignment
23
25
  */
24
26
  export const defaultChainGap = mm(3);
25
27
  const isExpression = (symbol) => symbol.type === 'expression';
@@ -35,6 +37,7 @@ const functionKey = (symbol, operation) => operation.sided ? `${operation.operat
35
37
  * the green bar, so drawing it as a perforation is out of the question,
36
38
  * but an edit still has to be shown somewhere, and the lane the green
37
39
  * scale gives the same function is where it belongs.
40
+ * @internal
38
41
  */
39
42
  export const positionOfSameFunction = (bar, symbol) => {
40
43
  const wanted = operationOf(symbol.expressionType);
@@ -132,6 +135,7 @@ const theOnly = (items) => items.length === 1 ? items[0] : undefined;
132
135
  * reported and the editor is left to say what happened. Nothing is
133
136
  * invented either: both sides are perforations somebody punched, and all
134
137
  * this asserts is which stands for which.
138
+ * @category Collation and alignment
135
139
  */
136
140
  export const substitutionsBetween = (own, inherited, locate, tolerance = defaultCollationTolerance, chainGap = defaultChainGap) => {
137
141
  const latched = latchedIn(inherited, locate);
@@ -4,6 +4,10 @@ import { Version } from "../model/Version.js";
4
4
  import { AnyPerformedRollFeature, EmulatedCurve, NegotiatedEvent, ReproducingSystem } from "../systems/ReproducingSystem.js";
5
5
  import { Millimeters } from "../model/Quantity.js";
6
6
  import { Edition } from "../model/Edition.js";
7
+ /**
8
+ * Which part of a version `emulate` plays, and where its clock starts.
9
+ * @category Systems and emulation
10
+ */
7
11
  export type EmulationScope = {
8
12
  /** Only notes whose onset lies within this span of the roll are played. */
9
13
  range?: [Millimeters, Millimeters];
@@ -15,15 +19,20 @@ export type EmulationScope = {
15
19
  * left as they were. The edition supplies the copies, whose measurements
16
20
  * decide how far before or after its reference a command goes, and a
17
21
  * punch diameter, or a millimetre, where no copy agrees with a statement.
22
+ * @category Systems and emulation
18
23
  */
19
24
  export declare const withPlacementsApplied: (edition: Edition, events: readonly NegotiatedEvent[]) => NegotiatedEvent[];
20
25
  /**
21
26
  * The commands of a version as the bar performs them, in order of place,
22
27
  * within the scope and with the placements applied. A note plays only
23
28
  * where its onset falls in the range; expressions play throughout.
29
+ * @category Systems and emulation
24
30
  */
25
31
  export declare const negotiatedEventsOf: (edition: Edition, version: Readonly<Version>, bar: TrackerBar, { range }?: Pick<EmulationScope, 'range'>) => NegotiatedEvent[];
26
- /** A version performed: what was negotiated, and what the system made of it. */
32
+ /**
33
+ * A version performed: what was negotiated, and what the system made of it.
34
+ * @category Systems and emulation
35
+ */
27
36
  export interface Emulated {
28
37
  /** The id of the version performed. */
29
38
  readonly source: string;
@@ -35,18 +44,21 @@ export interface Emulated {
35
44
  /**
36
45
  * Performs a version on a reproducing system: the symbols are negotiated
37
46
  * into placed events and the system plays them. Nothing given is changed.
47
+ * @category Systems and emulation
38
48
  */
39
49
  export declare const emulate: <Options extends object>(system: ReproducingSystem<Options>, version: Readonly<Version>, edition: Edition, options?: Options, { range, skipToFirstNote }?: EmulationScope) => Emulated;
40
50
  /**
41
51
  * The performed events as a MIDI file, in which every note and pedal step
42
52
  * is labelled with the symbol it performs. The file names the system, the
43
53
  * version and the options it was played with.
54
+ * @category Systems and emulation
44
55
  */
45
56
  export declare const midiOf: (events: readonly AnyPerformedRollFeature[], systemName: string, options: object, source?: string) => MidiFile;
46
57
  /**
47
58
  * A version of the edition, performed and kept: `emulate` and `midiOf`
48
59
  * with the result held on the object between the two calls. Prefer the
49
60
  * functions where nothing needs holding.
61
+ * @category Systems and emulation
50
62
  */
51
63
  export declare class Emulation<Options extends object> {
52
64
  readonly system: ReproducingSystem<Options>;
@@ -58,7 +70,10 @@ export declare class Emulation<Options extends object> {
58
70
  constructor(system: ReproducingSystem<Options>, options?: Options);
59
71
  /** Moves the negotiated events to where their statements put them; see `withPlacementsApplied`. */
60
72
  applyConstraints(edition: Edition): void;
73
+ /** Performs the version, keeps what came of it, and returns the performed events; see `emulate`. */
61
74
  emulateVersion(version: Version, edition: Edition, scope?: EmulationScope): AnyPerformedRollFeature[];
75
+ /** The performed events that sound or follow from the symbol with the id. */
62
76
  findEventsPerforming(id: string): AnyPerformedRollFeature[];
77
+ /** The performed events as a MIDI file; see `midiOf`. */
63
78
  asMIDI(): MidiFile;
64
79
  }
@@ -151,6 +151,7 @@ const earliestOf = (times) => times.length === 0 ? seconds(0) : times.reduce((so
151
151
  * left as they were. The edition supplies the copies, whose measurements
152
152
  * decide how far before or after its reference a command goes, and a
153
153
  * punch diameter, or a millimetre, where no copy agrees with a statement.
154
+ * @category Systems and emulation
154
155
  */
155
156
  export const withPlacementsApplied = (edition, events) => {
156
157
  const gap = meanPunchDiameterOf(edition) ?? mm(1);
@@ -168,6 +169,7 @@ export const withPlacementsApplied = (edition, events) => {
168
169
  * The commands of a version as the bar performs them, in order of place,
169
170
  * within the scope and with the placements applied. A note plays only
170
171
  * where its onset falls in the range; expressions play throughout.
172
+ * @category Systems and emulation
171
173
  */
172
174
  export const negotiatedEventsOf = (edition, version, bar, { range } = {}) => {
173
175
  const inScope = (event) => !range || event.type !== 'note' || (event.horizontal.from > range[0] && event.horizontal.from < range[1]);
@@ -180,6 +182,7 @@ export const negotiatedEventsOf = (edition, version, bar, { range } = {}) => {
180
182
  /**
181
183
  * Performs a version on a reproducing system: the symbols are negotiated
182
184
  * into placed events and the system plays them. Nothing given is changed.
185
+ * @category Systems and emulation
183
186
  */
184
187
  export const emulate = (system, version, edition, options = system.defaultOptions, { range, skipToFirstNote = false } = {}) => {
185
188
  const negotiated = negotiatedEventsOf(edition, version, system.trackerBar, { range });
@@ -202,6 +205,7 @@ export const emulate = (system, version, edition, options = system.defaultOption
202
205
  * The performed events as a MIDI file, in which every note and pedal step
203
206
  * is labelled with the symbol it performs. The file names the system, the
204
207
  * version and the options it was played with.
208
+ * @category Systems and emulation
205
209
  */
206
210
  export const midiOf = (events, systemName, options, source) => {
207
211
  const TICKS_PER_SECOND = 1000;
@@ -262,6 +266,8 @@ export const midiOf = (events, systemName, options, source) => {
262
266
  midi.push(controller(controllerOf(event), event.value, labelled ? deltaTime : 0));
263
267
  }
264
268
  }
269
+ // a standard MIDI file ends every track with this event
270
+ midi.push({ type: 'meta', subtype: 'endOfTrack', deltaTime: 0 });
265
271
  return {
266
272
  header: {
267
273
  ticksPerBeat: TICKS_PER_SECOND,
@@ -275,6 +281,7 @@ export const midiOf = (events, systemName, options, source) => {
275
281
  * A version of the edition, performed and kept: `emulate` and `midiOf`
276
282
  * with the result held on the object between the two calls. Prefer the
277
283
  * functions where nothing needs holding.
284
+ * @category Systems and emulation
278
285
  */
279
286
  export class Emulation {
280
287
  constructor(system, options = system.defaultOptions) {
@@ -322,6 +329,7 @@ export class Emulation {
322
329
  applyConstraints(edition) {
323
330
  this.negotiatedEvents = withPlacementsApplied(edition, this.negotiatedEvents);
324
331
  }
332
+ /** Performs the version, keeps what came of it, and returns the performed events; see `emulate`. */
325
333
  emulateVersion(version, edition, scope = {}) {
326
334
  const emulated = emulate(this.system, version, edition, this.options, scope);
327
335
  this.source = emulated.source;
@@ -330,9 +338,11 @@ export class Emulation {
330
338
  this.midiEvents = [...emulated.events];
331
339
  return this.midiEvents;
332
340
  }
341
+ /** The performed events that sound or follow from the symbol with the id. */
333
342
  findEventsPerforming(id) {
334
343
  return this.midiEvents.filter(event => event.performs.id === id);
335
344
  }
345
+ /** The performed events as a MIDI file; see `midiOf`. */
336
346
  asMIDI() {
337
347
  return midiOf(this.midiEvents, this.system.name, this.options, this.source);
338
348
  }
@@ -10,5 +10,6 @@ import { Edition } from "../model/Edition.js";
10
10
  * transfer between systems leaves behind: a red `ForzandoOn` a
11
11
  * green version still inherits cannot be performed on a green
12
12
  * machine, and an edit has yet to say what took its place.
13
+ * @category Systems and emulation
13
14
  */
14
15
  export declare const negotiatedEventOf: (edition: Edition, symbol: Note | Expression, bar: TrackerBar) => NegotiatedEvent | null;
@@ -7,6 +7,7 @@ import { placeOf } from "../analysis/text.js";
7
7
  * transfer between systems leaves behind: a red `ForzandoOn` a
8
8
  * green version still inherits cannot be performed on a green
9
9
  * machine, and an edit has yet to say what took its place.
10
+ * @category Systems and emulation
10
11
  */
11
12
  export const negotiatedEventOf = (edition, symbol, bar) => {
12
13
  const horizontal = placeOf(edition, symbol);
package/lib/index.d.ts CHANGED
@@ -1,11 +1,41 @@
1
1
  /**
2
+ * Digital editions of piano rolls: reading an edition and writing it out
3
+ * as JSON-LD, finding what it holds, changing it through operations on
4
+ * an immer draft, reading copies from scans and analysis files,
5
+ * collating them into versions, and working out what the edition can
6
+ * and cannot vouch for. The reproducing systems that play a version are
7
+ * entry points of their own, so that the emulator they need is loaded
8
+ * only where it is wanted.
9
+ *
2
10
  * The public interface of the library. Everything else under lib/ is its
3
11
  * implementation and may change in any release: the in-place helpers the
4
12
  * operations are built from, the date conversions of the serialisation,
5
- * and the general utilities.
13
+ * and the general utilities. So may the exports tagged `@internal`,
14
+ * which the API reference leaves out.
15
+ *
16
+ * @module linked-rolls
17
+ *
18
+ * @categoryDescription Format types
19
+ * The types of an edition. They are documented field by field, with the
20
+ * ontology terms each field maps to, in the
21
+ * [format reference](https://pfefferniels.github.io/linked-rolls/); they
22
+ * are listed here so that the signatures can link to them.
23
+ *
24
+ * @categoryDescription Units
25
+ * A quantity is a plain number at runtime; its unit lives in its type, so
26
+ * that a length in millimetres cannot be passed where one in pixels is
27
+ * wanted. The constructors make a number into a quantity.
6
28
  */
7
29
  export type { WithId, WithNote, WithType } from './shared/utils.js';
8
30
  export * from './model/Quantity.js';
31
+ /**
32
+ * A number in a unit, the unit carried in the type alone: at runtime it
33
+ * is the plain number it was made from. A number becomes a quantity only
34
+ * through a constructor such as `mm` or `track`, and a quantity in one
35
+ * unit cannot stand in for one in another.
36
+ * @category Units
37
+ */
38
+ export type { Quantity } from './model/Quantity.js';
9
39
  export * from './model/Agent.js';
10
40
  export * from './model/Assumption.js';
11
41
  export * from './model/ConditionState.js';
@@ -41,7 +71,8 @@ export * from './emulation/negotiation.js';
41
71
  export * from './collation/scatter.js';
42
72
  export * from './ops/index.js';
43
73
  export * from './emulation/Emulation.js';
44
- export * from './validate.js';
74
+ /** @category Reading and writing */
75
+ export { validate, type ValidateEdition } from './validate.js';
45
76
  export * from './analysis/constraints.js';
46
77
  export * from './collation/substitution.js';
47
78
  export * from './io/context.js';
package/lib/index.js CHANGED
@@ -34,7 +34,8 @@ export * from './emulation/negotiation.js';
34
34
  export * from './collation/scatter.js';
35
35
  export * from './ops/index.js';
36
36
  export * from './emulation/Emulation.js';
37
- export * from './validate.js';
37
+ /** @category Reading and writing */
38
+ export { validate } from './validate.js';
38
39
  export * from './analysis/constraints.js';
39
40
  export * from './collation/substitution.js';
40
41
  export * from './io/context.js';
@@ -5,4 +5,14 @@ import { Edition } from "../model/Edition.js";
5
5
  */
6
6
  export declare const derivedKeys: ReadonlySet<string>;
7
7
  export declare const exportDate: (date: Date) => string;
8
+ /**
9
+ * Writes the edition as a JSON-LD document in the terms of the Roll
10
+ * Edition Ontology. Each copy's features and tears go back to the
11
+ * copy's own places, as they were read, with the alignment beside them,
12
+ * and every version carries the context of its own reproducing system.
13
+ * A reference the edition holds possible, unlikely or false is quoted
14
+ * rather than stated, so that a reader of the RDF does not take it for
15
+ * a fact. The edition given is not changed.
16
+ * @category Reading and writing
17
+ */
8
18
  export declare const asJsonLd: (edition: Edition) => any;
@@ -160,6 +160,16 @@ const withDoubtedReferencesQuoted = (value, quoted) => {
160
160
  const atOwnPlacesAll = (edition) => edition.copies.some(copy => copy.measurements.alignment)
161
161
  ? { ...edition, copies: edition.copies.map(atOwnPlaces) }
162
162
  : edition;
163
+ /**
164
+ * Writes the edition as a JSON-LD document in the terms of the Roll
165
+ * Edition Ontology. Each copy's features and tears go back to the
166
+ * copy's own places, as they were read, with the alignment beside them,
167
+ * and every version carries the context of its own reproducing system.
168
+ * A reference the edition holds possible, unlikely or false is quoted
169
+ * rather than stated, so that a reader of the RDF does not take it for
170
+ * a fact. The edition given is not changed.
171
+ * @category Reading and writing
172
+ */
163
173
  export const asJsonLd = (edition) => {
164
174
  const quoted = [];
165
175
  const node = withDoubtedReferencesQuoted(withSystemContexts(withCreations(withChanges(asJsonLdEntity(atOwnPlacesAll(edition))))), quoted);
@@ -1,12 +1,26 @@
1
+ /**
2
+ * The JSON-LD context of the format, which an exported edition names by
3
+ * its address, `https://w3id.org/reo/context.jsonld`: it maps the keys of
4
+ * the document onto the Roll Edition Ontology, CIDOC CRM, LRMoo and
5
+ * CRMinf.
6
+ * @category Reading and writing
7
+ */
1
8
  export { default as jsonLdContext } from '../spec/context.json';
2
- /** The context of the Welte-Mignon T-100, added to a version coded for it. */
9
+ /**
10
+ * The context of the Welte-Mignon T-100, added to a version coded for it.
11
+ * @category Reading and writing
12
+ */
3
13
  export { default as welteT100JsonLdContext } from '../spec/welte-t100.context.json';
4
14
  /**
5
15
  * The context of the Welte-Mignon Licensee. Its expression terms are
6
16
  * the T-100's, the two systems differing in the tracker scale rather
7
17
  * than in the coding, so it reads them out of the T-100's vocabulary
8
18
  * rather than minting a second set of IRIs for the same commands.
19
+ * @category Reading and writing
9
20
  */
10
21
  export { default as welteLicenseeJsonLdContext } from '../spec/welte-licensee.context.json';
11
- /** The context of the Welte-Mignon T-98, added to an edition of a green roll. */
22
+ /**
23
+ * The context of the Welte-Mignon T-98, added to an edition of a green roll.
24
+ * @category Reading and writing
25
+ */
12
26
  export { default as welteT98JsonLdContext } from '../spec/welte-t98.context.json';
package/lib/io/context.js CHANGED
@@ -1,12 +1,26 @@
1
+ /**
2
+ * The JSON-LD context of the format, which an exported edition names by
3
+ * its address, `https://w3id.org/reo/context.jsonld`: it maps the keys of
4
+ * the document onto the Roll Edition Ontology, CIDOC CRM, LRMoo and
5
+ * CRMinf.
6
+ * @category Reading and writing
7
+ */
1
8
  export { default as jsonLdContext } from '../spec/context.json' with { type: 'json' };
2
- /** The context of the Welte-Mignon T-100, added to a version coded for it. */
9
+ /**
10
+ * The context of the Welte-Mignon T-100, added to a version coded for it.
11
+ * @category Reading and writing
12
+ */
3
13
  export { default as welteT100JsonLdContext } from '../spec/welte-t100.context.json' with { type: 'json' };
4
14
  /**
5
15
  * The context of the Welte-Mignon Licensee. Its expression terms are
6
16
  * the T-100's, the two systems differing in the tracker scale rather
7
17
  * than in the coding, so it reads them out of the T-100's vocabulary
8
18
  * rather than minting a second set of IRIs for the same commands.
19
+ * @category Reading and writing
9
20
  */
10
21
  export { default as welteLicenseeJsonLdContext } from '../spec/welte-licensee.context.json' with { type: 'json' };
11
- /** The context of the Welte-Mignon T-98, added to an edition of a green roll. */
22
+ /**
23
+ * The context of the Welte-Mignon T-98, added to an edition of a green roll.
24
+ * @category Reading and writing
25
+ */
12
26
  export { default as welteT98JsonLdContext } from '../spec/welte-t98.context.json' with { type: 'json' };
@@ -5,6 +5,7 @@ type Json = any;
5
5
  * Reads an edition. A document holds each copy's features and tears at
6
6
  * the copy's own places, as they were read; the edition holds them on
7
7
  * its axis, which is where the copy's alignment carries them.
8
+ * @category Reading and writing
8
9
  */
9
10
  export declare const importJsonLd: (json: Json) => Edition;
10
11
  export {};
@@ -133,6 +133,7 @@ const withQuotedStatementsInPlace = (edition) => {
133
133
  * Reads an edition. A document holds each copy's features and tears at
134
134
  * the copy's own places, as they were read; the edition holds them on
135
135
  * its axis, which is where the copy's alignment carries them.
136
+ * @category Reading and writing
136
137
  */
137
138
  export const importJsonLd = (json) => {
138
139
  const { '@context': context, ...document } = withoutEmptyCreations(withPlainCopyIds(migrate(withQuotedStatementsInPlace(json))));
@@ -13,5 +13,13 @@
13
13
  type Json = any;
14
14
  /** A copy's id without the `copy/` that documents of earlier releases put before it. */
15
15
  export declare const plainCopyId: (id: string) => string;
16
+ /**
17
+ * Brings the JSON of an edition written by an earlier release of the
18
+ * format up to the current shape. A document that is current already
19
+ * passes through unchanged, and one may be migrated any number of
20
+ * times. `importJsonLd` migrates what it reads, so this is needed only
21
+ * to look at an old document as JSON.
22
+ * @category Reading and writing
23
+ */
16
24
  export declare const migrate: (edition: Json) => Json;
17
25
  export {};
package/lib/io/migrate.js CHANGED
@@ -677,4 +677,12 @@ const withReferenceCopy = (edition) => {
677
677
  : edition;
678
678
  };
679
679
  const editionSteps = [withoutFormatVersion, withoutTempoAdjustment, withoutEditionType, withSystems, withEditors, withDerivationTolerance, withReferenceCopy];
680
+ /**
681
+ * Brings the JSON of an edition written by an earlier release of the
682
+ * format up to the current shape. A document that is current already
683
+ * passes through unchanged, and one may be migrated any number of
684
+ * times. `importJsonLd` migrates what it reads, so this is needed only
685
+ * to look at an old document as JSON.
686
+ * @category Reading and writing
687
+ */
680
688
  export const migrate = (edition) => walk(editionSteps.reduce((result, step) => step(result), edition));
@@ -10,17 +10,40 @@ import { NestedFeature } from "../model/Feature.js";
10
10
  import { AnySymbol } from "../model/Symbol.js";
11
11
  import { Version } from "../model/Version.js";
12
12
  import { Modification, ProductionEvent, RollCopy } from "../model/RollCopy.js";
13
+ /**
14
+ * The version with the id, where the edition holds one.
15
+ * @category Lookups
16
+ */
13
17
  export declare const versionIn: (edition: Pick<Edition, 'versions'>, id: string) => Readonly<Version> | undefined;
18
+ /**
19
+ * The copy with the id, where the edition holds one.
20
+ * @category Lookups
21
+ */
14
22
  export declare const copyIn: (edition: Pick<Edition, 'copies'>, id: string) => Readonly<RollCopy> | undefined;
15
- /** A symbol any version inserts. */
23
+ /**
24
+ * A symbol any version inserts.
25
+ * @category Lookups
26
+ */
16
27
  export declare const symbolIn: (edition: Pick<Edition, 'versions'>, id: string) => Readonly<AnySymbol> | undefined;
17
- /** The symbols under the ids, leaving out an id that names none. */
28
+ /**
29
+ * The symbols under the ids, leaving out an id that names none.
30
+ * @category Lookups
31
+ */
18
32
  export declare const symbolsIn: (edition: Pick<Edition, 'versions'>, ids: readonly string[]) => Readonly<AnySymbol>[];
19
- /** A feature or a patch on any copy, one a patch bears included. */
33
+ /**
34
+ * A feature or a patch on any copy, one a patch bears included.
35
+ * @category Lookups
36
+ */
20
37
  export declare const featureIn: (edition: Pick<Edition, 'copies'>, id: string) => Readonly<NestedFeature> | undefined;
21
- /** The features and patches under the ids, leaving out an id that names none. */
38
+ /**
39
+ * The features and patches under the ids, leaving out an id that names none.
40
+ * @category Lookups
41
+ */
22
42
  export declare const featuresIn: (edition: Pick<Edition, 'copies'>, ids: readonly string[]) => Readonly<NestedFeature>[];
23
- /** The copy a feature sits on, a patch and everything it bears included. */
43
+ /**
44
+ * The copy a feature sits on, a patch and everything it bears included.
45
+ * @category Lookups
46
+ */
24
47
  export declare const copyOfFeature: (edition: Pick<Edition, 'copies'>, featureId: string) => Readonly<RollCopy> | undefined;
25
48
  /**
26
49
  * The act a copy states a feature in: the production event that
@@ -28,5 +51,6 @@ export declare const copyOfFeature: (edition: Pick<Edition, 'copies'>, featureId
28
51
  * a patch bears came onto the copy with the patch, so the act is
29
52
  * the one that glued the patch on. Two features stand in one act
30
53
  * where this returns the very same object.
54
+ * @category Lookups
31
55
  */
32
56
  export declare const actOf: (edition: Pick<Edition, 'copies'>, featureId: string) => Readonly<ProductionEvent | Modification> | undefined;
@@ -10,17 +10,40 @@ const symbolsById = perState((edition) => byIdIn(edition.versions.flatMap(insert
10
10
  const featuresOnCopies = (edition) => edition.copies.flatMap(copy => featuresOf(copy).flatMap(withBorneFeatures).map(feature => ({ feature, copy })));
11
11
  const featuresById = perState((edition) => new Map(featuresOnCopies(edition).map(({ feature }) => [feature.id, feature])));
12
12
  const copiesByFeature = perState((edition) => new Map(featuresOnCopies(edition).map(({ feature, copy }) => [feature.id, copy])));
13
+ /**
14
+ * The version with the id, where the edition holds one.
15
+ * @category Lookups
16
+ */
13
17
  export const versionIn = (edition, id) => versionsById(edition).get(id);
18
+ /**
19
+ * The copy with the id, where the edition holds one.
20
+ * @category Lookups
21
+ */
14
22
  export const copyIn = (edition, id) => copiesById(edition).get(id);
15
- /** A symbol any version inserts. */
23
+ /**
24
+ * A symbol any version inserts.
25
+ * @category Lookups
26
+ */
16
27
  export const symbolIn = (edition, id) => symbolsById(edition).get(id);
17
- /** The symbols under the ids, leaving out an id that names none. */
28
+ /**
29
+ * The symbols under the ids, leaving out an id that names none.
30
+ * @category Lookups
31
+ */
18
32
  export const symbolsIn = (edition, ids) => ids.flatMap(id => symbolIn(edition, id) ?? []);
19
- /** A feature or a patch on any copy, one a patch bears included. */
33
+ /**
34
+ * A feature or a patch on any copy, one a patch bears included.
35
+ * @category Lookups
36
+ */
20
37
  export const featureIn = (edition, id) => featuresById(edition).get(id);
21
- /** The features and patches under the ids, leaving out an id that names none. */
38
+ /**
39
+ * The features and patches under the ids, leaving out an id that names none.
40
+ * @category Lookups
41
+ */
22
42
  export const featuresIn = (edition, ids) => ids.flatMap(id => featureIn(edition, id) ?? []);
23
- /** The copy a feature sits on, a patch and everything it bears included. */
43
+ /**
44
+ * The copy a feature sits on, a patch and everything it bears included.
45
+ * @category Lookups
46
+ */
24
47
  export const copyOfFeature = (edition, featureId) => copiesByFeature(edition).get(featureId);
25
48
  /**
26
49
  * The act a copy states a feature in: the production event that
@@ -28,6 +51,7 @@ export const copyOfFeature = (edition, featureId) => copiesByFeature(edition).ge
28
51
  * a patch bears came onto the copy with the patch, so the act is
29
52
  * the one that glued the patch on. Two features stand in one act
30
53
  * where this returns the very same object.
54
+ * @category Lookups
31
55
  */
32
56
  export const actOf = (edition, featureId) => {
33
57
  const copy = copyOfFeature(edition, featureId);
@@ -3,11 +3,31 @@
3
3
  * paths an operation can follow into a draft of it.
4
4
  */
5
5
  import { Edition } from "../model/Edition.js";
6
+ /**
7
+ * Where something stands in an edition: the keys and indices that lead
8
+ * to it, as `pathIn` gives them and the operations on beliefs take
9
+ * them.
10
+ * @category Lookups
11
+ */
6
12
  export type Path = (string | number)[];
13
+ /**
14
+ * What stands at the path in an edition or a draft of one, or nothing
15
+ * where the path leads nowhere.
16
+ * @category Lookups
17
+ */
7
18
  export declare const getAt: <T>(path: Path, obj: unknown) => T | undefined;
8
- /** Where the entity with the id stands in the edition, or nothing where it holds none. */
19
+ /**
20
+ * Where the entity with the id stands in the edition, or nothing where it holds none.
21
+ * @category Lookups
22
+ */
9
23
  export declare const pathIn: (edition: Edition, id: string) => Path | undefined;
10
- /** Every id the edition gives an entity of its own, references left out. */
24
+ /**
25
+ * Every id the edition gives an entity of its own, references left out.
26
+ * @category Lookups
27
+ */
11
28
  export declare const idsIn: (edition: Edition) => Iterable<string>;
12
- /** Where the edition references the id. */
29
+ /**
30
+ * Where the edition references the id.
31
+ * @category Lookups
32
+ */
13
33
  export declare const linksTo: (edition: Edition, id: string) => Path[];