@shopify/react-native-skia 2.0.0-next.1 → 2.0.0-next.2
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/build.gradle +11 -1
- package/android/cpp/jni/JniPlatformContext.cpp +1 -0
- package/{ios/RNSkia-iOS → apple}/MetalContext.h +0 -5
- package/{ios/RNSkia-iOS → apple}/MetalWindowContext.mm +4 -0
- package/{ios/RNSkia-iOS/RNSkiOSPlatformContext.h → apple/RNSkApplePlatformContext.h} +7 -3
- package/{ios/RNSkia-iOS/RNSkiOSPlatformContext.mm → apple/RNSkApplePlatformContext.mm} +19 -19
- package/{ios/RNSkia-iOS/RNSkiOSVideo.h → apple/RNSkAppleVideo.h} +3 -3
- package/{ios/RNSkia-iOS/RNSkiOSVideo.mm → apple/RNSkAppleVideo.mm} +14 -14
- package/{ios/RNSkia-iOS/RNSkiOSView.h → apple/RNSkAppleView.h} +4 -4
- package/{ios/RNSkia-iOS/RNSkiOSView.mm → apple/RNSkAppleView.mm} +4 -4
- package/{ios/RNSkia-iOS → apple}/RNSkMetalCanvasProvider.mm +6 -1
- package/{ios/RNSkia-iOS → apple}/SkiaManager.mm +2 -2
- package/{ios/RNSkia-iOS → apple}/SkiaPictureView.mm +2 -2
- package/{ios/RNSkia-iOS → apple}/SkiaPictureViewManager.mm +6 -2
- package/{ios/RNSkia-iOS → apple}/SkiaUIView.h +12 -4
- package/{ios/RNSkia-iOS → apple}/SkiaUIView.mm +11 -7
- package/{ios/RNSkia-iOS → apple}/ViewScreenshotService.h +4 -0
- package/{ios/RNSkia-iOS → apple}/ViewScreenshotService.mm +4 -0
- package/cpp/api/JsiSkContourMeasure.h +1 -1
- package/cpp/api/JsiSkHostObjects.h +21 -10
- package/cpp/api/JsiSkParagraph.h +17 -27
- package/cpp/api/JsiSkPathEffect.h +1 -1
- package/cpp/api/JsiSkPictureFactory.h +1 -1
- package/cpp/api/JsiSkShaderFactory.h +43 -8
- package/cpp/api/JsiSkVertices.h +14 -3
- package/cpp/api/recorder/Drawings.h +4 -3
- package/cpp/rnskia/DawnContext.h +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/__tests__/setup.d.ts +18 -0
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +4 -3
- package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/commonjs/headless/index.d.ts +1 -0
- package/lib/commonjs/headless/index.js +12 -0
- package/lib/commonjs/headless/index.js.map +1 -1
- package/lib/commonjs/mock/index.js +1 -2
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.js +3 -1
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/skia/web/Host.d.ts +4 -6
- package/lib/commonjs/skia/web/Host.js +23 -10
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +15 -15
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +3 -3
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFontMgr.js +1 -1
- package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +9 -9
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +4 -4
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +3 -3
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +2 -2
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +4 -3
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiVideo.js +2 -1
- package/lib/commonjs/skia/web/JsiVideo.js.map +1 -1
- package/lib/commonjs/sksg/HostConfig.js +3 -1
- package/lib/commonjs/sksg/HostConfig.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Core.d.ts +1 -5
- package/lib/commonjs/sksg/Recorder/Core.js +12 -4
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +4 -5
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Box.js +2 -4
- package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +2 -0
- package/lib/commonjs/specs/NativeSkiaModule.web.js +10 -1
- package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/module/__tests__/setup.d.ts +18 -0
- package/lib/module/external/reanimated/useAnimatedImageValue.js +4 -3
- package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
- package/lib/module/headless/index.d.ts +1 -0
- package/lib/module/headless/index.js +1 -0
- package/lib/module/headless/index.js.map +1 -1
- package/lib/module/mock/index.js +1 -2
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/renderer/Canvas.js +3 -1
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/skia/web/Host.d.ts +4 -6
- package/lib/module/skia/web/Host.js +21 -8
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +15 -15
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +4 -4
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkFontMgr.js +2 -2
- package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +6 -6
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +4 -4
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +10 -10
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js +1 -1
- package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +3 -3
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +4 -4
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +4 -4
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +3 -3
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +1 -1
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +5 -5
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +2 -2
- package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
- package/lib/module/skia/web/JsiSkVerticesFactory.js +1 -1
- package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +4 -3
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/skia/web/JsiVideo.js +2 -1
- package/lib/module/skia/web/JsiVideo.js.map +1 -1
- package/lib/module/sksg/HostConfig.js +3 -1
- package/lib/module/sksg/HostConfig.js.map +1 -1
- package/lib/module/sksg/Recorder/Core.d.ts +1 -5
- package/lib/module/sksg/Recorder/Core.js +10 -2
- package/lib/module/sksg/Recorder/Core.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +5 -6
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Box.js +3 -5
- package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
- package/lib/module/specs/NativeSkiaModule.web.d.ts +2 -0
- package/lib/module/specs/NativeSkiaModule.web.js +10 -1
- package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
- package/lib/typescript/lib/commonjs/mock/index.d.ts +2 -2
- package/lib/typescript/lib/commonjs/skia/index.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/Host.d.ts +3 -5
- package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkFontMgr.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
- package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +3 -3
- package/lib/typescript/lib/commonjs/skia/web/JsiVideo.d.ts +1 -1
- package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +1 -1
- package/lib/typescript/lib/module/headless/index.d.ts +1 -0
- package/lib/typescript/lib/module/mock/index.d.ts +5 -5
- package/lib/typescript/lib/module/skia/Skia.d.ts +1 -1
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +3 -3
- package/lib/typescript/lib/module/skia/web/Host.d.ts +3 -5
- package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkFontMgr.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
- package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +3 -3
- package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +1 -1
- package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +1 -1
- package/lib/typescript/src/__tests__/setup.d.ts +18 -0
- package/lib/typescript/src/headless/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/Host.d.ts +4 -6
- package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +1 -1
- package/lib/typescript/src/sksg/Recorder/Core.d.ts +1 -5
- package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +2 -0
- package/package.json +6 -5
- package/react-native-skia.podspec +3 -3
- package/src/__tests__/setup.ts +67 -1
- package/src/external/reanimated/useAnimatedImageValue.ts +4 -3
- package/src/headless/index.ts +2 -1
- package/src/mock/index.ts +1 -2
- package/src/renderer/Canvas.tsx +2 -1
- package/src/renderer/__tests__/e2e/Matrix4.spec.tsx +1 -2
- package/src/renderer/__tests__/e2e/Paths.spec.tsx +13 -11
- package/src/skia/__tests__/Enums.spec.ts +24 -2
- package/src/skia/__tests__/Path.spec.ts +2 -2
- package/src/skia/web/Host.ts +29 -11
- package/src/skia/web/JsiSkCanvas.ts +17 -17
- package/src/skia/web/JsiSkColorFilterFactory.ts +1 -1
- package/src/skia/web/JsiSkFont.ts +5 -5
- package/src/skia/web/JsiSkFontMgr.ts +3 -3
- package/src/skia/web/JsiSkImage.ts +14 -10
- package/src/skia/web/JsiSkImageFactory.ts +5 -5
- package/src/skia/web/JsiSkImageFilterFactory.ts +12 -22
- package/src/skia/web/JsiSkMaskFilterFactory.ts +1 -1
- package/src/skia/web/JsiSkPaint.ts +3 -3
- package/src/skia/web/JsiSkPath.ts +4 -4
- package/src/skia/web/JsiSkPathEffectFactory.ts +6 -6
- package/src/skia/web/JsiSkPathFactory.ts +4 -9
- package/src/skia/web/JsiSkPicture.ts +3 -3
- package/src/skia/web/JsiSkShaderFactory.ts +5 -5
- package/src/skia/web/JsiSkTypefaceFontProvider.ts +3 -3
- package/src/skia/web/JsiSkVerticesFactory.ts +1 -1
- package/src/skia/web/JsiSkia.ts +7 -4
- package/src/skia/web/JsiVideo.ts +2 -1
- package/src/sksg/HostConfig.ts +1 -1
- package/src/sksg/Recorder/Core.ts +5 -7
- package/src/sksg/Recorder/Player.ts +5 -6
- package/src/sksg/Recorder/commands/Box.ts +3 -5
- package/src/specs/NativeSkiaModule.web.ts +12 -2
- package/ios/Rnskia.xcodeproj/project.pbxproj +0 -281
- package/ios/Rnskia.xcworkspace/contents.xcworkspacedata +0 -7
- package/lib/commonjs/skia/types/Image/ColorType.web.d.ts +0 -19
- package/lib/commonjs/skia/types/Image/ColorType.web.js +0 -43
- package/lib/commonjs/skia/types/Image/ColorType.web.js.map +0 -1
- package/lib/module/skia/types/Image/ColorType.web.d.ts +0 -19
- package/lib/module/skia/types/Image/ColorType.web.js +0 -37
- package/lib/module/skia/types/Image/ColorType.web.js.map +0 -1
- package/lib/typescript/lib/commonjs/skia/types/Image/ColorType.web.d.ts +0 -2
- package/lib/typescript/lib/module/skia/types/Image/ColorType.web.d.ts +0 -1
- package/lib/typescript/src/skia/types/Image/ColorType.web.d.ts +0 -19
- package/src/skia/types/Image/ColorType.web.ts +0 -19
- /package/{ios/RNSkia-iOS → apple}/MetalContext.mm +0 -0
- /package/{ios/RNSkia-iOS → apple}/MetalWindowContext.h +0 -0
- /package/{ios/RNSkia-iOS → apple}/RNSkMetalCanvasProvider.h +0 -0
- /package/{ios → apple}/RNSkiaModule.h +0 -0
- /package/{ios → apple}/RNSkiaModule.mm +0 -0
- /package/{ios/RNSkia-iOS → apple}/SkiaCVPixelBufferUtils.h +0 -0
- /package/{ios/RNSkia-iOS → apple}/SkiaCVPixelBufferUtils.mm +0 -0
- /package/{ios/RNSkia-iOS → apple}/SkiaManager.h +0 -0
- /package/{ios/RNSkia-iOS → apple}/SkiaPictureView.h +0 -0
- /package/{ios/RNSkia-iOS → apple}/SkiaPictureViewManager.h +0 -0
package/package.json
CHANGED
@@ -5,10 +5,10 @@
|
|
5
5
|
"provenance": true
|
6
6
|
},
|
7
7
|
"bin": {
|
8
|
-
"setup-skia-web": "
|
8
|
+
"setup-skia-web": "scripts/setup-canvaskit.js"
|
9
9
|
},
|
10
10
|
"title": "React Native Skia",
|
11
|
-
"version": "2.0.0-next.
|
11
|
+
"version": "2.0.0-next.2",
|
12
12
|
"description": "High-performance React Native Graphics using Skia",
|
13
13
|
"main": "lib/module/index.js",
|
14
14
|
"react-native": "src/index.ts",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"jestSetup.mjs",
|
30
30
|
"jestEnv.mjs",
|
31
31
|
"cpp/**/*.{h,cpp}",
|
32
|
-
"
|
32
|
+
"apple/**",
|
33
33
|
"libs/apple/*.xcframework/**",
|
34
34
|
"react-native-skia.podspec",
|
35
35
|
"scripts/setup-canvaskit.js",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"build-skia": "ts-node ./scripts/build-skia.ts",
|
47
47
|
"copy-skia-headers": "ts-node ./scripts/copy-skia-headers.ts",
|
48
48
|
"clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
|
49
|
-
"clang-format-ios": "find
|
49
|
+
"clang-format-ios": "find apple/ -iname '*.h' -o -iname '*.mm' -o -iname '*.cpp' | xargs clang-format -i",
|
50
50
|
"clang-format-android": "find android/cpp/ -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' | xargs clang-format -i",
|
51
51
|
"clang-format-common": "find cpp/ \\( -path 'cpp//skia' -prune \\) -o \\( -iname '*.h' -o -iname '*.m' -o -iname '*.cpp' \\) -print | xargs clang-format -i",
|
52
52
|
"workflow-copy-libs": "yarn ts-node ./scripts/workflow-copy-libs.ts",
|
@@ -91,6 +91,7 @@
|
|
91
91
|
"devDependencies": {
|
92
92
|
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
|
93
93
|
"@semantic-release/commit-analyzer": "^13.0.0",
|
94
|
+
"@semantic-release/exec": "^7.0.3",
|
94
95
|
"@semantic-release/github": "^10.3.3",
|
95
96
|
"@semantic-release/release-notes-generator": "^14.0.1",
|
96
97
|
"@types/jest": "29.5.6",
|
@@ -121,7 +122,7 @@
|
|
121
122
|
"ws": "8.18.0"
|
122
123
|
},
|
123
124
|
"dependencies": {
|
124
|
-
"canvaskit-wasm": "0.
|
125
|
+
"canvaskit-wasm": "0.40.0",
|
125
126
|
"react-reconciler": "0.31.0"
|
126
127
|
},
|
127
128
|
"eslintIgnore": [
|
@@ -41,7 +41,7 @@ Pod::Spec.new do |s|
|
|
41
41
|
"Christian Falch" => "christian.falch@gmail.com",
|
42
42
|
"William Candillon" => "wcandillon@gmail.com"
|
43
43
|
}
|
44
|
-
s.platforms = { :ios => "13.0", :tvos => "13.0" }
|
44
|
+
s.platforms = { :ios => "13.0", :tvos => "13.0", :osx => "11" }
|
45
45
|
s.source = { :git => "https://github.com/shopify/react-native-skia/react-native-skia.git", :tag => "#{s.version}" }
|
46
46
|
|
47
47
|
s.requires_arc = true
|
@@ -54,13 +54,13 @@ Pod::Spec.new do |s|
|
|
54
54
|
|
55
55
|
s.frameworks = ['MetalKit', 'AVFoundation', 'AVKit', 'CoreMedia']
|
56
56
|
|
57
|
-
s.vendored_frameworks = use_graphite ?
|
57
|
+
s.vendored_frameworks = use_graphite ?
|
58
58
|
base_frameworks + graphite_frameworks :
|
59
59
|
base_frameworks
|
60
60
|
|
61
61
|
# All iOS cpp/h files
|
62
62
|
s.source_files = [
|
63
|
-
"
|
63
|
+
"apple/**/*.{h,c,cc,cpp,m,mm,swift}",
|
64
64
|
"cpp/**/*.{h,cpp}"
|
65
65
|
]
|
66
66
|
|
package/src/__tests__/setup.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
/* eslint-disable max-len */
|
1
2
|
import path from "path";
|
2
3
|
import fs from "fs";
|
3
4
|
|
@@ -97,8 +98,69 @@ export const checkImage = (
|
|
97
98
|
return 0;
|
98
99
|
};
|
99
100
|
|
101
|
+
declare global {
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
103
|
+
namespace jest {
|
104
|
+
interface Matchers<R> {
|
105
|
+
/**
|
106
|
+
* Checks if values are approximately equal within the given tolerance.
|
107
|
+
* Works with:
|
108
|
+
* - Single numbers
|
109
|
+
* - Arrays of numbers
|
110
|
+
* - Float32Arrays
|
111
|
+
* - SVG path strings (compares numeric values with tolerance)
|
112
|
+
*
|
113
|
+
* @param expected - The expected value to compare against
|
114
|
+
* @param tolerance - The maximum allowed difference between elements (default: 0.01)
|
115
|
+
*/
|
116
|
+
toBeApproximatelyEqual(
|
117
|
+
expected: number | number[] | Float32Array | string,
|
118
|
+
tolerance?: number
|
119
|
+
): R;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
100
124
|
expect.extend({
|
101
|
-
toBeApproximatelyEqual(_received, _argument, tolerance = 0.
|
125
|
+
toBeApproximatelyEqual(_received, _argument, tolerance = 0.01) {
|
126
|
+
// Handle SVG path strings
|
127
|
+
if (typeof _received === "string" && typeof _argument === "string") {
|
128
|
+
// Parse SVG path strings to extract numerical values
|
129
|
+
const parsePathString = (pathStr: string): number[] => {
|
130
|
+
// Extract all numeric values (including decimals) from the path string
|
131
|
+
const numbers = pathStr.match(/-?\d+(?:\.\d+)?/g) || [];
|
132
|
+
return numbers.map(Number);
|
133
|
+
};
|
134
|
+
|
135
|
+
const receivedPoints = parsePathString(_received);
|
136
|
+
const argumentPoints = parsePathString(_argument);
|
137
|
+
|
138
|
+
if (receivedPoints.length !== argumentPoints.length) {
|
139
|
+
return {
|
140
|
+
pass: false,
|
141
|
+
message: () =>
|
142
|
+
`SVG paths have different number of points: ${receivedPoints.length} vs ${argumentPoints.length}`,
|
143
|
+
};
|
144
|
+
}
|
145
|
+
|
146
|
+
for (let i = 0; i < receivedPoints.length; i++) {
|
147
|
+
if (
|
148
|
+
isNaN(receivedPoints[i]) ||
|
149
|
+
isNaN(argumentPoints[i]) ||
|
150
|
+
Math.abs(receivedPoints[i] - argumentPoints[i]) > tolerance
|
151
|
+
) {
|
152
|
+
return {
|
153
|
+
pass: false,
|
154
|
+
message: () =>
|
155
|
+
`SVG path points differ more than ${tolerance} at position ${i}: ${receivedPoints[i]} vs ${argumentPoints[i]}`,
|
156
|
+
};
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
return { pass: true, message: () => "SVG paths are approximately equal" };
|
161
|
+
}
|
162
|
+
|
163
|
+
// Original logic for numbers and arrays
|
102
164
|
const received =
|
103
165
|
Array.isArray(_received) || _received instanceof Float32Array
|
104
166
|
? _received
|
@@ -110,6 +172,7 @@ expect.extend({
|
|
110
172
|
if (received.length !== argument.length) {
|
111
173
|
return { pass: false, message: () => "Arrays have different lengths" };
|
112
174
|
}
|
175
|
+
|
113
176
|
for (let i = 0; i < received.length; i++) {
|
114
177
|
if (
|
115
178
|
isNaN(argument[i]) ||
|
@@ -127,3 +190,6 @@ ${diffString}`,
|
|
127
190
|
return { pass: true, message: () => "Arrays are approximately equal" };
|
128
191
|
},
|
129
192
|
});
|
193
|
+
|
194
|
+
// Export empty object to make this a module
|
195
|
+
export {};
|
@@ -40,10 +40,11 @@ export const useAnimatedImageValue = (
|
|
40
40
|
|
41
41
|
// Update the current frame
|
42
42
|
animatedImage.decodeNextFrame();
|
43
|
-
|
44
|
-
currentFrame.value.dispose();
|
45
|
-
}
|
43
|
+
const oldFrame = currentFrame.value;
|
46
44
|
currentFrame.value = animatedImage.getCurrentFrame();
|
45
|
+
if (oldFrame) {
|
46
|
+
oldFrame.dispose();
|
47
|
+
}
|
47
48
|
|
48
49
|
// Update the last timestamp
|
49
50
|
lastTimestamp.value = timestamp;
|
package/src/headless/index.ts
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
|
4
4
|
import type { ReactNode } from "react";
|
5
5
|
|
6
|
-
import { JsiSkApi } from "../skia/web";
|
7
6
|
import type { SkSurface } from "../skia";
|
7
|
+
import { JsiSkApi } from "../skia/web";
|
8
8
|
import { SkiaSGRoot } from "../sksg/Reconciler";
|
9
9
|
|
10
10
|
export * from "../renderer/components";
|
11
|
+
export * from "../skia/types";
|
11
12
|
|
12
13
|
let Skia: ReturnType<typeof JsiSkApi>;
|
13
14
|
|
package/src/mock/index.ts
CHANGED
@@ -21,8 +21,7 @@ export const Mock = (CanvasKit: CanvasKit) => {
|
|
21
21
|
...require("../animation"),
|
22
22
|
...require("../dom/types"),
|
23
23
|
...require("../dom/nodes"),
|
24
|
-
|
25
|
-
Canvas: Noop,
|
24
|
+
Canvas: require("react-native").View,
|
26
25
|
// Skia Animations
|
27
26
|
useValue: NoopValue,
|
28
27
|
useComputedValue: NoopValue,
|
package/src/renderer/Canvas.tsx
CHANGED
@@ -73,9 +73,10 @@ export const Canvas = ({
|
|
73
73
|
// Root
|
74
74
|
const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);
|
75
75
|
|
76
|
+
// Render effects
|
76
77
|
useLayoutEffect(() => {
|
77
78
|
root.render(children);
|
78
|
-
}, [
|
79
|
+
}, [children, root]);
|
79
80
|
|
80
81
|
useEffect(() => {
|
81
82
|
return () => {
|
@@ -217,8 +217,7 @@ describe("Matrix4", () => {
|
|
217
217
|
},
|
218
218
|
{ matrix }
|
219
219
|
);
|
220
|
-
|
221
|
-
(expect(result) as any).toBeApproximatelyEqual(
|
220
|
+
expect(result).toBeApproximatelyEqual(
|
222
221
|
toMatrix3(
|
223
222
|
processTransform3d([
|
224
223
|
{ translate: [width / 2, height / 2] },
|
@@ -110,7 +110,7 @@ describe("Paths", () => {
|
|
110
110
|
path.trim(0.0001, 1.00001, false);
|
111
111
|
return path.toSVGString();
|
112
112
|
});
|
113
|
-
expect(result).
|
113
|
+
expect(result).toBeApproximatelyEqual("M20 20.0048L20 40L40 20");
|
114
114
|
});
|
115
115
|
it("should accept [0, 1.2] as trim value", async () => {
|
116
116
|
const result = await surface.eval((Skia) => {
|
@@ -142,17 +142,19 @@ describe("Paths", () => {
|
|
142
142
|
path.interpolate(path2, 1.0001)!.toSVGString(),
|
143
143
|
path.interpolate(path2, 1.2)!.toSVGString(),
|
144
144
|
path.interpolate(path2, 2)!.toSVGString(),
|
145
|
-
];
|
145
|
+
].join(" ");
|
146
146
|
});
|
147
|
-
expect(result).
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
147
|
+
expect(result).toBeApproximatelyEqual(
|
148
|
+
[
|
149
|
+
"M-20 -20L20 0L0 60",
|
150
|
+
"M0 0L20 20L20 40",
|
151
|
+
"M0.002 0.002L20 20.002L20.002 39.998",
|
152
|
+
"M20 20L20 40L40 20",
|
153
|
+
"M20.002 20.002L20 40.002L40.002 19.998",
|
154
|
+
"M24 24L20 44L44 16",
|
155
|
+
"M40 40L20 60L60 0",
|
156
|
+
].join(" ")
|
157
|
+
);
|
156
158
|
});
|
157
159
|
it("should add a path", async () => {
|
158
160
|
const result = await surface.eval((Skia) => {
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
AlphaType,
|
5
5
|
BlurStyle,
|
6
6
|
ClipOp,
|
7
|
+
ColorType,
|
7
8
|
FillType,
|
8
9
|
FilterMode,
|
9
10
|
FontEdging,
|
@@ -26,7 +27,6 @@ import {
|
|
26
27
|
import { Path1DEffectStyle } from "../types/PathEffect";
|
27
28
|
import { BlendMode } from "../types/Paint/BlendMode";
|
28
29
|
import { mapKeys } from "../../renderer/typeddash";
|
29
|
-
import { ColorTypeCanvasKit } from "../types/Image/ColorType.web";
|
30
30
|
|
31
31
|
import { setupSkia } from "./setup";
|
32
32
|
|
@@ -71,7 +71,7 @@ describe("Enums", () => {
|
|
71
71
|
});
|
72
72
|
it("Should match Image enums values with CanvasKit", () => {
|
73
73
|
const { CanvasKit } = setupSkia();
|
74
|
-
checkEnum(
|
74
|
+
checkEnum(ColorType, CanvasKit.ColorType);
|
75
75
|
checkEnum(AlphaType, CanvasKit.AlphaType);
|
76
76
|
checkEnum(ImageFormat, CanvasKit.ImageFormat);
|
77
77
|
checkEnum(MipmapMode, CanvasKit.MipmapMode);
|
@@ -111,4 +111,26 @@ describe("Enums", () => {
|
|
111
111
|
);
|
112
112
|
checkEnum(ClipOp, CanvasKit.ClipOp);
|
113
113
|
});
|
114
|
+
it("Should match color types with CanvasKit", () => {
|
115
|
+
const { CanvasKit } = setupSkia();
|
116
|
+
//expect(CanvasKit.ColorType.Unknown.value).toBe(ColorType.Unknown);
|
117
|
+
expect(CanvasKit.ColorType.Alpha_8.value).toBe(ColorType.Alpha_8);
|
118
|
+
expect(CanvasKit.ColorType.RGB_565.value).toBe(ColorType.RGB_565);
|
119
|
+
//expect(CanvasKit.ColorType.ARGB_4444.value).toBe(ColorType.ARGB_4444);
|
120
|
+
expect(CanvasKit.ColorType.RGBA_8888.value).toBe(ColorType.RGBA_8888);
|
121
|
+
//expect(CanvasKit.ColorType.RGB_888x.value).toBe(ColorType.RGB_888x);
|
122
|
+
expect(CanvasKit.ColorType.BGRA_8888.value).toBe(ColorType.BGRA_8888);
|
123
|
+
expect(CanvasKit.ColorType.RGBA_1010102.value).toBe(ColorType.RGBA_1010102);
|
124
|
+
//expect(CanvasKit.ColorType.BGRA_1010102.value).toBe(ColorType.BGRA_1010102);
|
125
|
+
expect(CanvasKit.ColorType.RGB_101010x.value).toBe(ColorType.RGB_101010x);
|
126
|
+
//expect(CanvasKit.ColorType.BGR_101010x.value).toBe(ColorType.BGR_101010x);
|
127
|
+
//expect(CanvasKit.ColorType.BGR_101010x_XR.value).toBe(ColorType.BGR_101010x_XR);
|
128
|
+
//expect(CanvasKit.ColorType.BGRA_10101010_XR.value).toBe(ColorType.BGRA_10101010_XR);
|
129
|
+
//expect(CanvasKit.ColorType.RGBA_10x6.value).toBe(ColorType.RGBA_10x6);
|
130
|
+
expect(CanvasKit.ColorType.Gray_8.value).toBe(ColorType.Gray_8);
|
131
|
+
//expect(CanvasKit.ColorType.RGBA_F16Norm.value).toBe(ColorType.RGBA_F16Norm);
|
132
|
+
expect(CanvasKit.ColorType.RGBA_F16.value).toBe(ColorType.RGBA_F16);
|
133
|
+
//expect(CanvasKit.ColorType.RGB_F16F16F16x.value).toBe(ColorType.RGB_F16F16F16x);
|
134
|
+
expect(CanvasKit.ColorType.RGBA_F32.value).toBe(ColorType.RGBA_F32);
|
135
|
+
});
|
114
136
|
});
|
@@ -18,14 +18,14 @@ describe("Path", () => {
|
|
18
18
|
const svg2 =
|
19
19
|
"M128 191.877C104.213 216.339 80.8869 228.058 66.7826 219.915C52.6783 211.772 51.1647 185.712 60.4559 152.88C27.3773 144.511 5.56522 130.17 5.56522 113.884C5.56522 97.5975 27.3773 83.2565 60.4559 74.8871C51.1647 42.0555 52.6783 15.9952 66.7826 7.85209C80.8869 -0.291009 104.213 11.4283 128 35.8905C151.787 11.4283 175.113 -0.291018 189.217 7.85208C203.322 15.9952 204.835 42.0555 195.544 74.8871C228.623 83.2565 250.435 97.5975 250.435 113.884C250.435 130.17 228.623 144.511 195.544 152.88C204.835 185.712 203.322 211.772 189.217 219.915C175.113 228.058 151.787 216.339 128 191.877ZM71.7826 211.255C69.497 209.936 67.0111 206.926 65.6137 200.393C64.2166 193.861 64.1969 184.917 65.9598 173.914C66.9004 168.042 68.3234 161.739 70.2187 155.109C79.9755 157.106 90.5237 158.614 101.637 159.545C108.001 168.704 114.58 177.085 121.189 184.536C116.395 189.493 111.647 193.877 107.033 197.627C98.385 204.655 90.6292 209.111 84.2739 211.167C77.9172 213.223 74.0682 212.575 71.7826 211.255ZM185.781 72.6589C187.677 66.0285 189.1 59.7251 190.04 53.8539C191.803 42.8506 191.783 33.9062 190.386 27.3744C188.989 20.8411 186.503 17.8319 184.217 16.5123C181.932 15.1928 178.083 14.5444 171.726 16.6009C165.371 18.6569 157.615 23.112 148.967 30.1404C144.353 33.8906 139.605 38.2747 134.811 43.2312C141.42 50.6819 147.999 59.0631 154.363 68.2223C165.476 69.1534 176.025 70.6611 185.781 72.6589ZM121.189 43.2312C116.395 38.2747 111.647 33.8906 107.033 30.1404C98.385 23.112 90.6292 18.6569 84.2739 16.6009C77.9172 14.5445 74.0682 15.1928 71.7826 16.5123C69.497 17.8319 67.0111 20.8411 65.6137 27.3744C64.2166 33.9062 64.1969 42.8506 65.9598 53.8539C66.9004 59.7251 68.3234 66.0286 70.2187 72.6589C79.9755 70.6611 90.5237 69.1534 101.637 68.2223C108.001 59.0631 114.58 50.682 121.189 43.2312ZM114.51 67.4164C118.965 61.3763 123.485 55.7626 128 50.6258C132.515 55.7626 137.035 61.3763 141.49 67.4164C137.06 67.231 132.559 67.1359 128 67.1359C123.441 67.1359 118.94 67.231 114.51 67.4164ZM94.503 78.9676C87.0448 79.8054 79.9231 80.9132 73.2171 82.2548C75.4082 88.7331 78.0097 95.4546 81.0133 102.333C83.0676 98.4035 85.2357 94.4581 87.5152 90.5098C89.7947 86.5615 92.1276 82.7112 94.503 78.9676ZM86.3696 113.884C89.3439 107.821 92.6143 101.678 96.1754 95.5098C99.7366 89.3416 103.422 83.4378 107.185 77.8307C113.922 77.3752 120.878 77.1359 128 77.1359C135.122 77.1359 142.078 77.3752 148.815 77.8307C152.578 83.4378 156.263 89.3416 159.825 95.5098C163.386 101.678 166.656 107.821 169.63 113.884C166.656 119.946 163.386 126.089 159.825 132.258C156.263 138.426 152.578 144.33 148.815 149.937C142.078 150.392 135.122 150.632 128 150.632C120.878 150.632 113.922 150.392 107.185 149.937C103.422 144.33 99.7366 138.426 96.1754 132.258C92.6143 126.089 89.3439 119.946 86.3696 113.884ZM75.2747 113.884C70.5243 103.793 66.5558 93.9046 63.4076 84.4561C56.7179 86.1298 50.5474 88.0492 44.9926 90.1702C34.5819 94.1452 26.8457 98.6344 21.8875 103.11C16.9283 107.587 15.5652 111.245 15.5652 113.884C15.5652 116.523 16.9283 120.18 21.8875 124.657C26.8457 129.133 34.5819 133.622 44.9926 137.597C50.5474 139.718 56.7179 141.638 63.4076 143.311C66.5558 133.863 70.5243 123.974 75.2747 113.884ZM73.2171 145.513C75.4082 139.034 78.0097 132.313 81.0133 125.435C83.0676 129.364 85.2357 133.309 87.5152 137.258C89.7947 141.206 92.1276 145.056 94.503 148.8C87.0448 147.962 79.9231 146.854 73.2171 145.513ZM154.363 159.545C165.476 158.614 176.024 157.106 185.781 155.109C187.677 161.739 189.1 168.042 190.04 173.914C191.803 184.917 191.783 193.861 190.386 200.393C188.989 206.926 186.503 209.936 184.217 211.255C181.932 212.575 178.083 213.223 171.726 211.167C165.371 209.111 157.615 204.655 148.967 197.627C144.353 193.877 139.605 189.493 134.811 184.536C141.42 177.085 147.999 168.704 154.363 159.545ZM141.49 160.351C137.035 166.391 132.515 172.005 128 177.142C123.485 172.005 118.965 166.391 114.51 160.351C118.94 160.536 123.441 160.632 128 160.632C132.559 160.632 137.06 160.536 141.49 160.351ZM161.497 148.8C163.872 145.056 166.205 141.206 168.485 137.258C170.764 133.309 172.932 129.364 174.987 125.435C177.99 132.313 180.592 139.034 182.783 145.513C176.077 146.854 168.955 147.962 161.497 148.8ZM180.725 113.884C185.476 123.974 189.444 133.863 192.592 143.311C199.282 141.638 205.453 139.718 211.007 137.597C221.418 133.622 229.154 129.133 234.112 124.657C239.072 120.18 240.435 116.523 240.435 113.884C240.435 111.245 239.072 107.587 234.112 103.11C229.154 98.6344 221.418 94.1452 211.007 90.1702C205.453 88.0492 199.282 86.1298 192.592 84.4561C189.444 93.9046 185.476 103.793 180.725 113.884ZM174.987 102.333C177.99 95.4546 180.592 88.7331 182.783 82.2548C176.077 80.9132 168.955 79.8054 161.497 78.9676C163.872 82.7112 166.205 86.5615 168.485 90.5098C170.764 94.4581 172.932 98.4035 174.987 102.333Z";
|
20
20
|
const p1 = roundtrip(Skia, Skia.Path.MakeFromSVGString(svg1)!);
|
21
|
-
expect(p1.toSVGString()).
|
21
|
+
expect(p1.toSVGString()).toBeApproximatelyEqual(svg1);
|
22
22
|
|
23
23
|
const paint = Skia.Paint();
|
24
24
|
paint.setAntiAlias(true);
|
25
25
|
paint.setColor(Skia.Color("cyan"));
|
26
26
|
canvas.drawPath(p1, paint);
|
27
27
|
const p2 = roundtrip(Skia, Skia.Path.MakeFromSVGString(svg2)!);
|
28
|
-
expect(p2.toSVGString()).
|
28
|
+
expect(p2.toSVGString()).toBeApproximatelyEqual(svg2);
|
29
29
|
|
30
30
|
p2.setFillType(FillType.EvenOdd);
|
31
31
|
canvas.drawPath(p2, paint);
|
package/src/skia/web/Host.ts
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
import type { CanvasKit, EmbindEnumEntity
|
1
|
+
import type { CanvasKit, EmbindEnumEntity } from "canvaskit-wasm";
|
2
2
|
|
3
3
|
import type { SkJSIInstance } from "../types";
|
4
4
|
|
5
|
-
export
|
6
|
-
|
7
|
-
|
5
|
+
export const throwNotImplementedOnRNWeb = <T>(): T => {
|
6
|
+
if (typeof jest !== "undefined") {
|
7
|
+
return jest.fn() as unknown as T;
|
8
8
|
}
|
9
|
-
|
9
|
+
throw new Error("Not implemented on React Native Web");
|
10
|
+
};
|
10
11
|
|
11
12
|
export abstract class Host {
|
12
13
|
readonly CanvasKit: CanvasKit;
|
@@ -41,11 +42,28 @@ export abstract class HostObject<T, N extends string> extends BaseHostObject<
|
|
41
42
|
}
|
42
43
|
}
|
43
44
|
|
44
|
-
export const getEnum = (
|
45
|
-
|
45
|
+
export const getEnum = (
|
46
|
+
CanvasKit: CanvasKit,
|
47
|
+
name: keyof CanvasKit,
|
48
|
+
v: number
|
49
|
+
): EmbindEnumEntity => {
|
50
|
+
const e = CanvasKit[name];
|
51
|
+
if (typeof e !== "function") {
|
52
|
+
throw new Error(`${name} is not an number`);
|
53
|
+
}
|
54
|
+
const result = Object.values(e).find(({ value }) => value === v);
|
55
|
+
if (!result) {
|
56
|
+
throw new Error(
|
57
|
+
`Enum ${name} does not have value ${v} on React Native Web`
|
58
|
+
);
|
59
|
+
}
|
60
|
+
return result;
|
61
|
+
};
|
46
62
|
|
47
63
|
export const optEnum = (
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
64
|
+
CanvasKit: CanvasKit,
|
65
|
+
name: keyof CanvasKit,
|
66
|
+
v: number | undefined
|
67
|
+
): EmbindEnumEntity | undefined => {
|
68
|
+
return v === undefined ? undefined : getEnum(CanvasKit, name, v);
|
69
|
+
};
|
@@ -124,8 +124,8 @@ export class JsiSkCanvas
|
|
124
124
|
JsiSkImage.fromValue(img),
|
125
125
|
left,
|
126
126
|
top,
|
127
|
-
getEnum(this.CanvasKit
|
128
|
-
getEnum(this.CanvasKit
|
127
|
+
getEnum(this.CanvasKit, "FilterMode", fm),
|
128
|
+
getEnum(this.CanvasKit, "MipmapMode", mm),
|
129
129
|
paint ? JsiSkPaint.fromValue(paint) : paint
|
130
130
|
);
|
131
131
|
}
|
@@ -141,7 +141,7 @@ export class JsiSkCanvas
|
|
141
141
|
JsiSkImage.fromValue(img),
|
142
142
|
Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),
|
143
143
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
144
|
-
getEnum(this.CanvasKit
|
144
|
+
getEnum(this.CanvasKit, "FilterMode", filter),
|
145
145
|
paint ? JsiSkPaint.fromValue(paint) : paint
|
146
146
|
);
|
147
147
|
}
|
@@ -176,8 +176,8 @@ export class JsiSkCanvas
|
|
176
176
|
JsiSkImage.fromValue(img),
|
177
177
|
JsiSkRect.fromValue(this.CanvasKit, src),
|
178
178
|
JsiSkRect.fromValue(this.CanvasKit, dest),
|
179
|
-
getEnum(this.CanvasKit
|
180
|
-
getEnum(this.CanvasKit
|
179
|
+
getEnum(this.CanvasKit, "FilterMode", fm),
|
180
|
+
getEnum(this.CanvasKit, "MipmapMode", mm),
|
181
181
|
paint ? JsiSkPaint.fromValue(paint) : paint
|
182
182
|
);
|
183
183
|
}
|
@@ -197,7 +197,7 @@ export class JsiSkCanvas
|
|
197
197
|
drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {
|
198
198
|
this.ref.drawVertices(
|
199
199
|
JsiSkVertices.fromValue(verts),
|
200
|
-
getEnum(this.CanvasKit
|
200
|
+
getEnum(this.CanvasKit, "BlendMode", mode),
|
201
201
|
JsiSkPaint.fromValue(paint)
|
202
202
|
);
|
203
203
|
}
|
@@ -213,7 +213,7 @@ export class JsiSkCanvas
|
|
213
213
|
cubics.map(({ x, y }) => [x, y]).flat(),
|
214
214
|
colors,
|
215
215
|
texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,
|
216
|
-
mode ? getEnum(this.CanvasKit
|
216
|
+
mode ? getEnum(this.CanvasKit, "BlendMode", mode) : null,
|
217
217
|
paint ? JsiSkPaint.fromValue(paint) : undefined
|
218
218
|
);
|
219
219
|
}
|
@@ -224,7 +224,7 @@ export class JsiSkCanvas
|
|
224
224
|
|
225
225
|
drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {
|
226
226
|
this.ref.drawPoints(
|
227
|
-
getEnum(this.CanvasKit
|
227
|
+
getEnum(this.CanvasKit, "PointMode", mode),
|
228
228
|
points.map(({ x, y }) => [x, y]).flat(),
|
229
229
|
JsiSkPaint.fromValue(paint)
|
230
230
|
);
|
@@ -357,7 +357,7 @@ export class JsiSkCanvas
|
|
357
357
|
drawColor(color: SkColor, blendMode?: BlendMode) {
|
358
358
|
this.ref.drawColor(
|
359
359
|
color,
|
360
|
-
blendMode ? getEnum(this.CanvasKit
|
360
|
+
blendMode ? getEnum(this.CanvasKit, "BlendMode", blendMode) : undefined
|
361
361
|
);
|
362
362
|
}
|
363
363
|
|
@@ -368,7 +368,7 @@ export class JsiSkCanvas
|
|
368
368
|
clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {
|
369
369
|
this.ref.clipPath(
|
370
370
|
JsiSkPath.fromValue(path),
|
371
|
-
getEnum(this.CanvasKit
|
371
|
+
getEnum(this.CanvasKit, "PathOp", op),
|
372
372
|
doAntiAlias
|
373
373
|
);
|
374
374
|
}
|
@@ -376,7 +376,7 @@ export class JsiSkCanvas
|
|
376
376
|
clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {
|
377
377
|
this.ref.clipRect(
|
378
378
|
JsiSkRect.fromValue(this.CanvasKit, rect),
|
379
|
-
getEnum(this.CanvasKit
|
379
|
+
getEnum(this.CanvasKit, "PathOp", op),
|
380
380
|
doAntiAlias
|
381
381
|
);
|
382
382
|
}
|
@@ -384,7 +384,7 @@ export class JsiSkCanvas
|
|
384
384
|
clipRRect(rrect: InputRRect, op: ClipOp, doAntiAlias: boolean) {
|
385
385
|
this.ref.clipRRect(
|
386
386
|
JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
387
|
-
getEnum(this.CanvasKit
|
387
|
+
getEnum(this.CanvasKit, "PathOp", op),
|
388
388
|
doAntiAlias
|
389
389
|
);
|
390
390
|
}
|
@@ -426,9 +426,9 @@ export class JsiSkCanvas
|
|
426
426
|
ckSampling = sampling;
|
427
427
|
} else if (sampling) {
|
428
428
|
ckSampling = {
|
429
|
-
filter: getEnum(this.CanvasKit
|
429
|
+
filter: getEnum(this.CanvasKit, "FilterMode", sampling.filter),
|
430
430
|
mipmap: sampling.mipmap
|
431
|
-
? getEnum(this.CanvasKit
|
431
|
+
? getEnum(this.CanvasKit, "MipmapMode", sampling.mipmap)
|
432
432
|
: this.CanvasKit.MipmapMode.None,
|
433
433
|
};
|
434
434
|
}
|
@@ -438,7 +438,7 @@ export class JsiSkCanvas
|
|
438
438
|
dst,
|
439
439
|
JsiSkPaint.fromValue(paint),
|
440
440
|
blendMode
|
441
|
-
? getEnum(this.CanvasKit
|
441
|
+
? getEnum(this.CanvasKit, "BlendMode", blendMode)
|
442
442
|
: this.CanvasKit.BlendMode.DstOver,
|
443
443
|
cls,
|
444
444
|
ckSampling
|
@@ -450,8 +450,8 @@ export class JsiSkCanvas
|
|
450
450
|
width: imageInfo.width,
|
451
451
|
height: imageInfo.height,
|
452
452
|
colorSpace: this.CanvasKit.ColorSpace.SRGB,
|
453
|
-
alphaType: getEnum(this.CanvasKit
|
454
|
-
colorType: getEnum(this.CanvasKit
|
453
|
+
alphaType: getEnum(this.CanvasKit, "AlphaType", imageInfo.alphaType),
|
454
|
+
colorType: getEnum(this.CanvasKit, "ColorType", imageInfo.colorType),
|
455
455
|
};
|
456
456
|
return this.ref.readPixels(srcX, srcY, pxInfo);
|
457
457
|
}
|
@@ -10,7 +10,7 @@ import type {
|
|
10
10
|
SkTypeface,
|
11
11
|
} from "../types";
|
12
12
|
|
13
|
-
import { HostObject,
|
13
|
+
import { HostObject, getEnum, throwNotImplementedOnRNWeb } from "./Host";
|
14
14
|
import { JsiSkPaint } from "./JsiSkPaint";
|
15
15
|
import { JsiSkPoint } from "./JsiSkPoint";
|
16
16
|
import { JsiSkRect } from "./JsiSkRect";
|
@@ -21,8 +21,8 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
21
21
|
super(CanvasKit, ref, "Font");
|
22
22
|
}
|
23
23
|
|
24
|
-
measureText(_text: string, _paint?: SkPaint | undefined)
|
25
|
-
|
24
|
+
measureText(_text: string, _paint?: SkPaint | undefined) {
|
25
|
+
return throwNotImplementedOnRNWeb<SkRect>();
|
26
26
|
}
|
27
27
|
|
28
28
|
dispose = () => {
|
@@ -100,7 +100,7 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
100
100
|
}
|
101
101
|
|
102
102
|
setEdging(edging: FontEdging) {
|
103
|
-
this.ref.setEdging(getEnum(this.CanvasKit
|
103
|
+
this.ref.setEdging(getEnum(this.CanvasKit, "FontEdging", edging));
|
104
104
|
}
|
105
105
|
|
106
106
|
setEmbeddedBitmaps(embeddedBitmaps: boolean) {
|
@@ -108,7 +108,7 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
|
|
108
108
|
}
|
109
109
|
|
110
110
|
setHinting(hinting: FontHinting) {
|
111
|
-
this.ref.setHinting(getEnum(this.CanvasKit
|
111
|
+
this.ref.setHinting(getEnum(this.CanvasKit, "FontHinting", hinting));
|
112
112
|
}
|
113
113
|
|
114
114
|
setLinearMetrics(linearMetrics: boolean) {
|
@@ -2,7 +2,7 @@ import type { CanvasKit, FontMgr } from "canvaskit-wasm";
|
|
2
2
|
|
3
3
|
import type { FontStyle, SkFontMgr, SkTypeface } from "../types";
|
4
4
|
|
5
|
-
import { HostObject,
|
5
|
+
import { HostObject, throwNotImplementedOnRNWeb } from "./Host";
|
6
6
|
|
7
7
|
export class JsiSkFontMgr
|
8
8
|
extends HostObject<FontMgr, "FontMgr">
|
@@ -20,7 +20,7 @@ export class JsiSkFontMgr
|
|
20
20
|
getFamilyName(index: number) {
|
21
21
|
return this.ref.getFamilyName(index);
|
22
22
|
}
|
23
|
-
matchFamilyStyle(_familyName: string, _fontStyle: FontStyle)
|
24
|
-
|
23
|
+
matchFamilyStyle(_familyName: string, _fontStyle: FontStyle) {
|
24
|
+
return throwNotImplementedOnRNWeb<SkTypeface>();
|
25
25
|
}
|
26
26
|
}
|
@@ -77,10 +77,10 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
77
77
|
return new JsiSkShader(
|
78
78
|
this.CanvasKit,
|
79
79
|
this.ref.makeShaderOptions(
|
80
|
-
getEnum(this.CanvasKit
|
81
|
-
getEnum(this.CanvasKit
|
82
|
-
getEnum(this.CanvasKit
|
83
|
-
getEnum(this.CanvasKit
|
80
|
+
getEnum(this.CanvasKit, "TileMode", tx),
|
81
|
+
getEnum(this.CanvasKit, "TileMode", ty),
|
82
|
+
getEnum(this.CanvasKit, "FilterMode", fm),
|
83
|
+
getEnum(this.CanvasKit, "MipmapMode", mm),
|
84
84
|
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
|
85
85
|
)
|
86
86
|
);
|
@@ -96,8 +96,8 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
96
96
|
return new JsiSkShader(
|
97
97
|
this.CanvasKit,
|
98
98
|
this.ref.makeShaderCubic(
|
99
|
-
getEnum(this.CanvasKit
|
100
|
-
getEnum(this.CanvasKit
|
99
|
+
getEnum(this.CanvasKit, "TileMode", tx),
|
100
|
+
getEnum(this.CanvasKit, "TileMode", ty),
|
101
101
|
B,
|
102
102
|
C,
|
103
103
|
localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined
|
@@ -109,11 +109,13 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
109
109
|
let result: Uint8Array | null;
|
110
110
|
if (fmt && quality) {
|
111
111
|
result = this.ref.encodeToBytes(
|
112
|
-
getEnum(this.CanvasKit
|
112
|
+
getEnum(this.CanvasKit, "ImageFormat", fmt),
|
113
113
|
quality
|
114
114
|
);
|
115
115
|
} else if (fmt) {
|
116
|
-
result = this.ref.encodeToBytes(
|
116
|
+
result = this.ref.encodeToBytes(
|
117
|
+
getEnum(this.CanvasKit, "ImageFormat", fmt)
|
118
|
+
);
|
117
119
|
} else {
|
118
120
|
result = this.ref.encodeToBytes();
|
119
121
|
}
|
@@ -137,11 +139,13 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
|
|
137
139
|
width: imageInfo?.width ?? info.width,
|
138
140
|
height: imageInfo?.height ?? info.height,
|
139
141
|
alphaType: getEnum(
|
140
|
-
this.CanvasKit
|
142
|
+
this.CanvasKit,
|
143
|
+
"AlphaType",
|
141
144
|
(imageInfo ?? info).alphaType
|
142
145
|
),
|
143
146
|
colorType: getEnum(
|
144
|
-
this.CanvasKit
|
147
|
+
this.CanvasKit,
|
148
|
+
"ColorType",
|
145
149
|
(imageInfo ?? info).colorType
|
146
150
|
),
|
147
151
|
};
|