@shopify/react-native-skia 0.1.214 → 0.1.216

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/cpp/api/JsiSkMatrix.h +31 -0
  2. package/cpp/api/JsiSkPath.h +15 -7
  3. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  4. package/lib/commonjs/animation/functions/interpolatePaths.js +4 -4
  5. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  6. package/lib/commonjs/external/reanimated/index.d.ts +2 -1
  7. package/lib/commonjs/external/reanimated/index.js +17 -4
  8. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  9. package/lib/commonjs/external/reanimated/interpolators.d.ts +9 -0
  10. package/lib/commonjs/external/reanimated/interpolators.js +56 -0
  11. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -0
  12. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +8 -6
  13. package/lib/commonjs/external/reanimated/moduleWrapper.js +6 -11
  14. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  15. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +1 -0
  16. package/lib/commonjs/external/reanimated/renderHelpers.js +16 -3
  17. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  18. package/lib/commonjs/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  19. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +53 -0
  20. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -0
  21. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  22. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js +2 -1
  23. package/lib/commonjs/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  24. package/lib/commonjs/mock/index.js +8 -0
  25. package/lib/commonjs/mock/index.js.map +1 -1
  26. package/lib/commonjs/renderer/HostConfig.js +6 -5
  27. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  28. package/lib/commonjs/skia/core/AnimatedImage.d.ts +0 -1
  29. package/lib/commonjs/skia/core/AnimatedImage.js +1 -45
  30. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -1
  31. package/lib/commonjs/skia/types/Matrix.d.ts +4 -0
  32. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  33. package/lib/commonjs/skia/types/Path/Path.d.ts +10 -9
  34. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +6 -0
  36. package/lib/commonjs/skia/web/JsiSkMatrix.js +33 -5
  37. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkPath.d.ts +9 -9
  39. package/lib/commonjs/skia/web/JsiSkPath.js +15 -2
  40. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  41. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  42. package/lib/module/animation/functions/interpolatePaths.js +4 -4
  43. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  44. package/lib/module/external/reanimated/index.d.ts +2 -1
  45. package/lib/module/external/reanimated/index.js +2 -1
  46. package/lib/module/external/reanimated/index.js.map +1 -1
  47. package/lib/module/external/reanimated/interpolators.d.ts +9 -0
  48. package/lib/module/external/reanimated/interpolators.js +34 -0
  49. package/lib/module/external/reanimated/interpolators.js.map +1 -0
  50. package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -6
  51. package/lib/module/external/reanimated/moduleWrapper.js +4 -7
  52. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  53. package/lib/module/external/reanimated/renderHelpers.d.ts +1 -0
  54. package/lib/module/external/reanimated/renderHelpers.js +12 -3
  55. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  56. package/lib/module/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  57. package/lib/module/external/reanimated/useAnimatedImageValue.js +41 -0
  58. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -0
  59. package/lib/module/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  60. package/lib/module/external/reanimated/useDerivedValueOnJS.js +3 -2
  61. package/lib/module/external/reanimated/useDerivedValueOnJS.js.map +1 -1
  62. package/lib/module/mock/index.js +8 -0
  63. package/lib/module/mock/index.js.map +1 -1
  64. package/lib/module/renderer/HostConfig.js +2 -1
  65. package/lib/module/renderer/HostConfig.js.map +1 -1
  66. package/lib/module/skia/core/AnimatedImage.d.ts +0 -1
  67. package/lib/module/skia/core/AnimatedImage.js +0 -40
  68. package/lib/module/skia/core/AnimatedImage.js.map +1 -1
  69. package/lib/module/skia/types/Matrix.d.ts +4 -0
  70. package/lib/module/skia/types/Matrix.js.map +1 -1
  71. package/lib/module/skia/types/Path/Path.d.ts +10 -9
  72. package/lib/module/skia/types/Path/Path.js.map +1 -1
  73. package/lib/module/skia/web/JsiSkMatrix.d.ts +6 -0
  74. package/lib/module/skia/web/JsiSkMatrix.js +33 -5
  75. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkPath.d.ts +9 -9
  77. package/lib/module/skia/web/JsiSkPath.js +15 -2
  78. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  79. package/lib/typescript/jestEnv.d.mts +5 -0
  80. package/lib/typescript/jestSetup.d.mts +1 -0
  81. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  82. package/lib/typescript/src/external/reanimated/index.d.ts +2 -1
  83. package/lib/typescript/src/external/reanimated/interpolators.d.ts +9 -0
  84. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -6
  85. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +1 -0
  86. package/lib/typescript/src/external/reanimated/useAnimatedImageValue.d.ts +2 -0
  87. package/lib/typescript/src/external/reanimated/useDerivedValueOnJS.d.ts +1 -2
  88. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +0 -1
  89. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -0
  90. package/lib/typescript/src/skia/types/Path/Path.d.ts +10 -9
  91. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +6 -0
  92. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +9 -9
  93. package/package.json +4 -3
  94. package/src/animation/functions/interpolatePaths.ts +7 -4
  95. package/src/external/reanimated/index.ts +2 -1
  96. package/src/external/reanimated/interpolators.ts +89 -0
  97. package/src/external/reanimated/moduleWrapper.ts +33 -16
  98. package/src/external/reanimated/renderHelpers.ts +14 -5
  99. package/src/external/reanimated/useAnimatedImageValue.ts +51 -0
  100. package/src/external/reanimated/useDerivedValueOnJS.ts +4 -3
  101. package/src/mock/index.ts +5 -0
  102. package/src/renderer/HostConfig.ts +3 -1
  103. package/src/skia/core/AnimatedImage.ts +0 -47
  104. package/src/skia/types/Matrix.ts +4 -0
  105. package/src/skia/types/Path/Path.ts +10 -9
  106. package/src/skia/web/JsiSkMatrix.ts +33 -27
  107. package/src/skia/web/JsiSkPath.ts +15 -2
  108. package/globalJestSetup.js +0 -6
  109. package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +0 -8
  110. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +0 -49
  111. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +0 -1
  112. package/lib/module/external/reanimated/useSharedValueEffect.d.ts +0 -8
  113. package/lib/module/external/reanimated/useSharedValueEffect.js +0 -39
  114. package/lib/module/external/reanimated/useSharedValueEffect.js.map +0 -1
  115. package/lib/typescript/globalJestSetup.d.ts +0 -2
  116. package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +0 -8
  117. package/src/external/reanimated/useSharedValueEffect.ts +0 -55
@@ -117,10 +117,12 @@ class JsiSkPath extends _Host.HostObject {
117
117
 
118
118
  setFillType(fill) {
119
119
  this.ref.setFillType((0, _Host.ckEnum)(fill));
120
+ return this;
120
121
  }
121
122
 
122
123
  setIsVolatile(volatile) {
123
124
  this.ref.setIsVolatile(volatile);
125
+ return this;
124
126
  }
125
127
 
126
128
  stroke(opts) {
@@ -137,14 +139,17 @@ class JsiSkPath extends _Host.HostObject {
137
139
 
138
140
  close() {
139
141
  this.ref.close();
142
+ return this;
140
143
  }
141
144
 
142
145
  reset() {
143
146
  this.ref.reset();
147
+ return this;
144
148
  }
145
149
 
146
150
  rewind() {
147
151
  this.ref.rewind();
152
+ return this;
148
153
  }
149
154
 
150
155
  computeTightBounds() {
@@ -202,10 +207,12 @@ class JsiSkPath extends _Host.HostObject {
202
207
 
203
208
  quadTo(x1, y1, x2, y2) {
204
209
  this.ref.quadTo(x1, y1, x2, y2);
210
+ return this;
205
211
  }
206
212
 
207
213
  addRect(rect, isCCW) {
208
214
  this.ref.addRect(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);
215
+ return this;
209
216
  }
210
217
 
211
218
  addRRect(rrect, isCCW) {
@@ -260,16 +267,22 @@ class JsiSkPath extends _Host.HostObject {
260
267
 
261
268
  transform(m3) {
262
269
  this.ref.transform(_JsiSkMatrix.JsiSkMatrix.fromValue(m3));
270
+ return this;
263
271
  }
264
272
 
265
- interpolate(end, t) {
273
+ interpolate(end, t, output) {
266
274
  const path = this.CanvasKit.Path.MakeFromPathInterpolation(this.ref, JsiSkPath.fromValue(end), t);
267
275
 
268
276
  if (path === null) {
269
277
  return null;
270
278
  }
271
279
 
272
- return new JsiSkPath(this.CanvasKit, path);
280
+ if (output) {
281
+ output.ref = path;
282
+ return output;
283
+ } else {
284
+ return new JsiSkPath(this.CanvasKit, path);
285
+ }
273
286
  }
274
287
 
275
288
  isInterpolatable(path2) {
@@ -1 +1 @@
1
- {"version":3,"names":["CommandCount","PathVerb","Move","Line","Quad","Conic","Cubic","Close","pinT","t","Math","min","max","JsiSkPath","HostObject","constructor","CanvasKit","ref","delete","addPath","src","matrix","extend","args","fromValue","JsiSkMatrix","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","JsiSkRect","addOval","isCCW","startIndex","countPoints","addPoly","points","close","map","p","Array","from","JsiSkPoint","flat","moveTo","x","y","lineTo","makeAsWinding","result","offset","dx","dy","rArcTo","rx","ry","xAxisRotateInDegrees","useSmallArc","rConicTo","dx1","dy1","dx2","dy2","w","rCubicTo","cpx1","cpy1","cpx2","cpy2","rMoveTo","rLineTo","rQuadTo","x1","y1","x2","y2","setFillType","fill","ckEnum","setIsVolatile","volatile","stroke","opts","undefined","width","miter_limit","precision","join","optEnum","cap","reset","rewind","computeTightBounds","arcToOval","forceMoveTo","arcToRotated","arcToTangent","radius","conicTo","contains","copy","cubicTo","dash","on","off","phase","equals","other","getBounds","getFillType","value","quadTo","addRect","rect","addRRect","rrect","JsiSkRRect","getPoint","index","isEmpty","isVolatile","addCircle","r","getLastPt","op","path","simplify","toSVGString","trim","start","stop","isComplement","startT","stopT","transform","m3","interpolate","end","Path","MakeFromPathInterpolation","isInterpolatable","path2","CanInterpolate","toCmds","cmds","reduce","acc","cmd","i","push","current","length"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, Path } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n SkRRect,\n StrokeOpts,\n} from \"../types\";\n\nimport { ckEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nconst pinT = (t: number) => Math.min(Math.max(t, 0), 1);\n\nexport class JsiSkPath extends HostObject<Path, \"Path\"> implements SkPath {\n constructor(CanvasKit: CanvasKit, ref: Path) {\n super(CanvasKit, ref, \"Path\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n addPath(src: SkPath, matrix?: SkMatrix, extend = false) {\n const args = [\n JsiSkPath.fromValue(src),\n ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),\n extend,\n ];\n this.ref.addPath(...args);\n return this;\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n this.ref.addPoly(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n moveTo(x: number, y: number) {\n this.ref.moveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n this.ref.lineTo(x, y);\n return this;\n }\n\n makeAsWinding() {\n const result = this.ref.makeAsWinding();\n return result === null ? result : this;\n }\n\n offset(dx: number, dy: number) {\n this.ref.offset(dx, dy);\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {\n this.ref.rConicTo(dx1, dy1, dx2, dy2, w);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n this.ref.rLineTo(x, y);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n setFillType(fill: FillType) {\n this.ref.setFillType(ckEnum(fill));\n }\n\n setIsVolatile(volatile: boolean) {\n this.ref.setIsVolatile(volatile);\n }\n\n stroke(opts?: StrokeOpts) {\n const result = this.ref.stroke(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.width,\n precision: opts.width,\n join: optEnum(opts.join),\n cap: optEnum(opts.cap),\n }\n );\n return result === null ? result : this;\n }\n\n close() {\n this.ref.close();\n }\n\n reset() {\n this.ref.reset();\n }\n\n rewind() {\n this.ref.rewind();\n }\n\n computeTightBounds(): SkRect {\n return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n contains(x: number, y: number) {\n return this.ref.contains(x, y);\n }\n\n copy() {\n return new JsiSkPath(this.CanvasKit, this.ref.copy());\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n dash(on: number, off: number, phase: number) {\n return this.ref.dash(on, off, phase);\n }\n\n equals(other: SkPath) {\n return this.ref.equals(JsiSkPath.fromValue(other));\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType() {\n return this.ref.getFillType().value;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.quadTo(x1, y1, x2, y2);\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n }\n\n addRRect(rrect: SkRRect, isCCW?: boolean) {\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n getPoint(index: number) {\n return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return this.ref.isVolatile();\n }\n\n addCircle(x: number, y: number, r: number) {\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n getLastPt() {\n return new JsiSkPoint(\n this.CanvasKit,\n this.ref.getPoint(this.ref.countPoints() - 1)\n );\n }\n\n op(path: SkPath, op: PathOp) {\n return this.ref.op(JsiSkPath.fromValue(path), ckEnum(op));\n }\n\n simplify() {\n return this.ref.simplify();\n }\n\n toSVGString() {\n return this.ref.toSVGString();\n }\n\n trim(start: number, stop: number, isComplement: boolean) {\n const startT = pinT(start);\n const stopT = pinT(stop);\n if (startT === 0 && stopT === 1) {\n return this;\n }\n const result = this.ref.trim(startT, stopT, isComplement);\n return result === null ? result : this;\n }\n\n transform(m3: SkMatrix) {\n this.ref.transform(JsiSkMatrix.fromValue(m3));\n }\n\n interpolate(end: SkPath, t: number) {\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(\n this.ref,\n JsiSkPath.fromValue(end),\n t\n );\n if (path === null) {\n return null;\n }\n return new JsiSkPath(this.CanvasKit, path);\n }\n\n isInterpolatable(path2: SkPath): boolean {\n return this.CanvasKit.Path.CanInterpolate(\n this.ref,\n JsiSkPath.fromValue(path2)\n );\n }\n\n toCmds() {\n const cmds = this.ref.toCmds();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAaA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG;EACnB,CAACC,eAAA,CAASC,IAAV,GAAiB,CADE;EAEnB,CAACD,eAAA,CAASE,IAAV,GAAiB,CAFE;EAGnB,CAACF,eAAA,CAASG,IAAV,GAAiB,CAHE;EAInB,CAACH,eAAA,CAASI,KAAV,GAAkB,CAJC;EAKnB,CAACJ,eAAA,CAASK,KAAV,GAAkB,CALC;EAMnB,CAACL,eAAA,CAASM,KAAV,GAAkB;AANC,CAArB;;AASA,MAAMC,IAAI,GAAIC,CAAD,IAAeC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASH,CAAT,EAAY,CAAZ,CAAT,EAAyB,CAAzB,CAA5B;;AAEO,MAAMI,SAAN,SAAwBC,gBAAxB,CAAmE;EACxEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;;IAD2C,iCAInC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN4C;EAE5C;;EAMDC,OAAO,CAACC,GAAD,EAAcC,MAAd,EAAiD;IAAA,IAAhBC,MAAgB,uEAA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K,MAAJ,GAAa,CAAd,CAAnB;;MACA,IAAID,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;QACxBD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACA,MAAMI,MAAM,GAAGvJ,YAAY,CAACsJ,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF,CAND,MAMO;QACL,MAAME,MAAM,GAAGvJ,YAAY,CAACsJ,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACC,MAAR,GAAiBA,MAArB,EAA6B;UAC3BD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACD;;QACD,IAAIG,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF;;MACD,OAAOH,GAAP;IACD,CArBc,EAqBZ,EArBY,CAAf;IAsBA,OAAOjG,MAAP;EACD;;AA3VuE"}
1
+ {"version":3,"names":["CommandCount","PathVerb","Move","Line","Quad","Conic","Cubic","Close","pinT","t","Math","min","max","JsiSkPath","HostObject","constructor","CanvasKit","ref","delete","addPath","src","matrix","extend","args","fromValue","JsiSkMatrix","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","JsiSkRect","addOval","isCCW","startIndex","countPoints","addPoly","points","close","map","p","Array","from","JsiSkPoint","flat","moveTo","x","y","lineTo","makeAsWinding","result","offset","dx","dy","rArcTo","rx","ry","xAxisRotateInDegrees","useSmallArc","rConicTo","dx1","dy1","dx2","dy2","w","rCubicTo","cpx1","cpy1","cpx2","cpy2","rMoveTo","rLineTo","rQuadTo","x1","y1","x2","y2","setFillType","fill","ckEnum","setIsVolatile","volatile","stroke","opts","undefined","width","miter_limit","precision","join","optEnum","cap","reset","rewind","computeTightBounds","arcToOval","forceMoveTo","arcToRotated","arcToTangent","radius","conicTo","contains","copy","cubicTo","dash","on","off","phase","equals","other","getBounds","getFillType","value","quadTo","addRect","rect","addRRect","rrect","JsiSkRRect","getPoint","index","isEmpty","isVolatile","addCircle","r","getLastPt","op","path","simplify","toSVGString","trim","start","stop","isComplement","startT","stopT","transform","m3","interpolate","end","output","Path","MakeFromPathInterpolation","isInterpolatable","path2","CanInterpolate","toCmds","cmds","reduce","acc","cmd","i","push","current","length"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, Path } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n SkRRect,\n StrokeOpts,\n} from \"../types\";\n\nimport { ckEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nconst pinT = (t: number) => Math.min(Math.max(t, 0), 1);\n\nexport class JsiSkPath extends HostObject<Path, \"Path\"> implements SkPath {\n constructor(CanvasKit: CanvasKit, ref: Path) {\n super(CanvasKit, ref, \"Path\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n addPath(src: SkPath, matrix?: SkMatrix, extend = false) {\n const args = [\n JsiSkPath.fromValue(src),\n ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),\n extend,\n ];\n this.ref.addPath(...args);\n return this;\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n this.ref.addPoly(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n moveTo(x: number, y: number) {\n this.ref.moveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n this.ref.lineTo(x, y);\n return this;\n }\n\n makeAsWinding() {\n const result = this.ref.makeAsWinding();\n return result === null ? result : this;\n }\n\n offset(dx: number, dy: number) {\n this.ref.offset(dx, dy);\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {\n this.ref.rConicTo(dx1, dy1, dx2, dy2, w);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n this.ref.rLineTo(x, y);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n setFillType(fill: FillType) {\n this.ref.setFillType(ckEnum(fill));\n return this;\n }\n\n setIsVolatile(volatile: boolean) {\n this.ref.setIsVolatile(volatile);\n return this;\n }\n\n stroke(opts?: StrokeOpts) {\n const result = this.ref.stroke(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.width,\n precision: opts.width,\n join: optEnum(opts.join),\n cap: optEnum(opts.cap),\n }\n );\n return result === null ? result : this;\n }\n\n close() {\n this.ref.close();\n return this;\n }\n\n reset() {\n this.ref.reset();\n return this;\n }\n\n rewind() {\n this.ref.rewind();\n return this;\n }\n\n computeTightBounds(): SkRect {\n return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n contains(x: number, y: number) {\n return this.ref.contains(x, y);\n }\n\n copy() {\n return new JsiSkPath(this.CanvasKit, this.ref.copy());\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n dash(on: number, off: number, phase: number) {\n return this.ref.dash(on, off, phase);\n }\n\n equals(other: SkPath) {\n return this.ref.equals(JsiSkPath.fromValue(other));\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType() {\n return this.ref.getFillType().value;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.quadTo(x1, y1, x2, y2);\n return this;\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n return this;\n }\n\n addRRect(rrect: SkRRect, isCCW?: boolean) {\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n getPoint(index: number) {\n return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return this.ref.isVolatile();\n }\n\n addCircle(x: number, y: number, r: number) {\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n getLastPt() {\n return new JsiSkPoint(\n this.CanvasKit,\n this.ref.getPoint(this.ref.countPoints() - 1)\n );\n }\n\n op(path: SkPath, op: PathOp) {\n return this.ref.op(JsiSkPath.fromValue(path), ckEnum(op));\n }\n\n simplify() {\n return this.ref.simplify();\n }\n\n toSVGString() {\n return this.ref.toSVGString();\n }\n\n trim(start: number, stop: number, isComplement: boolean) {\n const startT = pinT(start);\n const stopT = pinT(stop);\n if (startT === 0 && stopT === 1) {\n return this;\n }\n const result = this.ref.trim(startT, stopT, isComplement);\n return result === null ? result : this;\n }\n\n transform(m3: SkMatrix) {\n this.ref.transform(JsiSkMatrix.fromValue(m3));\n return this;\n }\n\n interpolate(end: SkPath, t: number, output?: SkPath) {\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(\n this.ref,\n JsiSkPath.fromValue(end),\n t\n );\n if (path === null) {\n return null;\n }\n if (output) {\n (output as JsiSkPath).ref = path;\n return output;\n } else {\n return new JsiSkPath(this.CanvasKit, path);\n }\n }\n\n isInterpolatable(path2: SkPath): boolean {\n return this.CanvasKit.Path.CanInterpolate(\n this.ref,\n JsiSkPath.fromValue(path2)\n );\n }\n\n toCmds() {\n const cmds = this.ref.toCmds();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAaA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,YAAY,GAAG;EACnB,CAACC,eAAA,CAASC,IAAV,GAAiB,CADE;EAEnB,CAACD,eAAA,CAASE,IAAV,GAAiB,CAFE;EAGnB,CAACF,eAAA,CAASG,IAAV,GAAiB,CAHE;EAInB,CAACH,eAAA,CAASI,KAAV,GAAkB,CAJC;EAKnB,CAACJ,eAAA,CAASK,KAAV,GAAkB,CALC;EAMnB,CAACL,eAAA,CAASM,KAAV,GAAkB;AANC,CAArB;;AASA,MAAMC,IAAI,GAAIC,CAAD,IAAeC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASH,CAAT,EAAY,CAAZ,CAAT,EAAyB,CAAzB,CAA5B;;AAEO,MAAMI,SAAN,SAAwBC,gBAAxB,CAAmE;EACxEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;;IAD2C,iCAInC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN4C;EAE5C;;EAMDC,OAAO,CAACC,GAAD,EAAcC,MAAd,EAAiD;IAAA,IAAhBC,MAAgB,uEAAP,KAAO;IACtD,MAAMC,IAAI,GAAG,CACXV,SAAS,CAACW,SAAV,CAAoBJ,GAApB,CADW,E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,CAA2B,CAACC,GAAD,EAAMC,GAAN,EAAWC,CAAX,KAAiB;MACzD,IAAIA,CAAC,KAAK,CAAV,EAAa;QACXF,GAAG,CAACG,IAAJ,CAAS,EAAT;MACD;;MACD,MAAMC,OAAO,GAAGJ,GAAG,CAACA,GAAG,CAACK,MAAJ,GAAa,CAAd,CAAnB;;MACA,IAAID,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;QACxBD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACA,MAAMI,MAAM,GAAGxJ,YAAY,CAACuJ,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF,CAND,MAMO;QACL,MAAME,MAAM,GAAGxJ,YAAY,CAACuJ,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACC,MAAR,GAAiBA,MAArB,EAA6B;UAC3BD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACD;;QACD,IAAIG,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF;;MACD,OAAOH,GAAP;IACD,CArBc,EAqBZ,EArBY,CAAf;IAsBA,OAAOlG,MAAP;EACD;;AAxWuE"}
@@ -16,4 +16,4 @@ import type { ExtrapolationType } from "./interpolate";
16
16
  * path2.lineTo(0, 100);
17
17
  * const path = interpolatePath(0.5, [0, 1], [path1, path2]);
18
18
  */
19
- export declare const interpolatePaths: (value: number, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SkPath;
19
+ export declare const interpolatePaths: (value: number, input: number[], outputRange: SkPath[], options?: ExtrapolationType, output?: SkPath) => SkPath;
@@ -1,11 +1,11 @@
1
1
  import { exhaustiveCheck } from "../../renderer/typeddash";
2
2
  import { validateInterpolationOptions, Extrapolate } from "./interpolate";
3
3
 
4
- const lerp = (value, from, to, p1, p2) => {
4
+ const lerp = (value, from, to, p1, p2, output) => {
5
5
  "worklet";
6
6
 
7
7
  const t = (value - from) / (to - from);
8
- return p2.interpolate(p1, t);
8
+ return p2.interpolate(p1, t, output);
9
9
  };
10
10
  /**
11
11
  * Maps an input value within a range to an output path within a path range.
@@ -25,7 +25,7 @@ const lerp = (value, from, to, p1, p2) => {
25
25
  */
26
26
 
27
27
 
28
- export const interpolatePaths = (value, input, outputRange, options) => {
28
+ export const interpolatePaths = (value, input, outputRange, options, output) => {
29
29
  "worklet";
30
30
 
31
31
  const extrapolation = validateInterpolationOptions(options);
@@ -68,6 +68,6 @@ export const interpolatePaths = (value, input, outputRange, options) => {
68
68
  }
69
69
  }
70
70
 
71
- return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1]);
71
+ return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1], output);
72
72
  };
73
73
  //# sourceMappingURL=interpolatePaths.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["exhaustiveCheck","validateInterpolationOptions","Extrapolate","lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","extrapolation","extrapolateLeft","CLAMP","EXTEND","IDENTITY","Error","length","extrapolateRight","i"],"sources":["interpolatePaths.ts"],"sourcesContent":["import type { SkPath } from \"../../skia/types\";\nimport { exhaustiveCheck } from \"../../renderer/typeddash\";\n\nimport type { ExtrapolationType } from \"./interpolate\";\nimport { validateInterpolationOptions, Extrapolate } from \"./interpolate\";\n\nconst lerp = (\n value: number,\n from: number,\n to: number,\n p1: SkPath,\n p2: SkPath\n) => {\n \"worklet\";\n const t = (value - from) / (to - from);\n return p2.interpolate(p1, t)!;\n};\n\n/**\n * Maps an input value within a range to an output path within a path range.\n * @param value - The input value.\n * @param inputRange - The range of the input value.\n * @param outputRange - The range of the output path.\n * @param options - Extrapolation options\n * @returns The output path.\n * @example <caption>Map a value between 0 and 1 to a path between two paths.</caption>\n * const path1 = new Path();\n * path1.moveTo(0, 0);\n * path1.lineTo(100, 0);\n * const path2 = new Path();\n * path2.moveTo(0, 0);\n * path2.lineTo(0, 100);\n * const path = interpolatePath(0.5, [0, 1], [path1, path2]);\n */\nexport const interpolatePaths = (\n value: number,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) => {\n \"worklet\";\n const extrapolation = validateInterpolationOptions(options);\n if (value < input[0]) {\n switch (extrapolation.extrapolateLeft) {\n case Extrapolate.CLAMP:\n return outputRange[0];\n case Extrapolate.EXTEND:\n return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateLeft);\n }\n } else if (value > input[input.length - 1]) {\n switch (extrapolation.extrapolateRight) {\n case Extrapolate.CLAMP:\n return outputRange[outputRange.length - 1];\n case Extrapolate.EXTEND:\n return lerp(\n value,\n input[input.length - 2],\n input[input.length - 1],\n outputRange[input.length - 2],\n outputRange[input.length - 1]\n );\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateRight);\n }\n }\n let i = 0;\n for (; i <= input.length - 1; i++) {\n if (value >= input[i] && value <= input[i + 1]) {\n break;\n }\n }\n return lerp(\n value,\n input[i],\n input[i + 1],\n outputRange[i],\n outputRange[i + 1]\n );\n};\n"],"mappings":"AACA,SAASA,eAAT,QAAgC,0BAAhC;AAGA,SAASC,4BAAT,EAAuCC,WAAvC,QAA0D,eAA1D;;AAEA,MAAMC,IAAI,GAAG,CACXC,KADW,EAEXC,IAFW,EAGXC,EAHW,EAIXC,EAJW,EAKXC,EALW,KAMR;EACH;;EACA,MAAMC,CAAC,GAAG,CAACL,KAAK,GAA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AACA,KAAK,CAACS,MAAN,GAAe,CAAhB,CAHI,EAITR,WAAW,CAACD,KAAK,CAACS,MAAN,GAAe,CAAhB,CAJF,EAKTR,WAAW,CAACD,KAAK,CAACS,MAAN,GAAe,CAAhB,CALF,CAAX;;MAOF,KAAKnB,WAAW,CAACiB,QAAjB;QACE,MAAM,IAAIC,KAAJ,CACJ,uEADI,CAAN;;MAGF;QACEpB,eAAe,CAACe,aAAa,CAACO,gBAAf,CAAf;IAhBJ;EAkBD;;EACD,IAAIC,CAAC,GAAG,CAAR;;EACA,OAAOA,CAAC,IAAIX,KAAK,CAACS,MAAN,GAAe,CAA3B,EAA8BE,CAAC,EAA/B,EAAmC;IACjC,IAAInB,KAAK,IAAIQ,KAAK,CAACW,CAAD,CAAd,IAAqBnB,KAAK,IAAIQ,KAAK,CAACW,CAAC,GAAG,CAAL,CAAvC,EAAgD;MAC9C;IACD;EACF;;EACD,OAAOpB,IAAI,CACTC,KADS,EAETQ,KAAK,CAACW,CAAD,CAFI,EAGTX,KAAK,CAACW,CAAC,GAAG,CAAL,CAHI,EAITV,WAAW,CAACU,CAAD,CAJF,EAKTV,WAAW,CAACU,CAAC,GAAG,CAAL,CALF,CAAX;AAOD,CAtDM"}
1
+ {"version":3,"names":["exhaustiveCheck","validateInterpolationOptions","Extrapolate","lerp","value","from","to","p1","p2","output","t","interpolate","interpolatePaths","input","outputRange","options","extrapolation","extrapolateLeft","CLAMP","EXTEND","IDENTITY","Error","length","extrapolateRight","i"],"sources":["interpolatePaths.ts"],"sourcesContent":["import type { SkPath } from \"../../skia/types\";\nimport { exhaustiveCheck } from \"../../renderer/typeddash\";\n\nimport type { ExtrapolationType } from \"./interpolate\";\nimport { validateInterpolationOptions, Extrapolate } from \"./interpolate\";\n\nconst lerp = (\n value: number,\n from: number,\n to: number,\n p1: SkPath,\n p2: SkPath,\n output?: SkPath\n) => {\n \"worklet\";\n const t = (value - from) / (to - from);\n return p2.interpolate(p1, t, output)!;\n};\n\n/**\n * Maps an input value within a range to an output path within a path range.\n * @param value - The input value.\n * @param inputRange - The range of the input value.\n * @param outputRange - The range of the output path.\n * @param options - Extrapolation options\n * @returns The output path.\n * @example <caption>Map a value between 0 and 1 to a path between two paths.</caption>\n * const path1 = new Path();\n * path1.moveTo(0, 0);\n * path1.lineTo(100, 0);\n * const path2 = new Path();\n * path2.moveTo(0, 0);\n * path2.lineTo(0, 100);\n * const path = interpolatePath(0.5, [0, 1], [path1, path2]);\n */\nexport const interpolatePaths = (\n value: number,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType,\n output?: SkPath\n) => {\n \"worklet\";\n const extrapolation = validateInterpolationOptions(options);\n if (value < input[0]) {\n switch (extrapolation.extrapolateLeft) {\n case Extrapolate.CLAMP:\n return outputRange[0];\n case Extrapolate.EXTEND:\n return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateLeft);\n }\n } else if (value > input[input.length - 1]) {\n switch (extrapolation.extrapolateRight) {\n case Extrapolate.CLAMP:\n return outputRange[outputRange.length - 1];\n case Extrapolate.EXTEND:\n return lerp(\n value,\n input[input.length - 2],\n input[input.length - 1],\n outputRange[input.length - 2],\n outputRange[input.length - 1]\n );\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateRight);\n }\n }\n let i = 0;\n for (; i <= input.length - 1; i++) {\n if (value >= input[i] && value <= input[i + 1]) {\n break;\n }\n }\n return lerp(\n value,\n input[i],\n input[i + 1],\n outputRange[i],\n outputRange[i + 1],\n output\n );\n};\n"],"mappings":"AACA,SAASA,eAAT,QAAgC,0BAAhC;AAGA,SAASC,4BAAT,EAAuCC,WAAvC,QAA0D,eAA1D;;AAEA,MAAMC,IAAI,GAAG,CACXC,KADW,EAEXC,IAFW,EAGXC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,KAAKpB,WAAW,CAACiB,MAAjB;QACE,OAAOhB,IAAI,CACTC,KADS,EAETS,KAAK,CAACA,KAAK,CAACS,MAAN,GAAe,CAAhB,CAFI,EAGTT,KAAK,CAACA,KAAK,CAACS,MAAN,GAAe,CAAhB,CAHI,EAITR,WAAW,CAACD,KAAK,CAACS,MAAN,GAAe,CAAhB,CAJF,EAKTR,WAAW,CAACD,KAAK,CAACS,MAAN,GAAe,CAAhB,CALF,CAAX;;MAOF,KAAKpB,WAAW,CAACkB,QAAjB;QACE,MAAM,IAAIC,KAAJ,CACJ,uEADI,CAAN;;MAGF;QACErB,eAAe,CAACgB,aAAa,CAACO,gBAAf,CAAf;IAhBJ;EAkBD;;EACD,IAAIC,CAAC,GAAG,CAAR;;EACA,OAAOA,CAAC,IAAIX,KAAK,CAACS,MAAN,GAAe,CAA3B,EAA8BE,CAAC,EAA/B,EAAmC;IACjC,IAAIpB,KAAK,IAAIS,KAAK,CAACW,CAAD,CAAd,IAAqBpB,KAAK,IAAIS,KAAK,CAACW,CAAC,GAAG,CAAL,CAAvC,EAAgD;MAC9C;IACD;EACF;;EACD,OAAOrB,IAAI,CACTC,KADS,EAETS,KAAK,CAACW,CAAD,CAFI,EAGTX,KAAK,CAACW,CAAC,GAAG,CAAL,CAHI,EAITV,WAAW,CAACU,CAAD,CAJF,EAKTV,WAAW,CAACU,CAAC,GAAG,CAAL,CALF,EAMTf,MANS,CAAX;AAQD,CAxDM"}
@@ -1,3 +1,4 @@
1
- export * from "./useSharedValueEffect";
1
+ export * from "./useAnimatedImageValue";
2
2
  export * from "./useDerivedValueOnJS";
3
3
  export * from "./renderHelpers";
4
+ export * from "./interpolators";
@@ -1,4 +1,5 @@
1
- export * from "./useSharedValueEffect";
1
+ export * from "./useAnimatedImageValue";
2
2
  export * from "./useDerivedValueOnJS";
3
3
  export * from "./renderHelpers";
4
+ export * from "./interpolators";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useSharedValueEffect\";\nexport * from \"./useDerivedValueOnJS\";\nexport * from \"./renderHelpers\";\n"],"mappings":"AAAA,cAAc,wBAAd;AACA,cAAc,uBAAd;AACA,cAAc,iBAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useAnimatedImageValue\";\nexport * from \"./useDerivedValueOnJS\";\nexport * from \"./renderHelpers\";\nexport * from \"./interpolators\";\n"],"mappings":"AAAA,cAAc,yBAAd;AACA,cAAc,uBAAd;AACA,cAAc,iBAAd;AACA,cAAc,iBAAd"}
@@ -0,0 +1,9 @@
1
+ import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
2
+ import type { SkPath, SkPoint } from "../../skia/types";
3
+ export declare const notifyChange: (value: SharedValue<unknown>) => void;
4
+ export declare const useClock: () => SharedValue<number>;
5
+ export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
6
+ export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<{
7
+ x: number;
8
+ y: number;
9
+ }>;
@@ -0,0 +1,34 @@
1
+ import { useMemo } from "react";
2
+ import { interpolatePaths, interpolateVector } from "../../animation";
3
+ import { Skia } from "../../skia";
4
+ import { useAnimatedReaction, useFrameCallback, useSharedValue } from "./moduleWrapper";
5
+ export const notifyChange = value => {
6
+ "worklet"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ value._value = value.value;
9
+ };
10
+ export const useClock = () => {
11
+ const clock = useSharedValue(0);
12
+ useFrameCallback(info => {
13
+ clock.value = info.timeSinceFirstFrame;
14
+ });
15
+ return clock;
16
+ };
17
+ /**
18
+ * @worklet
19
+ */
20
+
21
+ const useInterpolator = (factory, value, interpolator, input, output, options) => {
22
+ // eslint-disable-next-line react-hooks/exhaustive-deps
23
+ const init = useMemo(() => factory(), []);
24
+ const result = useSharedValue(init);
25
+ useAnimatedReaction(() => value.value, val => {
26
+ result.value = interpolator(val, input, output, options, result.value);
27
+ notifyChange(result);
28
+ }, [input, output, options]);
29
+ return result;
30
+ };
31
+
32
+ export const usePathInterpolation = (value, input, outputRange, options) => useInterpolator(() => Skia.Path.Make(), value, interpolatePaths, input, outputRange, options);
33
+ export const useVectorInterpolation = (value, input, outputRange, options) => useInterpolator(() => Skia.Point(0, 0), value, interpolateVector, input, outputRange, options);
34
+ //# sourceMappingURL=interpolators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","interpolatePaths","interpolateVector","Skia","useAnimatedReaction","useFrameCallback","useSharedValue","notifyChange","value","_value","useClock","clock","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","Path","Make","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type { ExtrapolationType, SharedValue } from \"react-native-reanimated\";\nimport { useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n useFrameCallback((info) => {\n clock.value = info.timeSinceFirstFrame;\n });\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":"AACA,SAASA,OAAT,QAAwB,OAAxB;AAGA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,iBAApD;AACA,SAASC,IAAT,QAAqB,YAArB;AAEA,SACEC,mBADF,EAEEC,gBAFF,EAGEC,cAHF,QAIO,iBAJP;AAMA,OAAO,MAAMC,YAAY,GAAIC,KAAD,IAAiC;EAC3D,UAD2D,CAE3D;;EACCA,KAAD,CAAeC,MAAf,GAAwBD,KAAK,CAACA,KAA9B;AACD,CAJM;AAMP,OAAO,MAAME,QAAQ,GAAG,MAAM;EAC5B,MAAMC,KAAK,GAAGL,cAAc,CAAC,CAAD,CAA5B;EACAD,gBAAgB,CAAEO,IAAD,IAAU;IACzBD,KAAK,CAACH,KAAN,GAAcI,IAAI,CAACC,mBAAnB;EACD,CAFe,CAAhB;EAGA,OAAOF,KAAP;AACD,CANM;AAQP;AACA;AACA;;AASA,MAAMG,eAAe,GAAG,CACtBC,OADsB,EAEtBP,KAFsB,EAGtBQ,YAHsB,EAItBC,KAJsB,EAKtBC,MALsB,EAMtBC,OANsB,KAOnB;EACH;EACA,MAAMC,IAAI,GAAGpB,OAAO,CAAC,MAAMe,OAAO,EAAd,EAAkB,EAAlB,CAApB;EACA,MAAMM,MAAM,GAAGf,cAAc,CAACc,IAAD,CAA7B;EACAhB,mBAAmB,CACjB,MAAMI,KAAK,CAACA,KADK,EAEhBc,GAAD,IAAS;IACPD,MAAM,CAACb,KAAP,GAAeQ,YAAY,CAACM,GAAD,EAAML,KAAN,EAAaC,MAAb,EAAqBC,OAArB,EAA8BE,MAAM,CAACb,KAArC,CAA3B;IACAD,YAAY,CAACc,MAAD,CAAZ;EACD,CALgB,EAMjB,CAACJ,KAAD,EAAQC,MAAR,EAAgBC,OAAhB,CANiB,CAAnB;EAQA,OAAOE,MAAP;AACD,CApBD;;AAsBA,OAAO,MAAME,oBAAoB,GAAG,CAClCf,KADkC,EAElCS,KAFkC,EAGlCO,WAHkC,EAIlCL,OAJkC,KAMlCL,eAAe,CACb,MAAMX,IAAI,CAACsB,IAAL,CAAUC,IAAV,EADO,EAEblB,KAFa,EAGbP,gBAHa,EAIbgB,KAJa,EAKbO,WALa,EAMbL,OANa,CANV;AAeP,OAAO,MAAMQ,sBAAsB,GAAG,CACpCnB,KADoC,EAEpCS,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMX,IAAI,CAACyB,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbpB,KAFa,EAGbN,iBAHa,EAIbe,KAJa,EAKbO,WALa,EAMbL,OANa,CANV"}
@@ -1,10 +1,12 @@
1
- import type { SharedValueType } from "../../renderer/processors/Animations";
1
+ import type { DependencyList } from "react";
2
+ import type { FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
2
3
  export declare const HAS_REANIMATED2: boolean;
3
4
  export declare const HAS_REANIMATED3: boolean;
4
5
  export declare function throwOnMissingReanimated(): void;
5
- export declare const useSharedValue: any;
6
- export declare const useFrameCallback: (...args: any[]) => any;
7
- export declare const startMapper: any;
8
- export declare const stopMapper: any;
6
+ export declare const useSharedValue: <T>(init: T, oneWayReadsOnly?: boolean) => SharedValue<T>;
7
+ export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void, autostart?: boolean) => FrameCallback;
8
+ export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
9
+ export declare const stopMapper: (mapperID: number) => void;
9
10
  export declare const runOnJS: any;
10
- export declare const isSharedValue: <T>(value: unknown) => value is SharedValueType<T>;
11
+ export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
12
+ export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
@@ -1,7 +1,6 @@
1
- var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5;
1
+ var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6;
2
2
 
3
3
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
- import { useMemo } from "react";
5
4
  // This one is needed for the deprecated useSharedValue function
6
5
  // We can remove it once we remove the deprecation
7
6
  let Reanimated2;
@@ -10,8 +9,7 @@ let reanimatedVersion;
10
9
 
11
10
  try {
12
11
  Reanimated2 = require("react-native-reanimated");
13
- reanimatedVersion = // eslint-disable-next-line import/extensions
14
- require("react-native-reanimated/package.json").version;
12
+ reanimatedVersion = require("react-native-reanimated/package.json").version;
15
13
 
16
14
  if (reanimatedVersion && (reanimatedVersion >= "3.0.0" || reanimatedVersion.includes("3.0.0-"))) {
17
15
  Reanimated3 = Reanimated2;
@@ -26,13 +24,12 @@ export function throwOnMissingReanimated() {
26
24
  react-native-skia's integration layer API.");
27
25
  }
28
26
  }
29
- export const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || (value => useMemo(() => ({
30
- value
31
- }), [value]));
27
+ export const useSharedValue = ((_Reanimated = Reanimated2) === null || _Reanimated === void 0 ? void 0 : _Reanimated.useSharedValue) || throwOnMissingReanimated;
32
28
  export const useFrameCallback = ((_Reanimated2 = Reanimated2) === null || _Reanimated2 === void 0 ? void 0 : _Reanimated2.useFrameCallback) || throwOnMissingReanimated;
33
29
  export const startMapper = ((_Reanimated3 = Reanimated2) === null || _Reanimated3 === void 0 ? void 0 : _Reanimated3.startMapper) || throwOnMissingReanimated;
34
30
  export const stopMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.stopMapper) || throwOnMissingReanimated;
35
31
  export const runOnJS = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.runOnJS) || throwOnMissingReanimated;
32
+ export const useAnimatedReaction = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.useAnimatedReaction) || throwOnMissingReanimated;
36
33
  export const isSharedValue = value => {
37
34
  return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
38
35
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","value","useFrameCallback","startMapper","stopMapper","runOnJS","isSharedValue","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useMemo } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion =\n // eslint-disable-next-line import/extensions\n require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue =\n Reanimated2?.useSharedValue ||\n ((value: number) => useMemo(() => ({ value }), [value]));\nexport const useFrameCallback: (...args: any[]) => any =\n Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper = Reanimated2?.startMapper || throwOnMissingReanimated;\nexport const stopMapper = Reanimated2?.stopMapper || throwOnMissingReanimated;\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const isSharedValue = <T>(\n value: unknown\n): value is SharedValueType<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;AAAA;AACA,SAASA,OAAT,QAAwB,OAAxB;AAIA;AACA;AAEA,IAAIC,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GACf;EACAC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAFlD;;EAGA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CAXD,CAWE,OAAOM,CAAP,EAAU,CAAE;;AAEd,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;AACP,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;AAEP,OAAO,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;AAED,OAAO,MAAMC,cAAc,GACzB,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,MACEC,KAAD,IAAmBb,OAAO,CAAC,OAAO;EAAEa;AAAF,CAAP,CAAD,EAAoB,CAACA,KAAD,CAApB,CAD3B,CADK;AAGP,OAAO,MAAMC,gBAAyC,GACpD,iBAAAb,WAAW,UAAX,oDAAaa,gBAAb,KAAiCJ,wBAD5B;AAGP,OAAO,MAAMK,WAAW,GAAG,iBAAAd,WAAW,UAAX,oDAAac,WAAb,KAA4BL,wBAAhD;AACP,OAAO,MAAMM,UAAU,GAAG,iBAAAf,WAAW,UAAX,oDAAae,UAAb,KAA2BN,wBAA9C;AACP,OAAO,MAAMO,OAAO,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,OAAb,KAAwBP,wBAAxC;AACP,OAAO,MAAMQ,aAAa,GACxBL,KAD2B,IAEK;EAChC,OACE,CAAC,CAACA,KAAF,KACCX,WAAW,GACRA,WAAW,CAACgB,aAAZ,CAA0BL,KAA1B,CADQ,GAEPA,KAAD,CAAeA,KAAf,KAAyBM,SAH7B,CADF;AAMD,CATM"}
1
+ {"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","useFrameCallback","startMapper","stopMapper","runOnJS","useAnimatedReaction","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;AAAA;AAQA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GAAGC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAApE;;EACA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CATD,CASE,OAAOM,CAAP,EAAU,CAAE;;AAEd,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;AACP,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;AAEP,OAAO,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;AAED,OAAO,MAAMC,cAGM,GAAG,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,KAA+BF,wBAH9C;AAKP,OAAO,MAAMG,gBAGK,GAAG,iBAAAZ,WAAW,UAAX,oDAAaY,gBAAb,KAAiCH,wBAH/C;AAKP,OAAO,MAAMI,WAIF,GAAG,iBAAAb,WAAW,UAAX,oDAAaa,WAAb,KAA4BJ,wBAJnC;AAMP,OAAO,MAAMK,UAAsC,GACjD,iBAAAd,WAAW,UAAX,oDAAac,UAAb,KAA2BL,wBADtB;AAGP,OAAO,MAAMM,OAAO,GAAG,iBAAAf,WAAW,UAAX,oDAAae,OAAb,KAAwBN,wBAAxC;AAEP,OAAO,MAAMO,mBAIJ,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,mBAAb,KAAoCP,wBAJzC;AAMP,OAAO,MAAMQ,aAAa,GAAOC,KAAJ,IAAgD;EAC3E,OACE,CAAC,CAACA,KAAF,KACCjB,WAAW,GACRA,WAAW,CAACgB,aAAZ,CAA0BC,KAA1B,CADQ,GAEPA,KAAD,CAAeA,KAAf,KAAyBC,SAH7B,CADF;AAMD,CAPM"}
@@ -1,5 +1,6 @@
1
1
  import type { Container } from "../../renderer/Container";
2
2
  import type { AnimatedProps } from "../../renderer/processors";
3
3
  import type { Node } from "../../dom/types";
4
+ export declare const unbindReanimatedNode: (node: Node<unknown>) => void;
4
5
  export declare function extractReanimatedProps(props: AnimatedProps<any>): AnimatedProps<any, never>[];
5
6
  export declare function bindReanimatedProps(container: Container, node: Node<any>, reanimatedProps: AnimatedProps<any>): void;
@@ -5,6 +5,13 @@ import { startMapper, stopMapper, isSharedValue, HAS_REANIMATED3, HAS_REANIMATED
5
5
 
6
6
  const _bindings = new WeakMap();
7
7
 
8
+ export const unbindReanimatedNode = node => {
9
+ const previousMapperId = _bindings.get(node);
10
+
11
+ if (previousMapperId !== undefined) {
12
+ stopMapper(previousMapperId);
13
+ }
14
+ };
8
15
  export function extractReanimatedProps(props) {
9
16
  if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {
10
17
  return [props, {}];
@@ -73,7 +80,7 @@ function bindReanimatedProps2(container, node, reanimatedProps) {
73
80
  }
74
81
 
75
82
  export function bindReanimatedProps(container, node, reanimatedProps) {
76
- if (HAS_REANIMATED2) {
83
+ if (HAS_REANIMATED2 && !HAS_REANIMATED3) {
77
84
  return bindReanimatedProps2(container, node, reanimatedProps);
78
85
  }
79
86
 
@@ -97,8 +104,10 @@ export function bindReanimatedProps(container, node, reanimatedProps) {
97
104
  const mapperId = startMapper(() => {
98
105
  "worklet";
99
106
 
100
- for (const propName in reanimatedProps) {
101
- node && node.setProp(propName, reanimatedProps[propName].value);
107
+ if (node) {
108
+ for (const propName in reanimatedProps) {
109
+ node.setProp(propName, reanimatedProps[propName].value);
110
+ }
102
111
  } // On React Native we use the SkiaViewApi to redraw because it can
103
112
  // run on the worklet thread (container.redraw can't)
104
113
  // if SkiaViewApi is undefined, we are on web and container.redraw()
@@ -1 +1 @@
1
- {"version":3,"names":["startMapper","stopMapper","isSharedValue","HAS_REANIMATED3","HAS_REANIMATED2","runOnJS","_bindings","WeakMap","extractReanimatedProps","props","reanimatedProps","otherProps","propName","propValue","value","bindReanimatedProps2","container","node","sharedValues","Object","values","previousMapperId","get","undefined","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":"AAAA;;AACA;AAKA,SACEA,WADF,EAEEC,UAFF,EAGEC,aAHF,EAIEC,eAJF,EAKEC,eALF,EAMEC,OANF,QAOO,iBAPP;;AASA,MAAMC,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEA,OAAO,SAASC,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACN,eAAD,IAAoB,CAACC,eAAzB,EAA0C;IACxC,OAAO,CAACK,KAAD,EAAQ,EAAR,CAAP;EACD;;EACD,MAAMC,eAAe,GAAG,EAAxB;EACA,MAAMC,UAAU,GAAG,EAAnB;;EACA,KAAK,MAAMC,QAAX,IAAuBH,KAAvB,EAA8B;IAC5B,IAAIG,QAAQ,KAAK,UAAjB,EAA6B;MAC3B;IACD;;IACD,MAAMC,SAAS,GAAGJ,KAAK,CAACG,QAAD,CAAvB;;IACA,IAAIV,aAAa,CAACW,SAAD,CAAjB,EAA8B;MAC5BH,eAAe,CAACE,QAAD,CAAf,GAA4BC,SAA5B;MACAF,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAS,CAACC,KAAjC;IACD,CAHD,MAGO;MACLH,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAvB;IACD;EACF;;EACD,OAAO,CAACF,UAAD,EAAaD,eAAb,CAAP;AACD;;AAED,SAASK,oBAAT,CACEC,SADF,EAEEC,IAFF,EAGEP,eAHF,EAIE;EACA,MAAMQ,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcV,eAAd,CAArB;;EACA,MAAMW,gBAAgB,GAAGf,SAAS,CAACgB,GAAV,C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AACM,MAAb,GAAsB,CAA1B,EAA6B;IAC3B,MAAMC,MAAM,GAAGT,SAAS,CAACU,WAAV,EAAf;IACA,MAAM;MAAEC;IAAF,IAAkBC,MAAxB;IACA,MAAMK,QAAQ,GAAGjC,WAAW,CAAC,MAAM;MACjC;;MACA,KAAK,MAAMY,QAAX,IAAuBF,eAAvB,EAAwC;QACtCO,IAAI,IAAIA,IAAI,CAACa,OAAL,CAAalB,QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BE,KAAjD,CAAR;MACD,CAJgC,CAKjC;MACA;MACA;MACA;;;MACA,IAAIa,WAAJ,EAAiB;QACfA,WAAW,CAACI,aAAZ,CAA0BN,MAA1B;MACD,CAFD,MAEO;QACLT,SAAS,CAACgB,MAAV;MACD;IACF,CAd2B,EAczBd,YAdyB,CAA5B;;IAeAZ,SAAS,CAAC4B,GAAV,CAAcjB,IAAd,EAAoBgB,QAApB;EACD;AACF"}
1
+ {"version":3,"names":["startMapper","stopMapper","isSharedValue","HAS_REANIMATED3","HAS_REANIMATED2","runOnJS","_bindings","WeakMap","unbindReanimatedNode","node","previousMapperId","get","undefined","extractReanimatedProps","props","reanimatedProps","otherProps","propName","propValue","value","bindReanimatedProps2","container","sharedValues","Object","values","length","viewId","getNativeId","SkiaViewApi","global","updateProps","setProp","requestRedraw","redraw","mapperId","set","bindReanimatedProps"],"sources":["renderHelpers.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable reanimated/js-function-in-worklet */\nimport type { Container } from \"../../renderer/Container\";\nimport type { AnimatedProps } from \"../../renderer/processors\";\nimport type { Node } from \"../../dom/types\";\n\nimport {\n startMapper,\n stopMapper,\n isSharedValue,\n HAS_REANIMATED3,\n HAS_REANIMATED2,\n runOnJS,\n} from \"./moduleWrapper\";\n\nconst _bindings = new WeakMap<Node<unknown>, unknown>();\n\nexport const unbindReanimatedNode = (node: Node<unknown>) => {\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n};\n\nexport function extractReanimatedProps(props: AnimatedProps<any>) {\n if (!HAS_REANIMATED3 && !HAS_REANIMATED2) {\n return [props, {}];\n }\n const reanimatedProps = {} as AnimatedProps<any>;\n const otherProps = {} as AnimatedProps<any>;\n for (const propName in props) {\n if (propName === \"children\") {\n continue;\n }\n const propValue = props[propName];\n if (isSharedValue(propValue)) {\n reanimatedProps[propName] = propValue;\n otherProps[propName] = propValue.value;\n } else {\n otherProps[propName] = propValue;\n }\n }\n return [otherProps, reanimatedProps];\n}\n\nfunction bindReanimatedProps2(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const updateProps = () => {\n for (const propName in reanimatedProps) {\n node && node.setProp(propName, reanimatedProps[propName].value);\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n };\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(updateProps)();\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n\nexport function bindReanimatedProps(\n container: Container,\n node: Node<any>,\n reanimatedProps: AnimatedProps<any>\n) {\n if (HAS_REANIMATED2 && !HAS_REANIMATED3) {\n return bindReanimatedProps2(container, node, reanimatedProps);\n }\n if (!HAS_REANIMATED3) {\n return;\n }\n const sharedValues = Object.values(reanimatedProps);\n const previousMapperId = _bindings.get(node);\n if (previousMapperId !== undefined) {\n stopMapper(previousMapperId as number);\n }\n if (sharedValues.length > 0) {\n const viewId = container.getNativeId();\n const { SkiaViewApi } = global;\n const mapperId = startMapper(() => {\n \"worklet\";\n if (node) {\n for (const propName in reanimatedProps) {\n node.setProp(propName, reanimatedProps[propName].value);\n }\n }\n // On React Native we use the SkiaViewApi to redraw because it can\n // run on the worklet thread (container.redraw can't)\n // if SkiaViewApi is undefined, we are on web and container.redraw()\n // can safely be invoked\n if (SkiaViewApi) {\n SkiaViewApi.requestRedraw(viewId);\n } else {\n container.redraw();\n }\n }, sharedValues);\n _bindings.set(node, mapperId);\n }\n}\n"],"mappings":"AAAA;;AACA;AAKA,SACEA,WADF,EAEEC,UAFF,EAGEC,aAHF,EAIEC,eAJF,EAKEC,eALF,EAMEC,OANF,QAOO,iBAPP;;AASA,MAAMC,SAAS,GAAG,IAAIC,OAAJ,EAAlB;;AAEA,OAAO,MAAMC,oBAAoB,GAAIC,IAAD,IAAyB;EAC3D,MAAMC,gBAAgB,GAAGJ,SAAS,CAACK,GAAV,CAAcF,IAAd,CAAzB;;EACA,IAAIC,gBAAgB,KAAKE,SAAzB,EAAoC;IAClCX,UAAU,CAACS,gBAAD,CAAV;EACD;AACF,CALM;AAOP,OAAO,SAASG,sBAAT,CAAgCC,KAAhC,EAA2D;EAChE,IAAI,CAACX,eAAD,IAAoB,CAACC,eAAzB,EAA0C;IACxC,OAAO,CAACU,KAAD,EAAQ,EAAR,CAAP;EACD;;EACD,MAAMC,eAAe,GAAG,EAAxB;EACA,MAAMC,UAAU,GAAG,EAAnB;;EACA,KAAK,MAAMC,QAAX,IAAuBH,KAAvB,EAA8B;IAC5B,IAAIG,QAAQ,KAAK,UAAjB,EAA6B;MAC3B;IACD;;IACD,MAAMC,SAAS,GAAGJ,KAAK,CAACG,QAAD,CAAvB;;IACA,IAAIf,aAAa,CAACgB,SAAD,CAAjB,EAA8B;MAC5BH,eAAe,CAACE,QAAD,CAAf,GAA4BC,SAA5B;MACAF,UAAU,CAACC,QAAD,CAAV,GAAuBC,SAAS,CAACC,KAAjC;IACD,CAHD,MAGO;MACLH,UAAU,CAACC,QAAD,CAAV,GAAuBC,SA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,EAAsB;IACpB;EACD;;EACD,MAAMmB,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcT,eAAd,CAArB;;EACA,MAAML,gBAAgB,GAAGJ,SAAS,CAACK,GAAV,CAAcF,IAAd,CAAzB;;EACA,IAAIC,gBAAgB,KAAKE,SAAzB,EAAoC;IAClCX,UAAU,CAACS,gBAAD,CAAV;EACD;;EACD,IAAIY,YAAY,CAACG,MAAb,GAAsB,CAA1B,EAA6B;IAC3B,MAAMC,MAAM,GAAGL,SAAS,CAACM,WAAV,EAAf;IACA,MAAM;MAAEC;IAAF,IAAkBC,MAAxB;IACA,MAAMK,QAAQ,GAAGlC,WAAW,CAAC,MAAM;MACjC;;MACA,IAAIS,IAAJ,EAAU;QACR,KAAK,MAAMQ,QAAX,IAAuBF,eAAvB,EAAwC;UACtCN,IAAI,CAACsB,OAAL,CAAad,QAAb,EAAuBF,eAAe,CAACE,QAAD,CAAf,CAA0BE,KAAjD;QACD;MACF,CANgC,CAOjC;MACA;MACA;MACA;;;MACA,IAAIS,WAAJ,EAAiB;QACfA,WAAW,CAACI,aAAZ,CAA0BN,MAA1B;MACD,CAFD,MAEO;QACLL,SAAS,CAACY,MAAV;MACD;IACF,CAhB2B,EAgBzBX,YAhByB,CAA5B;;IAiBAhB,SAAS,CAAC6B,GAAV,CAAc1B,IAAd,EAAoByB,QAApB;EACD;AACF"}
@@ -0,0 +1,2 @@
1
+ import type { DataSourceParam, SkImage } from "../../skia/types";
2
+ export declare const useAnimatedImageValue: (source: DataSourceParam) => import("react-native-reanimated").SharedValue<SkImage | null>;
@@ -0,0 +1,41 @@
1
+ import { useAnimatedImage } from "../../skia/core/AnimatedImage";
2
+ import { throwOnMissingReanimated, useFrameCallback, useSharedValue } from "./moduleWrapper";
3
+ const DEFAULT_FRAME_DURATION = 60;
4
+ export const useAnimatedImageValue = source => {
5
+ throwOnMissingReanimated();
6
+ const currentFrame = useSharedValue(null);
7
+ const lastTimestamp = useSharedValue(0);
8
+ const animatedImage = useAnimatedImage(source, err => {
9
+ console.error(err);
10
+ throw new Error(`Could not load animated image - got '${err.message}'`);
11
+ });
12
+ const frameDuration = (animatedImage === null || animatedImage === void 0 ? void 0 : animatedImage.currentFrameDuration()) || DEFAULT_FRAME_DURATION;
13
+ useFrameCallback(frameInfo => {
14
+ if (!animatedImage) {
15
+ currentFrame.value = null;
16
+ return;
17
+ }
18
+
19
+ const {
20
+ timestamp
21
+ } = frameInfo;
22
+ const elapsed = timestamp - lastTimestamp.value; // Check if it's time to switch frames based on GIF frame duration
23
+
24
+ if (elapsed < frameDuration) {
25
+ return;
26
+ } // Update the current frame
27
+
28
+
29
+ animatedImage.decodeNextFrame();
30
+
31
+ if (currentFrame.value) {
32
+ currentFrame.value.dispose();
33
+ }
34
+
35
+ currentFrame.value = animatedImage.getCurrentFrame(); // Update the last timestamp
36
+
37
+ lastTimestamp.value = timestamp; // eslint-disable-next-line react-hooks/exhaustive-deps
38
+ }, true);
39
+ return currentFrame;
40
+ };
41
+ //# sourceMappingURL=useAnimatedImageValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useAnimatedImage","throwOnMissingReanimated","useFrameCallback","useSharedValue","DEFAULT_FRAME_DURATION","useAnimatedImageValue","source","currentFrame","lastTimestamp","animatedImage","err","console","error","Error","message","frameDuration","currentFrameDuration","frameInfo","value","timestamp","elapsed","decodeNextFrame","dispose","getCurrentFrame"],"sources":["useAnimatedImageValue.ts"],"sourcesContent":["import type { FrameInfo } from \"react-native-reanimated\";\n\nimport { useAnimatedImage } from \"../../skia/core/AnimatedImage\";\nimport type { DataSourceParam, SkImage } from \"../../skia/types\";\n\nimport {\n throwOnMissingReanimated,\n useFrameCallback,\n useSharedValue,\n} from \"./moduleWrapper\";\n\nconst DEFAULT_FRAME_DURATION = 60;\n\nexport const useAnimatedImageValue = (source: DataSourceParam) => {\n throwOnMissingReanimated();\n const currentFrame = useSharedValue<null | SkImage>(null);\n const lastTimestamp = useSharedValue(0);\n const animatedImage = useAnimatedImage(source, (err) => {\n console.error(err);\n throw new Error(`Could not load animated image - got '${err.message}'`);\n });\n const frameDuration =\n animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;\n\n useFrameCallback((frameInfo: FrameInfo) => {\n if (!animatedImage) {\n currentFrame.value = null;\n return;\n }\n\n const { timestamp } = frameInfo;\n const elapsed = timestamp - lastTimestamp.value;\n\n // Check if it's time to switch frames based on GIF frame duration\n if (elapsed < frameDuration) {\n return;\n }\n\n // Update the current frame\n animatedImage.decodeNextFrame();\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = animatedImage.getCurrentFrame();\n\n // Update the last timestamp\n lastTimestamp.value = timestamp;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, true);\n return currentFrame;\n};\n"],"mappings":"AAEA,SAASA,gBAAT,QAAiC,+BAAjC;AAGA,SACEC,wBADF,EAEEC,gBAFF,EAGEC,cAHF,QAIO,iBAJP;AAMA,MAAMC,sBAAsB,GAAG,EAA/B;AAEA,OAAO,MAAMC,qBAAqB,GAAIC,MAAD,IAA6B;EAChEL,wBAAwB;EACxB,MAAMM,YAAY,GAAGJ,cAAc,CAAiB,IAAjB,CAAnC;EACA,MAAMK,aAAa,GAAGL,cAAc,CAAC,CAAD,CAApC;EACA,MAAMM,aAAa,GAAGT,gBAAgB,CAACM,MAAD,EAAUI,GAAD,IAAS;IACtDC,OAAO,CAACC,KAAR,CAAcF,GAAd;IACA,MAAM,IAAIG,KAAJ,CAAW,wCAAuCH,GAAG,CAACI,OAAQ,GAA9D,CAAN;EACD,CAHqC,CAAtC;EAIA,MAAMC,aAAa,GACjB,CAAAN,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAEO,oBAAf,OAAyCZ,sBAD3C;EAGAF,gBAAgB,CAAEe,SAAD,IAA0B;IACzC,IAAI,CAACR,aAAL,EAAoB;MAClBF,YAAY,CAACW,KAAb,GAAqB,IAArB;MACA;IACD;;IAED,MAAM;MAAEC;IAAF,IAAgBF,SAAtB;IACA,MAAMG,OAAO,GAAGD,SAAS,GAAGX,aAAa,CAACU,KAA1C,CAPyC,CASzC;;IACA,IAAIE,OAAO,GAAGL,aAAd,EAA6B;MAC3B;IACD,CAZwC,CAczC;;;IACAN,aAAa,CAACY,eAAd;;IACA,IAAId,YAAY,CAACW,KAAjB,EAAwB;MACtBX,YAAY,CAACW,KAAb,CAAmBI,OAAnB;IACD;;IACDf,YAAY,CAACW,KAAb,GAAqBT,aAAa,CAACc,eAAd,EAArB,CAnByC,CAqBzC;;IACAf,aAAa,CAACU,KAAd,GAAsBC,SAAtB,CAtByC,CAuBzC;EACD,CAxBe,EAwBb,IAxBa,CAAhB;EAyBA,OAAOZ,YAAP;AACD,CArCM"}
@@ -1,2 +1 @@
1
- import { type DependencyList } from "react";
2
- export declare const useDerivedValueOnJS: (fn: () => any, deps?: DependencyList) => any;
1
+ export declare const useDerivedValueOnJS: (fn: () => any, deps: unknown[]) => import("react-native-reanimated").SharedValue<any>;
@@ -1,7 +1,8 @@
1
- import { useEffect } from "react";
1
+ import { useEffect, useMemo } from "react";
2
2
  import { useSharedValue, runOnJS, startMapper, stopMapper } from "./moduleWrapper";
3
3
  export const useDerivedValueOnJS = (fn, deps) => {
4
- const value = useSharedValue(fn());
4
+ const init = useMemo(() => fn(), [fn]);
5
+ const value = useSharedValue(init);
5
6
  useEffect(() => {
6
7
  const mapperId = startMapper(() => {
7
8
  "worklet";
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useSharedValue","runOnJS","startMapper","stopMapper","useDerivedValueOnJS","fn","deps","value","mapperId"],"sources":["useDerivedValueOnJS.ts"],"sourcesContent":["import { useEffect, type DependencyList } from \"react\";\n\nimport {\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\nexport const useDerivedValueOnJS = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fn: () => any,\n deps?: DependencyList\n) => {\n const value = useSharedValue(fn());\n useEffect(() => {\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(fn)();\n }, deps);\n return () => stopMapper(mapperId);\n }, [deps, fn]);\n return value;\n};\n"],"mappings":"AAAA,SAASA,SAAT,QAA+C,OAA/C;AAEA,SACEC,cADF,EAEEC,OAFF,EAGEC,WAHF,EAIEC,UAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,mBAAmB,GAAG,CAEjCC,EAFiC,EAGjCC,IAHiC,KAI9B;EACH,MAAMC,KAAK,GAAGP,cAAc,CAACK,EAAE,EAAH,CAA5B;EACAN,SAAS,CAAC,MAAM;IACd,MAAMS,QAAQ,GAAGN,WAAW,CAAC,MAAM;MACjC;;MACAD,OAAO,CAACI,EAAD,CAAP;IACD,CAH2B,EAGzBC,IAHyB,CAA5B;IAIA,OAAO,MAAMH,UAAU,CAACK,QAAD,CAAvB;EACD,CANQ,EAMN,CAACF,IAAD,EAAOD,EAAP,CANM,CAAT;EAOA,OAAOE,KAAP;AACD,CAdM"}
1
+ {"version":3,"names":["useEffect","useMemo","useSharedValue","runOnJS","startMapper","stopMapper","useDerivedValueOnJS","fn","deps","init","value","mapperId"],"sources":["useDerivedValueOnJS.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\n\nimport {\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\nexport const useDerivedValueOnJS = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fn: () => any,\n deps: unknown[]\n) => {\n const init = useMemo(() => fn(), [fn]);\n const value = useSharedValue(init);\n useEffect(() => {\n const mapperId = startMapper(() => {\n \"worklet\";\n runOnJS(fn)();\n }, deps);\n return () => stopMapper(mapperId);\n }, [deps, fn]);\n return value;\n};\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,OAApB,QAAmC,OAAnC;AAEA,SACEC,cADF,EAEEC,OAFF,EAGEC,WAHF,EAIEC,UAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,mBAAmB,GAAG,CAEjCC,EAFiC,EAGjCC,IAHiC,KAI9B;EACH,MAAMC,IAAI,GAAGR,OAAO,CAAC,MAAMM,EAAE,EAAT,EAAa,CAACA,EAAD,CAAb,CAApB;EACA,MAAMG,KAAK,GAAGR,cAAc,CAACO,IAAD,CAA5B;EACAT,SAAS,CAAC,MAAM;IACd,MAAMW,QAAQ,GAAGP,WAAW,CAAC,MAAM;MACjC;;MACAD,OAAO,CAACI,EAAD,CAAP;IACD,CAH2B,EAGzBC,IAHyB,CAA5B;IAIA,OAAO,MAAMH,UAAU,CAACM,QAAD,CAAvB;EACD,CANQ,EAMN,CAACH,IAAD,EAAOD,EAAP,CANM,CAAT;EAOA,OAAOG,KAAP;AACD,CAfM"}
@@ -7,6 +7,10 @@ const NoopValue = () => ({
7
7
  current: 0
8
8
  });
9
9
 
10
+ const NoopSharedValue = () => ({
11
+ value: 0
12
+ });
13
+
10
14
  export const Mock = CanvasKit => {
11
15
  global.SkiaApi = JsiSkApi(CanvasKit);
12
16
  global.SkiaValueApi = ValueApi;
@@ -21,6 +25,7 @@ export const Mock = CanvasKit => {
21
25
  ...require("../dom/nodes"),
22
26
  // We could use the real Canvas if we mock the SkiaView component for node
23
27
  Canvas: Noop,
28
+ // Skia Animations
24
29
  useValue: NoopValue,
25
30
  useComputedValue: NoopValue,
26
31
  useTouchHandler: Noop,
@@ -29,6 +34,9 @@ export const Mock = CanvasKit => {
29
34
  useSpring: NoopValue,
30
35
  useClockValue: NoopValue,
31
36
  useValueEffect: Noop,
37
+ // Reanimated hooks
38
+ useClock: NoopSharedValue,
39
+ usePathInterpolation: NoopSharedValue,
32
40
  useRawData: Noop,
33
41
  useData: Noop,
34
42
  useFont: () => Skia.Font(undefined, 0),
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkApi","ValueApi","Noop","undefined","NoopValue","current","Mock","CanvasKit","global","SkiaApi","SkiaValueApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { ValueApi } from \"../values/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n global.SkiaValueApi = ValueApi;\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../values\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,QAAyB,eAAzB,C,CAEA;;AACA,MAAMC,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AAEA,OAAO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiBT,QAAQ,CAACO,SAAD,CAAzB;EACAC,MAAM,CAACE,YAAP,GAAsBT,QAAtB;EACA,MAAMU,IAAI,GAAGH,MAAM,CAACC,OAApB;EACA,OAAO;IACLE,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,WAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL,GAAGA,OAAO,CAAC,cAAD,CAPL;IAQL;IACAC,MAAM,EAAEX,IATH;IAULY,QAAQ,EAAEV,SAVL;IAWLW,gBAAgB,EAAEX,SAXb;IAYLY,eAAe,EAAEd,IAZZ;IAaLe,SAAS,EAAEb,SAbN;IAcLc,OAAO,EAAEd,SAdJ;IAeLe,SAAS,EAAEf,SAfN;IAgBLgB,aAAa,EAAEhB,SAhBV;IAiBLiB,cAAc,EAAEnB,IAjBX;IAkBLoB,UAAU,EAAEpB,IAlBP;IAmBLqB,OAAO,EAAErB,IAnBJ;IAoBLsB,OAAO,EAAE,MAAMb,IAAI,CAACc,IAAL,CAAUtB,SAAV,EAAqB,CAArB,CApBV;IAqBLuB,WAAW,EAAE,MAAM,IArBd;IAsBLC,QAAQ,EAAE,MAAM,IAtBX;IAuBLC,MAAM,EAAE,MAAM;EAvBT,CAAP;AAyBD,CA7BM"}
1
+ {"version":3,"names":["JsiSkApi","ValueApi","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","SkiaValueApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useClock","usePathInterpolation","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { ValueApi } from \"../values/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n global.SkiaValueApi = ValueApi;\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../values\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,QAAyB,eAAzB,C,CAEA;;AACA,MAAMC,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AACA,MAAMC,eAAe,GAAG,OAAO;EAAEC,KAAK,EAAE;AAAT,CAAP,CAAxB;;AAEA,OAAO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiBX,QAAQ,CAACS,SAAD,CAAzB;EACAC,MAAM,CAACE,YAAP,GAAsBX,QAAtB;EACA,MAAMY,IAAI,GAAGH,MAAM,CAACC,OAApB;EACA,OAAO;IACLE,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,WAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL,GAAGA,OAAO,CAAC,cAAD,CAPL;IAQL;IACAC,MAAM,EAAEb,IATH;IAUL;IACAc,QAAQ,EAAEZ,SAXL;IAYLa,gBAAgB,EAAEb,SAZb;IAaLc,eAAe,EAA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