vexflow-native 1.0.1 → 1.1.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.
Files changed (31) hide show
  1. package/README.md +2 -0
  2. package/lib/module/base/VexflowRecordingContext.js +69 -7
  3. package/lib/module/base/VexflowRecordingContext.js.map +1 -1
  4. package/lib/module/base/VexflowRecordingReplay.js +79 -5
  5. package/lib/module/base/VexflowRecordingReplay.js.map +1 -1
  6. package/lib/module/base/index.js +1 -0
  7. package/lib/module/base/index.js.map +1 -1
  8. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +53 -8
  9. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
  10. package/lib/module/renderer/render.js +22 -1
  11. package/lib/module/renderer/render.js.map +1 -1
  12. package/lib/typescript/src/base/VexflowRecordingContext.d.ts +32 -3
  13. package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -1
  14. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +10 -2
  15. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -1
  16. package/lib/typescript/src/base/VexflowRecordingTypes.d.ts +53 -1
  17. package/lib/typescript/src/base/VexflowRecordingTypes.d.ts.map +1 -1
  18. package/lib/typescript/src/base/index.d.ts +1 -0
  19. package/lib/typescript/src/base/index.d.ts.map +1 -1
  20. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts +5 -4
  21. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
  22. package/lib/typescript/src/renderer/types.d.ts +5 -0
  23. package/lib/typescript/src/renderer/types.d.ts.map +1 -1
  24. package/package.json +2 -3
  25. package/src/base/VexflowRecordingContext.ts +57 -7
  26. package/src/base/VexflowRecordingReplay.ts +121 -5
  27. package/src/base/VexflowRecordingTypes.ts +54 -2
  28. package/src/base/index.ts +1 -0
  29. package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +87 -13
  30. package/src/renderer/render.tsx +31 -4
  31. package/src/renderer/types.ts +5 -0
@@ -7,6 +7,7 @@ import type { VexflowRecordingCommand } from './VexflowRecordingTypes';
7
7
  export default class VexflowRecordingContext implements VexflowRenderContext {
8
8
  __workletClass: boolean;
9
9
  private commands;
10
+ private colorGroupId?;
10
11
  private currentPath?;
11
12
  private fillPaint;
12
13
  private strokePaint;
@@ -24,11 +25,29 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
24
25
  setFillStyle(style: string | unknown): this;
25
26
  setBackgroundFillStyle(_style: string): this;
26
27
  setStrokeStyle(style: string): this;
27
- setShadowColor(_color: string): this;
28
- setShadowBlur(_blur: number): this;
28
+ /**
29
+ * Record a glow/shadow colour (CSS `shadowColor`) into both the fill and the
30
+ * stroke paint — VexFlow's `ElementStyle.shadowColor` is applied as ctx-level
31
+ * state that affects whatever is drawn next, fill or stroke. Replayed in Skia
32
+ * as a drop-shadow image filter (a glow around the ink) and overridable per
33
+ * group at replay.
34
+ */
35
+ setShadowColor(color: string): this;
36
+ /**
37
+ * Record a glow/shadow blur radius (CSS `shadowBlur`) into both the fill and
38
+ * the stroke paint. Mapped to a Gaussian sigma at replay; only takes effect
39
+ * when a `shadowColor` is also set.
40
+ */
41
+ setShadowBlur(blur: number): this;
29
42
  setLineWidth(width: number): this;
30
43
  setLineCap(cap: string): this;
31
- setLineDash(_dashPattern: number[]): this;
44
+ /**
45
+ * Record a dash pattern (CSS `setLineDash`) into the stroke paint — dashing is
46
+ * a stroke-only concept (stems, ledger lines, …). Replayed in Skia as a dash
47
+ * path effect and overridable per group at replay. An empty array clears any
48
+ * recorded dash (CSS semantics: solid line).
49
+ */
50
+ setLineDash(dashPattern: number[]): this;
32
51
  scale(x: number, y: number): this;
33
52
  translate(x: number, y: number): this;
34
53
  resize(_width: number, _height: number): this;
@@ -51,6 +70,16 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
51
70
  restore(): this;
52
71
  openGroup(_cls?: string, _id?: string): this;
53
72
  closeGroup(): this;
73
+ /**
74
+ * Open a colour group. Every command recorded until `endColorGroup()` is
75
+ * stamped with `id` as its `groupId`, so a replay can recolor the whole group
76
+ * from a `groupId -> color` override map without re-recording. This is a
77
+ * dedicated, explicit grouping — distinct from VexFlow's
78
+ * `openGroup`/`closeGroup` (above, no-ops here), which a real score nests per
79
+ * element. Returns `this` for chaining.
80
+ */
81
+ beginColorGroup(id: string): this;
82
+ endColorGroup(): this;
54
83
  openRotation(_angleDegrees: number, _x: number, _y: number): this;
55
84
  closeRotation(): this;
56
85
  add(_child: unknown): this;
@@ -1 +1 @@
1
- {"version":3,"file":"VexflowRecordingContext.d.ts","sourceRoot":"","sources":["../../../../src/base/VexflowRecordingContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAW,aAAa,IAAI,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,uBAAuB,EAMxB,MAAM,yBAAyB,CAAC;AAgBjC,MAAM,CAAC,OAAO,OAAO,uBAAwB,YAAW,oBAAoB;IAC1E,cAAc,UAAQ;IAEtB,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,WAAW,CAAC,CAAgC;IACpD,OAAO,CAAC,SAAS,CAEf;IACF,OAAO,CAAC,WAAW,CAIjB;IACF,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,sBAAsB,CAAqB;IACnD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAqB;gBAGvC,YAAY,EAAE,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,IAAI,WAAW,CAAC,KAAK,EAAE,MAAM,EAE5B;IAED,IAAI,WAAW,IAJQ,MAAM,CAO5B;IAED,OAAO,CACL,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,EACxB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,KAAK,CAAC,EAAE,MAAM;IAOhB,OAAO;IAKP,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAErB;IAED,IAAI,IAAI,IAJQ,MAAM,CAOrB;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,WAAW;CAapB"}
@@ -1,4 +1,12 @@
1
1
  import { type SkCanvas, type SkTypefaceFontProvider } from '@shopify/react-native-skia';
2
- import type { VexflowRecordingCommand } from './VexflowRecordingTypes';
3
- export declare function renderVexflowRecordingCommands(canvas: SkCanvas, commands: readonly VexflowRecordingCommand[], fontProvider: SkTypefaceFontProvider, defaultFont: string): void;
2
+ import type { VexflowRecordingCommand, VexflowStyleOverride } from './VexflowRecordingTypes';
3
+ export declare function renderVexflowRecordingCommands(canvas: SkCanvas, commands: readonly VexflowRecordingCommand[], fontProvider: SkTypefaceFontProvider, defaultFont: string,
4
+ /**
5
+ * Optional `groupId -> VexflowStyleOverride` map. Commands tagged (via
6
+ * `beginColorGroup`/`endColorGroup`) with a `groupId` present here are drawn
7
+ * with the override merged over their recorded paint — separate fill/stroke
8
+ * colours, a glow (shadow), and a stroke dash are all expressible. Omit for a
9
+ * byte-identical replay of the recorded style.
10
+ */
11
+ styleOverrides?: Record<string, VexflowStyleOverride>): void;
4
12
  //# sourceMappingURL=VexflowRecordingReplay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VexflowRecordingReplay.d.ts","sourceRoot":"","sources":["../../../../src/base/VexflowRecordingReplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EAGb,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EACV,uBAAuB,EAMxB,MAAM,yBAAyB,CAAC;AA8HjC,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,YAAY,EAAE,sBAAsB,EACpC,WAAW,EAAE,MAAM,QA4DpB"}
1
+ {"version":3,"file":"VexflowRecordingReplay.d.ts","sourceRoot":"","sources":["../../../../src/base/VexflowRecordingReplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EAGb,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EACV,uBAAuB,EAMvB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AA4NjC,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,YAAY,EAAE,sBAAsB,EACpC,WAAW,EAAE,MAAM;AACnB;;;;;;GAMG;AACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,QAyEtD"}
@@ -10,6 +10,49 @@ export interface VexflowRecordingPaint {
10
10
  color: string;
11
11
  strokeCap?: VexflowRecordingLineCap;
12
12
  strokeWidth?: number;
13
+ /**
14
+ * Glow/shadow colour (CSS `shadowColor`). Recorded from
15
+ * `VexflowRecordingContext.setShadowColor`. Replayed in Skia as a drop-shadow
16
+ * image filter with `dx = dy = 0` (a glow around the ink), and overridable per
17
+ * group via `VexflowStyleOverride.shadowColor`.
18
+ */
19
+ shadowColor?: string;
20
+ /**
21
+ * Glow/shadow blur radius in px (CSS `shadowBlur`). Recorded from
22
+ * `VexflowRecordingContext.setShadowBlur`. Mapped to a Gaussian sigma of
23
+ * `shadowBlur / 2` at replay. Only takes effect when `shadowColor` is set.
24
+ */
25
+ shadowBlur?: number;
26
+ /**
27
+ * Dash pattern (CSS `setLineDash`), stroke only. Recorded from
28
+ * `VexflowRecordingContext.setLineDash`. Replayed as a Skia dash path effect
29
+ * and overridable per group via `VexflowStyleOverride.lineDash`.
30
+ */
31
+ lineDash?: number[];
32
+ }
33
+ /**
34
+ * A granular, disambiguated style override applied to every command sharing a
35
+ * `groupId` at replay (see `renderVexflowRecordingCommands`'s `styleOverrides`).
36
+ *
37
+ * Each field is merged OVER the recorded paint, so any field left undefined
38
+ * falls back to whatever was recorded. An override is resolved per command
39
+ * against the paint that command uses (fill vs stroke), which is why fill and
40
+ * stroke colours are separable here — the consumer can, e.g., fill a notehead
41
+ * green while stroking its stem red.
42
+ */
43
+ export interface VexflowStyleOverride {
44
+ /** Fill paint colour (noteheads, rests, glyphs, filled shapes). */
45
+ fillColor?: string;
46
+ /** Stroke paint colour (stems, ledger lines, beam edges). */
47
+ strokeColor?: string;
48
+ /** Shorthand applied to both fill and stroke (lower precedence than the two above). */
49
+ color?: string;
50
+ /** Glow colour (CSS `shadowColor`), applied to both fill and stroke so the whole note glows. */
51
+ shadowColor?: string;
52
+ /** Glow blur radius in px (CSS `shadowBlur`). Only takes effect when a `shadowColor` resolves. */
53
+ shadowBlur?: number;
54
+ /** Dash pattern (stroke only). */
55
+ lineDash?: number[];
13
56
  }
14
57
  export interface VexflowRecordingFont {
15
58
  font?: string | FontInfo;
@@ -50,7 +93,16 @@ export type VexflowRecordingPathCommand = {
50
93
  } | {
51
94
  type: 'close';
52
95
  };
96
+ /**
97
+ * A recorded draw command. `groupId` (optional) is stamped by
98
+ * `beginColorGroup`/`endColorGroup` on the recording context: a replay can then
99
+ * recolor every command sharing a `groupId` from a `groupId -> color` override
100
+ * map without re-recording. Untagged commands (staff lines, clefs, …) are never
101
+ * overridden.
102
+ */
53
103
  export type VexflowRecordingCommand = {
104
+ groupId?: string;
105
+ } & ({
54
106
  type: 'clear';
55
107
  color: string;
56
108
  } | {
@@ -90,5 +142,5 @@ export type VexflowRecordingCommand = {
90
142
  y: number;
91
143
  paint: VexflowRecordingPaint;
92
144
  font: VexflowRecordingFont;
93
- };
145
+ });
94
146
  //# sourceMappingURL=VexflowRecordingTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VexflowRecordingTypes.d.ts","sourceRoot":"","sources":["../../../../src/base/VexflowRecordingTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,2BAA2B,GACnC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IAC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B,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,qBAAqB,CAAC;IAC7B,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CAAC"}
1
+ {"version":3,"file":"VexflowRecordingTypes.d.ts","sourceRoot":"","sources":["../../../../src/base/VexflowRecordingTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gGAAgG;IAChG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,EAAE,C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,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,SAAS,CAAC;CACjB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,oBAAoB,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,qBAAqB,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,oBAAoB,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,2BAA2B,EAAE,CAAC;IACpC,KAAK,EAAE,qBAAqB,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,2BAA2B,EAAE,CAAC;IACpC,KAAK,EAAE,qBAAqB,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,qBAAqB,CAAC;IAC7B,IAAI,EAAE,oBAAoB,CAAC;CAC5B,CACJ,CAAC"}
@@ -1,5 +1,6 @@
1
1
  export { default as VexflowCanvas } from './VexflowCanvas';
2
2
  export { default as VexflowRecordingContext } from './VexflowRecordingContext';
3
+ export { renderVexflowRecordingCommands } from './VexflowRecordingReplay';
3
4
  export * from './VexflowColorScheme';
4
5
  export * from './VexflowRecordingTypes';
5
6
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAE/E,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import type React from 'react';
2
- import { type SkTypefaceFontProvider, type Transforms3d } from '@shopify/react-native-skia';
2
+ import { type SkPicture, type SkTypefaceFontProvider, type Transforms3d } from '@shopify/react-native-skia';
3
3
  import type { VexflowRecordingCommand } from '../../base';
4
- import type { RendererSize, RendererType, ScoreRendererProps, Viewport } from '../types';
4
+ import type { RendererSize, RendererType, ScoreItemStyleOverrides, ScoreRendererProps, Viewport } from '../types';
5
5
  declare const _default: React.NamedExoticComponent<ScoreRendererProps>;
6
6
  export default _default;
7
- export declare function createScorePicture({ contentSize, defaultFont, fontManager, recordedCommands, }: {
7
+ export declare function createScorePicture({ contentSize, defaultFont, fontManager, recordedCommands, styleOverrides, }: {
8
8
  contentSize: RendererSize;
9
9
  defaultFont: string;
10
10
  fontManager: SkTypefaceFontProvider;
11
11
  recordedCommands: readonly VexflowRecordingCommand[];
12
- }): import("@shopify/react-native-skia").SkPicture;
12
+ styleOverrides?: ScoreItemStyleOverrides;
13
+ }): SkPicture;
13
14
  export declare function createPictureTransform(scrollOffset: number, rendererType: RendererType, viewport: Viewport, contentSize: RendererSize): Transforms3d;
14
15
  //# sourceMappingURL=ScoreRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ScoreRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/ScoreRenderer/ScoreRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAI1D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,QAAQ,EACT,MAAM,UAAU,CAAC;;AAuJlB,wBAAmC;AAEnC,wBAAgB,kBAAkB,CAAC,EACjC,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,YAAY,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,sBAAsB,CAAC;IACpC,gBAAgB,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACtD,kDA2BA;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,YAAY,GACxB,YAAY,CAkBd"}
1
+ {"version":3,"file":"ScoreRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/renderer/ScoreRenderer/ScoreRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAKpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAI1D,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,uBAAuB,EAEvB,kBAAkB,EAClB,QAAQ,EACT,MAAM,UAAU,CAAC;;AAmKlB,wBAAmC;AAkCnC,wBAAgB,kBAAkB,CAAC,EACjC,WAAW,EACX,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,cAAc,GACf,EAAE;IACD,WAAW,EAAE,YAAY,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,sBAAsB,CAAC;IACpC,gBAAgB,EAAE,SAAS,uBAAuB,EAAE,CAAC;IACrD,cAAc,CAAC,EAAE,uBAAuB,CAAC;CAC1C,aAsBA;AAiCD,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,YAAY,GACxB,YAAY,CAkBd"}
@@ -1,12 +1,17 @@
1
1
  import type { SkTypefaceFontProvider } from '@shopify/react-native-skia';
2
+ import type { SharedValue } from 'react-native-reanimated';
3
+ import type { VexflowStyleOverride } from '../base';
2
4
  import type { Score } from '../state';
3
5
  import type { ScoreColorScheme } from './colorScheme';
4
6
  export type RendererType = 'infiniteScore' | 'document' | 'documentEven';
7
+ export type ScoreItemStyleOverride = VexflowStyleOverride;
8
+ export type ScoreItemStyleOverrides = Record<string, ScoreItemStyleOverride>;
5
9
  export interface ScoreRendererProps {
6
10
  score: Score;
7
11
  defaultFont: string;
8
12
  fontManager: SkTypefaceFontProvider;
9
13
  colorScheme?: ScoreColorScheme;
14
+ itemStyleOverrides?: SharedValue<ScoreItemStyleOverrides>;
10
15
  rendererType?: RendererType;
11
16
  options?: Partial<ScoreOptions>;
12
17
  scrollEnabled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/renderer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;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M,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa,EAAE,YAAY;CAAG;AAEpE,MAAM,WAAW,eAAgB,SAAQ,YAAY;CAAG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vexflow-native",
3
- "version": "1.0.1",
4
- "description": "React native backend for rendering music notation using @shopify/react-native-skiaact-native-skia",
3
+ "version": "1.1.0",
4
+ "description": "React native backend for rendering music notation using @shopify/react-native-skia",
5
5
  "main": "./lib/module/base/index.js",
6
6
  "types": "./lib/typescript/src/base/index.d.ts",
7
7
  "exports": {
@@ -46,7 +46,6 @@
46
46
  "example": "yarn workspace vexflow-native-example",
47
47
  "clean": "del-cli lib",
48
48
  "prepare": "bob build",
49
- "postinstall": "yarn workspace vexflow-native-example apply-patches",
50
49
  "typecheck": "tsc",
51
50
  "lint": "eslint src example --ext .js,.ts,.tsx",
52
51
  "lint:fix": "yarn lint --fix",
@@ -40,6 +40,7 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
40
40
  __workletClass = true;
41
41
 
42
42
  private commands: VexflowRecordingCommand[] = [];
43
+ private colorGroupId?: string;
43
44
  private currentPath?: VexflowRecordingPathCommand[];
44
45
  private fillPaint: VexflowRecordingPaint = {
45
46
  color: '#000000',
@@ -136,13 +137,28 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
136
137
  return this;
137
138
  }
138
139
 
139
- setShadowColor(_color: string): this {
140
- logUnimplemented('setShadowColor');
140
+ /**
141
+ * Record a glow/shadow colour (CSS `shadowColor`) into both the fill and the
142
+ * stroke paint — VexFlow's `ElementStyle.shadowColor` is applied as ctx-level
143
+ * state that affects whatever is drawn next, fill or stroke. Replayed in Skia
144
+ * as a drop-shadow image filter (a glow around the ink) and overridable per
145
+ * group at replay.
146
+ */
147
+ setShadowColor(color: string): this {
148
+ const resolved = resolveVexflowColor(color, this.colorScheme);
149
+ this.fillPaint = { ...this.fillPaint, shadowColor: resolved };
150
+ this.strokePaint = { ...this.strokePaint, shadowColor: resolved };
141
151
  return this;
142
152
  }
143
153
 
144
- setShadowBlur(_blur: number) {
145
- logUnimplemented('setShadowBlur');
154
+ /**
155
+ * Record a glow/shadow blur radius (CSS `shadowBlur`) into both the fill and
156
+ * the stroke paint. Mapped to a Gaussian sigma at replay; only takes effect
157
+ * when a `shadowColor` is also set.
158
+ */
159
+ setShadowBlur(blur: number): this {
160
+ this.fillPaint = { ...this.fillPaint, shadowBlur: blur };
161
+ this.strokePaint = { ...this.strokePaint, shadowBlur: blur };
146
162
  return this;
147
163
  }
148
164
 
@@ -162,8 +178,17 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
162
178
  return this;
163
179
  }
164
180
 
165
- setLineDash(_dashPattern: number[]) {
166
- logUnimplemented('setLineDash');
181
+ /**
182
+ * Record a dash pattern (CSS `setLineDash`) into the stroke paint — dashing is
183
+ * a stroke-only concept (stems, ledger lines, …). Replayed in Skia as a dash
184
+ * path effect and overridable per group at replay. An empty array clears any
185
+ * recorded dash (CSS semantics: solid line).
186
+ */
187
+ setLineDash(dashPattern: number[]): this {
188
+ this.strokePaint = {
189
+ ...this.strokePaint,
190
+ lineDash: dashPattern.length > 0 ? [...dashPattern] : undefined,
191
+ };
167
192
  return this;
168
193
  }
169
194
 
@@ -336,6 +361,24 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
336
361
  return this;
337
362
  }
338
363
 
364
+ /**
365
+ * Open a colour group. Every command recorded until `endColorGroup()` is
366
+ * stamped with `id` as its `groupId`, so a replay can recolor the whole group
367
+ * from a `groupId -> color` override map without re-recording. This is a
368
+ * dedicated, explicit grouping — distinct from VexFlow's
369
+ * `openGroup`/`closeGroup` (above, no-ops here), which a real score nests per
370
+ * element. Returns `this` for chaining.
371
+ */
372
+ beginColorGroup(id: string) {
373
+ this.colorGroupId = id;
374
+ return this;
375
+ }
376
+
377
+ endColorGroup() {
378
+ this.colorGroupId = undefined;
379
+ return this;
380
+ }
381
+
339
382
  openRotation(_angleDegrees: number, _x: number, _y: number) {
340
383
  logUnimplemented('openRotation');
341
384
  return this;
@@ -414,6 +457,10 @@ export default class VexflowRecordingContext implements VexflowRenderContext {
414
457
  );
415
458
  }
416
459
 
460
+ if (this.colorGroupId != null) {
461
+ command.groupId = this.colorGroupId;
462
+ }
463
+
417
464
  this.commands.push(command);
418
465
  }
419
466
  }
@@ -436,7 +483,10 @@ function normalizeLineCap(cap: string): VexflowRecordingLineCap {
436
483
  }
437
484
 
438
485
  function clonePaint(paint: VexflowRecordingPaint): VexflowRecordingPaint {
439
- return { ...paint };
486
+ return {
487
+ ...paint,
488
+ ...(paint.lineDash ? { lineDash: [...paint.lineDash] } : null),
489
+ };
440
490
  }
441
491
 
442
492
  function cloneFont(font: VexflowRecordingFont): VexflowRecordingFont {
@@ -18,8 +18,47 @@ import type {
18
18
  VexflowRecordingPaint,
19
19
  VexflowRecordingPathCommand,
20
20
  VexflowRecordingRect,
21
+ VexflowStyleOverride,
21
22
  } from './VexflowRecordingTypes';
22
23
 
24
+ /**
25
+ * Map a CSS `shadowBlur` (a blur radius in px) to a Gaussian sigma for Skia's
26
+ * drop-shadow filter. Canvas measures shadow blur as a radius; Skia's filter is
27
+ * parameterised by sigma. `radius / 2` is the conventional approximation used
28
+ * across Skia-backed canvas shims and gives a visually matching glow.
29
+ */
30
+ function shadowBlurToSigma(shadowBlur: number): number {
31
+ 'worklet';
32
+
33
+ return shadowBlur / 2;
34
+ }
35
+
36
+ /**
37
+ * Apply the recorded glow (CSS shadow) to a Skia paint as a drop-shadow image
38
+ * filter. `dx = dy = 0` turns the drop shadow into a symmetric glow centred on
39
+ * the ink; `MakeDropShadow` (not `…Only`) keeps the source content, so the note
40
+ * still draws on top of its halo. No-op unless a `shadowColor` resolved.
41
+ */
42
+ function applyGlow(skPaint: SkPaint, paint: VexflowRecordingPaint) {
43
+ 'worklet';
44
+
45
+ if (paint.shadowColor == null) {
46
+ return;
47
+ }
48
+
49
+ const sigma = shadowBlurToSigma(paint.shadowBlur ?? 0);
50
+
51
+ skPaint.setImageFilter(
52
+ Skia.ImageFilter.MakeDropShadow(
53
+ 0,
54
+ 0,
55
+ sigma,
56
+ sigma,
57
+ Skia.Color(paint.shadowColor)
58
+ )
59
+ );
60
+ }
61
+
23
62
  function toSkiaRect(rect: VexflowRecordingRect) {
24
63
  'worklet';
25
64
 
@@ -47,6 +86,7 @@ function createFillPaint(paint: VexflowRecordingPaint): SkPaint {
47
86
  skPaint.setStyle(PaintStyle.Fill);
48
87
  skPaint.setAntiAlias(true);
49
88
  skPaint.setColor(Skia.Color(paint.color));
89
+ applyGlow(skPaint, paint);
50
90
 
51
91
  return skPaint;
52
92
  }
@@ -60,6 +100,11 @@ function createStrokePaint(paint: VexflowRecordingPaint): SkPaint {
60
100
  skPaint.setColor(Skia.Color(paint.color));
61
101
  skPaint.setStrokeWidth(paint.strokeWidth ?? 1);
62
102
  skPaint.setStrokeCap(mapRecordingLineCap(paint.strokeCap ?? 'butt'));
103
+ applyGlow(skPaint, paint);
104
+
105
+ if (paint.lineDash != null && paint.lineDash.length > 0) {
106
+ skPaint.setPathEffect(Skia.PathEffect.MakeDash(paint.lineDash));
107
+ }
63
108
 
64
109
  return skPaint;
65
110
  }
@@ -73,6 +118,56 @@ function createClearPaint(): SkPaint {
73
118
  return clearPaint;
74
119
  }
75
120
 
121
+ type PaintKind = 'fill' | 'stroke';
122
+
123
+ /**
124
+ * Resolve a recorded paint against an optional per-group style override map
125
+ * (`groupId -> VexflowStyleOverride`), merging the override OVER the recorded
126
+ * paint. Returns the original paint object (referentially) when no override
127
+ * applies, so untagged chrome (staff lines, clefs, …) is never restyled and a
128
+ * replay with no `styleOverrides` is byte-identical to a faithful replay.
129
+ *
130
+ * `kind` disambiguates which colour field wins: a fill command reads
131
+ * `fillColor ?? color`, a stroke command reads `strokeColor ?? color`, each
132
+ * falling back to the recorded colour. Glow (shadow) is applied to both kinds so
133
+ * the whole note glows; dash is stroke-only. This is the seam that lets a single
134
+ * recording be replayed many times in different styles (e.g. per-frame from a
135
+ * shared value) without re-recording.
136
+ */
137
+ function resolveStyle(
138
+ paint: VexflowRecordingPaint,
139
+ groupId: string | undefined,
140
+ kind: PaintKind,
141
+ styleOverrides?: Record<string, VexflowStyleOverride>
142
+ ): VexflowRecordingPaint {
143
+ 'worklet';
144
+
145
+ if (styleOverrides == null || groupId == null) {
146
+ return paint;
147
+ }
148
+
149
+ const override = styleOverrides[groupId];
150
+
151
+ if (override == null) {
152
+ return paint;
153
+ }
154
+
155
+ const color =
156
+ kind === 'fill'
157
+ ? override.fillColor ?? override.color ?? paint.color
158
+ : override.strokeColor ?? override.color ?? paint.color;
159
+
160
+ return {
161
+ ...paint,
162
+ color,
163
+ shadowColor: override.shadowColor ?? paint.shadowColor,
164
+ shadowBlur: override.shadowBlur ?? paint.shadowBlur,
165
+ // Dash is stroke-only; ignore any override.lineDash on fill commands.
166
+ lineDash:
167
+ kind === 'stroke' ? override.lineDash ?? paint.lineDash : paint.lineDash,
168
+ };
169
+ }
170
+
76
171
  function createFont(fontManager: FontManager, font: VexflowRecordingFont) {
77
172
  'worklet';
78
173
 
@@ -148,7 +243,15 @@ export function renderVexflowRecordingCommands(
148
243
  canvas: SkCanvas,
149
244
  commands: readonly VexflowRecordingCommand[],
150
245
  fontProvider: SkTypefaceFontProvider,
151
- defaultFont: string
246
+ defaultFont: string,
247
+ /**
248
+ * Optional `groupId -> VexflowStyleOverride` map. Commands tagged (via
249
+ * `beginColorGroup`/`endColorGroup`) with a `groupId` present here are drawn
250
+ * with the override merged over their recorded paint — separate fill/stroke
251
+ * colours, a glow (shadow), and a stroke dash are all expressible. Omit for a
252
+ * byte-identical replay of the recorded style.
253
+ */
254
+ styleOverrides?: Record<string, VexflowStyleOverride>
152
255
  ) {
153
256
  'worklet';
154
257
 
@@ -177,7 +280,9 @@ export function renderVexflowRecordingCommands(
177
280
  case 'fillRect':
178
281
  canvas.drawRect(
179
282
  toSkiaRect(command.rect),
180
- createFillPaint(command.paint)
283
+ createFillPaint(
284
+ resolveStyle(command.paint, command.groupId, 'fill', styleOverrides)
285
+ )
181
286
  );
182
287
  break;
183
288
  case 'clearRect':
@@ -186,13 +291,22 @@ export function renderVexflowRecordingCommands(
186
291
  case 'fillPath':
187
292
  canvas.drawPath(
188
293
  buildPath(command.path),
189
- createFillPaint(command.paint)
294
+ createFillPaint(
295
+ resolveStyle(command.paint, command.groupId, 'fill', styleOverrides)
296
+ )
190
297
  );
191
298
  break;
192
299
  case 'strokePath':
193
300
  canvas.drawPath(
194
301
  buildPath(command.path),
195
- createStrokePaint(command.paint)
302
+ createStrokePaint(
303
+ resolveStyle(
304
+ command.paint,
305
+ command.groupId,
306
+ 'stroke',
307
+ styleOverrides
308
+ )
309
+ )
196
310
  );
197
311
  break;
198
312
  case 'fillText':
@@ -200,7 +314,9 @@ export function renderVexflowRecordingCommands(
200
314
  command.text,
201
315
  command.x,
202
316
  command.y,
203
- createFillPaint(command.paint),
317
+ createFillPaint(
318
+ resolveStyle(command.paint, command.groupId, 'fill', styleOverrides)
319
+ ),
204
320
  createFont(fontManager, command.font)
205
321
  );
206
322
  break;
@@ -13,6 +13,50 @@ export interface VexflowRecordingPaint {
13
13
  color: string;
14
14
  strokeCap?: VexflowRecordingLineCap;
15
15
  strokeWidth?: number;
16
+ /**
17
+ * Glow/shadow colour (CSS `shadowColor`). Recorded from
18
+ * `VexflowRecordingContext.setShadowColor`. Replayed in Skia as a drop-shadow
19
+ * image filter with `dx = dy = 0` (a glow around the ink), and overridable per
20
+ * group via `VexflowStyleOverride.shadowColor`.
21
+ */
22
+ shadowColor?: string;
23
+ /**
24
+ * Glow/shadow blur radius in px (CSS `shadowBlur`). Recorded from
25
+ * `VexflowRecordingContext.setShadowBlur`. Mapped to a Gaussian sigma of
26
+ * `shadowBlur / 2` at replay. Only takes effect when `shadowColor` is set.
27
+ */
28
+ shadowBlur?: number;
29
+ /**
30
+ * Dash pattern (CSS `setLineDash`), stroke only. Recorded from
31
+ * `VexflowRecordingContext.setLineDash`. Replayed as a Skia dash path effect
32
+ * and overridable per group via `VexflowStyleOverride.lineDash`.
33
+ */
34
+ lineDash?: number[];
35
+ }
36
+
37
+ /**
38
+ * A granular, disambiguated style override applied to every command sharing a
39
+ * `groupId` at replay (see `renderVexflowRecordingCommands`'s `styleOverrides`).
40
+ *
41
+ * Each field is merged OVER the recorded paint, so any field left undefined
42
+ * falls back to whatever was recorded. An override is resolved per command
43
+ * against the paint that command uses (fill vs stroke), which is why fill and
44
+ * stroke colours are separable here — the consumer can, e.g., fill a notehead
45
+ * green while stroking its stem red.
46
+ */
47
+ export interface VexflowStyleOverride {
48
+ /** Fill paint colour (noteheads, rests, glyphs, filled shapes). */
49
+ fillColor?: string;
50
+ /** Stroke paint colour (stems, ledger lines, beam edges). */
51
+ strokeColor?: string;
52
+ /** Shorthand applied to both fill and stroke (lower precedence than the two above). */
53
+ color?: string;
54
+ /** Glow colour (CSS `shadowColor`), applied to both fill and stroke so the whole note glows. */
55
+ shadowColor?: string;
56
+ /** Glow blur radius in px (CSS `shadowBlur`). Only takes effect when a `shadowColor` resolves. */
57
+ shadowBlur?: number;
58
+ /** Dash pattern (stroke only). */
59
+ lineDash?: number[];
16
60
  }
17
61
 
18
62
  export interface VexflowRecordingFont {
@@ -63,7 +107,14 @@ export type VexflowRecordingPathCommand =
63
107
  type: 'close';
64
108
  };
65
109
 
66
- export type VexflowRecordingCommand =
110
+ /**
111
+ * A recorded draw command. `groupId` (optional) is stamped by
112
+ * `beginColorGroup`/`endColorGroup` on the recording context: a replay can then
113
+ * recolor every command sharing a `groupId` from a `groupId -> color` override
114
+ * map without re-recording. Untagged commands (staff lines, clefs, …) are never
115
+ * overridden.
116
+ */
117
+ export type VexflowRecordingCommand = { groupId?: string } & (
67
118
  | {
68
119
  type: 'clear';
69
120
  color: string;
@@ -114,4 +165,5 @@ export type VexflowRecordingCommand =
114
165
  y: number;
115
166
  paint: VexflowRecordingPaint;
116
167
  font: VexflowRecordingFont;
117
- };
168
+ }
169
+ );
package/src/base/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as VexflowCanvas } from './VexflowCanvas';
2
2
  export { default as VexflowRecordingContext } from './VexflowRecordingContext';
3
+ export { renderVexflowRecordingCommands } from './VexflowRecordingReplay';
3
4
 
4
5
  export * from './VexflowColorScheme';
5
6
  export * from './VexflowRecordingTypes';