linked-rolls 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Feature.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ObjectAssumption } from "./Assumption";
2
2
  import { ConditionState } from "./ConditionState";
3
3
  import { Text } from "./Symbol";
4
4
  import { PartialBy, WithId, WithType } from "./utils";
5
- import { Millimeters, Track } from "./Quantity";
5
+ import { Measure, Millimeters, Track } from "./Quantity";
6
6
  /**
7
7
  * Describes the horizontal extent of a feature on the roll,
8
8
  * measured in millimeters from the beginning of the roll.
@@ -119,11 +119,23 @@ export interface Hole extends RollFeature<'Hole', typeof conditions.Hole[number]
119
119
  */
120
120
  pattern?: 'regular' | 'accelerating' | 'staggering';
121
121
  }
122
+ /**
123
+ * Something that lies on a face of the paper rather than through it. A
124
+ * hole is not one: it goes through, and is on both faces at once.
125
+ */
126
+ export interface OnAFace {
127
+ /**
128
+ * The face of the roll it lies on: the side that faces the reader
129
+ * as the roll plays, or the back of it.
130
+ * @see reo:side
131
+ */
132
+ side?: 'recto' | 'verso';
133
+ }
122
134
  /**
123
135
  * A trace is a visible mark or writing on the roll surface.
124
136
  * Traces may fade over time.
125
137
  */
126
- export interface Trace<T extends FeatureType> extends RollFeature<T, typeof conditions[T][number]> {
138
+ export interface Trace<T extends FeatureType> extends RollFeature<T, typeof conditions[T][number]>, OnAFace {
127
139
  }
128
140
  export declare const writingMethods: readonly ['print', 'handwriting', 'stamp'];
129
141
  /**
@@ -156,6 +168,13 @@ export interface Writing extends Trace<'Writing'> {
156
168
  * @see crm:P128 carries
157
169
  */
158
170
  transcription: ObjectAssumption<Transcription>;
171
+ /**
172
+ * How far the writing stands askew, clockwise from the line across
173
+ * the roll. A stamp pressed crooked and a label written along the
174
+ * roll rather than across it are both stated here.
175
+ * @see reo:rotation
176
+ */
177
+ rotation?: Measure<'deg'>;
159
178
  }
160
179
  /**
161
180
  * A visible mark on the roll, such as a pencil circle, an ink stroke,
@@ -178,12 +197,18 @@ export interface Mark extends Trace<'Mark'> {
178
197
  * such as writings or additional holes.
179
198
  * @see reo:GluedOn
180
199
  */
181
- export interface GluedOn extends RollFeature<'GluedOn', typeof conditions.GluedOn[number]> {
200
+ export interface GluedOn extends RollFeature<'GluedOn', typeof conditions.GluedOn[number]>, OnAFace {
182
201
  /**
183
202
  * The material of the glued-on feature.
184
203
  * @see crm:P45 consists of
185
204
  */
186
205
  material: 'paper' | 'tape';
206
+ /**
207
+ * How far the patch was stuck on askew, clockwise from the line
208
+ * across the roll.
209
+ * @see reo:rotation
210
+ */
211
+ rotation?: Measure<'deg'>;
187
212
  /**
188
213
  * A glued-on feature itself may carry other features.
189
214
  * Nested features do not need to be positioned explicitly.
package/lib/Quantity.d.ts CHANGED
@@ -11,7 +11,7 @@ declare const unit: unique symbol;
11
11
  * The units a record may state. A `Measure` is limited to these, since
12
12
  * they are what the `unit` field is allowed to say.
13
13
  */
14
- export type Unit = 'mm' | 'cm' | 'px' | 'track' | 's' | 'ms' | 'ft/min' | 'm/min' | 'px/in';
14
+ export type Unit = 'mm' | 'cm' | 'px' | 'track' | 's' | 'ms' | 'ft/min' | 'm/min' | 'px/in' | 'deg';
15
15
  export type Quantity<U extends string> = number & {
16
16
  readonly [unit]: U;
17
17
  };
@@ -28,6 +28,8 @@ export type FeetPerMinute = Quantity<'ft/min'>;
28
28
  export type MetersPerMinute = Quantity<'m/min'>;
29
29
  /** How finely a scan was read: pixels of the image per inch of paper. */
30
30
  export type Resolution = Quantity<'px/in'>;
31
+ /** An angle, clockwise from the line across the roll. */
32
+ export type Degrees = Quantity<'deg'>;
31
33
  /** Names a number in a unit. Partially apply it to make a constructor. */
32
34
  export declare const quantity: <U extends string>(value: number) => Quantity<U>;
33
35
  export declare const mm: (value: number) => Quantity<"mm">;
@@ -39,6 +41,7 @@ export declare const milliseconds: (value: number) => Quantity<"ms">;
39
41
  export declare const feetPerMinute: (value: number) => Quantity<"ft/min">;
40
42
  export declare const metersPerMinute: (value: number) => Quantity<"m/min">;
41
43
  export declare const pixelsPerInch: (value: number) => Quantity<"px/in">;
44
+ export declare const degrees: (value: number) => Quantity<"deg">;
42
45
  /**
43
46
  * A value together with the unit it was measured in, as a record
44
47
  * states it.
package/lib/Quantity.js CHANGED
@@ -9,6 +9,7 @@ export const milliseconds = quantity;
9
9
  export const feetPerMinute = quantity;
10
10
  export const metersPerMinute = quantity;
11
11
  export const pixelsPerInch = quantity;
12
+ export const degrees = quantity;
12
13
  // The second operand takes its unit from the first. Inferred from both,
13
14
  // TypeScript would unite two units rather than reject them.
14
15
  export const add = (a, b) => quantity(a + b);
@@ -123,6 +123,14 @@ export type MergeObstacle = 'fewer-than-two' | 'different-types' | 'different-tr
123
123
  * perforations of their own is the editor's reading.
124
124
  */
125
125
  export declare const mergeObstacle: (features: readonly FeatureOrPatch[]) => MergeObstacle | undefined;
126
+ /**
127
+ * What stands in the way of reading the features the ids name as one,
128
+ * as `mergeFeatures` will find it. `mergeObstacle` asks only what the
129
+ * features themselves say, which cannot reach `different-acts`: one
130
+ * feature is the work of one act, and where the features stand is the
131
+ * edition's business rather than theirs.
132
+ */
133
+ export declare const mergeObstacleIn: (view: EditionView, featureIds: readonly string[]) => MergeObstacle | undefined;
126
134
  /**
127
135
  * Replaces the features of the copy with a single one covering them
128
136
  * all, where a scan has split what the editor reads as one feature.
package/lib/editionOps.js CHANGED
@@ -511,6 +511,32 @@ export const mergeObstacle = (features) => {
511
511
  return 'differing-conditions';
512
512
  return undefined;
513
513
  };
514
+ /** The acts of the copy that state any of the named features. */
515
+ const actsHolding = (copy, named) => featuresByAct(copy).filter(features => features.some(feature => named.has(feature.id)));
516
+ /**
517
+ * What stands in the way of reading the named features of the copy as
518
+ * one, which is the whole of what `mergeFeatures` asks: whether one act
519
+ * brought them all about, and what the features themselves say. An id
520
+ * the copy does not bear at a place of its own is passed over.
521
+ */
522
+ const obstacleIn = (copy, featureIds) => {
523
+ const named = new Set(featureIds);
524
+ const acts = actsHolding(copy, named);
525
+ return acts.length > 1
526
+ ? 'different-acts'
527
+ : mergeObstacle((acts[0] ?? []).filter(feature => named.has(feature.id)));
528
+ };
529
+ /**
530
+ * What stands in the way of reading the features the ids name as one,
531
+ * as `mergeFeatures` will find it. `mergeObstacle` asks only what the
532
+ * features themselves say, which cannot reach `different-acts`: one
533
+ * feature is the work of one act, and where the features stand is the
534
+ * edition's business rather than theirs.
535
+ */
536
+ export const mergeObstacleIn = (view, featureIds) => {
537
+ const copy = featureIds.map(id => view.copyOf(id)).find(copy => copy !== undefined);
538
+ return copy ? obstacleIn(copy, featureIds) : 'fewer-than-two';
539
+ };
514
540
  /** The items with the replacement in the place of the first it stands for, the others dropped. */
515
541
  const standingFor = (items, stands, replacement) => {
516
542
  const first = items.findIndex(stands);
@@ -576,14 +602,13 @@ const carryOver = (draft, replaced, mergedId) => {
576
602
  * says beforehand whether they can.
577
603
  */
578
604
  export const mergeFeatures = (copyId, featureIds) => onCopy(copyId, (copy, draft) => {
579
- const named = new Set(featureIds);
580
- const holds = (features) => features.some(feature => named.has(feature.id));
581
- const acts = featuresByAct(stateOf(copy)).filter(holds);
582
- const toMerge = (acts[0] ?? []).filter(feature => named.has(feature.id));
583
- const obstacle = acts.length > 1 ? 'different-acts' : mergeObstacle(toMerge);
605
+ const state = stateOf(copy);
606
+ const obstacle = obstacleIn(state, featureIds);
584
607
  if (obstacle) {
585
608
  throw new Error(`The features of copy ${copyId} cannot be merged: ${obstacle}`);
586
609
  }
610
+ const named = new Set(featureIds);
611
+ const toMerge = (actsHolding(state, named)[0] ?? []).filter(feature => named.has(feature.id));
587
612
  const replaced = new Set(toMerge.map(feature => feature.id));
588
613
  const mergedId = v4();
589
614
  rewriteFeatures(copy, (stated) => {
package/lib/schema.json CHANGED
@@ -780,6 +780,20 @@
780
780
  "type": "string",
781
781
  "ontology": "crm:P45 consists of"
782
782
  },
783
+ "rotation": {
784
+ "$ref": "#/definitions/Measure%3C%22deg%22%3E",
785
+ "description": "How far the patch was stuck on askew, clockwise from the line across the roll.",
786
+ "ontology": "reo:rotation"
787
+ },
788
+ "side": {
789
+ "description": "The face of the roll it lies on: the side that faces the reader as the roll plays, or the back of it.",
790
+ "enum": [
791
+ "recto",
792
+ "verso"
793
+ ],
794
+ "type": "string",
795
+ "ontology": "reo:side"
796
+ },
783
797
  "vertical": {
784
798
  "$ref": "#/definitions/VerticalSpan",
785
799
  "description": "Vertical span of the feature on the roll.",
@@ -1015,6 +1029,15 @@
1015
1029
  "description": "The medium the mark was drawn in, where it can be told.",
1016
1030
  "ontology": "reo:method"
1017
1031
  },
1032
+ "side": {
1033
+ "description": "The face of the roll it lies on: the side that faces the reader as the roll plays, or the back of it.",
1034
+ "enum": [
1035
+ "recto",
1036
+ "verso"
1037
+ ],
1038
+ "type": "string",
1039
+ "ontology": "reo:side"
1040
+ },
1018
1041
  "vertical": {
1019
1042
  "$ref": "#/definitions/VerticalSpan",
1020
1043
  "description": "Vertical span of the feature on the roll.",
@@ -1084,6 +1107,28 @@
1084
1107
  "type": "object",
1085
1108
  "ontology": "crminf:I16 Meaning Comprehension"
1086
1109
  },
1110
+ "Measure<\"deg\">": {
1111
+ "description": "A value together with the unit it was measured in, as a record states it.",
1112
+ "properties": {
1113
+ "unit": {
1114
+ "const": "deg",
1115
+ "description": "The unit of measurement.",
1116
+ "type": "string",
1117
+ "ontology": "crm:P91 has unit"
1118
+ },
1119
+ "value": {
1120
+ "$ref": "#/definitions/Quantity%3C%22deg%22%3E",
1121
+ "description": "The measured value.",
1122
+ "ontology": "crm:P90 has value"
1123
+ }
1124
+ },
1125
+ "required": [
1126
+ "value",
1127
+ "unit"
1128
+ ],
1129
+ "type": "object",
1130
+ "ontology": "crm:E54 Dimension"
1131
+ },
1087
1132
  "Measure<\"mm\">": {
1088
1133
  "description": "A value together with the unit it was measured in, as a record states it.",
1089
1134
  "properties": {
@@ -1411,6 +1456,20 @@
1411
1456
  "description": "The method by which this writing was produced (e.g. through print, handwriting, or stamping).",
1412
1457
  "ontology": "reo:method"
1413
1458
  },
1459
+ "rotation": {
1460
+ "$ref": "#/definitions/Measure%3C%22deg%22%3E",
1461
+ "description": "How far the writing stands askew, clockwise from the line across the roll. A stamp pressed crooked and a label written along the roll rather than across it are both stated here.",
1462
+ "ontology": "reo:rotation"
1463
+ },
1464
+ "side": {
1465
+ "description": "The face of the roll it lies on: the side that faces the reader as the roll plays, or the back of it.",
1466
+ "enum": [
1467
+ "recto",
1468
+ "verso"
1469
+ ],
1470
+ "type": "string",
1471
+ "ontology": "reo:side"
1472
+ },
1414
1473
  "transcription": {
1415
1474
  "$ref": "#/definitions/ObjectAssumption%3CTranscription%3E",
1416
1475
  "description": "A transcription of the text content of the writing. This is an object assumption so that the transcription can be annotated with a belief about its correctness.",
@@ -1462,6 +1521,15 @@
1462
1521
  "description": "The medium the mark was drawn in, where it can be told.",
1463
1522
  "ontology": "reo:method"
1464
1523
  },
1524
+ "side": {
1525
+ "description": "The face of the roll it lies on: the side that faces the reader as the roll plays, or the back of it.",
1526
+ "enum": [
1527
+ "recto",
1528
+ "verso"
1529
+ ],
1530
+ "type": "string",
1531
+ "ontology": "reo:side"
1532
+ },
1465
1533
  "vertical": {
1466
1534
  "$ref": "#/definitions/VerticalSpan",
1467
1535
  "description": "Vertical span of the feature on the roll. Left out by a feature a patch bears.",
@@ -1518,6 +1586,20 @@
1518
1586
  "type": "string",
1519
1587
  "ontology": "crm:P45 consists of"
1520
1588
  },
1589
+ "rotation": {
1590
+ "$ref": "#/definitions/Measure%3C%22deg%22%3E",
1591
+ "description": "How far the patch was stuck on askew, clockwise from the line across the roll.",
1592
+ "ontology": "reo:rotation"
1593
+ },
1594
+ "side": {
1595
+ "description": "The face of the roll it lies on: the side that faces the reader as the roll plays, or the back of it.",
1596
+ "enum": [
1597
+ "recto",
1598
+ "verso"
1599
+ ],
1600
+ "type": "string",
1601
+ "ontology": "reo:side"
1602
+ },
1521
1603
  "vertical": {
1522
1604
  "$ref": "#/definitions/VerticalSpan",
1523
1605
  "description": "Vertical span of the feature on the roll. Left out by a feature a patch bears.",
@@ -2406,6 +2488,9 @@
2406
2488
  "type": "object",
2407
2489
  "ontology": "lrmoo:F32 Item Production Event"
2408
2490
  },
2491
+ "Quantity<\"deg\">": {
2492
+ "type": "number"
2493
+ },
2409
2494
  "Quantity<\"ft/min\">": {
2410
2495
  "type": "number"
2411
2496
  },
@@ -3005,6 +3090,20 @@
3005
3090
  "description": "The method by which this writing was produced (e.g. through print, handwriting, or stamping).",
3006
3091
  "ontology": "reo:method"
3007
3092
  },
3093
+ "rotation": {
3094
+ "$ref": "#/definitions/Measure%3C%22deg%22%3E",
3095
+ "description": "How far the writing stands askew, clockwise from the line across the roll. A stamp pressed crooked and a label written along the roll rather than across it are both stated here.",
3096
+ "ontology": "reo:rotation"
3097
+ },
3098
+ "side": {
3099
+ "description": "The face of the roll it lies on: the side that faces the reader as the roll plays, or the back of it.",
3100
+ "enum": [
3101
+ "recto",
3102
+ "verso"
3103
+ ],
3104
+ "type": "string",
3105
+ "ontology": "reo:side"
3106
+ },
3008
3107
  "transcription": {
3009
3108
  "$ref": "#/definitions/ObjectAssumption%3CTranscription%3E",
3010
3109
  "description": "A transcription of the text content of the writing. This is an object assumption so that the transcription can be annotated with a belief about its correctness.",
@@ -247,6 +247,15 @@
247
247
  "@context": { "@vocab": "https://w3id.org/reo/type/" }
248
248
  },
249
249
  "transcription": "crm:P128_carries",
250
+ "side": {
251
+ "@id": "reo:side",
252
+ "@type": "@vocab",
253
+ "@context": { "@vocab": "https://w3id.org/reo/type/" }
254
+ },
255
+ "rotation": {
256
+ "@id": "reo:rotation",
257
+ "@context": { "value": "crm:P90_has_value" }
258
+ },
250
259
  "material": {
251
260
  "@id": "crm:P45_consists_of",
252
261
  "@type": "@vocab",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.38.0",
3
+ "version": "0.39.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": {