jpfun 0.4.1 → 0.6.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 +53 -113
- package/dist/converter/midi/convert.js +14 -7
- package/dist/converter/musicxml/features.d.ts +57 -16
- package/dist/converter/musicxml/features.js +204 -42
- package/dist/converter/musicxml/index.d.ts +7 -2
- package/dist/converter/musicxml/index.js +256 -268
- package/dist/converter/musicxml/model.d.ts +36 -7
- package/dist/converter/musicxml/resolve.d.ts +10 -0
- package/dist/converter/musicxml/resolve.js +152 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/fraction.js +7 -1
- package/dist/functions/ASTtypes.d.ts +6 -3
- package/dist/functions/ASTtypes.js +30 -23
- package/dist/functions/adjust/index.js +10 -50
- package/dist/functions/arpeggio/index.js +40 -25
- package/dist/functions/beam/auto.js +2 -11
- package/dist/functions/box/index.js +132 -82
- package/dist/functions/dash/index.js +20 -11
- package/dist/functions/default.js +2 -1
- package/dist/functions/div/index.d.ts +1 -1
- package/dist/functions/div/index.js +9 -10
- package/dist/functions/dot/index.js +4 -5
- package/dist/functions/dyn/index.js +28 -32
- package/dist/functions/grace/index.d.ts +23 -8
- package/dist/functions/grace/index.js +138 -119
- package/dist/functions/head/index.js +11 -4
- package/dist/functions/key/index.js +1 -1
- package/dist/functions/meter/index.js +40 -7
- package/dist/functions/meter/shape.d.ts +3 -0
- package/dist/functions/meter/shape.js +43 -0
- package/dist/functions/note/index.d.ts +6 -1
- package/dist/functions/note/index.js +60 -57
- package/dist/functions/note/source-transform.d.ts +21 -0
- package/dist/functions/note/source-transform.js +164 -0
- package/dist/functions/page/index.d.ts +5 -0
- package/dist/functions/page/index.js +8 -5
- package/dist/functions/rest/index.d.ts +2 -0
- package/dist/functions/rest/index.js +233 -0
- package/dist/functions/set/index.js +5 -1
- package/dist/functions/symbol/index.d.ts +2 -0
- package/dist/functions/symbol/index.js +1 -1
- package/dist/functions/symbol/ornament.d.ts +3 -3
- package/dist/functions/symbol/ornament.js +21 -35
- package/dist/functions/symbol/symbols/accent.js +5 -5
- package/dist/functions/symbol/symbols/fermata.js +5 -4
- package/dist/functions/temporal.d.ts +21 -7
- package/dist/functions/temporal.js +14 -4
- package/dist/functions/tie/index.js +36 -42
- package/dist/functions/tuplet/index.js +20 -24
- package/dist/functions/up/index.js +54 -34
- package/dist/functions/voice/connections.d.ts +19 -0
- package/dist/functions/voice/connections.js +88 -0
- package/dist/functions/voice/index.js +248 -102
- package/dist/functions/volta/index.js +7 -12
- package/dist/jpfun.core.min.js +61 -41
- package/dist/jpfun.from-midi.min.js +5 -5
- package/dist/jpfun.from-musicxml.min.js +8 -8
- package/dist/jpfun.min.js +70 -50
- package/dist/layout/engine.d.ts +13 -1
- package/dist/layout/engine.js +458 -129
- package/dist/layout/model.js +22 -66
- package/dist/layout/page.js +3 -1
- package/dist/layout/range.d.ts +26 -0
- package/dist/layout/range.js +75 -0
- package/dist/layout/types.d.ts +63 -49
- package/dist/lowering/loweringContext.d.ts +1 -1
- package/dist/lowering/loweringContext.js +34 -4
- package/dist/lowering/types.d.ts +5 -0
- package/dist/parser/parse-utils/length-utils.js +2 -0
- package/dist/parser/parse-utils/note-utils.d.ts +2 -0
- package/dist/parser/parse-utils/note-utils.js +6 -2
- package/dist/parser/parserContext.js +5 -9
- package/dist/parser/preprocess.js +4 -6
- package/dist/playback/compile.d.ts +2 -9
- package/dist/playback/compile.js +297 -186
- package/dist/playback/event.d.ts +8 -16
- package/dist/playback/event.js +13 -3
- package/dist/playback/types.d.ts +76 -18
- package/dist/playback/types.js +1 -0
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/paint.js +1 -1
- package/dist/render/recording.d.ts +1 -0
- package/dist/render/recording.js +21 -0
- package/dist/render/translate.d.ts +14 -0
- package/dist/render/translate.js +48 -0
- package/grammar.md +200 -250
- package/package.json +4 -4
|
@@ -7,6 +7,7 @@ import { findClosingQuote } from "./parse-utils/string-utils.js";
|
|
|
7
7
|
* - 设行尾连续 `\` 个数为 n;
|
|
8
8
|
* - 第 1/3/5... 个 `\` 替换为空格,第 2/4/6... 个保留;
|
|
9
9
|
* - 若 n 为奇数,则该行换行符也替换为空格(续行)
|
|
10
|
+
* 4. 字符串外 CRLF 中的 CR 等长替换为空格,词法层只消费 LF
|
|
10
11
|
*/
|
|
11
12
|
const CHAR_LF = 10;
|
|
12
13
|
const CHAR_CR = 13;
|
|
@@ -79,7 +80,6 @@ export function preprocessSource(source) {
|
|
|
79
80
|
* - inQuote:0=不在字符串;其他值为当前引号字符码
|
|
80
81
|
* - escaped:仅在字符串内有效,表示上一个字符是 `\`
|
|
81
82
|
* - pendingCommentStart:>=0 表示已遇到 `%`,等待到行尾/EOF 收口注释
|
|
82
|
-
* - lastSignificantIndex:当前行最后一个“非换行空白”字符位置
|
|
83
83
|
* - tailBackslashRunStart/tailBackslashRunCount:
|
|
84
84
|
* 当前行末尾候选连续 `\` 片段(允许后面跟空白),用于换行处一次性判定
|
|
85
85
|
*/
|
|
@@ -87,23 +87,20 @@ export function preprocessSource(source) {
|
|
|
87
87
|
let noPairedQuoteAfter = false;
|
|
88
88
|
let escaped = false;
|
|
89
89
|
let pendingCommentStart = -1;
|
|
90
|
-
let lastSignificantIndex = -1;
|
|
91
90
|
let tailBackslashRunStart = -1;
|
|
92
91
|
let tailBackslashRunCount = 0;
|
|
93
92
|
const updateLineTailState = (index, ch) => {
|
|
94
93
|
if (ch === CHAR_BACKSLASH) {
|
|
95
|
-
if (tailBackslashRunCount > 0 &&
|
|
94
|
+
if (tailBackslashRunCount > 0 && tailBackslashRunStart + tailBackslashRunCount === index)
|
|
96
95
|
tailBackslashRunCount++;
|
|
97
96
|
else {
|
|
98
97
|
tailBackslashRunStart = index;
|
|
99
98
|
tailBackslashRunCount = 1;
|
|
100
99
|
}
|
|
101
|
-
lastSignificantIndex = index;
|
|
102
100
|
return;
|
|
103
101
|
}
|
|
104
102
|
tailBackslashRunStart = -1;
|
|
105
103
|
tailBackslashRunCount = 0;
|
|
106
|
-
lastSignificantIndex = index;
|
|
107
104
|
};
|
|
108
105
|
for (let i = 0; i < sourceLength;) {
|
|
109
106
|
const ch = source.charCodeAt(i);
|
|
@@ -121,8 +118,9 @@ export function preprocessSource(source) {
|
|
|
121
118
|
}
|
|
122
119
|
if (isOddBackslashRun)
|
|
123
120
|
pushReplaceRange(i, i + newlineWidth);
|
|
121
|
+
else if (inQuote === 0 && newlineWidth === 2)
|
|
122
|
+
pushReplaceRange(i, i + 1);
|
|
124
123
|
// 新行重置行内状态
|
|
125
|
-
lastSignificantIndex = -1;
|
|
126
124
|
tailBackslashRunStart = -1;
|
|
127
125
|
tailBackslashRunCount = 0;
|
|
128
126
|
escaped = false;
|
|
@@ -3,15 +3,8 @@ import type { PlaybackPlan } from "./types.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* 把 lowering 的时间流编译成完整的演奏计划
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - [state] Temporal.playbackState:每次实际访问节点时,把 lowering 已固化的 BPM 登记到演奏轴;note、tempo 和正时值 dash 都用它恢复记谱位置的速度
|
|
9
|
-
* - [hook] Temporal.emitPlayback:按展开后的列序逐次调用;note 登记 NoteOn/NoteOff,up/grace 通过 emitter.play 递归登记折叠成员
|
|
10
|
-
* - [API] PlaybackEmitter.control:emit 时只登记控制;所有节点访问完成后按演奏时刻执行,同刻合并后生成 Tempo;fermata 用它修改 bpmScale
|
|
11
|
-
* - [API] PlaybackEmitter.affectFollowing:把 transform 加入当前 play frame;后续目标音完整登记 NoteOn/NoteOff 后,将冻结的 transform 紧接着写入顺序流;accent、tr、波音使用它
|
|
12
|
-
* - [API] PlaybackEmitter.defer:把 hook 写在当前节点之后;状态扫描完成后重放顺序流,走到该位置才执行,可见完整 Tempo 和此前音符;dash 用它延长前一组 NoteOff
|
|
13
|
-
* - [hook] PlaybackRelation.applyPlayback:顺序流重放完并首次排序后执行,可观察和改写完整事件计划;tie 用它合并相距很远的端点
|
|
14
|
-
* - comparePlaybackDraftEvents / finalizePlaybackEvents:最后稳定排序,再校验 NoteOn/NoteOff 配对并剥离 origins、order 等编译期字段
|
|
6
|
+
* 控制流展开 -> 音段结构 -> 连接及效果范围 -> 最终系统状态 -> 声音展开 -> 点事件
|
|
7
|
+
* 结构处理不读取最终状态,声音展开不改变结构边界;每个声明只执行一次
|
|
15
8
|
*/
|
|
16
9
|
export declare function compilePlayback(lowering: LoweringResult, options?: {
|
|
17
10
|
maxFlowSteps?: number;
|