@shopify/react-native-skia 0.1.209 → 0.1.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/cpp/api/JsiSkAnimatedImage.h +60 -0
  2. package/cpp/api/JsiSkAnimatedImageFactory.h +39 -0
  3. package/cpp/api/JsiSkApi.h +4 -0
  4. package/cpp/api/JsiSkFont.h +17 -0
  5. package/cpp/api/JsiSkImage.h +15 -23
  6. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -0
  7. package/lib/commonjs/external/reanimated/moduleWrapper.js +11 -11
  8. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  9. package/lib/commonjs/skia/core/AnimatedImage.d.ts +6 -0
  10. package/lib/commonjs/skia/core/AnimatedImage.js +65 -0
  11. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -0
  12. package/lib/commonjs/skia/core/index.d.ts +1 -0
  13. package/lib/commonjs/skia/core/index.js +13 -0
  14. package/lib/commonjs/skia/core/index.js.map +1 -1
  15. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
  16. package/lib/commonjs/{dom/nodes/PaintContext.js → skia/types/AnimatedImage/AnimatedImage.js} +1 -1
  17. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
  18. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
  19. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js +6 -0
  20. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
  21. package/lib/commonjs/skia/types/AnimatedImage/index.d.ts +2 -0
  22. package/lib/commonjs/skia/types/AnimatedImage/index.js +32 -0
  23. package/lib/commonjs/skia/types/AnimatedImage/index.js.map +1 -0
  24. package/lib/commonjs/skia/types/Font/Font.d.ts +9 -0
  25. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  26. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  27. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  28. package/lib/commonjs/skia/types/index.d.ts +1 -0
  29. package/lib/commonjs/skia/types/index.js +13 -0
  30. package/lib/commonjs/skia/types/index.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkAnimatedImage.d.ts +11 -0
  32. package/lib/commonjs/skia/web/JsiSkAnimatedImage.js +44 -0
  33. package/lib/commonjs/skia/web/JsiSkAnimatedImage.js.map +1 -0
  34. package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
  35. package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js +32 -0
  36. package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
  37. package/lib/commonjs/skia/web/JsiSkFont.d.ts +2 -1
  38. package/lib/commonjs/skia/web/JsiSkFont.js +4 -0
  39. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkia.js +3 -0
  41. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  42. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -0
  43. package/lib/module/external/reanimated/moduleWrapper.js +8 -11
  44. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  45. package/lib/module/skia/core/AnimatedImage.d.ts +6 -0
  46. package/lib/module/skia/core/AnimatedImage.js +49 -0
  47. package/lib/module/skia/core/AnimatedImage.js.map +1 -0
  48. package/lib/module/skia/core/index.d.ts +1 -0
  49. package/lib/module/skia/core/index.js +1 -0
  50. package/lib/module/skia/core/index.js.map +1 -1
  51. package/lib/module/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
  52. package/lib/module/skia/types/AnimatedImage/AnimatedImage.js +2 -0
  53. package/lib/module/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
  54. package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
  55. package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js +2 -0
  56. package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
  57. package/lib/module/skia/types/AnimatedImage/index.d.ts +2 -0
  58. package/lib/module/skia/types/AnimatedImage/index.js +3 -0
  59. package/lib/module/skia/types/AnimatedImage/index.js.map +1 -0
  60. package/lib/module/skia/types/Font/Font.d.ts +9 -0
  61. package/lib/module/skia/types/Font/Font.js.map +1 -1
  62. package/lib/module/skia/types/Skia.d.ts +2 -0
  63. package/lib/module/skia/types/Skia.js.map +1 -1
  64. package/lib/module/skia/types/index.d.ts +1 -0
  65. package/lib/module/skia/types/index.js +1 -0
  66. package/lib/module/skia/types/index.js.map +1 -1
  67. package/lib/module/skia/web/JsiSkAnimatedImage.d.ts +11 -0
  68. package/lib/module/skia/web/JsiSkAnimatedImage.js +33 -0
  69. package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -0
  70. package/lib/module/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
  71. package/lib/module/skia/web/JsiSkAnimatedImageFactory.js +20 -0
  72. package/lib/module/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
  73. package/lib/module/skia/web/JsiSkFont.d.ts +2 -1
  74. package/lib/module/skia/web/JsiSkFont.js +5 -1
  75. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkia.js +2 -0
  77. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  78. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -0
  79. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +6 -0
  80. package/lib/typescript/src/skia/core/index.d.ts +1 -0
  81. package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
  82. package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
  83. package/lib/typescript/src/skia/types/AnimatedImage/index.d.ts +2 -0
  84. package/lib/typescript/src/skia/types/Font/Font.d.ts +9 -0
  85. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  86. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  87. package/lib/typescript/src/skia/web/JsiSkAnimatedImage.d.ts +11 -0
  88. package/lib/typescript/src/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
  89. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +2 -1
  90. package/package.json +1 -1
  91. package/src/external/reanimated/moduleWrapper.ts +9 -8
  92. package/src/skia/core/AnimatedImage.ts +63 -0
  93. package/src/skia/core/index.ts +1 -0
  94. package/src/skia/types/AnimatedImage/AnimatedImage.ts +29 -0
  95. package/src/skia/types/AnimatedImage/AnimatedImageFactory.ts +15 -0
  96. package/src/skia/types/AnimatedImage/index.ts +2 -0
  97. package/src/skia/types/Font/Font.ts +10 -0
  98. package/src/skia/types/Skia.ts +3 -0
  99. package/src/skia/types/index.ts +1 -0
  100. package/src/skia/web/JsiSkAnimatedImage.ts +35 -0
  101. package/src/skia/web/JsiSkAnimatedImageFactory.ts +27 -0
  102. package/src/skia/web/JsiSkFont.ts +6 -1
  103. package/src/skia/web/JsiSkia.ts +2 -0
  104. package/lib/commonjs/dom/nodes/PaintContext.d.ts +0 -19
  105. package/lib/commonjs/dom/nodes/PaintContext.js.map +0 -1
  106. package/lib/module/dom/nodes/PaintContext.d.ts +0 -19
  107. package/lib/module/dom/nodes/PaintContext.js +0 -2
  108. package/lib/module/dom/nodes/PaintContext.js.map +0 -1
  109. package/lib/typescript/src/dom/nodes/PaintContext.d.ts +0 -19
  110. package/src/dom/nodes/PaintContext.ts +0 -32
@@ -0,0 +1,15 @@
1
+ import type { SkData } from "../Data";
2
+
3
+ import type { SkAnimatedImage } from "./AnimatedImage";
4
+
5
+ export interface AnimatedImageFactory {
6
+ /**
7
+ * Decodes the given bytes into an animated image. Returns null if the bytes were invalid.
8
+ * The passed in bytes will be copied into the WASM heap, so the caller can dispose of them.
9
+ *
10
+ * The returned AnimatedImage will be "pointing to" the first frame, i.e. currentFrameDuration
11
+ * and makeImageAtCurrentFrame will be referring to the first frame.
12
+ * @param encoded
13
+ */
14
+ MakeAnimatedImageFromEncoded: (encoded: SkData) => SkAnimatedImage | null;
15
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./AnimatedImage";
2
+ export * from "./AnimatedImageFactory";
@@ -12,10 +12,20 @@ export interface FontMetrics {
12
12
  }
13
13
 
14
14
  export interface SkFont extends SkJSIInstance<"Font"> {
15
+ /**
16
+ * Returns the advance width of text.
17
+ * The advance is the normal distance to move before drawing additional text.
18
+ * Returns the bounding box of text
19
+ * @param text
20
+ * @param paint
21
+ */
22
+ measureText(text: string, paint?: SkPaint): SkRect;
23
+
15
24
  /**
16
25
  * Retrieves the total width of the provided text
17
26
  * @param text
18
27
  * @param paint
28
+ * @deprecated Use measureText or getGlyphWidths instead
19
29
  */
20
30
  getTextWidth(text: string, paint?: SkPaint): number;
21
31
 
@@ -28,6 +28,8 @@ import type { SkContourMeasureIter } from "./ContourMeasure";
28
28
  import type { PictureFactory, SkPictureRecorder } from "./Picture";
29
29
  import type { Color, SkColor } from "./Color";
30
30
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
31
+ import type { AnimatedImageFactory } from "./AnimatedImage";
32
+
31
33
  /**
32
34
  * Declares the interface for the native Skia API
33
35
  */
@@ -78,6 +80,7 @@ export interface Skia {
78
80
  ): SkVertices;
79
81
  Data: DataFactory;
80
82
  Image: ImageFactory;
83
+ AnimatedImage: AnimatedImageFactory;
81
84
  SVG: SVGFactory;
82
85
  TextBlob: TextBlobFactory;
83
86
  Surface: SurfaceFactory;
@@ -6,6 +6,7 @@ export * from "./Vertices";
6
6
  export * from "./RuntimeEffect";
7
7
  export * from "./Shader";
8
8
  export * from "./Image";
9
+ export * from "./AnimatedImage";
9
10
  export * from "./ColorFilter";
10
11
  export * from "./ImageFilter";
11
12
  export * from "./Font";
@@ -0,0 +1,35 @@
1
+ import type { AnimatedImage, CanvasKit } from "canvaskit-wasm";
2
+
3
+ import type { SkAnimatedImage } from "../types/AnimatedImage";
4
+
5
+ import { HostObject } from "./Host";
6
+ import { JsiSkImage } from "./JsiSkImage";
7
+
8
+ export class JsiSkAnimatedImage
9
+ extends HostObject<AnimatedImage, "AnimatedImage">
10
+ implements SkAnimatedImage
11
+ {
12
+ constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {
13
+ super(CanvasKit, ref, "AnimatedImage");
14
+ }
15
+
16
+ decodeNextFrame() {
17
+ return this.ref.decodeNextFrame();
18
+ }
19
+
20
+ currentFrameDuration() {
21
+ return this.ref.currentFrameDuration();
22
+ }
23
+
24
+ getCurrentFrame() {
25
+ const image = this.ref.makeImageAtCurrentFrame();
26
+ if (image === null) {
27
+ return null;
28
+ }
29
+ return new JsiSkImage(this.CanvasKit, image);
30
+ }
31
+
32
+ dispose = () => {
33
+ this.ref.delete();
34
+ };
35
+ }
@@ -0,0 +1,27 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+
3
+ import type { SkData } from "../types";
4
+ import type { AnimatedImageFactory } from "../types/AnimatedImage/AnimatedImageFactory";
5
+
6
+ import { Host } from "./Host";
7
+ import { JsiSkData } from "./JsiSkData";
8
+ import { JsiSkAnimatedImage } from "./JsiSkAnimatedImage";
9
+
10
+ export class JsiSkAnimatedImageFactory
11
+ extends Host
12
+ implements AnimatedImageFactory
13
+ {
14
+ constructor(CanvasKit: CanvasKit) {
15
+ super(CanvasKit);
16
+ }
17
+
18
+ MakeAnimatedImageFromEncoded(encoded: SkData) {
19
+ const image = this.CanvasKit.MakeAnimatedImageFromEncoded(
20
+ JsiSkData.fromValue(encoded)
21
+ );
22
+ if (image === null) {
23
+ return null;
24
+ }
25
+ return new JsiSkAnimatedImage(this.CanvasKit, image);
26
+ }
27
+ }
@@ -6,10 +6,11 @@ import type {
6
6
  SkFont,
7
7
  SkPaint,
8
8
  SkPoint,
9
+ SkRect,
9
10
  SkTypeface,
10
11
  } from "../types";
11
12
 
12
- import { HostObject, ckEnum } from "./Host";
13
+ import { HostObject, NotImplementedOnRNWeb, ckEnum } from "./Host";
13
14
  import { JsiSkPaint } from "./JsiSkPaint";
14
15
  import { JsiSkPoint } from "./JsiSkPoint";
15
16
  import { JsiSkRect } from "./JsiSkRect";
@@ -20,6 +21,10 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
20
21
  super(CanvasKit, ref, "Font");
21
22
  }
22
23
 
24
+ measureText(_text: string, _paint?: SkPaint | undefined): SkRect {
25
+ throw new NotImplementedOnRNWeb();
26
+ }
27
+
23
28
  dispose = () => {
24
29
  this.ref.delete();
25
30
  };
@@ -39,6 +39,7 @@ import { JsiSkPath } from "./JsiSkPath";
39
39
  import { JsiSkTypeface } from "./JsiSkTypeface";
40
40
  import { JsiSkTypefaceFontProviderFactory } from "./JsiSkTypefaceFontProviderFactory";
41
41
  import { JsiSkFontMgrFactory } from "./JsiSkFontMgrFactory";
42
+ import { JsiSkAnimatedImageFactory } from "./JsiSkAnimatedImageFactory";
42
43
 
43
44
  export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
44
45
  Point: (x: number, y: number) =>
@@ -98,6 +99,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
98
99
  MakeVertices: MakeVertices.bind(null, CanvasKit),
99
100
  Data: new JsiSkDataFactory(CanvasKit),
100
101
  Image: new JsiSkImageFactory(CanvasKit),
102
+ AnimatedImage: new JsiSkAnimatedImageFactory(CanvasKit),
101
103
  SVG: new JsiSkSVGFactory(CanvasKit),
102
104
  TextBlob: new JsiSkTextBlobFactory(CanvasKit),
103
105
  XYWHRect: (x: number, y: number, width: number, height: number) => {
@@ -1,19 +0,0 @@
1
- import type { BlendMode, PaintStyle, SkColorFilter, SkImageFilter, SkMaskFilter, SkPathEffect, SkShader, StrokeCap, StrokeJoin } from "../../skia/types";
2
- import type { SkColor } from "../../skia/types/Color";
3
- export interface PaintContext {
4
- color?: SkColor;
5
- strokeWidth?: number;
6
- blendMode?: BlendMode;
7
- style?: PaintStyle;
8
- strokeJoin?: StrokeJoin;
9
- strokeCap?: StrokeCap;
10
- strokeMiter?: number;
11
- opacity?: number;
12
- antiAlias?: boolean;
13
- dither?: boolean;
14
- shader?: SkShader;
15
- colorFilter?: SkColorFilter;
16
- imageFilter?: SkImageFilter;
17
- maskFilter?: SkMaskFilter;
18
- pathEffect?: SkPathEffect;
19
- }
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PaintContext.ts"],"sourcesContent":["import type {\n BlendMode,\n PaintStyle,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n SkShader,\n StrokeCap,\n StrokeJoin,\n} from \"../../skia/types\";\nimport type { SkColor } from \"../../skia/types/Color\";\n\n// TODO: to remove\nexport interface PaintContext {\n color?: SkColor;\n strokeWidth?: number;\n blendMode?: BlendMode;\n style?: PaintStyle;\n strokeJoin?: StrokeJoin;\n strokeCap?: StrokeCap;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n\n shader?: SkShader;\n colorFilter?: SkColorFilter;\n imageFilter?: SkImageFilter;\n maskFilter?: SkMaskFilter;\n pathEffect?: SkPathEffect;\n}\n"],"mappings":""}
@@ -1,19 +0,0 @@
1
- import type { BlendMode, PaintStyle, SkColorFilter, SkImageFilter, SkMaskFilter, SkPathEffect, SkShader, StrokeCap, StrokeJoin } from "../../skia/types";
2
- import type { SkColor } from "../../skia/types/Color";
3
- export interface PaintContext {
4
- color?: SkColor;
5
- strokeWidth?: number;
6
- blendMode?: BlendMode;
7
- style?: PaintStyle;
8
- strokeJoin?: StrokeJoin;
9
- strokeCap?: StrokeCap;
10
- strokeMiter?: number;
11
- opacity?: number;
12
- antiAlias?: boolean;
13
- dither?: boolean;
14
- shader?: SkShader;
15
- colorFilter?: SkColorFilter;
16
- imageFilter?: SkImageFilter;
17
- maskFilter?: SkMaskFilter;
18
- pathEffect?: SkPathEffect;
19
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=PaintContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["PaintContext.ts"],"sourcesContent":["import type {\n BlendMode,\n PaintStyle,\n SkColorFilter,\n SkImageFilter,\n SkMaskFilter,\n SkPathEffect,\n SkShader,\n StrokeCap,\n StrokeJoin,\n} from \"../../skia/types\";\nimport type { SkColor } from \"../../skia/types/Color\";\n\n// TODO: to remove\nexport interface PaintContext {\n color?: SkColor;\n strokeWidth?: number;\n blendMode?: BlendMode;\n style?: PaintStyle;\n strokeJoin?: StrokeJoin;\n strokeCap?: StrokeCap;\n strokeMiter?: number;\n opacity?: number;\n antiAlias?: boolean;\n dither?: boolean;\n\n shader?: SkShader;\n colorFilter?: SkColorFilter;\n imageFilter?: SkImageFilter;\n maskFilter?: SkMaskFilter;\n pathEffect?: SkPathEffect;\n}\n"],"mappings":""}
@@ -1,19 +0,0 @@
1
- import type { BlendMode, PaintStyle, SkColorFilter, SkImageFilter, SkMaskFilter, SkPathEffect, SkShader, StrokeCap, StrokeJoin } from "../../skia/types";
2
- import type { SkColor } from "../../skia/types/Color";
3
- export interface PaintContext {
4
- color?: SkColor;
5
- strokeWidth?: number;
6
- blendMode?: BlendMode;
7
- style?: PaintStyle;
8
- strokeJoin?: StrokeJoin;
9
- strokeCap?: StrokeCap;
10
- strokeMiter?: number;
11
- opacity?: number;
12
- antiAlias?: boolean;
13
- dither?: boolean;
14
- shader?: SkShader;
15
- colorFilter?: SkColorFilter;
16
- imageFilter?: SkImageFilter;
17
- maskFilter?: SkMaskFilter;
18
- pathEffect?: SkPathEffect;
19
- }
@@ -1,32 +0,0 @@
1
- import type {
2
- BlendMode,
3
- PaintStyle,
4
- SkColorFilter,
5
- SkImageFilter,
6
- SkMaskFilter,
7
- SkPathEffect,
8
- SkShader,
9
- StrokeCap,
10
- StrokeJoin,
11
- } from "../../skia/types";
12
- import type { SkColor } from "../../skia/types/Color";
13
-
14
- // TODO: to remove
15
- export interface PaintContext {
16
- color?: SkColor;
17
- strokeWidth?: number;
18
- blendMode?: BlendMode;
19
- style?: PaintStyle;
20
- strokeJoin?: StrokeJoin;
21
- strokeCap?: StrokeCap;
22
- strokeMiter?: number;
23
- opacity?: number;
24
- antiAlias?: boolean;
25
- dither?: boolean;
26
-
27
- shader?: SkShader;
28
- colorFilter?: SkColorFilter;
29
- imageFilter?: SkImageFilter;
30
- maskFilter?: SkMaskFilter;
31
- pathEffect?: SkPathEffect;
32
- }