@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.
Files changed (61) hide show
  1. package/dist/constants.d.ts +4 -0
  2. package/dist/constants.js +10 -0
  3. package/dist/importers/MusicXMLParser.d.ts +4 -1
  4. package/dist/importers/MusicXMLParser.js +564 -75
  5. package/dist/importers/index.d.ts +1 -1
  6. package/dist/importers/index.js +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +1 -0
  9. package/dist/models/Measure.d.ts +25 -5
  10. package/dist/models/Measure.js +173 -35
  11. package/dist/models/Note.d.ts +38 -9
  12. package/dist/models/Note.js +104 -47
  13. package/dist/models/NoteSet.d.ts +14 -4
  14. package/dist/models/NoteSet.js +38 -4
  15. package/dist/models/Part.d.ts +6 -6
  16. package/dist/models/Part.js +4 -4
  17. package/dist/models/Pitch.d.ts +1 -1
  18. package/dist/models/Pitch.js +1 -1
  19. package/dist/models/PreMeasure.d.ts +1 -1
  20. package/dist/models/Score.d.ts +13 -9
  21. package/dist/models/Score.js +164 -126
  22. package/dist/models/Staff.d.ts +5 -5
  23. package/dist/models/Staff.js +4 -4
  24. package/dist/models/index.d.ts +10 -10
  25. package/dist/models/index.js +10 -10
  26. package/dist/types/AccidentalDisplay.d.ts +6 -0
  27. package/dist/types/AccidentalDisplay.js +1 -0
  28. package/dist/types/Arpeggio.d.ts +2 -1
  29. package/dist/types/Arpeggio.js +1 -0
  30. package/dist/types/Articulation.d.ts +3 -1
  31. package/dist/types/Articulation.js +2 -0
  32. package/dist/types/Beam.d.ts +4 -0
  33. package/dist/types/Beam.js +1 -0
  34. package/dist/types/Duration.d.ts +5 -1
  35. package/dist/types/Duration.js +27 -14
  36. package/dist/types/Grace.d.ts +7 -0
  37. package/dist/types/Grace.js +1 -0
  38. package/dist/types/Hairpin.d.ts +2 -1
  39. package/dist/types/Language.d.ts +6 -0
  40. package/dist/types/Language.js +7 -0
  41. package/dist/types/Lyric.d.ts +2 -0
  42. package/dist/types/Ornament.d.ts +23 -1
  43. package/dist/types/Ornament.js +9 -0
  44. package/dist/types/Pedal.d.ts +3 -2
  45. package/dist/types/Placement.d.ts +7 -0
  46. package/dist/types/Placement.js +1 -0
  47. package/dist/types/Repeat.d.ts +1 -0
  48. package/dist/types/RestDisplay.d.ts +6 -0
  49. package/dist/types/RestDisplay.js +1 -0
  50. package/dist/types/Slur.d.ts +1 -0
  51. package/dist/types/Technical.d.ts +20 -0
  52. package/dist/types/Technical.js +5 -0
  53. package/dist/types/Tempo.d.ts +1 -1
  54. package/dist/types/Tie.d.ts +4 -0
  55. package/dist/types/Tie.js +1 -0
  56. package/dist/types/Tuplet.d.ts +6 -0
  57. package/dist/types/User.d.ts +13 -7
  58. package/dist/types/User.js +9 -7
  59. package/dist/types/index.d.ts +8 -0
  60. package/dist/types/index.js +8 -0
  61. package/package.json +2 -1
@@ -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';
@@ -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,6 @@
1
+ export interface AccidentalDisplay {
2
+ cautionary?: boolean;
3
+ editorial?: boolean;
4
+ parenthesized?: boolean;
5
+ bracketed?: boolean;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,6 @@
1
1
  export declare enum Arpeggio {
2
2
  Normal = "normal",
3
3
  Up = "up",
4
- Down = "down"
4
+ Down = "down",
5
+ NonArpeggiate = "non-arpeggiate"
5
6
  }
@@ -3,4 +3,5 @@ export var Arpeggio;
3
3
  Arpeggio["Normal"] = "normal";
4
4
  Arpeggio["Up"] = "up";
5
5
  Arpeggio["Down"] = "down";
6
+ Arpeggio["NonArpeggiate"] = "non-arpeggiate";
6
7
  })(Arpeggio || (Arpeggio = {}));
@@ -6,5 +6,7 @@ export declare enum Articulation {
6
6
  Fermata = "fermata",
7
7
  Staccatissimo = "staccatissimo",
8
8
  Caesura = "caesura",
9
- BreathMark = "breath-mark"
9
+ BreathMark = "breath-mark",
10
+ Legato = "legato",
11
+ Portato = "portato"
10
12
  }
@@ -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,4 @@
1
+ export type BeamValue = 'begin' | 'continue' | 'end' | 'forward hook' | 'backward hook';
2
+ export interface BeamLevels {
3
+ [level: number]: BeamValue;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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
- isDotted: boolean;
22
+ dotCount: number;
19
23
  val: number;
20
24
  }[];
@@ -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: false },
33
- { val: 3, dur: Duration.Half, dot: true },
34
- { val: 2, dur: Duration.Half, dot: false },
35
- { val: 1.5, dur: Duration.Quarter, dot: true },
36
- { val: 1, dur: Duration.Quarter, dot: false },
37
- { val: 0.75, dur: Duration.Eighth, dot: true },
38
- { val: 0.5, dur: Duration.Eighth, dot: false },
39
- { val: 0.375, dur: Duration.Sixteenth, dot: true },
40
- { val: 0.25, dur: Duration.Sixteenth, dot: false },
41
- { val: 0.1875, dur: Duration.ThirtySecond, dot: true },
42
- { val: 0.125, dur: Duration.ThirtySecond, dot: false },
43
- { val: 0.09375, dur: Duration.SixtyFourth, dot: true },
44
- { val: 0.0625, dur: Duration.SixtyFourth, dot: false },
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, isDotted: match.dot, val: match.val });
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,7 @@
1
+ export interface GraceNote {
2
+ slash?: boolean;
3
+ stealTimePrevious?: number;
4
+ stealTimeFollowing?: number;
5
+ makeTime?: number;
6
+ cueSize?: boolean;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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
  }
@@ -0,0 +1,6 @@
1
+ export declare enum Language {
2
+ EN = "en",
3
+ CA = "ca",
4
+ ES = "es",
5
+ DE = "de"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var Language;
2
+ (function (Language) {
3
+ Language["EN"] = "en";
4
+ Language["CA"] = "ca";
5
+ Language["ES"] = "es";
6
+ Language["DE"] = "de";
7
+ })(Language || (Language = {}));
@@ -1,3 +1,4 @@
1
+ import { Placement } from './Placement.js';
1
2
  export declare enum Syllabic {
2
3
  Single = "single",
3
4
  Begin = "begin",
@@ -8,4 +9,5 @@ export interface Lyric {
8
9
  text: string;
9
10
  syllabic?: Syllabic;
10
11
  isExtension?: boolean;
12
+ placement?: Placement;
11
13
  }
@@ -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
- Tremolo = "tremolo"
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
  }
@@ -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 = {}));
@@ -1,4 +1,5 @@
1
1
  export interface Pedal {
2
- type: 'sustain' | 'una-corda';
3
- placement: 'start' | 'stop';
2
+ type: 'sustain' | 'una-corda' | 'sostenuto';
3
+ placement: 'start' | 'stop' | 'change' | 'continue';
4
+ style?: 'text' | 'bracket' | 'mixed';
4
5
  }
@@ -0,0 +1,7 @@
1
+ export interface Placement {
2
+ defaultX?: number;
3
+ defaultY?: number;
4
+ relativeX?: number;
5
+ relativeY?: number;
6
+ aboveBelow?: 'above' | 'below';
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -5,4 +5,5 @@ export interface Repeat {
5
5
  export interface Volta {
6
6
  type: 'start' | 'stop' | 'both';
7
7
  numbers: number[];
8
+ placement?: 'above' | 'below';
8
9
  }
@@ -0,0 +1,6 @@
1
+ export interface RestDisplay {
2
+ displayStep?: number;
3
+ displayOctave?: number;
4
+ defaultY?: number;
5
+ relativeY?: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export interface Slur {
2
2
  placement: 'start' | 'stop';
3
3
  direction?: 'up' | 'down';
4
+ number?: number;
4
5
  }
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ export var HarmonicType;
2
+ (function (HarmonicType) {
3
+ HarmonicType["Natural"] = "natural";
4
+ HarmonicType["Artificial"] = "artificial";
5
+ })(HarmonicType || (HarmonicType = {}));
@@ -2,7 +2,7 @@ import { Duration } from './Duration.js';
2
2
  export interface Tempo {
3
3
  bpm: number;
4
4
  duration: Duration;
5
- isDotted: boolean;
5
+ dotCount?: number;
6
6
  text?: string;
7
7
  gradual?: 'ritardando' | 'accelerando';
8
8
  }
@@ -0,0 +1,4 @@
1
+ export interface TieSpan {
2
+ placement: 'start' | 'stop' | 'continue';
3
+ number?: number;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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
  }
@@ -1,10 +1,12 @@
1
- /**
2
- * WARNING: DO NOT ADD SENSITIVE LOGIC OR PRIVATE CONSTANTS TO THIS FILE.
3
- * This package (@scorelabs/core) is used in public-facing frontend applications
4
- * and could be exposed. Keep all token generation, verification, and encryption
5
- * logic in the 'backend' or 'website' utilities.
6
- */
7
- export type UserTier = 'free' | 'premium';
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
  }
@@ -1,7 +1,9 @@
1
- /**
2
- * WARNING: DO NOT ADD SENSITIVE LOGIC OR PRIVATE CONSTANTS TO THIS FILE.
3
- * This package (@scorelabs/core) is used in public-facing frontend applications
4
- * and could be exposed. Keep all token generation, verification, and encryption
5
- * logic in the 'backend' or 'website' utilities.
6
- */
7
- export {};
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 = {}));
@@ -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';
@@ -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.10",
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
  }