vexflow-native 1.9.0 → 2.0.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.
Files changed (60) hide show
  1. package/README.md +42 -2
  2. package/lib/module/base/FontManager.js +3 -5
  3. package/lib/module/base/FontManager.js.map +1 -1
  4. package/lib/module/base/VexflowCanvas.js +1 -1
  5. package/lib/module/base/VexflowCanvas.js.map +1 -1
  6. package/lib/module/base/VexflowRecordingContext.js.map +1 -1
  7. package/lib/module/base/VexflowRecordingReplay.js +119 -79
  8. package/lib/module/base/VexflowRecordingReplay.js.map +1 -1
  9. package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js +4 -3
  10. package/lib/module/renderer/ScoreRenderer/ScoreOverlayPicture.js.map +1 -1
  11. package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js +1 -1
  12. package/lib/module/renderer/ScoreRenderer/ScorePlayhead.js.map +1 -1
  13. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js +1 -1
  14. package/lib/module/renderer/ScoreRenderer/ScoreRenderer.js.map +1 -1
  15. package/lib/module/renderer/ScoreRenderer/utils.js +1 -1
  16. package/lib/module/renderer/ScoreRenderer/utils.js.map +1 -1
  17. package/lib/module/renderer/layout.js +10 -0
  18. package/lib/module/renderer/layout.js.map +1 -1
  19. package/lib/module/renderer/useScoreRecording.js +50 -17
  20. package/lib/module/renderer/useScoreRecording.js.map +1 -1
  21. package/lib/typescript/src/base/FontManager.d.ts +2 -2
  22. package/lib/typescript/src/base/FontManager.d.ts.map +1 -1
  23. package/lib/typescript/src/base/VexflowRecordingContext.d.ts +1 -1
  24. package/lib/typescript/src/base/VexflowRecordingContext.d.ts.map +1 -1
  25. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts +1 -1
  26. package/lib/typescript/src/base/VexflowRecordingReplay.d.ts.map +1 -1
  27. package/lib/typescript/src/base/types.d.ts +1 -1
  28. package/lib/typescript/src/base/types.d.ts.map +1 -1
  29. package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts +1 -1
  30. package/lib/typescript/src/renderer/ScoreRenderer/ScoreOverlayPicture.d.ts.map +1 -1
  31. package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.d.ts +1 -1
  32. package/lib/typescript/src/renderer/ScoreRenderer/ScorePlayhead.d.ts.map +1 -1
  33. package/lib/typescript/src/renderer/ScoreRenderer/ScoreRenderer.d.ts.map +1 -1
  34. package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts +1 -1
  35. package/lib/typescript/src/renderer/ScoreRenderer/types.d.ts.map +1 -1
  36. package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts +1 -1
  37. package/lib/typescript/src/renderer/ScoreRenderer/utils.d.ts.map +1 -1
  38. package/lib/typescript/src/renderer/layout.d.ts +7 -0
  39. package/lib/typescript/src/renderer/layout.d.ts.map +1 -1
  40. package/lib/typescript/src/renderer/types.d.ts +1 -1
  41. package/lib/typescript/src/renderer/types.d.ts.map +1 -1
  42. package/lib/typescript/src/renderer/useScoreRecording.d.ts +1 -1
  43. package/lib/typescript/src/renderer/useScoreRecording.d.ts.map +1 -1
  44. package/package.json +20 -16
  45. package/src/base/FontManager.ts +4 -11
  46. package/src/base/TextMeasureContext.ts +1 -1
  47. package/src/base/VexflowCanvas.tsx +1 -1
  48. package/src/base/VexflowRecordingContext.ts +1 -4
  49. package/src/base/VexflowRecordingReplay.ts +194 -142
  50. package/src/base/types.ts +1 -1
  51. package/src/renderer/ScoreRenderer/ScoreOverlayPicture.tsx +4 -7
  52. package/src/renderer/ScoreRenderer/ScorePlayhead.tsx +1 -1
  53. package/src/renderer/ScoreRenderer/ScoreRenderer.tsx +1 -7
  54. package/src/renderer/ScoreRenderer/types.ts +1 -4
  55. package/src/renderer/ScoreRenderer/utils.ts +1 -1
  56. package/src/renderer/layout.ts +15 -0
  57. package/src/renderer/types.ts +1 -1
  58. package/src/renderer/useScoreRecording.ts +72 -20
  59. package/lib/module/musicxml/testfiles/lg-8102429.xml +0 -79620
  60. package/src/musicxml/testfiles/lg-8102429.xml +0 -79620
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vexflow-native",
3
- "version": "1.9.0",
4
- "description": "React native backend for rendering music notation using @shopify/react-native-skia",
3
+ "version": "2.0.1",
4
+ "description": "React Native backend for rendering music notation using react-native-skia",
5
5
  "main": "./lib/module/base/index.js",
6
6
  "types": "./lib/typescript/src/base/index.d.ts",
7
7
  "exports": {
@@ -82,12 +82,12 @@
82
82
  "@eslint/compat": "^1.3.2",
83
83
  "@eslint/eslintrc": "^3.3.1",
84
84
  "@eslint/js": "^9.35.0",
85
- "@react-native/babel-preset": "0.83.0",
86
- "@react-native/eslint-config": "0.83.0",
85
+ "@react-native/babel-preset": "0.86.3",
86
+ "@react-native/eslint-config": "0.86.3",
87
+ "@react-native/jest-preset": "0.86.3",
87
88
  "@release-it/conventional-changelog": "^10.0.1",
88
- "@shopify/react-native-skia": "2.6.2",
89
89
  "@types/jest": "^29.5.14",
90
- "@types/react": "^19.1.12",
90
+ "@types/react": "~19.2.2",
91
91
  "commitlint": "^19.8.1",
92
92
  "del-cli": "^6.0.0",
93
93
  "eslint": "^9.35.0",
@@ -96,12 +96,13 @@
96
96
  "jest": "^29.7.0",
97
97
  "lefthook": "^2.0.3",
98
98
  "prettier": "^2.8.8",
99
- "react": "19.1.0",
100
- "react-native": "0.81.5",
99
+ "react": "19.2.3",
100
+ "react-native": "0.86.3",
101
101
  "react-native-builder-bob": "^0.40.18",
102
- "react-native-gesture-handler": "^2.30.0",
103
- "react-native-reanimated": "^4.2.2",
104
- "react-native-worklets": "^0.7.4",
102
+ "react-native-gesture-handler": "~2.32.0",
103
+ "react-native-reanimated": "4.5.1",
104
+ "react-native-skia": "3.0.3",
105
+ "react-native-worklets": "0.10.1",
105
106
  "release-it": "^19.0.4",
106
107
  "turbo": "^2.5.6",
107
108
  "typedoc": "0.28.20",
@@ -109,12 +110,12 @@
109
110
  "vexflow": "^5.0.0"
110
111
  },
111
112
  "peerDependencies": {
112
- "@shopify/react-native-skia": "*",
113
113
  "react": "*",
114
114
  "react-native": "*",
115
115
  "react-native-gesture-handler": "*",
116
- "react-native-reanimated": "*",
117
- "react-native-worklets": "*",
116
+ "react-native-reanimated": ">=4.0.0",
117
+ "react-native-skia": ">=3.0.0",
118
+ "react-native-worklets": ">=0.7.0",
118
119
  "vexflow": "*"
119
120
  },
120
121
  "workspaces": [
@@ -147,17 +148,20 @@
147
148
  "useTabs": false
148
149
  },
149
150
  "jest": {
150
- "preset": "react-native",
151
+ "preset": "@react-native/jest-preset",
151
152
  "testMatch": [
152
153
  "**/__tests__/**/*.test.[jt]s?(x)"
153
154
  ],
155
+ "moduleNameMapper": {
156
+ "^react-native-skia$": "<rootDir>/src/__tests__/skiaMock"
157
+ },
154
158
  "modulePathIgnorePatterns": [
155
159
  "<rootDir>/example/node_modules",
156
160
  "<rootDir>/lib/",
157
161
  "<rootDir>/prev-implementation/"
158
162
  ],
159
163
  "testPathIgnorePatterns": [
160
- "<rootDir>/example/",
164
+ "<rootDir>/example/(?!src/benchmark/)",
161
165
  "<rootDir>/prev-implementation/"
162
166
  ]
163
167
  },
@@ -1,16 +1,11 @@
1
1
  import type { FontInfo } from 'vexflow';
2
- import {
3
- FontWeight,
4
- FontSlant,
5
- FontWidth,
6
- Skia,
7
- } from '@shopify/react-native-skia';
2
+ import { FontWeight, FontSlant, FontWidth, Skia } from 'react-native-skia';
8
3
  import type {
9
4
  SkFont,
10
5
  SkFontMgr,
11
6
  SkTypeface,
12
7
  SkTypefaceFontProvider,
13
- } from '@shopify/react-native-skia';
8
+ } from 'react-native-skia';
14
9
 
15
10
  // import Logger, { LogCategory } from '../shared/Logger';
16
11
 
@@ -99,10 +94,8 @@ export default class FontManager {
99
94
  private fontProvider: SkTypefaceFontProvider;
100
95
  private defaultFontName: string;
101
96
  private familiesLower: string[];
102
- // Each runtime's clone of a __workletClass instance owns its own caches
103
- // from the moment of capture; entries only ever hold same-usage-pattern
104
- // Skia host objects, which are shareable across reanimated runtimes (the
105
- // provider itself already crosses the same way).
97
+ // Instances never cross runtimes; each runtime builds its own, so these
98
+ // caches are runtime-local.
106
99
  private familyMatchCache: Record<string, string> = {};
107
100
  private skFontCache: Record<string, SkFont> = {};
108
101
  private systemFontMgr: SkFontMgr | null | undefined;
@@ -1,4 +1,4 @@
1
- import type { SkFont } from '@shopify/react-native-skia';
1
+ import type { SkFont } from 'react-native-skia';
2
2
  import { Font } from 'vexflow';
3
3
  import type VexflowRecordingContext from './VexflowRecordingContext';
4
4
 
@@ -4,7 +4,7 @@ import {
4
4
  Skia,
5
5
  useCanvasRef,
6
6
  useCanvasSize,
7
- } from '@shopify/react-native-skia';
7
+ } from 'react-native-skia';
8
8
  import React, { useMemo } from 'react';
9
9
  import { StyleSheet } from 'react-native';
10
10
 
@@ -1,7 +1,4 @@
1
- import {
2
- type SkFont,
3
- type SkTypefaceFontProvider,
4
- } from '@shopify/react-native-skia';
1
+ import { type SkFont, type SkTypefaceFontProvider } from 'react-native-skia';
5
2
  import { Platform } from 'react-native';
6
3
  import { Element, RenderContext as VexflowRenderContext } from 'vexflow';
7
4
  import type { FontInfo } from 'vexflow';
@@ -6,10 +6,12 @@ import {
6
6
  StrokeCap,
7
7
  type SkCanvas,
8
8
  type SkColor,
9
+ type SkImageFilter,
9
10
  type SkPaint,
10
11
  type SkPathBuilder,
12
+ type SkPathEffect,
11
13
  type SkTypefaceFontProvider,
12
- } from '@shopify/react-native-skia';
14
+ } from 'react-native-skia';
13
15
 
14
16
  import FontManager from './FontManager';
15
17
  import type {
@@ -18,7 +20,6 @@ import type {
18
20
  VexflowRecordingLineCap,
19
21
  VexflowRecordingPaint,
20
22
  VexflowRecordingPathCommand,
21
- VexflowRecordingRect,
22
23
  VexflowStyleOverride,
23
24
  } from './VexflowRecordingTypes';
24
25
 
@@ -35,15 +36,27 @@ function shadowBlurToSigma(shadowBlur: number): number {
35
36
  }
36
37
 
37
38
  /**
38
- * Per-replay `css color -> SkColor` cache: a recording uses a handful of
39
- * distinct colors but references them thousands of times.
39
+ * Skia objects one replay call allocates once and reuses across its commands.
40
+ * A recording uses a handful of distinct colors, glows and dashes but
41
+ * references them thousands of times, so each is created on first use and
42
+ * cached by value. Everything here is disposed when the replay ends: under
43
+ * NativeState only GC would free it otherwise.
40
44
  */
41
- type SkColorCache = Record<string, SkColor>;
42
-
43
- function getCachedColor(color: string, cache: SkColorCache): SkColor {
45
+ type ReplayPool = {
46
+ colors: Record<string, SkColor>;
47
+ glows: Record<string, SkImageFilter>;
48
+ dashes: Record<string, SkPathEffect>;
49
+ fillPaint: SkPaint;
50
+ strokePaint: SkPaint;
51
+ /** Created on the first `clearRect`; most recordings never clear a rect. */
52
+ clearPaint: SkPaint | null;
53
+ pathBuilder: SkPathBuilder;
54
+ };
55
+
56
+ function getCachedColor(color: string, pool: ReplayPool): SkColor {
44
57
  'worklet';
45
58
 
46
- return (cache[color] ??= Skia.Color(color));
59
+ return (pool.colors[color] ??= Skia.Color(color));
47
60
  }
48
61
 
49
62
  /**
@@ -55,7 +68,7 @@ function getCachedColor(color: string, cache: SkColorCache): SkColor {
55
68
  function applyGlow(
56
69
  skPaint: SkPaint,
57
70
  paint: VexflowRecordingPaint,
58
- colorCache: SkColorCache
71
+ pool: ReplayPool
59
72
  ) {
60
73
  'worklet';
61
74
 
@@ -67,22 +80,34 @@ function applyGlow(
67
80
  }
68
81
 
69
82
  const sigma = shadowBlurToSigma(paint.shadowBlur ?? 0);
83
+ const key = `${paint.shadowColor}|${sigma}`;
70
84
 
71
85
  skPaint.setImageFilter(
72
- Skia.ImageFilter.MakeDropShadow(
86
+ (pool.glows[key] ??= Skia.ImageFilter.MakeDropShadow(
73
87
  0,
74
88
  0,
75
89
  sigma,
76
90
  sigma,
77
- getCachedColor(paint.shadowColor, colorCache)
78
- )
91
+ getCachedColor(paint.shadowColor, pool)
92
+ ))
79
93
  );
80
94
  }
81
95
 
82
- function toSkiaRect(rect: VexflowRecordingRect) {
96
+ function applyDash(
97
+ skPaint: SkPaint,
98
+ lineDash: number[] | undefined,
99
+ pool: ReplayPool
100
+ ) {
83
101
  'worklet';
84
102
 
85
- return Skia.XYWHRect(rect.x, rect.y, rect.width, rect.height);
103
+ if (lineDash == null || lineDash.length === 0) {
104
+ skPaint.setPathEffect(null);
105
+ return;
106
+ }
107
+
108
+ skPaint.setPathEffect(
109
+ (pool.dashes[lineDash.join(',')] ??= Skia.PathEffect.MakeDash(lineDash))
110
+ );
86
111
  }
87
112
 
88
113
  function mapRecordingLineCap(cap: VexflowRecordingLineCap): StrokeCap {
@@ -106,67 +131,86 @@ function mapRecordingLineCap(cap: VexflowRecordingLineCap): StrokeCap {
106
131
  * state (glow filter, dash effect) is explicitly reset on every configure so
107
132
  * nothing bleeds between commands.
108
133
  */
109
- function createPooledFillPaint(): SkPaint {
134
+ function createReplayPool(): ReplayPool {
110
135
  'worklet';
111
136
 
112
- const skPaint = Skia.Paint();
113
- skPaint.setStyle(PaintStyle.Fill);
114
- skPaint.setAntiAlias(true);
137
+ const fillPaint = Skia.Paint();
138
+ fillPaint.setStyle(PaintStyle.Fill);
139
+ fillPaint.setAntiAlias(true);
115
140
 
116
- return skPaint;
141
+ const strokePaint = Skia.Paint();
142
+ strokePaint.setStyle(PaintStyle.Stroke);
143
+ strokePaint.setAntiAlias(true);
144
+
145
+ return {
146
+ colors: {},
147
+ glows: {},
148
+ dashes: {},
149
+ fillPaint,
150
+ strokePaint,
151
+ clearPaint: null,
152
+ pathBuilder: Skia.PathBuilder.Make(),
153
+ };
117
154
  }
118
155
 
119
- function createPooledStrokePaint(): SkPaint {
156
+ /**
157
+ * Paints keep their own reference to an image filter / path effect, and a
158
+ * recorded picture copies the paint state it drew with, so disposing the JS
159
+ * handles here never invalidates what was drawn.
160
+ */
161
+ function disposeReplayPool(pool: ReplayPool) {
120
162
  'worklet';
121
163
 
122
- const skPaint = Skia.Paint();
123
- skPaint.setStyle(PaintStyle.Stroke);
124
- skPaint.setAntiAlias(true);
125
-
126
- return skPaint;
164
+ for (const key in pool.glows) {
165
+ pool.glows[key]!.dispose();
166
+ }
167
+ for (const key in pool.dashes) {
168
+ pool.dashes[key]!.dispose();
169
+ }
170
+ pool.fillPaint.dispose();
171
+ pool.strokePaint.dispose();
172
+ pool.clearPaint?.dispose();
173
+ pool.pathBuilder.dispose();
127
174
  }
128
175
 
129
176
  function configureFillPaint(
130
- skPaint: SkPaint,
131
177
  paint: VexflowRecordingPaint,
132
- colorCache: SkColorCache
178
+ pool: ReplayPool
133
179
  ): SkPaint {
134
180
  'worklet';
135
181
 
136
- skPaint.setColor(getCachedColor(paint.color, colorCache));
137
- applyGlow(skPaint, paint, colorCache);
182
+ const skPaint = pool.fillPaint;
183
+ skPaint.setColor(getCachedColor(paint.color, pool));
184
+ applyGlow(skPaint, paint, pool);
138
185
 
139
186
  return skPaint;
140
187
  }
141
188
 
142
189
  function configureStrokePaint(
143
- skPaint: SkPaint,
144
190
  paint: VexflowRecordingPaint,
145
- colorCache: SkColorCache
191
+ pool: ReplayPool
146
192
  ): SkPaint {
147
193
  'worklet';
148
194
 
149
- skPaint.setColor(getCachedColor(paint.color, colorCache));
195
+ const skPaint = pool.strokePaint;
196
+ skPaint.setColor(getCachedColor(paint.color, pool));
150
197
  skPaint.setStrokeWidth(paint.strokeWidth ?? 1);
151
198
  skPaint.setStrokeCap(mapRecordingLineCap(paint.strokeCap ?? 'butt'));
152
- applyGlow(skPaint, paint, colorCache);
153
-
154
- if (paint.lineDash != null && paint.lineDash.length > 0) {
155
- skPaint.setPathEffect(Skia.PathEffect.MakeDash(paint.lineDash));
156
- } else {
157
- skPaint.setPathEffect(null);
158
- }
199
+ applyGlow(skPaint, paint, pool);
200
+ applyDash(skPaint, paint.lineDash, pool);
159
201
 
160
202
  return skPaint;
161
203
  }
162
204
 
163
- function createClearPaint(): SkPaint {
205
+ function getClearPaint(pool: ReplayPool): SkPaint {
164
206
  'worklet';
165
207
 
166
- const clearPaint = Skia.Paint();
167
- clearPaint.setBlendMode(BlendMode.Clear);
208
+ if (pool.clearPaint == null) {
209
+ pool.clearPaint = Skia.Paint();
210
+ pool.clearPaint.setBlendMode(BlendMode.Clear);
211
+ }
168
212
 
169
- return clearPaint;
213
+ return pool.clearPaint;
170
214
  }
171
215
 
172
216
  type PaintKind = 'fill' | 'stroke';
@@ -261,14 +305,10 @@ function applyPathCommand(
261
305
  builder.quadTo(command.cpx, command.cpy, command.x, command.y);
262
306
  break;
263
307
  case 'addRect':
264
- builder.addRect(toSkiaRect(command.rect));
308
+ builder.addRect(command.rect);
265
309
  break;
266
310
  case 'addArc':
267
- builder.addArc(
268
- toSkiaRect(command.rect),
269
- command.startDegrees,
270
- command.sweepDegrees
271
- );
311
+ builder.addArc(command.rect, command.startDegrees, command.sweepDegrees);
272
312
  break;
273
313
  case 'close':
274
314
  builder.close();
@@ -278,16 +318,26 @@ function applyPathCommand(
278
318
  }
279
319
  }
280
320
 
281
- function buildPath(path: readonly VexflowRecordingPathCommand[]) {
321
+ /**
322
+ * Build the recorded path in the pooled builder (`detach` hands over the path
323
+ * and resets the builder for the next command), draw it, and free it at once:
324
+ * the canvas copies the path at the draw call.
325
+ */
326
+ function drawRecordedPath(
327
+ canvas: SkCanvas,
328
+ path: readonly VexflowRecordingPathCommand[],
329
+ skPaint: SkPaint,
330
+ builder: SkPathBuilder
331
+ ) {
282
332
  'worklet';
283
333
 
284
- const builder = Skia.PathBuilder.Make();
285
-
286
334
  for (const command of path) {
287
335
  applyPathCommand(builder, command);
288
336
  }
289
337
 
290
- return builder.build();
338
+ const skPath = builder.detach();
339
+ canvas.drawPath(skPath, skPaint);
340
+ skPath.dispose();
291
341
  }
292
342
 
293
343
  export function renderVexflowRecordingCommands(
@@ -314,98 +364,100 @@ export function renderVexflowRecordingCommands(
314
364
 
315
365
  const fontManager =
316
366
  replayFontManager ?? new FontManager(fontProvider, defaultFont);
317
- const colorCache: SkColorCache = {};
318
- const fillPaint = createPooledFillPaint();
319
- const strokePaint = createPooledStrokePaint();
320
-
321
- for (const command of commands) {
322
- switch (command.type) {
323
- case 'clear':
324
- canvas.clear(getCachedColor(command.color, colorCache));
325
- break;
326
- case 'save':
327
- canvas.save();
328
- break;
329
- case 'restore':
330
- canvas.restore();
331
- break;
332
- case 'scale':
333
- canvas.scale(command.x, command.y);
334
- break;
335
- case 'translate':
336
- canvas.translate(command.x, command.y);
337
- break;
338
- case 'clipRect':
339
- canvas.clipRect(toSkiaRect(command.rect), ClipOp.Intersect, true);
340
- break;
341
- case 'fillRect':
342
- canvas.drawRect(
343
- toSkiaRect(command.rect),
344
- configureFillPaint(
345
- fillPaint,
346
- resolveStyle(
347
- command.paint,
348
- command.groupId,
349
- 'fill',
350
- styleOverrides
351
- ),
352
- colorCache
353
- )
354
- );
355
- break;
356
- case 'clearRect':
357
- canvas.drawRect(toSkiaRect(command.rect), createClearPaint());
358
- break;
359
- case 'fillPath':
360
- canvas.drawPath(
361
- buildPath(command.path),
362
- configureFillPaint(
363
- fillPaint,
364
- resolveStyle(
365
- command.paint,
366
- command.groupId,
367
- 'fill',
368
- styleOverrides
367
+ const pool = createReplayPool();
368
+
369
+ try {
370
+ for (const command of commands) {
371
+ switch (command.type) {
372
+ case 'clear':
373
+ canvas.clear(getCachedColor(command.color, pool));
374
+ break;
375
+ case 'save':
376
+ canvas.save();
377
+ break;
378
+ case 'restore':
379
+ canvas.restore();
380
+ break;
381
+ case 'scale':
382
+ canvas.scale(command.x, command.y);
383
+ break;
384
+ case 'translate':
385
+ canvas.translate(command.x, command.y);
386
+ break;
387
+ case 'clipRect':
388
+ canvas.clipRect(command.rect, ClipOp.Intersect, true);
389
+ break;
390
+ case 'fillRect':
391
+ canvas.drawRect(
392
+ command.rect,
393
+ configureFillPaint(
394
+ resolveStyle(
395
+ command.paint,
396
+ command.groupId,
397
+ 'fill',
398
+ styleOverrides
399
+ ),
400
+ pool
401
+ )
402
+ );
403
+ break;
404
+ case 'clearRect':
405
+ canvas.drawRect(command.rect, getClearPaint(pool));
406
+ break;
407
+ case 'fillPath':
408
+ drawRecordedPath(
409
+ canvas,
410
+ command.path,
411
+ configureFillPaint(
412
+ resolveStyle(
413
+ command.paint,
414
+ command.groupId,
415
+ 'fill',
416
+ styleOverrides
417
+ ),
418
+ pool
369
419
  ),
370
- colorCache
371
- )
372
- );
373
- break;
374
- case 'strokePath':
375
- canvas.drawPath(
376
- buildPath(command.path),
377
- configureStrokePaint(
378
- strokePaint,
379
- resolveStyle(
380
- command.paint,
381
- command.groupId,
382
- 'stroke',
383
- styleOverrides
420
+ pool.pathBuilder
421
+ );
422
+ break;
423
+ case 'strokePath':
424
+ drawRecordedPath(
425
+ canvas,
426
+ command.path,
427
+ configureStrokePaint(
428
+ resolveStyle(
429
+ command.paint,
430
+ command.groupId,
431
+ 'stroke',
432
+ styleOverrides
433
+ ),
434
+ pool
384
435
  ),
385
- colorCache
386
- )
387
- );
388
- break;
389
- case 'fillText':
390
- canvas.drawText(
391
- command.text,
392
- command.x,
393
- command.y,
394
- configureFillPaint(
395
- fillPaint,
396
- resolveStyle(
397
- command.paint,
398
- command.groupId,
399
- 'fill',
400
- styleOverrides
436
+ pool.pathBuilder
437
+ );
438
+ break;
439
+ case 'fillText':
440
+ canvas.drawText(
441
+ command.text,
442
+ command.x,
443
+ command.y,
444
+ configureFillPaint(
445
+ resolveStyle(
446
+ command.paint,
447
+ command.groupId,
448
+ 'fill',
449
+ styleOverrides
450
+ ),
451
+ pool
401
452
  ),
402
- colorCache
403
- ),
404
- createFont(fontManager, command.font)
405
- );
406
- break;
407
- default:
408
- assertNever(command);
453
+ createFont(fontManager, command.font)
454
+ );
455
+ break;
456
+ default:
457
+ assertNever(command);
458
+ }
409
459
  }
460
+ } finally {
461
+ disposeReplayPool(pool);
410
462
  }
411
463
  }
package/src/base/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SkTypefaceFontProvider } from '@shopify/react-native-skia';
1
+ import type { SkTypefaceFontProvider } from 'react-native-skia';
2
2
  import type VexflowRecordingContext from './VexflowRecordingContext';
3
3
 
4
4
  export interface OnDrawParams {
@@ -1,10 +1,7 @@
1
1
  import { useEffect, useMemo } from 'react';
2
- import { Picture, type SkPicture } from '@shopify/react-native-skia';
3
- import {
4
- runOnUI,
5
- useDerivedValue,
6
- useSharedValue,
7
- } from 'react-native-reanimated';
2
+ import { Picture, type SkPicture } from 'react-native-skia';
3
+ import { useDerivedValue, useSharedValue } from 'react-native-reanimated';
4
+ import { scheduleOnUI } from 'react-native-worklets';
8
5
 
9
6
  import type { VexflowRecordingCommand } from '../../base';
10
7
  import { isVexflowNativeDebugEnabled } from '../../shared/debug';
@@ -110,7 +107,7 @@ export default function ScoreOverlayPicture({
110
107
 
111
108
  useEffect(() => {
112
109
  return () => {
113
- runOnUI(disposeOverlayPictures)(disposal);
110
+ scheduleOnUI(disposeOverlayPictures, disposal);
114
111
  };
115
112
  }, [disposal]);
116
113
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { RoundedRect, Skia, type SkRRect } from '@shopify/react-native-skia';
2
+ import { RoundedRect, Skia, type SkRRect } from 'react-native-skia';
3
3
  import { useDerivedValue, type SharedValue } from 'react-native-reanimated';
4
4
 
5
5
  import type {
@@ -1,12 +1,6 @@
1
1
  import type React from 'react';
2
2
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import {
4
- Canvas,
5
- Group,
6
- Picture,
7
- Skia,
8
- useCanvasRef,
9
- } from '@shopify/react-native-skia';
3
+ import { Canvas, Group, Picture, Skia, useCanvasRef } from 'react-native-skia';
10
4
  import { StyleSheet, View, type LayoutChangeEvent } from 'react-native';
11
5
  import { GestureDetector } from 'react-native-gesture-handler';
12
6
  import { useDerivedValue } from 'react-native-reanimated';
@@ -1,7 +1,4 @@
1
- import type {
2
- SkPicture,
3
- SkTypefaceFontProvider,
4
- } from '@shopify/react-native-skia';
1
+ import type { SkPicture, SkTypefaceFontProvider } from 'react-native-skia';
5
2
  import type { GestureType } from 'react-native-gesture-handler';
6
3
  import type { SharedValue } from 'react-native-reanimated';
7
4
 
@@ -3,7 +3,7 @@ import {
3
3
  type SkPicture,
4
4
  type SkTypefaceFontProvider,
5
5
  type Transforms3d,
6
- } from '@shopify/react-native-skia';
6
+ } from 'react-native-skia';
7
7
  import type { SharedValue } from 'react-native-reanimated';
8
8
 
9
9
  import FontManager from '../../base/FontManager';