jpfun 0.1.0 → 0.3.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 +200 -200
- package/README.md +191 -133
- package/dist/diagnostic.js +5 -2
- package/dist/fraction.d.ts +24 -0
- package/dist/fraction.js +132 -0
- package/dist/functions/ASTtypes.d.ts +24 -7
- package/dist/functions/ASTtypes.js +35 -16
- package/dist/functions/adjust/index.d.ts +2 -0
- package/dist/functions/adjust/index.js +193 -0
- package/dist/functions/bar/index.d.ts +8 -0
- package/dist/functions/bar/index.js +48 -19
- package/dist/functions/beam/auto.js +35 -18
- package/dist/functions/beam/index.js +10 -6
- package/dist/functions/beam/layout.d.ts +3 -2
- package/dist/functions/beam/layout.js +42 -64
- package/dist/functions/box/index.js +35 -34
- package/dist/functions/br/index.js +14 -12
- package/dist/functions/dash/index.js +37 -5
- package/dist/functions/default.js +14 -7
- package/dist/functions/div/index.d.ts +16 -0
- package/dist/functions/div/index.js +51 -23
- package/dist/functions/dot/index.js +16 -8
- package/dist/functions/grace/index.d.ts +8 -18
- package/dist/functions/grace/index.js +98 -99
- package/dist/functions/head/index.d.ts +2 -0
- package/dist/functions/head/index.js +492 -0
- package/dist/functions/key/index.js +98 -5
- package/dist/functions/meter/index.d.ts +2 -0
- package/dist/functions/meter/index.js +154 -0
- package/dist/functions/note/accidentals.d.ts +24 -3
- package/dist/functions/note/accidentals.js +31 -1
- package/dist/functions/note/index.js +60 -80
- package/dist/functions/page/index.d.ts +9 -2
- package/dist/functions/page/index.js +50 -4
- package/dist/functions/set/index.js +42 -34
- package/dist/functions/stack/index.js +39 -34
- package/dist/functions/symbol/index.d.ts +21 -0
- package/dist/functions/symbol/index.js +94 -0
- package/dist/functions/symbol/ornament.d.ts +15 -0
- package/dist/functions/symbol/ornament.js +73 -0
- package/dist/functions/symbol/shape.d.ts +22 -0
- package/dist/functions/symbol/shape.js +48 -0
- package/dist/functions/symbol/symbols/accent.d.ts +2 -0
- package/dist/functions/symbol/symbols/accent.js +24 -0
- package/dist/functions/symbol/symbols/f.d.ts +2 -0
- package/dist/functions/symbol/symbols/f.js +55 -0
- package/dist/functions/symbol/symbols/fermata.d.ts +2 -0
- package/dist/functions/symbol/symbols/fermata.js +24 -0
- package/dist/functions/symbol/symbols/mordent.d.ts +2 -0
- package/dist/functions/symbol/symbols/mordent.js +43 -0
- package/dist/functions/symbol/symbols/p.d.ts +2 -0
- package/dist/functions/symbol/symbols/p.js +61 -0
- package/dist/functions/symbol/symbols/tr.d.ts +2 -0
- package/dist/functions/symbol/symbols/tr.js +75 -0
- package/dist/functions/tempo/glyph.d.ts +12 -0
- package/dist/functions/tempo/glyph.js +30 -0
- package/dist/functions/tempo/index.js +53 -3
- package/dist/functions/text/index.js +78 -26
- package/dist/functions/tie/index.js +103 -128
- package/dist/functions/tuplet/index.d.ts +2 -0
- package/dist/functions/tuplet/index.js +211 -0
- package/dist/functions/{over → up}/index.d.ts +1 -0
- package/dist/functions/up/index.js +370 -0
- package/dist/functions/voice/index.js +125 -108
- package/dist/functions/volta/index.d.ts +2 -0
- package/dist/functions/volta/index.js +227 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/jpfun.min.js +143 -0
- package/dist/layout/engine.d.ts +4 -11
- package/dist/layout/engine.js +100 -66
- package/dist/layout/model.d.ts +8 -1
- package/dist/layout/model.js +16 -6
- package/dist/layout/path.d.ts +19 -0
- package/dist/layout/path.js +101 -0
- package/dist/layout/types.d.ts +51 -18
- package/dist/layout/types.js +3 -1
- package/dist/lowering/loweringContext.d.ts +19 -23
- package/dist/lowering/loweringContext.js +179 -187
- package/dist/lowering/track.d.ts +33 -10
- package/dist/lowering/track.js +6 -6
- package/dist/lowering/types.d.ts +57 -43
- package/dist/lowering/types.js +20 -4
- package/dist/parser/parse-utils/call-utils.d.ts +0 -2
- package/dist/parser/parse-utils/call-utils.js +0 -6
- package/dist/parser/parse-utils/note-utils.d.ts +8 -0
- package/dist/parser/parse-utils/note-utils.js +35 -13
- package/dist/parser/parse-utils/string-utils.d.ts +8 -0
- package/dist/parser/parse-utils/string-utils.js +20 -0
- package/dist/parser/parserContext.d.ts +8 -5
- package/dist/parser/parserContext.js +38 -33
- package/dist/parser/preprocess.js +17 -11
- package/dist/playback/compile.d.ts +18 -0
- package/dist/playback/compile.js +401 -0
- package/dist/playback/event.d.ts +91 -0
- package/dist/playback/event.js +87 -0
- package/dist/playback/time.d.ts +14 -0
- package/dist/playback/time.js +81 -0
- package/dist/playback/types.d.ts +128 -0
- package/dist/playback/types.js +3 -0
- package/dist/render/canvas.d.ts +4 -4
- package/dist/render/canvas.js +20 -5
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.js +1 -0
- package/dist/render/paint.d.ts +8 -0
- package/dist/render/paint.js +101 -0
- package/dist/render/svg.d.ts +3 -3
- package/dist/render/svg.js +10 -8
- package/dist/render/text.d.ts +17 -0
- package/dist/render/text.js +35 -0
- package/dist/render/types.d.ts +1 -1
- package/grammar.md +217 -122
- package/package.json +14 -9
- package/dist/functions/over/index.js +0 -307
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Diagnostic } from "../diagnostic.js";
|
|
2
|
+
import { Fraction } from "../fraction.js";
|
|
2
3
|
import { ASTFunctionClass, ASTNodeBase } from "../functions/ASTtypes.js";
|
|
3
|
-
import type {
|
|
4
|
-
import { TemporalNodeBase, type LoweringGroup, type LoweringResult } from "./types.js";
|
|
4
|
+
import type { PageConfig } from "../layout/types.js";
|
|
5
|
+
import { TemporalNodeBase, type LoweringGroup, type LoweringAttachment, type LoweringResult } from "./types.js";
|
|
5
6
|
import { Track } from "./track.js";
|
|
6
7
|
/**
|
|
7
8
|
* 把 AST 展开并固化为时间列、attachment 和页面配置
|
|
@@ -15,7 +16,7 @@ import { Track } from "./track.js";
|
|
|
15
16
|
* 大多数 AST 函数通过以下入口参与 lowering(按时间顺序):
|
|
16
17
|
* - [hook] loweringEnter/loweringExit:进入或离开节点时生成 TemporalNode、管理作用域
|
|
17
18
|
* - [API] LoweringContext.beginLoweringGroup/endLoweringGroup:通常在 enter/exit 中被调用,以栈方式观察当前子树产生的 TemporalNode 和 attachment
|
|
18
|
-
* - [API] LoweringContext.
|
|
19
|
+
* - [API] LoweringContext.addAttachment:注册不推进时间的附属对象;当前外层分组会收到该对象
|
|
19
20
|
* - [config] timeFlowModel:声明子节点按 sequence 或 parallel 推进时间;parallel 还要声明音轨复用键与纵向排列策略
|
|
20
21
|
* - [hook] Temporal.onTimeState:锚点归并后固化调性、速度等状态
|
|
21
22
|
* - [hook] loweringAugment:最终列和 layoutLine 固化后扫描结果并生成要追加的 attachment
|
|
@@ -25,7 +26,8 @@ export declare class LoweringContext {
|
|
|
25
26
|
private loweringAugmenters;
|
|
26
27
|
private loweringFinalizers;
|
|
27
28
|
private cnt;
|
|
28
|
-
|
|
29
|
+
private usedTracks;
|
|
30
|
+
/** 不推进时间的附属对象 */
|
|
29
31
|
private attachments;
|
|
30
32
|
/** 当前完整文档的页面配置 */
|
|
31
33
|
private page?;
|
|
@@ -66,20 +68,15 @@ export declare class LoweringContext {
|
|
|
66
68
|
* 结束最近的分组并注册其辅助排版对象
|
|
67
69
|
* 嵌套分组按退出顺序注册,因此天然是由内向外计算边界
|
|
68
70
|
*/
|
|
69
|
-
endLoweringGroup(owner: ASTNodeBase):
|
|
71
|
+
endLoweringGroup(owner: ASTNodeBase): LoweringGroup;
|
|
70
72
|
/** 先统一生成派生 attachment,再按注册顺序执行最终处理 */
|
|
71
73
|
private postprocessResult;
|
|
72
74
|
/**
|
|
73
75
|
* 注册不推进时间的排版对象
|
|
74
76
|
* 被 tie、beam、box 等函数使用
|
|
75
77
|
*/
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 查询 AST 节点在当前 lowering 中产生的所有 temporal 节点
|
|
79
|
-
*
|
|
80
|
-
* 被折叠进别人盒子的成员没有独立的全局位置,统一上溯到宿主,
|
|
81
|
-
* 所以写在成员上的标签等价于写在整个复合节点上。
|
|
82
|
-
*/
|
|
78
|
+
addAttachment(attachment: LoweringAttachment): void;
|
|
79
|
+
/** 查询 AST 自己产生的 temporal;是否沿 foldedInto 投影由调用者决定 */
|
|
83
80
|
getTemporalNodes(ast: ASTNodeBase): readonly TemporalNodeBase[];
|
|
84
81
|
/**
|
|
85
82
|
* 展开内容,但外层分组看不见它们
|
|
@@ -95,14 +92,14 @@ export declare class LoweringContext {
|
|
|
95
92
|
private initEvent;
|
|
96
93
|
/**
|
|
97
94
|
* 递归展开一棵子树,得到它的时间列与结束时间
|
|
98
|
-
* @param timeOffset 当前节点的时间偏移量(单位QN)
|
|
95
|
+
* @param timeOffset 当前节点的时间偏移量(单位QN) 由父节点传入,会被原地修改
|
|
99
96
|
* @param track 当前所在的纵向音轨
|
|
100
97
|
*/
|
|
101
|
-
trackedEvents(node: ASTNodeBase, timeOffset:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
trackedEvents(node: ASTNodeBase, timeOffset: Fraction, track: Track): TimeColumn[];
|
|
99
|
+
/**
|
|
100
|
+
* 将 hook 返回的事件规范化、加入索引与分组,再追加到时间列
|
|
101
|
+
* 原地修改 timeOffset
|
|
102
|
+
*/
|
|
106
103
|
private appendEvents;
|
|
107
104
|
/** 记录 AST->TemporalNode 的映射 */
|
|
108
105
|
private indexTemporal;
|
|
@@ -114,12 +111,11 @@ export declare class LoweringContext {
|
|
|
114
111
|
static anchorAlign(tracks: TimeColumn[][]): TimeColumn[];
|
|
115
112
|
}
|
|
116
113
|
declare class TimeColumn extends Array<TemporalNodeBase> {
|
|
117
|
-
|
|
114
|
+
readonly mergeKey: number;
|
|
118
115
|
constructor(n: TemporalNodeBase);
|
|
119
|
-
get t():
|
|
120
|
-
set t(value:
|
|
121
|
-
|
|
122
|
-
get breakRequested(): boolean;
|
|
116
|
+
get t(): Fraction;
|
|
117
|
+
set t(value: Fraction);
|
|
118
|
+
shiftTime(offset: Fraction): void;
|
|
123
119
|
/** 将当前列所有事件的行号固化为 lowering 后的实际行号 */
|
|
124
120
|
set layoutLine(value: number);
|
|
125
121
|
}
|