linked-rolls 0.0.1 → 0.1.1
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/README.md +48 -1
- package/lib/Assumption.d.ts +124 -0
- package/lib/Assumption.js +34 -0
- package/lib/Collation.d.ts +11 -0
- package/lib/ConditionState.d.ts +8 -3
- package/lib/ConditionState.js +0 -5
- package/lib/Edit.d.ts +44 -14
- package/lib/Edit.js +2 -95
- package/lib/Edition.d.ts +144 -4
- package/lib/EditionView.d.ts +51 -0
- package/lib/EditionView.js +294 -0
- package/lib/Emulation.d.ts +21 -68
- package/lib/Emulation.js +94 -386
- package/lib/Feature.d.ts +137 -16
- package/lib/Feature.js +9 -1
- package/lib/Plan.d.ts +190 -0
- package/lib/Plan.js +555 -0
- package/lib/ReproducingSystem.d.ts +80 -0
- package/lib/RollCopy.d.ts +265 -24
- package/lib/RollCopy.js +276 -215
- package/lib/Symbol.d.ts +70 -37
- package/lib/Symbol.js +2 -27
- package/lib/TrackCalibration.d.ts +33 -0
- package/lib/TrackCalibration.js +14 -0
- package/lib/TrackerBar.d.ts +52 -5
- package/lib/TrackerBar.js +70 -49
- package/lib/Version.d.ts +32 -33
- package/lib/Version.js +3 -209
- package/lib/alignFeatures.d.ts +3 -2
- package/lib/alignFeatures.js +5 -4
- package/lib/asJsonLd.d.ts +1 -1
- package/lib/asJsonLd.js +13 -26
- package/lib/importJsonLd.d.ts +0 -1
- package/lib/importJsonLd.js +9 -72
- package/lib/index.d.ts +7 -3
- package/lib/index.js +7 -3
- package/lib/schema.json +1739 -0
- package/lib/spec/context.json +125 -144
- package/lib/systems/welteT100.d.ts +55 -0
- package/lib/systems/welteT100.js +191 -0
- package/lib/utils.d.ts +29 -0
- package/lib/validate.d.ts +3 -0
- package/lib/validate.js +10 -0
- package/package.json +41 -8
- package/lib/Condition.d.ts +0 -10
- package/lib/EditorialAssumption.d.ts +0 -67
- package/lib/EditorialAssumption.js +0 -26
- package/lib/Measurement.d.ts +0 -9
- package/lib/PlaceTimeConversion.d.ts +0 -65
- package/lib/PlaceTimeConversion.js +0 -175
- package/lib/RollEvent.d.ts +0 -76
- package/lib/RollEvent.js +0 -3
- package/lib/Stage.d.ts +0 -37
- package/lib/Stage.js +0 -165
- package/lib/Transcription.d.ts +0 -7
- package/lib/Transcription.js +0 -9
- package/lib/WithId.d.ts +0 -3
- package/lib/WithId.js +0 -1
- package/lib/alignRolls.d.ts +0 -7
- package/lib/alignRolls.js +0 -49
- package/lib/alignSymbols.d.ts +0 -7
- package/lib/alignSymbols.js +0 -49
- package/lib/aton/AtonParser.test.d.ts +0 -1
- package/lib/aton/AtonParser.test.js +0 -16
- package/lib/build-schema.cjs +0 -113
- /package/lib/{Condition.js → ReproducingSystem.js} +0 -0
- /package/lib/{Measurement.js → utils.js} +0 -0
package/lib/importJsonLd.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { RollCopy } from "./RollCopy";
|
|
2
|
-
import { referenceTypes } from "./asJsonLd";
|
|
3
|
-
export const exportDate = (date) => {
|
|
4
|
-
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
|
5
|
-
};
|
|
6
1
|
const isDate = (value) => {
|
|
7
2
|
const datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/;
|
|
8
3
|
return datePattern.test(value);
|
|
@@ -14,81 +9,24 @@ export const importDate = (str) => {
|
|
|
14
9
|
}
|
|
15
10
|
return new Date(y, m - 1, d);
|
|
16
11
|
};
|
|
17
|
-
const
|
|
18
|
-
const result = new Map();
|
|
19
|
-
// Check if the current object has an `id` property and store it
|
|
20
|
-
if (json && typeof json === 'object') {
|
|
21
|
-
if ('@id' in json) {
|
|
22
|
-
result.set(json['@id'], json);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// Recursively search within arrays or nested objects
|
|
26
|
-
for (const key in json) {
|
|
27
|
-
if (Array.isArray(json[key])) {
|
|
28
|
-
for (const item of json[key]) {
|
|
29
|
-
collectEntitiesWithId(item).forEach((v, k) => result.set(k, v));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else if (typeof json[key] === 'object' && json[key] !== null) {
|
|
33
|
-
collectEntitiesWithId(json[key]).forEach((v, k) => result.set(k, v));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
const fromIDArray = (arr, entities) => {
|
|
39
|
-
return arr.map(id => {
|
|
40
|
-
const entity = entities.get(id);
|
|
41
|
-
if (!entity) {
|
|
42
|
-
console.warn('Could not find entity with id', id);
|
|
43
|
-
}
|
|
44
|
-
return entity;
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const fromJsonLdEntity = (json, entitiesWithId) => {
|
|
12
|
+
const fromJsonLdEntity = (json) => {
|
|
48
13
|
if (typeof json !== 'object') {
|
|
49
14
|
return json;
|
|
50
15
|
}
|
|
51
16
|
let result = json;
|
|
52
17
|
if ('@type' in json) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
result = new RollCopy();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
result['type'] = value;
|
|
59
|
-
}
|
|
18
|
+
result['type'] = json['@type'];
|
|
19
|
+
delete result['@type'];
|
|
60
20
|
}
|
|
61
21
|
for (const [key, value] of Object.entries(json)) {
|
|
62
22
|
if (key === '@id') {
|
|
23
|
+
// console.log("deleting @id", value);
|
|
63
24
|
result['id'] = value;
|
|
25
|
+
delete result['@id'];
|
|
64
26
|
}
|
|
65
|
-
if (typeof value === 'string' && isDate(value)) {
|
|
66
|
-
console.log('importing date', value);
|
|
27
|
+
else if (typeof value === 'string' && isDate(value)) {
|
|
67
28
|
result[key] = importDate(value);
|
|
68
29
|
}
|
|
69
|
-
else if ([...referenceTypes, 'premises', 'delete', 'comprehends', 'assigned'].includes(key)) {
|
|
70
|
-
if (Array.isArray(value) && value.every(e => typeof e === 'string')) {
|
|
71
|
-
result[key] = fromIDArray(value, entitiesWithId);
|
|
72
|
-
}
|
|
73
|
-
else if (typeof value === 'string') {
|
|
74
|
-
if (isDate(value)) {
|
|
75
|
-
console.log('treating', value, 'as date');
|
|
76
|
-
result[key] = importDate(value);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
if (value.startsWith('1905')) {
|
|
80
|
-
console.log('oh no, dealing with a date, but it is treated as a string!', value);
|
|
81
|
-
}
|
|
82
|
-
const entity = entitiesWithId.get(value);
|
|
83
|
-
if (entity) {
|
|
84
|
-
result[key] = entity;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
result[key] = value;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
30
|
else if (Array.isArray(value)) {
|
|
93
31
|
result[key] = value.map(v => {
|
|
94
32
|
if (typeof v === 'string') {
|
|
@@ -98,12 +36,12 @@ const fromJsonLdEntity = (json, entitiesWithId) => {
|
|
|
98
36
|
return v;
|
|
99
37
|
}
|
|
100
38
|
else {
|
|
101
|
-
return fromJsonLdEntity(v
|
|
39
|
+
return fromJsonLdEntity(v);
|
|
102
40
|
}
|
|
103
41
|
});
|
|
104
42
|
}
|
|
105
43
|
else if (typeof value === 'object') {
|
|
106
|
-
result[key] = fromJsonLdEntity(value
|
|
44
|
+
result[key] = fromJsonLdEntity(value);
|
|
107
45
|
}
|
|
108
46
|
else {
|
|
109
47
|
result[key] = value;
|
|
@@ -112,8 +50,7 @@ const fromJsonLdEntity = (json, entitiesWithId) => {
|
|
|
112
50
|
return result;
|
|
113
51
|
};
|
|
114
52
|
export const importJsonLd = (json) => {
|
|
115
|
-
const
|
|
116
|
-
const edition = fromJsonLdEntity(json, entitiesWithId);
|
|
53
|
+
const edition = fromJsonLdEntity(json);
|
|
117
54
|
if (Array.isArray(json['@context'])) {
|
|
118
55
|
edition.base = json['@context'].find((c) => c['@base'])?.['@base'] || '';
|
|
119
56
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
export * from './Assumption';
|
|
1
2
|
export * from './asJsonLd';
|
|
2
3
|
export * from './Collation';
|
|
3
4
|
export * from './ConditionState';
|
|
4
5
|
export * from './context';
|
|
5
6
|
export * from './Edit';
|
|
6
7
|
export * from './Edition';
|
|
7
|
-
export * from './EditorialAssumption';
|
|
8
8
|
export * from './Emulation';
|
|
9
|
+
export * from './ReproducingSystem';
|
|
9
10
|
export * from './Feature';
|
|
10
11
|
export * from './importJsonLd';
|
|
11
|
-
export * from './PlaceTimeConversion';
|
|
12
12
|
export * from './RollCopy';
|
|
13
13
|
export * from './Version';
|
|
14
14
|
export * from './Symbol';
|
|
15
15
|
export * from './TrackerBar';
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './TrackCalibration';
|
|
17
17
|
export * from './alignFeatures';
|
|
18
|
+
export * from './EditionView';
|
|
19
|
+
export * from './Plan';
|
|
20
|
+
export * from './validate';
|
|
21
|
+
export * from './utils';
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
export * from './Assumption';
|
|
1
2
|
export * from './asJsonLd';
|
|
2
3
|
export * from './Collation';
|
|
3
4
|
export * from './ConditionState';
|
|
4
5
|
export * from './context';
|
|
5
6
|
export * from './Edit';
|
|
6
7
|
export * from './Edition';
|
|
7
|
-
export * from './EditorialAssumption';
|
|
8
8
|
export * from './Emulation';
|
|
9
|
+
export * from './ReproducingSystem';
|
|
9
10
|
export * from './Feature';
|
|
10
11
|
export * from './importJsonLd';
|
|
11
|
-
export * from './PlaceTimeConversion';
|
|
12
12
|
export * from './RollCopy';
|
|
13
13
|
export * from './Version';
|
|
14
14
|
export * from './Symbol';
|
|
15
15
|
export * from './TrackerBar';
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './TrackCalibration';
|
|
17
17
|
export * from './alignFeatures';
|
|
18
|
+
export * from './EditionView';
|
|
19
|
+
export * from './Plan';
|
|
20
|
+
export * from './validate';
|
|
21
|
+
export * from './utils';
|