jpfun 0.6.0 → 0.8.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 (134) hide show
  1. package/Bravura-LICENSE.txt +93 -0
  2. package/README.md +49 -146
  3. package/dist/Bravura-LICENSE.txt +93 -0
  4. package/dist/converter/midi/convert.d.ts +3 -11
  5. package/dist/converter/midi/convert.js +89 -67
  6. package/dist/converter/musicxml/features.d.ts +34 -12
  7. package/dist/converter/musicxml/features.js +131 -24
  8. package/dist/converter/musicxml/index.js +221 -54
  9. package/dist/converter/musicxml/model.d.ts +24 -0
  10. package/dist/core.d.ts +1 -0
  11. package/dist/core.js +1 -0
  12. package/dist/diagnostic.d.ts +7 -1
  13. package/dist/diagnostic.js +40 -88
  14. package/dist/fraction.js +3 -2
  15. package/dist/functions/ASTtypes.d.ts +2 -18
  16. package/dist/functions/ASTtypes.js +0 -16
  17. package/dist/functions/arpeggio/index.js +17 -22
  18. package/dist/functions/arpeggio/shape.d.ts +1 -1
  19. package/dist/functions/arpeggio/shape.js +27 -21
  20. package/dist/functions/bar/index.d.ts +8 -0
  21. package/dist/functions/bar/index.js +139 -36
  22. package/dist/functions/beam/auto.d.ts +1 -2
  23. package/dist/functions/beam/auto.js +44 -27
  24. package/dist/functions/beam/index.js +2 -3
  25. package/dist/functions/beam/layout.d.ts +1 -1
  26. package/dist/functions/beam/layout.js +16 -24
  27. package/dist/functions/br/index.d.ts +34 -2
  28. package/dist/functions/br/index.js +8 -8
  29. package/dist/functions/dash/index.js +6 -6
  30. package/dist/functions/default.js +10 -5
  31. package/dist/functions/div/index.d.ts +1 -0
  32. package/dist/functions/div/index.js +8 -4
  33. package/dist/functions/dot/index.js +2 -2
  34. package/dist/functions/dyn/index.js +49 -31
  35. package/dist/functions/gliss/index.d.ts +2 -0
  36. package/dist/functions/gliss/index.js +202 -0
  37. package/dist/functions/grace/index.d.ts +1 -7
  38. package/dist/functions/grace/index.js +11 -19
  39. package/dist/functions/head/index.js +41 -60
  40. package/dist/functions/key/index.js +8 -10
  41. package/dist/functions/meter/index.d.ts +56 -1
  42. package/dist/functions/meter/index.js +30 -24
  43. package/dist/functions/note/accidentals.js +10 -16
  44. package/dist/functions/note/index.js +18 -8
  45. package/dist/functions/note/noteName.d.ts +16 -0
  46. package/dist/functions/note/noteName.js +88 -0
  47. package/dist/functions/note/source-transform.js +6 -5
  48. package/dist/functions/ottava/index.d.ts +2 -0
  49. package/dist/functions/ottava/index.js +233 -0
  50. package/dist/functions/page/index.d.ts +1 -0
  51. package/dist/functions/page/index.js +22 -13
  52. package/dist/functions/pagebreak/index.d.ts +2 -0
  53. package/dist/functions/pagebreak/index.js +36 -0
  54. package/dist/functions/rest/index.js +15 -15
  55. package/dist/functions/set/index.js +4 -4
  56. package/dist/functions/slide/index.d.ts +2 -0
  57. package/dist/functions/slide/index.js +132 -0
  58. package/dist/functions/stack/index.js +8 -15
  59. package/dist/functions/symbol/index.d.ts +30 -2
  60. package/dist/functions/symbol/index.js +93 -19
  61. package/dist/functions/symbol/ornament.d.ts +1 -2
  62. package/dist/functions/symbol/ornament.js +14 -19
  63. package/dist/functions/symbol/shape.d.ts +6 -0
  64. package/dist/functions/symbol/shape.js +20 -4
  65. package/dist/functions/symbol/symbols/coda.d.ts +4 -0
  66. package/dist/functions/symbol/symbols/coda.js +56 -0
  67. package/dist/functions/symbol/symbols/dynamics.d.ts +1 -1
  68. package/dist/functions/symbol/symbols/dynamics.js +18 -8
  69. package/dist/functions/symbol/symbols/fine.js +1 -1
  70. package/dist/functions/symbol/symbols/harmonic.d.ts +2 -0
  71. package/dist/functions/symbol/symbols/harmonic.js +11 -0
  72. package/dist/functions/symbol/symbols/marcato.d.ts +2 -0
  73. package/dist/functions/symbol/symbols/marcato.js +22 -0
  74. package/dist/functions/symbol/symbols/staccato.d.ts +2 -0
  75. package/dist/functions/symbol/symbols/staccato.js +24 -0
  76. package/dist/functions/symbol/symbols/tenuto.d.ts +2 -0
  77. package/dist/functions/symbol/symbols/tenuto.js +11 -0
  78. package/dist/functions/symbol/symbols/tocoda.d.ts +2 -0
  79. package/dist/functions/symbol/symbols/tocoda.js +16 -0
  80. package/dist/functions/symbol/symbols/tr.js +46 -1
  81. package/dist/functions/symbol/symbols/turn.d.ts +3 -0
  82. package/dist/functions/symbol/symbols/turn.js +50 -0
  83. package/dist/functions/symbol/symbols/wheel.d.ts +2 -0
  84. package/dist/functions/symbol/symbols/wheel.js +36 -0
  85. package/dist/functions/temporal.d.ts +17 -6
  86. package/dist/functions/temporal.js +17 -6
  87. package/dist/functions/text/index.js +15 -6
  88. package/dist/functions/tie/index.js +64 -30
  89. package/dist/functions/tremolo/index.d.ts +2 -0
  90. package/dist/functions/tremolo/index.js +319 -0
  91. package/dist/functions/tuplet/index.js +4 -8
  92. package/dist/functions/up/index.js +7 -9
  93. package/dist/functions/voice/connections.js +7 -5
  94. package/dist/functions/voice/index.js +19 -11
  95. package/dist/functions/volta/index.js +41 -21
  96. package/dist/jpfun.core.min.js +64 -80
  97. package/dist/jpfun.from-midi.min.js +5 -5
  98. package/dist/jpfun.from-musicxml.min.js +8 -8
  99. package/dist/jpfun.min.js +69 -85
  100. package/dist/layout/default.d.ts +0 -1
  101. package/dist/layout/default.js +0 -1
  102. package/dist/layout/engine.d.ts +1 -0
  103. package/dist/layout/engine.js +42 -11
  104. package/dist/layout/page.d.ts +3 -2
  105. package/dist/layout/page.js +6 -5
  106. package/dist/layout/types.d.ts +4 -0
  107. package/dist/lowering/loweringContext.d.ts +11 -13
  108. package/dist/lowering/loweringContext.js +30 -197
  109. package/dist/lowering/types.d.ts +1 -3
  110. package/dist/parser/parse-utils/note-utils.d.ts +1 -1
  111. package/dist/parser/parse-utils/note-utils.js +8 -9
  112. package/dist/parser/parse-utils/string-utils.d.ts +3 -2
  113. package/dist/parser/parse-utils/string-utils.js +16 -3
  114. package/dist/parser/parserContext.d.ts +2 -0
  115. package/dist/parser/parserContext.js +36 -8
  116. package/dist/pipeline.js +0 -1
  117. package/dist/playback/compile.js +131 -72
  118. package/dist/playback/event.d.ts +1 -1
  119. package/dist/playback/event.js +9 -9
  120. package/dist/playback/time.js +42 -31
  121. package/dist/playback/types.d.ts +7 -3
  122. package/dist/render/canvas.d.ts +2 -0
  123. package/dist/render/canvas.js +25 -22
  124. package/dist/render/recording.js +1 -4
  125. package/dist/render/svg.js +1 -0
  126. package/dist/render/text.d.ts +1 -1
  127. package/dist/render/text.js +3 -2
  128. package/dist/render/translate.d.ts +0 -1
  129. package/dist/render/translate.js +6 -23
  130. package/dist/render/types.d.ts +1 -0
  131. package/grammar.md +52 -25
  132. package/package.json +3 -3
  133. package/dist/functions/note/noteNameFSM.d.ts +0 -8
  134. package/dist/functions/note/noteNameFSM.js +0 -181
@@ -0,0 +1,93 @@
1
+ Copyright (c) 2026, Steinberg Media Technologies GmbH (http://www.steinberg.net/),
2
+ with Reserved Font Name "Bravura".
3
+
4
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
5
+ This license is copied below, and is also available with a FAQ at:
6
+ http://scripts.sil.org/OFL
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION AND CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
package/README.md CHANGED
@@ -1,15 +1,8 @@
1
1
  # jpFun
2
2
 
3
- A TypeScript engine that compiles a compact numbered-notation DSL into SVG or Canvas, with layout-independent playback.
3
+ A zero-dependency TypeScript engine that compiles a functional numbered-notation (Jianpu) DSL into SVG, Canvas, and layout-independent playback plans.
4
4
 
5
- [Documentation](https://madderscientist.github.io/jpFun/)
6
-
7
- ## Features
8
-
9
- - Extensible music DSL with exact rational timing
10
- - Automatic spacing and pagination, shared by SVG and Canvas
11
- - Structured diagnostics and source-aware editing
12
- - Zero runtime dependencies; works in Node.js and modern browsers
5
+ [Documentation](https://madderscientist.github.io/jpFun/docs/) · [Playground](https://madderscientist.github.io/jpFun/playground) · [Grammar Reference](grammar.md)
13
6
 
14
7
  ## Installation
15
8
 
@@ -17,188 +10,98 @@ A TypeScript engine that compiles a compact numbered-notation DSL into SVG or Ca
17
10
  npm install jpfun
18
11
  ```
19
12
 
20
- jpFun is ESM-only, supports Node.js 18+ and modern browsers, and has no compiler DOM dependency.
21
-
22
- ## Browser via CDN
13
+ The npm package is ESM-only and supports Node.js 18+ and modern browsers.
23
14
 
24
- Use the bundled `jpfun` global without a build step:
15
+ Or load via CDN (`globalThis.jpfun`):
25
16
 
26
17
  ```html
27
18
  <script src="https://unpkg.com/jpfun"></script>
28
- <script>
29
- const { compileScore, renderLayoutPagesToSvg } = jpfun;
30
- document.body.innerHTML = renderLayoutPagesToSvg(compileScore("1 2 3 | 4 -").layout)[0];
31
- </script>
32
19
  ```
33
20
 
34
- Or import an ES module:
35
-
36
- ```html
37
- <script type="module">
38
- import { compileScore } from "https://cdn.jsdelivr.net/npm/jpfun/+esm";
39
- </script>
40
- ```
21
+ In production, pin all CDN bundles to the same `jpfun@x.y.z` version.
41
22
 
42
- Pin `jpfun@x.y.z` in production; these URLs otherwise use the latest release.
43
-
44
- Optional bundles under `https://unpkg.com/jpfun/dist/` share the same global:
23
+ IIFE bundles under `jpfun/dist/` share the `jpfun` global:
45
24
 
46
25
  | Bundle | Capabilities |
47
26
  | --- | --- |
48
- | `jpfun.core.min.js` | Compilation, rendering, playback, and source editing |
27
+ | `jpfun.min.js` | Core and both converters |
28
+ | `jpfun.core.min.js` | Compilation, rendering, playback, and source editing; no converters |
29
+ | `jpfun.from-midi.min.js` | MIDI JSON import; automatic line breaking also requires core |
49
30
  | `jpfun.from-musicxml.min.js` | Standalone MusicXML import |
50
- | `jpfun.from-midi.min.js` | MIDI JSON import; automatic line breaking also requires the core bundle |
51
31
 
52
32
  For standalone MIDI import, set a positive `barsPerLine`.
53
33
 
54
34
  ## Quick Start
55
35
 
56
36
  ```ts
57
- import { compileScore, renderLayoutPagesToSvg } from "jpfun";
37
+ import {
38
+ compilePlayback,
39
+ compileScore,
40
+ renderLayoutPagesToSvg,
41
+ } from "jpfun";
58
42
 
59
43
  const source = `
60
- @1(C4)
61
- @tempo(96)
62
-
44
+ @1(C4) @tempo(96)
63
45
  1/ 2/ 3 4 | 5 -
64
46
  `;
65
47
 
66
- const result = compileScore(source);
67
- const pages = renderLayoutPagesToSvg(result.layout);
68
- ```
69
-
70
- `renderLayoutPagesToSvg` returns one SVG string per page, ready to save or insert into a web page.
71
-
72
- ## Note Source Transformations
73
-
74
- `transformNotes(source, lowering, operation, ranges?)` returns sorted `{ span, text }` edits for `to-absolute`, `to-relative`, `semitone-up`, or `semitone-down`. Use lowering from the same source and apply edits in one editor transaction or right to left.
75
-
76
- Only notes fully covered by `ranges` are changed; omit it for the whole source, or pass `[]` for no changes. Conversion preserves pitch; semitone shifts preserve each note's representation. Key declarations, rests, spacers, percussion, and surrounding source are retained. Invalid note input throws a diagnostic.
77
-
78
- ## Browser Rendering
79
-
80
- The default text measurer estimates glyph widths. For accurate browser layout, pass `CanvasTextMeasurer`, including when rendering SVG:
81
-
82
- ```ts
83
- import { compileScore, CanvasTextMeasurer, renderLayoutPagesToCanvas } from "jpfun";
84
-
85
- const context = document.createElement("canvas").getContext("2d")!;
86
- const result = compileScore(source, { textMeasurer: new CanvasTextMeasurer(context) });
87
- renderLayoutPagesToCanvas(result.layout, [context]);
88
- ```
89
-
90
- Canvas rendering takes one context per page. Measurement can use a separate canvas.
91
-
92
- ## Compilation Pipeline
93
-
94
- ```text
95
- Source
96
- -> Parser -> AST
97
- -> Lowering -> timed events and relations
98
- |-> Playback -> NoteOn / NoteOff / Tempo events
99
- `-> Layout -> document geometry
100
- -> Renderer -> SVG or Canvas
101
- ```
102
-
103
- `compileScore` exposes `parser`, `ast`, `lowering`, and `layout`. Compile playback separately:
48
+ // Compile source, retaining diagnostics and intermediate results
49
+ const compiled = compileScore(source);
104
50
 
105
- ```ts
106
- import { compilePlayback } from "jpfun";
51
+ // Render to SVG strings (one per page)
52
+ const svgPages = renderLayoutPagesToSvg(compiled.layout);
107
53
 
108
- const playback = compilePlayback(result.lowering);
54
+ // Generate timed events and score mappings; this does not play audio
55
+ const playback = compilePlayback(compiled.lowering);
109
56
  ```
110
57
 
111
- The plan contains device-independent `events`, `scoreMap`, `tracks`, and `durationSeconds`, with exact `Fraction` timestamps. Repeat expansion exceeding 65,536 visited columns throws; raise the limit with `{ maxFlowSteps: 200_000 }` when needed.
58
+ Check returned `diagnostics` for recoverable problems and catch compilation errors when processing user input. The host handles audio/MIDI devices, real-time scheduling, and MIDI byte encoding.
112
59
 
113
- ## MIDI JSON Conversion
60
+ For Canvas, create and size one canvas per layout page; see the [rendering example](https://madderscientist.github.io/jpFun/docs/developer/use/#渲染结果). The default text measurer estimates widths; `CanvasTextMeasurer` measures browser font widths for both SVG and Canvas layout.
114
61
 
115
- `midiJsonToJpFun` accepts the JSON returned by [`midi.js`](https://madderscientist.github.io/noteDigger/lib/midi.js)'s `JSON()` method. Parse MIDI bytes in your application.
62
+ ## Core APIs
116
63
 
117
- ```ts
118
- import { midiJsonToJpFun } from "jpfun";
119
-
120
- const source = midiJsonToJpFun(parsedMidiJson, {
121
- title: "My Score",
122
- alignRate: 4,
123
- barsPerLine: 0,
124
- });
125
- ```
64
+ ### Custom Symbols (`symbols`)
126
65
 
127
- `pitchMode` defaults to `"absolute"`; `"relative"` uses C-based numbered notation. `alignRate` controls quantization. `barsPerLine` defaults to `0` for automatic breaks; positive values fix the measures per system.
128
-
129
- Preserves notes, tracks, tempo, time signatures, programs, and standard 3:2 quarter-, eighth-, and sixteenth-note triplets. Other tuplets are unsupported. Percussion channel 10, velocity, controllers, pitch bends, and lyrics are omitted; time-signature changes snap to measure boundaries.
130
-
131
- ## MusicXML Conversion
132
-
133
- `musicXmlToJpFun` accepts a parsed MusicXML root element. Use `DOMParser` in browsers or a compatible DOM implementation in Node.js:
66
+ Register or override `@symbol` (`$name`) definitions for instrument-specific symbol packages:
134
67
 
135
68
  ```ts
136
- import { musicXmlToJpFun } from "jpfun";
69
+ import { symbols, type SymbolDefinition } from "jpfun";
137
70
 
138
- const xml = await file.text();
139
- const document = new DOMParser().parseFromString(xml, "application/xml");
140
- if (document.querySelector("parsererror")) throw new SyntaxError("Invalid MusicXML");
71
+ const dieyin: SymbolDefinition = {
72
+ name: "dizi.dy",
73
+ description: "Dieyin ornament",
74
+ text: { content: "又", fontFamily: "serif" },
75
+ emitPlayback: emitter => emitter.affectFollowing(symbols.ornament({ body: [1, 0] })),
76
+ };
141
77
 
142
- const { script, diagnostics } = musicXmlToJpFun(document.documentElement, {
143
- barsPerLine: 4,
144
- });
78
+ symbols.register(dieyin); // Register or override by lowercase name
145
79
  ```
146
80
 
147
- The result contains the generated `script` and a `MusicXmlDiagnostic[]`. Callers that previously used the return value as a string must now read `.script`. Each diagnostic is a plain object with `code`, `severity: "warning"`, `message`, and `location`; no diagnostics means an empty array. Conversion failures still throw instead of returning partial output.
148
-
149
- | Code | Reported loss |
150
- | --- | --- |
151
- | `W_MUSICXML_PERCUSSION_SKIPPED` | Channel 10 notes omitted |
152
- | `W_MUSICXML_APPROXIMATED` | Display pitches used for unpitched notes, after-grace fallback, or wedges mapped to note onsets with a fixed velocity change |
153
- | `W_MUSICXML_UNSUPPORTED_ELEMENT` | Harmony and discarded children of supported notation or direction containers, including pedal, slur, unsupported articulations, ornaments, and dynamics |
154
- | `W_MUSICXML_UNATTACHED_CONTENT` | Grace notes, text, or dynamics with no target |
155
- | `W_MUSICXML_UNRESOLVED_RELATION` | Unmatched, replaced, unclosed, or unrenderable ties, wedges, and endings |
156
-
157
- `location.element` is the XML tag name without its namespace prefix. Available context includes `partId`, `measureIndex` (1-based within the part), `measureNumber` (the original string), `staff`, and `voice`. These refer to the imported score, not offsets in `script`; XML line/column information is not available through the minimal DOM interface. Reports follow deterministic processing order, not necessarily XML document order.
158
-
159
- Diagnostics cover the cases above, not the entire MusicXML specification. Empty diagnostics do not guarantee lossless conversion. Ordinary defaults and detailed engraving coordinates do not produce warnings. Diagnostic messages describe the loss; use `code` for programmatic classification.
160
-
161
- Text, dynamics, and wedges target the matching part and staff. With no voice specified, dynamics and wedges apply to matching voices on that staff, while text is attached only once. Missing targets produce diagnostics instead of redirecting the marking to another staff or voice. Tuplet markers are confirmed only when the resulting event rhythm retains their boundaries, including equivalent declarations on chord members.
81
+ The registry is shared across compilations. Names are case-insensitive, and later registrations override existing definitions, including built-ins. When finished, use `symbols.reset()` to remove extensions and restore `symbols.core`; `symbols.clear()` removes everything, including built-ins.
162
82
 
163
- All `notations` containers on a note are inspected. Tempo and dynamic marks that never reach the generated script, including terminal marks, produce unattached-content warnings. Arpeggios that cannot be emitted after chord merging and voice splitting, such as cross-staff groups reduced to single-note events, produce unsupported-element warnings.
83
+ ### Note Transformations & Editor Analysis
164
84
 
165
- Supports partwise/timewise scores, multiple voices, rhythm, lyrics, dynamics, repeats, and basic layout metadata. `pitchMode` defaults to `"absolute"`; `"relative"` uses the active MusicXML key.
85
+ - `transformNotes(source, lowering, operation, ranges?)`: Returns `{ span, text }[]` edits for `"to-absolute"`, `"to-relative"`, `"semitone-up"`, or `"semitone-down"`. Use lowering from the exact same source; apply edits in one editor transaction or from right to left.
86
+ - `analyzeScoreSyntax(source, functions?)`: Fault-tolerant lexical/call analysis for real-time editor highlighting and completion.
87
+ - `Diagnostic.format(code, message, params)`: Override to localize diagnostic messages.
166
88
 
167
- Decompress `.mxl` archives before parsing. Percussion channel 10, pedal, cross-staff arpeggio grouping, and detailed engraving coordinates are omitted.
89
+ ### MIDI & MusicXML Import
168
90
 
169
- ## Syntax Example
170
-
171
- ```jpfun
172
- @page(width=860px, left=38px, right=38px)
173
- @1(C4)
174
- @tempo(96)
175
-
176
- N(Melody): 1/ 1/ 5/ 5/ 6/ 6/ 5 -
177
- N: @div(C4 C4) G4/G4/ A4/ A/ G
178
- L(Lyrics): do do so so la la so
179
- ```
91
+ Import from dedicated subpaths (or from `"jpfun"`):
180
92
 
181
- See the [language reference](grammar.md) for the complete syntax.
182
-
183
- ## Development
184
-
185
- jpFun is maintained in a pnpm workspace. From the repository root:
93
+ ```ts
94
+ import { midiJsonToJpFun } from "jpfun/converter/midi";
95
+ import { musicXmlToJpFun } from "jpfun/converter/musicxml";
186
96
 
187
- ```sh
188
- pnpm install
189
- pnpm run build:core
190
- pnpm test
191
- pnpm run dev
97
+ const fromMidi = midiJsonToJpFun(parsedMidiJson, { pitchMode: "absolute", alignRate: 4, barsPerLine: 0 });
98
+ const { script, diagnostics } = musicXmlToJpFun(xmlDocument.documentElement, { pitchMode: "absolute", barsPerLine: 4 });
192
99
  ```
193
100
 
194
- The development server opens the Playground at <http://127.0.0.1:4173>.
195
-
196
- ## Documentation
101
+ MIDI import expects [midi.js](https://madderscientist.github.io/noteDigger/lib/midi.js)-compatible JSON, not MIDI bytes. MusicXML import expects a parsed DOM root: provide a DOM implementation in Node.js and decompress `.mxl` first. Conversion can be lossy; inspect MusicXML diagnostics, and do not treat an empty array as a lossless guarantee.
197
102
 
198
- - [Language reference](grammar.md)
199
- - [Repository](https://github.com/madderscientist/jpFun)
200
- - [Issue tracker](https://github.com/madderscientist/jpFun/issues)
103
+ See the [Developer Documentation](https://madderscientist.github.io/jpFun/docs/developer/use/) for full option and diagnostic details.
201
104
 
202
105
  ## License
203
106
 
204
- [Apache License 2.0](LICENSE)
107
+ [Apache-2.0](LICENSE), except the `$turn` / `$iturn` / `$coda` glyphs derived from [Bravura](https://github.com/steinbergmedia/bravura), licensed under [SIL OFL 1.1](Bravura-LICENSE.txt). Include `Bravura-LICENSE.txt` when redistributing these glyphs or bundles containing them.
@@ -0,0 +1,93 @@
1
+ Copyright (c) 2026, Steinberg Media Technologies GmbH (http://www.steinberg.net/),
2
+ with Reserved Font Name "Bravura".
3
+
4
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
5
+ This license is copied below, and is also available with a FAQ at:
6
+ http://scripts.sil.org/OFL
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION AND CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,13 +1,3 @@
1
- /**
2
- * MIDI JSON -> jpFun 的转换流水线:
3
- * 1. 校验输入,选择足以表达原时值的二进制精度;
4
- * 2. 在原始 tick 上识别 3:2 三连音,再把其余音符量化到二进制网格;
5
- * 3. 合并同起止音为和弦,把重叠内容拆到不同 lane;
6
- * 4. 生成单行源码,以真实自然排版宽度选择换行点;
7
- * 5. 重新生成最终源码,并用 tie 表达跨小节或不足一拍的持续音。
8
- *
9
- * MIDI 字节解析不属于 core;这里接收的是 midi.js 已解析好的 JSON。
10
- */
11
1
  import type { MidiJson } from "./json.js";
12
2
  import { type PitchMode } from "../source.js";
13
3
  export type * from "./json.js";
@@ -18,7 +8,9 @@ export interface MidiToJpFunOptions {
18
8
  title?: string;
19
9
  }
20
10
  export interface MidiLayoutCapability {
21
- compileScore: (source: string) => {
11
+ compileScore: (source: string, options?: {
12
+ horizontalOnly?: boolean;
13
+ }) => {
22
14
  layout: {
23
15
  objects: {
24
16
  T: {