notula 0.0.0-stage → 0.7.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 (76) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/LICENSE +21 -0
  3. package/README.md +214 -2
  4. package/README.zh-CN.md +216 -0
  5. package/THIRD_PARTY_NOTICES.md +50 -0
  6. package/assets/fonts/OFL.txt +94 -0
  7. package/dist-lib/analyze-DA8Fg8Gs.js +2 -0
  8. package/dist-lib/analyze-DA8Fg8Gs.js.map +1 -0
  9. package/dist-lib/audio/highlight.d.ts +14 -0
  10. package/dist-lib/audio/index.d.ts +3 -0
  11. package/dist-lib/audio/player.d.ts +58 -0
  12. package/dist-lib/audio/timeline.d.ts +45 -0
  13. package/dist-lib/audio.js +2 -0
  14. package/dist-lib/audio.js.map +1 -0
  15. package/dist-lib/core/color.d.ts +1 -0
  16. package/dist-lib/core/number.d.ts +2 -0
  17. package/dist-lib/core/rational.d.ts +20 -0
  18. package/dist-lib/core/text.d.ts +1 -0
  19. package/dist-lib/dsl/ast.d.ts +295 -0
  20. package/dist-lib/dsl/lexer.d.ts +115 -0
  21. package/dist-lib/dsl/parser.d.ts +7 -0
  22. package/dist-lib/index-B2NJU9Bz.js +2 -0
  23. package/dist-lib/index-B2NJU9Bz.js.map +1 -0
  24. package/dist-lib/index.d.ts +16 -0
  25. package/dist-lib/index.js +2 -0
  26. package/dist-lib/index.js.map +1 -0
  27. package/dist-lib/integrations/index.d.ts +1 -0
  28. package/dist-lib/integrations/markdown-dom.d.ts +8 -0
  29. package/dist-lib/integrations/markdown.d.ts +45 -0
  30. package/dist-lib/integrations/obsidian-child.d.ts +16 -0
  31. package/dist-lib/integrations/obsidian-playback.d.ts +19 -0
  32. package/dist-lib/integrations/obsidian.d.ts +86 -0
  33. package/dist-lib/integrations/panorama-scroll.d.ts +7 -0
  34. package/dist-lib/integrations/resize.d.ts +6 -0
  35. package/dist-lib/integrations.js +2 -0
  36. package/dist-lib/integrations.js.map +1 -0
  37. package/dist-lib/ir/analyze.d.ts +13 -0
  38. package/dist-lib/ir/types.d.ts +263 -0
  39. package/dist-lib/layout/accidentals.d.ts +20 -0
  40. package/dist-lib/layout/annotations.d.ts +163 -0
  41. package/dist-lib/layout/articulations.d.ts +93 -0
  42. package/dist-lib/layout/beaming.d.ts +92 -0
  43. package/dist-lib/layout/grace.d.ts +33 -0
  44. package/dist-lib/layout/layout.d.ts +3 -0
  45. package/dist-lib/layout/polyphony.d.ts +20 -0
  46. package/dist-lib/layout/spacing.d.ts +38 -0
  47. package/dist-lib/layout/staff.d.ts +60 -0
  48. package/dist-lib/layout/stems-chords.d.ts +59 -0
  49. package/dist-lib/layout/systems.d.ts +31 -0
  50. package/dist-lib/layout/ties-slurs.d.ts +59 -0
  51. package/dist-lib/layout/tuplets.d.ts +25 -0
  52. package/dist-lib/layout/types.d.ts +210 -0
  53. package/dist-lib/metrics/bravura-glyph-paths.d.ts +9 -0
  54. package/dist-lib/metrics/bravura-metrics.d.ts +52 -0
  55. package/dist-lib/micro/micro.d.ts +33 -0
  56. package/dist-lib/obsidian.js +2 -0
  57. package/dist-lib/obsidian.js.map +1 -0
  58. package/dist-lib/render.d.ts +20 -0
  59. package/dist-lib/shared.d.ts +8 -0
  60. package/dist-lib/svg/dom.d.ts +4 -0
  61. package/dist-lib/svg/emitter.d.ts +56 -0
  62. package/docs/INTEGRATIONS.md +200 -0
  63. package/docs/SYNTAX.md +74 -0
  64. package/docs/assets/cadenza-dark.svg +497 -0
  65. package/docs/assets/cadenza-light.svg +497 -0
  66. package/docs/assets/chords-dark.svg +695 -0
  67. package/docs/assets/chords-light.svg +695 -0
  68. package/docs/assets/hero-dark.svg +498 -0
  69. package/docs/assets/hero-light.svg +498 -0
  70. package/docs/assets/logo-dark.svg +12 -0
  71. package/docs/assets/logo-light.svg +12 -0
  72. package/docs/assets/wordmark-dark.svg +41 -0
  73. package/docs/assets/wordmark-light.svg +41 -0
  74. package/examples/obsidian-plugin/README.md +43 -0
  75. package/llms.txt +141 -0
  76. package/package.json +94 -4
@@ -0,0 +1,16 @@
1
+ export type { Rational } from './core/rational.js';
2
+ export type { Alteration, ArpeggioAst, ArpeggioKind, ArticulationAst, ArticulationKind, AstDocument, AstDuration, AstPitch, AstStatement, BarlineKind, BaseDurationDen, BracketMarkAst, BreathMarkAst, BreathMarkKind, ClefName, Diagnostic, DurationAst, DynamicAst, DynamicKind, FingeringAst, FingeringDigit, HairpinKind, HairpinMarkAst, LeadSheetChordAst, MarkPlacement, OrnamentAst, OrnamentKind, OttavaShift, ParsedLeadSheetChord, PartialStatement, PedalKind, PedalMarkAst, PitchLetter, Position, ScaleDegreeAst, Span, TimeSignatureSymbol, TimeStatement, TremoloAst, TremoloDiv, } from './dsl/ast.js';
3
+ export { tokenize } from './dsl/lexer.js';
4
+ export { parse } from './dsl/parser.js';
5
+ export * from './ir/types.js';
6
+ export { analyze } from './ir/analyze.js';
7
+ export type { BBox, BezierCurveShape, BraceShape, DebugColumnInfo, EmbedMode, GlyphBox, GlyphRole, LayoutItem, LayoutOptions, LayoutTree, LineShape, Point, PolygonShape, SystemBounds, TextBox, } from './layout/types.js';
8
+ export { layoutScore } from './layout/layout.js';
9
+ export { DEFAULT_PALETTE } from './layout/annotations.js';
10
+ export { emitSvg, emitSvgHast, emitSvgTree, type HastElementNode, type HastNode, type HastPropertyValue, type HastTextNode, type SvgEmitOptions, type SvgElementNode, } from './svg/emitter.js';
11
+ export { compileMicro, compileMicroHast, compileMicroSvgTree, renderMicroToString, type MicroLayoutResult, type MicroRenderOptions, } from './micro/micro.js';
12
+ export { BRAVURA_GLYPH_PATHS, type GlyphPathMap, } from './metrics/bravura-glyph-paths.js';
13
+ export { BRAVURA_METRICS, type SmuflMetrics, type SmuflGlyphName } from './metrics/bravura-metrics.js';
14
+ export * from './audio/index.js';
15
+ export * from './integrations/index.js';
16
+ export { compile, render, renderToHast, renderToString, renderToSvgTree, type CompileResult, type RenderOptions, } from './render.js';
@@ -0,0 +1,2 @@
1
+ import{a,p as s,t as e}from"./analyze-DA8Fg8Gs.js";import{B as r,a as i,D as o,c as l,b as t,d as n,e as c,f as m,g as T,h as d,i as g,l as p,n as y,r as u,j as S,k as P,m as h,o as b,p as k}from"./index-B2NJU9Bz.js";import{NotulaPlayer as A,attachPlaybackHighlight as H,buildPlaybackTimeline as M,midiToFrequency as R,playScore as v}from"./audio.js";export{r as BRAVURA_GLYPH_PATHS,i as BRAVURA_METRICS,o as DEFAULT_PALETTE,A as NotulaPlayer,a as analyze,H as attachPlaybackHighlight,M as buildPlaybackTimeline,l as compile,t as compileMicro,n as compileMicroHast,c as compileMicroSvgTree,m as createRehypeNotulaPlugin,T as emitSvg,d as emitSvgHast,g as emitSvgTree,p as layoutScore,R as midiToFrequency,y as notulaMarkdownItPlugin,s as parse,v as playScore,u as render,S as renderMicroToString,P as renderNotulaInElement,h as renderToHast,b as renderToString,k as renderToSvgTree,e as tokenize};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export { createRehypeNotulaPlugin, notulaMarkdownItPlugin, renderNotulaInElement, type AutoRenderOptions, type HastNode, type MarkdownItFenceTokenLike, type MarkdownItLike, type MarkdownItRenderRule, type MarkdownItTokenLike, type MarkdownNotulaOptions, type NotulaPluginOptions, } from './markdown.js';
@@ -0,0 +1,8 @@
1
+ export declare function isRenderedNotula(el: Element): boolean;
2
+ type InlineMode = 'micro' | 'compact';
3
+ export declare function getNotulaInlineMode(text: string, code?: Element): InlineMode | undefined;
4
+ export declare function parseNotulaInline(text: string, code?: Element): {
5
+ mode: InlineMode;
6
+ source: string;
7
+ } | undefined;
8
+ export {};
@@ -0,0 +1,45 @@
1
+ import { type HastNode } from '../svg/emitter.js';
2
+ export type { HastNode };
3
+ export interface MarkdownNotulaOptions {
4
+ readonly standalone?: boolean;
5
+ readonly defaultPxPerSp?: number;
6
+ readonly maxWidthSp?: number;
7
+ readonly emPerSp?: number;
8
+ readonly palette?: Readonly<Record<string, string>>;
9
+ readonly color?: string;
10
+ readonly maxBlocks?: number;
11
+ readonly maxInline?: number;
12
+ }
13
+ export type NotulaPluginOptions = MarkdownNotulaOptions;
14
+ export declare function normalizeBlockBudget(maxBlocks?: number): number;
15
+ interface ParsedFenceConfig {
16
+ readonly mode?: 'display' | 'compact' | 'micro';
17
+ readonly maxWidth?: number;
18
+ readonly pxPerSp?: number;
19
+ readonly standalone?: boolean;
20
+ }
21
+ export declare function parseFenceParams(info: string): ParsedFenceConfig;
22
+ export interface MarkdownItTokenLike {
23
+ readonly content: string;
24
+ }
25
+ export interface MarkdownItFenceTokenLike extends MarkdownItTokenLike {
26
+ readonly info: string;
27
+ }
28
+ export type MarkdownItRenderRule<TToken extends MarkdownItTokenLike = MarkdownItTokenLike, TRest extends readonly unknown[] = readonly any[]> = (tokens: TToken[], idx: number, ...rest: TRest) => string;
29
+ export interface MarkdownItLike<TFenceToken extends MarkdownItFenceTokenLike = MarkdownItFenceTokenLike, TInlineToken extends MarkdownItTokenLike = MarkdownItTokenLike, TFenceRest extends readonly unknown[] = readonly any[], TInlineRest extends readonly unknown[] = readonly any[]> {
30
+ renderer: {
31
+ render?(tokens: any[], ...rest: any[]): string;
32
+ rules: {
33
+ fence?: MarkdownItRenderRule<TFenceToken, TFenceRest>;
34
+ code_inline?: MarkdownItRenderRule<TInlineToken, TInlineRest>;
35
+ };
36
+ };
37
+ }
38
+ export declare function notulaMarkdownItPlugin<TFenceToken extends MarkdownItFenceTokenLike = MarkdownItFenceTokenLike, TInlineToken extends MarkdownItTokenLike = MarkdownItTokenLike, TFenceRest extends readonly unknown[] = readonly any[], TInlineRest extends readonly unknown[] = readonly any[]>(md: MarkdownItLike<TFenceToken, TInlineToken, TFenceRest, TInlineRest>, pluginOpts?: NotulaPluginOptions): void;
39
+ export declare function createRehypeNotulaPlugin(pluginOpts?: NotulaPluginOptions): () => (tree: HastNode) => HastNode;
40
+ export interface AutoRenderOptions extends NotulaPluginOptions {
41
+ readonly autoResize?: boolean;
42
+ }
43
+ export declare function renderNotulaInElement(root: HTMLElement, options?: AutoRenderOptions): {
44
+ destroy(): void;
45
+ };
@@ -0,0 +1,16 @@
1
+ export interface ObsidianChildLike {
2
+ containerEl?: HTMLElement;
3
+ load(): void;
4
+ onload(): void;
5
+ unload(): void;
6
+ onunload(): void;
7
+ register?(cb: () => void): void;
8
+ addChild?(child: ObsidianChildLike): ObsidianChildLike;
9
+ removeChild?(child: ObsidianChildLike): ObsidianChildLike;
10
+ }
11
+ export type ObsidianRenderChildCtor = new (containerEl: HTMLElement) => ObsidianChildLike;
12
+ export interface ObsidianMarkdownContextLike {
13
+ readonly sourcePath?: string;
14
+ addChild?(child: ObsidianChildLike): void;
15
+ }
16
+ export declare function trackObsidianRenderChild(containerEl: HTMLElement, ctx: ObsidianMarkdownContextLike | undefined, activeCleanups: Set<() => void>, onUnload: () => void, RenderChildCtor?: ObsidianRenderChildCtor): () => void;
@@ -0,0 +1,19 @@
1
+ import { NotulaPlayer, type AudioVoiceBackend } from '../audio/player.js';
2
+ export type LoadSampledPiano = (ctx: AudioContext, opts?: {
3
+ signal?: AbortSignal;
4
+ onRuntimeError?: () => void;
5
+ }) => Promise<AudioVoiceBackend>;
6
+ export interface PlaybackBlock {
7
+ begin(): void;
8
+ play(player: NotulaPlayer, backend: AudioVoiceBackend | undefined, onEnd: () => void): void;
9
+ status(message: '' | 'Loading…' | 'Offline fallback'): void;
10
+ reset(keepSoundStatus?: boolean): void;
11
+ }
12
+ export declare function createObsidianPlayback(loadSampledPiano?: LoadSampledPiano): {
13
+ isActive: (block: PlaybackBlock) => boolean;
14
+ play: (block: PlaybackBlock, sampled: boolean) => void;
15
+ restart: (block: PlaybackBlock) => void;
16
+ release: (block: PlaybackBlock) => void;
17
+ stop: (block: PlaybackBlock) => void;
18
+ dispose: () => void;
19
+ };
@@ -0,0 +1,86 @@
1
+ import { type LoadSampledPiano } from './obsidian-playback.js';
2
+ import { type ObsidianMarkdownContextLike, type ObsidianRenderChildCtor } from './obsidian-child.js';
3
+ export type { ObsidianChildLike, ObsidianMarkdownContextLike, ObsidianRenderChildCtor } from './obsidian-child.js';
4
+ export type { LoadSampledPiano } from './obsidian-playback.js';
5
+ export type ObsidianAppLike = object;
6
+ export interface ObsidianPluginLike {
7
+ app?: ObsidianAppLike;
8
+ loadData?(): Promise<unknown>;
9
+ saveData?(settings: NotulaObsidianSettings): Promise<void>;
10
+ addSettingTab?(tab: SettingsTab): void;
11
+ registerMarkdownCodeBlockProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: ObsidianMarkdownContextLike) => void | Promise<void>): unknown;
12
+ registerMarkdownPostProcessor(processor: (el: HTMLElement, ctx: ObsidianMarkdownContextLike) => void | Promise<void>, sortOrder?: number): unknown;
13
+ register(cb: () => void): void;
14
+ onload(): void | Promise<void>;
15
+ onunload(): void;
16
+ }
17
+ export type ObsidianPluginCtor<T extends ObsidianPluginLike> = new (...args: any[]) => T;
18
+ type ScoreView = 'wrap' | 'panorama';
19
+ type SoundEngine = 'builtin' | 'smplr';
20
+ export interface NotulaBlockHeader {
21
+ zoom?: number;
22
+ view?: ScoreView;
23
+ speed?: number;
24
+ audio?: 'on' | 'off';
25
+ sound?: SoundEngine;
26
+ theme?: 'inherit';
27
+ }
28
+ export interface NotulaObsidianSettings {
29
+ readonly defaultZoom: number;
30
+ readonly defaultView: ScoreView;
31
+ readonly defaultSpeed: number;
32
+ readonly defaultSound?: SoundEngine;
33
+ }
34
+ export declare const DEFAULT_OBSIDIAN_SETTINGS: Readonly<Required<NotulaObsidianSettings>>;
35
+ interface SettingsTab {
36
+ containerEl: HTMLElement;
37
+ display(): void;
38
+ }
39
+ interface SettingDropdown {
40
+ addOption(value: string, label: string): unknown;
41
+ setValue(value: string): unknown;
42
+ onChange(cb: (value: string) => void | Promise<void>): unknown;
43
+ }
44
+ interface SettingRow {
45
+ setName(name: string): SettingRow;
46
+ setDesc?(desc: string): SettingRow;
47
+ addDropdown(cb: (dropdown: SettingDropdown) => void): unknown;
48
+ }
49
+ type AddDropdown = (name: string, choices: Array<[string, string]>, value: string, onChange: (selected: string) => void | Promise<void>, description?: string) => void;
50
+ export interface ObsidianBlockExtensionContext<T> {
51
+ readonly secondary: HTMLElement;
52
+ readonly stage: HTMLElement;
53
+ readonly source: string;
54
+ readonly sourcePath?: string;
55
+ readonly doc: Document;
56
+ readonly plugin: T;
57
+ readonly getExtraSetting: (key: string) => unknown;
58
+ readonly registerCleanup: (cleanup: () => void) => void;
59
+ }
60
+ export interface ObsidianSettingsExtensionContext<T> {
61
+ readonly containerEl: HTMLElement;
62
+ readonly plugin: T;
63
+ readonly addDropdown: AddDropdown;
64
+ readonly getExtraSetting: (key: string) => unknown;
65
+ readonly saveExtraSetting: (key: string, value: unknown) => Promise<void>;
66
+ }
67
+ export interface NotulaObsidianOptions<T extends ObsidianPluginLike = ObsidianPluginLike> {
68
+ readonly pxPerSp?: number;
69
+ readonly maxWidthSp?: number;
70
+ readonly maxBlocks?: number;
71
+ readonly emPerSp?: number;
72
+ readonly standalone?: boolean;
73
+ readonly color?: string;
74
+ readonly palette?: Readonly<Record<string, string>>;
75
+ readonly enableAudio?: boolean;
76
+ readonly loadSampledPiano?: LoadSampledPiano;
77
+ /** Settings text describing when the optional sampler downloads audio. */
78
+ readonly soundDescription?: string;
79
+ readonly MarkdownRenderChild?: ObsidianRenderChildCtor;
80
+ readonly PluginSettingTab?: abstract new (app: NonNullable<T['app']>, plugin: T) => SettingsTab;
81
+ readonly Setting?: new (containerEl: HTMLElement) => SettingRow;
82
+ readonly onMountBlock?: (ctx: ObsidianBlockExtensionContext<T>) => void;
83
+ readonly onRenderSettings?: (ctx: ObsidianSettingsExtensionContext<T>) => void;
84
+ }
85
+ export declare function parseNotulaBlockHeader(source: string): NotulaBlockHeader;
86
+ export declare function createNotulaObsidianPluginClass<T extends ObsidianPluginLike>(BasePlugin: abstract new (...args: ConstructorParameters<ObsidianPluginCtor<T>>) => T, opts?: NotulaObsidianOptions<T>): ObsidianPluginCtor<T>;
@@ -0,0 +1,7 @@
1
+ export declare function createPanoramaScroll(stage: HTMLElement): {
2
+ readonly target: number | undefined;
3
+ cancel: () => void;
4
+ resumeWhenIdle(resume: () => void): void;
5
+ to(left: number, smooth?: boolean): void;
6
+ movedManually(): boolean;
7
+ };
@@ -0,0 +1,6 @@
1
+ type ResizeListener = (width: number) => void;
2
+ export declare function observeResize(element: HTMLElement, listener: ResizeListener, Observer?: {
3
+ new (callback: ResizeObserverCallback): ResizeObserver;
4
+ prototype: ResizeObserver;
5
+ }): () => void;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ import{f as a,n as e,k as n}from"./index-B2NJU9Bz.js";export{a as createRehypeNotulaPlugin,e as notulaMarkdownItPlugin,n as renderNotulaInElement};
2
+ //# sourceMappingURL=integrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { type AstDocument, type BaseDurationDen, type PitchLetter, type TremoloDiv } from '../dsl/ast.js';
2
+ import type { ScoreIR } from './types.js';
3
+ export declare const MAX_MEASURES = 256;
4
+ export declare const MAX_EVENTS_PER_STAFF = 4096;
5
+ export declare const MAX_NOTES_PER_CHORD = 16;
6
+ export declare const MAX_GRACE_PER_HOST = 16;
7
+ export declare const MAX_STAVES = 8;
8
+ export declare const MIN_RELATIVE_OCTAVE = -2;
9
+ export declare const MAX_RELATIVE_OCTAVE = 9;
10
+ export declare function computeKeyMap(fifths: number): Record<PitchLetter, -1 | 0 | 1>;
11
+ export declare function beamCountForBaseDen(baseDen: BaseDurationDen): 0 | 1 | 2 | 3 | 4 | 5;
12
+ export declare function tremoloStrokeCount(baseDen: BaseDurationDen, div: TremoloDiv): number;
13
+ export declare function analyze(ast: AstDocument): ScoreIR;
@@ -0,0 +1,263 @@
1
+ import type { Rational } from '../core/rational.js';
2
+ import type { Alteration, ArpeggioKind, ArticulationKind, BarlineKind, BaseDurationDen, ClefName, Diagnostic, DynamicKind, FingeringDigit, MarkPlacement, OrnamentKind, ParsedLeadSheetChord, PedalKind, PitchLetter, BreathMarkKind, Span, TimeSignatureSymbol, TremoloDiv } from '../dsl/ast.js';
3
+ export type { ArpeggioKind, ArticulationKind, BreathMarkKind, DynamicKind, HairpinKind, MarkPlacement, OrnamentKind, OttavaShift, PedalKind, TimeSignatureSymbol, TremoloDiv, } from '../dsl/ast.js';
4
+ export interface ArticulationIR {
5
+ readonly kind: ArticulationKind;
6
+ readonly placement: MarkPlacement;
7
+ }
8
+ export interface OrnamentIR {
9
+ readonly kind: OrnamentKind;
10
+ readonly placement: MarkPlacement;
11
+ }
12
+ export interface DynamicIR {
13
+ readonly kind: DynamicKind;
14
+ readonly placement: MarkPlacement;
15
+ }
16
+ export interface TimeSignatureIR {
17
+ readonly numerator: number;
18
+ readonly denominator: number;
19
+ readonly measureCapacity: Rational;
20
+ readonly symbol?: TimeSignatureSymbol;
21
+ }
22
+ export interface KeySignatureIR {
23
+ readonly fifths: number;
24
+ readonly mode: 'major' | 'minor';
25
+ }
26
+ export interface FingeringIR {
27
+ readonly digit: FingeringDigit;
28
+ readonly placement: 'above' | 'below';
29
+ }
30
+ export interface ScaleDegreeIR {
31
+ readonly degree: 1 | 2 | 3 | 4 | 5 | 6 | 7;
32
+ readonly accidental?: '#' | 'b' | 'n';
33
+ readonly placement: 'above' | 'below';
34
+ }
35
+ export interface LeadSheetChordIR extends ParsedLeadSheetChord {
36
+ readonly raw: string;
37
+ }
38
+ export interface AnnotationIR {
39
+ readonly above: readonly string[];
40
+ readonly below: readonly string[];
41
+ readonly fingerings: readonly FingeringIR[];
42
+ readonly scaleDegrees?: readonly ScaleDegreeIR[];
43
+ readonly chordSymbol?: LeadSheetChordIR;
44
+ }
45
+ export interface PitchIR {
46
+ readonly letter: PitchLetter;
47
+ readonly alter: Alteration;
48
+ readonly octave: number;
49
+ readonly diatonicPitch: number;
50
+ readonly midi: number;
51
+ readonly displayedAccidental: Alteration | null;
52
+ readonly cautionary?: boolean;
53
+ readonly parenthesized?: true;
54
+ readonly highlight?: string;
55
+ }
56
+ export interface GraceEventIR {
57
+ readonly kind: 'grace';
58
+ readonly id: string;
59
+ readonly acciaccatura: boolean;
60
+ readonly notes: readonly PitchIR[];
61
+ readonly baseDen: BaseDurationDen;
62
+ readonly dots: 0 | 1 | 2;
63
+ readonly beamCount: 0 | 1 | 2 | 3 | 4 | 5;
64
+ readonly graceBlockId?: number;
65
+ readonly graceBeamGroup?: number;
66
+ readonly ottavaShift?: -1 | 1;
67
+ readonly highlight?: string;
68
+ readonly span: Span;
69
+ }
70
+ export type VoiceStemRole = 'neutral' | 'up' | 'down';
71
+ export interface NoteOrChordEventIR {
72
+ readonly visualStaffIndex?: 0 | 1;
73
+ readonly kind: 'notes';
74
+ readonly id: string;
75
+ readonly notes: readonly PitchIR[];
76
+ readonly baseDen: BaseDurationDen;
77
+ readonly dots: 0 | 1 | 2;
78
+ readonly duration: Rational;
79
+ readonly beatStart: Rational;
80
+ readonly beamCount: 0 | 1 | 2 | 3 | 4 | 5;
81
+ readonly ottavaShift?: -1 | 1;
82
+ readonly highlight?: string;
83
+ readonly annotations?: AnnotationIR;
84
+ readonly articulations?: readonly ArticulationIR[];
85
+ readonly ornament?: OrnamentIR;
86
+ readonly arpeggio?: ArpeggioKind;
87
+ readonly breathMark?: BreathMarkKind;
88
+ readonly tremolo?: TremoloDiv;
89
+ readonly dynamic?: DynamicIR;
90
+ readonly gracePrefix?: readonly GraceEventIR[];
91
+ readonly tupletIds?: readonly string[];
92
+ readonly voiceId?: string;
93
+ readonly staffId?: string;
94
+ readonly stemRole?: VoiceStemRole;
95
+ readonly span: Span;
96
+ }
97
+ export interface RestEventIR {
98
+ readonly kind: 'rest';
99
+ readonly id: string;
100
+ readonly fullMeasure?: boolean;
101
+ readonly baseDen: BaseDurationDen;
102
+ readonly dots: 0 | 1 | 2;
103
+ readonly duration: Rational;
104
+ readonly beatStart: Rational;
105
+ readonly beamCount: 0;
106
+ readonly annotations?: AnnotationIR;
107
+ readonly articulations?: readonly ArticulationIR[];
108
+ readonly breathMark?: BreathMarkKind;
109
+ readonly dynamic?: DynamicIR;
110
+ readonly tupletIds?: readonly string[];
111
+ readonly voiceId?: string;
112
+ readonly staffId?: string;
113
+ readonly stemRole?: VoiceStemRole;
114
+ readonly span: Span;
115
+ }
116
+ export interface SpacerEventIR {
117
+ readonly kind: 'spacer';
118
+ readonly id: string;
119
+ readonly baseDen: BaseDurationDen;
120
+ readonly dots: 0 | 1 | 2;
121
+ readonly duration: Rational;
122
+ readonly beatStart: Rational;
123
+ readonly beamCount: 0;
124
+ readonly dynamic?: DynamicIR;
125
+ readonly tupletIds?: readonly string[];
126
+ readonly voiceId?: string;
127
+ readonly staffId?: string;
128
+ readonly span: Span;
129
+ }
130
+ export type MeasureEventIR = NoteOrChordEventIR | RestEventIR | SpacerEventIR;
131
+ export interface BeamGroupIR {
132
+ readonly crossStaff?: boolean;
133
+ readonly eventIds: readonly string[];
134
+ readonly manual: boolean;
135
+ }
136
+ export interface TieLinkIR {
137
+ readonly fromEventId: string;
138
+ readonly toEventId: string;
139
+ readonly diatonicPitch: number;
140
+ readonly alter: Alteration;
141
+ }
142
+ export interface SlurLinkIR {
143
+ readonly fromEventId: string;
144
+ readonly toEventId: string;
145
+ }
146
+ export interface TupletIR {
147
+ readonly id: string;
148
+ readonly num: number;
149
+ readonly den: number;
150
+ readonly eventIds: readonly string[];
151
+ }
152
+ export interface VoiceIR {
153
+ readonly voiceId: string;
154
+ readonly voiceIndex: number;
155
+ readonly stemRole: VoiceStemRole;
156
+ readonly events: readonly MeasureEventIR[];
157
+ readonly beamGroups: readonly BeamGroupIR[];
158
+ }
159
+ export interface HairpinIR {
160
+ readonly id: string;
161
+ readonly kind: 'cresc' | 'dim';
162
+ readonly placement: 'above' | 'below';
163
+ readonly startMeasure: number;
164
+ readonly startEventId: string;
165
+ readonly startBeat: Rational;
166
+ readonly endMeasure: number;
167
+ readonly endEventId: string;
168
+ readonly endBeat: Rational;
169
+ readonly startDynamic?: DynamicKind;
170
+ readonly endDynamic?: DynamicKind;
171
+ readonly endReason: 'stop' | 'dynamic';
172
+ readonly color?: string;
173
+ readonly highlightTag?: string;
174
+ }
175
+ export interface MeasureIR {
176
+ readonly index: number;
177
+ readonly clef: ClefName;
178
+ readonly key: KeySignatureIR;
179
+ readonly previousKey?: KeySignatureIR;
180
+ readonly time: TimeSignatureIR;
181
+ readonly showClef: boolean;
182
+ readonly showKey: boolean;
183
+ readonly showTime: boolean;
184
+ readonly openingBarline?: '|:';
185
+ readonly voices: readonly VoiceIR[];
186
+ readonly events: readonly MeasureEventIR[];
187
+ readonly beamGroups: readonly BeamGroupIR[];
188
+ readonly barline: BarlineKind;
189
+ readonly explicitBarline: boolean;
190
+ readonly capacityReached: boolean;
191
+ readonly isPartial?: boolean;
192
+ readonly capacityOverride?: Rational;
193
+ readonly breakAfter?: boolean;
194
+ }
195
+ export interface OttavaSpanIR {
196
+ readonly id: string;
197
+ readonly shift: -1 | 1;
198
+ readonly startMeasure: number;
199
+ readonly startEventId: string;
200
+ readonly endMeasure: number;
201
+ readonly endEventId: string;
202
+ }
203
+ export interface PedalMarkIR {
204
+ readonly id: string;
205
+ readonly kind: PedalKind;
206
+ readonly measureIndex: number;
207
+ readonly eventId: string;
208
+ readonly beatStart: Rational;
209
+ }
210
+ export interface AnalysisBracketIR {
211
+ readonly id: string;
212
+ readonly voiceId: string;
213
+ readonly placement: 'above' | 'below';
214
+ readonly label: string;
215
+ readonly startEventId: string;
216
+ readonly endEventId: string;
217
+ }
218
+ export interface StaffIR {
219
+ readonly id: string;
220
+ readonly index: number;
221
+ readonly measures: readonly MeasureIR[];
222
+ readonly ties: readonly TieLinkIR[];
223
+ readonly slurs: readonly SlurLinkIR[];
224
+ readonly tuplets: readonly TupletIR[];
225
+ readonly hairpins?: readonly HairpinIR[];
226
+ readonly ottavas?: readonly OttavaSpanIR[];
227
+ readonly pedals?: readonly PedalMarkIR[];
228
+ readonly analysisBrackets?: readonly AnalysisBracketIR[];
229
+ }
230
+ export interface TempoMarkIR {
231
+ readonly id: string;
232
+ readonly measureIndex: number;
233
+ readonly beatStart: Rational;
234
+ readonly text?: string;
235
+ readonly beatUnit?: BaseDurationDen;
236
+ readonly beatDots?: 0 | 1;
237
+ readonly bpm?: number;
238
+ readonly quarterBpm?: number;
239
+ readonly span: Span;
240
+ }
241
+ export interface VoltaRegionIR {
242
+ readonly id: string;
243
+ readonly repeatStartMeasure: number;
244
+ readonly ending1Start: number;
245
+ readonly ending1End: number;
246
+ readonly ending2Start: number;
247
+ readonly ending2End: number;
248
+ readonly ending2Closed: boolean;
249
+ }
250
+ export type StaffGroupKind = 'single' | 'grandStaff' | 'stacked';
251
+ export interface ScoreIR {
252
+ readonly groupKind: StaffGroupKind;
253
+ readonly staves: readonly StaffIR[];
254
+ readonly measures: readonly MeasureIR[];
255
+ readonly ties: readonly TieLinkIR[];
256
+ readonly slurs: readonly SlurLinkIR[];
257
+ readonly tuplets: readonly TupletIR[];
258
+ readonly tempos?: readonly TempoMarkIR[];
259
+ readonly voltas?: readonly VoltaRegionIR[];
260
+ readonly hasInvalidRepeats?: boolean;
261
+ readonly minEventDuration: Rational;
262
+ readonly diagnostics: readonly Diagnostic[];
263
+ }
@@ -0,0 +1,20 @@
1
+ import type { PitchIR } from '../ir/types.js';
2
+ import { type SmuflGlyphName, type SmuflMetrics } from '../metrics/bravura-metrics.js';
3
+ import { type BBox, type GlyphBox, type LineShape, type PositionedHead } from './types.js';
4
+ export declare const ACCIDENTAL_CONSTANTS: {
5
+ readonly toNoteGap: 0.28;
6
+ readonly columnGap: 0.18;
7
+ readonly verticalPad: 0.15;
8
+ readonly parenGap: 0.04;
9
+ readonly cutOutMargin: 0.03;
10
+ };
11
+ /**
12
+ * ACC-04: Build horizontal-band cutout bounding rectangles for an accidental glyph,
13
+ * expressed with X relative to the item's right edge (`rightEdge = 0`, so `maxX <= 0`)
14
+ * and Y in staff coordinates centered at `y`. Cautionary triples remain uncarved.
15
+ */
16
+ export declare function buildAccidentalCutoutRects(glyphName: SmuflGlyphName, y: number, metrics: SmuflMetrics, scale?: number, cautionary?: boolean): BBox[];
17
+ export declare function layoutChordAccidentals(sortedNotesAsc: ReadonlyArray<{
18
+ pitch: PitchIR;
19
+ step: number;
20
+ }>, heads: readonly PositionedHead[], ledgerLines: readonly LineShape[], metrics: SmuflMetrics, sourceId: string, scale?: number, palette?: Readonly<Record<string, string>>): GlyphBox[];