@shopify/react-native-skia 0.1.166 → 0.1.167

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +0 -5
  2. package/cpp/api/JsiSkPath.h +20 -3
  3. package/cpp/rnskia/dom/nodes/JsiBoxNode.h +4 -12
  4. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +30 -9
  5. package/cpp/rnskia/dom/props/ImageProps.h +9 -6
  6. package/cpp/rnskia/dom/props/PointProp.h +4 -13
  7. package/cpp/rnskia/dom/props/PointsProp.h +1 -7
  8. package/cpp/rnskia/dom/props/RRectProp.h +53 -0
  9. package/cpp/rnskia/dom/props/RadiusProp.h +7 -9
  10. package/cpp/rnskia/dom/props/TransformProp.h +2 -2
  11. package/lib/commonjs/dom/nodes/datatypes/Transform.js +0 -3
  12. package/lib/commonjs/dom/nodes/datatypes/Transform.js.map +1 -1
  13. package/lib/commonjs/dom/nodes/paint/Shaders.js +1 -1
  14. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  15. package/lib/commonjs/renderer/Canvas.js +8 -39
  16. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  17. package/lib/commonjs/renderer/DrawingContext.js.map +1 -1
  18. package/lib/commonjs/renderer/Reconciler.js +64 -0
  19. package/lib/commonjs/renderer/Reconciler.js.map +1 -0
  20. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  21. package/lib/commonjs/skia/web/JsiSkPath.js +7 -0
  22. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  23. package/lib/commonjs/skia/web/JsiSkRRect.js +14 -1
  24. package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
  25. package/lib/commonjs/skia/web/JsiSkia.js +1 -1
  26. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  27. package/lib/module/dom/nodes/datatypes/Transform.js +0 -3
  28. package/lib/module/dom/nodes/datatypes/Transform.js.map +1 -1
  29. package/lib/module/dom/nodes/paint/Shaders.js +1 -1
  30. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  31. package/lib/module/renderer/Canvas.js +7 -33
  32. package/lib/module/renderer/Canvas.js.map +1 -1
  33. package/lib/module/renderer/DrawingContext.js.map +1 -1
  34. package/lib/module/renderer/Reconciler.js +48 -0
  35. package/lib/module/renderer/Reconciler.js.map +1 -0
  36. package/lib/module/skia/types/Path/Path.js.map +1 -1
  37. package/lib/module/skia/web/JsiSkPath.js +7 -0
  38. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  39. package/lib/module/skia/web/JsiSkRRect.js +14 -1
  40. package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
  41. package/lib/module/skia/web/JsiSkia.js +1 -1
  42. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  43. package/lib/typescript/src/renderer/Canvas.d.ts +4 -7
  44. package/lib/typescript/src/renderer/DrawingContext.d.ts +2 -5
  45. package/lib/typescript/src/renderer/Reconciler.d.ts +13 -0
  46. package/lib/typescript/src/skia/types/Path/Path.d.ts +13 -0
  47. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +1 -0
  48. package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
  49. package/package.json +1 -1
  50. package/src/dom/nodes/datatypes/Transform.ts +0 -2
  51. package/src/dom/nodes/paint/Shaders.ts +1 -1
  52. package/src/renderer/Canvas.tsx +12 -61
  53. package/src/renderer/DrawingContext.ts +2 -6
  54. package/src/renderer/Reconciler.tsx +66 -0
  55. package/src/skia/types/Path/Path.ts +14 -0
  56. package/src/skia/web/JsiSkPath.ts +10 -0
  57. package/src/skia/web/JsiSkRRect.ts +13 -2
  58. package/src/skia/web/JsiSkia.ts +1 -4
@@ -0,0 +1,48 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import ReactReconciler from "react-reconciler";
4
+ import { DependencyManager } from "./DependencyManager";
5
+ import { skHostConfig, debug as hostDebug } from "./HostConfig";
6
+ import { Container } from "./Container";
7
+ const skiaReconciler = ReactReconciler(skHostConfig);
8
+
9
+ const createDependencyManager = registerValues => global.SkiaDomApi && global.SkiaDomApi.DependencyManager ? global.SkiaDomApi.DependencyManager(registerValues) : new DependencyManager(registerValues);
10
+
11
+ skiaReconciler.injectIntoDevTools({
12
+ bundleType: 1,
13
+ version: "0.0.1",
14
+ rendererPackageName: "react-native-skia"
15
+ });
16
+ export class SkiaRoot {
17
+ constructor(Skia) {
18
+ let registerValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => () => {};
19
+ let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
20
+
21
+ _defineProperty(this, "root", void 0);
22
+
23
+ _defineProperty(this, "container", void 0);
24
+
25
+ const depMgr = createDependencyManager(registerValues);
26
+ this.container = new Container(Skia, depMgr, redraw);
27
+ this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
28
+ }
29
+
30
+ render(element) {
31
+ skiaReconciler.updateContainer(element, this.root, null, () => {
32
+ hostDebug("updateContainer");
33
+ this.container.depMgr.update();
34
+ });
35
+ }
36
+
37
+ unmount() {
38
+ skiaReconciler.updateContainer(null, this.root, null, () => {
39
+ this.container.depMgr.remove();
40
+ });
41
+ }
42
+
43
+ get dom() {
44
+ return this.container.root;
45
+ }
46
+
47
+ }
48
+ //# sourceMappingURL=Reconciler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ReactReconciler","DependencyManager","skHostConfig","debug","hostDebug","Container","skiaReconciler","createDependencyManager","registerValues","global","SkiaDomApi","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","depMgr","container","root","createContainer","console","error","render","element","updateContainer","update","unmount","remove","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\nimport type { SkiaValue } from \"../values/types\";\n\nimport { DependencyManager } from \"./DependencyManager\";\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\ntype RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;\n\nconst createDependencyManager = (registerValues: RegisterValues) =>\n global.SkiaDomApi && global.SkiaDomApi.DependencyManager\n ? global.SkiaDomApi.DependencyManager(registerValues)\n : new DependencyManager(registerValues);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(\n Skia: Skia,\n registerValues: RegisterValues = () => () => {},\n redraw: () => void = () => {}\n ) {\n const depMgr = createDependencyManager(registerValues);\n this.container = new Container(Skia, depMgr, redraw);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n render(element: ReactNode) {\n skiaReconciler.updateContainer(element, this.root, null, () => {\n hostDebug(\"updateContainer\");\n this.container.depMgr.update();\n });\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n this.container.depMgr.remove();\n });\n }\n\n get dom() {\n return this.container.root;\n }\n}\n"],"mappings":";;AAEA,OAAOA,eAAP,MAA4B,kBAA5B;AAKA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,YAAT,EAAuBC,KAAK,IAAIC,SAAhC,QAAiD,cAAjD;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,MAAMC,cAAc,GAAGN,eAAe,CAACE,YAAD,CAAtC;;AAIA,MAAMK,uBAAuB,GAAIC,cAAD,IAC9BC,MAAM,CAACC,UAAP,IAAqBD,MAAM,CAACC,UAAP,CAAkBT,iBAAvC,GACIQ,MAAM,CAACC,UAAP,CAAkBT,iBAAlB,CAAoCO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ourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): SkPath;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): SkPath;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): SkPath;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): SkPath;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\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 ): SkPath;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(\n dx1: number,\n dy1: number,\n dx2: number,\n dy2: number,\n w: number\n ): SkPath;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): void;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): void;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n * If such a transformation cannot be done, null is returned.\n */\n stroke(opts?: StrokeOpts): null | SkPath;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): void;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n */\n computeTightBounds(): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param 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 ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): void;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): void;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,\n four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing\n clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.\n\n Has no effect if radius is zero or negative.\n\n @param x center of circle\n @param y center of circle\n @param radius distance from center to edge \n @return reference to SkPath\n */\n addCircle(x: number, y: number, r: number): SkPath;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix): void;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @return Path replaced by interpolated averages or null if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number): SkPath | null;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"],"mappings":"AAOA;AACA;AACA;AAcA,WAAYA,QAAZ;;WAAYA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,WAAYC,MAAZ;;WAAYA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAQZ,WAAYC,QAAZ;;WAAYA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAWZ,OAAO,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC"}
1
+ {"version":3,"names":["FillType","PathOp","PathVerb","isPath","obj","__typename__"],"sources":["Path.ts"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkPoint } from \"../Point\";\nimport type { SkRRect } from \"../RRect\";\nimport type { StrokeJoin, StrokeCap } from \"../Paint\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\n/**\n * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.\n */\nexport interface StrokeOpts {\n /** The width of the stroked lines. */\n width?: number;\n miter_limit?: number;\n /**\n * if > 1, increase precision, else if (0 < resScale < 1) reduce precision to\n * favor speed and size\n */\n precision?: number;\n join?: StrokeJoin;\n cap?: StrokeCap;\n}\n\nexport enum FillType {\n Winding,\n EvenOdd,\n InverseWinding,\n InverseEvenOdd,\n}\n\nexport enum PathOp {\n Difference, //!< subtract the op path from the first path\n Intersect, //!< intersect the two paths\n Union, //!< union (inclusive-or) the two paths\n XOR, //!< exclusive-or the two paths\n ReverseDifference,\n}\n\nexport enum PathVerb {\n Move,\n Line,\n Quad,\n Conic,\n Cubic,\n Close,\n}\n\nexport type PathCommand = number[];\n\nexport const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>\n obj !== null && obj.__typename__ === \"Path\";\n\nexport interface SkPath extends SkJSIInstance<\"Path\"> {\n /**\n * Appends arc to Path, as the start of new contour. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngle\n * @param sweepAngle\n */\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ): SkPath;\n\n /**\n * Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.\n * Oval is upright ellipse bounded by Rect oval with radii equal to half oval width\n * and half oval height. Oval begins at start and continues clockwise by default.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param isCCW - if the path should be drawn counter-clockwise or not\n * @param startIndex - index of initial point of ellipse\n */\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): SkPath;\n\n /**\n * Returns the number of points in this path. Initially zero.\n */\n countPoints(): number;\n\n /**\n * Adds contour created from array of n points, adding (count - 1) line segments.\n * Contour added starts at pts[0], then adds a line for every additional point\n * in pts array. If close is true, appends kClose_Verb to Path, connecting\n * pts[count - 1] and pts[0].\n * Returns the modified path for easier chaining.\n * @param points\n * @param close - if true, will add a line connecting last point to the first point.\n */\n addPoly(points: SkPoint[], close: boolean): SkPath;\n\n /** Adds beginning of contour at SkPoint (x, y).\n\n @param x x-axis value of contour start\n @param y y-axis value of contour start\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_moveTo\n */\n moveTo(x: number, y: number): SkPath;\n /** Adds line from last point to (x, y). If SkPath is empty, or last SkPath::Verb is\n kClose_Verb, last point is set to (0, 0) before adding line.\n\n lineTo() appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed.\n lineTo() then appends kLine_Verb to verb array and (x, y) to SkPoint array.\n\n @param x end of added line on x-axis\n @param y end of added line on y-axis\n @return reference to SkPath\n\n example: https://fiddle.skia.org/c/@Path_lineTo\n */\n lineTo(x: number, y: number): SkPath;\n\n /**\n * Returns a new path that covers the same area as the original path, but with the\n * Winding FillType. This may re-draw some contours in the path as counter-clockwise\n * instead of clockwise to achieve that effect. If such a transformation cannot\n * be done, null is returned.\n */\n makeAsWinding(): SkPath | null;\n\n /**\n * Translates all the points in the path by dx, dy.\n * @param dx\n * @param dy\n */\n offset(dx: number, dy: number): SkPath;\n\n /**\n * Relative version of arcToRotated.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param dx\n * @param dy\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 ): SkPath;\n\n /**\n * Relative version of conicTo.\n * @param dx1\n * @param dy1\n * @param dx2\n * @param dy2\n * @param w\n */\n rConicTo(\n dx1: number,\n dy1: number,\n dx2: number,\n dy2: number,\n w: number\n ): SkPath;\n\n /**\n * Relative version of cubicTo.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Relative version of moveTo.\n * @param x\n * @param y\n */\n rMoveTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of lineTo.\n * @param x\n * @param y\n */\n rLineTo(x: number, y: number): SkPath;\n\n /**\n * Relative version of quadTo.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n */\n rQuadTo(x1: number, y1: number, x2: number, y2: number): SkPath;\n\n /**\n * Sets FillType, the rule used to fill Path.\n * @param fill\n */\n setFillType(fill: FillType): void;\n\n /**\n * Specifies whether Path is volatile; whether it will be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false.\n *\n * Mark animating or temporary paths as volatile to improve performance.\n * Mark unchanging Path non-volatile to improve repeated rendering.\n * @param volatile\n */\n setIsVolatile(volatile: boolean): void;\n\n /**\n * Turns this path into the filled equivalent of the stroked path. Returns false if the operation\n * fails (e.g. the path is a hairline).\n * @param opts - describe how stroked path should look.\n * If such a transformation cannot be done, null is returned.\n */\n stroke(opts?: StrokeOpts): null | SkPath;\n\n /**\n * Appends CLOSE_VERB to Path. A closed contour connects the first and last point\n * with a line, forming a continuous loop.\n */\n close(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is released\n */\n reset(): void;\n\n /**\n * Sets Path to its initial state.\n * Removes verb array, point array, and weights, and sets FillType to Winding.\n * Internal storage associated with Path is *not* released.\n * Use rewind() instead of reset() if Path storage will be reused and performance\n * is critical.\n */\n rewind(): void;\n\n /**\n * Returns minimum and maximum axes values of the lines and curves in Path.\n * Returns (0, 0, 0, 0) if Path contains no points.\n * Returned bounds width and height may be larger or smaller than area affected\n * when Path is drawn.\n *\n * Behaves identically to getBounds() when Path contains\n * only lines. If Path contains curves, computed bounds includes\n * the maximum extent of the quad, conic, or cubic; is slower than getBounds();\n * and unlike getBounds(), does not cache the result.\n */\n computeTightBounds(): SkRect;\n\n /**\n * Appends arc to Path. Arc added is part of ellipse\n * bounded by oval, from startAngle through sweepAngle. Both startAngle and\n * sweepAngle are measured in degrees, where zero degrees is aligned with the\n * positive x-axis, and positive sweeps extends arc clockwise.\n * Returns the modified path for easier chaining.\n * @param oval\n * @param startAngleInDegrees\n * @param sweepAngleInDegrees\n * @param forceMoveTo\n */\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ): SkPath;\n\n /**\n * Appends arc to Path. Arc is implemented by one or more conics weighted to\n * describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc\n * curves from last Path Point to (x, y), choosing one of four possible routes:\n * clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details.\n * Returns the modified path for easier chaining.\n * @param rx\n * @param ry\n * @param xAxisRotate\n * @param useSmallArc\n * @param isCCW\n * @param x\n * @param 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 ): SkPath;\n\n /**\n * Appends arc to Path, after appending line if needed. Arc is implemented by conic\n * weighted to describe part of circle. Arc is contained by tangent from\n * last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc\n * is part of circle sized to radius, positioned so it touches both tangent lines.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param radius\n */\n arcToTangent(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n radius: number\n ): SkPath;\n\n /**\n * Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.\n * If Path is empty, or path is closed, the last point is set to (0, 0)\n * before adding conic.\n * Returns the modified path for easier chaining.\n * @param x1\n * @param y1\n * @param x2\n * @param y2\n * @param w\n */\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number): SkPath;\n\n /**\n * Returns true if the point (x, y) is contained by Path, taking into\n * account FillType.\n * @param x\n * @param y\n */\n contains(x: number, y: number): boolean;\n\n /**\n * Returns a copy of this Path.\n */\n copy(): SkPath;\n\n /**\n * Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at\n * (x3, y3). If Path is empty, or path is closed, the last point is set to\n * (0, 0) before adding cubic.\n * @param cpx1\n * @param cpy1\n * @param cpx2\n * @param cpy2\n * @param x\n * @param y\n */\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ): SkPath;\n\n /**\n * Changes this path to be the dashed version of itself. This is the same effect as creating\n * a DashPathEffect and calling filterPath on this path.\n * @param on\n * @param off\n * @param phase\n */\n dash(on: number, off: number, phase: number): boolean;\n\n /**\n * Returns true if other path is equal to this path.\n * @param other\n */\n equals(other: SkPath): boolean;\n\n /**\n * Returns minimum and maximum axes values of Point array.\n * Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may\n * be larger or smaller than area affected when Path is drawn.\n */\n getBounds(): SkRect;\n\n /**\n * Return the FillType for this path.\n */\n getFillType(): FillType;\n\n /**\n Adds quad from last point towards (x1, y1), to (x2, y2).\n\n If SkPath is empty, or last SkPath::Verb is kClose_Verb, last point is set to (0, 0) before adding quad.\n\n Appends kMove_Verb to verb array and (0, 0) to SkPoint array, if needed; then appends kQuad_Verb to verb array;\n and (x1, y1), (x2, y2) to SkPoint array.\n\n Parameters\n x1\tcontrol SkPoint of quad on x-axis\n y1\tcontrol SkPoint of quad on y-axis\n x2\tend SkPoint of quad on x-axis\n y2\tend SkPoint of quad on y-axis\n Returns\n reference to SkPath\n example: https://fiddle.skia.org/c/@Path_quadTo\n */\n quadTo(x1: number, y1: number, x2: number, y2: number): void;\n\n /**\n * Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb,\n * starting with top-left corner of Rect; followed by top-right, bottom-right,\n * and bottom-left if isCCW is false; or followed by bottom-left,\n * bottom-right, and top-right if isCCW is true.\n * Returns the modified path for easier chaining.\n * @param rect\n * @param isCCW\n */\n addRect(rect: SkRect, isCCW?: boolean): void;\n\n /**\n * Adds rrect to Path, creating a new closed contour.\n * Returns the modified path for easier chaining.\n * @param rrect\n * @param isCCW\n */\n addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;\n\n /** Appends src to SkPath, transformed by matrix. Transformed curves may have\n different verbs, SkPoint, and conic weights.\n\n If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic\n weights are added unaltered. If mode is kExtend_AddPathMode, add line\n before appending verbs, SkPoint, and conic weights.\n\n @param src SkPath verbs, SkPoint, and conic weights to add\n @param matrix transform applied to src\n @param extend extends path with line if true\n @return reference to SkPath\n */\n addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;\n\n /**\n * Returns the Point at index in Point array. Valid range for index is\n * 0 to countPoints() - 1.\n * @param index\n */\n getPoint(index: number): SkPoint;\n\n /**\n * Returns true if there are no verbs in the path.\n */\n isEmpty(): boolean;\n\n /**\n * Returns true if the path is volatile; it will not be altered or discarded\n * by the caller after it is drawn. Path by default have volatile set false, allowing\n * Surface to attach a cache of data which speeds repeated drawing. If true, Surface\n * may not speed repeated drawing.\n */\n isVolatile(): boolean;\n\n /** Adds circle centered at (x, y) of size radius to SkPath, appending kMove_Verb,\n four kConic_Verb, and kClose_Verb. Circle begins at: (x + radius, y), continuing\n clockwise if dir is kCW_Direction, and counterclockwise if dir is kCCW_Direction.\n\n Has no effect if radius is zero or negative.\n\n @param x center of circle\n @param y center of circle\n @param radius distance from center to edge \n @return reference to SkPath\n */\n addCircle(x: number, y: number, r: number): SkPath;\n\n getLastPt(): { x: number; y: number };\n\n /** Set this path to the result of applying the Op to this path and the\n specified path: this = (this op operand).\n The resulting path will be constructed from non-overlapping contours.\n The curve order is reduced where possible so that cubics may be turned\n into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param path The second path (for difference, the subtrahend)\n @param op The operator to apply.\n @param result The product of the operands. The result may be one of the\n inputs.\n @return True if the operation succeeded.\n */\n op(path: SkPath, op: PathOp): boolean;\n\n /** Set this path to a set of non-overlapping contours that describe the\n same area as the original path.\n The curve order is reduced where possible so that cubics may\n be turned into quadratics, and quadratics maybe turned into lines.\n\n Returns true if operation was able to produce a result;\n otherwise, result is unmodified.\n\n @param result The simplified path. The result may be the input.\n @return True if simplification succeeded.\n */\n simplify(): boolean;\n\n /**\n * Returns this path as an SVG string.\n */\n toSVGString(): string;\n\n /**\n * Take start and stop \"t\" values (values between 0...1), and modify this path such that\n * it is a subset of the original path.\n * The trim values apply to the entire path, so if it contains several contours, all of them\n * are including in the calculation.\n * Null is returned if either input value is NaN.\n * @param startT - a value in the range [0.0, 1.0]. 0.0 is the beginning of the path.\n * @param stopT - a value in the range [0.0, 1.0]. 1.0 is the end of the path.\n * @param isComplement\n */\n trim(startT: number, stopT: number, isComplement: boolean): null | SkPath;\n\n /**\n * Transforms the path by the specified matrix.\n */\n transform(m3: SkMatrix): void;\n\n /**\n * Interpolates between Path with point array of equal size.\n * Copy verb array and weights to result, and set result path to a weighted\n * average of this path array and ending path.\n\n * weight is most useful when between zero (ending path) and\n one (this path); will work with values outside of this\n range.\n\n * interpolate() returns undefined if path is not\n * the same size as ending path. Call isInterpolatable() to check Path\n * compatibility prior to calling interpolate().\n\n * @param ending path to interpolate with\n * @param weight contribution of this path, and\n * one minus contribution of ending path\n * @return Path replaced by interpolated averages or null if \n * not interpolatable\n * */\n interpolate(end: SkPath, weight: number): SkPath | null;\n\n /** Returns true if Path contain equal verbs and equal weights.\n * @param compare path to compare\n * @return true if Path can be interpolated equivalent\n *\n * */\n isInterpolatable(compare: SkPath): boolean;\n\n /**\n * Serializes the contents of this path as a series of commands.\n */\n toCmds(): PathCommand[];\n}\n"],"mappings":"AAOA;AACA;AACA;AAcA,WAAYA,QAAZ;;WAAYA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAOZ,WAAYC,MAAZ;;WAAYA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAQZ,WAAYC,QAAZ;;WAAYA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAWZ,OAAO,MAAMC,MAAM,GAAIC,GAAD,IACpBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,MADhC"}
@@ -17,6 +17,13 @@ export class JsiSkPath extends HostObject {
17
17
  super(CanvasKit, ref, "Path");
18
18
  }
19
19
 
20
+ addPath(src, matrix) {
21
+ let extend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
22
+ const args = [JsiSkPath.fromValue(src), ...(matrix ? JsiSkMatrix.fromValue(matrix) : []), extend];
23
+ this.ref.addPath(...args);
24
+ return this;
25
+ }
26
+
20
27
  addArc(oval, startAngleInDegrees, sweepAngleInDegrees) {
21
28
  this.ref.addArc(JsiSkRect.fromValue(this.CanvasKit, oval), startAngleInDegrees, sweepAngleInDegrees);
22
29
  return this;
@@ -1 +1 @@
1
- {"version":3,"names":["PathVerb","ckEnum","HostObject","optEnum","JsiSkPoint","JsiSkRect","JsiSkRRect","JsiSkMatrix","CommandCount","Move","Line","Quad","Conic","Cubic","Close","JsiSkPath","constructor","CanvasKit","ref","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","fromValue","addOval","isCCW","startIndex","countPoints","addPoly","points","close","map","p","Array","from","flat","moveTo","x","y","lineTo","makeAsWinding","result","offset","dx","dy","rArcTo","rx","ry","xAxisRotateInDegrees","useSmallArc","rConicTo","dx1","dy1","dx2","dy2","w","rCubicTo","cpx1","cpy1","cpx2","cpy2","rMoveTo","rLineTo","rQuadTo","x1","y1","x2","y2","setFillType","fill","setIsVolatile","volatile","stroke","opts","undefined","width","miter_limit","precision","join","cap","reset","rewind","computeTightBounds","arcToOval","forceMoveTo","arcToRotated","arcToTangent","radius","conicTo","contains","copy","cubicTo","dash","on","off","phase","equals","other","getBounds","getFillType","value","quadTo","addRect","rect","addRRect","rrect","getPoint","index","isEmpty","isVolatile","addCircle","r","getLastPt","op","path","simplify","toSVGString","trim","startT","stopT","isComplement","transform","m3","interpolate","end","t","Path","MakeFromPathInterpolation","isInterpolatable","path2","CanInterpolate","toCmds","cmds","reduce","acc","cmd","i","push","current","length"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, Path } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n SkRRect,\n StrokeOpts,\n} from \"../types\";\n\nimport { ckEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nexport class JsiSkPath extends HostObject<Path, \"Path\"> implements SkPath {\n constructor(CanvasKit: CanvasKit, ref: Path) {\n super(CanvasKit, ref, \"Path\");\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n this.ref.addPoly(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n moveTo(x: number, y: number) {\n this.ref.moveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n this.ref.lineTo(x, y);\n return this;\n }\n\n makeAsWinding() {\n const result = this.ref.makeAsWinding();\n return result === null ? result : this;\n }\n\n offset(dx: number, dy: number) {\n this.ref.offset(dx, dy);\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {\n this.ref.rConicTo(dx1, dy1, dx2, dy2, w);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n this.ref.rLineTo(x, y);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n setFillType(fill: FillType) {\n this.ref.setFillType(ckEnum(fill));\n }\n\n setIsVolatile(volatile: boolean) {\n this.ref.setIsVolatile(volatile);\n }\n\n stroke(opts?: StrokeOpts) {\n const result = this.ref.stroke(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.width,\n precision: opts.width,\n join: optEnum(opts.join),\n cap: optEnum(opts.cap),\n }\n );\n return result === null ? result : this;\n }\n\n close() {\n this.ref.close();\n }\n\n reset() {\n this.ref.reset();\n }\n\n rewind() {\n this.ref.rewind();\n }\n\n computeTightBounds(): SkRect {\n return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n contains(x: number, y: number) {\n return this.ref.contains(x, y);\n }\n\n copy() {\n return new JsiSkPath(this.CanvasKit, this.ref.copy());\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n dash(on: number, off: number, phase: number) {\n return this.ref.dash(on, off, phase);\n }\n\n equals(other: SkPath) {\n return this.ref.equals(JsiSkPath.fromValue(other));\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType() {\n return this.ref.getFillType().value;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.quadTo(x1, y1, x2, y2);\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n }\n\n addRRect(rrect: SkRRect, isCCW?: boolean) {\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n getPoint(index: number) {\n return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return this.ref.isVolatile();\n }\n\n addCircle(x: number, y: number, r: number) {\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n getLastPt() {\n return new JsiSkPoint(\n this.CanvasKit,\n this.ref.getPoint(this.ref.countPoints() - 1)\n );\n }\n\n op(path: SkPath, op: PathOp) {\n return this.ref.op(JsiSkPath.fromValue(path), ckEnum(op));\n }\n\n simplify() {\n return this.ref.simplify();\n }\n\n toSVGString() {\n return this.ref.toSVGString();\n }\n\n trim(startT: number, stopT: number, isComplement: boolean) {\n const result = this.ref.trim(startT, stopT, isComplement);\n return result === null ? result : this;\n }\n\n transform(m3: SkMatrix) {\n this.ref.transform(JsiSkMatrix.fromValue(m3));\n }\n\n interpolate(end: SkPath, t: number) {\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(\n this.ref,\n JsiSkPath.fromValue(end),\n t\n );\n if (path === null) {\n return null;\n }\n return new JsiSkPath(this.CanvasKit, path);\n }\n\n isInterpolatable(path2: SkPath): boolean {\n return this.CanvasKit.Path.CanInterpolate(\n this.ref,\n JsiSkPath.fromValue(path2)\n );\n }\n\n toCmds() {\n const cmds = this.ref.toCmds();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,UAAzB;AAaA,SAASC,MAAT,EAAiBC,UAAjB,EAA6BC,OAA7B,QAA4C,QAA5C;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,WAAT,QAA4B,eAA5B;AAEA,MAAMC,YAAY,GAAG;EACnB,CAACR,QAAQ,CAACS,IAAV,GAAiB,CADE;EAEnB,CAACT,QAAQ,CAACU,IAAV,GAAiB,CAFE;EAGnB,CAACV,QAAQ,CAACW,IAAV,GAAiB,CAHE;EAInB,CAACX,QAAQ,CAACY,KAAV,GAAkB,CAJC;EAKnB,CAACZ,QAAQ,CAACa,KAAV,GAAkB,CALC;EAMnB,CAACb,QAAQ,CAACc,KAAV,GAAkB;AANC,CAArB;AASA,OAAO,MAAMC,SAAN,SAAwBb,UAAxB,CAAmE;EACxEc,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;EACD;;EAEDC,MAAM,CACJC,IADI,E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AACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF;;MACD,OAAOH,GAAP;IACD,CArBc,EAqBZ,EArBY,CAAf;IAsBA,OAAO7F,MAAP;EACD;;AAxUuE"}
1
+ {"version":3,"names":["PathVerb","ckEnum","HostObject","optEnum","JsiSkPoint","JsiSkRect","JsiSkRRect","JsiSkMatrix","CommandCount","Move","Line","Quad","Conic","Cubic","Close","JsiSkPath","constructor","CanvasKit","ref","addPath","src","matrix","extend","args","fromValue","addArc","oval","startAngleInDegrees","sweepAngleInDegrees","addOval","isCCW","startIndex","countPoints","addPoly","points","close","map","p","Array","from","flat","moveTo","x","y","lineTo","makeAsWinding","result","offset","dx","dy","rArcTo","rx","ry","xAxisRotateInDegrees","useSmallArc","rConicTo","dx1","dy1","dx2","dy2","w","rCubicTo","cpx1","cpy1","cpx2","cpy2","rMoveTo","rLineTo","rQuadTo","x1","y1","x2","y2","setFillType","fill","setIsVolatile","volatile","stroke","opts","undefined","width","miter_limit","precision","join","cap","reset","rewind","computeTightBounds","arcToOval","forceMoveTo","arcToRotated","arcToTangent","radius","conicTo","contains","copy","cubicTo","dash","on","off","phase","equals","other","getBounds","getFillType","value","quadTo","addRect","rect","addRRect","rrect","getPoint","index","isEmpty","isVolatile","addCircle","r","getLastPt","op","path","simplify","toSVGString","trim","startT","stopT","isComplement","transform","m3","interpolate","end","t","Path","MakeFromPathInterpolation","isInterpolatable","path2","CanInterpolate","toCmds","cmds","reduce","acc","cmd","i","push","current","length"],"sources":["JsiSkPath.ts"],"sourcesContent":["import type { CanvasKit, Path } from \"canvaskit-wasm\";\n\nimport { PathVerb } from \"../types\";\nimport type {\n FillType,\n PathCommand,\n PathOp,\n SkMatrix,\n SkPath,\n SkPoint,\n SkRect,\n SkRRect,\n StrokeOpts,\n} from \"../types\";\n\nimport { ckEnum, HostObject, optEnum } from \"./Host\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\n\nconst CommandCount = {\n [PathVerb.Move]: 3,\n [PathVerb.Line]: 3,\n [PathVerb.Quad]: 5,\n [PathVerb.Conic]: 6,\n [PathVerb.Cubic]: 7,\n [PathVerb.Close]: 1,\n};\n\nexport class JsiSkPath extends HostObject<Path, \"Path\"> implements SkPath {\n constructor(CanvasKit: CanvasKit, ref: Path) {\n super(CanvasKit, ref, \"Path\");\n }\n\n addPath(src: SkPath, matrix?: SkMatrix, extend = false) {\n const args = [\n JsiSkPath.fromValue(src),\n ...(matrix ? JsiSkMatrix.fromValue<Float32Array>(matrix) : []),\n extend,\n ];\n this.ref.addPath(...args);\n return this;\n }\n\n addArc(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number\n ) {\n this.ref.addArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees\n );\n return this;\n }\n\n addOval(oval: SkRect, isCCW?: boolean, startIndex?: number) {\n this.ref.addOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n isCCW,\n startIndex\n );\n return this;\n }\n\n countPoints() {\n return this.ref.countPoints();\n }\n\n addPoly(points: SkPoint[], close: boolean) {\n this.ref.addPoly(\n points.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n close\n );\n return this;\n }\n\n moveTo(x: number, y: number) {\n this.ref.moveTo(x, y);\n return this;\n }\n\n lineTo(x: number, y: number) {\n this.ref.lineTo(x, y);\n return this;\n }\n\n makeAsWinding() {\n const result = this.ref.makeAsWinding();\n return result === null ? result : this;\n }\n\n offset(dx: number, dy: number) {\n this.ref.offset(dx, dy);\n return this;\n }\n\n rArcTo(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n dx: number,\n dy: number\n ) {\n this.ref.rArcTo(rx, ry, xAxisRotateInDegrees, useSmallArc, isCCW, dx, dy);\n return this;\n }\n\n rConicTo(dx1: number, dy1: number, dx2: number, dy2: number, w: number) {\n this.ref.rConicTo(dx1, dy1, dx2, dy2, w);\n return this;\n }\n\n rCubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.rCubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n rMoveTo(x: number, y: number) {\n this.ref.rMoveTo(x, y);\n return this;\n }\n\n rLineTo(x: number, y: number) {\n this.ref.rLineTo(x, y);\n return this;\n }\n\n rQuadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.rQuadTo(x1, y1, x2, y2);\n return this;\n }\n\n setFillType(fill: FillType) {\n this.ref.setFillType(ckEnum(fill));\n }\n\n setIsVolatile(volatile: boolean) {\n this.ref.setIsVolatile(volatile);\n }\n\n stroke(opts?: StrokeOpts) {\n const result = this.ref.stroke(\n opts === undefined\n ? undefined\n : {\n width: opts.width,\n // eslint-disable-next-line camelcase\n miter_limit: opts.width,\n precision: opts.width,\n join: optEnum(opts.join),\n cap: optEnum(opts.cap),\n }\n );\n return result === null ? result : this;\n }\n\n close() {\n this.ref.close();\n }\n\n reset() {\n this.ref.reset();\n }\n\n rewind() {\n this.ref.rewind();\n }\n\n computeTightBounds(): SkRect {\n return new JsiSkRect(this.CanvasKit, this.ref.computeTightBounds());\n }\n\n arcToOval(\n oval: SkRect,\n startAngleInDegrees: number,\n sweepAngleInDegrees: number,\n forceMoveTo: boolean\n ) {\n this.ref.arcToOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngleInDegrees,\n sweepAngleInDegrees,\n forceMoveTo\n );\n return this;\n }\n\n arcToRotated(\n rx: number,\n ry: number,\n xAxisRotateInDegrees: number,\n useSmallArc: boolean,\n isCCW: boolean,\n x: number,\n y: number\n ) {\n this.ref.arcToRotated(\n rx,\n ry,\n xAxisRotateInDegrees,\n useSmallArc,\n isCCW,\n x,\n y\n );\n return this;\n }\n\n arcToTangent(x1: number, y1: number, x2: number, y2: number, radius: number) {\n this.ref.arcToTangent(x1, y1, x2, y2, radius);\n return this;\n }\n\n conicTo(x1: number, y1: number, x2: number, y2: number, w: number) {\n this.ref.conicTo(x1, y1, x2, y2, w);\n return this;\n }\n\n contains(x: number, y: number) {\n return this.ref.contains(x, y);\n }\n\n copy() {\n return new JsiSkPath(this.CanvasKit, this.ref.copy());\n }\n\n cubicTo(\n cpx1: number,\n cpy1: number,\n cpx2: number,\n cpy2: number,\n x: number,\n y: number\n ) {\n this.ref.cubicTo(cpx1, cpy1, cpx2, cpy2, x, y);\n return this;\n }\n\n dash(on: number, off: number, phase: number) {\n return this.ref.dash(on, off, phase);\n }\n\n equals(other: SkPath) {\n return this.ref.equals(JsiSkPath.fromValue(other));\n }\n\n getBounds() {\n return new JsiSkRect(this.CanvasKit, this.ref.getBounds());\n }\n\n getFillType() {\n return this.ref.getFillType().value;\n }\n\n quadTo(x1: number, y1: number, x2: number, y2: number) {\n this.ref.quadTo(x1, y1, x2, y2);\n }\n\n addRect(rect: SkRect, isCCW?: boolean) {\n this.ref.addRect(JsiSkRect.fromValue(this.CanvasKit, rect), isCCW);\n }\n\n addRRect(rrect: SkRRect, isCCW?: boolean) {\n this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);\n return this;\n }\n\n getPoint(index: number) {\n return new JsiSkPoint(this.CanvasKit, this.ref.getPoint(index));\n }\n\n isEmpty() {\n return this.ref.isEmpty();\n }\n\n isVolatile() {\n return this.ref.isVolatile();\n }\n\n addCircle(x: number, y: number, r: number) {\n this.ref.addCircle(x, y, r);\n return this;\n }\n\n getLastPt() {\n return new JsiSkPoint(\n this.CanvasKit,\n this.ref.getPoint(this.ref.countPoints() - 1)\n );\n }\n\n op(path: SkPath, op: PathOp) {\n return this.ref.op(JsiSkPath.fromValue(path), ckEnum(op));\n }\n\n simplify() {\n return this.ref.simplify();\n }\n\n toSVGString() {\n return this.ref.toSVGString();\n }\n\n trim(startT: number, stopT: number, isComplement: boolean) {\n const result = this.ref.trim(startT, stopT, isComplement);\n return result === null ? result : this;\n }\n\n transform(m3: SkMatrix) {\n this.ref.transform(JsiSkMatrix.fromValue(m3));\n }\n\n interpolate(end: SkPath, t: number) {\n const path = this.CanvasKit.Path.MakeFromPathInterpolation(\n this.ref,\n JsiSkPath.fromValue(end),\n t\n );\n if (path === null) {\n return null;\n }\n return new JsiSkPath(this.CanvasKit, path);\n }\n\n isInterpolatable(path2: SkPath): boolean {\n return this.CanvasKit.Path.CanInterpolate(\n this.ref,\n JsiSkPath.fromValue(path2)\n );\n }\n\n toCmds() {\n const cmds = this.ref.toCmds();\n const result = cmds.reduce<PathCommand[]>((acc, cmd, i) => {\n if (i === 0) {\n acc.push([]);\n }\n const current = acc[acc.length - 1];\n if (current.length === 0) {\n current.push(cmd);\n const length = CommandCount[current[0] as PathVerb];\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n } else {\n const length = CommandCount[current[0] as PathVerb];\n if (current.length < length) {\n current.push(cmd);\n }\n if (current.length === length && i !== cmds.length - 1) {\n acc.push([]);\n }\n }\n return acc;\n }, []);\n return result;\n }\n}\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,UAAzB;AAaA,SAASC,MAAT,EAAiBC,UAAjB,EAA6BC,OAA7B,QAA4C,QAA5C;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,WAAT,QAA4B,eAA5B;AAEA,MAAMC,YAAY,GAAG;EACnB,CAACR,QAAQ,CAACS,IAAV,GAAiB,CADE;EAEnB,CAACT,QAAQ,CAACU,IAAV,GAAiB,CAFE;EAGnB,CAACV,QAAQ,CAACW,IAAV,GAAiB,CAHE;EAInB,CAACX,QAAQ,CAACY,KAAV,GAAkB,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,CAAS,EAAT;MACD;;MACD,MAAMC,OAAO,GAAGJ,GAAG,CAACA,GAAG,CAACK,MAAJ,GAAa,CAAd,CAAnB;;MACA,IAAID,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;QACxBD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACA,MAAMI,MAAM,GAAGxI,YAAY,CAACuI,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF,CAND,MAMO;QACL,MAAME,MAAM,GAAGxI,YAAY,CAACuI,OAAO,CAAC,CAAD,CAAR,CAA3B;;QACA,IAAIA,OAAO,CAACC,MAAR,GAAiBA,MAArB,EAA6B;UAC3BD,OAAO,CAACD,IAAR,CAAaF,GAAb;QACD;;QACD,IAAIG,OAAO,CAACC,MAAR,KAAmBA,MAAnB,IAA6BH,CAAC,KAAKJ,IAAI,CAACO,MAAL,GAAc,CAArD,EAAwD;UACtDL,GAAG,CAACG,IAAJ,CAAS,EAAT;QACD;MACF;;MACD,OAAOH,GAAP;IACD,CArBc,EAqBZ,EArBY,CAAf;IAsBA,OAAO7F,MAAP;EACD;;AAlVuE"}
@@ -9,7 +9,20 @@ export class JsiSkRRect extends BaseHostObject {
9
9
  return CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect.rect), rect.rx, rect.ry);
10
10
  }
11
11
 
12
- constructor(CanvasKit, ref) {
12
+ constructor(CanvasKit, rect, rx, ry) {
13
+ // based on https://github.com/google/skia/blob/main/src/core/SkRRect.cpp#L51
14
+ if (rx === Infinity || ry === Infinity) {
15
+ rx = ry = 0;
16
+ }
17
+
18
+ if (rect.width < rx + rx || rect.height < ry + ry) {
19
+ // At most one of these two divides will be by zero, and neither numerator is zero.
20
+ const scale = Math.min(rect.width / (rx + rx), rect.height / (ry + ry));
21
+ rx *= scale;
22
+ ry *= scale;
23
+ }
24
+
25
+ const ref = CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry);
13
26
  super(CanvasKit, ref, "RRect");
14
27
  }
15
28
 
@@ -1 +1 @@
1
- {"version":3,"names":["BaseHostObject","JsiSkRect","JsiSkRRect","fromValue","CanvasKit","rect","ref","RRectXY","rx","ry","constructor","Float32Array","of"],"sources":["JsiSkRRect.ts"],"sourcesContent":["import type { CanvasKit, RRect } from \"canvaskit-wasm\";\n\nimport type { SkRRect } from \"../types\";\n\nimport { BaseHostObject } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkRRect\n extends BaseHostObject<RRect, \"RRect\">\n implements SkRRect\n{\n static fromValue(CanvasKit: CanvasKit, rect: SkRRect) {\n if (rect instanceof JsiSkRect) {\n return rect.ref;\n }\n return CanvasKit.RRectXY(\n JsiSkRect.fromValue(CanvasKit, rect.rect),\n rect.rx,\n rect.ry\n );\n }\n\n constructor(CanvasKit: CanvasKit, ref: RRect) {\n super(CanvasKit, ref, \"RRect\");\n }\n\n get rx() {\n return this.ref[4];\n }\n\n get ry() {\n return this.ref[5];\n }\n\n get rect() {\n return new JsiSkRect(\n this.CanvasKit,\n Float32Array.of(this.ref[0], this.ref[1], this.ref[2], this.ref[3])\n );\n }\n}\n"],"mappings":"AAIA,SAASA,cAAT,QAA+B,QAA/B;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,OAAO,MAAMC,UAAN,SACGF,cADH,CAGP;EACkB,OAATG,SAAS,CAACC,SAAD,EAAuBC,IAAvB,EAAsC;IACpD,IAAIA,IAAI,YAAYJ,SAApB,EAA+B;MAC7B,OAAOI,IAAI,CAACC,GAAZ;IACD;;IACD,OAAOF,SAAS,CAACG,OAAV,CACLN,SAAS,CAACE,SAAV,CAAoBC,SAApB,EAA+BC,IAAI,CAACA,IAApC,CADK,EAELA,IAAI,CAACG,EAFA,EAGLH,IAAI,CAACI,EAHA,CAAP;EAKD;;EAEDC,WAAW,CAACN,SAAD,EAAuBE,GAAvB,EAAmC;IAC5C,MAAMF,SAAN,EAAiBE,GAAjB,EAAsB,OAAtB;EACD;;EAEK,IAAFE,EAAE,GAAG;IACP,OAAO,KAAKF,GAAL,CAAS,CAAT,CAAP;EACD;;EAEK,IAAFG,EAAE,GAAG;IACP,OAAO,KAAKH,GAAL,CAAS,CAAT,CAAP;EACD;;EAEO,IAAJD,IAAI,GAAG;IACT,OAAO,IAAIJ,SAAJ,CACL,KAAKG,SADA,EAELO,YAAY,CAACC,EAAb,CAAgB,KAAKN,GAAL,CAAS,CAAT,CAAhB,EAA6B,KAAKA,GAAL,CAAS,CAAT,CAA7B,EAA0C,KAAKA,GAAL,CAAS,CAAT,CAA1C,EAAuD,KAAKA,GAAL,CAAS,CAAT,CAAvD,CAFK,CAAP;EAID;;AA7BH"}
1
+ {"version":3,"names":["BaseHostObject","JsiSkRect","JsiSkRRect","fromValue","CanvasKit","rect","ref","RRectXY","rx","ry","constructor","Infinity","width","height","scale","Math","min","Float32Array","of"],"sources":["JsiSkRRect.ts"],"sourcesContent":["import type { CanvasKit, RRect } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkRRect } from \"../types\";\n\nimport { BaseHostObject } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkRRect\n extends BaseHostObject<RRect, \"RRect\">\n implements SkRRect\n{\n static fromValue(CanvasKit: CanvasKit, rect: SkRRect) {\n if (rect instanceof JsiSkRect) {\n return rect.ref;\n }\n return CanvasKit.RRectXY(\n JsiSkRect.fromValue(CanvasKit, rect.rect),\n rect.rx,\n rect.ry\n );\n }\n\n constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number) {\n // based on https://github.com/google/skia/blob/main/src/core/SkRRect.cpp#L51\n if (rx === Infinity || ry === Infinity) {\n rx = ry = 0;\n }\n if (rect.width < rx + rx || rect.height < ry + ry) {\n // At most one of these two divides will be by zero, and neither numerator is zero.\n const scale = Math.min(rect.width / (rx + rx), rect.height / (ry + ry));\n rx *= scale;\n ry *= scale;\n }\n const ref = CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry);\n super(CanvasKit, ref, \"RRect\");\n }\n\n get rx() {\n return this.ref[4];\n }\n\n get ry() {\n return this.ref[5];\n }\n\n get rect() {\n return new JsiSkRect(\n this.CanvasKit,\n Float32Array.of(this.ref[0], this.ref[1], this.ref[2], this.ref[3])\n );\n }\n}\n"],"mappings":"AAIA,SAASA,cAAT,QAA+B,QAA/B;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,OAAO,MAAMC,UAAN,SACGF,cADH,CAGP;EACkB,OAATG,SAAS,CAACC,SAAD,EAAuBC,IAAvB,EAAsC;IACpD,IAAIA,IAAI,YAAYJ,SAApB,EAA+B;MAC7B,OAAOI,IAAI,CAACC,GAAZ;IACD;;IACD,OAAOF,SAAS,CAACG,OAAV,CACLN,SAAS,CAACE,SAAV,CAAoBC,SAApB,EAA+BC,IAAI,CAACA,IAApC,CADK,EAELA,IAAI,CAACG,EAFA,EAGLH,IAAI,CAACI,EAHA,CAAP;EAKD;;EAEDC,WAAW,CAACN,SAAD,EAAuBC,IAAvB,EAAqCG,EAArC,EAAiDC,EAAjD,EAA6D;IACtE;IACA,IAAID,EAAE,KAAKG,QAAP,IAAmBF,EAAE,KAAKE,QAA9B,EAAwC;MACtCH,EAAE,GAAGC,EAAE,GAAG,CAAV;IACD;;IACD,IAAIJ,IAAI,CAACO,KAAL,GAAaJ,EAAE,GAAGA,EAAlB,IAAwBH,IAAI,CAACQ,MAAL,GAAcJ,EAAE,GAAGA,EAA/C,EAAmD;MACjD;MACA,MAAMK,KAAK,GAAGC,IAAI,CAACC,GAAL,CAASX,IAAI,CAACO,KAAL,IAAcJ,EAAE,GAAGA,EAAnB,CAAT,EAAiCH,IAAI,CAACQ,MAAL,IAAeJ,EAAE,GAAGA,EAApB,CAAjC,CAAd;MACAD,EAAE,IAAIM,KAAN;MACAL,EAAE,IAAIK,KAAN;IACD;;IACD,MAAMR,GAAG,GAAGF,SAAS,CAACG,OAAV,CAAkBN,SAAS,CAACE,SAAV,CAAoBC,SAApB,EAA+BC,IAA/B,CAAlB,EAAwDG,EAAxD,EAA4DC,EAA5D,CAAZ;IACA,MAAML,SAAN,EAAiBE,GAAjB,EAAsB,OAAtB;EACD;;EAEK,IAAFE,EAAE,GAAG;IACP,OAAO,KAAKF,GAAL,CAAS,CAAT,CAAP;EACD;;EAEK,IAAFG,EAAE,GAAG;IACP,OAAO,KAAKH,GAAL,CAAS,CAAT,CAAP;EACD;;EAEO,IAAJD,IAAI,GAAG;IACT,OAAO,IAAIJ,SAAJ,CACL,KAAKG,SADA,EAELa,YAAY,CAACC,EAAb,CAAgB,KAAKZ,GAAL,CAAS,CAAT,CAAhB,EAA6B,KAAKA,GAAL,CAAS,CAAT,CAA7B,EAA0C,KAAKA,GAAL,CAAS,CAAT,CAA1C,EAAuD,KAAKA,GAAL,CAAS,CAAT,CAAvD,CAFK,CAAP;EAID;;AAxCH"}
@@ -30,7 +30,7 @@ export const JsiSkApi = CanvasKit => ({
30
30
  RuntimeShaderBuilder: _ => {
31
31
  throw new Error("Not implemented on React Native Web");
32
32
  },
33
- RRectXY: (rect, rx, ry) => new JsiSkRRect(CanvasKit, CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry)),
33
+ RRectXY: (rect, rx, ry) => new JsiSkRRect(CanvasKit, rect, rx, ry),
34
34
  RSXform: (scos, ssin, tx, ty) => new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),
35
35
  Color,
36
36
  ContourMeasureIter: (path, forceClosed, resScale) => new JsiSkContourMeasureIter(CanvasKit, new CanvasKit.ContourMeasureIter(JsiSkPath.fromValue(path), forceClosed, resScale)),
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","fromValue","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","XYWHRect","width","height","Surface"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(\n CanvasKit,\n CanvasKit.RRectXY(JsiSkRect.fromValue(CanvasKit, rect), rx, ry)\n ),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA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kPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","fromValue","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","XYWHRect","width","height","Surface"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B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bc,SAA3B,CAlD2C;EAmDvDuC,aAAa,EAAE,IAAIpD,yBAAJ,CAA8Ba,SAA9B,CAnDwC;EAoDvDwC,WAAW,EAAE,IAAIpD,uBAAJ,CAA4BY,SAA5B,CApD0C;EAqDvDyC,MAAM,EAAE,IAAIpD,kBAAJ,CAAuBW,SAAvB,CArD+C;EAsDvD0C,UAAU,EAAE,IAAIpD,sBAAJ,CAA2BU,SAA3B,CAtD2C;EAuDvDJ,YAAY,EAAEA,YAAY,CAAC+C,IAAb,CAAkB,IAAlB,EAAwB3C,SAAxB,CAvDyC;EAwDvD4C,IAAI,EAAE,IAAIrD,gBAAJ,CAAqBS,SAArB,CAxDiD;EAyDvD6C,KAAK,EAAE,IAAIrD,iBAAJ,CAAsBQ,SAAtB,CAzDgD;EA0DvD8C,GAAG,EAAE,IAAIrD,eAAJ,CAAoBO,SAApB,CA1DkD;EA2DvD+C,QAAQ,EAAE,IAAIrD,oBAAJ,CAAyBM,SAAzB,CA3D6C;EA4DvDgD,QAAQ,EAAE,CAAC9C,CAAD,EAAYC,CAAZ,EAAuB8C,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAI5E,SAAJ,CAAc0B,SAAd,EAAyBA,SAAS,CAACgD,QAAV,CAAmB9C,CAAnB,EAAsBC,CAAtB,EAAyB8C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CA9DsD;EA+DvDC,OAAO,EAAE,IAAI3E,mBAAJ,CAAwBwB,SAAxB;AA/D8C,CAAjC,CAAjB"}
@@ -1,14 +1,11 @@
1
1
  import React from "react";
2
- import type { RefObject, ReactNode, ComponentProps } from "react";
3
- import ReactReconciler from "react-reconciler";
2
+ import type { RefObject, ReactNode } from "react";
4
3
  import { SkiaDomView } from "../views";
5
- import type { TouchHandler } from "../views";
6
- import { Container } from "./Container";
7
- export declare const skiaReconciler: ReactReconciler.Reconciler<Container, import("..").Node<unknown>, import("..").Node<unknown>, import("..").Node<unknown>, import("..").Node<unknown>>;
4
+ import type { TouchHandler, SkiaBaseViewProps } from "../views";
8
5
  export declare const useCanvasRef: () => React.RefObject<SkiaDomView>;
9
- export interface CanvasProps extends ComponentProps<typeof SkiaDomView> {
6
+ export interface CanvasProps extends SkiaBaseViewProps {
10
7
  ref?: RefObject<SkiaDomView>;
11
8
  children: ReactNode;
12
9
  onTouch?: TouchHandler;
13
10
  }
14
- export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "children" | "style" | "mode" | "debug" | "onSize" | "root" | "onTouch" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors"> & React.RefAttributes<SkiaDomView>>;
11
+ export declare const Canvas: React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;
@@ -1,9 +1,6 @@
1
- import type { RefObject } from "react";
2
- import type { DrawingInfo, SkiaView } from "../views";
3
- import type { Skia, Vector } from "../skia/types";
1
+ import type { DrawingInfo } from "../views";
2
+ import type { Skia } from "../skia/types";
4
3
  import type { DrawingContext as DOMDrawingContext } from "../dom/types";
5
4
  export interface DrawingContext extends Omit<DrawingInfo, "touches">, DOMDrawingContext {
6
- center: Vector;
7
- ref: RefObject<SkiaView>;
8
5
  Skia: Skia;
9
6
  }
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from "react";
2
+ import type { Skia } from "../skia/types";
3
+ import type { SkiaValue } from "../values/types";
4
+ declare type RegisterValues = (values: Array<SkiaValue<unknown>>) => () => void;
5
+ export declare class SkiaRoot {
6
+ private root;
7
+ private container;
8
+ constructor(Skia: Skia, registerValues?: RegisterValues, redraw?: () => void);
9
+ render(element: ReactNode): void;
10
+ unmount(): void;
11
+ get dom(): import("..").RenderNode<import("..").GroupProps>;
12
+ }
13
+ export {};
@@ -348,6 +348,19 @@ export interface SkPath extends SkJSIInstance<"Path"> {
348
348
  * @param isCCW
349
349
  */
350
350
  addRRect(rrect: SkRRect, isCCW?: boolean): SkPath;
351
+ /** Appends src to SkPath, transformed by matrix. Transformed curves may have
352
+ different verbs, SkPoint, and conic weights.
353
+
354
+ If mode is kAppend_AddPathMode, src verb array, SkPoint array, and conic
355
+ weights are added unaltered. If mode is kExtend_AddPathMode, add line
356
+ before appending verbs, SkPoint, and conic weights.
357
+
358
+ @param src SkPath verbs, SkPoint, and conic weights to add
359
+ @param matrix transform applied to src
360
+ @param extend extends path with line if true
361
+ @return reference to SkPath
362
+ */
363
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): SkPath;
351
364
  /**
352
365
  * Returns the Point at index in Point array. Valid range for index is
353
366
  * 0 to countPoints() - 1.
@@ -5,6 +5,7 @@ import { JsiSkPoint } from "./JsiSkPoint";
5
5
  import { JsiSkRect } from "./JsiSkRect";
6
6
  export declare class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
7
7
  constructor(CanvasKit: CanvasKit, ref: Path);
8
+ addPath(src: SkPath, matrix?: SkMatrix, extend?: boolean): this;
8
9
  addArc(oval: SkRect, startAngleInDegrees: number, sweepAngleInDegrees: number): this;
9
10
  addOval(oval: SkRect, isCCW?: boolean, startIndex?: number): this;
10
11
  countPoints(): number;
@@ -1,10 +1,10 @@
1
1
  import type { CanvasKit, RRect } from "canvaskit-wasm";
2
- import type { SkRRect } from "../types";
2
+ import type { SkRect, SkRRect } from "../types";
3
3
  import { BaseHostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
5
  export declare class JsiSkRRect extends BaseHostObject<RRect, "RRect"> implements SkRRect {
6
6
  static fromValue(CanvasKit: CanvasKit, rect: SkRRect): Float32Array;
7
- constructor(CanvasKit: CanvasKit, ref: RRect);
7
+ constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number);
8
8
  get rx(): number;
9
9
  get ry(): number;
10
10
  get rect(): JsiSkRect;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.166",
10
+ "version": "0.1.167",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -10,11 +10,9 @@ export const processTransformProps = (m3: SkMatrix, props: TransformProps) => {
10
10
  m3.concat(matrix);
11
11
  m3.translate(-origin.x, -origin.y);
12
12
  } else {
13
- m3.identity();
14
13
  m3.concat(matrix);
15
14
  }
16
15
  } else if (transform) {
17
- m3.identity();
18
16
  if (origin) {
19
17
  m3.translate(origin.x, origin.y);
20
18
  }
@@ -79,8 +79,8 @@ export class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {
79
79
  m3.scale(sx.scaleX, sy.scaleY);
80
80
  }
81
81
  const lm = this.Skia.Matrix();
82
- processTransformProps(lm, imageShaderProps);
83
82
  lm.concat(m3);
83
+ processTransformProps(lm, imageShaderProps);
84
84
  return image.makeShaderOptions(
85
85
  TileMode[enumKey(tx)],
86
86
  TileMode[enumKey(ty)],
@@ -8,48 +8,20 @@ import React, {
8
8
  import type {
9
9
  RefObject,
10
10
  ReactNode,
11
- ComponentProps,
12
11
  MutableRefObject,
13
12
  ForwardedRef,
14
13
  } from "react";
15
- import type { OpaqueRoot } from "react-reconciler";
16
- import ReactReconciler from "react-reconciler";
17
14
 
18
15
  import { SkiaDomView } from "../views";
19
- import type { TouchHandler } from "../views";
20
16
  import { Skia } from "../skia/Skia";
21
- import type { SkiaValue } from "../values";
17
+ import type { TouchHandler, SkiaBaseViewProps } from "../views";
18
+ import type { SkiaValue } from "../values/types";
22
19
 
23
- import { debug as hostDebug, skHostConfig } from "./HostConfig";
24
- // import { debugTree } from "./nodes";
25
- import { Container } from "./Container";
26
- import { DependencyManager } from "./DependencyManager";
27
-
28
- export const skiaReconciler = ReactReconciler(skHostConfig);
29
-
30
- skiaReconciler.injectIntoDevTools({
31
- bundleType: 1,
32
- version: "0.0.1",
33
- rendererPackageName: "react-native-skia",
34
- });
35
-
36
- const render = (element: ReactNode, root: OpaqueRoot, container: Container) => {
37
- skiaReconciler.updateContainer(element, root, null, () => {
38
- hostDebug("updateContainer");
39
- container.depMgr.update();
40
- });
41
- };
20
+ import { SkiaRoot } from "./Reconciler";
42
21
 
43
22
  export const useCanvasRef = () => useRef<SkiaDomView>(null);
44
23
 
45
- const createDependencyManager = (
46
- registerValues: (values: Array<SkiaValue<unknown>>) => () => void
47
- ) =>
48
- global.SkiaDomApi && global.SkiaDomApi.DependencyManager
49
- ? global.SkiaDomApi.DependencyManager(registerValues)
50
- : new DependencyManager(registerValues);
51
-
52
- export interface CanvasProps extends ComponentProps<typeof SkiaDomView> {
24
+ export interface CanvasProps extends SkiaBaseViewProps {
53
25
  ref?: RefObject<SkiaDomView>;
54
26
  children: ReactNode;
55
27
  onTouch?: TouchHandler;
@@ -75,48 +47,27 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
75
47
  },
76
48
  [ref]
77
49
  );
78
-
79
- const container = useMemo(() => {
80
- return new Container(
81
- Skia,
82
- createDependencyManager(registerValues),
83
- redraw
84
- );
85
- }, [redraw, registerValues]);
86
-
87
50
  const root = useMemo(
88
- () =>
89
- skiaReconciler.createContainer(
90
- container,
91
- 0,
92
- null,
93
- true,
94
- null,
95
- "",
96
- console.error,
97
- null
98
- ),
99
- [container]
51
+ () => new SkiaRoot(Skia, registerValues, redraw),
52
+ [redraw, registerValues]
100
53
  );
101
54
 
102
55
  // Render effect
103
56
  useEffect(() => {
104
- render(children, root, container);
105
- }, [children, root, redraw, container]);
57
+ root.render(children);
58
+ }, [children, root, redraw]);
106
59
 
107
60
  useEffect(() => {
108
61
  return () => {
109
- skiaReconciler.updateContainer(null, root, null, () => {
110
- container.depMgr.remove();
111
- });
62
+ root.unmount();
112
63
  };
113
- }, [container, root]);
64
+ }, [root]);
114
65
 
115
66
  return (
116
67
  <SkiaDomView
117
68
  ref={ref}
118
69
  style={style}
119
- root={container.root}
70
+ root={root.dom}
120
71
  onTouch={onTouch}
121
72
  onSize={onSize}
122
73
  mode={mode}
@@ -125,7 +76,7 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
125
76
  />
126
77
  );
127
78
  }
128
- );
79
+ ) as React.FC<CanvasProps & React.RefAttributes<SkiaDomView>>;
129
80
 
130
81
  /**
131
82
  * Combines a list of refs into a single ref. This can be used to provide