@ugfoundation/swaralipi-js 0.2.1 → 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.
Files changed (37) hide show
  1. package/dist/{batch-SCSIUDB3.js → batch-QPSHVNDS.js} +4 -4
  2. package/dist/{batch-SCSIUDB3.js.map → batch-QPSHVNDS.js.map} +1 -1
  3. package/dist/{chunk-DINRYGRI.js → chunk-4YTOLN3C.js} +3 -3
  4. package/dist/{chunk-DINRYGRI.js.map → chunk-4YTOLN3C.js.map} +1 -1
  5. package/dist/chunk-V5ZSUJCA.js +354 -0
  6. package/dist/chunk-V5ZSUJCA.js.map +1 -0
  7. package/dist/{chunk-KYNCQ7OF.js → chunk-VCRWS3F3.js} +3 -3
  8. package/dist/{chunk-KYNCQ7OF.js.map → chunk-VCRWS3F3.js.map} +1 -1
  9. package/dist/cli.cjs +1 -1
  10. package/dist/cli.cjs.map +1 -1
  11. package/dist/cli.js +2 -2
  12. package/dist/convert/index.cjs +1 -1
  13. package/dist/convert/index.cjs.map +1 -1
  14. package/dist/convert/index.js +2 -2
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/player/index.cjs +58 -2
  19. package/dist/player/index.cjs.map +1 -1
  20. package/dist/player/index.d.cts +12 -158
  21. package/dist/player/index.d.ts +12 -158
  22. package/dist/player/index.js +31 -324
  23. package/dist/player/index.js.map +1 -1
  24. package/dist/schedule-DhO_Xzz4.d.cts +167 -0
  25. package/dist/schedule-PTHUONrA.d.ts +167 -0
  26. package/dist/spec/index.cjs +1 -1
  27. package/dist/spec/index.cjs.map +1 -1
  28. package/dist/spec/index.d.cts +1 -1
  29. package/dist/spec/index.d.ts +1 -1
  30. package/dist/spec/index.js +1 -1
  31. package/dist/viewer/index.cjs +584 -54
  32. package/dist/viewer/index.cjs.map +1 -1
  33. package/dist/viewer/index.d.cts +177 -18
  34. package/dist/viewer/index.d.ts +177 -18
  35. package/dist/viewer/index.js +322 -30
  36. package/dist/viewer/index.js.map +1 -1
  37. package/package.json +7 -2
@@ -0,0 +1,167 @@
1
+ import * as tone from 'tone';
2
+ import { T as Taal, S as Swaralipi } from './schema-D3wyNRqM.cjs';
3
+ import { T as TaalId } from './taals-FmEulsjY.cjs';
4
+
5
+ /** The dynamically-imported Tone module, typed without importing it. */
6
+ type ToneModule = typeof tone;
7
+ /** A melodic instrument: a Tone.Sampler note→filename map + where to find it. */
8
+ interface InstrumentDef {
9
+ /** Human label for UIs. */
10
+ label: string;
11
+ /** Tone.Sampler `urls`: note name (`C#4`) → filename (`Cs4.mp3`). */
12
+ urls: Record<string, string>;
13
+ /** Sample directory: an absolute URL, or — when `local` — a path segment
14
+ * appended to the player's `soundsBaseUrl`. */
15
+ baseUrl: string;
16
+ /** `baseUrl` is relative to `soundsBaseUrl` (needs it set). */
17
+ local?: boolean;
18
+ /** Sampler release time in seconds. */
19
+ release?: number;
20
+ }
21
+ /** Built-in melody instrument ids (consumers may add their own via the
22
+ * player's `customInstruments`, so the runtime id type stays open). */
23
+ type InstrumentId = string;
24
+ /**
25
+ * Default host for the project's samples (santoor / tabla / tanpura /
26
+ * metronome) — CC-BY, redistribution-verified and CORS-enabled, so the player
27
+ * works with zero config. Override via the player's `soundsBaseUrl` to
28
+ * self-host. (Melody defaults to the CDN-hosted piano, so it needs no host.)
29
+ */
30
+ declare const DEFAULT_SOUNDS_BASE = "https://cdn.daserve.in/swaralipijs-instruments/";
31
+ /** CC-BY Salamander Grand Piano (Tone's de-facto piano), CDN-hosted. */
32
+ declare const SALAMANDER_BASE = "https://tonejs.github.io/audio/salamander/";
33
+ /** CC-BY tonejs-instruments sample CDN (harmonium/violin/flute). */
34
+ declare const TONEJS_INSTRUMENTS_BASE = "https://nbrosowsky.github.io/tonejs-instruments/samples/";
35
+ /** Built-in melody instruments. santoor is local; the rest are CDN-hosted
36
+ * (CC-BY) so they need only network — `pianoBaseUrl`/`customInstruments`
37
+ * override for self-hosting. */
38
+ declare const INSTRUMENTS: Record<string, InstrumentDef>;
39
+ /** Taals with recorded tabla loops (everything else → metronome fallback). */
40
+ declare const SAMPLED_TAALS: ReadonlySet<TaalId>;
41
+ /** Available tabla loop tempos (file suffix `…<bpm>bpm.mp3`). */
42
+ declare const TABLA_BPMS: readonly number[];
43
+ /**
44
+ * Tabla loop variations per taal. Most taals have one unnamed loop at
45
+ * `tabla/<id>/`; an entry here overrides that:
46
+ * - `variations` lists the variation suffixes, **first = default**.
47
+ * A lone named variation (shashthi → `pro`, i.e. `tabla/shashthi-pro/`) IS
48
+ * the default; later entries are premium upsells the player never auto-selects.
49
+ * An empty-string entry (kehrwa → `''`) means the unnamed `tabla/<id>/` loop
50
+ * is the default and a named entry follows it as an upsell.
51
+ * - `skipBpms` are grid tempos this taal's loops were not recorded at.
52
+ * Consumers read this to build a variation/upsell UI; the player itself only
53
+ * ever plays the default (or whatever a doc's `meta.taal.variation` pins).
54
+ */
55
+ declare const TABLA_VARIATIONS: Record<string, {
56
+ variations: string[];
57
+ skipBpms?: number[];
58
+ }>;
59
+ /** Tabla tempos actually available for a taal: the grid minus any it lacks. */
60
+ declare function tablaBpms(taalId: string): readonly number[];
61
+ /** Ensure exactly one trailing slash. */
62
+ declare function normalizeBase(url: string): string;
63
+ /** The 37 santoor samples, as a Tone.Sampler `urls` map (`C4` → `c4.mp3`). */
64
+ declare function santoorUrls(): Record<string, string>;
65
+ /**
66
+ * Restrict a Sampler `urls` map to just the samples needed to cover MIDI
67
+ * `[lo, hi]`: every sample inside the range, plus the nearest one below and
68
+ * above it (so Tone interpolates the edges without extrapolating). Cuts a
69
+ * typical song from ~37 santoor files to a handful — a big win on mobile and
70
+ * never worse on fast links (Tone fetches what's left in parallel). The
71
+ * Sampler pitch-shifts from the nearest sample, so audio is unchanged.
72
+ */
73
+ declare function subsetUrls(urls: Record<string, string>, lo: number, hi: number): Record<string, string>;
74
+ /** Resolve a representative sample URL for an instrument (its first sample),
75
+ * used to probe availability. undefined when a local instrument has no
76
+ * `soundsBaseUrl` or the def has no samples. */
77
+ declare function instrumentSampleUrl(def: InstrumentDef, soundsBaseUrl?: string): string | undefined;
78
+ /**
79
+ * Liveness check for a sample URL: a single tiny ranged GET (one byte), the
80
+ * same CORS-enabled fetch Tone uses to load the buffer — so a pass means Tone
81
+ * can actually load it. Resolves false on any error/timeout/non-2xx, and false
82
+ * (no throw) when `fetch` is unavailable (Node/SSR). `Range: bytes=0-0` is a
83
+ * CORS-safelisted header, so no preflight.
84
+ */
85
+ declare function probeUrl(url: string, timeoutMs?: number): Promise<boolean>;
86
+ /**
87
+ * Snap a tabla loop's end to the nearest whole beat of its measured length so a
88
+ * slightly-mistrimmed file still phase-locks to the melody grid instead of
89
+ * drifting a fraction of a beat each cycle. `spb` = seconds per beat (60/bpm).
90
+ * No-op for correctly trimmed loops (already an integer beat count); never
91
+ * extends past the buffer — a too-short file can't be repaired here.
92
+ *
93
+ * ponytail: belt-and-braces for off-spec audio; the real fix is trimming each
94
+ * loop to exactly `cycles × numBeats × 60/bpm` seconds at production time.
95
+ */
96
+ declare function quantizeLoopEnd(durationSec: number, spb: number): number;
97
+ /** Snap an arbitrary bpm to the nearest available tabla tempo (default grid;
98
+ * pass a taal's `tablaBpms()` so it never snaps to a tempo that taal lacks). */
99
+ declare function nearestTablaBpm(bpm: number, bpms?: readonly number[]): number;
100
+ /** URL of the tabla loop for a taal at a (snapped) bpm, optionally a named
101
+ * variation (defaults to the taal's default variation — see TABLA_VARIATIONS). */
102
+ declare function tablaUrl(base: string, taalId: string, bpm: number, variation?: string): string;
103
+ declare const DRUM_KIT_BASE = "https://tonejs.github.io/audio/drum-samples/acoustic-kit/";
104
+ type DrumVoice = 'kick' | 'snare' | 'hihat' | 'tom1' | 'tom2' | 'tom3';
105
+ /**
106
+ * Per-beat drumset voice for one তাল cycle, following sam/tali/khaali theory:
107
+ * sam (cycle start) → kick, the first beat of each accented (non-khaali)
108
+ * vibhag → snare (the tali clap), the first beat of a khaali vibhag → closed
109
+ * hihat (the khaali "wave off"), every other beat → hihat (fill, keeping the
110
+ * kit's groove going the way a tabla's filler strokes do).
111
+ */
112
+ declare function drumPattern(taal: Pick<Taal, 'numBeats' | 'sam' | 'bhaags' | 'khaali'>): DrumVoice[];
113
+
114
+ /**
115
+ * Pure spec-doc → playback timeline. No Tone, no audio — the player turns
116
+ * this `Schedule` into Transport events, but it is fully unit-testable on its
117
+ * own and mirrors the viewer's spec-driven (not raw-driven) reading.
118
+ *
119
+ * Timing unit is the মাত্রা (matra / beat). One global beat cursor runs across
120
+ * every part and row: NLTR "systems" (rows) are wraps of one continuous line,
121
+ * and parts (asthayi → antara …) play back-to-back, so the music never pauses
122
+ * at a row or part boundary.
123
+ *
124
+ * Each audible column carries the same `data-note` path the viewer emits
125
+ * (`part.row.note`, note = absolute index into `row.notes`; see
126
+ * src/viewer/render.ts), so `SwaralipiPlayer` can drive `highlight()` directly.
127
+ */
128
+
129
+ interface PlayEvent {
130
+ /** Onset in matra from the start of the document. */
131
+ beat: number;
132
+ /** Ring length in matra (extended by following আ-কার holds). */
133
+ durationBeats: number;
134
+ /** Pitch as MIDI, or null for a rest / আ-কার hold column. */
135
+ midi: number | null;
136
+ /** Grace-note MIDI struck just before the main attack, when present. */
137
+ kan: number | null;
138
+ /** `part.row.note` highlight path. */
139
+ path: string;
140
+ kind: 'note' | 'rest' | 'sustain';
141
+ }
142
+ interface Schedule {
143
+ events: PlayEvent[];
144
+ /** Total length in matra (the cursor's final value). */
145
+ totalBeats: number;
146
+ }
147
+ interface ScheduleOptions {
148
+ /** Tonic; accepts `C`, `C#`, `cs`… (see parseTonic). Default C. */
149
+ tonic?: string;
150
+ /** Octave of madhyam Sa (C4 = MIDI 60). Default 4. */
151
+ baseOctave?: number;
152
+ }
153
+ /**
154
+ * Walk a document into a flat, time-ordered list of play events.
155
+ *
156
+ * - svara note → an attack at the cursor; advances by `durationMatra ?? 1`.
157
+ * - rest → a silent column that still advances the cursor.
158
+ * - sustain **with** svara (melisma) → a fresh attack (the pitch moves under
159
+ * a held vowel); advances.
160
+ * - sustain **without** svara (আ-কার hold) → no attack, but the previous
161
+ * audible note's ring is extended; still emitted (midi null) so the lyric
162
+ * column highlights; advances.
163
+ * - bar / bracket-only / carrier / raw-only → ignored (no event, no advance).
164
+ */
165
+ declare function buildSchedule(doc: Swaralipi, opts?: ScheduleOptions): Schedule;
166
+
167
+ export { DEFAULT_SOUNDS_BASE as D, type InstrumentId as I, type PlayEvent as P, type Schedule as S, TABLA_BPMS as T, type InstrumentDef as a, DRUM_KIT_BASE as b, type DrumVoice as c, INSTRUMENTS as d, SALAMANDER_BASE as e, SAMPLED_TAALS as f, type ScheduleOptions as g, TABLA_VARIATIONS as h, TONEJS_INSTRUMENTS_BASE as i, type ToneModule as j, buildSchedule as k, drumPattern as l, instrumentSampleUrl as m, nearestTablaBpm as n, normalizeBase as o, probeUrl as p, quantizeLoopEnd as q, subsetUrls as r, santoorUrls as s, tablaBpms as t, tablaUrl as u };
@@ -0,0 +1,167 @@
1
+ import * as tone from 'tone';
2
+ import { T as Taal, S as Swaralipi } from './schema-D3wyNRqM.js';
3
+ import { T as TaalId } from './taals-FmEulsjY.js';
4
+
5
+ /** The dynamically-imported Tone module, typed without importing it. */
6
+ type ToneModule = typeof tone;
7
+ /** A melodic instrument: a Tone.Sampler note→filename map + where to find it. */
8
+ interface InstrumentDef {
9
+ /** Human label for UIs. */
10
+ label: string;
11
+ /** Tone.Sampler `urls`: note name (`C#4`) → filename (`Cs4.mp3`). */
12
+ urls: Record<string, string>;
13
+ /** Sample directory: an absolute URL, or — when `local` — a path segment
14
+ * appended to the player's `soundsBaseUrl`. */
15
+ baseUrl: string;
16
+ /** `baseUrl` is relative to `soundsBaseUrl` (needs it set). */
17
+ local?: boolean;
18
+ /** Sampler release time in seconds. */
19
+ release?: number;
20
+ }
21
+ /** Built-in melody instrument ids (consumers may add their own via the
22
+ * player's `customInstruments`, so the runtime id type stays open). */
23
+ type InstrumentId = string;
24
+ /**
25
+ * Default host for the project's samples (santoor / tabla / tanpura /
26
+ * metronome) — CC-BY, redistribution-verified and CORS-enabled, so the player
27
+ * works with zero config. Override via the player's `soundsBaseUrl` to
28
+ * self-host. (Melody defaults to the CDN-hosted piano, so it needs no host.)
29
+ */
30
+ declare const DEFAULT_SOUNDS_BASE = "https://cdn.daserve.in/swaralipijs-instruments/";
31
+ /** CC-BY Salamander Grand Piano (Tone's de-facto piano), CDN-hosted. */
32
+ declare const SALAMANDER_BASE = "https://tonejs.github.io/audio/salamander/";
33
+ /** CC-BY tonejs-instruments sample CDN (harmonium/violin/flute). */
34
+ declare const TONEJS_INSTRUMENTS_BASE = "https://nbrosowsky.github.io/tonejs-instruments/samples/";
35
+ /** Built-in melody instruments. santoor is local; the rest are CDN-hosted
36
+ * (CC-BY) so they need only network — `pianoBaseUrl`/`customInstruments`
37
+ * override for self-hosting. */
38
+ declare const INSTRUMENTS: Record<string, InstrumentDef>;
39
+ /** Taals with recorded tabla loops (everything else → metronome fallback). */
40
+ declare const SAMPLED_TAALS: ReadonlySet<TaalId>;
41
+ /** Available tabla loop tempos (file suffix `…<bpm>bpm.mp3`). */
42
+ declare const TABLA_BPMS: readonly number[];
43
+ /**
44
+ * Tabla loop variations per taal. Most taals have one unnamed loop at
45
+ * `tabla/<id>/`; an entry here overrides that:
46
+ * - `variations` lists the variation suffixes, **first = default**.
47
+ * A lone named variation (shashthi → `pro`, i.e. `tabla/shashthi-pro/`) IS
48
+ * the default; later entries are premium upsells the player never auto-selects.
49
+ * An empty-string entry (kehrwa → `''`) means the unnamed `tabla/<id>/` loop
50
+ * is the default and a named entry follows it as an upsell.
51
+ * - `skipBpms` are grid tempos this taal's loops were not recorded at.
52
+ * Consumers read this to build a variation/upsell UI; the player itself only
53
+ * ever plays the default (or whatever a doc's `meta.taal.variation` pins).
54
+ */
55
+ declare const TABLA_VARIATIONS: Record<string, {
56
+ variations: string[];
57
+ skipBpms?: number[];
58
+ }>;
59
+ /** Tabla tempos actually available for a taal: the grid minus any it lacks. */
60
+ declare function tablaBpms(taalId: string): readonly number[];
61
+ /** Ensure exactly one trailing slash. */
62
+ declare function normalizeBase(url: string): string;
63
+ /** The 37 santoor samples, as a Tone.Sampler `urls` map (`C4` → `c4.mp3`). */
64
+ declare function santoorUrls(): Record<string, string>;
65
+ /**
66
+ * Restrict a Sampler `urls` map to just the samples needed to cover MIDI
67
+ * `[lo, hi]`: every sample inside the range, plus the nearest one below and
68
+ * above it (so Tone interpolates the edges without extrapolating). Cuts a
69
+ * typical song from ~37 santoor files to a handful — a big win on mobile and
70
+ * never worse on fast links (Tone fetches what's left in parallel). The
71
+ * Sampler pitch-shifts from the nearest sample, so audio is unchanged.
72
+ */
73
+ declare function subsetUrls(urls: Record<string, string>, lo: number, hi: number): Record<string, string>;
74
+ /** Resolve a representative sample URL for an instrument (its first sample),
75
+ * used to probe availability. undefined when a local instrument has no
76
+ * `soundsBaseUrl` or the def has no samples. */
77
+ declare function instrumentSampleUrl(def: InstrumentDef, soundsBaseUrl?: string): string | undefined;
78
+ /**
79
+ * Liveness check for a sample URL: a single tiny ranged GET (one byte), the
80
+ * same CORS-enabled fetch Tone uses to load the buffer — so a pass means Tone
81
+ * can actually load it. Resolves false on any error/timeout/non-2xx, and false
82
+ * (no throw) when `fetch` is unavailable (Node/SSR). `Range: bytes=0-0` is a
83
+ * CORS-safelisted header, so no preflight.
84
+ */
85
+ declare function probeUrl(url: string, timeoutMs?: number): Promise<boolean>;
86
+ /**
87
+ * Snap a tabla loop's end to the nearest whole beat of its measured length so a
88
+ * slightly-mistrimmed file still phase-locks to the melody grid instead of
89
+ * drifting a fraction of a beat each cycle. `spb` = seconds per beat (60/bpm).
90
+ * No-op for correctly trimmed loops (already an integer beat count); never
91
+ * extends past the buffer — a too-short file can't be repaired here.
92
+ *
93
+ * ponytail: belt-and-braces for off-spec audio; the real fix is trimming each
94
+ * loop to exactly `cycles × numBeats × 60/bpm` seconds at production time.
95
+ */
96
+ declare function quantizeLoopEnd(durationSec: number, spb: number): number;
97
+ /** Snap an arbitrary bpm to the nearest available tabla tempo (default grid;
98
+ * pass a taal's `tablaBpms()` so it never snaps to a tempo that taal lacks). */
99
+ declare function nearestTablaBpm(bpm: number, bpms?: readonly number[]): number;
100
+ /** URL of the tabla loop for a taal at a (snapped) bpm, optionally a named
101
+ * variation (defaults to the taal's default variation — see TABLA_VARIATIONS). */
102
+ declare function tablaUrl(base: string, taalId: string, bpm: number, variation?: string): string;
103
+ declare const DRUM_KIT_BASE = "https://tonejs.github.io/audio/drum-samples/acoustic-kit/";
104
+ type DrumVoice = 'kick' | 'snare' | 'hihat' | 'tom1' | 'tom2' | 'tom3';
105
+ /**
106
+ * Per-beat drumset voice for one তাল cycle, following sam/tali/khaali theory:
107
+ * sam (cycle start) → kick, the first beat of each accented (non-khaali)
108
+ * vibhag → snare (the tali clap), the first beat of a khaali vibhag → closed
109
+ * hihat (the khaali "wave off"), every other beat → hihat (fill, keeping the
110
+ * kit's groove going the way a tabla's filler strokes do).
111
+ */
112
+ declare function drumPattern(taal: Pick<Taal, 'numBeats' | 'sam' | 'bhaags' | 'khaali'>): DrumVoice[];
113
+
114
+ /**
115
+ * Pure spec-doc → playback timeline. No Tone, no audio — the player turns
116
+ * this `Schedule` into Transport events, but it is fully unit-testable on its
117
+ * own and mirrors the viewer's spec-driven (not raw-driven) reading.
118
+ *
119
+ * Timing unit is the মাত্রা (matra / beat). One global beat cursor runs across
120
+ * every part and row: NLTR "systems" (rows) are wraps of one continuous line,
121
+ * and parts (asthayi → antara …) play back-to-back, so the music never pauses
122
+ * at a row or part boundary.
123
+ *
124
+ * Each audible column carries the same `data-note` path the viewer emits
125
+ * (`part.row.note`, note = absolute index into `row.notes`; see
126
+ * src/viewer/render.ts), so `SwaralipiPlayer` can drive `highlight()` directly.
127
+ */
128
+
129
+ interface PlayEvent {
130
+ /** Onset in matra from the start of the document. */
131
+ beat: number;
132
+ /** Ring length in matra (extended by following আ-কার holds). */
133
+ durationBeats: number;
134
+ /** Pitch as MIDI, or null for a rest / আ-কার hold column. */
135
+ midi: number | null;
136
+ /** Grace-note MIDI struck just before the main attack, when present. */
137
+ kan: number | null;
138
+ /** `part.row.note` highlight path. */
139
+ path: string;
140
+ kind: 'note' | 'rest' | 'sustain';
141
+ }
142
+ interface Schedule {
143
+ events: PlayEvent[];
144
+ /** Total length in matra (the cursor's final value). */
145
+ totalBeats: number;
146
+ }
147
+ interface ScheduleOptions {
148
+ /** Tonic; accepts `C`, `C#`, `cs`… (see parseTonic). Default C. */
149
+ tonic?: string;
150
+ /** Octave of madhyam Sa (C4 = MIDI 60). Default 4. */
151
+ baseOctave?: number;
152
+ }
153
+ /**
154
+ * Walk a document into a flat, time-ordered list of play events.
155
+ *
156
+ * - svara note → an attack at the cursor; advances by `durationMatra ?? 1`.
157
+ * - rest → a silent column that still advances the cursor.
158
+ * - sustain **with** svara (melisma) → a fresh attack (the pitch moves under
159
+ * a held vowel); advances.
160
+ * - sustain **without** svara (আ-কার hold) → no attack, but the previous
161
+ * audible note's ring is extended; still emitted (midi null) so the lyric
162
+ * column highlights; advances.
163
+ * - bar / bracket-only / carrier / raw-only → ignored (no event, no advance).
164
+ */
165
+ declare function buildSchedule(doc: Swaralipi, opts?: ScheduleOptions): Schedule;
166
+
167
+ export { DEFAULT_SOUNDS_BASE as D, type InstrumentId as I, type PlayEvent as P, type Schedule as S, TABLA_BPMS as T, type InstrumentDef as a, DRUM_KIT_BASE as b, type DrumVoice as c, INSTRUMENTS as d, SALAMANDER_BASE as e, SAMPLED_TAALS as f, type ScheduleOptions as g, TABLA_VARIATIONS as h, TONEJS_INSTRUMENTS_BASE as i, type ToneModule as j, buildSchedule as k, drumPattern as l, instrumentSampleUrl as m, nearestTablaBpm as n, normalizeBase as o, probeUrl as p, quantizeLoopEnd as q, subsetUrls as r, santoorUrls as s, tablaBpms as t, tablaUrl as u };
@@ -130,7 +130,7 @@ var TAALS = {
130
130
  };
131
131
 
132
132
  // src/spec/index.ts
133
- var SPEC_VERSION = "0.2.1";
133
+ var SPEC_VERSION = "0.3.0";
134
134
  function parseSwaralipi(data) {
135
135
  return swaralipiSchema.parse(data);
136
136
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/spec/schema.ts","../../src/spec/taals.ts","../../src/spec/index.ts"],"names":["z"],"mappings":";;;;;AAMO,IAAM,YAAA,GAAeA,MAAE,IAAA,CAAK;AAAA,EACjC,YAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,MAAA;AAAA;AAAA,EACA;AAAA;AACF,CAAC;AAOM,IAAM,iBAAA,GAAoBA,KAAA,CAAE,IAAA,CAAK,CAAC,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAG,CAAC;AAIpE,IAAM,cAAcA,KAAA,CAAE,KAAA,CAAM,CAAC,YAAA,EAAc,iBAAiB,CAAC;AAI7D,IAAM,kBAAkBA,KAAA,CAAE,IAAA,CAAK,CAAC,WAAA,EAAa,UAAU,CAAC;AAWxD,IAAM,SAAA,GAAYA,MAAE,IAAA,CAAK,CAAC,QAAQ,QAAA,EAAU,QAAA,EAAU,MAAM,CAAC;AAS7D,IAAM,aAAA,GAAgBA,MAAE,MAAA,CAAO;AAAA,EACpC,MAAMA,KAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,MAAA,EAAQ,KAAK,CAAC,CAAA;AAAA,EACtC,MAAMA,KAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,OAAO,CAAC;AAChC,CAAC;AAwDM,IAAM,aAA8BA,KAAA,CAAE,IAAA;AAAA,EAAK,MAChDA,MACG,MAAA,CAAO;AAAA,IACN,KAAA,EAAO,YAAY,QAAA,EAAS;AAAA,IAC5B,KAAA,EAAOA,KAAA,CAAE,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,IAC5B,KAAA,EAAOA,KAAA,CAAE,OAAA,EAAQ,CAA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E,EAAA,EAAI,UAAA,EAAY,QAAA,EAAU,CAAA,EAAG,MAAA,EAAQ,CAAC,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,CAAA,EAAE;AAAA;AAAA,EAChE,KAAA,EAAO,EAAE,EAAA,EAAI,OAAA,EAAS,QAAA,EAAU,CAAA,EAAG,MAAA,EAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,KAAK,CAAA,EAAE;AAAA;AAAA,EAC7D,UAAU,EAAE,EAAA,EAAI,YAAY,QAAA,EAAU,EAAA,EAAI,QAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAC,CAAA,EAAE;AAAA,EACpF,UAAU,EAAE,EAAA,EAAI,YAAY,QAAA,EAAU,EAAA,EAAI,QAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAC,CAAA;AAAE;AACtF;;;AClBO,IAAM,YAAA,GAAe;AAmCrB,SAAS,eAAe,IAAA,EAA0B;AACvD,EAAA,OAAO,eAAA,CAAgB,MAAM,IAAI,CAAA;AACnC;AAGO,SAAS,mBAAmB,IAAA,EAAe;AAChD,EAAA,OAAO,eAAA,CAAgB,UAAU,IAAI,CAAA;AACvC","file":"index.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * swaralipi-js JSON spec — Zod schema + inferred types.\n\n/** Octave registers */\nexport const octaveSchema = z.enum([\n 'ati-mandra', // very low\n 'mandra', // low (dot below)\n 'madhyam', // middle\n 'taar', // high (ref/dot above)\n 'ati-taar', // very high\n]);\nexport type Octave = z.infer<typeof octaveSchema>;\n\n/**\n * The seven shuddha svara letters:\n * `d` = ধৈবত (dha), `n` = নিষাদ (ni). Komal/tivra are flags, not letters.\n */\nexport const svaraLetterSchema = z.enum(['s', 'r', 'g', 'm', 'p', 'd', 'n']);\nexport type SvaraLetter = z.infer<typeof svaraLetterSchema>;\n\n/** A pitch as `[octave, letter]` */\nexport const svaraSchema = z.tuple([octaveSchema, svaraLetterSchema]);\nexport type Svara = z.infer<typeof svaraSchema>;\n\n/** Microtone variants below komal (legend: অল্পকোমল / অতিকোমল). */\nexport const microtoneSchema = z.enum(['alpakomal', 'atikomal']);\nexport type Microtone = z.infer<typeof microtoneSchema>;\n\n/**\n * Barline weights. Swarabitan distinguishes the light দাঁড়ি (।) that\n * separates vibhags *within* a taal cycle from the দণ্ড (danda, I) strokes:\n * - `dari` — । vibhag separator inside the cycle\n * - `single` — I end of one taal cycle (ফেরা)\n * - `double` — II section (kali) boundary / return-to-asthayi marker\n * - `quad` — IIII end of the song\n */\nexport const barSchema = z.enum(['dari', 'single', 'double', 'quad']);\nexport type Bar = z.infer<typeof barSchema>;\n\n/**\n * A repeat-bracket edge. Brackets span a range of notes; the opening note\n * carries `{ ..., edge: 'open' }` and the closing note `{ ..., edge: 'close' }`.\n * kind: `repeat` = {} গুন্ডবন্ধনী, `skip` = () বক্রবন্ধনী (omit on repeat),\n * `alt` = [] সরল বন্ধনী (changed notes on repeat).\n */\nexport const bracketSchema = z.object({\n kind: z.enum(['repeat', 'skip', 'alt']),\n edge: z.enum(['open', 'close']),\n});\nexport type Bracket = z.infer<typeof bracketSchema>;\n\n/**\n * A single token in a row. A token is one of: a pitched note (`svara`),\n * a rest (`rest`), an আ-কার sustain (`sustain`), a barline (`bar`), or a\n * purely raw/undecoded cell (`raw`) — possibly carrying annotations\n * (`above`/`below`) or a lyric syllable on an otherwise empty column.\n * The `.refine` enforces that a note carries at least one of these so\n * truly empty tokens can't slip through.\n *\n * `above`/`below` make `Note` recursive, so the type is hand-written and\n * the schema is typed `z.ZodType<Note>` via `z.lazy` (all fields are\n * optional, hence input ≡ output and the annotation is sound).\n */\nexport interface Note {\n /** Pitch. Omitted for rests, sustains, and barlines. */\n svara?: Svara;\n /** কোমল (flat). */\n komal?: boolean;\n /** তীব্র / কড়ি (sharp — applies to ma). */\n tivra?: boolean;\n /** Sub-komal microtone (legend: অল্পকোমল / অতিকোমল). */\n microtone?: Microtone;\n /** Duration in মাত্রা (beats): 1 (default), 0.5, 0.25, 2, … */\n durationMatra?: number;\n /**\n * আ-কার: no new syllable attack. Alone (no `svara`) it holds the previous\n * note's pitch and vowel; combined with `svara` it is a melisma — the\n * pitch moves while the previous syllable's vowel continues (Swarabitan\n * writes these with a leading hyphen, e.g. `-sfa`).\n */\n sustain?: boolean;\n /** বিরাম: a rest of `durationMatra` beats. */\n rest?: boolean;\n /** কণ স্বর: a grace note attached before this note. */\n kan?: Svara;\n /** মীড় (glide/slur) endpoint. */\n meend?: 'start' | 'end';\n /** Barline. A bar token usually has no `svara`. */\n bar?: Bar;\n /** Repeat-bracket edges opening/closing on this token. */\n brackets?: Bracket[];\n /** Lyric syllable aligned under this note */\n lyric?: string;\n /** Lossless passthrough of the source cell (e.g. raw Swarabitan code). */\n raw?: string;\n /**\n * Annotation notes rendered above this column: alt-on-repeat passages\n * (legend: পরিবর্তিত স্বর in [ ] শিরোদেশে), stop marks, beat numbers.\n */\n above?: Note[];\n /** Annotation notes rendered below this column. */\n below?: Note[];\n}\n\nexport const noteSchema: z.ZodType<Note> = z.lazy(() =>\n z\n .object({\n svara: svaraSchema.optional(),\n komal: z.boolean().optional(),\n tivra: z.boolean().optional(),\n microtone: microtoneSchema.optional(),\n durationMatra: z.number().positive().optional(),\n sustain: z.boolean().optional(),\n rest: z.boolean().optional(),\n kan: svaraSchema.optional(),\n meend: z.enum(['start', 'end']).optional(),\n bar: barSchema.optional(),\n brackets: z.array(bracketSchema).optional(),\n lyric: z.string().optional(),\n raw: z.string().optional(),\n above: z.array(noteSchema).optional(),\n below: z.array(noteSchema).optional(),\n })\n .refine(\n (n) =>\n n.svara !== undefined ||\n n.rest === true ||\n n.sustain === true ||\n n.bar !== undefined ||\n n.raw !== undefined ||\n (n.brackets !== undefined && n.brackets.length > 0) ||\n (n.above !== undefined && n.above.length > 0) ||\n (n.below !== undefined && n.below.length > 0) ||\n n.lyric !== undefined,\n {\n message:\n 'note must carry one of: svara, rest, sustain, bar, raw, lyric, brackets, or a non-empty above/below',\n },\n ),\n);\n\n/** A written line of the song: a sequence of note tokens. */\nexport const rowSchema = z.object({\n /** Optional line label (e.g. a tuk/section marker). */\n label: z.string().optional(),\n notes: z.array(noteSchema),\n});\nexport type Row = z.infer<typeof rowSchema>;\n\n/** A structural section: আস্থায়ী / অন্তরা / সঞ্চারী / আভোগ, or free text. */\nexport const partSchema = z.object({\n name: z.string().optional(),\n rows: z.array(rowSchema),\n});\nexport type Part = z.infer<typeof partSchema>;\n\n/**\n * Taal definition. `numBeats` is the cycle length in মাত্রা; `bhaags` (if\n * present) must sum to `numBeats`; `sam`/`khaali` are 0-based beat indices.\n */\nexport const taalSchema = z\n .object({\n /** Player sample key, e.g. `dadra`, `teentaal`. */\n id: z.string(),\n /**\n * Which tabla loop variation to play, e.g. `pro` (CDN dir suffix). Optional\n * and additive — omitted means the taal's default variation, so existing\n * docs are unaffected. The player honors it but never exposes a variation\n * picker; selecting a non-default variation is the consumer's premium policy.\n */\n variation: z.string().optional(),\n numBeats: z.number().int().positive(),\n /** Vibhag groupings; if given, they sum to numBeats. */\n bhaags: z.array(z.number().int().positive()).optional(),\n /** Sam (cycle start) beat index, 0-based. */\n sam: z.number().int().nonnegative().optional(),\n /** Khaali (wave) beat indices, 0-based. */\n khaali: z.array(z.number().int().nonnegative()).optional(),\n })\n .refine((t) => t.bhaags === undefined || t.bhaags.reduce((a, b) => a + b, 0) === t.numBeats, {\n message: 'bhaags must sum to numBeats',\n });\nexport type Taal = z.infer<typeof taalSchema>;\n\n/** Document-level metadata. */\nexport const metaSchema = z.object({\n title: z.string(),\n /** Cross-reference to a gitabitan.io song content id (filename, immutable). */\n songId: z.string().optional(),\n /** Source NLTR node/song id. */\n nltrId: z.number().int().optional(),\n taal: taalSchema.optional(),\n /**\n * The taal name exactly as printed in the source (e.g. `তালমুক্ত`,\n * `ষষ্ঠী(২/৪)`). Always set by the NLTR converter; `taal` is set only\n * when the name resolves to a known definition.\n */\n taalName: z.string().optional(),\n /** Base pitch for playback, e.g. `C`, `C#`, or the player's `cs` form. */\n tonic: z.string().optional(),\n /** Default playback tempo in matra/min. Player-only — the viewer ignores it.\n * The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`\n * tweak → this → 90). `null` is the converter's blank placeholder = unset. */\n bpm: z.number().positive().nullable().optional(),\n raag: z.string().optional(),\n /** আবর্তন: number of taal cycles, when the source states it. */\n avartan: z.number().int().positive().optional(),\n /** স্বরলিপিকার (notation author). */\n notationBy: z.string().optional(),\n /** Provenance note or URL. */\n source: z.string().optional(),\n});\nexport type Meta = z.infer<typeof metaSchema>;\n\n/** A complete swaralipi document. */\nexport const swaralipiSchema = z.object({\n /** Spec version this document targets (see SPEC_VERSION in ./index). */\n version: z.string(),\n meta: metaSchema,\n parts: z.array(partSchema),\n});\nexport type Swaralipi = z.infer<typeof swaralipiSchema>;\n","import type { Taal } from './schema.js';\n\n/**\n * Reference definitions for the taals the player will sample:\n * adachautaal, dadra, ektaal, jhaptaal, kehrwa, rupak, shashthi, teentaal.\n *\n * `numBeats` and the `bhaags` given below are standard Hindustani taal theory.\n * `bhaags` is omitted where a single canonical division isn't well-agreed\n * (adachautaal) — we assert only what's uncontested. `sam` is beat 0 for all.\n *\n * Tabla loops live under `tabla/<id>/` by default; per-taal variation and\n * skip-bpm overrides (e.g. shashthi → `tabla/shashthi-pro/`) are in\n * instruments.ts's `TABLA_VARIATIONS`.\n */\nexport const TAALS = {\n dadra: { id: 'dadra', numBeats: 6, bhaags: [3, 3], sam: 0, khaali: [3] },\n kehrwa: { id: 'kehrwa', numBeats: 8, bhaags: [4, 4], sam: 0, khaali: [4] },\n rupak: { id: 'rupak', numBeats: 7, bhaags: [3, 2, 2], sam: 0, khaali: [0] },\n jhaptaal: { id: 'jhaptaal', numBeats: 10, bhaags: [2, 3, 2, 3], sam: 0, khaali: [5] },\n ektaal: { id: 'ektaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] },\n adachautaal: { id: 'adachautaal', numBeats: 14, sam: 0 },\n choutaal: { id: 'choutaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] }, // চৌতাল\n shashthi: { id: 'shashthi', numBeats: 6, bhaags: [2, 4], sam: 0 }, // ষষ্ঠী\n teora: { id: 'teora', numBeats: 7, bhaags: [3, 2, 2], sam: 0 }, // টেওরা\n teentaal: { id: 'teentaal', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] },\n aratheka: { id: 'aratheka', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] }, // আড়াঠেকা\n} as const satisfies Record<string, Taal>;\n\nexport type TaalId = keyof typeof TAALS;\n","/**\n * @ugfoundation/swaralipi-js/spec\n *\n * The swaralipi JSON spec: Zod schemas, inferred TS types, and parse helpers.\n */\nimport { swaralipiSchema, type Swaralipi } from './schema.js';\n\n/** Current spec version. Documents declare the version they target. */\nexport const SPEC_VERSION = '0.2.1';\n\nexport {\n octaveSchema,\n svaraLetterSchema,\n svaraSchema,\n microtoneSchema,\n barSchema,\n bracketSchema,\n noteSchema,\n rowSchema,\n partSchema,\n taalSchema,\n metaSchema,\n swaralipiSchema,\n} from './schema.js';\n\nexport type {\n Octave,\n SvaraLetter,\n Svara,\n Microtone,\n Bar,\n Bracket,\n Note,\n Row,\n Part,\n Taal,\n Meta,\n Swaralipi,\n} from './schema.js';\n\nexport { TAALS, type TaalId } from './taals.js';\n\n/** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */\nexport function parseSwaralipi(data: unknown): Swaralipi {\n return swaralipiSchema.parse(data);\n}\n\n/** Non-throwing variant: returns Zod's `{ success, data | error }` result. */\nexport function safeParseSwaralipi(data: unknown) {\n return swaralipiSchema.safeParse(data);\n}\n"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;AAAA;AAAA,EAChE,KAAA,EAAO,EAAE,EAAA,EAAI,OAAA,EAAS,QAAA,EAAU,CAAA,EAAG,MAAA,EAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,KAAK,CAAA,EAAE;AAAA;AAAA,EAC7D,UAAU,EAAE,EAAA,EAAI,YAAY,QAAA,EAAU,EAAA,EAAI,QAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAC,CAAA,EAAE;AAAA,EACpF,UAAU,EAAE,EAAA,EAAI,YAAY,QAAA,EAAU,EAAA,EAAI,QAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAC,CAAA;AAAE;AACtF;;;AClBO,IAAM,YAAA,GAAe;AAmCrB,SAAS,eAAe,IAAA,EAA0B;AACvD,EAAA,OAAO,eAAA,CAAgB,MAAM,IAAI,CAAA;AACnC;AAGO,SAAS,mBAAmB,IAAA,EAAe;AAChD,EAAA,OAAO,eAAA,CAAgB,UAAU,IAAI,CAAA;AACvC","file":"index.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * swaralipi-js JSON spec — Zod schema + inferred types.\n\n/** Octave registers */\nexport const octaveSchema = z.enum([\n 'ati-mandra', // very low\n 'mandra', // low (dot below)\n 'madhyam', // middle\n 'taar', // high (ref/dot above)\n 'ati-taar', // very high\n]);\nexport type Octave = z.infer<typeof octaveSchema>;\n\n/**\n * The seven shuddha svara letters:\n * `d` = ধৈবত (dha), `n` = নিষাদ (ni). Komal/tivra are flags, not letters.\n */\nexport const svaraLetterSchema = z.enum(['s', 'r', 'g', 'm', 'p', 'd', 'n']);\nexport type SvaraLetter = z.infer<typeof svaraLetterSchema>;\n\n/** A pitch as `[octave, letter]` */\nexport const svaraSchema = z.tuple([octaveSchema, svaraLetterSchema]);\nexport type Svara = z.infer<typeof svaraSchema>;\n\n/** Microtone variants below komal (legend: অল্পকোমল / অতিকোমল). */\nexport const microtoneSchema = z.enum(['alpakomal', 'atikomal']);\nexport type Microtone = z.infer<typeof microtoneSchema>;\n\n/**\n * Barline weights. Swarabitan distinguishes the light দাঁড়ি (।) that\n * separates vibhags *within* a taal cycle from the দণ্ড (danda, I) strokes:\n * - `dari` — । vibhag separator inside the cycle\n * - `single` — I end of one taal cycle (ফেরা)\n * - `double` — II section (kali) boundary / return-to-asthayi marker\n * - `quad` — IIII end of the song\n */\nexport const barSchema = z.enum(['dari', 'single', 'double', 'quad']);\nexport type Bar = z.infer<typeof barSchema>;\n\n/**\n * A repeat-bracket edge. Brackets span a range of notes; the opening note\n * carries `{ ..., edge: 'open' }` and the closing note `{ ..., edge: 'close' }`.\n * kind: `repeat` = {} গুন্ডবন্ধনী, `skip` = () বক্রবন্ধনী (omit on repeat),\n * `alt` = [] সরল বন্ধনী (changed notes on repeat).\n */\nexport const bracketSchema = z.object({\n kind: z.enum(['repeat', 'skip', 'alt']),\n edge: z.enum(['open', 'close']),\n});\nexport type Bracket = z.infer<typeof bracketSchema>;\n\n/**\n * A single token in a row. A token is one of: a pitched note (`svara`),\n * a rest (`rest`), an আ-কার sustain (`sustain`), a barline (`bar`), or a\n * purely raw/undecoded cell (`raw`) — possibly carrying annotations\n * (`above`/`below`) or a lyric syllable on an otherwise empty column.\n * The `.refine` enforces that a note carries at least one of these so\n * truly empty tokens can't slip through.\n *\n * `above`/`below` make `Note` recursive, so the type is hand-written and\n * the schema is typed `z.ZodType<Note>` via `z.lazy` (all fields are\n * optional, hence input ≡ output and the annotation is sound).\n */\nexport interface Note {\n /** Pitch. Omitted for rests, sustains, and barlines. */\n svara?: Svara;\n /** কোমল (flat). */\n komal?: boolean;\n /** তীব্র / কড়ি (sharp — applies to ma). */\n tivra?: boolean;\n /** Sub-komal microtone (legend: অল্পকোমল / অতিকোমল). */\n microtone?: Microtone;\n /** Duration in মাত্রা (beats): 1 (default), 0.5, 0.25, 2, … */\n durationMatra?: number;\n /**\n * আ-কার: no new syllable attack. Alone (no `svara`) it holds the previous\n * note's pitch and vowel; combined with `svara` it is a melisma — the\n * pitch moves while the previous syllable's vowel continues (Swarabitan\n * writes these with a leading hyphen, e.g. `-sfa`).\n */\n sustain?: boolean;\n /** বিরাম: a rest of `durationMatra` beats. */\n rest?: boolean;\n /** কণ স্বর: a grace note attached before this note. */\n kan?: Svara;\n /** মীড় (glide/slur) endpoint. */\n meend?: 'start' | 'end';\n /** Barline. A bar token usually has no `svara`. */\n bar?: Bar;\n /** Repeat-bracket edges opening/closing on this token. */\n brackets?: Bracket[];\n /** Lyric syllable aligned under this note */\n lyric?: string;\n /** Lossless passthrough of the source cell (e.g. raw Swarabitan code). */\n raw?: string;\n /**\n * Annotation notes rendered above this column: alt-on-repeat passages\n * (legend: পরিবর্তিত স্বর in [ ] শিরোদেশে), stop marks, beat numbers.\n */\n above?: Note[];\n /** Annotation notes rendered below this column. */\n below?: Note[];\n}\n\nexport const noteSchema: z.ZodType<Note> = z.lazy(() =>\n z\n .object({\n svara: svaraSchema.optional(),\n komal: z.boolean().optional(),\n tivra: z.boolean().optional(),\n microtone: microtoneSchema.optional(),\n durationMatra: z.number().positive().optional(),\n sustain: z.boolean().optional(),\n rest: z.boolean().optional(),\n kan: svaraSchema.optional(),\n meend: z.enum(['start', 'end']).optional(),\n bar: barSchema.optional(),\n brackets: z.array(bracketSchema).optional(),\n lyric: z.string().optional(),\n raw: z.string().optional(),\n above: z.array(noteSchema).optional(),\n below: z.array(noteSchema).optional(),\n })\n .refine(\n (n) =>\n n.svara !== undefined ||\n n.rest === true ||\n n.sustain === true ||\n n.bar !== undefined ||\n n.raw !== undefined ||\n (n.brackets !== undefined && n.brackets.length > 0) ||\n (n.above !== undefined && n.above.length > 0) ||\n (n.below !== undefined && n.below.length > 0) ||\n n.lyric !== undefined,\n {\n message:\n 'note must carry one of: svara, rest, sustain, bar, raw, lyric, brackets, or a non-empty above/below',\n },\n ),\n);\n\n/** A written line of the song: a sequence of note tokens. */\nexport const rowSchema = z.object({\n /** Optional line label (e.g. a tuk/section marker). */\n label: z.string().optional(),\n notes: z.array(noteSchema),\n});\nexport type Row = z.infer<typeof rowSchema>;\n\n/** A structural section: আস্থায়ী / অন্তরা / সঞ্চারী / আভোগ, or free text. */\nexport const partSchema = z.object({\n name: z.string().optional(),\n rows: z.array(rowSchema),\n});\nexport type Part = z.infer<typeof partSchema>;\n\n/**\n * Taal definition. `numBeats` is the cycle length in মাত্রা; `bhaags` (if\n * present) must sum to `numBeats`; `sam`/`khaali` are 0-based beat indices.\n */\nexport const taalSchema = z\n .object({\n /** Player sample key, e.g. `dadra`, `teentaal`. */\n id: z.string(),\n /**\n * Which tabla loop variation to play, e.g. `pro` (CDN dir suffix). Optional\n * and additive — omitted means the taal's default variation, so existing\n * docs are unaffected. The player honors it but never exposes a variation\n * picker; selecting a non-default variation is the consumer's premium policy.\n */\n variation: z.string().optional(),\n numBeats: z.number().int().positive(),\n /** Vibhag groupings; if given, they sum to numBeats. */\n bhaags: z.array(z.number().int().positive()).optional(),\n /** Sam (cycle start) beat index, 0-based. */\n sam: z.number().int().nonnegative().optional(),\n /** Khaali (wave) beat indices, 0-based. */\n khaali: z.array(z.number().int().nonnegative()).optional(),\n })\n .refine((t) => t.bhaags === undefined || t.bhaags.reduce((a, b) => a + b, 0) === t.numBeats, {\n message: 'bhaags must sum to numBeats',\n });\nexport type Taal = z.infer<typeof taalSchema>;\n\n/** Document-level metadata. */\nexport const metaSchema = z.object({\n title: z.string(),\n /** Cross-reference to a gitabitan.io song content id (filename, immutable). */\n songId: z.string().optional(),\n /** Source NLTR node/song id. */\n nltrId: z.number().int().optional(),\n taal: taalSchema.optional(),\n /**\n * The taal name exactly as printed in the source (e.g. `তালমুক্ত`,\n * `ষষ্ঠী(২/৪)`). Always set by the NLTR converter; `taal` is set only\n * when the name resolves to a known definition.\n */\n taalName: z.string().optional(),\n /** Base pitch for playback, e.g. `C`, `C#`, or the player's `cs` form. */\n tonic: z.string().optional(),\n /** Default playback tempo in matra/min. Player-only — the viewer ignores it.\n * The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`\n * tweak → this → 90). `null` is the converter's blank placeholder = unset. */\n bpm: z.number().positive().nullable().optional(),\n raag: z.string().optional(),\n /** আবর্তন: number of taal cycles, when the source states it. */\n avartan: z.number().int().positive().optional(),\n /** স্বরলিপিকার (notation author). */\n notationBy: z.string().optional(),\n /** Provenance note or URL. */\n source: z.string().optional(),\n});\nexport type Meta = z.infer<typeof metaSchema>;\n\n/** A complete swaralipi document. */\nexport const swaralipiSchema = z.object({\n /** Spec version this document targets (see SPEC_VERSION in ./index). */\n version: z.string(),\n meta: metaSchema,\n parts: z.array(partSchema),\n});\nexport type Swaralipi = z.infer<typeof swaralipiSchema>;\n","import type { Taal } from './schema.js';\n\n/**\n * Reference definitions for the taals the player will sample:\n * adachautaal, dadra, ektaal, jhaptaal, kehrwa, rupak, shashthi, teentaal.\n *\n * `numBeats` and the `bhaags` given below are standard Hindustani taal theory.\n * `bhaags` is omitted where a single canonical division isn't well-agreed\n * (adachautaal) — we assert only what's uncontested. `sam` is beat 0 for all.\n *\n * Tabla loops live under `tabla/<id>/` by default; per-taal variation and\n * skip-bpm overrides (e.g. shashthi → `tabla/shashthi-pro/`) are in\n * instruments.ts's `TABLA_VARIATIONS`.\n */\nexport const TAALS = {\n dadra: { id: 'dadra', numBeats: 6, bhaags: [3, 3], sam: 0, khaali: [3] },\n kehrwa: { id: 'kehrwa', numBeats: 8, bhaags: [4, 4], sam: 0, khaali: [4] },\n rupak: { id: 'rupak', numBeats: 7, bhaags: [3, 2, 2], sam: 0, khaali: [0] },\n jhaptaal: { id: 'jhaptaal', numBeats: 10, bhaags: [2, 3, 2, 3], sam: 0, khaali: [5] },\n ektaal: { id: 'ektaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] },\n adachautaal: { id: 'adachautaal', numBeats: 14, sam: 0 },\n choutaal: { id: 'choutaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] }, // চৌতাল\n shashthi: { id: 'shashthi', numBeats: 6, bhaags: [2, 4], sam: 0 }, // ষষ্ঠী\n teora: { id: 'teora', numBeats: 7, bhaags: [3, 2, 2], sam: 0 }, // টেওরা\n teentaal: { id: 'teentaal', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] },\n aratheka: { id: 'aratheka', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] }, // আড়াঠেকা\n} as const satisfies Record<string, Taal>;\n\nexport type TaalId = keyof typeof TAALS;\n","/**\n * @ugfoundation/swaralipi-js/spec\n *\n * The swaralipi JSON spec: Zod schemas, inferred TS types, and parse helpers.\n */\nimport { swaralipiSchema, type Swaralipi } from './schema.js';\n\n/** Current spec version. Documents declare the version they target. */\nexport const SPEC_VERSION = '0.3.0';\n\nexport {\n octaveSchema,\n svaraLetterSchema,\n svaraSchema,\n microtoneSchema,\n barSchema,\n bracketSchema,\n noteSchema,\n rowSchema,\n partSchema,\n taalSchema,\n metaSchema,\n swaralipiSchema,\n} from './schema.js';\n\nexport type {\n Octave,\n SvaraLetter,\n Svara,\n Microtone,\n Bar,\n Bracket,\n Note,\n Row,\n Part,\n Taal,\n Meta,\n Swaralipi,\n} from './schema.js';\n\nexport { TAALS, type TaalId } from './taals.js';\n\n/** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */\nexport function parseSwaralipi(data: unknown): Swaralipi {\n return swaralipiSchema.parse(data);\n}\n\n/** Non-throwing variant: returns Zod's `{ success, data | error }` result. */\nexport function safeParseSwaralipi(data: unknown) {\n return swaralipiSchema.safeParse(data);\n}\n"]}
@@ -4,7 +4,7 @@ export { B as Bar, b as Bracket, M as Meta, c as Microtone, O as Octave, P as Pa
4
4
  export { a as TAALS, T as TaalId } from '../taals-FmEulsjY.cjs';
5
5
 
6
6
  /** Current spec version. Documents declare the version they target. */
7
- declare const SPEC_VERSION = "0.2.1";
7
+ declare const SPEC_VERSION = "0.3.0";
8
8
 
9
9
  /** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */
10
10
  declare function parseSwaralipi(data: unknown): Swaralipi;
@@ -4,7 +4,7 @@ export { B as Bar, b as Bracket, M as Meta, c as Microtone, O as Octave, P as Pa
4
4
  export { a as TAALS, T as TaalId } from '../taals-FmEulsjY.js';
5
5
 
6
6
  /** Current spec version. Documents declare the version they target. */
7
- declare const SPEC_VERSION = "0.2.1";
7
+ declare const SPEC_VERSION = "0.3.0";
8
8
 
9
9
  /** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */
10
10
  declare function parseSwaralipi(data: unknown): Swaralipi;
@@ -1,4 +1,4 @@
1
- export { SPEC_VERSION, barSchema, bracketSchema, metaSchema, microtoneSchema, noteSchema, octaveSchema, parseSwaralipi, partSchema, rowSchema, safeParseSwaralipi, svaraLetterSchema, svaraSchema, swaralipiSchema, taalSchema } from '../chunk-KYNCQ7OF.js';
1
+ export { SPEC_VERSION, barSchema, bracketSchema, metaSchema, microtoneSchema, noteSchema, octaveSchema, parseSwaralipi, partSchema, rowSchema, safeParseSwaralipi, svaraLetterSchema, svaraSchema, swaralipiSchema, taalSchema } from '../chunk-VCRWS3F3.js';
2
2
  export { TAALS } from '../chunk-H6HC44PZ.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map