@sudobility/music_drawing 0.0.33 → 0.0.35
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/dist/canvas-renderer.d.ts +79 -4
- package/dist/canvas-renderer.d.ts.map +1 -1
- package/dist/canvas-renderer.js +245 -53
- package/dist/canvas-renderer.js.map +1 -1
- package/dist/cursor.d.ts +60 -0
- package/dist/cursor.d.ts.map +1 -0
- package/dist/cursor.js +157 -0
- package/dist/cursor.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/keyboard-geometry.d.ts +50 -2
- package/dist/keyboard-geometry.d.ts.map +1 -1
- package/dist/keyboard-geometry.js +71 -2
- package/dist/keyboard-geometry.js.map +1 -1
- package/dist/keyboard-keys.d.ts +93 -0
- package/dist/keyboard-keys.d.ts.map +1 -0
- package/dist/keyboard-keys.js +60 -0
- package/dist/keyboard-keys.js.map +1 -0
- package/dist/layered-paint.d.ts +47 -0
- package/dist/layered-paint.d.ts.map +1 -0
- package/dist/layered-paint.js +22 -0
- package/dist/layered-paint.js.map +1 -0
- package/dist/pagination.d.ts +6 -2
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +4 -0
- package/dist/pagination.js.map +1 -1
- package/dist/playback-binding.d.ts +57 -0
- package/dist/playback-binding.d.ts.map +1 -0
- package/dist/playback-binding.js +110 -0
- package/dist/playback-binding.js.map +1 -0
- package/dist/playhead.d.ts.map +1 -1
- package/dist/playhead.js +22 -3
- package/dist/playhead.js.map +1 -1
- package/dist/press.d.ts +66 -0
- package/dist/press.d.ts.map +1 -0
- package/dist/press.js +64 -0
- package/dist/press.js.map +1 -0
- package/dist/print-plan.d.ts +64 -0
- package/dist/print-plan.d.ts.map +1 -0
- package/dist/print-plan.js +101 -0
- package/dist/print-plan.js.map +1 -0
- package/dist/render-theme.d.ts.map +1 -1
- package/dist/render-theme.js +11 -2
- package/dist/render-theme.js.map +1 -1
- package/dist/score-canvas.d.ts +280 -0
- package/dist/score-canvas.d.ts.map +1 -0
- package/dist/score-canvas.js +702 -0
- package/dist/score-canvas.js.map +1 -0
- package/dist/skia/index.d.ts +2 -0
- package/dist/skia/index.d.ts.map +1 -1
- package/dist/skia/index.js +1 -0
- package/dist/skia/index.js.map +1 -1
- package/dist/skia/skia-layers.d.ts +43 -0
- package/dist/skia/skia-layers.d.ts.map +1 -0
- package/dist/skia/skia-layers.js +24 -0
- package/dist/skia/skia-layers.js.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/dist/playhead.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { measureAtXInSystem, systemAtY } from './layout.js';
|
|
2
|
+
import { headerWidthForMeasure } from './stave-header.js';
|
|
2
3
|
/** The score's shared measure grid (first track — every track shares it once `rebuildMeasureTicks` has run; same convention as `store/selectors.ts`). */
|
|
3
4
|
function measureTimings(score) {
|
|
4
5
|
const measures = score.tracks[0]?.measures ?? [];
|
|
@@ -49,6 +50,21 @@ function systemForMeasureIndex(plan, measureIndex) {
|
|
|
49
50
|
}
|
|
50
51
|
return null;
|
|
51
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Where a bar's music can begin and end when nothing has been drawn yet.
|
|
55
|
+
*
|
|
56
|
+
* The stave box runs barline to barline, but its left edge holds whatever
|
|
57
|
+
* header the layout reserved — the clef, key and time signature a system
|
|
58
|
+
* restates, and a change mid-system. Spreading the bar across the whole box put
|
|
59
|
+
* tick 0 on the barline, left of the clef, for the frame before the first paint
|
|
60
|
+
* and anywhere off the drawn window. The header width is the layout's own
|
|
61
|
+
* figure, so this and the stave agree about where the notes start.
|
|
62
|
+
*/
|
|
63
|
+
function undrawnSpan(plan, system, measureIndex, box) {
|
|
64
|
+
const header = headerWidthForMeasure(plan.tracks, measureIndex, system.measureIndices[0] === measureIndex);
|
|
65
|
+
const inset = Math.max(0, Math.min(header, box.width));
|
|
66
|
+
return { startX: box.x + inset, width: box.width - inset };
|
|
67
|
+
}
|
|
52
68
|
/** Straight-line interpolation between two known points. */
|
|
53
69
|
function lerp(tick, a, b) {
|
|
54
70
|
if (b.tick === a.tick)
|
|
@@ -205,8 +221,9 @@ export function caretPositionForTick(plan, score, tick, notePositions) {
|
|
|
205
221
|
const fraction = timing.durationTicks > 0
|
|
206
222
|
? Math.min(1, Math.max(0, (tick - timing.startTick) / timing.durationTicks))
|
|
207
223
|
: 0;
|
|
224
|
+
const span = undrawnSpan(plan, system, measureIndex, layout.box);
|
|
208
225
|
return {
|
|
209
|
-
x:
|
|
226
|
+
x: span.startX + fraction * span.width,
|
|
210
227
|
yTop: system.yTop,
|
|
211
228
|
yBottom: system.yBottom,
|
|
212
229
|
};
|
|
@@ -247,8 +264,10 @@ export function tickForPoint(plan, score, x, y, notePositions) {
|
|
|
247
264
|
const endX = endAnchorFor(plan, system, hit.measureIndex, drawn.area, notePositions);
|
|
248
265
|
return Math.round(tickForX(x, drawn.positions, drawn.area, timing.startTick, endTick, endX));
|
|
249
266
|
}
|
|
250
|
-
|
|
251
|
-
|
|
267
|
+
// The inverse of the undrawn caret, over the same span.
|
|
268
|
+
const span = undrawnSpan(plan, system, hit.measureIndex, hit.box);
|
|
269
|
+
const fraction = span.width > 0
|
|
270
|
+
? Math.min(1, Math.max(0, (x - span.startX) / span.width))
|
|
252
271
|
: 0;
|
|
253
272
|
return Math.round(timing.startTick + fraction * timing.durationTicks);
|
|
254
273
|
}
|
package/dist/playhead.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playhead.js","sourceRoot":"","sources":["../src/playhead.ts"],"names":[],"mappings":"AA6CA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"playhead.js","sourceRoot":"","sources":["../src/play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AM,OAAO,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC;QACxD,MAAM,IAAI,GAAG,YAAY,CACvB,IAAI,EACJ,MAAM,EACN,GAAG,CAAC,YAAY,EAChB,KAAK,CAAC,IAAI,EACV,aAAa,CACd,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CACf,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAC1E,CAAC;IACJ,CAAC;IAED,wDAAwD;IACxD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAClE,MAAM,QAAQ,GACZ,IAAI,CAAC,KAAK,GAAG,CAAC;QACZ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC,CAAC;IACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/press.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a press on the score was: a tap, a long press, or a drag.
|
|
3
|
+
*
|
|
4
|
+
* Both apps answer this at the end of every press, and they answered it with
|
|
5
|
+
* different numbers in different files — the web's `DRAG_THRESHOLD` inside the
|
|
6
|
+
* notation view, the native app's `LONG_PRESS_MS`/`LONG_PRESS_SLOP` inside its
|
|
7
|
+
* scrolling score. The question is about the canvas (did the press stay on the
|
|
8
|
+
* thing under it?), so it lives beside the hit-testing that answers the next
|
|
9
|
+
* question.
|
|
10
|
+
*
|
|
11
|
+
* ## Mouse and touch differ, on purpose
|
|
12
|
+
*
|
|
13
|
+
* A mouse is still: a click that moved more than 3px was meant to move, which
|
|
14
|
+
* is exactly where the web's box select has always started. A finger is not —
|
|
15
|
+
* a deliberate tap on a phone routinely lands several points from where it
|
|
16
|
+
* touched down, and holding a finger to 3px would turn a good share of taps
|
|
17
|
+
* into drags. So a touch gets `TOUCH_TAP_SLOP`, the same allowance a long press
|
|
18
|
+
* already had: a press that stays put long enough to be a long press would
|
|
19
|
+
* otherwise have been a *drag* had it been released a moment sooner, which is
|
|
20
|
+
* not a distinction a thumb can make.
|
|
21
|
+
*
|
|
22
|
+
* A mouse never long-presses. It has a secondary button for the context menu,
|
|
23
|
+
* and a click held while the reader looks at something is not a request for
|
|
24
|
+
* one — reading it as one would change what an ordinary slow click does on the
|
|
25
|
+
* web. React Native on macOS passes `'touch'`, because its gesture model is the
|
|
26
|
+
* touch one: the long press is how it opens the menu.
|
|
27
|
+
*
|
|
28
|
+
* ## Distance
|
|
29
|
+
*
|
|
30
|
+
* Measured per axis (the larger of |dx| and |dy|), which is the web's existing
|
|
31
|
+
* rule to the pixel. The native app used the straight-line distance; per axis
|
|
32
|
+
* lets a diagonal wander up to √2 further, which is under five points at a
|
|
33
|
+
* 12pt slop and not something a hand can aim at.
|
|
34
|
+
*
|
|
35
|
+
* The caller latches: once a press has classified as a drag it stays one even
|
|
36
|
+
* if the pointer comes back, which is how the web's `drag.moved` behaves. This
|
|
37
|
+
* function answers for one moment and keeps no state.
|
|
38
|
+
*/
|
|
39
|
+
/** What produced the press. */
|
|
40
|
+
export type PointerKind = 'mouse' | 'touch';
|
|
41
|
+
export type PressKind = 'tap' | 'longPress' | 'drag';
|
|
42
|
+
/** How far a mouse press may move and still be a click, in px (web). */
|
|
43
|
+
export declare const TAP_SLOP = 3;
|
|
44
|
+
/** How far a finger may move and still be a tap, in pt. */
|
|
45
|
+
export declare const TOUCH_TAP_SLOP = 12;
|
|
46
|
+
/** How long a press is held to be a long press — iOS's and Android's own threshold. */
|
|
47
|
+
export declare const LONG_PRESS_MS = 500;
|
|
48
|
+
/** How far a long press may wander — about a thumb's width. */
|
|
49
|
+
export declare const LONG_PRESS_SLOP = 12;
|
|
50
|
+
/** The tap slop for a pointer kind. */
|
|
51
|
+
export declare function tapSlopFor(pointer: PointerKind): number;
|
|
52
|
+
export type PressMeasure = {
|
|
53
|
+
/** Movement since the press began, either sign. */
|
|
54
|
+
dx: number;
|
|
55
|
+
dy: number;
|
|
56
|
+
/** How long the press has been (or was) held. */
|
|
57
|
+
heldMs: number;
|
|
58
|
+
/** Defaults to `'mouse'`, the web's rule. */
|
|
59
|
+
pointer?: PointerKind;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* `'longPress'` if a touch was held `LONG_PRESS_MS` within `LONG_PRESS_SLOP`;
|
|
63
|
+
* otherwise `'tap'` if it moved no more than the tap slop; otherwise `'drag'`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function classifyPress({ dx, dy, heldMs, pointer, }: PressMeasure): PressKind;
|
|
66
|
+
//# sourceMappingURL=press.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../src/press.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,+BAA+B;AAC/B,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,CAAC;AAErD,wEAAwE;AACxE,eAAO,MAAM,QAAQ,IAAI,CAAC;AAE1B,2DAA2D;AAC3D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,uFAAuF;AACvF,eAAO,MAAM,aAAa,MAAM,CAAC;AAEjC,+DAA+D;AAC/D,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,uCAAuC;AACvC,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAEvD;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,EAAE,EACF,EAAE,EACF,MAAM,EACN,OAAiB,GAClB,EAAE,YAAY,GAAG,SAAS,CAU1B"}
|
package/dist/press.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a press on the score was: a tap, a long press, or a drag.
|
|
3
|
+
*
|
|
4
|
+
* Both apps answer this at the end of every press, and they answered it with
|
|
5
|
+
* different numbers in different files — the web's `DRAG_THRESHOLD` inside the
|
|
6
|
+
* notation view, the native app's `LONG_PRESS_MS`/`LONG_PRESS_SLOP` inside its
|
|
7
|
+
* scrolling score. The question is about the canvas (did the press stay on the
|
|
8
|
+
* thing under it?), so it lives beside the hit-testing that answers the next
|
|
9
|
+
* question.
|
|
10
|
+
*
|
|
11
|
+
* ## Mouse and touch differ, on purpose
|
|
12
|
+
*
|
|
13
|
+
* A mouse is still: a click that moved more than 3px was meant to move, which
|
|
14
|
+
* is exactly where the web's box select has always started. A finger is not —
|
|
15
|
+
* a deliberate tap on a phone routinely lands several points from where it
|
|
16
|
+
* touched down, and holding a finger to 3px would turn a good share of taps
|
|
17
|
+
* into drags. So a touch gets `TOUCH_TAP_SLOP`, the same allowance a long press
|
|
18
|
+
* already had: a press that stays put long enough to be a long press would
|
|
19
|
+
* otherwise have been a *drag* had it been released a moment sooner, which is
|
|
20
|
+
* not a distinction a thumb can make.
|
|
21
|
+
*
|
|
22
|
+
* A mouse never long-presses. It has a secondary button for the context menu,
|
|
23
|
+
* and a click held while the reader looks at something is not a request for
|
|
24
|
+
* one — reading it as one would change what an ordinary slow click does on the
|
|
25
|
+
* web. React Native on macOS passes `'touch'`, because its gesture model is the
|
|
26
|
+
* touch one: the long press is how it opens the menu.
|
|
27
|
+
*
|
|
28
|
+
* ## Distance
|
|
29
|
+
*
|
|
30
|
+
* Measured per axis (the larger of |dx| and |dy|), which is the web's existing
|
|
31
|
+
* rule to the pixel. The native app used the straight-line distance; per axis
|
|
32
|
+
* lets a diagonal wander up to √2 further, which is under five points at a
|
|
33
|
+
* 12pt slop and not something a hand can aim at.
|
|
34
|
+
*
|
|
35
|
+
* The caller latches: once a press has classified as a drag it stays one even
|
|
36
|
+
* if the pointer comes back, which is how the web's `drag.moved` behaves. This
|
|
37
|
+
* function answers for one moment and keeps no state.
|
|
38
|
+
*/
|
|
39
|
+
/** How far a mouse press may move and still be a click, in px (web). */
|
|
40
|
+
export const TAP_SLOP = 3;
|
|
41
|
+
/** How far a finger may move and still be a tap, in pt. */
|
|
42
|
+
export const TOUCH_TAP_SLOP = 12;
|
|
43
|
+
/** How long a press is held to be a long press — iOS's and Android's own threshold. */
|
|
44
|
+
export const LONG_PRESS_MS = 500;
|
|
45
|
+
/** How far a long press may wander — about a thumb's width. */
|
|
46
|
+
export const LONG_PRESS_SLOP = 12;
|
|
47
|
+
/** The tap slop for a pointer kind. */
|
|
48
|
+
export function tapSlopFor(pointer) {
|
|
49
|
+
return pointer === 'touch' ? TOUCH_TAP_SLOP : TAP_SLOP;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* `'longPress'` if a touch was held `LONG_PRESS_MS` within `LONG_PRESS_SLOP`;
|
|
53
|
+
* otherwise `'tap'` if it moved no more than the tap slop; otherwise `'drag'`.
|
|
54
|
+
*/
|
|
55
|
+
export function classifyPress({ dx, dy, heldMs, pointer = 'mouse', }) {
|
|
56
|
+
const moved = Math.max(Math.abs(dx), Math.abs(dy));
|
|
57
|
+
if (pointer === 'touch' &&
|
|
58
|
+
heldMs >= LONG_PRESS_MS &&
|
|
59
|
+
moved <= LONG_PRESS_SLOP) {
|
|
60
|
+
return 'longPress';
|
|
61
|
+
}
|
|
62
|
+
return moved <= tapSlopFor(pointer) ? 'tap' : 'drag';
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=press.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"press.js","sourceRoot":"","sources":["../src/press.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAOH,wEAAwE;AACxE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAE1B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,uFAAuF;AACvF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,uCAAuC;AACvC,MAAM,UAAU,UAAU,CAAC,OAAoB;IAC7C,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC;AACzD,CAAC;AAYD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,EAAE,EACF,EAAE,EACF,MAAM,EACN,OAAO,GAAG,OAAO,GACJ;IACb,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,IACE,OAAO,KAAK,OAAO;QACnB,MAAM,IAAI,aAAa;QACvB,KAAK,IAAI,eAAe,EACxB,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Score } from '@sudobility/music_types';
|
|
2
|
+
import type { LayoutPlan } from './layout.js';
|
|
3
|
+
import type { PaperOrientation, PaperSize, PrintPage } from './pagination.js';
|
|
4
|
+
import { printRenderOptions } from './print-layout.js';
|
|
5
|
+
import type { PrintSystemSlice } from './print-layout.js';
|
|
6
|
+
/**
|
|
7
|
+
* The paper picker. `css` is the `@page` size keyword; an orientation's value
|
|
8
|
+
* is its own CSS keyword already.
|
|
9
|
+
*
|
|
10
|
+
* A4 has a key like the others even though it reads "A4" in both languages —
|
|
11
|
+
* one shape for every entry is what lets a picker map straight through, and the
|
|
12
|
+
* locales list it as shared by design.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PAPER_OPTIONS: ReadonlyArray<{
|
|
15
|
+
value: PaperSize;
|
|
16
|
+
labelKey: string;
|
|
17
|
+
css: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const ORIENTATION_OPTIONS: ReadonlyArray<{
|
|
20
|
+
value: PaperOrientation;
|
|
21
|
+
labelKey: string;
|
|
22
|
+
}>;
|
|
23
|
+
/** The whole score, as against one track's id. */
|
|
24
|
+
export declare const WHOLE_SCORE = "score";
|
|
25
|
+
export type PrintPlanOptions = {
|
|
26
|
+
/** `'score'` (default) or a track id to print that player's part. */
|
|
27
|
+
scope?: string;
|
|
28
|
+
/** What the whole score prints; empty or absent means every track. Ignored for a part. */
|
|
29
|
+
visibleTrackIds?: readonly string[];
|
|
30
|
+
paper?: PaperSize;
|
|
31
|
+
orientation?: PaperOrientation;
|
|
32
|
+
};
|
|
33
|
+
export type PrintPlan = {
|
|
34
|
+
/** The score drawn onto the pages — a part or the marked full score, lenses applied. Draw slices from this, not the stored score. */
|
|
35
|
+
score: Score;
|
|
36
|
+
/** Passed to the renderer as the track filter; empty means every track. */
|
|
37
|
+
trackIds: readonly string[];
|
|
38
|
+
plan: LayoutPlan;
|
|
39
|
+
slices: PrintSystemSlice[];
|
|
40
|
+
/** Never an empty page. */
|
|
41
|
+
pages: PrintPage[];
|
|
42
|
+
/** In layout units, not millimetres. */
|
|
43
|
+
pageHeight: number;
|
|
44
|
+
renderOptions: ReturnType<typeof printRenderOptions>;
|
|
45
|
+
/** The player page turns were laid out for, or null for a whole score. */
|
|
46
|
+
turnTrackId: string | null;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Plan the printout of `score` (the **stored** score).
|
|
50
|
+
*
|
|
51
|
+
* - A part goes through `extractPart`: that track alone, written for its
|
|
52
|
+
* instrument (a clarinet a tone up), with the whole score's rehearsal marks,
|
|
53
|
+
* collapsed rests and cues. Page turns are laid out for that player.
|
|
54
|
+
* - The whole score stays in concert pitch — a conductor compares parts, so
|
|
55
|
+
* none may be transposed — gains rehearsal marks, and prints the visible
|
|
56
|
+
* tracks. Nobody turns for a dozen staves at once, so it has no turn track.
|
|
57
|
+
* - Both are drawn through `displayScore` in concert mode, which applies the
|
|
58
|
+
* octave-bracket lens: an `8va` is part of the notation, not a reading mode.
|
|
59
|
+
* (A part is already written pitch; the lens adds only the bracket.)
|
|
60
|
+
*
|
|
61
|
+
* Null when `scope` names a track the score does not have.
|
|
62
|
+
*/
|
|
63
|
+
export declare function printPlan(score: Score, options?: PrintPlanOptions): PrintPlan | null;
|
|
64
|
+
//# sourceMappingURL=print-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-plan.d.ts","sourceRoot":"","sources":["../src/print-plan.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAEL,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAo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
* is actually printed, its layout, the system slices and which of them go on
|
|
4
|
+
* which page.
|
|
5
|
+
*
|
|
6
|
+
* Both apps had written this, and each had half of it right. The web extracted
|
|
7
|
+
* a part for its instrument, added rehearsal marks and laid page turns out for
|
|
8
|
+
* one player only — but drew the stored score, so an `8va` printed an octave
|
|
9
|
+
* off. The native app drew through `displayScore` and dropped empty pages — but
|
|
10
|
+
* printed every track in concert pitch with no marks, and laid turns out for the
|
|
11
|
+
* first track even across a whole score. This is the union, with the web's
|
|
12
|
+
* rules wherever the two disagreed.
|
|
13
|
+
*
|
|
14
|
+
* Pure: no renderer, no DOM, no Skia. Each app still owns how a slice reaches
|
|
15
|
+
* paper (the web scales canvases under a print stylesheet; the native app hands
|
|
16
|
+
* page images to the platform's print service).
|
|
17
|
+
*/
|
|
18
|
+
import { displayScore, extractPart, withRehearsalMarks, } from '@sudobility/music_types';
|
|
19
|
+
import { computeLayout } from './layout.js';
|
|
20
|
+
import { PAPER_ORIENTATIONS, PAPER_SIZES, paginate, usablePageHeight, } from './pagination.js';
|
|
21
|
+
import { PRINT_WIDTH, printRenderOptions, printSystems, } from './print-layout.js';
|
|
22
|
+
const PAPER_LABEL_KEY = {
|
|
23
|
+
a4: 'print.paperA4',
|
|
24
|
+
letter: 'print.paperLetter',
|
|
25
|
+
legal: 'print.paperLegal',
|
|
26
|
+
};
|
|
27
|
+
/** The CSS `@page { size }` keyword for each paper. */
|
|
28
|
+
const PAPER_CSS = {
|
|
29
|
+
a4: 'A4',
|
|
30
|
+
letter: 'letter',
|
|
31
|
+
legal: 'legal',
|
|
32
|
+
};
|
|
33
|
+
const ORIENTATION_LABEL_KEY = {
|
|
34
|
+
portrait: 'print.portrait',
|
|
35
|
+
landscape: 'print.landscape',
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The paper picker. `css` is the `@page` size keyword; an orientation's value
|
|
39
|
+
* is its own CSS keyword already.
|
|
40
|
+
*
|
|
41
|
+
* A4 has a key like the others even though it reads "A4" in both languages —
|
|
42
|
+
* one shape for every entry is what lets a picker map straight through, and the
|
|
43
|
+
* locales list it as shared by design.
|
|
44
|
+
*/
|
|
45
|
+
export const PAPER_OPTIONS = PAPER_SIZES.map(value => ({
|
|
46
|
+
value,
|
|
47
|
+
labelKey: PAPER_LABEL_KEY[value],
|
|
48
|
+
css: PAPER_CSS[value],
|
|
49
|
+
}));
|
|
50
|
+
export const ORIENTATION_OPTIONS = PAPER_ORIENTATIONS.map(value => ({
|
|
51
|
+
value,
|
|
52
|
+
labelKey: ORIENTATION_LABEL_KEY[value],
|
|
53
|
+
}));
|
|
54
|
+
/** The whole score, as against one track's id. */
|
|
55
|
+
export const WHOLE_SCORE = 'score';
|
|
56
|
+
/**
|
|
57
|
+
* Plan the printout of `score` (the **stored** score).
|
|
58
|
+
*
|
|
59
|
+
* - A part goes through `extractPart`: that track alone, written for its
|
|
60
|
+
* instrument (a clarinet a tone up), with the whole score's rehearsal marks,
|
|
61
|
+
* collapsed rests and cues. Page turns are laid out for that player.
|
|
62
|
+
* - The whole score stays in concert pitch — a conductor compares parts, so
|
|
63
|
+
* none may be transposed — gains rehearsal marks, and prints the visible
|
|
64
|
+
* tracks. Nobody turns for a dozen staves at once, so it has no turn track.
|
|
65
|
+
* - Both are drawn through `displayScore` in concert mode, which applies the
|
|
66
|
+
* octave-bracket lens: an `8va` is part of the notation, not a reading mode.
|
|
67
|
+
* (A part is already written pitch; the lens adds only the bracket.)
|
|
68
|
+
*
|
|
69
|
+
* Null when `scope` names a track the score does not have.
|
|
70
|
+
*/
|
|
71
|
+
export function printPlan(score, options = {}) {
|
|
72
|
+
const scope = options.scope ?? WHOLE_SCORE;
|
|
73
|
+
const paper = options.paper ?? 'a4';
|
|
74
|
+
const orientation = options.orientation ?? 'portrait';
|
|
75
|
+
const isPart = scope !== WHOLE_SCORE;
|
|
76
|
+
const source = isPart ? extractPart(score, scope) : withRehearsalMarks(score);
|
|
77
|
+
if (!source)
|
|
78
|
+
return null;
|
|
79
|
+
const printed = displayScore(source);
|
|
80
|
+
const trackIds = isPart
|
|
81
|
+
? [scope]
|
|
82
|
+
: [...(options.visibleTrackIds ?? [])];
|
|
83
|
+
const renderOptions = printRenderOptions(trackIds);
|
|
84
|
+
const plan = computeLayout(printed, renderOptions);
|
|
85
|
+
const pageHeight = usablePageHeight(paper, orientation, PRINT_WIDTH);
|
|
86
|
+
const turnTrack = isPart ? printed.tracks[0] : undefined;
|
|
87
|
+
const pages = paginate(plan, pageHeight, turnTrack).filter(
|
|
88
|
+
// A page holding no systems is a page turn onto silence.
|
|
89
|
+
page => page.systemIndices.length > 0);
|
|
90
|
+
return {
|
|
91
|
+
score: printed,
|
|
92
|
+
trackIds,
|
|
93
|
+
plan,
|
|
94
|
+
slices: printSystems(plan),
|
|
95
|
+
pages,
|
|
96
|
+
pageHeight,
|
|
97
|
+
renderOptions,
|
|
98
|
+
turnTrackId: turnTrack?.id ?? null,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=print-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-plan.js","sourceRoot":"","sources":["../src/print-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,YAAY,EACZ,WAAW,EACX,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,MAAM,eAAe,GAA8B;IACjD,EAAE,EAAE,eAAe;IACnB,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE,kBAAkB;CAC1B,CAAC;AAEF,uDAAuD;AACvD,MAAM,SAAS,GAA8B;IAC3C,EAAE,EAAE,IAA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AC,CAAC,KAAK,CAAC;QACT,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACrE,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEzD,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,MAAM;IACxD,yDAAyD;IACzD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CACtC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,OAAO;QACd,QAAQ;QACR,IAAI;QACJ,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC;QAC1B,KAAK;QACL,UAAU;QACV,aAAa;QACb,WAAW,EAAE,SAAS,EAAE,EAAE,IAAI,IAAI;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-theme.d.ts","sourceRoot":"","sources":["../src/render-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"render-theme.d.ts","sourceRoot":"","sources":["../src/render-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,kBAAkB,EAAE,WAahC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAkB/B,CAAC"}
|
package/dist/render-theme.js
CHANGED
|
@@ -5,10 +5,12 @@ export const LIGHT_RENDER_THEME = {
|
|
|
5
5
|
noteSelected: '#6d28d9',
|
|
6
6
|
noteRegenerated: '#8b5a2b',
|
|
7
7
|
notePlaying: '#1565c0',
|
|
8
|
-
noteOutOfRange: '#
|
|
8
|
+
noteOutOfRange: '#ea580c',
|
|
9
9
|
staveActive: '#000000',
|
|
10
10
|
staveInactive: '#71717a',
|
|
11
11
|
caret: '#d32f2f',
|
|
12
|
+
keyboardLit: '#1565c0',
|
|
13
|
+
keyboardSelected: '#6d28d9',
|
|
12
14
|
};
|
|
13
15
|
export const DARK_RENDER_THEME = {
|
|
14
16
|
foreground: '#d4d4d8',
|
|
@@ -17,9 +19,16 @@ export const DARK_RENDER_THEME = {
|
|
|
17
19
|
noteSelected: '#a78bfa',
|
|
18
20
|
noteRegenerated: '#d9a066',
|
|
19
21
|
notePlaying: '#64b5f6',
|
|
20
|
-
|
|
22
|
+
/*
|
|
23
|
+
Saturated rather than the lighter `#fb923c` it was: that sat beside
|
|
24
|
+
`noteRegenerated`'s `#d9a066` closely enough that a regenerated note and one
|
|
25
|
+
the instrument cannot play were hard to tell apart on a dark stave.
|
|
26
|
+
*/
|
|
27
|
+
noteOutOfRange: '#f97316',
|
|
21
28
|
staveActive: '#ffffff',
|
|
22
29
|
staveInactive: '#8a8a93',
|
|
23
30
|
caret: '#ef5350',
|
|
31
|
+
keyboardLit: '#64b5f6',
|
|
32
|
+
keyboardSelected: '#a78bfa',
|
|
24
33
|
};
|
|
25
34
|
//# sourceMappingURL=render-theme.js.map
|
package/dist/render-theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-theme.js","sourceRoot":"","sources":["../src/render-theme.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,SAAS;IAC1B,WAAW,EAAE,SAAS;IACtB,cAAc,EAAE,SAAS;IACzB,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,SAAS;IACxB,KAAK,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"render-theme.js","sourceRoot":"","sources":["../src/render-theme.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,SAAS;IAC1B,WAAW,EAAE,SAAS;IACtB,cAAc,EAAE,SAAS;IACzB,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,SAAS;IACxB,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,SAAS;IACtB,gBAAgB,EAAE,SAAS;CAC5B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAgB;IAC5C,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,SAAS;IAC1B,WAAW,EAAE,SAAS;IACtB;;;;MAIE;IACF,cAAc,EAAE,SAAS;IACzB,WAAW,EAAE,SAAS;IACtB,aAAa,EAAE,SAAS;IACxB,KAAK,EAAE,SAAS;IAChB,WAAW,EAAE,SAAS;IACtB,gBAAgB,EAAE,SAAS;CAC5B,CAAC"}
|