@shopify/react-native-skia 1.3.2 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. package/android/cpp/jni/JniPlatformContext.cpp +4 -3
  2. package/android/cpp/rnskia-android/RNSkAndroidVideo.cpp +59 -1
  3. package/android/cpp/rnskia-android/RNSkAndroidVideo.h +4 -0
  4. package/android/src/main/java/com/shopify/reactnative/skia/RNSkVideo.java +80 -7
  5. package/cpp/api/JsiVideo.h +32 -7
  6. package/cpp/rnskia/RNSkVideo.h +4 -0
  7. package/ios/RNSkia-iOS/RNSkiOSVideo.h +13 -4
  8. package/ios/RNSkia-iOS/RNSkiOSVideo.mm +65 -67
  9. package/lib/commonjs/dom/nodes/datatypes/Fitting.js +42 -30
  10. package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
  11. package/lib/commonjs/external/reanimated/useVideo.d.ts +16 -4
  12. package/lib/commonjs/external/reanimated/useVideo.js +92 -17
  13. package/lib/commonjs/external/reanimated/useVideo.js.map +1 -1
  14. package/lib/commonjs/external/reanimated/useVideoLoading.d.ts +4 -0
  15. package/lib/commonjs/external/reanimated/useVideoLoading.js +27 -0
  16. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -0
  17. package/lib/commonjs/external/reanimated/useVideoLoading.web.d.ts +4 -0
  18. package/lib/commonjs/external/reanimated/useVideoLoading.web.js +20 -0
  19. package/lib/commonjs/external/reanimated/useVideoLoading.web.js.map +1 -0
  20. package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +2 -10
  21. package/lib/commonjs/renderer/components/shapes/FitBox.js +32 -3
  22. package/lib/commonjs/renderer/components/shapes/FitBox.js.map +1 -1
  23. package/lib/commonjs/skia/core/Matrix.js +5 -1
  24. package/lib/commonjs/skia/core/Matrix.js.map +1 -1
  25. package/lib/commonjs/skia/types/Matrix.js +2 -0
  26. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  27. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.d.ts +3 -1
  28. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js +4 -2
  29. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  30. package/lib/commonjs/skia/types/Skia.d.ts +1 -1
  31. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  32. package/lib/commonjs/skia/types/Video/Video.d.ts +9 -1
  33. package/lib/commonjs/skia/types/Video/Video.js.map +1 -1
  34. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.d.ts +9 -0
  35. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js +30 -0
  36. package/lib/commonjs/skia/web/CanvasKitWebGLBufferImpl.js.map +1 -0
  37. package/lib/commonjs/skia/web/JsiSkImageFactory.js +8 -2
  38. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  39. package/lib/commonjs/skia/web/JsiSkia.js +2 -3
  40. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiVideo.d.ts +24 -0
  42. package/lib/commonjs/skia/web/JsiVideo.js +83 -0
  43. package/lib/commonjs/skia/web/JsiVideo.js.map +1 -0
  44. package/lib/commonjs/views/SkiaDomView.js +2 -0
  45. package/lib/commonjs/views/SkiaDomView.js.map +1 -1
  46. package/lib/commonjs/views/SkiaDomView.web.js +2 -0
  47. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
  48. package/lib/commonjs/views/SkiaJSDomView.js +2 -0
  49. package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
  50. package/lib/module/dom/nodes/datatypes/Fitting.js +41 -29
  51. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  52. package/lib/module/external/reanimated/useVideo.d.ts +16 -4
  53. package/lib/module/external/reanimated/useVideo.js +92 -17
  54. package/lib/module/external/reanimated/useVideo.js.map +1 -1
  55. package/lib/module/external/reanimated/useVideoLoading.d.ts +4 -0
  56. package/lib/module/external/reanimated/useVideoLoading.js +20 -0
  57. package/lib/module/external/reanimated/useVideoLoading.js.map +1 -0
  58. package/lib/module/external/reanimated/useVideoLoading.web.d.ts +4 -0
  59. package/lib/module/external/reanimated/useVideoLoading.web.js +13 -0
  60. package/lib/module/external/reanimated/useVideoLoading.web.js.map +1 -0
  61. package/lib/module/renderer/components/shapes/FitBox.d.ts +2 -10
  62. package/lib/module/renderer/components/shapes/FitBox.js +32 -3
  63. package/lib/module/renderer/components/shapes/FitBox.js.map +1 -1
  64. package/lib/module/skia/core/Matrix.js +5 -1
  65. package/lib/module/skia/core/Matrix.js.map +1 -1
  66. package/lib/module/skia/types/Matrix.js +2 -0
  67. package/lib/module/skia/types/Matrix.js.map +1 -1
  68. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.d.ts +3 -1
  69. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js +2 -1
  70. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  71. package/lib/module/skia/types/Skia.d.ts +1 -1
  72. package/lib/module/skia/types/Skia.js.map +1 -1
  73. package/lib/module/skia/types/Video/Video.d.ts +9 -1
  74. package/lib/module/skia/types/Video/Video.js.map +1 -1
  75. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +9 -0
  76. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +23 -0
  77. package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +1 -0
  78. package/lib/module/skia/web/JsiSkImageFactory.js +9 -3
  79. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  80. package/lib/module/skia/web/JsiSkia.js +2 -3
  81. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  82. package/lib/module/skia/web/JsiVideo.d.ts +24 -0
  83. package/lib/module/skia/web/JsiVideo.js +75 -0
  84. package/lib/module/skia/web/JsiVideo.js.map +1 -0
  85. package/lib/module/views/SkiaDomView.js +2 -0
  86. package/lib/module/views/SkiaDomView.js.map +1 -1
  87. package/lib/module/views/SkiaDomView.web.js +2 -0
  88. package/lib/module/views/SkiaDomView.web.js.map +1 -1
  89. package/lib/module/views/SkiaJSDomView.js +2 -0
  90. package/lib/module/views/SkiaJSDomView.js.map +1 -1
  91. package/lib/typescript/src/external/reanimated/useVideo.d.ts +16 -4
  92. package/lib/typescript/src/external/reanimated/useVideoLoading.d.ts +4 -0
  93. package/lib/typescript/src/external/reanimated/useVideoLoading.web.d.ts +4 -0
  94. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +2 -10
  95. package/lib/typescript/src/skia/types/NativeBuffer/NativeBufferFactory.d.ts +3 -1
  96. package/lib/typescript/src/skia/types/Skia.d.ts +1 -1
  97. package/lib/typescript/src/skia/types/Video/Video.d.ts +9 -1
  98. package/lib/typescript/src/skia/web/CanvasKitWebGLBufferImpl.d.ts +9 -0
  99. package/lib/typescript/src/skia/web/JsiVideo.d.ts +24 -0
  100. package/package.json +1 -1
  101. package/src/dom/nodes/datatypes/Fitting.ts +28 -21
  102. package/src/external/reanimated/useVideo.ts +108 -31
  103. package/src/external/reanimated/useVideoLoading.ts +28 -0
  104. package/src/external/reanimated/useVideoLoading.web.ts +17 -0
  105. package/src/renderer/components/shapes/FitBox.tsx +38 -4
  106. package/src/skia/core/Matrix.ts +4 -2
  107. package/src/skia/types/Matrix.ts +1 -0
  108. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +10 -2
  109. package/src/skia/types/Skia.ts +1 -1
  110. package/src/skia/types/Video/Video.ts +7 -1
  111. package/src/skia/web/CanvasKitWebGLBufferImpl.ts +22 -0
  112. package/src/skia/web/JsiSkImageFactory.ts +16 -3
  113. package/src/skia/web/JsiSkia.ts +2 -3
  114. package/src/skia/web/JsiVideo.ts +96 -0
  115. package/src/views/SkiaDomView.tsx +4 -0
  116. package/src/views/SkiaDomView.web.tsx +4 -0
  117. package/src/views/SkiaJSDomView.tsx +4 -0
  118. package/lib/commonjs/external/reanimated/video.d.ts +0 -16
  119. package/lib/commonjs/external/reanimated/video.js +0 -54
  120. package/lib/commonjs/external/reanimated/video.js.map +0 -1
  121. package/lib/module/external/reanimated/video.d.ts +0 -16
  122. package/lib/module/external/reanimated/video.js +0 -46
  123. package/lib/module/external/reanimated/video.js.map +0 -1
  124. package/lib/typescript/src/external/reanimated/video.d.ts +0 -16
  125. package/src/external/reanimated/video.ts +0 -82
@@ -1 +1 @@
1
- {"version":3,"names":["_typeddash","require","size","width","height","exports","rect2rect","src","dst","scaleX","scaleY","translateX","x","translateY","y","fitRects","fit","rect","sizes","applyBoxFit","inscribe","halfWidthDelta","halfHeightDelta","input","output","Math","min","aspectRatio","exhaustiveCheck"],"sources":["Fitting.ts"],"sourcesContent":["import { exhaustiveCheck } from \"../../../renderer/typeddash\";\nimport type { SkRect } from \"../../../skia/types\";\nimport type { Fit } from \"../../types\";\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport const size = (width = 0, height = 0) => ({ width, height });\n\nexport const rect2rect = (\n src: SkRect,\n dst: SkRect\n): [\n { translateX: number },\n { translateY: number },\n { scaleX: number },\n { scaleY: number }\n] => {\n const scaleX = dst.width / src.width;\n const scaleY = dst.height / src.height;\n const translateX = dst.x - src.x * scaleX;\n const translateY = dst.y - src.y * scaleY;\n return [{ translateX }, { translateY }, { scaleX }, { scaleY }];\n};\n\nexport const fitRects = (\n fit: Fit,\n rect: SkRect,\n { x, y, width, height }: SkRect\n) => {\n const sizes = applyBoxFit(\n fit,\n { width: rect.width, height: rect.height },\n { width, height }\n );\n const src = inscribe(sizes.src, rect);\n const dst = inscribe(sizes.dst, {\n x,\n y,\n width,\n height,\n });\n return { src, dst };\n};\n\nconst inscribe = (\n { width, height }: Size,\n rect: { x: number; y: number; width: number; height: number }\n) => {\n const halfWidthDelta = (rect.width - width) / 2.0;\n const halfHeightDelta = (rect.height - height) / 2.0;\n return {\n x: rect.x + halfWidthDelta,\n y: rect.y + halfHeightDelta,\n width,\n height,\n };\n};\n\nconst applyBoxFit = (fit: Fit, input: Size, output: Size) => {\n let src = size(),\n dst = size();\n if (\n input.height <= 0.0 ||\n input.width <= 0.0 ||\n output.height <= 0.0 ||\n output.width <= 0.0\n ) {\n return { src, dst };\n }\n switch (fit) {\n case \"fill\":\n src = input;\n dst = output;\n break;\n case \"contain\":\n src = input;\n if (output.width / output.height > src.width / src.height) {\n dst = size((src.width * output.height) / src.height, output.height);\n } else {\n dst = size(output.width, (src.height * output.width) / src.width);\n }\n break;\n case \"cover\":\n if (output.width / output.height > input.width / input.height) {\n src = size(input.width, (input.width * output.height) / output.width);\n } else {\n src = size((input.height * output.width) / output.height, input.height);\n }\n dst = output;\n break;\n case \"fitWidth\":\n src = size(input.width, (input.width * output.height) / output.width);\n dst = size(output.width, (src.height * output.width) / src.width);\n break;\n case \"fitHeight\":\n src = size((input.height * output.width) / output.height, input.height);\n dst = size((src.width * output.height) / src.height, output.height);\n break;\n case \"none\":\n src = size(\n Math.min(input.width, output.width),\n Math.min(input.height, output.height)\n );\n dst = src;\n break;\n case \"scaleDown\":\n src = input;\n dst = input;\n const aspectRatio = input.width / input.height;\n if (dst.height > output.height) {\n dst = size(output.height * aspectRatio, output.height);\n }\n if (dst.width > output.width) {\n dst = size(output.width, output.width / aspectRatio);\n }\n break;\n default:\n exhaustiveCheck(fit);\n }\n return { src, dst };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,IAAI,GAAGA,CAACC,KAAK,GAAG,CAAC,EAAEC,MAAM,GAAG,CAAC,MAAM;EAAED,KAAK;EAAEC;AAAO,CAAC,CAAC;AAACC,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAE5D,MAAMI,SAAS,GAAGA,CACvBC,GAAW,EACXC,GAAW,KAMR;EACH,MAAMC,MAAM,GAAGD,GAAG,CAACL,KAAK,GAAGI,GAAG,CAACJ,KAAK;EACpC,MAAMO,MAAM,GAAGF,GAAG,CAACJ,MAAM,GAAGG,GAAG,CAACH,MAAM;EACtC,MAAMO,UAAU,GAAGH,GAAG,CAACI,CAAC,GAAGL,GAAG,CAACK,CAAC,GAAG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,MAAM,GAAGoB,MAAM,CAACpB,MAAM,EAAE;QAC9BI,GAAG,GAAGN,IAAI,CAACsB,MAAM,CAACpB,MAAM,GAAGuB,WAAW,EAAEH,MAAM,CAACpB,MAAM,CAAC;MACxD;MACA,IAAII,GAAG,CAACL,KAAK,GAAGqB,MAAM,CAACrB,KAAK,EAAE;QAC5BK,GAAG,GAAGN,IAAI,CAACsB,MAAM,CAACrB,KAAK,EAAEqB,MAAM,CAACrB,KAAK,GAAGwB,WAAW,CAAC;MACtD;MACA;IACF;MACE,IAAAC,0BAAe,EAACZ,GAAG,CAAC;EACxB;EACA,OAAO;IAAET,GAAG;IAAEC;EAAI,CAAC;AACrB,CAAC"}
1
+ {"version":3,"names":["_typeddash","require","size","width","height","exports","rect2rect","src","dst","scaleX","scaleY","translateX","x","translateY","y","inscribe","rect","halfWidthDelta","halfHeightDelta","applyBoxFit","fit","input","output","Math","min","aspectRatio","exhaustiveCheck","fitRects","sizes"],"sources":["Fitting.ts"],"sourcesContent":["import { exhaustiveCheck } from \"../../../renderer/typeddash\";\nimport type { SkRect } from \"../../../skia/types\";\nimport type { Fit } from \"../../types\";\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport const size = (width = 0, height = 0) => {\n \"worklet\";\n return { width, height };\n};\n\nexport const rect2rect = (\n src: SkRect,\n dst: SkRect\n): [\n { translateX: number },\n { translateY: number },\n { scaleX: number },\n { scaleY: number }\n] => {\n \"worklet\";\n const scaleX = dst.width / src.width;\n const scaleY = dst.height / src.height;\n const translateX = dst.x - src.x * scaleX;\n const translateY = dst.y - src.y * scaleY;\n return [{ translateX }, { translateY }, { scaleX }, { scaleY }];\n};\n\nconst inscribe = (\n { width, height }: Size,\n rect: { x: number; y: number; width: number; height: number }\n) => {\n \"worklet\";\n const halfWidthDelta = (rect.width - width) / 2.0;\n const halfHeightDelta = (rect.height - height) / 2.0;\n return {\n x: rect.x + halfWidthDelta,\n y: rect.y + halfHeightDelta,\n width,\n height,\n };\n};\n\nconst applyBoxFit = (fit: Fit, input: Size, output: Size) => {\n \"worklet\";\n let src = size(),\n dst = size();\n if (\n input.height <= 0.0 ||\n input.width <= 0.0 ||\n output.height <= 0.0 ||\n output.width <= 0.0\n ) {\n return { src, dst };\n }\n switch (fit) {\n case \"fill\":\n src = input;\n dst = output;\n break;\n case \"contain\":\n src = input;\n if (output.width / output.height > src.width / src.height) {\n dst = size((src.width * output.height) / src.height, output.height);\n } else {\n dst = size(output.width, (src.height * output.width) / src.width);\n }\n break;\n case \"cover\":\n if (output.width / output.height > input.width / input.height) {\n src = size(input.width, (input.width * output.height) / output.width);\n } else {\n src = size((input.height * output.width) / output.height, input.height);\n }\n dst = output;\n break;\n case \"fitWidth\":\n src = size(input.width, (input.width * output.height) / output.width);\n dst = size(output.width, (src.height * output.width) / src.width);\n break;\n case \"fitHeight\":\n src = size((input.height * output.width) / output.height, input.height);\n dst = size((src.width * output.height) / src.height, output.height);\n break;\n case \"none\":\n src = size(\n Math.min(input.width, output.width),\n Math.min(input.height, output.height)\n );\n dst = src;\n break;\n case \"scaleDown\":\n src = input;\n dst = input;\n const aspectRatio = input.width / input.height;\n if (dst.height > output.height) {\n dst = size(output.height * aspectRatio, output.height);\n }\n if (dst.width > output.width) {\n dst = size(output.width, output.width / aspectRatio);\n }\n break;\n default:\n exhaustiveCheck(fit);\n }\n return { src, dst };\n};\n\nexport const fitRects = (\n fit: Fit,\n rect: SkRect,\n { x, y, width, height }: SkRect\n) => {\n \"worklet\";\n const sizes = applyBoxFit(\n fit,\n { width: rect.width, height: rect.height },\n { width, height }\n );\n const src = inscribe(sizes.src, rect);\n const dst = inscribe(sizes.dst, {\n x,\n y,\n width,\n height,\n });\n return { src, dst };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,IAAI,GAAGA,CAACC,KAAK,GAAG,CAAC,EAAEC,MAAM,GAAG,CAAC,KAAK;EAC7C,SAAS;;EACT,OAAO;IAAED,KAAK;IAAEC;EA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B,MAAM,CAACnB,KAAK,EAAEmB,MAAM,CAACnB,KAAK,GAAGsB,WAAW,CAAC;MACtD;MACA;IACF;MACE,IAAAC,0BAAe,EAACN,GAAG,CAAC;EACxB;EACA,OAAO;IAAEb,GAAG;IAAEC;EAAI,CAAC;AACrB,CAAC;AAEM,MAAMmB,QAAQ,GAAGA,CACtBP,GAAQ,EACRJ,IAAY,EACZ;EAAEJ,CAAC;EAAEE,CAAC;EAAEX,KAAK;EAAEC;AAAe,CAAC,KAC5B;EACH,SAAS;;EACT,MAAMwB,KAAK,GAAGT,WAAW,CACvBC,GAAG,EACH;IAAEjB,KAAK,EAAEa,IAAI,CAACb,KAAK;IAAEC,MAAM,EAAEY,IAAI,CAACZ;EAAO,CAAC,EAC1C;IAAED,KAAK;IAAEC;EAAO,CAClB,CAAC;EACD,MAAMG,GAAG,GAAGQ,QAAQ,CAACa,KAAK,CAACrB,GAAG,EAAES,IAAI,CAAC;EACrC,MAAMR,GAAG,GAAGO,QAAQ,CAACa,KAAK,CAACpB,GAAG,EAAE;IAC9BI,CAAC;IACDE,CAAC;IACDX,KAAK;IACLC;EACF,CAAC,CAAC;EACF,OAAO;IAAEG,GAAG;IAAEC;EAAI,CAAC;AACrB,CAAC;AAACH,OAAA,CAAAsB,QAAA,GAAAA,QAAA"}
@@ -1,9 +1,21 @@
1
+ import type { SharedValue } from "react-native-reanimated";
1
2
  import type { SkImage } from "../../skia/types";
2
- import { type PlaybackOptions } from "./video";
3
+ type Animated<T> = SharedValue<T> | T;
4
+ interface PlaybackOptions {
5
+ looping: Animated<boolean>;
6
+ paused: Animated<boolean>;
7
+ seek: Animated<number | null>;
8
+ volume: Animated<number>;
9
+ }
3
10
  export declare const useVideo: (source: string | null, userOptions?: Partial<PlaybackOptions>) => {
4
- currentFrame: import("react-native-reanimated").SharedValue<SkImage | null>;
5
- currentTime: import("react-native-reanimated").SharedValue<number>;
11
+ currentFrame: SharedValue<SkImage | null>;
12
+ currentTime: SharedValue<number>;
6
13
  duration: number;
7
14
  framerate: number;
8
- rotationInDegrees: number;
15
+ rotation: import("../../skia/types").VideoRotation;
16
+ size: {
17
+ width: number;
18
+ height: number;
19
+ };
9
20
  };
21
+ export {};
@@ -5,16 +5,41 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useVideo = void 0;
7
7
  var _react = require("react");
8
- var _Skia = require("../../skia/Skia");
8
+ var _Platform = require("../../Platform");
9
9
  var _ReanimatedProxy = _interopRequireDefault(require("./ReanimatedProxy"));
10
- var _video = require("./video");
10
+ var _useVideoLoading = require("./useVideoLoading");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const copyFrameOnAndroid = currentFrame => {
13
+ "worklet";
14
+
15
+ // on android we need to copy the texture before it's invalidated
16
+ if (_Platform.Platform.OS === "android") {
17
+ const tex = currentFrame.value;
18
+ if (tex) {
19
+ currentFrame.value = tex.makeNonTextureImage();
20
+ tex.dispose();
21
+ }
22
+ }
23
+ };
24
+ const setFrame = (video, currentFrame) => {
25
+ "worklet";
26
+
27
+ const img = video.nextImage();
28
+ if (img) {
29
+ if (currentFrame.value) {
30
+ currentFrame.value.dispose();
31
+ }
32
+ currentFrame.value = img;
33
+ } else {
34
+ copyFrameOnAndroid(currentFrame);
35
+ }
36
+ };
12
37
  const defaultOptions = {
13
- playbackSpeed: 1,
14
38
  looping: true,
15
39
  paused: false,
16
40
  seek: null,
17
- currentTime: 0
41
+ currentTime: 0,
42
+ volume: 0
18
43
  };
19
44
  const useOption = value => {
20
45
  "worklet";
@@ -29,12 +54,12 @@ const disposeVideo = video => {
29
54
  video === null || video === void 0 || video.dispose();
30
55
  };
31
56
  const useVideo = (source, userOptions) => {
32
- var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$playback;
33
- const video = (0, _react.useMemo)(() => source ? _Skia.Skia.Video(source) : null, [source]);
57
+ var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$volume;
58
+ const video = (0, _useVideoLoading.useVideoLoading)(source);
34
59
  const isPaused = useOption((_userOptions$paused = userOptions === null || userOptions === void 0 ? void 0 : userOptions.paused) !== null && _userOptions$paused !== void 0 ? _userOptions$paused : defaultOptions.paused);
35
60
  const looping = useOption((_userOptions$looping = userOptions === null || userOptions === void 0 ? void 0 : userOptions.looping) !== null && _userOptions$looping !== void 0 ? _userOptions$looping : defaultOptions.looping);
36
61
  const seek = useOption((_userOptions$seek = userOptions === null || userOptions === void 0 ? void 0 : userOptions.seek) !== null && _userOptions$seek !== void 0 ? _userOptions$seek : defaultOptions.seek);
37
- const playbackSpeed = useOption((_userOptions$playback = userOptions === null || userOptions === void 0 ? void 0 : userOptions.playbackSpeed) !== null && _userOptions$playback !== void 0 ? _userOptions$playback : defaultOptions.playbackSpeed);
62
+ const volume = useOption((_userOptions$volume = userOptions === null || userOptions === void 0 ? void 0 : userOptions.volume) !== null && _userOptions$volume !== void 0 ? _userOptions$volume : defaultOptions.volume);
38
63
  const currentFrame = _ReanimatedProxy.default.useSharedValue(null);
39
64
  const currentTime = _ReanimatedProxy.default.useSharedValue(0);
40
65
  const lastTimestamp = _ReanimatedProxy.default.useSharedValue(-1);
@@ -44,18 +69,67 @@ const useVideo = (source, userOptions) => {
44
69
  }, [video]);
45
70
  const framerate = (0, _react.useMemo)(() => {
46
71
  var _video$framerate;
47
- return (_video$framerate = video === null || video === void 0 ? void 0 : video.framerate()) !== null && _video$framerate !== void 0 ? _video$framerate : 0;
72
+ return _Platform.Platform.OS === "web" ? -1 : (_video$framerate = video === null || video === void 0 ? void 0 : video.framerate()) !== null && _video$framerate !== void 0 ? _video$framerate : 0;
48
73
  }, [video]);
49
- const rotationInDegrees = (0, _react.useMemo)(() => {
50
- var _video$getRotationInD;
51
- return (_video$getRotationInD = video === null || video === void 0 ? void 0 : video.getRotationInDegrees()) !== null && _video$getRotationInD !== void 0 ? _video$getRotationInD : 0;
74
+ const size = (0, _react.useMemo)(() => {
75
+ var _video$size;
76
+ return (_video$size = video === null || video === void 0 ? void 0 : video.size()) !== null && _video$size !== void 0 ? _video$size : {
77
+ width: 0,
78
+ height: 0
79
+ };
80
+ }, [video]);
81
+ const rotation = (0, _react.useMemo)(() => {
82
+ var _video$rotation;
83
+ return (_video$rotation = video === null || video === void 0 ? void 0 : video.rotation()) !== null && _video$rotation !== void 0 ? _video$rotation : 0;
52
84
  }, [video]);
85
+ const frameDuration = 1000 / framerate;
86
+ const currentFrameDuration = Math.floor(frameDuration);
87
+ _ReanimatedProxy.default.useAnimatedReaction(() => isPaused.value, paused => {
88
+ if (paused) {
89
+ video === null || video === void 0 || video.pause();
90
+ } else {
91
+ lastTimestamp.value = -1;
92
+ video === null || video === void 0 || video.play();
93
+ }
94
+ });
95
+ _ReanimatedProxy.default.useAnimatedReaction(() => seek.value, value => {
96
+ if (value !== null) {
97
+ copyFrameOnAndroid(currentFrame);
98
+ video === null || video === void 0 || video.seek(value);
99
+ currentTime.value = value;
100
+ seek.value = null;
101
+ }
102
+ });
103
+ _ReanimatedProxy.default.useAnimatedReaction(() => volume.value, value => {
104
+ video === null || video === void 0 || video.setVolume(value);
105
+ });
53
106
  _ReanimatedProxy.default.useFrameCallback(frameInfo => {
54
- (0, _video.processVideoState)(video, duration, framerate, frameInfo.timestamp, {
55
- paused: isPaused.value,
56
- looping: looping.value,
57
- playbackSpeed: playbackSpeed.value
58
- }, currentTime, currentFrame, lastTimestamp, seek);
107
+ "worklet";
108
+
109
+ if (!video) {
110
+ return;
111
+ }
112
+ if (isPaused.value) {
113
+ return;
114
+ }
115
+ const currentTimestamp = frameInfo.timestamp;
116
+ if (lastTimestamp.value === -1) {
117
+ lastTimestamp.value = currentTimestamp;
118
+ }
119
+ const delta = currentTimestamp - lastTimestamp.value;
120
+ const isOver = currentTime.value + delta > duration;
121
+ if (isOver && looping.value) {
122
+ seek.value = 0;
123
+ currentTime.value = seek.value;
124
+ lastTimestamp.value = currentTimestamp;
125
+ }
126
+ // On Web the framerate is uknown.
127
+ // This could be optimized by using requestVideoFrameCallback (Chrome only)
128
+ if (delta >= currentFrameDuration && !isOver || _Platform.Platform.OS === "web") {
129
+ setFrame(video, currentFrame);
130
+ currentTime.value += delta;
131
+ lastTimestamp.value = currentTimestamp;
132
+ }
59
133
  });
60
134
  (0, _react.useEffect)(() => {
61
135
  return () => {
@@ -68,7 +142,8 @@ const useVideo = (source, userOptions) => {
68
142
  currentTime,
69
143
  duration,
70
144
  framerate,
71
- rotationInDegrees
145
+ rotation,
146
+ size
72
147
  };
73
148
  };
74
149
  exports.useVideo = useVideo;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Skia","_ReanimatedProxy","_interopRequireDefault","_video","obj","__esModule","default","defaultOptions","playbackSpeed","looping","paused","seek","currentTime","useOption","value","defaultValue","Rea","useSharedValue","isSharedValue","disposeVideo","video","dispose","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$playback","useMemo","Skia","Video","isPaused","currentFrame","lastTimestamp","duration","_video$duration","framerate","_video$framerate","rotationInDegrees","_video$getRotationInD","getRotationInDegrees","useFrameCallback","frameInfo","processVideoState","timestamp","useEffect","runOnUI","exports"],"sources":["useVideo.ts"],"sourcesContent":["import { type FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport { Skia } from \"../../skia/Skia\";\nimport type { SkImage, Video } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport {\n processVideoState,\n type Animated,\n type PlaybackOptions,\n} from \"./video\";\n\nconst defaultOptions = {\n playbackSpeed: 1,\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useMemo(() => (source ? Skia.Video(source) : null), [source]);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const playbackSpeed = useOption(\n userOptions?.playbackSpeed ?? defaultOptions.playbackSpeed\n );\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(() => video?.framerate() ?? 0, [video]);\n const rotationInDegrees = useMemo(\n () => video?.getRotationInDegrees() ?? 0,\n [video]\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n processVideoState(\n video,\n duration,\n framerate,\n frameInfo.timestamp,\n {\n paused: isPaused.value,\n looping: looping.value,\n playbackSpeed: playbackSpeed.value,\n },\n currentTime,\n currentFrame,\n lastTimestamp,\n seek\n );\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return { currentFrame, currentTime, duration, framerate, rotationInDegrees };\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAGA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAIiB,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjB,MAAMG,cAAc,GAAG;EACrBC,aAAa,EAAE,CAAC;EAChBC,OAAO,EAAE,IAAI;EACbC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE;AACf,CAAC;AAED,MAAMC,SAAS,GAAOC,K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/B,CAAC,EACDF,WAAW,EACXqB,YAAY,EACZC,aAAa,EACbvB,IACF,CAAC;EACH,CAAC,CAAC;EAEF,IAAAmC,gBAAS,EAAC,MAAM;IACd,OAAO,MAAM;MACX;MACA9B,wBAAG,CAAC+B,OAAO,CAAC5B,YAAY,CAAC,CAACC,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAO;IAAEa,YAAY;IAAErB,WAAW;IAAEuB,QAAQ;IAAEE,SAAS;IAAEE;EAAkB,CAAC;AAC9E,CAAC;AAACS,OAAA,CAAA1B,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_react","require","_Platform","_ReanimatedProxy","_interopRequireDefault","_useVideoLoading","obj","__esModule","default","copyFrameOnAndroid","currentFrame","Platform","OS","tex","value","makeNonTextureImage","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","currentTime","volume","useOption","defaultValue","Rea","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","useVideoLoading","isPaused","lastTimestamp","duration","useMemo","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","frameDuration","currentFrameDuration","Math","floor","useAnimatedReaction","pause","play","setVolume","useFrameCallback","frameInfo","currentTimestamp","timestamp","delta","isOver","useEffect","runOnUI","exports"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype Animated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: Animated<boolean>;\n paused: Animated<boolean>;\n seek: Animated<number | null>;\n volume: Animated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n currentFrame.value = tex.makeNonTextureImage();\n tex.dispose();\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = img;\n } else {\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n volume: 0,\n};\n\nconst useOption = <T>(value: Animated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value) ? value : defaultValue;\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : video?.framerate() ?? 0),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(frameDuration);\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n lastTimestamp.value = -1;\n video?.play();\n }\n }\n );\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n copyFrameOnAndroid(currentFrame);\n video?.seek(value);\n currentTime.value = value;\n seek.value = null;\n }\n }\n );\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (isPaused.value) {\n return;\n }\n const currentTimestamp = frameInfo.timestamp;\n if (lastTimestamp.value === -1) {\n lastTimestamp.value = currentTimestamp;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const isOver = currentTime.value + delta > duration;\n if (isOver && looping.value) {\n seek.value = 0;\n currentTime.value = seek.value;\n lastTimestamp.value = currentTimestamp;\n }\n // On Web the framerate is uknown.\n // This could be optimized by using requestVideoFrameCallback (Chrome only)\n if ((delta >= currentFrameDuration && !isOver) || Platform.OS === \"web\") {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return {\n currentFrame,\n currentTime,\n duration,\n framerate,\n rotation,\n size,\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAAoD,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAWpD,MAAMG,kBAAkB,GAAIC,YAAyC,IAAK;EACxE,SAAS;;EACT;EACA,IAAIC,kBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAGH,YAAY,CAACI,KAAK;IAC9B,IAAID,GAAG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EACF,CAAC,CAAC;EAEF,IAAAI,gBAAS,EAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAvC,wBAAG,CAACwC,OAAO,CAACrC,YAAY,CAAC,CAACd,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAO;IACLR,YAAY;IACZe,WAAW;IACXkB,QAAQ;IACRG,SAAS;IACTM,QAAQ;IACRJ;EACF,CAAC;AACH,CAAC;AAACsB,OAAA,CAAArC,QAAA,GAAAA,QAAA"}
@@ -0,0 +1,4 @@
1
+ import type { Video } from "../../skia/types";
2
+ type VideoSource = string | null;
3
+ export declare const useVideoLoading: (source: VideoSource) => Video | null;
4
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useVideoLoading = void 0;
7
+ var _react = require("react");
8
+ var _reactNativeReanimated = require("react-native-reanimated");
9
+ var _skia = require("../../skia");
10
+ const runtime = (0, _reactNativeReanimated.createWorkletRuntime)("video-metadata-runtime");
11
+ const useVideoLoading = source => {
12
+ const [video, setVideo] = (0, _react.useState)(null);
13
+ const cb = src => {
14
+ "worklet";
15
+
16
+ const vid = _skia.Skia.Video(src);
17
+ (0, _reactNativeReanimated.runOnJS)(setVideo)(vid);
18
+ };
19
+ (0, _react.useEffect)(() => {
20
+ if (source) {
21
+ (0, _reactNativeReanimated.runOnRuntime)(runtime, cb)(source);
22
+ }
23
+ }, [source]);
24
+ return video;
25
+ };
26
+ exports.useVideoLoading = useVideoLoading;
27
+ //# sourceMappingURL=useVideoLoading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNativeReanimated","_skia","runtime","createWorkletRuntime","useVideoLoading","source","video","setVideo","useState","cb","src","vid","Skia","Video","runOnJS","useEffect","runOnRuntime","exports"],"sources":["useVideoLoading.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport {\n createWorkletRuntime,\n runOnJS,\n runOnRuntime,\n} from \"react-native-reanimated\";\n\nimport type { Video } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nconst runtime = createWorkletRuntime(\"video-metadata-runtime\");\n\ntype VideoSource = string | null;\n\nexport const useVideoLoading = (source: VideoSource) => {\n const [video, setVideo] = useState<Video | null>(null);\n const cb = (src: string) => {\n \"worklet\";\n const vid = Skia.Video(src) as Video;\n runOnJS(setVideo)(vid);\n };\n useEffect(() => {\n if (source) {\n runOnRuntime(runtime, cb)(source);\n }\n }, [source]);\n return video;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,2CAAoB,EAAC,wBAAwB,CAAC;AAIvD,MAAMC,eAAe,GAAIC,MAAmB,IAAK;EACtD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAe,IAAI,CAAC;EACtD,MAAMC,EAAE,GAAIC,GAAW,IAAK;IAC1B,SAAS;;IACT,MAAMC,GAAG,GAAGC,UAAI,CAACC,KAAK,CAACH,GAAG,CAAU;IACpC,IAAAI,8BAAO,EAACP,QAAQ,CAAC,CAACI,GAAG,CAAC;EACxB,CAAC;EACD,IAAAI,gBAAS,EAAC,MAAM;IACd,IAAIV,MAAM,EAAE;MACV,IAAAW,mCAAY,EAACd,OAAO,EAAEO,EAAE,CAAC,CAACJ,MAAM,CAAC;IACnC;EACF,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EACZ,OAAOC,KAAK;AACd,CAAC;AAACW,OAAA,CAAAb,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,4 @@
1
+ import type { Video } from "../../skia/types";
2
+ type VideoSource = string | null;
3
+ export declare const useVideoLoading: (source: VideoSource) => Video | null;
4
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useVideoLoading = void 0;
7
+ var _react = require("react");
8
+ var _skia = require("../../skia");
9
+ const useVideoLoading = source => {
10
+ const [video, setVideo] = (0, _react.useState)(null);
11
+ (0, _react.useEffect)(() => {
12
+ if (source) {
13
+ const vid = _skia.Skia.Video(source);
14
+ vid.then(v => setVideo(v));
15
+ }
16
+ }, [source]);
17
+ return video;
18
+ };
19
+ exports.useVideoLoading = useVideoLoading;
20
+ //# sourceMappingURL=useVideoLoading.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_skia","useVideoLoading","source","video","setVideo","useState","useEffect","vid","Skia","Video","then","v","exports"],"sources":["useVideoLoading.web.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport type { Video } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\ntype VideoSource = string | null;\n\nexport const useVideoLoading = (source: VideoSource) => {\n const [video, setVideo] = useState<Video | null>(null);\n useEffect(() => {\n if (source) {\n const vid = Skia.Video(source) as Promise<Video>;\n vid.then((v) => setVideo(v));\n }\n }, [source]);\n return video;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAIO,MAAME,eAAe,GAAIC,MAAmB,IAAK;EACtD,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAe,IAAI,CAAC;EACtD,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIJ,MAAM,EAAE;MACV,MAAMK,GAAG,GAAGC,UAAI,CAACC,KAAK,CAACP,MAAM,CAAmB;MAChDK,GAAG,CAACG,IAAI,CAAEC,CAAC,IAAKP,QAAQ,CAACO,CAAC,CAAC,CAAC;IAC9B;EACF,CAAC,EAAE,CAACT,MAAM,CAAC,CAAC;EACZ,OAAOC,KAAK;AACd,CAAC;AAACS,OAAA,CAAAX,eAAA,GAAAA,eAAA"}
@@ -1,21 +1,13 @@
1
1
  import type { ReactNode } from "react";
2
2
  import React from "react";
3
3
  import type { Fit } from "../../../dom/nodes";
4
- import type { SkRect } from "../../../skia/types";
4
+ import type { SkRect, Transforms3d } from "../../../skia/types";
5
5
  interface FitProps {
6
6
  fit?: Fit;
7
7
  src: SkRect;
8
8
  dst: SkRect;
9
9
  children: ReactNode | ReactNode[];
10
10
  }
11
- export declare const fitbox: (fit: Fit, src: SkRect, dst: SkRect) => [{
12
- translateX: number;
13
- }, {
14
- translateY: number;
15
- }, {
16
- scaleX: number;
17
- }, {
18
- scaleY: number;
19
- }];
11
+ export declare const fitbox: (fit: Fit, src: SkRect, dst: SkRect, rotation?: 0 | 90 | 180 | 270) => Transforms3d;
20
12
  export declare const FitBox: ({ fit, src, dst, children }: FitProps) => React.JSX.Element;
21
13
  export {};
@@ -9,9 +9,38 @@ var _nodes = require("../../../dom/nodes");
9
9
  var _Group = require("../Group");
10
10
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
11
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
- const fitbox = (fit, src, dst) => {
13
- const rects = (0, _nodes.fitRects)(fit, src, dst);
14
- return (0, _nodes.rect2rect)(rects.src, rects.dst);
12
+ const fitbox = (fit, src, dst, rotation = 0) => {
13
+ "worklet";
14
+
15
+ const rects = (0, _nodes.fitRects)(fit, rotation === 90 || rotation === 270 ? {
16
+ x: 0,
17
+ y: 0,
18
+ width: src.height,
19
+ height: src.width
20
+ } : src, dst);
21
+ const result = (0, _nodes.rect2rect)(rects.src, rects.dst);
22
+ if (rotation === 90) {
23
+ return [...result, {
24
+ translate: [src.height, 0]
25
+ }, {
26
+ rotate: Math.PI / 2
27
+ }];
28
+ }
29
+ if (rotation === 180) {
30
+ return [...result, {
31
+ translate: [src.width, src.height]
32
+ }, {
33
+ rotate: Math.PI
34
+ }];
35
+ }
36
+ if (rotation === 270) {
37
+ return [...result, {
38
+ translate: [0, src.width]
39
+ }, {
40
+ rotate: -Math.PI / 2
41
+ }];
42
+ }
43
+ return result;
15
44
  };
16
45
  exports.fitbox = fitbox;
17
46
  const FitBox = ({
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_nodes","_Group","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","fitbox","fit","src","dst","rects","fitRects","rect2rect","exports","FitBox","children","transform","useMemo","createElement","Group"],"sources":["FitBox.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useMemo } from \"react\";\n\nimport type { Fit } from \"../../../dom/nodes\";\nimport { fitRects, rect2rect } from \"../../../dom/nodes\";\nimport type { SkRect } from \"../../../skia/types\";\nimport { Group } from \"../Group\";\n\ninterface FitProps {\n fit?: Fit;\n src: SkRect;\n dst: SkRect;\n children: ReactNode | ReactNode[];\n}\n\nexport const fitbox = (fit: Fit, src: SkRect, dst: SkRect) => {\n const rects = fitRects(fit, src, dst);\n return rect2rect(rects.src, rects.dst);\n};\n\nexport const FitBox = ({ fit = \"contain\", src, dst, children }: FitProps) => {\n const transform = useMemo(() => fitbox(fit, src, dst), [dst, fit, src]);\n return <Group transform={transform}>{children}</Group>;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OA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,GAAG,IAAAC,eAAQ,EAACJ,GAAG,EAAEC,GAAG,EAAEC,GAAG,CAAC;EACrC,OAAO,IAAAG,gBAAS,EAACF,KAAK,CAACF,GAAG,EAAEE,KAAK,CAACD,GAAG,CAAC;AACxC,CAAC;AAACI,OAAA,CAAAP,MAAA,GAAAA,MAAA;AAEK,MAAMQ,MAAM,GAAGA,CAAC;EAAEP,GAAG,GAAG,SAAS;EAAEC,GAAG;EAAEC,GAAG;EAAEM;AAAmB,CAAC,KAAK;EAC3E,MAAMC,SAAS,GAAG,IAAAC,cAAO,EAAC,MAAMX,MAAM,CAACC,GAAG,EAAEC,GAAG,EAAEC,GAAG,CAAC,EAAE,CAACA,GAAG,EAAEF,GAAG,EAAEC,GAAG,CAAC,CAAC;EACvE,oBAAO5B,MAAA,CAAAW,OAAA,CAAA2B,aAAA,CAAClC,MAAA,CAAAmC,KAAK;IAACH,SAAS,EAAEA;EAAU,GAAED,QAAgB,CAAC;AACxD,CAAC;AAACF,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_nodes","_Group","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","fitbox","fit","src","dst","rotation","rects","fitRects","x","y","width","height","result","rect2rect","translate","rotate","Math","PI","exports","FitBox","children","transform","useMemo","createElement","Group"],"sources":["FitBox.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport React, { useMemo } from \"react\";\n\nimport type { Fit } from \"../../../dom/nodes\";\nimport { fitRects, rect2rect } from \"../../../dom/nodes\";\nimport type { SkRect, Transforms3d } from \"../../../skia/types\";\nimport { Group } from \"../Group\";\n\ninterface FitProps {\n fit?: Fit;\n src: SkRect;\n dst: SkRect;\n children: ReactNode | ReactNode[];\n}\n\nexport const fitbox = (\n fit: Fit,\n src: SkRect,\n dst: SkRect,\n rotation: 0 | 90 | 180 | 270 = 0\n) => {\n \"worklet\";\n const rects = fitRects(\n fit,\n rotation === 90 || rotation === 270\n ? { x: 0, y: 0, width: src.height, height: src.width }\n : src,\n dst\n );\n const result = rect2rect(rects.src, rects.dst);\n if (rotation === 90) {\n return [\n ...result,\n { translate: [src.height, 0] },\n { rotate: Math.PI / 2 },\n ] as Transforms3d;\n }\n if (rotation === 180) {\n return [\n ...result,\n { translate: [src.width, src.height] },\n { rotate: Math.PI },\n ] as Transforms3d;\n }\n if (rotation === 270) {\n return [\n ...result,\n { translate: [0, src.width] },\n { rotate: -Math.PI / 2 },\n ] as Transforms3d;\n }\n return result;\n};\n\nexport const FitBox = ({ fit = \"contain\", src, dst, children }: FitProps) => {\n const transform = useMemo(() => fitbox(fit, src, dst), [dst, fit, src]);\n return <Group transform={transform}>{children}</Group>;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAAiC,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WA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,GAAG,EAAE;IACpB,OAAO,CACL,GAAGO,MAAM,EACT;MAAEE,SAAS,EAAE,CAACX,GAAG,CAACO,KAAK,EAAEP,GAAG,CAACQ,MAAM;IAAE,CAAC,EACtC;MAAEI,MAAM,EAAEC,IAAI,CAACC;IAAG,CAAC,CACpB;EACH;EACA,IAAIZ,QAAQ,KAAK,GAAG,EAAE;IACpB,OAAO,CACL,GAAGO,MAAM,EACT;MAAEE,SAAS,EAAE,CAAC,CAAC,EAAEX,GAAG,CAACO,KAAK;IAAE,CAAC,EAC7B;MAAEK,MAAM,EAAE,CAACC,IAAI,CAACC,EAAE,GAAG;IAAE,CAAC,CACzB;EACH;EACA,OAAOL,MAAM;AACf,CAAC;AAACM,OAAA,CAAAjB,MAAA,GAAAA,MAAA;AAEK,MAAMkB,MAAM,GAAGA,CAAC;EAAEjB,GAAG,GAAG,SAAS;EAAEC,GAAG;EAAEC,GAAG;EAAEgB;AAAmB,CAAC,KAAK;EAC3E,MAAMC,SAAS,GAAG,IAAAC,cAAO,EAAC,MAAMrB,MAAM,CAACC,GAAG,EAAEC,GAAG,EAAEC,GAAG,CAAC,EAAE,CAACA,GAAG,EAAEF,GAAG,EAAEC,GAAG,CAAC,CAAC;EACvE,oBAAO5B,MAAA,CAAAW,OAAA,CAAAqC,aAAA,CAAC5C,MAAA,CAAA6C,KAAK;IAACH,SAAS,EAAEA;EAAU,GAAED,QAAgB,CAAC;AACxD,CAAC;AAACF,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
@@ -6,6 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.processTransform2d = void 0;
7
7
  var _Skia = require("../Skia");
8
8
  var _types = require("../types");
9
- const processTransform2d = transforms => (0, _types.processTransform)(_Skia.Skia.Matrix(), transforms);
9
+ const processTransform2d = transforms => {
10
+ "worklet";
11
+
12
+ return (0, _types.processTransform)(_Skia.Skia.Matrix(), transforms);
13
+ };
10
14
  exports.processTransform2d = processTransform2d;
11
15
  //# sourceMappingURL=Matrix.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Skia","require","_types","processTransform2d","transforms","processTransform","Skia","Matrix","exports"],"sources":["Matrix.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Transforms3d } from \"../types\";\nimport { processTransform } from \"../types\";\n\nexport const processTransform2d = (transforms: Transforms3d) =>\n processTransform(Skia.Matrix(), transforms);\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,GAAIC,UAAwB,IACzD,IAAAC,uBAAgB,EAACC,UAAI,CAACC,MAAM,CAAC,CAAC,EAAEH,UAAU,CAAC;AAACI,OAAA,CAAAL,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_Skia","require","_types","processTransform2d","transforms","processTransform","Skia","Matrix","exports"],"sources":["Matrix.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Transforms3d } from \"../types\";\nimport { processTransform } from \"../types\";\n\nexport const processTransform2d = (transforms: Transforms3d) => {\n \"worklet\";\n return processTransform(Skia.Matrix(), transforms);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,GAAIC,UAAwB,IAAK;EAC9D,SAAS;;EACT,OAAO,IAAAC,uBAAgB,EAACC,UAAI,CAACC,MAAM,CAAC,CAAC,EAAEH,UAAU,CAAC;AACpD,CAAC;AAACI,OAAA,CAAAL,kBAAA,GAAAA,kBAAA"}
@@ -8,6 +8,8 @@ var _Matrix = require("./Matrix4");
8
8
  const isMatrix = obj => obj !== null && obj.__typename__ === "Matrix";
9
9
  exports.isMatrix = isMatrix;
10
10
  const processTransform = (m, transforms) => {
11
+ "worklet";
12
+
11
13
  const m3 = (0, _Matrix.processTransform3d)(transforms);
12
14
  m.concat(m3);
13
15
  return m;
@@ -1 +1 @@
1
- {"version":3,"names":["_Matrix","require","isMatrix","obj","__typename__","exports","processTransform","m","transforms","m3","processTransform3d","concat","toDegrees","rad","Math","PI"],"sources":["Matrix.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\nimport type { SkCanvas } from \"./Canvas\";\nimport type { Matrix3, Matrix4, Transforms3d } from \"./Matrix4\";\nimport { processTransform3d } from \"./Matrix4\";\n\nexport const isMatrix = (obj: unknown): obj is SkMatrix =>\n obj !== null && (obj as SkJSIInstance<string>).__typename__ === \"Matrix\";\n\nexport interface SkMatrix extends SkJSIInstance<\"Matrix\"> {\n concat: (matrix: InputMatrix) => SkMatrix;\n translate: (x: number, y: number) => SkMatrix;\n scale: (x: number, y?: number) => SkMatrix;\n skew: (x: number, y: number) => SkMatrix;\n rotate: (theta: number) => SkMatrix;\n postTranslate: (x: number, y: number) => SkMatrix;\n postScale: (x: number, y?: number) => SkMatrix;\n postSkew: (x: number, y: number) => SkMatrix;\n postRotate: (theta: number) => SkMatrix;\n identity: () => SkMatrix;\n get: () => number[];\n}\n\nexport type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];\n\nexport interface TransformProp {\n transform?: Transforms3d;\n}\n\nexport const processTransform = <T extends SkMatrix | SkCanvas>(\n m: T,\n transforms: Transforms3d\n) => {\n const m3 = processTransform3d(transforms);\n m.concat(m3);\n return m;\n};\n\nexport const toDegrees = (rad: number) => {\n return (rad * 180) / Math.PI;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAIC,GAAY,IACnCA,GAAG,KAAK,IAAI,IAAKA,GAAG,CAA2BC,YAAY,KAAK,QAAQ;AAACC,OAAA,CAAAH,QAAA,GAAAA,QAAA;AAsBpE,MAAMI,gBAAgB,GAAGA,CAC9BC,CAAI,EACJC,UAAwB,KACrB;EACH,MAAMC,EAAE,GAAG,IAAAC,0BAAkB,EAACF,UAAU,CAAC;EACzCD,CAAC,CAACI,MAAM,CAACF,EAAE,CAAC;EACZ,OAAOF,CAAC;AACV,CAAC;AAACF,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEK,MAAMM,SAAS,GAAIC,GAAW,IAAK;EACxC,OAAQA,GAAG,GAAG,GAAG,GAAIC,IAAI,CAACC,EAAE;AAC9B,CAAC;AAACV,OAAA,CAAAO,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_Matrix","require","isMatrix","obj","__typename__","exports","processTransform","m","transforms","m3","processTransform3d","concat","toDegrees","rad","Math","PI"],"sources":["Matrix.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\nimport type { SkCanvas } from \"./Canvas\";\nimport type { Matrix3, Matrix4, Transforms3d } from \"./Matrix4\";\nimport { processTransform3d } from \"./Matrix4\";\n\nexport const isMatrix = (obj: unknown): obj is SkMatrix =>\n obj !== null && (obj as SkJSIInstance<string>).__typename__ === \"Matrix\";\n\nexport interface SkMatrix extends SkJSIInstance<\"Matrix\"> {\n concat: (matrix: InputMatrix) => SkMatrix;\n translate: (x: number, y: number) => SkMatrix;\n scale: (x: number, y?: number) => SkMatrix;\n skew: (x: number, y: number) => SkMatrix;\n rotate: (theta: number) => SkMatrix;\n postTranslate: (x: number, y: number) => SkMatrix;\n postScale: (x: number, y?: number) => SkMatrix;\n postSkew: (x: number, y: number) => SkMatrix;\n postRotate: (theta: number) => SkMatrix;\n identity: () => SkMatrix;\n get: () => number[];\n}\n\nexport type InputMatrix = SkMatrix | Matrix3 | Matrix4 | number[];\n\nexport interface TransformProp {\n transform?: Transforms3d;\n}\n\nexport const processTransform = <T extends SkMatrix | SkCanvas>(\n m: T,\n transforms: Transforms3d\n) => {\n \"worklet\";\n const m3 = processTransform3d(transforms);\n m.concat(m3);\n return m;\n};\n\nexport const toDegrees = (rad: number) => {\n return (rad * 180) / Math.PI;\n};\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAIC,GAAY,IACnCA,GAAG,KAAK,IAAI,IAAKA,GAAG,CAA2BC,YAAY,KAAK,QAAQ;AAACC,OAAA,CAAAH,QAAA,GAAAA,QAAA;AAsBpE,MAAMI,gBAAgB,GAAGA,CAC9BC,CAAI,EACJC,UAAwB,KACrB;EACH,SAAS;;EACT,MAAMC,EAAE,GAAG,IAAAC,0BAAkB,EAACF,UAAU,CAAC;EACzCD,CAAC,CAACI,MAAM,CAACF,EAAE,CAAC;EACZ,OAAOF,CAAC;AACV,CAAC;AAACF,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEK,MAAMM,SAAS,GAAIC,GAAW,IAAK;EACxC,OAAQA,GAAG,GAAG,GAAG,GAAIC,IAAI,CAACC,EAAE;AAC9B,CAAC;AAACV,OAAA,CAAAO,SAAA,GAAAA,SAAA"}
@@ -1,5 +1,7 @@
1
1
  import type { SkImage } from "../Image";
2
- export type NativeBuffer<T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown> = T;
2
+ export declare abstract class CanvasKitWebGLBuffer {
3
+ }
4
+ export type NativeBuffer<T extends bigint | ArrayBuffer | CanvasImageSource | CanvasKitWebGLBuffer | unknown = unknown> = T;
3
5
  export type NativeBufferAddr = NativeBuffer<bigint>;
4
6
  export type NativeBufferWeb = NativeBuffer<CanvasImageSource>;
5
7
  export type NativeBufferNode = NativeBuffer<ArrayBuffer>;
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isNativeBufferWeb = exports.isNativeBufferNode = exports.isNativeBufferAddr = void 0;
6
+ exports.isNativeBufferWeb = exports.isNativeBufferNode = exports.isNativeBufferAddr = exports.CanvasKitWebGLBuffer = void 0;
7
+ class CanvasKitWebGLBuffer {}
8
+ exports.CanvasKitWebGLBuffer = CanvasKitWebGLBuffer;
7
9
  const isNativeBufferAddr = buffer => buffer instanceof BigInt;
8
10
  exports.isNativeBufferAddr = isNativeBufferAddr;
9
- const isNativeBufferWeb = buffer => buffer instanceof HTMLVideoElement || buffer instanceof HTMLCanvasElement || buffer instanceof ImageBitmap || buffer instanceof OffscreenCanvas || buffer instanceof VideoFrame || buffer instanceof HTMLImageElement || buffer instanceof SVGImageElement;
11
+ const isNativeBufferWeb = buffer => buffer instanceof HTMLVideoElement || buffer instanceof HTMLCanvasElement || buffer instanceof ImageBitmap || buffer instanceof OffscreenCanvas || buffer instanceof VideoFrame || buffer instanceof HTMLImageElement || buffer instanceof SVGImageElement || buffer instanceof CanvasKitWebGLBuffer;
10
12
  exports.isNativeBufferWeb = isNativeBufferWeb;
11
13
  const isNativeBufferNode = buffer => buffer instanceof ArrayBuffer;
12
14
  exports.isNativeBufferNode = isNativeBufferNode;
@@ -1 +1 @@
1
- {"version":3,"names":["isNativeBufferAddr","buffer","BigInt","exports","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport type NativeBuffer<\n T extends bigint | ArrayBuffer | CanvasImageSource | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":";;;;;;AAUO,MAAMA,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AAACC,OAAA,CAAAH,kBAAA,GAAAA,kBAAA;AACnD,MAAMI,iBAAiB,GAC5BH,MAAoB,IAEpBA,MAAM,YAAYI,gBAAgB,IAClCJ,MAAM,YAAYK,iBAAiB,IACnCL,MAAM,YAAYM,WAAW,IAC7BN,MAAM,YAAYO,eAAe,IACjCP,MAAM,YAAYQ,UAAU,IAC5BR,MAAM,YAAYS,gBAAgB,IAClCT,MAAM,YAAYU,eAAe;AAACR,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAE7B,MAAMQ,kBAAkB,GAC7BX,MAAoB,IACWA,MAAM,YAAYY,WAAW;AAACV,OAAA,CAAAS,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["CanvasKitWebGLBuffer","exports","isNativeBufferAddr","buffer","BigInt","isNativeBufferWeb","HTMLVideoElement","HTMLCanvasElement","ImageBitmap","OffscreenCanvas","VideoFrame","HTMLImageElement","SVGImageElement","isNativeBufferNode","ArrayBuffer"],"sources":["NativeBufferFactory.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\n\nexport abstract class CanvasKitWebGLBuffer {}\n\nexport type NativeBuffer<\n T extends\n | bigint\n | ArrayBuffer\n | CanvasImageSource\n | CanvasKitWebGLBuffer\n | unknown = unknown\n> = T;\n\nexport type NativeBufferAddr = NativeBuffer<bigint>;\nexport type NativeBufferWeb = NativeBuffer<CanvasImageSource>;\nexport type NativeBufferNode = NativeBuffer<ArrayBuffer>;\n\nexport const isNativeBufferAddr = (\n buffer: NativeBuffer\n): buffer is NativeBufferAddr => buffer instanceof BigInt;\nexport const isNativeBufferWeb = (\n buffer: NativeBuffer\n): buffer is NativeBufferWeb =>\n buffer instanceof HTMLVideoElement ||\n buffer instanceof HTMLCanvasElement ||\n buffer instanceof ImageBitmap ||\n buffer instanceof OffscreenCanvas ||\n buffer instanceof VideoFrame ||\n buffer instanceof HTMLImageElement ||\n buffer instanceof SVGImageElement ||\n buffer instanceof CanvasKitWebGLBuffer;\n\nexport const isNativeBufferNode = (\n buffer: NativeBuffer\n): buffer is NativeBufferNode => buffer instanceof ArrayBuffer;\n\nexport interface NativeBufferFactory {\n /**\n * Copy pixels to a native buffer.\n */\n MakeFromImage: (image: SkImage) => NativeBuffer;\n /**\n * Release a native buffer that was created with `MakeFromImage`.\n */\n Release: (nativeBuffer: NativeBuffer) => void;\n}\n"],"mappings":";;;;;;AAEO,MAAeA,oBAAoB,CAAC;AAAEC,OAAA,CAAAD,oBAAA,GAAAA,oBAAA;AAetC,MAAME,kBAAkB,GAC7BC,MAAoB,IACWA,MAAM,YAAYC,MAAM;AAACH,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AACnD,MAAMG,iBAAiB,GAC5BF,MAAoB,IAEpBA,MAAM,YAAYG,gBAAgB,IAClCH,MAAM,YAAYI,iBAAiB,IACnCJ,MAAM,YAAYK,WAAW,IAC7BL,MAAM,YAAYM,eAAe,IACjCN,MAAM,YAAYO,UAAU,IAC5BP,MAAM,YAAYQ,gBAAgB,IAClCR,MAAM,YAAYS,eAAe,IACjCT,MAAM,YAAYH,oBAAoB;AAACC,OAAA,CAAAI,iBAAA,GAAAA,iBAAA;AAElC,MAAMQ,kBAAkB,GAC7BV,MAAoB,IACWA,MAAM,YAAYW,WAAW;AAACb,OAAA,CAAAY,kBAAA,GAAAA,kBAAA"}
@@ -73,6 +73,6 @@ export interface Skia {
73
73
  TextBlob: TextBlobFactory;
74
74
  Surface: SurfaceFactory;
75
75
  ParagraphBuilder: ParagraphBuilderFactory;
76
- Video: (url: string) => Video;
76
+ Video: (url: string) => Promise<Video> | Video;
77
77
  NativeBuffer: NativeBufferFactory;
78
78
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Video: (url: string) => Video;\n NativeBuffer: NativeBufferFactory;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkHostRect, SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\nimport type { Video } from \"./Video\";\nimport type { NativeBufferFactory } from \"./NativeBuffer\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkHostRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n RSXformFromRadians: (\n scale: number,\n radians: number,\n tx: number,\n ty: number,\n px: number,\n py: number\n ) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n ParagraphBuilder: ParagraphBuilderFactory;\n Video: (url: string) => Promise<Video> | Video;\n NativeBuffer: NativeBufferFactory;\n}\n"],"mappings":""}
@@ -1,9 +1,17 @@
1
1
  import type { SkImage } from "../Image";
2
2
  import type { SkJSIInstance } from "../JsiInstance";
3
+ export type VideoRotation = 0 | 90 | 180 | 270;
3
4
  export interface Video extends SkJSIInstance<"Video"> {
4
5
  duration(): number;
5
6
  framerate(): number;
6
7
  nextImage(): SkImage | null;
7
8
  seek(time: number): void;
8
- getRotationInDegrees(): number;
9
+ rotation(): VideoRotation;
10
+ size(): {
11
+ width: number;
12
+ height: number;
13
+ };
14
+ pause(): void;
15
+ play(): void;
16
+ setVolume(volume: number): void;
9
17
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n getRotationInDegrees(): number;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Video.ts"],"sourcesContent":["import type { SkImage } from \"../Image\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport type VideoRotation = 0 | 90 | 180 | 270;\n\nexport interface Video extends SkJSIInstance<\"Video\"> {\n duration(): number;\n framerate(): number;\n nextImage(): SkImage | null;\n seek(time: number): void;\n rotation(): VideoRotation;\n size(): { width: number; height: number };\n pause(): void;\n play(): void;\n setVolume(volume: number): void;\n}\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { Surface, TextureSource, Image } from "canvaskit-wasm";
2
+ import { CanvasKitWebGLBuffer } from "../types";
3
+ export declare class CanvasKitWebGLBufferImpl extends CanvasKitWebGLBuffer {
4
+ surface: Surface;
5
+ private source;
6
+ image: Image | null;
7
+ constructor(surface: Surface, source: TextureSource);
8
+ toImage(): Image;
9
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CanvasKitWebGLBufferImpl = void 0;
7
+ var _types = require("../types");
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ class CanvasKitWebGLBufferImpl extends _types.CanvasKitWebGLBuffer {
12
+ constructor(surface, source) {
13
+ super();
14
+ this.surface = surface;
15
+ this.source = source;
16
+ _defineProperty(this, "image", null);
17
+ }
18
+ toImage() {
19
+ if (this.image === null) {
20
+ this.image = this.surface.makeImageFromTextureSource(this.source);
21
+ }
22
+ if (this.image === null) {
23
+ throw new Error("Failed to create image from texture source");
24
+ }
25
+ this.surface.updateTextureFromSource(this.image, this.source);
26
+ return this.image;
27
+ }
28
+ }
29
+ exports.CanvasKitWebGLBufferImpl = CanvasKitWebGLBufferImpl;
30
+ //# sourceMappingURL=CanvasKitWebGLBufferImpl.js.map