jpfun 0.8.0 → 1.0.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 (140) hide show
  1. package/README.md +10 -15
  2. package/dist/diagnostic.d.ts +29 -2
  3. package/dist/diagnostic.js +5 -4
  4. package/dist/functions/ASTtypes.d.ts +1 -14
  5. package/dist/functions/ASTtypes.js +5 -36
  6. package/dist/functions/adjust/index.js +45 -33
  7. package/dist/functions/arpeggio/index.js +44 -48
  8. package/dist/functions/arpeggio/shape.d.ts +2 -3
  9. package/dist/functions/arpeggio/shape.js +20 -50
  10. package/dist/functions/bar/index.d.ts +3 -0
  11. package/dist/functions/bar/index.js +21 -11
  12. package/dist/functions/beam/auto.js +54 -123
  13. package/dist/functions/beam/index.js +4 -9
  14. package/dist/functions/beam/layout.js +3 -2
  15. package/dist/functions/box/index.js +1 -6
  16. package/dist/functions/dash/index.js +6 -4
  17. package/dist/functions/div/index.d.ts +3 -5
  18. package/dist/functions/div/index.js +14 -12
  19. package/dist/functions/dot/index.js +3 -9
  20. package/dist/functions/dyn/index.js +7 -26
  21. package/dist/functions/gliss/index.js +99 -91
  22. package/dist/functions/grace/index.d.ts +2 -5
  23. package/dist/functions/grace/index.js +47 -94
  24. package/dist/functions/head/index.js +32 -36
  25. package/dist/functions/key/index.js +9 -12
  26. package/dist/functions/meter/index.d.ts +1 -0
  27. package/dist/functions/meter/index.js +6 -3
  28. package/dist/functions/meter/shape.d.ts +1 -1
  29. package/dist/functions/note/accidentals.d.ts +3 -3
  30. package/dist/functions/note/accidentals.js +29 -16
  31. package/dist/functions/note/index.js +12 -14
  32. package/dist/functions/note/source-transform.d.ts +15 -0
  33. package/dist/functions/note/source-transform.js +75 -71
  34. package/dist/functions/ottava/index.js +12 -32
  35. package/dist/functions/page/index.js +15 -17
  36. package/dist/functions/rest/index.js +10 -10
  37. package/dist/functions/slide/index.js +1 -1
  38. package/dist/functions/stack/index.js +8 -57
  39. package/dist/functions/temporal.d.ts +11 -5
  40. package/dist/functions/temporal.js +22 -2
  41. package/dist/functions/text/index.js +24 -30
  42. package/dist/functions/tie/index.js +42 -41
  43. package/dist/functions/tremolo/index.js +1 -1
  44. package/dist/functions/tuplet/index.js +1 -6
  45. package/dist/functions/up/index.js +82 -88
  46. package/dist/functions/voice/connections.d.ts +3 -2
  47. package/dist/functions/voice/connections.js +48 -10
  48. package/dist/functions/voice/index.d.ts +2 -3
  49. package/dist/functions/voice/index.js +2 -970
  50. package/dist/functions/voice/lyrics.d.ts +34 -0
  51. package/dist/functions/voice/lyrics.js +393 -0
  52. package/dist/functions/voice/voice.d.ts +67 -0
  53. package/dist/functions/voice/voice.js +405 -0
  54. package/dist/functions/voice/voices.d.ts +106 -0
  55. package/dist/functions/voice/voices.js +424 -0
  56. package/dist/functions/volta/index.js +6 -23
  57. package/dist/index.d.ts +97 -3
  58. package/dist/index.js +97 -3
  59. package/dist/jpfun.min.js +63 -67
  60. package/dist/layout/engine.d.ts +4 -3
  61. package/dist/layout/engine.js +190 -24
  62. package/dist/layout/model.d.ts +12 -4
  63. package/dist/layout/model.js +16 -11
  64. package/dist/layout/page.d.ts +2 -1
  65. package/dist/layout/page.js +15 -15
  66. package/dist/layout/path.js +1 -1
  67. package/dist/layout/range.d.ts +7 -6
  68. package/dist/layout/range.js +23 -14
  69. package/dist/layout/types.d.ts +19 -30
  70. package/dist/lowering/loweringContext.d.ts +8 -11
  71. package/dist/lowering/loweringContext.js +7 -13
  72. package/dist/lowering/track.d.ts +8 -1
  73. package/dist/lowering/types.d.ts +12 -8
  74. package/dist/parser/grammarType.d.ts +3 -3
  75. package/dist/parser/parse-utils/brace-utils.js +7 -17
  76. package/dist/parser/parse-utils/call-utils.d.ts +4 -3
  77. package/dist/parser/parse-utils/call-utils.js +23 -66
  78. package/dist/parser/parse-utils/note-utils.d.ts +7 -3
  79. package/dist/parser/parse-utils/note-utils.js +25 -40
  80. package/dist/parser/parse-utils/string-utils.d.ts +1 -1
  81. package/dist/parser/parse-utils/string-utils.js +8 -6
  82. package/dist/parser/parserContext.d.ts +17 -11
  83. package/dist/parser/parserContext.js +111 -65
  84. package/dist/parser/preprocess.d.ts +7 -0
  85. package/dist/parser/preprocess.js +21 -19
  86. package/dist/pipeline.d.ts +1 -1
  87. package/dist/pipeline.js +2 -2
  88. package/dist/playback/compile.js +14 -15
  89. package/dist/playback/event.d.ts +6 -6
  90. package/dist/playback/event.js +13 -49
  91. package/dist/render/canvas.d.ts +0 -2
  92. package/dist/render/canvas.js +50 -56
  93. package/dist/render/index.d.ts +1 -1
  94. package/dist/render/index.js +1 -1
  95. package/dist/render/paint.d.ts +7 -0
  96. package/dist/render/paint.js +70 -20
  97. package/dist/render/recording.d.ts +8 -1
  98. package/dist/render/recording.js +12 -0
  99. package/dist/render/svg.d.ts +5 -2
  100. package/dist/render/svg.js +70 -48
  101. package/dist/render/text.d.ts +37 -2
  102. package/dist/render/text.js +136 -1
  103. package/dist/render/translate.d.ts +3 -1
  104. package/dist/render/translate.js +6 -0
  105. package/dist/render/types.d.ts +9 -2
  106. package/grammar.md +18 -14
  107. package/package.json +8 -18
  108. package/dist/converter/midi/convert.d.ts +0 -42
  109. package/dist/converter/midi/convert.js +0 -729
  110. package/dist/converter/midi/index.d.ts +0 -5
  111. package/dist/converter/midi/index.js +0 -11
  112. package/dist/converter/midi/json.d.ts +0 -38
  113. package/dist/converter/midi/json.js +0 -1
  114. package/dist/converter/midi/triplet.d.ts +0 -30
  115. package/dist/converter/midi/triplet.js +0 -75
  116. package/dist/converter/musicxml/dom.d.ts +0 -25
  117. package/dist/converter/musicxml/dom.js +0 -65
  118. package/dist/converter/musicxml/features.d.ts +0 -114
  119. package/dist/converter/musicxml/features.js +0 -501
  120. package/dist/converter/musicxml/index.d.ts +0 -14
  121. package/dist/converter/musicxml/index.js +0 -1295
  122. package/dist/converter/musicxml/model.d.ts +0 -176
  123. package/dist/converter/musicxml/model.js +0 -1
  124. package/dist/converter/musicxml/resolve.d.ts +0 -10
  125. package/dist/converter/musicxml/resolve.js +0 -152
  126. package/dist/converter/source.d.ts +0 -22
  127. package/dist/converter/source.js +0 -51
  128. package/dist/core.d.ts +0 -24
  129. package/dist/core.js +0 -24
  130. package/dist/iife/core.d.ts +0 -1
  131. package/dist/iife/core.js +0 -3
  132. package/dist/iife/from-midi.d.ts +0 -1
  133. package/dist/iife/from-midi.js +0 -15
  134. package/dist/iife/from-musicxml.d.ts +0 -1
  135. package/dist/iife/from-musicxml.js +0 -3
  136. package/dist/iife/full.d.ts +0 -1
  137. package/dist/iife/full.js +0 -3
  138. package/dist/jpfun.core.min.js +0 -123
  139. package/dist/jpfun.from-midi.min.js +0 -9
  140. package/dist/jpfun.from-musicxml.min.js +0 -12
@@ -1,18 +1,21 @@
1
1
  import { layoutPageBounds, paintLayoutPages } from "./paint.js";
2
- import { DEFAULT_TEXT_FONT } from "./text.js";
2
+ import { DEFAULT_TEXT_FONT, JIANPU_NUMBER_FONT } from "./text.js";
3
3
  function number(value) {
4
4
  if (!Number.isFinite(value))
5
5
  return "0";
6
6
  return String(Math.round(value * 1000) / 1000);
7
7
  }
8
+ const XML_SPECIAL_CHARS = /[&<>"]/;
8
9
  function escapeXml(value) {
10
+ if (!XML_SPECIAL_CHARS.test(value))
11
+ return value;
9
12
  return value
10
13
  .replace(/&/g, "&amp;")
11
14
  .replace(/</g, "&lt;")
12
15
  .replace(/>/g, "&gt;")
13
- .replace(/"/g, "&quot;")
14
- .replace(/'/g, "&apos;");
16
+ .replace(/"/g, "&quot;");
15
17
  }
18
+ const DEFAULT_SVG_FONT_ATTR = escapeXml(JIANPU_NUMBER_FONT);
16
19
  /**
17
20
  * 把结构化路径命令转换为 SVG path data
18
21
  * 可选缩放和平移用于直接生成最终坐标
@@ -26,35 +29,47 @@ function pathCommandsToSvg(commands, transform) {
26
29
  ? (value) => number(transform.y + value * transform.scaleY)
27
30
  : number;
28
31
  for (const command of commands) {
29
- if (command.op === "Z") {
30
- parts.push("Z");
31
- continue;
32
+ switch (command.op) {
33
+ case "M":
34
+ case "L":
35
+ parts.push(`${command.op}${x(command.x)} ${y(command.y)}`);
36
+ break;
37
+ case "Q":
38
+ parts.push(`Q${x(command.cx)} ${y(command.cy)} ${x(command.x)} ${y(command.y)}`);
39
+ break;
40
+ case "C":
41
+ parts.push(`C${x(command.cx1)} ${y(command.cy1)} `
42
+ + `${x(command.cx2)} ${y(command.cy2)} `
43
+ + `${x(command.x)} ${y(command.y)}`);
44
+ break;
45
+ case "Z":
46
+ parts.push("Z");
47
+ break;
48
+ default:
49
+ command;
32
50
  }
33
- if (command.op === "M" || command.op === "L") {
34
- parts.push(`${command.op}${x(command.x)} ${y(command.y)}`);
35
- continue;
36
- }
37
- if (command.op === "Q") {
38
- parts.push(`Q${x(command.cx)} ${y(command.cy)} `
39
- + `${x(command.x)} ${y(command.y)}`);
40
- continue;
41
- }
42
- if (!("cx1" in command))
43
- continue;
44
- parts.push(`C${x(command.cx1)} ${y(command.cy1)} `
45
- + `${x(command.cx2)} ${y(command.cy2)} `
46
- + `${x(command.x)} ${y(command.y)}`);
47
51
  }
48
52
  return parts.join(" ");
49
53
  }
50
- function opacityAttribute(style) {
51
- if (style?.opacity === void 0)
52
- return "";
53
- return ` opacity="${number(style.opacity)}"`;
54
- }
55
54
  /** 生成独立 SVG 字符串的 Painter;路径直接输出最终坐标 */
56
55
  export class SvgPainter {
57
56
  body = [];
57
+ /** 未结束分组的开标签在 body 中的下标 */
58
+ groupStarts = [];
59
+ beginGroup(group) {
60
+ this.groupStarts.push(this.body.length);
61
+ this.body.push(`<g data-kind="${escapeXml(group.kind)}">`);
62
+ }
63
+ endGroup() {
64
+ const start = this.groupStarts.pop();
65
+ if (start === undefined)
66
+ return;
67
+ // 组内没有图元时连开标签一起删掉,内层空组已先被删除
68
+ if (this.body.length === start + 1)
69
+ this.body.pop();
70
+ else
71
+ this.body.push("</g>");
72
+ }
58
73
  drawText(text, x, y, style) {
59
74
  const family = style.fontFamily ?? DEFAULT_TEXT_FONT;
60
75
  const weight = style.fontWeight ?? "normal";
@@ -62,38 +77,42 @@ export class SvgPainter {
62
77
  const textAnchor = style.textAlign === "center"
63
78
  ? "middle"
64
79
  : style.textAlign === "right" ? "end" : "start";
65
- this.body.push(`<text x="${number(x)}" y="${number(y)}" `
66
- + `font-family="${escapeXml(family)}" font-size="${number(style.fontSize)}" `
67
- + `font-weight="${escapeXml(String(weight))}" text-anchor="${textAnchor}" `
68
- + (style.fontStyle ? `font-style="${escapeXml(style.fontStyle)}" ` : "")
69
- + `fill="${escapeXml(fill)}" xml:space="preserve"`
70
- + `${opacityAttribute(style)}>${escapeXml(text)}</text>`);
80
+ this.body.push(`<text x="${number(x)}" y="${number(y)}"`
81
+ + (family !== JIANPU_NUMBER_FONT ? ` font-family="${escapeXml(family)}"` : "")
82
+ + ` font-size="${number(style.fontSize)}"`
83
+ + (weight !== "normal" ? ` font-weight="${escapeXml(String(weight))}"` : "")
84
+ + (textAnchor !== "start" ? ` text-anchor="${textAnchor}"` : "")
85
+ + (style.fontStyle && style.fontStyle !== "normal" ? ` font-style="${escapeXml(style.fontStyle)}"` : "")
86
+ + (fill !== "#000" ? ` fill="${escapeXml(fill)}"` : "")
87
+ + (/\s/.test(text) ? ` xml:space="preserve"` : "")
88
+ + `>${escapeXml(text)}</text>`);
71
89
  }
72
90
  drawLine(x1, y1, x2, y2, style) {
73
91
  const stroke = style?.stroke ?? style?.fill ?? "#000";
74
92
  const strokeWidth = style?.strokeWidth ?? 1;
75
93
  this.body.push(`<line x1="${number(x1)}" y1="${number(y1)}" `
76
94
  + `x2="${number(x2)}" y2="${number(y2)}" `
77
- + `stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}" stroke-linecap="round"`
78
- + `${opacityAttribute(style)} />`);
95
+ + `stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}" stroke-linecap="round" />`);
79
96
  }
80
97
  drawRect(x, y, w, h, style) {
81
98
  const fill = style?.fill ?? "none";
82
99
  const stroke = style?.stroke ?? "none";
83
100
  const strokeWidth = style?.strokeWidth ?? 1;
84
101
  this.body.push(`<rect x="${number(x)}" y="${number(y)}" `
85
- + `width="${number(Math.max(0, w))}" height="${number(Math.max(0, h))}" `
86
- + `fill="${escapeXml(fill)}" stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}"`
87
- + `${opacityAttribute(style)} />`);
102
+ + `width="${number(Math.max(0, w))}" height="${number(Math.max(0, h))}"`
103
+ + (fill !== "#000" ? ` fill="${escapeXml(fill)}"` : "")
104
+ + (stroke !== "none" ? ` stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}"` : "")
105
+ + ` />`);
88
106
  }
89
107
  drawCircle(cx, cy, r, style) {
90
108
  const fill = style?.fill ?? "#000";
91
109
  const stroke = style?.stroke ?? "none";
92
110
  const strokeWidth = style?.strokeWidth ?? 1;
93
111
  this.body.push(`<circle cx="${number(cx)}" cy="${number(cy)}" `
94
- + `r="${number(Math.max(0, r))}" fill="${escapeXml(fill)}" `
95
- + `stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}"`
96
- + `${opacityAttribute(style)} />`);
112
+ + `r="${number(Math.max(0, r))}"`
113
+ + (fill !== "#000" ? ` fill="${escapeXml(fill)}"` : "")
114
+ + (stroke !== "none" ? ` stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}"` : "")
115
+ + ` />`);
97
116
  }
98
117
  drawPath(commands, style, transform) {
99
118
  if (commands.length === 0)
@@ -102,21 +121,24 @@ export class SvgPainter {
102
121
  const fill = style?.fill ?? "none";
103
122
  const stroke = style?.stroke ?? "none";
104
123
  const strokeWidth = style?.strokeWidth ?? 1;
105
- this.body.push(`<path d="${d}" fill="${escapeXml(fill)}" stroke="${escapeXml(stroke)}" `
106
- + `stroke-width="${number(strokeWidth)}" stroke-linecap="round" stroke-linejoin="round"`
107
- + `${opacityAttribute(style)} />`);
124
+ this.body.push(`<path d="${d}"`
125
+ + (fill !== "#000" ? ` fill="${escapeXml(fill)}"` : "")
126
+ + (stroke !== "none"
127
+ ? ` stroke="${escapeXml(stroke)}" stroke-width="${number(strokeWidth)}" stroke-linecap="round" stroke-linejoin="round"`
128
+ : "")
129
+ + ` />`);
108
130
  }
109
131
  toSvg(bounds, options = {}) {
110
- const padding = Math.max(0, options.padding ?? 0);
111
- const left = bounds.x - padding;
112
- const top = bounds.y - padding;
113
- const width = Math.max(1, bounds.w + padding * 2);
114
- const height = Math.max(1, bounds.h + padding * 2);
132
+ const left = bounds.x;
133
+ const top = bounds.y;
134
+ const width = Math.max(1, bounds.w);
135
+ const height = Math.max(1, bounds.h);
115
136
  const background = options.background
116
137
  ? `<rect x="${number(left)}" y="${number(top)}" width="${number(width)}" height="${number(height)}" fill="${escapeXml(options.background)}" />`
117
138
  : "";
118
139
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${number(width)}" height="${number(height)}" `
119
- + `viewBox="${number(left)} ${number(top)} ${number(width)} ${number(height)}">`
140
+ + `viewBox="${number(left)} ${number(top)} ${number(width)} ${number(height)}" `
141
+ + `font-family="${DEFAULT_SVG_FONT_ATTR}" font-weight="normal" fill="#000">`
120
142
  + `${background}${this.body.join("")}</svg>`;
121
143
  }
122
144
  }
@@ -1,8 +1,43 @@
1
- import type { GlyphMetrics, TextMeasurer, TextStyle } from "./types.js";
1
+ import type { GlyphMetrics, Painter, TextMeasurer, TextStyle } from "./types.js";
2
2
  /** 未指定字体族时,普通文本使用的字体栈 */
3
3
  export declare const DEFAULT_TEXT_FONT = "sans-serif";
4
4
  /** 简谱数字及同类谱面数字使用的字体栈 */
5
- export declare const JIANPU_NUMBER_FONT = "'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";
5
+ export declare const JIANPU_NUMBER_FONT = "Arial, 'Century Schoolbook', 'Palatino Linotype', Cambria, 'Cascadia Mono', monospace";
6
+ /** 同一行内具有相同样式掩码的连续纯文本片段 */
7
+ export interface RichTextRun {
8
+ text: string;
9
+ mask: number;
10
+ }
11
+ /** 向片段序列末尾追加字符;掩码相同时原地合并 */
12
+ export declare function appendRun(runs: RichTextRun[], text: string, mask: number): void;
13
+ /**
14
+ * 按状态机扫描 `**`、`*`、`_`、`^` 样式开关并逐字符回调 `(ch, mask, escaped)`。
15
+ * 遇到标记即异或切换对应样式位;若未闭合则后续文本(含跨行、跨音符槽)持续保持该样式。
16
+ */
17
+ export declare function scanMarkdown(source: string, onChar: (ch: string, mask: number, escaped: boolean, start: number, end: number) => void, escapable?: string): void;
18
+ /** 解析多行富文本:单遍跨行扫描样式状态,遇换行切分为每行的片段列表 */
19
+ export declare function parseRichText(source: string): RichTextRun[][];
20
+ /** 将前一片段与下一片段的样式掩码差值(`prevMask ^ nextMask`)还原为状态切换标记 */
21
+ export declare function markdownToggles(maskDiff: number): string;
22
+ /** 单行富文本的完整排版结果,供布局与绘制阶段直接复用 */
23
+ export interface PreparedRichLine extends GlyphMetrics {
24
+ runs: (RichTextRun & {
25
+ style: TextStyle;
26
+ w: number;
27
+ })[];
28
+ style: TextStyle;
29
+ }
30
+ /**
31
+ * 度量单行富文本(可传原始字符串或已解析片段)并汇总整行尺寸。
32
+ * 行高 h 与 baseline 始终取基准字号(非上标)的度量,避免行内含有上标时导致同行基线错位。
33
+ */
34
+ export declare function prepareRichLine(source: string | readonly RichTextRun[], baseStyle: TextStyle, measurer: TextMeasurer): PreparedRichLine;
35
+ /**
36
+ * 绘制已度量的单行富文本及其下划线装饰。
37
+ * 单片段时保留原 textAlign 直接绘制;多片段时从整行左缘起按段累加推进,
38
+ * 并将同一基线高度上相邻的下划线片段合并为单条连续线段。
39
+ */
40
+ export declare function paintRichLine(painter: Painter, line: PreparedRichLine, x: number, baselineY: number): void;
6
41
  /** Canvas 的 font 简写;测量与绘制必须用同一份,否则量到的不是将要画出的字形 */
7
42
  export declare function canvasFont(style: TextStyle): string;
8
43
  /** 默认文本测量保持确定性,不依赖浏览器和操作系统字体。 */
@@ -1,7 +1,142 @@
1
1
  /** 未指定字体族时,普通文本使用的字体栈 */
2
2
  export const DEFAULT_TEXT_FONT = "sans-serif";
3
3
  /** 简谱数字及同类谱面数字使用的字体栈 */
4
- export const JIANPU_NUMBER_FONT = "'Cascadia Mono', Consolas, 'Liberation Mono', 'Noto Sans Mono', monospace";
4
+ export const JIANPU_NUMBER_FONT = "Arial, 'Century Schoolbook', 'Palatino Linotype', Cambria, 'Cascadia Mono', monospace";
5
+ /** 富文本样式位掩码:四种内联样式正交叠加,通过异或翻转状态 */
6
+ const STYLE_BOLD = 1;
7
+ const STYLE_ITALIC = 2;
8
+ const STYLE_UNDERLINE = 4;
9
+ const STYLE_SUP = 8;
10
+ /** 向片段序列末尾追加字符;掩码相同时原地合并 */
11
+ export function appendRun(runs, text, mask) {
12
+ const last = runs.at(-1);
13
+ if (last && last.mask === mask)
14
+ last.text += text;
15
+ else
16
+ runs.push({ text, mask });
17
+ }
18
+ /**
19
+ * 按状态机扫描 `**`、`*`、`_`、`^` 样式开关并逐字符回调 `(ch, mask, escaped)`。
20
+ * 遇到标记即异或切换对应样式位;若未闭合则后续文本(含跨行、跨音符槽)持续保持该样式。
21
+ */
22
+ export function scanMarkdown(source, onChar, escapable = "\\*_^") {
23
+ let mask = 0;
24
+ for (let i = 0; i < source.length; i++) {
25
+ const start = i;
26
+ const ch = String.fromCodePoint(source.codePointAt(i));
27
+ i += ch.length - 1;
28
+ if (ch === "\\" && i + 1 < source.length && escapable.includes(source[i + 1])) {
29
+ onChar(source[++i], mask, true, start, i + 1);
30
+ continue;
31
+ }
32
+ if (ch === "*") {
33
+ mask ^= source[i + 1] === "*" ? (i++, STYLE_BOLD) : STYLE_ITALIC;
34
+ continue;
35
+ }
36
+ if (ch === "_") {
37
+ mask ^= STYLE_UNDERLINE;
38
+ continue;
39
+ }
40
+ if (ch === "^") {
41
+ mask ^= STYLE_SUP;
42
+ continue;
43
+ }
44
+ onChar(ch, mask, false, start, i + 1);
45
+ }
46
+ }
47
+ /** 解析多行富文本:单遍跨行扫描样式状态,遇换行切分为每行的片段列表 */
48
+ export function parseRichText(source) {
49
+ const lines = [[]];
50
+ scanMarkdown(source, (ch, mask) => {
51
+ if (ch === "\n")
52
+ lines.push([]);
53
+ else
54
+ appendRun(lines.at(-1), ch, mask);
55
+ });
56
+ return lines;
57
+ }
58
+ /** 将前一片段与下一片段的样式掩码差值(`prevMask ^ nextMask`)还原为状态切换标记 */
59
+ export function markdownToggles(maskDiff) {
60
+ return (maskDiff & STYLE_BOLD ? "**" : "")
61
+ + (maskDiff & STYLE_ITALIC ? "*" : "")
62
+ + (maskDiff & STYLE_UNDERLINE ? "_" : "")
63
+ + (maskDiff & STYLE_SUP ? "^" : "");
64
+ }
65
+ /** 上标相对基准字号的缩放比例与基线上移比例 */
66
+ const SUP_SCALE = 0.7;
67
+ const SUP_SHIFT = 0.35;
68
+ /**
69
+ * 度量单行富文本(可传原始字符串或已解析片段)并汇总整行尺寸。
70
+ * 行高 h 与 baseline 始终取基准字号(非上标)的度量,避免行内含有上标时导致同行基线错位。
71
+ */
72
+ export function prepareRichLine(source, baseStyle, measurer) {
73
+ const runs = [];
74
+ if (typeof source === "string")
75
+ scanMarkdown(source, (ch, mask) => appendRun(runs, ch, mask));
76
+ else
77
+ runs.push(...source);
78
+ let totalW = 0;
79
+ let lineMetrics;
80
+ const forceLeft = runs.length > 1 && baseStyle.textAlign && baseStyle.textAlign !== "left";
81
+ const preparedRuns = runs.map(run => {
82
+ const style = !forceLeft && (run.mask & (STYLE_BOLD | STYLE_ITALIC | STYLE_SUP)) === 0
83
+ ? baseStyle
84
+ : {
85
+ ...baseStyle,
86
+ ...(forceLeft ? { textAlign: "left" } : {}),
87
+ ...(run.mask & STYLE_SUP ? { fontSize: baseStyle.fontSize * SUP_SCALE } : {}),
88
+ ...(run.mask & STYLE_BOLD ? { fontWeight: "bold" } : {}),
89
+ ...(run.mask & STYLE_ITALIC ? { fontStyle: "italic" } : {}),
90
+ };
91
+ const metrics = measurer.measureText(run.text, style);
92
+ if ((run.mask & STYLE_SUP) === 0)
93
+ lineMetrics ??= metrics;
94
+ totalW += metrics.w;
95
+ return { ...run, style, w: metrics.w };
96
+ });
97
+ lineMetrics ??= measurer.measureText("", baseStyle);
98
+ return {
99
+ runs: preparedRuns,
100
+ style: baseStyle,
101
+ w: runs.length ? totalW : lineMetrics.w,
102
+ h: lineMetrics.h,
103
+ baseline: lineMetrics.baseline,
104
+ };
105
+ }
106
+ /**
107
+ * 绘制已度量的单行富文本及其下划线装饰。
108
+ * 单片段时保留原 textAlign 直接绘制;多片段时从整行左缘起按段累加推进,
109
+ * 并将同一基线高度上相邻的下划线片段合并为单条连续线段。
110
+ */
111
+ export function paintRichLine(painter, line, x, baselineY) {
112
+ const { runs, style: baseStyle, w } = line;
113
+ const { textAlign } = baseStyle;
114
+ const leftX = textAlign === "center" ? x - w / 2 : textAlign === "right" ? x - w : x;
115
+ const runY = (mask) => mask & STYLE_SUP ? baselineY - baseStyle.fontSize * SUP_SHIFT : baselineY;
116
+ let cursorX = leftX;
117
+ for (const run of runs) {
118
+ painter.drawText(run.text, runs.length === 1 ? x : cursorX, runY(run.mask), run.style);
119
+ cursorX += run.w;
120
+ }
121
+ // Canvas 2D 原生不支持 text-decoration,统一用 drawLine 绘制下划线以保证 SVG/Canvas 一致
122
+ for (let i = 0, cursor = leftX; i < runs.length;) {
123
+ const { mask, style, w: runW } = runs[i++];
124
+ if (!(mask & STYLE_UNDERLINE)) {
125
+ cursor += runW;
126
+ continue;
127
+ }
128
+ let endX = cursor + runW;
129
+ while (i < runs.length && (runs[i].mask & (STYLE_UNDERLINE | STYLE_SUP)) === (mask & (STYLE_UNDERLINE | STYLE_SUP))) {
130
+ endX += runs[i++].w;
131
+ }
132
+ const h = Math.max(1, style.fontSize * 0.06);
133
+ const y = runY(mask) + style.fontSize * 0.12;
134
+ painter.drawRect(cursor, y - h / 2, endX - cursor, h, {
135
+ fill: baseStyle.fill ?? "#000",
136
+ });
137
+ cursor = endX;
138
+ }
139
+ }
5
140
  /** Canvas 的 font 简写;测量与绘制必须用同一份,否则量到的不是将要画出的字形 */
6
141
  export function canvasFont(style) {
7
142
  const slant = style.fontStyle ? `${style.fontStyle} ` : "";
@@ -1,10 +1,12 @@
1
- import type { PaintStyle, Painter, PathCommand, PathTransform, TextStyle } from "./types.js";
1
+ import type { PaintGroup, PaintStyle, Painter, PathCommand, PathTransform, TextStyle } from "./types.js";
2
2
  /** Painter 没有变换栈,整体平移的几何只能逐条命令平移 */
3
3
  export declare class TranslatingPainter implements Painter {
4
4
  private readonly target;
5
5
  private readonly dx;
6
6
  private readonly dy;
7
7
  constructor(target: Painter, dx: number, dy: number);
8
+ beginGroup(group: PaintGroup): void;
9
+ endGroup(): void;
8
10
  drawText(text: string, x: number, y: number, style: TextStyle): void;
9
11
  drawLine(x1: number, y1: number, x2: number, y2: number, style?: PaintStyle): void;
10
12
  drawRect(x: number, y: number, w: number, h: number, style?: PaintStyle): void;
@@ -8,6 +8,12 @@ export class TranslatingPainter {
8
8
  this.dx = dx;
9
9
  this.dy = dy;
10
10
  }
11
+ beginGroup(group) {
12
+ this.target.beginGroup?.(group);
13
+ }
14
+ endGroup() {
15
+ this.target.endGroup?.();
16
+ }
11
17
  drawText(text, x, y, style) {
12
18
  this.target.drawText(text, x + this.dx, y + this.dy, style);
13
19
  }
@@ -18,7 +18,6 @@ export interface PaintStyle {
18
18
  fill?: string;
19
19
  stroke?: string;
20
20
  strokeWidth?: number;
21
- opacity?: number;
22
21
  }
23
22
  /**
24
23
  * 任意文本的排版样式
@@ -33,7 +32,6 @@ export interface TextStyle {
33
32
  fontStyle?: "normal" | "italic" | "oblique";
34
33
  textAlign?: "left" | "center" | "right";
35
34
  fill?: string;
36
- opacity?: number;
37
35
  }
38
36
  /**
39
37
  * 通用路径命令
@@ -72,6 +70,11 @@ export interface PathTransform {
72
70
  scaleX: number;
73
71
  scaleY: number;
74
72
  }
73
+ /** 一组图元的语义信息,SVG 输出为 `<g data-kind>` */
74
+ export interface PaintGroup {
75
+ /** 时值对象取 TemporalNodeBase.kind,attachment 取 LayoutAttachment.kind */
76
+ readonly kind: string;
77
+ }
75
78
  /**
76
79
  * 所有渲染后端必须实现的最小绘制接口
77
80
  *
@@ -84,4 +87,8 @@ export interface Painter {
84
87
  drawRect(x: number, y: number, w: number, h: number, style?: PaintStyle): void;
85
88
  drawCircle(cx: number, cy: number, r: number, style?: PaintStyle): void;
86
89
  drawPath(commands: readonly PathCommand[], style?: PaintStyle, transform?: PathTransform): void;
90
+ /** 开始一个语义分组,必须与 endGroup 成对调用,可以嵌套;不关心分组的后端可以不实现 */
91
+ beginGroup?(group: PaintGroup): void;
92
+ /** 结束最近一个未结束的分组 */
93
+ endGroup?(): void;
87
94
  }
package/grammar.md CHANGED
@@ -25,10 +25,10 @@ sidebar:
25
25
  | [关系型:连线、反复房子、八度号、渐强渐弱](#关系型) | `@beam` `@tie` `@gliss` `@volta` `@ottava` `@dyn` |
26
26
 
27
27
  ## 2. 基本类型
28
- - **字符串**:双引号 `"..."`,无歧义时可省;含分隔符须加引号,如 `@note("b6,")`。
28
+ - **字符串**:双引号 `"..."`,无歧义时可省;含分隔符须加引号,如 `@note("b6,")`。有无引号共享同一套转义规则:
29
29
  - 可跨行;引号须配对,孤立 `"` 按普通字符处理。
30
- - 引号内仅支持 JSON 风格的 Unicode 转义:`\uXXXX` 为恰好四位十六进制码元,例如 `"\uE050"`;补充平面字符用 `"\uD834\uDD1E"` 这样的代理对表示。
31
- - 其他 `\X` 仍转为 `X`,如 `\"`、`\\`;不新增 `\n`、`\t` 等语义转义,换行和制表符直接输入。转义只解码一次,`"\\uE050"` 显示字面文本 `\uE050`。
30
+ - 支持 JSON 风格的 Unicode 转义:`\uXXXX` 为恰好四位十六进制码元,例如 `"\uE050"`;补充平面字符用 `"\uD834\uDD1E"` 这样的代理对表示。
31
+ - 用 `\"`、`\\` 输入双引号和反斜杠,用 `\*`、`\_`、`\^`、`\-`、`\@`、`\{`、`\}` 显示符号本身;不支持 `\n`、`\t`,换行和制表符直接输入。转义只处理一次,`"\\uE050"` 显示 `\uE050`。
32
32
  - **布尔值**:`true` / `false`。
33
33
  - **数字**:有限整数或小数。
34
34
  - **长度**:数字加 `px`(默认)或 `em`(相对当前字号)。
@@ -53,15 +53,16 @@ sidebar:
53
53
  - 首小节允许弱起,不可超拍;后续在小节线、拍号变更或曲末校验满拍。
54
54
  - `@set(key=value, ...)`:从当前位置设置本级及子作用域默认值;退出 `{}` 恢复外层设置。优先级见[参数规则](#4-参数规则)。
55
55
  - `函数名.参数名=值`:支持别名,未知目标警告并忽略。
56
- - 系统项:`fontsize` 基准字号,`font` 文本字体,`numberfont` 数字字体。
56
+ - 系统项:`fontsize` 基准字号,`font` 文本字体,`numberfont` 数字字体,`numberweight` 主谱面数字字重(默认 `700`,仅作用于 `note`、`meter`、`rest`)。
57
57
  - `strict`:默认 `false`;开启后未知函数及部分可恢复问题改为报错。
58
58
 
59
59
  ### 页面与谱头
60
60
 
61
- - `@page(width, height, top, bottom, left, right, gap, numbering, barNumbering, font, fillRatio)`:页面布局。
61
+ - `@page(width, height, top, bottom, left, right, gap, minGap, numbering, barNumbering, font, fillRatio)`:页面布局。
62
62
  - 仅顶层首次声明有效,其余警告并忽略;`em` 按声明时字号计算。
63
- - 默认:宽 `794px`、高 `0px`、上 `45px`、下 `48px`、左右 `40px`、行距 `1em`、`fillRatio=0.5`。
64
- - `height <= 0` 不自动分页,仍可手动换页;正值按整行分页,单行超高报错。自动封页均分剩余高度,末页保持最小行距。
63
+ - 默认:宽 `794px`、高 `0px`、上 `45px`、下 `48px`、左右 `40px`、行距 `1em`、最小行距 `0.4em`、`fillRatio=0.5`。
64
+ - `gap` 为上一行下沿到下一行主旋律上沿(基线减半字高)的标准行距;顶部外扩图形优先借用行距,但与上一行下沿至少保留 `minGap`(不超过 `gap`)。
65
+ - `height <= 0` 不自动分页,仍可手动换页;正值按整行分页,单行超高报错。自动封页均分剩余高度,末页保持自然行距。
65
66
  - `fillRatio`:自然宽度达到版心宽度的该比例时撑满;负值始终撑满,`>= 1` 不自动拉开。
66
67
  - `numbering`:页码格式,如 `"1/1"`,默认 `""` 不显示;`font`:页码/小节号字体,默认 `""` 沿用当前字体。
67
68
  - `barNumbering`:从第二行起每行行首的小节号格式,如 `"1"`、`"(1)"`,默认 `""` 不显示。
@@ -107,6 +108,7 @@ sidebar:
107
108
  - `@text(字符串, size=1em, lineheight=1.25, align=left, font="")`:文本标记。
108
109
  - 简写 `"渐强"`;可直接换行,`lineheight` 为自身字号的倍数。
109
110
  - `align=left/center/right`:左对齐 / 居中 / 右对齐,锚点为首行首字中心 / 整块中心 / 首行末字中心。
111
+ - 文字样式:`*斜体*`、`**粗体**`、`_下划线_`、`^上标^`(再次出现即关闭,不关闭则一直生效;写 `\*`、`\_`、`\^` 显示原字符。谱头、歌词与各类名称同样支持)。
110
112
  - `font` 指定字体,空值沿用当前字体。宿主加载音乐字体后可写 `@text("\uE050", font="Bravura")`;Unicode 转义只决定字符,不会自动选择或加载字体。
111
113
 
112
114
  - `@symbol(name, size=0.5em)` / `@$(...)`:乐谱符号,简写 `$name`。
@@ -136,14 +138,16 @@ sidebar:
136
138
  - 简写:`N(声部名): 内容`、`L(歌词行名): 歌词`,名称均可省。
137
139
  - `N:` 到同层换行、下一条 `N/L/V` 或块末结束;跨源码行须用 `{}` 包裹。
138
140
  - `name` 后每个字符串参数或 `L:` 对应一行歌词;命名参数名为歌词行名。`L:` 属于前一声部,无所属声部则报错。
139
- - 按空格、连字符和非 ASCII 字符分词;`{你好}` 合为一个音符槽,显示时去掉花括号。
141
+ - 按空格、连字符和非 ASCII 字符分词,依次对应音符、休止符与增时线 `-`;`{你好}` 合为一个槽位,显示时去掉花括号;花括号末尾每加一个 `@` 多覆盖一个槽位并与首位置左对齐(如 `{a@@}` 覆盖三个槽位)。`*`、`**`、`_`、`^` 样式可跨多个音符(如 `L: *春眠不觉晓*`),标记本身不占位置。
140
142
 
141
- - `@voices(...声部, connect="[-]")` / `@vs(...)`:声部按书写顺序自上而下并行。
143
+ - `@voices(...声部, connect="[-]", gap=0.75em, minGap=0.2em)` / `@vs(...)`:声部按书写顺序自上而下并行。
142
144
  - 位置参数须为 `@voice`,各占独立音轨;连续 `N:` 及所属 `L:` 自动成组,空行、作用域结束或普通非成员内容结束组。
145
+ - **gap / minGap(仅命名传参)**:`gap` 为上一声部下沿到下一声部主旋律上沿(基线减半字高)的标准间距(默认 `0.75em`);顶部外扩记号优先借用这段间距,但与上一声部下沿至少保留 `minGap`(默认 `0.2em`,不超过 `gap`);两者均须为非负有限长度。同一宿主下声部数相同的组始终复用音轨,间距不一致时取较大值并产生警告。
143
146
  - **connect(仅命名传参)**:只改外观。`"[-]"` 全组带钩括线,`"{-}"` 全组大括号,`""` 或纯空白字符串仅公共细连谱线;单声部组不画连接。
144
147
  - 范围可组合,如 `"[1-4]{5-7}"`;从 1 编号,只数直接声部,含两端,省略端点取首 / 末声部。
145
148
  - 端点为正整数,不可反向或越界;单成员可写 `[3]` 或 `{3}`,分别等价于 `[3-3]` 或 `{3-3}`;可重叠,不自动嵌套或避让。
146
- - **连接声明**:`V{}:` 大括号、`V[]:` 带钩括线、`V|:` 仅细线;不限行首,后须有 `N:`,可同行或换行。
149
+ - 范围后可用 `:名称` 指定分组总名称(如 `"{1-2:钢琴}[3-4:合唱]"`、`"{-:钢琴}"`、`"{3:独奏}"`),含 `[]{}:`、引号、换行或首尾空白时用双引号包裹;显示在对应连谱号垂直中心左侧,组内有声部名或歌词行名时自动向左错开,重叠连谱号各自按自身中心绘制、不相互避让。
150
+ - **连接声明**:`V{}:`(或 `V{组名}:`)大括号、`V[]:`(或 `V[组名]:`)带钩括线、`V|:` 仅细线;不限行首,后须有 `N:`,可同行或换行。
147
151
  - 到下一 `V` 或组末结束,不拆分并行组;相邻同形声明仍独立,`L:` 不跨声明寻找声部。
148
152
  - **默认值**:省略 `connect` 时取 `@set` 预设或内置 `"[-]"`;显式参数或本组 `V` 声明优先。任一 `V` 完整替换本组预设,未声明部分仅细线,不影响后续组。
149
153
 
@@ -153,11 +157,11 @@ sidebar:
153
157
  - 各分支同时开始、独立计时,可含旋律;首分支留在宿主轨,其余使用分支轨并依次向上排列。
154
158
  - 与 `@up` 不同,整体不能作为单个连音线端点。
155
159
 
156
- - `@up(...)`:和弦,简写 `^`,自下而上排列。
157
- - 折叠为一个事件,时值、对齐和减时线取首成员(宿主);每个参数须恰好产生一个可见对象。
160
+ - `@up(..., gap=0.12em)`:和弦,简写 `^`,自下而上排列。
161
+ - 折叠为一个事件,时值、对齐和减时线取首成员(宿主);每个参数须恰好产生一个可见对象;仅命名参数 `gap` 指定相邻成员间距(默认 `0.12em`,须为非负有限长度)。
158
162
  - 至少一个成员可标注时,整体才可标注;`{1@x ^ 3}` 定位成员,`{1 ^ 3}@x` 定位整体,后者的连音线从最上方成员起跳。
159
163
 
160
- - `@down(...)`:向下堆叠,简写 `_`,与 `^` 共用宿主及折叠规则。
164
+ - `@down(..., gap=0.12em)`:向下堆叠,简写 `_`,与 `^` 共用宿主及折叠规则。
161
165
  - `1^2_3^4_5`:宿主 `1`,上方 `2 4`,下方 `3 5`;横向占位取宿主,附属成员撑开行高。
162
166
  - `1 ^ $accent`、`1 _ $accent` 均修饰宿主,`$accent ^ 1` 无效。
163
167
  - `1 ^ $p`、`1 _ $p` 从宿主生效;`$p ^ 1` 的宿主力度不变,之后的音才改变。
@@ -208,7 +212,6 @@ sidebar:
208
212
  - 两端音高均为有限数值时,同轨按音高绘制,并在起点(或所标增时线及其后续延音)区间内按半音阶离散步进至终点音高;无法比较音高时发出 `W_GLISS_NO_PITCH` 警告并画水平箭头,每条关系只警告一次。
209
213
  - 从被标记对象右侧连接到终点左侧,避让附点与升降号,不自动移至最后一根增时线。
210
214
  - 如 `1 - -@a 5@b @gliss(a,b)`;增时线缺少自身音高时,由 gliss 查找前方音高,并从该增时线起点开始半音步进。
211
- - 同一谱面行内可跨轨;跨轨始终连接实际端点,斜率不代表音高方向。不支持跨行、跨页、同一倚音组内部连接或复杂绕障。
212
215
  - `@beam(...端点标签)`:手工连梁,不受 `div.autobeam` 影响。
213
216
  - 端点须按时间顺序指向同轨、同谱面行的相邻可见元素,可跨零时长小节线;和弦仅宿主参与。
214
217
  - `@tie(...端点标签, height=0)`:连音线 / 延音线。
@@ -219,6 +222,7 @@ sidebar:
219
222
  - `@volta(from, to, pass, ...)`:反复房子,限定区间演奏遍数。
220
223
  - 首末标签可相同、顺序不限;遍数为必填正整数,可多个,如 `@volta(a,b,1,2)`,自动排序去重。
221
224
  - 区间位置决定所属反复段,各段独立计遍;重叠房子限定互斥遍数时警告,重叠列不演奏。
225
+ - `$dc`/`$ds` 跳回后,有 `:|` 的段只走最后一遍,即只进最后一个房子(同 MuseScore 默认);没有 `:|` 的段把跳回算作下一遍。
222
226
  - `@ottava(a, b, shift=1)`:八度号,前两个标签仅支持位置传参;`shift` 为非零整数八度数,正数为高、负数为低,可命名传参。
223
227
  - 标签按 `7 * abs(shift) + 1` 显示:`±1` 为 8、`±2` 为 15、`±3` 为 22,以此类推;使用 `numberfont` 的斜体。
224
228
  - 只改变区间内同轨的播放音高(`12 * shift` 半音,须为安全整数),不改变记谱音符、八度点或时值;其他音轨和打击节拍不受影响。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jpfun",
3
- "version": "0.8.0",
3
+ "version": "1.0.0",
4
4
  "description": "A functional numbered musical notation typesetting engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,14 +12,6 @@
12
12
  "types": "./dist/index.d.ts",
13
13
  "import": "./dist/index.js"
14
14
  },
15
- "./converter/midi": {
16
- "types": "./dist/converter/midi/index.d.ts",
17
- "import": "./dist/converter/midi/index.js"
18
- },
19
- "./converter/musicxml": {
20
- "types": "./dist/converter/musicxml/index.d.ts",
21
- "import": "./dist/converter/musicxml/index.js"
22
- },
23
15
  "./package.json": "./package.json"
24
16
  },
25
17
  "sideEffects": false,
@@ -45,14 +37,6 @@
45
37
  "publishConfig": {
46
38
  "access": "public"
47
39
  },
48
- "scripts": {
49
- "clean": "node -e \"for (const path of ['dist', 'tsconfig.tsbuildinfo']) require('node:fs').rmSync(path, { recursive: true, force: true })\"",
50
- "build": "pnpm run clean && tsc -p tsconfig.json && pnpm run build:bundle",
51
- "build:bundle": "node ../../scripts/build-jpfun-bundles.mjs && node --test ../../scripts/test-jpfun-bundles.mjs",
52
- "prepack": "pnpm run build",
53
- "typecheck": "tsc -p test/tsconfig.json",
54
- "test": "node --import tsx --test \"test/*.test.ts\""
55
- },
56
40
  "keywords": [
57
41
  "numbered-musical-notation",
58
42
  "jianpu",
@@ -64,9 +48,15 @@
64
48
  "license": "Apache-2.0",
65
49
  "devDependencies": {
66
50
  "@types/node": "^26.5.1",
67
- "@xmldom/xmldom": "^0.9.12",
68
51
  "esbuild": "^0.28.2",
69
52
  "tsx": "^4.23.13",
70
53
  "typescript": "^7.0.2"
54
+ },
55
+ "scripts": {
56
+ "clean": "node -e \"for (const path of ['dist', 'tsconfig.tsbuildinfo']) require('node:fs').rmSync(path, { recursive: true, force: true })\"",
57
+ "build": "pnpm run clean && tsc -p tsconfig.json && pnpm run build:bundle",
58
+ "build:bundle": "node ../../scripts/build-jpfun-bundles.mjs && node --test ../../scripts/test-jpfun-bundles.mjs",
59
+ "typecheck": "tsc -p test/tsconfig.json",
60
+ "test": "node --import tsx --test \"test/*.test.ts\""
71
61
  }
72
62
  }
@@ -1,42 +0,0 @@
1
- import type { MidiJson } from "./json.js";
2
- import { type PitchMode } from "../source.js";
3
- export type * from "./json.js";
4
- export interface MidiToJpFunOptions {
5
- pitchMode?: PitchMode;
6
- alignRate?: number;
7
- barsPerLine?: number;
8
- title?: string;
9
- }
10
- export interface MidiLayoutCapability {
11
- compileScore: (source: string, options?: {
12
- horizontalOnly?: boolean;
13
- }) => {
14
- layout: {
15
- objects: {
16
- T: {
17
- isZero(): boolean;
18
- };
19
- t: {
20
- toNumber(): number;
21
- };
22
- layoutLine: number;
23
- mergeKey: number;
24
- box: {
25
- x: number;
26
- w: number;
27
- };
28
- }[];
29
- };
30
- };
31
- anchorKey: number;
32
- page: {
33
- width: number;
34
- marginLeft: number;
35
- marginRight: number;
36
- };
37
- }
38
- /**
39
- * 公开转换入口。options 只控制表示方式;量化后的 track/note 仍保留原始字段,
40
- * 方便后续加入力度、乐器和踏板时直接扩展现有时间线。
41
- */
42
- export declare function convertMidiJsonToJpFun(input: MidiJson, options?: MidiToJpFunOptions, layoutCapability?: MidiLayoutCapability): string;