@shopify/react-native-skia 0.1.182 → 0.1.184

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +23 -8
  2. package/lib/commonjs/animation/functions/interpolate.js +10 -1
  3. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  4. package/lib/commonjs/animation/functions/interpolateColors.js +6 -0
  5. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
  6. package/lib/commonjs/animation/functions/interpolatePaths.js +4 -0
  7. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  8. package/lib/commonjs/animation/functions/interpolateVector.js +13 -5
  9. package/lib/commonjs/animation/functions/interpolateVector.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +5 -2
  11. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
  12. package/lib/commonjs/renderer/processors/math/Coordinates.js +42 -18
  13. package/lib/commonjs/renderer/processors/math/Coordinates.js.map +1 -1
  14. package/lib/commonjs/renderer/processors/math/Math.js +10 -2
  15. package/lib/commonjs/renderer/processors/math/Math.js.map +1 -1
  16. package/lib/commonjs/renderer/processors/math/Transforms.js +2 -0
  17. package/lib/commonjs/renderer/processors/math/Transforms.js.map +1 -1
  18. package/lib/commonjs/renderer/typeddash.js +2 -0
  19. package/lib/commonjs/renderer/typeddash.js.map +1 -1
  20. package/lib/commonjs/skia/core/Vector.js +24 -4
  21. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  22. package/lib/module/animation/functions/interpolate.js +10 -1
  23. package/lib/module/animation/functions/interpolate.js.map +1 -1
  24. package/lib/module/animation/functions/interpolateColors.js +6 -0
  25. package/lib/module/animation/functions/interpolateColors.js.map +1 -1
  26. package/lib/module/animation/functions/interpolatePaths.js +4 -0
  27. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  28. package/lib/module/animation/functions/interpolateVector.js +13 -5
  29. package/lib/module/animation/functions/interpolateVector.js.map +1 -1
  30. package/lib/module/external/reanimated/useSharedValueEffect.js +6 -3
  31. package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
  32. package/lib/module/renderer/processors/math/Coordinates.js +42 -18
  33. package/lib/module/renderer/processors/math/Coordinates.js.map +1 -1
  34. package/lib/module/renderer/processors/math/Math.js +10 -2
  35. package/lib/module/renderer/processors/math/Math.js.map +1 -1
  36. package/lib/module/renderer/processors/math/Transforms.js +2 -0
  37. package/lib/module/renderer/processors/math/Transforms.js.map +1 -1
  38. package/lib/module/renderer/typeddash.js +2 -0
  39. package/lib/module/renderer/typeddash.js.map +1 -1
  40. package/lib/module/skia/core/Vector.js +24 -4
  41. package/lib/module/skia/core/Vector.js.map +1 -1
  42. package/package.json +1 -1
  43. package/react-native-skia.podspec +2 -6
  44. package/src/animation/functions/interpolate.ts +5 -0
  45. package/src/animation/functions/interpolateColors.ts +3 -0
  46. package/src/animation/functions/interpolatePaths.ts +2 -0
  47. package/src/animation/functions/interpolateVector.ts +21 -16
  48. package/src/external/reanimated/useSharedValueEffect.ts +7 -4
  49. package/src/renderer/processors/math/Coordinates.ts +36 -20
  50. package/src/renderer/processors/math/Math.ts +12 -4
  51. package/src/renderer/processors/math/Transforms.ts +1 -0
  52. package/src/renderer/typeddash.ts +1 -0
  53. package/src/skia/core/Vector.ts +24 -7
@@ -103,11 +103,29 @@ void RNSkMetalCanvasProvider::renderToCanvas(
103
103
  // usage growing very fast in the simulator without this.
104
104
  @autoreleasepool {
105
105
 
106
- GrMTLHandle drawableHandle;
107
- auto skSurface = SkSurface::MakeFromCAMetalLayer(
108
- renderContext->skContext.get(), (__bridge GrMTLHandle)_layer,
109
- kTopLeft_GrSurfaceOrigin, 1, kBGRA_8888_SkColorType, nullptr, nullptr,
110
- &drawableHandle);
106
+ /* It is super important that we use the pattern of calling nextDrawable
107
+ inside this autoreleasepool and not depend on Skia's
108
+ SkSurface::MakeFromCAMetalLayer to encapsulate since we're seeing a lot of
109
+ drawables leaking if they're not done this way.
110
+
111
+ This is now reverted from:
112
+ (https://github.com/Shopify/react-native-skia/commit/2e2290f8e6dfc6921f97b79f779d920fbc1acceb)
113
+ back to the original implementation.
114
+ */
115
+ id<CAMetalDrawable> currentDrawable = [_layer nextDrawable];
116
+ if (currentDrawable == nullptr) {
117
+ return;
118
+ }
119
+
120
+ GrMtlTextureInfo fbInfo;
121
+ fbInfo.fTexture.retain((__bridge void *)currentDrawable.texture);
122
+
123
+ GrBackendRenderTarget backendRT(_layer.drawableSize.width,
124
+ _layer.drawableSize.height, 1, fbInfo);
125
+
126
+ auto skSurface = SkSurface::MakeFromBackendRenderTarget(
127
+ renderContext->skContext.get(), backendRT, kTopLeft_GrSurfaceOrigin,
128
+ kBGRA_8888_SkColorType, nullptr, nullptr);
111
129
 
112
130
  if (skSurface == nullptr || skSurface->getCanvas() == nullptr) {
113
131
  RNSkia::RNSkLogger::logToConsole(
@@ -120,11 +138,8 @@ void RNSkMetalCanvasProvider::renderToCanvas(
120
138
 
121
139
  skSurface->flushAndSubmit();
122
140
 
123
- id<CAMetalDrawable> currentDrawable =
124
- (__bridge id<CAMetalDrawable>)drawableHandle;
125
141
  id<MTLCommandBuffer> commandBuffer(
126
142
  [renderContext->commandQueue commandBuffer]);
127
- commandBuffer.label = @"PresentSkia";
128
143
  [commandBuffer presentDrawable:currentDrawable];
129
144
  [commandBuffer commit];
130
145
  }
@@ -18,6 +18,8 @@ exports.Extrapolate = Extrapolate;
18
18
  })(Extrapolate || (exports.Extrapolate = Extrapolate = {}));
19
19
 
20
20
  function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
21
+ "worklet";
22
+
21
23
  switch (type) {
22
24
  case Extrapolate.IDENTITY:
23
25
  return x;
@@ -36,13 +38,16 @@ function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
36
38
  }
37
39
 
38
40
  function isExtrapolate(value) {
41
+ "worklet";
42
+
39
43
  return value === Extrapolate.EXTEND || value === Extrapolate.CLAMP || value === Extrapolate.IDENTITY;
40
44
  } // validates extrapolations type
41
45
  // if type is correct, converts it to ExtrapolationConfig
42
46
 
43
47
 
44
48
  function validateInterpolationOptions(type) {
45
- // initialize extrapolationConfig with default extrapolation
49
+ "worklet"; // initialize extrapolationConfig with default extrapolation
50
+
46
51
  const extrapolationConfig = {
47
52
  extrapolateLeft: Extrapolate.EXTEND,
48
53
  extrapolateRight: Extrapolate.EXTEND
@@ -77,6 +82,8 @@ function validateInterpolationOptions(type) {
77
82
  }
78
83
 
79
84
  function internalInterpolate(x, narrowedInput, extrapolationConfig) {
85
+ "worklet";
86
+
80
87
  const {
81
88
  leftEdgeInput,
82
89
  rightEdgeInput,
@@ -103,6 +110,8 @@ function internalInterpolate(x, narrowedInput, extrapolationConfig) {
103
110
 
104
111
 
105
112
  function interpolate(x, input, output, type) {
113
+ "worklet";
114
+
106
115
  if (input.length < 2 || output.length < 2) {
107
116
  throw Error("Interpolation input and output should contain at least two values.");
108
117
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Extrapolate","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateInterpolationOptions","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolate.ts"],"sourcesContent":["/* eslint-disable max-len */\nexport enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolate\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nexport function validateInterpolationOptions(\n type: ExtrapolationType\n): RequiredExtrapolationConfig {\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateInterpolationOptions(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }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,GAAG,CAAL,CAArC;UACAR,aAAa,CAACf,eAAd,GAAgCqB,MAAM,CAACE,CAAD,CAAtC;UACA;QACD;MACF;IACF;EACF;;EAED,OAAOT,mBAAmB,CAACb,CAAD,EAAIc,aAAJ,EAAmBP,mBAAnB,CAA1B;AACD"}
1
+ {"version":3,"names":["Extrapolate","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateInterpolationOptions","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolate.ts"],"sourcesContent":["/* eslint-disable max-len */\nexport enum Extrapolate {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolate | string;\n extrapolateRight?: Extrapolate | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolate;\n extrapolateRight: Extrapolate;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolate\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolate,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n \"worklet\";\n switch (type) {\n case Extrapolate.IDENTITY:\n return x;\n case Extrapolate.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolate.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolate {\n \"worklet\";\n return (\n value === Extrapolate.EXTEND ||\n value === Extrapolate.CLAMP ||\n value === Extrapolate.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nexport function validateInterpolationOptions(\n type: ExtrapolationType\n): RequiredExtrapolationConfig {\n \"worklet\";\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolate.EXTEND,\n extrapolateRight: Extrapolate.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === \"string\") {\n if (!isExtrapolate(type)) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `No supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n \"worklet\";\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput;\n }\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n \"worklet\";\n if (input.length < 2 || output.length < 2) {\n throw Error(\n \"Interpolation input and output should contain at least two values.\"\n );\n }\n\n const extrapolationConfig = validateInterpolationOptions(type);\n const { length } = input;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":";;;;;;;;;AAAA;IACYA,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W;;AA6BZ,SAASC,MAAT,CACEC,IADF,EAEEC,IAFF,EAGEC,GAHF,EAIEC,cAJF,EAKEC,eALF,EAMEC,CANF,EAOU;EACR;;EACA,QAAQL,IAAR;IACE,KAAKF,WAAW,CAACQ,QAAjB;MACE,OAAOD,CAAP;;IACF,KAAKP,WAAW,CAACS,KAAjB;MACE,I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AC,CAAD,CAD4B;IAEhDH,cAAc,EAAEG,KAAK,CAAC,CAAD,CAF2B;IAGhDrB,cAAc,EAAEsB,MAAM,CAAC,CAAD,CAH0B;IAIhDrB,eAAe,EAAEqB,MAAM,CAAC,CAAD;EAJyB,CAAlD;;EAMA,IAAIC,MAAM,GAAG,CAAb,EAAgB;IACd,IAAIrB,CAAC,GAAGmB,KAAK,CAACE,MAAM,GAAG,CAAV,CAAb,EAA2B;MACzBP,aAAa,CAACC,aAAd,GAA8BI,KAAK,CAACE,MAAM,GAAG,CAAV,CAAnC;MACAP,aAAa,CAACE,cAAd,GAA+BG,KAAK,CAACE,MAAM,GAAG,CAAV,CAApC;MACAP,aAAa,CAAChB,cAAd,GAA+BsB,MAAM,CAACC,MAAM,GAAG,CAAV,CAArC;MACAP,aAAa,CAACf,eAAd,GAAgCqB,MAAM,CAACC,MAAM,GAAG,CAAV,CAAtC;IACD,CALD,MAKO;MACL,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,MAApB,EAA4B,EAAEC,CAA9B,EAAiC;QAC/B,IAAItB,CAAC,IAAImB,KAAK,CAACG,CAAD,CAAd,EAAmB;UACjBR,aAAa,CAACC,aAAd,GAA8BI,KAAK,CAACG,CAAC,GAAG,CAAL,CAAnC;UACAR,aAAa,CAACE,cAAd,GAA+BG,KAAK,CAACG,CAAD,CAApC;UACAR,aAAa,CAAChB,cAAd,GAA+BsB,MAAM,CAACE,CAAC,GAAG,CAAL,CAArC;UACAR,aAAa,CAACf,eAAd,GAAgCqB,MAAM,CAACE,CAAD,CAAtC;UACA;QACD;MACF;IACF;EACF;;EAED,OAAOT,mBAAmB,CAACb,CAAD,EAAIc,aAAJ,EAAmBP,mBAAnB,CAA1B;AACD"}
@@ -12,6 +12,8 @@ var _skia = require("../../skia");
12
12
  var _interpolate = require("./interpolate");
13
13
 
14
14
  const interpolateColorsRGB = (value, inputRange, outputRange) => {
15
+ "worklet";
16
+
15
17
  const r = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[0]), "clamp");
16
18
  const g = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[1]), "clamp");
17
19
  const b = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[2]), "clamp");
@@ -20,6 +22,8 @@ const interpolateColorsRGB = (value, inputRange, outputRange) => {
20
22
  };
21
23
 
22
24
  const interpolateColors = (value, inputRange, _outputRange) => {
25
+ "worklet";
26
+
23
27
  const outputRange = _outputRange.map(cl => _skia.Skia.Color(cl));
24
28
 
25
29
  return interpolateColorsRGB(value, inputRange, outputRange);
@@ -28,6 +32,8 @@ const interpolateColors = (value, inputRange, _outputRange) => {
28
32
  exports.interpolateColors = interpolateColors;
29
33
 
30
34
  const mixColors = (value, x, y) => {
35
+ "worklet";
36
+
31
37
  const c1 = _skia.Skia.Color(x);
32
38
 
33
39
  const c2 = _skia.Skia.Color(y);
@@ -1 +1 @@
1
- {"version":3,"names":["interpolateColorsRGB","value","inputRange","outputRange","r","interpolate","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y","c1","c2","mix"],"sources":["interpolateColors.ts"],"sourcesContent":["import { mix } from \"../../renderer/processors/math\";\nimport type { Color, SkColor } from \"../../skia\";\nimport { Skia } from \"../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n return new Float32Array([r, g, b, a]);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA,MAAMA,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;EACH,MAAMC,CAAC,GAAG,IAAAC,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAMC,CAAC,GAAG,IAAAH,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAME,CAAC,GAAG,IAAAJ,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAMG,CAAC,GAAG,IAAAL,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,OAAO,IAAII,YAAJ,CAAiB,CAACP,CAAD,EAAII,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,CA9BD;;AAgCO,MAAME,iBAAiB,GAAG,CAC/BX,KAD+B,EAE/BC,UAF+B,EAG/BW,YAH+B,KAI5B;EACH,MAAMV,WAAW,GAAGU,YAAY,CAACP,GAAb,CAAkBQ,EAAD,IAAQC,UAAA,CAAKC,KAAL,CAAWF,EAAX,CAAzB,CAApB;;EACA,OAAOd,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CAPM;;;;AASA,MAAMc,SAAS,GAAG,CAAChB,KAAD,EAAgBiB,CAAhB,EAA0BC,CAA1B,KAAuC;EAC9D,MAAMC,EAAE,GAAGL,UAAA,CAAKC,KAAL,CAAWE,CAAX,CAAX;;EACA,MAAMG,EAAE,GAAGN,UAAA,CAAKC,KAAL,CAAWG,CAAX,CAAX;;EACA,OAAO,IAAIR,YAAJ,CAAiB,CACtB,IAAAW,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CADsB,EAEtB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAFsB,EAGtB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAHsB,EAItB,IAAAC,SAAA,EAAIrB,KAAJ,EAAWmB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAJsB,CAAjB,CAAP;AAMD,CATM"}
1
+ {"version":3,"names":["interpolateColorsRGB","value","inputRange","outputRange","r","interpolate","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y","c1","c2","mix"],"sources":["interpolateColors.ts"],"sourcesContent":["import { mix } from \"../../renderer/processors/math\";\nimport type { Color, SkColor } from \"../../skia\";\nimport { Skia } from \"../../skia\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n \"worklet\";\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n return new Float32Array([r, g, b, a]);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n \"worklet\";\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n \"worklet\";\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA,MAAMA,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;EACH;;EACA,MAAMC,CAAC,GAAG,IAAAC,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAMC,CAAC,GAAG,IAAAH,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAME,CAAC,GAAG,IAAAJ,wBAAA,EACRJ,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;EAMA,MAAMG,CAAC,GAAG,IAAAL,wBAA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10,6 +10,8 @@ var _typeddash = require("../../renderer/typeddash");
10
10
  var _interpolate = require("./interpolate");
11
11
 
12
12
  const lerp = (value, from, to, p1, p2) => {
13
+ "worklet";
14
+
13
15
  const t = (value - from) / (to - from);
14
16
  return p2.interpolate(p1, t);
15
17
  };
@@ -32,6 +34,8 @@ const lerp = (value, from, to, p1, p2) => {
32
34
 
33
35
 
34
36
  const interpolatePaths = (value, input, outputRange, options) => {
37
+ "worklet";
38
+
35
39
  const extrapolation = (0, _interpolate.validateInterpolationOptions)(options);
36
40
 
37
41
  if (value < input[0]) {
@@ -1 +1 @@
1
- {"version":3,"names":["lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","extrapolation","validateInterpolationOptions","extrapolateLeft","Extrapolate","CLAMP","EXTEND","IDENTITY","Error","exhaustiveCheck","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 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 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;;AAGA;;AAEA,MAAMA,IAAI,GAAG,CACXC,KADW,EAEXC,IAFW,EAGXC,EAHW,EAIXC,EAJW,EAKXC,EALW,KAMR;EACH,MAAMC,CAAC,GAAG,CAACL,KAAK,GAAGC,IAAT,KAAkBC,EAAE,GAAGD,IAAvB,CAAV;EACA,OAAOG,EAAE,CAACE,WAAH,CAAeH,EAAf,EAAmBE,CAAnB,CAAP;AACD,CATD;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,gBAAgB,GAAG,CAC9BP,KAD8B,EAE9BQ,KAF8B,EAG9BC,WAH8B,EAI9BC,OAJ8B,KAK3B;EACH,MAAMC,aAAa,GAAG,IAAAC,yCAAA,EAA6BF,OAA7B,CAAtB;;EACA,IAAIV,KAAK,GAAGQ,KAAK,CAAC,CAAD,CAAjB,EAAsB;IACpB,QAA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ACjC,IAAItB,KAAK,IAAIQ,KAAK,CAACc,CAAD,CAAd,IAAqBtB,KAAK,IAAIQ,KAAK,CAACc,CAAC,GAAG,CAAL,CAAvC,EAAgD;MAC9C;IACD;EACF;;EACD,OAAOvB,IAAI,CACTC,KADS,EAETQ,KAAK,CAACc,CAAD,CAFI,EAGTd,KAAK,CAACc,CAAC,GAAG,CAAL,CAHI,EAITb,WAAW,CAACa,CAAD,CAJF,EAKTb,WAAW,CAACa,CAAC,GAAG,CAAL,CALF,CAAX;AAOD,CArDM"}
1
+ {"version":3,"names":["lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","extrapolation","validateInterpolationOptions","extrapolateLeft","Extrapolate","CLAMP","EXTEND","IDENTITY","Error","exhaustiveCheck","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;;AAGA;;AAEA,MAAMA,IAAI,GAAG,CACXC,KADW,EAEXC,IAFW,EAGXC,EAHW,EAIXC,EAJW,EAKXC,EALW,KAMR;EACH;;EACA,MAAMC,CAAC,GAAG,CAACL,KAAK,GAAGC,IAAT,KAAkBC,EAAE,GAAGD,IAAvB,CAAV;EACA,OAAOG,EAAE,CAACE,WAAH,CAAeH,EAAf,EAAmBE,CAAnB,CAAP;AACD,CAVD;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,gBAAgB,GAAG,CAC9BP,KAD8B,EAE9BQ,KAF8B,EAG9BC,WAH8B,EAI9BC,OAJ8B,KAK3B;EACH;;EACA,MAAMC,aAAa,GAAG,IAAAC,yCAAA,EAA6BF,OAA7B,CAAtB;;EACA,IAAIV,KAAK,GAAGQ,KAAK,CAAC,CAAD,CAAjB,EAAsB;IACpB,QAAQ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jC,IAAItB,KAAK,IAAIQ,KAAK,CAACc,CAAD,CAAd,IAAqBtB,KAAK,IAAIQ,KAAK,CAACc,CAAC,GAAG,CAAL,CAAvC,EAAgD;MAC9C;IACD;EACF;;EACD,OAAOvB,IAAI,CACTC,KADS,EAETQ,KAAK,CAACc,CAAD,CAFI,EAGTd,KAAK,CAACc,CAAC,GAAG,CAAL,CAHI,EAITb,WAAW,CAACa,CAAD,CAJF,EAKTb,WAAW,CAACa,CAAC,GAAG,CAAL,CALF,CAAX;AAOD,CAtDM"}
@@ -7,14 +7,22 @@ exports.mixVector = exports.interpolateVector = void 0;
7
7
 
8
8
  var _interpolate = require("./interpolate");
9
9
 
10
- const interpolateVector = (value, inputRange, outputRange, options) => ({
11
- x: (0, _interpolate.interpolate)(value, inputRange, outputRange.map(v => v.x), options),
12
- y: (0, _interpolate.interpolate)(value, inputRange, outputRange.map(v => v.y), options)
13
- });
10
+ const interpolateVector = (value, inputRange, outputRange, options) => {
11
+ "worklet";
12
+
13
+ return {
14
+ x: (0, _interpolate.interpolate)(value, inputRange, outputRange.map(v => v.x), options),
15
+ y: (0, _interpolate.interpolate)(value, inputRange, outputRange.map(v => v.y), options)
16
+ };
17
+ };
14
18
 
15
19
  exports.interpolateVector = interpolateVector;
16
20
 
17
- const mixVector = (value, from, to) => interpolateVector(value, [0, 1], [from, to]);
21
+ const mixVector = (value, from, to) => {
22
+ "worklet";
23
+
24
+ return interpolateVector(value, [0, 1], [from, to]);
25
+ };
18
26
 
19
27
  exports.mixVector = mixVector;
20
28
  //# sourceMappingURL=interpolateVector.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["interpolateVector","value","inputRange","outputRange","options","x","interpolate","map","v","y","mixVector","from","to"],"sources":["interpolateVector.ts"],"sourcesContent":["import type { Vector } from \"../../skia/types\";\n\nimport { interpolate } from \"./interpolate\";\n\nexport const interpolateVector = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly Vector[],\n options?: Parameters<typeof interpolate>[3]\n) => ({\n x: interpolate(\n value,\n inputRange,\n outputRange.map((v) => v.x),\n options\n ),\n y: interpolate(\n value,\n inputRange,\n outputRange.map((v) => v.y),\n options\n ),\n});\n\nexport const mixVector = (value: number, from: Vector, to: Vector) =>\n interpolateVector(value, [0, 1], [from, to]);\n"],"mappings":";;;;;;;AAEA;;AAEO,MAAMA,iBAAiB,GAAG,CAC/BC,KAD+B,EAE/BC,UAF+B,EAG/BC,WAH+B,EAI/BC,OAJ+B,MAK3B;EACJC,CAAC,EAAE,IAAAC,wBAAA,EACDL,KADC,EAEDC,UAFC,EAGDC,WAAW,CAACI,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAACH,CAAzB,CAHC,EAIDD,OAJC,CADC;EAOJK,CAAC,EAAE,IAAAH,wBAAA,EACDL,KADC,EAEDC,UAFC,EAGDC,WAAW,CAACI,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAACC,CAAzB,CAHC,EAIDL,OAJC;AAPC,CAL2B,CAA1B;;;;AAoBA,MAAMM,SAAS,GAAG,CAACT,KAAD,EAAgBU,IAAhB,EAA8BC,EAA9B,KACvBZ,iBAAiB,CAACC,KAAD,EAAQ,CAAC,CAAD,EAAI,CAAJ,CAAR,EAAgB,CAACU,IAAD,EAAOC,EAAP,CAAhB,CADZ"}
1
+ {"version":3,"names":["interpolateVector","value","inputRange","outputRange","options","x","interpolate","map","v","y","mixVector","from","to"],"sources":["interpolateVector.ts"],"sourcesContent":["import type { Vector } from \"../../skia/types\";\n\nimport { interpolate } from \"./interpolate\";\n\nexport const interpolateVector = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly Vector[],\n options?: Parameters<typeof interpolate>[3]\n) => {\n \"worklet\";\n return {\n x: interpolate(\n value,\n inputRange,\n outputRange.map((v) => v.x),\n options\n ),\n y: interpolate(\n value,\n inputRange,\n outputRange.map((v) => v.y),\n options\n ),\n };\n};\n\nexport const mixVector = (value: number, from: Vector, to: Vector) => {\n \"worklet\";\n return interpolateVector(value, [0, 1], [from, to]);\n};\n"],"mappings":";;;;;;;AAEA;;AAEO,MAAMA,iBAAiB,GAAG,CAC/BC,KAD+B,EAE/BC,UAF+B,EAG/BC,WAH+B,EAI/BC,OAJ+B,KAK5B;EACH;;EACA,OAAO;IACLC,CAAC,EAAE,IAAAC,wBAAA,EACDL,KADC,EAEDC,UAFC,EAGDC,WAAW,CAACI,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAACH,CAAzB,CAHC,EAIDD,OAJC,CADE;IAOLK,CAAC,EAAE,IAAAH,wBAAA,EACDL,KADC,EAEDC,UAFC,EAGDC,WAAW,CAACI,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAACC,CAAzB,CAHC,EAIDL,OAJC;EAPE,CAAP;AAcD,CArBM;;;;AAuBA,MAAMM,SAAS,GAAG,CAACT,KAAD,EAAgBU,IAAhB,EAA8BC,EAA9B,KAA6C;EACpE;;EACA,OAAOZ,iBAAiB,CAACC,KAAD,EAAQ,CAAC,CAAD,EAAI,CAAJ,CAAR,EAAgB,CAACU,IAAD,EAAOC,EAAP,CAAhB,CAAxB;AACD,CAHM"}
@@ -20,8 +20,11 @@ const useSharedValueEffect = function (cb, value) {
20
20
  values[_key - 2] = arguments[_key];
21
21
  }
22
22
 
23
- console.warn(`useSharedValueEffect() is now deprecated, you can use Reanimated values directly.
24
- Learn more at https://shopify.github.io/react-native-skia/.`);
23
+ if (_moduleWrapper.HAS_REANIMATED3) {
24
+ console.warn(`useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.
25
+ Learn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`);
26
+ }
27
+
25
28
  const input = (0, _moduleWrapper.useSharedValue)(0);
26
29
  (0, _react.useEffect)(() => {
27
30
  if (!_moduleWrapper.HAS_REANIMATED2) {
@@ -1 +1 @@
1
- {"version":3,"names":["useSharedValueEffect","cb","value","values","console","warn","input","useSharedValue","useEffect","HAS_REANIMATED2","mapperId","startMapper","runOnJS","stopMapper","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n console.warn(\n `useSharedValueEffect() is now deprecated, you can use Reanimated values directly.\nLearn more at https://shopify.github.io/react-native-skia/.`\n );\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACHC,OAAO,CAACC,IAAR,CACG;AACL,4DAFE;EAIA,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,CAACC,8BAAL,EAAsB;MACpBL,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAMK,QAAQ,GAAG,IAAAC,0BAAA,EACf,MAAM;QACJ;;QACA,IAAAC,sBAAA,EAAQX,EAAR;MACD,CAJc,EAKf,CAACC,KAAD,EAAQ,GAAGC,MAAX,CALe,EAMf,CAACG,KAAD,CANe,CAAjB,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIO,yBAAA,IAAcH,QAAQ,KAAKI,SAA/B,EAA0C;UACxC,IAAAD,yBAAA,EAAWH,QAAX;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBD,EAwBG,CAACJ,KAAD,EAAQJ,KAAR,EAAe,GAAGC,MAAlB,CAxBH;AAyBD,CApCM"}
1
+ {"version":3,"names":["useSharedValueEffect","cb","value","values","HAS_REANIMATED3","console","warn","input","useSharedValue","useEffect","HAS_REANIMATED2","mapperId","startMapper","runOnJS","stopMapper","undefined"],"sources":["useSharedValueEffect.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport type { SharedValueType } from \"../../renderer/processors/Animations\";\n\nimport {\n HAS_REANIMATED2,\n useSharedValue,\n runOnJS,\n startMapper,\n stopMapper,\n HAS_REANIMATED3,\n} from \"./moduleWrapper\";\n\n/**\n * Connects a shared value from reanimated to a SkiaView or Canvas\n * so whenever the shared value changes the SkiaView will redraw.\n * @param cb Callback that will be called whenever the shared value changes.\n * @param values One or more shared values to listen for.\n */\nexport const useSharedValueEffect = <T = number>(\n cb: () => void,\n value: SharedValueType<T>,\n ...values: SharedValueType<T>[]\n) => {\n if (HAS_REANIMATED3) {\n console.warn(\n `useSharedValueEffect() is deprecated with Reanimated 3, you can use Reanimated values directly.\nLearn more at https://shopify.github.io/react-native-skia/docs/animations/reanimated.`\n );\n }\n const input = useSharedValue(0);\n\n useEffect(() => {\n if (!HAS_REANIMATED2) {\n console.warn(\n \"Reanimated was not found and the useSharedValueEffect hook will have no effect.\"\n );\n } else {\n // Start a mapper in Reanimated\n const mapperId = startMapper(\n () => {\n \"worklet\";\n runOnJS(cb)();\n },\n [value, ...values],\n [input]\n );\n // Return unregistering the mapper\n return () => {\n if (stopMapper && mapperId !== undefined) {\n stopMapper(mapperId);\n }\n };\n }\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [input, value, ...values]);\n};\n"],"mappings":";;;;;;;AAAA;;AAIA;;AASA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAClCC,EADkC,EAElCC,KAFkC,EAI/B;EAAA,kCADAC,MACA;IADAA,MACA;EAAA;;EACH,IAAIC,8BAAJ,EAAqB;IACnBC,OAAO,CAACC,IAAR,CACG;AACP,sFAFI;EAID;;EACD,MAAMC,KAAK,GAAG,IAAAC,6BAAA,EAAe,CAAf,CAAd;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,CAACC,8BAAL,EAAsB;MACpBL,OAAO,CAACC,IAAR,CACE,iFADF;IAGD,CAJD,MAIO;MACL;MACA,MAAMK,QAAQ,GAAG,IAAAC,0BAAA,EACf,MAAM;QACJ;;QACA,IAAAC,sBAAA,EAAQZ,EAAR;MACD,CAJc,EAKf,CAACC,KAAD,EAAQ,GAAGC,MAAX,CALe,EAMf,CAACI,KAAD,CANe,CAAjB,CAFK,CAUL;;MACA,OAAO,MAAM;QACX,IAAIO,yBAAA,IAAcH,QAAQ,KAAKI,SAA/B,EAA0C;UACxC,IAAAD,yBAAA,EAAWH,QAAX;QACD;MACF,CAJD;IAKD;;IACD,OAAO,MAAM,CAAE,CAAf,CAtBc,CAuBd;EACD,CAxBD,EAwBG,CAACJ,KAAD,EAAQL,KAAR,EAAe,GAAGC,MAAlB,CAxBH;AAyBD,CAtCM"}
@@ -5,39 +5,63 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.polar2Cartesian = exports.polar2Canvas = exports.cartesian2Polar = exports.cartesian2Canvas = exports.canvas2Polar = exports.canvas2Cartesian = void 0;
7
7
 
8
- const canvas2Cartesian = (v, center) => ({
9
- x: v.x - center.x,
10
- y: -1 * (v.y - center.y)
11
- });
8
+ const canvas2Cartesian = (v, center) => {
9
+ "worklet";
10
+
11
+ return {
12
+ x: v.x - center.x,
13
+ y: -1 * (v.y - center.y)
14
+ };
15
+ };
12
16
 
13
17
  exports.canvas2Cartesian = canvas2Cartesian;
14
18
 
15
- const cartesian2Canvas = (v, center) => ({
16
- x: v.x + center.x,
17
- y: -1 * v.y + center.y
18
- });
19
+ const cartesian2Canvas = (v, center) => {
20
+ "worklet";
21
+
22
+ return {
23
+ x: v.x + center.x,
24
+ y: -1 * v.y + center.y
25
+ };
26
+ };
19
27
 
20
28
  exports.cartesian2Canvas = cartesian2Canvas;
21
29
 
22
- const cartesian2Polar = v => ({
23
- theta: Math.atan2(v.y, v.x),
24
- radius: Math.sqrt(v.x ** 2 + v.y ** 2)
25
- });
30
+ const cartesian2Polar = v => {
31
+ "worklet";
32
+
33
+ return {
34
+ theta: Math.atan2(v.y, v.x),
35
+ radius: Math.sqrt(v.x ** 2 + v.y ** 2)
36
+ };
37
+ };
26
38
 
27
39
  exports.cartesian2Polar = cartesian2Polar;
28
40
 
29
- const polar2Cartesian = p => ({
30
- x: p.radius * Math.cos(p.theta),
31
- y: p.radius * Math.sin(p.theta)
32
- });
41
+ const polar2Cartesian = p => {
42
+ "worklet";
43
+
44
+ return {
45
+ x: p.radius * Math.cos(p.theta),
46
+ y: p.radius * Math.sin(p.theta)
47
+ };
48
+ };
33
49
 
34
50
  exports.polar2Cartesian = polar2Cartesian;
35
51
 
36
- const polar2Canvas = (p, center) => cartesian2Canvas(polar2Cartesian(p), center);
52
+ const polar2Canvas = (p, center) => {
53
+ "worklet";
54
+
55
+ return cartesian2Canvas(polar2Cartesian(p), center);
56
+ };
37
57
 
38
58
  exports.polar2Canvas = polar2Canvas;
39
59
 
40
- const canvas2Polar = (v, center) => cartesian2Polar(canvas2Cartesian(v, center));
60
+ const canvas2Polar = (v, center) => {
61
+ "worklet";
62
+
63
+ return cartesian2Polar(canvas2Cartesian(v, center));
64
+ };
41
65
 
42
66
  exports.canvas2Polar = canvas2Polar;
43
67
  //# sourceMappingURL=Coordinates.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["canvas2Cartesian","v","center","x","y","cartesian2Canvas","cartesian2Polar","theta","Math","atan2","radius","sqrt","polar2Cartesian","p","cos","sin","polar2Canvas","canvas2Polar"],"sources":["Coordinates.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nexport interface PolarPoint {\n theta: number;\n radius: number;\n}\n\nexport const canvas2Cartesian = (v: Vector, center: Vector) => ({\n x: v.x - center.x,\n y: -1 * (v.y - center.y),\n});\n\nexport const cartesian2Canvas = (v: Vector, center: Vector) => ({\n x: v.x + center.x,\n y: -1 * v.y + center.y,\n});\n\nexport const cartesian2Polar = (v: Vector) => ({\n theta: Math.atan2(v.y, v.x),\n radius: Math.sqrt(v.x ** 2 + v.y ** 2),\n});\n\nexport const polar2Cartesian = (p: PolarPoint) => ({\n x: p.radius * Math.cos(p.theta),\n y: p.radius * Math.sin(p.theta),\n});\n\nexport const polar2Canvas = (p: PolarPoint, center: Vector) =>\n cartesian2Canvas(polar2Cartesian(p), center);\n\nexport const canvas2Polar = (v: Vector, center: Vector) =>\n cartesian2Polar(canvas2Cartesian(v, center));\n"],"mappings":";;;;;;;AAOO,MAAMA,gBAAgB,GAAG,CAACC,CAAD,EAAYC,MAAZ,MAAgC;EAC9DC,CAAC,EAAEF,CAAC,CAACE,CAAF,GAAMD,MAAM,CAACC,CAD8C;EAE9DC,CAAC,EAAE,CAAC,CAAD,IAAMH,CAAC,CAACG,CAAF,GAAMF,MAAM,CAACE,CAAnB;AAF2D,CAAhC,CAAzB;;;;AAKA,MAAMC,gBAAgB,GAAG,CAACJ,CAAD,EAAYC,MAAZ,MAAgC;EAC9DC,CAAC,EAAEF,CAAC,CAACE,CAAF,GAAMD,MAAM,CAACC,CAD8C;EAE9DC,CAAC,EAAE,CAAC,CAAD,GAAKH,CAAC,CAACG,CAAP,GAAWF,MAAM,CAACE;AAFyC,CAAhC,CAAzB;;;;AAKA,MAAME,eAAe,GAAIL,CAAD,KAAgB;EAC7CM,KAAK,EAAEC,IAAI,CAACC,KAAL,CAAWR,CAAC,CAACG,CAAb,EAAgBH,CAAC,CAACE,CAAlB,CADsC;EAE7CO,MAAM,EAAEF,IAAI,CAACG,IAAL,CAAUV,CAAC,CAACE,CAAF,IAAO,CAAP,GAAWF,CAAC,CAACG,CAAF,IAAO,CAA5B;AAFqC,CAAhB,CAAxB;;;;AAKA,MAAMQ,eAAe,GAAIC,CAAD,KAAoB;EACjDV,CAAC,EAAEU,CAAC,CAACH,MAAF,GAAWF,IAAI,CAACM,GAAL,CAASD,CAAC,CAACN,KAAX,CADmC;EAEjDH,CAAC,EAAES,CAAC,CAACH,MAAF,GAAWF,IAAI,CAACO,GAAL,CAASF,CAAC,CAACN,KAAX;AAFmC,CAApB,CAAxB;;;;AAKA,MAAMS,YAAY,GAAG,CAACH,CAAD,EAAgBX,MAAhB,KAC1BG,gBAAgB,CAACO,eAAe,CAACC,CAAD,CAAhB,EAAqBX,MAArB,CADX;;;;AAGA,MAAMe,YAAY,GAAG,CAAChB,CAAD,EAAYC,MAAZ,KAC1BI,eAAe,CAACN,gBAAgB,CAACC,CAAD,EAAIC,MAAJ,CAAjB,CADV"}
1
+ {"version":3,"names":["canvas2Cartesian","v","center","x","y","cartesian2Canvas","cartesian2Polar","theta","Math","atan2","radius","sqrt","polar2Cartesian","p","cos","sin","polar2Canvas","canvas2Polar"],"sources":["Coordinates.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nexport interface PolarPoint {\n theta: number;\n radius: number;\n}\n\nexport const canvas2Cartesian = (v: Vector, center: Vector) => {\n \"worklet\";\n return {\n x: v.x - center.x,\n y: -1 * (v.y - center.y),\n };\n};\n\nexport const cartesian2Canvas = (v: Vector, center: Vector) => {\n \"worklet\";\n return {\n x: v.x + center.x,\n y: -1 * v.y + center.y,\n };\n};\n\nexport const cartesian2Polar = (v: Vector) => {\n \"worklet\";\n return {\n theta: Math.atan2(v.y, v.x),\n radius: Math.sqrt(v.x ** 2 + v.y ** 2),\n };\n};\n\nexport const polar2Cartesian = (p: PolarPoint) => {\n \"worklet\";\n return {\n x: p.radius * Math.cos(p.theta),\n y: p.radius * Math.sin(p.theta),\n };\n};\n\nexport const polar2Canvas = (p: PolarPoint, center: Vector) => {\n \"worklet\";\n return cartesian2Canvas(polar2Cartesian(p), center);\n};\n\nexport const canvas2Polar = (v: Vector, center: Vector) => {\n \"worklet\";\n return cartesian2Polar(canvas2Cartesian(v, center));\n};\n"],"mappings":";;;;;;;AAOO,MAAMA,gBAAgB,GAAG,CAACC,CAAD,EAAYC,MAAZ,KAA+B;EAC7D;;EACA,OAAO;IACLC,CAAC,EAAEF,CAAC,CAACE,CAAF,GAAMD,MAAM,CAACC,CADX;IAELC,CAAC,EAAE,CAAC,CAAD,IAAMH,CAAC,CAACG,CAAF,GAAMF,MAAM,CAACE,CAAnB;EAFE,CAAP;AAID,CANM;;;;AAQA,MAAMC,gBAAgB,GAAG,CAACJ,CAAD,EAAYC,MAAZ,KAA+B;EAC7D;;EACA,OAAO;IACLC,CAAC,EAAEF,CAAC,CAACE,CAAF,GAAMD,MAAM,CAACC,CADX;IAELC,CAAC,EAAE,CAAC,CAAD,GAAKH,CAAC,CAACG,CAAP,GAAWF,MAAM,CAACE;EAFhB,CAAP;AAID,CANM;;;;AAQA,MAAME,eAAe,GAAIL,CAAD,IAAe;EAC5C;;EACA,OAAO;IACLM,KAAK,EAAEC,IAAI,CAACC,KAAL,CAAWR,CAAC,CAACG,CAAb,EAAgBH,CAAC,CAACE,CAAlB,CADF;IAELO,MAAM,EAAEF,IAAI,CAACG,IAAL,CAAUV,CAAC,CAACE,CAAF,IAAO,CAAP,GAAWF,CAAC,CAACG,CAAF,IAAO,CAA5B;EAFH,CAAP;AAID,CANM;;;;AAQA,MAAMQ,eAAe,GAAIC,CAAD,IAAmB;EAChD;;EACA,OAAO;IACLV,CAAC,EAAEU,CAAC,CAACH,MAAF,GAAWF,IAAI,CAACM,GAAL,CAASD,CAAC,CAACN,KAAX,CADT;IAELH,CAAC,EAAES,CAAC,CAACH,MAAF,GAAWF,IAAI,CAACO,GAAL,CAASF,CAAC,CAACN,KAAX;EAFT,CAAP;AAID,CANM;;;;AAQA,MAAMS,YAAY,GAAG,CAACH,CAAD,EAAgBX,MAAhB,KAAmC;EAC7D;;EACA,OAAOG,gBAAgB,CAACO,eAAe,CAACC,CAAD,CAAhB,EAAqBX,MAArB,CAAvB;AACD,CAHM;;;;AAKA,MAAMe,YAAY,GAAG,CAAChB,CAAD,EAAYC,MAAZ,KAA+B;EACzD;;EACA,OAAOI,eAAe,CAACN,gBAAgB,CAACC,CAAD,EAAIC,MAAJ,CAAjB,CAAtB;AACD,CAHM"}
@@ -11,7 +11,11 @@ exports.mix = exports.clamp = void 0;
11
11
  * @param x
12
12
  * @param y
13
13
  */
14
- const mix = (value, x, y) => x * (1 - value) + y * value;
14
+ const mix = (value, x, y) => {
15
+ "worklet";
16
+
17
+ return x * (1 - value) + y * value;
18
+ };
15
19
  /**
16
20
  * @summary Clamps a node with a lower and upper bound.
17
21
  * @example
@@ -23,7 +27,11 @@ const mix = (value, x, y) => x * (1 - value) + y * value;
23
27
 
24
28
  exports.mix = mix;
25
29
 
26
- const clamp = (value, lowerBound, upperBound) => Math.min(Math.max(lowerBound, value), upperBound);
30
+ const clamp = (value, lowerBound, upperBound) => {
31
+ "worklet";
32
+
33
+ return Math.min(Math.max(lowerBound, value), upperBound);
34
+ };
27
35
 
28
36
  exports.clamp = clamp;
29
37
  //# sourceMappingURL=Math.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["mix","value","x","y","clamp","lowerBound","upperBound","Math","min","max"],"sources":["Math.ts"],"sourcesContent":["/**\n * Linear interpolation\n * @param value\n * @param x\n * @param y\n */\nexport const mix = (value: number, x: number, y: number) =>\n x * (1 - value) + y * value;\n\n/**\n * @summary Clamps a node with a lower and upper bound.\n * @example\n clamp(-1, 0, 100); // 0\n clamp(1, 0, 100); // 1\n clamp(101, 0, 100); // 100\n */\nexport const clamp = (value: number, lowerBound: number, upperBound: number) =>\n Math.min(Math.max(lowerBound, value), upperBound);\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,GAAG,GAAG,CAACC,KAAD,EAAgBC,CAAhB,EAA2BC,CAA3B,KACjBD,CAAC,IAAI,IAAID,KAAR,CAAD,GAAkBE,CAAC,GAAGF,KADjB;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,KAAK,GAAG,CAACH,KAAD,EAAgBI,UAAhB,EAAoCC,UAApC,KACnBC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASJ,UAAT,EAAqBJ,KAArB,CAAT,EAAsCK,UAAtC,CADK"}
1
+ {"version":3,"names":["mix","value","x","y","clamp","lowerBound","upperBound","Math","min","max"],"sources":["Math.ts"],"sourcesContent":["/**\n * Linear interpolation\n * @param value\n * @param x\n * @param y\n */\nexport const mix = (value: number, x: number, y: number) => {\n \"worklet\";\n return x * (1 - value) + y * value;\n};\n\n/**\n * @summary Clamps a node with a lower and upper bound.\n * @example\n clamp(-1, 0, 100); // 0\n clamp(1, 0, 100); // 1\n clamp(101, 0, 100); // 100\n */\nexport const clamp = (\n value: number,\n lowerBound: number,\n upperBound: number\n) => {\n \"worklet\";\n return Math.min(Math.max(lowerBound, value), upperBound);\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,GAAG,GAAG,CAACC,KAAD,EAAgBC,CAAhB,EAA2BC,CAA3B,KAAyC;EAC1D;;EACA,OAAOD,CAAC,IAAI,IAAID,KAAR,CAAD,GAAkBE,CAAC,GAAGF,KAA7B;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,KAAK,GAAG,CACnBH,KADmB,EAEnBI,UAFmB,EAGnBC,UAHmB,KAIhB;EACH;;EACA,OAAOC,IAAI,CAACC,GAAL,CAASD,IAAI,CAACE,GAAL,CAASJ,UAAT,EAAqBJ,KAArB,CAAT,EAAsCK,UAAtC,CAAP;AACD,CAPM"}
@@ -8,6 +8,8 @@ exports.rotate = void 0;
8
8
  var _Coordinates = require("./Coordinates");
9
9
 
10
10
  const rotate = (tr, origin, rotation) => {
11
+ "worklet";
12
+
11
13
  const {
12
14
  radius,
13
15
  theta
@@ -1 +1 @@
1
- {"version":3,"names":["rotate","tr","origin","rotation","radius","theta","canvas2Polar","polar2Canvas"],"sources":["Transforms.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nimport { canvas2Polar, polar2Canvas } from \"./Coordinates\";\n\nexport const rotate = (tr: Vector, origin: Vector, rotation: number) => {\n const { radius, theta } = canvas2Polar(tr, origin);\n return polar2Canvas({ radius, theta: theta + rotation }, origin);\n};\n"],"mappings":";;;;;;;AAEA;;AAEO,MAAMA,MAAM,GAAG,CAACC,EAAD,EAAaC,MAAb,EAA6BC,QAA7B,KAAkD;EACtE,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoB,IAAAC,yBAAA,EAAaL,EAAb,EAAiBC,MAAjB,CAA1B;EACA,OAAO,IAAAK,yBAAA,EAAa;IAAEH,MAAF;IAAUC,KAAK,EAAEA,KAAK,GAAGF;EAAzB,CAAb,EAAkDD,MAAlD,CAAP;AACD,CAHM"}
1
+ {"version":3,"names":["rotate","tr","origin","rotation","radius","theta","canvas2Polar","polar2Canvas"],"sources":["Transforms.ts"],"sourcesContent":["import type { Vector } from \"../../../skia/types\";\n\nimport { canvas2Polar, polar2Canvas } from \"./Coordinates\";\n\nexport const rotate = (tr: Vector, origin: Vector, rotation: number) => {\n \"worklet\";\n const { radius, theta } = canvas2Polar(tr, origin);\n return polar2Canvas({ radius, theta: theta + rotation }, origin);\n};\n"],"mappings":";;;;;;;AAEA;;AAEO,MAAMA,MAAM,GAAG,CAACC,EAAD,EAAaC,MAAb,EAA6BC,QAA7B,KAAkD;EACtE;;EACA,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoB,IAAAC,yBAAA,EAAaL,EAAb,EAAiBC,MAAjB,CAA1B;EACA,OAAO,IAAAK,yBAAA,EAAa;IAAEH,MAAF;IAAUC,KAAK,EAAEA,KAAK,GAAGF;EAAzB,CAAb,EAAkDD,MAAlD,CAAP;AACD,CAJM"}
@@ -10,6 +10,8 @@ const mapKeys = obj => Object.keys(obj);
10
10
  exports.mapKeys = mapKeys;
11
11
 
12
12
  const exhaustiveCheck = a => {
13
+ "worklet";
14
+
13
15
  throw new Error(`Unexhaustive handling for ${a}`);
14
16
  }; // Shallow eq on props (without children)
15
17
 
@@ -1 +1 @@
1
- {"version":3,"names":["mapKeys","obj","Object","keys","exhaustiveCheck","a","Error","shallowEq","p1","p2","keys1","keys2","length","key"],"sources":["typeddash.ts"],"sourcesContent":["export const mapKeys = <T extends object>(obj: T) =>\n Object.keys(obj) as (keyof T)[];\n\nexport const exhaustiveCheck = (a: never): never => {\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n// Shallow eq on props (without children)\nexport const shallowEq = <P extends object>(p1: P, p2: P): boolean => {\n const keys1 = mapKeys(p1);\n const keys2 = mapKeys(p2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n if (key === \"children\") {\n continue;\n }\n if (p1[key] !== p2[key]) {\n return false;\n }\n }\n return true;\n};\n"],"mappings":";;;;;;;AAAO,MAAMA,OAAO,GAAsBC,GAAnB,IACrBC,MAAM,CAACC,IAAP,CAAYF,GAAZ,CADK;;;;AAGA,MAAMG,eAAe,GAAIC,CAAD,IAAqB;EAClD,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAFM,C,CAIP;;;;;AACO,MAAME,SAAS,GAAG,CAAmBC,EAAnB,EAA0BC,EAA1B,KAA6C;EACpE,MAAMC,KAAK,GAAGV,OAAO,CAACQ,EAAD,CAArB;EACA,MAAMG,KAAK,GAAGX,OAAO,CAACS,EAAD,CAArB;;EACA,IAAIC,KAAK,CAACE,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;IACjC,OAAO,KAAP;EACD;;EACD,KAAK,MAAMC,GAAX,IAAkBH,KAAlB,EAAyB;IACvB,IAAIG,GAAG,KAAK,UAAZ,EAAwB;MACtB;IACD;;IACD,IAAIL,EAAE,CAACK,GAAD,CAAF,KAAYJ,EAAE,CAACI,GAAD,CAAlB,EAAyB;MACvB,OAAO,KAAP;IACD;EACF;;EACD,OAAO,IAAP;AACD,CAfM"}
1
+ {"version":3,"names":["mapKeys","obj","Object","keys","exhaustiveCheck","a","Error","shallowEq","p1","p2","keys1","keys2","length","key"],"sources":["typeddash.ts"],"sourcesContent":["export const mapKeys = <T extends object>(obj: T) =>\n Object.keys(obj) as (keyof T)[];\n\nexport const exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n// Shallow eq on props (without children)\nexport const shallowEq = <P extends object>(p1: P, p2: P): boolean => {\n const keys1 = mapKeys(p1);\n const keys2 = mapKeys(p2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n if (key === \"children\") {\n continue;\n }\n if (p1[key] !== p2[key]) {\n return false;\n }\n }\n return true;\n};\n"],"mappings":";;;;;;;AAAO,MAAMA,OAAO,GAAsBC,GAAnB,IACrBC,MAAM,CAACC,IAAP,CAAYF,GAAZ,CADK;;;;AAGA,MAAMG,eAAe,GAAIC,CAAD,IAAqB;EAClD;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHM,C,CAKP;;;;;AACO,MAAME,SAAS,GAAG,CAAmBC,EAAnB,EAA0BC,EAA1B,KAA6C;EACpE,MAAMC,KAAK,GAAGV,OAAO,CAACQ,EAAD,CAArB;EACA,MAAMG,KAAK,GAAGX,OAAO,CAACS,EAAD,CAArB;;EACA,IAAIC,KAAK,CAACE,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;IACjC,OAAO,KAAP;EACD;;EACD,KAAK,MAAMC,GAAX,IAAkBH,KAAlB,EAAyB;IACvB,IAAIG,GAAG,KAAK,UAAZ,EAAwB;MACtB;IACD;;IACD,IAAIL,EAAE,CAACK,GAAD,CAAF,KAAYJ,EAAE,CAACI,GAAD,CAAlB,EAAyB;MACvB,OAAO,KAAP;IACD;EACF;;EACD,OAAO,IAAP;AACD,CAfM"}
@@ -8,6 +8,8 @@ exports.vec = exports.translate = exports.sub = exports.point = exports.neg = ex
8
8
  var _Skia = require("../Skia");
9
9
 
10
10
  const vec = function () {
11
+ "worklet";
12
+
11
13
  let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
12
14
  let y = arguments.length > 1 ? arguments[1] : undefined;
13
15
  return _Skia.Skia.Point(x, y ?? x);
@@ -17,23 +19,41 @@ exports.vec = vec;
17
19
  const point = vec;
18
20
  exports.point = point;
19
21
 
20
- const neg = a => vec(-a.x, -a.y);
22
+ const neg = a => {
23
+ "worklet";
24
+
25
+ return vec(-a.x, -a.y);
26
+ };
21
27
 
22
28
  exports.neg = neg;
23
29
 
24
- const add = (a, b) => vec(a.x + b.x, a.y + b.y);
30
+ const add = (a, b) => {
31
+ "worklet";
32
+
33
+ return vec(a.x + b.x, a.y + b.y);
34
+ };
25
35
 
26
36
  exports.add = add;
27
37
 
28
- const sub = (a, b) => vec(a.x - b.x, a.y - b.y);
38
+ const sub = (a, b) => {
39
+ "worklet";
40
+
41
+ return vec(a.x - b.x, a.y - b.y);
42
+ };
29
43
 
30
44
  exports.sub = sub;
31
45
 
32
- const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
46
+ const dist = (a, b) => {
47
+ "worklet";
48
+
49
+ return Math.hypot(a.x - b.x, a.y - b.y);
50
+ };
33
51
 
34
52
  exports.dist = dist;
35
53
 
36
54
  const translate = _ref => {
55
+ "worklet";
56
+
37
57
  let {
38
58
  x,
39
59
  y
@@ -1 +1 @@
1
- {"version":3,"names":["vec","x","y","Skia","Point","point","neg","a","add","b","sub","dist","Math","hypot","translate","translateX","translateY"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => Skia.Point(x, y ?? x);\nexport const point = vec;\nexport const neg = (a: Vector) => vec(-a.x, -a.y);\nexport const add = (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y);\nexport const sub = (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y);\nexport const dist = (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y);\nexport const translate = ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const;\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,GAAG,GAAG;EAAA,IAACC,CAAD,uEAAK,CAAL;EAAA,IAAQC,CAAR;EAAA,OAAuBC,UAAA,CAAKC,KAAL,CAAWH,CAAX,EAAcC,CAAC,IAAID,CAAnB,CAAvB;AAAA,CAAZ;;;AACA,MAAMI,KAAK,GAAGL,GAAd;;;AACA,MAAMM,GAAG,GAAIC,CAAD,IAAeP,GAAG,CAAC,CAACO,CAAC,CAACN,CAAJ,EAAO,CAACM,CAAC,CAACL,CAAV,CAA9B;;;;AACA,MAAMM,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0BT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAzC;;;;AACA,MAAMQ,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0BT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAzC;;;;AACA,MAAMS,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0BG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAnB,EAAsBM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAA9B,CAAvC;;;;AACA,MAAMY,SAAS,GAAG;EAAA,IAAC;IAAEb,CAAF;IAAKC;EAAL,CAAD;EAAA,OACvB,CAAC;IAAEa,UAAU,EAAEd;EAAd,CAAD,EAAoB;IAAEe,UAAU,EAAEd;EAAd,CAApB,CADuB;AAAA,CAAlB"}
1
+ {"version":3,"names":["vec","x","y","Skia","Point","point","neg","a","add","b","sub","dist","Math","hypot","translate","translateX","translateY"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\nexport const translate = ({ x, y }: Vector) => {\n \"worklet\";\n return [{ translateX: x }, { translateY: y }] as const;\n};\n"],"mappings":";;;;;;;AAAA;;AAGO,MAAMA,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOC,UAAA,CAAKC,KAAL,CAAWH,CAAX,EAAcC,CAAC,IAAID,CAAnB,CAAP;AACD,CAHM;;;AAIA,MAAMI,KAAK,GAAGL,GAAd;;;AACA,MAAMM,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAOP,GAAG,CAAC,CAACO,CAAC,CAACN,CAAJ,EAAO,CAACM,CAAC,CAACL,CAAV,CAAV;AACD,CAHM;;;;AAIA,MAAMM,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAV;AACD,CAHM;;;;AAIA,MAAMQ,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOT,GAAG,CAACO,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAT,EAAYM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAApB,CAAV;AACD,CAHM;;;;AAIA,MAAMS,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACN,CAAF,GAAMQ,CAAC,CAACR,CAAnB,EAAsBM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAA9B,CAAP;AACD,CAHM;;;;AAIA,MAAMY,SAAS,GAAG,QAAsB;EAC7C;;EAD6C,IAArB;IAAEb,CAAF;IAAKC;EAAL,CAAqB;EAE7C,OAAO,CAAC;IAAEa,UAAU,EAAEd;EAAd,CAAD,EAAoB;IAAEe,UAAU,EAAEd;EAAd,CAApB,CAAP;AACD,CAHM"}
@@ -8,6 +8,8 @@ export let Extrapolate;
8
8
  })(Extrapolate || (Extrapolate = {}));
9
9
 
10
10
  function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
11
+ "worklet";
12
+
11
13
  switch (type) {
12
14
  case Extrapolate.IDENTITY:
13
15
  return x;
@@ -26,13 +28,16 @@ function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
26
28
  }
27
29
 
28
30
  function isExtrapolate(value) {
31
+ "worklet";
32
+
29
33
  return value === Extrapolate.EXTEND || value === Extrapolate.CLAMP || value === Extrapolate.IDENTITY;
30
34
  } // validates extrapolations type
31
35
  // if type is correct, converts it to ExtrapolationConfig
32
36
 
33
37
 
34
38
  export function validateInterpolationOptions(type) {
35
- // initialize extrapolationConfig with default extrapolation
39
+ "worklet"; // initialize extrapolationConfig with default extrapolation
40
+
36
41
  const extrapolationConfig = {
37
42
  extrapolateLeft: Extrapolate.EXTEND,
38
43
  extrapolateRight: Extrapolate.EXTEND
@@ -67,6 +72,8 @@ export function validateInterpolationOptions(type) {
67
72
  }
68
73
 
69
74
  function internalInterpolate(x, narrowedInput, extrapolationConfig) {
75
+ "worklet";
76
+
70
77
  const {
71
78
  leftEdgeInput,
72
79
  rightEdgeInput,
@@ -93,6 +100,8 @@ function internalInterpolate(x, narrowedInput, extrapolationConfig) {
93
100
 
94
101
 
95
102
  export function interpolate(x, input, output, type) {
103
+ "worklet";
104
+
96
105
  if (input.length < 2 || output.length < 2) {
97
106
  throw Error("Interpolation input and output should contain at least two values.");
98
107
  }