@shopify/react-native-skia 0.1.234 → 0.1.236
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkTypefaceFactory.h +2 -1
- package/cpp/skia/include/android/AHardwareBufferUtils.h +23 -0
- package/cpp/skia/include/android/GrAHardwareBufferUtils.h +2 -0
- package/cpp/skia/include/android/graphite/SurfaceAndroid.h +59 -0
- package/cpp/skia/include/codec/SkAvifDecoder.h +1 -1
- package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
- package/cpp/skia/include/codec/SkCodec.h +21 -3
- package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
- package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
- package/cpp/skia/include/codec/SkJpegDecoder.h +1 -1
- package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
- package/cpp/skia/include/codec/SkPngDecoder.h +1 -1
- package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
- package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
- package/cpp/skia/include/codec/SkWebpDecoder.h +1 -1
- package/cpp/skia/include/config/SkUserConfig.h +3 -1
- package/cpp/skia/include/core/SkCanvas.h +66 -37
- package/cpp/skia/include/core/SkColorFilter.h +5 -2
- package/cpp/skia/include/core/SkContourMeasure.h +1 -0
- package/cpp/skia/include/core/SkDocument.h +1 -0
- package/cpp/skia/include/core/SkFont.h +14 -24
- package/cpp/skia/include/core/SkFontArguments.h +1 -1
- package/cpp/skia/include/core/SkFontMetrics.h +1 -1
- package/cpp/skia/include/core/SkFontMgr.h +0 -7
- package/cpp/skia/include/core/SkGraphics.h +13 -0
- package/cpp/skia/include/core/SkMesh.h +9 -13
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPathMeasure.h +2 -0
- package/cpp/skia/include/core/SkSerialProcs.h +29 -11
- package/cpp/skia/include/core/SkSize.h +3 -3
- package/cpp/skia/include/core/SkStream.h +3 -13
- package/cpp/skia/include/core/SkSurface.h +6 -3
- package/cpp/skia/include/core/SkSurfaceProps.h +2 -4
- package/cpp/skia/include/core/SkTraceMemoryDump.h +15 -0
- package/cpp/skia/include/core/SkTypeface.h +8 -56
- package/cpp/skia/include/core/SkTypes.h +8 -0
- package/cpp/skia/include/core/SkVertices.h +1 -1
- package/cpp/skia/include/docs/SkMultiPictureDocument.h +53 -0
- package/cpp/skia/include/docs/SkPDFDocument.h +11 -0
- package/cpp/skia/include/effects/SkGradientShader.h +9 -0
- package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -7
- package/cpp/skia/include/gpu/GrBackendSemaphore.h +33 -47
- package/cpp/skia/include/gpu/GrBackendSurface.h +2 -3
- package/cpp/skia/include/gpu/GrContextOptions.h +0 -6
- package/cpp/skia/include/gpu/GrContextThreadSafeProxy.h +44 -28
- package/cpp/skia/include/gpu/GrDirectContext.h +12 -31
- package/cpp/skia/include/gpu/GrTypes.h +1 -16
- package/cpp/skia/include/gpu/MutableTextureState.h +35 -80
- package/cpp/skia/include/gpu/ShaderErrorHandler.h +11 -1
- package/cpp/skia/include/gpu/ganesh/SkImageGanesh.h +2 -2
- package/cpp/skia/include/gpu/ganesh/SkSurfaceGanesh.h +1 -1
- package/cpp/skia/include/gpu/ganesh/gl/GrGLDirectContext.h +3 -2
- package/cpp/skia/include/gpu/ganesh/vk/GrVkBackendSemaphore.h +20 -0
- package/cpp/skia/include/gpu/ganesh/vk/GrVkDirectContext.h +30 -0
- package/cpp/skia/include/gpu/gl/GrGLFunctions.h +1 -1
- package/cpp/skia/include/gpu/gl/GrGLInterface.h +2 -0
- package/cpp/skia/include/gpu/gl/glx/GrGLMakeGLXInterface.h +6 -0
- package/cpp/skia/include/gpu/graphite/BackendSemaphore.h +3 -3
- package/cpp/skia/include/gpu/graphite/BackendTexture.h +39 -27
- package/cpp/skia/include/gpu/graphite/Context.h +39 -13
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +2 -0
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +2 -1
- package/cpp/skia/include/gpu/graphite/Image.h +106 -87
- package/cpp/skia/include/gpu/graphite/Recorder.h +24 -3
- package/cpp/skia/include/gpu/graphite/Surface.h +7 -2
- package/cpp/skia/include/gpu/graphite/dawn/DawnBackendContext.h +41 -2
- package/cpp/skia/include/gpu/graphite/dawn/DawnTypes.h +11 -6
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -2
- package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +6 -6
- package/cpp/skia/include/gpu/mock/GrMockTypes.h +1 -0
- package/cpp/skia/include/gpu/vk/GrVkBackendContext.h +1 -1
- package/cpp/skia/include/gpu/vk/GrVkTypes.h +1 -44
- package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
- package/cpp/skia/include/gpu/vk/VulkanMutableTextureState.h +25 -0
- package/cpp/skia/include/gpu/vk/VulkanTypes.h +44 -0
- package/cpp/skia/include/ports/SkFontConfigInterface.h +3 -6
- package/cpp/skia/include/private/SkEncodedInfo.h +5 -0
- package/cpp/skia/include/private/SkExif.h +102 -0
- package/cpp/skia/include/private/SkGainmapInfo.h +11 -1
- package/cpp/skia/include/private/base/SkAssert.h +16 -0
- package/cpp/skia/include/private/base/SkDeque.h +2 -7
- package/cpp/skia/include/private/base/SkLoadUserConfig.h +1 -1
- package/cpp/skia/include/private/base/SkTArray.h +69 -28
- package/cpp/skia/include/private/base/SkThreadAnnotations.h +18 -5
- package/cpp/skia/include/private/chromium/GrSurfaceCharacterization.h +26 -30
- package/cpp/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h +4 -3
- package/cpp/skia/include/private/chromium/SkImageChromium.h +1 -1
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +8 -6
- package/cpp/skia/include/private/gpu/graphite/ContextOptionsPriv.h +29 -0
- package/cpp/skia/include/private/gpu/graphite/DawnTypesPriv.h +12 -9
- package/cpp/skia/include/private/gpu/graphite/VulkanGraphiteTypesPriv.h +16 -11
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_platform.h +2 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std.h +312 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h264std_decode.h +77 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std.h +446 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codec_h265std_decode.h +67 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vk_video/vulkan_video_codecs_common.h +36 -0
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan.h +9 -2
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_android.h +31 -3
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_core.h +10624 -5716
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_ios.h +2 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_macos.h +2 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_win32.h +28 -1
- package/cpp/skia/include/third_party/vulkan/vulkan/vulkan_xcb.h +2 -1
- package/cpp/skia/include/utils/mac/SkCGUtils.h +23 -11
- package/cpp/skia/modules/skcms/skcms.h +2 -410
- package/cpp/skia/modules/skcms/src/Transform_inl.h +831 -704
- package/cpp/skia/modules/skcms/src/skcms_Transform.h +161 -0
- package/cpp/skia/modules/skcms/src/skcms_internals.h +136 -0
- package/cpp/skia/modules/skcms/src/skcms_public.h +404 -0
- package/cpp/skia/modules/skparagraph/include/FontArguments.h +1 -1
- package/cpp/skia/modules/skparagraph/include/FontCollection.h +2 -0
- package/cpp/skia/modules/skparagraph/include/Paragraph.h +2 -2
- package/cpp/skia/modules/skparagraph/include/TextStyle.h +4 -3
- package/cpp/skia/modules/skparagraph/include/TypefaceFontProvider.h +1 -3
- package/cpp/skia/modules/skresources/include/SkResources.h +28 -17
- package/cpp/skia/modules/skunicode/include/SkUnicode.h +12 -0
- package/cpp/skia/modules/svg/include/SkSVGDOM.h +4 -1
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +4 -1
- package/cpp/skia/src/base/SkUTF.h +7 -0
- package/cpp/skia/src/core/SkTHash.h +20 -8
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +3 -2
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -57
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/external/reanimated/index.d.ts +1 -0
- package/lib/commonjs/external/reanimated/index.js +13 -0
- package/lib/commonjs/external/reanimated/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/interpolators.js +13 -1
- package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
- package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +1 -0
- package/lib/commonjs/external/reanimated/moduleWrapper.js +5 -3
- package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/commonjs/external/reanimated/textures.d.ts +5 -0
- package/lib/commonjs/external/reanimated/textures.js +52 -0
- package/lib/commonjs/external/reanimated/textures.js.map +1 -0
- package/lib/commonjs/headless/index.js +1 -1
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +3 -0
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +1 -1
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/Container.d.ts +1 -1
- package/lib/commonjs/renderer/Container.js +2 -1
- package/lib/commonjs/renderer/Container.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.d.ts +1 -0
- package/lib/commonjs/renderer/Offscreen.js +18 -5
- package/lib/commonjs/renderer/Offscreen.js.map +1 -1
- package/lib/commonjs/renderer/Reconciler.d.ts +1 -1
- package/lib/commonjs/renderer/Reconciler.js +7 -4
- package/lib/commonjs/renderer/Reconciler.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +2 -2
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.d.ts +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +3 -2
- package/lib/module/dom/nodes/JsiSkDOM.js +56 -56
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/external/reanimated/index.d.ts +1 -0
- package/lib/module/external/reanimated/index.js +1 -0
- package/lib/module/external/reanimated/index.js.map +1 -1
- package/lib/module/external/reanimated/interpolators.js +13 -1
- package/lib/module/external/reanimated/interpolators.js.map +1 -1
- package/lib/module/external/reanimated/moduleWrapper.d.ts +1 -0
- package/lib/module/external/reanimated/moduleWrapper.js +3 -2
- package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
- package/lib/module/external/reanimated/textures.d.ts +5 -0
- package/lib/module/external/reanimated/textures.js +35 -0
- package/lib/module/external/reanimated/textures.js.map +1 -0
- package/lib/module/headless/index.js +1 -1
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/mock/index.js +3 -0
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +1 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/Container.d.ts +1 -1
- package/lib/module/renderer/Container.js +2 -1
- package/lib/module/renderer/Container.js.map +1 -1
- package/lib/module/renderer/Offscreen.d.ts +1 -0
- package/lib/module/renderer/Offscreen.js +11 -3
- package/lib/module/renderer/Offscreen.js.map +1 -1
- package/lib/module/renderer/Reconciler.d.ts +1 -1
- package/lib/module/renderer/Reconciler.js +7 -4
- package/lib/module/renderer/Reconciler.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +2 -2
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.d.ts +1 -1
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +3 -2
- package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +1 -0
- package/lib/typescript/src/external/reanimated/textures.d.ts +5 -0
- package/lib/typescript/src/renderer/Container.d.ts +1 -1
- package/lib/typescript/src/renderer/Offscreen.d.ts +1 -0
- package/lib/typescript/src/renderer/Reconciler.d.ts +1 -1
- package/lib/typescript/src/skia/types/Matrix4.d.ts +2 -2
- package/lib/typescript/src/skia/types/Shader/Shader.d.ts +1 -1
- package/libs/android/arm64-v8a/libskia.a +0 -0
- package/libs/android/arm64-v8a/libskottie.a +0 -0
- package/libs/android/arm64-v8a/libskparagraph.a +0 -0
- package/libs/android/arm64-v8a/libsksg.a +0 -0
- package/libs/android/arm64-v8a/libskshaper.a +0 -0
- package/libs/android/arm64-v8a/libskunicode.a +0 -0
- package/libs/android/arm64-v8a/libsvg.a +0 -0
- package/libs/android/armeabi-v7a/libskia.a +0 -0
- package/libs/android/armeabi-v7a/libskottie.a +0 -0
- package/libs/android/armeabi-v7a/libskparagraph.a +0 -0
- package/libs/android/armeabi-v7a/libsksg.a +0 -0
- package/libs/android/armeabi-v7a/libskshaper.a +0 -0
- package/libs/android/armeabi-v7a/libskunicode.a +0 -0
- package/libs/android/armeabi-v7a/libsvg.a +0 -0
- package/libs/android/x86/libskia.a +0 -0
- package/libs/android/x86/libskottie.a +0 -0
- package/libs/android/x86/libskparagraph.a +0 -0
- package/libs/android/x86/libsksg.a +0 -0
- package/libs/android/x86/libskshaper.a +0 -0
- package/libs/android/x86/libskunicode.a +0 -0
- package/libs/android/x86/libsvg.a +0 -0
- package/libs/android/x86_64/libskia.a +0 -0
- package/libs/android/x86_64/libskottie.a +0 -0
- package/libs/android/x86_64/libskparagraph.a +0 -0
- package/libs/android/x86_64/libsksg.a +0 -0
- package/libs/android/x86_64/libskshaper.a +0 -0
- package/libs/android/x86_64/libskunicode.a +0 -0
- package/libs/android/x86_64/libsvg.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/Info.plist +5 -5
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/dom/nodes/JsiSkDOM.ts +55 -56
- package/src/external/reanimated/index.ts +1 -0
- package/src/external/reanimated/interpolators.ts +15 -2
- package/src/external/reanimated/moduleWrapper.ts +1 -0
- package/src/external/reanimated/textures.tsx +50 -0
- package/src/headless/index.ts +1 -1
- package/src/mock/index.ts +3 -0
- package/src/renderer/Canvas.tsx +1 -1
- package/src/renderer/Container.tsx +3 -2
- package/src/renderer/Offscreen.tsx +12 -3
- package/src/renderer/Reconciler.tsx +5 -2
- package/src/skia/types/Matrix4.ts +2 -2
- package/src/skia/types/Shader/Shader.ts +6 -1
- package/cpp/skia/include/gpu/GrSurfaceInfo.h +0 -142
- package/cpp/skia/include/private/gpu/ganesh/GrGLTypesPriv.h +0 -107
- package/cpp/skia/include/private/gpu/ganesh/GrMockTypesPriv.h +0 -32
- package/cpp/skia/include/private/gpu/ganesh/GrMtlTypesPriv.h +0 -83
- package/cpp/skia/include/private/gpu/ganesh/GrVkTypesPriv.h +0 -47
- package/cpp/skia/include/private/gpu/vk/VulkanTypesPriv.h +0 -57
- package/cpp/skia/include/utils/SkBase64.h +0 -53
- package/cpp/skia/modules/skcms/skcms_internal.h +0 -56
@@ -46,6 +46,18 @@ const useInterpolator = (factory, value, interpolator, input, output, options) =
|
|
46
46
|
return result;
|
47
47
|
};
|
48
48
|
|
49
|
-
export const usePathInterpolation = (value, input, outputRange, options) =>
|
49
|
+
export const usePathInterpolation = (value, input, outputRange, options) => {
|
50
|
+
// Check if all paths in outputRange are interpolable
|
51
|
+
const allPathsInterpolable = outputRange.slice(1).every(path => outputRange[0].isInterpolatable(path));
|
52
|
+
|
53
|
+
if (!allPathsInterpolable) {
|
54
|
+
// Handle the case where not all paths are interpolable
|
55
|
+
// For example, throw an error or return early
|
56
|
+
throw new Error(`Not all paths in the output range are interpolable.
|
57
|
+
See: https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathinterpolation`);
|
58
|
+
}
|
59
|
+
|
60
|
+
return useInterpolator(() => Skia.Path.Make(), value, interpolatePaths, input, outputRange, options);
|
61
|
+
};
|
50
62
|
export const useVectorInterpolation = (value, input, outputRange, options) => useInterpolator(() => Skia.Point(0, 0), value, interpolateVector, input, outputRange, options);
|
51
63
|
//# sourceMappingURL=interpolators.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","Platform","useAnimatedReaction","useFrameCallback","useSharedValue","useDerivedValue","notifyChange","value","_WORKLET","OS","_value","usePathValue","cb","pathInit","Path","Make","path","reset","useClock","clock","callback","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { Platform } from \"../../Platform\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET || Platform.OS === \"web\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n)
|
1
|
+
{"version":3,"names":["useCallback","useMemo","interpolatePaths","interpolateVector","Skia","Platform","useAnimatedReaction","useFrameCallback","useSharedValue","useDerivedValue","notifyChange","value","_WORKLET","OS","_value","usePathValue","cb","pathInit","Path","Make","path","reset","useClock","clock","callback","info","timeSinceFirstFrame","useInterpolator","factory","interpolator","input","output","options","init","result","val","usePathInterpolation","outputRange","allPathsInterpolable","slice","every","isInterpolatable","Error","useVectorInterpolation","Point"],"sources":["interpolators.ts"],"sourcesContent":["import type {\n ExtrapolationType,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\nimport { useCallback, useMemo } from \"react\";\n\nimport type { SkPath, SkPoint } from \"../../skia/types\";\nimport { interpolatePaths, interpolateVector } from \"../../animation\";\nimport { Skia } from \"../../skia\";\nimport { Platform } from \"../../Platform\";\n\nimport {\n useAnimatedReaction,\n useFrameCallback,\n useSharedValue,\n useDerivedValue,\n} from \"./moduleWrapper\";\n\nexport const notifyChange = (value: SharedValue<unknown>) => {\n \"worklet\";\n if (_WORKLET || Platform.OS === \"web\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (value as any)._value = value.value;\n }\n};\n\nexport const usePathValue = (cb: (path: SkPath) => void) => {\n const pathInit = useMemo(() => Skia.Path.Make(), []);\n const path = useSharedValue(pathInit);\n useDerivedValue(() => {\n path.value.reset();\n cb(path.value);\n notifyChange(path);\n });\n return path;\n};\n\nexport const useClock = () => {\n const clock = useSharedValue(0);\n const callback = useCallback(\n (info: FrameInfo) => {\n \"worklet\";\n clock.value = info.timeSinceFirstFrame;\n },\n [clock]\n );\n useFrameCallback(callback);\n return clock;\n};\n\n/**\n * @worklet\n */\ntype Interpolator<T> = (\n value: number,\n input: number[],\n output: T[],\n options: ExtrapolationType,\n result: T\n) => T;\n\nconst useInterpolator = <T>(\n factory: () => T,\n value: SharedValue<number>,\n interpolator: Interpolator<T>,\n input: number[],\n output: T[],\n options?: ExtrapolationType\n) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const init = useMemo(() => factory(), []);\n const result = useSharedValue(init);\n useAnimatedReaction(\n () => value.value,\n (val) => {\n result.value = interpolator(val, input, output, options, result.value);\n notifyChange(result);\n },\n [input, output, options]\n );\n return result;\n};\n\nexport const usePathInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPath[],\n options?: ExtrapolationType\n) => {\n // Check if all paths in outputRange are interpolable\n const allPathsInterpolable = outputRange\n .slice(1)\n .every((path) => outputRange[0].isInterpolatable(path));\n if (!allPathsInterpolable) {\n // Handle the case where not all paths are interpolable\n // For example, throw an error or return early\n throw new Error(\n `Not all paths in the output range are interpolable.\nSee: https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathinterpolation`\n );\n }\n return useInterpolator(\n () => Skia.Path.Make(),\n value,\n interpolatePaths,\n input,\n outputRange,\n options\n );\n};\n\nexport const useVectorInterpolation = (\n value: SharedValue<number>,\n input: number[],\n outputRange: SkPoint[],\n options?: ExtrapolationType\n) =>\n useInterpolator(\n () => Skia.Point(0, 0),\n value,\n interpolateVector,\n input,\n outputRange,\n options\n );\n"],"mappings":"AAKA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,OAArC;AAGA,SAASC,gBAAT,EAA2BC,iBAA3B,QAAoD,iBAApD;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,QAAT,QAAyB,gBAAzB;AAEA,SACEC,mBADF,EAEEC,gBAFF,EAGEC,cAHF,EAIEC,eAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,YAAY,GAAIC,KAAD,IAAiC;EAC3D;;EACA,IAAIC,QAAQ,IAAIP,QAAQ,CAACQ,EAAT,KAAgB,KAAhC,EAAuC;IACrC;IACCF,KAAD,CAAeG,MAAf,GAAwBH,KAAK,CAACA,KAA9B;EACD;AACF,CANM;AAQP,OAAO,MAAMI,YAAY,GAAIC,EAAD,IAAgC;EAC1D,MAAMC,QAAQ,GAAGhB,OAAO,CAAC,MAAMG,IAAI,CAACc,IAAL,CAAUC,IAAV,EAAP,EAA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AFkC,EAGlCO,WAHkC,EAIlCL,OAJkC,KAK/B;EACH;EACA,MAAMM,oBAAoB,GAAGD,WAAW,CACrCE,KAD0B,CACpB,CADoB,EAE1BC,KAF0B,CAEnBpB,IAAD,IAAUiB,WAAW,CAAC,CAAD,CAAX,CAAeI,gBAAf,CAAgCrB,IAAhC,CAFU,CAA7B;;EAGA,IAAI,CAACkB,oBAAL,EAA2B;IACzB;IACA;IACA,MAAM,IAAII,KAAJ,CACH;AACP,4FAFU,CAAN;EAID;;EACD,OAAOf,eAAe,CACpB,MAAMvB,IAAI,CAACc,IAAL,CAAUC,IAAV,EADc,EAEpBR,KAFoB,EAGpBT,gBAHoB,EAIpB4B,KAJoB,EAKpBO,WALoB,EAMpBL,OANoB,CAAtB;AAQD,CA1BM;AA4BP,OAAO,MAAMW,sBAAsB,GAAG,CACpChC,KADoC,EAEpCmB,KAFoC,EAGpCO,WAHoC,EAIpCL,OAJoC,KAMpCL,eAAe,CACb,MAAMvB,IAAI,CAACwC,KAAL,CAAW,CAAX,EAAc,CAAd,CADO,EAEbjC,KAFa,EAGbR,iBAHa,EAIb2B,KAJa,EAKbO,WALa,EAMbL,OANa,CANV"}
|
@@ -9,5 +9,6 @@ export declare const useFrameCallback: (callback: (frameInfo: FrameInfo) => void
|
|
9
9
|
export declare const startMapper: (worklet: () => void, inputs?: unknown[], outputs?: unknown[]) => number;
|
10
10
|
export declare const stopMapper: (mapperID: number) => void;
|
11
11
|
export declare const runOnJS: any;
|
12
|
+
export declare const runOnUI: any;
|
12
13
|
export declare const useAnimatedReaction: <T>(prepare: () => T, react: (v: T) => void, dependencies?: DependencyList) => void;
|
13
14
|
export declare const isSharedValue: <T>(value: unknown) => value is SharedValue<T>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7;
|
1
|
+
var _Reanimated, _Reanimated2, _Reanimated3, _Reanimated4, _Reanimated5, _Reanimated6, _Reanimated7, _Reanimated8;
|
2
2
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
4
4
|
// This one is needed for the deprecated useSharedValue function
|
@@ -30,7 +30,8 @@ export const useFrameCallback = ((_Reanimated3 = Reanimated2) === null || _Reani
|
|
30
30
|
export const startMapper = ((_Reanimated4 = Reanimated2) === null || _Reanimated4 === void 0 ? void 0 : _Reanimated4.startMapper) || throwOnMissingReanimated;
|
31
31
|
export const stopMapper = ((_Reanimated5 = Reanimated2) === null || _Reanimated5 === void 0 ? void 0 : _Reanimated5.stopMapper) || throwOnMissingReanimated;
|
32
32
|
export const runOnJS = ((_Reanimated6 = Reanimated2) === null || _Reanimated6 === void 0 ? void 0 : _Reanimated6.runOnJS) || throwOnMissingReanimated;
|
33
|
-
export const
|
33
|
+
export const runOnUI = ((_Reanimated7 = Reanimated2) === null || _Reanimated7 === void 0 ? void 0 : _Reanimated7.runOnUI) || throwOnMissingReanimated;
|
34
|
+
export const useAnimatedReaction = ((_Reanimated8 = Reanimated2) === null || _Reanimated8 === void 0 ? void 0 : _Reanimated8.useAnimatedReaction) || throwOnMissingReanimated;
|
34
35
|
export const isSharedValue = value => {
|
35
36
|
return !!value && (Reanimated3 ? Reanimated3.isSharedValue(value) : value.value !== undefined);
|
36
37
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","useDerivedValue","useFrameCallback","startMapper","stopMapper","runOnJS","useAnimatedReaction","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;AAAA;AASA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GAAGC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAApE;;EACA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CATD,CASE,OAAOM,CAAP,EAAU,CAAE;;AAEd,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;AACP,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;AAEP,OAAO,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;AAED,OAAO,MAAMC,cAGM,GAAG,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,KAA+BF,wBAH9C;AAKP,OAAO,MAAMG,eAGO,GAAG,iBAAAZ,WAAW,UAAX,oDAAaY,eAAb,KAAgCH,wBAHhD;AAKP,OAAO,MAAMI,gBAGK,GAAG,iBAAAb,WAAW,UAAX,oDAAaa,gBAAb,KAAiCJ,wBAH/C;AAKP,OAAO,MAAMK,WAIF,GAAG,iBAAAd,WAAW,UAAX,oDAAac,WAAb,KAA4BL,wBAJnC;AAMP,OAAO,MAAMM,UAAsC,GACjD,iBAAAf,WAAW,UAAX,oDAAae,UAAb,KAA2BN,wBADtB;AAGP,OAAO,MAAMO,OAAO,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,OAAb,KAAwBP,wBAAxC;
|
1
|
+
{"version":3,"names":["Reanimated2","Reanimated3","reanimatedVersion","require","version","includes","e","HAS_REANIMATED2","HAS_REANIMATED3","throwOnMissingReanimated","Error","useSharedValue","useDerivedValue","useFrameCallback","startMapper","stopMapper","runOnJS","runOnUI","useAnimatedReaction","isSharedValue","value","undefined"],"sources":["moduleWrapper.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from \"react\";\nimport type {\n DerivedValue,\n FrameCallback,\n FrameInfo,\n SharedValue,\n} from \"react-native-reanimated\";\n\n// This one is needed for the deprecated useSharedValue function\n// We can remove it once we remove the deprecation\n\nlet Reanimated2: any;\n\nlet Reanimated3: any;\nlet reanimatedVersion: string;\n\ntry {\n Reanimated2 = require(\"react-native-reanimated\");\n reanimatedVersion = require(\"react-native-reanimated/package.json\").version;\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n Reanimated3 = Reanimated2;\n }\n} catch (e) {}\n\nexport const HAS_REANIMATED2 = !!Reanimated2;\nexport const HAS_REANIMATED3 = !!Reanimated3;\n\nexport function throwOnMissingReanimated() {\n if (!HAS_REANIMATED2) {\n throw new Error(\n \"Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \\\n react-native-skia's integration layer API.\"\n );\n }\n}\n\nexport const useSharedValue: <T>(\n init: T,\n oneWayReadsOnly?: boolean\n) => SharedValue<T> = Reanimated2?.useSharedValue || throwOnMissingReanimated;\n\nexport const useDerivedValue: <T>(\n processor: () => T,\n dependencies?: DependencyList\n) => DerivedValue<T> = Reanimated2?.useDerivedValue || throwOnMissingReanimated;\n\nexport const useFrameCallback: (\n callback: (frameInfo: FrameInfo) => void,\n autostart?: boolean\n) => FrameCallback = Reanimated2?.useFrameCallback || throwOnMissingReanimated;\n\nexport const startMapper: (\n worklet: () => void,\n inputs?: unknown[],\n outputs?: unknown[]\n) => number = Reanimated2?.startMapper || throwOnMissingReanimated;\n\nexport const stopMapper: (mapperID: number) => void =\n Reanimated2?.stopMapper || throwOnMissingReanimated;\n\nexport const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;\nexport const runOnUI = Reanimated2?.runOnUI || throwOnMissingReanimated;\n\nexport const useAnimatedReaction: <T>(\n prepare: () => T,\n react: (v: T) => void,\n dependencies?: DependencyList\n) => void = Reanimated2?.useAnimatedReaction || throwOnMissingReanimated;\n\nexport const isSharedValue = <T>(value: unknown): value is SharedValue<T> => {\n return (\n !!value &&\n (Reanimated3\n ? Reanimated3.isSharedValue(value)\n : (value as any).value !== undefined)\n );\n};\n"],"mappings":";;AAAA;AASA;AACA;AAEA,IAAIA,WAAJ;AAEA,IAAIC,WAAJ;AACA,IAAIC,iBAAJ;;AAEA,IAAI;EACFF,WAAW,GAAGG,OAAO,CAAC,yBAAD,CAArB;EACAD,iBAAiB,GAAGC,OAAO,CAAC,sCAAD,CAAP,CAAgDC,OAApE;;EACA,IACEF,iBAAiB,KAChBA,iBAAiB,IAAI,OAArB,IAAgCA,iBAAiB,CAACG,QAAlB,CAA2B,QAA3B,CADhB,CADnB,EAGE;IACAJ,WAAW,GAAGD,WAAd;EACD;AACF,CATD,CASE,OAAOM,CAAP,EAAU,CAAE;;AAEd,OAAO,MAAMC,eAAe,GAAG,CAAC,CAACP,WAA1B;AACP,OAAO,MAAMQ,eAAe,GAAG,CAAC,CAACP,WAA1B;AAEP,OAAO,SAASQ,wBAAT,GAAoC;EACzC,IAAI,CAACF,eAAL,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CACJ;AACN,iDAFU,CAAN;EAID;AACF;AAED,OAAO,MAAMC,cAGM,GAAG,gBAAAX,WAAW,UAAX,kDAAaW,cAAb,KAA+BF,wBAH9C;AAKP,OAAO,MAAMG,eAGO,GAAG,iBAAAZ,WAAW,UAAX,oDAAaY,eAAb,KAAgCH,wBAHhD;AAKP,OAAO,MAAMI,gBAGK,GAAG,iBAAAb,WAAW,UAAX,oDAAaa,gBAAb,KAAiCJ,wBAH/C;AAKP,OAAO,MAAMK,WAIF,GAAG,iBAAAd,WAAW,UAAX,oDAAac,WAAb,KAA4BL,wBAJnC;AAMP,OAAO,MAAMM,UAAsC,GACjD,iBAAAf,WAAW,UAAX,oDAAae,UAAb,KAA2BN,wBADtB;AAGP,OAAO,MAAMO,OAAO,GAAG,iBAAAhB,WAAW,UAAX,oDAAagB,OAAb,KAAwBP,wBAAxC;AACP,OAAO,MAAMQ,OAAO,GAAG,iBAAAjB,WAAW,UAAX,oDAAaiB,OAAb,KAAwBR,wBAAxC;AAEP,OAAO,MAAMS,mBAIJ,GAAG,iBAAAlB,WAAW,UAAX,oDAAakB,mBAAb,KAAoCT,wBAJzC;AAMP,OAAO,MAAMU,aAAa,GAAOC,KAAJ,IAAgD;EAC3E,OACE,CAAC,CAACA,KAAF,KACCnB,WAAW,GACRA,WAAW,CAACkB,aAAZ,CAA0BC,KAA1B,CADQ,GAEPA,KAAD,CAAeA,KAAf,KAAyBC,SAH7B,CADF;AAMD,CAPM"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { ReactElement } from "react";
|
2
|
+
import type { SharedValue } from "react-native-reanimated";
|
3
|
+
import type { SkImage, SkPicture, SkSize } from "../../skia/types";
|
4
|
+
export declare const useTextureValue: (element: ReactElement, size: SkSize) => SharedValue<SkImage | null>;
|
5
|
+
export declare const useTextureValueFromPicture: (picture: SkPicture, size: SkSize) => SharedValue<SkImage | null>;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
2
|
+
import { Skia } from "../../skia";
|
3
|
+
import { drawAsPicture } from "../../renderer/Offscreen";
|
4
|
+
import { runOnUI, useSharedValue } from "./moduleWrapper"; // TODO: We're not sure yet why PixelRatio is not needed here.
|
5
|
+
|
6
|
+
const pd = 1; //Platform.PixelRatio;
|
7
|
+
|
8
|
+
const createTexture = (texture, picture, size) => {
|
9
|
+
"worklet";
|
10
|
+
|
11
|
+
const surface = Skia.Surface.MakeOffscreen(size.width * pd, size.height * pd);
|
12
|
+
const canvas = surface.getCanvas(); // see comment above
|
13
|
+
//canvas.save();
|
14
|
+
//canvas.scale(pd, pd);
|
15
|
+
|
16
|
+
canvas.drawPicture(picture); //canvas.restore();
|
17
|
+
|
18
|
+
surface.flush();
|
19
|
+
texture.value = surface.makeImageSnapshot();
|
20
|
+
};
|
21
|
+
|
22
|
+
export const useTextureValue = (element, size) => {
|
23
|
+
const picture = useMemo(() => {
|
24
|
+
return drawAsPicture(element);
|
25
|
+
}, [element]);
|
26
|
+
return useTextureValueFromPicture(picture, size);
|
27
|
+
};
|
28
|
+
export const useTextureValueFromPicture = (picture, size) => {
|
29
|
+
const texture = useSharedValue(null);
|
30
|
+
useEffect(() => {
|
31
|
+
runOnUI(createTexture)(texture, picture, size);
|
32
|
+
}, [texture, picture, size]);
|
33
|
+
return texture;
|
34
|
+
};
|
35
|
+
//# sourceMappingURL=textures.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Skia","drawAsPicture","runOnUI","useSharedValue","pd","createTexture","texture","picture","size","surface","Surface","MakeOffscreen","width","height","canvas","getCanvas","drawPicture","flush","value","makeImageSnapshot","useTextureValue","element","useTextureValueFromPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { Skia } from \"../../skia\";\nimport type { SkImage, SkPicture, SkSize } from \"../../skia/types\";\nimport { drawAsPicture } from \"../../renderer/Offscreen\";\n\nimport { runOnUI, useSharedValue } from \"./moduleWrapper\";\n\n// TODO: We're not sure yet why PixelRatio is not needed here.\nconst pd = 1; //Platform.PixelRatio;\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n const surface = Skia.Surface.MakeOffscreen(\n size.width * pd,\n size.height * pd\n )!;\n const canvas = surface.getCanvas();\n // see comment above\n //canvas.save();\n //canvas.scale(pd, pd);\n canvas.drawPicture(picture);\n //canvas.restore();\n surface.flush();\n texture.value = surface.makeImageSnapshot();\n};\n\nexport const useTextureValue = (element: ReactElement, size: SkSize) => {\n const picture = useMemo(() => {\n return drawAsPicture(element);\n }, [element]);\n return useTextureValueFromPicture(picture, size);\n};\n\nexport const useTextureValueFromPicture = (\n picture: SkPicture,\n size: SkSize\n) => {\n const texture = useSharedValue<SkImage | null>(null);\n useEffect(() => {\n runOnUI(createTexture)(texture, picture, size);\n }, [texture, picture, size]);\n return texture;\n};\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,OAApB,QAAmC,OAAnC;AAIA,SAASC,IAAT,QAAqB,YAArB;AAEA,SAASC,aAAT,QAA8B,0BAA9B;AAEA,SAASC,OAAT,EAAkBC,cAAlB,QAAwC,iBAAxC,C,CAEA;;AACA,MAAMC,EAAE,GAAG,CAAX,C,CAAc;;AAEd,MAAMC,aAAa,GAAG,CACpBC,OADoB,EAEpBC,OAFoB,EAGpBC,IAHoB,KAIjB;EACH;;EACA,MAAMC,OAAO,GAAGT,IAAI,CAACU,OAAL,CAAaC,aAAb,CACdH,IAAI,CAACI,KAAL,GAAaR,EADC,EAEdI,IAAI,CAACK,MAAL,GAAcT,EAFA,CAAhB;EAIA,MAAMU,MAAM,GAAGL,OAAO,CAACM,SAAR,EAAf,CANG,CAOH;EACA;EACA;;EACAD,MAAM,CAACE,WAAP,CAAmBT,OAAnB,EAVG,CAWH;;EACAE,OAAO,CAACQ,KAAR;EACAX,OAAO,CAACY,KAAR,GAAgBT,OAAO,CAACU,iBAAR,EAAhB;AACD,CAlBD;;AAoBA,OAAO,MAAMC,eAAe,GAAG,CAACC,OAAD,EAAwBb,IAAxB,KAAyC;EACtE,MAAMD,OAAO,GAAGR,OAAO,CAAC,MAAM;IAC5B,OAAOE,aAAa,CAACoB,OAAD,CAApB;EACD,CAFsB,EAEpB,CAACA,OAAD,CAFoB,CAAvB;EAGA,OAAOC,0BAA0B,CAACf,OAAD,EAAUC,IAAV,CAAjC;AACD,CALM;AAOP,OAAO,MAAMc,0BAA0B,GAAG,CACxCf,OADwC,EAExCC,IAFwC,KAGrC;EACH,MAAMF,OAAO,GAAGH,cAAc,CAAiB,IAAjB,CAA9B;EACAL,SAAS,CAAC,MAAM;IACdI,OAAO,CAACG,aAAD,CAAP,CAAuBC,OAAvB,EAAgCC,OAAhC,EAAyCC,IAAzC;EACD,CAFQ,EAEN,CAACF,OAAD,EAAUC,OAAV,EAAmBC,IAAnB,CAFM,CAAT;EAGA,OAAOF,OAAP;AACD,CATM"}
|
@@ -20,7 +20,7 @@ export const makeOffscreenSurface = (width, height) => {
|
|
20
20
|
return surface;
|
21
21
|
};
|
22
22
|
export const drawOffscreen = (surface, element) => {
|
23
|
-
const root = new SkiaRoot(Skia);
|
23
|
+
const root = new SkiaRoot(Skia, false);
|
24
24
|
root.render(element);
|
25
25
|
const canvas = surface.getCanvas();
|
26
26
|
const ctx = new JsiDrawingContext(Skia, canvas);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkApi","SkiaRoot","JsiDrawingContext","Skia","makeOffscreenSurface","width","height","CanvasKit","surface","Surface","MakeOffscreen","Error","drawOffscreen","element","root","render","canvas","getCanvas","ctx","dom","flush","makeImageSnapshot"],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { ReactNode } from \"react\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { SkiaRoot } from \"../renderer/Reconciler\";\nimport { JsiDrawingContext } from \"../dom/types\";\nimport type { SkSurface } from \"../skia\";\n\nexport * from \"../renderer/components\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet Skia: any;\n\nexport const makeOffscreenSurface = (width: number, height: number) => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n const surface = Skia.Surface.MakeOffscreen(width, height);\n if (surface === null) {\n throw new Error(\"Couldn't create surface!\");\n }\n return surface;\n};\n\nexport const drawOffscreen = (surface: SkSurface, element: ReactNode) => {\n const root = new SkiaRoot(Skia);\n root.render(element);\n const canvas = surface.getCanvas();\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n surface.flush();\n return surface.makeImageSnapshot();\n};\n"],"mappings":"AAAA;AACA;AAIA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,QAAyB,wBAAzB;AACA,SAASC,iBAAT,QAAkC,cAAlC;AAGA,cAAc,wBAAd,C,CAEA;;AACA,IAAIC,IAAJ;AAEA,OAAO,MAAMC,oBAAoB,GAAG,CAACC,KAAD,EAAgBC,MAAhB,KAAmC;EACrE,IAAI,CAACH,IAAL,EAAW;IACTA,IAAI,GAAGH,QAAQ,CAACO,SAAD,CAAf;EACD;;EACD,MAAMC,OAAO,GAAGL,IAAI,CAACM,OAAL,CAAaC,aAAb,CAA2BL,KAA3B,EAAkCC,MAAlC,CAAhB;;EACA,IAAIE,OAAO,KAAK,IAAhB,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CAAU,0BAAV,CAAN;EACD;;EACD,OAAOH,OAAP;AACD,CATM;AAWP,OAAO,MAAMI,aAAa,GAAG,CAACJ,OAAD,EAAqBK,OAArB,KAA4C;EACvE,MAAMC,IAAI,GAAG,IAAIb,QAAJ,CAAaE,IAAb,CAAb;EACAW,IAAI,CAACC,MAAL,CAAYF,OAAZ;EACA,MAAMG,MAAM,GAAGR,OAAO,CAACS,SAAR,EAAf;EACA,MAAMC,GAAG,GAAG,IAAIhB,iBAAJ,CAAsBC,IAAtB,EAA4Ba,MAA5B,CAAZ;EACAF,IAAI,CAACK,GAAL,CAASJ,MAAT,CAAgBG,GAAhB;EACAV,OAAO,CAACY,KAAR;EACA,OAAOZ,OAAO,CAACa,iBAAR,EAAP;AACD,CARM"}
|
1
|
+
{"version":3,"names":["JsiSkApi","SkiaRoot","JsiDrawingContext","Skia","makeOffscreenSurface","width","height","CanvasKit","surface","Surface","MakeOffscreen","Error","drawOffscreen","element","root","render","canvas","getCanvas","ctx","dom","flush","makeImageSnapshot"],"sources":["index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { ReactNode } from \"react\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { SkiaRoot } from \"../renderer/Reconciler\";\nimport { JsiDrawingContext } from \"../dom/types\";\nimport type { SkSurface } from \"../skia\";\n\nexport * from \"../renderer/components\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet Skia: any;\n\nexport const makeOffscreenSurface = (width: number, height: number) => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n const surface = Skia.Surface.MakeOffscreen(width, height);\n if (surface === null) {\n throw new Error(\"Couldn't create surface!\");\n }\n return surface;\n};\n\nexport const drawOffscreen = (surface: SkSurface, element: ReactNode) => {\n const root = new SkiaRoot(Skia, false);\n root.render(element);\n const canvas = surface.getCanvas();\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n surface.flush();\n return surface.makeImageSnapshot();\n};\n"],"mappings":"AAAA;AACA;AAIA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,QAAyB,wBAAzB;AACA,SAASC,iBAAT,QAAkC,cAAlC;AAGA,cAAc,wBAAd,C,CAEA;;AACA,IAAIC,IAAJ;AAEA,OAAO,MAAMC,oBAAoB,GAAG,CAACC,KAAD,EAAgBC,MAAhB,KAAmC;EACrE,IAAI,CAACH,IAAL,EAAW;IACTA,IAAI,GAAGH,QAAQ,CAACO,SAAD,CAAf;EACD;;EACD,MAAMC,OAAO,GAAGL,IAAI,CAACM,OAAL,CAAaC,aAAb,CAA2BL,KAA3B,EAAkCC,MAAlC,CAAhB;;EACA,IAAIE,OAAO,KAAK,IAAhB,EAAsB;IACpB,MAAM,IAAIG,KAAJ,CAAU,0BAAV,CAAN;EACD;;EACD,OAAOH,OAAP;AACD,CATM;AAWP,OAAO,MAAMI,aAAa,GAAG,CAACJ,OAAD,EAAqBK,OAArB,KAA4C;EACvE,MAAMC,IAAI,GAAG,IAAIb,QAAJ,CAAaE,IAAb,EAAmB,KAAnB,CAAb;EACAW,IAAI,CAACC,MAAL,CAAYF,OAAZ;EACA,MAAMG,MAAM,GAAGR,OAAO,CAACS,SAAR,EAAf;EACA,MAAMC,GAAG,GAAG,IAAIhB,iBAAJ,CAAsBC,IAAtB,EAA4Ba,MAA5B,CAAZ;EACAF,IAAI,CAACK,GAAL,CAASJ,MAAT,CAAgBG,GAAhB;EACAV,OAAO,CAACY,KAAR;EACA,OAAOZ,OAAO,CAACa,iBAAR,EAAP;AACD,CARM"}
|
package/lib/module/mock/index.js
CHANGED
@@ -34,9 +34,12 @@ export const Mock = CanvasKit => {
|
|
34
34
|
// Reanimated hooks
|
35
35
|
useClock: NoopSharedValue,
|
36
36
|
usePathInterpolation: NoopSharedValue,
|
37
|
+
useTextureValue: NoopSharedValue,
|
38
|
+
useTextureValueFromPicture: NoopSharedValue,
|
37
39
|
useRawData: Noop,
|
38
40
|
useData: Noop,
|
39
41
|
useFont: () => Skia.Font(undefined, 0),
|
42
|
+
useFonts: Noop,
|
40
43
|
useTypeface: () => null,
|
41
44
|
useImage: () => null,
|
42
45
|
useSVG: () => null
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkApi","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useClock","usePathInterpolation","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB,C,CAEA;;AACA,MAAMC,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AACA,MAAMC,eAAe,GAAG,OAAO;EAAEC,KAAK,EAAE;AAAT,CAAP,CAAxB;;AAEA,OAAO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiBV,QAAQ,CAACQ,SAAD,CAAzB;EACA,MAAMG,IAAI,GAAGF,MAAM,CAACC,OAApB;EACA,OAAO;IACLC,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,cAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL;IACAC,MAAM,EAAEZ,IARH;IASL;IACAa,QAAQ,EAAEX,SAVL;IAWLY,gBAAgB,EAAEZ,SAXb;IAYLa,eAAe,EAAEf,IAZZ;IAaLgB,SAAS,EAAEd,SAbN;IAcLe,OAAO,EAAEf,SAdJ;IAeLgB,SAAS,EAAEhB,SAfN;IAgBLiB,aAAa,EAAEjB,SAhBV;IAiBLkB,cAAc,EAAEpB,IAjBX;IAkBL;IACAqB,QAAQ,EAAEjB,eAnBL;IAoBLkB,oBAAoB,EAAElB,eApBjB;IAqBLmB,UAAU,
|
1
|
+
{"version":3,"names":["JsiSkApi","Noop","undefined","NoopValue","current","NoopSharedValue","value","Mock","CanvasKit","global","SkiaApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useClock","usePathInterpolation","useTextureValue","useTextureValueFromPicture","useRawData","useData","useFont","Font","useFonts","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\nconst NoopSharedValue = () => ({ value: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n // Skia Animations\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n // Reanimated hooks\n useClock: NoopSharedValue,\n usePathInterpolation: NoopSharedValue,\n useTextureValue: NoopSharedValue,\n useTextureValueFromPicture: NoopSharedValue,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useFonts: Noop,\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB,C,CAEA;;AACA,MAAMC,IAAe,GAAG,MAAMC,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7 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
53
53
|
const id = (_innerRef$current$nat = (_innerRef$current2 = innerRef.current) === null || _innerRef$current2 === void 0 ? void 0 : _innerRef$current2.nativeId) !== null && _innerRef$current$nat !== void 0 ? _innerRef$current$nat : -1;
|
54
54
|
return id;
|
55
55
|
}, [innerRef]);
|
56
|
-
const root = useMemo(() => new SkiaRoot(Skia, redraw, getNativeId), [redraw, getNativeId]); // Render effect
|
56
|
+
const root = useMemo(() => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId), [redraw, getNativeId]); // Render effect
|
57
57
|
|
58
58
|
useEffect(() => {
|
59
59
|
root.render(children);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaJSDomView","SkiaRoot","NATIVE_DOM","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","root","render","unmount","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const root = useMemo(\n () => new SkiaRoot(Skia, redraw, getNativeId),\n [redraw, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaJSDomView\n Skia={Skia}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAgBA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,aAAT,QAA8B,wBAA9B;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA,OAAO,MAAMC,YAAY,GAAG,MAAMN,MAAM,CAAc,IAAd,CAAjC;;AAQP,MAAMO,cAAc,GAAG,CACrBC,WADqB,EAErBC,QAFqB,KAGlB;EACH,OAAOZ,WAAW,CACfa,KAAD,IAA8B;IAC5B,IAAID,QAAJ,EAAc;MACZA,QAAQ,CAACC,KAAD,CAAR;IACD;;IACD,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAoBF,KAAK,CAACG,WAAN,CAAkBC,MAA5C;;IAEA,IAAIN,WAAJ,EAAiB;MACfA,WAAW,CAACO,KAAZ,GAAoB;QAAEJ,KAAF;QAASC;MAAT,CAApB;IACD;EACF,CAVe,EAWhB,CAACH,QAAD,EAAWD,WAAX,CAXgB,CAAlB;AAaD,CAjBD;;AAmBA,OAAO,MAAMQ,MAAM,gBAAGjB,UAAU,CAC9B,OAWEkB,YAXF,KAYK;EAAA,IAXH;IACEC,QADF;IAEEC,KAFF;IAGEC,KAHF;IAIEC,IAJF;IAKEC,OALF;IAMEC,MAAM,EAAEC,OANV;IAOEf,QAAQ,EAAEgB,SAPZ;IAQE,GAAGC;EARL,CAWG;EACH,MAAMjB,QAAQ,GAAGF,cAAc,CAACiB,OAAD,EAAUC,SAAV,CAA/B;EACA,MAAME,QAAQ,GAAGrB,YAAY,EAA7B;EACA,MAAMsB,GAAG,GAAGC,eAAe,CAACZ,YAAD,EAAeU,QAAf,CAA3B;EACA,MAAMG,MAAM,GAAGjC,WAAW,CAAC,MAAM;IAAA;;IAC/B,qBAAA8B,QAAQ,CAACI,OAAT,wEAAkBD,MAAlB;EACD,CAFyB,EAEvB,CAACH,QAAD,CAFuB,CAA1B;EAGA,MAAMK,WAAW,GAAGnC,WAAW,CAAC,MAAM;IAAA;;IACpC,MAAMoC,EAAE,kDAAGN,QAAQ,CAACI,OAAZ,uDAAG,mBAAkBG,QAArB,yEAAiC,CAAC,CAA1C;IACA,OAAOD,EAAP;EACD,CAH8B,EAG5B,CAACN,QAAD,CAH4B,CAA/B;EAKA,MAAMQ,IAAI,GAAGrC,OAAO,CAClB,MAAM,IAAIM,QAAJ,CAAaF,IAAb,
|
1
|
+
{"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaJSDomView","SkiaRoot","NATIVE_DOM","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","current","getNativeId","id","nativeId","root","render","unmount","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const root = useMemo(\n () => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId),\n [redraw, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaJSDomView\n Skia={Skia}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAgBA,SAASC,WAAT,QAA4B,UAA5B;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,aAAT,QAA8B,wBAA9B;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,kBAA3B;AAEA,OAAO,MAAMC,YAAY,GAAG,MAAMN,MAAM,CAAc,IAAd,CAAjC;;AAQP,MAAMO,cAAc,GAAG,CACrBC,WADqB,EAErBC,QAFqB,KAGlB;EACH,OAAOZ,WAAW,CACfa,KAAD,IAA8B;IAC5B,IAAID,QAAJ,EAAc;MACZA,QAAQ,CAACC,KAAD,CAAR;IACD;;IACD,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAoBF,KAAK,CAACG,WAAN,CAAkBC,MAA5C;;IAEA,IAAIN,WAAJ,EAAiB;MACfA,WAAW,CAACO,KAAZ,GAAoB;QAAEJ,KAAF;QAASC;MAAT,CAApB;IACD;EACF,CAVe,EAWhB,CAACH,QAAD,EAAWD,WAAX,CAXgB,CAAlB;AAaD,CAjBD;;AAmBA,OAAO,MAAMQ,MAAM,gBAAGjB,UAAU,CAC9B,OAWEkB,YAXF,KAYK;EAAA,IAXH;IACEC,QADF;IAEEC,KAFF;IAGEC,KAHF;IAIEC,IAJF;IAKEC,OALF;IAMEC,MAAM,EAAEC,OANV;IAOEf,QA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Y,IANR;MAOE,KAAK,EAAED;IAPT,GAQMM,KARN,EADF;EAYD,CAbD,MAaO;IACL,oBACE,oBAAC,aAAD;MACE,IAAI,EAAExB,IADR,CAEE;MAFF;MAGE,GAAG,EAAE0B,GAHP;MAIE,KAAK,EAAET,KAJT;MAKE,IAAI,EAAEgB,IAAI,CAACG,GALb;MAME,OAAO,EAAEhB,OANX;MAOE,QAAQ,EAAEb,QAPZ;MAQE,IAAI,EAAEY,IARR;MASE,KAAK,EAAED;IATT,GAUMM,KAVN,EADF;EAcD;AACF,CAtE6B,CAAzB;AAyEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMG,eAAe,GAAG,YAEnB;EAAA,kCADAU,IACA;IADAA,IACA;EAAA;;EACH,MAAMC,SAAS,GAAG7C,KAAK,CAACK,MAAN,CAAgB,IAAhB,CAAlB;EACAL,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpB2C,IAAI,CAACE,OAAL,CAAcb,GAAD,IAAS;MACpB,IAAIA,GAAJ,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACY,SAAS,CAACT,OAAX,CAAH;QACD,CAFD,MAEO;UACLH,GAAG,CAACG,OAAJ,GAAcS,SAAS,CAACT,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACQ,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
|
@@ -5,7 +5,7 @@ export declare class Container {
|
|
5
5
|
getNativeId: () => number;
|
6
6
|
private _root;
|
7
7
|
Sk: SkDOM;
|
8
|
-
constructor(Skia: Skia, redraw
|
8
|
+
constructor(Skia: Skia, redraw: () => void, getNativeId: () => number, native: boolean);
|
9
9
|
draw(ctx: DrawingContext): void;
|
10
10
|
get root(): RenderNode<GroupProps>;
|
11
11
|
}
|
@@ -5,6 +5,7 @@ export class Container {
|
|
5
5
|
constructor(Skia) {
|
6
6
|
let redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => {};
|
7
7
|
let getNativeId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => 0;
|
8
|
+
let native = arguments.length > 3 ? arguments[3] : undefined;
|
8
9
|
this.redraw = redraw;
|
9
10
|
this.getNativeId = getNativeId;
|
10
11
|
|
@@ -14,7 +15,7 @@ export class Container {
|
|
14
15
|
|
15
16
|
this.Sk = new JsiSkDOM({
|
16
17
|
Skia
|
17
|
-
});
|
18
|
+
}, native);
|
18
19
|
this._root = this.Sk.Group();
|
19
20
|
}
|
20
21
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkDOM","Container","constructor","Skia","redraw","getNativeId","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public redraw: () => void = () => {},\n public getNativeId: () => number = () => 0\n ) {\n this.Sk = new JsiSkDOM({ Skia });\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AASA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,
|
1
|
+
{"version":3,"names":["JsiSkDOM","Container","constructor","Skia","redraw","getNativeId","native","Sk","_root","Group","draw","ctx","render","root"],"sources":["Container.tsx"],"sourcesContent":["import { JsiSkDOM } from \"../dom/nodes\";\nimport type {\n GroupProps,\n DrawingContext,\n RenderNode,\n SkDOM,\n} from \"../dom/types\";\nimport type { Skia } from \"../skia/types\";\n\nexport class Container {\n private _root: RenderNode<GroupProps>;\n public Sk: SkDOM;\n constructor(\n Skia: Skia,\n public redraw: () => void = () => {},\n public getNativeId: () => number = () => 0,\n native: boolean\n ) {\n this.Sk = new JsiSkDOM({ Skia }, native);\n this._root = this.Sk.Group();\n }\n\n draw(ctx: DrawingContext) {\n this._root.render(ctx);\n }\n\n get root() {\n return this._root;\n }\n}\n"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AASA,OAAO,MAAMC,SAAN,CAAgB;EAGrBC,WAAW,CACTC,IADS,EAKT;IAAA,IAHOC,MAGP,uEAH4B,MAAM,CAAE,CAGpC;IAAA,IAFOC,WAEP,uEAFmC,MAAM,CAEzC;IAAA,IADAC,MACA;IAAA,KAHOF,MAGP,GAHOA,MAGP;IAAA,KAFOC,WAEP,GAFOA,WAEP;;IAAA;;IAAA;;IACA,KAAKE,EAAL,GAAU,IAAIP,QAAJ,CAAa;MAAEG;IAAF,CAAb,EAAuBG,MAAvB,CAAV;IACA,KAAKE,KAAL,GAAa,KAAKD,EAAL,CAAQE,KAAR,EAAb;EACD;;EAEDC,IAAI,CAACC,GAAD,EAAsB;IACxB,KAAKH,KAAL,CAAWI,MAAX,CAAkBD,GAAlB;EACD;;EAEO,IAAJE,IAAI,GAAG;IACT,OAAO,KAAKL,KAAZ;EACD;;AAnBoB"}
|
@@ -2,6 +2,7 @@ import { JsiDrawingContext } from "../dom/types";
|
|
2
2
|
import { Skia } from "../skia";
|
3
3
|
import { SkiaRoot } from "./Reconciler";
|
4
4
|
export const drawAsImage = (element, width, height) => {
|
5
|
+
const picture = drawAsPicture(element);
|
5
6
|
const surface = Skia.Surface.MakeOffscreen(width, height);
|
6
7
|
|
7
8
|
if (!surface) {
|
@@ -9,11 +10,18 @@ export const drawAsImage = (element, width, height) => {
|
|
9
10
|
}
|
10
11
|
|
11
12
|
const canvas = surface.getCanvas();
|
12
|
-
|
13
|
+
canvas.drawPicture(picture);
|
14
|
+
surface.flush();
|
15
|
+
return surface.makeImageSnapshot();
|
16
|
+
};
|
17
|
+
export const drawAsPicture = element => {
|
18
|
+
const recorder = Skia.PictureRecorder();
|
19
|
+
const canvas = recorder.beginRecording();
|
20
|
+
const root = new SkiaRoot(Skia, false);
|
13
21
|
root.render(element);
|
14
22
|
const ctx = new JsiDrawingContext(Skia, canvas);
|
15
23
|
root.dom.render(ctx);
|
16
|
-
|
17
|
-
return
|
24
|
+
const picture = recorder.finishRecordingAsPicture();
|
25
|
+
return picture;
|
18
26
|
};
|
19
27
|
//# sourceMappingURL=Offscreen.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiDrawingContext","Skia","SkiaRoot","drawAsImage","element","width","height","surface","Surface","MakeOffscreen","Error","canvas","getCanvas","root","render","ctx","dom","
|
1
|
+
{"version":3,"names":["JsiDrawingContext","Skia","SkiaRoot","drawAsImage","element","width","height","picture","drawAsPicture","surface","Surface","MakeOffscreen","Error","canvas","getCanvas","drawPicture","flush","makeImageSnapshot","recorder","PictureRecorder","beginRecording","root","render","ctx","dom","finishRecordingAsPicture"],"sources":["Offscreen.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nimport { JsiDrawingContext } from \"../dom/types\";\nimport { Skia } from \"../skia\";\n\nimport { SkiaRoot } from \"./Reconciler\";\n\nexport const drawAsImage = (\n element: ReactElement,\n width: number,\n height: number\n) => {\n const picture = drawAsPicture(element);\n const surface = Skia.Surface.MakeOffscreen(width, height);\n if (!surface) {\n throw new Error(\"Could not create offscreen surface\");\n }\n const canvas = surface.getCanvas();\n canvas.drawPicture(picture);\n surface.flush();\n return surface.makeImageSnapshot();\n};\n\nexport const drawAsPicture = (element: ReactElement) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n const root = new SkiaRoot(Skia, false);\n root.render(element);\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n const picture = recorder.finishRecordingAsPicture();\n return picture;\n};\n"],"mappings":"AAEA,SAASA,iBAAT,QAAkC,cAAlC;AACA,SAASC,IAAT,QAAqB,SAArB;AAEA,SAASC,QAAT,QAAyB,cAAzB;AAEA,OAAO,MAAMC,WAAW,GAAG,CACzBC,OADyB,EAEzBC,KAFyB,EAGzBC,MAHyB,KAItB;EACH,MAAMC,OAAO,GAAGC,aAAa,CAACJ,OAAD,CAA7B;EACA,MAAMK,OAAO,GAAGR,IAAI,CAACS,OAAL,CAAaC,aAAb,CAA2BN,KAA3B,EAAkCC,MAAlC,CAAhB;;EACA,IAAI,CAACG,OAAL,EAAc;IACZ,MAAM,IAAIG,KAAJ,CAAU,oCAAV,CAAN;EACD;;EACD,MAAMC,MAAM,GAAGJ,OAAO,CAACK,SAAR,EAAf;EACAD,MAAM,CAACE,WAAP,CAAmBR,OAAnB;EACAE,OAAO,CAACO,KAAR;EACA,OAAOP,OAAO,CAACQ,iBAAR,EAAP;AACD,CAdM;AAgBP,OAAO,MAAMT,aAAa,GAAIJ,OAAD,IAA2B;EACtD,MAAMc,QAAQ,GAAGjB,IAAI,CAACkB,eAAL,EAAjB;EACA,MAAMN,MAAM,GAAGK,QAAQ,CAACE,cAAT,EAAf;EACA,MAAMC,IAAI,GAAG,IAAInB,QAAJ,CAAaD,IAAb,EAAmB,KAAnB,CAAb;EACAoB,IAAI,CAACC,MAAL,CAAYlB,OAAZ;EACA,MAAMmB,GAAG,GAAG,IAAIvB,iBAAJ,CAAsBC,IAAtB,EAA4BY,MAA5B,CAAZ;EACAQ,IAAI,CAACG,GAAL,CAASF,MAAT,CAAgBC,GAAhB;EACA,MAAMhB,OAAO,GAAGW,QAAQ,CAACO,wBAAT,EAAhB;EACA,OAAOlB,OAAP;AACD,CATM"}
|
@@ -3,7 +3,7 @@ import type { Skia } from "../skia/types";
|
|
3
3
|
export declare class SkiaRoot {
|
4
4
|
private root;
|
5
5
|
private container;
|
6
|
-
constructor(Skia: Skia, redraw?: () => void, getNativeId?: () => number);
|
6
|
+
constructor(Skia: Skia, native?: boolean, redraw?: () => void, getNativeId?: () => number);
|
7
7
|
render(element: ReactNode): void;
|
8
8
|
unmount(): void;
|
9
9
|
get dom(): import("..").RenderNode<import("..").GroupProps>;
|
@@ -11,14 +11,15 @@ skiaReconciler.injectIntoDevTools({
|
|
11
11
|
});
|
12
12
|
export class SkiaRoot {
|
13
13
|
constructor(Skia) {
|
14
|
-
let
|
15
|
-
let
|
14
|
+
let native = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
15
|
+
let redraw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
|
16
|
+
let getNativeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => 0;
|
16
17
|
|
17
18
|
_defineProperty(this, "root", void 0);
|
18
19
|
|
19
20
|
_defineProperty(this, "container", void 0);
|
20
21
|
|
21
|
-
this.container = new Container(Skia, redraw, getNativeId);
|
22
|
+
this.container = new Container(Skia, redraw, getNativeId, native);
|
22
23
|
this.root = skiaReconciler.createContainer(this.container, 0, null, true, null, "", console.error, null);
|
23
24
|
}
|
24
25
|
|
@@ -30,7 +31,9 @@ export class SkiaRoot {
|
|
30
31
|
}
|
31
32
|
|
32
33
|
unmount() {
|
33
|
-
skiaReconciler.updateContainer(null, this.root, null, () => {
|
34
|
+
skiaReconciler.updateContainer(null, this.root, null, () => {
|
35
|
+
hostDebug("unmountContainer");
|
36
|
+
});
|
34
37
|
}
|
35
38
|
|
36
39
|
get dom() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ReactReconciler","skHostConfig","debug","hostDebug","Container","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","redraw","getNativeId","container","root","createContainer","console","error","render","element","updateContainer","unmount","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\n\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(\n Skia: Skia,\n redraw: () => void = () => {},\n getNativeId: () => number = () => 0\n ) {\n this.container = new Container(Skia, redraw, getNativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n hostDebug(\"updateContainer\");\n });\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {});\n }\n\n get dom() {\n return this.container.root;\n }\n}\n"],"mappings":";;AAEA,OAAOA,eAAP,MAA4B,kBAA5B;AAIA,SAASC,YAAT,EAAuBC,KAAK,IAAIC,SAAhC,QAAiD,cAAjD;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,MAAMC,cAAc,GAAGL,eAAe,CAACC,YAAD,CAAtC;AAEAI,cAAc,CAACC,kBAAf,CAAkC;EAChCC,UAAU,EAAE,CADoB;EAEhCC,OAAO,EAAE,OAFuB;EAGhCC,mBAAmB,EAAE;AAHW,CAAlC;AAMA,OAAO,MAAMC,QAAN,CAAe;EAIpBC,WAAW,CACTC,IADS,
|
1
|
+
{"version":3,"names":["ReactReconciler","skHostConfig","debug","hostDebug","Container","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaRoot","constructor","Skia","native","redraw","getNativeId","container","root","createContainer","console","error","render","element","updateContainer","unmount","dom"],"sources":["Reconciler.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { Skia } from \"../skia/types\";\n\nimport { skHostConfig, debug as hostDebug } from \"./HostConfig\";\nimport { Container } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(\n Skia: Skia,\n native = false,\n redraw: () => void = () => {},\n getNativeId: () => number = () => 0\n ) {\n this.container = new Container(Skia, redraw, getNativeId, native);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n hostDebug(\"updateContainer\");\n });\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n hostDebug(\"unmountContainer\");\n });\n }\n\n get dom() {\n return this.container.root;\n }\n}\n"],"mappings":";;AAEA,OAAOA,eAAP,MAA4B,kBAA5B;AAIA,SAASC,YAAT,EAAuBC,KAAK,IAAIC,SAAhC,QAAiD,cAAjD;AACA,SAASC,SAAT,QAA0B,aAA1B;AAEA,MAAMC,cAAc,GAAGL,eAAe,CAACC,YAAD,CAAtC;AAEAI,cAAc,CAACC,kBAAf,CAAkC;EAChCC,UAAU,EAAE,CADoB;EAEhCC,OAAO,EAAE,OAFuB;EAGhCC,mBAAmB,EAAE;AAHW,CAAlC;AAMA,OAAO,MAAMC,QAAN,CAAe;EAIpBC,WAAW,CACTC,IADS,EAKT;IAAA,IAHAC,MAGA,uEAHS,KAGT;IAAA,IAFAC,MAEA,uEAFqB,MAAM,CAAE,CAE7B;IAAA,IADAC,WACA,uEAD4B,MAAM,CAClC;;IAAA;;IAAA;;IACA,KAAKC,SAAL,GAAiB,IAAIZ,SAAJ,CAAcQ,IAAd,EAAoBE,MAApB,EAA4BC,WAA5B,EAAyCF,MAAzC,CAAjB;IACA,KAAKI,IAAL,GAAYZ,cAAc,CAACa,eAAf,CACV,KAAKF,SADK,EAEV,CAFU,EAGV,IAHU,EAIV,IAJU,EAKV,IALU,EAMV,EANU,EAOVG,OAAO,CAACC,KAPE,EAQV,IARU,CAAZ;EAUD;;EAEDC,MAAM,CAACC,OAAD,EAAqB;IACzB;IACAjB,cAAc,CAACkB,eAAf,CAA+BD,OAA/B,EAA+C,KAAKL,IAApD,EAA0D,IAA1D,EAAgE,MAAM;MACpEd,SAAS,CAAC,iBAAD,CAAT;IACD,CAFD;EAGD;;EAEDqB,OAAO,GAAG;IACRnB,cAAc,CAACkB,eAAf,CAA+B,IAA/B,EAAqC,KAAKN,IAA1C,EAAgD,IAAhD,EAAsD,MAAM;MAC1Dd,SAAS,CAAC,kBAAD,CAAT;IACD,CAFD;EAGD;;EAEM,IAAHsB,GAAG,GAAG;IACR,OAAO,KAAKT,SAAL,CAAeC,IAAtB;EACD;;AAtCmB"}
|
@@ -95,9 +95,9 @@ export declare const processTransform3d: (transforms: Transforms3d) => Matrix4;
|
|
95
95
|
/**
|
96
96
|
* @worklet
|
97
97
|
*/
|
98
|
-
export declare const convertToColumnMajor: (rowMajorMatrix: Matrix4) =>
|
98
|
+
export declare const convertToColumnMajor: (rowMajorMatrix: Matrix4) => Matrix4;
|
99
99
|
/**
|
100
100
|
* @worklet
|
101
101
|
*/
|
102
|
-
export declare const convertToAffineMatrix: (m4:
|
102
|
+
export declare const convertToAffineMatrix: (m4: Matrix4) => number[];
|
103
103
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["exhaustiveCheck","a","Error","Matrix4","translate","x","y","z","perspective","p","normalizeVec","vec","length","Math","sqrt","rotatedUnitSinCos","axisVec","sinAngle","cosAngle","c","s","t","matrixVecMul4","m","v","mapPoint3d","r","multiply4","b","result","Array","fill","i","j","skewY","angle","tan","skewX","toMatrix3","rotate","axis","value","sin","cos","pivot","scale","sx","sy","sz","m4","rotateAxis","rotateZ","rotateX","rotateY","processTransform3d","transforms","reduce","acc","val","key","Object","keys","transform","convertToColumnMajor","rowMajorMatrix","colMajorMatrix","size","row","col","convertToAffineMatrix","d","tx","ty"],"sources":["Matrix4.ts"],"sourcesContent":["type Point = { x: number; y: number };\ntype Vec2 = readonly [number, number];\ntype Vec3 = readonly [number, number, number];\ntype Vec4 = readonly [number, number, number, number];\n\nexport type Matrix3 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\nexport type Matrix4 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\ntype Transform3dName =\n | \"translateX\"\n | \"translateY\"\n | \"translateZ\"\n | \"translate\"\n | \"scale\"\n | \"scaleX\"\n | \"scaleY\"\n | \"skewX\"\n | \"skewY\"\n | \"rotateZ\"\n | \"rotate\"\n | \"perspective\"\n | \"rotateX\"\n | \"rotateY\"\n | \"matrix\";\n\ntype Transformations = {\n [Name in Transform3dName]: Name extends \"matrix\"\n ? Matrix4\n : Name extends \"translate\"\n ? Vec3 | Vec2\n : number;\n};\n\ntype Transform3d =\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"translateZ\">\n | Pick<Transformations, \"translate\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"perspective\">\n | Pick<Transformations, \"rotateX\">\n | Pick<Transformations, \"rotateY\">\n | Pick<Transformations, \"rotateZ\">\n | Pick<Transformations, \"rotate\">\n | Pick<Transformations, \"matrix\">;\n\nexport type Transforms3d = Transform3d[];\n\nconst exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n/**\n * @worklet\n */\nexport const Matrix4 = (): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const translate = (x: number, y: number, z: number = 0): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const perspective = (p: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];\n};\n\nconst normalizeVec = (vec: Vec3): Vec3 => {\n \"worklet\";\n const [x, y, z] = vec;\n const length = Math.sqrt(x * x + y * y + z * z);\n // Check for zero length to avoid division by zero\n if (length === 0) {\n return [0, 0, 0];\n }\n return [x / length, y / length, z / length];\n};\n\nconst rotatedUnitSinCos = (\n axisVec: Vec3,\n sinAngle: number,\n cosAngle: number\n): Matrix4 => {\n \"worklet\";\n const x = axisVec[0];\n const y = axisVec[1];\n const z = axisVec[2];\n const c = cosAngle;\n const s = sinAngle;\n const t = 1 - c;\n return [\n t * x * x + c,\n t * x * y - s * z,\n t * x * z + s * y,\n 0,\n t * x * y + s * z,\n t * y * y + c,\n t * y * z - s * x,\n 0,\n t * x * z - s * y,\n t * y * z + s * x,\n t * z * z + c,\n 0,\n 0,\n 0,\n 0,\n 1,\n ];\n};\n\n/**\n * @worklet\n */\nexport const matrixVecMul4 = (m: Matrix4, v: Vec4): Vec4 => {\n \"worklet\";\n return [\n m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3] * v[3],\n m[4] * v[0] + m[5] * v[1] + m[6] * v[2] + m[7] * v[3],\n m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11] * v[3],\n m[12] * v[0] + m[13] * v[1] + m[14] * v[2] + m[15] * v[3],\n ];\n};\n\n/**\n * @worklet\n */\nexport const mapPoint3d = (m: Matrix4, v: Vec3) => {\n \"worklet\";\n const r = matrixVecMul4(m, [...v, 1]);\n return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;\n};\n\n/**\n * @worklet\n */\nexport const multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {\n \"worklet\";\n const result = new Array(16).fill(0);\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n result[i * 4 + j] =\n a[i * 4] * b[j] +\n a[i * 4 + 1] * b[j + 4] +\n a[i * 4 + 2] * b[j + 8] +\n a[i * 4 + 3] * b[j + 12];\n }\n }\n return result as unknown as Matrix4;\n};\n\nconst skewY = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst skewX = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const toMatrix3 = (m: Matrix4) => {\n \"worklet\";\n return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];\n};\n\nconst rotate = (axis: Vec3, value: number) => {\n \"worklet\";\n return rotatedUnitSinCos(\n normalizeVec(axis),\n Math.sin(value),\n Math.cos(value)\n );\n};\n\n/**\n * @worklet\n */\nexport const pivot = (m: Matrix4, p: Point) => {\n \"worklet\";\n return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));\n};\n\n/**\n * @worklet\n */\nexport const scale = (\n sx: number,\n sy: number,\n sz: number = 1,\n p?: Point\n): Matrix4 => {\n \"worklet\";\n const m4: Matrix4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n if (p) {\n return pivot(m4, p);\n }\n return m4;\n};\n\nconst rotateAxis = (axis: Vec3, angle: number, p?: Point) => {\n \"worklet\";\n const result = rotate(axis, angle);\n if (p) {\n return pivot(result, p);\n }\n return result;\n};\n\n/**\n * @worklet\n */\nexport const rotateZ = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 0, 1], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateX = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([1, 0, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateY = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 1, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const processTransform3d = (transforms: Transforms3d) => {\n \"worklet\";\n return transforms.reduce((acc, val) => {\n const key = Object.keys(val)[0] as Transform3dName;\n const transform = val as Pick<Transformations, typeof key>;\n if (key === \"translateX\") {\n const value = transform[key];\n return multiply4(acc, translate(value, 0, 0));\n }\n if (key === \"translate\") {\n const [x, y, z = 0] = transform[key];\n return multiply4(acc, translate(x, y, z));\n }\n if (key === \"translateY\") {\n const value = transform[key];\n return multiply4(acc, translate(0, value, 0));\n }\n if (key === \"translateZ\") {\n const value = transform[key];\n return multiply4(acc, translate(0, 0, value));\n }\n if (key === \"scale\") {\n const value = transform[key];\n return multiply4(acc, scale(value, value, 1));\n }\n if (key === \"scaleX\") {\n const value = transform[key];\n return multiply4(acc, scale(value, 1, 1));\n }\n if (key === \"scaleY\") {\n const value = transform[key];\n return multiply4(acc, scale(1, value, 1));\n }\n if (key === \"skewX\") {\n const value = transform[key];\n return multiply4(acc, skewX(value));\n }\n if (key === \"skewY\") {\n const value = transform[key];\n return multiply4(acc, skewY(value));\n }\n if (key === \"rotateX\") {\n const value = transform[key];\n return multiply4(acc, rotate([1, 0, 0], value));\n }\n if (key === \"rotateY\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 1, 0], value));\n }\n if (key === \"perspective\") {\n const value = transform[key];\n return multiply4(acc, perspective(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 0, 1], value));\n }\n if (key === \"matrix\") {\n const value = transform[key];\n return multiply4(acc, value);\n }\n return exhaustiveCheck(key);\n }, Matrix4());\n};\n\n/**\n * @worklet\n */\nexport const convertToColumnMajor = (rowMajorMatrix: Matrix4) => {\n \"worklet\";\n\n const colMajorMatrix = new Array<number>(16);\n const size = 4;\n for (let row = 0; row < size; row++) {\n for (let col = 0; col < size; col++) {\n colMajorMatrix[col * size + row] = rowMajorMatrix[row * size + col];\n }\n }\n return colMajorMatrix;\n};\n\n/**\n * @worklet\n */\nexport const convertToAffineMatrix = (m4: number[]) => {\n \"worklet\";\n // Extracting the relevant components from the 4x4 matrix\n const a = m4[0]; // Scale X\n const b = m4[1]; // Skew Y\n const c = m4[4]; // Skew X\n const d = m4[5]; // Scale Y\n const tx = m4[12]; // Translate X\n const ty = m4[13]; // Translate Y\n\n // Returning the 6-element affine transformation matrix\n return [a, b, c, d, tx, ty];\n};\n"],"mappings":"AAgFA,MAAMA,eAAe,GAAIC,CAAD,IAAqB;EAC3C;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHD;AAKA;AACA;AACA;;;AACA,OAAO,MAAME,OAAO,GAAG,MAAe;EACpC;;EACA,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,CAAP;AACD,CAHM;AAKP;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,UAACC,CAAD,EAAYC,CAAZ,EAAkD;EACzE;;EADyE,IAA3BC,CAA2B,uEAAf,CAAe;EAEzE,OAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAUF,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsBC,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkCC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,CAAP;AACD,CAHM;AAKP;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAIC,CAAD,IAAwB;EACjD;;EACA,OAAO,CAAC,CAAD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AE,CAAC,CAAD,CAAZ,CALqD,CAKpC;;EACjB,MAAMqB,CAAC,GAAGrB,EAAE,CAAC,CAAD,CAAZ,CANqD,CAMpC;;EACjB,MAAMsB,EAAE,GAAGtB,EAAE,CAAC,EAAD,CAAb,CAPqD,CAOlC;;EACnB,MAAMuB,EAAE,GAAGvB,EAAE,CAAC,EAAD,CAAb,CARqD,CAQlC;EAEnB;;EACA,OAAO,CAAChD,CAAD,EAAI2B,CAAJ,EAAOT,CAAP,EAAUmD,CAAV,EAAaC,EAAb,EAAiBC,EAAjB,CAAP;AACD,CAZM"}
|
1
|
+
{"version":3,"names":["exhaustiveCheck","a","Error","Matrix4","translate","x","y","z","perspective","p","normalizeVec","vec","length","Math","sqrt","rotatedUnitSinCos","axisVec","sinAngle","cosAngle","c","s","t","matrixVecMul4","m","v","mapPoint3d","r","multiply4","b","result","Array","fill","i","j","skewY","angle","tan","skewX","toMatrix3","rotate","axis","value","sin","cos","pivot","scale","sx","sy","sz","m4","rotateAxis","rotateZ","rotateX","rotateY","processTransform3d","transforms","reduce","acc","val","key","Object","keys","transform","convertToColumnMajor","rowMajorMatrix","colMajorMatrix","size","row","col","convertToAffineMatrix","d","tx","ty"],"sources":["Matrix4.ts"],"sourcesContent":["type Point = { x: number; y: number };\ntype Vec2 = readonly [number, number];\ntype Vec3 = readonly [number, number, number];\ntype Vec4 = readonly [number, number, number, number];\n\nexport type Matrix3 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\nexport type Matrix4 = readonly [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n\ntype Transform3dName =\n | \"translateX\"\n | \"translateY\"\n | \"translateZ\"\n | \"translate\"\n | \"scale\"\n | \"scaleX\"\n | \"scaleY\"\n | \"skewX\"\n | \"skewY\"\n | \"rotateZ\"\n | \"rotate\"\n | \"perspective\"\n | \"rotateX\"\n | \"rotateY\"\n | \"matrix\";\n\ntype Transformations = {\n [Name in Transform3dName]: Name extends \"matrix\"\n ? Matrix4\n : Name extends \"translate\"\n ? Vec3 | Vec2\n : number;\n};\n\ntype Transform3d =\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"translateZ\">\n | Pick<Transformations, \"translate\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"perspective\">\n | Pick<Transformations, \"rotateX\">\n | Pick<Transformations, \"rotateY\">\n | Pick<Transformations, \"rotateZ\">\n | Pick<Transformations, \"rotate\">\n | Pick<Transformations, \"matrix\">;\n\nexport type Transforms3d = Transform3d[];\n\nconst exhaustiveCheck = (a: never): never => {\n \"worklet\";\n throw new Error(`Unexhaustive handling for ${a}`);\n};\n\n/**\n * @worklet\n */\nexport const Matrix4 = (): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const translate = (x: number, y: number, z: number = 0): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const perspective = (p: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1 / p, 1];\n};\n\nconst normalizeVec = (vec: Vec3): Vec3 => {\n \"worklet\";\n const [x, y, z] = vec;\n const length = Math.sqrt(x * x + y * y + z * z);\n // Check for zero length to avoid division by zero\n if (length === 0) {\n return [0, 0, 0];\n }\n return [x / length, y / length, z / length];\n};\n\nconst rotatedUnitSinCos = (\n axisVec: Vec3,\n sinAngle: number,\n cosAngle: number\n): Matrix4 => {\n \"worklet\";\n const x = axisVec[0];\n const y = axisVec[1];\n const z = axisVec[2];\n const c = cosAngle;\n const s = sinAngle;\n const t = 1 - c;\n return [\n t * x * x + c,\n t * x * y - s * z,\n t * x * z + s * y,\n 0,\n t * x * y + s * z,\n t * y * y + c,\n t * y * z - s * x,\n 0,\n t * x * z - s * y,\n t * y * z + s * x,\n t * z * z + c,\n 0,\n 0,\n 0,\n 0,\n 1,\n ];\n};\n\n/**\n * @worklet\n */\nexport const matrixVecMul4 = (m: Matrix4, v: Vec4): Vec4 => {\n \"worklet\";\n return [\n m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3] * v[3],\n m[4] * v[0] + m[5] * v[1] + m[6] * v[2] + m[7] * v[3],\n m[8] * v[0] + m[9] * v[1] + m[10] * v[2] + m[11] * v[3],\n m[12] * v[0] + m[13] * v[1] + m[14] * v[2] + m[15] * v[3],\n ];\n};\n\n/**\n * @worklet\n */\nexport const mapPoint3d = (m: Matrix4, v: Vec3) => {\n \"worklet\";\n const r = matrixVecMul4(m, [...v, 1]);\n return [r[0] / r[3], r[1] / r[3], r[2] / r[3]] as const;\n};\n\n/**\n * @worklet\n */\nexport const multiply4 = (a: Matrix4, b: Matrix4): Matrix4 => {\n \"worklet\";\n const result = new Array(16).fill(0);\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n result[i * 4 + j] =\n a[i * 4] * b[j] +\n a[i * 4 + 1] * b[j + 4] +\n a[i * 4 + 2] * b[j + 8] +\n a[i * 4 + 3] * b[j + 12];\n }\n }\n return result as unknown as Matrix4;\n};\n\nconst skewY = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\nconst skewX = (angle: number): Matrix4 => {\n \"worklet\";\n return [1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n};\n\n/**\n * @worklet\n */\nexport const toMatrix3 = (m: Matrix4) => {\n \"worklet\";\n return [m[0], m[1], m[3], m[4], m[5], m[7], m[12], m[13], m[15]];\n};\n\nconst rotate = (axis: Vec3, value: number) => {\n \"worklet\";\n return rotatedUnitSinCos(\n normalizeVec(axis),\n Math.sin(value),\n Math.cos(value)\n );\n};\n\n/**\n * @worklet\n */\nexport const pivot = (m: Matrix4, p: Point) => {\n \"worklet\";\n return multiply4(translate(p.x, p.y), multiply4(m, translate(-p.x, -p.y)));\n};\n\n/**\n * @worklet\n */\nexport const scale = (\n sx: number,\n sy: number,\n sz: number = 1,\n p?: Point\n): Matrix4 => {\n \"worklet\";\n const m4: Matrix4 = [sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1];\n if (p) {\n return pivot(m4, p);\n }\n return m4;\n};\n\nconst rotateAxis = (axis: Vec3, angle: number, p?: Point) => {\n \"worklet\";\n const result = rotate(axis, angle);\n if (p) {\n return pivot(result, p);\n }\n return result;\n};\n\n/**\n * @worklet\n */\nexport const rotateZ = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 0, 1], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateX = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([1, 0, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const rotateY = (value: number, p?: Point) => {\n \"worklet\";\n return rotateAxis([0, 1, 0], value, p);\n};\n\n/**\n * @worklet\n */\nexport const processTransform3d = (transforms: Transforms3d) => {\n \"worklet\";\n return transforms.reduce((acc, val) => {\n const key = Object.keys(val)[0] as Transform3dName;\n const transform = val as Pick<Transformations, typeof key>;\n if (key === \"translateX\") {\n const value = transform[key];\n return multiply4(acc, translate(value, 0, 0));\n }\n if (key === \"translate\") {\n const [x, y, z = 0] = transform[key];\n return multiply4(acc, translate(x, y, z));\n }\n if (key === \"translateY\") {\n const value = transform[key];\n return multiply4(acc, translate(0, value, 0));\n }\n if (key === \"translateZ\") {\n const value = transform[key];\n return multiply4(acc, translate(0, 0, value));\n }\n if (key === \"scale\") {\n const value = transform[key];\n return multiply4(acc, scale(value, value, 1));\n }\n if (key === \"scaleX\") {\n const value = transform[key];\n return multiply4(acc, scale(value, 1, 1));\n }\n if (key === \"scaleY\") {\n const value = transform[key];\n return multiply4(acc, scale(1, value, 1));\n }\n if (key === \"skewX\") {\n const value = transform[key];\n return multiply4(acc, skewX(value));\n }\n if (key === \"skewY\") {\n const value = transform[key];\n return multiply4(acc, skewY(value));\n }\n if (key === \"rotateX\") {\n const value = transform[key];\n return multiply4(acc, rotate([1, 0, 0], value));\n }\n if (key === \"rotateY\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 1, 0], value));\n }\n if (key === \"perspective\") {\n const value = transform[key];\n return multiply4(acc, perspective(value));\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n const value = transform[key];\n return multiply4(acc, rotate([0, 0, 1], value));\n }\n if (key === \"matrix\") {\n const value = transform[key];\n return multiply4(acc, value);\n }\n return exhaustiveCheck(key);\n }, Matrix4());\n};\n\n/**\n * @worklet\n */\nexport const convertToColumnMajor = (rowMajorMatrix: Matrix4) => {\n \"worklet\";\n\n const colMajorMatrix = new Array<number>(16);\n const size = 4;\n for (let row = 0; row < size; row++) {\n for (let col = 0; col < size; col++) {\n colMajorMatrix[col * size + row] = rowMajorMatrix[row * size + col];\n }\n }\n return colMajorMatrix as unknown as Matrix4;\n};\n\n/**\n * @worklet\n */\nexport const convertToAffineMatrix = (m4: Matrix4) => {\n \"worklet\";\n // Extracting the relevant components from the 4x4 matrix\n const a = m4[0]; // Scale X\n const b = m4[1]; // Skew Y\n const c = m4[4]; // Skew X\n const d = m4[5]; // Scale Y\n const tx = m4[12]; // Translate X\n const ty = m4[13]; // Translate Y\n\n // Returning the 6-element affine transformation matrix\n return [a, b, c, d, tx, ty];\n};\n"],"mappings":"AAgFA,MAAMA,eAAe,GAAIC,CAAD,IAAqB;EAC3C;;EACA,MAAM,IAAIC,KAAJ,CAAW,6BAA4BD,CAAE,EAAzC,CAAN;AACD,CAHD;AAKA;AACA;AACA;;;AAC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;AACA,OAAO,MAAM4D,oBAAoB,GAAIC,cAAD,IAA6B;EAC/D;;EAEA,MAAMC,cAAc,GAAG,IAAInC,KAAJ,CAAkB,EAAlB,CAAvB;EACA,MAAMoC,IAAI,GAAG,CAAb;;EACA,KAAK,IAAIC,GAAG,GAAG,CAAf,EAAkBA,GAAG,GAAGD,IAAxB,EAA8BC,GAAG,EAAjC,EAAqC;IACnC,KAAK,IAAIC,GAAG,GAAG,CAAf,EAAkBA,GAAG,GAAGF,IAAxB,EAA8BE,GAAG,EAAjC,EAAqC;MACnCH,cAAc,CAACG,GAAG,GAAGF,IAAN,GAAaC,GAAd,CAAd,GAAmCH,cAAc,CAACG,GAAG,GAAGD,IAAN,GAAaE,GAAd,CAAjD;IACD;EACF;;EACD,OAAOH,cAAP;AACD,CAXM;AAaP;AACA;AACA;;AACA,OAAO,MAAMI,qBAAqB,GAAIpB,EAAD,IAAiB;EACpD,UADoD,CAEpD;;EACA,MAAMhD,CAAC,GAAGgD,EAAE,CAAC,CAAD,CAAZ,CAHoD,CAGnC;;EACjB,MAAMrB,CAAC,GAAGqB,EAAE,CAAC,CAAD,CAAZ,CAJoD,CAInC;;EACjB,MAAM9B,CAAC,GAAG8B,EAAE,CAAC,CAAD,CAAZ,CALoD,CAKnC;;EACjB,MAAMqB,CAAC,GAAGrB,EAAE,CAAC,CAAD,CAAZ,CANoD,CAMnC;;EACjB,MAAMsB,EAAE,GAAGtB,EAAE,CAAC,EAAD,CAAb,CAPoD,CAOjC;;EACnB,MAAMuB,EAAE,GAAGvB,EAAE,CAAC,EAAD,CAAb,CARoD,CAQjC;EAEnB;;EACA,OAAO,CAAChD,CAAD,EAAI2B,CAAJ,EAAOT,CAAP,EAAUmD,CAAV,EAAaC,EAAb,EAAiBC,EAAjB,CAAP;AACD,CAZM"}
|
@@ -3,7 +3,7 @@ import type { Vector } from "../Point";
|
|
3
3
|
import type { SkRuntimeEffect, SkRuntimeShaderBuilder } from "../RuntimeEffect";
|
4
4
|
export declare const isShader: (obj: SkJSIInstance<string> | null) => obj is SkShader;
|
5
5
|
export type SkShader = SkJSIInstance<"Shader">;
|
6
|
-
export type Uniform = number | Vector | Float32Array | Uniform[];
|
6
|
+
export type Uniform = number | Vector | Float32Array | readonly Uniform[] | Uniform[];
|
7
7
|
export interface Uniforms {
|
8
8
|
[name: string]: Uniform;
|
9
9
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isShader","obj","__typename__","isVector","x","undefined","y","processValue","values","value","push","Array","isArray","forEach","v","Float32Array","processUniforms","source","uniforms","builder","result","uniformsCount","getUniformCount","i","name","getUniformName","Error","uniformValue","setUniform"],"sources":["Shader.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { Vector } from \"../Point\";\nimport type { SkRuntimeEffect, SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n\nexport type Uniform
|
1
|
+
{"version":3,"names":["isShader","obj","__typename__","isVector","x","undefined","y","processValue","values","value","push","Array","isArray","forEach","v","Float32Array","processUniforms","source","uniforms","builder","result","uniformsCount","getUniformCount","i","name","getUniformName","Error","uniformValue","setUniform"],"sources":["Shader.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { Vector } from \"../Point\";\nimport type { SkRuntimeEffect, SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\n\nexport const isShader = (obj: SkJSIInstance<string> | null): obj is SkShader =>\n obj !== null && obj.__typename__ === \"Shader\";\n\nexport type SkShader = SkJSIInstance<\"Shader\">;\n\nexport type Uniform =\n | number\n | Vector\n | Float32Array\n | readonly Uniform[]\n | Uniform[];\n\nexport interface Uniforms {\n [name: string]: Uniform;\n}\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\nconst processValue = (values: number[], value: Uniform) => {\n if (typeof value === \"number\") {\n values.push(value);\n } else if (Array.isArray(value)) {\n value.forEach((v) => processValue(values, v));\n } else if (isVector(value)) {\n values.push(value.x, value.y);\n } else if (value instanceof Float32Array) {\n values.push(...value);\n }\n};\n\nexport const processUniforms = (\n source: SkRuntimeEffect,\n uniforms: Uniforms,\n builder?: SkRuntimeShaderBuilder\n) => {\n const result: number[] = [];\n const uniformsCount = source.getUniformCount();\n for (let i = 0; i < uniformsCount; i++) {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(\n // eslint-disable-next-line max-len\n `The runtime effect has the uniform value \"${name}\" declared, but it is missing from the uniforms property of the Runtime effect.`\n );\n }\n if (builder === undefined) {\n processValue(result, value);\n } else {\n const uniformValue: number[] = [];\n processValue(uniformValue, value);\n builder.setUniform(name, uniformValue);\n result.push(...uniformValue);\n }\n }\n return result;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAgBA,GAAG,CAACC,YAAJ,KAAqB,QADhC;;AAgBP,MAAMC,QAAQ,GAAIF,GAAD,IACf;AACA;AACCA,GAAD,CAAaG,CAAb,KAAmBC,SAAnB,IAAiCJ,GAAD,CAAaK,CAAb,KAAmBD,SAHrD;;AAKA,MAAME,YAAY,GAAG,CAACC,MAAD,EAAmBC,KAAnB,KAAsC;EACzD,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;IAC7BD,MAAM,CAACE,IAAP,CAAYD,KAAZ;EACD,CAFD,MAEO,IAAIE,KAAK,CAACC,OAAN,CAAcH,KAAd,CAAJ,EAA0B;IAC/BA,KAAK,CAACI,OAAN,CAAeC,CAAD,IAAOP,YAAY,CAACC,MAAD,EAASM,CAAT,CAAjC;EACD,CAFM,MAEA,IAAIX,QAAQ,CAACM,KAAD,CAAZ,EAAqB;IAC1BD,MAAM,CAACE,IAAP,CAAYD,KAAK,CAACL,CAAlB,EAAqBK,KAAK,CAACH,CAA3B;EACD,CAFM,MAEA,IAAIG,KAAK,YAAYM,YAArB,EAAmC;IACxCP,MAAM,CAACE,IAAP,CAAY,GAAGD,KAAf;EACD;AACF,CAVD;;AAYA,OAAO,MAAMO,eAAe,GAAG,CAC7BC,MAD6B,EAE7BC,QAF6B,EAG7BC,OAH6B,KAI1B;EACH,MAAMC,MAAgB,GAAG,EAAzB;EACA,MAAMC,aAAa,GAAGJ,MAAM,CAACK,eAAP,EAAtB;;EACA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,aAApB,EAAmCE,CAAC,EAApC,EAAwC;IACtC,MAAMC,IAAI,GAAGP,MAAM,CAACQ,cAAP,CAAsBF,CAAtB,CAAb;IACA,MAAMd,KAAK,GAAGS,QAAQ,CAACM,IAAD,CAAtB;;IACA,IAAIf,KAAK,KAAKJ,SAAd,EAAyB;MACvB,MAAM,IAAIqB,KAAJ,EACJ;MACC,6CAA4CF,IAAK,iFAF9C,CAAN;IAID;;IACD,IAAIL,OAAO,KAAKd,SAAhB,EAA2B;MACzBE,YAAY,CAACa,MAAD,EAASX,KAAT,CAAZ;IACD,CAFD,MAEO;MACL,MAAMkB,YAAsB,GAAG,EAA/B;MACApB,YAAY,CAACoB,YAAD,EAAelB,KAAf,CAAZ;MACAU,OAAO,CAACS,UAAR,CAAmBJ,IAAnB,EAAyBG,YAAzB;MACAP,MAAM,CAACV,IAAP,CAAY,GAAGiB,YAAf;IACD;EACF;;EACD,OAAOP,MAAP;AACD,CA1BM"}
|
@@ -6,7 +6,8 @@ import { RRectNode } from "./drawings";
|
|
6
6
|
import type { NodeContext } from "./Node";
|
7
7
|
export declare class JsiSkDOM implements SkDOM {
|
8
8
|
private ctx;
|
9
|
-
|
9
|
+
private native;
|
10
|
+
constructor(ctx: NodeContext, native: boolean);
|
10
11
|
Layer(props?: ChildrenProps): import("../types").RenderNode<ChildrenProps>;
|
11
12
|
Group(props?: GroupProps): import("../types").RenderNode<GroupProps>;
|
12
13
|
Paint(props: PaintProps): import("../types").DeclarationNode<PaintProps>;
|
@@ -19,7 +20,7 @@ export declare class JsiSkDOM implements SkDOM {
|
|
19
20
|
Patch(props: PatchProps): import("../types").RenderNode<PatchProps>;
|
20
21
|
Points(props: PointsProps): import("../types").RenderNode<PointsProps>;
|
21
22
|
Rect(props: RectProps): import("./DrawingNode").JsiDrawingNode<RectProps, import("../..").SkRect>;
|
22
|
-
RRect(props: RoundedRectProps): import("./DrawingNode").JsiDrawingNode<RoundedRectProps, import("../..").SkRRect
|
23
|
+
RRect(props: RoundedRectProps): RRectNode | import("./DrawingNode").JsiDrawingNode<RoundedRectProps, import("../..").SkRRect>;
|
23
24
|
Vertices(props: VerticesProps): import("../types").RenderNode<VerticesProps>;
|
24
25
|
Text(props: TextProps): import("../types").RenderNode<TextProps>;
|
25
26
|
TextPath(props: TextPathProps): import("../types").RenderNode<TextPathProps>;
|