@tspro/web-music-score 5.4.2 → 5.5.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +24 -0
  3. package/README.md +13 -6
  4. package/dist/audio/index.d.ts +1 -1
  5. package/dist/audio/index.js +1637 -5
  6. package/dist/audio/index.mjs +9 -6
  7. package/dist/audio-cg/index.js +17487 -46
  8. package/dist/audio-cg/index.mjs +7 -5
  9. package/dist/audio-synth/index.js +18434 -32
  10. package/dist/audio-synth/index.mjs +12 -7
  11. package/dist/{chunk-MMWSQGVR.mjs → chunk-2DCCUAGC.mjs} +3 -3
  12. package/dist/{chunk-CVYTUTL6.mjs → chunk-2PEB4HWS.mjs} +2 -2
  13. package/dist/{chunk-42IBAVOC.mjs → chunk-33HIE3HR.mjs} +18 -13
  14. package/dist/chunk-BMKUAUSJ.mjs +101 -0
  15. package/dist/chunk-PCQGQM63.mjs +18381 -0
  16. package/dist/chunk-T6TYLAJE.mjs +3766 -0
  17. package/dist/core/index.js +2 -2
  18. package/dist/core/index.mjs +4 -4
  19. package/dist/{guitar-CNOxM4ZK.d.ts → guitar-CarHGDAt.d.ts} +1 -1
  20. package/dist/iife/audio-cg.global.js +1 -1
  21. package/dist/iife/index.global.js +11 -11
  22. package/dist/{music-objects-DqoO-Sfv.d.mts → music-objects-CcJvZxS6.d.mts} +123 -96
  23. package/dist/{music-objects-T8u8bnNP.d.ts → music-objects-l5Ai97QA.d.ts} +125 -98
  24. package/dist/{note-RVXvpfyV.d.ts → note-CJuq5aBy.d.ts} +1 -1
  25. package/dist/pieces/index.d.mts +12 -6
  26. package/dist/pieces/index.d.ts +14 -8
  27. package/dist/pieces/index.js +25 -13
  28. package/dist/pieces/index.mjs +25 -14
  29. package/dist/react-ui/index.d.mts +1 -1
  30. package/dist/react-ui/index.d.ts +5 -5
  31. package/dist/react-ui/index.js +2163 -22
  32. package/dist/react-ui/index.mjs +18 -15
  33. package/dist/{scale-CUYFBo-8.d.ts → scale-DulPFco_.d.ts} +2 -2
  34. package/dist/score/index.d.mts +51 -3
  35. package/dist/score/index.d.ts +54 -6
  36. package/dist/score/index.js +4828 -872
  37. package/dist/score/index.mjs +1280 -729
  38. package/dist/{tempo-DwuZsv2T.d.ts → tempo-BnUjm25M.d.ts} +1 -1
  39. package/dist/theory/index.d.ts +6 -6
  40. package/dist/theory/index.js +2576 -136
  41. package/dist/theory/index.mjs +41 -49
  42. package/package.json +4 -5
  43. package/dist/chunk-ROBXPR34.mjs +0 -9
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v5.4.2 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.5.0 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
2
  import {
3
3
  NoteLength,
4
4
  NoteLengthProps,
@@ -8,19 +8,20 @@ import {
8
8
  isTupletRatio,
9
9
  validateNoteLength,
10
10
  validateTupletRatio
11
- } from "../chunk-42IBAVOC.mjs";
11
+ } from "../chunk-33HIE3HR.mjs";
12
+ import {
13
+ IndexArray,
14
+ LRUCache,
15
+ SignedIndexArray,
16
+ UniMap,
17
+ guard_exports,
18
+ utils_exports
19
+ } from "../chunk-T6TYLAJE.mjs";
12
20
  import {
13
21
  __publicField
14
- } from "../chunk-ROBXPR34.mjs";
15
-
16
- // src/theory/chord.ts
17
- import { IndexArray, Utils as Utils4 } from "@tspro/ts-utils-lib";
18
-
19
- // src/theory/note.ts
20
- import { Guard as Guard2, UniMap } from "@tspro/ts-utils-lib";
22
+ } from "../chunk-BMKUAUSJ.mjs";
21
23
 
22
24
  // src/theory/types.ts
23
- import { Guard, Utils } from "@tspro/ts-utils-lib";
24
25
  import { MusicError, MusicErrorType } from "@tspro/web-music-score/core";
25
26
  var SymbolSet = /* @__PURE__ */ ((SymbolSet2) => {
26
27
  SymbolSet2[SymbolSet2["Ascii"] = 0] = "Ascii";
@@ -32,10 +33,10 @@ var PitchNotation = /* @__PURE__ */ ((PitchNotation2) => {
32
33
  PitchNotation2[PitchNotation2["Helmholtz"] = 1] = "Helmholtz";
33
34
  return PitchNotation2;
34
35
  })(PitchNotation || {});
35
- var PitchNotationList = Utils.Enum.getEnumValues(PitchNotation);
36
+ var PitchNotationList = utils_exports.Enum.getEnumValues(PitchNotation);
36
37
  var DefaultPitchNotation = 0 /* Scientific */;
37
38
  function validatePitchNotation(pn) {
38
- if (Guard.isEnumValue(pn, PitchNotation)) {
39
+ if (guard_exports.isEnumValue(pn, PitchNotation)) {
39
40
  return pn;
40
41
  } else {
41
42
  throw new MusicError(MusicErrorType.InvalidArg, `Invalid pitchNotation: ${pn}`);
@@ -51,9 +52,9 @@ var GuitarNoteLabel = /* @__PURE__ */ ((GuitarNoteLabel2) => {
51
52
  return GuitarNoteLabel2;
52
53
  })(GuitarNoteLabel || {});
53
54
  var DefaultGuitarNoteLabel = "Default" /* Default */;
54
- var GuitarNoteLabelList = Utils.Enum.getEnumValues(GuitarNoteLabel);
55
+ var GuitarNoteLabelList = utils_exports.Enum.getEnumValues(GuitarNoteLabel);
55
56
  function validateGuitarNoteLabel(label) {
56
- if (Guard.isEnumValue(label, GuitarNoteLabel)) {
57
+ if (guard_exports.isEnumValue(label, GuitarNoteLabel)) {
57
58
  return label;
58
59
  } else {
59
60
  throw new MusicError(MusicErrorType.Timesignature, `Invalid guitarNoteLabel: ${label}`);
@@ -359,7 +360,7 @@ var _Note = class _Note {
359
360
  * @returns - Valid diatonic id or throws.
360
361
  */
361
362
  static validateDiatonicId(diatonicId) {
362
- if (Guard2.isInteger(diatonicId)) {
363
+ if (guard_exports.isInteger(diatonicId)) {
363
364
  return diatonicId;
364
365
  } else {
365
366
  throw new MusicError2(MusicErrorType2.Note, `Invalid diatonicId: ${diatonicId}`);
@@ -371,7 +372,7 @@ var _Note = class _Note {
371
372
  * @returns - Valid diatonic class or throws.
372
373
  */
373
374
  static validateDiatonicClass(diatonicClass) {
374
- if (Guard2.isIntegerBetween(diatonicClass, 0, 6)) {
375
+ if (guard_exports.isIntegerBetween(diatonicClass, 0, 6)) {
375
376
  return diatonicClass;
376
377
  } else {
377
378
  throw new MusicError2(MusicErrorType2.Note, `Invalid diatonicClass: ${diatonicClass}`);
@@ -383,7 +384,7 @@ var _Note = class _Note {
383
384
  * @returns - Valid chromatic id, or throws.
384
385
  */
385
386
  static validateChromaticId(chromaticId) {
386
- if (Guard2.isInteger(chromaticId)) {
387
+ if (guard_exports.isInteger(chromaticId)) {
387
388
  return chromaticId;
388
389
  } else {
389
390
  throw new MusicError2(MusicErrorType2.Note, `Invalid chromaticId: ${chromaticId}`);
@@ -395,7 +396,7 @@ var _Note = class _Note {
395
396
  * @returns - Valid chromatic class, or throws.
396
397
  */
397
398
  static validatechromaticClass(chromaticClass) {
398
- if (Guard2.isIntegerBetween(chromaticClass, 0, 11)) {
399
+ if (guard_exports.isIntegerBetween(chromaticClass, 0, 11)) {
399
400
  return chromaticClass;
400
401
  } else {
401
402
  throw new MusicError2(MusicErrorType2.Note, `Invalid chromaticClass: ${chromaticClass}`);
@@ -419,7 +420,7 @@ var _Note = class _Note {
419
420
  * @returns - Valid octave or throws.
420
421
  */
421
422
  static validateOctave(octave) {
422
- if (Guard2.isInteger(octave)) {
423
+ if (guard_exports.isInteger(octave)) {
423
424
  return octave;
424
425
  } else {
425
426
  throw new MusicError2(MusicErrorType2.Note, `Invalid octave: ${octave}`);
@@ -431,7 +432,7 @@ var _Note = class _Note {
431
432
  * @returns - Valid accidental or thorws.
432
433
  */
433
434
  static validateAccidental(acc) {
434
- if (Guard2.isIntegerBetween(acc, -2, 2)) {
435
+ if (guard_exports.isIntegerBetween(acc, -2, 2)) {
435
436
  return acc;
436
437
  } else {
437
438
  throw new MusicError2(MusicErrorType2.Note, `Invalid accidental: ${acc}`);
@@ -485,11 +486,7 @@ __publicField(_Note, "noteCache", new UniMap());
485
486
  __publicField(_Note, "chromaticNoteCache", new UniMap());
486
487
  var Note = _Note;
487
488
 
488
- // src/theory/scale.ts
489
- import { Guard as Guard5, UniMap as UniMap3, SignedIndexArray, Utils as Utils3 } from "@tspro/ts-utils-lib";
490
-
491
489
  // src/theory/key-signature.ts
492
- import { Guard as Guard3 } from "@tspro/ts-utils-lib";
493
490
  import { MusicError as MusicError3, MusicErrorType as MusicErrorType3 } from "@tspro/web-music-score/core";
494
491
  function getAccidental(chromaticId, diatonicId) {
495
492
  let a = Note.getChromaticClass(chromaticId) - new Note(diatonicId, 0).chromaticClass;
@@ -510,7 +507,7 @@ function parseDegree(degree) {
510
507
  }
511
508
  let acc = (_b = Note.getAccidental((_a = m[1]) != null ? _a : "")) != null ? _b : 0;
512
509
  let deg = +m[2];
513
- if (!Guard3.isInteger(acc) || acc < -2 || acc > 2 || !Guard3.isInteger(deg) || deg < 1) {
510
+ if (!guard_exports.isInteger(acc) || acc < -2 || acc > 2 || !guard_exports.isInteger(deg) || deg < 1) {
514
511
  throw new MusicError3(MusicErrorType3.KeySignature, `Invalid degree: ${degree}`);
515
512
  } else {
516
513
  return { deg, acc };
@@ -546,7 +543,7 @@ var _KeySignature = class _KeySignature {
546
543
  __publicField(this, "naturalScaleNotes");
547
544
  __publicField(this, "accidentalByDiatonicClass");
548
545
  __publicField(this, "orderedAccidentedNotes");
549
- if (!Guard3.isEnumValue(mode, Mode)) {
546
+ if (!guard_exports.isEnumValue(mode, Mode)) {
550
547
  throw new MusicError3(MusicErrorType3.KeySignature, `Invalid mode: ${mode}`);
551
548
  }
552
549
  let intervals = [2, 2, 1, 2, 2, 2, 1];
@@ -664,9 +661,8 @@ __publicField(_KeySignature, "OrderOfFlats", "BEADGCF");
664
661
  var KeySignature = _KeySignature;
665
662
 
666
663
  // src/theory/interval.ts
667
- import { Guard as Guard4, UniMap as UniMap2, Utils as Utils2 } from "@tspro/ts-utils-lib";
668
664
  import { MusicError as MusicError4, MusicErrorType as MusicErrorType4 } from "@tspro/web-music-score/core";
669
- var IntervalQualityAbbrMap = new UniMap2([
665
+ var IntervalQualityAbbrMap = new UniMap([
670
666
  ["Major", "M"],
671
667
  ["minor", "m"],
672
668
  ["Perfect", "P"],
@@ -769,10 +765,10 @@ function validateIntervalQuality(q) {
769
765
  }
770
766
  }
771
767
  function formatQuantity(q) {
772
- if (!Guard4.isIntegerGte(q, 1)) {
768
+ if (!guard_exports.isIntegerGte(q, 1)) {
773
769
  throw new MusicError4(MusicErrorType4.InvalidArg, `Invalid interval quantity: ${q}`);
774
770
  } else {
775
- return Utils2.Math.toOrdinalNumber(q);
771
+ return utils_exports.Math.toOrdinalNumber(q);
776
772
  }
777
773
  }
778
774
  var InvalidIntervalException = class extends Error {
@@ -1014,7 +1010,7 @@ var Scale = class extends KeySignature {
1014
1010
  * @returns - Array of scale notes.
1015
1011
  */
1016
1012
  getScaleNotes(bottomNote, numOctaves) {
1017
- if (!Guard5.isIntegerGte(numOctaves, 1)) {
1013
+ if (!guard_exports.isIntegerGte(numOctaves, 1)) {
1018
1014
  throw new MusicError5(MusicErrorType5.Scale, `Invalid numOctaves: ${numOctaves}`);
1019
1015
  }
1020
1016
  let scaleNoteList = [];
@@ -1043,7 +1039,7 @@ var Scale = class extends KeySignature {
1043
1039
  let chromaticIds = this.getScaleNotes("C4", 1).map((note) => note.chromaticId);
1044
1040
  let steps = [];
1045
1041
  for (let i = 0; i < chromaticIds.length - 1; i++) {
1046
- steps.push(Utils3.Math.mod(chromaticIds[i + 1] - chromaticIds[i], 12));
1042
+ steps.push(utils_exports.Math.mod(chromaticIds[i + 1] - chromaticIds[i], 12));
1047
1043
  }
1048
1044
  return steps;
1049
1045
  }
@@ -1253,7 +1249,7 @@ var ScaleFactoryList = [
1253
1249
  function getScaleFactoryList() {
1254
1250
  return ScaleFactoryList;
1255
1251
  }
1256
- var ScaleFactoryMap = new UniMap3();
1252
+ var ScaleFactoryMap = new UniMap();
1257
1253
  ScaleFactoryList.forEach((factory) => {
1258
1254
  if (factory instanceof ScaleFactory) {
1259
1255
  ScaleFactoryMap.set(factory.getType(), factory);
@@ -1268,7 +1264,7 @@ function getScaleFactory(scaleType) {
1268
1264
  }
1269
1265
  }
1270
1266
  function validateScaleType(scaleType) {
1271
- if (Guard5.isEnumValue(scaleType, ScaleType)) {
1267
+ if (guard_exports.isEnumValue(scaleType, ScaleType)) {
1272
1268
  return scaleType;
1273
1269
  } else {
1274
1270
  throw new MusicError5(MusicErrorType5.Scale, `Invalid scaleType: "${scaleType}"`);
@@ -1328,7 +1324,7 @@ function getChordNoteByDegree(chordRootNote, degree) {
1328
1324
  return ks.getNoteByDegree(degree);
1329
1325
  }
1330
1326
  function removeNoteDuplicates(notes) {
1331
- return Utils4.Arr.removeDuplicates(notes, isEqualNote);
1327
+ return utils_exports.Arr.removeDuplicates(notes, isEqualNote);
1332
1328
  }
1333
1329
  var ChordInfoList = [
1334
1330
  // Power chord
@@ -1525,9 +1521,6 @@ var Chord = class _Chord {
1525
1521
  }
1526
1522
  };
1527
1523
 
1528
- // src/theory/guitar.ts
1529
- import { Guard as Guard6, LRUCache } from "@tspro/ts-utils-lib";
1530
-
1531
1524
  // src/theory/assets/tunings.json
1532
1525
  var tunings_default = {
1533
1526
  list: [
@@ -1785,7 +1778,7 @@ var Handedness = /* @__PURE__ */ ((Handedness2) => {
1785
1778
  })(Handedness || {});
1786
1779
  var DefaultHandedness = 0 /* RightHanded */;
1787
1780
  function validateHandedness(h) {
1788
- if (Guard6.isEnumValue(h, Handedness)) {
1781
+ if (guard_exports.isEnumValue(h, Handedness)) {
1789
1782
  return h;
1790
1783
  } else {
1791
1784
  throw new MusicError7(MusicErrorType7.InvalidArg, `Invalid handedness: ${h}`);
@@ -1809,7 +1802,7 @@ function getTuningStrings(tuningName) {
1809
1802
  throw new MusicError7(MusicErrorType7.InvalidArg, `Invalid tuningName: ${tuningName}`);
1810
1803
  }
1811
1804
  tuningStrings = tuningData.strings.slice().reverse().map((noteName) => Note.getNote(noteName));
1812
- if (!Guard6.isIntegerEq(tuningStrings.length, 6)) {
1805
+ if (!guard_exports.isIntegerEq(tuningStrings.length, 6)) {
1813
1806
  throw new MusicError7(MusicErrorType7.Unknown, `Tuning has ${tuningStrings.length} strings.`);
1814
1807
  }
1815
1808
  TuningStringsCache.set(tuningName, tuningStrings);
@@ -1818,7 +1811,6 @@ function getTuningStrings(tuningName) {
1818
1811
  }
1819
1812
 
1820
1813
  // src/theory/time-signature.ts
1821
- import { Guard as Guard7 } from "@tspro/ts-utils-lib";
1822
1814
  import { MusicError as MusicError8, MusicErrorType as MusicErrorType8 } from "@tspro/web-music-score/core";
1823
1815
  var TimeSignatures = /* @__PURE__ */ ((TimeSignatures2) => {
1824
1816
  TimeSignatures2["_2_4"] = "2/4";
@@ -1852,25 +1844,25 @@ var TimeSignature = class {
1852
1844
  /** Beam groups (e.g. [[2], [2]] or [[2, 2], [2, 2]] (first try as [[4], [4]])). */
1853
1845
  __publicField(this, "beamGroupSizes", []);
1854
1846
  let beamGrouping;
1855
- if (Guard7.isEnumValue(args[0], TimeSignatures)) {
1847
+ if (guard_exports.isEnumValue(args[0], TimeSignatures)) {
1856
1848
  let parts = args[0].split("/");
1857
1849
  this.beatCount = +parts[0];
1858
1850
  this.beatSize = +parts[1];
1859
- if (Guard7.isEnumValue(args[1], BeamGrouping)) {
1851
+ if (guard_exports.isEnumValue(args[1], BeamGrouping)) {
1860
1852
  beamGrouping = args[1];
1861
1853
  }
1862
- } else if (Guard7.isIntegerGte(args[0], 2) && Guard7.isIntegerGte(args[1], 2)) {
1854
+ } else if (guard_exports.isIntegerGte(args[0], 2) && guard_exports.isIntegerGte(args[1], 2)) {
1863
1855
  this.beatCount = args[0];
1864
1856
  this.beatSize = args[1];
1865
- if (Guard7.isEnumValue(args[2], BeamGrouping)) {
1857
+ if (guard_exports.isEnumValue(args[2], BeamGrouping)) {
1866
1858
  beamGrouping = args[2];
1867
1859
  }
1868
1860
  } else {
1869
1861
  throw new MusicError8(MusicErrorType8.Timesignature, `Invalid args: ${args}`);
1870
1862
  }
1871
- if (!Guard7.isIntegerGte(this.beatCount, 1)) {
1863
+ if (!guard_exports.isIntegerGte(this.beatCount, 1)) {
1872
1864
  throw new MusicError8(MusicErrorType8.Timesignature, `Invalid beatCount: ${this.beatCount}`);
1873
- } else if (!Guard7.isIntegerGte(this.beatSize, 1)) {
1865
+ } else if (!guard_exports.isIntegerGte(this.beatSize, 1)) {
1874
1866
  throw new MusicError8(MusicErrorType8.Timesignature, `Invalid beatSize: ${this.beatSize}`);
1875
1867
  }
1876
1868
  let { noteLength, ticks } = NoteLengthProps.create(this.beatSize);
@@ -1885,7 +1877,7 @@ var TimeSignature = class {
1885
1877
  } else if (this.is(3, 8)) {
1886
1878
  this.beamGroupSizes = [[3]];
1887
1879
  } else if (this.is(5, 8)) {
1888
- if (!Guard7.isUndefined(beamGrouping) && beamGrouping !== "2-3" /* _2_3 */ && beamGrouping !== "3-2" /* _3_2 */) {
1880
+ if (!guard_exports.isUndefined(beamGrouping) && beamGrouping !== "2-3" /* _2_3 */ && beamGrouping !== "3-2" /* _3_2 */) {
1889
1881
  throw new MusicError8(MusicErrorType8.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
1890
1882
  } else {
1891
1883
  this.beamGroupSizes = beamGrouping === "3-2" /* _3_2 */ ? [[3], [2]] : [[2], [3]];
@@ -1894,7 +1886,7 @@ var TimeSignature = class {
1894
1886
  } else if (this.is(6, 8)) {
1895
1887
  this.beamGroupSizes = [[3], [3]];
1896
1888
  } else if (this.is(7, 8)) {
1897
- if (!Guard7.isUndefined(beamGrouping) && beamGrouping !== "2-2-3" /* _2_2_3 */ && beamGrouping !== "3-2-2" /* _3_2_2 */) {
1889
+ if (!guard_exports.isUndefined(beamGrouping) && beamGrouping !== "2-2-3" /* _2_2_3 */ && beamGrouping !== "3-2-2" /* _3_2_2 */) {
1898
1890
  throw new MusicError8(MusicErrorType8.Timesignature, `Invalid beam grouping "${beamGrouping}" for time signature "${this.toString()}".`);
1899
1891
  } else {
1900
1892
  this.beamGroupSizes = beamGrouping === "3-2-2" /* _3_2_2 */ ? [[3], [2], [2]] : [[2], [2], [3]];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tspro/web-music-score",
3
- "version": "5.4.2",
3
+ "version": "5.5.0",
4
4
  "author": "PahkaSoft",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -105,18 +105,17 @@
105
105
  "dist/**/*.d.mts",
106
106
  "package.json"
107
107
  ],
108
- "dependencies": {
109
- "@tspro/ts-utils-lib": "^2.1.0",
110
- "tone": "^15.1.22"
111
- },
112
108
  "peerDependencies": {
113
109
  "react": "^18.0.0 || ^19.0.0"
114
110
  },
115
111
  "devDependencies": {
116
112
  "@tspro/tsup-plugin-inline-assets": "^1.0.0",
113
+ "@tspro/ts-utils-lib": "^2.2.0",
117
114
  "@types/react": "^18.0.0",
118
115
  "@types/react-dom": "^18.0.0",
116
+ "color-name-to-code": "^1.0.1",
119
117
  "rimraf": "^6.0.1",
118
+ "tone": "^15.1.22",
120
119
  "tsup": "^8.5.0",
121
120
  "typedoc": "^0.28.13",
122
121
  "typescript": "latest"
@@ -1,9 +0,0 @@
1
- /* WebMusicScore v5.4.2 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
-
6
- export {
7
- __publicField
8
- };
9
- //# sourceMappingURL=chunk-ROBXPR34.mjs.map