@scorelabs/core 1.0.10 → 1.0.13
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/dist/constants.d.ts +4 -0
- package/dist/constants.js +10 -0
- package/dist/importers/MusicXMLParser.d.ts +4 -1
- package/dist/importers/MusicXMLParser.js +564 -75
- package/dist/importers/index.d.ts +1 -1
- package/dist/importers/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/Measure.d.ts +25 -5
- package/dist/models/Measure.js +173 -35
- package/dist/models/Note.d.ts +38 -9
- package/dist/models/Note.js +104 -47
- package/dist/models/NoteSet.d.ts +14 -4
- package/dist/models/NoteSet.js +38 -4
- package/dist/models/Part.d.ts +6 -6
- package/dist/models/Part.js +4 -4
- package/dist/models/Pitch.d.ts +1 -1
- package/dist/models/Pitch.js +1 -1
- package/dist/models/PreMeasure.d.ts +1 -1
- package/dist/models/Score.d.ts +13 -9
- package/dist/models/Score.js +164 -126
- package/dist/models/Staff.d.ts +5 -5
- package/dist/models/Staff.js +4 -4
- package/dist/models/index.d.ts +10 -10
- package/dist/models/index.js +10 -10
- package/dist/types/AccidentalDisplay.d.ts +6 -0
- package/dist/types/AccidentalDisplay.js +1 -0
- package/dist/types/Arpeggio.d.ts +2 -1
- package/dist/types/Arpeggio.js +1 -0
- package/dist/types/Articulation.d.ts +3 -1
- package/dist/types/Articulation.js +2 -0
- package/dist/types/Beam.d.ts +4 -0
- package/dist/types/Beam.js +1 -0
- package/dist/types/Duration.d.ts +5 -1
- package/dist/types/Duration.js +27 -14
- package/dist/types/Grace.d.ts +7 -0
- package/dist/types/Grace.js +1 -0
- package/dist/types/Hairpin.d.ts +2 -1
- package/dist/types/Language.d.ts +6 -0
- package/dist/types/Language.js +7 -0
- package/dist/types/Lyric.d.ts +2 -0
- package/dist/types/Ornament.d.ts +23 -1
- package/dist/types/Ornament.js +9 -0
- package/dist/types/Pedal.d.ts +3 -2
- package/dist/types/Placement.d.ts +7 -0
- package/dist/types/Placement.js +1 -0
- package/dist/types/Repeat.d.ts +1 -0
- package/dist/types/RestDisplay.d.ts +6 -0
- package/dist/types/RestDisplay.js +1 -0
- package/dist/types/Slur.d.ts +1 -0
- package/dist/types/Technical.d.ts +20 -0
- package/dist/types/Technical.js +5 -0
- package/dist/types/Tempo.d.ts +1 -1
- package/dist/types/Tie.d.ts +4 -0
- package/dist/types/Tie.js +1 -0
- package/dist/types/Tuplet.d.ts +6 -0
- package/dist/types/User.d.ts +13 -7
- package/dist/types/User.js +9 -7
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +8 -0
- package/package.json +2 -1
package/dist/models/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './Pitch';
|
|
3
|
-
export * from './Note';
|
|
4
|
-
export * from './NoteSet';
|
|
5
|
-
export * from './Measure';
|
|
6
|
-
export * from './Staff';
|
|
7
|
-
export * from './Part';
|
|
8
|
-
export * from './Score';
|
|
9
|
-
export * from './Instrument';
|
|
10
|
-
export * from './PreMeasure';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './Pitch.js';
|
|
3
|
+
export * from './Note.js';
|
|
4
|
+
export * from './NoteSet.js';
|
|
5
|
+
export * from './Measure.js';
|
|
6
|
+
export * from './Staff.js';
|
|
7
|
+
export * from './Part.js';
|
|
8
|
+
export * from './Score.js';
|
|
9
|
+
export * from './Instrument.js';
|
|
10
|
+
export * from './PreMeasure.js';
|
package/dist/models/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './Pitch';
|
|
3
|
-
export * from './Note';
|
|
4
|
-
export * from './NoteSet';
|
|
5
|
-
export * from './Measure';
|
|
6
|
-
export * from './Staff';
|
|
7
|
-
export * from './Part';
|
|
8
|
-
export * from './Score';
|
|
9
|
-
export * from './Instrument';
|
|
10
|
-
export * from './PreMeasure';
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './Pitch.js';
|
|
3
|
+
export * from './Note.js';
|
|
4
|
+
export * from './NoteSet.js';
|
|
5
|
+
export * from './Measure.js';
|
|
6
|
+
export * from './Staff.js';
|
|
7
|
+
export * from './Part.js';
|
|
8
|
+
export * from './Score.js';
|
|
9
|
+
export * from './Instrument.js';
|
|
10
|
+
export * from './PreMeasure.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Arpeggio.d.ts
CHANGED
package/dist/types/Arpeggio.js
CHANGED
|
@@ -8,4 +8,6 @@ export var Articulation;
|
|
|
8
8
|
Articulation["Staccatissimo"] = "staccatissimo";
|
|
9
9
|
Articulation["Caesura"] = "caesura";
|
|
10
10
|
Articulation["BreathMark"] = "breath-mark";
|
|
11
|
+
Articulation["Legato"] = "legato";
|
|
12
|
+
Articulation["Portato"] = "portato";
|
|
11
13
|
})(Articulation || (Articulation = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Duration.d.ts
CHANGED
|
@@ -10,11 +10,15 @@ export declare enum Duration {
|
|
|
10
10
|
TwoHundredFiftySixth = "two-hundred-fifty-sixth"
|
|
11
11
|
}
|
|
12
12
|
export declare const DURATION_VALUES: Record<Duration, number>;
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the numeric duration value (quarter = 1) for a given duration and dot count.
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculateDurationValue(duration: Duration, dotCount?: number): number;
|
|
13
17
|
/**
|
|
14
18
|
* Decomposes a duration value (quarter = 1) into a list of duration/dot pairs.
|
|
15
19
|
*/
|
|
16
20
|
export declare function decomposeDuration(value: number): {
|
|
17
21
|
duration: Duration;
|
|
18
|
-
|
|
22
|
+
dotCount: number;
|
|
19
23
|
val: number;
|
|
20
24
|
}[];
|
package/dist/types/Duration.js
CHANGED
|
@@ -22,6 +22,19 @@ export const DURATION_VALUES = {
|
|
|
22
22
|
[Duration.OneHundredTwentyEighth]: 0.03125,
|
|
23
23
|
[Duration.TwoHundredFiftySixth]: 0.015625,
|
|
24
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Calculates the numeric duration value (quarter = 1) for a given duration and dot count.
|
|
27
|
+
*/
|
|
28
|
+
export function calculateDurationValue(duration, dotCount = 0) {
|
|
29
|
+
const base = DURATION_VALUES[duration];
|
|
30
|
+
let multiplier = 1;
|
|
31
|
+
let dotValue = 0.5;
|
|
32
|
+
for (let i = 0; i < dotCount; i++) {
|
|
33
|
+
multiplier += dotValue;
|
|
34
|
+
dotValue /= 2;
|
|
35
|
+
}
|
|
36
|
+
return base * multiplier;
|
|
37
|
+
}
|
|
25
38
|
/**
|
|
26
39
|
* Decomposes a duration value (quarter = 1) into a list of duration/dot pairs.
|
|
27
40
|
*/
|
|
@@ -29,26 +42,26 @@ export function decomposeDuration(value) {
|
|
|
29
42
|
const result = [];
|
|
30
43
|
let remaining = value;
|
|
31
44
|
const options = [
|
|
32
|
-
{ val: 4, dur: Duration.Whole, dot:
|
|
33
|
-
{ val: 3, dur: Duration.Half, dot:
|
|
34
|
-
{ val: 2, dur: Duration.Half, dot:
|
|
35
|
-
{ val: 1.5, dur: Duration.Quarter, dot:
|
|
36
|
-
{ val: 1, dur: Duration.Quarter, dot:
|
|
37
|
-
{ val: 0.75, dur: Duration.Eighth, dot:
|
|
38
|
-
{ val: 0.5, dur: Duration.Eighth, dot:
|
|
39
|
-
{ val: 0.375, dur: Duration.Sixteenth, dot:
|
|
40
|
-
{ val: 0.25, dur: Duration.Sixteenth, dot:
|
|
41
|
-
{ val: 0.1875, dur: Duration.ThirtySecond, dot:
|
|
42
|
-
{ val: 0.125, dur: Duration.ThirtySecond, dot:
|
|
43
|
-
{ val: 0.09375, dur: Duration.SixtyFourth, dot:
|
|
44
|
-
{ val: 0.0625, dur: Duration.SixtyFourth, dot:
|
|
45
|
+
{ val: 4, dur: Duration.Whole, dot: 0 },
|
|
46
|
+
{ val: 3, dur: Duration.Half, dot: 1 },
|
|
47
|
+
{ val: 2, dur: Duration.Half, dot: 0 },
|
|
48
|
+
{ val: 1.5, dur: Duration.Quarter, dot: 1 },
|
|
49
|
+
{ val: 1, dur: Duration.Quarter, dot: 0 },
|
|
50
|
+
{ val: 0.75, dur: Duration.Eighth, dot: 1 },
|
|
51
|
+
{ val: 0.5, dur: Duration.Eighth, dot: 0 },
|
|
52
|
+
{ val: 0.375, dur: Duration.Sixteenth, dot: 1 },
|
|
53
|
+
{ val: 0.25, dur: Duration.Sixteenth, dot: 0 },
|
|
54
|
+
{ val: 0.1875, dur: Duration.ThirtySecond, dot: 1 },
|
|
55
|
+
{ val: 0.125, dur: Duration.ThirtySecond, dot: 0 },
|
|
56
|
+
{ val: 0.09375, dur: Duration.SixtyFourth, dot: 1 },
|
|
57
|
+
{ val: 0.0625, dur: Duration.SixtyFourth, dot: 0 },
|
|
45
58
|
];
|
|
46
59
|
// Protect against infinite loop with max iterations
|
|
47
60
|
let loops = 0;
|
|
48
61
|
while (remaining > 0.001 && loops < 100) {
|
|
49
62
|
const match = options.find((o) => o.val <= remaining + 0.001);
|
|
50
63
|
if (match) {
|
|
51
|
-
result.push({ duration: match.dur,
|
|
64
|
+
result.push({ duration: match.dur, dotCount: match.dot, val: match.val });
|
|
52
65
|
remaining -= match.val;
|
|
53
66
|
}
|
|
54
67
|
else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Hairpin.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Placement } from './Placement.js';
|
|
1
2
|
export declare enum HairpinType {
|
|
2
3
|
Crescendo = "crescendo",
|
|
3
4
|
Decrescendo = "decrescendo"
|
|
4
5
|
}
|
|
5
|
-
export interface Hairpin {
|
|
6
|
+
export interface Hairpin extends Placement {
|
|
6
7
|
type: HairpinType;
|
|
7
8
|
placement: 'start' | 'stop';
|
|
8
9
|
}
|
package/dist/types/Lyric.d.ts
CHANGED
package/dist/types/Ornament.d.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
+
import { Accidental } from './Accidental.js';
|
|
1
2
|
export declare enum Ornament {
|
|
2
3
|
Trill = "trill",
|
|
3
4
|
Mordent = "mordent",
|
|
4
5
|
InvertedMordent = "inverted-mordent",
|
|
5
6
|
Turn = "turn",
|
|
6
7
|
InvertedTurn = "inverted-turn",
|
|
7
|
-
|
|
8
|
+
DelayedTurn = "delayed-turn",
|
|
9
|
+
Tremolo = "tremolo",
|
|
10
|
+
Tremolo1 = "tremolo-1",
|
|
11
|
+
Tremolo2 = "tremolo-2",
|
|
12
|
+
Tremolo3 = "tremolo-3",
|
|
13
|
+
Tremolo4 = "tremolo-4",
|
|
14
|
+
TremoloMeasured1 = "tremolo-measured-1",
|
|
15
|
+
TremoloMeasured2 = "tremolo-measured-2",
|
|
16
|
+
TremoloMeasured3 = "tremolo-measured-3",
|
|
17
|
+
TremoloMeasured4 = "tremolo-measured-4"
|
|
18
|
+
}
|
|
19
|
+
export interface OrnamentAccidentalMark {
|
|
20
|
+
accidental: Accidental;
|
|
21
|
+
placement?: 'above' | 'below';
|
|
22
|
+
}
|
|
23
|
+
export interface OrnamentWavyLine {
|
|
24
|
+
type: 'start' | 'stop' | 'continue';
|
|
25
|
+
number?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface OrnamentDetails {
|
|
28
|
+
wavyLine?: OrnamentWavyLine;
|
|
29
|
+
accidentalMarks?: OrnamentAccidentalMark[];
|
|
8
30
|
}
|
package/dist/types/Ornament.js
CHANGED
|
@@ -5,5 +5,14 @@ export var Ornament;
|
|
|
5
5
|
Ornament["InvertedMordent"] = "inverted-mordent";
|
|
6
6
|
Ornament["Turn"] = "turn";
|
|
7
7
|
Ornament["InvertedTurn"] = "inverted-turn";
|
|
8
|
+
Ornament["DelayedTurn"] = "delayed-turn";
|
|
8
9
|
Ornament["Tremolo"] = "tremolo";
|
|
10
|
+
Ornament["Tremolo1"] = "tremolo-1";
|
|
11
|
+
Ornament["Tremolo2"] = "tremolo-2";
|
|
12
|
+
Ornament["Tremolo3"] = "tremolo-3";
|
|
13
|
+
Ornament["Tremolo4"] = "tremolo-4";
|
|
14
|
+
Ornament["TremoloMeasured1"] = "tremolo-measured-1";
|
|
15
|
+
Ornament["TremoloMeasured2"] = "tremolo-measured-2";
|
|
16
|
+
Ornament["TremoloMeasured3"] = "tremolo-measured-3";
|
|
17
|
+
Ornament["TremoloMeasured4"] = "tremolo-measured-4";
|
|
9
18
|
})(Ornament || (Ornament = {}));
|
package/dist/types/Pedal.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Repeat.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Slur.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum HarmonicType {
|
|
2
|
+
Natural = "natural",
|
|
3
|
+
Artificial = "artificial"
|
|
4
|
+
}
|
|
5
|
+
export interface Harmonic {
|
|
6
|
+
type: HarmonicType;
|
|
7
|
+
printObject?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface Bend {
|
|
10
|
+
alter: number;
|
|
11
|
+
release?: boolean;
|
|
12
|
+
preBend?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface Technical {
|
|
15
|
+
harmonic?: Harmonic;
|
|
16
|
+
bend?: Bend;
|
|
17
|
+
tap?: boolean;
|
|
18
|
+
vibrato?: 'start' | 'stop' | boolean;
|
|
19
|
+
handVibrato?: boolean;
|
|
20
|
+
}
|
package/dist/types/Tempo.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/Tuplet.d.ts
CHANGED
|
@@ -2,4 +2,10 @@ export interface Tuplet {
|
|
|
2
2
|
actual: number;
|
|
3
3
|
normal: number;
|
|
4
4
|
type: 'start' | 'stop' | 'middle';
|
|
5
|
+
number?: number;
|
|
6
|
+
placement?: 'above' | 'below';
|
|
7
|
+
bracket?: 'yes' | 'no' | 'auto';
|
|
8
|
+
showNumber?: 'none' | 'actual' | 'both';
|
|
9
|
+
actualDisplay?: number;
|
|
10
|
+
normalDisplay?: number;
|
|
5
11
|
}
|
package/dist/types/User.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export type UserTier = 'free' | 'premium' | 'school';
|
|
2
|
+
export declare enum SubscriptionStatus {
|
|
3
|
+
ACTIVE = "active",
|
|
4
|
+
TRIALING = "trialing",
|
|
5
|
+
CANCELED = "canceled",
|
|
6
|
+
PAST_DUE = "past_due",
|
|
7
|
+
UNPAID = "unpaid",
|
|
8
|
+
INCOMPLETE = "incomplete"
|
|
9
|
+
}
|
|
8
10
|
export interface UserData {
|
|
9
11
|
accessToken?: string;
|
|
10
12
|
access_token?: string;
|
|
@@ -18,4 +20,8 @@ export interface UserData {
|
|
|
18
20
|
id?: string | number;
|
|
19
21
|
tier?: UserTier | string;
|
|
20
22
|
picture?: string;
|
|
23
|
+
language?: string;
|
|
24
|
+
subscription_status?: SubscriptionStatus | string | null;
|
|
25
|
+
subscription_end_date?: string | null;
|
|
26
|
+
available_schools_counter?: number;
|
|
21
27
|
}
|
package/dist/types/User.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export var SubscriptionStatus;
|
|
2
|
+
(function (SubscriptionStatus) {
|
|
3
|
+
SubscriptionStatus["ACTIVE"] = "active";
|
|
4
|
+
SubscriptionStatus["TRIALING"] = "trialing";
|
|
5
|
+
SubscriptionStatus["CANCELED"] = "canceled";
|
|
6
|
+
SubscriptionStatus["PAST_DUE"] = "past_due";
|
|
7
|
+
SubscriptionStatus["UNPAID"] = "unpaid";
|
|
8
|
+
SubscriptionStatus["INCOMPLETE"] = "incomplete";
|
|
9
|
+
})(SubscriptionStatus || (SubscriptionStatus = {}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export * from './InstrumentType.js';
|
|
|
3
3
|
export * from './StemDirection.js';
|
|
4
4
|
export * from './Clef.js';
|
|
5
5
|
export * from './Duration.js';
|
|
6
|
+
export * from './Beam.js';
|
|
6
7
|
export * from './Accidental.js';
|
|
8
|
+
export * from './AccidentalDisplay.js';
|
|
7
9
|
export * from './Articulation.js';
|
|
8
10
|
export * from './Dynamic.js';
|
|
9
11
|
export * from './Genre.js';
|
|
@@ -22,6 +24,12 @@ export * from './Arpeggio.js';
|
|
|
22
24
|
export * from './Glissando.js';
|
|
23
25
|
export * from './Pedal.js';
|
|
24
26
|
export * from './Slur.js';
|
|
27
|
+
export * from './Tie.js';
|
|
25
28
|
export * from './Tuplet.js';
|
|
29
|
+
export * from './Grace.js';
|
|
30
|
+
export * from './RestDisplay.js';
|
|
26
31
|
export * from './Repeat.js';
|
|
27
32
|
export * from './User.js';
|
|
33
|
+
export * from './Language.js';
|
|
34
|
+
export * from './Technical.js';
|
|
35
|
+
export * from './Placement.js';
|
package/dist/types/index.js
CHANGED
|
@@ -3,7 +3,9 @@ export * from './InstrumentType.js';
|
|
|
3
3
|
export * from './StemDirection.js';
|
|
4
4
|
export * from './Clef.js';
|
|
5
5
|
export * from './Duration.js';
|
|
6
|
+
export * from './Beam.js';
|
|
6
7
|
export * from './Accidental.js';
|
|
8
|
+
export * from './AccidentalDisplay.js';
|
|
7
9
|
export * from './Articulation.js';
|
|
8
10
|
export * from './Dynamic.js';
|
|
9
11
|
export * from './Genre.js';
|
|
@@ -22,6 +24,12 @@ export * from './Arpeggio.js';
|
|
|
22
24
|
export * from './Glissando.js';
|
|
23
25
|
export * from './Pedal.js';
|
|
24
26
|
export * from './Slur.js';
|
|
27
|
+
export * from './Tie.js';
|
|
25
28
|
export * from './Tuplet.js';
|
|
29
|
+
export * from './Grace.js';
|
|
30
|
+
export * from './RestDisplay.js';
|
|
26
31
|
export * from './Repeat.js';
|
|
27
32
|
export * from './User.js';
|
|
33
|
+
export * from './Language.js';
|
|
34
|
+
export * from './Technical.js';
|
|
35
|
+
export * from './Placement.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scorelabs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Core logic and models for ScoreLabs music notation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@types/jszip": "^3.4.0",
|
|
35
35
|
"@types/node": "^25.2.3",
|
|
36
36
|
"@vitest/coverage-v8": "^4.0.18",
|
|
37
|
+
"@xmldom/xmldom": "^0.8.11",
|
|
37
38
|
"typescript": "^5.9.3",
|
|
38
39
|
"vitest": "^4.0.18"
|
|
39
40
|
}
|