jpfun 0.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/LICENSE +201 -0
- package/README.md +134 -0
- package/dist/diagnostic.d.ts +27 -0
- package/dist/diagnostic.js +141 -0
- package/dist/functions/ASTtypes.d.ts +115 -0
- package/dist/functions/ASTtypes.js +187 -0
- package/dist/functions/bar/index.d.ts +2 -0
- package/dist/functions/bar/index.js +180 -0
- package/dist/functions/beam/auto.d.ts +4 -0
- package/dist/functions/beam/auto.js +202 -0
- package/dist/functions/beam/index.d.ts +2 -0
- package/dist/functions/beam/index.js +54 -0
- package/dist/functions/beam/layout.d.ts +9 -0
- package/dist/functions/beam/layout.js +233 -0
- package/dist/functions/box/index.d.ts +2 -0
- package/dist/functions/box/index.js +202 -0
- package/dist/functions/br/index.d.ts +2 -0
- package/dist/functions/br/index.js +83 -0
- package/dist/functions/dash/index.d.ts +2 -0
- package/dist/functions/dash/index.js +61 -0
- package/dist/functions/default.d.ts +2 -0
- package/dist/functions/default.js +32 -0
- package/dist/functions/div/index.d.ts +50 -0
- package/dist/functions/div/index.js +190 -0
- package/dist/functions/dot/index.d.ts +2 -0
- package/dist/functions/dot/index.js +160 -0
- package/dist/functions/grace/index.d.ts +84 -0
- package/dist/functions/grace/index.js +464 -0
- package/dist/functions/key/index.d.ts +2 -0
- package/dist/functions/key/index.js +40 -0
- package/dist/functions/note/accidentals.d.ts +10 -0
- package/dist/functions/note/accidentals.js +60 -0
- package/dist/functions/note/index.d.ts +2 -0
- package/dist/functions/note/index.js +284 -0
- package/dist/functions/note/noteNameFSM.d.ts +8 -0
- package/dist/functions/note/noteNameFSM.js +192 -0
- package/dist/functions/over/index.d.ts +2 -0
- package/dist/functions/over/index.js +307 -0
- package/dist/functions/page/index.d.ts +20 -0
- package/dist/functions/page/index.js +63 -0
- package/dist/functions/set/index.d.ts +2 -0
- package/dist/functions/set/index.js +55 -0
- package/dist/functions/stack/index.d.ts +2 -0
- package/dist/functions/stack/index.js +164 -0
- package/dist/functions/tempo/index.d.ts +2 -0
- package/dist/functions/tempo/index.js +37 -0
- package/dist/functions/text/index.d.ts +2 -0
- package/dist/functions/text/index.js +65 -0
- package/dist/functions/tie/index.d.ts +2 -0
- package/dist/functions/tie/index.js +301 -0
- package/dist/functions/voice/index.d.ts +3 -0
- package/dist/functions/voice/index.js +714 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/layout/default.d.ts +12 -0
- package/dist/layout/default.js +27 -0
- package/dist/layout/engine.d.ts +47 -0
- package/dist/layout/engine.js +410 -0
- package/dist/layout/model.d.ts +73 -0
- package/dist/layout/model.js +422 -0
- package/dist/layout/page.d.ts +27 -0
- package/dist/layout/page.js +121 -0
- package/dist/layout/types.d.ts +197 -0
- package/dist/layout/types.js +1 -0
- package/dist/lowering/loweringContext.d.ts +126 -0
- package/dist/lowering/loweringContext.js +625 -0
- package/dist/lowering/track.d.ts +61 -0
- package/dist/lowering/track.js +35 -0
- package/dist/lowering/types.d.ts +176 -0
- package/dist/lowering/types.js +82 -0
- package/dist/parser/grammarType.d.ts +81 -0
- package/dist/parser/grammarType.js +1 -0
- package/dist/parser/parse-utils/brace-utils.d.ts +1 -0
- package/dist/parser/parse-utils/brace-utils.js +29 -0
- package/dist/parser/parse-utils/call-utils.d.ts +24 -0
- package/dist/parser/parse-utils/call-utils.js +178 -0
- package/dist/parser/parse-utils/label-utils.d.ts +4 -0
- package/dist/parser/parse-utils/label-utils.js +17 -0
- package/dist/parser/parse-utils/length-utils.d.ts +3 -0
- package/dist/parser/parse-utils/length-utils.js +20 -0
- package/dist/parser/parse-utils/note-utils.d.ts +10 -0
- package/dist/parser/parse-utils/note-utils.js +111 -0
- package/dist/parser/parserContext.d.ts +93 -0
- package/dist/parser/parserContext.js +542 -0
- package/dist/parser/preprocess.d.ts +6 -0
- package/dist/parser/preprocess.js +193 -0
- package/dist/parser/types.d.ts +31 -0
- package/dist/parser/types.js +2 -0
- package/dist/pipeline.d.ts +36 -0
- package/dist/pipeline.js +51 -0
- package/dist/render/canvas.d.ts +19 -0
- package/dist/render/canvas.js +121 -0
- package/dist/render/index.d.ts +5 -0
- package/dist/render/index.js +5 -0
- package/dist/render/recording.d.ts +46 -0
- package/dist/render/recording.js +76 -0
- package/dist/render/svg.d.ts +18 -0
- package/dist/render/svg.js +126 -0
- package/dist/render/text.d.ts +6 -0
- package/dist/render/text.js +17 -0
- package/dist/render/types.d.ts +86 -0
- package/dist/render/types.js +1 -0
- package/grammar.md +123 -0
- package/package.json +58 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Painter, TextMeasurer } from "../render/types.js";
|
|
2
|
+
import type { Extent, Track } from "../lowering/track.js";
|
|
3
|
+
import type { HorizontalLayoutHook } from "./model.js";
|
|
4
|
+
/** 轴对齐矩形,是所有排版几何的公共部分 */
|
|
5
|
+
export interface Rect {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
w: number;
|
|
9
|
+
h: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 一个排版对象的完整矩形和两个对齐基准
|
|
13
|
+
*
|
|
14
|
+
* prepareLayout 负责填写 w、h、anchor、visualAxis
|
|
15
|
+
* layout 负责原地修改 x、y
|
|
16
|
+
* 所有字段保持扁平,布局器可以直接持有并修改这个对象的引用
|
|
17
|
+
*/
|
|
18
|
+
export interface LayoutBox extends Rect {
|
|
19
|
+
anchor: number;
|
|
20
|
+
visualAxis: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 横向弹簧的物理属性 含义见排版模型的文档
|
|
24
|
+
*/
|
|
25
|
+
export interface HorizontalSpringConfig {
|
|
26
|
+
alpha_L?: number;
|
|
27
|
+
alpha_R?: number;
|
|
28
|
+
mu_L?: number;
|
|
29
|
+
mu_R?: number;
|
|
30
|
+
beta_L?: number;
|
|
31
|
+
beta_R?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface TimeLineEvent {
|
|
34
|
+
t: number;
|
|
35
|
+
T: number;
|
|
36
|
+
track: Track;
|
|
37
|
+
}
|
|
38
|
+
/** 文档页面的固化尺寸,所有值均为 px */
|
|
39
|
+
export interface PageConfig {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
marginTop: number;
|
|
43
|
+
marginBottom: number;
|
|
44
|
+
marginLeft: number;
|
|
45
|
+
marginRight: number;
|
|
46
|
+
lineGap: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 排版前的共享资源
|
|
50
|
+
*
|
|
51
|
+
* textMeasurer 只负责确定性文本测量
|
|
52
|
+
* 字号由具体视觉函数在 parse 时固化为 px,不属于布局上下文
|
|
53
|
+
*/
|
|
54
|
+
export interface LayoutPrepareContext {
|
|
55
|
+
textMeasurer: TextMeasurer;
|
|
56
|
+
decorationHandlers: ReadonlyMap<string, LayoutDecorationHandler>;
|
|
57
|
+
}
|
|
58
|
+
/** attachment 根据当前视觉轴生成几何时需要的完整页面信息 */
|
|
59
|
+
export interface AttachmentLayoutContext extends LayoutPrepareContext {
|
|
60
|
+
width: number;
|
|
61
|
+
originX: number;
|
|
62
|
+
getVisualAxis(line: number, track: Track): number;
|
|
63
|
+
/** 只包含可见主体的轴局部占用(top 通常为负),不受 attachment 或最终分页坐标影响 */
|
|
64
|
+
getHostExtent(line: number, track: Track): Readonly<Extent> | undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 装饰所依附的主体
|
|
68
|
+
*
|
|
69
|
+
* 属性含义参考 TemporalNodeBase
|
|
70
|
+
* 其他属性刻意不开放:
|
|
71
|
+
* - addon 的值会直接传递给 LayoutDecorationHandler
|
|
72
|
+
* - decorations 正是 LayoutDecorationHandler 的返回值构成的,也就是此时 LayoutHost 的 decorations 正在建立
|
|
73
|
+
* - prepareLayout/finalizeLayout/onPlaced/paint 是引擎调度的生命周期方法,不许私自调用
|
|
74
|
+
*/
|
|
75
|
+
export interface LayoutHost extends TimeLineEvent {
|
|
76
|
+
box: LayoutBox;
|
|
77
|
+
springConfig: HorizontalSpringConfig;
|
|
78
|
+
ports: Record<string, LayoutPoint>;
|
|
79
|
+
readonly layoutLine: number;
|
|
80
|
+
readonly ast: {
|
|
81
|
+
readonly size: number;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 一条谱面行进入横向求解前的只读视图
|
|
86
|
+
*
|
|
87
|
+
* 时间列拓扑不可改变,但其中的 host 仍可写;
|
|
88
|
+
* 调用方可以调整 springConfig,也可以注册在 LayoutElement 归一化后执行的横向布局
|
|
89
|
+
*/
|
|
90
|
+
export interface HorizontalLineView {
|
|
91
|
+
/** 谱面行号,与 host.layoutLine 同一坐标系 */
|
|
92
|
+
readonly index: number;
|
|
93
|
+
/** 同一 Track 上按时间列顺序排好的主体,相邻两项即视觉上的前后邻居 */
|
|
94
|
+
readonly trackRuns: ReadonlyMap<Track, readonly LayoutHost[]>;
|
|
95
|
+
/** 主体所在时间列下标;不在本行时返回 -1 */
|
|
96
|
+
columnOf(host: LayoutHost): number;
|
|
97
|
+
/** 注册横向布局 hook;同一行内按跨度从小到大执行 */
|
|
98
|
+
registerHorizontalLayoutHook(from: LayoutHost, to: LayoutHost, hook: HorizontalLayoutHook): void;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 相对于对象 LayoutBox 左上角的局部坐标
|
|
102
|
+
* tie、beam 等关系函数通过命名端口获取几何位置
|
|
103
|
+
*/
|
|
104
|
+
export interface LayoutPoint {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
}
|
|
108
|
+
/** 把 addon 字段变为可绘制的 LayoutDecoration;返回 null 表示本次不生成装饰 */
|
|
109
|
+
export type LayoutDecorationHandler = (host: LayoutHost, value: unknown, // 存在 addon 中的值
|
|
110
|
+
context: LayoutPrepareContext) => LayoutDecoration | null;
|
|
111
|
+
/**
|
|
112
|
+
* 一次 layout 中生成并保留到 paint 阶段的装饰对象
|
|
113
|
+
*
|
|
114
|
+
* 实例有两种来源:Temporal.prepareLayout 可以直接加入;addon 对应的 LayoutDecorationHandler 也可以在主体 prepareLayout 后创建
|
|
115
|
+
* 两者都在创建时就拿到了宿主,因此回调不再重复传入它;实例可以在返回前调整 host.box,例如 dot 先扩张主体宽度
|
|
116
|
+
* 被 arrangeBelowDecorations 使用
|
|
117
|
+
*
|
|
118
|
+
* 通用部分只有 paint:主体绘制完成后,引擎调用它绘制当前装饰。
|
|
119
|
+
*
|
|
120
|
+
* below 是可选的“主体下方空间”子协议,只向下扩张 box.h,不管理主体上方空间
|
|
121
|
+
* 上方内容若会改变主体 visualAxis 或内部绘制坐标,应由具体 Temporal 在 prepareLayout 中处理。
|
|
122
|
+
*
|
|
123
|
+
* 当前内置示例:
|
|
124
|
+
* - dot:handler 生成只负责横向扩宽和绘制的装饰,不声明 below;
|
|
125
|
+
* - div:handler 生成减时线装饰,使用 order=0,排在主体下方最内层;
|
|
126
|
+
* - note 下八度点:prepareLayout 直接加入装饰,使用 order=100,排在减时线之后;
|
|
127
|
+
* - note 上八度点不使用 LayoutDecoration,而是主体 prepareLayout 的一部分。
|
|
128
|
+
*
|
|
129
|
+
* LayoutDecoration 不是 addon 语义本身。实例可以用闭包保存本次测量参数和 place 结果,因此必须由 Temporal.decorations 持有到当前 paint 结束。
|
|
130
|
+
*/
|
|
131
|
+
export interface LayoutDecoration {
|
|
132
|
+
paint(painter: Painter): void;
|
|
133
|
+
/** 声明后进入主体下方空间管理,引擎只理解这四个字段,不知道空间来自哪个函数 */
|
|
134
|
+
below?: {
|
|
135
|
+
order: number;
|
|
136
|
+
gap?: number;
|
|
137
|
+
height?: number;
|
|
138
|
+
/**
|
|
139
|
+
* 引擎分配好本装饰的下方区域后调用一次,y 是该区域 **顶边到 host.box 顶部** 的距离
|
|
140
|
+
*
|
|
141
|
+
* 该做的:把这一刻才确定的局部几何存进闭包供 paint 使用(note 存下八度点的 y),
|
|
142
|
+
* 以及发布依赖这个位置的端口(div 在这里建 div.N.left/right)。只占位不绘制时可以不实现。
|
|
143
|
+
*
|
|
144
|
+
* 不该做的:改 box.h(引擎会按 height 统一扩张)、读 box.y 或 box.h (前者尚未求解、后者正在向下累加)。
|
|
145
|
+
* 此时只有 box.w/anchor 和 ports 是最终值,因此一律记录相对盒顶的局部坐标,绘制时再加 host.box.x / host.box.y。
|
|
146
|
+
*
|
|
147
|
+
* 例(一条减时线):
|
|
148
|
+
* ```ts
|
|
149
|
+
* let lineY = 0; // 闭包保存本轮测量结果
|
|
150
|
+
* return {
|
|
151
|
+
* below: {
|
|
152
|
+
* order: 0,
|
|
153
|
+
* height: strokeWidth,
|
|
154
|
+
* place(y) {
|
|
155
|
+
* lineY = y + strokeWidth / 2;
|
|
156
|
+
* host.ports["div.0.left"] = { x: 0, y: lineY };
|
|
157
|
+
* },
|
|
158
|
+
* },
|
|
159
|
+
* paint(painter) {
|
|
160
|
+
* const y = host.box.y + lineY; // 此时 box.y 才有意义
|
|
161
|
+
* painter.drawLine(host.box.x, y, host.box.x + host.box.w, y, { stroke: "#000", strokeWidth });
|
|
162
|
+
* },
|
|
163
|
+
* };
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
place?(y: number): void;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 不占用时间、附着于一个或多个主体对象的独立排版对象
|
|
171
|
+
*
|
|
172
|
+
* tie、beam、box 和歌词都使用这个接口
|
|
173
|
+
* 它们不进入时间列,只需要报出自己占住的矩形,外接盒与纵向占用都由引擎从中导出
|
|
174
|
+
*/
|
|
175
|
+
export interface LayoutAttachment {
|
|
176
|
+
box: Rect;
|
|
177
|
+
layer: "background" | "foreground";
|
|
178
|
+
/** 横向求解前:调整弹簧参数或注册横向布局 hook,不得改变对象/列顺序 */
|
|
179
|
+
prepareHorizontal?(context: HorizontalLineView[]): void;
|
|
180
|
+
/**
|
|
181
|
+
* 根据当前视觉轴生成完整几何,并返回自己占住的区域
|
|
182
|
+
* 首次返回带 line + track 且扩张主体占用的区域时,引擎会重新求轴并再次调用;
|
|
183
|
+
* 因此实现必须幂等(每次从主体几何重算,不能做累加)
|
|
184
|
+
*/
|
|
185
|
+
layout?(context: AttachmentLayoutContext): readonly LayoutRegion[] | void;
|
|
186
|
+
paint(painter: Painter): void;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* attachment 报出的一块几何(全局坐标)
|
|
190
|
+
*
|
|
191
|
+
* 总是计入外接盒;同时声明 line 和 track 时,还会折算成该轨道的纵向占用
|
|
192
|
+
* 只想影响画布边界、不想撑高行的图形(括线、边框)省略归属即可
|
|
193
|
+
*/
|
|
194
|
+
export interface LayoutRegion extends Rect {
|
|
195
|
+
line?: number;
|
|
196
|
+
track?: Track;
|
|
197
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Diagnostic } from "../diagnostic.js";
|
|
2
|
+
import { ASTFunctionClass, ASTNodeBase } from "../functions/ASTtypes.js";
|
|
3
|
+
import type { LayoutAttachment, PageConfig } from "../layout/types.js";
|
|
4
|
+
import { TemporalNodeBase, type LoweringGroup, type LoweringResult } from "./types.js";
|
|
5
|
+
import { Track } from "./track.js";
|
|
6
|
+
/**
|
|
7
|
+
* 把 AST 展开并固化为时间列、attachment 和页面配置
|
|
8
|
+
*
|
|
9
|
+
* 标准用法:
|
|
10
|
+
* 1. 创建 LoweringContext
|
|
11
|
+
* 2. 调用 registerFunctions,传入与 parser 相同的函数类列表
|
|
12
|
+
* 3. 调用 lowerDocument(root),得到 LoweringResult
|
|
13
|
+
* 4. 把结果交给 layoutDocument
|
|
14
|
+
*
|
|
15
|
+
* 大多数 AST 函数通过以下入口参与 lowering(按时间顺序):
|
|
16
|
+
* - [hook] loweringEnter/loweringExit:进入或离开节点时生成 TemporalNode、管理作用域
|
|
17
|
+
* - [API] LoweringContext.beginLoweringGroup/endLoweringGroup:通常在 enter/exit 中被调用,以栈方式观察当前子树产生的 TemporalNode 和 attachment
|
|
18
|
+
* - [API] LoweringContext.addLayoutAttachment:注册不推进时间的独立排版对象,供 tie、beam 等函数使用;若当前位于分组中,其 box 也会加入外层分组
|
|
19
|
+
* - [config] timeFlowModel:声明子节点按 sequence 或 parallel 推进时间;parallel 还要声明音轨复用键与纵向排列策略
|
|
20
|
+
* - [hook] Temporal.onTimeState:锚点归并后固化调性、速度等状态
|
|
21
|
+
* - [hook] loweringAugment:最终列和 layoutLine 固化后扫描结果并生成要追加的 attachment
|
|
22
|
+
* - [hook] loweringFinalize:所有派生 attachment 追加完成后,按注册顺序处理完整结果
|
|
23
|
+
*/
|
|
24
|
+
export declare class LoweringContext {
|
|
25
|
+
private loweringAugmenters;
|
|
26
|
+
private loweringFinalizers;
|
|
27
|
+
private cnt;
|
|
28
|
+
/** 不推进时间的关系对象和分组对象 */
|
|
29
|
+
private attachments;
|
|
30
|
+
/** 当前完整文档的页面配置 */
|
|
31
|
+
private page?;
|
|
32
|
+
/**
|
|
33
|
+
* 一个 AST 节点可能不产生 temporal,也可能产生多个 temporal
|
|
34
|
+
* 不包含子节点的 TemporalNode
|
|
35
|
+
*/
|
|
36
|
+
private astToTemporal;
|
|
37
|
+
/**
|
|
38
|
+
* 当前递归路径上正在收集成员的作用域 的栈
|
|
39
|
+
* 使用 beginLoweringGroup/endLoweringGroup 维护
|
|
40
|
+
*/
|
|
41
|
+
private activeLoweringGroups;
|
|
42
|
+
/** 收集本轮 lowering 产生的诊断信息 */
|
|
43
|
+
readonly diagnostics: Diagnostic[];
|
|
44
|
+
constructor(diagnostics?: Diagnostic[]);
|
|
45
|
+
/** 供外部调用: 初始化 hook */
|
|
46
|
+
registerFunctions(functionClasses: ASTFunctionClass[]): void;
|
|
47
|
+
/** 供 page 函数调用 */
|
|
48
|
+
setPageConfig(page: PageConfig): void;
|
|
49
|
+
/**
|
|
50
|
+
* 完整 lowering 入口
|
|
51
|
+
*
|
|
52
|
+
* 每次调用都会重置本轮产生的数据
|
|
53
|
+
* 已注册的后处理 hook 会保留,可以复用同一个 LoweringContext
|
|
54
|
+
*/
|
|
55
|
+
lowerDocument(node: ASTNodeBase): LoweringResult;
|
|
56
|
+
/**
|
|
57
|
+
* 固化谱面行号并进行时间状态固化
|
|
58
|
+
*/
|
|
59
|
+
private solidifyColumns;
|
|
60
|
+
/**
|
|
61
|
+
* 开始一个 lowering 分组作用域
|
|
62
|
+
* group 可以收集并提交新增 temporal,也可以观察成员并携带一个 attachment
|
|
63
|
+
*/
|
|
64
|
+
beginLoweringGroup(owner: ASTNodeBase, group: LoweringGroup): void;
|
|
65
|
+
/**
|
|
66
|
+
* 结束最近的分组并注册其辅助排版对象
|
|
67
|
+
* 嵌套分组按退出顺序注册,因此天然是由内向外计算边界
|
|
68
|
+
*/
|
|
69
|
+
endLoweringGroup(owner: ASTNodeBase): void;
|
|
70
|
+
/** 先统一生成派生 attachment,再按注册顺序执行最终处理 */
|
|
71
|
+
private postprocessResult;
|
|
72
|
+
/**
|
|
73
|
+
* 注册不推进时间的排版对象
|
|
74
|
+
* 被 tie、beam、box 等函数使用
|
|
75
|
+
*/
|
|
76
|
+
addLayoutAttachment(attachment: LayoutAttachment): void;
|
|
77
|
+
/**
|
|
78
|
+
* 查询 AST 节点在当前 lowering 中产生的所有 temporal 节点
|
|
79
|
+
*
|
|
80
|
+
* 被折叠进别人盒子的成员没有独立的全局位置,统一上溯到宿主,
|
|
81
|
+
* 所以写在成员上的标签等价于写在整个复合节点上。
|
|
82
|
+
*/
|
|
83
|
+
getTemporalNodes(ast: ASTNodeBase): readonly TemporalNodeBase[];
|
|
84
|
+
/**
|
|
85
|
+
* 展开内容,但外层分组看不见它们
|
|
86
|
+
*
|
|
87
|
+
* 复合节点把子树折叠成一个符号时,成员不是外层分组的成员,宿主才是。
|
|
88
|
+
* 否则 voice 的歌词按下标配对时,一个和弦会占掉成员数加一个槽位,
|
|
89
|
+
* 而这些槽位都在同一个 x 上,后面的音符全部对不上歌词。
|
|
90
|
+
*/
|
|
91
|
+
isolateFromLoweringGroups<T>(run: () => T): T;
|
|
92
|
+
/**
|
|
93
|
+
* 原地补全 hook: loweringEnter / loweringExit 返回的事件
|
|
94
|
+
*/
|
|
95
|
+
private initEvent;
|
|
96
|
+
/**
|
|
97
|
+
* 递归展开一棵子树,得到它的时间列与结束时间
|
|
98
|
+
* @param timeOffset 当前节点的时间偏移量(单位QN) 由父节点传入
|
|
99
|
+
* @param track 当前所在的纵向音轨
|
|
100
|
+
*/
|
|
101
|
+
trackedEvents(node: ASTNodeBase, timeOffset: number, track: Track): {
|
|
102
|
+
timeOffset: number;
|
|
103
|
+
columns: TimeColumn[];
|
|
104
|
+
};
|
|
105
|
+
/** 将 hook 返回的事件规范化、加入索引与分组,再追加到时间列 */
|
|
106
|
+
private appendEvents;
|
|
107
|
+
/** 记录 AST->TemporalNode 的映射 */
|
|
108
|
+
private indexTemporal;
|
|
109
|
+
/**
|
|
110
|
+
* 多轨时间上的 ANCHOR 对齐形成列,被 trackedEvents 在中间使用。会修改时间
|
|
111
|
+
* @param tracks 多个 trackedEvents 的结果
|
|
112
|
+
* @returns 锚点对齐后的 tracks,多轨道相同时间的会被合并为一个列
|
|
113
|
+
*/
|
|
114
|
+
static anchorAlign(tracks: TimeColumn[][]): TimeColumn[];
|
|
115
|
+
}
|
|
116
|
+
declare class TimeColumn extends Array<TemporalNodeBase> {
|
|
117
|
+
type: TemporalNodeBase["type"];
|
|
118
|
+
constructor(n: TemporalNodeBase);
|
|
119
|
+
get t(): number;
|
|
120
|
+
set t(value: number);
|
|
121
|
+
/** 当前列是否携带换行请求 */
|
|
122
|
+
get breakRequested(): boolean;
|
|
123
|
+
/** 将当前列所有事件的行号固化为 lowering 后的实际行号 */
|
|
124
|
+
set layoutLine(value: number);
|
|
125
|
+
}
|
|
126
|
+
export {};
|