@dsebastien/music-notation 0.13.0 → 0.15.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.
- package/README.md +3 -2
- package/dist/blocks/renderers.d.ts +11 -0
- package/dist/fretboard/fretboard.d.ts +5 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6020 -5313
- package/dist/index.js.map +20 -17
- package/dist/keyboard/keyboard.d.ts +5 -0
- package/dist/music-notation.css +152 -50
- package/dist/music-notation.publish.min.js +179 -77
- package/dist/music-notation.tab.min.js +159 -57
- package/dist/playback/bar-parts.d.ts +46 -0
- package/dist/playback/block-bar.d.ts +80 -0
- package/dist/playback/controls.d.ts +32 -9
- package/dist/playback/progression-bar.d.ts +3 -2
- package/dist/playback/strum-bar.d.ts +4 -4
- package/dist/publish/index.js +5849 -5246
- package/dist/publish/index.js.map +20 -17
- package/dist/render/dom.d.ts +2 -0
- package/dist/render/pick.d.ts +82 -0
- package/dist/render/render-block.d.ts +3 -0
- package/dist/tab/index.js +5 -1
- package/dist/tab/index.js.map +4 -4
- package/dist/theory/note-set.d.ts +2 -0
- package/dist/voicings/index.js +5 -1
- package/dist/voicings/index.js.map +4 -4
- package/package.json +1 -1
package/dist/render/dom.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export declare function dotLabel(doc: Document, text: string, point: [number, nu
|
|
|
16
16
|
export declare function svgLine(doc: Document, [x1, y1]: [number, number], [x2, y2]: [number, number], cls: string): SVGElement;
|
|
17
17
|
/** An HTML element with a class and optional text. */
|
|
18
18
|
export declare function html<K extends keyof HTMLElementTagNameMap>(doc: Document, tag: K, cls?: string, text?: string): HTMLElementTagNameMap[K];
|
|
19
|
+
/** An id unique on the page (a counter behind this copy's random prefix). */
|
|
20
|
+
export declare const uniqueId: () => string;
|
|
19
21
|
/**
|
|
20
22
|
* A root <svg> sized by its viewBox, scaling with the container up to its natural width.
|
|
21
23
|
*
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type PlayOptions } from '../playback/controls.js';
|
|
2
|
+
/** A target as the app sees it: where it is and what it sounds. */
|
|
3
|
+
export interface Pick {
|
|
4
|
+
/** 1 is the highest string, as on the dots; null on keyboards. */
|
|
5
|
+
string: number | null;
|
|
6
|
+
fret: number | null;
|
|
7
|
+
/** The pitch class as the drawing spells it ("C", "Bb"). */
|
|
8
|
+
note: string;
|
|
9
|
+
/** MIDI. */
|
|
10
|
+
pitch: number;
|
|
11
|
+
/** The target (`rect.mn-pick`). */
|
|
12
|
+
element: SVGElement;
|
|
13
|
+
/** A click, or Space or Enter on the focused target. */
|
|
14
|
+
via: 'pointer' | 'keyboard';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A target by its place on a fretboard, or every target of a pitch. A pick may be passed as it is:
|
|
18
|
+
* its place wins (its own target), and on keyboards its pitch is its key.
|
|
19
|
+
*/
|
|
20
|
+
export type PickAt = {
|
|
21
|
+
string: number;
|
|
22
|
+
fret: number;
|
|
23
|
+
} | {
|
|
24
|
+
pitch: number;
|
|
25
|
+
string?: number | null;
|
|
26
|
+
fret?: number | null;
|
|
27
|
+
};
|
|
28
|
+
export type PickResult = 'right' | 'wrong';
|
|
29
|
+
export interface PickOptions {
|
|
30
|
+
/** Called with each pick and the layer (to mark it). A handler that throws is ignored. */
|
|
31
|
+
onPick?: (pick: Pick, layer: PickLayer) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Plays each pick's note for 1.5 s (off by default): the play options' player, volume
|
|
34
|
+
* (read at each pick) and sound (guitar on fretboards, piano on keyboards by default). A new
|
|
35
|
+
* pick stops the note before. Through `renderBlock`, `true` uses the block's `play` options.
|
|
36
|
+
*/
|
|
37
|
+
play?: boolean | PlayOptions;
|
|
38
|
+
}
|
|
39
|
+
/** How long a picked note sounds, in seconds (as a click on a note of a playable diagram). */
|
|
40
|
+
export declare const PICK_NOTE = 1.5;
|
|
41
|
+
export interface PickLayer {
|
|
42
|
+
/** The diagram. */
|
|
43
|
+
readonly element: Element;
|
|
44
|
+
/** Every target, in document order (the highest string's frets first; white keys, then black). */
|
|
45
|
+
targets(): Pick[];
|
|
46
|
+
/** Marks the target(s) at `at` right or wrong (replacing a mark); false when none is there. */
|
|
47
|
+
mark(at: PickAt, result: PickResult): boolean;
|
|
48
|
+
/** Takes the mark(s) at `at` away; false when none was there. */
|
|
49
|
+
unmark(at: PickAt): boolean;
|
|
50
|
+
/** Takes every mark away. */
|
|
51
|
+
clear(): void;
|
|
52
|
+
/** Focuses the target at `at` (the first one there), else the layer's tab stop. */
|
|
53
|
+
focus(at?: PickAt): boolean;
|
|
54
|
+
/** Stops picking: listeners off, marks, names and tab stops removed. */
|
|
55
|
+
destroy(): void;
|
|
56
|
+
}
|
|
57
|
+
export interface PickTargetData {
|
|
58
|
+
pitch: number;
|
|
59
|
+
note: string;
|
|
60
|
+
/** 1 is the highest string (fretboards). */
|
|
61
|
+
string?: number;
|
|
62
|
+
fret?: number;
|
|
63
|
+
/** The place, for screen readers ("String 5, fret 3"): never the note, so it gives no answer away. */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Where a mark goes, and its radius. */
|
|
66
|
+
mark: [number, number];
|
|
67
|
+
radius: number;
|
|
68
|
+
}
|
|
69
|
+
/** The layer's group, drawn last (above the dots and labels). */
|
|
70
|
+
export declare function pickGroup(doc: Document): SVGElement;
|
|
71
|
+
/** One target: a transparent rectangle that takes clicks, without the stylesheet too. */
|
|
72
|
+
export declare function pickTarget(doc: Document, area: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
}, data: PickTargetData): SVGElement;
|
|
78
|
+
/**
|
|
79
|
+
* Makes a diagram's pick layer live (see `PickLayer`). A diagram without one gets a layer with no
|
|
80
|
+
* targets; a diagram whose layer is live gets that layer (its first options).
|
|
81
|
+
*/
|
|
82
|
+
export declare function attachPick(diagram: Element, options?: PickOptions): PickLayer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Render a notation block into a host element. Never throws: errors render inline. */
|
|
2
2
|
import { type NotationLanguage, type RenderOptions } from '../blocks/renderers.js';
|
|
3
|
+
import { type PickLayer } from './pick.js';
|
|
3
4
|
export declare const LANGUAGES: NotationLanguage[];
|
|
4
5
|
export declare const isNotationLanguage: (language: string) => language is NotationLanguage;
|
|
5
6
|
/** More diagrams than this in one block is an error, so a page stays quick to draw. */
|
|
@@ -12,6 +13,8 @@ export interface RenderResult {
|
|
|
12
13
|
error: string | null;
|
|
13
14
|
/** Removes what was rendered. */
|
|
14
15
|
destroy(): void;
|
|
16
|
+
/** The live pick layers (the `pick` option), one per diagram that has one, in page order. */
|
|
17
|
+
picks: PickLayer[];
|
|
15
18
|
}
|
|
16
19
|
export declare function renderBlock(language: NotationLanguage, source: string, host: HTMLElement, given?: RenderOptions): RenderResult;
|
|
17
20
|
/** Properties as given, or what a function of the block's element returns; null when it fails. */
|
package/dist/tab/index.js
CHANGED
|
@@ -44,6 +44,7 @@ function html(doc, tag, cls, text) {
|
|
|
44
44
|
}
|
|
45
45
|
var NAME_PREFIX = `mn-name-${Math.random().toString(36).slice(2, 8)}-`;
|
|
46
46
|
var names = 0;
|
|
47
|
+
var uniqueId = () => `${NAME_PREFIX}${++names}`;
|
|
47
48
|
function svgRoot(doc, width, height, cls, label) {
|
|
48
49
|
const id = `${NAME_PREFIX}${++names}`;
|
|
49
50
|
const title = svg(doc, "title", { class: "mn-name", id });
|
|
@@ -1278,6 +1279,9 @@ function intervalFrom(root, name) {
|
|
|
1278
1279
|
const m = /^(\d+)([PMmdA]+)$/.exec(spelled);
|
|
1279
1280
|
return m && m[1] !== "1" && m[1] !== "8" ? spelled : PLAIN_INTERVALS[semitones];
|
|
1280
1281
|
}
|
|
1282
|
+
function emptyNoteSet(title = "no notes") {
|
|
1283
|
+
return { title, members: [], root: null, pitches: null, preferFlats: false, list: true };
|
|
1284
|
+
}
|
|
1281
1285
|
function listNoteSet(text, root) {
|
|
1282
1286
|
const tokens = text.split(/[\s,]+/).filter(Boolean);
|
|
1283
1287
|
if (!tokens.length)
|
|
@@ -2105,5 +2109,5 @@ export {
|
|
|
2105
2109
|
textTabToAlphaTex
|
|
2106
2110
|
};
|
|
2107
2111
|
|
|
2108
|
-
//# debugId=
|
|
2112
|
+
//# debugId=160F69C2F95D7AC964756E2164756E21
|
|
2109
2113
|
//# sourceMappingURL=index.js.map
|