@ugfoundation/swaralipi-js 0.2.0 → 0.3.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/dist/{batch-CIAXVKP5.js → batch-QPSHVNDS.js} +4 -4
- package/dist/{batch-CIAXVKP5.js.map → batch-QPSHVNDS.js.map} +1 -1
- package/dist/{chunk-2NBNF6JP.js → chunk-4YTOLN3C.js} +3 -3
- package/dist/{chunk-2NBNF6JP.js.map → chunk-4YTOLN3C.js.map} +1 -1
- package/dist/chunk-V5ZSUJCA.js +354 -0
- package/dist/chunk-V5ZSUJCA.js.map +1 -0
- package/dist/{chunk-SH2INDZ2.js → chunk-VCRWS3F3.js} +3 -3
- package/dist/{chunk-SH2INDZ2.js.map → chunk-VCRWS3F3.js.map} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/convert/index.cjs +1 -1
- package/dist/convert/index.cjs.map +1 -1
- package/dist/convert/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/player/index.cjs +58 -2
- package/dist/player/index.cjs.map +1 -1
- package/dist/player/index.d.cts +12 -158
- package/dist/player/index.d.ts +12 -158
- package/dist/player/index.js +31 -324
- package/dist/player/index.js.map +1 -1
- package/dist/schedule-DhO_Xzz4.d.cts +167 -0
- package/dist/schedule-PTHUONrA.d.ts +167 -0
- package/dist/spec/index.cjs +1 -1
- package/dist/spec/index.cjs.map +1 -1
- package/dist/spec/index.d.cts +1 -1
- package/dist/spec/index.d.ts +1 -1
- package/dist/spec/index.js +1 -1
- package/dist/viewer/index.cjs +684 -202
- package/dist/viewer/index.cjs.map +1 -1
- package/dist/viewer/index.d.cts +217 -64
- package/dist/viewer/index.d.ts +217 -64
- package/dist/viewer/index.js +421 -177
- package/dist/viewer/index.js.map +1 -1
- package/package.json +7 -2
package/dist/viewer/index.d.cts
CHANGED
|
@@ -1,86 +1,81 @@
|
|
|
1
|
-
import { O as Octave, a as SvaraLetter, N as Note, S as Swaralipi } from '../schema-D3wyNRqM.cjs';
|
|
1
|
+
import { O as Octave, a as SvaraLetter, N as Note, M as Meta, S as Swaralipi } from '../schema-D3wyNRqM.cjs';
|
|
2
|
+
import { S as Schedule, P as PlayEvent, c as DrumVoice } from '../schedule-DhO_Xzz4.cjs';
|
|
2
3
|
import 'zod';
|
|
4
|
+
import 'tone';
|
|
5
|
+
import '../taals-FmEulsjY.cjs';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
|
-
* Per-language
|
|
8
|
+
* Per-language notation encoding for the viewer.
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Every language renders its notation through a dedicated, purpose-built
|
|
11
|
+
* font whose glyphs ARE the akarmatrik/Bhatkhande marks — so composeCluster
|
|
12
|
+
* emits that font's ASCII encoding and the font does all the hard work
|
|
13
|
+
* (komal/tivra forms, octave reph/dots, matra). This is why the viewer no
|
|
14
|
+
* longer touches Unicode cluster composition at all: the old reph-over-
|
|
15
|
+
* vowel, hasanta-before-matra and dotted-circle hazards simply don't exist
|
|
16
|
+
* when the font supplies precomposed glyphs keyed by plain ASCII.
|
|
13
17
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
18
|
+
* - bn → NLTR's **Swarabitan** (the akarmatrik font this project decodes).
|
|
19
|
+
* Letters s r g m p q n = স র গ ম প ধ ন (q=ধ); komal v t d u = ঋ জ্ঞ দ ণ;
|
|
20
|
+
* tivra ma k = the authentic কড়ি-ম conjunct (ম-based — has NO Unicode
|
|
21
|
+
* form, which is what forced this whole approach); suffix f = taar reph,
|
|
22
|
+
* h = mandra hasanta; trailing a = the আ-কার matra carrier. See codec.ts.
|
|
23
|
+
* - hi/en → **Ome Bhatkhande** Hindi/English (SIL OFL 1.1, © Omenad —
|
|
24
|
+
* github.com/omenad/fonts). Same clean keymap for both: lowercase
|
|
25
|
+
* s r g m p d n = the seven shuddha swaras, uppercase R G M D N = komal
|
|
26
|
+
* Re/Ga, tivra Ma, komal Dha/Ni; octave suffix u/l = taar/mandra dot,
|
|
27
|
+
* U/L = ati (two dots). Bhatkhande has no আ-কার, so no matra is appended.
|
|
28
|
+
*
|
|
29
|
+
* The font is applied by CSS keyed on `.sw-sheet`'s `lang` (see styles.ts);
|
|
30
|
+
* composeCluster only chooses the ASCII. The single residual CSS mark is the
|
|
31
|
+
* bn ati-octave extra dot (Swarabitan's f/h are single reph/hasanta only).
|
|
24
32
|
*/
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
komal?: string;
|
|
31
|
-
/** Distinct tivra glyph (bn/hi ক্ষ/क्ष); absent for en (CSS prime). */
|
|
32
|
-
tivra?: string;
|
|
33
|
-
}
|
|
34
|
-
declare const LETTERS: Record<ViewerLang, Record<SvaraLetter, LetterForms>>;
|
|
34
|
+
/** Akarmatrik/Bhatkhande grid languages, rendered synchronously by renderToHtml. */
|
|
35
|
+
type GridLang = 'bn' | 'hi' | 'en';
|
|
36
|
+
/** All viewer languages. `staff` = Western staff notation (async, via abcjs). */
|
|
37
|
+
type ViewerLang = GridLang | 'staff';
|
|
35
38
|
/** Digits 0-9 in the target script (beat labels, avartan). */
|
|
36
|
-
declare const DIGITS: Record<
|
|
39
|
+
declare const DIGITS: Record<GridLang, string>;
|
|
37
40
|
interface LangMarks {
|
|
38
|
-
/** আ-কার matra carrier appended to a group-final cluster ('' for en). */
|
|
39
|
-
matra: string;
|
|
40
41
|
/** Melisma / no-new-attack dash before a sustained cluster. */
|
|
41
42
|
hyphen: string;
|
|
42
43
|
/** Lyric continuation mark shown under sustains (the source uses ৹). */
|
|
43
44
|
melisma: string;
|
|
44
45
|
/** ছেদ cut/articulation mark (two stacked rings, ঃ-shaped). */
|
|
45
46
|
cut: string;
|
|
46
|
-
/** Real-text reph prefix for taar ('' for en → CSS dot instead). */
|
|
47
|
-
reph: string;
|
|
48
47
|
}
|
|
49
|
-
declare const MARKS: Record<
|
|
48
|
+
declare const MARKS: Record<GridLang, LangMarks>;
|
|
50
49
|
/** Header labels (NLTR prints নাম / তাল / আবর্তন …). */
|
|
51
|
-
declare const LABELS: Record<
|
|
50
|
+
declare const LABELS: Record<GridLang, {
|
|
52
51
|
title: string;
|
|
53
52
|
taal: string;
|
|
54
53
|
raag: string;
|
|
55
54
|
avartan: string;
|
|
56
55
|
notationBy: string;
|
|
57
56
|
}>;
|
|
58
|
-
/** A composed notation cluster:
|
|
59
|
-
*
|
|
60
|
-
* CSS-reph fallback). */
|
|
57
|
+
/** A composed notation cluster: the font's ASCII text plus any residual CSS
|
|
58
|
+
* classes the font itself cannot express (only the bn ati-octave dot). */
|
|
61
59
|
interface Cluster {
|
|
62
60
|
text: string;
|
|
63
61
|
classes: string[];
|
|
64
|
-
/** Set when the matra could not join the cluster (ঋ/ऋ, or en where the
|
|
65
|
-
* carrier doesn't exist) and must be emitted as an isolated-matra span. */
|
|
66
|
-
matraSeparate: boolean;
|
|
67
62
|
}
|
|
68
63
|
interface ComposeOptions {
|
|
69
64
|
komal?: boolean;
|
|
70
65
|
tivra?: boolean;
|
|
71
66
|
octave: Octave;
|
|
72
|
-
/** Append the আ-কার matra carrier (group-final notes only). */
|
|
67
|
+
/** Append the আ-কার matra carrier (bn group-final notes only). */
|
|
73
68
|
withMatra: boolean;
|
|
74
|
-
lang:
|
|
69
|
+
lang: GridLang;
|
|
75
70
|
}
|
|
76
71
|
/**
|
|
77
|
-
* Compose one svara
|
|
78
|
-
*
|
|
79
|
-
*
|
|
72
|
+
* Compose one svara into its notation-font ASCII. bn = Swarabitan
|
|
73
|
+
* (letter + f/h octave + a matra); hi/en = Ome Bhatkhande (case-encoded
|
|
74
|
+
* letter + u/l/U/L octave, no matra). The font renders the actual glyph.
|
|
80
75
|
*/
|
|
81
76
|
declare function composeCluster(letter: SvaraLetter, opts: ComposeOptions): Cluster;
|
|
82
77
|
/** Map ASCII digits in `s` to the target script's digits. */
|
|
83
|
-
declare function localizeDigits(s: string, lang:
|
|
78
|
+
declare function localizeDigits(s: string, lang: GridLang): string;
|
|
84
79
|
|
|
85
80
|
/**
|
|
86
81
|
* Pure spec-JSON → HTML renderer. No DOM, no side effects: usable for SSR
|
|
@@ -97,8 +92,8 @@ declare function localizeDigits(s: string, lang: ViewerLang): string;
|
|
|
97
92
|
* Rendering is spec-driven (semantics, not `raw`): grouping derives from
|
|
98
93
|
* `durationMatra` accumulation so hand-authored documents without `raw`
|
|
99
94
|
* render identically. `raw` is consulted only for (a) raw-only fallback
|
|
100
|
-
* notes (never dropped — dimmed
|
|
101
|
-
* labels, whose grammar lives in raw (see
|
|
95
|
+
* notes (never dropped — dimmed, in Swarabitan when loaded), (b) the ছেদ
|
|
96
|
+
* cut mark and beat labels, whose grammar lives in raw (see codec.ts).
|
|
102
97
|
*/
|
|
103
98
|
|
|
104
99
|
interface RenderOptions {
|
|
@@ -152,6 +147,13 @@ interface Arc {
|
|
|
152
147
|
* A row with fill segments but no ends at all renders one straight line.
|
|
153
148
|
*/
|
|
154
149
|
declare function resolveArcs(cells: Cell[], noteCount: number): Arc[];
|
|
150
|
+
/**
|
|
151
|
+
* The নাম / তাল / রাগ / আবর্তন / স্বরলিপিকার header block, shared by the
|
|
152
|
+
* akarmatrik grid and the staff view so both show the same metadata (localized
|
|
153
|
+
* labels; values injected pre-localized by the consumer). Exported so the
|
|
154
|
+
* staff renderer can reuse the exact markup + styling.
|
|
155
|
+
*/
|
|
156
|
+
declare function renderMetaHeader(meta: Meta, lang: GridLang, tr?: (s: string) => string): string;
|
|
155
157
|
/** Render a complete swaralipi document to an HTML string. Pair with
|
|
156
158
|
* SWARALIPI_CSS (shadow DOM does this automatically; SSR consumers emit a
|
|
157
159
|
* `<style>` themselves). All source text is HTML-escaped. */
|
|
@@ -170,12 +172,17 @@ declare function renderToHtml(doc: Swaralipi, opts?: RenderOptions): string;
|
|
|
170
172
|
* --sw-rule header rule / muted line color
|
|
171
173
|
*
|
|
172
174
|
* All ink uses `currentColor`, so the sheet follows the host's text color
|
|
173
|
-
* (dark mode included).
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* the NLTR reference rendering of song 4270.
|
|
175
|
+
* (dark mode included). The only octave mark drawn as a pseudo-element is
|
|
176
|
+
* the bn ati-octave extra dot (Swarabitan's f/h glyphs are a single
|
|
177
|
+
* reph/hasanta); everything else is a real glyph in the notation font.
|
|
177
178
|
*/
|
|
178
|
-
|
|
179
|
+
/** Notation fonts, self-hosted on the project CDN (CORS-enabled), keyed by
|
|
180
|
+
* the CSS `font-family` this stylesheet uses. bn = NLTR's Swarabitan; hi/en
|
|
181
|
+
* = Ome Bhatkhande (SIL OFL 1.1, © Omenad — github.com/omenad/fonts).
|
|
182
|
+
* Self-hosters: declare your own \`@font-face\` for any of these families
|
|
183
|
+
* before this stylesheet / before defineSwaralipiSheet() and it wins. */
|
|
184
|
+
declare const NOTATION_FONT_URLS: Record<string, string>;
|
|
185
|
+
declare const SWARALIPI_CSS: string;
|
|
179
186
|
/**
|
|
180
187
|
* Print stylesheet — pair with `SWARALIPI_CSS` (renderPrintDocument injects
|
|
181
188
|
* both). Gated on `@media print`, so it also works if a consumer drops it into
|
|
@@ -188,7 +195,130 @@ declare const SWARALIPI_CSS = "\n.sw-sheet {\n font-family: var(--sw-font, 'Not
|
|
|
188
195
|
* - rows are un-clipped (no scrollbar on paper) and kept whole across page
|
|
189
196
|
* breaks; part headings stay with their first row.
|
|
190
197
|
*/
|
|
191
|
-
declare const SWARALIPI_PRINT_CSS = "\n@page { margin: 16mm; }\n@media print {\n .sw-sheet { -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #000; }\n .sw-row { overflow: visible !important; break-inside: avoid; page-break-inside: avoid; }\n .sw-part { break-inside: auto; }\n .sw-part-name, .sw-header { break-after: avoid-page; page-break-after: avoid; }\n .sw-hl { background: none !important; }\n}\n";
|
|
198
|
+
declare const SWARALIPI_PRINT_CSS = "\n@page { margin: 16mm; }\n@media print {\n .sw-sheet, .sw-staff { -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #000; }\n .sw-row { overflow: visible !important; break-inside: avoid; page-break-inside: avoid; }\n .sw-part { break-inside: auto; }\n .sw-part-name, .sw-header { break-after: avoid-page; page-break-after: avoid; }\n .sw-hl { background: none !important; }\n /* Keep each engraved staff system whole across a page break (the abcjs line\n is a <div> wrapping the <svg>, so the break rule must sit on the div). */\n .sw-staff-lines > div { break-inside: avoid; page-break-inside: avoid; }\n .sw-staff-meta { break-after: avoid-page; page-break-after: avoid; }\n}\n";
|
|
199
|
+
/** Staff-notation (abcjs) wrapper chrome: instrument/tempo header + a fluid
|
|
200
|
+
* SVG. The engraving itself is drawn by abcjs; this only frames it. */
|
|
201
|
+
declare const SWARALIPI_STAFF_CSS = "\n.sw-staff { color: currentColor; }\n.sw-staff-meta { display: flex; gap: 1.25em; align-items: baseline; margin: 0 0 .5em; font-size: .95em; opacity: .85; }\n.sw-staff-instrument { font-weight: 600; }\n.sw-staff-drums { opacity: .75; }\n.sw-staff-tempo { font-variant-numeric: tabular-nums; }\n/* abcjs (oneSvgPerLine) wraps the music into one <div><svg> per system; stack\n them as short, swaralipi-style lines. abcjs sets a fixed pixel height +\n overflow:hidden on each wrapper div \u2014 neutralise it so the viewBox'd SVG can\n scale to the container (and to the print page) instead of being clipped. */\n.sw-staff-lines > div { margin: 0 0 .35em; height: auto !important; overflow: visible !important; }\n/* Fill up to the engraved (staffwidth) size \u2014 shrink to fit a narrow container,\n but never stretch past natural width (abcToSvg pins per-SVG max-width in px),\n else a short last system balloons. */\n.sw-staff-lines svg { display: block; width: 100%; height: auto; }\n.sw-staff-missing { padding: 1em; border: 1px dashed currentColor; border-radius: 6px; opacity: .8; font-size: .9em; }\n.sw-staff-title { font-size: 1.15em; font-weight: 700; }\n.sw-staff-subtitle { opacity: .8; font-size: .95em; margin-top: .15em; }\n";
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Staff (Western) notation — a 4th "language" for the viewer.
|
|
205
|
+
*
|
|
206
|
+
* Staff notation IS the melody voice drawn as a Western score, so it reuses
|
|
207
|
+
* the player's pure `buildSchedule` (the same (midi, beat, durationBeats, kan)
|
|
208
|
+
* the MIDI export writes) and turns it into an **ABC notation** string, which
|
|
209
|
+
* `abcjs` (MIT, zero-dep) engraves to SVG. abcjs is loaded through a *dynamic*
|
|
210
|
+
* `import('abcjs')` — an optional peer dep, exactly like tone/lamejs — so the
|
|
211
|
+
* viewer bundle keeps its bare-load guarantee and only consumers who want staff
|
|
212
|
+
* notation install it. Without it, `renderStaffHtml` returns a graceful notice.
|
|
213
|
+
*
|
|
214
|
+
* Scope (matches the player/MIDI): a single treble-clef melody line. The chosen
|
|
215
|
+
* instrument is a header label, not a clef change (the line is monophonic and
|
|
216
|
+
* treble covers piano + violin range with ledger lines). Microtones render as
|
|
217
|
+
* their komal approximation — the same documented limitation as playback, since
|
|
218
|
+
* abcjs has no sub-komal glyph.
|
|
219
|
+
*/
|
|
220
|
+
|
|
221
|
+
interface StaffOptions {
|
|
222
|
+
/** Tonic (Sa). Accepts `C`, `C#`, `cs`… Default: `meta.tonic`, else `C`. */
|
|
223
|
+
tonic?: string;
|
|
224
|
+
/** Octave of madhyam Sa (C4 = MIDI 60). Default 4. */
|
|
225
|
+
baseOctave?: number;
|
|
226
|
+
/** Tempo written into the score (Q:) and shown as a header. Default `meta.bpm`, else 90. */
|
|
227
|
+
bpm?: number;
|
|
228
|
+
/** Instrument name shown above the staff (label only — clef stays treble). */
|
|
229
|
+
instrument?: string;
|
|
230
|
+
/** Show the নাম/তাল/আবর্তন/স্বরলিপিকার header block. Default true. */
|
|
231
|
+
showHeader?: boolean;
|
|
232
|
+
/** Language for the header **labels** (values are injected pre-localized by
|
|
233
|
+
* the consumer). Default `en` — staff is the Western view. */
|
|
234
|
+
headerLang?: GridLang;
|
|
235
|
+
/** Transliterate header values (title/taal/notator) — same fn as the grid. */
|
|
236
|
+
transliterate?: (bengaliText: string) => string;
|
|
237
|
+
/** Include the `w:` lyric line under each staff. Default true. */
|
|
238
|
+
lyrics?: boolean;
|
|
239
|
+
/** Matra per bar (one তাল cycle). Default `meta.taal.numBeats`, else 4. */
|
|
240
|
+
beatsPerBar?: number;
|
|
241
|
+
/** Target line width in px passed to abcjs (music wraps within it). Default 680. */
|
|
242
|
+
staffwidth?: number;
|
|
243
|
+
/** Preferred bars per wrapped line (swaralipi-short systems). Default 4. */
|
|
244
|
+
measuresPerLine?: number;
|
|
245
|
+
/** abcjs `scale`. Default 1. */
|
|
246
|
+
scale?: number;
|
|
247
|
+
/** Add a second percussion staff below the melody, sequencing a Western
|
|
248
|
+
* drumset (kick/snare/hi-hat) to the taal's sam/tali/khaali structure —
|
|
249
|
+
* the same pattern `SwaralipiPlayer`'s `rhythm: 'drums'` plays, engraved via
|
|
250
|
+
* abcjs `%%percmap`. Default false (the score stays a single staff). Taal:
|
|
251
|
+
* `meta.taal`, else a plain 4-beat cycle (matches `beatsPerBar`'s fallback). */
|
|
252
|
+
drums?: boolean;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* MIDI number → ABC pitch token. ABC's octave anchor is fixed by the standard:
|
|
256
|
+
* middle C (MIDI 60, C4) is uppercase `C`; lowercase `c` = C5; a comma drops an
|
|
257
|
+
* octave (`C,` = C3), an apostrophe raises one (`c'` = C6). Sharps carry a `^`.
|
|
258
|
+
*/
|
|
259
|
+
declare function midiToAbc(midi: number): string;
|
|
260
|
+
/**
|
|
261
|
+
* ABC duration suffix for a beat length, where the unit note (`L:`) is one
|
|
262
|
+
* matra = a quarter note. Whole numbers append the multiplier (`2`, `3`);
|
|
263
|
+
* simple fractions use `/n` (`/2` = eighth); anything else falls back to the
|
|
264
|
+
* nearest 1/4-matra count of `/4` units so odd durations still sum correctly.
|
|
265
|
+
*/
|
|
266
|
+
declare function abcDuration(beats: number): string;
|
|
267
|
+
/**
|
|
268
|
+
* Build a complete ABC tune string from a schedule. Pure and dependency-free
|
|
269
|
+
* (the testable seam). Rests advance time as `z`; melody notes carry duration;
|
|
270
|
+
* lyrics become a `w:` line aligned to the notes.
|
|
271
|
+
*
|
|
272
|
+
* Bar lines are inserted every `beatsPerBar` matra (= one তাল cycle, so an ABC
|
|
273
|
+
* measure is one আবর্তন). This is what lets abcjs **wrap into short systems** —
|
|
274
|
+
* it only breaks lines at bar lines. `M:` is set to match so the notes-per-bar
|
|
275
|
+
* check-out. The tempo (`Q:`) rides the header.
|
|
276
|
+
*
|
|
277
|
+
* `drums`, if given, is the taal's per-beat `drumPattern()` — a second
|
|
278
|
+
* `V:2 clef=perc` percussion staff is added below the melody, cycling that
|
|
279
|
+
* pattern one quarter-note per matra with `%%percmap` GM drum sounds (see
|
|
280
|
+
* `buildDrumVoice`). Both voices share the same bar grid, so they wrap and
|
|
281
|
+
* align together.
|
|
282
|
+
*/
|
|
283
|
+
declare function buildAbc(schedule: Schedule, lyricOf: (ev: PlayEvent) => string | undefined, opts: {
|
|
284
|
+
bpm: number;
|
|
285
|
+
lyrics: boolean;
|
|
286
|
+
beatsPerBar: number;
|
|
287
|
+
drums?: DrumVoice[];
|
|
288
|
+
}): string;
|
|
289
|
+
/** Build the ABC tune string for a whole document (schedule + lyrics + tempo).
|
|
290
|
+
* The measure length is one তাল cycle (`meta.taal.numBeats`), falling back to 4.
|
|
291
|
+
* `opts.drums` adds the percussion staff (see `buildAbc`). */
|
|
292
|
+
declare function docToAbc(doc: Swaralipi, opts?: StaffOptions): string;
|
|
293
|
+
/**
|
|
294
|
+
* Render an ABC tune string to engraved HTML using abcjs. Requires a DOM
|
|
295
|
+
* (`document`) — abcjs measures glyphs and draws into an element; call it in a
|
|
296
|
+
* browser, in a print iframe, or under jsdom (tests stub `getBBox`). abcjs is
|
|
297
|
+
* dynamically imported so it is never bundled or loaded unless staff notation
|
|
298
|
+
* is actually used.
|
|
299
|
+
*
|
|
300
|
+
* The music is **wrapped into short systems** (a few bars per line, each its
|
|
301
|
+
* own SVG-in-DIV) — matching how আকারমাত্রিক swaralipi is laid out in stacked
|
|
302
|
+
* rows rather than one long staff. Returns the full multi-line markup (all
|
|
303
|
+
* line DIVs), or a notice string if abcjs is not installed.
|
|
304
|
+
*
|
|
305
|
+
* `notePaths`, if given, is the `part.row.note` highlight path for each ABC
|
|
306
|
+
* melody note/rest token in schedule order (see `eventPaths`). The melody is
|
|
307
|
+
* voice 0; abcjs emits its `.abcjs-v0.abcjs-note`/`.abcjs-rest` elements in
|
|
308
|
+
* document order = that same order, so painting `notePaths[i]` onto the i-th
|
|
309
|
+
* melody element gives every engraved note the same `data-note` attribute the
|
|
310
|
+
* grid languages use — playback highlighting works identically for staff. (We
|
|
311
|
+
* key off voice + document order, NOT `data-index`: with a drum voice abcjs
|
|
312
|
+
* numbers each line/voice block separately, so data-index isn't global order.)
|
|
313
|
+
*/
|
|
314
|
+
declare function abcToSvg(abc: string, opts?: StaffOptions, notePaths?: string[]): Promise<string>;
|
|
315
|
+
/**
|
|
316
|
+
* Full doc → staff-notation HTML fragment: the shared নাম/তাল/আবর্তন/স্বরলিপিকার
|
|
317
|
+
* header (same block as the akarmatrik grid, so the staff shows the identical
|
|
318
|
+
* metadata) + an instrument label + the wrapped Western systems. Styled by
|
|
319
|
+
* SWARALIPI_CSS + SWARALIPI_STAFF_CSS. Async because abcjs is dynamic-imported.
|
|
320
|
+
*/
|
|
321
|
+
declare function renderStaffHtml(doc: Swaralipi, opts?: StaffOptions): Promise<string>;
|
|
192
322
|
|
|
193
323
|
/**
|
|
194
324
|
* Print / "Save as PDF" support.
|
|
@@ -198,16 +328,24 @@ declare const SWARALIPI_PRINT_CSS = "\n@page { margin: 16mm; }\n@media print {\n
|
|
|
198
328
|
* matra) and the CSS-drawn marks (octave dots, slur arcs, danda strokes) that
|
|
199
329
|
* the viewer renders on screen. Rasterizers (html2canvas) and PDF-primitive
|
|
200
330
|
* libraries (jsPDF/pdfmake) have no Indic shaping and drop pseudo-element
|
|
201
|
-
* marks, so we deliberately avoid them.
|
|
331
|
+
* marks, so we deliberately avoid them. Staff notation (lang `staff`) is drawn
|
|
332
|
+
* by abcjs to SVG, which the same print engine engraves faithfully.
|
|
202
333
|
*
|
|
203
334
|
* `renderPrintDocument` builds a self-contained HTML page from the pure
|
|
204
335
|
* `renderToHtml` + `SWARALIPI_CSS` (so it sidesteps the shadow-DOM "print drops
|
|
205
336
|
* encapsulated styles" gotcha); `printSwaralipi` prints it via a hidden iframe.
|
|
206
337
|
* Both reuse the same renderer as the viewer, so the PDF matches the screen.
|
|
338
|
+
*
|
|
339
|
+
* Every printed page also carries a light diagonal watermark and a notator
|
|
340
|
+
* credit footer — both defaulted for gitabitan.io but overridable by consumers.
|
|
207
341
|
*/
|
|
208
342
|
|
|
209
|
-
|
|
210
|
-
|
|
343
|
+
/** Default diagonal page watermark (empty string disables it). */
|
|
344
|
+
declare const DEFAULT_WATERMARK = "www.gitabitan.io";
|
|
345
|
+
/** Default notator credit printed in the footer. */
|
|
346
|
+
declare const DEFAULT_NOTATOR = "gitabitan.io Team";
|
|
347
|
+
interface PrintOptions extends StaffOptions {
|
|
348
|
+
/** Notation + UI language. `staff` = Western staff notation. Default `bn`. */
|
|
211
349
|
lang?: ViewerLang;
|
|
212
350
|
/** Render the নাম/তাল header block. Default true. */
|
|
213
351
|
showHeader?: boolean;
|
|
@@ -216,20 +354,33 @@ interface PrintOptions {
|
|
|
216
354
|
/** Document `<title>` — the browser's default "Save as PDF" filename.
|
|
217
355
|
* Defaults to the document's `meta.title`. */
|
|
218
356
|
title?: string;
|
|
357
|
+
/** Diagonal full-page watermark. Default `www.gitabitan.io`; '' to disable. */
|
|
358
|
+
watermark?: string;
|
|
359
|
+
/** Notator credited in the footer. Default `gitabitan.io Team`; '' to disable.
|
|
360
|
+
* A document's `meta.notationBy` takes precedence when present. */
|
|
361
|
+
notator?: string;
|
|
219
362
|
}
|
|
220
363
|
/**
|
|
221
|
-
* Build a complete, standalone HTML document for printing
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
364
|
+
* Build a complete, standalone HTML document for printing an akarmatrik
|
|
365
|
+
* (bn/hi/en) swaralipi sheet, with watermark + notator footer. Usable for a
|
|
366
|
+
* hidden-iframe print, a new browser tab, or server-side headless-Chrome PDF.
|
|
367
|
+
*
|
|
368
|
+
* For `lang: 'staff'` this renders the grid instead (staff engraving is async
|
|
369
|
+
* — use `renderStaffPrintDocument` or `printSwaralipi`, which handle it).
|
|
225
370
|
*/
|
|
226
371
|
declare function renderPrintDocument(doc: Swaralipi, opts?: PrintOptions): string;
|
|
372
|
+
/**
|
|
373
|
+
* Async variant that engraves staff notation (abcjs) into the print page. Falls
|
|
374
|
+
* back to the grid document for non-staff langs. Returns a self-contained HTML
|
|
375
|
+
* string (for headless-Chrome PDF or a print iframe).
|
|
376
|
+
*/
|
|
377
|
+
declare function renderStaffPrintDocument(doc: Swaralipi, opts?: PrintOptions): Promise<string>;
|
|
227
378
|
/**
|
|
228
379
|
* Open the browser print dialog for a swaralipi document (the user picks a
|
|
229
380
|
* printer or "Save as PDF"). Renders into an off-screen iframe so it prints
|
|
230
381
|
* only the sheet — independent of the host page's chrome and CSS — then cleans
|
|
231
|
-
* up. Browser-only; throws in a non-DOM environment (use renderPrintDocument
|
|
232
|
-
* for SSR / headless-Chrome instead).
|
|
382
|
+
* up. Browser-only; throws in a non-DOM environment (use renderPrintDocument /
|
|
383
|
+
* renderStaffPrintDocument for SSR / headless-Chrome instead).
|
|
233
384
|
*/
|
|
234
385
|
declare function printSwaralipi(doc: Swaralipi, opts?: PrintOptions): void;
|
|
235
386
|
|
|
@@ -258,6 +409,8 @@ interface SwaralipiSheetElement extends HTMLElement {
|
|
|
258
409
|
clearHighlights(): void;
|
|
259
410
|
/** Open the print dialog (→ "Save as PDF") for the current document. */
|
|
260
411
|
print(options?: PrintOptions): void;
|
|
412
|
+
/** Options for the `staff` language (instrument label, tonic, bpm…). */
|
|
413
|
+
staffOptions: StaffOptions;
|
|
261
414
|
}
|
|
262
415
|
/**
|
|
263
416
|
* Register `<swaralipi-sheet>` (or a custom tag name). Idempotent. Throws
|
|
@@ -282,4 +435,4 @@ type Transliterator = (bengaliText: string) => string;
|
|
|
282
435
|
*/
|
|
283
436
|
declare function loadLyricTransliterator(lang: ViewerLang): Promise<Transliterator | undefined>;
|
|
284
437
|
|
|
285
|
-
export { type Arc, type Cell, type Cluster, type ComposeOptions, DIGITS,
|
|
438
|
+
export { type Arc, type Cell, type Cluster, type ComposeOptions, DEFAULT_NOTATOR, DEFAULT_WATERMARK, DIGITS, type GridLang, LABELS, MARKS, NOTATION_FONT_URLS, type PrintOptions, type RenderOptions, SWARALIPI_CSS, SWARALIPI_PRINT_CSS, SWARALIPI_STAFF_CSS, type StaffOptions, type SwaralipiSheetElement, type Transliterator, type ViewerLang, abcDuration, abcToSvg, buildAbc, composeCluster, defineSwaralipiSheet, docToAbc, groupRowIntoCells, loadLyricTransliterator, localizeDigits, midiToAbc, printSwaralipi, renderMetaHeader, renderPrintDocument, renderStaffHtml, renderStaffPrintDocument, renderToHtml, resolveArcs };
|