@dsebastien/music-notation 0.18.1 → 0.19.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/README.md +6 -1
- package/dist/THIRD_PARTY_LICENSES.md +208 -27
- package/dist/blocks/captions.d.ts +10 -0
- package/dist/blocks/renderers.d.ts +11 -0
- package/dist/cli.js +26 -46
- package/dist/export/image.d.ts +83 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3944 -3000
- package/dist/index.js.map +24 -19
- package/dist/music-notation.css +52 -2
- package/dist/music-notation.publish.min.js +88 -35
- package/dist/music-notation.tab.min.js +59 -9
- package/dist/playback/bar-parts.d.ts +8 -0
- package/dist/playback/controls.d.ts +5 -0
- package/dist/playback/copy-image.d.ts +21 -0
- package/dist/publish/auto.d.ts +5 -0
- package/dist/publish/index.js +3907 -3023
- package/dist/publish/index.js.map +24 -19
- package/dist/render/dom.d.ts +8 -0
- package/dist/render/root-mark.d.ts +29 -0
- package/dist/tab/index.d.ts +1 -1
- package/dist/tab/index.js +43 -6
- package/dist/tab/index.js.map +5 -5
- package/dist/theory/formula.d.ts +11 -0
- package/dist/voicings/index.js +1022 -756
- package/dist/voicings/index.js.map +8 -6
- package/package.json +11 -11
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** The colors of the image: the page's, or the library's for a light or a dark theme. */
|
|
2
|
+
export type ExportTheme = 'inherit' | 'light' | 'dark';
|
|
3
|
+
export interface SvgExportOptions {
|
|
4
|
+
/** `inherit` (default): the page's colors; `light` or `dark`: the library's for that theme. */
|
|
5
|
+
theme?: ExportTheme;
|
|
6
|
+
/** A CSS color under everything; none by default (transparent). */
|
|
7
|
+
background?: string;
|
|
8
|
+
/** Room around what is drawn, in CSS pixels; 8 by default. */
|
|
9
|
+
padding?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PngExportOptions extends Omit<SvgExportOptions, 'background'> {
|
|
12
|
+
/** Pixels per CSS pixel, 2 by default (lowered so no side passes 16384 px). */
|
|
13
|
+
scale?: number;
|
|
14
|
+
/** By default the page's background behind the element (white when it has none). */
|
|
15
|
+
background?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A box in CSS pixels. */
|
|
18
|
+
export interface Box {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
/** A line of text as the page lays it out. */
|
|
25
|
+
export interface TextLine {
|
|
26
|
+
text: string;
|
|
27
|
+
box: Box;
|
|
28
|
+
}
|
|
29
|
+
/** A computed style, read by property name. */
|
|
30
|
+
export interface StyleOf {
|
|
31
|
+
get(name: string): string;
|
|
32
|
+
}
|
|
33
|
+
/** What the composition reads from the page: the browser's layout, or a fake one in specs. */
|
|
34
|
+
export interface Measure {
|
|
35
|
+
box(el: Element): Box;
|
|
36
|
+
/** The lines of a text node; `pre` keeps its spaces. */
|
|
37
|
+
lines(text: Text, pre: boolean): TextLine[];
|
|
38
|
+
style(el: Element): StyleOf;
|
|
39
|
+
/** The share of a line box above the baseline, for a CSS font shorthand. */
|
|
40
|
+
ascent(font: string): number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The variables the library's colors come from, with the values of Obsidian's default light and
|
|
44
|
+
* dark themes (so `light` and `dark` look like a default vault). Set around a copy of the element,
|
|
45
|
+
* they win over the page's.
|
|
46
|
+
*/
|
|
47
|
+
export declare const THEME_VARIABLES: Record<'light' | 'dark', Record<string, string>>;
|
|
48
|
+
/** The background of a PNG in a light or a dark theme. */
|
|
49
|
+
export declare const THEME_BACKGROUND: {
|
|
50
|
+
readonly light: "#ffffff";
|
|
51
|
+
readonly dark: "#1e1e1e";
|
|
52
|
+
};
|
|
53
|
+
/** A font family list that ends with a generic family (an SVG image can't load web fonts). */
|
|
54
|
+
export declare function withGenericFamily(family: string, generic?: string): string;
|
|
55
|
+
/** Whether a computed color paints anything. */
|
|
56
|
+
export declare function paints(color: string): boolean;
|
|
57
|
+
/** The layout of the page the element is in. */
|
|
58
|
+
export declare function pageMeasure(doc: Document): Measure;
|
|
59
|
+
/** The room around what is drawn, by default. */
|
|
60
|
+
export declare const PADDING = 8;
|
|
61
|
+
/**
|
|
62
|
+
* The composed image of `el` (a drawing, a block, any element holding drawings) as the page lays
|
|
63
|
+
* it out, through `measure`, cropped to what it draws plus `padding`. Exported for specs and apps
|
|
64
|
+
* with their own layout.
|
|
65
|
+
*/
|
|
66
|
+
export declare function composeSvg(el: Element, measure: Measure, background?: string, padding?: number): {
|
|
67
|
+
svg: SVGElement;
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* A standalone SVG of `el`: a drawing (`svg.mn-svg`) or any element holding drawings and text (a
|
|
73
|
+
* block, a row, a captioned figure, a chart), laid out as on the page, every style inlined.
|
|
74
|
+
*/
|
|
75
|
+
export declare function toSvgString(el: Element, options?: SvgExportOptions): string;
|
|
76
|
+
/** The page's background behind `el`: its own or an ancestor's, else white. */
|
|
77
|
+
export declare function backgroundOf(el: Element, theme?: ExportTheme): string;
|
|
78
|
+
/** The largest side a canvas takes in every browser. */
|
|
79
|
+
export declare const MAX_SIDE = 16384;
|
|
80
|
+
/** `scale`, lowered so neither side of the image passes `MAX_SIDE` pixels. */
|
|
81
|
+
export declare function fitScale(width: number, height: number, scale?: number): number;
|
|
82
|
+
/** A PNG of `el` (see `toSvgString`), at `scale` (2 by default), on the page's background. */
|
|
83
|
+
export declare function toPng(el: Element, options?: PngExportOptions): Promise<Blob>;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { generateVoicings, fingerVoicing, voicingShape, MAX_GENERATED_STRINGS, t
|
|
|
8
8
|
export { sequenceOf, scaleRun, lengthOf, lightPlayer, pluckedString, pianoTone, DEFAULT_SEQUENCE, DEFAULT_STRUM, type NoteEvent, type NotePlayer, type PluckOptions, type PlayHandle, type PlayKind, type Sound, type SequenceOptions } from './playback/player.js';
|
|
9
9
|
export { attachPlayback, type PlayOptions, type TimedBar } from './playback/controls.js';
|
|
10
10
|
export { volumeChanged } from './playback/live-volume.js';
|
|
11
|
+
export { attachCopy } from './playback/copy-image.js';
|
|
12
|
+
export { toSvgString, toPng, type ExportTheme, type SvgExportOptions, type PngExportOptions } from './export/image.js';
|
|
11
13
|
export { followNotes, noteTargets, PLAYING_CLASS, START_WAIT, type Follower } from './playback/follow.js';
|
|
12
14
|
export { transition, smoothProgression, type TransitionStep, type TransitionOptions, type ProgressionStep, type ProgressionOptions } from './chord/transitions.js';
|
|
13
15
|
export { fingeringInWords, type GuitarFingering, type PianoFingering } from './chord/fingering-words.js';
|
|
@@ -17,6 +19,9 @@ export { pianoVoicing, pianoPitches, triadFingering, type PianoVoicing, type Pia
|
|
|
17
19
|
export { standardScaleFingering, scaleFingers, type ScaleHand } from './keyboard/scale-fingering.js';
|
|
18
20
|
export { renderFretboard, type FretboardOptions } from './fretboard/fretboard.js';
|
|
19
21
|
export { NAMINGS, parseNaming, namingOf, toLetters, lettersInBlock, quoteAsWritten, noteInNaming, chordInNaming, shownText, withNaming, type Naming, type BlockReading } from './theory/naming.js';
|
|
22
|
+
export { ROOT_MARKS, rootMarkOf, parseRootMark, withRootMark, type RootMark } from './render/root-mark.js';
|
|
23
|
+
export { chordFormula, scaleFormula } from './theory/formula.js';
|
|
24
|
+
export { descriptionOf } from './render/dom.js';
|
|
20
25
|
export { attachPick, type Pick, type PickAt, type PickLayer, type PickOptions, type PickResult } from './render/pick.js';
|
|
21
26
|
export { parseTuning } from './fretboard/tuning.js';
|
|
22
27
|
export { parseChordPro, parseLyrics, type Song, type Section, type Line, type Segment, type ChordDefinition } from './chords/chordpro.js';
|