jpfun 1.0.0 → 1.2.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 +1 -1
- package/dist/diagnostic.d.ts +1 -0
- package/dist/diagnostic.js +1 -0
- package/dist/functions/ASTtypes.d.ts +2 -3
- package/dist/functions/ASTtypes.js +2 -3
- package/dist/functions/adjust/index.js +15 -67
- package/dist/functions/bar/index.js +11 -7
- package/dist/functions/beam/auto.js +15 -11
- package/dist/functions/beam/layout.js +22 -48
- package/dist/functions/br/index.d.ts +9 -3
- package/dist/functions/br/index.js +20 -16
- package/dist/functions/dash/index.js +13 -11
- package/dist/functions/default.js +2 -1
- package/dist/functions/div/index.d.ts +2 -2
- package/dist/functions/div/index.js +5 -9
- package/dist/functions/dot/index.js +5 -9
- package/dist/functions/dyn/index.js +125 -53
- package/dist/functions/gliss/index.js +81 -7
- package/dist/functions/grace/index.d.ts +3 -10
- package/dist/functions/grace/index.js +25 -57
- package/dist/functions/head/index.js +6 -7
- package/dist/functions/key/index.js +1 -0
- package/dist/functions/meter/index.js +7 -5
- package/dist/functions/note/index.d.ts +5 -2
- package/dist/functions/note/index.js +162 -19
- package/dist/functions/note/source-transform.d.ts +8 -2
- package/dist/functions/note/source-transform.js +25 -11
- package/dist/functions/ottava/index.js +8 -7
- package/dist/functions/page/index.d.ts +1 -36
- package/dist/functions/page/index.js +11 -15
- package/dist/functions/pagebreak/index.js +2 -1
- package/dist/functions/rest/index.js +5 -5
- package/dist/functions/set/index.js +2 -2
- package/dist/functions/stack/index.js +7 -7
- package/dist/functions/symbol/symbols/dynamics.d.ts +3 -0
- package/dist/functions/symbol/symbols/dynamics.js +10 -1
- package/dist/functions/tempo/index.js +8 -3
- package/dist/functions/temporal.d.ts +21 -6
- package/dist/functions/temporal.js +1 -1
- package/dist/functions/text/index.js +3 -5
- package/dist/functions/up/index.js +37 -34
- package/dist/functions/voice/connections.js +2 -2
- package/dist/functions/voice/lyrics.d.ts +2 -0
- package/dist/functions/voice/lyrics.js +4 -4
- package/dist/functions/voice/voice.d.ts +2 -1
- package/dist/functions/voice/voice.js +9 -15
- package/dist/functions/voice/voices.d.ts +6 -4
- package/dist/functions/voice/voices.js +10 -10
- package/dist/index.d.ts +6 -34
- package/dist/index.js +6 -34
- package/dist/jpfun.min.js +49 -46
- package/dist/layout/engine.js +237 -232
- package/dist/layout/model.d.ts +1 -1
- package/dist/layout/page.d.ts +2 -2
- package/dist/layout/page.js +8 -22
- package/dist/layout/types.d.ts +4 -5
- package/dist/lowering/accidentalMemory.d.ts +33 -0
- package/dist/lowering/accidentalMemory.js +84 -0
- package/dist/lowering/loweringContext.d.ts +12 -7
- package/dist/lowering/loweringContext.js +54 -51
- package/dist/lowering/types.d.ts +2 -3
- package/dist/parser/grammarType.d.ts +10 -4
- package/dist/parser/parse-utils/brace-utils.js +4 -3
- package/dist/parser/parse-utils/call-utils.js +7 -7
- 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 +30 -34
- package/dist/parser/parserContext.js +77 -181
- package/dist/parser/preprocess.js +10 -23
- package/dist/parser/syntax.d.ts +9 -0
- package/dist/parser/syntax.js +109 -0
- package/dist/parser/types.d.ts +2 -1
- package/dist/pipeline.js +3 -2
- package/dist/playback/compile.js +26 -18
- package/dist/playback/event.d.ts +1 -2
- package/dist/playback/event.js +2 -3
- package/dist/playback/types.d.ts +0 -1
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.js +1 -0
- package/grammar.md +8 -6
- package/package.json +2 -2
- package/dist/functions/voice/index.d.ts +0 -2
- package/dist/functions/voice/index.js +0 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Diagnostic } from "../diagnostic.js";
|
|
2
|
+
import { resolveArgType } from "../functions/ASTtypes.js";
|
|
3
|
+
import { callArgName } from "./parse-utils/call-utils.js";
|
|
4
|
+
import { parseLength } from "./parse-utils/length-utils.js";
|
|
5
|
+
import { BOOL_RE, ParserContext } from "./parserContext.js";
|
|
6
|
+
/** 有函数参数契约时直接用声明类型;未知参数回落到真正的字面量解析器,不另写一套正则 */
|
|
7
|
+
function classifySyntaxValue(type, text) {
|
|
8
|
+
if (type)
|
|
9
|
+
return type === "content" ? undefined : type;
|
|
10
|
+
if (BOOL_RE.test(text))
|
|
11
|
+
return "boolean";
|
|
12
|
+
if (text.startsWith('"'))
|
|
13
|
+
return "string";
|
|
14
|
+
if (!isNaN(Number(text)))
|
|
15
|
+
return "number";
|
|
16
|
+
if (!(parseLength(text) instanceof Diagnostic))
|
|
17
|
+
return "length";
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 编辑器语法视图:以词法层模式观察 parseGrammar,收集着色 token 与调用结构,不构造 AST
|
|
22
|
+
* 节点按源码顺序发出、子区间就地递归,所以 tokens 有序且互不重叠,calls 按起点严格递增,无需排序;
|
|
23
|
+
* 注释在预处理阶段已被掩码,最后从 commentSpans 归并回来
|
|
24
|
+
*/
|
|
25
|
+
export function collectSyntax(parser, commentSpans) {
|
|
26
|
+
const { source, functions } = parser;
|
|
27
|
+
const tokens = [];
|
|
28
|
+
const calls = [];
|
|
29
|
+
// 词法层不构造 AST,识别阶段的 span 没有其他读写者,可直接引用
|
|
30
|
+
const add = (kind, span) => {
|
|
31
|
+
if (span && span.start < span.end)
|
|
32
|
+
tokens.push({ kind, span });
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 把已识别的 GrammarNode 映射为源码 token;content/brace 在子上下文中继续递归,作用域深度随之加一
|
|
36
|
+
* 总是返回 true 接管节点:输入途中的语法错误只记诊断,继续扫描以保留已识别的结构
|
|
37
|
+
*/
|
|
38
|
+
const record = (node, ctx) => {
|
|
39
|
+
if (node.kind === "brace") {
|
|
40
|
+
add("punctuation", { start: node.span.start, end: node.span.start + 1 });
|
|
41
|
+
const close = Math.min(source.length, node.span.end - 1);
|
|
42
|
+
new ParserContext(ctx).parseGrammar(node.span.start + 1, close, record);
|
|
43
|
+
if (source[close] === "}")
|
|
44
|
+
add("punctuation", { start: close, end: close + 1 });
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (node.kind === "label") {
|
|
48
|
+
add("label", node.span);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (node.kind === "sugar" || node.typed) {
|
|
52
|
+
if (Array.isArray(node.syntaxKind)) {
|
|
53
|
+
for (const token of node.syntaxKind)
|
|
54
|
+
add(token.kind, token.span);
|
|
55
|
+
}
|
|
56
|
+
else
|
|
57
|
+
add(node.syntaxKind ?? "operator", node.span);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
// calls 只暴露源码结构,不带 grammar 阶段的字段
|
|
61
|
+
const { kind, typed, syntaxKind, ...call } = node;
|
|
62
|
+
calls.push(call);
|
|
63
|
+
add("function", call.nameSpan);
|
|
64
|
+
add("punctuation", call.openParenSpan);
|
|
65
|
+
const def = functions.get(call.name.toLowerCase())?.def;
|
|
66
|
+
for (let index = 0; index < call.args.length; index++) {
|
|
67
|
+
const arg = call.args[index];
|
|
68
|
+
add("property", arg.nameSpan);
|
|
69
|
+
add("punctuation", arg.equalsSpan);
|
|
70
|
+
const type = def && resolveArgType(def, callArgName(source, arg), index);
|
|
71
|
+
if (type === "content") {
|
|
72
|
+
new ParserContext(ctx).parseGrammar(arg.valueSpan.start, arg.valueSpan.end, record);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const valueKind = classifySyntaxValue(type, source.slice(arg.valueSpan.start, arg.valueSpan.end));
|
|
76
|
+
if (valueKind)
|
|
77
|
+
add(valueKind, arg.valueSpan);
|
|
78
|
+
}
|
|
79
|
+
add("punctuation", arg.commaSpan);
|
|
80
|
+
}
|
|
81
|
+
add("punctuation", call.closeParenSpan);
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
parser.parseGrammar(0, source.length, record);
|
|
85
|
+
return { tokens: interleaveComments(tokens, commentSpans), calls };
|
|
86
|
+
}
|
|
87
|
+
/** 线性归并注释;未裁剪的值(如歌词行)会跨过注释,在注释处切开,保证输出有序且互不重叠 */
|
|
88
|
+
function interleaveComments(tokens, comments) {
|
|
89
|
+
if (comments.length === 0)
|
|
90
|
+
return tokens;
|
|
91
|
+
const out = [];
|
|
92
|
+
let c = 0;
|
|
93
|
+
for (const token of tokens) {
|
|
94
|
+
const { kind, span } = token;
|
|
95
|
+
let start = span.start;
|
|
96
|
+
for (; c < comments.length && comments[c].start < span.end; c++) {
|
|
97
|
+
const comment = comments[c];
|
|
98
|
+
if (start < comment.start)
|
|
99
|
+
out.push({ kind, span: { start, end: comment.start } });
|
|
100
|
+
out.push({ kind: "comment", span: comment });
|
|
101
|
+
start = Math.max(start, comment.end);
|
|
102
|
+
}
|
|
103
|
+
if (start < span.end)
|
|
104
|
+
out.push(start === span.start ? token : { kind, span: { start, end: span.end } });
|
|
105
|
+
}
|
|
106
|
+
for (; c < comments.length; c++)
|
|
107
|
+
out.push({ kind: "comment", span: comments[c] });
|
|
108
|
+
return out;
|
|
109
|
+
}
|
package/dist/parser/types.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ export type deSugarAtomFunction = (source: string, start: number, end: number, d
|
|
|
24
24
|
node: GrammarNode;
|
|
25
25
|
} | null;
|
|
26
26
|
/**
|
|
27
|
+
* 关系去糖:由 deSugarAtom 挂在 sugar 节点上,makeNodes 遇到该节点时直接调用,不再逐个尝试
|
|
27
28
|
* 传入的列表已经被拆为单字符了 会修改 ctx
|
|
28
|
-
* 返回值是下一个位置 指 nodes
|
|
29
|
+
* 返回值是下一个位置 指 nodes 数组;返回 null 表示放弃,该 sugar 保留为文本
|
|
29
30
|
* 内部报错需要push到ctx再throw
|
|
30
31
|
*/
|
|
31
32
|
export type deSugarRelationFunction = (ctx: ParserContext, nodes: (GrammarNode | number)[], at: number) => number | null;
|
package/dist/pipeline.js
CHANGED
|
@@ -5,6 +5,7 @@ import { layoutDocument, } from "./layout/engine.js";
|
|
|
5
5
|
import { LoweringContext } from "./lowering/loweringContext.js";
|
|
6
6
|
import { ParserContext } from "./parser/parserContext.js";
|
|
7
7
|
import { preprocessSource } from "./parser/preprocess.js";
|
|
8
|
+
import { collectSyntax } from "./parser/syntax.js";
|
|
8
9
|
/**
|
|
9
10
|
* 默认的源码到布局流水线
|
|
10
11
|
*
|
|
@@ -40,10 +41,10 @@ export function compileScore(source, options = {}) {
|
|
|
40
41
|
*/
|
|
41
42
|
export function analyzeScoreSyntax(source, functions = defaultFunctions) {
|
|
42
43
|
const { maskedSource, commentSpans } = preprocessSource(source);
|
|
43
|
-
const parser = new ParserContext({ source: maskedSource
|
|
44
|
+
const parser = new ParserContext({ source: maskedSource });
|
|
44
45
|
parser.registerFunctions(functions);
|
|
45
46
|
return {
|
|
46
|
-
syntax: parser
|
|
47
|
+
syntax: collectSyntax(parser, commentSpans),
|
|
47
48
|
diagnostics: parser.diagnostics,
|
|
48
49
|
};
|
|
49
50
|
}
|
package/dist/playback/compile.js
CHANGED
|
@@ -34,7 +34,7 @@ function linearizeColumns(lowering, diagnostics, maxFlowSteps) {
|
|
|
34
34
|
const finish = at.t.clone().add(at.T);
|
|
35
35
|
let end = index;
|
|
36
36
|
// 用顺序向后找而不是二分因为基本就在后一个(@rest除外)
|
|
37
|
-
while (end + 1 < columns.length && columns[end + 1]
|
|
37
|
+
while (end + 1 < columns.length && columns[end + 1].t.compare(finish) < 0)
|
|
38
38
|
end++;
|
|
39
39
|
return end;
|
|
40
40
|
}
|
|
@@ -172,7 +172,13 @@ export function compilePlayback(lowering, options) {
|
|
|
172
172
|
const notes = [];
|
|
173
173
|
const transforms = new Map();
|
|
174
174
|
const activePrograms = new Map();
|
|
175
|
-
let
|
|
175
|
+
let lastSignature;
|
|
176
|
+
/** 与上一个拍号相同则跳过,避免跳转补发与目标列自身拍号重复 */
|
|
177
|
+
const emitTimeSignature = (event) => {
|
|
178
|
+
if (lastSignature?.numerator === event.numerator && lastSignature.denominator === event.denominator)
|
|
179
|
+
return;
|
|
180
|
+
events.push(lastSignature = { ...event, at: event.at.clone() });
|
|
181
|
+
};
|
|
176
182
|
let nextNoteId = 0;
|
|
177
183
|
const changes = [{ kind: "initial", at: new Fraction(), origins: [] }];
|
|
178
184
|
const factors = new Map();
|
|
@@ -224,15 +230,12 @@ export function compilePlayback(lowering, options) {
|
|
|
224
230
|
spanScales.set(span, inheritedScales);
|
|
225
231
|
return span;
|
|
226
232
|
}
|
|
227
|
-
//
|
|
233
|
+
// 每次访问都恢复记谱位置固化的音轨音色,回跳不继承上一遍结束时的状态
|
|
228
234
|
const program = node.playbackState?.program;
|
|
229
235
|
if (program !== undefined && activePrograms.get(track) !== program) {
|
|
230
236
|
activePrograms.set(track, program);
|
|
231
|
-
events.push({ kind: "program-change", at: start.clone(),
|
|
237
|
+
events.push({ kind: "program-change", at: start.clone(), track, program });
|
|
232
238
|
}
|
|
233
|
-
const bpm = node.playbackState?.bpm;
|
|
234
|
-
if (bpm !== undefined)
|
|
235
|
-
scheduleControl(start, lineage, state => { state.bpm = bpm; });
|
|
236
239
|
node.emitPlayback?.({
|
|
237
240
|
start,
|
|
238
241
|
end: start.clone().add(duration),
|
|
@@ -267,7 +270,7 @@ export function compilePlayback(lowering, options) {
|
|
|
267
270
|
spanScales.set(span, scales);
|
|
268
271
|
span.end.add(duration);
|
|
269
272
|
},
|
|
270
|
-
emit:
|
|
273
|
+
emit: emitTimeSignature,
|
|
271
274
|
control: (at, apply) => scheduleControl(at, lineage, apply),
|
|
272
275
|
/** 只登记效果身份和比例,范围等结构与连接确定后再计算 */
|
|
273
276
|
scaleFollowingBpm(key, numerator, denominator = 1, options) {
|
|
@@ -294,7 +297,7 @@ export function compilePlayback(lowering, options) {
|
|
|
294
297
|
hook(structureContext);
|
|
295
298
|
}
|
|
296
299
|
const order = linearizeColumns(lowering, diagnostics, maxFlowSteps);
|
|
297
|
-
const firstScore = lowering.columns[order[0]]?.
|
|
300
|
+
const firstScore = lowering.columns[order[0]]?.t.clone() ?? new Fraction();
|
|
298
301
|
const scoreMap = [{
|
|
299
302
|
performance: new Fraction(), // 演奏时间0
|
|
300
303
|
score: firstScore // 记谱时间0
|
|
@@ -304,20 +307,26 @@ export function compilePlayback(lowering, options) {
|
|
|
304
307
|
const performanceEnd = new Fraction();
|
|
305
308
|
for (let step = 0; step < order.length; step++) {
|
|
306
309
|
const index = order[step];
|
|
310
|
+
const column = lowering.columns[index];
|
|
307
311
|
// 同列各顶层访问共享演奏坐标,但分别建立自己的效果作用域
|
|
308
|
-
for (const node of
|
|
312
|
+
for (const node of column) {
|
|
309
313
|
if (!node.playbackState && !node.emitPlayback)
|
|
310
314
|
continue;
|
|
311
|
-
play(node, [], [],
|
|
315
|
+
play(node, [], [], column.t.clone().add(shift), node.T.clone());
|
|
312
316
|
}
|
|
313
|
-
const boundary = lowering.columns[index + 1]?.
|
|
317
|
+
const boundary = lowering.columns[index + 1]?.t ?? lowering.duration; // 当前列的控制终点
|
|
314
318
|
performanceEnd.copyFrom(boundary).add(shift);
|
|
315
319
|
const next = order[step + 1];
|
|
316
320
|
if (next === undefined || next === index + 1)
|
|
317
321
|
continue;
|
|
318
|
-
// 离开记谱顺序时 performance
|
|
319
|
-
const
|
|
322
|
+
// 离开记谱顺序时 performance 不跳,只改变接下来对应的 score 坐标并恢复目标列速度
|
|
323
|
+
const nextColumn = lowering.columns[next];
|
|
324
|
+
const resume = nextColumn.t.clone();
|
|
320
325
|
shift.add(boundary).sub(resume);
|
|
326
|
+
scheduleControl(performanceEnd, [{ node: nextColumn[0] }], state => { state.bpm = nextColumn.bpm; });
|
|
327
|
+
const { timeSignature } = nextColumn;
|
|
328
|
+
if (timeSignature)
|
|
329
|
+
emitTimeSignature({ kind: "time-signature", at: performanceEnd, ...timeSignature });
|
|
321
330
|
const point = { performance: performanceEnd.clone(), score: resume };
|
|
322
331
|
const previous = scoreMap[scoreMap.length - 1];
|
|
323
332
|
// 同一个演奏时刻指向后面最近的谱面时刻
|
|
@@ -387,7 +396,7 @@ export function compilePlayback(lowering, options) {
|
|
|
387
396
|
}
|
|
388
397
|
}
|
|
389
398
|
const system = {
|
|
390
|
-
bpm: DEFAULT_BPM,
|
|
399
|
+
bpm: lowering.columns[order[0]]?.bpm ?? DEFAULT_BPM,
|
|
391
400
|
bpmScale: new Fraction(1),
|
|
392
401
|
};
|
|
393
402
|
const activeCounts = new Map();
|
|
@@ -437,7 +446,6 @@ export function compilePlayback(lowering, options) {
|
|
|
437
446
|
kind: "tempo",
|
|
438
447
|
at: at.clone(),
|
|
439
448
|
bpm: snapshot.effectiveBpm,
|
|
440
|
-
order: nextEventOrder++,
|
|
441
449
|
});
|
|
442
450
|
}
|
|
443
451
|
}
|
|
@@ -519,12 +527,12 @@ export function compilePlayback(lowering, options) {
|
|
|
519
527
|
const { start, end, track, midi, velocity, percussion, sourceSpans } = sound;
|
|
520
528
|
const noteId = nextNoteId++;
|
|
521
529
|
const on = {
|
|
522
|
-
kind: "note-on", at: start.clone(), noteId,
|
|
530
|
+
kind: "note-on", at: start.clone(), noteId,
|
|
523
531
|
track, midi, velocity, percussion,
|
|
524
532
|
sourceSpans: [...sourceSpans],
|
|
525
533
|
};
|
|
526
534
|
const off = {
|
|
527
|
-
kind: "note-off", at: end.clone(), noteId,
|
|
535
|
+
kind: "note-off", at: end.clone(), noteId,
|
|
528
536
|
track, midi,
|
|
529
537
|
};
|
|
530
538
|
audible.add(track);
|
package/dist/playback/event.d.ts
CHANGED
|
@@ -45,7 +45,6 @@ export interface PlaybackOrigin {
|
|
|
45
45
|
}
|
|
46
46
|
interface PlaybackDraftEventBase {
|
|
47
47
|
at: Fraction;
|
|
48
|
-
order: number;
|
|
49
48
|
}
|
|
50
49
|
/** 声音展开后生成的点事件;最终输出前压实轨道编号并剥离编译期字段 */
|
|
51
50
|
export interface PlaybackDraftNoteOnEvent extends PlaybackDraftEventBase {
|
|
@@ -84,7 +83,7 @@ export interface PlaybackEventInput {
|
|
|
84
83
|
numerator: number;
|
|
85
84
|
denominator: number;
|
|
86
85
|
}
|
|
87
|
-
/**
|
|
86
|
+
/** 同刻先处理系统状态,再关音和开音;相同类别依赖稳定排序保持原发布次序 */
|
|
88
87
|
export declare function comparePlaybackDraftEvents(left: PlaybackDraftEvent, right: PlaybackDraftEvent): number;
|
|
89
88
|
/**
|
|
90
89
|
* 压实发声 Track 编号并剥掉编译期字段,得到稳定、可序列化的公开事件
|
package/dist/playback/event.js
CHANGED
|
@@ -5,10 +5,9 @@ const EVENT_PRIORITY = {
|
|
|
5
5
|
"note-off": 3,
|
|
6
6
|
"note-on": 4,
|
|
7
7
|
};
|
|
8
|
-
/**
|
|
8
|
+
/** 同刻先处理系统状态,再关音和开音;相同类别依赖稳定排序保持原发布次序 */
|
|
9
9
|
export function comparePlaybackDraftEvents(left, right) {
|
|
10
|
-
|
|
11
|
-
return byTime || EVENT_PRIORITY[left.kind] - EVENT_PRIORITY[right.kind] || left.order - right.order;
|
|
10
|
+
return left.at.compare(right.at) || EVENT_PRIORITY[left.kind] - EVENT_PRIORITY[right.kind];
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
13
|
* 压实发声 Track 编号并剥掉编译期字段,得到稳定、可序列化的公开事件
|
package/dist/playback/types.d.ts
CHANGED
package/dist/render/index.d.ts
CHANGED
package/dist/render/index.js
CHANGED
package/grammar.md
CHANGED
|
@@ -58,10 +58,9 @@ sidebar:
|
|
|
58
58
|
|
|
59
59
|
### 页面与谱头
|
|
60
60
|
|
|
61
|
-
- `@page(width, height, top, bottom, left, right,
|
|
61
|
+
- `@page(width, height, top, bottom, left, right, numbering, barNumbering, font, fillRatio)`:页面布局。
|
|
62
62
|
- 仅顶层首次声明有效,其余警告并忽略;`em` 按声明时字号计算。
|
|
63
|
-
- 默认:宽 `794px`、高 `0px`、上 `45px`、下 `48px`、左右 `40px
|
|
64
|
-
- `gap` 为上一行下沿到下一行主旋律上沿(基线减半字高)的标准行距;顶部外扩图形优先借用行距,但与上一行下沿至少保留 `minGap`(不超过 `gap`)。
|
|
63
|
+
- 默认:宽 `794px`、高 `0px`、上 `45px`、下 `48px`、左右 `40px`、`fillRatio=0.5`。行距由 [`@br`](#换行) 设置。
|
|
65
64
|
- `height <= 0` 不自动分页,仍可手动换页;正值按整行分页,单行超高报错。自动封页均分剩余高度,末页保持自然行距。
|
|
66
65
|
- `fillRatio`:自然宽度达到版心宽度的该比例时撑满;负值始终撑满,`>= 1` 不自动拉开。
|
|
67
66
|
- `numbering`:页码格式,如 `"1/1"`,默认 `""` 不显示;`font`:页码/小节号字体,默认 `""` 沿用当前字体。
|
|
@@ -80,6 +79,7 @@ sidebar:
|
|
|
80
79
|
- `1`~`7`:相对音级,`octave` 默认 `0`;后缀 `'` 升八度、`,` 降八度,如 `1'`、`6,,`。
|
|
81
80
|
- `A`~`G`:绝对音名,`octave` 默认 `4`,如 `C4`、`F#5`;实际音高不随调性变化。
|
|
82
81
|
- `acc`:`#` 升半音、`b` 降半音、`n` 还原,可重复;简写如 `#1'`、`b6,`、`C#4`。
|
|
82
|
+
- `force`:强制显示实际生效的变音号(无变音显示 `n`),不改变音高;简写为音名末尾的 `!`,如 `C4!`、`#1'!`、`@n(C!, #, 4)`。
|
|
83
83
|
- `0` / `Z` 休止,`8` 隐形静音占位,`9` / `X` 打击节拍记号;均忽略升降号与八度。
|
|
84
84
|
- JE 兼容:`(`、`]` 降八度,`[`、`)` 升八度;可嵌套,不越过当前 `{}`。
|
|
85
85
|
|
|
@@ -128,9 +128,11 @@ sidebar:
|
|
|
128
128
|
- 有限页高下默认分配当前页的剩余空间;`justify=false` 只保留最小行距。无限页高按自然高度结束,不拉伸。
|
|
129
129
|
- 同时刻的并行调用只换一次页,任一 `justify=false` 则不拉伸;同轨连续调用分别执行。
|
|
130
130
|
|
|
131
|
-
- `@br(
|
|
131
|
+
- `@br(gap=1em, minGap=0.4em)`:换到下一谱面行,并设置与上一行的行距。
|
|
132
132
|
- 顶层空行(连续至少两个换行)等价于一次 `@br()`;普通源码换行及块内空行不换谱面行。
|
|
133
|
-
-
|
|
133
|
+
- 同轨连续调用累加,`@br() @br()` 产生一条高 0 的空行,即叠加两段行距;同时刻的并行调用只换一次行,行距取较大值。
|
|
134
|
+
- `gap` 为上一行下沿到下一行主旋律上沿(基线减半字高)的标准行距;顶部外扩图形优先借用行距,但与上一行下沿至少保留 `minGap`(不超过 `gap`)。负值允许行与行重叠,`em` 按调用处字号计算;用 `@set(br.gap=...)` 设置后续默认行距。
|
|
135
|
+
- 换页后的首行没有行距,`gap` 不生效。
|
|
134
136
|
|
|
135
137
|
### 声部与歌词
|
|
136
138
|
|
|
@@ -249,5 +251,5 @@ sidebar:
|
|
|
249
251
|
|
|
250
252
|
## 5. 预处理规则(换行与注释)
|
|
251
253
|
- **注释**:字符串外 `%` 至行末;`\%` 不能阻止注释。
|
|
252
|
-
- **换行**:支持 `\n`、`\r\n
|
|
254
|
+
- **换行**:支持 `\n`、`\r\n`。
|
|
253
255
|
- **续行**:忽略行尾空白后,末尾连续 `\` 每对保留一个;总数为奇数则合并下一行,偶数则保留换行。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jpfun",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A functional numbered musical notation typesetting engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"author": "madderscientist",
|
|
48
48
|
"license": "Apache-2.0",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/node": "^26.
|
|
50
|
+
"@types/node": "^26.6.11",
|
|
51
51
|
"esbuild": "^0.28.2",
|
|
52
52
|
"tsx": "^4.23.13",
|
|
53
53
|
"typescript": "^7.0.2"
|