@shopify/react-native-skia 1.11.8 → 1.11.9-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +30 -153
- package/android/build.gradle +1 -1
- package/cpp/skia/include/codec/SkCodec.h +7 -2
- package/cpp/skia/include/config/SkUserConfig.h +11 -0
- package/cpp/skia/include/core/SkCanvas.h +11 -7
- package/cpp/skia/include/core/SkColor.h +10 -0
- package/cpp/skia/include/core/SkColorSpace.h +184 -2
- package/cpp/skia/include/core/SkColorType.h +114 -32
- package/cpp/skia/include/core/SkFontScanner.h +5 -8
- package/cpp/skia/include/core/SkFontStyle.h +1 -1
- package/cpp/skia/include/core/SkMaskFilter.h +0 -8
- package/cpp/skia/include/core/SkMilestone.h +1 -1
- package/cpp/skia/include/core/SkPath.h +1 -1
- package/cpp/skia/include/core/SkRRect.h +3 -1
- package/cpp/skia/include/core/SkShader.h +3 -3
- package/cpp/skia/include/core/SkString.h +8 -8
- package/cpp/skia/include/core/SkSurface.h +14 -0
- package/cpp/skia/include/core/SkTypeface.h +24 -7
- package/cpp/skia/include/effects/SkGradientShader.h +6 -1
- package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -0
- package/cpp/skia/include/encode/SkPngEncoder.h +14 -0
- package/cpp/skia/include/gpu/GpuTypes.h +9 -0
- package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +135 -133
- package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +5 -0
- package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +3 -3
- package/cpp/skia/include/gpu/ganesh/GrTypes.h +14 -9
- package/cpp/skia/include/gpu/graphite/Context.h +25 -2
- package/cpp/skia/include/gpu/graphite/ContextOptions.h +23 -5
- package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +20 -1
- package/cpp/skia/include/gpu/graphite/Image.h +1 -0
- package/cpp/skia/include/gpu/graphite/LogPriority.h +36 -0
- package/cpp/skia/include/gpu/graphite/PrecompileContext.h +52 -0
- package/cpp/skia/include/gpu/graphite/Recorder.h +6 -0
- package/cpp/skia/include/gpu/graphite/Recording.h +3 -1
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +4 -36
- package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +48 -0
- package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +3 -2
- package/cpp/skia/include/pathops/SkPathOps.h +9 -1
- package/cpp/skia/include/ports/SkFontMgr_FontConfigInterface.h +3 -0
- package/cpp/skia/include/private/SkPathRef.h +15 -21
- package/cpp/skia/include/private/base/SkAttributes.h +16 -10
- package/cpp/skia/include/private/base/SkMutex.h +8 -0
- package/cpp/skia/include/private/base/SkTArray.h +1 -1
- package/cpp/skia/include/private/base/SkTDArray.h +1 -1
- package/cpp/skia/include/private/base/SkTemplates.h +24 -11
- package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
- package/cpp/skia/include/sksl/SkSLDebugTrace.h +0 -3
- package/cpp/skia/modules/skcms/src/Transform_inl.h +20 -20
- package/cpp/skia/modules/skcms/src/skcms_Transform.h +4 -3
- package/cpp/skia/modules/skcms/src/skcms_public.h +19 -15
- package/cpp/skia/modules/skresources/include/SkResources.h +3 -1
- package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGImage.h +2 -2
- package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +2 -0
- package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -0
- package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
- package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +4 -0
- package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
- package/cpp/skia/src/core/SkLRUCache.h +19 -13
- package/cpp/skia/src/core/SkTHash.h +50 -4
- package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +1 -0
- package/lib/commonjs/external/reanimated/textures.js +4 -3
- package/lib/commonjs/external/reanimated/textures.js.map +1 -1
- package/lib/commonjs/headless/index.d.ts +1 -1
- package/lib/commonjs/headless/index.js +2 -2
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +2 -2
- package/lib/commonjs/renderer/Canvas.js +10 -27
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/renderer/Offscreen.d.ts +2 -2
- package/lib/commonjs/renderer/Offscreen.js +4 -4
- package/lib/commonjs/renderer/Offscreen.js.map +1 -1
- package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -5
- package/lib/commonjs/sksg/Container.d.ts +3 -1
- package/lib/commonjs/sksg/Container.js +7 -1
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.d.ts +1 -1
- package/lib/commonjs/sksg/HostConfig.js +36 -6
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Reconciler.d.ts +3 -2
- package/lib/commonjs/sksg/Reconciler.js +16 -6
- package/lib/commonjs/sksg/Reconciler.js.map +1 -1
- package/lib/module/Platform/Platform.web.js +1 -1
- package/lib/module/Platform/Platform.web.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Circle.js +1 -2
- package/lib/module/dom/nodes/datatypes/Circle.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.js +3 -3
- package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Rect.js +3 -5
- package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/module/external/reanimated/buffers.js +1 -2
- package/lib/module/external/reanimated/buffers.js.map +1 -1
- package/lib/module/external/reanimated/textures.js +5 -4
- package/lib/module/external/reanimated/textures.js.map +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.js +1 -1
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/module/external/reanimated/useVideo.js +10 -23
- package/lib/module/external/reanimated/useVideo.js.map +1 -1
- package/lib/module/headless/index.d.ts +1 -1
- package/lib/module/headless/index.js +2 -2
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +2 -2
- package/lib/module/renderer/Canvas.js +9 -27
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/renderer/Offscreen.d.ts +2 -2
- package/lib/module/renderer/Offscreen.js +4 -4
- package/lib/module/renderer/Offscreen.js.map +1 -1
- package/lib/module/renderer/__tests__/setup.d.ts +5 -5
- package/lib/module/skia/core/Vector.js +1 -1
- package/lib/module/skia/core/Vector.js.map +1 -1
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js +1 -4
- package/lib/module/skia/web/CanvasKitWebGLBufferImpl.js.map +1 -1
- package/lib/module/skia/web/Host.js +1 -7
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkAnimatedImage.js +3 -6
- package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +3 -6
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilter.js +3 -6
- package/lib/module/skia/web/JsiSkColorFilter.js.map +1 -1
- package/lib/module/skia/web/JsiSkContourMeasure.js +3 -6
- package/lib/module/skia/web/JsiSkContourMeasure.js.map +1 -1
- package/lib/module/skia/web/JsiSkContourMeasureIter.js +3 -6
- package/lib/module/skia/web/JsiSkContourMeasureIter.js.map +1 -1
- package/lib/module/skia/web/JsiSkData.js +3 -6
- package/lib/module/skia/web/JsiSkData.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +3 -6
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +8 -12
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilter.js +3 -6
- package/lib/module/skia/web/JsiSkImageFilter.js.map +1 -1
- package/lib/module/skia/web/JsiSkMaskFilter.js +3 -6
- package/lib/module/skia/web/JsiSkMaskFilter.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +5 -8
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +3 -6
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphBuilder.js +2 -3
- package/lib/module/skia/web/JsiSkParagraphBuilder.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js +1 -1
- package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraphStyle.js +15 -15
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +3 -6
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffect.js +3 -6
- package/lib/module/skia/web/JsiSkPathEffect.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +3 -6
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -6
- package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/module/skia/web/JsiSkPoint.js +3 -6
- package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.js +3 -6
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRSXform.js +3 -6
- package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/module/skia/web/JsiSkRect.js +3 -6
- package/lib/module/skia/web/JsiSkRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffect.js +3 -6
- package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/module/skia/web/JsiSkSVG.js +5 -8
- package/lib/module/skia/web/JsiSkSVG.js.map +1 -1
- package/lib/module/skia/web/JsiSkShader.js +3 -6
- package/lib/module/skia/web/JsiSkShader.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.js +3 -6
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextBlob.js +3 -6
- package/lib/module/skia/web/JsiSkTextBlob.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypeface.js +3 -6
- package/lib/module/skia/web/JsiSkTypeface.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +1 -4
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
- package/lib/module/skia/web/JsiSkVertices.js +3 -6
- package/lib/module/skia/web/JsiSkVertices.js.map +1 -1
- package/lib/module/skia/web/JsiVideo.js +2 -5
- package/lib/module/skia/web/JsiVideo.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +3 -1
- package/lib/module/sksg/Container.js +11 -8
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/HostConfig.d.ts +1 -1
- package/lib/module/sksg/HostConfig.js +36 -7
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Reconciler.d.ts +3 -2
- package/lib/module/sksg/Reconciler.js +16 -11
- package/lib/module/sksg/Reconciler.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +1 -5
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.js +3 -6
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +1 -1
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.js +2 -4
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Shaders.js +2 -3
- package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
- package/lib/module/views/SkiaBaseWebView.js +9 -12
- package/lib/module/views/SkiaBaseWebView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.js +1 -5
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/SkiaPictureView.web.js +1 -4
- package/lib/module/views/SkiaPictureView.web.js.map +1 -1
- package/lib/module/web/LoadSkiaWeb.js +1 -2
- package/lib/module/web/LoadSkiaWeb.js.map +1 -1
- package/lib/module/web/WithSkiaWeb.js +1 -1
- package/lib/module/web/WithSkiaWeb.js.map +1 -1
- package/lib/typescript/lib/commonjs/headless/index.d.ts +1 -1
- package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +9 -1
- package/lib/typescript/lib/commonjs/renderer/Offscreen.d.ts +2 -2
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +3 -0
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +21 -4
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +9 -2
- package/lib/typescript/lib/module/headless/index.d.ts +1 -1
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +9 -1
- package/lib/typescript/lib/module/renderer/Offscreen.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/CanvasKitWebGLBufferImpl.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/JsiSkAnimatedImage.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkColorFilter.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkContourMeasure.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkContourMeasureIter.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkData.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFilter.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkMaskFilter.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkMatrix.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPaint.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPathEffect.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPicture.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkPoint.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkRRect.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkRSXform.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkRect.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkRuntimeEffect.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkSVG.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkShader.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkTextBlob.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkTypeface.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkVertices.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +2 -2
- package/lib/typescript/lib/module/sksg/Container.d.ts +7 -12
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +20 -4
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +18 -17
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +5 -2
- package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +12 -11
- package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +2 -2
- package/lib/typescript/lib/module/views/SkiaPictureView.web.d.ts +1 -1
- package/lib/typescript/src/headless/index.d.ts +1 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +2 -2
- package/lib/typescript/src/renderer/Offscreen.d.ts +2 -2
- package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -5
- package/lib/typescript/src/sksg/Container.d.ts +3 -1
- package/lib/typescript/src/sksg/HostConfig.d.ts +1 -1
- package/lib/typescript/src/sksg/Reconciler.d.ts +3 -2
- package/libs/apple/libskia.xcframework/Info.plist +15 -15
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/macos-arm64_x86_64/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e/libskia.a +0 -0
- package/libs/apple/libskia.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/apple/libskottie.xcframework/Info.plist +8 -8
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/macos-arm64_x86_64/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e/libskottie.a +0 -0
- package/libs/apple/libskottie.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/apple/libskparagraph.xcframework/Info.plist +7 -7
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/macos-arm64_x86_64/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/apple/libskparagraph.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/apple/libsksg.xcframework/Info.plist +12 -12
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/macos-arm64_x86_64/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e/libsksg.a +0 -0
- package/libs/apple/libsksg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/apple/libskshaper.xcframework/Info.plist +14 -14
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/macos-arm64_x86_64/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e/libskshaper.a +0 -0
- package/libs/apple/libskshaper.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/Info.plist +14 -14
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/macos-arm64_x86_64/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_core.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_core.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/macos-arm64_x86_64/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libskunicode_libgrapheme.xcframework/tvos-arm64_arm64e_x86_64-simulator/libskunicode_libgrapheme.a +0 -0
- package/libs/apple/libsvg.xcframework/Info.plist +11 -11
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/macos-arm64_x86_64/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e/libsvg.a +0 -0
- package/libs/apple/libsvg.xcframework/tvos-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +10 -9
- package/src/external/reanimated/textures.tsx +5 -4
- package/src/headless/index.ts +2 -2
- package/src/renderer/Canvas.tsx +57 -80
- package/src/renderer/Offscreen.tsx +4 -4
- package/src/renderer/__tests__/Data.spec.tsx +9 -10
- package/src/renderer/__tests__/Drawings.spec.tsx +11 -11
- package/src/renderer/__tests__/FitBox.spec.tsx +10 -10
- package/src/renderer/__tests__/Glyphs.spec.tsx +2 -2
- package/src/renderer/__tests__/Image.spec.tsx +2 -2
- package/src/renderer/__tests__/Paths.spec.tsx +8 -8
- package/src/renderer/__tests__/Picture.spec.tsx +10 -12
- package/src/renderer/__tests__/Simple.spec.tsx +6 -6
- package/src/renderer/__tests__/Surfaces.spec.tsx +2 -2
- package/src/renderer/__tests__/Text.spec.tsx +12 -12
- package/src/renderer/__tests__/Transform.spec.tsx +8 -8
- package/src/renderer/__tests__/documentation/Group.spec.tsx +12 -12
- package/src/renderer/__tests__/documentation/getting-started/HelloWorld.spec.tsx +2 -2
- package/src/renderer/__tests__/documentation/paint/Overview.spec.tsx +8 -8
- package/src/renderer/__tests__/documentation/shapes/Box.spec.tsx +4 -4
- package/src/renderer/__tests__/e2e/Atlas.spec.tsx +3 -3
- package/src/renderer/__tests__/e2e/Offscreen.spec.tsx +1 -1
- package/src/renderer/__tests__/examples/BlendModes.spec.tsx +4 -4
- package/src/renderer/__tests__/setup.tsx +13 -13
- package/src/sksg/Container.ts +9 -1
- package/src/sksg/HostConfig.ts +37 -7
- package/src/sksg/Reconciler.ts +17 -6
- package/src/sksg/__tests__/Simple.spec.tsx +8 -8
- package/lib/commonjs/sksg/HostConfig2.d.ts +0 -19
- package/lib/commonjs/sksg/HostConfig2.js +0 -159
- package/lib/commonjs/sksg/HostConfig2.js.map +0 -1
- package/lib/module/sksg/HostConfig2.d.ts +0 -19
- package/lib/module/sksg/HostConfig2.js +0 -152
- package/lib/module/sksg/HostConfig2.js.map +0 -1
- package/lib/typescript/lib/commonjs/sksg/HostConfig2.d.ts +0 -44
- package/lib/typescript/lib/module/sksg/HostConfig2.d.ts +0 -43
- package/lib/typescript/src/sksg/HostConfig2.d.ts +0 -19
- package/src/sksg/HostConfig2.ts +0 -247
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","Skia","notifyChange","Rea","useBufferValue","size","bufferInitializer","makeMutable","Array","fill","map","useBuffer","modifier","
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Skia","notifyChange","Rea","useBufferValue","size","bufferInitializer","makeMutable","Array","fill","map","useBuffer","modifier","values","mod","deps","Object","__closure","mapperId","startMapper","value","forEach","val","index","stopMapper","useRectBuffer","XYWHRect","useRSXformBuffer","RSXform","usePointBuffer","Point","useColorBuffer","Color"],"sources":["buffers.ts"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { WorkletFunction } from \"react-native-reanimated/lib/typescript/commonTypes\";\n\nimport type { SkColor, SkHostRect, SkPoint, SkRSXform } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport { notifyChange } from \"./interpolators\";\nimport Rea from \"./ReanimatedProxy\";\n\ntype Modifier<T> = (input: T, index: number) => void;\n\nconst useBufferValue = <T>(size: number, bufferInitializer: () => T) => {\n return useMemo(\n () => Rea.makeMutable(new Array(size).fill(0).map(bufferInitializer)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [size]\n );\n};\n\nconst useBuffer = <T>(\n size: number,\n bufferInitializer: () => T,\n modifier: Modifier<T>\n) => {\n const values = useBufferValue(size, bufferInitializer);\n const mod = modifier as WorkletFunction;\n const deps = [size, ...Object.values(mod.__closure ?? {})];\n const mapperId = Rea.startMapper(() => {\n \"worklet\";\n values.value.forEach((val, index) => {\n modifier(val, index);\n });\n notifyChange(values);\n }, deps);\n\n useEffect(() => {\n return () => {\n Rea.stopMapper(mapperId);\n };\n }, [mapperId]);\n\n return values;\n};\n\nexport const useRectBuffer = (size: number, modifier: Modifier<SkHostRect>) =>\n useBuffer(size, () => Skia.XYWHRect(0, 0, 0, 0), modifier);\n\n// Usage for RSXform Buffer\nexport const useRSXformBuffer = (size: number, modifier: Modifier<SkRSXform>) =>\n useBuffer(size, () => Skia.RSXform(1, 0, 0, 0), modifier);\n\n// Usage for Point Buffer\nexport const usePointBuffer = (size: number, modifier: Modifier<SkPoint>) =>\n useBuffer(size, () => Skia.Point(0, 0), modifier);\n\n// Usage for Color Buffer\nexport const useColorBuffer = (size: number, modifier: Modifier<SkColor>) =>\n useBuffer(size, () => Skia.Color(\"black\"), modifier);\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAI1C,SAASC,IAAI,QAAQ,YAAY;AAEjC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,OAAOC,GAAG,MAAM,mBAAmB;AAInC,MAAMC,cAAc,GA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AAEO,QAA6B,KAC1ED,SAAS,CAACN,IAAI,EAAE,MAAMJ,IAAI,CAAC2B,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAEhB,QAAQ,CAAC;;AAE3D;AACA,OAAO,MAAMiB,cAAc,GAAGA,CAACxB,IAAY,EAAEO,QAA2B,KACtED,SAAS,CAACN,IAAI,EAAE,MAAMJ,IAAI,CAAC6B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAElB,QAAQ,CAAC;;AAEnD;AACA,OAAO,MAAMmB,cAAc,GAAGA,CAAC1B,IAAY,EAAEO,QAA2B,KACtED,SAAS,CAACN,IAAI,EAAE,MAAMJ,IAAI,CAAC+B,KAAK,CAAC,OAAO,CAAC,EAAEpB,QAAQ,CAAC","ignoreList":[]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useEffect, useMemo } from "react";
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
2
2
|
import { drawAsImageFromPicture, drawAsPicture } from "../../renderer/Offscreen";
|
3
3
|
import { Skia, useImage } from "../../skia";
|
4
4
|
import Rea from "./ReanimatedProxy";
|
@@ -12,13 +12,14 @@ export const useTexture = (element, size) => {
|
|
12
12
|
width,
|
13
13
|
height
|
14
14
|
} = size;
|
15
|
-
const picture =
|
16
|
-
|
15
|
+
const [picture, setPicture] = useState(null);
|
16
|
+
useEffect(() => {
|
17
|
+
drawAsPicture(element, {
|
17
18
|
x: 0,
|
18
19
|
y: 0,
|
19
20
|
width,
|
20
21
|
height
|
21
|
-
});
|
22
|
+
}).then(pic => setPicture(pic));
|
22
23
|
}, [element, width, height]);
|
23
24
|
return usePictureAsTexture(picture, size);
|
24
25
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","drawAsImageFromPicture","drawAsPicture","Skia","useImage","Rea","createTexture","texture","picture","size","value","useTexture","element","width","height","x","y","usePictureAsTexture","useTextureAsValue","console","warn","useTextureValueFromPicture","useSharedValue","runOnUI","useImageAsTexture","source","image","recorder","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (element: ReactElement, size: SkSize) => {\n const { width, height } = size;\n const picture =
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useState","drawAsImageFromPicture","drawAsPicture","Skia","useImage","Rea","createTexture","texture","picture","size","value","useTexture","element","width","height","setPicture","x","y","then","pic","usePictureAsTexture","useTextureAsValue","console","warn","useTextureValueFromPicture","useSharedValue","runOnUI","useImageAsTexture","source","image","recorder","PictureRecorder","canvas","beginRecording","drawImage","finishRecordingAsPicture"],"sources":["textures.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport type { ReactElement } from \"react\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport type {\n DataSourceParam,\n SkImage,\n SkPicture,\n SkSize,\n} from \"../../skia/types\";\nimport {\n drawAsImageFromPicture,\n drawAsPicture,\n} from \"../../renderer/Offscreen\";\nimport { Skia, useImage } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst createTexture = (\n texture: SharedValue<SkImage | null>,\n picture: SkPicture,\n size: SkSize\n) => {\n \"worklet\";\n texture.value = drawAsImageFromPicture(picture, size);\n};\n\nexport const useTexture = (element: ReactElement, size: SkSize) => {\n const { width, height } = size;\n const [picture, setPicture] = useState<SkPicture | null>(null);\n useEffect(() => {\n drawAsPicture(element, {\n x: 0,\n y: 0,\n width,\n height,\n }).then((pic) => setPicture(pic));\n }, [element, width, height]);\n return usePictureAsTexture(picture, size);\n};\n\nexport const useTextureAsValue = (element: ReactElement, size: SkSize) => {\n console.warn(\"useTextureAsValue has been renamed to use useTexture\");\n return useTexture(element, size);\n};\n\nexport const useTextureValueFromPicture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n console.warn(\n \"useTextureValueFromPicture has been renamed to use usePictureAsTexture\"\n );\n return usePictureAsTexture(picture, size);\n};\n\nexport const usePictureAsTexture = (\n picture: SkPicture | null,\n size: SkSize\n) => {\n const texture = Rea.useSharedValue<SkImage | null>(null);\n useEffect(() => {\n if (picture !== null) {\n Rea.runOnUI(createTexture)(texture, picture, size);\n }\n }, [texture, picture, size]);\n return texture;\n};\n\nexport const useImageAsTexture = (source: DataSourceParam) => {\n const image = useImage(source);\n const size = useMemo(() => {\n if (image) {\n return { width: image.width(), height: image.height() };\n }\n return { width: 0, height: 0 };\n }, [image]);\n const picture = useMemo(() => {\n if (image) {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording({\n x: 0,\n y: 0,\n width: size.width,\n height: size.height,\n });\n canvas.drawImage(image, 0, 0);\n return recorder.finishRecordingAsPicture();\n } else {\n return null;\n }\n }, [size, image]);\n return usePictureAsTexture(picture, size);\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAUpD,SACEC,sBAAsB,EACtBC,aAAa,QACR,0BAA0B;AACjC,SAASC,IAAI,EAAEC,QAAQ,QAAQ,YAAY;AAE3C,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,aAAa,GAAGA,CACpBC,OAAoC,EACpCC,OAAkB,EAClBC,IAAY,KACT;EACH,SAAS;;EACTF,OAAO,CAACG,KAAK,GAAGT,sBAAsB,CAACO,OAAO,EAAEC,IAAI,CAAC;AACvD,CAAC;AA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,CAAC,CAAC;EAC5B,OAAOF,OAAO;AAChB,CAAC;AAED,OAAO,MAAMoB,iBAAiB,GAAIC,MAAuB,IAAK;EAC5D,MAAMC,KAAK,GAAGzB,QAAQ,CAACwB,MAAM,CAAC;EAC9B,MAAMnB,IAAI,GAAGV,OAAO,CAAC,MAAM;IACzB,IAAI8B,KAAK,EAAE;MACT,OAAO;QAAEhB,KAAK,EAAEgB,KAAK,CAAChB,KAAK,CAAC,CAAC;QAAEC,MAAM,EAAEe,KAAK,CAACf,MAAM,CAAC;MAAE,CAAC;IACzD;IACA,OAAO;MAAED,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;EAChC,CAAC,EAAE,CAACe,KAAK,CAAC,CAAC;EACX,MAAMrB,OAAO,GAAGT,OAAO,CAAC,MAAM;IAC5B,IAAI8B,KAAK,EAAE;MACT,MAAMC,QAAQ,GAAG3B,IAAI,CAAC4B,eAAe,CAAC,CAAC;MACvC,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAc,CAAC;QACrCjB,CAAC,EAAE,CAAC;QACJC,CAAC,EAAE,CAAC;QACJJ,KAAK,EAAEJ,IAAI,CAACI,KAAK;QACjBC,MAAM,EAAEL,IAAI,CAACK;MACf,CAAC,CAAC;MACFkB,MAAM,CAACE,SAAS,CAACL,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;MAC7B,OAAOC,QAAQ,CAACK,wBAAwB,CAAC,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,EAAE,CAAC1B,IAAI,EAAEoB,KAAK,CAAC,CAAC;EACjB,OAAOT,mBAAmB,CAACZ,OAAO,EAAEC,IAAI,CAAC;AAC3C,CAAC","ignoreList":[]}
|
@@ -3,7 +3,7 @@ import Rea from "./ReanimatedProxy";
|
|
3
3
|
const DEFAULT_FRAME_DURATION = 60;
|
4
4
|
export const useAnimatedImageValue = (source, paused) => {
|
5
5
|
const defaultPaused = Rea.useSharedValue(false);
|
6
|
-
const isPaused = paused
|
6
|
+
const isPaused = paused ?? defaultPaused;
|
7
7
|
const currentFrame = Rea.useSharedValue(null);
|
8
8
|
const lastTimestamp = Rea.useSharedValue(-1);
|
9
9
|
const animatedImage = useAnimatedImage(source, err => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useAnimatedImage","Rea","DEFAULT_FRAME_DURATION","useAnimatedImageValue","source","paused","defaultPaused","useSharedValue","isPaused","currentFrame","lastTimestamp","animatedImage","err","console","error","Error","message","frameDuration","currentFrameDuration","useFrameCallback","frameInfo","value","timestamp","elapsed","decodeNextFrame","dispose","getCurrentFrame"],"sources":["useAnimatedImageValue.ts"],"sourcesContent":["import type { FrameInfo, SharedValue } from \"react-native-reanimated\";\n\nimport { useAnimatedImage } from \"../../skia/core/AnimatedImage\";\nimport type { DataSourceParam, SkImage } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst DEFAULT_FRAME_DURATION = 60;\n\nexport const useAnimatedImageValue = (\n source: DataSourceParam,\n paused?: SharedValue<boolean>\n) => {\n const defaultPaused = Rea.useSharedValue(false);\n const isPaused = paused ?? defaultPaused;\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const animatedImage = useAnimatedImage(source, (err) => {\n console.error(err);\n throw new Error(`Could not load animated image - got '${err.message}'`);\n });\n const frameDuration =\n animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!animatedImage) {\n currentFrame.value = null;\n return;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n const elapsed = timestamp - lastTimestamp.value;\n\n // Check if it's time to switch frames based on GIF frame duration\n if (elapsed < frameDuration) {\n return;\n }\n\n // Update the current frame\n animatedImage.decodeNextFrame();\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = animatedImage.getCurrentFrame();\n\n // Update the last timestamp\n lastTimestamp.value = timestamp;\n });\n return currentFrame;\n};\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,+BAA+B;AAGhE,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,sBAAsB,GAAG,EAAE;AAEjC,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,MAAuB,EACvBC,MAA6B,KAC1B;EACH,MAAMC,aAAa,GAAGL,GAAG,CAACM,cAAc,CAAC,KAAK,CAAC;EAC/C,MAAMC,QAAQ,GAAGH,MAAM,
|
1
|
+
{"version":3,"names":["useAnimatedImage","Rea","DEFAULT_FRAME_DURATION","useAnimatedImageValue","source","paused","defaultPaused","useSharedValue","isPaused","currentFrame","lastTimestamp","animatedImage","err","console","error","Error","message","frameDuration","currentFrameDuration","useFrameCallback","frameInfo","value","timestamp","elapsed","decodeNextFrame","dispose","getCurrentFrame"],"sources":["useAnimatedImageValue.ts"],"sourcesContent":["import type { FrameInfo, SharedValue } from \"react-native-reanimated\";\n\nimport { useAnimatedImage } from \"../../skia/core/AnimatedImage\";\nimport type { DataSourceParam, SkImage } from \"../../skia/types\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst DEFAULT_FRAME_DURATION = 60;\n\nexport const useAnimatedImageValue = (\n source: DataSourceParam,\n paused?: SharedValue<boolean>\n) => {\n const defaultPaused = Rea.useSharedValue(false);\n const isPaused = paused ?? defaultPaused;\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const lastTimestamp = Rea.useSharedValue(-1);\n const animatedImage = useAnimatedImage(source, (err) => {\n console.error(err);\n throw new Error(`Could not load animated image - got '${err.message}'`);\n });\n const frameDuration =\n animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;\n\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n if (!animatedImage) {\n currentFrame.value = null;\n return;\n }\n if (isPaused.value && lastTimestamp.value !== -1) {\n return;\n }\n const { timestamp } = frameInfo;\n const elapsed = timestamp - lastTimestamp.value;\n\n // Check if it's time to switch frames based on GIF frame duration\n if (elapsed < frameDuration) {\n return;\n }\n\n // Update the current frame\n animatedImage.decodeNextFrame();\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = animatedImage.getCurrentFrame();\n\n // Update the last timestamp\n lastTimestamp.value = timestamp;\n });\n return currentFrame;\n};\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,+BAA+B;AAGhE,OAAOC,GAAG,MAAM,mBAAmB;AAEnC,MAAMC,sBAAsB,GAAG,EAAE;AAEjC,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,MAAuB,EACvBC,MAA6B,KAC1B;EACH,MAAMC,aAAa,GAAGL,GAAG,CAACM,cAAc,CAAC,KAAK,CAAC;EAC/C,MAAMC,QAAQ,GAAGH,MAAM,IAAIC,aAAa;EACxC,MAAMG,YAAY,GAAGR,GAAG,CAACM,cAAc,CAAiB,IAAI,CAAC;EAC7D,MAAMG,aAAa,GAAGT,GAAG,CAACM,cAAc,CAAC,CAAC,CAAC,CAAC;EAC5C,MAAMI,aAAa,GAAGX,gBAAgB,CAACI,MAAM,EAAGQ,GAAG,IAAK;IACtDC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;IAClB,MAAM,IAAIG,KAAK,CAAC,wCAAwCH,GAAG,CAACI,OAAO,GAAG,CAAC;EACzE,CAAC,CAAC;EACF,MAAMC,aAAa,GACjB,CAAAN,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEO,oBAAoB,CAAC,CAAC,KAAIhB,sBAAsB;EAEjED,GAAG,CAACkB,gBAAgB,CAAEC,SAAoB,IAAK;IAC7C,IAAI,CAACT,aAAa,EAAE;MAClBF,YAAY,CAACY,KAAK,GAAG,IAAI;MACzB;IACF;IACA,IAAIb,QAAQ,CAACa,KAAK,IAAIX,aAAa,CAACW,KAAK,KAAK,CAAC,CAAC,EAAE;MAChD;IACF;IACA,MAAM;MAAEC;IAAU,CAAC,GAAGF,SAAS;IAC/B,MAAMG,OAAO,GAAGD,SAAS,GAAGZ,aAAa,CAACW,KAAK;;IAE/C;IACA,IAAIE,OAAO,GAAGN,aAAa,EAAE;MAC3B;IACF;;IAEA;IACAN,aAAa,CAACa,eAAe,CAAC,CAAC;IAC/B,IAAIf,YAAY,CAACY,KAAK,EAAE;MACtBZ,YAAY,CAACY,KAAK,CAACI,OAAO,CAAC,CAAC;IAC9B;IACAhB,YAAY,CAACY,KAAK,GAAGV,aAAa,CAACe,eAAe,CAAC,CAAC;;IAEpD;IACAhB,aAAa,CAACW,KAAK,GAAGC,SAAS;EACjC,CAAC,CAAC;EACF,OAAOb,YAAY;AACrB,CAAC","ignoreList":[]}
|
@@ -46,34 +46,21 @@ const disposeVideo = video => {
|
|
46
46
|
video === null || video === void 0 || video.dispose();
|
47
47
|
};
|
48
48
|
export const useVideo = (source, userOptions) => {
|
49
|
-
var _userOptions$paused, _userOptions$looping, _userOptions$seek, _userOptions$volume;
|
50
49
|
const video = useVideoLoading(source);
|
51
|
-
const isPaused = useOption((
|
52
|
-
const looping = useOption((
|
53
|
-
const seek = useOption((
|
54
|
-
const volume = useOption((
|
50
|
+
const isPaused = useOption((userOptions === null || userOptions === void 0 ? void 0 : userOptions.paused) ?? defaultOptions.paused);
|
51
|
+
const looping = useOption((userOptions === null || userOptions === void 0 ? void 0 : userOptions.looping) ?? defaultOptions.looping);
|
52
|
+
const seek = useOption((userOptions === null || userOptions === void 0 ? void 0 : userOptions.seek) ?? defaultOptions.seek);
|
53
|
+
const volume = useOption((userOptions === null || userOptions === void 0 ? void 0 : userOptions.volume) ?? defaultOptions.volume);
|
55
54
|
const currentFrame = Rea.useSharedValue(null);
|
56
55
|
const currentTime = Rea.useSharedValue(0);
|
57
56
|
const lastTimestamp = Rea.useSharedValue(-1);
|
58
|
-
const duration = useMemo(() =>
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
var _video$framerate;
|
64
|
-
return Platform.OS === "web" ? -1 : (_video$framerate = video === null || video === void 0 ? void 0 : video.framerate()) !== null && _video$framerate !== void 0 ? _video$framerate : 0;
|
65
|
-
}, [video]);
|
66
|
-
const size = useMemo(() => {
|
67
|
-
var _video$size;
|
68
|
-
return (_video$size = video === null || video === void 0 ? void 0 : video.size()) !== null && _video$size !== void 0 ? _video$size : {
|
69
|
-
width: 0,
|
70
|
-
height: 0
|
71
|
-
};
|
72
|
-
}, [video]);
|
73
|
-
const rotation = useMemo(() => {
|
74
|
-
var _video$rotation;
|
75
|
-
return (_video$rotation = video === null || video === void 0 ? void 0 : video.rotation()) !== null && _video$rotation !== void 0 ? _video$rotation : 0;
|
57
|
+
const duration = useMemo(() => (video === null || video === void 0 ? void 0 : video.duration()) ?? 0, [video]);
|
58
|
+
const framerate = useMemo(() => Platform.OS === "web" ? -1 : (video === null || video === void 0 ? void 0 : video.framerate()) ?? 0, [video]);
|
59
|
+
const size = useMemo(() => (video === null || video === void 0 ? void 0 : video.size()) ?? {
|
60
|
+
width: 0,
|
61
|
+
height: 0
|
76
62
|
}, [video]);
|
63
|
+
const rotation = useMemo(() => (video === null || video === void 0 ? void 0 : video.rotation()) ?? 0, [video]);
|
77
64
|
const frameDuration = 1000 / framerate;
|
78
65
|
const currentFrameDuration = Math.floor(frameDuration);
|
79
66
|
Rea.useAnimatedReaction(() => isPaused.value, paused => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useEffect","useMemo","Platform","Rea","useVideoLoading","copyFrameOnAndroid","currentFrame","OS","tex","value","makeNonTextureImage","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","currentTime","volume","useOption","defaultValue","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","_userOptions$paused","_userOptions$looping","_userOptions$seek","_userOptions$volume","isPaused","lastTimestamp","duration","_video$duration","framerate","_video$framerate","size","_video$size","width","height","rotation","_video$rotation","frameDuration","currentFrameDuration","Math","floor","useAnimatedReaction","pause","play","setVolume","useFrameCallback","frameInfo","currentTimestamp","timestamp","delta","isOver","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype MaybeAnimated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: MaybeAnimated<boolean>;\n paused: MaybeAnimated<boolean>;\n seek: MaybeAnimated<number | null>;\n volume: MaybeAnimated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n currentFrame.value = tex.makeNonTextureImage();\n tex.dispose();\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = img;\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n volume: 0,\n};\n\nconst useOption = <T>(value: MaybeAnimated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value)\n ? (value as SharedValue<T>)\n : (defaultValue as SharedValue<T>);\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : video?.framerate() ?? 0),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(frameDuration);\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n lastTimestamp.value = -1;\n video?.play();\n }\n }\n );\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n video?.seek(value);\n currentTime.value = value;\n seek.value = null;\n }\n }\n );\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (isPaused.value) {\n return;\n }\n const currentTimestamp = frameInfo.timestamp;\n if (lastTimestamp.value === -1) {\n lastTimestamp.value = currentTimestamp;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const isOver = currentTime.value + delta > duration;\n if (isOver && looping.value) {\n seek.value = 0;\n currentTime.value = seek.value;\n lastTimestamp.value = currentTimestamp;\n }\n // On Web the framerate is uknown.\n // This could be optimized by using requestVideoFrameCallback (Chrome only)\n if ((delta >= currentFrameDuration && !isOver) || Platform.OS === \"web\") {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return {\n currentFrame,\n currentTime,\n duration,\n framerate,\n rotation,\n size,\n };\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,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KAAK,IAAIX,oBAAoB,IAAI,CAACY,MAAM,IAAKzD,QAAQ,CAACK,EAAE,KAAK,KAAK,EAAE;MACvEK,QAAQ,CAACC,KAAK,EAAEP,YAAY,CAAC;MAC7Bc,WAAW,CAACX,KAAK,IAAIiD,KAAK;MAC1BvB,aAAa,CAAC1B,KAAK,GAAG+C,gBAAgB;IACxC;EACF,CAAC,CAAC;EAEFxD,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAG,GAAG,CAACyD,OAAO,CAAClC,YAAY,CAAC,CAACb,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAO;IACLP,YAAY;IACZc,WAAW;IACXgB,QAAQ;IACRE,SAAS;IACTM,QAAQ;IACRJ;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"names":["useEffect","useMemo","Platform","Rea","useVideoLoading","copyFrameOnAndroid","currentFrame","OS","tex","value","makeNonTextureImage","dispose","setFrame","video","img","nextImage","defaultOptions","looping","paused","seek","currentTime","volume","useOption","defaultValue","useSharedValue","isSharedValue","disposeVideo","useVideo","source","userOptions","isPaused","lastTimestamp","duration","framerate","size","width","height","rotation","frameDuration","currentFrameDuration","Math","floor","useAnimatedReaction","pause","play","setVolume","useFrameCallback","frameInfo","currentTimestamp","timestamp","delta","isOver","runOnUI"],"sources":["useVideo.ts"],"sourcesContent":["import type { SharedValue, FrameInfo } from \"react-native-reanimated\";\nimport { useEffect, useMemo } from \"react\";\n\nimport type { SkImage, Video } from \"../../skia/types\";\nimport { Platform } from \"../../Platform\";\n\nimport Rea from \"./ReanimatedProxy\";\nimport { useVideoLoading } from \"./useVideoLoading\";\n\ntype MaybeAnimated<T> = SharedValue<T> | T;\n\ninterface PlaybackOptions {\n looping: MaybeAnimated<boolean>;\n paused: MaybeAnimated<boolean>;\n seek: MaybeAnimated<number | null>;\n volume: MaybeAnimated<number>;\n}\n\nconst copyFrameOnAndroid = (currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n // on android we need to copy the texture before it's invalidated\n if (Platform.OS === \"android\") {\n const tex = currentFrame.value;\n if (tex) {\n currentFrame.value = tex.makeNonTextureImage();\n tex.dispose();\n }\n }\n};\n\nconst setFrame = (video: Video, currentFrame: SharedValue<SkImage | null>) => {\n \"worklet\";\n const img = video.nextImage();\n if (img) {\n if (currentFrame.value) {\n currentFrame.value.dispose();\n }\n currentFrame.value = img;\n copyFrameOnAndroid(currentFrame);\n }\n};\n\nconst defaultOptions = {\n looping: true,\n paused: false,\n seek: null,\n currentTime: 0,\n volume: 0,\n};\n\nconst useOption = <T>(value: MaybeAnimated<T>) => {\n \"worklet\";\n // TODO: only create defaultValue is needed (via makeMutable)\n const defaultValue = Rea.useSharedValue(\n Rea.isSharedValue(value) ? value.value : value\n );\n return Rea.isSharedValue(value)\n ? (value as SharedValue<T>)\n : (defaultValue as SharedValue<T>);\n};\n\nconst disposeVideo = (video: Video | null) => {\n \"worklet\";\n video?.dispose();\n};\n\nexport const useVideo = (\n source: string | null,\n userOptions?: Partial<PlaybackOptions>\n) => {\n const video = useVideoLoading(source);\n const isPaused = useOption(userOptions?.paused ?? defaultOptions.paused);\n const looping = useOption(userOptions?.looping ?? defaultOptions.looping);\n const seek = useOption(userOptions?.seek ?? defaultOptions.seek);\n const volume = useOption(userOptions?.volume ?? defaultOptions.volume);\n const currentFrame = Rea.useSharedValue<null | SkImage>(null);\n const currentTime = Rea.useSharedValue(0);\n const lastTimestamp = Rea.useSharedValue(-1);\n const duration = useMemo(() => video?.duration() ?? 0, [video]);\n const framerate = useMemo(\n () => (Platform.OS === \"web\" ? -1 : video?.framerate() ?? 0),\n [video]\n );\n const size = useMemo(() => video?.size() ?? { width: 0, height: 0 }, [video]);\n const rotation = useMemo(() => video?.rotation() ?? 0, [video]);\n const frameDuration = 1000 / framerate;\n const currentFrameDuration = Math.floor(frameDuration);\n Rea.useAnimatedReaction(\n () => isPaused.value,\n (paused) => {\n if (paused) {\n video?.pause();\n } else {\n lastTimestamp.value = -1;\n video?.play();\n }\n }\n );\n Rea.useAnimatedReaction(\n () => seek.value,\n (value) => {\n if (value !== null) {\n video?.seek(value);\n currentTime.value = value;\n seek.value = null;\n }\n }\n );\n Rea.useAnimatedReaction(\n () => volume.value,\n (value) => {\n video?.setVolume(value);\n }\n );\n Rea.useFrameCallback((frameInfo: FrameInfo) => {\n \"worklet\";\n if (!video) {\n return;\n }\n if (isPaused.value) {\n return;\n }\n const currentTimestamp = frameInfo.timestamp;\n if (lastTimestamp.value === -1) {\n lastTimestamp.value = currentTimestamp;\n }\n const delta = currentTimestamp - lastTimestamp.value;\n\n const isOver = currentTime.value + delta > duration;\n if (isOver && looping.value) {\n seek.value = 0;\n currentTime.value = seek.value;\n lastTimestamp.value = currentTimestamp;\n }\n // On Web the framerate is uknown.\n // This could be optimized by using requestVideoFrameCallback (Chrome only)\n if ((delta >= currentFrameDuration && !isOver) || Platform.OS === \"web\") {\n setFrame(video, currentFrame);\n currentTime.value += delta;\n lastTimestamp.value = currentTimestamp;\n }\n });\n\n useEffect(() => {\n return () => {\n // TODO: should video simply be a shared value instead?\n Rea.runOnUI(disposeVideo)(video);\n };\n }, [video]);\n\n return {\n currentFrame,\n currentTime,\n duration,\n framerate,\n rotation,\n size,\n };\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAG1C,SAASC,QAAQ,QAAQ,gBAAgB;AAEzC,OAAOC,GAAG,MAAM,mBAAmB;AACnC,SAASC,eAAe,QAAQ,mBAAmB;AAWnD,MAAMC,kBAAkB,GAAIC,YAAyC,IAAK;EACxE,SAAS;;EACT;EACA,IAAIJ,QAAQ,CAACK,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAGF,YAAY,CAACG,KAAK;IAC9B,IAAID,GAAG,EAAE;MACPF,YAAY,CAACG,KAAK,GAAGD,GAAG,CAACE,mBAAmB,CAAC,CAAC;MAC9CF,GAAG,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K,GAAGF,gBAAgB,GAAGjB,aAAa,CAACtB,KAAK;IAEpD,MAAM0C,MAAM,GAAG/B,WAAW,CAACX,KAAK,GAAGyC,KAAK,GAAGlB,QAAQ;IACnD,IAAImB,MAAM,IAAIlC,OAAO,CAACR,KAAK,EAAE;MAC3BU,IAAI,CAACV,KAAK,GAAG,CAAC;MACdW,WAAW,CAACX,KAAK,GAAGU,IAAI,CAACV,KAAK;MAC9BsB,aAAa,CAACtB,KAAK,GAAGuC,gBAAgB;IACxC;IACA;IACA;IACA,IAAKE,KAAK,IAAIX,oBAAoB,IAAI,CAACY,MAAM,IAAKjD,QAAQ,CAACK,EAAE,KAAK,KAAK,EAAE;MACvEK,QAAQ,CAACC,KAAK,EAAEP,YAAY,CAAC;MAC7Bc,WAAW,CAACX,KAAK,IAAIyC,KAAK;MAC1BnB,aAAa,CAACtB,KAAK,GAAGuC,gBAAgB;IACxC;EACF,CAAC,CAAC;EAEFhD,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX;MACAG,GAAG,CAACiD,OAAO,CAAC1B,YAAY,CAAC,CAACb,KAAK,CAAC;IAClC,CAAC;EACH,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,OAAO;IACLP,YAAY;IACZc,WAAW;IACXY,QAAQ;IACRC,SAAS;IACTI,QAAQ;IACRH;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
@@ -5,4 +5,4 @@ export declare const makeOffscreenSurface: (width: number, height: number) => Sk
|
|
5
5
|
export declare const getSkiaExports: () => {
|
6
6
|
Skia: import("../skia/types").Skia;
|
7
7
|
};
|
8
|
-
export declare const drawOffscreen: (surface: SkSurface, element: ReactNode) => import("../skia").SkImage
|
8
|
+
export declare const drawOffscreen: (surface: SkSurface, element: ReactNode) => Promise<import("../skia").SkImage>;
|
@@ -23,9 +23,9 @@ export const getSkiaExports = () => {
|
|
23
23
|
Skia
|
24
24
|
};
|
25
25
|
};
|
26
|
-
export const drawOffscreen = (surface, element) => {
|
26
|
+
export const drawOffscreen = async (surface, element) => {
|
27
27
|
const root = new SkiaSGRoot(Skia);
|
28
|
-
root.render(element);
|
28
|
+
await root.render(element);
|
29
29
|
const canvas = surface.getCanvas();
|
30
30
|
root.drawOnCanvas(canvas);
|
31
31
|
root.unmount();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkApi","SkiaSGRoot","Skia","makeOffscreenSurface","width","height","CanvasKit","surface","Surface","MakeOffscreen","Error","getSkiaExports","drawOffscreen","element","root","render","canvas","getCanvas","drawOnCanvas","unmount","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 type { SkSurface } from \"../skia\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\nexport * from \"../renderer/components\";\n\nlet Skia: ReturnType<typeof JsiSkApi>;\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 getSkiaExports = () => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n return { Skia };\n};\n\nexport const drawOffscreen = (surface: SkSurface, element: ReactNode) => {\n const root = new SkiaSGRoot(Skia);\n root.render(element);\n const canvas = surface.getCanvas();\n root.drawOnCanvas(canvas);\n root.unmount();\n surface.flush();\n return surface.makeImageSnapshot();\n};\n"],"mappings":"AAAA;AACA;;AAIA,SAASA,QAAQ,QAAQ,aAAa;AAEtC,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,cAAc,wBAAwB;AAEtC,IAAIC,IAAiC;AAErC,OAAO,MAAMC,oBAAoB,GAAGA,CAACC,KAAa,EAAEC,MAAc,KAAK;EACrE,IAAI,CAACH,IAAI,EAAE;IACTA,IAAI,GAAGF,QAAQ,CAACM,SAAS,CAAC;EAC5B;EACA,MAAMC,OAAO,GAAGL,IAAI,CAACM,OAAO,CAACC,aAAa,CAACL,KAAK,EAAEC,MAAM,CAAC;EACzD,IAAIE,OAAO,KAAK,IAAI,EAAE;IACpB,MAAM,IAAIG,KAAK,CAAC,0BAA0B,CAAC;EAC7C;EACA,OAAOH,OAAO;AAChB,CAAC;AAED,OAAO,MAAMI,cAAc,GAAGA,CAAA,KAAM;EAClC,IAAI,CAACT,IAAI,EAAE;IACTA,IAAI,GAAGF,QAAQ,CAACM,SAAS,CAAC;EAC5B;EACA,OAAO;IAAEJ;EAAK,CAAC;AACjB,CAAC;AAED,OAAO,MAAMU,aAAa,
|
1
|
+
{"version":3,"names":["JsiSkApi","SkiaSGRoot","Skia","makeOffscreenSurface","width","height","CanvasKit","surface","Surface","MakeOffscreen","Error","getSkiaExports","drawOffscreen","element","root","render","canvas","getCanvas","drawOnCanvas","unmount","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 type { SkSurface } from \"../skia\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\nexport * from \"../renderer/components\";\n\nlet Skia: ReturnType<typeof JsiSkApi>;\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 getSkiaExports = () => {\n if (!Skia) {\n Skia = JsiSkApi(CanvasKit);\n }\n return { Skia };\n};\n\nexport const drawOffscreen = async (surface: SkSurface, element: ReactNode) => {\n const root = new SkiaSGRoot(Skia);\n await root.render(element);\n const canvas = surface.getCanvas();\n root.drawOnCanvas(canvas);\n root.unmount();\n surface.flush();\n return surface.makeImageSnapshot();\n};\n"],"mappings":"AAAA;AACA;;AAIA,SAASA,QAAQ,QAAQ,aAAa;AAEtC,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,cAAc,wBAAwB;AAEtC,IAAIC,IAAiC;AAErC,OAAO,MAAMC,oBAAoB,GAAGA,CAACC,KAAa,EAAEC,MAAc,KAAK;EACrE,IAAI,CAACH,IAAI,EAAE;IACTA,IAAI,GAAGF,QAAQ,CAACM,SAAS,CAAC;EAC5B;EACA,MAAMC,OAAO,GAAGL,IAAI,CAACM,OAAO,CAACC,aAAa,CAACL,KAAK,EAAEC,MAAM,CAAC;EACzD,IAAIE,OAAO,KAAK,IAAI,EAAE;IACpB,MAAM,IAAIG,KAAK,CAAC,0BAA0B,CAAC;EAC7C;EACA,OAAOH,OAAO;AAChB,CAAC;AAED,OAAO,MAAMI,cAAc,GAAGA,CAAA,KAAM;EAClC,IAAI,CAACT,IAAI,EAAE;IACTA,IAAI,GAAGF,QAAQ,CAACM,SAAS,CAAC;EAC5B;EACA,OAAO;IAAEJ;EAAK,CAAC;AACjB,CAAC;AAED,OAAO,MAAMU,aAAa,GAAG,MAAAA,CAAOL,OAAkB,EAAEM,OAAkB,KAAK;EAC7E,MAAMC,IAAI,GAAG,IAAIb,UAAU,CAACC,IAAI,CAAC;EACjC,MAAMY,IAAI,CAACC,MAAM,CAACF,OAAO,CAAC;EAC1B,MAAMG,MAAM,GAAGT,OAAO,CAACU,SAAS,CAAC,CAAC;EAClCH,IAAI,CAACI,YAAY,CAACF,MAAM,CAAC;EACzBF,IAAI,CAACK,OAAO,CAAC,CAAC;EACdZ,OAAO,CAACa,KAAK,CAAC,CAAC;EACf,OAAOb,OAAO,CAACc,iBAAiB,CAAC,CAAC;AACpC,CAAC","ignoreList":[]}
|
@@ -14,7 +14,7 @@ export interface CanvasProps extends ViewProps {
|
|
14
14
|
debug?: boolean;
|
15
15
|
opaque?: boolean;
|
16
16
|
onSize?: SharedValue<SkSize>;
|
17
|
-
|
17
|
+
ref?: React.Ref<CanvasRef>;
|
18
18
|
}
|
19
|
-
export declare const Canvas:
|
19
|
+
export declare const Canvas: ({ debug, opaque, children, onSize, onLayout: _onLayout, ref, ...viewProps }: CanvasProps) => React.JSX.Element;
|
20
20
|
export {};
|
@@ -1,11 +1,12 @@
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
2
|
-
import React, {
|
2
|
+
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
|
3
3
|
import { SkiaViewNativeId } from "../views/SkiaViewNativeId";
|
4
4
|
import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
|
5
5
|
import { SkiaSGRoot } from "../sksg/Reconciler";
|
6
6
|
import { Skia } from "../skia";
|
7
7
|
export const useCanvasRef = () => useRef(null);
|
8
|
-
|
8
|
+
|
9
|
+
//const NativeSkiaPictureView = SkiaPictureViewNativeComponent;
|
9
10
|
|
10
11
|
// TODO: no need to go through the JS thread for this
|
11
12
|
const useOnSizeEvent = (resultValue, onLayout) => {
|
@@ -25,16 +26,15 @@ const useOnSizeEvent = (resultValue, onLayout) => {
|
|
25
26
|
}
|
26
27
|
}, [onLayout, resultValue]);
|
27
28
|
};
|
28
|
-
export const Canvas =
|
29
|
-
mode,
|
29
|
+
export const Canvas = ({
|
30
30
|
debug,
|
31
31
|
opaque,
|
32
32
|
children,
|
33
33
|
onSize,
|
34
34
|
onLayout: _onLayout,
|
35
|
+
ref,
|
35
36
|
...viewProps
|
36
|
-
}
|
37
|
-
const rafId = useRef(null);
|
37
|
+
}) => {
|
38
38
|
const onLayout = useOnSizeEvent(onSize, _onLayout);
|
39
39
|
// Native ID
|
40
40
|
const nativeId = useMemo(() => {
|
@@ -53,25 +53,7 @@ export const Canvas = /*#__PURE__*/forwardRef(({
|
|
53
53
|
root.unmount();
|
54
54
|
};
|
55
55
|
}, [root]);
|
56
|
-
|
57
|
-
rafId.current = requestAnimationFrame(() => {
|
58
|
-
root.render(children);
|
59
|
-
if (mode === "continuous") {
|
60
|
-
requestRedraw();
|
61
|
-
}
|
62
|
-
});
|
63
|
-
}, [children, mode, root]);
|
64
|
-
useEffect(() => {
|
65
|
-
if (mode === "continuous") {
|
66
|
-
console.warn("The `mode` property in `Canvas` is deprecated.");
|
67
|
-
requestRedraw();
|
68
|
-
}
|
69
|
-
return () => {
|
70
|
-
if (rafId.current !== null) {
|
71
|
-
cancelAnimationFrame(rafId.current);
|
72
|
-
}
|
73
|
-
};
|
74
|
-
}, [mode, requestRedraw]);
|
56
|
+
|
75
57
|
// Component methods
|
76
58
|
useImperativeHandle(ref, () => ({
|
77
59
|
makeImageSnapshot: rect => {
|
@@ -87,12 +69,12 @@ export const Canvas = /*#__PURE__*/forwardRef(({
|
|
87
69
|
return nativeId;
|
88
70
|
}
|
89
71
|
}));
|
90
|
-
return /*#__PURE__*/React.createElement(
|
72
|
+
return /*#__PURE__*/React.createElement(SkiaPictureViewNativeComponent, _extends({
|
91
73
|
collapsable: false,
|
92
74
|
nativeID: `${nativeId}`,
|
93
75
|
debug: debug,
|
94
76
|
opaque: opaque,
|
95
77
|
onLayout: onLayout
|
96
78
|
}, viewProps));
|
97
|
-
}
|
79
|
+
};
|
98
80
|
//# sourceMappingURL=Canvas.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useImperativeHandle","useMemo","useRef","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","debug","opaque","children","onSize","_onLayout","ref","viewProps","nativeId","current","root","render","unmount","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","requestRedraw","getNativeId","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\n//const NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\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 interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n ref?: React.Ref<CanvasRef>;\n}\n\nexport const Canvas = ({\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ref,\n ...viewProps\n}: CanvasProps) => {\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n // Component methods\n useImperativeHandle(\n ref,\n () =>\n ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n } as CanvasRef)\n );\n return (\n <SkiaPictureViewNativeComponent\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n};\n"],"mappings":";AACA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AAId,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAU9B,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAML,MAAM,CAAY,IAAI,CAAC;;AAEzD;;AAEA;AACA,MAAMM,cAAc,GAAGA,CACrBC,WAAwC,EACxCC,QAA6C,KAC1C;EACH,OAAOZ,WAAW,CACfa,KAAwB,IAAK;IAC5B,IAAID,QAAQ,EAAE;MACZA,QAAQ,CAACC,KAAK,CAAC;IACjB;IACA,MAAM;MAAEC,KAAK;MAAEC;IAAO,CAAC,GAAGF,KAAK,CAACG,WAAW,CAACC,MAAM;IAElD,IAAIN,WAAW,EAAE;MACfA,WAAW,CAACO,KAAK,GAAG;QAAEJ,KAAK;QAAEC;MAAO,CAAC;IACvC;EACF,CAAC,EACD,CAACH,QAAQ,EAAED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,CAAAwC,aAAA,CAACjC,8BAA8B,EAAAkC,QAAA;IAC7BC,WAAW,EAAE,KAAM;IACnBC,QAAQ,EAAE,GAAGf,QAAQ,EAAG;IACxBP,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfT,QAAQ,EAAEA;EAAS,GACfc,SAAS,CACd,CAAC;AAEN,CAAC","ignoreList":[]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ReactElement } from "react";
|
2
2
|
import type { SkPicture, SkRect, SkSize } from "../skia/types";
|
3
3
|
export declare const isOnMainThread: () => boolean;
|
4
|
-
export declare const drawAsPicture: (element: ReactElement, bounds?: SkRect) => SkPicture
|
5
|
-
export declare const drawAsImage: (element: ReactElement, size: SkSize) => import("../skia").SkImage
|
4
|
+
export declare const drawAsPicture: (element: ReactElement, bounds?: SkRect) => Promise<SkPicture>;
|
5
|
+
export declare const drawAsImage: (element: ReactElement, size: SkSize) => Promise<import("../skia").SkImage>;
|
6
6
|
export declare const drawAsImageFromPicture: (picture: SkPicture, size: SkSize) => import("../skia").SkImage;
|
@@ -8,18 +8,18 @@ export const isOnMainThread = () => {
|
|
8
8
|
|
9
9
|
return typeof _WORKLET !== "undefined" && _WORKLET === true || Platform.OS === "web";
|
10
10
|
};
|
11
|
-
export const drawAsPicture = (element, bounds) => {
|
11
|
+
export const drawAsPicture = async (element, bounds) => {
|
12
12
|
const recorder = Skia.PictureRecorder();
|
13
13
|
const canvas = recorder.beginRecording(bounds);
|
14
14
|
const root = new SkiaSGRoot(Skia);
|
15
|
-
root.render(element);
|
15
|
+
await root.render(element);
|
16
16
|
root.drawOnCanvas(canvas);
|
17
17
|
const picture = recorder.finishRecordingAsPicture();
|
18
18
|
root.unmount();
|
19
19
|
return picture;
|
20
20
|
};
|
21
|
-
export const drawAsImage = (element, size) => {
|
22
|
-
return drawAsImageFromPicture(drawAsPicture(element), size);
|
21
|
+
export const drawAsImage = async (element, size) => {
|
22
|
+
return drawAsImageFromPicture(await drawAsPicture(element), size);
|
23
23
|
};
|
24
24
|
export const drawAsImageFromPicture = (picture, size) => {
|
25
25
|
"worklet";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","Platform","SkiaSGRoot","isOnMainThread","_WORKLET","OS","drawAsPicture","element","bounds","recorder","PictureRecorder","canvas","beginRecording","root","render","drawOnCanvas","picture","finishRecordingAsPicture","unmount","drawAsImage","size","drawAsImageFromPicture","surface","Surface","MakeOffscreen","width","height","getCanvas","drawPicture","flush","image","makeImageSnapshot","makeNonTextureImage"],"sources":["Offscreen.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nimport type { SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\n// We call it main thread because on web main is JS thread\nexport const isOnMainThread = () => {\n \"worklet\";\n return (\n (typeof _WORKLET !== \"undefined\" && _WORKLET === true) ||\n Platform.OS === \"web\"\n );\n};\n\nexport const drawAsPicture = (element: ReactElement, bounds?: SkRect) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(bounds);\n const root = new SkiaSGRoot(Skia);\n root.render(element);\n root.drawOnCanvas(canvas);\n const picture = recorder.finishRecordingAsPicture();\n root.unmount();\n return picture;\n};\n\nexport const drawAsImage = (element: ReactElement, size: SkSize) => {\n return drawAsImageFromPicture(drawAsPicture(element), size);\n};\n\nexport const drawAsImageFromPicture = (picture: SkPicture, size: SkSize) => {\n \"worklet\";\n const surface = Skia.Surface.MakeOffscreen(size.width, size.height)!;\n const canvas = surface.getCanvas();\n canvas.drawPicture(picture);\n surface.flush();\n const image = surface.makeImageSnapshot();\n // If we are not on the main thread or if we are on Web, we need to make the image non-texture.\n if (!isOnMainThread() || Platform.OS === \"web\") {\n return image.makeNonTextureImage();\n } else {\n return image;\n }\n};\n"],"mappings":"AAGA,SAASA,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,SAAS;;EACT,OACG,OAAOC,QAAQ,KAAK,WAAW,IAAIA,QAAQ,KAAK,IAAI,IACrDH,QAAQ,CAACI,EAAE,KAAK,KAAK;AAEzB,CAAC;AAED,OAAO,MAAMC,aAAa,
|
1
|
+
{"version":3,"names":["Skia","Platform","SkiaSGRoot","isOnMainThread","_WORKLET","OS","drawAsPicture","element","bounds","recorder","PictureRecorder","canvas","beginRecording","root","render","drawOnCanvas","picture","finishRecordingAsPicture","unmount","drawAsImage","size","drawAsImageFromPicture","surface","Surface","MakeOffscreen","width","height","getCanvas","drawPicture","flush","image","makeImageSnapshot","makeNonTextureImage"],"sources":["Offscreen.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nimport type { SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport { Skia } from \"../skia\";\nimport { Platform } from \"../Platform\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\n\n// We call it main thread because on web main is JS thread\nexport const isOnMainThread = () => {\n \"worklet\";\n return (\n (typeof _WORKLET !== \"undefined\" && _WORKLET === true) ||\n Platform.OS === \"web\"\n );\n};\n\nexport const drawAsPicture = async (element: ReactElement, bounds?: SkRect) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(bounds);\n const root = new SkiaSGRoot(Skia);\n await root.render(element);\n root.drawOnCanvas(canvas);\n const picture = recorder.finishRecordingAsPicture();\n root.unmount();\n return picture;\n};\n\nexport const drawAsImage = async (element: ReactElement, size: SkSize) => {\n return drawAsImageFromPicture(await drawAsPicture(element), size);\n};\n\nexport const drawAsImageFromPicture = (picture: SkPicture, size: SkSize) => {\n \"worklet\";\n const surface = Skia.Surface.MakeOffscreen(size.width, size.height)!;\n const canvas = surface.getCanvas();\n canvas.drawPicture(picture);\n surface.flush();\n const image = surface.makeImageSnapshot();\n // If we are not on the main thread or if we are on Web, we need to make the image non-texture.\n if (!isOnMainThread() || Platform.OS === \"web\") {\n return image.makeNonTextureImage();\n } else {\n return image;\n }\n};\n"],"mappings":"AAGA,SAASA,IAAI,QAAQ,SAAS;AAC9B,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAClC,SAAS;;EACT,OACG,OAAOC,QAAQ,KAAK,WAAW,IAAIA,QAAQ,KAAK,IAAI,IACrDH,QAAQ,CAACI,EAAE,KAAK,KAAK;AAEzB,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,MAAAA,CAAOC,OAAqB,EAAEC,MAAe,KAAK;EAC7E,MAAMC,QAAQ,GAAGT,IAAI,CAACU,eAAe,CAAC,CAAC;EACvC,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAc,CAACJ,MAAM,CAAC;EAC9C,MAAMK,IAAI,GAAG,IAAIX,UAAU,CAACF,IAAI,CAAC;EACjC,MAAMa,IAAI,CAACC,MAAM,CAACP,OAAO,CAAC;EAC1BM,IAAI,CAACE,YAAY,CAACJ,MAAM,CAAC;EACzB,MAAMK,OAAO,GAAGP,QAAQ,CAACQ,wBAAwB,CAAC,CAAC;EACnDJ,IAAI,CAACK,OAAO,CAAC,CAAC;EACd,OAAOF,OAAO;AAChB,CAAC;AAED,OAAO,MAAMG,WAAW,GAAG,MAAAA,CAAOZ,OAAqB,EAAEa,IAAY,KAAK;EACxE,OAAOC,sBAAsB,CAAC,MAAMf,aAAa,CAACC,OAAO,CAAC,EAAEa,IAAI,CAAC;AACnE,CAAC;AAED,OAAO,MAAMC,sBAAsB,GAAGA,CAACL,OAAkB,EAAEI,IAAY,KAAK;EAC1E,SAAS;;EACT,MAAME,OAAO,GAAGtB,IAAI,CAACuB,OAAO,CAACC,aAAa,CAACJ,IAAI,CAACK,KAAK,EAAEL,IAAI,CAACM,MAAM,CAAE;EACpE,MAAMf,MAAM,GAAGW,OAAO,CAACK,SAAS,CAAC,CAAC;EAClChB,MAAM,CAACiB,WAAW,CAACZ,OAAO,CAAC;EAC3BM,OAAO,CAACO,KAAK,CAAC,CAAC;EACf,MAAMC,KAAK,GAAGR,OAAO,CAACS,iBAAiB,CAAC,CAAC;EACzC;EACA,IAAI,CAAC5B,cAAc,CAAC,CAAC,IAAIF,QAAQ,CAACI,EAAE,KAAK,KAAK,EAAE;IAC9C,OAAOyB,KAAK,CAACE,mBAAmB,CAAC,CAAC;EACpC,CAAC,MAAM;IACL,OAAOF,KAAK;EACd;AACF,CAAC","ignoreList":[]}
|
@@ -43,13 +43,13 @@ export declare const center: {
|
|
43
43
|
x: number;
|
44
44
|
y: number;
|
45
45
|
};
|
46
|
-
export declare const drawOnNode: (element: ReactNode) => SkiaExports.SkSurface
|
47
|
-
export declare const mountCanvas: (element: ReactNode) => {
|
46
|
+
export declare const drawOnNode: (element: ReactNode) => Promise<SkiaExports.SkSurface>;
|
47
|
+
export declare const mountCanvas: (element: ReactNode) => Promise<{
|
48
48
|
surface: SkiaExports.SkSurface;
|
49
49
|
root: SkiaSGRoot;
|
50
|
-
draw: () => void
|
51
|
-
}
|
52
|
-
export declare const serialize: (element: ReactNode) => string
|
50
|
+
draw: () => Promise<void>;
|
51
|
+
}>;
|
52
|
+
export declare const serialize: (element: ReactNode) => Promise<string>;
|
53
53
|
export type EvalContext = Record<string, any>;
|
54
54
|
interface TestingSurface {
|
55
55
|
eval<Ctx extends EvalContext = EvalContext, R = any>(fn: (Skia: Skia, ctx: Ctx) => R, ctx?: Ctx): Promise<R>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Skia","vec","x","y","Point","point","neg","a","add","b","sub","dist","Math","hypot"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,GAAG,GAAGA,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAU,KAAK;EACxC,SAAS;;EACT,OAAOH,IAAI,CAACI,KAAK,CAACF,CAAC,EAAEC,CAAC,
|
1
|
+
{"version":3,"names":["Skia","vec","x","y","Point","point","neg","a","add","b","sub","dist","Math","hypot"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,SAAS;AAG9B,OAAO,MAAMC,GAAG,GAAGA,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAU,KAAK;EACxC,SAAS;;EACT,OAAOH,IAAI,CAACI,KAAK,CAACF,CAAC,EAAEC,CAAC,IAAID,CAAC,CAAC;AAC9B,CAAC;AACD,OAAO,MAAMG,KAAK,GAAGJ,GAAG;AACxB,OAAO,MAAMK,GAAG,GAAIC,CAAS,IAAK;EAChC,SAAS;;EACT,OAAON,GAAG,CAAC,CAACM,CAAC,CAACL,CAAC,EAAE,CAACK,CAAC,CAACJ,CAAC,CAAC;AACxB,CAAC;AACD,OAAO,MAAMK,GAAG,GAAGA,CAACD,CAAS,EAAEE,CAAS,KAAK;EAC3C,SAAS;;EACT,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAC,GAAGO,CAAC,CAACP,CAAC,EAAEK,CAAC,CAACJ,CAAC,GAAGM,CAAC,CAACN,CAAC,CAAC;AAClC,CAAC;AACD,OAAO,MAAMO,GAAG,GAAGA,CAACH,CAAS,EAAEE,CAAS,KAAK;EAC3C,SAAS;;EACT,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAC,GAAGO,CAAC,CAACP,CAAC,EAAEK,CAAC,CAACJ,CAAC,GAAGM,CAAC,CAACN,CAAC,CAAC;AAClC,CAAC;AACD,OAAO,MAAMQ,IAAI,GAAGA,CAACJ,CAAS,EAAEE,CAAS,KAAK;EAC5C,SAAS;;EACT,OAAOG,IAAI,CAACC,KAAK,CAACN,CAAC,CAACL,CAAC,GAAGO,CAAC,CAACP,CAAC,EAAEK,CAAC,CAACJ,CAAC,GAAGM,CAAC,CAACN,CAAC,CAAC;AACzC,CAAC","ignoreList":[]}
|
@@ -1,13 +1,10 @@
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
1
|
import { CanvasKitWebGLBuffer } from "../types";
|
5
2
|
export class CanvasKitWebGLBufferImpl extends CanvasKitWebGLBuffer {
|
3
|
+
image = null;
|
6
4
|
constructor(surface, source) {
|
7
5
|
super();
|
8
6
|
this.surface = surface;
|
9
7
|
this.source = source;
|
10
|
-
_defineProperty(this, "image", null);
|
11
8
|
}
|
12
9
|
toImage() {
|
13
10
|
if (this.image === null) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["CanvasKitWebGLBuffer","CanvasKitWebGLBufferImpl","constructor","surface","source","
|
1
|
+
{"version":3,"names":["CanvasKitWebGLBuffer","CanvasKitWebGLBufferImpl","image","constructor","surface","source","toImage","makeImageFromTextureSource","Error","updateTextureFromSource"],"sources":["CanvasKitWebGLBufferImpl.ts"],"sourcesContent":["import type { Surface, TextureSource, Image } from \"canvaskit-wasm\";\n\nimport { CanvasKitWebGLBuffer } from \"../types\";\n\nexport class CanvasKitWebGLBufferImpl extends CanvasKitWebGLBuffer {\n public image: Image | null = null;\n\n constructor(public surface: Surface, private source: TextureSource) {\n super();\n }\n\n toImage() {\n if (this.image === null) {\n this.image = this.surface.makeImageFromTextureSource(this.source);\n }\n if (this.image === null) {\n throw new Error(\"Failed to create image from texture source\");\n }\n this.surface.updateTextureFromSource(this.image, this.source);\n return this.image;\n }\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAU;AAE/C,OAAO,MAAMC,wBAAwB,SAASD,oBAAoB,CAAC;EAC1DE,KAAK,GAAiB,IAAI;EAEjCC,WAAWA,CAAQC,OAAgB,EAAUC,MAAqB,EAAE;IAClE,KAAK,CAAC,CAAC;IAAC,KADSD,OAAgB,GAAhBA,OAAgB;IAAA,KAAUC,MAAqB,GAArBA,MAAqB;EAElE;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,IAAI,CAACJ,KAAK,KAAK,IAAI,EAAE;MACvB,IAAI,CAACA,KAAK,GAAG,IAAI,CAACE,OAAO,CAACG,0BAA0B,CAAC,IAAI,CAACF,MAAM,CAAC;IACnE;IACA,IAAI,IAAI,CAACH,KAAK,KAAK,IAAI,EAAE;MACvB,MAAM,IAAIM,KAAK,CAAC,4CAA4C,CAAC;IAC/D;IACA,IAAI,CAACJ,OAAO,CAACK,uBAAuB,CAAC,IAAI,CAACP,KAAK,EAAE,IAAI,CAACG,MAAM,CAAC;IAC7D,OAAO,IAAI,CAACH,KAAK;EACnB;AACF","ignoreList":[]}
|
@@ -1,22 +1,16 @@
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
1
|
export class NotImplementedOnRNWeb extends Error {
|
5
2
|
constructor(msg) {
|
6
|
-
super(msg
|
3
|
+
super(msg ?? "Not implemented on React Native Web");
|
7
4
|
}
|
8
5
|
}
|
9
6
|
export class Host {
|
10
7
|
constructor(CanvasKit) {
|
11
|
-
_defineProperty(this, "CanvasKit", void 0);
|
12
8
|
this.CanvasKit = CanvasKit;
|
13
9
|
}
|
14
10
|
}
|
15
11
|
export class BaseHostObject extends Host {
|
16
12
|
constructor(CanvasKit, ref, typename) {
|
17
13
|
super(CanvasKit);
|
18
|
-
_defineProperty(this, "__typename__", void 0);
|
19
|
-
_defineProperty(this, "ref", void 0);
|
20
14
|
this.ref = ref;
|
21
15
|
this.__typename__ = typename;
|
22
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","
|
1
|
+
{"version":3,"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","getEnum","e","v","Object","values","find","optEnum","undefined"],"sources":["Host.ts"],"sourcesContent":["import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n\n abstract dispose(): void;\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const getEnum = (e: EmbindEnum, v: number): EmbindEnumEntity =>\n Object.values(e).find(({ value }) => value === v);\n\nexport const optEnum = (\n e: EmbindEnum,\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : getEnum(e, value);\n"],"mappings":"AAIA,OAAO,MAAMA,qBAAqB,SAASC,KAAK,CAAC;EAC/CC,WAAWA,CAACC,GAAY,EAAE;IACxB,KAAK,CAACA,GAAG,IAAI,qCAAqC,CAAC;EACrD;AACF;AAEA,OAAO,MAAeC,IAAI,CAAC;EAGzBF,WAAWA,CAACG,SAAoB,EAAE;IAChC,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC5B;AACF;AAEA,OAAO,MAAeC,cAAc,SAC1BF,IAAI,CAEd;EAIEF,WAAWA,CAACG,SAAoB,EAAEE,GAAM,EAAEC,QAAW,EAAE;IACrD,KAAK,CAACH,SAAS,CAAC;IAChB,IAAI,CAACE,GAAG,GAAGA,GAAG;IACd,IAAI,CAACE,YAAY,GAAGD,QAAQ;EAC9B;AAGF;AAEA,OAAO,MAAeE,UAAU,SAA8BJ,cAAc,CAG1E;EACA,OAAOK,SAASA,CAAIC,KAA4B,EAAE;IAChD,OAAQA,KAAK,CAA2BL,GAAG;EAC7C;AACF;AAEA,OAAO,MAAMM,OAAO,GAAGA,CAACC,CAAa,EAAEC,CAAS,KAC9CC,MAAM,CAACC,MAAM,CAACH,CAAC,CAAC,CAACI,IAAI,CAAC,CAAC;EAAEN;AAAM,CAAC,KAAKA,KAAK,KAAKG,CAAC,CAAC;AAEnD,OAAO,MAAMI,OAAO,GAAGA,CACrBL,CAAa,EACbF,KAAyB,KAEzBA,KAAK,KAAKQ,SAAS,GAAGA,SAAS,GAAGP,OAAO,CAACC,CAAC,EAAEF,KAAK,CAAC","ignoreList":[]}
|
@@ -1,14 +1,8 @@
|
|
1
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
2
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
3
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
1
|
import { HostObject } from "./Host";
|
5
2
|
import { JsiSkImage } from "./JsiSkImage";
|
6
3
|
export class JsiSkAnimatedImage extends HostObject {
|
7
4
|
constructor(CanvasKit, ref) {
|
8
5
|
super(CanvasKit, ref, "AnimatedImage");
|
9
|
-
_defineProperty(this, "dispose", () => {
|
10
|
-
this.ref.delete();
|
11
|
-
});
|
12
6
|
}
|
13
7
|
decodeNextFrame() {
|
14
8
|
return this.ref.decodeNextFrame();
|
@@ -26,5 +20,8 @@ export class JsiSkAnimatedImage extends HostObject {
|
|
26
20
|
}
|
27
21
|
return new JsiSkImage(this.CanvasKit, image);
|
28
22
|
}
|
23
|
+
dispose = () => {
|
24
|
+
this.ref.delete();
|
25
|
+
};
|
29
26
|
}
|
30
27
|
//# sourceMappingURL=JsiSkAnimatedImage.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["HostObject","JsiSkImage","JsiSkAnimatedImage","constructor","CanvasKit","ref","
|
1
|
+
{"version":3,"names":["HostObject","JsiSkImage","JsiSkAnimatedImage","constructor","CanvasKit","ref","decodeNextFrame","currentFrameDuration","getFrameCount","getCurrentFrame","image","makeImageAtCurrentFrame","dispose","delete"],"sources":["JsiSkAnimatedImage.ts"],"sourcesContent":["import type { AnimatedImage, CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkAnimatedImage } from \"../types/AnimatedImage\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\n\nexport class JsiSkAnimatedImage\n extends HostObject<AnimatedImage, \"AnimatedImage\">\n implements SkAnimatedImage\n{\n constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {\n super(CanvasKit, ref, \"AnimatedImage\");\n }\n\n decodeNextFrame() {\n return this.ref.decodeNextFrame();\n }\n\n currentFrameDuration() {\n return this.ref.currentFrameDuration();\n }\n\n getFrameCount() {\n return this.ref.getFrameCount();\n }\n\n getCurrentFrame() {\n const image = this.ref.makeImageAtCurrentFrame();\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n}\n"],"mappings":"AAIA,SAASA,UAAU,QAAQ,QAAQ;AACnC,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,kBAAkB,SACrBF,UAAU,CAEpB;EACEG,WAAWA,CAACC,SAAoB,EAAEC,GAAkB,EAAE;IACpD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,eAAe,CAAC;EACxC;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACD,GAAG,CAACC,eAAe,CAAC,CAAC;EACnC;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,GAAG,CAACE,oBAAoB,CAAC,CAAC;EACxC;EAEAC,aAAaA,CAAA,EAAG;IACd,OAAO,IAAI,CAACH,GAAG,CAACG,aAAa,CAAC,CAAC;EACjC;EAEAC,eAAeA,CAAA,EAAG;IAChB,MAAMC,KAAK,GAAG,IAAI,CAACL,GAAG,CAACM,uBAAuB,CAAC,CAAC;IAChD,IAAID,KAAK,KAAK,IAAI,EAAE;MAClB,OAAO,IAAI;IACb;IACA,OAAO,IAAIT,UAAU,CAAC,IAAI,CAACG,SAAS,EAAEM,KAAK,CAAC;EAC9C;EAEAE,OAAO,GAAGA,CAAA,KAAM;IACd,IAAI,CAACP,GAAG,CAACQ,MAAM,CAAC,CAAC;EACnB,CAAC;AACH","ignoreList":[]}
|