linked-rolls 0.0.1 → 0.1.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 (67) hide show
  1. package/README.md +48 -1
  2. package/lib/Assumption.d.ts +124 -0
  3. package/lib/Assumption.js +34 -0
  4. package/lib/Collation.d.ts +11 -0
  5. package/lib/ConditionState.d.ts +8 -3
  6. package/lib/ConditionState.js +0 -5
  7. package/lib/Edit.d.ts +44 -14
  8. package/lib/Edit.js +2 -95
  9. package/lib/Edition.d.ts +144 -4
  10. package/lib/EditionView.d.ts +51 -0
  11. package/lib/EditionView.js +294 -0
  12. package/lib/Emulation.d.ts +21 -68
  13. package/lib/Emulation.js +94 -386
  14. package/lib/Feature.d.ts +137 -16
  15. package/lib/Feature.js +9 -1
  16. package/lib/Plan.d.ts +190 -0
  17. package/lib/Plan.js +555 -0
  18. package/lib/ReproducingSystem.d.ts +80 -0
  19. package/lib/RollCopy.d.ts +259 -24
  20. package/lib/RollCopy.js +232 -215
  21. package/lib/Symbol.d.ts +70 -37
  22. package/lib/Symbol.js +2 -27
  23. package/lib/TrackCalibration.d.ts +33 -0
  24. package/lib/TrackCalibration.js +14 -0
  25. package/lib/TrackerBar.d.ts +52 -5
  26. package/lib/TrackerBar.js +70 -49
  27. package/lib/Version.d.ts +32 -33
  28. package/lib/Version.js +3 -209
  29. package/lib/alignFeatures.d.ts +3 -2
  30. package/lib/alignFeatures.js +5 -4
  31. package/lib/asJsonLd.d.ts +1 -1
  32. package/lib/asJsonLd.js +13 -26
  33. package/lib/importJsonLd.d.ts +0 -1
  34. package/lib/importJsonLd.js +9 -72
  35. package/lib/index.d.ts +7 -3
  36. package/lib/index.js +7 -3
  37. package/lib/schema.json +1739 -0
  38. package/lib/spec/context.json +125 -144
  39. package/lib/systems/welteT100.d.ts +55 -0
  40. package/lib/systems/welteT100.js +191 -0
  41. package/lib/utils.d.ts +29 -0
  42. package/lib/validate.d.ts +3 -0
  43. package/lib/validate.js +10 -0
  44. package/package.json +41 -8
  45. package/lib/Condition.d.ts +0 -10
  46. package/lib/EditorialAssumption.d.ts +0 -67
  47. package/lib/EditorialAssumption.js +0 -26
  48. package/lib/Measurement.d.ts +0 -9
  49. package/lib/PlaceTimeConversion.d.ts +0 -65
  50. package/lib/PlaceTimeConversion.js +0 -175
  51. package/lib/RollEvent.d.ts +0 -76
  52. package/lib/RollEvent.js +0 -3
  53. package/lib/Stage.d.ts +0 -37
  54. package/lib/Stage.js +0 -165
  55. package/lib/Transcription.d.ts +0 -7
  56. package/lib/Transcription.js +0 -9
  57. package/lib/WithId.d.ts +0 -3
  58. package/lib/WithId.js +0 -1
  59. package/lib/alignRolls.d.ts +0 -7
  60. package/lib/alignRolls.js +0 -49
  61. package/lib/alignSymbols.d.ts +0 -7
  62. package/lib/alignSymbols.js +0 -49
  63. package/lib/aton/AtonParser.test.d.ts +0 -1
  64. package/lib/aton/AtonParser.test.js +0 -16
  65. package/lib/build-schema.cjs +0 -113
  66. /package/lib/{Condition.js → ReproducingSystem.js} +0 -0
  67. /package/lib/{Measurement.js → utils.js} +0 -0
package/lib/RollCopy.d.ts CHANGED
@@ -1,62 +1,241 @@
1
1
  import { ConditionState } from "./ConditionState";
2
2
  import { AnySymbol } from "./Symbol";
3
- import { EditorialAssumption } from "./EditorialAssumption";
4
- import { PlaceTimeConversion } from "./PlaceTimeConversion";
5
- import { RollFeature } from "./Feature";
3
+ import { TrackerBar } from "./TrackerBar";
4
+ import { TrackCalibration } from "./TrackCalibration";
5
+ import { AnyFeature } from "./Feature";
6
+ import { ObjectAssumption, ValueAssumption } from "./Assumption";
7
+ import { WithId, WithType } from "./utils";
8
+ import { ActorAssignment } from "./Edit";
6
9
  /**
7
- * This condition state is used to describe to roll's
10
+ * This condition state is used to describe the roll's
8
11
  * paper shrinkage or stretching. It might be calculated
9
12
  * on the basis of comparing the vertical or horizontal
10
13
  * extent with other witnesses of the same roll.
11
14
  */
12
15
  export interface PaperStretch extends ConditionState<'paper-stretch'> {
16
+ /**
17
+ * The stretch factor, e.g. 1.02 means the paper has
18
+ * stretched by 2% compared to its original dimensions.
19
+ */
13
20
  factor: number;
14
21
  }
22
+ /**
23
+ * A general condition description for a roll copy, e.g.
24
+ * overall wear, discoloration, or other observations.
25
+ * @see crm:E3 Condition State
26
+ */
15
27
  export interface GeneralRollCondition extends ConditionState<'general'> {
16
28
  }
17
- export type RollConditionAssignment = EditorialAssumption<'conditionAssignment', GeneralRollCondition | PaperStretch>;
29
+ /**
30
+ * An assignment of a condition (general or paper-stretch)
31
+ * to a roll copy, annotatable with a belief about its certainty.
32
+ */
33
+ export type RollConditionAssignment = ObjectAssumption<GeneralRollCondition | PaperStretch>;
34
+ export declare const rollConditions: readonly ["general", "paper-stretch"];
35
+ /**
36
+ * A shift correction applied to a roll copy to align it
37
+ * with other copies. The shift is defined as horizontal
38
+ * (along the roll length, in mm) and vertical (across tracks).
39
+ */
18
40
  export interface Shift {
41
+ /**
42
+ * Horizontal shift in millimeters (along the roll length).
43
+ */
19
44
  horizontal: number;
45
+ /**
46
+ * Vertical shift in track numbers (across the tracker bar).
47
+ */
20
48
  vertical: number;
21
49
  }
22
- export type DateAssignment = EditorialAssumption<'dateAssignment', Date>;
50
+ export declare const applyShift: (shift: Shift, copy: RollCopy) => void;
51
+ export declare const applyStretch: (paperStretch: ObjectAssumption<PaperStretch>, copy: RollCopy) => void;
52
+ /**
53
+ * A date value wrapped as an assumption, so that the date
54
+ * can be annotated with a belief about its certainty and source.
55
+ */
56
+ export type DateAssignment = ValueAssumption<Date>;
57
+ /**
58
+ * Describes the production of a roll copy, including the
59
+ * manufacturing company, the roll system, and the paper used.
60
+ * @see lrm:F33 Reproduction Event
61
+ */
23
62
  export interface ProductionEvent {
63
+ /**
64
+ * The company that produced the roll copy
65
+ * (e.g. "M. Welte & Söhne").
66
+ * @see crm:P14 carried out by
67
+ */
24
68
  company: string;
69
+ /**
70
+ * The roll system used for production
71
+ * (e.g. "Welte-Mignon T100", "Welte-Mignon T98").
72
+ */
25
73
  system: string;
74
+ /**
75
+ * The paper type used for the roll copy.
76
+ * @see P126:employed
77
+ */
26
78
  paper: string;
27
- date: DateAssignment;
79
+ /**
80
+ * The date of production, if known.
81
+ * @see crm:P4 has time-span
82
+ */
83
+ date?: DateAssignment;
28
84
  }
29
- export declare class RollCopy {
30
- type: 'RollCopy';
31
- id: string;
85
+ /**
86
+ * This type denotes identifiable activities that modified
87
+ * the roll copy after its production, e.g. annotations, repairs,
88
+ * etc.
89
+ * @see crm:E79 Part Addition, crm:E80 Part Removal
90
+ */
91
+ export type Modification = Partial<{
92
+ actor: ActorAssignment;
93
+ date: DateAssignment;
94
+ }> & ({
95
+ type: 'Addition';
96
+ /**
97
+ * @see crm:P111 added
98
+ */
99
+ added: string[];
100
+ /**
101
+ * @see crm:P21 had general purpose
102
+ */
103
+ purpose: 'musical-improvement' | 'technical-improvement' | 'repair' | 'labeling' | 'control' | 'dating' | 'glossing';
104
+ } | {
105
+ type: 'Removal';
106
+ /**
107
+ * @see crm:P113 removed
108
+ */
109
+ removed: string[];
110
+ /**
111
+ * Usually, roll features are being added.
112
+ * Sometimes however, we may see traces of features
113
+ * that have been removed, e.g. through bright spots on
114
+ * the roll.
115
+ */
116
+ purpose: 'delabeling';
117
+ });
118
+ /**
119
+ * A physical copy of a roll, held at a specific location.
120
+ * Each roll copy has its own set of features, measurements,
121
+ * conditions, and modifications. Multiple copies of the same
122
+ * roll may exist across different archives or collections.
123
+ * @see crm:E22 Human-Made Object
124
+ */
125
+ export interface RollCopy extends WithType<'RollCopy'>, WithId {
126
+ /**
127
+ * A list of operations that have been applied to this copy's features
128
+ * (e.g. 'shifted', 'stretched') to normalize measurements
129
+ * for comparison with other copies.
130
+ */
131
+ ops: Array<'shifted' | 'stretched'>;
132
+ /**
133
+ * Physical measurements of this roll copy, including
134
+ * dimensions, punch diameter, hole separation, margins,
135
+ * shift corrections, and information about the measuring software.
136
+ */
32
137
  measurements: Partial<{
138
+ /**
139
+ * The physical dimensions of the roll.
140
+ */
33
141
  dimensions: {
142
+ /**
143
+ * The width of the roll in the given unit.
144
+ */
34
145
  width: number;
146
+ /**
147
+ * The total height (length) of the roll in the given unit.
148
+ */
35
149
  height: number;
150
+ /**
151
+ * The unit of measurement (e.g. 'mm').
152
+ */
36
153
  unit: string;
37
154
  };
155
+ /**
156
+ * The average diameter of punched holes.
157
+ */
38
158
  punchDiameter: {
159
+ /**
160
+ * The measured punch diameter value.
161
+ */
39
162
  value: number;
163
+ /**
164
+ * The unit of measurement (e.g. 'mm').
165
+ */
40
166
  unit: string;
41
167
  };
168
+ /**
169
+ * The distance between adjacent tracker bar holes.
170
+ */
42
171
  holeSeparation: {
172
+ /**
173
+ * The measured hole separation value.
174
+ */
43
175
  value: number;
176
+ /**
177
+ * The unit of measurement (e.g. 'px', 'mm').
178
+ */
44
179
  unit: string;
45
180
  };
181
+ /**
182
+ * The margins on the treble and bass sides of the roll.
183
+ */
46
184
  margins: {
185
+ /**
186
+ * The margin on the treble side.
187
+ */
47
188
  treble: number;
189
+ /**
190
+ * The margin on the bass side.
191
+ */
48
192
  bass: number;
193
+ /**
194
+ * The unit of measurement (e.g. 'px', 'mm').
195
+ */
49
196
  unit: string;
50
197
  };
51
198
  shift: Shift;
199
+ /**
200
+ * Relates this copy's scan to the tracker bar: how the scanning
201
+ * software's hole numbering was shifted onto the bar, and where
202
+ * the track grid sits in the image.
203
+ */
204
+ trackCalibration: TrackCalibration;
205
+ /**
206
+ * Information about the software used to take the measurements.
207
+ */
52
208
  measuredBy: {
209
+ /**
210
+ * The name of the measurement software.
211
+ */
53
212
  software: string;
213
+ /**
214
+ * The version of the measurement software.
215
+ */
54
216
  version: string;
217
+ /**
218
+ * The date on which the measurements were taken.
219
+ * @format date
220
+ */
55
221
  date: Date;
56
222
  };
57
223
  }>;
58
- productionEvent?: ProductionEvent;
224
+ /**
225
+ * The production event that created this roll copy.
226
+ * @see lrm:R28i was produced by
227
+ */
228
+ production?: ProductionEvent;
229
+ /**
230
+ * Condition assessments of this roll copy (e.g. paper stretch,
231
+ * general wear). Each condition is an assumption annotatable
232
+ * with a belief.
233
+ */
59
234
  conditions: RollConditionAssignment[];
235
+ /**
236
+ * The current physical location or archive where this copy is held.
237
+ * @see crm:P55 has current location
238
+ */
60
239
  location: string;
61
240
  /**
62
241
  * Provides a reconstructed version of the roll,
@@ -64,22 +243,78 @@ export declare class RollCopy {
64
243
  * taken into account. This property will not be
65
244
  * exported in the final JSON.
66
245
  */
67
- features: RollFeature[];
246
+ features: AnyFeature[];
247
+ /**
248
+ * @see crm:P31 was modified by
249
+ */
250
+ modifications: Modification[];
251
+ /**
252
+ * The scan URL or IIIF URL of the roll.
253
+ * @see crm:P138i has representation
254
+ */
68
255
  scan?: string;
69
- insertFeature(feature: RollFeature): void;
70
- setShift(shift: Shift): void;
71
- setStretch(stretch: EditorialAssumption<'conditionAssignment', PaperStretch>): void;
72
- shallowClone(): RollCopy;
73
256
  }
74
- export declare function asSymbols(features: RollFeature[]): AnySymbol[];
75
- export declare function readFromStanfordAton(atonString: string, adjustByRewind?: boolean, shift?: number): RollCopy;
76
257
  /**
77
- * Spencer Chase's rolls seem to be scanned at a roll speed of
78
- * 83 (=8.3 feet per minute).
258
+ * Reads the features of a copy as the tracker bar would read them.
259
+ * Holes on a position the bar does not read carry no symbol and are
260
+ * dropped, which is what happens physically as well.
261
+ */
262
+ export declare function asSymbols(features: AnyFeature[], bar?: TrackerBar): AnySymbol[];
263
+ /**
264
+ * The tracks a copy carries holes on that the tracker bar does not read.
265
+ * A non-empty result usually means the scan is calibrated wrongly.
266
+ */
267
+ export declare function unreadTracks(features: AnyFeature[], bar?: TrackerBar): Map<number, number>;
268
+ /**
269
+ * Falls back to the way the scan geometry was reconstructed before the
270
+ * calibration was recorded: the bass hard margin stood in for the phase
271
+ * of the tracker grid, with a constant making up most of the difference.
79
272
  *
80
- * @param midiBuffer
81
- * @param conversion
273
+ * The constant of one and a half tracks is the one the facsimile tiles
274
+ * were laid out with, and on the rolls measured so far it comes within
275
+ * about a quarter of a track. It is kept for copies imported before the
276
+ * calibration was written down; anything read since carries its own.
277
+ */
278
+ export declare const calibrationOf: (copy: RollCopy) => TrackCalibration | undefined;
279
+ export interface StanfordAtonOptions {
280
+ /**
281
+ * Added to the scanning software's hole numbering to reach the
282
+ * tracker bar. Left out, it is inferred by putting the rewind
283
+ * perforation on the bar's rewind track.
284
+ */
285
+ trackShift?: number;
286
+ bar?: TrackerBar;
287
+ }
288
+ export declare function readFromStanfordAton(atonString: string, { trackShift, bar }?: StanfordAtonOptions): RollCopy;
289
+ /**
290
+ * How a MIDI key number in one of Spencer Chase's roll files names a
291
+ * tracker bar track.
292
+ *
293
+ * The note block follows the obvious rule, `pitch - 13`, which puts
294
+ * track 11 on MIDI 24 as the T100 compass requires. The bass expression
295
+ * block does not: it reads two tracks high, and subtracting two is what
296
+ * has made these files come out right so far.
297
+ *
298
+ * The boundary between the two rules is unresolved. Taken literally the
299
+ * rules leave tracks 8 and 9 unreachable and jump from track 7 to track 10,
300
+ * which no lateral offset can produce, so at least one of them is
301
+ * approximate. Settling it needs a Spencer file whose expression holes
302
+ * can be checked against the roll, hence the option to override.
303
+ */
304
+ export declare const spencerTrackOf: (pitch: number) => number;
305
+ /**
306
+ * Spencer Chase's rolls seem to be scanned at a roll speed of
307
+ * 83 (=8.3 feet per minute). A scanner feeds the paper at one
308
+ * speed, so time in his files is proportional to place.
309
+ */
310
+ export declare const SPENCER_FEET_PER_MINUTE = 8.3;
311
+ /** Place on the roll in mm after `seconds` at a constant `feetPerMinute`. */
312
+ export declare const atConstantSpeed: (feetPerMinute: number) => (seconds: number) => number;
313
+ export declare function readFromSpencerMIDI(midiBuffer: ArrayBuffer, placeAt?: (seconds: number) => number, trackOf?: (pitch: number) => number): RollCopy;
314
+ /**
315
+ * Moves features across the tracker bar. What the new position means is
316
+ * left to the tracker bar to say, since meaning belongs to the symbols
317
+ * read off a copy rather than to the holes themselves.
82
318
  */
83
- export declare function readFromSpencerMIDI(midiBuffer: ArrayBuffer, conversion?: PlaceTimeConversion): RollCopy;
84
- export declare function shiftVertically(features: RollFeature[], amount: number): void;
319
+ export declare function shiftVertically(features: AnyFeature[], amount: number): void;
85
320
  export declare const findCopiesCarrying: (sources: RollCopy[], symbol: AnySymbol) => Set<string>;