@shopify/react-native-skia 0.1.230 → 0.1.231
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +1 -0
- package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.cpp +2 -2
- package/cpp/api/JsiSkAnimatedImage.h +1 -1
- package/cpp/api/JsiSkDataFactory.h +6 -6
- package/cpp/api/JsiSkImage.h +4 -4
- package/cpp/api/JsiSkPath.h +1 -1
- package/cpp/api/JsiSkRRect.h +30 -3
- package/cpp/api/third_party/base64.cpp +153 -0
- package/cpp/api/third_party/base64.h +50 -0
- package/cpp/jsi/JsiPromises.h +1 -1
- package/cpp/rnskia/dom/props/FontProp.h +4 -1
- package/cpp/rnskia/dom/props/RRectProp.h +50 -0
- package/ios/RNSkia-iOS/SkiaMetalSurfaceFactory.mm +1 -1
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +2 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.d.ts +1 -1
- package/lib/commonjs/dom/nodes/drawings/RRectNode.d.ts +3 -3
- package/lib/commonjs/dom/nodes/drawings/RRectNode.js.map +1 -1
- package/lib/commonjs/dom/types/Common.d.ts +2 -2
- package/lib/commonjs/dom/types/Common.js.map +1 -1
- package/lib/commonjs/headless/index.d.ts +3 -1
- package/lib/commonjs/headless/index.js +12 -6
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/skia/types/Canvas.d.ts +4 -4
- package/lib/commonjs/skia/types/Canvas.js.map +1 -1
- package/lib/commonjs/skia/types/Path/Path.d.ts +2 -2
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/RRect.d.ts +9 -0
- package/lib/commonjs/skia/types/RRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +4 -4
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.d.ts +2 -2
- package/lib/commonjs/skia/web/JsiSkRRect.js +4 -0
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +2 -1
- package/lib/module/dom/nodes/datatypes/Rect.d.ts +1 -1
- package/lib/module/dom/nodes/drawings/RRectNode.d.ts +3 -3
- package/lib/module/dom/nodes/drawings/RRectNode.js.map +1 -1
- package/lib/module/dom/types/Common.d.ts +2 -2
- package/lib/module/dom/types/Common.js.map +1 -1
- package/lib/module/headless/index.d.ts +3 -1
- package/lib/module/headless/index.js +5 -3
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/skia/types/Canvas.d.ts +4 -4
- package/lib/module/skia/types/Canvas.js.map +1 -1
- package/lib/module/skia/types/Path/Path.d.ts +2 -2
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/RRect.d.ts +9 -0
- package/lib/module/skia/types/RRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.d.ts +4 -4
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.d.ts +2 -2
- package/lib/module/skia/web/JsiSkRRect.js +4 -0
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -1
- package/lib/typescript/src/dom/nodes/datatypes/Rect.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/drawings/RRectNode.d.ts +3 -3
- package/lib/typescript/src/dom/types/Common.d.ts +2 -2
- package/lib/typescript/src/headless/index.d.ts +3 -1
- package/lib/typescript/src/skia/types/Canvas.d.ts +4 -4
- package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -2
- package/lib/typescript/src/skia/types/RRect.d.ts +9 -0
- package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +4 -4
- package/lib/typescript/src/skia/web/JsiSkPath.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +5 -5
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/dom/nodes/drawings/RRectNode.ts +2 -2
- package/src/dom/types/Common.ts +2 -1
- package/src/headless/index.ts +7 -3
- package/src/skia/types/Canvas.ts +4 -4
- package/src/skia/types/Path/Path.ts +2 -2
- package/src/skia/types/RRect.ts +11 -0
- package/src/skia/web/JsiSkCanvas.ts +4 -4
- package/src/skia/web/JsiSkPath.ts +2 -2
- package/src/skia/web/JsiSkRRect.ts +23 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["BaseHostObject","JsiSkRect","JsiSkRRect","fromValue","CanvasKit","rect","ref","
|
1
|
+
{"version":3,"names":["BaseHostObject","JsiSkRect","JsiSkRRect","fromValue","CanvasKit","rect","ref","Float32Array","of","x","y","width","height","topLeft","topRight","bottomRight","bottomLeft","RRectXY","rx","ry","constructor","Infinity","scale","Math","min"],"sources":["JsiSkRRect.ts"],"sourcesContent":["import type { CanvasKit, RRect } from \"canvaskit-wasm\";\n\nimport type { InputRRect, 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 dispose = () => {\n // Float32Array\n };\n\n static fromValue(CanvasKit: CanvasKit, rect: InputRRect) {\n if (rect instanceof JsiSkRect) {\n return rect.ref;\n }\n if (\n \"topLeft\" in rect &&\n \"topRight\" in rect &&\n \"bottomRight\" in rect &&\n \"bottomLeft\" in rect\n ) {\n return Float32Array.of(\n rect.rect.x,\n rect.rect.y,\n rect.rect.x + rect.rect.width,\n rect.rect.y + rect.rect.height,\n rect.topLeft.x,\n rect.topLeft.y,\n rect.topRight.x,\n rect.topRight.y,\n rect.bottomRight.x,\n rect.bottomRight.y,\n rect.bottomLeft.x,\n rect.bottomLeft.y\n );\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;EAKkB,OAATG,SAAS,CAACC,SAAD,EAAuBC,IAAvB,EAAyC;IACvD,IAAIA,IAAI,YAAYJ,SAApB,EAA+B;MAC7B,OAAOI,IAAI,CAACC,GAAZ;IACD;;IACD,IACE,aAAaD,IAAb,IACA,cAAcA,IADd,IAEA,iBAAiBA,IAFjB,IAGA,gBAAgBA,IAJlB,EAKE;MACA,OAAOE,YAAY,CAACC,EAAb,CACLH,IAAI,CAACA,IAAL,CAAUI,CADL,EAELJ,IAAI,CAACA,IAAL,CAAUK,CAFL,EAGLL,IAAI,CAACA,IAAL,CAAUI,CAAV,GAAcJ,IAAI,CAACA,IAAL,CAAUM,KAHnB,EAILN,IAAI,CAACA,IAAL,CAAUK,CAAV,GAAcL,IAAI,CAACA,IAAL,CAAUO,MAJnB,EAKLP,IAAI,CAACQ,OAAL,CAAaJ,CALR,EAMLJ,IAAI,CAACQ,OAAL,CAAaH,CANR,EAOLL,IAAI,CAACS,QAAL,CAAcL,CAPT,EAQLJ,IAAI,CAACS,QAAL,CAAcJ,CART,EASLL,IAAI,CAACU,WAAL,CAAiBN,CATZ,EAULJ,IAAI,CAACU,WAAL,CAAiBL,CAVZ,EAWLL,IAAI,CAACW,UAAL,CAAgBP,CAXX,EAYLJ,IAAI,CAACW,UAAL,CAAgBN,CAZX,CAAP;IAcD;;IACD,OAAON,SAAS,CAACa,OAAV,CACLhB,SAAS,CAACE,SAAV,CAAoBC,SAApB,EAA+BC,IAAI,CAACA,IAApC,CADK,EAELA,IAAI,CAACa,EAFA,EAGLb,IAAI,CAACc,EAHA,CAAP;EAKD;;EAEDC,WAAW,CAAChB,SAAD,EAAuBC,IAAvB,EAAqCa,EAArC,EAAiDC,EAAjD,EAA6D;IACtE;IACA,IAAID,EAAE,KAAKG,QAAP,IAAmBF,EAAE,KAAKE,QAA9B,EAAwC;MACtCH,EAAE,GAAGC,EAAE,GAAG,CAAV;IACD;;IACD,IAAId,IAAI,CAACM,KAAL,GAAaO,EAAE,GAAGA,EAAlB,IAAwBb,IAAI,CAACO,MAAL,GAAcO,EAAE,GAAGA,EAA/C,EAAmD;MACjD;MACA,MAAMG,KAAK,GAAGC,IAAI,CAACC,GAAL,CAASnB,IAAI,CAACM,KAAL,IAAcO,EAAE,GAAGA,EAAnB,CAAT,EAAiCb,IAAI,CAACO,MAAL,IAAeO,EAAE,GAAGA,EAApB,CAAjC,CAAd;MACAD,EAAE,IAAII,KAAN;MACAH,EAAE,IAAIG,KAAN;IACD;;IACD,MAAMhB,GAAG,GAAGF,SAAS,CAACa,OAAV,CAAkBhB,SAAS,CAACE,SAAV,CAAoBC,SAApB,EAA+BC,IAA/B,CAAlB,EAAwDa,EAAxD,EAA4DC,EAA5D,CAAZ;IACA,MAAMf,SAAN,EAAiBE,GAAjB,EAAsB,OAAtB;;IAZsE,iCApC9D,MAAM,CACd;IACD,CAkCuE;EAavE;;EAEK,IAAFY,EAAE,GAAG;IACP,OAAO,KAAKZ,GAAL,CAAS,CAAT,CAAP;EACD;;EAEK,IAAFa,EAAE,GAAG;IACP,OAAO,KAAKb,GAAL,CAAS,CAAT,CAAP;EACD;;EAEO,IAAJD,IAAI,GAAG;IACT,OAAO,IAAIJ,SAAJ,CACL,KAAKG,SADA,EAELG,YAAY,CAACC,EAAb,CAAgB,KAAKF,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;;AAjEH"}
|
@@ -2,6 +2,7 @@ import type { PathProps, SkDOM, GroupProps, ImageProps, BlurImageFilterProps, Ma
|
|
2
2
|
import type { BlendImageFilterProps, BlendProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, MorphologyImageFilterProps, RuntimeShaderImageFilterProps } from "../types/ImageFilters";
|
3
3
|
import type { CornerPathEffectProps, DashPathEffectProps, DiscretePathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps } from "../types/PathEffects";
|
4
4
|
import type { ParagraphProps } from "../types/Paragraph";
|
5
|
+
import { RRectNode } from "./drawings";
|
5
6
|
import type { NodeContext } from "./Node";
|
6
7
|
export declare class JsiSkDOM implements SkDOM {
|
7
8
|
private ctx;
|
@@ -18,7 +19,7 @@ export declare class JsiSkDOM implements SkDOM {
|
|
18
19
|
Patch(props: PatchProps): import("../types").RenderNode<PatchProps>;
|
19
20
|
Points(props: PointsProps): import("../types").RenderNode<PointsProps>;
|
20
21
|
Rect(props: RectProps): import("./DrawingNode").JsiDrawingNode<RectProps, import("../..").SkRect>;
|
21
|
-
RRect(props: RoundedRectProps): import("./DrawingNode").JsiDrawingNode<RoundedRectProps, import("../..").SkRRect
|
22
|
+
RRect(props: RoundedRectProps): import("./DrawingNode").JsiDrawingNode<RoundedRectProps, import("../..").SkRRect> | RRectNode;
|
22
23
|
Vertices(props: VerticesProps): import("../types").RenderNode<VerticesProps>;
|
23
24
|
Text(props: TextProps): import("../types").RenderNode<TextProps>;
|
24
25
|
TextPath(props: TextPathProps): import("../types").RenderNode<TextPathProps>;
|
@@ -2,4 +2,4 @@ import type { Skia, SkRect, Vector } from "../../../skia/types";
|
|
2
2
|
import type { RectDef, RRectDef } from "../../types";
|
3
3
|
export declare const isEdge: (pos: Vector, b: SkRect) => boolean;
|
4
4
|
export declare const processRect: (Skia: Skia, def: RectDef) => SkRect;
|
5
|
-
export declare const processRRect: (Skia: Skia, def: RRectDef) => import("../../../skia/types").
|
5
|
+
export declare const processRRect: (Skia: Skia, def: RRectDef) => import("../../../skia/types").InputRRect;
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import type { SkRRect } from "../../../skia/types";
|
1
|
+
import type { InputRRect, SkRRect } from "../../../skia/types";
|
2
2
|
import type { DrawingContext, RoundedRectProps } from "../../types";
|
3
3
|
import { JsiDrawingNode } from "../DrawingNode";
|
4
4
|
import type { NodeContext } from "../Node";
|
5
|
-
export declare class RRectNode extends JsiDrawingNode<RoundedRectProps,
|
5
|
+
export declare class RRectNode extends JsiDrawingNode<RoundedRectProps, InputRRect> {
|
6
6
|
rect?: SkRRect;
|
7
7
|
constructor(ctx: NodeContext, props: RoundedRectProps);
|
8
|
-
protected deriveProps():
|
8
|
+
protected deriveProps(): InputRRect;
|
9
9
|
draw({ canvas, paint }: DrawingContext): void;
|
10
10
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ReactNode } from "react";
|
2
|
-
import type { BlendMode, Color, InputMatrix, PaintStyle, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
|
2
|
+
import type { BlendMode, Color, InputMatrix, InputRRect, PaintStyle, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
|
3
3
|
export type SkEnum<T> = Uncapitalize<keyof T extends string ? keyof T : never>;
|
4
4
|
export type PathDef = string | SkPath;
|
5
5
|
export type ClipDef = SkRRect | SkRect | PathDef;
|
@@ -21,7 +21,7 @@ export type RectDef = RectCtor | {
|
|
21
21
|
rect: SkRect;
|
22
22
|
};
|
23
23
|
export type RRectDef = RRectCtor | {
|
24
|
-
rect:
|
24
|
+
rect: InputRRect;
|
25
25
|
};
|
26
26
|
export interface PointCircleDef {
|
27
27
|
c?: Vector;
|
@@ -1,3 +1,5 @@
|
|
1
1
|
import type { ReactNode } from "react";
|
2
|
+
import type { SkSurface } from "../skia";
|
2
3
|
export * from "../renderer/components";
|
3
|
-
export declare const
|
4
|
+
export declare const makeOffscreenSurface: (width: number, height: number) => any;
|
5
|
+
export declare const drawOffscreen: (surface: SkSurface, element: ReactNode) => import("../skia").SkImage;
|
@@ -5,7 +5,7 @@ import type { SkPath } from "./Path";
|
|
5
5
|
import type { SkImage, MipmapMode, FilterMode, ImageInfo } from "./Image";
|
6
6
|
import type { SkSVG } from "./SVG";
|
7
7
|
import type { SkColor } from "./Color";
|
8
|
-
import type {
|
8
|
+
import type { InputRRect } from "./RRect";
|
9
9
|
import type { BlendMode } from "./Paint/BlendMode";
|
10
10
|
import type { SkPoint, PointMode } from "./Point";
|
11
11
|
import type { InputMatrix } from "./Matrix";
|
@@ -202,7 +202,7 @@ export interface SkCanvas {
|
|
202
202
|
* @param rrect
|
203
203
|
* @param paint
|
204
204
|
*/
|
205
|
-
drawRRect(rrect:
|
205
|
+
drawRRect(rrect: InputRRect, paint: SkPaint): void;
|
206
206
|
/**
|
207
207
|
* Draws RRect outer and inner using clip, Matrix, and Paint paint.
|
208
208
|
* outer must contain inner or the drawing is undefined.
|
@@ -210,7 +210,7 @@ export interface SkCanvas {
|
|
210
210
|
* @param inner
|
211
211
|
* @param paint
|
212
212
|
*/
|
213
|
-
drawDRRect(outer:
|
213
|
+
drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint): void;
|
214
214
|
/**
|
215
215
|
* Draws an oval bounded by the given rectangle using the current clip, current matrix,
|
216
216
|
* and the provided paint.
|
@@ -367,7 +367,7 @@ export interface SkCanvas {
|
|
367
367
|
* @param op
|
368
368
|
* @param doAntiAlias
|
369
369
|
*/
|
370
|
-
clipRRect(rrect:
|
370
|
+
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean): void;
|
371
371
|
/**
|
372
372
|
* Replaces current matrix with m premultiplied with the existing matrix.
|
373
373
|
* @param m
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { SkRect } from "../Rect";
|
2
2
|
import type { SkPoint } from "../Point";
|
3
|
-
import type {
|
3
|
+
import type { InputRRect } from "../RRect";
|
4
4
|
import type { StrokeJoin, StrokeCap } from "../Paint";
|
5
5
|
import type { InputMatrix, SkMatrix } from "../Matrix";
|
6
6
|
import type { SkJSIInstance } from "../JsiInstance";
|
@@ -347,7 +347,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
|
|
347
347
|
* @param rrect
|
348
348
|
* @param isCCW
|
349
349
|
*/
|
350
|
-
addRRect(rrect:
|
350
|
+
addRRect(rrect: InputRRect, isCCW?: boolean): SkPath;
|
351
351
|
/** Appends src to SkPath, transformed by matrix. Transformed curves may have
|
352
352
|
different verbs, SkPoint, and conic weights.
|
353
353
|
|
@@ -1,7 +1,16 @@
|
|
1
|
+
import type { SkPoint } from "./Point";
|
1
2
|
import type { SkRect } from "./Rect";
|
2
3
|
export interface SkRRect {
|
3
4
|
readonly rect: SkRect;
|
4
5
|
readonly rx: number;
|
5
6
|
readonly ry: number;
|
6
7
|
}
|
8
|
+
export interface NonUniformRRect {
|
9
|
+
readonly rect: SkRect;
|
10
|
+
readonly topLeft: SkPoint;
|
11
|
+
readonly topRight: SkPoint;
|
12
|
+
readonly bottomRight: SkPoint;
|
13
|
+
readonly bottomLeft: SkPoint;
|
14
|
+
}
|
15
|
+
export type InputRRect = SkRRect | NonUniformRRect;
|
7
16
|
export declare const isRRect: (def: SkRect | SkRRect) => def is SkRRect;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Canvas, CanvasKit } from "canvaskit-wasm";
|
2
|
-
import type { BlendMode, ClipOp, FilterMode, MipmapMode, PointMode, SaveLayerFlag, ImageInfo, SkCanvas, SkColor, SkFont, SkImage, SkImageFilter, SkMatrix, SkPaint, SkPath, SkPicture, SkPoint, SkRect,
|
2
|
+
import type { BlendMode, ClipOp, FilterMode, MipmapMode, PointMode, SaveLayerFlag, ImageInfo, SkCanvas, SkColor, SkFont, SkImage, SkImageFilter, SkMatrix, SkPaint, SkPath, SkPicture, SkPoint, SkRect, InputRRect, SkSVG, SkTextBlob, SkVertices } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
4
|
export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements SkCanvas {
|
5
5
|
constructor(CanvasKit: CanvasKit, ref: Canvas);
|
@@ -20,8 +20,8 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
20
20
|
restoreToCount(saveCount: number): void;
|
21
21
|
drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;
|
22
22
|
drawArc(oval: SkRect, startAngle: number, sweepAngle: number, useCenter: boolean, paint: SkPaint): void;
|
23
|
-
drawRRect(rrect:
|
24
|
-
drawDRRect(outer:
|
23
|
+
drawRRect(rrect: InputRRect, paint: SkPaint): void;
|
24
|
+
drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint): void;
|
25
25
|
drawOval(oval: SkRect, paint: SkPaint): void;
|
26
26
|
drawPath(path: SkPath, paint: SkPaint): void;
|
27
27
|
drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont): void;
|
@@ -39,7 +39,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
|
|
39
39
|
clear(color: SkColor): void;
|
40
40
|
clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;
|
41
41
|
clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;
|
42
|
-
clipRRect(rrect:
|
42
|
+
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean): void;
|
43
43
|
concat(m: SkMatrix | number[]): void;
|
44
44
|
drawPicture(skp: SkPicture): void;
|
45
45
|
readPixels(srcX: number, srcY: number, imageInfo: ImageInfo): Float32Array | Uint8Array | null;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { CanvasKit, Path } from "canvaskit-wasm";
|
2
|
-
import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect,
|
2
|
+
import type { FillType, PathCommand, PathOp, SkMatrix, SkPath, SkPoint, SkRect, InputRRect, StrokeOpts } from "../types";
|
3
3
|
import { HostObject } from "./Host";
|
4
4
|
import { JsiSkPoint } from "./JsiSkPoint";
|
5
5
|
import { JsiSkRect } from "./JsiSkRect";
|
@@ -41,7 +41,7 @@ export declare class JsiSkPath extends HostObject<Path, "Path"> implements SkPat
|
|
41
41
|
getFillType(): number;
|
42
42
|
quadTo(x1: number, y1: number, x2: number, y2: number): this;
|
43
43
|
addRect(rect: SkRect, isCCW?: boolean): this;
|
44
|
-
addRRect(rrect:
|
44
|
+
addRRect(rrect: InputRRect, isCCW?: boolean): this;
|
45
45
|
getPoint(index: number): JsiSkPoint;
|
46
46
|
isEmpty(): boolean;
|
47
47
|
isVolatile(): boolean;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { CanvasKit, RRect } from "canvaskit-wasm";
|
2
|
-
import type { SkRect, SkRRect } from "../types";
|
2
|
+
import type { InputRRect, 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
|
dispose: () => void;
|
7
|
-
static fromValue(CanvasKit: CanvasKit, rect:
|
7
|
+
static fromValue(CanvasKit: CanvasKit, rect: InputRRect): Float32Array;
|
8
8
|
constructor(CanvasKit: CanvasKit, rect: SkRect, rx: number, ry: number);
|
9
9
|
get rx(): number;
|
10
10
|
get ry(): number;
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libskottie.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
-
<string>x86_64</string>
|
17
16
|
</array>
|
18
17
|
<key>SupportedPlatform</key>
|
19
18
|
<string>ios</string>
|
20
|
-
<key>SupportedPlatformVariant</key>
|
21
|
-
<string>simulator</string>
|
22
19
|
</dict>
|
23
20
|
<dict>
|
24
21
|
<key>LibraryIdentifier</key>
|
25
|
-
<string>ios-
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
26
23
|
<key>LibraryPath</key>
|
27
24
|
<string>libskottie.a</string>
|
28
25
|
<key>SupportedArchitectures</key>
|
29
26
|
<array>
|
30
27
|
<string>arm64</string>
|
31
28
|
<string>arm64e</string>
|
29
|
+
<string>x86_64</string>
|
32
30
|
</array>
|
33
31
|
<key>SupportedPlatform</key>
|
34
32
|
<string>ios</string>
|
33
|
+
<key>SupportedPlatformVariant</key>
|
34
|
+
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
Binary file
|
package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a
CHANGED
Binary file
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libskshaper.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
-
<string>x86_64</string>
|
17
16
|
</array>
|
18
17
|
<key>SupportedPlatform</key>
|
19
18
|
<string>ios</string>
|
20
|
-
<key>SupportedPlatformVariant</key>
|
21
|
-
<string>simulator</string>
|
22
19
|
</dict>
|
23
20
|
<dict>
|
24
21
|
<key>LibraryIdentifier</key>
|
25
|
-
<string>ios-
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
26
23
|
<key>LibraryPath</key>
|
27
24
|
<string>libskshaper.a</string>
|
28
25
|
<key>SupportedArchitectures</key>
|
29
26
|
<array>
|
30
27
|
<string>arm64</string>
|
31
28
|
<string>arm64e</string>
|
29
|
+
<string>x86_64</string>
|
32
30
|
</array>
|
33
31
|
<key>SupportedPlatform</key>
|
34
32
|
<string>ios</string>
|
33
|
+
<key>SupportedPlatformVariant</key>
|
34
|
+
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -6,32 +6,32 @@
|
|
6
6
|
<array>
|
7
7
|
<dict>
|
8
8
|
<key>LibraryIdentifier</key>
|
9
|
-
<string>ios-
|
9
|
+
<string>ios-arm64_arm64e</string>
|
10
10
|
<key>LibraryPath</key>
|
11
11
|
<string>libsvg.a</string>
|
12
12
|
<key>SupportedArchitectures</key>
|
13
13
|
<array>
|
14
14
|
<string>arm64</string>
|
15
15
|
<string>arm64e</string>
|
16
|
-
<string>x86_64</string>
|
17
16
|
</array>
|
18
17
|
<key>SupportedPlatform</key>
|
19
18
|
<string>ios</string>
|
20
|
-
<key>SupportedPlatformVariant</key>
|
21
|
-
<string>simulator</string>
|
22
19
|
</dict>
|
23
20
|
<dict>
|
24
21
|
<key>LibraryIdentifier</key>
|
25
|
-
<string>ios-
|
22
|
+
<string>ios-arm64_arm64e_x86_64-simulator</string>
|
26
23
|
<key>LibraryPath</key>
|
27
24
|
<string>libsvg.a</string>
|
28
25
|
<key>SupportedArchitectures</key>
|
29
26
|
<array>
|
30
27
|
<string>arm64</string>
|
31
28
|
<string>arm64e</string>
|
29
|
+
<string>x86_64</string>
|
32
30
|
</array>
|
33
31
|
<key>SupportedPlatform</key>
|
34
32
|
<string>ios</string>
|
33
|
+
<key>SupportedPlatformVariant</key>
|
34
|
+
<string>simulator</string>
|
35
35
|
</dict>
|
36
36
|
</array>
|
37
37
|
<key>CFBundlePackageType</key>
|
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import type { SkRRect } from "../../../skia/types";
|
1
|
+
import type { InputRRect, SkRRect } from "../../../skia/types";
|
2
2
|
import type { DrawingContext, RoundedRectProps } from "../../types";
|
3
3
|
import { NodeType } from "../../types";
|
4
4
|
import { processRRect } from "../datatypes";
|
5
5
|
import { JsiDrawingNode } from "../DrawingNode";
|
6
6
|
import type { NodeContext } from "../Node";
|
7
7
|
|
8
|
-
export class RRectNode extends JsiDrawingNode<RoundedRectProps,
|
8
|
+
export class RRectNode extends JsiDrawingNode<RoundedRectProps, InputRRect> {
|
9
9
|
rect?: SkRRect;
|
10
10
|
|
11
11
|
constructor(ctx: NodeContext, props: RoundedRectProps) {
|
package/src/dom/types/Common.ts
CHANGED
@@ -4,6 +4,7 @@ import type {
|
|
4
4
|
BlendMode,
|
5
5
|
Color,
|
6
6
|
InputMatrix,
|
7
|
+
InputRRect,
|
7
8
|
PaintStyle,
|
8
9
|
SkPaint,
|
9
10
|
SkPath,
|
@@ -48,7 +49,7 @@ export interface RRectCtor extends RectCtor {
|
|
48
49
|
}
|
49
50
|
|
50
51
|
export type RectDef = RectCtor | { rect: SkRect };
|
51
|
-
export type RRectDef = RRectCtor | { rect:
|
52
|
+
export type RRectDef = RRectCtor | { rect: InputRRect };
|
52
53
|
|
53
54
|
export interface PointCircleDef {
|
54
55
|
c?: Vector;
|
package/src/headless/index.ts
CHANGED
@@ -6,13 +6,14 @@ import type { ReactNode } from "react";
|
|
6
6
|
import { JsiSkApi } from "../skia/web";
|
7
7
|
import { SkiaRoot } from "../renderer/Reconciler";
|
8
8
|
import { JsiDrawingContext } from "../dom/types";
|
9
|
+
import type { SkSurface } from "../skia";
|
9
10
|
|
10
11
|
export * from "../renderer/components";
|
11
12
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
13
14
|
let Skia: any;
|
14
15
|
|
15
|
-
export const
|
16
|
+
export const makeOffscreenSurface = (width: number, height: number) => {
|
16
17
|
if (!Skia) {
|
17
18
|
Skia = JsiSkApi(CanvasKit);
|
18
19
|
}
|
@@ -20,12 +21,15 @@ export const draw = (element: ReactNode, width: number, height: number) => {
|
|
20
21
|
if (surface === null) {
|
21
22
|
throw new Error("Couldn't create surface!");
|
22
23
|
}
|
24
|
+
return surface;
|
25
|
+
};
|
26
|
+
|
27
|
+
export const drawOffscreen = (surface: SkSurface, element: ReactNode) => {
|
23
28
|
const root = new SkiaRoot(Skia);
|
24
29
|
root.render(element);
|
25
30
|
const canvas = surface.getCanvas();
|
26
31
|
const ctx = new JsiDrawingContext(Skia, canvas);
|
27
32
|
root.dom.render(ctx);
|
28
33
|
surface.flush();
|
29
|
-
|
30
|
-
return image;
|
34
|
+
return surface.makeImageSnapshot();
|
31
35
|
};
|
package/src/skia/types/Canvas.ts
CHANGED
@@ -5,7 +5,7 @@ import type { SkPath } from "./Path";
|
|
5
5
|
import type { SkImage, MipmapMode, FilterMode, ImageInfo } from "./Image";
|
6
6
|
import type { SkSVG } from "./SVG";
|
7
7
|
import type { SkColor } from "./Color";
|
8
|
-
import type {
|
8
|
+
import type { InputRRect } from "./RRect";
|
9
9
|
import type { BlendMode } from "./Paint/BlendMode";
|
10
10
|
import type { SkPoint, PointMode } from "./Point";
|
11
11
|
import type { InputMatrix } from "./Matrix";
|
@@ -278,7 +278,7 @@ export interface SkCanvas {
|
|
278
278
|
* @param rrect
|
279
279
|
* @param paint
|
280
280
|
*/
|
281
|
-
drawRRect(rrect:
|
281
|
+
drawRRect(rrect: InputRRect, paint: SkPaint): void;
|
282
282
|
|
283
283
|
/**
|
284
284
|
* Draws RRect outer and inner using clip, Matrix, and Paint paint.
|
@@ -287,7 +287,7 @@ export interface SkCanvas {
|
|
287
287
|
* @param inner
|
288
288
|
* @param paint
|
289
289
|
*/
|
290
|
-
drawDRRect(outer:
|
290
|
+
drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint): void;
|
291
291
|
|
292
292
|
/**
|
293
293
|
* Draws an oval bounded by the given rectangle using the current clip, current matrix,
|
@@ -479,7 +479,7 @@ export interface SkCanvas {
|
|
479
479
|
* @param op
|
480
480
|
* @param doAntiAlias
|
481
481
|
*/
|
482
|
-
clipRRect(rrect:
|
482
|
+
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean): void;
|
483
483
|
|
484
484
|
/**
|
485
485
|
* Replaces current matrix with m premultiplied with the existing matrix.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { SkRect } from "../Rect";
|
2
2
|
import type { SkPoint } from "../Point";
|
3
|
-
import type {
|
3
|
+
import type { InputRRect } from "../RRect";
|
4
4
|
import type { StrokeJoin, StrokeCap } from "../Paint";
|
5
5
|
import type { InputMatrix, SkMatrix } from "../Matrix";
|
6
6
|
import type { SkJSIInstance } from "../JsiInstance";
|
@@ -439,7 +439,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
|
|
439
439
|
* @param rrect
|
440
440
|
* @param isCCW
|
441
441
|
*/
|
442
|
-
addRRect(rrect:
|
442
|
+
addRRect(rrect: InputRRect, isCCW?: boolean): SkPath;
|
443
443
|
|
444
444
|
/** Appends src to SkPath, transformed by matrix. Transformed curves may have
|
445
445
|
different verbs, SkPoint, and conic weights.
|
package/src/skia/types/RRect.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { SkPoint } from "./Point";
|
1
2
|
import type { SkRect } from "./Rect";
|
2
3
|
|
3
4
|
export interface SkRRect {
|
@@ -6,6 +7,16 @@ export interface SkRRect {
|
|
6
7
|
readonly ry: number;
|
7
8
|
}
|
8
9
|
|
10
|
+
export interface NonUniformRRect {
|
11
|
+
readonly rect: SkRect;
|
12
|
+
readonly topLeft: SkPoint;
|
13
|
+
readonly topRight: SkPoint;
|
14
|
+
readonly bottomRight: SkPoint;
|
15
|
+
readonly bottomLeft: SkPoint;
|
16
|
+
}
|
17
|
+
|
18
|
+
export type InputRRect = SkRRect | NonUniformRRect;
|
19
|
+
|
9
20
|
// We have an issue to check property existence on JSI backed instances
|
10
21
|
export const isRRect = (def: SkRect | SkRRect): def is SkRRect =>
|
11
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -19,7 +19,7 @@ import type {
|
|
19
19
|
SkPicture,
|
20
20
|
SkPoint,
|
21
21
|
SkRect,
|
22
|
-
|
22
|
+
InputRRect,
|
23
23
|
SkSVG,
|
24
24
|
SkTextBlob,
|
25
25
|
SkVertices,
|
@@ -235,14 +235,14 @@ export class JsiSkCanvas
|
|
235
235
|
);
|
236
236
|
}
|
237
237
|
|
238
|
-
drawRRect(rrect:
|
238
|
+
drawRRect(rrect: InputRRect, paint: SkPaint) {
|
239
239
|
this.ref.drawRRect(
|
240
240
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
241
241
|
JsiSkPaint.fromValue(paint)
|
242
242
|
);
|
243
243
|
}
|
244
244
|
|
245
|
-
drawDRRect(outer:
|
245
|
+
drawDRRect(outer: InputRRect, inner: InputRRect, paint: SkPaint) {
|
246
246
|
this.ref.drawDRRect(
|
247
247
|
JsiSkRRect.fromValue(this.CanvasKit, outer),
|
248
248
|
JsiSkRRect.fromValue(this.CanvasKit, inner),
|
@@ -367,7 +367,7 @@ export class JsiSkCanvas
|
|
367
367
|
);
|
368
368
|
}
|
369
369
|
|
370
|
-
clipRRect(rrect:
|
370
|
+
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {
|
371
371
|
this.ref.clipRRect(
|
372
372
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
373
373
|
getEnum(this.CanvasKit.PathOp, op),
|
@@ -9,7 +9,7 @@ import type {
|
|
9
9
|
SkPath,
|
10
10
|
SkPoint,
|
11
11
|
SkRect,
|
12
|
-
|
12
|
+
InputRRect,
|
13
13
|
StrokeOpts,
|
14
14
|
} from "../types";
|
15
15
|
|
@@ -285,7 +285,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
|
|
285
285
|
return this;
|
286
286
|
}
|
287
287
|
|
288
|
-
addRRect(rrect:
|
288
|
+
addRRect(rrect: InputRRect, isCCW?: boolean) {
|
289
289
|
this.ref.addRRect(JsiSkRRect.fromValue(this.CanvasKit, rrect), isCCW);
|
290
290
|
return this;
|
291
291
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { CanvasKit, RRect } from "canvaskit-wasm";
|
2
2
|
|
3
|
-
import type { SkRect, SkRRect } from "../types";
|
3
|
+
import type { InputRRect, SkRect, SkRRect } from "../types";
|
4
4
|
|
5
5
|
import { BaseHostObject } from "./Host";
|
6
6
|
import { JsiSkRect } from "./JsiSkRect";
|
@@ -13,10 +13,31 @@ export class JsiSkRRect
|
|
13
13
|
// Float32Array
|
14
14
|
};
|
15
15
|
|
16
|
-
static fromValue(CanvasKit: CanvasKit, rect:
|
16
|
+
static fromValue(CanvasKit: CanvasKit, rect: InputRRect) {
|
17
17
|
if (rect instanceof JsiSkRect) {
|
18
18
|
return rect.ref;
|
19
19
|
}
|
20
|
+
if (
|
21
|
+
"topLeft" in rect &&
|
22
|
+
"topRight" in rect &&
|
23
|
+
"bottomRight" in rect &&
|
24
|
+
"bottomLeft" in rect
|
25
|
+
) {
|
26
|
+
return Float32Array.of(
|
27
|
+
rect.rect.x,
|
28
|
+
rect.rect.y,
|
29
|
+
rect.rect.x + rect.rect.width,
|
30
|
+
rect.rect.y + rect.rect.height,
|
31
|
+
rect.topLeft.x,
|
32
|
+
rect.topLeft.y,
|
33
|
+
rect.topRight.x,
|
34
|
+
rect.topRight.y,
|
35
|
+
rect.bottomRight.x,
|
36
|
+
rect.bottomRight.y,
|
37
|
+
rect.bottomLeft.x,
|
38
|
+
rect.bottomLeft.y
|
39
|
+
);
|
40
|
+
}
|
20
41
|
return CanvasKit.RRectXY(
|
21
42
|
JsiSkRect.fromValue(CanvasKit, rect.rect),
|
22
43
|
rect.rx,
|