@dsebastien/music-notation 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +107 -2
- package/dist/THIRD_PARTY_LICENSES.md +57 -0
- package/dist/blocks/block-source.d.ts +12 -0
- package/dist/blocks/note-set-field.d.ts +8 -0
- package/dist/blocks/renderers.d.ts +16 -0
- package/dist/chord/guitar.d.ts +24 -0
- package/dist/chords/chart.d.ts +6 -0
- package/dist/chords/chordpro.d.ts +39 -0
- package/dist/chunks/index-b71brbpf.js +1028 -0
- package/dist/chunks/index-b71brbpf.js.map +23 -0
- package/dist/chunks/index-y8a78sfx.js +50 -0
- package/dist/chunks/index-y8a78sfx.js.map +10 -0
- package/dist/fretboard/fretboard.d.ts +10 -0
- package/dist/fretboard/tuning.d.ts +5 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +281 -0
- package/dist/index.js.map +10 -0
- package/dist/keyboard/keyboard.d.ts +14 -0
- package/dist/music-notation.css +190 -0
- package/dist/music-notation.publish.min.js +192 -0
- package/dist/publish/auto.d.ts +15 -0
- package/dist/publish/index.d.ts +5 -0
- package/dist/publish/index.js +81 -0
- package/dist/publish/index.js.map +10 -0
- package/dist/render/dom.d.ts +12 -0
- package/dist/render/render-block.d.ts +14 -0
- package/dist/styles.d.ts +4 -0
- package/dist/theory/chord-symbol.d.ts +10 -0
- package/dist/theory/note-set.d.ts +32 -0
- package/dist/theory/pitch.d.ts +27 -0
- package/dist/theory/transpose.d.ts +9 -0
- package/dist/voicings/index.d.ts +6 -0
- package/dist/voicings/index.js +78 -0
- package/dist/voicings/index.js.map +10 -0
- package/package.json +131 -5
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/voicings/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Guitar voicings for chord symbols, from @tombatossals/chords-db (MIT, ~2,000 voicings). A\n * separate entry point: the data adds about 230 KB, so only consumers that want it pay for it.\n */\nimport db from '@tombatossals/chords-db/lib/guitar.json'\nimport type { FrettedVoicing } from '../chord/guitar.js'\nimport { chromaOf, splitChordSymbol } from '../theory/pitch.js'\n\n/** Finds the n-th voicing (0-based) of a chord symbol; null when unknown. */\nexport type VoicingLookup = (symbol: string, index: number) => FrettedVoicing | null\n\n/** The database's own key names: sharps for C# and F#, flats elsewhere. */\nconst DB_KEYS = ['C', 'Csharp', 'D', 'Eb', 'E', 'F', 'Fsharp', 'G', 'Ab', 'A', 'Bb', 'B']\n\n/** The database's bass names in slash-chord suffixes. */\nconst DB_BASSES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B']\n\n/** Chord-symbol suffix → database suffix, for the spellings the database doesn't use. */\nconst SUFFIX_ALIASES: Record<string, string> = {\n '': 'major',\n 'M': 'major',\n 'maj': 'major',\n 'm': 'minor',\n 'min': 'minor',\n '-': 'minor',\n '°': 'dim',\n '°7': 'dim7',\n '+': 'aug',\n 'sus': 'sus4',\n 'M7': 'maj7',\n 'Δ': 'maj7',\n 'Δ7': 'maj7',\n 'min7': 'm7',\n '-7': 'm7',\n 'ø': 'm7b5',\n 'ø7': 'm7b5',\n 'm7-5': 'm7b5',\n 'add2': 'add9',\n '6/9': '69',\n 'mM7': 'mmaj7',\n 'mMaj7': 'mmaj7',\n 'm(maj7)': 'mmaj7',\n '-(maj7)': 'mmaj7'\n}\n\nexport const lookupGuitarVoicing: VoicingLookup = (symbol, index) => {\n const parts = splitChordSymbol(symbol)\n if (!parts) return null\n const chroma = chromaOf(parts.root)\n if (chroma === null) return null\n const suffix = Object.prototype.hasOwnProperty.call(SUFFIX_ALIASES, parts.suffix)\n ? SUFFIX_ALIASES[parts.suffix]!\n : parts.suffix\n // Slash chords are stored as \"/E\" (major) and \"m/B\" (minor) suffixes.\n const bassChroma = parts.bass ? chromaOf(parts.bass) : null\n const bass = bassChroma === null ? null : DB_BASSES[bassChroma]!\n const wanted = bass\n ? `${suffix === 'major' ? '' : suffix === 'minor' ? 'm' : suffix}/${bass}`\n : suffix\n const chords = db.chords[DB_KEYS[chroma]!] ?? []\n const chord = chords.find((c) => c.suffix === wanted)\n const position = chord?.positions[index]\n if (!position) return null\n const absolute = (f: number) => (f < 0 ? null : f === 0 ? 0 : f + position.baseFret - 1)\n return {\n frets: position.frets.map(absolute),\n fingers: position.fingers.map((f) => (f > 0 ? String(f) : null)),\n baseFret: position.baseFret\n }\n}\n\n/** How many voicings the database has for a symbol. */\nexport function voicingCount(symbol: string): number {\n let n = 0\n while (lookupGuitarVoicing(symbol, n)) n++\n return n\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;AAYA,IAAM,UAAU,CAAC,KAAK,UAAU,KAAK,MAAM,KAAK,KAAK,UAAU,KAAK,MAAM,KAAK,MAAM,GAAG;AAGxF,IAAM,YAAY,CAAC,KAAK,MAAM,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG;AAGlF,IAAM,iBAAyC;AAAA,EAC3C,IAAI;AAAA,EACJ,GAAK;AAAA,EACL,KAAO;AAAA,EACP,GAAK;AAAA,EACL,KAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAO;AAAA,EACP,IAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAQ;AAAA,EACR,OAAO;AAAA,EACP,KAAO;AAAA,EACP,OAAS;AAAA,EACT,WAAW;AAAA,EACX,WAAW;AACf;AAEO,IAAM,sBAAqC,CAAC,QAAQ,UAAU;AAAA,EACjE,MAAM,QAAQ,iBAAiB,MAAM;AAAA,EACrC,IAAI,CAAC;AA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
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Chord diagrams, piano keyboards, fretboards and ChordPro charts rendered as SVG and HTML, with no framework. Works in Obsidian, on Obsidian Publish and on any web page.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Sébastien Dubois",
|
|
7
|
+
"email": "developassion.sprl@gmail.com",
|
|
8
|
+
"url": "https://dsebastien.net"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"music",
|
|
12
|
+
"notation",
|
|
13
|
+
"chord",
|
|
14
|
+
"chord-diagram",
|
|
15
|
+
"guitar",
|
|
16
|
+
"piano",
|
|
17
|
+
"fretboard",
|
|
18
|
+
"chordpro",
|
|
19
|
+
"svg",
|
|
20
|
+
"obsidian"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/dsebastien/music-notation.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/dsebastien/music-notation/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/dsebastien/music-notation",
|
|
31
|
+
"funding": "https://github.com/sponsors/dsebastien",
|
|
32
|
+
"type": "module",
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"./dist/music-notation.publish.min.js",
|
|
35
|
+
"*.css"
|
|
36
|
+
],
|
|
37
|
+
"main": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"typesVersions": {
|
|
40
|
+
"*": {
|
|
41
|
+
"voicings": [
|
|
42
|
+
"./dist/voicings/index.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"publish": [
|
|
45
|
+
"./dist/publish/index.d.ts"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"exports": {
|
|
50
|
+
".": {
|
|
51
|
+
"types": "./dist/index.d.ts",
|
|
52
|
+
"import": "./dist/index.js",
|
|
53
|
+
"default": "./dist/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./voicings": {
|
|
56
|
+
"types": "./dist/voicings/index.d.ts",
|
|
57
|
+
"import": "./dist/voicings/index.js",
|
|
58
|
+
"default": "./dist/voicings/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./publish": {
|
|
61
|
+
"types": "./dist/publish/index.d.ts",
|
|
62
|
+
"import": "./dist/publish/index.js",
|
|
63
|
+
"default": "./dist/publish/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./music-notation.css": "./dist/music-notation.css",
|
|
66
|
+
"./music-notation.publish.min.js": "./dist/music-notation.publish.min.js",
|
|
67
|
+
"./package.json": "./package.json"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dist",
|
|
71
|
+
"README.md",
|
|
72
|
+
"LICENSE"
|
|
73
|
+
],
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=20.0.0"
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "bun@1.4.0",
|
|
78
|
+
"config": {
|
|
79
|
+
"commitizen": {
|
|
80
|
+
"path": "node_modules/cz-customizable"
|
|
81
|
+
},
|
|
82
|
+
"cz-customizable": {
|
|
83
|
+
"config": ".cz-config.cjs"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"build": "bun run tsc && bun scripts/build.ts",
|
|
88
|
+
"setup": "git config --local --replace-all include.path ../.gitconfig",
|
|
89
|
+
"tsc": "tsc --noEmit",
|
|
90
|
+
"lint": "eslint . --max-warnings 0",
|
|
91
|
+
"lint:fix": "eslint . --fix",
|
|
92
|
+
"format": "prettier --write .",
|
|
93
|
+
"format:check": "prettier --check .",
|
|
94
|
+
"test": "bun test",
|
|
95
|
+
"test:watch": "bun test --watch",
|
|
96
|
+
"commit": "cz",
|
|
97
|
+
"cm": "cz",
|
|
98
|
+
"validate": "bun run --parallel tsc test lint",
|
|
99
|
+
"prepublishOnly": "bun run validate && bun run build"
|
|
100
|
+
},
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"tonal": "6.5.1"
|
|
103
|
+
},
|
|
104
|
+
"devDependencies": {
|
|
105
|
+
"@commitlint/cli": "^20.1.0",
|
|
106
|
+
"@commitlint/config-conventional": "^20.1.0",
|
|
107
|
+
"@eslint/js": "^9.36.0",
|
|
108
|
+
"@happy-dom/global-registrator": "21.0.4",
|
|
109
|
+
"@tombatossals/chords-db": "0.5.1",
|
|
110
|
+
"@types/bun": "1.4.0",
|
|
111
|
+
"@types/node": "24.10.1",
|
|
112
|
+
"commitizen": "^4.3.1",
|
|
113
|
+
"cz-customizable": "^7.5.1",
|
|
114
|
+
"eslint": "^9.36.0",
|
|
115
|
+
"eslint-config-prettier": "^10.1.5",
|
|
116
|
+
"globals": "17.0.0",
|
|
117
|
+
"jiti": "2.6.1",
|
|
118
|
+
"prettier": "^3.6.2",
|
|
119
|
+
"typescript": "^5.9.3",
|
|
120
|
+
"typescript-eslint": "8.48.1"
|
|
121
|
+
},
|
|
122
|
+
"overrides": {
|
|
123
|
+
"fast-uri": "3.1.9",
|
|
124
|
+
"flatted": "3.4.2",
|
|
125
|
+
"js-yaml": "4.3.2",
|
|
126
|
+
"brace-expansion": "2.1.7",
|
|
127
|
+
"minimatch": "3.1.5",
|
|
128
|
+
"picomatch": "2.3.2",
|
|
129
|
+
"lodash": "4.18.1",
|
|
130
|
+
"tmp": "0.2.7"
|
|
131
|
+
}
|
|
132
|
+
}
|