linked-rolls 0.49.0 → 0.51.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/constraints.d.ts +4 -3
- package/lib/constraints.js +28 -3
- package/lib/validate.js +4 -1
- package/package.json +4 -3
package/lib/constraints.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EditionView } from "./EditionView.js";
|
|
|
2
2
|
export type ConstraintProblem = {
|
|
3
3
|
version: string;
|
|
4
4
|
symbol: string;
|
|
5
|
-
problem: 'alignment-reference-missing' | 'before-reference-missing' | 'after-reference-missing' | 'placed-relative-to-itself' | 'placed-several-ways' | 'partner-missing' | 'paired-with-itself' | 'in-several-pairs' | 'pair-placed-on-both-sides' | 'type-not-on-the-bar' | 'carrier-on-another-track' | 'copies-disagree-on-the-paper';
|
|
5
|
+
problem: 'alignment-reference-missing' | 'before-reference-missing' | 'after-reference-missing' | 'placed-relative-to-itself' | 'placed-several-ways' | 'partner-missing' | 'paired-with-itself' | 'in-several-pairs' | 'pair-placed-on-both-sides' | 'type-not-on-the-bar' | 'carrier-on-another-track' | 'copies-disagree-on-the-paper' | 'strike-bites-nothing';
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Where the edition cannot hold as stated, version by version: a
|
|
@@ -10,7 +10,8 @@ export type ConstraintProblem = {
|
|
|
10
10
|
* placed relative to itself or in several ways at once, one claimed by
|
|
11
11
|
* several pairs, a pair whose members are both placed and so cannot
|
|
12
12
|
* keep their distance and follow their references at once, an
|
|
13
|
-
* expression the version's own bar cannot read,
|
|
14
|
-
*
|
|
13
|
+
* expression the version's own bar cannot read, a carrier sitting on a
|
|
14
|
+
* track that does not say what its symbol says, and a strike that takes
|
|
15
|
+
* nothing out.
|
|
15
16
|
*/
|
|
16
17
|
export declare const constraintProblems: (view: EditionView) => ConstraintProblem[];
|
package/lib/constraints.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isCommand, pairsAmong, placementsOf } from "./Symbol.js";
|
|
|
3
3
|
import { keyOf } from "./TrackerBar.js";
|
|
4
4
|
import { trackerBarOf } from "./systems/index.js";
|
|
5
5
|
import { barOf } from "./RollCopy.js";
|
|
6
|
+
import { deletedBy, insertedBy } from "./Version.js";
|
|
6
7
|
const missingReference = {
|
|
7
8
|
alignedWith: 'alignment-reference-missing',
|
|
8
9
|
before: 'before-reference-missing',
|
|
@@ -100,14 +101,37 @@ const carriersOffTheirMeaning = (view, version, commands) => {
|
|
|
100
101
|
const paperDisagreed = (view, version) => view.speedScalesIn(version).length > 1
|
|
101
102
|
? [{ version: version.id, symbol: version.id, problem: 'copies-disagree-on-the-paper' }]
|
|
102
103
|
: [];
|
|
104
|
+
/**
|
|
105
|
+
* A version's strikes that take nothing out of its text: each deleted
|
|
106
|
+
* symbol has to be one the parent hands down, or one the version put
|
|
107
|
+
* there itself, or the strike says nothing.
|
|
108
|
+
*
|
|
109
|
+
* It is the check for what happens when a symbol two versions shared is
|
|
110
|
+
* parted in two. The strike still names a symbol that exists, so
|
|
111
|
+
* nothing dangles and nothing looks wrong, but the reading it meant to
|
|
112
|
+
* reject has passed to the symbol standing in its place and comes back
|
|
113
|
+
* into the text unstruck. Nothing else in the edition shows it: the
|
|
114
|
+
* counts move, and only by a handful.
|
|
115
|
+
*/
|
|
116
|
+
const strikesBitingNothing = (view, version) => {
|
|
117
|
+
const parent = view.predecessorOf(version.id);
|
|
118
|
+
const reachable = new Set([
|
|
119
|
+
...(parent ? view.snapshot(parent.id).map(symbol => symbol.id) : []),
|
|
120
|
+
...insertedBy(version).map(symbol => symbol.id)
|
|
121
|
+
]);
|
|
122
|
+
return deletedBy(version)
|
|
123
|
+
.filter(id => !reachable.has(id))
|
|
124
|
+
.map(id => ({ version: version.id, symbol: id, problem: 'strike-bites-nothing' }));
|
|
125
|
+
};
|
|
103
126
|
/**
|
|
104
127
|
* Where the edition cannot hold as stated, version by version: a
|
|
105
128
|
* placement or pairing reference absent from the version, a command
|
|
106
129
|
* placed relative to itself or in several ways at once, one claimed by
|
|
107
130
|
* several pairs, a pair whose members are both placed and so cannot
|
|
108
131
|
* keep their distance and follow their references at once, an
|
|
109
|
-
* expression the version's own bar cannot read,
|
|
110
|
-
*
|
|
132
|
+
* expression the version's own bar cannot read, a carrier sitting on a
|
|
133
|
+
* track that does not say what its symbol says, and a strike that takes
|
|
134
|
+
* nothing out.
|
|
111
135
|
*/
|
|
112
136
|
export const constraintProblems = (view) => view.edition.versions.flatMap(version => {
|
|
113
137
|
const snapshot = view.snapshot(version.id);
|
|
@@ -116,6 +140,7 @@ export const constraintProblems = (view) => view.edition.versions.flatMap(versio
|
|
|
116
140
|
...problemsIn(version.id, commands),
|
|
117
141
|
...typesNotOnTheBar(version, snapshot),
|
|
118
142
|
...carriersOffTheirMeaning(view, version.id, commands),
|
|
119
|
-
...paperDisagreed(view, version)
|
|
143
|
+
...paperDisagreed(view, version),
|
|
144
|
+
...strikesBitingNothing(view, version)
|
|
120
145
|
];
|
|
121
146
|
});
|
package/lib/validate.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import Ajv from "ajv";
|
|
2
|
-
|
|
2
|
+
// A default import, not a namespace one: Node's ESM gives a JSON module
|
|
3
|
+
// only a default export, so `import * as` hands ajv the namespace object
|
|
4
|
+
// and it compiles a schema that constrains nothing.
|
|
5
|
+
import schema from "./schema.json" with { type: 'json' };
|
|
3
6
|
const compileEditionSchema = () => new Ajv({ strict: false, formats: { "date": true } }).compile(schema);
|
|
4
7
|
/**
|
|
5
8
|
* Compiling costs enough that a consumer which never validates should not
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linked-rolls",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.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": {
|
|
@@ -38,10 +38,11 @@
|
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "npm run build:schema && rm -rf lib && tsc",
|
|
41
|
-
"prepublishOnly": "npm run build && vitest run",
|
|
41
|
+
"prepublishOnly": "npm run build && vitest run && npm run smoke",
|
|
42
42
|
"test": "vitest",
|
|
43
43
|
"build:schema": "npx ts-json-schema-generator --additional-properties --validation-keywords see --path 'src/**/*.ts' --type 'Edition' > schema_.json && node schema/postprocess.js && rm schema_.json && mv schema.json src/schema.json",
|
|
44
|
-
"build:docs": "node schema/docs/generate.ts src/schema.json docs/index.html"
|
|
44
|
+
"build:docs": "node schema/docs/generate.ts src/schema.json docs/index.html",
|
|
45
|
+
"smoke": "node scripts/smoke.mjs"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/jsonld": "^1.5.15",
|