vexflow-native 1.3.0 → 1.4.1
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 +16 -1
- package/lib/module/base/FontManager.js +0 -0
- package/lib/module/base/FontManager.js.map +1 -1
- package/lib/module/base/VexflowRecordingIndex.js +13 -0
- package/lib/module/base/VexflowRecordingIndex.js.map +1 -0
- package/lib/module/base/VexflowRecordingReplay.js +58 -15
- package/lib/module/base/VexflowRecordingReplay.js.map +1 -1
- package/lib/module/base/index.js +2 -0
- package/lib/module/base/index.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js +81 -0
- package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js +54 -0
- package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js.map +1 -0
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +54 -151
- package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/index.js +3 -1
- package/lib/module/renderer/ScoreRenderer/index.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/useScoreScroll.js +3 -1
- package/lib/module/renderer/ScoreRenderer/useScoreScroll.js.map +1 -1
- package/lib/module/renderer/ScoreRenderer/utils.js +207 -0
- package/lib/module/renderer/ScoreRenderer/utils.js.map +1 -0
- package/lib/module/renderer/index.js +1 -0
- package/lib/module/renderer/index.js.map +1 -1
- package/lib/module/renderer/render.js +5 -1
- package/lib/module/renderer/render.js.map +1 -1
- package/lib/module/renderer/scale.js +5 -1
- package/lib/module/renderer/scale.js.map +1 -1
- package/lib/module/renderer/useScoreRecording.js +9 -7
- package/lib/module/renderer/useScoreRecording.js.map +1 -1
- package/lib/module/shared/debug.js +24 -0
- package/lib/module/shared/debug.js.map +1 -0
- package/lib/typescript/src/base/FontManager.d.ts +3 -0
- package/lib/typescript/src/base/FontManager.d.ts.map +1 -1
- package/lib/typescript/src/base/VexflowRecordingIndex.d.ts +4 -0
- package/lib/typescript/src/base/VexflowRecordingIndex.d.ts.map +1 -0
- package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +8 -1
- package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -1
- package/lib/typescript/src/base/index.d.ts +2 -0
- package/lib/typescript/src/base/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts +11 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.d.ts +32 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.d.ts.map +1 -0
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +1 -17
- package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts +3 -1
- package/lib/typescript/src/renderer/ScoreRenderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +35 -2
- package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts +5 -1
- package/lib/typescript/src/renderer/ScoreRenderer/useScoreScroll.d.ts.map +1 -1
- package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts +40 -0
- package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts.map +1 -0
- package/lib/typescript/src/renderer/index.d.ts +1 -0
- package/lib/typescript/src/renderer/index.d.ts.map +1 -1
- package/lib/typescript/src/renderer/render.d.ts.map +1 -1
- package/lib/typescript/src/renderer/scale.d.ts.map +1 -1
- package/lib/typescript/src/renderer/types.d.ts +63 -3
- package/lib/typescript/src/renderer/types.d.ts.map +1 -1
- package/lib/typescript/src/renderer/useScoreRecording.d.ts +6 -0
- package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
- package/lib/typescript/src/shared/debug.d.ts +3 -0
- package/lib/typescript/src/shared/debug.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/base/FontManager.ts +0 -0
- package/src/base/VexflowRecordingIndex.ts +21 -0
- package/src/base/VexflowRecordingReplay.ts +103 -19
- package/src/base/index.ts +9 -0
- package/src/renderer/ScoreRenderer/ScoreOverlayPicture.tsx +118 -0
- package/src/renderer/ScoreRenderer/ScorePlayhead.tsx +123 -0
- package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +86 -206
- package/src/renderer/ScoreRenderer/index.ts +3 -1
- package/src/renderer/ScoreRenderer/types.ts +48 -2
- package/src/renderer/ScoreRenderer/useScoreScroll.ts +7 -1
- package/src/renderer/ScoreRenderer/utils.ts +285 -0
- package/src/renderer/index.ts +5 -0
- package/src/renderer/render.tsx +4 -0
- package/src/renderer/scale.ts +4 -0
- package/src/renderer/types.ts +67 -3
- package/src/renderer/useScoreRecording.ts +18 -9
- package/src/shared/debug.ts +27 -0
package/README.md
CHANGED
|
@@ -332,8 +332,23 @@ export function DirectVexFlow() {
|
|
|
332
332
|
- `scrollEnabled`: enables or disables pan scrolling. Defaults to `true`.
|
|
333
333
|
- `showScrollbars`: shows scrollbars when the score overflows. Defaults to
|
|
334
334
|
`true`.
|
|
335
|
+
- `scrollOffset`: optional controlled Reanimated shared value for the scroll
|
|
336
|
+
position along the renderer's axis. The renderer reads and writes it (pan
|
|
337
|
+
gesture, clamping), and external writes move the content — the seam for
|
|
338
|
+
playback auto-scroll. Must stay the same shared value for the component's
|
|
339
|
+
lifetime.
|
|
340
|
+
- `playhead`: optional Reanimated shared value positioning a playhead overlay
|
|
341
|
+
(`{ x, y, height }` in `onItemsLayout` coordinates, `null` hides it). The
|
|
342
|
+
overlay tracks scrolling on the UI thread without re-recording the score.
|
|
343
|
+
- `playheadStyle`: optional playhead appearance (`color`, `width`,
|
|
344
|
+
`borderRadius`, `opacity`); defaults derive from the color scheme
|
|
345
|
+
foreground.
|
|
346
|
+
- `onScrollGeometry`: optional callback fired when the scroll envelope
|
|
347
|
+
changes (`axis`, `viewportSize`, `contentSize`, `maxScroll`) — everything a
|
|
348
|
+
consumer needs to compute follow-scroll targets.
|
|
335
349
|
- `onItemsLayout`: optional callback fired after each recording pass with the
|
|
336
|
-
view-space geometry (at scroll offset 0) of rendered items and measures
|
|
350
|
+
view-space geometry (at scroll offset 0) of rendered items and measures,
|
|
351
|
+
including each measure's system band `y`/`height`.
|
|
337
352
|
|
|
338
353
|
## Contributing
|
|
339
354
|
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FontWeight","FontSlant","FontWidth","Skia","PT_TO_PX","parseSize","size","match","trim","value","parseFloat","unit","parseWeight","weight","weightStr","String","toLowerCase","Normal","Bold","Thin","ExtraLight","Light","Medium","SemiBold","ExtraBold","Black","parseSlant","style","styleStr","normal","Upright","italic","Italic","oblique","Oblique","FontManager","__workletClass","constructor","fontProvider","defaultFontName","families","i","countFamilies","push","getFamilyName","includes","Error","join","
|
|
1
|
+
{"version":3,"names":["FontWeight","FontSlant","FontWidth","Skia","PT_TO_PX","parseSize","size","match","trim","value","parseFloat","unit","parseWeight","weight","weightStr","String","toLowerCase","Normal","Bold","Thin","ExtraLight","Light","Medium","SemiBold","ExtraBold","Black","parseSlant","style","styleStr","normal","Upright","italic","Italic","oblique","Oblique","FontManager","__workletClass","familyMatchCache","skFontCache","constructor","fontProvider","defaultFontName","families","i","countFamilies","push","getFamilyName","includes","Error","join","familiesLower","map","family","isFamilyAvailable","getFamiliesFromFont","font","split","f","matchFontFamilyName","cacheKey","cached","matched","resolveFontDescriptor","slant","width","createSkFont","resolvedSize","resolvedWeight","typeface","matchFamilyStyle","skFont","Font"],"sourceRoot":"../../../src","sources":["base/FontManager.ts"],"mappings":";;AACA,SACEA,UAAU,EACVC,SAAS,EACTC,SAAS,EACTC,IAAI,QACC,4BAA4B;;AAMnC;;AA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CAAC;IACH;IAEA,MAAMO,MAAM,GAAGnE,IAAI,CAACoE,IAAI,CAACH,QAAQ,EAAEF,YAAY,GAAG9D,QAAQ,CAAC,CAAC,CAAC;IAC7D,IAAI,CAACkC,WAAW,CAACqB,QAAQ,CAAC,GAAGW,MAAM;IACnC,OAAOA,MAAM;EACf;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function buildVexflowGroupIndex(commands) {
|
|
4
|
+
const index = {};
|
|
5
|
+
for (const command of commands) {
|
|
6
|
+
if (command.groupId == null) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
(index[command.groupId] ??= []).push(command);
|
|
10
|
+
}
|
|
11
|
+
return index;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=VexflowRecordingIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["buildVexflowGroupIndex","commands","index","command","groupId","push"],"sourceRoot":"../../../src","sources":["base/VexflowRecordingIndex.ts"],"mappings":";;AAMA,OAAO,SAASA,sBAAsBA,CACpCC,QAA4C,EAChB;EAC5B,MAAMC,KAAgD,GAAG,CAAC,CAAC;EAE3D,KAAK,MAAMC,OAAO,IAAIF,QAAQ,EAAE;IAC9B,IAAIE,OAAO,CAACC,OAAO,IAAI,IAAI,EAAE;MAC3B;IACF;IAEA,CAACF,KAAK,CAACC,OAAO,CAACC,OAAO,CAAC,KAAK,EAAE,EAAEC,IAAI,CAACF,OAAO,CAAC;EAC/C;EAEA,OAAOD,KAAK;AACd","ignoreList":[]}
|
|
@@ -14,20 +14,34 @@ function shadowBlurToSigma(shadowBlur) {
|
|
|
14
14
|
return shadowBlur / 2;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Per-replay `css color -> SkColor` cache: a recording uses a handful of
|
|
19
|
+
* distinct colors but references them thousands of times.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function getCachedColor(color, cache) {
|
|
23
|
+
'worklet';
|
|
24
|
+
|
|
25
|
+
return cache[color] ??= Skia.Color(color);
|
|
26
|
+
}
|
|
27
|
+
|
|
17
28
|
/**
|
|
18
29
|
* Apply the recorded glow (CSS shadow) to a Skia paint as a drop-shadow image
|
|
19
30
|
* filter. `dx = dy = 0` turns the drop shadow into a symmetric glow centred on
|
|
20
31
|
* the ink; `MakeDropShadow` (not `…Only`) keeps the source content, so the note
|
|
21
32
|
* still draws on top of its halo. No-op unless a `shadowColor` resolved.
|
|
22
33
|
*/
|
|
23
|
-
function applyGlow(skPaint, paint) {
|
|
34
|
+
function applyGlow(skPaint, paint, colorCache) {
|
|
24
35
|
'worklet';
|
|
25
36
|
|
|
26
37
|
if (paint.shadowColor == null) {
|
|
38
|
+
// Pooled paints carry state between commands — explicitly clear a filter
|
|
39
|
+
// a previous command may have set.
|
|
40
|
+
skPaint.setImageFilter(null);
|
|
27
41
|
return;
|
|
28
42
|
}
|
|
29
43
|
const sigma = shadowBlurToSigma(paint.shadowBlur ?? 0);
|
|
30
|
-
skPaint.setImageFilter(Skia.ImageFilter.MakeDropShadow(0, 0, sigma, sigma,
|
|
44
|
+
skPaint.setImageFilter(Skia.ImageFilter.MakeDropShadow(0, 0, sigma, sigma, getCachedColor(paint.shadowColor, colorCache)));
|
|
31
45
|
}
|
|
32
46
|
function toSkiaRect(rect) {
|
|
33
47
|
'worklet';
|
|
@@ -47,28 +61,48 @@ function mapRecordingLineCap(cap) {
|
|
|
47
61
|
return StrokeCap.Butt;
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
|
-
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* One fill and one stroke paint are pooled per replay call and reconfigured
|
|
67
|
+
* per command — Skia snapshots paint state into the canvas/display list at
|
|
68
|
+
* each draw call, so mutating the pooled paint afterwards is safe. Optional
|
|
69
|
+
* state (glow filter, dash effect) is explicitly reset on every configure so
|
|
70
|
+
* nothing bleeds between commands.
|
|
71
|
+
*/
|
|
72
|
+
function createPooledFillPaint() {
|
|
51
73
|
'worklet';
|
|
52
74
|
|
|
53
75
|
const skPaint = Skia.Paint();
|
|
54
76
|
skPaint.setStyle(PaintStyle.Fill);
|
|
55
77
|
skPaint.setAntiAlias(true);
|
|
56
|
-
skPaint.setColor(Skia.Color(paint.color));
|
|
57
|
-
applyGlow(skPaint, paint);
|
|
58
78
|
return skPaint;
|
|
59
79
|
}
|
|
60
|
-
function
|
|
80
|
+
function createPooledStrokePaint() {
|
|
61
81
|
'worklet';
|
|
62
82
|
|
|
63
83
|
const skPaint = Skia.Paint();
|
|
64
84
|
skPaint.setStyle(PaintStyle.Stroke);
|
|
65
85
|
skPaint.setAntiAlias(true);
|
|
66
|
-
skPaint
|
|
86
|
+
return skPaint;
|
|
87
|
+
}
|
|
88
|
+
function configureFillPaint(skPaint, paint, colorCache) {
|
|
89
|
+
'worklet';
|
|
90
|
+
|
|
91
|
+
skPaint.setColor(getCachedColor(paint.color, colorCache));
|
|
92
|
+
applyGlow(skPaint, paint, colorCache);
|
|
93
|
+
return skPaint;
|
|
94
|
+
}
|
|
95
|
+
function configureStrokePaint(skPaint, paint, colorCache) {
|
|
96
|
+
'worklet';
|
|
97
|
+
|
|
98
|
+
skPaint.setColor(getCachedColor(paint.color, colorCache));
|
|
67
99
|
skPaint.setStrokeWidth(paint.strokeWidth ?? 1);
|
|
68
100
|
skPaint.setStrokeCap(mapRecordingLineCap(paint.strokeCap ?? 'butt'));
|
|
69
|
-
applyGlow(skPaint, paint);
|
|
101
|
+
applyGlow(skPaint, paint, colorCache);
|
|
70
102
|
if (paint.lineDash != null && paint.lineDash.length > 0) {
|
|
71
103
|
skPaint.setPathEffect(Skia.PathEffect.MakeDash(paint.lineDash));
|
|
104
|
+
} else {
|
|
105
|
+
skPaint.setPathEffect(null);
|
|
72
106
|
}
|
|
73
107
|
return skPaint;
|
|
74
108
|
}
|
|
@@ -167,14 +201,23 @@ export function renderVexflowRecordingCommands(canvas, commands, fontProvider, d
|
|
|
167
201
|
* colours, a glow (shadow), and a stroke dash are all expressible. Omit for a
|
|
168
202
|
* byte-identical replay of the recorded style.
|
|
169
203
|
*/
|
|
170
|
-
styleOverrides
|
|
204
|
+
styleOverrides,
|
|
205
|
+
/**
|
|
206
|
+
* Optional pre-built FontManager to reuse across replays so its SkFont /
|
|
207
|
+
* family caches survive between calls (e.g. one overlay replay per note).
|
|
208
|
+
* Omitted, one is constructed per call — the original behavior.
|
|
209
|
+
*/
|
|
210
|
+
replayFontManager) {
|
|
171
211
|
'worklet';
|
|
172
212
|
|
|
173
|
-
const fontManager = new FontManager(fontProvider, defaultFont);
|
|
213
|
+
const fontManager = replayFontManager ?? new FontManager(fontProvider, defaultFont);
|
|
214
|
+
const colorCache = {};
|
|
215
|
+
const fillPaint = createPooledFillPaint();
|
|
216
|
+
const strokePaint = createPooledStrokePaint();
|
|
174
217
|
for (const command of commands) {
|
|
175
218
|
switch (command.type) {
|
|
176
219
|
case 'clear':
|
|
177
|
-
canvas.clear(
|
|
220
|
+
canvas.clear(getCachedColor(command.color, colorCache));
|
|
178
221
|
break;
|
|
179
222
|
case 'save':
|
|
180
223
|
canvas.save();
|
|
@@ -192,19 +235,19 @@ styleOverrides) {
|
|
|
192
235
|
canvas.clipRect(toSkiaRect(command.rect), ClipOp.Intersect, true);
|
|
193
236
|
break;
|
|
194
237
|
case 'fillRect':
|
|
195
|
-
canvas.drawRect(toSkiaRect(command.rect),
|
|
238
|
+
canvas.drawRect(toSkiaRect(command.rect), configureFillPaint(fillPaint, resolveStyle(command.paint, command.groupId, 'fill', styleOverrides), colorCache));
|
|
196
239
|
break;
|
|
197
240
|
case 'clearRect':
|
|
198
241
|
canvas.drawRect(toSkiaRect(command.rect), createClearPaint());
|
|
199
242
|
break;
|
|
200
243
|
case 'fillPath':
|
|
201
|
-
canvas.drawPath(buildPath(command.path),
|
|
244
|
+
canvas.drawPath(buildPath(command.path), configureFillPaint(fillPaint, resolveStyle(command.paint, command.groupId, 'fill', styleOverrides), colorCache));
|
|
202
245
|
break;
|
|
203
246
|
case 'strokePath':
|
|
204
|
-
canvas.drawPath(buildPath(command.path),
|
|
247
|
+
canvas.drawPath(buildPath(command.path), configureStrokePaint(strokePaint, resolveStyle(command.paint, command.groupId, 'stroke', styleOverrides), colorCache));
|
|
205
248
|
break;
|
|
206
249
|
case 'fillText':
|
|
207
|
-
canvas.drawText(command.text, command.x, command.y,
|
|
250
|
+
canvas.drawText(command.text, command.x, command.y, configureFillPaint(fillPaint, resolveStyle(command.paint, command.groupId, 'fill', styleOverrides), colorCache), createFont(fontManager, command.font));
|
|
208
251
|
break;
|
|
209
252
|
default:
|
|
210
253
|
assertNever(command);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlendMode","ClipOp","PaintStyle","Skia","StrokeCap","FontManager","shadowBlurToSigma","shadowBlur","applyGlow","skPaint","paint","
|
|
1
|
+
{"version":3,"names":["BlendMode","ClipOp","PaintStyle","Skia","StrokeCap","FontManager","shadowBlurToSigma","shadowBlur","getCachedColor","color","cache","Color","applyGlow","skPaint","paint","colorCache","shadowColor","setImageFilter","sigma","ImageFilter","MakeDropShadow","toSkiaRect","rect","XYWHRect","x","y","width","height","mapRecordingLineCap","cap","Round","Square","Butt","createPooledFillPaint","Paint","setStyle","Fill","setAntiAlias","createPooledStrokePaint","Stroke","configureFillPaint","setColor","configureStrokePaint","setStrokeWidth","strokeWidth","setStrokeCap","strokeCap","lineDash","length","setPathEffect","PathEffect","MakeDash","createClearPaint","clearPaint","setBlendMode","Clear","resolveStyle","groupId","kind","styleOverrides","override","fillColor","strokeColor","createFont","fontManager","font","createSkFont","size","weight","style","assertNever","value","Error","String","applyPathCommand","builder","command","type","moveTo","lineTo","cubicTo","cp1x","cp1y","cp2x","cp2y","quadTo","cpx","cpy","addRect","addArc","startDegrees","sweepDegrees","close","buildPath","path","PathBuilder","Make","build","renderVexflowRecordingCommands","canvas","commands","fontProvider","defaultFont","replayFontManager","fillPaint","strokePaint","clear","save","restore","scale","translate","clipRect","Intersect","drawRect","drawPath","drawText","text"],"sourceRoot":"../../../src","sources":["base/VexflowRecordingReplay.ts"],"mappings":";;AAAA,SACEA,SAAS,EACTC,MAAM,EACNC,UAAU,EACVC,IAAI,EACJC,SAAS,QAMJ,4BAA4B;AAEnC,OAAOC,WAAW,MAAM,kBAAe;AAWvC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACC,UAAkB,EAAU;EACrD,SAAS;;EAET,OAAOA,UAAU,GAAG,CAAC;AACvB;;AAEA;AACA;AACA;AACA;;AAGA,SAASC,cAAcA,CAACC,KAAa,EAAEC,KAAmB,EAAW;EACnE,SAAS;;EAET,OAAQA,KAAK,CAACD,KAAK,CAAC,KAAKN,IAAI,CAACQ,KAAK,CAACF,KAAK,CAAC;AAC5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,SAASA,CAChBC,OAAgB,EAChBC,KAA4B,EAC5BC,UAAwB,EACxB;EACA,SAAS;;EAET,IAAID,KAAK,CAACE,WAAW,IAAI,IAAI,EAAE;IAC7B;IACA;IACAH,OAAO,CAACI,cAAc,CAAC,IAAI,CAAC;IAC5B;EACF;EAEA,MAAMC,KAAK,GAAGZ,iBAAiB,CAACQ,KAAK,CAACP,UAAU,IAAI,CAAC,CAAC;EAEtDM,OAAO,CAACI,cAAc,CACpBd,IAAI,CAACgB,WAAW,CAACC,cAAc,CAC7B,CAAC,EACD,CAAC,EACDF,KAAK,EACLA,KAAK,EACLV,cAAc,CAACM,KAAK,CAACE,WAAW,EAAED,UAAU,CAC9C,CACF,CAAC;AACH;AAEA,SAASM,UAAUA,CAACC,IAA0B,EAAE;EAC9C,SAAS;;EAET,OAAOnB,IAAI,CAACoB,QAAQ,CAACD,IAAI,CAACE,CAAC,EAAEF,IAAI,CAACG,CAAC,EAAEH,IAAI,CAACI,KAAK,EAAEJ,IAAI,CAACK,MAAM,CAAC;AAC/D;AAEA,SAASC,mB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F,KAAK,YAAY;QACfoF,MAAM,CAACe,QAAQ,CACbrB,SAAS,CAACjB,OAAO,CAACkB,IAAI,CAAC,EACvBpD,oBAAoB,CAClB+D,WAAW,EACXjD,YAAY,CACVoB,OAAO,CAAC9D,KAAK,EACb8D,OAAO,CAACnB,OAAO,EACf,QAAQ,EACRE,cACF,CAAC,EACD5C,UACF,CACF,CAAC;QACD;MACF,KAAK,UAAU;QACboF,MAAM,CAACgB,QAAQ,CACbvC,OAAO,CAACwC,IAAI,EACZxC,OAAO,CAACpD,CAAC,EACToD,OAAO,CAACnD,CAAC,EACTe,kBAAkB,CAChBgE,SAAS,EACThD,YAAY,CACVoB,OAAO,CAAC9D,KAAK,EACb8D,OAAO,CAACnB,OAAO,EACf,MAAM,EACNE,cACF,CAAC,EACD5C,UACF,CAAC,EACDgD,UAAU,CAACC,WAAW,EAAEY,OAAO,CAACX,IAAI,CACtC,CAAC;QACD;MACF;QACEK,WAAW,CAACM,OAAO,CAAC;IACxB;EACF;AACF","ignoreList":[]}
|
package/lib/module/base/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
export { default as VexflowCanvas } from "./VexflowCanvas.js";
|
|
4
4
|
export { default as VexflowRecordingContext } from "./VexflowRecordingContext.js";
|
|
5
5
|
export { renderVexflowRecordingCommands } from "./VexflowRecordingReplay.js";
|
|
6
|
+
export { buildVexflowGroupIndex } from "./VexflowRecordingIndex.js";
|
|
6
7
|
export * from "./VexflowColorScheme.js";
|
|
7
8
|
export * from "./VexflowRecordingTypes.js";
|
|
8
9
|
export * from "./types.js";
|
|
10
|
+
export { isVexflowNativeDebugEnabled, setVexflowNativeDebugEnabled } from "../shared/debug.js";
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","VexflowCanvas","VexflowRecordingContext","renderVexflowRecordingCommands"],"sourceRoot":"../../../src","sources":["base/index.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,aAAa,QAAQ,oBAAiB;AAC1D,SAASD,OAAO,IAAIE,uBAAuB,QAAQ,8BAA2B;AAC9E,SAASC,8BAA8B,QAAQ,6BAA0B;
|
|
1
|
+
{"version":3,"names":["default","VexflowCanvas","VexflowRecordingContext","renderVexflowRecordingCommands","buildVexflowGroupIndex","isVexflowNativeDebugEnabled","setVexflowNativeDebugEnabled"],"sourceRoot":"../../../src","sources":["base/index.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,aAAa,QAAQ,oBAAiB;AAC1D,SAASD,OAAO,IAAIE,uBAAuB,QAAQ,8BAA2B;AAC9E,SAASC,8BAA8B,QAAQ,6BAA0B;AACzE,SACEC,sBAAsB,QAEjB,4BAAyB;AAEhC,cAAc,yBAAsB;AACpC,cAAc,4BAAyB;AACvC,cAAc,YAAS;AAEvB,SACEC,2BAA2B,EAC3BC,4BAA4B,QACvB,oBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { Picture } from '@shopify/react-native-skia';
|
|
5
|
+
import { runOnUI, useDerivedValue, useSharedValue } from 'react-native-reanimated';
|
|
6
|
+
import { isVexflowNativeDebugEnabled } from "../../shared/debug.js";
|
|
7
|
+
import { createScorePictureWorklet, disposeOverlayPictures, getEmptyOverlayPicture, getOverlayFontManager, logOverlayProfile, nowMsWorklet, retireOverlayPicture } from "./utils.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Draws the style-overridden items on top of the static base picture. Only
|
|
11
|
+
* the overridden groups' commands are re-recorded per override write — the
|
|
12
|
+
* full command array never reaches the UI runtime. Overridden items are drawn
|
|
13
|
+
* opaque over their base-colored twins at identical coordinates; with an
|
|
14
|
+
* opaque override color the result matches an in-place recolor up to a ≤1px
|
|
15
|
+
* anti-aliasing fringe of base ink at glyph edges.
|
|
16
|
+
*/
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
export default function ScoreOverlayPicture({
|
|
19
|
+
contentSize,
|
|
20
|
+
defaultFont,
|
|
21
|
+
fontManager,
|
|
22
|
+
groupIndex,
|
|
23
|
+
itemStyleOverrides
|
|
24
|
+
}) {
|
|
25
|
+
const emptyPicture = useMemo(getEmptyOverlayPicture, []);
|
|
26
|
+
// A FontManager instance cannot be serialized into a worklet closure, so
|
|
27
|
+
// each runtime lazily constructs its own in this slot (never crossing
|
|
28
|
+
// runtimes) — its SkFont caches still persist across onsets.
|
|
29
|
+
const fontManagerSlot = useSharedValue({
|
|
30
|
+
manager: null
|
|
31
|
+
});
|
|
32
|
+
const disposal = useSharedValue({
|
|
33
|
+
prev: null,
|
|
34
|
+
pending: []
|
|
35
|
+
});
|
|
36
|
+
const profile = useSharedValue({
|
|
37
|
+
windowStartMs: 0,
|
|
38
|
+
maxMs: 0,
|
|
39
|
+
count: 0
|
|
40
|
+
});
|
|
41
|
+
// Read on JS and captured: the debug singleton lives on the JS runtime, so
|
|
42
|
+
// a toggle takes effect on the overlay's next render.
|
|
43
|
+
const enableProfiling = isVexflowNativeDebugEnabled();
|
|
44
|
+
const picture = useDerivedValue(() => {
|
|
45
|
+
const overrides = itemStyleOverrides.value;
|
|
46
|
+
let commands = null;
|
|
47
|
+
for (const groupId in overrides) {
|
|
48
|
+
const group = groupIndex[groupId];
|
|
49
|
+
if (group != null) {
|
|
50
|
+
(commands ??= []).push(...group);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (commands == null) {
|
|
54
|
+
retireOverlayPicture(disposal, null);
|
|
55
|
+
return emptyPicture;
|
|
56
|
+
}
|
|
57
|
+
const start = enableProfiling ? nowMsWorklet() : 0;
|
|
58
|
+
const next = createScorePictureWorklet({
|
|
59
|
+
contentSize,
|
|
60
|
+
defaultFont,
|
|
61
|
+
fontManager,
|
|
62
|
+
recordedCommands: commands,
|
|
63
|
+
replayFontManager: getOverlayFontManager(fontManagerSlot, fontManager, defaultFont),
|
|
64
|
+
styleOverrides: overrides
|
|
65
|
+
});
|
|
66
|
+
if (enableProfiling) {
|
|
67
|
+
logOverlayProfile(profile, commands.length, nowMsWorklet() - start);
|
|
68
|
+
}
|
|
69
|
+
retireOverlayPicture(disposal, next);
|
|
70
|
+
return next;
|
|
71
|
+
}, [contentSize, defaultFont, disposal, emptyPicture, enableProfiling, fontManager, fontManagerSlot, groupIndex, itemStyleOverrides, profile]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
return () => {
|
|
74
|
+
runOnUI(disposeOverlayPictures)(disposal);
|
|
75
|
+
};
|
|
76
|
+
}, [disposal]);
|
|
77
|
+
return /*#__PURE__*/_jsx(Picture, {
|
|
78
|
+
picture: picture
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=ScoreOverlayPicture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Picture","runOnUI","useDerivedValue","useSharedValue","isVexflowNativeDebugEnabled","createScorePictureWorklet","disposeOverlayPictures","getEmptyOverlayPicture","getOverlayFontManager","logOverlayProfile","nowMsWorklet","retireOverlayPicture","jsx","_jsx","ScoreOverlayPicture","contentSize","defaultFont","fontManager","groupIndex","itemStyleOverrides","emptyPicture","fontManagerSlot","manager","disposal","prev","pending","profile","windowStartMs","maxMs","count","enableProfiling","picture","overrides","value","commands","groupId","group","push","start","next","recordedCommands","replayFontManager","styleOverrides","length"],"sourceRoot":"../../../../src","sources":["renderer/ScoreRenderer/ScoreOverlayPicture.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1C,SAASC,OAAO,QAAwB,4BAA4B;AACpE,SACEC,OAAO,EACPC,eAAe,EACfC,cAAc,QACT,yBAAyB;AAGhC,SAASC,2BAA2B,QAAQ,uBAAoB;AAOhE,SACEC,yBAAyB,EACzBC,sBAAsB,EACtBC,sBAAsB,EACtBC,qBAAqB,EACrBC,iBAAiB,EACj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,CAAC;MACrCU,WAAW;MACXC,WAAW;MACXC,WAAW;MACXuB,gBAAgB,EAAEN,QAAQ;MAC1BO,iBAAiB,EAAEjC,qBAAqB,CACtCa,eAAe,EACfJ,WAAW,EACXD,WACF,CAAC;MACD0B,cAAc,EAAEV;IAClB,CAAC,CAAC;IAEF,IAAIF,eAAe,EAAE;MACnBrB,iBAAiB,CAACiB,OAAO,EAAEQ,QAAQ,CAACS,MAAM,EAAEjC,YAAY,CAAC,CAAC,GAAG4B,KAAK,CAAC;IACrE;IAEA3B,oBAAoB,CAACY,QAAQ,EAAEgB,IAAI,CAAC;IACpC,OAAOA,IAAI;EACb,CAAC,EAAE,CACDxB,WAAW,EACXC,WAAW,EACXO,QAAQ,EACRH,YAAY,EACZU,eAAe,EACfb,WAAW,EACXI,eAAe,EACfH,UAAU,EACVC,kBAAkB,EAClBO,OAAO,CACR,CAAC;EAEF5B,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXG,OAAO,CAACK,sBAAsB,CAAC,CAACiB,QAAQ,CAAC;IAC3C,CAAC;EACH,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,oBAAOV,IAAA,CAACb,OAAO;IAAC+B,OAAO,EAAEA;EAAQ,CAAE,CAAC;AACtC","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { RoundedRect, Skia } from '@shopify/react-native-skia';
|
|
5
|
+
import { useDerivedValue } from 'react-native-reanimated';
|
|
6
|
+
import { createVisibleViewport } from "../viewport.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export function resolvePlayheadStyle(style, foreground) {
|
|
9
|
+
const width = style?.width ?? 2;
|
|
10
|
+
return {
|
|
11
|
+
color: style?.color ?? foreground,
|
|
12
|
+
width,
|
|
13
|
+
borderRadius: style?.borderRadius ?? width / 2,
|
|
14
|
+
opacity: style?.opacity ?? 0.9
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Maps a playhead state (view space at scroll offset 0) to the on-screen
|
|
20
|
+
* rect: the scroll translation along the active axis is subtracted, the
|
|
21
|
+
* render scale is NOT applied — itemsLayout coordinates are already view
|
|
22
|
+
* space. A null state collapses to a zero rect (declarative Skia cannot
|
|
23
|
+
* unmount from the UI thread; a zero rect draws nothing).
|
|
24
|
+
*/
|
|
25
|
+
export function createPlayheadRect(state, scrollOffset, rendererType, viewportSize, contentSize, width, borderRadius) {
|
|
26
|
+
'worklet';
|
|
27
|
+
|
|
28
|
+
if (!state) {
|
|
29
|
+
return Skia.RRectXY(Skia.XYWHRect(0, 0, 0, 0), 0, 0);
|
|
30
|
+
}
|
|
31
|
+
const visible = createVisibleViewport(scrollOffset, rendererType, viewportSize, contentSize);
|
|
32
|
+
return Skia.RRectXY(Skia.XYWHRect(state.x - width / 2 - visible.x, state.y - visible.y, width, state.height), borderRadius, borderRadius);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The playback position line, drawn over the notation inside the viewport
|
|
36
|
+
* clip. Follows scrolling on the UI thread without re-recording the score. */
|
|
37
|
+
const ScorePlayhead = ({
|
|
38
|
+
playhead,
|
|
39
|
+
scrollOffset,
|
|
40
|
+
rendererType,
|
|
41
|
+
viewportSize,
|
|
42
|
+
contentSize,
|
|
43
|
+
style
|
|
44
|
+
}) => {
|
|
45
|
+
const rect = useDerivedValue(() => createPlayheadRect(playhead.value, scrollOffset.value, rendererType, viewportSize.value, contentSize.value, style.width, style.borderRadius), [contentSize, playhead, rendererType, scrollOffset, style.borderRadius, style.width, viewportSize]);
|
|
46
|
+
const opacity = useDerivedValue(() => playhead.value ? style.opacity : 0, [playhead, style.opacity]);
|
|
47
|
+
return /*#__PURE__*/_jsx(RoundedRect, {
|
|
48
|
+
rect: rect,
|
|
49
|
+
color: style.color,
|
|
50
|
+
opacity: opacity
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export default ScorePlayhead;
|
|
54
|
+
//# sourceMappingURL=ScorePlayhead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","RoundedRect","Skia","useDerivedValue","createVisibleViewport","jsx","_jsx","resolvePlayheadStyle","style","foreground","width","color","borderRadius","opacity","createPlayheadRect","state","scrollOffset","rendererType","viewportSize","contentSize","RRectXY","XYWHRect","visible","x","y","height","ScorePlayhead","playhead","rect","value"],"sourceRoot":"../../../../src","sources":["renderer/ScoreRenderer/ScorePlayhead.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,EAAEC,IAAI,QAAsB,4BAA4B;AAC5E,SAASC,eAAe,QAA0B,yBAAyB;AAQ3E,SAASC,qBAAqB,QAAQ,gBAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAkBpD,OAAO,SAASC,oBAAoBA,CAClCC,KAAqC,EACrCC,UAAkB,EACK;EACvB,MAAMC,KAAK,GAAGF,KAAK,EAAEE,KAAK,IAAI,CAAC;EAE/B,OAAO;IACLC,KAAK,EAAEH,KAAK,EAAEG,KAAK,IAAIF,UAAU;IACjCC,KAAK;IACLE,YAAY,EAAEJ,KAAK,EAAEI,YAAY,IAAIF,KAAK,GAAG,CAAC;IAC9CG,OAAO,EAAEL,KAAK,EAAEK,OAAO,IAAI;EAC7B,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCC,KAAgC,EAChCC,YAAoB,EACpBC,YAA0B,EAC1BC,YAA0B,EAC1BC,WAAyB,EACzBT,KAAa,EACbE,YAAoB,EACX;EACT,SAAS;;EAET,IAAI,CAACG,KAAK,EAAE;IACV,OAAOb,IAAI,CAACkB,OAAO,CAAClB,IAAI,CAACmB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;EAC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