@shopify/react-native-skia 0.1.227 → 0.1.229

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 (154) hide show
  1. package/cpp/api/JsiSkCanvas.h +2 -1
  2. package/cpp/api/JsiSkMatrix.h +27 -11
  3. package/cpp/api/JsiSkTypeface.h +1 -0
  4. package/cpp/rnskia/dom/props/MatrixProp.h +14 -3
  5. package/lib/commonjs/dom/types/Common.d.ts +2 -2
  6. package/lib/commonjs/dom/types/Common.js.map +1 -1
  7. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
  8. package/lib/commonjs/external/reanimated/interpolators.js +16 -3
  9. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  10. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
  11. package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
  12. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  13. package/lib/commonjs/renderer/Canvas.js +7 -13
  14. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  15. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  16. package/lib/commonjs/skia/core/Vector.js +1 -17
  17. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  18. package/lib/commonjs/skia/types/Canvas.d.ts +2 -2
  19. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  20. package/lib/commonjs/skia/types/Matrix.d.ts +3 -13
  21. package/lib/commonjs/skia/types/Matrix.js +1 -16
  22. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  23. package/lib/commonjs/skia/types/Matrix4.d.ts +60 -1
  24. package/lib/commonjs/skia/types/Matrix4.js +159 -14
  25. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  26. package/lib/commonjs/skia/types/Path/Path.d.ts +2 -2
  27. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  28. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  29. package/lib/commonjs/skia/web/Host.js +4 -12
  30. package/lib/commonjs/skia/web/Host.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkCanvas.js +12 -12
  32. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  33. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  34. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  35. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  36. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  37. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  38. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  40. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  42. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  43. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  44. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  45. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  46. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  47. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  49. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
  51. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  52. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  53. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  54. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  55. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  56. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  57. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  58. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  59. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  60. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  61. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  62. package/lib/module/dom/types/Common.d.ts +2 -2
  63. package/lib/module/dom/types/Common.js.map +1 -1
  64. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  65. package/lib/module/external/reanimated/interpolators.js +14 -4
  66. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  67. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  68. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  69. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  70. package/lib/module/renderer/Canvas.js +7 -12
  71. package/lib/module/renderer/Canvas.js.map +1 -1
  72. package/lib/module/skia/core/Vector.d.ts +0 -5
  73. package/lib/module/skia/core/Vector.js +0 -13
  74. package/lib/module/skia/core/Vector.js.map +1 -1
  75. package/lib/module/skia/types/Canvas.d.ts +2 -2
  76. package/lib/module/skia/types/Canvas.js.map +1 -1
  77. package/lib/module/skia/types/Matrix.d.ts +3 -13
  78. package/lib/module/skia/types/Matrix.js +0 -14
  79. package/lib/module/skia/types/Matrix.js.map +1 -1
  80. package/lib/module/skia/types/Matrix4.d.ts +60 -1
  81. package/lib/module/skia/types/Matrix4.js +132 -18
  82. package/lib/module/skia/types/Matrix4.js.map +1 -1
  83. package/lib/module/skia/types/Path/Path.d.ts +2 -2
  84. package/lib/module/skia/types/Path/Path.js.map +1 -1
  85. package/lib/module/skia/web/Host.d.ts +2 -3
  86. package/lib/module/skia/web/Host.js +2 -7
  87. package/lib/module/skia/web/Host.js.map +1 -1
  88. package/lib/module/skia/web/JsiSkCanvas.js +13 -13
  89. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  90. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  91. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  92. package/lib/module/skia/web/JsiSkFont.js +3 -3
  93. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  94. package/lib/module/skia/web/JsiSkImage.js +7 -7
  95. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  96. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  97. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  98. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  99. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  100. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  101. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  102. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  103. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  104. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  105. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  106. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  107. package/lib/module/skia/web/JsiSkPath.js +5 -5
  108. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  109. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  110. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  111. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  112. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  113. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  114. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  115. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  116. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  117. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  118. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  119. package/lib/typescript/src/dom/types/Common.d.ts +2 -2
  120. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  121. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  122. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  123. package/lib/typescript/src/skia/types/Canvas.d.ts +2 -2
  124. package/lib/typescript/src/skia/types/Matrix.d.ts +3 -13
  125. package/lib/typescript/src/skia/types/Matrix4.d.ts +60 -1
  126. package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -2
  127. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  128. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  129. package/package.json +2 -1
  130. package/src/dom/types/Common.ts +2 -2
  131. package/src/external/reanimated/interpolators.ts +20 -5
  132. package/src/external/reanimated/moduleWrapper.ts +6 -0
  133. package/src/renderer/Canvas.tsx +6 -13
  134. package/src/skia/core/Vector.ts +0 -7
  135. package/src/skia/types/Canvas.ts +2 -2
  136. package/src/skia/types/Matrix.ts +4 -13
  137. package/src/skia/types/Matrix4.ts +190 -81
  138. package/src/skia/types/Path/Path.ts +2 -2
  139. package/src/skia/web/Host.ts +4 -3
  140. package/src/skia/web/JsiSkCanvas.ts +22 -15
  141. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  142. package/src/skia/web/JsiSkFont.ts +3 -3
  143. package/src/skia/web/JsiSkImage.ts +14 -11
  144. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  145. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  146. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  147. package/src/skia/web/JsiSkMatrix.ts +12 -3
  148. package/src/skia/web/JsiSkPaint.ts +4 -4
  149. package/src/skia/web/JsiSkPath.ts +8 -5
  150. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  151. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  152. package/src/skia/web/JsiSkPicture.ts +4 -4
  153. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  154. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
@@ -1,5 +1,5 @@
1
- import { ckEnum } from "./Host";
2
1
  import { JsiSkVertices } from "./JsiSkVertices";
2
+ import { getEnum } from "./Host";
3
3
 
4
4
  const concat = function () {
5
5
  let totalLength = 0;
@@ -23,7 +23,7 @@ const concat = function () {
23
23
  return result;
24
24
  };
25
25
 
26
- export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(ckEnum(mode), positions.map(_ref => {
26
+ export const MakeVertices = (CanvasKit, mode, positions, textureCoordinates, colors, indices, isVolatile) => new JsiSkVertices(CanvasKit, CanvasKit.MakeVertices(getEnum(CanvasKit.VertexMode, mode), positions.map(_ref => {
27
27
  let {
28
28
  x,
29
29
  y
@@ -1 +1 @@
1
- {"version":3,"names":["ckEnum","JsiSkVertices","concat","totalLength","arrays","arr","length","result","Float32Array","offset","set","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","map","x","y","flat","reduce","a","c"],"sources":["JsiSkVerticesFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkColor, SkPoint, VertexMode } from \"../types\";\n\nimport { ckEnum } from \"./Host\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\n\nconst concat = (...arrays: Float32Array[]) => {\n let totalLength = 0;\n for (const arr of arrays) {\n totalLength += arr.length;\n }\n const result = new Float32Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n};\n\nexport const MakeVertices = (\n CanvasKit: CanvasKit,\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n) =>\n new JsiSkVertices(\n CanvasKit,\n CanvasKit.MakeVertices(\n ckEnum(mode),\n positions.map(({ x, y }) => [x, y]).flat(),\n (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),\n !colors ? null : colors.reduce((a, c) => concat(a, c)),\n indices,\n isVolatile\n )\n );\n"],"mappings":"AAIA,SAASA,MAAT,QAAuB,QAAvB;AACA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,MAAMC,MAAM,GAAG,YAA+B;EAC5C,IAAIC,WAAW,GAAG,CAAlB;;EAD4C,kCAA3BC,MAA2B;IAA3BA,MAA2B;EAAA;;EAE5C,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACxBD,WAAW,IAAIE,GAAG,CAACC,MAAnB;EACD;;EACD,MAAMC,MAAM,GAAG,IAAIC,YAAJ,CAAiBL,WAAjB,CAAf;EACA,IAAIM,MAAM,GAAG,CAAb;;EACA,KAAK,MAAMJ,GAAX,IAAkBD,MAAlB,EAA0B;IACxBG,MAAM,CAACG,GAAP,CAAWL,GAAX,EAAgBI,MAAhB;IACAA,MAAM,IAAIJ,GAAG,CAACC,MAAd;EACD;;EACD,OAAOC,MAAP;AACD,CAZD;;AAcA,OAAO,MAAMI,YAAY,GAAG,CAC1BC,SAD0B,EAE1BC,IAF0B,EAG1BC,SAH0B,EAI1BC,kBAJ0B,EAK1BC,MAL0B,EAM1BC,OAN0B,EAO1BC,UAP0B,KAS1B,IAAIjB,aAAJ,CACEW,SADF,EAEEA,SAAS,CAACD,YAAV,CACEX,MAAM,CAACa,IAAD,CADR,EAEEC,SAAS,CAACK,GAAV,CAAc;EAAA,IAAC;IAAEC,CAAF;IAAKC;EAAL,CAAD;EAAA,OAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAAd,EAAoCC,IAApC,EAFF,EAGE,CAACP,kBAAkB,IAAI,EAAvB,EAA2BI,GAA3B,CAA+B;EAAA,IAAC;IAAEC,CAAF;IAAKC;EAAL,CAAD;EAAA,OAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAA/B,EAAqDC,IAArD,EAHF,EAIE,CAACN,MAAD,GAAU,IAAV,GAAiBA,MAAM,CAACO,MAAP,CAAc,CAACC,CAAD,EAAIC,CAAJ,KAAUvB,MAAM,CAACsB,CAAD,EAAIC,CAAJ,CAA9B,CAJnB,EAKER,OALF,EAMEC,UANF,CAFF,CATK"}
1
+ {"version":3,"names":["JsiSkVertices","getEnum","concat","totalLength","arrays","arr","length","result","Float32Array","offset","set","MakeVertices","CanvasKit","mode","positions","textureCoordinates","colors","indices","isVolatile","VertexMode","map","x","y","flat","reduce","a","c"],"sources":["JsiSkVerticesFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkColor, SkPoint, VertexMode } from \"../types\";\n\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { getEnum } from \"./Host\";\n\nconst concat = (...arrays: Float32Array[]) => {\n let totalLength = 0;\n for (const arr of arrays) {\n totalLength += arr.length;\n }\n const result = new Float32Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n};\n\nexport const MakeVertices = (\n CanvasKit: CanvasKit,\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n) =>\n new JsiSkVertices(\n CanvasKit,\n CanvasKit.MakeVertices(\n getEnum(CanvasKit.VertexMode, mode),\n positions.map(({ x, y }) => [x, y]).flat(),\n (textureCoordinates || []).map(({ x, y }) => [x, y]).flat(),\n !colors ? null : colors.reduce((a, c) => concat(a, c)),\n indices,\n isVolatile\n )\n );\n"],"mappings":"AAIA,SAASA,aAAT,QAA8B,iBAA9B;AACA,SAASC,OAAT,QAAwB,QAAxB;;AAEA,MAAMC,MAAM,GAAG,YAA+B;EAC5C,IAAIC,WAAW,GAAG,CAAlB;;EAD4C,kCAA3BC,MAA2B;IAA3BA,MAA2B;EAAA;;EAE5C,KAAK,MAAMC,GAAX,IAAkBD,MAAlB,EAA0B;IACxBD,WAAW,IAAIE,GAAG,CAACC,MAAnB;EACD;;EACD,MAAMC,MAAM,GAAG,IAAIC,YAAJ,CAAiBL,WAAjB,CAAf;EACA,IAAIM,MAAM,GAAG,CAAb;;EACA,KAAK,MAAMJ,GAAX,IAAkBD,MAAlB,EAA0B;IACxBG,MAAM,CAACG,GAAP,CAAWL,GAAX,EAAgBI,MAAhB;IACAA,MAAM,IAAIJ,GAAG,CAACC,MAAd;EACD;;EACD,OAAOC,MAAP;AACD,CAZD;;AAcA,OAAO,MAAMI,YAAY,GAAG,CAC1BC,SAD0B,EAE1BC,IAF0B,EAG1BC,SAH0B,EAI1BC,kBAJ0B,EAK1BC,MAL0B,EAM1BC,OAN0B,EAO1BC,UAP0B,KAS1B,IAAIlB,aAAJ,CACEY,SADF,EAEEA,SAAS,CAACD,YAAV,CACEV,OAAO,CAACW,SAAS,CAACO,UAAX,EAAuBN,IAAvB,CADT,EAEEC,SAAS,CAACM,GAAV,CAAc;EAAA,IAAC;IAAEC,CAAF;IAAKC;EAAL,CAAD;EAAA,OAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAAd,EAAoCC,IAApC,EAFF,EAGE,CAACR,kBAAkB,IAAI,EAAvB,EAA2BK,GAA3B,CAA+B;EAAA,IAAC;IAAEC,CAAF;IAAKC;EAAL,CAAD;EAAA,OAAc,CAACD,CAAD,EAAIC,CAAJ,CAAd;AAAA,CAA/B,EAAqDC,IAArD,EAHF,EAIE,CAACP,MAAD,GAAU,IAAV,GAAiBA,MAAM,CAACQ,MAAP,CAAc,CAACC,CAAD,EAAIC,CAAJ,KAAUxB,MAAM,CAACuB,CAAD,EAAIC,CAAJ,CAA9B,CAJnB,EAKET,OALF,EAMEC,UANF,CAFF,CATK"}
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { BlendMode, Color, PaintStyle, SkMatrix, SkPaint, SkPath, SkRect, SkRRect, StrokeCap, StrokeJoin, Transforms3d, Vector } from "../../skia/types";
2
+ import type { BlendMode, Color, InputMatrix, 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;
@@ -36,7 +36,7 @@ export type CircleDef = PointCircleDef | ScalarCircleDef;
36
36
  export interface TransformProps {
37
37
  transform?: Transforms3d;
38
38
  origin?: Vector;
39
- matrix?: SkMatrix | number[];
39
+ matrix?: InputMatrix;
40
40
  }
41
41
  export interface PaintProps extends ChildrenProps {
42
42
  color?: Color;
@@ -1,6 +1,7 @@
1
1
  import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
2
2
  import type { SkPath, SkPoint } from "../../skia/types";
3
3
  export declare const notifyChange: (value: SharedValue<unknown>) => void;
4
+ export declare const usePathValue: (cb: (path: SkPath) => void) => SharedValue<SkPath>;
4
5
  export declare const useClock: () => SharedValue<number>;
5
6
  export declare const usePathInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPath[], options?: ExtrapolationType) => SharedValue<SkPath>;
6
7
  export declare const useVectorInterpolation: (value: SharedValue<number>, input: number[], outputRange: SkPoint[], options?: ExtrapolationType) => SharedValue<{
@@ -1,9 +1,10 @@
1
1
  import type { DependencyList } from "react";
2
- import type { FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
2
+ import type { DerivedValue, FrameCallback, FrameInfo, SharedValue } from "react-native-reanimated";
3
3
  export declare const HAS_REANIMATED2: boolean;
4
4
  export declare const HAS_REANIMATED3: boolean;
5
5
  export declare function throwOnMissingReanimated(): void;
6
6
  export declare const useSharedValue: <T>(init: T, oneWayReadsOnly?: boolean) => SharedValue<T>;
7
+ export declare const useDerivedValue: <T>(processor: () => T, dependencies?: DependencyList) => DerivedValue<T>;
7
8
  export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void, autostart?: boolean) => FrameCallback;
8
9
  export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
9
10
  export declare const stopMapper: (mapperID: number) => void;
@@ -5,8 +5,3 @@ export declare const neg: (a: Vector) => import("../types").SkPoint;
5
5
  export declare const add: (a: Vector, b: Vector) => import("../types").SkPoint;
6
6
  export declare const sub: (a: Vector, b: Vector) => import("../types").SkPoint;
7
7
  export declare const dist: (a: Vector, b: Vector) => number;
8
- export declare const translate: ({ x, y, }: Vector) => [{
9
- translateX: number;
10
- }, {
11
- translateY: number;
12
- }];
@@ -8,7 +8,7 @@ import type { SkColor } from "./Color";
8
8
  import type { SkRRect } from "./RRect";
9
9
  import type { BlendMode } from "./Paint/BlendMode";
10
10
  import type { SkPoint, PointMode } from "./Point";
11
- import type { SkMatrix } from "./Matrix";
11
+ import type { InputMatrix } from "./Matrix";
12
12
  import type { SkImageFilter } from "./ImageFilter";
13
13
  import type { SkVertices } from "./Vertices";
14
14
  import type { SkTextBlob } from "./TextBlob";
@@ -372,7 +372,7 @@ export interface SkCanvas {
372
372
  * Replaces current matrix with m premultiplied with the existing matrix.
373
373
  * @param m
374
374
  */
375
- concat(m: SkMatrix | number[]): void;
375
+ concat(m: InputMatrix): void;
376
376
  /**
377
377
  * Draws the given picture using the current clip, current matrix, and the provided paint.
378
378
  * @param skp
@@ -1,20 +1,9 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
2
  import type { SkCanvas } from "./Canvas";
3
- import type { Transforms3d } from "./Matrix4";
4
- export declare enum MatrixIndex {
5
- ScaleX = 0,
6
- SkewX = 1,
7
- TransX = 2,
8
- SkewY = 3,
9
- ScaleY = 4,
10
- TransY = 5,
11
- Persp0 = 6,
12
- Persp1 = 7,
13
- Persp2 = 8
14
- }
3
+ import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
15
4
  export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
16
5
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
17
- concat: (matrix: SkMatrix | number[]) => SkMatrix;
6
+ concat: (matrix: InputMatrix) => SkMatrix;
18
7
  translate: (x: number, y: number) => SkMatrix;
19
8
  scale: (x: number, y?: number) => SkMatrix;
20
9
  skew: (x: number, y: number) => SkMatrix;
@@ -26,6 +15,7 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
26
15
  identity: () => SkMatrix;
27
16
  get: () => number[];
28
17
  }
18
+ export type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];
29
19
  export interface TransformProp {
30
20
  transform?: Transforms3d;
31
21
  }
@@ -1,5 +1,20 @@
1
+ type Point = {
2
+ x: number;
3
+ y: number;
4
+ };
1
5
  type Vec2 = readonly [number, number];
2
6
  type Vec3 = readonly [number, number, number];
7
+ export type Matrix3 = readonly [
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number
17
+ ];
3
18
  export type Matrix4 = readonly [
4
19
  number,
5
20
  number,
@@ -28,6 +43,14 @@ export type Transforms3d = Transform3d[];
28
43
  * @worklet
29
44
  */
30
45
  export declare const Matrix4: () => Matrix4;
46
+ /**
47
+ * @worklet
48
+ */
49
+ export declare const translate: (x: number, y: number, z?: number) => Matrix4;
50
+ /**
51
+ * @worklet
52
+ */
53
+ export declare const perspective: (p: number) => Matrix4;
31
54
  /**
32
55
  * @worklet
33
56
  */
@@ -35,5 +58,41 @@ export declare const mapPoint3d: (m: Matrix4, v: Vec3) => readonly [number, numb
35
58
  /**
36
59
  * @worklet
37
60
  */
38
- export declare const processTransform3d: (transforms: Transforms3d) => number[];
61
+ export declare const multiply4: (a: Matrix4, b: Matrix4) => Matrix4;
62
+ /**
63
+ * @worklet
64
+ */
65
+ export declare const toMatrix3: (m: Matrix4) => number[];
66
+ /**
67
+ * @worklet
68
+ */
69
+ export declare const pivot: (m: Matrix4, p: Point) => Matrix4;
70
+ /**
71
+ * @worklet
72
+ */
73
+ export declare const scale: (sx: number, sy: number, sz?: number, p?: Point) => Matrix4;
74
+ /**
75
+ * @worklet
76
+ */
77
+ export declare const rotateZ: (value: number, p?: Point) => Matrix4;
78
+ /**
79
+ * @worklet
80
+ */
81
+ export declare const rotateX: (value: number, p?: Point) => Matrix4;
82
+ /**
83
+ * @worklet
84
+ */
85
+ export declare const rotateY: (value: number, p?: Point) => Matrix4;
86
+ /**
87
+ * @worklet
88
+ */
89
+ export declare const processTransform3d: (transforms: Transforms3d) => Matrix4;
90
+ /**
91
+ * @worklet
92
+ */
93
+ export declare const convertToColumnMajor: (rowMajorMatrix: Matrix4) => number[];
94
+ /**
95
+ * @worklet
96
+ */
97
+ export declare const convertToAffineMatrix: (m4: number[]) => number[];
39
98
  export {};
@@ -2,7 +2,7 @@ import type { SkRect } from "../Rect";
2
2
  import type { SkPoint } from "../Point";
3
3
  import type { SkRRect } from "../RRect";
4
4
  import type { StrokeJoin, StrokeCap } from "../Paint";
5
- import type { SkMatrix } from "../Matrix";
5
+ import type { InputMatrix, SkMatrix } from "../Matrix";
6
6
  import type { SkJSIInstance } from "../JsiInstance";
7
7
  /**
8
8
  * Options used for Path.stroke(). If an option is omitted, a sensible default will be used.
@@ -440,7 +440,7 @@ export interface SkPath extends SkJSIInstance<"Path"> {
440
440
  /**
441
441
  * Transforms the path by the specified matrix.
442
442
  */
443
- transform(m3: SkMatrix | number[]): SkPath;
443
+ transform(m3: InputMatrix): SkPath;
444
444
  /**
445
445
  * Interpolates between Path with point array of equal size.
446
446
  * Copy verb array and weights to result, and set result path to a weighted
@@ -16,6 +16,5 @@ export declare abstract class BaseHostObject<T, N extends string> extends Host i
16
16
  export declare abstract class HostObject<T, N extends string> extends BaseHostObject<T, N> {
17
17
  static fromValue<T>(value: SkJSIInstance<string>): T;
18
18
  }
19
- export declare const getCkEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
20
- export declare const ckEnum: (value: number) => EmbindEnumEntity;
21
- export declare const optEnum: (value: number | undefined) => EmbindEnumEntity | undefined;
19
+ export declare const getEnum: (e: EmbindEnum, v: number) => EmbindEnumEntity;
20
+ export declare const optEnum: (e: EmbindEnum, value: number | undefined) => EmbindEnumEntity | undefined;
@@ -1,12 +1,12 @@
1
1
  import type { CanvasKit, Matrix3x3 } from "canvaskit-wasm";
2
- import type { SkMatrix } from "../types";
2
+ import type { SkMatrix, InputMatrix } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  export declare class JsiSkMatrix extends HostObject<Matrix3x3, "Matrix"> implements SkMatrix {
5
5
  constructor(CanvasKit: CanvasKit, ref: Matrix3x3);
6
6
  private preMultiply;
7
7
  private postMultiply;
8
8
  dispose: () => void;
9
- concat(matrix: SkMatrix | number[]): this;
9
+ concat(matrix: InputMatrix): this;
10
10
  translate(x: number, y: number): this;
11
11
  postTranslate(x: number, y: number): this;
12
12
  scale(x: number, y?: number): this;
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.227",
10
+ "version": "0.1.229",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -94,6 +94,7 @@
94
94
  "eslint-config-react-native-wcandillon": "3.10.2",
95
95
  "eslint-plugin-reanimated": "2.0.0",
96
96
  "jest": "29.6.4",
97
+ "jest-diff": "^29.7.0",
97
98
  "merge-dirs": "^0.2.1",
98
99
  "pixelmatch": "^5.3.0",
99
100
  "pngjs": "^6.0.0",
@@ -3,8 +3,8 @@ import type { ReactNode } from "react";
3
3
  import type {
4
4
  BlendMode,
5
5
  Color,
6
+ InputMatrix,
6
7
  PaintStyle,
7
- SkMatrix,
8
8
  SkPaint,
9
9
  SkPath,
10
10
  SkRect,
@@ -66,7 +66,7 @@ export type CircleDef = PointCircleDef | ScalarCircleDef;
66
66
  export interface TransformProps {
67
67
  transform?: Transforms3d;
68
68
  origin?: Vector;
69
- matrix?: SkMatrix | number[];
69
+ matrix?: InputMatrix;
70
70
  }
71
71
 
72
72
  export interface PaintProps extends ChildrenProps {
@@ -3,7 +3,7 @@ import type {
3
3
  FrameInfo,
4
4
  SharedValue,
5
5
  } from "react-native-reanimated";
6
- import { useMemo, useRef } from "react";
6
+ import { useCallback, useMemo } from "react";
7
7
 
8
8
  import type { SkPath, SkPoint } from "../../skia/types";
9
9
  import { interpolatePaths, interpolateVector } from "../../animation";
@@ -13,6 +13,7 @@ import {
13
13
  useAnimatedReaction,
14
14
  useFrameCallback,
15
15
  useSharedValue,
16
+ useDerivedValue,
16
17
  } from "./moduleWrapper";
17
18
 
18
19
  export const notifyChange = (value: SharedValue<unknown>) => {
@@ -23,12 +24,26 @@ export const notifyChange = (value: SharedValue<unknown>) => {
23
24
  }
24
25
  };
25
26
 
27
+ export const usePathValue = (cb: (path: SkPath) => void) => {
28
+ const pathInit = useMemo(() => Skia.Path.Make(), []);
29
+ const path = useSharedValue(pathInit);
30
+ useDerivedValue(() => {
31
+ path.value.reset();
32
+ cb(path.value);
33
+ notifyChange(path);
34
+ });
35
+ return path;
36
+ };
37
+
26
38
  export const useClock = () => {
27
39
  const clock = useSharedValue(0);
28
- const callback = useRef((info: FrameInfo) => {
29
- "worklet";
30
- clock.value = info.timeSinceFirstFrame;
31
- }).current;
40
+ const callback = useCallback(
41
+ (info: FrameInfo) => {
42
+ "worklet";
43
+ clock.value = info.timeSinceFirstFrame;
44
+ },
45
+ [clock]
46
+ );
32
47
  useFrameCallback(callback);
33
48
  return clock;
34
49
  };
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import type { DependencyList } from "react";
3
3
  import type {
4
+ DerivedValue,
4
5
  FrameCallback,
5
6
  FrameInfo,
6
7
  SharedValue,
@@ -42,6 +43,11 @@ export const useSharedValue: <T>(
42
43
  oneWayReadsOnly?: boolean
43
44
  ) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;
44
45
 
46
+ export const useDerivedValue: <T>(
47
+ processor: () => T,
48
+ dependencies?: DependencyList
49
+ ) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;
50
+
45
51
  export const useFrameCallback: (
46
52
  callback: (frameInfo: FrameInfo) => void,
47
53
  autostart?: boolean
@@ -14,11 +14,11 @@ import type {
14
14
  } from "react";
15
15
  import type { LayoutChangeEvent } from "react-native";
16
16
 
17
- import { SkiaDomView, SkiaPictureView } from "../views";
17
+ import { SkiaDomView } from "../views";
18
+ import { SkiaDomView as SkiaDomViewWeb } from "../views/SkiaDomView.web";
18
19
  import { Skia } from "../skia/Skia";
19
20
  import type { TouchHandler, SkiaBaseViewProps } from "../views";
20
21
  import type { SkiaValue } from "../values/types";
21
- import { JsiDrawingContext } from "../dom/types";
22
22
 
23
23
  import { SkiaRoot } from "./Reconciler";
24
24
  import { NATIVE_DOM } from "./HostComponents";
@@ -116,23 +116,16 @@ export const Canvas = forwardRef<SkiaDomView, CanvasProps>(
116
116
  />
117
117
  );
118
118
  } else {
119
- // This is for debugging
120
- const recorder = Skia.PictureRecorder();
121
- const canvas = recorder.beginRecording(
122
- Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)
123
- );
124
- const ctx = new JsiDrawingContext(Skia, canvas);
125
- root.dom.render(ctx);
126
- const picture = recorder.finishRecordingAsPicture();
127
119
  return (
128
- <SkiaPictureView
120
+ <SkiaDomViewWeb
129
121
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
122
  ref={ref as any}
131
123
  style={style}
124
+ root={root.dom}
125
+ onTouch={onTouch}
126
+ onLayout={onLayout}
132
127
  mode={mode}
133
128
  debug={debug}
134
- picture={picture}
135
- onLayout={onLayout}
136
129
  {...props}
137
130
  />
138
131
  );
@@ -22,10 +22,3 @@ export const dist = (a: Vector, b: Vector) => {
22
22
  "worklet";
23
23
  return Math.hypot(a.x - b.x, a.y - b.y);
24
24
  };
25
- export const translate = ({
26
- x,
27
- y,
28
- }: Vector): [{ translateX: number }, { translateY: number }] => {
29
- "worklet";
30
- return [{ translateX: x }, { translateY: y }];
31
- };
@@ -8,7 +8,7 @@ import type { SkColor } from "./Color";
8
8
  import type { SkRRect } from "./RRect";
9
9
  import type { BlendMode } from "./Paint/BlendMode";
10
10
  import type { SkPoint, PointMode } from "./Point";
11
- import type { SkMatrix } from "./Matrix";
11
+ import type { InputMatrix } from "./Matrix";
12
12
  import type { SkImageFilter } from "./ImageFilter";
13
13
  import type { SkVertices } from "./Vertices";
14
14
  import type { SkTextBlob } from "./TextBlob";
@@ -485,7 +485,7 @@ export interface SkCanvas {
485
485
  * Replaces current matrix with m premultiplied with the existing matrix.
486
486
  * @param m
487
487
  */
488
- concat(m: SkMatrix | number[]): void;
488
+ concat(m: InputMatrix): void;
489
489
 
490
490
  /**
491
491
  * Draws the given picture using the current clip, current matrix, and the provided paint.
@@ -1,24 +1,13 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
2
  import type { SkCanvas } from "./Canvas";
3
- import type { Transforms3d } from "./Matrix4";
3
+ import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
4
4
  import { processTransform3d } from "./Matrix4";
5
- export enum MatrixIndex {
6
- ScaleX = 0,
7
- SkewX = 1,
8
- TransX = 2,
9
- SkewY = 3,
10
- ScaleY = 4,
11
- TransY = 5,
12
- Persp0 = 6,
13
- Persp1 = 7,
14
- Persp2 = 8,
15
- }
16
5
 
17
6
  export const isMatrix = (obj: unknown): obj is SkMatrix =>
18
7
  obj !== null && (obj as SkJSIInstance<string>).__typename__ === "Matrix";
19
8
 
20
9
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
21
- concat: (matrix: SkMatrix | number[]) => SkMatrix;
10
+ concat: (matrix: InputMatrix) => SkMatrix;
22
11
  translate: (x: number, y: number) => SkMatrix;
23
12
  scale: (x: number, y?: number) => SkMatrix;
24
13
  skew: (x: number, y: number) => SkMatrix;
@@ -31,6 +20,8 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
31
20
  get: () => number[];
32
21
  }
33
22
 
23
+ export type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];
24
+
34
25
  export interface TransformProp {
35
26
  transform?: Transforms3d;
36
27
  }