@ugfoundation/swaralipi-js 0.3.1 → 0.3.3
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-TVEIT2OJ.js → batch-6YAUMVHC.js} +5 -5
- package/dist/{batch-TVEIT2OJ.js.map → batch-6YAUMVHC.js.map} +1 -1
- package/dist/{chunk-V5ZSUJCA.js → chunk-32LOBRC2.js} +3 -3
- package/dist/{chunk-V5ZSUJCA.js.map → chunk-32LOBRC2.js.map} +1 -1
- package/dist/{chunk-HDN3YZ6K.js → chunk-RTCRSOVW.js} +3 -3
- package/dist/{chunk-HDN3YZ6K.js.map → chunk-RTCRSOVW.js.map} +1 -1
- package/dist/{chunk-WBSIKYWB.js → chunk-UBJZUKQD.js} +6 -6
- package/dist/chunk-UBJZUKQD.js.map +1 -0
- package/dist/{chunk-H6HC44PZ.js → chunk-YE7UVYRY.js} +5 -3
- package/dist/chunk-YE7UVYRY.js.map +1 -0
- package/dist/cli.cjs +6 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/convert/index.cjs +6 -4
- package/dist/convert/index.cjs.map +1 -1
- package/dist/convert/index.js +3 -3
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/player/index.cjs +70 -11
- package/dist/player/index.cjs.map +1 -1
- package/dist/player/index.d.cts +17 -4
- package/dist/player/index.d.ts +17 -4
- package/dist/player/index.js +70 -13
- package/dist/player/index.js.map +1 -1
- package/dist/{schedule-BhiP_maG.d.ts → schedule-BaE3JGHe.d.ts} +1 -1
- package/dist/{schedule-Dsb2paUE.d.cts → schedule-CHXz3V6T.d.cts} +1 -1
- package/dist/spec/index.cjs +4 -2
- package/dist/spec/index.cjs.map +1 -1
- package/dist/spec/index.d.cts +2 -2
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +2 -2
- package/dist/{taals-FmEulsjY.d.cts → taals-DxJ8wRtF.d.cts} +8 -1
- package/dist/{taals-FmEulsjY.d.ts → taals-DxJ8wRtF.d.ts} +8 -1
- package/dist/viewer/index.cjs +28 -2
- package/dist/viewer/index.cjs.map +1 -1
- package/dist/viewer/index.d.cts +36 -4
- package/dist/viewer/index.d.ts +36 -4
- package/dist/viewer/index.js +25 -3
- package/dist/viewer/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-H6HC44PZ.js.map +0 -1
- package/dist/chunk-WBSIKYWB.js.map +0 -1
package/dist/viewer/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { O as Octave, a as SvaraLetter, N as Note, M as Meta, S as Swaralipi } from '../schema-D3wyNRqM.cjs';
|
|
2
|
-
import {
|
|
1
|
+
import { O as Octave, a as SvaraLetter, N as Note, M as Meta, S as Swaralipi, T as Taal } from '../schema-D3wyNRqM.cjs';
|
|
2
|
+
import { D as DrumVoice, S as Schedule, P as PlayEvent } from '../schedule-CHXz3V6T.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'tone';
|
|
5
|
-
import '../taals-
|
|
5
|
+
import '../taals-DxJ8wRtF.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Per-language notation encoding for the viewer.
|
|
@@ -319,6 +319,38 @@ declare function abcToSvg(abc: string, opts?: StaffOptions, notePaths?: string[]
|
|
|
319
319
|
* SWARALIPI_CSS + SWARALIPI_STAFF_CSS. Async because abcjs is dynamic-imported.
|
|
320
320
|
*/
|
|
321
321
|
declare function renderStaffHtml(doc: Swaralipi, opts?: StaffOptions): Promise<string>;
|
|
322
|
+
/** Options for the standalone taal staff (a single percussion voice — no
|
|
323
|
+
* melody doc). Layout fields mirror `StaffOptions`; `abcToSvg` reads them. */
|
|
324
|
+
interface TaalStaffOptions {
|
|
325
|
+
/** Tempo written into the score (Q:). Default 90. */
|
|
326
|
+
bpm?: number;
|
|
327
|
+
/** Per-matra drum voices (one per beat of the cycle). Default: the taal's own
|
|
328
|
+
* `drumPattern()` (sam→kick, tali→snare, khaali→hihat). Length is cycled to
|
|
329
|
+
* `numBeats`, so an explicit book-accurate mapping overrides the geometric one. */
|
|
330
|
+
drums?: DrumVoice[];
|
|
331
|
+
/** Theka bols aligned under each matra (the `w:` line). One per beat. */
|
|
332
|
+
bols?: string[];
|
|
333
|
+
/** abcjs target width in px. Default 680. */
|
|
334
|
+
staffwidth?: number;
|
|
335
|
+
/** abcjs `scale`. Default 1. */
|
|
336
|
+
scale?: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Build a **percussion-only** ABC tune for one avartan of a taal — no melody
|
|
340
|
+
* voice. One quarter-note per matra over a single `V:1 clef=perc` staff, voices
|
|
341
|
+
* from `opts.drums ?? drumPattern(taal)`, `%%percmap` for the used sounds, and
|
|
342
|
+
* (optional) bols as the aligned `w:` line. The whole cycle is one bar (M:n/4).
|
|
343
|
+
* Pure + dependency-free — the testable seam, mirroring `buildAbc`.
|
|
344
|
+
*/
|
|
345
|
+
declare function buildTaalAbc(taal: Pick<Taal, 'numBeats' | 'sam' | 'bhaags' | 'khaali'>, opts?: TaalStaffOptions): string;
|
|
346
|
+
/**
|
|
347
|
+
* Render a standalone taal theka as an engraved drum staff (abcjs). Each perc
|
|
348
|
+
* note carries `data-note="<matra-index>"` so a consumer's per-beat clock can
|
|
349
|
+
* highlight the active note (the same `data-note` mechanism the grid uses).
|
|
350
|
+
* Async because abcjs is dynamic-imported; returns a "needs abcjs" notice if
|
|
351
|
+
* the optional package is absent.
|
|
352
|
+
*/
|
|
353
|
+
declare function renderTaalStaffHtml(taal: Pick<Taal, 'numBeats' | 'sam' | 'bhaags' | 'khaali'>, opts?: TaalStaffOptions): Promise<string>;
|
|
322
354
|
|
|
323
355
|
/**
|
|
324
356
|
* Print / "Save as PDF" support.
|
|
@@ -435,4 +467,4 @@ type Transliterator = (bengaliText: string) => string;
|
|
|
435
467
|
*/
|
|
436
468
|
declare function loadLyricTransliterator(lang: ViewerLang): Promise<Transliterator | undefined>;
|
|
437
469
|
|
|
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 };
|
|
470
|
+
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 TaalStaffOptions, type Transliterator, type ViewerLang, abcDuration, abcToSvg, buildAbc, buildTaalAbc, composeCluster, defineSwaralipiSheet, docToAbc, groupRowIntoCells, loadLyricTransliterator, localizeDigits, midiToAbc, printSwaralipi, renderMetaHeader, renderPrintDocument, renderStaffHtml, renderStaffPrintDocument, renderTaalStaffHtml, renderToHtml, resolveArcs };
|
package/dist/viewer/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { O as Octave, a as SvaraLetter, N as Note, M as Meta, S as Swaralipi } from '../schema-D3wyNRqM.js';
|
|
2
|
-
import {
|
|
1
|
+
import { O as Octave, a as SvaraLetter, N as Note, M as Meta, S as Swaralipi, T as Taal } from '../schema-D3wyNRqM.js';
|
|
2
|
+
import { D as DrumVoice, S as Schedule, P as PlayEvent } from '../schedule-BaE3JGHe.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'tone';
|
|
5
|
-
import '../taals-
|
|
5
|
+
import '../taals-DxJ8wRtF.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Per-language notation encoding for the viewer.
|
|
@@ -319,6 +319,38 @@ declare function abcToSvg(abc: string, opts?: StaffOptions, notePaths?: string[]
|
|
|
319
319
|
* SWARALIPI_CSS + SWARALIPI_STAFF_CSS. Async because abcjs is dynamic-imported.
|
|
320
320
|
*/
|
|
321
321
|
declare function renderStaffHtml(doc: Swaralipi, opts?: StaffOptions): Promise<string>;
|
|
322
|
+
/** Options for the standalone taal staff (a single percussion voice — no
|
|
323
|
+
* melody doc). Layout fields mirror `StaffOptions`; `abcToSvg` reads them. */
|
|
324
|
+
interface TaalStaffOptions {
|
|
325
|
+
/** Tempo written into the score (Q:). Default 90. */
|
|
326
|
+
bpm?: number;
|
|
327
|
+
/** Per-matra drum voices (one per beat of the cycle). Default: the taal's own
|
|
328
|
+
* `drumPattern()` (sam→kick, tali→snare, khaali→hihat). Length is cycled to
|
|
329
|
+
* `numBeats`, so an explicit book-accurate mapping overrides the geometric one. */
|
|
330
|
+
drums?: DrumVoice[];
|
|
331
|
+
/** Theka bols aligned under each matra (the `w:` line). One per beat. */
|
|
332
|
+
bols?: string[];
|
|
333
|
+
/** abcjs target width in px. Default 680. */
|
|
334
|
+
staffwidth?: number;
|
|
335
|
+
/** abcjs `scale`. Default 1. */
|
|
336
|
+
scale?: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Build a **percussion-only** ABC tune for one avartan of a taal — no melody
|
|
340
|
+
* voice. One quarter-note per matra over a single `V:1 clef=perc` staff, voices
|
|
341
|
+
* from `opts.drums ?? drumPattern(taal)`, `%%percmap` for the used sounds, and
|
|
342
|
+
* (optional) bols as the aligned `w:` line. The whole cycle is one bar (M:n/4).
|
|
343
|
+
* Pure + dependency-free — the testable seam, mirroring `buildAbc`.
|
|
344
|
+
*/
|
|
345
|
+
declare function buildTaalAbc(taal: Pick<Taal, 'numBeats' | 'sam' | 'bhaags' | 'khaali'>, opts?: TaalStaffOptions): string;
|
|
346
|
+
/**
|
|
347
|
+
* Render a standalone taal theka as an engraved drum staff (abcjs). Each perc
|
|
348
|
+
* note carries `data-note="<matra-index>"` so a consumer's per-beat clock can
|
|
349
|
+
* highlight the active note (the same `data-note` mechanism the grid uses).
|
|
350
|
+
* Async because abcjs is dynamic-imported; returns a "needs abcjs" notice if
|
|
351
|
+
* the optional package is absent.
|
|
352
|
+
*/
|
|
353
|
+
declare function renderTaalStaffHtml(taal: Pick<Taal, 'numBeats' | 'sam' | 'bhaags' | 'khaali'>, opts?: TaalStaffOptions): Promise<string>;
|
|
322
354
|
|
|
323
355
|
/**
|
|
324
356
|
* Print / "Save as PDF" support.
|
|
@@ -435,4 +467,4 @@ type Transliterator = (bengaliText: string) => string;
|
|
|
435
467
|
*/
|
|
436
468
|
declare function loadLyricTransliterator(lang: ViewerLang): Promise<Transliterator | undefined>;
|
|
437
469
|
|
|
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 };
|
|
470
|
+
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 TaalStaffOptions, type Transliterator, type ViewerLang, abcDuration, abcToSvg, buildAbc, buildTaalAbc, composeCluster, defineSwaralipiSheet, docToAbc, groupRowIntoCells, loadLyricTransliterator, localizeDigits, midiToAbc, printSwaralipi, renderMetaHeader, renderPrintDocument, renderStaffHtml, renderStaffPrintDocument, renderTaalStaffHtml, renderToHtml, resolveArcs };
|
package/dist/viewer/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildSchedule, drumPattern } from '../chunk-
|
|
2
|
-
import { TAALS } from '../chunk-
|
|
1
|
+
import { buildSchedule, drumPattern } from '../chunk-32LOBRC2.js';
|
|
2
|
+
import { TAALS } from '../chunk-YE7UVYRY.js';
|
|
3
3
|
|
|
4
4
|
// src/viewer/glyphs.ts
|
|
5
5
|
var SWARABITAN_SHUDDHA = {
|
|
@@ -759,6 +759,28 @@ async function renderStaffHtml(doc, opts = {}) {
|
|
|
759
759
|
function escapeAttr(s) {
|
|
760
760
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
761
761
|
}
|
|
762
|
+
function buildTaalAbc(taal, opts = {}) {
|
|
763
|
+
const n = Math.max(1, taal.numBeats);
|
|
764
|
+
const src = opts.drums && opts.drums.length ? opts.drums : drumPattern(taal);
|
|
765
|
+
const voices = Array.from({ length: n }, (_, i) => src[i % src.length]);
|
|
766
|
+
const bpm = Math.round(opts.bpm ?? 90);
|
|
767
|
+
const head = ["X:1", `M:${ratioMeter(n)}`, "L:1/4", `Q:1/4=${bpm}`, ...percMapLines(voices), "K:C"];
|
|
768
|
+
const lines = [...head, "V:1 clef=perc stem=up", buildDrumVoice(n, n, voices)];
|
|
769
|
+
if (opts.bols?.length) {
|
|
770
|
+
const w = opts.bols.slice(0, n).map((b) => b.trim() ? abcText(b).replace(/\s+/g, "~") : "*");
|
|
771
|
+
while (w.length < n) w.push("*");
|
|
772
|
+
lines.push(`w: ${w.join(" ")}`);
|
|
773
|
+
}
|
|
774
|
+
return lines.join("\n");
|
|
775
|
+
}
|
|
776
|
+
async function renderTaalStaffHtml(taal, opts = {}) {
|
|
777
|
+
const abc = buildTaalAbc(taal, opts);
|
|
778
|
+
const n = Math.max(1, taal.numBeats);
|
|
779
|
+
const paths = Array.from({ length: n }, (_, i) => String(i));
|
|
780
|
+
const engraved = await abcToSvg(abc, { staffwidth: opts.staffwidth, scale: opts.scale }, paths);
|
|
781
|
+
const lines = engraved.includes("sw-staff-missing") ? engraved : `<div class="sw-staff-lines">${engraved}</div>`;
|
|
782
|
+
return `<div class="sw-staff sw-staff--taal">${lines}</div>`;
|
|
783
|
+
}
|
|
762
784
|
|
|
763
785
|
// src/viewer/print.ts
|
|
764
786
|
var DEFAULT_WATERMARK = "www.gitabitan.io";
|
|
@@ -1053,6 +1075,6 @@ function defineSwaralipiSheet(tagName = "swaralipi-sheet") {
|
|
|
1053
1075
|
return ctor;
|
|
1054
1076
|
}
|
|
1055
1077
|
|
|
1056
|
-
export { DEFAULT_NOTATOR, DEFAULT_WATERMARK, DIGITS, LABELS, MARKS, NOTATION_FONT_URLS, SWARALIPI_CSS, SWARALIPI_PRINT_CSS, SWARALIPI_STAFF_CSS, abcDuration, abcToSvg, buildAbc, composeCluster, defineSwaralipiSheet, docToAbc, groupRowIntoCells, loadLyricTransliterator, localizeDigits, midiToAbc, printSwaralipi, renderMetaHeader, renderPrintDocument, renderStaffHtml, renderStaffPrintDocument, renderToHtml, resolveArcs };
|
|
1078
|
+
export { DEFAULT_NOTATOR, DEFAULT_WATERMARK, DIGITS, LABELS, MARKS, NOTATION_FONT_URLS, SWARALIPI_CSS, SWARALIPI_PRINT_CSS, SWARALIPI_STAFF_CSS, abcDuration, abcToSvg, buildAbc, buildTaalAbc, composeCluster, defineSwaralipiSheet, docToAbc, groupRowIntoCells, loadLyricTransliterator, localizeDigits, midiToAbc, printSwaralipi, renderMetaHeader, renderPrintDocument, renderStaffHtml, renderStaffPrintDocument, renderTaalStaffHtml, renderToHtml, resolveArcs };
|
|
1057
1079
|
//# sourceMappingURL=index.js.map
|
|
1058
1080
|
//# sourceMappingURL=index.js.map
|