linked-rolls 0.29.0 → 0.30.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/RollCopy.d.ts CHANGED
@@ -274,8 +274,10 @@ export interface RollCopy extends WithType<'RollCopy'>, WithId {
274
274
  */
275
275
  conditions: RollConditionAssignment[];
276
276
  /**
277
- * A short siglum to identify the copy, e.g. "W1" or "S2". A copy
278
- * without one is named by its keeper.
277
+ * A short siglum to identify the copy, e.g. "St1" or "Wi1": letters
278
+ * for the collection the copy was read in, and a number counting the
279
+ * copies of the roll held there. A copy without one is named by its
280
+ * keeper.
279
281
  * @see reo:siglum
280
282
  */
281
283
  siglum?: string;
package/lib/Version.d.ts CHANGED
@@ -66,7 +66,11 @@ export interface VersionCreation {
66
66
  */
67
67
  export interface Version extends WithId, WithType<'Version'> {
68
68
  /**
69
- * A short siglum to identify the version, e.g. "A", "B1", "B2_rev", etc.
69
+ * A short siglum to identify the version, e.g. "A" or "B2". A siglum
70
+ * is given once and not changed: its letter names the line the version
71
+ * was first recognised in, its number counts the versions admitted to
72
+ * that line. Where later work places the version elsewhere in the
73
+ * stemma, `basedOn` changes and the siglum stays.
70
74
  * @see reo:siglum
71
75
  */
72
76
  siglum: string;
package/lib/editionOps.js CHANGED
@@ -637,6 +637,19 @@ export const removeVersion = (view, versionId) => {
637
637
  };
638
638
  /** Takes the symbols out of the version's own insertions, and the edits that had nothing else. */
639
639
  export const removeSymbols = (versionId, symbolIds) => onVersion(versionId, version => dropInsertions(version, new Set(symbolIds)));
640
+ /**
641
+ * The siglum for a version derived from this one: the line the siglum
642
+ * names, and the next number free in it. A number already given stays
643
+ * given, whatever the stemma does later.
644
+ */
645
+ const nextInLine = (versions, siglum) => {
646
+ const [line] = siglum.match(/^\D*/) ?? [siglum];
647
+ const numbers = versions.flatMap(other => {
648
+ const match = other.siglum.match(/^(\D*)(\d*)$/);
649
+ return match && match[1] === line ? [Number(match[2] || 1)] : [];
650
+ });
651
+ return `${line}${Math.max(1, ...numbers) + 1}`;
652
+ };
640
653
  /** Moves the edits into a new version based on this one. */
641
654
  export const deriveVersion = (versionId, editIds) => onVersion(versionId, (version, draft) => {
642
655
  const chosen = new Set(editIds);
@@ -646,7 +659,7 @@ export const deriveVersion = (versionId, editIds) => onVersion(versionId, (versi
646
659
  draft.versions.push({
647
660
  type: 'Version',
648
661
  id: v4(),
649
- siglum: `${version.siglum}_derived`,
662
+ siglum: nextInLine(draft.versions, version.siglum),
650
663
  system: stateOf(version).system,
651
664
  basedOn: [assignReference(versionId)],
652
665
  edits: moved,
package/lib/schema.json CHANGED
@@ -2271,7 +2271,7 @@
2271
2271
  "ontology": "crm:P138i has representation"
2272
2272
  },
2273
2273
  "siglum": {
2274
- "description": "A short siglum to identify the copy, e.g. \"W1\" or \"S2\". A copy without one is named by its keeper.",
2274
+ "description": "A short siglum to identify the copy, e.g. \"St1\" or \"Wi1\": letters for the collection the copy was read in, and a number counting the copies of the roll held there. A copy without one is named by its keeper.",
2275
2275
  "type": "string",
2276
2276
  "ontology": "reo:siglum"
2277
2277
  },
@@ -2446,7 +2446,7 @@
2446
2446
  "type": "array"
2447
2447
  },
2448
2448
  "siglum": {
2449
- "description": "A short siglum to identify the version, e.g. \"A\", \"B1\", \"B2_rev\", etc.",
2449
+ "description": "A short siglum to identify the version, e.g. \"A\" or \"B2\". A siglum is given once and not changed: its letter names the line the version was first recognised in, its number counts the versions admitted to that line. Where later work places the version elsewhere in the stemma, `basedOn` changes and the siglum stays.",
2450
2450
  "type": "string",
2451
2451
  "ontology": "reo:siglum"
2452
2452
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.29.0",
3
+ "version": "0.30.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": {