@tspro/web-music-score 5.3.0 → 5.4.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/CHANGELOG.md +18 -0
- package/LICENSE +1 -1
- package/README.md +6 -4
- package/dist/audio/index.d.mts +1 -1
- package/dist/audio/index.d.ts +1 -1
- package/dist/audio/index.js +3 -3
- package/dist/audio/index.mjs +6 -6
- package/dist/audio-cg/index.js +1 -1
- package/dist/audio-cg/index.mjs +3 -3
- package/dist/audio-synth/index.js +1 -1
- package/dist/audio-synth/index.mjs +3 -3
- package/dist/{chunk-PMDIUO22.mjs → chunk-5I5KENEC.mjs} +2 -2
- package/dist/chunk-6P4ECBUH.mjs +37 -0
- package/dist/{chunk-ZBA5XLYR.mjs → chunk-A5SMODAT.mjs} +21 -21
- package/dist/{chunk-C6UQDKWU.mjs → chunk-U2ACCEHX.mjs} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +6 -31
- package/dist/{guitar-BsSayRsH.d.ts → guitar-CNOxM4ZK.d.ts} +1 -1
- package/dist/{guitar-DdexKdN6.d.mts → guitar-DXlB-9vK.d.mts} +1 -1
- package/dist/iife/audio-cg.global.js +1 -1
- package/dist/iife/index.global.js +18 -11
- package/dist/{music-objects-BGiRQIXW.d.mts → music-objects-DYMqx839.d.mts} +66 -260
- package/dist/{music-objects-Ih9vCl4p.d.ts → music-objects-DumXKWJp.d.ts} +66 -260
- package/dist/{note-eA2xPPiG.d.mts → note-RVXvpfyV.d.mts} +13 -1
- package/dist/{note-CgCIBwvR.d.ts → note-RVXvpfyV.d.ts} +14 -2
- package/dist/pieces/index.d.mts +3 -3
- package/dist/pieces/index.d.ts +3 -3
- package/dist/pieces/index.js +1 -1
- package/dist/pieces/index.mjs +2 -2
- package/dist/react-ui/index.d.mts +9 -9
- package/dist/react-ui/index.d.ts +9 -9
- package/dist/react-ui/index.js +12 -14
- package/dist/react-ui/index.mjs +14 -16
- package/dist/{scale-CBW4eTz7.d.ts → scale-C8gHC448.d.mts} +3 -3
- package/dist/{scale-DQP3b9Zx.d.mts → scale-CUYFBo-8.d.ts} +3 -3
- package/dist/score/index.d.mts +232 -6
- package/dist/score/index.d.ts +232 -6
- package/dist/score/index.js +1122 -975
- package/dist/score/index.mjs +978 -861
- package/dist/{tempo-dkctPkCS.d.mts → tempo-BlCGZuYg.d.mts} +14 -2
- package/dist/{tempo-DMt3iwz9.d.ts → tempo-DwuZsv2T.d.ts} +14 -2
- package/dist/theory/index.d.mts +6 -6
- package/dist/theory/index.d.ts +6 -6
- package/dist/theory/index.js +88 -86
- package/dist/theory/index.mjs +85 -81
- package/package.json +5 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
1
|
+
/* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
import {
|
|
3
3
|
__publicField
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U2ACCEHX.mjs";
|
|
5
5
|
|
|
6
6
|
// src/theory/rhythm.ts
|
|
7
|
-
import { Utils } from "@tspro/ts-utils-lib";
|
|
7
|
+
import { Guard, IndexArray, UniMap, Utils } from "@tspro/ts-utils-lib";
|
|
8
8
|
import { MusicError, MusicErrorType } from "@tspro/web-music-score/core";
|
|
9
9
|
var MaxTupletRatioValue = 12;
|
|
10
10
|
var TicksMultiplier = 12 * 11 * 9 * 7 * 5;
|
|
@@ -47,8 +47,11 @@ var NoteLength = /* @__PURE__ */ ((NoteLength2) => {
|
|
|
47
47
|
NoteLength2["SixtyFourthTriplet"] = "64t";
|
|
48
48
|
return NoteLength2;
|
|
49
49
|
})(NoteLength || {});
|
|
50
|
+
function isNoteLength(noteLength) {
|
|
51
|
+
return Guard.isEnumValue(noteLength, NoteLength);
|
|
52
|
+
}
|
|
50
53
|
function validateNoteLength(noteLength) {
|
|
51
|
-
if (
|
|
54
|
+
if (isNoteLength(noteLength)) {
|
|
52
55
|
return noteLength;
|
|
53
56
|
} else {
|
|
54
57
|
throw new MusicError(MusicErrorType.InvalidArg, `Invalid noteLength: ${noteLength}`);
|
|
@@ -95,11 +98,7 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
95
98
|
* @returns - Note length props.
|
|
96
99
|
*/
|
|
97
100
|
static get(noteLength) {
|
|
98
|
-
|
|
99
|
-
if (!p) {
|
|
100
|
-
this.cache.set(noteLength, p = new _NoteLengthProps(noteLength));
|
|
101
|
-
}
|
|
102
|
-
return p;
|
|
101
|
+
return this.cache.getOrCreate(noteLength, () => new _NoteLengthProps(noteLength));
|
|
103
102
|
}
|
|
104
103
|
/**
|
|
105
104
|
* Create note length props.
|
|
@@ -109,7 +108,7 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
109
108
|
*/
|
|
110
109
|
static create(noteLength, dotCount = 0) {
|
|
111
110
|
let noteSize = typeof noteLength === "number" ? noteLength : this.get(noteLength).noteSize;
|
|
112
|
-
return this.get(noteSize + (
|
|
111
|
+
return this.get(noteSize + (Guard.isIntegerGte(dotCount, 1) ? ".".repeat(dotCount) : "n"));
|
|
113
112
|
}
|
|
114
113
|
/**
|
|
115
114
|
* Compare note lengths/sizes. Whole (1) > half (2) > quarter (4), etc.
|
|
@@ -140,10 +139,13 @@ var _NoteLengthProps = class _NoteLengthProps {
|
|
|
140
139
|
__publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
|
|
141
140
|
/** Shortest note size (e.g. 64 = sixtyfourth note). */
|
|
142
141
|
__publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
|
|
143
|
-
__publicField(_NoteLengthProps, "cache",
|
|
142
|
+
__publicField(_NoteLengthProps, "cache", new UniMap());
|
|
144
143
|
var NoteLengthProps = _NoteLengthProps;
|
|
144
|
+
function isTupletRatio(tupletRatio) {
|
|
145
|
+
return Guard.isObject(tupletRatio) && Guard.isIntegerBetween(tupletRatio.parts, 2, MaxTupletRatioValue) && Guard.isIntegerBetween(tupletRatio.inTimeOf, 2, MaxTupletRatioValue);
|
|
146
|
+
}
|
|
145
147
|
function validateTupletRatio(tupletRatio) {
|
|
146
|
-
if (
|
|
148
|
+
if (isTupletRatio(tupletRatio)) {
|
|
147
149
|
return tupletRatio;
|
|
148
150
|
} else {
|
|
149
151
|
throw new MusicError(MusicErrorType.Note, `Invalid tupletRatio ${JSON.stringify(tupletRatio)}`);
|
|
@@ -183,7 +185,7 @@ var _RhythmProps = class _RhythmProps {
|
|
|
183
185
|
this.dotCount = dotCount != null ? dotCount : p.dotCount;
|
|
184
186
|
this.hasStem = p.hasStem;
|
|
185
187
|
this.isSolidNoteHead = p.isSolid;
|
|
186
|
-
if (
|
|
188
|
+
if (Guard.isObject(tupletRatio)) {
|
|
187
189
|
this.tupletRatio = validateTupletRatio(tupletRatio);
|
|
188
190
|
} else if (p.isTriplet) {
|
|
189
191
|
this.tupletRatio = Tuplet.Triplet;
|
|
@@ -222,11 +224,7 @@ var _RhythmProps = class _RhythmProps {
|
|
|
222
224
|
if (dotCount !== void 0 || tupletRatio !== void 0) {
|
|
223
225
|
return new _RhythmProps(noteLength, dotCount, tupletRatio);
|
|
224
226
|
} else {
|
|
225
|
-
|
|
226
|
-
if (!rhythmProps) {
|
|
227
|
-
this.cache.set(noteLength, rhythmProps = new _RhythmProps(noteLength));
|
|
228
|
-
}
|
|
229
|
-
return rhythmProps;
|
|
227
|
+
return this.cache.getOrCreate(noteLength, () => new _RhythmProps(noteLength));
|
|
230
228
|
}
|
|
231
229
|
}
|
|
232
230
|
/**
|
|
@@ -248,16 +246,18 @@ var _RhythmProps = class _RhythmProps {
|
|
|
248
246
|
return a.ticks === b.ticks;
|
|
249
247
|
}
|
|
250
248
|
};
|
|
251
|
-
__publicField(_RhythmProps, "NoteSymbolMap",
|
|
252
|
-
__publicField(_RhythmProps, "cache",
|
|
249
|
+
__publicField(_RhythmProps, "NoteSymbolMap", new IndexArray([[1, "\u{1D15D}"], [2, "\u{1D15E}"], [4, "\u{1D15F}"], [8, "\u{1D160}"], [16, "\u{1D161}"], [32, "\u{1D162}"], [64, "\u{1D163}"], [128, "\u{1D164}"]]));
|
|
250
|
+
__publicField(_RhythmProps, "cache", new UniMap());
|
|
253
251
|
var RhythmProps = _RhythmProps;
|
|
254
252
|
|
|
255
253
|
export {
|
|
256
254
|
NoteLength,
|
|
255
|
+
isNoteLength,
|
|
257
256
|
validateNoteLength,
|
|
258
257
|
NoteLengthProps,
|
|
258
|
+
isTupletRatio,
|
|
259
259
|
validateTupletRatio,
|
|
260
260
|
Tuplet,
|
|
261
261
|
RhythmProps
|
|
262
262
|
};
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-A5SMODAT.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
1
|
+
/* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -6,4 +6,4 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
6
6
|
export {
|
|
7
7
|
__publicField
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-U2ACCEHX.mjs.map
|
package/dist/core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
1
|
+
/* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -63,7 +63,7 @@ function init() {
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
initialized = true;
|
|
66
|
-
console.log("%cWebMusicScore v5.
|
|
66
|
+
console.log("%cWebMusicScore v5.4.1 (cjs) initialized.", "background: black; color: white; padding: 2px;");
|
|
67
67
|
}
|
|
68
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
69
|
0 && (module.exports = {
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
/* WebMusicScore v5.
|
|
1
|
+
/* WebMusicScore v5.4.1 | (c) 2023-2025 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var MusicErrorType = /* @__PURE__ */ ((MusicErrorType2) => {
|
|
8
|
-
MusicErrorType2[MusicErrorType2["Unknown"] = 0] = "Unknown";
|
|
9
|
-
MusicErrorType2[MusicErrorType2["InvalidArg"] = 1] = "InvalidArg";
|
|
10
|
-
MusicErrorType2[MusicErrorType2["Note"] = 2] = "Note";
|
|
11
|
-
MusicErrorType2[MusicErrorType2["Scale"] = 3] = "Scale";
|
|
12
|
-
MusicErrorType2[MusicErrorType2["KeySignature"] = 4] = "KeySignature";
|
|
13
|
-
MusicErrorType2[MusicErrorType2["Timesignature"] = 5] = "Timesignature";
|
|
14
|
-
MusicErrorType2[MusicErrorType2["Score"] = 6] = "Score";
|
|
15
|
-
MusicErrorType2[MusicErrorType2["Audio"] = 7] = "Audio";
|
|
16
|
-
return MusicErrorType2;
|
|
17
|
-
})(MusicErrorType || {});
|
|
18
|
-
function formatType(type) {
|
|
19
|
-
return type === void 0 ? "" : `[${MusicErrorType[type]}] `;
|
|
20
|
-
}
|
|
21
|
-
var MusicError = class extends Error {
|
|
22
|
-
constructor(...args) {
|
|
23
|
-
const [type, msg] = args.length === 1 ? [0 /* Unknown */, args[0]] : args;
|
|
24
|
-
super(formatType(type) + msg);
|
|
25
|
-
/** Music error type. */
|
|
26
|
-
__publicField(this, "type");
|
|
27
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
28
|
-
this.name = "MusicError";
|
|
29
|
-
this.type = type;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
3
|
+
MusicError,
|
|
4
|
+
MusicErrorType
|
|
5
|
+
} from "../chunk-6P4ECBUH.mjs";
|
|
6
|
+
import "../chunk-U2ACCEHX.mjs";
|
|
32
7
|
|
|
33
8
|
// src/core/index.ts
|
|
34
9
|
var initialized = false;
|
|
@@ -37,7 +12,7 @@ function init() {
|
|
|
37
12
|
return;
|
|
38
13
|
}
|
|
39
14
|
initialized = true;
|
|
40
|
-
console.log("%cWebMusicScore v5.
|
|
15
|
+
console.log("%cWebMusicScore v5.4.1 (esm) initialized.", "background: black; color: white; padding: 2px;");
|
|
41
16
|
}
|
|
42
17
|
export {
|
|
43
18
|
MusicError,
|