jpfun 0.9.0 → 1.1.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.
- package/README.md +11 -16
- package/dist/diagnostic.d.ts +29 -2
- package/dist/diagnostic.js +5 -4
- package/dist/functions/arpeggio/index.js +2 -3
- package/dist/functions/bar/index.d.ts +3 -0
- package/dist/functions/bar/index.js +21 -3
- package/dist/functions/beam/layout.js +3 -2
- package/dist/functions/box/index.js +1 -0
- package/dist/functions/dash/index.js +5 -2
- package/dist/functions/default.js +2 -1
- package/dist/functions/div/index.d.ts +1 -1
- package/dist/functions/div/index.js +4 -2
- package/dist/functions/dyn/index.js +1 -0
- package/dist/functions/gliss/index.js +85 -9
- package/dist/functions/grace/index.d.ts +1 -8
- package/dist/functions/grace/index.js +23 -53
- package/dist/functions/head/index.js +23 -30
- package/dist/functions/key/index.js +5 -7
- package/dist/functions/meter/index.d.ts +1 -0
- package/dist/functions/meter/index.js +3 -0
- package/dist/functions/meter/shape.d.ts +1 -1
- package/dist/functions/note/accidentals.d.ts +3 -3
- package/dist/functions/note/accidentals.js +29 -16
- package/dist/functions/note/index.d.ts +5 -2
- package/dist/functions/note/index.js +168 -25
- package/dist/functions/note/source-transform.d.ts +23 -2
- package/dist/functions/note/source-transform.js +95 -74
- package/dist/functions/ottava/index.js +1 -0
- package/dist/functions/page/index.d.ts +1 -36
- package/dist/functions/page/index.js +8 -7
- package/dist/functions/rest/index.js +8 -6
- package/dist/functions/set/index.js +2 -2
- package/dist/functions/slide/index.js +1 -0
- package/dist/functions/stack/index.js +6 -4
- package/dist/functions/temporal.d.ts +12 -3
- package/dist/functions/temporal.js +15 -2
- package/dist/functions/text/index.js +2 -2
- package/dist/functions/tie/index.js +28 -4
- package/dist/functions/tremolo/index.js +1 -0
- package/dist/functions/tuplet/index.js +1 -0
- package/dist/functions/up/index.js +12 -12
- package/dist/functions/voice/connections.d.ts +1 -1
- package/dist/functions/voice/connections.js +2 -2
- package/dist/functions/voice/lyrics.d.ts +11 -5
- package/dist/functions/voice/lyrics.js +151 -47
- package/dist/functions/voice/voice.d.ts +6 -2
- package/dist/functions/voice/voice.js +51 -19
- package/dist/functions/voice/voices.d.ts +2 -1
- package/dist/functions/voice/voices.js +4 -3
- package/dist/functions/volta/index.js +1 -0
- package/dist/index.d.ts +69 -3
- package/dist/index.js +69 -3
- package/dist/jpfun.min.js +47 -60
- package/dist/layout/engine.d.ts +4 -3
- package/dist/layout/engine.js +173 -27
- package/dist/layout/model.d.ts +13 -4
- package/dist/layout/model.js +15 -7
- package/dist/layout/page.js +2 -2
- package/dist/layout/path.js +1 -1
- package/dist/layout/types.d.ts +12 -3
- package/dist/lowering/accidentalMemory.d.ts +33 -0
- package/dist/lowering/accidentalMemory.js +84 -0
- package/dist/lowering/loweringContext.js +4 -0
- package/dist/parser/grammarType.d.ts +8 -3
- package/dist/parser/parse-utils/brace-utils.js +7 -17
- package/dist/parser/parse-utils/call-utils.d.ts +3 -1
- package/dist/parser/parse-utils/call-utils.js +17 -32
- package/dist/parser/parse-utils/note-utils.d.ts +4 -0
- package/dist/parser/parse-utils/note-utils.js +8 -12
- package/dist/parser/parse-utils/string-utils.d.ts +1 -1
- package/dist/parser/parse-utils/string-utils.js +1 -1
- package/dist/parser/parserContext.d.ts +32 -26
- package/dist/parser/parserContext.js +104 -194
- package/dist/parser/preprocess.d.ts +7 -0
- package/dist/parser/preprocess.js +31 -42
- package/dist/parser/syntax.d.ts +9 -0
- package/dist/parser/syntax.js +109 -0
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +3 -2
- package/dist/playback/compile.js +5 -7
- package/dist/playback/event.d.ts +1 -2
- package/dist/playback/event.js +2 -3
- package/dist/render/canvas.js +50 -35
- package/dist/render/index.d.ts +2 -1
- package/dist/render/index.js +2 -1
- package/dist/render/paint.d.ts +7 -0
- package/dist/render/paint.js +70 -20
- package/dist/render/recording.d.ts +8 -1
- package/dist/render/recording.js +12 -0
- package/dist/render/svg.d.ts +5 -1
- package/dist/render/svg.js +37 -17
- package/dist/render/text.d.ts +2 -2
- package/dist/render/text.js +7 -6
- package/dist/render/translate.d.ts +3 -1
- package/dist/render/translate.js +6 -0
- package/dist/render/types.d.ts +9 -0
- package/grammar.md +7 -5
- package/package.json +8 -18
- package/dist/converter/midi/convert.d.ts +0 -42
- package/dist/converter/midi/convert.js +0 -682
- package/dist/converter/midi/index.d.ts +0 -5
- package/dist/converter/midi/index.js +0 -11
- package/dist/converter/midi/json.d.ts +0 -38
- package/dist/converter/midi/json.js +0 -1
- package/dist/converter/midi/triplet.d.ts +0 -30
- package/dist/converter/midi/triplet.js +0 -75
- package/dist/converter/musicxml/dom.d.ts +0 -25
- package/dist/converter/musicxml/dom.js +0 -65
- package/dist/converter/musicxml/features.d.ts +0 -114
- package/dist/converter/musicxml/features.js +0 -501
- package/dist/converter/musicxml/index.d.ts +0 -14
- package/dist/converter/musicxml/index.js +0 -1285
- package/dist/converter/musicxml/model.d.ts +0 -176
- package/dist/converter/musicxml/model.js +0 -1
- package/dist/converter/musicxml/resolve.d.ts +0 -10
- package/dist/converter/musicxml/resolve.js +0 -152
- package/dist/converter/source.d.ts +0 -19
- package/dist/converter/source.js +0 -53
- package/dist/core.d.ts +0 -24
- package/dist/core.js +0 -24
- package/dist/functions/voice/index.d.ts +0 -2
- package/dist/functions/voice/index.js +0 -2
- package/dist/jpfun.core.min.js +0 -132
- package/dist/jpfun.from-midi.min.js +0 -9
- package/dist/jpfun.from-musicxml.min.js +0 -12
|
@@ -3,6 +3,7 @@ import { ErrorDiagnostic } from "../../diagnostic.js";
|
|
|
3
3
|
import { ANCHOR_KEY, DEFAULT_KEY, transferFunctionAddons, isVisualTemporalNode, TemporalNodeBase, } from "../temporal.js";
|
|
4
4
|
import { Fraction } from "../../fraction.js";
|
|
5
5
|
import { getLayoutBounds, layoutLocalSequence } from "../../layout/engine.js";
|
|
6
|
+
import { paintVisual } from "../../render/paint.js";
|
|
6
7
|
const FOLD_ARGS = [{
|
|
7
8
|
name: "gap",
|
|
8
9
|
namedOnly: true,
|
|
@@ -115,7 +116,7 @@ class FoldFunction extends ASTFunctionNode {
|
|
|
115
116
|
*
|
|
116
117
|
* 被掏空的一方必须撤销候选登记:空壳已不在 AST 里,留在表中会让 @tie() 取到孤儿端点。
|
|
117
118
|
*/
|
|
118
|
-
flatten(drop, side, ctx, gap = this.gap) {
|
|
119
|
+
flatten(drop, side, ctx, gap = this.gap, registered = true) {
|
|
119
120
|
// 成员顺序跟随源码;比较必须在 growSpan 之前
|
|
120
121
|
const front = drop.sourceSpan.start < this.sourceSpan.start ? drop : this;
|
|
121
122
|
const back = front === drop ? this : drop;
|
|
@@ -132,6 +133,8 @@ class FoldFunction extends ASTFunctionNode {
|
|
|
132
133
|
c.parent = this;
|
|
133
134
|
this.growSpan(drop.sourceSpan);
|
|
134
135
|
drop.contents.length = drop.belows.length = drop.aboveGaps.length = drop.belowGaps.length = 0;
|
|
136
|
+
if (!registered)
|
|
137
|
+
return this; // 语法糖新建的左包装从未入表;合成在本层末尾,整表扫描会让平放和弦变成平方级
|
|
135
138
|
const stale = ctx.labelableNodes.lastIndexOf(drop);
|
|
136
139
|
if (stale >= 0)
|
|
137
140
|
ctx.labelableNodes.splice(stale, 1);
|
|
@@ -154,19 +157,19 @@ class FoldFunction extends ASTFunctionNode {
|
|
|
154
157
|
const host = leftNode instanceof FoldFunction
|
|
155
158
|
? leftNode
|
|
156
159
|
: wrapper.addContent(leftNode, "above", ctx);
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
ctx.deferRightOperand(right => {
|
|
161
|
+
if (!right)
|
|
162
|
+
throw new ErrorDiagnostic("E_FOLD_NO_TARGET", "{fn}语法糖错误: 右边没有找到可叠加的目标", n.span, { fn: label });
|
|
163
|
+
// 右操作数可能已被 @tie() 等按引用取走(它就在本层剩余部分里,先于合成解析),
|
|
159
164
|
// 而新建的左包装无人引用,所以合并时让右边存活;接收者就是存活的那一方
|
|
160
165
|
const merged = right instanceof FoldFunction
|
|
161
|
-
? right.flatten(host, this.side, ctx, wrapper.gap)
|
|
166
|
+
? right.flatten(host, this.side, ctx, wrapper.gap, host !== wrapper)
|
|
162
167
|
: host.addContent(right, this.side, ctx, wrapper.gap);
|
|
163
168
|
// 语法糖不走 pushNode,这里补登记;null 同样入表,和显式调用一样成为边界
|
|
164
169
|
ctx.labelableNodes.push(merged.labelable());
|
|
165
170
|
return merged;
|
|
166
171
|
});
|
|
167
|
-
|
|
168
|
-
return next;
|
|
169
|
-
throw new ErrorDiagnostic("E_FOLD_NO_TARGET", "{fn}语法糖错误: 右边没有找到可叠加的目标", n.span, { fn: label });
|
|
172
|
+
return at;
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
class UpFunction extends FoldFunction {
|
|
@@ -380,10 +383,7 @@ class FoldTemporal extends TemporalNodeBase {
|
|
|
380
383
|
}
|
|
381
384
|
}
|
|
382
385
|
paint(painter) {
|
|
383
|
-
for (const member of this.members)
|
|
384
|
-
|
|
385
|
-
for (const decoration of member.decorations)
|
|
386
|
-
decoration.paint?.(painter);
|
|
387
|
-
}
|
|
386
|
+
for (const member of this.members)
|
|
387
|
+
paintVisual(painter, member);
|
|
388
388
|
}
|
|
389
389
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SourceSpan } from "../ASTtypes.js";
|
|
2
2
|
import type { PathCommand } from "../../render/types.js";
|
|
3
3
|
export declare const CURVED_BRACE_COMMANDS: readonly PathCommand[];
|
|
4
|
-
export declare const CURVED_BRACE_BOUNDS: import("../../
|
|
4
|
+
export declare const CURVED_BRACE_BOUNDS: import("../../index.js").Rect;
|
|
5
5
|
/** 方括线端钩,以粗竖线宽度为单位,绘制时上下镜像 */
|
|
6
6
|
export declare const BRACKET_HOOK_REACH = 2.33;
|
|
7
7
|
export declare const BRACKET_HOOK_DROP = 1.17;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorDiagnostic } from "../../diagnostic.js";
|
|
2
2
|
import { pathBounds } from "../../layout/path.js";
|
|
3
|
-
import { findClosingQuote, parseString,
|
|
3
|
+
import { findClosingQuote, parseString, quoteSourceString } from "../../parser/parse-utils/string-utils.js";
|
|
4
4
|
export const CURVED_BRACE_COMMANDS = [
|
|
5
5
|
{ op: "M", x: 2.98438, y: -165.5 },
|
|
6
6
|
{ op: "C", cx1: 8.9375, cy1: -171.781, cx2: 20.5156, cy2: -184.688, x: 20.5156, y: -208.531 },
|
|
@@ -121,7 +121,7 @@ export function resolveConnections(specs, count, span) {
|
|
|
121
121
|
}
|
|
122
122
|
export function serializeConnections(specs) {
|
|
123
123
|
return specs.map(({ kind, from, to, name }) => {
|
|
124
|
-
const label = !name ? "" : `:${FORBIDDEN_RAW_NAME_RE.test(name) || name.trim() !== name ?
|
|
124
|
+
const label = !name ? "" : `:${FORBIDDEN_RAW_NAME_RE.test(name) || name.trim() !== name ? quoteSourceString(name) : name}`;
|
|
125
125
|
const range = `${from ?? ""}-${to ?? ""}${label}`;
|
|
126
126
|
return kind === "brace" ? `{${range}}` : `[${range}]`;
|
|
127
127
|
}).join("");
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import type { AttachmentLayoutContext, HorizontalLineView, LayoutAttachment, LayoutPrepareContext, LayoutRegion } from "../../layout/types.js";
|
|
2
|
+
import type { SourceSpan } from "../../parser/types.js";
|
|
2
3
|
import { type PreparedRichLine, type RichTextRun } from "../../render/text.js";
|
|
3
4
|
import type { Painter, TextStyle } from "../../render/types.js";
|
|
4
5
|
import type { VisualTemporalNode } from "../temporal.js";
|
|
5
6
|
import type { VoiceNameTemporal } from "./voice.js";
|
|
6
7
|
/** 歌词与歌词行名称相对声部字号的字号 */
|
|
7
|
-
export declare const LYRIC_SIZE_RATIO = 0.
|
|
8
|
+
export declare const LYRIC_SIZE_RATIO = 0.88;
|
|
9
|
+
export declare const LYRIC_OPENING_PUNCTUATION: Set<string>;
|
|
10
|
+
export declare const LYRIC_SILENT_PUNCTUATION: Set<string>;
|
|
8
11
|
/** 歌词行名称与歌词正文共用同一个基础样式 */
|
|
9
12
|
export declare function lyricNameStyle(size: number, fontFamily: string): TextStyle;
|
|
13
|
+
export type LyricSlot = RichTextRun[] | null;
|
|
10
14
|
/**
|
|
11
15
|
* 把歌词拆成与音符一一对应的富文本槽位,同时支持跨槽或槽内的 Markdown 样式(`**`、`*`、`_`、`^`)。
|
|
12
16
|
* 例如 `hello world` 拆成 `hello`、`world`,`hel-lo` 拆成 `hel-`、`lo`;
|
|
13
|
-
* `你好吗` 默认逐字拆分,`你 @ 好` 中的 `@`
|
|
17
|
+
* `你好吗` 默认逐字拆分,`你 @ 好` 中的 `@` 留出一个空槽,
|
|
18
|
+
* `{你好} 啊` 把 `你好` 放在同一个槽位,`{a@@}` 则左对齐并覆盖三个槽位(后续槽记为 `null`)。
|
|
14
19
|
*/
|
|
15
|
-
export declare function parseLyric(value: string):
|
|
16
|
-
export declare function serializeLyric(tokens: readonly (readonly RichTextRun[])[]): string;
|
|
20
|
+
export declare function parseLyric(value: string, offsets?: readonly number[], tokenSpans?: (SourceSpan | undefined)[]): LyricSlot[];
|
|
21
|
+
export declare function serializeLyric(tokens: readonly (readonly RichTextRun[] | null)[]): string;
|
|
17
22
|
export declare class VoiceLyricsAttachment implements LayoutAttachment {
|
|
18
23
|
private readonly nodes;
|
|
19
24
|
private readonly nameHost;
|
|
20
25
|
private readonly frames;
|
|
26
|
+
readonly kind = "lyrics";
|
|
21
27
|
layer: "foreground";
|
|
22
|
-
get sourceSpan():
|
|
28
|
+
get sourceSpan(): SourceSpan;
|
|
23
29
|
constructor(nodes: readonly VisualTemporalNode[], nameHost: VoiceNameTemporal, frames: readonly LayoutAttachment[]);
|
|
24
30
|
prepareHorizontal(lines: HorizontalLineView[], context: LayoutPrepareContext): void;
|
|
25
31
|
createGeometry(context: AttachmentLayoutContext): {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { getLayoutBounds } from "../../layout/engine.js";
|
|
2
|
-
import {
|
|
2
|
+
import { quoteSourceString } from "../../parser/parse-utils/string-utils.js";
|
|
3
3
|
import { appendRun, markdownToggles, paintRichLine, prepareRichLine, scanMarkdown, } from "../../render/text.js";
|
|
4
4
|
const WHITESPACE_RE = /\s/;
|
|
5
5
|
/** 歌词与歌词行名称相对声部字号的字号 */
|
|
6
|
-
export const LYRIC_SIZE_RATIO = 0.
|
|
6
|
+
export const LYRIC_SIZE_RATIO = 0.88;
|
|
7
7
|
// 分词跟后面的标点
|
|
8
|
-
const LYRIC_OPENING_PUNCTUATION = new Set("(([
|
|
8
|
+
export const LYRIC_OPENING_PUNCTUATION = new Set("(([[{〈《「『【〔〖〘〚‘“⒈⒉⒊⒋⒌");
|
|
9
9
|
// 不发声的标点;位于歌词槽首尾时只渲染,不占位,也不参与对齐中心计算
|
|
10
|
-
const LYRIC_SILENT_PUNCTUATION = new Set([
|
|
10
|
+
export const LYRIC_SILENT_PUNCTUATION = new Set([
|
|
11
11
|
...LYRIC_OPENING_PUNCTUATION,
|
|
12
12
|
...",。!?;:、,.!?;:))]]}〉》」』】〕〗〙〛’”\"'…—–",
|
|
13
13
|
]);
|
|
@@ -44,12 +44,25 @@ function measureLyricToken(runs, style, measurer) {
|
|
|
44
44
|
};
|
|
45
45
|
return { richLine, prefixWidth: rangeWidth(0, start), bodyWidth: rangeWidth(start, end) };
|
|
46
46
|
}
|
|
47
|
+
function lyricLeftPortX(target) {
|
|
48
|
+
return target.ports["body.left"]?.x ?? 0;
|
|
49
|
+
}
|
|
50
|
+
/** 将刚性半宽提升至 min,并从同侧弹簧 margin 中等量扣减:未超长时保持 WL/WR+margin 总宽不变,压缩时以刚性下界防重叠 */
|
|
51
|
+
function reserveSide(el, side, min) {
|
|
52
|
+
const w = side === "L" ? "WL" : "WR";
|
|
53
|
+
const m = side === "L" ? "margin_L" : "margin_R";
|
|
54
|
+
if (min > el[w]) {
|
|
55
|
+
el[m] = Math.max(0, el[w] + el[m] - min);
|
|
56
|
+
el[w] = min;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
47
59
|
/**
|
|
48
60
|
* 把歌词拆成与音符一一对应的富文本槽位,同时支持跨槽或槽内的 Markdown 样式(`**`、`*`、`_`、`^`)。
|
|
49
61
|
* 例如 `hello world` 拆成 `hello`、`world`,`hel-lo` 拆成 `hel-`、`lo`;
|
|
50
|
-
* `你好吗` 默认逐字拆分,`你 @ 好` 中的 `@`
|
|
62
|
+
* `你好吗` 默认逐字拆分,`你 @ 好` 中的 `@` 留出一个空槽,
|
|
63
|
+
* `{你好} 啊` 把 `你好` 放在同一个槽位,`{a@@}` 则左对齐并覆盖三个槽位(后续槽记为 `null`)。
|
|
51
64
|
*/
|
|
52
|
-
export function parseLyric(value) {
|
|
65
|
+
export function parseLyric(value, offsets, tokenSpans) {
|
|
53
66
|
let closeBraces = 0;
|
|
54
67
|
for (let i = 0; i < value.length; i++) {
|
|
55
68
|
if (value[i] === "\\")
|
|
@@ -59,99 +72,152 @@ export function parseLyric(value) {
|
|
|
59
72
|
}
|
|
60
73
|
const result = [];
|
|
61
74
|
let pending = [];
|
|
62
|
-
let
|
|
63
|
-
let
|
|
64
|
-
|
|
75
|
+
let lastToken;
|
|
76
|
+
let lastSpan;
|
|
77
|
+
let tokStart = -1, tokEnd = 0, keepRuns = 0, keepLen = 0, span = 0;
|
|
78
|
+
let hasBody = false, grouped = false;
|
|
79
|
+
const mark = (from, to) => { if (tokStart < 0)
|
|
80
|
+
tokStart = from; tokEnd = to; };
|
|
81
|
+
const add = (text, mask, from, to) => {
|
|
65
82
|
appendRun(pending, text, mask);
|
|
83
|
+
mark(from, to);
|
|
66
84
|
hasBody = true;
|
|
67
85
|
};
|
|
68
86
|
const flush = (force = false) => {
|
|
69
87
|
if (!force && !hasBody)
|
|
70
88
|
return;
|
|
71
|
-
|
|
89
|
+
if (tokenSpans && offsets && tokStart >= 0) {
|
|
90
|
+
tokenSpans[result.length] = lastSpan = { start: offsets[tokStart], end: offsets[tokEnd] };
|
|
91
|
+
}
|
|
92
|
+
result.push(lastToken = pending);
|
|
72
93
|
pending = [];
|
|
94
|
+
tokStart = -1;
|
|
73
95
|
hasBody = false;
|
|
74
96
|
};
|
|
75
|
-
scanMarkdown(value, (ch, mask, escaped) => {
|
|
97
|
+
scanMarkdown(value, (ch, mask, escaped, from, to) => {
|
|
76
98
|
if (!escaped && ch === "}")
|
|
77
99
|
closeBraces--;
|
|
78
100
|
if (grouped) {
|
|
79
101
|
if (!escaped && ch === "}") {
|
|
80
|
-
|
|
102
|
+
mark(from, to);
|
|
103
|
+
if (span) {
|
|
104
|
+
pending.length = keepRuns;
|
|
105
|
+
if (keepRuns)
|
|
106
|
+
pending[keepRuns - 1].text = pending[keepRuns - 1].text.slice(0, keepLen);
|
|
107
|
+
}
|
|
108
|
+
if (!keepRuns && span) {
|
|
109
|
+
while (span--)
|
|
110
|
+
result.push([]);
|
|
111
|
+
tokStart = -1;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
flush(true);
|
|
115
|
+
while (span--)
|
|
116
|
+
result.push(null);
|
|
117
|
+
}
|
|
118
|
+
keepRuns = keepLen = span = 0;
|
|
81
119
|
grouped = false;
|
|
82
120
|
}
|
|
121
|
+
else if (!escaped && (ch === "@" || WHITESPACE_RE.test(ch))) {
|
|
122
|
+
if (ch === "@")
|
|
123
|
+
span++;
|
|
124
|
+
add(ch, mask, from, to);
|
|
125
|
+
}
|
|
83
126
|
else {
|
|
84
|
-
|
|
127
|
+
add(ch, mask, from, to);
|
|
128
|
+
keepRuns = pending.length;
|
|
129
|
+
keepLen = pending[keepRuns - 1].text.length;
|
|
130
|
+
span = 0;
|
|
85
131
|
}
|
|
86
132
|
}
|
|
87
133
|
else if (!escaped && ch === "{" && closeBraces > 0) {
|
|
88
134
|
flush();
|
|
135
|
+
mark(from, to);
|
|
89
136
|
grouped = true;
|
|
90
137
|
}
|
|
91
138
|
else if (escaped) {
|
|
92
|
-
add(ch, mask);
|
|
139
|
+
add(ch, mask, from, to);
|
|
93
140
|
}
|
|
94
141
|
else if (WHITESPACE_RE.test(ch)) {
|
|
95
142
|
flush();
|
|
96
143
|
}
|
|
97
144
|
else if (ch === "-") {
|
|
98
145
|
const shouldFlush = hasBody;
|
|
99
|
-
add(ch, mask);
|
|
146
|
+
add(ch, mask, from, to);
|
|
100
147
|
if (shouldFlush)
|
|
101
148
|
flush();
|
|
102
149
|
}
|
|
103
150
|
else if (ch === "@") {
|
|
104
151
|
if (hasBody) {
|
|
105
|
-
add(ch, mask);
|
|
152
|
+
add(ch, mask, from, to);
|
|
106
153
|
flush();
|
|
107
154
|
}
|
|
108
155
|
result.push([]);
|
|
156
|
+
lastToken = lastSpan = undefined;
|
|
109
157
|
}
|
|
110
158
|
else if (LYRIC_OPENING_PUNCTUATION.has(ch)) {
|
|
111
159
|
flush();
|
|
160
|
+
mark(from, to);
|
|
112
161
|
appendRun(pending, ch, mask);
|
|
113
162
|
}
|
|
114
163
|
else if (LYRIC_SILENT_PUNCTUATION.has(ch)) {
|
|
115
|
-
|
|
164
|
+
if (pending.length > 0 || !lastToken?.length) {
|
|
165
|
+
mark(from, to);
|
|
166
|
+
appendRun(pending, ch, mask);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
appendRun(lastToken, ch, mask);
|
|
170
|
+
if (lastSpan && offsets)
|
|
171
|
+
lastSpan.end = offsets[to];
|
|
172
|
+
}
|
|
116
173
|
}
|
|
117
174
|
else if (ch.charCodeAt(0) > 0x7F) {
|
|
118
175
|
flush();
|
|
119
|
-
add(ch, mask);
|
|
176
|
+
add(ch, mask, from, to);
|
|
120
177
|
flush();
|
|
121
178
|
}
|
|
122
179
|
else {
|
|
123
|
-
add(ch, mask);
|
|
180
|
+
add(ch, mask, from, to);
|
|
124
181
|
}
|
|
125
182
|
}, "\\*_{}@-^");
|
|
126
183
|
flush();
|
|
127
184
|
if (pending.length > 0) {
|
|
128
|
-
if (
|
|
185
|
+
if (lastToken?.length) {
|
|
129
186
|
for (const run of pending)
|
|
130
|
-
appendRun(
|
|
187
|
+
appendRun(lastToken, run.text, run.mask);
|
|
188
|
+
if (lastSpan && offsets)
|
|
189
|
+
lastSpan.end = offsets[tokEnd];
|
|
131
190
|
}
|
|
132
191
|
else {
|
|
192
|
+
if (tokenSpans && offsets && tokStart >= 0) {
|
|
193
|
+
tokenSpans[result.length] = { start: offsets[tokStart], end: offsets[tokEnd] };
|
|
194
|
+
}
|
|
133
195
|
result.push(pending);
|
|
134
196
|
}
|
|
135
197
|
}
|
|
136
198
|
return result;
|
|
137
199
|
}
|
|
138
200
|
export function serializeLyric(tokens) {
|
|
139
|
-
return
|
|
201
|
+
return quoteSourceString(tokens.flatMap((runs, i) => {
|
|
202
|
+
if (runs === null)
|
|
203
|
+
return [];
|
|
140
204
|
if (runs.length === 0)
|
|
141
205
|
return "@";
|
|
142
|
-
let mask = 0;
|
|
143
|
-
|
|
206
|
+
let span = 0, mask = 0, inner = "";
|
|
207
|
+
while (tokens[i + 1 + span] === null)
|
|
208
|
+
span++;
|
|
144
209
|
for (const run of runs) {
|
|
145
210
|
inner += markdownToggles(mask ^ run.mask) + run.text.replace(/[\\{}@\-*_^]/g, "\\$&");
|
|
146
211
|
mask = run.mask;
|
|
147
212
|
}
|
|
148
|
-
return `{${inner}${markdownToggles(mask)}}`;
|
|
213
|
+
return `{${inner}${markdownToggles(mask)}${"@".repeat(span)}}`;
|
|
149
214
|
}).join(" "));
|
|
150
215
|
}
|
|
151
216
|
export class VoiceLyricsAttachment {
|
|
152
217
|
nodes;
|
|
153
218
|
nameHost;
|
|
154
219
|
frames;
|
|
220
|
+
kind = "lyrics";
|
|
155
221
|
layer = "foreground";
|
|
156
222
|
get sourceSpan() { return this.nameHost.ast.sourceSpan; }
|
|
157
223
|
constructor(nodes, nameHost, frames) {
|
|
@@ -165,26 +231,59 @@ export class VoiceLyricsAttachment {
|
|
|
165
231
|
return;
|
|
166
232
|
const { lyrics, size, font } = this.nameHost.ast;
|
|
167
233
|
const style = lyricNameStyle(size, font);
|
|
168
|
-
for (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
234
|
+
for (const { tokens } of lyrics) {
|
|
235
|
+
for (let i = 0; i < tokens.length && i < targets.length; i++) {
|
|
236
|
+
const runs = tokens[i];
|
|
237
|
+
if (!runs?.length)
|
|
238
|
+
continue;
|
|
239
|
+
const { bodyWidth } = measureLyricToken(runs, style, context.textMeasurer);
|
|
240
|
+
if (bodyWidth === 0)
|
|
241
|
+
continue;
|
|
242
|
+
const first = targets[i];
|
|
243
|
+
if (tokens[i + 1] !== null) {
|
|
244
|
+
// 只扩大求解占用;视觉盒和端口不动,音符内部几何因此保持原位。
|
|
245
|
+
lines[first.layoutLine]?.registerHorizontalLayoutHook(first, first, ({ columns, start }) => {
|
|
246
|
+
const element = columns[start].find(item => item.time === first);
|
|
247
|
+
if (!element)
|
|
248
|
+
return;
|
|
249
|
+
const lyricOffset = first.ports["lyric"].x - first.box.anchor;
|
|
250
|
+
element.WL = Math.max(element.WL, bodyWidth / 2 - lyricOffset);
|
|
251
|
+
element.WR = Math.max(element.WR, bodyWidth / 2 + lyricOffset);
|
|
252
|
+
});
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
let end = i;
|
|
256
|
+
while (tokens[i + 1] === null) {
|
|
257
|
+
i++;
|
|
258
|
+
if (targets[i]?.layoutLine === first.layoutLine && targets[i].track === first.track)
|
|
259
|
+
end = i;
|
|
175
260
|
}
|
|
261
|
+
const leftExtent = first.box.anchor - lyricLeftPortX(first);
|
|
262
|
+
const rightSpan = Math.max(0, bodyWidth - leftExtent);
|
|
263
|
+
// 跨槽词从首音符 body.left 向右延伸 rightSpan:
|
|
264
|
+
// 1. 词未超过自然宽度(total - lastEl.margin_R)时,按各段自然宽度比例从 margin 置换刚性下界,自然间距不变;
|
|
265
|
+
// 2. 词超过自然宽度时,scale > 1 按原间距比例等比撑开各列,并借 keepMargin 保留末音右侧的弹性间隙。
|
|
266
|
+
lines[first.layoutLine]?.registerHorizontalLayoutHook(first, targets[end], ({ columns, start, end }) => {
|
|
267
|
+
const row = columns[start].findIndex(item => item.time === first);
|
|
268
|
+
if (row < 0)
|
|
269
|
+
return;
|
|
270
|
+
const lastEl = columns[end][row];
|
|
271
|
+
reserveSide(columns[start][row], "L", leftExtent);
|
|
272
|
+
let total = lastEl.WR + lastEl.margin_R;
|
|
273
|
+
for (let c = start; c < end; c++) {
|
|
274
|
+
const a = columns[c][row], b = columns[c + 1][row];
|
|
275
|
+
total += a.WR + a.margin_R + b.WL + b.margin_L;
|
|
276
|
+
}
|
|
277
|
+
const keepMargin = Math.max(0, Math.min(lastEl.margin_R, rightSpan - (total - lastEl.margin_R)));
|
|
278
|
+
const scale = (rightSpan + keepMargin) / total;
|
|
279
|
+
for (let c = start; c < end; c++) {
|
|
280
|
+
const a = columns[c][row], b = columns[c + 1][row];
|
|
281
|
+
reserveSide(a, "R", (a.WR + a.margin_R) * scale);
|
|
282
|
+
reserveSide(b, "L", (b.WL + b.margin_L) * scale);
|
|
283
|
+
}
|
|
284
|
+
reserveSide(lastEl, "R", (lastEl.WR + lastEl.margin_R) * scale - keepMargin);
|
|
285
|
+
});
|
|
176
286
|
}
|
|
177
|
-
if (halfWidth === 0)
|
|
178
|
-
continue;
|
|
179
|
-
// 只扩大求解占用;视觉盒和端口不动,音符内部几何因此保持原位。
|
|
180
|
-
lines[target.layoutLine]?.registerHorizontalLayoutHook(target, target, ({ columns, start }) => {
|
|
181
|
-
const element = columns[start].find(item => item.time === target);
|
|
182
|
-
if (!element)
|
|
183
|
-
return;
|
|
184
|
-
const lyricOffset = target.ports["lyric"].x - target.box.anchor;
|
|
185
|
-
element.WL = Math.max(element.WL, halfWidth - lyricOffset);
|
|
186
|
-
element.WR = Math.max(element.WR, halfWidth + lyricOffset);
|
|
187
|
-
});
|
|
188
287
|
}
|
|
189
288
|
}
|
|
190
289
|
createGeometry(context) {
|
|
@@ -238,8 +337,8 @@ export class VoiceLyricsAttachment {
|
|
|
238
337
|
byTrack.set(target.track, baseline);
|
|
239
338
|
}
|
|
240
339
|
const style = lyricNameStyle(size, font);
|
|
241
|
-
const rowAdvance = style.fontSize + size * 0.
|
|
242
|
-
const baselineOffset = context.textMeasurer.measureText("M", style).baseline + size * 0.
|
|
340
|
+
const rowAdvance = style.fontSize + size * 0.25;
|
|
341
|
+
const baselineOffset = context.textMeasurer.measureText("M", style).baseline + size * 0.4;
|
|
243
342
|
const baselineOf = (bottom, row) => bottom + baselineOffset + row * rowAdvance;
|
|
244
343
|
// 跨轨框外的歌词由最下轨承担占用,各原始轨的歌词行依次排列
|
|
245
344
|
if (this.frames.length)
|
|
@@ -262,15 +361,20 @@ export class VoiceLyricsAttachment {
|
|
|
262
361
|
const runs = lyric.tokens[i];
|
|
263
362
|
const target = targets[i];
|
|
264
363
|
const baseline = baselines.get(target.layoutLine)?.get(target.track);
|
|
265
|
-
if (!runs
|
|
364
|
+
if (!runs?.length || !baseline)
|
|
266
365
|
continue;
|
|
267
366
|
const { richLine, prefixWidth, bodyWidth } = measureLyricToken(runs, style, context.textMeasurer);
|
|
367
|
+
const leftAligned = lyric.tokens[i + 1] === null;
|
|
368
|
+
const ast = this.nameHost.ast;
|
|
268
369
|
preparedText.push({
|
|
269
370
|
...richLine,
|
|
270
|
-
x: target.box.x +
|
|
371
|
+
x: target.box.x + (leftAligned
|
|
372
|
+
? lyricLeftPortX(target) - prefixWidth
|
|
373
|
+
: target.ports["lyric"].x - bodyWidth / 2 - prefixWidth),
|
|
271
374
|
y: baselineOf(baseline.bottom, row) - richLine.baseline,
|
|
272
375
|
line: target.layoutLine,
|
|
273
376
|
track: baseline.owner,
|
|
377
|
+
get sourceSpan() { return ast.lyricTokenSpan(row, i); },
|
|
274
378
|
});
|
|
275
379
|
}
|
|
276
380
|
if (!lyric.name || !labelBox || !labelBaseline)
|
|
@@ -3,9 +3,9 @@ import { type LayoutBox, type LayoutPrepareContext } from "../../layout/types.js
|
|
|
3
3
|
import type { LoweringContext } from "../../lowering/loweringContext.js";
|
|
4
4
|
import { GrammarNode, GrammarSugarNode } from "../../parser/grammarType.js";
|
|
5
5
|
import { ParserContext } from "../../parser/parserContext.js";
|
|
6
|
-
import { type RichTextRun } from "../../render/text.js";
|
|
7
6
|
import type { Painter, TextStyle } from "../../render/types.js";
|
|
8
7
|
import { TemporalNodeBase } from "../temporal.js";
|
|
8
|
+
import { type LyricSlot } from "./lyrics.js";
|
|
9
9
|
export declare function voiceNameStyle(size: number, fontFamily: string): TextStyle;
|
|
10
10
|
export declare class VoiceFunction extends ASTFunctionNode {
|
|
11
11
|
static def: {
|
|
@@ -37,9 +37,13 @@ export declare class VoiceFunction extends ASTFunctionNode {
|
|
|
37
37
|
readonly font: string;
|
|
38
38
|
lyrics: {
|
|
39
39
|
name: string;
|
|
40
|
-
tokens:
|
|
40
|
+
tokens: LyricSlot[];
|
|
41
41
|
}[];
|
|
42
|
+
private readonly lyricSources;
|
|
43
|
+
private cachedLyricSpans?;
|
|
42
44
|
get children(): ASTBraceNode[];
|
|
45
|
+
/** 仅在导航定位读取时按需计算词元源码区间,正常编译渲染零开销 */
|
|
46
|
+
lyricTokenSpan(row: number, index: number): SourceSpan | undefined;
|
|
43
47
|
/**
|
|
44
48
|
* voice 的音符内容仍按普通 sequence 进入全局时间列
|
|
45
49
|
* 此处按需建立歌词作用域,并在内容前创建声部名对象
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ASTBraceNode, ASTFunctionNode, ASTTextNode } from "../ASTtypes.js";
|
|
2
2
|
import { Diagnostic, ErrorDiagnostic, WarningDiagnostic } from "../../diagnostic.js";
|
|
3
3
|
import { isLayoutAttachment } from "../../layout/types.js";
|
|
4
|
-
import { findRightParen } from "../../parser/parse-utils/call-utils.js";
|
|
5
|
-
import { findClosingQuote,
|
|
4
|
+
import { findRightParen, trimRange } from "../../parser/parse-utils/call-utils.js";
|
|
5
|
+
import { findClosingQuote, quoteSourceString } from "../../parser/parse-utils/string-utils.js";
|
|
6
6
|
import { ParserContext, skipSpaces } from "../../parser/parserContext.js";
|
|
7
7
|
import { paintRichLine, prepareRichLine } from "../../render/text.js";
|
|
8
8
|
import { isVisualTemporalNode, TemporalNodeBase } from "../temporal.js";
|
|
@@ -28,7 +28,7 @@ export class VoiceFunction extends ASTFunctionNode {
|
|
|
28
28
|
~~~
|
|
29
29
|
- **额外参数**:每项为一行歌词;命名参数同时给出歌词行名,位置参数表示无行名。省略声部名但仍需歌词时,保留空位,如 \`@voice({1 2 3}, , ha ha ha)\`。
|
|
30
30
|
|
|
31
|
-
歌词可用引号包裹;调用 \`@voice\` 时歌词若含逗号须加引号。英文用空格或连字符 \`-\` 分词,用 \`@\`
|
|
31
|
+
歌词可用引号包裹;调用 \`@voice\` 时歌词若含逗号须加引号。英文用空格或连字符 \`-\` 分词,用 \`@\` 留空;\`{你好}\` 合为一个音符槽,末尾加 \`@\`(如 \`{a@@}\`)可左对齐并覆盖多个音符槽。名称与歌词均支持 \`*斜体*\`、\`**粗体**\`、\`_下划线_\`、\`^上标^\`(可跨多个音符,如 \`*春眠不觉晓*\`)。
|
|
32
32
|
|
|
33
33
|
**简写**:\`N\` 声明音符行,\`L\` 声明歌词行,括号内的名称可省略:
|
|
34
34
|
~~~jpfun
|
|
@@ -84,25 +84,24 @@ L: la la la
|
|
|
84
84
|
return { next: pos, node };
|
|
85
85
|
}
|
|
86
86
|
// 字符串收集
|
|
87
|
-
|
|
88
|
-
if (
|
|
87
|
+
const from = skipSpaces(source, pos, end);
|
|
88
|
+
if (from >= end)
|
|
89
89
|
return null; // 没有内容了 不去糖
|
|
90
90
|
let lyric;
|
|
91
91
|
// 双引号才是字符串,单引号不是
|
|
92
|
-
if (source[
|
|
92
|
+
if (source[from] === '"') {
|
|
93
93
|
// 未闭合就不去糖,词法层每次击键都跑,不能抛
|
|
94
|
-
const close = findClosingQuote(source,
|
|
94
|
+
const close = findClosingQuote(source, from, end);
|
|
95
95
|
if (close < 0)
|
|
96
96
|
return null;
|
|
97
|
-
lyric = { start:
|
|
98
|
-
pos = close + 1;
|
|
97
|
+
lyric = { start: from, end: close + 1 };
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
100
|
// 没有引号的 以换行符为界切分 预处理已经跳过了转义的换行符了
|
|
102
|
-
|
|
103
|
-
while (
|
|
104
|
-
|
|
105
|
-
lyric = { start: from, end:
|
|
101
|
+
let close = from;
|
|
102
|
+
while (close < end && source[close] !== "\n")
|
|
103
|
+
close++;
|
|
104
|
+
lyric = { start: from, end: close };
|
|
106
105
|
}
|
|
107
106
|
const node = {
|
|
108
107
|
kind: "sugar",
|
|
@@ -111,9 +110,13 @@ L: la la la
|
|
|
111
110
|
lyric,
|
|
112
111
|
name,
|
|
113
112
|
},
|
|
114
|
-
span: { start, end:
|
|
113
|
+
span: { start, end: lyric.end },
|
|
114
|
+
syntaxKind: [
|
|
115
|
+
{ kind: "operator", span: { start, end: pos } },
|
|
116
|
+
{ kind: "string", span: lyric },
|
|
117
|
+
],
|
|
115
118
|
};
|
|
116
|
-
return { next:
|
|
119
|
+
return { next: lyric.end, node };
|
|
117
120
|
}
|
|
118
121
|
static deSugarRelation(ctx, nodes, at, members) {
|
|
119
122
|
const n = nodes[at++];
|
|
@@ -141,7 +144,7 @@ L: la la la
|
|
|
141
144
|
if (voiceNode === null) {
|
|
142
145
|
throw new ErrorDiagnostic("E_LYRICS_WITHOUT_VOICE_NOTES", `语法糖 'L:' 或 'L(name):' 必须跟在 @voice(或 N:)之后,但没有找到符合要求的 voice;请检查语法或直接使用 @voice 函数`, n.span);
|
|
143
146
|
}
|
|
144
|
-
voiceNode.addLyric(parseStr(n.data.name), parseStr(n.data.lyric), n.
|
|
147
|
+
voiceNode.addLyric(parseStr(n.data.name), parseStr(n.data.lyric), n.data.lyric, ctx);
|
|
145
148
|
ctx.nodes.length = voiceNodeAt + 1; // 清除voiceNodeAt之后的TextNode 因为被夹在N和L之间
|
|
146
149
|
// 消费后面可能的换行符 只消费一个
|
|
147
150
|
if (at < nodes.length && typeof nodes[at] === "number" && ctx.source[nodes[at]] === "\n")
|
|
@@ -238,7 +241,33 @@ L: la la la
|
|
|
238
241
|
size; // 声部的字体大小
|
|
239
242
|
font;
|
|
240
243
|
lyrics;
|
|
244
|
+
lyricSources = [];
|
|
245
|
+
cachedLyricSpans;
|
|
241
246
|
get children() { return [this.content]; }
|
|
247
|
+
/** 仅在导航定位读取时按需计算词元源码区间,正常编译渲染零开销 */
|
|
248
|
+
lyricTokenSpan(row, index) {
|
|
249
|
+
this.cachedLyricSpans ??= this.lyricSources.map(({ source, lyric, span }) => {
|
|
250
|
+
const { start, end } = trimRange(source, span.start, span.end);
|
|
251
|
+
const quoted = end - start >= 2 && source[start] === '"' && source[end - 1] === '"';
|
|
252
|
+
const base = start + (quoted ? 1 : 0), raw = source.slice(base, end - (quoted ? 1 : 0));
|
|
253
|
+
const offsets = [];
|
|
254
|
+
let c = 0;
|
|
255
|
+
if (lyric !== raw || !raw.includes("\\u")) {
|
|
256
|
+
raw.replace(/\\(u[0-9a-fA-F]{4}|["\\])/g, (m, _, i) => {
|
|
257
|
+
while (c <= i)
|
|
258
|
+
offsets.push(base + c++);
|
|
259
|
+
c = i + m.length;
|
|
260
|
+
return "";
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
while (c <= raw.length)
|
|
264
|
+
offsets.push(base + c++);
|
|
265
|
+
const tokenSpans = [];
|
|
266
|
+
parseLyric(lyric, offsets, tokenSpans);
|
|
267
|
+
return tokenSpans;
|
|
268
|
+
});
|
|
269
|
+
return this.cachedLyricSpans[row]?.[index];
|
|
270
|
+
}
|
|
242
271
|
/**
|
|
243
272
|
* voice 的音符内容仍按普通 sequence 进入全局时间列
|
|
244
273
|
* 此处按需建立歌词作用域,并在内容前创建声部名对象
|
|
@@ -289,7 +318,7 @@ L: la la la
|
|
|
289
318
|
this.lyrics = [];
|
|
290
319
|
for (const [key, value] of args) {
|
|
291
320
|
if (typeof value === "string") {
|
|
292
|
-
this.addLyric(key, value);
|
|
321
|
+
this.addLyric(key, value, ctx.callNode?.args[key]?.valueSpan ?? null, ctx);
|
|
293
322
|
continue;
|
|
294
323
|
}
|
|
295
324
|
const arg = value;
|
|
@@ -298,7 +327,7 @@ L: la la la
|
|
|
298
327
|
ctx.diagnostics.push(new WarningDiagnostic("W_VOICE_INVALID_LYRIC", "@voice 的歌词参数值解析失败, 参数[{key}]将被忽略", arg.valueSpan, { key }));
|
|
299
328
|
}
|
|
300
329
|
else
|
|
301
|
-
this.addLyric(key, v);
|
|
330
|
+
this.addLyric(key, v, arg.valueSpan, ctx);
|
|
302
331
|
}
|
|
303
332
|
}
|
|
304
333
|
addLyric(name, lyric, span = null, ctx = null) {
|
|
@@ -308,6 +337,9 @@ L: la la la
|
|
|
308
337
|
if (tokens.length === 0 && ctx && span) {
|
|
309
338
|
ctx.diagnostics.push(new WarningDiagnostic("W_EMPTY_LYRIC", "@voice的歌词{name}是空的", span, { name }));
|
|
310
339
|
}
|
|
340
|
+
this.cachedLyricSpans = undefined;
|
|
341
|
+
if (ctx && span)
|
|
342
|
+
this.lyricSources[this.lyrics.length] = { source: ctx.source, lyric, span };
|
|
311
343
|
this.lyrics.push({ name, tokens });
|
|
312
344
|
if (span) {
|
|
313
345
|
// 歌词是成节点之后才补上来的,祖先的 span 得一起长,否则按源码位置查节点会漏掉歌词那几行
|
|
@@ -318,7 +350,7 @@ L: la la la
|
|
|
318
350
|
}
|
|
319
351
|
}
|
|
320
352
|
toString(source) {
|
|
321
|
-
const parameters = [`${this.content.toString(source)},${
|
|
353
|
+
const parameters = [`${this.content.toString(source)},${quoteSourceString(this.name)}`];
|
|
322
354
|
for (const lyric of this.lyrics) {
|
|
323
355
|
const text = serializeLyric(lyric.tokens);
|
|
324
356
|
parameters.push(lyric.name ? `${lyric.name}=${text}` : text);
|
|
@@ -3,6 +3,7 @@ import type { LoweringContext } from "../../lowering/loweringContext.js";
|
|
|
3
3
|
import type { MeasureFn, Track } from "../../lowering/track.js";
|
|
4
4
|
import type { GrammarNode } from "../../parser/grammarType.js";
|
|
5
5
|
import { ParserContext } from "../../parser/parserContext.js";
|
|
6
|
+
import { type ConnectionSpec } from "./connections.js";
|
|
6
7
|
import { VoiceFunction } from "./voice.js";
|
|
7
8
|
/**
|
|
8
9
|
* voices 块在宿主基线上局部居中:首末两条 voice 基线的中点对齐宿主轴
|
|
@@ -85,7 +86,7 @@ export declare class VoicesFunction extends ASTFunctionNode {
|
|
|
85
86
|
private readonly connect;
|
|
86
87
|
/** 声部名右侧为大括号预留的横向空间 */
|
|
87
88
|
get braceSpace(): number;
|
|
88
|
-
|
|
89
|
+
get connectionSpecs(): ConnectionSpec[];
|
|
89
90
|
get children(): VoiceFunction[];
|
|
90
91
|
timeFlowModel(): {
|
|
91
92
|
children: VoiceFunction[];
|