jpfun 0.9.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 (104) 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/arpeggio/index.js +2 -3
  5. package/dist/functions/bar/index.d.ts +3 -0
  6. package/dist/functions/bar/index.js +18 -3
  7. package/dist/functions/beam/layout.js +3 -2
  8. package/dist/functions/box/index.js +1 -0
  9. package/dist/functions/dash/index.js +5 -2
  10. package/dist/functions/div/index.d.ts +1 -1
  11. package/dist/functions/div/index.js +4 -2
  12. package/dist/functions/dyn/index.js +1 -0
  13. package/dist/functions/gliss/index.js +4 -2
  14. package/dist/functions/grace/index.js +3 -5
  15. package/dist/functions/head/index.js +23 -30
  16. package/dist/functions/key/index.js +4 -7
  17. package/dist/functions/meter/index.d.ts +1 -0
  18. package/dist/functions/meter/index.js +3 -0
  19. package/dist/functions/meter/shape.d.ts +1 -1
  20. package/dist/functions/note/accidentals.d.ts +3 -3
  21. package/dist/functions/note/accidentals.js +29 -16
  22. package/dist/functions/note/index.js +11 -13
  23. package/dist/functions/note/source-transform.d.ts +15 -0
  24. package/dist/functions/note/source-transform.js +74 -67
  25. package/dist/functions/ottava/index.js +1 -0
  26. package/dist/functions/page/index.js +4 -3
  27. package/dist/functions/rest/index.js +8 -6
  28. package/dist/functions/slide/index.js +1 -0
  29. package/dist/functions/temporal.d.ts +9 -3
  30. package/dist/functions/temporal.js +15 -2
  31. package/dist/functions/tie/index.js +28 -4
  32. package/dist/functions/tremolo/index.js +1 -0
  33. package/dist/functions/tuplet/index.js +1 -0
  34. package/dist/functions/up/index.js +3 -5
  35. package/dist/functions/voice/connections.d.ts +1 -1
  36. package/dist/functions/voice/lyrics.d.ts +9 -5
  37. package/dist/functions/voice/lyrics.js +148 -44
  38. package/dist/functions/voice/voice.d.ts +6 -2
  39. package/dist/functions/voice/voice.js +49 -17
  40. package/dist/functions/voice/voices.js +2 -1
  41. package/dist/functions/volta/index.js +1 -0
  42. package/dist/index.d.ts +97 -3
  43. package/dist/index.js +97 -3
  44. package/dist/jpfun.min.js +47 -60
  45. package/dist/layout/engine.d.ts +4 -3
  46. package/dist/layout/engine.js +160 -6
  47. package/dist/layout/model.d.ts +12 -3
  48. package/dist/layout/model.js +15 -7
  49. package/dist/layout/page.js +2 -2
  50. package/dist/layout/path.js +1 -1
  51. package/dist/layout/types.d.ts +10 -2
  52. package/dist/parser/grammarType.d.ts +3 -3
  53. package/dist/parser/parse-utils/brace-utils.js +7 -17
  54. package/dist/parser/parse-utils/call-utils.d.ts +3 -1
  55. package/dist/parser/parse-utils/call-utils.js +17 -32
  56. package/dist/parser/parse-utils/note-utils.d.ts +4 -0
  57. package/dist/parser/parse-utils/note-utils.js +8 -12
  58. package/dist/parser/parserContext.d.ts +8 -2
  59. package/dist/parser/parserContext.js +57 -55
  60. package/dist/parser/preprocess.d.ts +7 -0
  61. package/dist/parser/preprocess.js +21 -19
  62. package/dist/pipeline.d.ts +1 -1
  63. package/dist/playback/compile.js +1 -1
  64. package/dist/render/canvas.js +50 -35
  65. package/dist/render/index.d.ts +1 -1
  66. package/dist/render/index.js +1 -1
  67. package/dist/render/paint.d.ts +7 -0
  68. package/dist/render/paint.js +70 -20
  69. package/dist/render/recording.d.ts +8 -1
  70. package/dist/render/recording.js +12 -0
  71. package/dist/render/svg.d.ts +5 -1
  72. package/dist/render/svg.js +37 -17
  73. package/dist/render/text.d.ts +2 -2
  74. package/dist/render/text.js +7 -6
  75. package/dist/render/translate.d.ts +3 -1
  76. package/dist/render/translate.js +6 -0
  77. package/dist/render/types.d.ts +9 -0
  78. package/grammar.md +6 -5
  79. package/package.json +8 -18
  80. package/dist/converter/midi/convert.d.ts +0 -42
  81. package/dist/converter/midi/convert.js +0 -682
  82. package/dist/converter/midi/index.d.ts +0 -5
  83. package/dist/converter/midi/index.js +0 -11
  84. package/dist/converter/midi/json.d.ts +0 -38
  85. package/dist/converter/midi/json.js +0 -1
  86. package/dist/converter/midi/triplet.d.ts +0 -30
  87. package/dist/converter/midi/triplet.js +0 -75
  88. package/dist/converter/musicxml/dom.d.ts +0 -25
  89. package/dist/converter/musicxml/dom.js +0 -65
  90. package/dist/converter/musicxml/features.d.ts +0 -114
  91. package/dist/converter/musicxml/features.js +0 -501
  92. package/dist/converter/musicxml/index.d.ts +0 -14
  93. package/dist/converter/musicxml/index.js +0 -1285
  94. package/dist/converter/musicxml/model.d.ts +0 -176
  95. package/dist/converter/musicxml/model.js +0 -1
  96. package/dist/converter/musicxml/resolve.d.ts +0 -10
  97. package/dist/converter/musicxml/resolve.js +0 -152
  98. package/dist/converter/source.d.ts +0 -19
  99. package/dist/converter/source.js +0 -53
  100. package/dist/core.d.ts +0 -24
  101. package/dist/core.js +0 -24
  102. package/dist/jpfun.core.min.js +0 -132
  103. package/dist/jpfun.from-midi.min.js +0 -9
  104. package/dist/jpfun.from-musicxml.min.js +0 -12
@@ -24,9 +24,21 @@ export class RecordingPainter {
24
24
  case "path":
25
25
  painter.drawPath(command.commands, command.style);
26
26
  break;
27
+ case "begin-group":
28
+ painter.beginGroup?.(command.group);
29
+ break;
30
+ case "end-group":
31
+ painter.endGroup?.();
32
+ break;
27
33
  }
28
34
  }
29
35
  }
36
+ beginGroup(group) {
37
+ this.commands.push({ kind: "begin-group", group });
38
+ }
39
+ endGroup() {
40
+ this.commands.push({ kind: "end-group" });
41
+ }
30
42
  drawText(text, x, y, style) {
31
43
  this.commands.push({
32
44
  kind: "text",
@@ -1,11 +1,15 @@
1
1
  import type { DocumentLayoutResult } from "../layout/engine.js";
2
- import type { PaintStyle, Painter, PathCommand, PathTransform, TextStyle } from "./types.js";
2
+ import type { PaintGroup, PaintStyle, Painter, PathCommand, PathTransform, TextStyle } from "./types.js";
3
3
  export interface SvgRenderOptions {
4
4
  background?: string;
5
5
  }
6
6
  /** 生成独立 SVG 字符串的 Painter;路径直接输出最终坐标 */
7
7
  export declare class SvgPainter implements Painter {
8
8
  private body;
9
+ /** 未结束分组的开标签在 body 中的下标 */
10
+ private groupStarts;
11
+ beginGroup(group: PaintGroup): void;
12
+ endGroup(): void;
9
13
  drawText(text: string, x: number, y: number, style: TextStyle): void;
10
14
  drawLine(x1: number, y1: number, x2: number, y2: number, style?: PaintStyle): void;
11
15
  drawRect(x: number, y: number, w: number, h: number, style?: PaintStyle): void;
@@ -5,7 +5,10 @@ function number(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;")
@@ -26,30 +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
54
  /** 生成独立 SVG 字符串的 Painter;路径直接输出最终坐标 */
51
55
  export class SvgPainter {
52
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
+ }
53
73
  drawText(text, x, y, style) {
54
74
  const family = style.fontFamily ?? DEFAULT_TEXT_FONT;
55
75
  const weight = style.fontWeight ?? "normal";
@@ -2,7 +2,7 @@ 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
6
  /** 同一行内具有相同样式掩码的连续纯文本片段 */
7
7
  export interface RichTextRun {
8
8
  text: string;
@@ -14,7 +14,7 @@ export declare function appendRun(runs: RichTextRun[], text: string, mask: numbe
14
14
  * 按状态机扫描 `**`、`*`、`_`、`^` 样式开关并逐字符回调 `(ch, mask, escaped)`。
15
15
  * 遇到标记即异或切换对应样式位;若未闭合则后续文本(含跨行、跨音符槽)持续保持该样式。
16
16
  */
17
- export declare function scanMarkdown(source: string, onChar: (ch: string, mask: number, escaped: boolean) => void, escapable?: string): void;
17
+ export declare function scanMarkdown(source: string, onChar: (ch: string, mask: number, escaped: boolean, start: number, end: number) => void, escapable?: string): void;
18
18
  /** 解析多行富文本:单遍跨行扫描样式状态,遇换行切分为每行的片段列表 */
19
19
  export declare function parseRichText(source: string): RichTextRun[][];
20
20
  /** 将前一片段与下一片段的样式掩码差值(`prevMask ^ nextMask`)还原为状态切换标记 */
@@ -1,7 +1,7 @@
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
5
  /** 富文本样式位掩码:四种内联样式正交叠加,通过异或翻转状态 */
6
6
  const STYLE_BOLD = 1;
7
7
  const STYLE_ITALIC = 2;
@@ -22,10 +22,11 @@ export function appendRun(runs, text, mask) {
22
22
  export function scanMarkdown(source, onChar, escapable = "\\*_^") {
23
23
  let mask = 0;
24
24
  for (let i = 0; i < source.length; i++) {
25
+ const start = i;
25
26
  const ch = String.fromCodePoint(source.codePointAt(i));
26
27
  i += ch.length - 1;
27
28
  if (ch === "\\" && i + 1 < source.length && escapable.includes(source[i + 1])) {
28
- onChar(source[++i], mask, true);
29
+ onChar(source[++i], mask, true, start, i + 1);
29
30
  continue;
30
31
  }
31
32
  if (ch === "*") {
@@ -40,7 +41,7 @@ export function scanMarkdown(source, onChar, escapable = "\\*_^") {
40
41
  mask ^= STYLE_SUP;
41
42
  continue;
42
43
  }
43
- onChar(ch, mask, false);
44
+ onChar(ch, mask, false, start, i + 1);
44
45
  }
45
46
  }
46
47
  /** 解析多行富文本:单遍跨行扫描样式状态,遇换行切分为每行的片段列表 */
@@ -128,10 +129,10 @@ export function paintRichLine(painter, line, x, baselineY) {
128
129
  while (i < runs.length && (runs[i].mask & (STYLE_UNDERLINE | STYLE_SUP)) === (mask & (STYLE_UNDERLINE | STYLE_SUP))) {
129
130
  endX += runs[i++].w;
130
131
  }
132
+ const h = Math.max(1, style.fontSize * 0.06);
131
133
  const y = runY(mask) + style.fontSize * 0.12;
132
- painter.drawLine(cursor, y, endX, y, {
133
- stroke: baseStyle.fill ?? "#000",
134
- strokeWidth: Math.max(1, style.fontSize * 0.06),
134
+ painter.drawRect(cursor, y - h / 2, endX - cursor, h, {
135
+ fill: baseStyle.fill ?? "#000",
135
136
  });
136
137
  cursor = endX;
137
138
  }
@@ -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
  }
@@ -70,6 +70,11 @@ export interface PathTransform {
70
70
  scaleX: number;
71
71
  scaleY: number;
72
72
  }
73
+ /** 一组图元的语义信息,SVG 输出为 `<g data-kind>` */
74
+ export interface PaintGroup {
75
+ /** 时值对象取 TemporalNodeBase.kind,attachment 取 LayoutAttachment.kind */
76
+ readonly kind: string;
77
+ }
73
78
  /**
74
79
  * 所有渲染后端必须实现的最小绘制接口
75
80
  *
@@ -82,4 +87,8 @@ export interface Painter {
82
87
  drawRect(x: number, y: number, w: number, h: number, style?: PaintStyle): void;
83
88
  drawCircle(cx: number, cy: number, r: number, style?: PaintStyle): void;
84
89
  drawPath(commands: readonly PathCommand[], style?: PaintStyle, transform?: PathTransform): void;
90
+ /** 开始一个语义分组,必须与 endGroup 成对调用,可以嵌套;不关心分组的后端可以不实现 */
91
+ beginGroup?(group: PaintGroup): void;
92
+ /** 结束最近一个未结束的分组 */
93
+ endGroup?(): void;
85
94
  }
package/grammar.md CHANGED
@@ -53,14 +53,14 @@ 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
61
  - `@page(width, height, top, bottom, left, right, gap, minGap, numbering, barNumbering, font, fillRatio)`:页面布局。
62
62
  - 仅顶层首次声明有效,其余警告并忽略;`em` 按声明时字号计算。
63
- - 默认:宽 `794px`、高 `0px`、上 `45px`、下 `48px`、左右 `40px`、行距 `1em`、最小行距 `0.5em`、`fillRatio=0.5`。
63
+ - 默认:宽 `794px`、高 `0px`、上 `45px`、下 `48px`、左右 `40px`、行距 `1em`、最小行距 `0.4em`、`fillRatio=0.5`。
64
64
  - `gap` 为上一行下沿到下一行主旋律上沿(基线减半字高)的标准行距;顶部外扩图形优先借用行距,但与上一行下沿至少保留 `minGap`(不超过 `gap`)。
65
65
  - `height <= 0` 不自动分页,仍可手动换页;正值按整行分页,单行超高报错。自动封页均分剩余高度,末页保持自然行距。
66
66
  - `fillRatio`:自然宽度达到版心宽度的该比例时撑满;负值始终撑满,`>= 1` 不自动拉开。
@@ -138,11 +138,11 @@ sidebar:
138
138
  - 简写:`N(声部名): 内容`、`L(歌词行名): 歌词`,名称均可省。
139
139
  - `N:` 到同层换行、下一条 `N/L/V` 或块末结束;跨源码行须用 `{}` 包裹。
140
140
  - `name` 后每个字符串参数或 `L:` 对应一行歌词;命名参数名为歌词行名。`L:` 属于前一声部,无所属声部则报错。
141
- - 按空格、连字符和非 ASCII 字符分词;`{你好}` 合为一个音符槽,显示时去掉花括号。`*`、`**`、`_`、`^` 样式可跨多个音符(如 `L: *春眠不觉晓*`),标记本身不占音符位置。
141
+ - 按空格、连字符和非 ASCII 字符分词,依次对应音符、休止符与增时线 `-`;`{你好}` 合为一个槽位,显示时去掉花括号;花括号末尾每加一个 `@` 多覆盖一个槽位并与首位置左对齐(如 `{a@@}` 覆盖三个槽位)。`*`、`**`、`_`、`^` 样式可跨多个音符(如 `L: *春眠不觉晓*`),标记本身不占位置。
142
142
 
143
- - `@voices(...声部, connect="[-]", gap=0.75em, minGap=0.35em)` / `@vs(...)`:声部按书写顺序自上而下并行。
143
+ - `@voices(...声部, connect="[-]", gap=0.75em, minGap=0.2em)` / `@vs(...)`:声部按书写顺序自上而下并行。
144
144
  - 位置参数须为 `@voice`,各占独立音轨;连续 `N:` 及所属 `L:` 自动成组,空行、作用域结束或普通非成员内容结束组。
145
- - **gap / minGap(仅命名传参)**:`gap` 为上一声部下沿到下一声部主旋律上沿(基线减半字高)的标准间距(默认 `0.75em`);顶部外扩记号优先借用这段间距,但与上一声部下沿至少保留 `minGap`(默认 `0.35em`,不超过 `gap`);两者均须为非负有限长度。同一宿主下声部数相同的组始终复用音轨,间距不一致时取较大值并产生警告。
145
+ - **gap / minGap(仅命名传参)**:`gap` 为上一声部下沿到下一声部主旋律上沿(基线减半字高)的标准间距(默认 `0.75em`);顶部外扩记号优先借用这段间距,但与上一声部下沿至少保留 `minGap`(默认 `0.2em`,不超过 `gap`);两者均须为非负有限长度。同一宿主下声部数相同的组始终复用音轨,间距不一致时取较大值并产生警告。
146
146
  - **connect(仅命名传参)**:只改外观。`"[-]"` 全组带钩括线,`"{-}"` 全组大括号,`""` 或纯空白字符串仅公共细连谱线;单声部组不画连接。
147
147
  - 范围可组合,如 `"[1-4]{5-7}"`;从 1 编号,只数直接声部,含两端,省略端点取首 / 末声部。
148
148
  - 端点为正整数,不可反向或越界;单成员可写 `[3]` 或 `{3}`,分别等价于 `[3-3]` 或 `{3-3}`;可重叠,不自动嵌套或避让。
@@ -222,6 +222,7 @@ sidebar:
222
222
  - `@volta(from, to, pass, ...)`:反复房子,限定区间演奏遍数。
223
223
  - 首末标签可相同、顺序不限;遍数为必填正整数,可多个,如 `@volta(a,b,1,2)`,自动排序去重。
224
224
  - 区间位置决定所属反复段,各段独立计遍;重叠房子限定互斥遍数时警告,重叠列不演奏。
225
+ - `$dc`/`$ds` 跳回后,有 `:|` 的段只走最后一遍,即只进最后一个房子(同 MuseScore 默认);没有 `:|` 的段把跳回算作下一遍。
225
226
  - `@ottava(a, b, shift=1)`:八度号,前两个标签仅支持位置传参;`shift` 为非零整数八度数,正数为高、负数为低,可命名传参。
226
227
  - 标签按 `7 * abs(shift) + 1` 显示:`±1` 为 8、`±2` 为 15、`±3` 为 22,以此类推;使用 `numberfont` 的斜体。
227
228
  - 只改变区间内同轨的播放音高(`12 * shift` 半音,须为安全整数),不改变记谱音符、八度点或时值;其他音轨和打击节拍不受影响。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jpfun",
3
- "version": "0.9.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;