@shopify/react-native-skia 2.5.4 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +7 -7
  2. package/apple/{WebGPUView.h → SkiaWebGPUView.h} +1 -1
  3. package/apple/{WebGPUView.mm → SkiaWebGPUView.mm} +7 -7
  4. package/cpp/api/CustomBlendModes.h +1 -0
  5. package/cpp/api/JsiSkApi.h +4 -0
  6. package/cpp/api/JsiSkCanvas.h +2 -2
  7. package/cpp/api/JsiSkContourMeasureIter.h +1 -1
  8. package/cpp/api/JsiSkPath.h +483 -355
  9. package/cpp/api/JsiSkPathBuilder.h +415 -0
  10. package/cpp/api/JsiSkPathBuilderFactory.h +53 -0
  11. package/cpp/api/JsiSkPathEffectFactory.h +2 -2
  12. package/cpp/api/JsiSkPathFactory.h +274 -3
  13. package/cpp/api/recorder/DataTypes.h +1 -1
  14. package/cpp/api/recorder/Drawings.h +6 -2
  15. package/cpp/rnskia/RNDawnContext.h +21 -0
  16. package/cpp/rnskia/RNDawnUtils.h +115 -113
  17. package/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  18. package/lib/commonjs/animation/functions/interpolatePaths.js +5 -4
  19. package/lib/commonjs/animation/functions/interpolatePaths.js.map +1 -1
  20. package/lib/commonjs/external/reanimated/interpolators.d.ts +11 -2
  21. package/lib/commonjs/external/reanimated/interpolators.js +21 -4
  22. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  23. package/lib/commonjs/skia/types/Path/PathBuilder.d.ts +201 -0
  24. package/lib/commonjs/skia/types/Path/PathBuilder.js +6 -0
  25. package/lib/commonjs/skia/types/Path/PathBuilder.js.map +1 -0
  26. package/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  27. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js +6 -0
  28. package/lib/commonjs/skia/types/Path/PathBuilderFactory.js.map +1 -0
  29. package/lib/commonjs/skia/types/Path/PathFactory.d.ts +87 -1
  30. package/lib/commonjs/skia/types/Path/PathFactory.js.map +1 -1
  31. package/lib/commonjs/skia/types/Path/index.d.ts +2 -0
  32. package/lib/commonjs/skia/types/Path/index.js +22 -0
  33. package/lib/commonjs/skia/types/Path/index.js.map +1 -1
  34. package/lib/commonjs/skia/types/Skia.d.ts +2 -1
  35. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  36. package/lib/commonjs/skia/web/Host.js +1 -3
  37. package/lib/commonjs/skia/web/Host.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkCanvas.js +6 -2
  39. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkContourMeasure.js +4 -1
  41. package/lib/commonjs/skia/web/JsiSkContourMeasure.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkPath.d.ts +42 -30
  43. package/lib/commonjs/skia/web/JsiSkPath.js +302 -111
  44. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  45. package/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +45 -0
  46. package/lib/commonjs/skia/web/JsiSkPathBuilder.js +192 -0
  47. package/lib/commonjs/skia/web/JsiSkPathBuilder.js.map +1 -0
  48. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  49. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js +26 -0
  50. package/lib/commonjs/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  51. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +6 -2
  52. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +13 -1
  54. package/lib/commonjs/skia/web/JsiSkPathFactory.js +140 -5
  55. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkia.js +8 -1
  57. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  58. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +18 -6
  59. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  60. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  61. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js +2 -3
  62. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  63. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -2
  64. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +2 -3
  65. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +1 -1
  66. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +2 -0
  67. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  68. package/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  69. package/lib/module/animation/functions/interpolatePaths.js +5 -4
  70. package/lib/module/animation/functions/interpolatePaths.js.map +1 -1
  71. package/lib/module/external/reanimated/interpolators.d.ts +11 -2
  72. package/lib/module/external/reanimated/interpolators.js +21 -4
  73. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  74. package/lib/module/skia/types/Path/PathBuilder.d.ts +201 -0
  75. package/lib/module/skia/types/Path/PathBuilder.js +2 -0
  76. package/lib/module/skia/types/Path/PathBuilder.js.map +1 -0
  77. package/lib/module/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  78. package/lib/module/skia/types/Path/PathBuilderFactory.js +2 -0
  79. package/lib/module/skia/types/Path/PathBuilderFactory.js.map +1 -0
  80. package/lib/module/skia/types/Path/PathFactory.d.ts +87 -1
  81. package/lib/module/skia/types/Path/PathFactory.js.map +1 -1
  82. package/lib/module/skia/types/Path/index.d.ts +2 -0
  83. package/lib/module/skia/types/Path/index.js +2 -0
  84. package/lib/module/skia/types/Path/index.js.map +1 -1
  85. package/lib/module/skia/types/Skia.d.ts +2 -1
  86. package/lib/module/skia/types/Skia.js.map +1 -1
  87. package/lib/module/skia/web/Host.js +1 -3
  88. package/lib/module/skia/web/Host.js.map +1 -1
  89. package/lib/module/skia/web/JsiSkCanvas.js +6 -2
  90. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  91. package/lib/module/skia/web/JsiSkContourMeasure.js +4 -1
  92. package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkPath.d.ts +42 -30
  94. package/lib/module/skia/web/JsiSkPath.js +300 -110
  95. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  96. package/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  97. package/lib/module/skia/web/JsiSkPathBuilder.js +186 -0
  98. package/lib/module/skia/web/JsiSkPathBuilder.js.map +1 -0
  99. package/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  100. package/lib/module/skia/web/JsiSkPathBuilderFactory.js +19 -0
  101. package/lib/module/skia/web/JsiSkPathBuilderFactory.js.map +1 -0
  102. package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -2
  103. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  104. package/lib/module/skia/web/JsiSkPathFactory.d.ts +13 -1
  105. package/lib/module/skia/web/JsiSkPathFactory.js +141 -6
  106. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  107. package/lib/module/skia/web/JsiSkia.js +8 -1
  108. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  109. package/lib/module/sksg/Recorder/commands/Drawing.js +18 -6
  110. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  111. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  112. package/lib/module/specs/SkiaPictureViewNativeComponent.js +1 -1
  113. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  114. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +2 -2
  115. package/lib/module/specs/WebGPUViewNativeComponent.js +2 -2
  116. package/lib/module/specs/WebGPUViewNativeComponent.js.map +1 -1
  117. package/lib/module/specs/WebGPUViewNativeComponent.web.js +2 -0
  118. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +1 -1
  119. package/lib/typescript/lib/commonjs/animation/functions/interpolatePaths.d.ts +1 -1
  120. package/lib/typescript/lib/commonjs/external/reanimated/interpolators.d.ts +1 -1
  121. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilder.d.ts +1 -0
  122. package/lib/typescript/lib/commonjs/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  123. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +33 -25
  124. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilder.d.ts +46 -0
  125. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathBuilderFactory.d.ts +7 -0
  126. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +12 -0
  127. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  128. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +2 -1
  129. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +2 -1
  130. package/lib/typescript/lib/module/animation/functions/interpolatePaths.d.ts +1 -1
  131. package/lib/typescript/lib/module/external/reanimated/interpolators.d.ts +1 -1
  132. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  133. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  134. package/lib/typescript/lib/module/skia/types/Path/PathBuilder.d.ts +1 -0
  135. package/lib/typescript/lib/module/skia/types/Path/PathBuilderFactory.d.ts +1 -0
  136. package/lib/typescript/lib/module/skia/types/Path/index.d.ts +2 -0
  137. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +38 -25
  138. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilder.d.ts +45 -0
  139. package/lib/typescript/lib/module/skia/web/JsiSkPathBuilderFactory.d.ts +6 -0
  140. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +12 -0
  141. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  142. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -1
  143. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +1 -1
  144. package/lib/typescript/src/animation/functions/interpolatePaths.d.ts +1 -1
  145. package/lib/typescript/src/external/reanimated/interpolators.d.ts +11 -2
  146. package/lib/typescript/src/skia/types/Path/PathBuilder.d.ts +201 -0
  147. package/lib/typescript/src/skia/types/Path/PathBuilderFactory.d.ts +13 -0
  148. package/lib/typescript/src/skia/types/Path/PathFactory.d.ts +87 -1
  149. package/lib/typescript/src/skia/types/Path/index.d.ts +2 -0
  150. package/lib/typescript/src/skia/types/Skia.d.ts +2 -1
  151. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +42 -30
  152. package/lib/typescript/src/skia/web/JsiSkPathBuilder.d.ts +45 -0
  153. package/lib/typescript/src/skia/web/JsiSkPathBuilderFactory.d.ts +9 -0
  154. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +13 -1
  155. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +2 -2
  156. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +2 -2
  157. package/package.json +4 -3
  158. package/scripts/install-libs.js +16 -6
  159. package/src/animation/functions/interpolatePaths.ts +5 -6
  160. package/src/external/reanimated/interpolators.ts +25 -5
  161. package/src/skia/types/Path/PathBuilder.ts +303 -0
  162. package/src/skia/types/Path/PathBuilderFactory.ts +15 -0
  163. package/src/skia/types/Path/PathFactory.ts +108 -1
  164. package/src/skia/types/Path/index.ts +2 -0
  165. package/src/skia/types/Skia.ts +2 -1
  166. package/src/skia/web/Host.ts +7 -1
  167. package/src/skia/web/JsiSkCanvas.ts +6 -6
  168. package/src/skia/web/JsiSkContourMeasure.ts +4 -4
  169. package/src/skia/web/JsiSkPath.ts +451 -168
  170. package/src/skia/web/JsiSkPathBuilder.ts +293 -0
  171. package/src/skia/web/JsiSkPathBuilderFactory.ts +32 -0
  172. package/src/skia/web/JsiSkPathEffectFactory.ts +6 -2
  173. package/src/skia/web/JsiSkPathFactory.ts +231 -8
  174. package/src/skia/web/JsiSkia.ts +11 -8
  175. package/src/sksg/Recorder/commands/Drawing.ts +20 -7
  176. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -2
  177. package/src/specs/WebGPUViewNativeComponent.ts +3 -3
  178. package/src/specs/WebGPUViewNativeComponent.web.ts +2 -0
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.interpolatePaths = void 0;
7
7
  var _typeddash = require("../../renderer/typeddash");
8
8
  var _interpolate = require("./interpolate");
9
- const lerp = (value, from, to, p1, p2, output) => {
9
+ const lerp = (value, from, to, p1, p2) => {
10
10
  "worklet";
11
11
 
12
12
  const t = (value - from) / (to - from);
13
- return p2.interpolate(p1, t, output);
13
+ // interpolate returns a new path (immutable operation)
14
+ return p2.interpolate(p1, t);
14
15
  };
15
16
 
16
17
  /**
@@ -29,7 +30,7 @@ const lerp = (value, from, to, p1, p2, output) => {
29
30
  * path2.lineTo(0, 100);
30
31
  * const path = interpolatePath(0.5, [0, 1], [path1, path2]);
31
32
  */
32
- const interpolatePaths = (value, input, outputRange, options, output) => {
33
+ const interpolatePaths = (value, input, outputRange, options, _output) => {
33
34
  "worklet";
34
35
 
35
36
  const extrapolation = (0, _interpolate.validateInterpolationOptions)(options);
@@ -62,7 +63,7 @@ const interpolatePaths = (value, input, outputRange, options, output) => {
62
63
  break;
63
64
  }
64
65
  }
65
- return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1], output);
66
+ return lerp(value, input[i], input[i + 1], outputRange[i], outputRange[i + 1]);
66
67
  };
67
68
  exports.interpolatePaths = interpolatePaths;
68
69
  //# sourceMappingURL=interpolatePaths.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_typeddash","require","_interpolate","lerp","value","from","to","p1","p2","output","t","interpolate","interpolatePaths","input","outputRange","options","extrapolation","validateInterpolationOptions","extrapolateLeft","Extrapolate","CLAMP","EXTEND","IDENTITY","Error","exhaustiveCheck","length","extrapolateRight","i","exports"],"sources":["interpolatePaths.ts"],"sourcesContent":["import type { SkPath } from \"../../skia/types\";\nimport { exhaustiveCheck } from \"../../renderer/typeddash\";\n\nimport type { ExtrapolationType } from \"./interpolate\";\nimport { validateInterpolationOptions, Extrapolate } from \"./interpolate\";\n\nconst lerp = (\n value: number,\n from: number,\n to: number,\n p1: SkPath,\n p2: SkPath,\n output?: SkPath\n) => {\n \"worklet\";\n const t = (value - from) / (to - from);\n return p2.interpolate(p1, t, output)!;\n};\n\n/**\n * Maps an input value within a range to an output path within a path range.\n * @param value - The input value.\n * @param inputRange - The range of the input value.\n * @param outputRange - The range of the output path.\n * @param options - Extrapolation options\n * @returns The output path.\n * @example <caption>Map a value between 0 and 1 to a path between two paths.</caption>\n * const path1 = new Path();\n * path1.moveTo(0, 0);\n * path1.lineTo(100, 0);\n * const path2 = new Path();\n * path2.moveTo(0, 0);\n * path2.lineTo(0, 100);\n * const path = interpolatePath(0.5, [0, 1], [path1, path2]);\n */\nexport const interpolatePaths = (\n value: number,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType,\n output?: SkPath\n) => {\n \"worklet\";\n const extrapolation = validateInterpolationOptions(options);\n if (value < input[0]) {\n switch (extrapolation.extrapolateLeft) {\n case Extrapolate.CLAMP:\n return outputRange[0];\n case Extrapolate.EXTEND:\n return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateLeft);\n }\n } else if (value > input[input.length - 1]) {\n switch (extrapolation.extrapolateRight) {\n case Extrapolate.CLAMP:\n return outputRange[outputRange.length - 1];\n case Extrapolate.EXTEND:\n return lerp(\n value,\n input[input.length - 2],\n input[input.length - 1],\n outputRange[input.length - 2],\n outputRange[input.length - 1]\n );\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateRight);\n }\n }\n let i = 0;\n for (; i <= input.length - 1; i++) {\n if (value >= input[i] && value <= input[i + 1]) {\n break;\n }\n }\n return lerp(\n value,\n input[i],\n input[i + 1],\n outputRange[i],\n outputRange[i + 1],\n output\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAD,OAAA;AAEA,MAAME,IAAI,GAAGA,CACXC,KAAa,EACbC,IAAY,EACZC,EAAU,EACVC,EAAU,EACVC,EAAU,EACVC,MAAe,KACZ;EACH,SAAS;;EACT,MAAMC,CAAC,GAAG,CAACN,KAAK,GAAGC,IAAI,KAAKC,EAAE,GAAGD,IAAI,CAAC;EACtC,OAAOG,EAAE,CAACG,WAAW,CAACJ,EAAE,EAAEG,CAAC,EAAED,MAAM,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,GAAGA,CAC9BR,KAAa,EACbS,KAAe,EACfC,WAAqB,EACrBC,OAA2B,EAC3BN,MAAe,KACZ;EACH,SAAS;;EACT,MAAMO,aAAa,GAAG,IAAAC,yCAA4B,EAACF,OAAO,CAAC;EAC3D,IAAIX,KAAK,GAAGS,KAAK,CAAC,CAAC,CAAC,EAAE;IACpB,QAAQG,aAAa,CAACE,eAAe;MACnC,KAAKC,wBAAW,CAACC,KAAK;QACpB,OAAON,WAAW,CAAC,CAAC,CAAC;MACvB,KAAKK,wBAAW,CAACE,MAAM;QACrB,OAAOlB,IAAI,CAACC,KAAK,EAAES,KAAK,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC,CAAC,EAAEA,WAAW,CAA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ClBlB,MACF,CAAC;AACH,CAAC;AAACmB,OAAA,CAAAhB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_typeddash","require","_interpolate","lerp","value","from","to","p1","p2","t","interpolate","interpolatePaths","input","outputRange","options","_output","extrapolation","validateInterpolationOptions","extrapolateLeft","Extrapolate","CLAMP","EXTEND","IDENTITY","Error","exhaustiveCheck","length","extrapolateRight","i","exports"],"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 // interpolate returns a new path (immutable operation)\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 _output?: SkPath\n) => {\n \"worklet\";\n const extrapolation = validateInterpolationOptions(options);\n if (value < input[0]) {\n switch (extrapolation.extrapolateLeft) {\n case Extrapolate.CLAMP:\n return outputRange[0];\n case Extrapolate.EXTEND:\n return lerp(value, input[0], input[1], outputRange[0], outputRange[1]);\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateLeft);\n }\n } else if (value > input[input.length - 1]) {\n switch (extrapolation.extrapolateRight) {\n case Extrapolate.CLAMP:\n return outputRange[outputRange.length - 1];\n case Extrapolate.EXTEND:\n return lerp(\n value,\n input[input.length - 2],\n input[input.length - 1],\n outputRange[input.length - 2],\n outputRange[input.length - 1]\n );\n case Extrapolate.IDENTITY:\n throw new Error(\n \"Identity is not a supported extrapolation type for interpolatePaths()\"\n );\n default:\n exhaustiveCheck(extrapolation.extrapolateRight);\n }\n }\n let i = 0;\n for (; i <= input.length - 1; i++) {\n if (value >= input[i] && value <= input[i + 1]) {\n break;\n }\n }\n return lerp(\n value,\n input[i],\n input[i + 1],\n outputRange[i],\n outputRange[i + 1]\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAD,OAAA;AAEA,MAAME,IAAI,GAAGA,CACXC,KAAa,EACbC,IAAY,EACZC,EAAU,EACVC,EAAU,EACVC,EAAU,KACP;EACH,SAAS;;EACT,MAAMC,CAAC,GAAG,CAACL,KAAK,GAAGC,IAAI,KAAKC,EAAE,GAAGD,IAAI,CAAC;EACtC;EACA,OAAOG,EAAE,CAACE,WAAW,CAACH,EAAE,EAAEE,CAAC,CAAC;AAC9B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,gBAAgB,GAAGA,CAC9BP,KAAa,EACbQ,KAAe,EACfC,WAAqB,EACrBC,OAA2B,EAC3BC,OAAgB,KACb;EACH,SAAS;;EACT,MAAMC,aAAa,GAAG,IAAAC,yCAA4B,EAACH,OAAO,CAAC;EAC3D,IAAIV,KAAK,GAAGQ,KAAK,CAAC,CAAC,CAAC,EAAE;IACpB,QAAQI,aAAa,CAACE,eAAe;MACnC,KAAKC,wBAAW,CAACC,KAAK;QACpB,OAAOP,WAAW,CAAC,CAAC,CAAC;MACvB,KAAKM,wBAAW,CAACE,MAAM;QACrB,OAAO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,KAAK,CAACe,CAAC,CAAC,EACRf,KAAK,CAACe,CAAC,GAAG,CAAC,CAAC,EACZd,WAAW,CAACc,CAAC,CAAC,EACdd,WAAW,CAACc,CAAC,GAAG,CAAC,CACnB,CAAC;AACH,CAAC;AAACC,OAAA,CAAAjB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,7 +1,16 @@
1
1
  import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
2
- import type { SkPath, SkPoint } from "../../skia/types";
2
+ import type { SkPath, SkPathBuilder, SkPoint } from "../../skia/types";
3
3
  export declare const notifyChange: <T>(value: SharedValue<T>) => void;
4
- export declare const usePathValue: (cb: (path: SkPath) => void, init?: SkPath) => SharedValue<SkPath>;
4
+ /**
5
+ * Hook for creating animated paths using PathBuilder.
6
+ * The callback receives a mutable PathBuilder that can be used to construct the path.
7
+ * The resulting immutable SkPath is stored in a shared value.
8
+ *
9
+ * @param cb - Callback that receives the PathBuilder to construct the path
10
+ * @param init - Optional initial path to add to the builder
11
+ * @param transform - Optional transform function applied to the built path
12
+ */
13
+ export declare const usePathValue: (cb: (builder: SkPathBuilder) => void, init?: SkPath, transform?: (path: SkPath) => SkPath) => SharedValue<SkPath>;
5
14
  export declare const useClock: () => SharedValue<number>;
6
15
  export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
7
16
  export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<SkPoint>;
@@ -18,16 +18,33 @@ const notifyChange = value => {
18
18
  value._value = value.value;
19
19
  }
20
20
  };
21
+
22
+ /**
23
+ * Hook for creating animated paths using PathBuilder.
24
+ * The callback receives a mutable PathBuilder that can be used to construct the path.
25
+ * The resulting immutable SkPath is stored in a shared value.
26
+ *
27
+ * @param cb - Callback that receives the PathBuilder to construct the path
28
+ * @param init - Optional initial path to add to the builder
29
+ * @param transform - Optional transform function applied to the built path
30
+ */
21
31
  exports.notifyChange = notifyChange;
22
- const usePathValue = (cb, init) => {
32
+ const usePathValue = (cb, init, transform) => {
33
+ const builderInit = (0, _react.useMemo)(() => _skia.Skia.PathBuilder.Make(), []);
23
34
  const pathInit = (0, _react.useMemo)(() => _skia.Skia.Path.Make(), []);
35
+ const builder = _ReanimatedProxy.default.useSharedValue(builderInit);
24
36
  const path = _ReanimatedProxy.default.useSharedValue(pathInit);
25
37
  _ReanimatedProxy.default.useDerivedValue(() => {
26
- path.value.reset();
38
+ builder.value.reset();
27
39
  if (init !== undefined) {
28
- path.value.addPath(init);
40
+ builder.value.addPath(init);
41
+ }
42
+ cb(builder.value);
43
+ let result = builder.value.build();
44
+ if (transform !== undefined) {
45
+ result = transform(result);
29
46
  }
30
- cb(path.value);
47
+ path.value = result;
31
48
  notifyChange(path);
32
49
  });
33
50
  return path;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_animation","_skia","_Offscreen","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","notifyChange","value","isOnMainThread","_value","exports","usePathValue","cb","init","pathInit","useMemo","Skia","Path","Make","path","Rea","useSharedValue","useDerivedValue","reset","undefined","addPath","useClock","clock","callback","useCallback","info","timeSinceFirstFrame","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","result","useAnimatedReaction","val","usePathInterpolation","outputRange","allPathsInterpolable","slice","every","isInterpolatable","Error","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { isOnMainThread } from \"../../renderer/Offscreen\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nexport const notifyChange = <T>(value: SharedValue<T>) => {\n \"worklet\";\n if (isOnMainThread()) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void, init?: SkPath) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = Rea.useSharedValue(pathInit);\n Rea.useDerivedValue(() => {\n path.value.reset();\n if (init !== undefined) {\n path.value.addPath(init);\n }\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = Rea.useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n Rea.useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = Rea.useSharedValue(init);\n Rea.useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) => {\n // Check if all paths in outputRange are interpolable\n const allPathsInterpolable = outputRange\n .slice(1)\n .every((path) => outputRange[0].isInterpolatable(path));\n if (!allPathsInterpolable) {\n // Handle the case where not all paths are interpolable\n // For example, throw an error or return early\n throw new Error(\n `Not all paths in the output range are interpolable.\nSee: https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathinterpolation`\n );\n }\n return useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n};\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAoC,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7B,MAAMG,YAAY,GAAOC,KAAqB,IAAK;EACxD,SAAS;;EACT,IAAI,IAAAC,yBAAc,EAAC,CAAC,EAAE;IACpB;IACCD,KAAK,CAASE,MAAM,GAAGF,KAAK,CAACA,KAAK;EACrC;AACF,CAAC;AAACG,OAAA,CAAAJ,YAAA,GAAAA,YAAA;AAEK,MAAMK,YAAY,GAAGA,CAACC,EAA0B,EAAEC,IAAa,KAAK;EACzE,MAAMC,QAAQ,GAAG,IAAAC,cAAO,EAAC,MAAMC,UAAI,CAACC,IAAI,CAACC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;EACpD,MAAMC,IAAI,GAAGC,wBAAG,CAACC,cAAc,CAACP,QAAQ,CAAC;EACzCM,wBAAG,CAACE,eAAe,CAAC,MAAM;IACxBH,IAAI,CAACZ,KAAK,CAACgB,KAAK,CAAC,CAAC;IAClB,IAAIV,IAAI,KAAKW,SAAS,EAAE;MACtBL,IAAI,CAACZ,KAAK,CAACkB,OAAO,CAACZ,IAAI,CAAC;IAC1B;IACAD,EAAE,CAACO,IAAI,CAACZ,KAAK,CAAC;IACdD,YAAY,CAACa,IAAI,CAAC;EACpB,CAAC,CAAC;EACF,OAAOA,IAAI;AACb,CAAC;AAACT,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEK,MAAMe,QAAQ,GAAGA,CAAA,KAAM;EAC5B,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,CAAC;EACzD,IAAI,CAACyB,oBAAoB,EAAE;IACzB;IACA;IACA,MAAM,IAAII,KAAK,CACb;AACN,4FACI,CAAC;EACH;EACA,OAAOf,eAAe,CACpB,MAAMjB,UAAI,CAACC,IAAI,CAACC,IAAI,CAAC,CAAC,EACtBX,KAAK,EACL0C,2BAAgB,EAChBb,KAAK,EACLO,WAAW,EACXL,OACF,CAAC;AACH,CAAC;AAAC5B,OAAA,CAAAgC,oBAAA,GAAAA,oBAAA;AAEK,MAAMQ,sBAAsB,GAAGA,CACpC3C,KAA0B,EAC1B6B,KAAe,EACfO,WAAsB,EACtBL,OAA2B,KAE3BL,eAAe,CACb,MAAMjB,UAAI,CAACmC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB5C,KAAK,EACL6C,4BAAiB,EACjBhB,KAAK,EACLO,WAAW,EACXL,OACF,CAAC;AAAC5B,OAAA,CAAAwC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_animation","_skia","_Offscreen","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","notifyChange","value","isOnMainThread","_value","exports","usePathValue","cb","init","transform","builderInit","useMemo","Skia","PathBuilder","Make","pathInit","Path","builder","Rea","useSharedValue","path","useDerivedValue","reset","undefined","addPath","result","build","useClock","clock","callback","useCallback","info","timeSinceFirstFrame","useFrameCallback","useInterpolator","factory","interpolator","input","output","options","useAnimatedReaction","val","usePathInterpolation","outputRange","allPathsInterpolable","slice","every","isInterpolatable","Error","interpolatePaths","useVectorInterpolation","Point","interpolateVector"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPathBuilder, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { isOnMainThread } from \"../../renderer/Offscreen\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nexport const notifyChange = <T>(value: SharedValue<T>) => {\n \"worklet\";\n if (isOnMainThread()) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\n/**\n * Hook for creating animated paths using PathBuilder.\n * The callback receives a mutable PathBuilder that can be used to construct the path.\n * The resulting immutable SkPath is stored in a shared value.\n *\n * @param cb - Callback that receives the PathBuilder to construct the path\n * @param init - Optional initial path to add to the builder\n * @param transform - Optional transform function applied to the built path\n */\nexport const usePathValue = (\n cb: (builder: SkPathBuilder) => void,\n init?: SkPath,\n transform?: (path: SkPath) => SkPath\n) => {\n const builderInit = useMemo(() => Skia.PathBuilder.Make(), []);\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const builder = Rea.useSharedValue(builderInit);\n const path = Rea.useSharedValue(pathInit);\n Rea.useDerivedValue(() => {\n builder.value.reset();\n if (init !== undefined) {\n builder.value.addPath(init);\n }\n cb(builder.value);\n let result = builder.value.build();\n if (transform !== undefined) {\n result = transform(result);\n }\n path.value = result;\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = Rea.useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n Rea.useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = Rea.useSharedValue(init);\n Rea.useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) => {\n // Check if all paths in outputRange are interpolable\n const allPathsInterpolable = outputRange\n .slice(1)\n .every((path) => outputRange[0].isInterpolatable(path));\n if (!allPathsInterpolable) {\n // Handle the case where not all paths are interpolable\n // For example, throw an error or return early\n throw new Error(\n `Not all paths in the output range are interpolable.\nSee: https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathinterpolation`\n );\n }\n return useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n};\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAoC,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7B,MAAMG,YAAY,GAAOC,KAAqB,IAAK;EACxD,SAAS;;EACT,IAAI,IAAAC,yBAAc,EAAC,CAAC,EAAE;IACpB;IACCD,KAAK,CAASE,MAAM,GAAGF,KAAK,CAACA,KAAK;EACrC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARAG,OAAA,CAAAJ,YAAA,GAAAA,YAAA;AASO,MAAMK,YAAY,GAAGA,CAC1BC,EAAoC,EACpCC,IAAa,EACbC,SAAoC,KACjC;EACH,MAAMC,WAAW,GAAG,IAAAC,cAAO,EAAC,MAAMC,UAAI,CAACC,WAAW,CAACC,IAAI,CAAC,CAAC,EAAE,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Ae,EACfM,WAAsB,EACtBJ,OAA2B,KAE3BL,eAAe,CACb,MAAMtB,UAAI,CAACuC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EACtBjD,KAAK,EACLkD,4BAAiB,EACjBf,KAAK,EACLM,WAAW,EACXJ,OACF,CAAC;AAAClC,OAAA,CAAA6C,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,201 @@
1
+ import type { SkRect } from "../Rect";
2
+ import type { SkPoint } from "../Point";
3
+ import type { InputRRect } from "../RRect";
4
+ import type { InputMatrix, SkMatrix } from "../Matrix";
5
+ import type { SkJSIInstance } from "../JsiInstance";
6
+ import type { FillType, SkPath } from "./Path";
7
+ /**
8
+ * SkPathBuilder is a mutable builder for constructing SkPath objects.
9
+ * Once construction is complete, call build() or detach() to get the immutable SkPath.
10
+ */
11
+ export interface SkPathBuilder extends SkJSIInstance<"PathBuilder"> {
12
+ /**
13
+ * Adds beginning of contour at point (x, y).
14
+ * @param x - x-axis value of contour start
15
+ * @param y - y-axis value of contour start
16
+ * @returns reference to this PathBuilder for chaining
17
+ */
18
+ moveTo(x: number, y: number): SkPathBuilder;
19
+ /**
20
+ * Adds beginning of contour relative to the last point.
21
+ * @param x - offset from last point on x-axis
22
+ * @param y - offset from last point on y-axis
23
+ * @returns reference to this PathBuilder for chaining
24
+ */
25
+ rMoveTo(x: number, y: number): SkPathBuilder;
26
+ /**
27
+ * Adds line from last point to (x, y).
28
+ * @param x - end of line on x-axis
29
+ * @param y - end of line on y-axis
30
+ * @returns reference to this PathBuilder for chaining
31
+ */
32
+ lineTo(x: number, y: number): SkPathBuilder;
33
+ /**
34
+ * Adds line from last point, relative to last point.
35
+ * @param x - offset from last point on x-axis
36
+ * @param y - offset from last point on y-axis
37
+ * @returns reference to this PathBuilder for chaining
38
+ */
39
+ rLineTo(x: number, y: number): SkPathBuilder;
40
+ /**
41
+ * Adds quad from last point towards (x1, y1), to (x2, y2).
42
+ */
43
+ quadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;
44
+ /**
45
+ * Relative version of quadTo.
46
+ */
47
+ rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;
48
+ /**
49
+ * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
50
+ */
51
+ conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPathBuilder;
52
+ /**
53
+ * Relative version of conicTo.
54
+ */
55
+ rConicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPathBuilder;
56
+ /**
57
+ * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).
58
+ */
59
+ cubicTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): SkPathBuilder;
60
+ /**
61
+ * Relative version of cubicTo.
62
+ */
63
+ rCubicTo(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): SkPathBuilder;
64
+ /**
65
+ * Appends CLOSE_VERB to the builder, connecting first and last points.
66
+ */
67
+ close(): SkPathBuilder;
68
+ /**
69
+ * Appends arc to the builder. Arc is part of ellipse bounded by oval.
70
+ * @param oval - bounds of ellipse containing arc
71
+ * @param startAngleInDegrees - starting angle of arc in degrees
72
+ * @param sweepAngleInDegrees - sweep, in degrees. Positive is clockwise
73
+ * @param forceMoveTo - true to start a new contour with arc
74
+ */
75
+ arcToOval(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number, forceMoveTo: boolean): SkPathBuilder;
76
+ /**
77
+ * Appends arc to the builder with SVG-style parameters.
78
+ * @param rx - x-radius of ellipse
79
+ * @param ry - y-radius of ellipse
80
+ * @param xAxisRotateInDegrees - rotation of ellipse
81
+ * @param useSmallArc - if true, use smaller of two arcs
82
+ * @param isCCW - if true, arc sweeps counter-clockwise
83
+ * @param x - end point x
84
+ * @param y - end point y
85
+ */
86
+ arcToRotated(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, x: number, y: number): SkPathBuilder;
87
+ /**
88
+ * Relative version of arcToRotated.
89
+ */
90
+ rArcTo(rx: number, ry: number, xAxisRotateInDegrees: number, useSmallArc: boolean, isCCW: boolean, dx: number, dy: number): SkPathBuilder;
91
+ /**
92
+ * Appends arc to the builder, tangent to two lines.
93
+ * @param x1 - x of first tangent point
94
+ * @param y1 - y of first tangent point
95
+ * @param x2 - x of second tangent point
96
+ * @param y2 - y of second tangent point
97
+ * @param radius - arc radius
98
+ */
99
+ arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number): SkPathBuilder;
100
+ /**
101
+ * Adds Rect to the builder.
102
+ * @param rect - rectangle to add
103
+ * @param isCCW - if true, draws counter-clockwise
104
+ */
105
+ addRect(rect: SkRect, isCCW?: boolean): SkPathBuilder;
106
+ /**
107
+ * Adds oval to the builder.
108
+ * @param oval - bounds of ellipse
109
+ * @param isCCW - if true, draws counter-clockwise
110
+ * @param startIndex - index of initial point
111
+ */
112
+ addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPathBuilder;
113
+ /**
114
+ * Appends arc to the builder as a new contour.
115
+ * @param oval - bounds of ellipse
116
+ * @param startAngleInDegrees - starting angle
117
+ * @param sweepAngleInDegrees - sweep angle
118
+ */
119
+ addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): SkPathBuilder;
120
+ /**
121
+ * Adds rounded rectangle to the builder.
122
+ * @param rrect - rounded rectangle to add
123
+ * @param isCCW - if true, draws counter-clockwise
124
+ */
125
+ addRRect(rrect: InputRRect, isCCW?: boolean): SkPathBuilder;
126
+ /**
127
+ * Adds circle to the builder.
128
+ * @param x - center x
129
+ * @param y - center y
130
+ * @param r - radius
131
+ * @param isCCW - if true, draws counter-clockwise
132
+ */
133
+ addCircle(x: number, y: number, r: number, isCCW?: boolean): SkPathBuilder;
134
+ /**
135
+ * Adds polygon to the builder from array of points.
136
+ * @param points - array of points
137
+ * @param close - if true, close the polygon
138
+ */
139
+ addPoly(points: SkPoint[], close: boolean): SkPathBuilder;
140
+ /**
141
+ * Adds the path to the builder.
142
+ * @param src - path to add
143
+ * @param matrix - optional transform matrix
144
+ * @param extend - if true, extend rather than append
145
+ */
146
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPathBuilder;
147
+ /**
148
+ * Sets the fill type for the path.
149
+ * @param fill - fill type to set
150
+ */
151
+ setFillType(fill: FillType): SkPathBuilder;
152
+ /**
153
+ * Sets whether the path is volatile (temporary/animating).
154
+ * @param isVolatile - true if path will be altered frequently
155
+ */
156
+ setIsVolatile(isVolatile: boolean): SkPathBuilder;
157
+ /**
158
+ * Resets the builder to empty state.
159
+ */
160
+ reset(): SkPathBuilder;
161
+ /**
162
+ * Translates all points in the builder.
163
+ * @param dx - translation in x
164
+ * @param dy - translation in y
165
+ */
166
+ offset(dx: number, dy: number): SkPathBuilder;
167
+ /**
168
+ * Transforms all points in the builder by the matrix.
169
+ * @param m - transformation matrix
170
+ */
171
+ transform(m: InputMatrix): SkPathBuilder;
172
+ /**
173
+ * Returns the bounds of the path being built.
174
+ */
175
+ computeBounds(): SkRect;
176
+ /**
177
+ * Returns true if the builder has no verbs.
178
+ */
179
+ isEmpty(): boolean;
180
+ /**
181
+ * Returns the last point added to the builder.
182
+ */
183
+ getLastPt(): {
184
+ x: number;
185
+ y: number;
186
+ };
187
+ /**
188
+ * Returns the number of points in the builder.
189
+ */
190
+ countPoints(): number;
191
+ /**
192
+ * Returns a new SkPath with the current builder state.
193
+ * The builder is NOT reset and can continue to be used.
194
+ */
195
+ build(): SkPath;
196
+ /**
197
+ * Returns a new SkPath with the current builder state and resets the builder.
198
+ * More efficient than build() when you're done with this builder.
199
+ */
200
+ detach(): SkPath;
201
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=PathBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["PathBuilder.ts"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { InputRRect } from \"../RRect\";\nimport type { InputMatrix, SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nimport type { FillType, SkPath } from \"./Path\";\n\n/**\n * SkPathBuilder is a mutable builder for constructing SkPath objects.\n * Once construction is complete, call build() or detach() to get the immutable SkPath.\n */\nexport interface SkPathBuilder extends SkJSIInstance<\"PathBuilder\"> {\n // Movement methods\n\n /**\n * Adds beginning of contour at point (x, y).\n * @param x - x-axis value of contour start\n * @param y - y-axis value of contour start\n * @returns reference to this PathBuilder for chaining\n */\n moveTo(x: number, y: number): SkPathBuilder;\n\n /**\n * Adds beginning of contour relative to the last point.\n * @param x - offset from last point on x-axis\n * @param y - offset from last point on y-axis\n * @returns reference to this PathBuilder for chaining\n */\n rMoveTo(x: number, y: number): SkPathBuilder;\n\n /**\n * Adds line from last point to (x, y).\n * @param x - end of line on x-axis\n * @param y - end of line on y-axis\n * @returns reference to this PathBuilder for chaining\n */\n lineTo(x: number, y: number): SkPathBuilder;\n\n /**\n * Adds line from last point, relative to last point.\n * @param x - offset from last point on x-axis\n * @param y - offset from last point on y-axis\n * @returns reference to this PathBuilder for chaining\n */\n rLineTo(x: number, y: number): SkPathBuilder;\n\n // Curve methods\n\n /**\n * Adds quad from last point towards (x1, y1), to (x2, y2).\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;\n\n /**\n * Relative version of quadTo.\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPathBuilder;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n */\n conicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n w: number\n ): SkPathBuilder;\n\n /**\n * Relative version of conicTo.\n */\n rConicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n w: number\n ): SkPathBuilder;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).\n */\n cubicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): SkPathBuilder;\n\n /**\n * Relative version of cubicTo.\n */\n rCubicTo(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n x3: number,\n y3: number\n ): SkPathBuilder;\n\n /**\n * Appends CLOSE_VERB to the builder, connecting first and last points.\n */\n close(): SkPathBuilder;\n\n // Arc methods\n\n /**\n * Appends arc to the builder. Arc is part of ellipse bounded by oval.\n * @param oval - bounds of ellipse containing arc\n * @param startAngleInDegrees - starting angle of arc in degrees\n * @param sweepAngleInDegrees - sweep, in degrees. Positive is clockwise\n * @param forceMoveTo - true to start a new contour with arc\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPathBuilder;\n\n /**\n * Appends arc to the builder with SVG-style parameters.\n * @param rx - x-radius of ellipse\n * @param ry - y-radius of ellipse\n * @param xAxisRotateInDegrees - rotation of ellipse\n * @param useSmallArc - if true, use smaller of two arcs\n * @param isCCW - if true, arc sweeps counter-clockwise\n * @param x - end point x\n * @param y - end point y\n */\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ): SkPathBuilder;\n\n /**\n * Relative version of arcToRotated.\n */\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ): SkPathBuilder;\n\n /**\n * Appends arc to the builder, tangent to two lines.\n * @param x1 - x of first tangent point\n * @param y1 - y of first tangent point\n * @param x2 - x of second tangent point\n * @param y2 - y of second tangent point\n * @param radius - arc radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPathBuilder;\n\n // Shape methods\n\n /**\n * Adds Rect to the builder.\n * @param rect - rectangle to add\n * @param isCCW - if true, draws counter-clockwise\n */\n addRect(rect: SkRect, isCCW?: boolean): SkPathBuilder;\n\n /**\n * Adds oval to the builder.\n * @param oval - bounds of ellipse\n * @param isCCW - if true, draws counter-clockwise\n * @param startIndex - index of initial point\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPathBuilder;\n\n /**\n * Appends arc to the builder as a new contour.\n * @param oval - bounds of ellipse\n * @param startAngleInDegrees - starting angle\n * @param sweepAngleInDegrees - sweep angle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPathBuilder;\n\n /**\n * Adds rounded rectangle to the builder.\n * @param rrect - rounded rectangle to add\n * @param isCCW - if true, draws counter-clockwise\n */\n addRRect(rrect: InputRRect, isCCW?: boolean): SkPathBuilder;\n\n /**\n * Adds circle to the builder.\n * @param x - center x\n * @param y - center y\n * @param r - radius\n * @param isCCW - if true, draws counter-clockwise\n */\n addCircle(x: number, y: number, r: number, isCCW?: boolean): SkPathBuilder;\n\n /**\n * Adds polygon to the builder from array of points.\n * @param points - array of points\n * @param close - if true, close the polygon\n */\n addPoly(points: SkPoint[], close: boolean): SkPathBuilder;\n\n /**\n * Adds the path to the builder.\n * @param src - path to add\n * @param matrix - optional transform matrix\n * @param extend - if true, extend rather than append\n */\n addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPathBuilder;\n\n // Configuration methods\n\n /**\n * Sets the fill type for the path.\n * @param fill - fill type to set\n */\n setFillType(fill: FillType): SkPathBuilder;\n\n /**\n * Sets whether the path is volatile (temporary/animating).\n * @param isVolatile - true if path will be altered frequently\n */\n setIsVolatile(isVolatile: boolean): SkPathBuilder;\n\n /**\n * Resets the builder to empty state.\n */\n reset(): SkPathBuilder;\n\n /**\n * Translates all points in the builder.\n * @param dx - translation in x\n * @param dy - translation in y\n */\n offset(dx: number, dy: number): SkPathBuilder;\n\n /**\n * Transforms all points in the builder by the matrix.\n * @param m - transformation matrix\n */\n transform(m: InputMatrix): SkPathBuilder;\n\n // Query methods\n\n /**\n * Returns the bounds of the path being built.\n */\n computeBounds(): SkRect;\n\n /**\n * Returns true if the builder has no verbs.\n */\n isEmpty(): boolean;\n\n /**\n * Returns the last point added to the builder.\n */\n getLastPt(): { x: number; y: number };\n\n /**\n * Returns the number of points in the builder.\n */\n countPoints(): number;\n\n // Build methods\n\n /**\n * Returns a new SkPath with the current builder state.\n * The builder is NOT reset and can continue to be used.\n */\n build(): SkPath;\n\n /**\n * Returns a new SkPath with the current builder state and resets the builder.\n * More efficient than build() when you're done with this builder.\n */\n detach(): SkPath;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ import type { SkPath } from "./Path";
2
+ import type { SkPathBuilder } from "./PathBuilder";
3
+ export interface PathBuilderFactory {
4
+ /**
5
+ * Creates a new empty PathBuilder.
6
+ */
7
+ Make(): SkPathBuilder;
8
+ /**
9
+ * Creates a new PathBuilder initialized with the given path's contents.
10
+ * @param path - path to copy into the builder
11
+ */
12
+ MakeFromPath(path: SkPath): SkPathBuilder;
13
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=PathBuilderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["PathBuilderFactory.ts"],"sourcesContent":["import type { SkPath } from \"./Path\";\nimport type { SkPathBuilder } from \"./PathBuilder\";\n\nexport interface PathBuilderFactory {\n /**\n * Creates a new empty PathBuilder.\n */\n Make(): SkPathBuilder;\n\n /**\n * Creates a new PathBuilder initialized with the given path's contents.\n * @param path - path to copy into the builder\n */\n MakeFromPath(path: SkPath): SkPathBuilder;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,8 @@
1
1
  import type { SkFont } from "../Font";
2
- import type { SkPath, PathOp, PathCommand } from "./Path";
2
+ import type { SkRect } from "../Rect";
3
+ import type { SkPoint } from "../Point";
4
+ import type { InputRRect } from "../RRect";
5
+ import type { SkPath, PathOp, PathCommand, StrokeOpts } from "./Path";
3
6
  export interface PathFactory {
4
7
  Make(): SkPath;
5
8
  /**
@@ -26,4 +29,87 @@ export interface PathFactory {
26
29
  * Converts the text to a path with the given font at location x / y.
27
30
  */
28
31
  MakeFromText(text: string, x: number, y: number, font: SkFont): SkPath | null;
32
+ /**
33
+ * Creates a path containing a rectangle.
34
+ * @param rect - the rectangle
35
+ * @param isCCW - if true, draws counter-clockwise
36
+ */
37
+ Rect(rect: SkRect, isCCW?: boolean): SkPath;
38
+ /**
39
+ * Creates a path containing an oval (ellipse).
40
+ * @param rect - bounds of the oval
41
+ * @param isCCW - if true, draws counter-clockwise
42
+ * @param startIndex - index of initial point
43
+ */
44
+ Oval(rect: SkRect, isCCW?: boolean, startIndex?: number): SkPath;
45
+ /**
46
+ * Creates a path containing a circle.
47
+ * @param x - center x
48
+ * @param y - center y
49
+ * @param r - radius
50
+ */
51
+ Circle(x: number, y: number, r: number): SkPath;
52
+ /**
53
+ * Creates a path containing a rounded rectangle.
54
+ * @param rrect - the rounded rectangle
55
+ * @param isCCW - if true, draws counter-clockwise
56
+ */
57
+ RRect(rrect: InputRRect, isCCW?: boolean): SkPath;
58
+ /**
59
+ * Creates a path containing a line segment.
60
+ * @param p1 - start point
61
+ * @param p2 - end point
62
+ */
63
+ Line(p1: SkPoint, p2: SkPoint): SkPath;
64
+ /**
65
+ * Creates a path containing a polygon from the given points.
66
+ * @param points - array of points
67
+ * @param close - if true, close the polygon
68
+ */
69
+ Polygon(points: SkPoint[], close: boolean): SkPath;
70
+ /**
71
+ * Creates a new stroked path from the input path.
72
+ * @param path - source path to stroke
73
+ * @param opts - stroke options (width, cap, join, miter_limit, precision)
74
+ * @returns stroked path or null if operation fails
75
+ */
76
+ Stroke(path: SkPath, opts?: StrokeOpts): SkPath | null;
77
+ /**
78
+ * Creates a trimmed path from the input path.
79
+ * @param path - source path
80
+ * @param start - start of trim (0-1)
81
+ * @param end - end of trim (0-1)
82
+ * @param isComplement - if true, returns the complement
83
+ * @returns trimmed path or null if operation fails
84
+ */
85
+ Trim(path: SkPath, start: number, end: number, isComplement: boolean): SkPath | null;
86
+ /**
87
+ * Simplifies the path to non-overlapping contours.
88
+ * @param path - source path
89
+ * @returns simplified path or null if operation fails
90
+ */
91
+ Simplify(path: SkPath): SkPath | null;
92
+ /**
93
+ * Creates a dashed version of the path.
94
+ * @param path - source path
95
+ * @param on - length of dash
96
+ * @param off - length of gap
97
+ * @param phase - offset into dash pattern
98
+ * @returns dashed path or null if operation fails
99
+ */
100
+ Dash(path: SkPath, on: number, off: number, phase: number): SkPath | null;
101
+ /**
102
+ * Creates a path with Winding fill type.
103
+ * @param path - source path
104
+ * @returns path with winding fill or null if operation fails
105
+ */
106
+ AsWinding(path: SkPath): SkPath | null;
107
+ /**
108
+ * Interpolates between two paths.
109
+ * @param start - starting path
110
+ * @param end - ending path
111
+ * @param weight - interpolation weight (0 = start, 1 = end)
112
+ * @returns interpolated path or null if paths are not interpolatable
113
+ */
114
+ Interpolate(start: SkPath, end: SkPath, weight: number): SkPath | null;
29
115
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["PathFactory.ts"],"sourcesContent":["import type { SkFont } from \"../Font\";\n\nimport type { SkPath, PathOp, PathCommand } from \"./Path\";\n\nexport interface PathFactory {\n Make(): SkPath;\n /**\n * Creates a new path from the provided SVG string. If this fails, null will be\n * returned instead.\n * @param str\n */\n MakeFromSVGString(str: string): SkPath | null;\n\n /**\n * Creates a new path by combining the given paths according to op. If this fails, null will\n * be returned instead.\n * @param one\n * @param two\n * @param op\n */\n MakeFromOp(one: SkPath, two: SkPath, op: PathOp): SkPath | null;\n\n /**\n * Creates a new path from the given list of path commands. If this fails, null will be\n * returned instead.\n * @param cmds\n */\n MakeFromCmds(cmds: PathCommand[]): SkPath | null;\n\n /**\n * Converts the text to a path with the given font at location x / y.\n */\n MakeFromText(text: string, x: number, y: number, font: SkFont): SkPath | null;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["PathFactory.ts"],"sourcesContent":["import type { SkFont } from \"../Font\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { InputRRect } from \"../RRect\";\n\nimport type { SkPath, PathOp, PathCommand, StrokeOpts } from \"./Path\";\n\nexport interface PathFactory {\n Make(): SkPath;\n /**\n * Creates a new path from the provided SVG string. If this fails, null will be\n * returned instead.\n * @param str\n */\n MakeFromSVGString(str: string): SkPath | null;\n\n /**\n * Creates a new path by combining the given paths according to op. If this fails, null will\n * be returned instead.\n * @param one\n * @param two\n * @param op\n */\n MakeFromOp(one: SkPath, two: SkPath, op: PathOp): SkPath | null;\n\n /**\n * Creates a new path from the given list of path commands. If this fails, null will be\n * returned instead.\n * @param cmds\n */\n MakeFromCmds(cmds: PathCommand[]): SkPath | null;\n\n /**\n * Converts the text to a path with the given font at location x / y.\n */\n MakeFromText(text: string, x: number, y: number, font: SkFont): SkPath | null;\n\n // Static shape factories\n\n /**\n * Creates a path containing a rectangle.\n * @param rect - the rectangle\n * @param isCCW - if true, draws counter-clockwise\n */\n Rect(rect: SkRect, isCCW?: boolean): SkPath;\n\n /**\n * Creates a path containing an oval (ellipse).\n * @param rect - bounds of the oval\n * @param isCCW - if true, draws counter-clockwise\n * @param startIndex - index of initial point\n */\n Oval(rect: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Creates a path containing a circle.\n * @param x - center x\n * @param y - center y\n * @param r - radius\n */\n Circle(x: number, y: number, r: number): SkPath;\n\n /**\n * Creates a path containing a rounded rectangle.\n * @param rrect - the rounded rectangle\n * @param isCCW - if true, draws counter-clockwise\n */\n RRect(rrect: InputRRect, isCCW?: boolean): SkPath;\n\n /**\n * Creates a path containing a line segment.\n * @param p1 - start point\n * @param p2 - end point\n */\n Line(p1: SkPoint, p2: SkPoint): SkPath;\n\n /**\n * Creates a path containing a polygon from the given points.\n * @param points - array of points\n * @param close - if true, close the polygon\n */\n Polygon(points: SkPoint[], close: boolean): SkPath;\n\n // Static path operations\n\n /**\n * Creates a new stroked path from the input path.\n * @param path - source path to stroke\n * @param opts - stroke options (width, cap, join, miter_limit, precision)\n * @returns stroked path or null if operation fails\n */\n Stroke(path: SkPath, opts?: StrokeOpts): SkPath | null;\n\n /**\n * Creates a trimmed path from the input path.\n * @param path - source path\n * @param start - start of trim (0-1)\n * @param end - end of trim (0-1)\n * @param isComplement - if true, returns the complement\n * @returns trimmed path or null if operation fails\n */\n Trim(\n path: SkPath,\n start: number,\n end: number,\n isComplement: boolean\n ): SkPath | null;\n\n /**\n * Simplifies the path to non-overlapping contours.\n * @param path - source path\n * @returns simplified path or null if operation fails\n */\n Simplify(path: SkPath): SkPath | null;\n\n /**\n * Creates a dashed version of the path.\n * @param path - source path\n * @param on - length of dash\n * @param off - length of gap\n * @param phase - offset into dash pattern\n * @returns dashed path or null if operation fails\n */\n Dash(path: SkPath, on: number, off: number, phase: number): SkPath | null;\n\n /**\n * Creates a path with Winding fill type.\n * @param path - source path\n * @returns path with winding fill or null if operation fails\n */\n AsWinding(path: SkPath): SkPath | null;\n\n /**\n * Interpolates between two paths.\n * @param start - starting path\n * @param end - ending path\n * @param weight - interpolation weight (0 = start, 1 = end)\n * @returns interpolated path or null if paths are not interpolatable\n */\n Interpolate(start: SkPath, end: SkPath, weight: number): SkPath | null;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +1,4 @@
1
1
  export * from "./Path";
2
+ export * from "./PathBuilder";
3
+ export * from "./PathBuilderFactory";
2
4
  export * from "./PathFactory";
@@ -14,6 +14,28 @@ Object.keys(_Path).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _PathBuilder = require("./PathBuilder");
18
+ Object.keys(_PathBuilder).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _PathBuilder[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _PathBuilder[key];
25
+ }
26
+ });
27
+ });
28
+ var _PathBuilderFactory = require("./PathBuilderFactory");
29
+ Object.keys(_PathBuilderFactory).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _PathBuilderFactory[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _PathBuilderFactory[key];
36
+ }
37
+ });
38
+ });
17
39
  var _PathFactory = require("./PathFactory");
18
40
  Object.keys(_PathFactory).forEach(function (key) {
19
41
  if (key === "default" || key === "__esModule") return;
@@ -1 +1 @@
1
- {"version":3,"names":["_Path","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_PathFactory"],"sources":["index.ts"],"sourcesContent":["export * from \"./Path\";\nexport * from \"./PathFactory\";\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Path","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_PathBuilder","_PathBuilderFactory","_PathFactory"],"sources":["index.ts"],"sourcesContent":["export * from \"./Path\";\nexport * from \"./PathBuilder\";\nexport * from \"./PathBuilderFactory\";\nexport * from \"./PathFactory\";\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,mBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,mBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,mBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,mBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,YAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,YAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,YAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,YAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { ImageFilterFactory } from "./ImageFilter";
2
- import type { PathFactory } from "./Path";
2
+ import type { PathFactory, PathBuilderFactory } from "./Path";
3
3
  import type { ColorFilterFactory } from "./ColorFilter";
4
4
  import type { SkFont, FontMgrFactory } from "./Font";
5
5
  import type { SkTypeface, TypefaceFactory } from "./Typeface";
@@ -50,6 +50,7 @@ export interface Skia {
50
50
  PictureRecorder: () => SkPictureRecorder;
51
51
  Picture: PictureFactory;
52
52
  Path: PathFactory;
53
+ PathBuilder: PathBuilderFactory;
53
54
  Matrix: (matrix?: readonly number[]) => SkMatrix;
54
55
  ColorFilter: ColorFilterFactory;
55
56
  Font: (typeface?: SkTypeface, size?: number) => SkFont;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SkSurface, SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\nimport type { JsiRecorder } from \"./Recorder\";\nimport type { SkottieFactory } from \"./Skottie\";\n\nexport interface SkiaContext {\n getSurface(): SkSurface;\n present(): void;\n}\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Skottie: SkottieFactory;\n Video: (url: string) => Promise<Video> | Video;\n Context(surface: bigint, width: number, height: number): SkiaContext;\n NativeBuffer: NativeBufferFactory;\n Recorder(): JsiRecorder;\n /**\n * Returns whether the Graphite backend is enabled and WebGPU is available.\n *\n * @returns true if Graphite/WebGPU is available, false otherwise\n */\n hasDevice(): boolean;\n /**\n * Returns the shared WebGPU device used by Skia's Graphite backend.\n * This allows direct access to the GPU device for WebGPU operations.\n *\n * Note: This method is only available when the Graphite backend is enabled.\n * Use hasDevice() to check availability before calling this method.\n *\n * @returns The GPUDevice used by Skia\n * @throws Error if Graphite backend is not enabled\n */\n getDevice(): GPUDevice;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory, PathBuilderFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SkSurface, SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\nimport type { JsiRecorder } from \"./Recorder\";\nimport type { SkottieFactory } from \"./Skottie\";\n\nexport interface SkiaContext {\n getSurface(): SkSurface;\n present(): void;\n}\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n PathBuilder: PathBuilderFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Skottie: SkottieFactory;\n Video: (url: string) => Promise<Video> | Video;\n Context(surface: bigint, width: number, height: number): SkiaContext;\n NativeBuffer: NativeBufferFactory;\n Recorder(): JsiRecorder;\n /**\n * Returns whether the Graphite backend is enabled and WebGPU is available.\n *\n * @returns true if Graphite/WebGPU is available, false otherwise\n */\n hasDevice(): boolean;\n /**\n * Returns the shared WebGPU device used by Skia's Graphite backend.\n * This allows direct access to the GPU device for WebGPU operations.\n *\n * Note: This method is only available when the Graphite backend is enabled.\n * Use hasDevice() to check availability before calling this method.\n *\n * @returns The GPUDevice used by Skia\n * @throws Error if Graphite backend is not enabled\n */\n getDevice(): GPUDevice;\n}\n"],"mappings":"","ignoreList":[]}
@@ -50,9 +50,7 @@ const getEnum = (CanvasKit, name, v) => {
50
50
  if (typeof e !== "function") {
51
51
  throw new Error(`${name} is not an number`);
52
52
  }
53
- const result = Object.values(e).find(({
54
- value
55
- }) => value === v);
53
+ const result = Object.values(e).find(entry => entry !== null && typeof entry === "object" && "value" in entry && entry.value === v);
56
54
  if (!result) {
57
55
  throw new Error(`Enum ${name} does not have value ${v} on React Native Web`);
58
56
  }