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,295 @@
1
+ export interface Position {
2
+ readonly line: number;
3
+ readonly column: number;
4
+ readonly offset: number;
5
+ }
6
+ export interface Span {
7
+ readonly start: Position;
8
+ readonly end: Position;
9
+ }
10
+ export interface Diagnostic {
11
+ readonly severity: 'error' | 'warning';
12
+ readonly code: string;
13
+ readonly message: string;
14
+ readonly span: Span;
15
+ }
16
+ export type PitchLetter = 'c' | 'd' | 'e' | 'f' | 'g' | 'a' | 'b';
17
+ export type Alteration = -2 | -1 | 0 | 1 | 2;
18
+ export type ClefName = 'treble' | 'treble_8' | 'treble^8' | 'bass' | 'bass_8' | 'bass^8' | 'alto' | 'tenor';
19
+ export type BarlineKind = '|' | '||' | '|.' | '|:' | ':|' | ':|:';
20
+ export type BaseDurationDen = 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128;
21
+ export type FingeringDigit = 0 | 1 | 2 | 3 | 4 | 5;
22
+ export type TimeSignatureSymbol = 'numeric' | 'common' | 'cut';
23
+ export type ArticulationKind = 'staccato' | 'tenuto' | 'accent' | 'marcato' | 'fermata';
24
+ export type OrnamentKind = 'trill' | 'prall' | 'mordent' | 'turn';
25
+ export type PedalKind = 'on' | 'off';
26
+ export type ArpeggioKind = 'normal' | 'up' | 'down';
27
+ export type BreathMarkKind = 'comma' | 'caesura';
28
+ export type TremoloDiv = 8 | 16 | 32;
29
+ export type OttavaShift = -1 | 0 | 1;
30
+ export type MarkPlacement = 'auto' | 'above' | 'below';
31
+ export type DynamicKind = 'ppp' | 'pp' | 'p' | 'mp' | 'mf' | 'f' | 'ff' | 'fff' | 'sf' | 'sfz' | 'sffff' | 'fp';
32
+ export type HairpinKind = 'cresc' | 'dim' | 'stop';
33
+ export interface HairpinMarkAst {
34
+ readonly kind: HairpinKind;
35
+ readonly placement: MarkPlacement;
36
+ readonly span: Span;
37
+ }
38
+ export interface ArticulationAst {
39
+ readonly kind: ArticulationKind;
40
+ readonly placement: MarkPlacement;
41
+ readonly span: Span;
42
+ }
43
+ export interface OrnamentAst {
44
+ readonly kind: OrnamentKind;
45
+ readonly placement: MarkPlacement;
46
+ readonly span: Span;
47
+ }
48
+ export interface PedalMarkAst {
49
+ readonly kind: PedalKind;
50
+ readonly span: Span;
51
+ }
52
+ export interface ArpeggioAst {
53
+ readonly kind: ArpeggioKind;
54
+ readonly span: Span;
55
+ }
56
+ export interface BreathMarkAst {
57
+ readonly kind: BreathMarkKind;
58
+ readonly span: Span;
59
+ }
60
+ export interface TremoloAst {
61
+ readonly kind: TremoloDiv;
62
+ readonly span: Span;
63
+ }
64
+ export interface DynamicAst {
65
+ readonly kind: DynamicKind;
66
+ readonly placement: MarkPlacement;
67
+ readonly span: Span;
68
+ }
69
+ export interface FingeringAst {
70
+ readonly digit: FingeringDigit;
71
+ readonly placement: 'above' | 'below';
72
+ readonly span: Span;
73
+ }
74
+ export interface ScaleDegreeAst {
75
+ readonly degree: 1 | 2 | 3 | 4 | 5 | 6 | 7;
76
+ readonly accidental?: '#' | 'b' | 'n';
77
+ readonly placement: 'above' | 'below';
78
+ readonly span: Span;
79
+ }
80
+ export interface LeadSheetChordAst {
81
+ readonly text: string;
82
+ readonly span: Span;
83
+ }
84
+ export type BracketMarkAst = {
85
+ readonly kind: 'start';
86
+ readonly placement: 'above' | 'below';
87
+ readonly label: string;
88
+ readonly span: Span;
89
+ } | {
90
+ readonly kind: 'end';
91
+ readonly span: Span;
92
+ };
93
+ export interface ParsedLeadSheetChord {
94
+ readonly root: string;
95
+ readonly rootAccidental?: string;
96
+ readonly quality: string;
97
+ readonly bass?: string;
98
+ readonly bassAccidental?: string;
99
+ }
100
+ export declare function hasOwn(obj: object, key: PropertyKey): boolean;
101
+ export declare function parseLeadSheetChordText(raw: string): ParsedLeadSheetChord | null;
102
+ export interface AstPitch {
103
+ readonly letter: PitchLetter;
104
+ readonly alter: Alteration;
105
+ readonly octave: number;
106
+ readonly forcedAccidental?: '!' | '?';
107
+ readonly parenthesized?: true;
108
+ readonly highlight?: string;
109
+ readonly tie?: boolean;
110
+ readonly span: Span;
111
+ }
112
+ export interface AstDuration {
113
+ readonly baseDen: BaseDurationDen;
114
+ readonly dots: 0 | 1 | 2;
115
+ readonly span: Span;
116
+ }
117
+ export type DurationAst = AstDuration;
118
+ export interface TimeStatement {
119
+ readonly kind: 'time';
120
+ readonly numerator: number;
121
+ readonly denominator: number;
122
+ readonly symbol?: TimeSignatureSymbol;
123
+ readonly span: Span;
124
+ }
125
+ export interface PartialStatement {
126
+ readonly kind: 'partial';
127
+ readonly duration: DurationAst;
128
+ readonly span: Span;
129
+ }
130
+ export type AstStatement = {
131
+ readonly kind: 'clef';
132
+ readonly clef: ClefName;
133
+ readonly span: Span;
134
+ } | {
135
+ readonly kind: 'key';
136
+ readonly tonicLetter: PitchLetter;
137
+ readonly tonicAlter: Alteration;
138
+ readonly mode: 'major' | 'minor';
139
+ readonly span: Span;
140
+ } | TimeStatement | PartialStatement | {
141
+ readonly kind: 'tempo';
142
+ readonly text?: string;
143
+ readonly beatUnit?: BaseDurationDen;
144
+ readonly beatDots?: 0 | 1;
145
+ readonly bpm?: number;
146
+ readonly span: Span;
147
+ } | {
148
+ readonly kind: 'bar';
149
+ readonly barline: BarlineKind;
150
+ readonly explicit: boolean;
151
+ readonly span: Span;
152
+ } | {
153
+ readonly kind: 'note';
154
+ readonly pitch: AstPitch;
155
+ readonly duration: AstDuration | null;
156
+ readonly tie?: boolean;
157
+ readonly slurStart?: boolean;
158
+ readonly slurEnd?: boolean;
159
+ readonly highlight?: string;
160
+ readonly aboveLabels?: readonly string[];
161
+ readonly belowLabels?: readonly string[];
162
+ readonly fingerings?: readonly FingeringAst[];
163
+ readonly scaleDegrees?: readonly ScaleDegreeAst[];
164
+ readonly chordSymbol?: LeadSheetChordAst;
165
+ readonly articulations?: readonly ArticulationAst[];
166
+ readonly ornaments?: readonly OrnamentAst[];
167
+ readonly dynamics?: readonly DynamicAst[];
168
+ readonly hairpins?: readonly HairpinMarkAst[];
169
+ readonly pedals?: readonly PedalMarkAst[];
170
+ readonly arpeggios?: readonly ArpeggioAst[];
171
+ readonly breathMarks?: readonly BreathMarkAst[];
172
+ readonly tremolos?: readonly TremoloAst[];
173
+ readonly bracketMarks?: readonly BracketMarkAst[];
174
+ readonly span: Span;
175
+ } | {
176
+ readonly kind: 'rest';
177
+ readonly duration: AstDuration | null;
178
+ readonly aboveLabels?: readonly string[];
179
+ readonly belowLabels?: readonly string[];
180
+ readonly articulations?: readonly ArticulationAst[];
181
+ readonly dynamics?: readonly DynamicAst[];
182
+ readonly hairpins?: readonly HairpinMarkAst[];
183
+ readonly pedals?: readonly PedalMarkAst[];
184
+ readonly breathMarks?: readonly BreathMarkAst[];
185
+ readonly span: Span;
186
+ } | {
187
+ readonly kind: 'measureRest';
188
+ readonly aboveLabels?: readonly string[];
189
+ readonly belowLabels?: readonly string[];
190
+ readonly articulations?: readonly ArticulationAst[];
191
+ readonly dynamics?: readonly DynamicAst[];
192
+ readonly hairpins?: readonly HairpinMarkAst[];
193
+ readonly pedals?: readonly PedalMarkAst[];
194
+ readonly breathMarks?: readonly BreathMarkAst[];
195
+ readonly span: Span;
196
+ } | {
197
+ readonly kind: 'chord';
198
+ readonly pitches: readonly AstPitch[];
199
+ readonly duration: AstDuration | null;
200
+ readonly tie?: boolean;
201
+ readonly slurStart?: boolean;
202
+ readonly slurEnd?: boolean;
203
+ readonly highlight?: string;
204
+ readonly aboveLabels?: readonly string[];
205
+ readonly belowLabels?: readonly string[];
206
+ readonly fingerings?: readonly FingeringAst[];
207
+ readonly scaleDegrees?: readonly ScaleDegreeAst[];
208
+ readonly chordSymbol?: LeadSheetChordAst;
209
+ readonly articulations?: readonly ArticulationAst[];
210
+ readonly ornaments?: readonly OrnamentAst[];
211
+ readonly dynamics?: readonly DynamicAst[];
212
+ readonly hairpins?: readonly HairpinMarkAst[];
213
+ readonly pedals?: readonly PedalMarkAst[];
214
+ readonly arpeggios?: readonly ArpeggioAst[];
215
+ readonly breathMarks?: readonly BreathMarkAst[];
216
+ readonly tremolos?: readonly TremoloAst[];
217
+ readonly bracketMarks?: readonly BracketMarkAst[];
218
+ readonly span: Span;
219
+ } | {
220
+ readonly kind: 'staffSwitch';
221
+ readonly visualStaffIndex: 0 | 1;
222
+ readonly span: Span;
223
+ } | {
224
+ readonly kind: 'beamOpen';
225
+ readonly span: Span;
226
+ } | {
227
+ readonly kind: 'beamClose';
228
+ readonly span: Span;
229
+ } | {
230
+ readonly kind: 'tuplet';
231
+ readonly num: number;
232
+ readonly den: number;
233
+ readonly body: readonly AstStatement[];
234
+ readonly span: Span;
235
+ } | {
236
+ readonly kind: 'relative';
237
+ readonly refPitch: AstPitch | null;
238
+ readonly body: readonly AstStatement[];
239
+ readonly span: Span;
240
+ } | {
241
+ readonly kind: 'grace';
242
+ readonly acciaccatura: boolean;
243
+ readonly body: readonly AstStatement[];
244
+ readonly span: Span;
245
+ } | {
246
+ readonly kind: 'cadenza';
247
+ readonly on: boolean;
248
+ readonly span: Span;
249
+ } | {
250
+ readonly kind: 'highlight';
251
+ readonly colorOrRole: string;
252
+ readonly body: readonly AstStatement[];
253
+ readonly span: Span;
254
+ } | {
255
+ readonly kind: 'spacer';
256
+ readonly duration: AstDuration | null;
257
+ readonly dynamics?: readonly DynamicAst[];
258
+ readonly hairpins?: readonly HairpinMarkAst[];
259
+ readonly pedals?: readonly PedalMarkAst[];
260
+ readonly span: Span;
261
+ } | {
262
+ readonly kind: 'break';
263
+ readonly span: Span;
264
+ } | {
265
+ readonly kind: 'volta';
266
+ readonly ending: 0 | 1 | 2;
267
+ readonly span: Span;
268
+ } | {
269
+ readonly kind: 'ottava';
270
+ readonly shift: OttavaShift;
271
+ readonly span: Span;
272
+ } | {
273
+ readonly kind: 'voiceDir';
274
+ readonly dir: 'up' | 'down' | 'neutral';
275
+ readonly span: Span;
276
+ } | {
277
+ readonly kind: 'polyphony';
278
+ readonly voices: readonly (readonly AstStatement[])[];
279
+ readonly span: Span;
280
+ } | {
281
+ readonly kind: 'staff';
282
+ readonly id?: string;
283
+ readonly body: readonly AstStatement[];
284
+ readonly span: Span;
285
+ } | {
286
+ readonly kind: 'grandStaff';
287
+ readonly staves: readonly Extract<AstStatement, {
288
+ kind: 'staff';
289
+ }>[];
290
+ readonly span: Span;
291
+ };
292
+ export interface AstDocument {
293
+ readonly statements: readonly AstStatement[];
294
+ readonly diagnostics: readonly Diagnostic[];
295
+ }
@@ -0,0 +1,115 @@
1
+ import type { Alteration, BarlineKind, Diagnostic, PitchLetter, Span } from './ast.js';
2
+ export type Token = {
3
+ readonly type: 'command';
4
+ readonly name: string;
5
+ readonly span: Span;
6
+ } | {
7
+ readonly type: 'string';
8
+ readonly value: string;
9
+ readonly unclosed?: boolean;
10
+ readonly span: Span;
11
+ } | {
12
+ readonly type: 'pitch';
13
+ readonly letter: PitchLetter;
14
+ readonly alter: Alteration;
15
+ readonly octave: number;
16
+ readonly hasOctaveMarks: boolean;
17
+ readonly raw: string;
18
+ readonly span: Span;
19
+ } | {
20
+ readonly type: 'rest';
21
+ readonly span: Span;
22
+ } | {
23
+ readonly type: 'spacer';
24
+ readonly span: Span;
25
+ } | {
26
+ readonly type: 'ident';
27
+ readonly value: string;
28
+ readonly span: Span;
29
+ } | {
30
+ readonly type: 'int';
31
+ readonly value: number;
32
+ readonly raw: string;
33
+ readonly span: Span;
34
+ } | {
35
+ readonly type: 'dots';
36
+ readonly count: number;
37
+ readonly span: Span;
38
+ } | {
39
+ readonly type: 'barline';
40
+ readonly value: BarlineKind;
41
+ readonly span: Span;
42
+ } | {
43
+ readonly type: 'ldangle';
44
+ readonly span: Span;
45
+ } | {
46
+ readonly type: 'rdangle';
47
+ readonly span: Span;
48
+ } | {
49
+ readonly type: 'hairpin';
50
+ readonly value: 'cresc' | 'dim' | 'stop';
51
+ readonly span: Span;
52
+ } | {
53
+ readonly type: 'langle';
54
+ readonly span: Span;
55
+ } | {
56
+ readonly type: 'rangle';
57
+ readonly span: Span;
58
+ } | {
59
+ readonly type: 'doubleBackslash';
60
+ readonly span: Span;
61
+ } | {
62
+ readonly type: 'lbracket';
63
+ readonly span: Span;
64
+ } | {
65
+ readonly type: 'rbracket';
66
+ readonly span: Span;
67
+ } | {
68
+ readonly type: 'lbrace';
69
+ readonly span: Span;
70
+ } | {
71
+ readonly type: 'rbrace';
72
+ readonly span: Span;
73
+ } | {
74
+ readonly type: 'lparen';
75
+ readonly span: Span;
76
+ } | {
77
+ readonly type: 'rparen';
78
+ readonly span: Span;
79
+ } | {
80
+ readonly type: 'tilde';
81
+ readonly span: Span;
82
+ } | {
83
+ readonly type: 'bang';
84
+ readonly span: Span;
85
+ } | {
86
+ readonly type: 'question';
87
+ readonly span: Span;
88
+ } | {
89
+ readonly type: 'at';
90
+ readonly span: Span;
91
+ } | {
92
+ readonly type: 'caret';
93
+ readonly span: Span;
94
+ } | {
95
+ readonly type: 'underscore';
96
+ readonly span: Span;
97
+ } | {
98
+ readonly type: 'minus';
99
+ readonly span: Span;
100
+ } | {
101
+ readonly type: 'slash';
102
+ readonly span: Span;
103
+ } | {
104
+ readonly type: 'equals';
105
+ readonly span: Span;
106
+ } | {
107
+ readonly type: 'eof';
108
+ readonly span: Span;
109
+ };
110
+ export declare const MAX_INPUT_LENGTH = 65536;
111
+ export declare function tokenize(source: string): {
112
+ tokens: Token[];
113
+ diagnostics: Diagnostic[];
114
+ truncated: boolean;
115
+ };
@@ -0,0 +1,7 @@
1
+ import { type AstDocument } from './ast.js';
2
+ import { MAX_INPUT_LENGTH } from './lexer.js';
3
+ export { MAX_INPUT_LENGTH };
4
+ export declare const MAX_NESTING_DEPTH = 32;
5
+ export declare const MAX_TIME_NUMERATOR = 64;
6
+ export declare const MAX_OCTAVE_MARKS = 6;
7
+ export declare function parse(source: string): AstDocument;