@shopify/react-native-skia 0.1.134 → 0.1.138

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/README.md +4 -47
  2. package/android/build.gradle +1 -2
  3. package/cpp/api/JsiSkFont.h +25 -1
  4. package/cpp/api/JsiSkMatrix.h +12 -0
  5. package/cpp/api/JsiSkTypeface.h +1 -29
  6. package/jestSetup.js +5 -0
  7. package/lib/commonjs/animation/functions/interpolate.js +3 -2
  8. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  9. package/lib/commonjs/animation/functions/interpolateColors.js +2 -2
  10. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -1
  11. package/lib/commonjs/animation/functions/interpolatePaths.js +45 -11
  12. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  13. package/lib/commonjs/mock/index.js +121 -177
  14. package/lib/commonjs/mock/index.js.map +1 -1
  15. package/lib/commonjs/renderer/components/Group.js +1 -1
  16. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  17. package/lib/commonjs/renderer/processors/Transform.js +8 -15
  18. package/lib/commonjs/renderer/processors/Transform.js.map +1 -1
  19. package/lib/commonjs/skia/core/Data.js +7 -4
  20. package/lib/commonjs/skia/core/Data.js.map +1 -1
  21. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  22. package/lib/commonjs/skia/types/Matrix.js +18 -3
  23. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  24. package/lib/commonjs/skia/web/JsiSkFont.js +6 -0
  25. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  26. package/lib/commonjs/skia/web/JsiSkMatrix.js +4 -0
  27. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  28. package/lib/commonjs/values/api.js +1 -7
  29. package/lib/commonjs/values/api.js.map +1 -1
  30. package/lib/commonjs/values/hooks/useComputedValue.js +2 -2
  31. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  32. package/lib/commonjs/views/SkiaView.web.js +27 -37
  33. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  34. package/lib/commonjs/web/LoadSkiaWeb.js +29 -0
  35. package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -0
  36. package/lib/commonjs/web/WithSkiaWeb.js +39 -0
  37. package/lib/commonjs/web/WithSkiaWeb.js.map +1 -0
  38. package/lib/commonjs/web/index.js +22 -12
  39. package/lib/commonjs/web/index.js.map +1 -1
  40. package/lib/module/animation/functions/interpolate.js +2 -2
  41. package/lib/module/animation/functions/interpolate.js.map +1 -1
  42. package/lib/module/animation/functions/interpolateColors.js +1 -1
  43. package/lib/module/animation/functions/interpolateColors.js.map +1 -1
  44. package/lib/module/animation/functions/interpolatePaths.js +44 -11
  45. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  46. package/lib/module/mock/index.js +103 -147
  47. package/lib/module/mock/index.js.map +1 -1
  48. package/lib/module/renderer/components/Group.js +1 -1
  49. package/lib/module/renderer/components/Group.js.map +1 -1
  50. package/lib/module/renderer/processors/Transform.js +8 -15
  51. package/lib/module/renderer/processors/Transform.js.map +1 -1
  52. package/lib/module/skia/core/Data.js +7 -4
  53. package/lib/module/skia/core/Data.js.map +1 -1
  54. package/lib/module/skia/types/Font/Font.js.map +1 -1
  55. package/lib/module/skia/types/Matrix.js +12 -2
  56. package/lib/module/skia/types/Matrix.js.map +1 -1
  57. package/lib/module/skia/web/JsiSkFont.js +6 -0
  58. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  59. package/lib/module/skia/web/JsiSkMatrix.js +4 -0
  60. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  61. package/lib/module/values/api.js +0 -4
  62. package/lib/module/values/api.js.map +1 -1
  63. package/lib/module/values/hooks/useComputedValue.js +1 -1
  64. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  65. package/lib/module/views/SkiaView.web.js +27 -37
  66. package/lib/module/views/SkiaView.web.js.map +1 -1
  67. package/lib/module/web/LoadSkiaWeb.js +16 -0
  68. package/lib/module/web/LoadSkiaWeb.js.map +1 -0
  69. package/lib/module/web/WithSkiaWeb.js +23 -0
  70. package/lib/module/web/WithSkiaWeb.js.map +1 -0
  71. package/lib/module/web/index.js +2 -9
  72. package/lib/module/web/index.js.map +1 -1
  73. package/lib/typescript/jestSetup.d.ts +1 -0
  74. package/lib/typescript/src/animation/functions/interpolate.d.ts +6 -0
  75. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +3 -1
  76. package/lib/typescript/src/mock/index.d.ts +11 -42
  77. package/lib/typescript/src/renderer/Canvas.d.ts +1 -1
  78. package/lib/typescript/src/renderer/processors/Transform.d.ts +2 -2
  79. package/lib/typescript/src/skia/types/Font/Font.d.ts +6 -0
  80. package/lib/typescript/src/skia/types/Matrix.d.ts +6 -2
  81. package/lib/typescript/src/skia/types/Typeface/Typeface.d.ts +1 -4
  82. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -0
  83. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +1 -0
  84. package/lib/typescript/src/values/api.d.ts +0 -1
  85. package/lib/typescript/src/views/SkiaView.web.d.ts +4 -6
  86. package/lib/typescript/src/web/LoadSkiaWeb.d.ts +6 -0
  87. package/lib/typescript/src/web/WithSkiaWeb.d.ts +12 -0
  88. package/lib/typescript/src/web/index.d.ts +2 -5
  89. package/package.json +7 -3
  90. package/scripts/setup-canvaskit.js +74 -0
  91. package/src/animation/functions/interpolate.ts +4 -2
  92. package/src/animation/functions/interpolateColors.ts +1 -1
  93. package/src/animation/functions/interpolatePaths.ts +59 -10
  94. package/src/mock/index.ts +103 -149
  95. package/src/renderer/components/Group.tsx +1 -1
  96. package/src/renderer/processors/Transform.ts +7 -10
  97. package/src/skia/core/Data.ts +7 -8
  98. package/src/skia/types/Font/Font.ts +7 -0
  99. package/src/skia/types/Matrix.ts +19 -3
  100. package/src/skia/types/Typeface/Typeface.ts +1 -4
  101. package/src/skia/web/JsiSkFont.ts +6 -0
  102. package/src/skia/web/JsiSkMatrix.ts +4 -0
  103. package/src/values/api.ts +0 -2
  104. package/src/values/hooks/useComputedValue.ts +1 -1
  105. package/src/views/SkiaView.web.tsx +36 -43
  106. package/src/web/LoadSkiaWeb.tsx +24 -0
  107. package/src/web/WithSkiaWeb.tsx +37 -0
  108. package/src/web/index.ts +2 -15
@@ -1 +1 @@
1
- {"version":3,"sources":["interpolateColors.ts"],"names":["mix","Skia","interpolate","interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Color","mixColors","x","y","c1","c2"],"mappings":"AAAA,SAASA,GAAT,QAAoB,gBAApB;AAEA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,WAAT,QAA4B,eAA5B;;AAEA,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;AACH,QAAMC,CAAC,GAAGL,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;AAMA,QAAMC,CAAC,GAAGR,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;AAMA,QAAME,CAAC,GAAGT,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;AAMA,QAAMG,CAAC,GAAGV,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;AAMA,SAAO,IAAII,YAAJ,CAAiB,CAACN,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,CA9BD;;AAgCA,OAAO,MAAME,iBAAiB,GAAG,CAC/BV,KAD+B,EAE/BC,UAF+B,EAG/BU,YAH+B,KAI5B;AACH,QAAMT,WAAW,GAAGS,YAAY,CAACP,GAAb,CAAkBQ,EAAD,IAAQf,IAAI,CAACgB,KAAL,CAAWD,EAAX,CAAzB,CAApB;;AACA,SAAOb,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CAPM;AASP,OAAO,MAAMY,SAAS,GAAG,CAACd,KAAD,EAAgBe,CAAhB,EAA0BC,CAA1B,KAAuC;AAC9D,QAAMC,EAAE,GAAGpB,IAAI,CAACgB,KAAL,CAAWE,CAAX,CAAX;AACA,QAAMG,EAAE,GAAGrB,IAAI,CAACgB,KAAL,CAAWG,CAAX,CAAX;AACA,SAAO,IAAIP,YAAJ,CAAiB,CACtBb,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CADmB,EAEtBtB,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAFmB,EAGtBtB,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAHmB,EAItBtB,GAAG,CAACI,KAAD,EAAQiB,EAAE,CAAC,CAAD,CAAV,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAJmB,CAAjB,CAAP;AAMD,CATM","sourcesContent":["import { mix } from \"../../renderer\";\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"]}
1
+ {"version":3,"sources":["interpolateColors.ts"],"names":["mix","Skia","interpolate","interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Color","mixColors","x","y","c1","c2"],"mappings":"AAAA,SAASA,GAAT,QAAoB,gCAApB;AAEA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,WAAT,QAA4B,eAA5B;;AAEA,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;AACH,QAAMC,CAAC,GAAGL,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;AAMA,QAAMC,CAAC,GAAGR,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHmB,EAInB,OAJmB,CAArB;AAMA,QAAME,CAAC,GAAGT,WAAW,CACnBE,KADmB,EAEnBC,UAFmB,EAGnBC,WAAW,CAACE,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V,EAAeC,EAAE,CAAC,CAAD,CAAjB,CAJmB,CAAjB,CAAP;AAMD,CATM","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"]}
@@ -1,8 +1,16 @@
1
+ import { exhaustiveCheck } from "../../renderer/typeddash";
2
+ import { validateInterpolationOptions, Extrapolate } from "./interpolate";
3
+
4
+ const lerp = (value, from, to, p1, p2) => {
5
+ const t = (value - from) / (to - from);
6
+ return p2.interpolate(p1, t);
7
+ };
1
8
  /**
2
9
  * Maps an input value within a range to an output path within a path range.
3
10
  * @param value - The input value.
4
11
  * @param inputRange - The range of the input value.
5
12
  * @param outputRange - The range of the output path.
13
+ * @param options - Extrapolation options
6
14
  * @returns The output path.
7
15
  * @example <caption>Map a value between 0 and 1 to a path between two paths.</caption>
8
16
  * const path1 = new Path();
@@ -13,24 +21,49 @@
13
21
  * path2.lineTo(0, 100);
14
22
  * const path = interpolatePath(0.5, [0, 1], [path1, path2]);
15
23
  */
16
- export const interpolatePaths = (value, input, outputRange) => {
24
+
25
+
26
+ export const interpolatePaths = (value, input, outputRange, options) => {
27
+ const extrapolation = validateInterpolationOptions(options);
28
+
29
+ if (value < input[0]) {
30
+ switch (extrapolation.extrapolateLeft) {
31
+ case Extrapolate.CLAMP:
32
+ return outputRange[0];
33
+
34
+ case Extrapolate.EXTEND:
35
+ return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);
36
+
37
+ case Extrapolate.IDENTITY:
38
+ throw new Error("Identity is not a supported extrapolation type for interpolatePaths()");
39
+
40
+ default:
41
+ exhaustiveCheck(extrapolation.extrapolateLeft);
42
+ }
43
+ } else if (value > input[input.length - 1]) {
44
+ switch (extrapolation.extrapolateRight) {
45
+ case Extrapolate.CLAMP:
46
+ return outputRange[outputRange.length - 1];
47
+
48
+ case Extrapolate.EXTEND:
49
+ return lerp(value, input[input.length - 2], input[input.length - 1], outputRange[input.length - 2], outputRange[input.length - 1]);
50
+
51
+ case Extrapolate.IDENTITY:
52
+ throw new Error("Identity is not a supported extrapolation type for interpolatePaths()");
53
+
54
+ default:
55
+ exhaustiveCheck(extrapolation.extrapolateRight);
56
+ }
57
+ }
58
+
17
59
  let i = 0;
18
60
 
19
61
  for (; i <= input.length - 1; i++) {
20
62
  if (value >= input[i] && value <= input[i + 1]) {
21
63
  break;
22
64
  }
23
-
24
- if (i === input.length - 1) {
25
- if (value < input[0]) {
26
- return outputRange[0];
27
- } else {
28
- return outputRange[i];
29
- }
30
- }
31
65
  }
32
66
 
33
- const t = (value - input[i]) / (input[i + 1] - input[i]);
34
- return outputRange[i + 1].interpolate(outputRange[i], t);
67
+ return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1]);
35
68
  };
36
69
  //# sourceMappingURL=interpolatePaths.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["interpolatePaths.ts"],"names":["interpolatePaths","value","input","outputRange","i","length","t","interpolate"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAG,CAC9BC,KAD8B,EAE9BC,KAF8B,EAG9BC,WAH8B,KAI3B;AACH,MAAIC,CAAC,GAAG,CAAR;;AACA,SAAOA,CAAC,IAAIF,KAAK,CAACG,MAAN,GAAe,CAA3B,EAA8BD,CAAC,EAA/B,EAAmC;AACjC,QAAIH,KAAK,IAAIC,KAAK,CAACE,CAAD,CAAd,IAAqBH,KAAK,IAAIC,KAAK,CAACE,CAAC,GAAG,CAAL,CAAvC,EAAgD;AAC9C;AACD;;AACD,QAAIA,CAAC,KAAKF,KAAK,CAACG,MAAN,GAAe,CAAzB,EAA4B;AAC1B,UAAIJ,KAAK,GAAGC,KAAK,CAAC,CAAD,CAAjB,EAAsB;AACpB,eAAOC,WAAW,CAAC,CAAD,CAAlB;AACD,OAFD,MAEO;AACL,eAAOA,WAAW,CAACC,CAAD,CAAlB;AACD;AACF;AACF;;AACD,QAAME,CAAC,GAAG,CAACL,KAAK,GAAGC,KAAK,CAACE,CAAD,CAAd,KAAsBF,KAAK,CAACE,CAAC,GAAG,CAAL,CAAL,GAAeF,KAAK,CAACE,CAAD,CAA1C,CAAV;AACA,SAAOD,WAAW,CAACC,CAAC,GAAG,CAAL,CAAX,CAAmBG,WAAnB,CAA+BJ,WAAW,CAACC,CAAD,CAA1C,EAA+CE,CAA/C,CAAP;AACD,CApBM","sourcesContent":["import type { SkPath } from \"../../skia/types\";\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 * @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) => {\n let i = 0;\n for (; i <= input.length - 1; i++) {\n if (value >= input[i] && value <= input[i + 1]) {\n break;\n }\n if (i === input.length - 1) {\n if (value < input[0]) {\n return outputRange[0];\n } else {\n return outputRange[i];\n }\n }\n }\n const t = (value - input[i]) / (input[i + 1] - input[i]);\n return outputRange[i + 1].interpolate(outputRange[i], t)!;\n};\n"]}
1
+ {"version":3,"sources":["interpolatePaths.ts"],"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"],"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;AACH,QAAMC,CAAC,GAAG,CAACL,KAAK,GAAGC,IAAT,KAAkBC,EAAE,GAAGD,IAAvB,CAAV;AACA,SAAOG,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;;;AACA,OAAO,MAAME,gBAAgB,GAAG,CAC9BP,KAD8B,EAE9BQ,KAF8B,EAG9BC,WAH8B,EAI9BC,OAJ8B,KAK3B;AACH,QAAMC,aAAa,GAAGd,4BAA4B,CAACa,OAAD,CAAlD;;AACA,MAAIV,KAAK,GAAGQ,KAAK,CAAC,CAAD,CAAjB,EAAsB;AACpB,YAAQG,aAAa,CAACC,eAAtB;AACE,WAAKd,WAAW,CAACe,KAAjB;AACE,eAAOJ,WAAW,CAAC,CAAD,C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CAACW,CAAC,GAAG,CAAL,CAAvC,EAAgD;AAC9C;AACD;AACF;;AACD,SAAOpB,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,CArDM","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"]}
@@ -1,152 +1,108 @@
1
- /**
2
- * Mock implementation for test runners.
3
- *
4
- * Example:
5
- *
6
- * ```js
7
- * jest.mock('@shopify/react-native-skia', () => require('@shopify/react-native-skia/lib/commonjs/mock'));
8
- * ```
9
- */
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- const MockJSIInstance = {};
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import * as Values from "../values/web";
3
+ import * as ValuesHooks from "../values/hooks";
4
+ import * as BaseSkia from "../skia/types";
5
+ import { useSharedValueEffect } from "../external/reanimated/useSharedValueEffect";
6
+ import * as timingFunctions from "../animation/timing";
7
+ import * as springFunctions from "../animation/spring";
8
+ import * as decayFunctions from "../animation/decay";
9
+ import * as interpolateFn from "../animation/functions/interpolate";
10
+ import * as interpolatePathFn from "../animation/functions/interpolatePaths";
11
+ import * as interpolateVectorFn from "../animation/functions/interpolateVector";
12
+ import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
12
13
 
13
- const Noop = () => MockJSIInstance;
14
+ class Stub {
15
+ constructor() {
16
+ return new Proxy(() => {}, {
17
+ get: () => new Stub(),
18
+ apply: () => new Stub(),
19
+ set: () => true
20
+ });
21
+ }
14
22
 
15
- export const Skia = {
16
- Point: Noop,
17
- XYWHRect: Noop,
18
- RuntimeShaderBuilder: Noop,
19
- RRectXY: Noop,
20
- RSXform: Noop,
21
- Color: Noop,
22
- ContourMeasureIter: Noop,
23
- Paint: Noop,
24
- PictureRecorder: Noop,
25
- Picture: {
26
- MakePicture: Noop
27
- },
28
- Path: {
29
- Make: Noop,
30
- MakeFromSVGString: Noop,
31
- MakeFromOp: Noop,
32
- MakeFromCmds: Noop,
33
- MakeFromText: Noop
34
- },
35
- Matrix: Noop,
36
- ColorFilter: {
37
- MakeMatrix: Noop,
38
- MakeBlend: Noop,
39
- MakeCompose: Noop,
40
- MakeLerp: Noop,
41
- MakeLinearToSRGBGamma: Noop,
42
- MakeSRGBToLinearGamma: Noop,
43
- MakeLumaColorFilter: Noop
44
- },
45
- Font: Noop,
46
- Typeface: {
47
- MakeFreeTypeFaceFromData: Noop
48
- },
49
- MaskFilter: {
50
- MakeBlur: Noop
51
- },
52
- RuntimeEffect: {
53
- Make: Noop
54
- },
55
- ImageFilter: {
56
- MakeOffset: Noop,
57
- MakeDisplacementMap: Noop,
58
- MakeShader: Noop,
59
- MakeBlur: Noop,
60
- MakeColorFilter: Noop,
61
- MakeCompose: Noop,
62
- MakeDropShadow: Noop,
63
- MakeDropShadowOnly: Noop,
64
- MakeErode: Noop,
65
- MakeDilate: Noop,
66
- MakeBlend: Noop,
67
- MakeRuntimeShader: Noop
68
- },
69
- Shader: {
70
- MakeLinearGradient: Noop,
71
- MakeRadialGradient: Noop,
72
- MakeTwoPointConicalGradient: Noop,
73
- MakeSweepGradient: Noop,
74
- MakeTurbulence: Noop,
75
- MakeFractalNoise: Noop,
76
- MakeBlend: Noop,
77
- MakeColor: Noop
78
- },
79
- PathEffect: {
80
- MakeCorner: Noop,
81
- MakeDash: Noop,
82
- MakeDiscrete: Noop,
83
- MakeCompose: Noop,
84
- MakeSum: Noop,
85
- MakeLine2D: Noop,
86
- MakePath1D: Noop,
87
- MakePath2D: Noop
88
- },
89
- MakeVertices: Noop,
90
- Data: {
91
- fromURI: Noop,
92
- fromBytes: Noop,
93
- fromBase64: Noop
94
- },
95
- Image: {
96
- MakeImageFromEncoded: Noop,
97
- MakeImage: Noop
98
- },
99
- SVG: {
100
- MakeFromData: Noop,
101
- MakeFromString: Noop
102
- },
103
- FontMgr: {
104
- RefDefault: Noop
105
- },
106
- TextBlob: {
107
- MakeFromText: Noop,
108
- MakeFromGlyphs: Noop,
109
- MakeFromRSXform: Noop,
110
- MakeFromRSXformGlyphs: Noop
23
+ }
24
+
25
+ const Noop = () => {};
26
+
27
+ export const Skia = new Stub();
28
+ export const vec = (x, y) => {
29
+ var _ref;
30
+
31
+ return {
32
+ x: x !== null && x !== void 0 ? x : 0,
33
+ y: (_ref = y !== null && y !== void 0 ? y : x) !== null && _ref !== void 0 ? _ref : 0
34
+ };
35
+ };
36
+ export const Mock = {
37
+ // SkiaExports
38
+ // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc
39
+ Skia,
40
+ ...BaseSkia,
41
+ // 2. Hooks
42
+ useDataCollection: Noop,
43
+ useRawData: Noop,
44
+ useData: Noop,
45
+ useFont: Noop,
46
+ useTypeface: Noop,
47
+ useImage: Noop,
48
+ usePath: Noop,
49
+ useSVG: Noop,
50
+ useTextPath: Noop,
51
+ usePaint: Noop,
52
+ usePicture: Noop,
53
+ useSvgPath: Noop,
54
+ // 3. Point/Rect/Transform utilities
55
+ vec,
56
+ rect: (x, y, width, height) => ({
57
+ x,
58
+ y,
59
+ width,
60
+ height
61
+ }),
62
+ rrect: (r, rx, ry) => ({
63
+ rect: r,
64
+ rx,
65
+ ry
66
+ }),
67
+ point: vec,
68
+ add: (a, b) => vec(a.x + b.x, a.y + b.y),
69
+ sub: (a, b) => vec(a.x - b.x, a.y - b.y),
70
+ neg: a => vec(-a.x, -a.y),
71
+ dist: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
72
+ translate: _ref2 => {
73
+ let {
74
+ x,
75
+ y
76
+ } = _ref2;
77
+ return [{
78
+ translateX: x
79
+ }, {
80
+ translateY: y
81
+ }];
111
82
  },
112
- Surface: {
113
- Make: Noop
114
- }
83
+ bounds: Noop,
84
+ topLeft: Noop,
85
+ topRight: Noop,
86
+ bottomLeft: Noop,
87
+ bottomRight: Noop,
88
+ center: Noop,
89
+ processTransform2d: Noop,
90
+ // ExternalExports
91
+ useSharedValueEffect,
92
+ // ValueExports
93
+ ...Values,
94
+ ...ValuesHooks,
95
+ // Animations
96
+ ...timingFunctions,
97
+ ...springFunctions,
98
+ ...decayFunctions,
99
+ ...interpolateFn,
100
+ ...interpolatePathFn,
101
+ ...interpolateVectorFn,
102
+ interpolateColors: (_value, _inputRange, _outputRange) => Float32Array.of(0, 0, 0, 0),
103
+ mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
104
+ ShaderLib,
105
+ createDrawing: Noop,
106
+ createDeclaration: Noop
115
107
  };
116
- export const vec = (x, y) => ({
117
- x,
118
- y
119
- });
120
- export const rect = (x, y, width, height) => ({
121
- x,
122
- y,
123
- width,
124
- height
125
- });
126
- export const rrect = (r, rx, ry) => ({
127
- rect: r,
128
- rx,
129
- ry
130
- });
131
- export const useTouchHandler = Noop;
132
- export const useComputedValue = Noop;
133
- export const useValue = Noop;
134
- export const useClockValue = Noop;
135
- export const useValueEffect = Noop;
136
- export const useTiming = Noop;
137
- export const runTiming = Noop;
138
- export const timing = Noop;
139
- export const useSpring = Noop;
140
- export const runSpring = Noop;
141
- export const spring = Noop;
142
- export const runDecay = Noop;
143
- export const decay = Noop;
144
- export const useSharedValueEffect = Noop;
145
- export const useData = Noop;
146
- export const useDataCollection = Noop;
147
- export const useFont = Noop;
148
- export const useImage = Noop;
149
- export const usePicture = Noop;
150
- export const useSVG = Noop;
151
- export const useTypeface = Noop;
152
108
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["MockJSIInstance","Noop","Skia","Point","XYWHRect","RuntimeShaderBuilder","RRectXY","RSXform","Color","ContourMeasureIter","Paint","PictureRecorder","Picture","MakePicture","Path","Make","MakeFromSVGString","MakeFromOp","MakeFromCmds","MakeFromText","Matrix","ColorFilter","MakeMatrix","MakeBlend","MakeCompose","MakeLerp","MakeLinearToSRGBGamma","MakeSRGBToLinearGamma","MakeLumaColorFilter","Font","Typeface","MakeFreeTypeFaceFromData","MaskFilter","MakeBlur","RuntimeEffect","ImageFilter","MakeOffset","MakeDisplacementMap","MakeShader","MakeColorFilter","MakeDropShadow","MakeDropShadowOnly","MakeErode","MakeDilate","MakeRuntimeShader","Shader","MakeLinearGradient","MakeRadialGradient","MakeTwoPointConicalGradient","MakeSweepGradient","MakeTurbulence","MakeFractalNoise","MakeColor","PathEffect","MakeCorner","MakeDash","MakeDiscrete","MakeSum","MakeLine2D","MakePath1D","MakePath2D","MakeVertices","Data","fromURI","fromBytes","fromBase64","Image","MakeImageFromEncoded","MakeImage","SVG","MakeFromData","MakeFromString","FontMgr","RefDefault","TextBlob","MakeFromGlyphs","MakeFromRSXform","MakeFromRSXformGlyphs","Surface","vec","x","y","rect","width","height","rrect","r","rx","ry","useTouchHandler","useComputedValue","useValue","useClockValue","useValueEffect","useTiming","runTiming","timing","useSpring","runSpring","spring","runDecay","decay","useSharedValueEffect","useData","useDataCollection","useFont","useImage","usePicture","useSVG","useTypeface"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA,MAAMA,eAAoB,GAAG,EAA7B;;AACA,MAAMC,IAAI,GAAG,MAAMD,eAAnB;;AAEA,OAAO,MAAME,IAAa,GAAG;AAC3BC,EAAAA,KAAK,EAAEF,IADoB;AAE3BG,EAAAA,QAAQ,EAAEH,IAFiB;AAG3BI,EAAAA,oBAAoB,EAAEJ,IAHK;AAI3BK,EAAAA,OAAO,EAAEL,IAJkB;AAK3BM,EAAAA,OAAO,EAAEN,IALkB;AAM3BO,EAAAA,KAAK,EAAEP,IANoB;AAO3BQ,EAAAA,kBAAkB,EAAER,IAPO;AAQ3BS,EAAAA,KAAK,EAAET,IARoB;AAS3BU,EAAAA,eAAe,EAAEV,IATU;AAU3BW,EAAAA,OAAO,EAAE;AACPC,IAAAA,WAAW,EAAEZ;AAD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AMqG,oBAAoB,GAAGrG,IAA7B;AAEP,OAAO,MAAMsG,OAAO,GAAGtG,IAAhB;AACP,OAAO,MAAMuG,iBAAiB,GAAGvG,IAA1B;AACP,OAAO,MAAMwG,OAAO,GAAGxG,IAAhB;AACP,OAAO,MAAMyG,QAAQ,GAAGzG,IAAjB;AACP,OAAO,MAAM0G,UAAU,GAAG1G,IAAnB;AACP,OAAO,MAAM2G,MAAM,GAAG3G,IAAf;AACP,OAAO,MAAM4G,WAAW,GAAG5G,IAApB","sourcesContent":["/**\n * Mock implementation for test runners.\n *\n * Example:\n *\n * ```js\n * jest.mock('@shopify/react-native-skia', () => require('@shopify/react-native-skia/lib/commonjs/mock'));\n * ```\n */\n\nimport type { Skia as SkiaApi, SkRect } from \"../skia/types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst MockJSIInstance: any = {};\nconst Noop = () => MockJSIInstance;\n\nexport const Skia: SkiaApi = {\n Point: Noop,\n XYWHRect: Noop,\n RuntimeShaderBuilder: Noop,\n RRectXY: Noop,\n RSXform: Noop,\n Color: Noop,\n ContourMeasureIter: Noop,\n Paint: Noop,\n PictureRecorder: Noop,\n Picture: {\n MakePicture: Noop,\n },\n Path: {\n Make: Noop,\n MakeFromSVGString: Noop,\n MakeFromOp: Noop,\n MakeFromCmds: Noop,\n MakeFromText: Noop,\n },\n Matrix: Noop,\n ColorFilter: {\n MakeMatrix: Noop,\n MakeBlend: Noop,\n MakeCompose: Noop,\n MakeLerp: Noop,\n MakeLinearToSRGBGamma: Noop,\n MakeSRGBToLinearGamma: Noop,\n MakeLumaColorFilter: Noop,\n },\n Font: Noop,\n Typeface: {\n MakeFreeTypeFaceFromData: Noop,\n },\n MaskFilter: {\n MakeBlur: Noop,\n },\n RuntimeEffect: {\n Make: Noop,\n },\n ImageFilter: {\n MakeOffset: Noop,\n MakeDisplacementMap: Noop,\n MakeShader: Noop,\n MakeBlur: Noop,\n MakeColorFilter: Noop,\n MakeCompose: Noop,\n MakeDropShadow: Noop,\n MakeDropShadowOnly: Noop,\n MakeErode: Noop,\n MakeDilate: Noop,\n MakeBlend: Noop,\n MakeRuntimeShader: Noop,\n },\n Shader: {\n MakeLinearGradient: Noop,\n MakeRadialGradient: Noop,\n MakeTwoPointConicalGradient: Noop,\n MakeSweepGradient: Noop,\n MakeTurbulence: Noop,\n MakeFractalNoise: Noop,\n MakeBlend: Noop,\n MakeColor: Noop,\n },\n PathEffect: {\n MakeCorner: Noop,\n MakeDash: Noop,\n MakeDiscrete: Noop,\n MakeCompose: Noop,\n MakeSum: Noop,\n MakeLine2D: Noop,\n MakePath1D: Noop,\n MakePath2D: Noop,\n },\n MakeVertices: Noop,\n Data: {\n fromURI: Noop,\n fromBytes: Noop,\n fromBase64: Noop,\n },\n Image: {\n MakeImageFromEncoded: Noop,\n MakeImage: Noop,\n },\n SVG: {\n MakeFromData: Noop,\n MakeFromString: Noop,\n },\n FontMgr: {\n RefDefault: Noop,\n },\n TextBlob: {\n MakeFromText: Noop,\n MakeFromGlyphs: Noop,\n MakeFromRSXform: Noop,\n MakeFromRSXformGlyphs: Noop,\n },\n Surface: {\n Make: Noop,\n },\n};\n\nexport const vec = (x: number, y: number) => ({ x, y });\n\nexport const rect = (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n});\n\nexport const rrect = (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n});\n\nexport const useTouchHandler = Noop;\nexport const useComputedValue = Noop;\nexport const useValue = Noop;\nexport const useClockValue = Noop;\nexport const useValueEffect = Noop;\nexport const useTiming = Noop;\nexport const runTiming = Noop;\nexport const timing = Noop;\nexport const useSpring = Noop;\nexport const runSpring = Noop;\nexport const spring = Noop;\nexport const runDecay = Noop;\nexport const decay = Noop;\n\nexport const useSharedValueEffect = Noop;\n\nexport const useData = Noop;\nexport const useDataCollection = Noop;\nexport const useFont = Noop;\nexport const useImage = Noop;\nexport const usePicture = Noop;\nexport const useSVG = Noop;\nexport const useTypeface = Noop;\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["Values","ValuesHooks","BaseSkia","useSharedValueEffect","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","useDataCollection","useRawData","useData","useFont","useTypeface","useImage","usePath","useSVG","useTextPath","usePaint","usePicture","useSvgPath","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","createDrawing","createDeclaration"],"mappings":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAKA,SAASC,oBAAT,QAAqC,6CAArC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AACA,OAAO,KAAKC,mBAAZ,MAAqC,0CAArC;AACA,SAASC,SAAT,QAA0B,0CAA1B;;AAEA,MAAMC,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;AACzBC,MAAAA,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;AAEzBI,MAAAA,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;AAGzBK,MAAAA,GAAG,EAAE,MAAM;AAHc,KAApB,CAAP;AAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEA,OAAO,MAAMC,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;AAgDJ;AACA,KAAGH,MAjDC;AAkDJ,KAAGC,WAlDC;AAmDJ;AACA,KAAGG,eApDC;AAqDJ,KAAGC,eArDC;AAsDJ,KAAGC,cAtDC;AAuDJ,KAAGC,aAvDC;AAwDJ,KAAGC,iBAxDC;AAyDJ,KAAGC,mBAzDC;AA0DJoD,EAAAA,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA9DD;AA+DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA/D7C;AAgEJxD,EAAAA,SAhEI;AAiEJ6D,EAAAA,aAAa,EAAEtD,IAjEX;AAkEJuD,EAAAA,iBAAiB,EAAEvD;AAlEf,CAPC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ExternalExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useDataCollection: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n usePath: Noop,\n useSVG: Noop,\n useTextPath: Noop,\n usePaint: Noop,\n usePicture: Noop,\n useSvgPath: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"]}
@@ -42,7 +42,7 @@ const onDraw = createDrawing((ctx, _ref, node) => {
42
42
  canvas.save();
43
43
  }
44
44
 
45
- processCanvasTransform(ctx, groupProps);
45
+ processCanvasTransform(canvas, groupProps);
46
46
 
47
47
  if (clip) {
48
48
  const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;
@@ -1 +1 @@
1
- {"version":3,"sources":["Group.tsx"],"names":["React","ClipOp","processCanvasTransform","processPaint","processClip","createDrawing","DrawingNode","isDeclarationNode","isSkPaint","obj","__typename__","onDraw","ctx","node","layer","clip","invertClip","groupProps","canvas","opacity","Skia","declarations","children","filter","map","child","draw","drawings","paint","copy","hasTransform","transform","matrix","hasClip","shouldSave","saveLayer","current","undefined","save","op","Difference","Intersect","visit","restore","Group","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAIA,SAASC,MAAT,QAAuB,kBAAvB;AACA,SACEC,sBADF,EAEEC,YAFF,EAGEC,WAHF,QAIO,eAJP;AAWA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,UAA3C;AACA,SAASC,iBAAT,QAAkC,sBAAlC;;AAEA,MAAMC,SAAS,GAAIC,GAAD,IAChB,kBAAkBA,GAAlB,IAAyBA,GAAG,CAACC,YAAJ,KAAqB,OADhD;;AASA,MAAMC,MAAM,GAAGN,aAAa,CAC1B,CAACO,GAAD,QAAkDC,IAAlD,KAA2D;AAAA,MAArD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,UAAf;AAA2B,OAAGC;AAA9B,GAAqD;AACzD,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAV;AAAmBC,IAAAA;AAAnB,MAA4BR,GAAlC;AACA,QAAMS,YAAY,GAAGR,IAAI,CAACS,QAAL,CAClBC,MADkB,CACXhB,iBADW,EAElBiB,GAFkB,CAEbC,KAAD,IAAW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,CACE,EACE,GAAG9B,GADL;AAEEgB,IAAAA,KAFF;AAGET,IAAAA,OAAO,EAAEF,UAAU,CAACE,OAAX,GAAqBF,UAAU,CAACE,OAAX,GAAqBA,OAA1C,GAAoDA;AAH/D,GADF,EAMEQ,QANF;;AAQA,MAAIO,UAAJ,EAAgB;AACdhB,IAAAA,MAAM,CAACyB,OAAP;AACD;AACF,CAjDyB,CAA5B;AAoDA,OAAO,MAAMC,KAAK,GAAIC,KAAD,IAAsC;AACzD,sBAAO;AAAW,IAAA,MAAM,EAAElC;AAAnB,KAA+BkC,KAA/B;AAAsC,IAAA,cAAc;AAApD,KAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { RefObject } from \"react\";\n\nimport type { SkPaint } from \"../../skia/types\";\nimport { ClipOp } from \"../../skia/types\";\nimport {\n processCanvasTransform,\n processPaint,\n processClip,\n} from \"../processors\";\nimport type {\n CustomPaintProps,\n TransformProps,\n AnimatedProps,\n ClipDef,\n} from \"../processors\";\nimport { createDrawing, DrawingNode } from \"../nodes\";\nimport { isDeclarationNode } from \"../nodes/Declaration\";\n\nconst isSkPaint = (obj: RefObject<SkPaint> | SkPaint): obj is SkPaint =>\n \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nexport interface GroupProps extends CustomPaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: RefObject<SkPaint> | SkPaint | boolean;\n}\n\nconst onDraw = createDrawing<GroupProps>(\n (ctx, { layer, clip, invertClip, ...groupProps }, node) => {\n const { canvas, opacity, Skia } = ctx;\n const declarations = node.children\n .filter(isDeclarationNode)\n .map((child) => child.draw(ctx));\n\n const drawings = node.children.filter(\n (child) => child instanceof DrawingNode\n );\n const paint = processPaint(\n ctx.Skia,\n ctx.paint.copy(),\n opacity,\n groupProps,\n declarations\n );\n const hasTransform = !!groupProps.transform || !!groupProps.matrix;\n const hasClip = !!clip;\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else if (isSkPaint(layer)) {\n canvas.saveLayer(layer);\n } else {\n canvas.saveLayer(layer.current ?? undefined);\n }\n } else {\n canvas.save();\n }\n processCanvasTransform(ctx, groupProps);\n if (clip) {\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n processClip(Skia, canvas, clip, op);\n }\n }\n node.visit(\n {\n ...ctx,\n paint,\n opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,\n },\n drawings\n );\n if (shouldSave) {\n canvas.restore();\n }\n }\n);\n\nexport const Group = (props: AnimatedProps<GroupProps>) => {\n return <skDrawing onDraw={onDraw} {...props} skipProcessing />;\n};\n"]}
1
+ {"version":3,"sources":["Group.tsx"],"names":["React","ClipOp","processCanvasTransform","processPaint","processClip","createDrawing","DrawingNode","isDeclarationNode","isSkPaint","obj","__typename__","onDraw","ctx","node","layer","clip","invertClip","groupProps","canvas","opacity","Skia","declarations","children","filter","map","child","draw","drawings","paint","copy","hasTransform","transform","matrix","hasClip","shouldSave","saveLayer","current","undefined","save","op","Difference","Intersect","visit","restore","Group","props"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAIA,SAASC,MAAT,QAAuB,kBAAvB;AACA,SACEC,sBADF,EAEEC,YAFF,EAGEC,WAHF,QAIO,eAJP;AAWA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,UAA3C;AACA,SAASC,iBAAT,QAAkC,sBAAlC;;AAEA,MAAMC,SAAS,GAAIC,GAAD,IAChB,kBAAkBA,GAAlB,IAAyBA,GAAG,CAACC,YAAJ,KAAqB,OADhD;;AASA,MAAMC,MAAM,GAAGN,aAAa,CAC1B,CAACO,GAAD,QAAkDC,IAAlD,KAA2D;AAAA,MAArD;AAAEC,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,UAAf;AAA2B,OAAGC;AAA9B,GAAqD;AACzD,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,OAAV;A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,CAACwC,SAAnD;AACArC,MAAAA,WAAW,CAACgB,IAAD,EAAOF,MAAP,EAAeH,IAAf,EAAqBwB,EAArB,CAAX;AACD;AACF;;AACD1B,EAAAA,IAAI,CAAC6B,KAAL,CACE,EACE,GAAG9B,GADL;AAEEgB,IAAAA,KAFF;AAGET,IAAAA,OAAO,EAAEF,UAAU,CAACE,OAAX,GAAqBF,UAAU,CAACE,OAAX,GAAqBA,OAA1C,GAAoDA;AAH/D,GADF,EAMEQ,QANF;;AAQA,MAAIO,UAAJ,EAAgB;AACdhB,IAAAA,MAAM,CAACyB,OAAP;AACD;AACF,CAjDyB,CAA5B;AAoDA,OAAO,MAAMC,KAAK,GAAIC,KAAD,IAAsC;AACzD,sBAAO;AAAW,IAAA,MAAM,EAAElC;AAAnB,KAA+BkC,KAA/B;AAAsC,IAAA,cAAc;AAApD,KAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { RefObject } from \"react\";\n\nimport type { SkPaint } from \"../../skia/types\";\nimport { ClipOp } from \"../../skia/types\";\nimport {\n processCanvasTransform,\n processPaint,\n processClip,\n} from \"../processors\";\nimport type {\n CustomPaintProps,\n TransformProps,\n AnimatedProps,\n ClipDef,\n} from \"../processors\";\nimport { createDrawing, DrawingNode } from \"../nodes\";\nimport { isDeclarationNode } from \"../nodes/Declaration\";\n\nconst isSkPaint = (obj: RefObject<SkPaint> | SkPaint): obj is SkPaint =>\n \"__typename__\" in obj && obj.__typename__ === \"Paint\";\n\nexport interface GroupProps extends CustomPaintProps, TransformProps {\n clip?: ClipDef;\n invertClip?: boolean;\n layer?: RefObject<SkPaint> | SkPaint | boolean;\n}\n\nconst onDraw = createDrawing<GroupProps>(\n (ctx, { layer, clip, invertClip, ...groupProps }, node) => {\n const { canvas, opacity, Skia } = ctx;\n const declarations = node.children\n .filter(isDeclarationNode)\n .map((child) => child.draw(ctx));\n\n const drawings = node.children.filter(\n (child) => child instanceof DrawingNode\n );\n const paint = processPaint(\n ctx.Skia,\n ctx.paint.copy(),\n opacity,\n groupProps,\n declarations\n );\n const hasTransform = !!groupProps.transform || !!groupProps.matrix;\n const hasClip = !!clip;\n const shouldSave = hasTransform || hasClip || !!layer;\n if (shouldSave) {\n if (layer) {\n if (typeof layer === \"boolean\") {\n canvas.saveLayer();\n } else if (isSkPaint(layer)) {\n canvas.saveLayer(layer);\n } else {\n canvas.saveLayer(layer.current ?? undefined);\n }\n } else {\n canvas.save();\n }\n processCanvasTransform(canvas, groupProps);\n if (clip) {\n const op = invertClip ? ClipOp.Difference : ClipOp.Intersect;\n processClip(Skia, canvas, clip, op);\n }\n }\n node.visit(\n {\n ...ctx,\n paint,\n opacity: groupProps.opacity ? groupProps.opacity * opacity : opacity,\n },\n drawings\n );\n if (shouldSave) {\n canvas.restore();\n }\n }\n);\n\nexport const Group = (props: AnimatedProps<GroupProps>) => {\n return <skDrawing onDraw={onDraw} {...props} skipProcessing />;\n};\n"]}
@@ -1,35 +1,28 @@
1
1
  import { processTransform } from "../../skia/types";
2
- export const processCanvasTransform = (_ref, _ref2) => {
3
- let {
4
- canvas,
5
- Skia
6
- } = _ref;
2
+ export const processCanvasTransform = (canvas, _ref) => {
7
3
  let {
8
4
  transform,
9
5
  origin,
10
6
  matrix
11
- } = _ref2;
7
+ } = _ref;
12
8
 
13
9
  if (matrix) {
14
10
  if (origin) {
15
- const m3 = Skia.Matrix();
16
- m3.translate(origin.x, origin.y);
17
- m3.concat(matrix);
18
- m3.translate(-origin.x, -origin.y);
19
- canvas.concat(m3);
11
+ canvas.translate(origin.x, origin.y);
12
+ canvas.concat(matrix);
13
+ canvas.translate(-origin.x, -origin.y);
20
14
  } else {
21
15
  canvas.concat(matrix);
22
16
  }
23
17
  } else if (transform) {
24
- const m3 = processTransform(Skia.Matrix(), origin ? transformOrigin(origin, transform) : transform);
25
- canvas.concat(m3);
18
+ processTransform(canvas, origin ? transformOrigin(origin, transform) : transform);
26
19
  }
27
20
  };
28
- export const localMatrix = (m, _ref3) => {
21
+ export const localMatrix = (m, _ref2) => {
29
22
  let {
30
23
  transform,
31
24
  origin
32
- } = _ref3;
25
+ } = _ref2;
33
26
 
34
27
  if (transform) {
35
28
  return processTransform(m, origin ? transformOrigin(origin, transform) : transform);
@@ -1 +1 @@
1
- {"version":3,"sources":["Transform.ts"],"names":["processTransform","processCanvasTransform","canvas","Skia","transform","origin","matrix","m3","Matrix","translate","x","y","concat","transformOrigin","localMatrix","m","undefined","translateX","translateY"],"mappings":"AAEA,SAASA,gBAAT,QAAiC,kBAAjC;AAQA,OAAO,MAAMC,sBAAsB,GAAG,iBAGjC;AAAA,MAFH;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAEG;AAAA,MADH;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,MAAb;AAAqBC,IAAAA;AAArB,GACG;;AACH,MAAIA,MAAJ,EAAY;AACV,QAAID,MAAJ,EAAY;AACV,YAAME,EAAE,GAAGJ,IAAI,CAACK,MAAL,EAAX;AACAD,MAAAA,EAAE,CAACE,SAAH,CAAaJ,MAAM,CAACK,CAApB,EAAuBL,MAAM,CAACM,CAA9B;AACAJ,MAAAA,EAAE,CAACK,MAAH,CAAUN,MAAV;AACAC,MAAAA,EAAE,CAACE,SAAH,CAAa,CAACJ,MAAM,CAACK,CAArB,EAAwB,CAACL,MAAM,CAACM,CAAhC;AACAT,MAAAA,MAAM,CAACU,MAAP,CAAcL,EAAd;AACD,KAND,MAMO;AACLL,MAAAA,MAAM,CAACU,MAAP,CAAcN,MAAd;AACD;AACF,GAVD,MAUO,IAAIF,SAAJ,EAAe;AACpB,UAAMG,EAAE,GAAGP,gBAAgB,CACzBG,IAAI,CAACK,MAAL,EADyB,EAEzBH,MAAM,GAAGQ,eAAe,CAACR,MAAD,EAASD,SAAT,CAAlB,GAAwCA,SAFrB,CAA3B;AAIAF,IAAAA,MAAM,CAACU,MAAP,CAAcL,EAAd;AACD;AACF,CArBM;AAuBP,OAAO,MAAMO,WAAW,GAAG,CACzBC,CADyB,YAGtB;AAAA,MADH;AAAEX,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GACG;;AACH,MAAID,SAAJ,EAAe;AACb,WAAOJ,gBAAgB,CACrBe,CADqB,EAErBV,MAAM,GAAGQ,eAAe,CAACR,MAAD,EAASD,SAAT,CAAlB,GAAwCA,SAFzB,CAAvB;AAID;;AACD,SAAOY,SAAP;AACD,CAXM;AAaP,OAAO,MAAMH,eAAe,GAAG,CAACR,MAAD,EAAiBD,SAAjB,KAA6C,CAC1E;AAAEa,EAAAA,UAAU,EAAEZ,MAAM,CAACK;AAArB,CAD0E,EAE1E;AAAEQ,EAAAA,UAAU,EAAEb,MAAM,CAACM;AAArB,CAF0E,EAG1E,GAAGP,SAHuE,EAI1E;AAAEa,EAAAA,UAAU,EAAE,CAACZ,MAAM,CAACK;AAAtB,CAJ0E,EAK1E;AAAEQ,EAAAA,UAAU,EAAE,CAACb,MAAM,CAACM;AAAtB,CAL0E,CAArE","sourcesContent":["import type { DrawingContext } from \"../DrawingContext\";\nimport type { SkMatrix, Vector, Transforms2d } from \"../../skia/types\";\nimport { processTransform } from \"../../skia/types\";\n\nexport interface TransformProps {\n transform?: Transforms2d;\n origin?: Vector;\n matrix?: SkMatrix;\n}\n\nexport const processCanvasTransform = (\n { canvas, Skia }: DrawingContext,\n { transform, origin, matrix }: TransformProps\n) => {\n if (matrix) {\n if (origin) {\n const m3 = Skia.Matrix();\n m3.translate(origin.x, origin.y);\n m3.concat(matrix);\n m3.translate(-origin.x, -origin.y);\n canvas.concat(m3);\n } else {\n canvas.concat(matrix);\n }\n } else if (transform) {\n const m3 = processTransform(\n Skia.Matrix(),\n origin ? transformOrigin(origin, transform) : transform\n );\n canvas.concat(m3);\n }\n};\n\nexport const localMatrix = (\n m: SkMatrix,\n { transform, origin }: TransformProps\n) => {\n if (transform) {\n return processTransform(\n m,\n origin ? transformOrigin(origin, transform) : transform\n );\n }\n return undefined;\n};\n\nexport const transformOrigin = (origin: Vector, transform: Transforms2d) => [\n { translateX: origin.x },\n { translateY: origin.y },\n ...transform,\n { translateX: -origin.x },\n { translateY: -origin.y },\n];\n"]}
1
+ {"version":3,"sources":["Transform.ts"],"names":["processTransform","processCanvasTransform","canvas","transform","origin","matrix","translate","x","y","concat","transformOrigin","localMatrix","m","undefined","translateX","translateY"],"mappings":"AACA,SAASA,gBAAT,QAAiC,kBAAjC;AASA,OAAO,MAAMC,sBAAsB,GAAG,CACpCC,MADoC,WAGjC;AAAA,MADH;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,MAAb;AAAqBC,IAAAA;AAArB,GACG;;AACH,MAAIA,MAAJ,EAAY;AACV,QAAID,MAAJ,EAAY;AACVF,MAAAA,MAAM,CAACI,SAAP,CAAiBF,MAAM,CAACG,CAAxB,EAA2BH,MAAM,CAACI,CAAlC;AACAN,MAAAA,MAAM,CAACO,MAAP,CAAcJ,MAAd;AACAH,MAAAA,MAAM,CAACI,SAAP,CAAiB,CAACF,MAAM,CAACG,CAAzB,EAA4B,CAACH,MAAM,CAACI,CAApC;AACD,KAJD,MAIO;AACLN,MAAAA,MAAM,CAACO,MAAP,CAAcJ,MAAd;AACD;AACF,GARD,MAQO,IAAIF,SAAJ,EAAe;AACpBH,IAAAA,gBAAgB,CACdE,MADc,EAEdE,MAAM,GAAGM,eAAe,CAACN,MAAD,EAASD,SAAT,CAAlB,GAAwCA,SAFhC,CAAhB;AAID;AACF,CAlBM;AAoBP,OAAO,MAAMQ,WAAW,GAAG,CACzBC,CADyB,YAGtB;AAAA,MADH;AAAET,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GACG;;AACH,MAAID,SAAJ,EAAe;AACb,WAAOH,gBAAgB,CACrBY,CADqB,EAErBR,MAAM,GAAGM,eAAe,CAACN,MAAD,EAASD,SAAT,CAAlB,GAAwCA,SAFzB,CAAvB;AAID;;AACD,SAAOU,SAAP;AACD,CAXM;AAaP,OAAO,MAAMH,eAAe,GAAG,CAACN,MAAD,EAAiBD,SAAjB,KAA6C,CAC1E;AAAEW,EAAAA,UAAU,EAAEV,MAAM,CAACG;AAArB,CAD0E,EAE1E;AAAEQ,EAAAA,UAAU,EAAEX,MAAM,CAACI;AAArB,CAF0E,EAG1E,GAAGL,SAHuE,EAI1E;AAAEW,EAAAA,UAAU,EAAE,CAACV,MAAM,CAACG;AAAtB,CAJ0E,EAK1E;AAAEQ,EAAAA,UAAU,EAAE,CAACX,MAAM,CAACI;AAAtB,CAL0E,CAArE","sourcesContent":["import type { SkMatrix, Vector, Transforms2d } from \"../../skia/types\";\nimport { processTransform } from \"../../skia/types\";\nimport type { SkCanvas } from \"../../skia/types/Canvas\";\n\nexport interface TransformProps {\n transform?: Transforms2d;\n origin?: Vector;\n matrix?: SkMatrix;\n}\n\nexport const processCanvasTransform = (\n canvas: SkCanvas,\n { transform, origin, matrix }: TransformProps\n) => {\n if (matrix) {\n if (origin) {\n canvas.translate(origin.x, origin.y);\n canvas.concat(matrix);\n canvas.translate(-origin.x, -origin.y);\n } else {\n canvas.concat(matrix);\n }\n } else if (transform) {\n processTransform(\n canvas,\n origin ? transformOrigin(origin, transform) : transform\n );\n }\n};\n\nexport const localMatrix = (\n m: SkMatrix,\n { transform, origin }: TransformProps\n) => {\n if (transform) {\n return processTransform(\n m,\n origin ? transformOrigin(origin, transform) : transform\n );\n }\n return undefined;\n};\n\nexport const transformOrigin = (origin: Vector, transform: Transforms2d) => [\n { translateX: origin.x },\n { translateY: origin.y },\n ...transform,\n { translateX: -origin.x },\n { translateY: -origin.y },\n];\n"]}
@@ -19,12 +19,15 @@ const factoryWrapper = (data2, factory, onError) => {
19
19
 
20
20
  const loadDataCollection = (sources, factory, onError) => Promise.all(sources.map(source => loadData(source, factory, onError)));
21
21
 
22
- const loadData = (source, factory, onError) => {
23
- if (source instanceof Uint8Array) {
24
- return new Promise(resolve => resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError)));
22
+ const loadData = async (source, factory, onError) => {
23
+ if (source === null) {
24
+ return null;
25
+ } else if (source instanceof Uint8Array) {
26
+ return factoryWrapper(Skia.Data.fromBytes(source), factory, onError);
25
27
  } else {
26
28
  const uri = typeof source === "string" ? source : resolveAsset(source);
27
- return Skia.Data.fromURI(uri).then(d => factoryWrapper(d, factory, onError));
29
+ const d = await Skia.Data.fromURI(uri);
30
+ return factoryWrapper(d, factory, onError);
28
31
  }
29
32
  };
30
33
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Data.ts"],"names":["useRef","useEffect","useState","Image","Platform","Skia","resolveAsset","source","OS","default","resolveAssetSource","uri","factoryWrapper","data2","factory","onError","factoryResult","Error","loadDataCollection","sources","Promise","all","map","loadData","Uint8Array","resolve","Data","fromBytes","fromURI","then","d","useLoading","loader","deps","data","setData","prevSourceRef","current","useDataCollection","useRawData","identity","useData"],"mappings":"AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,QAA4C,OAA5C;AACA,SAASC,KAAT,EAAgBC,QAAhB,QAAgC,cAAhC;AAEA,SAASC,IAAT,QAAqB,SAArB;;AAGA,MAAMC,YAAY,GAAIC,MAAD,IAAwC;AAC3D,SAAOH,QAAQ,CAACI,EAAT,KAAgB,KAAhB,GACHD,MAAM,CAACE,OADJ,GAEHN,KAAK,CAACO,kBAAN,CAAyBH,MAAzB,EAAiCI,GAFrC;AAGD,CAJD;;AAMA,MAAMC,cAAc,GAAG,CACrBC,KADqB,EAErBC,OAFqB,EAGrBC,OAHqB,KAIlB;AACH,QAAMC,aAAa,GAAGF,OAAO,CAACD,KAAD,CAA7B;;AACA,MAAIG,aAAa,KAAK,IAAtB,EAA4B;AAC1BD,IAAAA,OAAO,IAAIA,OAAO,CAAC,IAAIE,KAAJ,CAAU,qBAAV,CAAD,CAAlB;AACA,WAAO,IAAP;AACD,GAHD,MAGO;AACL,WAAOD,aAAP;AACD;AACF,CAZD;;AAcA,MAAME,kBAAkB,GAAG,CACzBC,OADyB,EAEzBL,OAFyB,EAGzBC,OAHyB,KAKzBK,OAAO,CAACC,GAAR,CAAYF,OAAO,CA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iB,GAAG,CAC/BnB,OAD+B,EAE/BL,OAF+B,EAG/BC,OAH+B,EAI/BkB,IAJ+B,KAM/BF,UAAU,CACRZ,OADQ,EAER,MAAMD,kBAAkB,CAACC,OAAD,EAAUL,OAAV,EAAmBC,OAAnB,CAFhB,EAGRkB,IAHQ,CANL;AAYP,OAAO,MAAMM,UAAU,GAAG,CACxBhC,MADwB,EAExBO,OAFwB,EAGxBC,OAHwB,EAIxBkB,IAJwB,KAKrBF,UAAU,CAACxB,MAAD,EAAS,MAAMgB,QAAQ,CAAChB,MAAD,EAASO,OAAT,EAAkBC,OAAlB,CAAvB,EAAmDkB,IAAnD,CALR;;AAOP,MAAMO,QAAQ,GAAIN,IAAD,IAAkBA,IAAnC;;AAEA,OAAO,MAAMO,OAAO,GAAG,CACrBlC,MADqB,EAErBQ,OAFqB,EAGrBkB,IAHqB,KAIlBM,UAAU,CAAChC,MAAD,EAASiC,QAAT,EAAmBzB,OAAnB,EAA4BkB,IAA5B,CAJR","sourcesContent":["import type { DependencyList } from \"react\";\nimport { useRef, useEffect, useState } from \"react\";\nimport { Image, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSource } from \"../types\";\n\nconst resolveAsset = (source: ReturnType<typeof require>) => {\n return Platform.OS === \"web\"\n ? source.default\n : Image.resolveAssetSource(source).uri;\n};\n\nconst factoryWrapper = <T>(\n data2: SkData,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n return null;\n } else {\n return factoryResult;\n }\n};\n\nconst loadDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<(T | null)[]> =>\n Promise.all(sources.map((source) => loadData(source, factory, onError)));\n\nconst loadData = <T>(\n source: DataSource,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source instanceof Uint8Array) {\n return new Promise((resolve) =>\n resolve(factoryWrapper(Skia.Data.fromBytes(source), factory, onError))\n );\n } else {\n const uri = typeof source === \"string\" ? source : resolveAsset(source);\n return Skia.Data.fromURI(uri).then((d) =>\n factoryWrapper(d, factory, onError)\n );\n }\n};\n\ntype Source = DataSource | null | undefined;\n\nconst useLoading = <T>(\n source: Source,\n loader: () => Promise<T | null>,\n deps: DependencyList = []\n) => {\n const [data, setData] = useState<T | null>(null);\n const prevSourceRef = useRef<Source>();\n useEffect(() => {\n if (prevSourceRef.current !== source) {\n prevSourceRef.current = source;\n loader().then(setData);\n } else {\n setData(null);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n return data;\n};\n\nexport const useDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) =>\n useLoading(\n sources,\n () => loadDataCollection(sources, factory, onError),\n deps\n );\n\nexport const useRawData = <T>(\n source: DataSource | null | undefined,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useLoading(source, () => loadData(source, factory, onError), deps);\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useRawData(source, identity, onError, deps);\n"]}
1
+ {"version":3,"sources":["Data.ts"],"names":["useRef","useEffect","useState","Image","Platform","Skia","resolveAsset","source","OS","default","resolveAssetSource","uri","factoryWrapper","data2","factory","onError","factoryResult","Error","loadDataCollection","sources","Promise","all","map","loadData","Uint8Array","Data","fromBytes","d","fromURI","useLoading","loader","deps","data","setData","prevSourceRef","current","then","useDataCollection","useRawData","identity","useData"],"mappings":"AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,QAA4C,OAA5C;AACA,SAASC,KAAT,EAAgBC,QAAhB,QAAgC,cAAhC;AAEA,SAASC,IAAT,QAAqB,SAArB;;AAGA,MAAMC,YAAY,GAAIC,MAAD,IAAwC;AAC3D,SAA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from \"react\";\nimport { Image, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { SkData, DataSource } from \"../types\";\n\nconst resolveAsset = (source: ReturnType<typeof require>) => {\n return Platform.OS === \"web\"\n ? source.default\n : Image.resolveAssetSource(source).uri;\n};\n\nconst factoryWrapper = <T>(\n data2: SkData,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n) => {\n const factoryResult = factory(data2);\n if (factoryResult === null) {\n onError && onError(new Error(\"Could not load data\"));\n return null;\n } else {\n return factoryResult;\n }\n};\n\nconst loadDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<(T | null)[]> =>\n Promise.all(sources.map((source) => loadData(source, factory, onError)));\n\nconst loadData = async <T>(\n source: DataSource,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void\n): Promise<T | null> => {\n if (source === null) {\n return null;\n } else if (source instanceof Uint8Array) {\n return factoryWrapper(Skia.Data.fromBytes(source), factory, onError);\n } else {\n const uri = typeof source === \"string\" ? source : resolveAsset(source);\n const d = await Skia.Data.fromURI(uri);\n return factoryWrapper(d, factory, onError);\n }\n};\n\ntype Source = DataSource | null | undefined;\n\nconst useLoading = <T>(\n source: Source,\n loader: () => Promise<T | null>,\n deps: DependencyList = []\n) => {\n const [data, setData] = useState<T | null>(null);\n const prevSourceRef = useRef<Source>();\n useEffect(() => {\n if (prevSourceRef.current !== source) {\n prevSourceRef.current = source;\n loader().then(setData);\n } else {\n setData(null);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n return data;\n};\n\nexport const useDataCollection = <T>(\n sources: DataSource[],\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) =>\n useLoading(\n sources,\n () => loadDataCollection(sources, factory, onError),\n deps\n );\n\nexport const useRawData = <T>(\n source: DataSource | null | undefined,\n factory: (data: SkData) => T,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useLoading(source, () => loadData(source, factory, onError), deps);\n\nconst identity = (data: SkData) => data;\n\nexport const useData = (\n source: DataSource | null | undefined,\n onError?: (err: Error) => void,\n deps?: DependencyList\n) => useRawData(source, identity, onError, deps);\n"]}