@shopify/react-native-skia 2.0.6 → 2.1.0
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 +20 -1
- package/cpp/api/JsiSkApi.h +3 -0
- package/cpp/api/JsiSkImageFilterFactory.h +478 -39
- package/cpp/api/JsiSkPath.h +2 -1
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkSkottie.h +590 -0
- package/cpp/api/JsiSkottieFactory.h +65 -0
- package/cpp/api/recorder/Command.h +1 -0
- package/cpp/api/recorder/Convertor.h +16 -0
- package/cpp/api/recorder/Drawings.h +23 -0
- package/cpp/api/recorder/JsiRecorder.h +6 -0
- package/cpp/api/recorder/RNRecorder.h +9 -0
- package/cpp/api/third_party/SkottieUtils.cpp +333 -0
- package/cpp/api/third_party/SkottieUtils.h +172 -0
- package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +980 -0
- package/cpp/skia/modules/jsonreader/SkJSONReader.h +389 -0
- package/cpp/skia/modules/skottie/include/ExternalLayer.h +56 -0
- package/cpp/skia/modules/skottie/include/Skottie.h +313 -0
- package/cpp/skia/modules/skottie/include/SkottieProperty.h +190 -0
- package/cpp/skia/modules/skottie/include/SlotManager.h +113 -0
- package/cpp/skia/modules/skottie/include/TextShaper.h +200 -0
- package/cpp/skia/modules/skottie/src/SkottieValue.h +56 -0
- package/cpp/skia/modules/skottie/src/animator/Animator.h +89 -0
- package/cpp/skia/modules/skottie/src/text/Font.h +82 -0
- package/cpp/skia/modules/skottie/src/text/TextAdapter.h +155 -0
- package/cpp/skia/modules/skottie/src/text/TextAnimator.h +121 -0
- package/cpp/skia/modules/skottie/src/text/TextValue.h +28 -0
- package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +61 -0
- package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +135 -0
- package/cpp/skia/modules/sksg/include/SkSGDraw.h +57 -0
- package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +50 -0
- package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +181 -0
- package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +54 -0
- package/cpp/skia/modules/sksg/include/SkSGGradient.h +108 -0
- package/cpp/skia/modules/sksg/include/SkSGGroup.h +65 -0
- package/cpp/skia/modules/sksg/include/SkSGImage.h +59 -0
- package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +46 -0
- package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +65 -0
- package/cpp/skia/modules/sksg/include/SkSGMerge.h +74 -0
- package/cpp/skia/modules/sksg/include/SkSGNode.h +128 -0
- package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +54 -0
- package/cpp/skia/modules/sksg/include/SkSGPaint.h +112 -0
- package/cpp/skia/modules/sksg/include/SkSGPath.h +68 -0
- package/cpp/skia/modules/sksg/include/SkSGPlane.h +47 -0
- package/cpp/skia/modules/sksg/include/SkSGRect.h +122 -0
- package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +283 -0
- package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +157 -0
- package/cpp/skia/modules/sksg/include/SkSGScene.h +47 -0
- package/cpp/skia/modules/sksg/include/SkSGText.h +82 -0
- package/cpp/skia/modules/sksg/include/SkSGTransform.h +127 -0
- package/cpp/skia/src/base/SkArenaAlloc.h +371 -0
- package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +15 -15
- package/lib/commonjs/dom/types/Drawings.d.ts +5 -1
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
- package/lib/commonjs/dom/types/NodeType.js +2 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
- package/lib/commonjs/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
- package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -0
- package/lib/commonjs/renderer/components/Skottie.d.ts +4 -0
- package/lib/commonjs/renderer/components/Skottie.js +13 -0
- package/lib/commonjs/renderer/components/Skottie.js.map +1 -0
- package/lib/commonjs/renderer/components/index.d.ts +1 -0
- package/lib/commonjs/renderer/components/index.js +11 -0
- package/lib/commonjs/renderer/components/index.js.map +1 -1
- package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
- package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/types/Matrix4.d.ts +11 -2
- package/lib/commonjs/skia/types/Matrix4.js +42 -1
- package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
- package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
- package/lib/commonjs/skia/types/Recorder.js.map +1 -1
- package/lib/commonjs/skia/types/Skia.d.ts +2 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/Skottie.d.ts +223 -0
- package/lib/commonjs/skia/types/Skottie.js +73 -0
- package/lib/commonjs/skia/types/Skottie.js.map +1 -0
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +11 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +88 -19
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +2 -0
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +59 -0
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js +243 -0
- package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +9 -0
- package/lib/commonjs/skia/web/JsiSkottieFactory.js +26 -0
- package/lib/commonjs/skia/web/JsiSkottieFactory.js.map +1 -0
- package/lib/commonjs/sksg/Elements.d.ts +2 -1
- package/lib/commonjs/sksg/Elements.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Core.d.ts +4 -2
- package/lib/commonjs/sksg/Recorder/Core.js +1 -0
- package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Player.js +2 -0
- package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -1
- package/lib/commonjs/sksg/Recorder/Recorder.js +6 -0
- package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/Visitor.js +3 -0
- package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +2 -2
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
- package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +1 -1
- package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.d.ts +15 -15
- package/lib/module/dom/types/Drawings.d.ts +5 -1
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/NodeType.d.ts +2 -1
- package/lib/module/dom/types/NodeType.js +2 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
- package/lib/module/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
- package/lib/module/renderer/__tests__/setup.d.ts +5 -0
- package/lib/module/renderer/components/Skottie.d.ts +4 -0
- package/lib/module/renderer/components/Skottie.js +5 -0
- package/lib/module/renderer/components/Skottie.js.map +1 -0
- package/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/module/renderer/components/index.js +1 -0
- package/lib/module/renderer/components/index.js.map +1 -1
- package/lib/module/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
- package/lib/module/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
- package/lib/module/skia/types/Matrix4.d.ts +11 -2
- package/lib/module/skia/types/Matrix4.js +40 -0
- package/lib/module/skia/types/Matrix4.js.map +1 -1
- package/lib/module/skia/types/Recorder.d.ts +2 -1
- package/lib/module/skia/types/Recorder.js.map +1 -1
- package/lib/module/skia/types/Skia.d.ts +2 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/Skottie.d.ts +223 -0
- package/lib/module/skia/types/Skottie.js +74 -0
- package/lib/module/skia/types/Skottie.js.map +1 -0
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +88 -19
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +2 -0
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/skia/web/JsiSkottieAnimation.d.ts +59 -0
- package/lib/module/skia/web/JsiSkottieAnimation.js +236 -0
- package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -0
- package/lib/module/skia/web/JsiSkottieFactory.d.ts +9 -0
- package/lib/module/skia/web/JsiSkottieFactory.js +19 -0
- package/lib/module/skia/web/JsiSkottieFactory.js.map +1 -0
- package/lib/module/sksg/Elements.d.ts +2 -1
- package/lib/module/sksg/Elements.js.map +1 -1
- package/lib/module/sksg/Recorder/Core.d.ts +4 -2
- package/lib/module/sksg/Recorder/Core.js +1 -0
- package/lib/module/sksg/Recorder/Core.js.map +1 -1
- package/lib/module/sksg/Recorder/Player.js +3 -1
- package/lib/module/sksg/Recorder/Player.js.map +1 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
- package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Recorder.d.ts +2 -1
- package/lib/module/sksg/Recorder/Recorder.js +6 -0
- package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
- package/lib/module/sksg/Recorder/Visitor.js +3 -0
- package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/Drawing.d.ts +2 -2
- package/lib/module/sksg/Recorder/commands/Drawing.js +9 -2
- package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js +1 -1
- package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
- package/lib/typescript/lib/commonjs/renderer/components/Skottie.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/lib/commonjs/skia/types/Skottie.d.ts +6 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
- package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +48 -0
- package/lib/typescript/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +6 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -1
- package/lib/typescript/lib/module/mock/index.d.ts +7 -0
- package/lib/typescript/lib/module/renderer/components/Skottie.d.ts +2 -0
- package/lib/typescript/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
- package/lib/typescript/lib/module/skia/types/Skottie.d.ts +5 -0
- package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
- package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
- package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
- package/lib/typescript/lib/module/skia/web/JsiSkottieAnimation.d.ts +47 -0
- package/lib/typescript/lib/module/skia/web/JsiSkottieFactory.d.ts +5 -0
- package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -1
- package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +15 -15
- package/lib/typescript/src/dom/types/Drawings.d.ts +5 -1
- package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
- package/lib/typescript/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
- package/lib/typescript/src/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
- package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -0
- package/lib/typescript/src/renderer/components/Skottie.d.ts +4 -0
- package/lib/typescript/src/renderer/components/index.d.ts +1 -0
- package/lib/typescript/src/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
- package/lib/typescript/src/skia/types/Matrix4.d.ts +11 -2
- package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
- package/lib/typescript/src/skia/types/Skottie.d.ts +223 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
- package/lib/typescript/src/skia/web/JsiSkottieAnimation.d.ts +59 -0
- package/lib/typescript/src/skia/web/JsiSkottieFactory.d.ts +9 -0
- package/lib/typescript/src/sksg/Elements.d.ts +2 -1
- package/lib/typescript/src/sksg/Recorder/Core.d.ts +4 -2
- package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
- package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +2 -1
- package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +2 -2
- package/libs/android/arm64-v8a/libjsonreader.a +0 -0
- package/libs/android/armeabi-v7a/libjsonreader.a +0 -0
- package/libs/android/x86/libjsonreader.a +0 -0
- package/libs/android/x86_64/libjsonreader.a +0 -0
- package/libs/apple/libpathops.xcframework/Info.plist +9 -9
- package/libs/apple/libskia.xcframework/Info.plist +14 -14
- package/libs/apple/libskottie.xcframework/Info.plist +13 -13
- package/libs/apple/libskparagraph.xcframework/Info.plist +15 -15
- package/libs/apple/libsksg.xcframework/Info.plist +13 -13
- package/libs/apple/libskshaper.xcframework/Info.plist +15 -15
- package/libs/apple/libskunicode_core.xcframework/Info.plist +9 -9
- package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
- package/libs/apple/libsvg.xcframework/Info.plist +15 -15
- package/package.json +1 -1
- package/react-native-skia.podspec +4 -2
- package/src/__tests__/snapshots/matrix4/camera-corner.png +0 -0
- package/src/__tests__/snapshots/matrix4/camera-offset.png +0 -0
- package/src/__tests__/snapshots/matrix4/camera-top-left-center.png +0 -0
- package/src/__tests__/snapshots/matrix4/camera-zoom-out.png +0 -0
- package/src/__tests__/snapshots/matrix4/full-rect.png +0 -0
- package/src/__tests__/snapshots/matrix4/rect.png +0 -0
- package/src/__tests__/snapshots/matrix4/scaled-rect.png +0 -0
- package/src/__tests__/snapshots/matrix4/test-perspective.png +0 -0
- package/src/__tests__/snapshots/matrix4/test-perspective2.png +0 -0
- package/src/dom/types/Drawings.ts +6 -0
- package/src/dom/types/NodeType.ts +2 -0
- package/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.tsx +492 -0
- package/src/renderer/__tests__/e2e/Camera.spec.tsx +475 -0
- package/src/renderer/__tests__/e2e/LightingImageFilters.spec.tsx +1478 -0
- package/src/renderer/__tests__/e2e/Skottie.spec.tsx +440 -0
- package/src/renderer/__tests__/e2e/setup/skottie/basic_slots.json +1118 -0
- package/src/renderer/__tests__/e2e/setup/skottie/color-props.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/confetti.json +5899 -0
- package/src/renderer/__tests__/e2e/setup/skottie/drinks.json +43857 -0
- package/src/renderer/__tests__/e2e/setup/skottie/fingerprint.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/lego_loader.json +29540 -0
- package/src/renderer/__tests__/e2e/setup/skottie/new-drop.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/onboarding.json +1 -0
- package/src/renderer/__tests__/e2e/setup/skottie/text-layer.json +1 -0
- package/src/renderer/__tests__/setup.tsx +23 -0
- package/src/renderer/components/Skottie.tsx +8 -0
- package/src/renderer/components/index.ts +1 -0
- package/src/skia/__tests__/assets/Avenir-Heavy.ttf +0 -0
- package/src/skia/types/ImageFilter/ImageFilterFactory.ts +391 -21
- package/src/skia/types/Matrix4.ts +108 -2
- package/src/skia/types/Recorder.ts +2 -0
- package/src/skia/types/Skia.ts +2 -0
- package/src/skia/types/Skottie.ts +266 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkImageFilterFactory.ts +266 -31
- package/src/skia/web/JsiSkia.ts +2 -0
- package/src/skia/web/JsiSkottieAnimation.ts +259 -0
- package/src/skia/web/JsiSkottieFactory.ts +25 -0
- package/src/sksg/Elements.tsx +2 -0
- package/src/sksg/Recorder/Core.ts +3 -0
- package/src/sksg/Recorder/Player.ts +3 -0
- package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -0
- package/src/sksg/Recorder/Recorder.ts +5 -0
- package/src/sksg/Recorder/Visitor.ts +3 -0
- package/src/sksg/Recorder/commands/Drawing.ts +7 -3
- package/src/sksg/Recorder/commands/ImageFilters.ts +1 -1
- package/cpp/skia/include/pathops/SkPathOps.h +0 -17
@@ -11,6 +11,12 @@ import type {
|
|
11
11
|
SkRuntimeShaderBuilder,
|
12
12
|
SkShader,
|
13
13
|
TileMode,
|
14
|
+
FilterMode,
|
15
|
+
MipmapMode,
|
16
|
+
SkImage,
|
17
|
+
SkMatrix,
|
18
|
+
SkPicture,
|
19
|
+
SkPoint3,
|
14
20
|
} from "../types";
|
15
21
|
|
16
22
|
import { Host, throwNotImplementedOnRNWeb, getEnum } from "./Host";
|
@@ -24,10 +30,180 @@ export class JsiSkImageFilterFactory
|
|
24
30
|
constructor(CanvasKit: CanvasKit) {
|
25
31
|
super(CanvasKit);
|
26
32
|
}
|
33
|
+
MakeRuntimeShaderWithChildren(
|
34
|
+
_builder: SkRuntimeShaderBuilder,
|
35
|
+
_sampleRadius: number,
|
36
|
+
_childShaderNames: string[],
|
37
|
+
_inputs: Array<SkImageFilter | null>
|
38
|
+
): SkImageFilter {
|
39
|
+
throw throwNotImplementedOnRNWeb();
|
40
|
+
}
|
41
|
+
MakeArithmetic(
|
42
|
+
_k1: number,
|
43
|
+
_k2: number,
|
44
|
+
_k3: number,
|
45
|
+
_k4: number,
|
46
|
+
_enforcePMColor: boolean,
|
47
|
+
_background?: SkImageFilter | null,
|
48
|
+
_foreground?: SkImageFilter | null,
|
49
|
+
_cropRect?: SkRect | null
|
50
|
+
): SkImageFilter {
|
51
|
+
throw throwNotImplementedOnRNWeb();
|
52
|
+
}
|
53
|
+
MakeCrop(
|
54
|
+
_rect: SkRect,
|
55
|
+
_tileMode?: TileMode | null,
|
56
|
+
_input?: SkImageFilter | null
|
57
|
+
): SkImageFilter {
|
58
|
+
throw throwNotImplementedOnRNWeb();
|
59
|
+
}
|
60
|
+
MakeEmpty(): SkImageFilter {
|
61
|
+
throw throwNotImplementedOnRNWeb();
|
62
|
+
}
|
63
|
+
MakeImage(
|
64
|
+
_image: SkImage,
|
65
|
+
_srcRect?: SkRect | null,
|
66
|
+
_dstRect?: SkRect | null,
|
67
|
+
_filterMode?: FilterMode,
|
68
|
+
_mipmap?: MipmapMode
|
69
|
+
): SkImageFilter {
|
70
|
+
throw throwNotImplementedOnRNWeb();
|
71
|
+
}
|
72
|
+
MakeMagnifier(
|
73
|
+
_lensBounds: SkRect,
|
74
|
+
_zoomAmount: number,
|
75
|
+
_inset: number,
|
76
|
+
_filterMode?: FilterMode,
|
77
|
+
_mipmap?: MipmapMode,
|
78
|
+
_input?: SkImageFilter | null,
|
79
|
+
_cropRect?: SkRect | null
|
80
|
+
): SkImageFilter {
|
81
|
+
throw throwNotImplementedOnRNWeb();
|
82
|
+
}
|
83
|
+
MakeMatrixConvolution(
|
84
|
+
_kernelSizeX: number,
|
85
|
+
_kernelSizeY: number,
|
86
|
+
_kernel: number[],
|
87
|
+
_gain: number,
|
88
|
+
_bias: number,
|
89
|
+
_kernelOffsetX: number,
|
90
|
+
_kernelOffsetY: number,
|
91
|
+
_tileMode: TileMode,
|
92
|
+
_convolveAlpha: boolean,
|
93
|
+
_input?: SkImageFilter | null,
|
94
|
+
_cropRect?: SkRect | null
|
95
|
+
): SkImageFilter {
|
96
|
+
throw throwNotImplementedOnRNWeb();
|
97
|
+
}
|
98
|
+
MakeMatrixTransform(
|
99
|
+
_matrix: SkMatrix,
|
100
|
+
_filterMode?: FilterMode,
|
101
|
+
_mipmap?: MipmapMode,
|
102
|
+
_input?: SkImageFilter | null
|
103
|
+
): SkImageFilter {
|
104
|
+
throw throwNotImplementedOnRNWeb();
|
105
|
+
}
|
106
|
+
MakeMerge(
|
107
|
+
_filters: Array<SkImageFilter | null>,
|
108
|
+
_cropRect?: SkRect | null
|
109
|
+
): SkImageFilter {
|
110
|
+
throw throwNotImplementedOnRNWeb();
|
111
|
+
}
|
112
|
+
MakePicture(_picture: SkPicture, _targetRect?: SkRect | null): SkImageFilter {
|
113
|
+
throw throwNotImplementedOnRNWeb();
|
114
|
+
}
|
115
|
+
MakeTile(
|
116
|
+
_src: SkRect,
|
117
|
+
_dst: SkRect,
|
118
|
+
_input?: SkImageFilter | null
|
119
|
+
): SkImageFilter {
|
120
|
+
throw throwNotImplementedOnRNWeb();
|
121
|
+
}
|
122
|
+
MakeDistantLitDiffuse(
|
123
|
+
_direction: SkPoint3,
|
124
|
+
_lightColor: SkColor,
|
125
|
+
_surfaceScale: number,
|
126
|
+
_kd: number,
|
127
|
+
_input?: SkImageFilter | null,
|
128
|
+
_cropRect?: SkRect | null
|
129
|
+
): SkImageFilter {
|
130
|
+
throw throwNotImplementedOnRNWeb();
|
131
|
+
}
|
132
|
+
MakePointLitDiffuse(
|
133
|
+
_location: SkPoint3,
|
134
|
+
_lightColor: SkColor,
|
135
|
+
_surfaceScale: number,
|
136
|
+
_kd: number,
|
137
|
+
_input?: SkImageFilter | null,
|
138
|
+
_cropRect?: SkRect | null
|
139
|
+
): SkImageFilter {
|
140
|
+
throw throwNotImplementedOnRNWeb();
|
141
|
+
}
|
142
|
+
MakeSpotLitDiffuse(
|
143
|
+
_location: SkPoint3,
|
144
|
+
_target: SkPoint3,
|
145
|
+
_falloffExponent: number,
|
146
|
+
_cutoffAngle: number,
|
147
|
+
_lightColor: SkColor,
|
148
|
+
_surfaceScale: number,
|
149
|
+
_kd: number,
|
150
|
+
_input?: SkImageFilter | null,
|
151
|
+
_cropRect?: SkRect | null
|
152
|
+
): SkImageFilter {
|
153
|
+
throw throwNotImplementedOnRNWeb();
|
154
|
+
}
|
155
|
+
MakeDistantLitSpecular(
|
156
|
+
_direction: SkPoint3,
|
157
|
+
_lightColor: SkColor,
|
158
|
+
_surfaceScale: number,
|
159
|
+
_ks: number,
|
160
|
+
_shininess: number,
|
161
|
+
_input?: SkImageFilter | null,
|
162
|
+
_cropRect?: SkRect | null
|
163
|
+
): SkImageFilter {
|
164
|
+
throw throwNotImplementedOnRNWeb();
|
165
|
+
}
|
166
|
+
MakePointLitSpecular(
|
167
|
+
_location: SkPoint3,
|
168
|
+
_lightColor: SkColor,
|
169
|
+
_surfaceScale: number,
|
170
|
+
_ks: number,
|
171
|
+
_shininess: number,
|
172
|
+
_input?: SkImageFilter | null,
|
173
|
+
_cropRect?: SkRect | null
|
174
|
+
): SkImageFilter {
|
175
|
+
throw throwNotImplementedOnRNWeb();
|
176
|
+
}
|
177
|
+
MakeSpotLitSpecular(
|
178
|
+
_location: SkPoint3,
|
179
|
+
_target: SkPoint3,
|
180
|
+
_falloffExponent: number,
|
181
|
+
_cutoffAngle: number,
|
182
|
+
_lightColor: SkColor,
|
183
|
+
_surfaceScale: number,
|
184
|
+
_ks: number,
|
185
|
+
_shininess: number,
|
186
|
+
_input?: SkImageFilter | null,
|
187
|
+
_cropRect?: SkRect | null
|
188
|
+
): SkImageFilter {
|
189
|
+
throw throwNotImplementedOnRNWeb();
|
190
|
+
}
|
27
191
|
|
28
|
-
MakeOffset(
|
192
|
+
MakeOffset(
|
193
|
+
dx: number,
|
194
|
+
dy: number,
|
195
|
+
input?: SkImageFilter | null,
|
196
|
+
cropRect?: SkRect | null
|
197
|
+
) {
|
29
198
|
const inputFilter =
|
30
|
-
input === null
|
199
|
+
input === null || input === undefined
|
200
|
+
? null
|
201
|
+
: JsiSkImageFilter.fromValue<ImageFilter>(input);
|
202
|
+
if (cropRect) {
|
203
|
+
console.warn(
|
204
|
+
"cropRect is not supported on React Native Web for MakeOffset"
|
205
|
+
);
|
206
|
+
}
|
31
207
|
const filter = this.CanvasKit.ImageFilter.MakeOffset(dx, dy, inputFilter);
|
32
208
|
return new JsiSkImageFilter(this.CanvasKit, filter);
|
33
209
|
}
|
@@ -37,10 +213,18 @@ export class JsiSkImageFilterFactory
|
|
37
213
|
channelY: ColorChannel,
|
38
214
|
scale: number,
|
39
215
|
in1: SkImageFilter,
|
40
|
-
input
|
216
|
+
input?: SkImageFilter | null,
|
217
|
+
cropRect?: SkRect | null
|
41
218
|
): SkImageFilter {
|
42
219
|
const inputFilter =
|
43
|
-
input === null
|
220
|
+
input === null || input === undefined
|
221
|
+
? null
|
222
|
+
: JsiSkImageFilter.fromValue<ImageFilter>(input);
|
223
|
+
if (cropRect) {
|
224
|
+
console.warn(
|
225
|
+
"cropRect is not supported on React Native Web for MakeDisplacementMap"
|
226
|
+
);
|
227
|
+
}
|
44
228
|
const filter = this.CanvasKit.ImageFilter.MakeDisplacementMap(
|
45
229
|
getEnum(this.CanvasKit, "ColorChannel", channelX),
|
46
230
|
getEnum(this.CanvasKit, "ColorChannel", channelY),
|
@@ -51,7 +235,21 @@ export class JsiSkImageFilterFactory
|
|
51
235
|
return new JsiSkImageFilter(this.CanvasKit, filter);
|
52
236
|
}
|
53
237
|
|
54
|
-
MakeShader(
|
238
|
+
MakeShader(
|
239
|
+
shader: SkShader,
|
240
|
+
dither?: boolean,
|
241
|
+
cropRect?: SkRect | null
|
242
|
+
): SkImageFilter {
|
243
|
+
if (dither !== undefined) {
|
244
|
+
console.warn(
|
245
|
+
"dither parameter is not supported on React Native Web for MakeShader"
|
246
|
+
);
|
247
|
+
}
|
248
|
+
if (cropRect) {
|
249
|
+
console.warn(
|
250
|
+
"cropRect is not supported on React Native Web for MakeShader"
|
251
|
+
);
|
252
|
+
}
|
55
253
|
const filter = this.CanvasKit.ImageFilter.MakeShader(
|
56
254
|
JsiSkImageFilter.fromValue(shader)
|
57
255
|
);
|
@@ -62,25 +260,44 @@ export class JsiSkImageFilterFactory
|
|
62
260
|
sigmaX: number,
|
63
261
|
sigmaY: number,
|
64
262
|
mode: TileMode,
|
65
|
-
input
|
263
|
+
input?: SkImageFilter | null,
|
264
|
+
cropRect?: SkRect | null
|
66
265
|
) {
|
266
|
+
if (cropRect) {
|
267
|
+
console.warn(
|
268
|
+
"cropRect is not supported on React Native Web for MakeBlur"
|
269
|
+
);
|
270
|
+
}
|
67
271
|
return new JsiSkImageFilter(
|
68
272
|
this.CanvasKit,
|
69
273
|
this.CanvasKit.ImageFilter.MakeBlur(
|
70
274
|
sigmaX,
|
71
275
|
sigmaY,
|
72
276
|
getEnum(this.CanvasKit, "TileMode", mode),
|
73
|
-
input === null
|
277
|
+
input === null || input === undefined
|
278
|
+
? null
|
279
|
+
: JsiSkImageFilter.fromValue(input)
|
74
280
|
)
|
75
281
|
);
|
76
282
|
}
|
77
283
|
|
78
|
-
MakeColorFilter(
|
284
|
+
MakeColorFilter(
|
285
|
+
colorFilter: SkColorFilter,
|
286
|
+
input?: SkImageFilter | null,
|
287
|
+
cropRect?: SkRect | null
|
288
|
+
) {
|
289
|
+
if (cropRect) {
|
290
|
+
console.warn(
|
291
|
+
"cropRect is not supported on React Native Web for MakeColorFilter"
|
292
|
+
);
|
293
|
+
}
|
79
294
|
return new JsiSkImageFilter(
|
80
295
|
this.CanvasKit,
|
81
296
|
this.CanvasKit.ImageFilter.MakeColorFilter(
|
82
|
-
JsiSkColorFilter.fromValue(
|
83
|
-
input === null
|
297
|
+
JsiSkColorFilter.fromValue(colorFilter),
|
298
|
+
input === null || input === undefined
|
299
|
+
? null
|
300
|
+
: JsiSkImageFilter.fromValue(input)
|
84
301
|
)
|
85
302
|
);
|
86
303
|
}
|
@@ -101,13 +318,17 @@ export class JsiSkImageFilterFactory
|
|
101
318
|
sigmaX: number,
|
102
319
|
sigmaY: number,
|
103
320
|
color: SkColor,
|
104
|
-
input
|
105
|
-
cropRect?: SkRect
|
321
|
+
input?: SkImageFilter | null,
|
322
|
+
cropRect?: SkRect | null
|
106
323
|
): SkImageFilter {
|
107
324
|
const inputFilter =
|
108
|
-
input === null
|
325
|
+
input === null || input === undefined
|
326
|
+
? null
|
327
|
+
: JsiSkImageFilter.fromValue<ImageFilter>(input);
|
109
328
|
if (cropRect) {
|
110
|
-
|
329
|
+
console.warn(
|
330
|
+
"cropRect is not supported on React Native Web for MakeDropShadow"
|
331
|
+
);
|
111
332
|
}
|
112
333
|
const filter = this.CanvasKit.ImageFilter.MakeDropShadow(
|
113
334
|
dx,
|
@@ -126,13 +347,17 @@ export class JsiSkImageFilterFactory
|
|
126
347
|
sigmaX: number,
|
127
348
|
sigmaY: number,
|
128
349
|
color: SkColor,
|
129
|
-
input
|
130
|
-
cropRect?: SkRect
|
350
|
+
input?: SkImageFilter | null,
|
351
|
+
cropRect?: SkRect | null
|
131
352
|
): SkImageFilter {
|
132
353
|
const inputFilter =
|
133
|
-
input === null
|
354
|
+
input === null || input === undefined
|
355
|
+
? null
|
356
|
+
: JsiSkImageFilter.fromValue<ImageFilter>(input);
|
134
357
|
if (cropRect) {
|
135
|
-
|
358
|
+
console.warn(
|
359
|
+
"cropRect is not supported on React Native Web for MakeDropShadowOnly"
|
360
|
+
);
|
136
361
|
}
|
137
362
|
const filter = this.CanvasKit.ImageFilter.MakeDropShadowOnly(
|
138
363
|
dx,
|
@@ -148,13 +373,17 @@ export class JsiSkImageFilterFactory
|
|
148
373
|
MakeErode(
|
149
374
|
rx: number,
|
150
375
|
ry: number,
|
151
|
-
input
|
152
|
-
cropRect?: SkRect
|
376
|
+
input?: SkImageFilter | null,
|
377
|
+
cropRect?: SkRect | null
|
153
378
|
): SkImageFilter {
|
154
379
|
const inputFilter =
|
155
|
-
input === null
|
380
|
+
input === null || input === undefined
|
381
|
+
? null
|
382
|
+
: JsiSkImageFilter.fromValue<ImageFilter>(input);
|
156
383
|
if (cropRect) {
|
157
|
-
|
384
|
+
console.warn(
|
385
|
+
"cropRect is not supported on React Native Web for MakeErode"
|
386
|
+
);
|
158
387
|
}
|
159
388
|
const filter = this.CanvasKit.ImageFilter.MakeErode(rx, ry, inputFilter);
|
160
389
|
return new JsiSkImageFilter(this.CanvasKit, filter);
|
@@ -163,13 +392,17 @@ export class JsiSkImageFilterFactory
|
|
163
392
|
MakeDilate(
|
164
393
|
rx: number,
|
165
394
|
ry: number,
|
166
|
-
input
|
167
|
-
cropRect?: SkRect
|
395
|
+
input?: SkImageFilter | null,
|
396
|
+
cropRect?: SkRect | null
|
168
397
|
): SkImageFilter {
|
169
398
|
const inputFilter =
|
170
|
-
input === null
|
399
|
+
input === null || input === undefined
|
400
|
+
? null
|
401
|
+
: JsiSkImageFilter.fromValue<ImageFilter>(input);
|
171
402
|
if (cropRect) {
|
172
|
-
|
403
|
+
console.warn(
|
404
|
+
"cropRect is not supported on React Native Web for MakeDilate"
|
405
|
+
);
|
173
406
|
}
|
174
407
|
const filter = this.CanvasKit.ImageFilter.MakeDilate(rx, ry, inputFilter);
|
175
408
|
return new JsiSkImageFilter(this.CanvasKit, filter);
|
@@ -178,15 +411,17 @@ export class JsiSkImageFilterFactory
|
|
178
411
|
MakeBlend(
|
179
412
|
mode: BlendMode,
|
180
413
|
background: SkImageFilter,
|
181
|
-
foreground
|
182
|
-
cropRect?: SkRect
|
414
|
+
foreground?: SkImageFilter | null,
|
415
|
+
cropRect?: SkRect | null
|
183
416
|
): SkImageFilter {
|
184
417
|
const inputFilter =
|
185
|
-
foreground === null
|
418
|
+
foreground === null || foreground === undefined
|
186
419
|
? null
|
187
420
|
: JsiSkImageFilter.fromValue<ImageFilter>(foreground);
|
188
421
|
if (cropRect) {
|
189
|
-
|
422
|
+
console.warn(
|
423
|
+
"cropRect is not supported on React Native Web for MakeBlend"
|
424
|
+
);
|
190
425
|
}
|
191
426
|
const filter = this.CanvasKit.ImageFilter.MakeBlend(
|
192
427
|
getEnum(this.CanvasKit, "BlendMode", mode),
|
@@ -199,7 +434,7 @@ export class JsiSkImageFilterFactory
|
|
199
434
|
MakeRuntimeShader(
|
200
435
|
_builder: SkRuntimeShaderBuilder,
|
201
436
|
_childShaderName: string | null,
|
202
|
-
_input
|
437
|
+
_input?: SkImageFilter | null
|
203
438
|
) {
|
204
439
|
return throwNotImplementedOnRNWeb<SkImageFilter>();
|
205
440
|
}
|
package/src/skia/web/JsiSkia.ts
CHANGED
@@ -46,6 +46,7 @@ import { JsiSkParagraphBuilderFactory } from "./JsiSkParagraphBuilderFactory";
|
|
46
46
|
import { JsiSkNativeBufferFactory } from "./JsiSkNativeBufferFactory";
|
47
47
|
import { createVideo } from "./JsiVideo";
|
48
48
|
import { throwNotImplementedOnRNWeb } from "./Host";
|
49
|
+
import { JsiSkottieFactory } from "./JsiSkottieFactory";
|
49
50
|
|
50
51
|
export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
|
51
52
|
Point: (x: number, y: number) =>
|
@@ -131,6 +132,7 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
|
|
131
132
|
FontMgr: new JsiSkFontMgrFactory(CanvasKit),
|
132
133
|
ParagraphBuilder: new JsiSkParagraphBuilderFactory(CanvasKit),
|
133
134
|
NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),
|
135
|
+
Skottie: new JsiSkottieFactory(CanvasKit),
|
134
136
|
Video: createVideo.bind(null, CanvasKit),
|
135
137
|
Context: (_surface: bigint, _width: number, _height: number) => {
|
136
138
|
return throwNotImplementedOnRNWeb<SkiaContext>();
|
@@ -0,0 +1,259 @@
|
|
1
|
+
import type {
|
2
|
+
CanvasKit,
|
3
|
+
ManagedSkottieAnimation,
|
4
|
+
SlottableTextProperty as CKSlottableTextProperty,
|
5
|
+
} from "canvaskit-wasm";
|
6
|
+
|
7
|
+
import type {
|
8
|
+
SkSkottieAnimation,
|
9
|
+
SlotInfo,
|
10
|
+
SlottableTextProperty,
|
11
|
+
} from "../types/Skottie";
|
12
|
+
import type { SkColor, SkPoint, SkRect } from "../types";
|
13
|
+
|
14
|
+
import { HostObject } from "./Host";
|
15
|
+
import type { JsiSkCanvas } from "./JsiSkCanvas";
|
16
|
+
import { JsiSkTypeface } from "./JsiSkTypeface";
|
17
|
+
import { Color } from "./JsiSkColor";
|
18
|
+
import { JsiSkRect } from "./JsiSkRect";
|
19
|
+
|
20
|
+
export class JsiSkottieAnimation
|
21
|
+
extends HostObject<ManagedSkottieAnimation, "SkottieAnimation">
|
22
|
+
implements SkSkottieAnimation
|
23
|
+
{
|
24
|
+
constructor(CanvasKit: CanvasKit, ref: ManagedSkottieAnimation) {
|
25
|
+
super(CanvasKit, ref, "SkottieAnimation");
|
26
|
+
}
|
27
|
+
getOpacityProps() {
|
28
|
+
return this.ref.getOpacityProps();
|
29
|
+
}
|
30
|
+
getTextProps() {
|
31
|
+
return this.ref.getTextProps();
|
32
|
+
}
|
33
|
+
getColorProps() {
|
34
|
+
return this.ref
|
35
|
+
.getColorProps()
|
36
|
+
.map(({ key, value }) => ({ key, value: Color(value) }));
|
37
|
+
}
|
38
|
+
getTransformProps() {
|
39
|
+
return this.ref.getTransformProps().map(({ key, value }) => ({
|
40
|
+
key,
|
41
|
+
value: {
|
42
|
+
anchor: { x: value.anchor[0], y: value.anchor[1] },
|
43
|
+
position: { x: value.position[0], y: value.position[1] },
|
44
|
+
scale: { x: value.scale[0], y: value.scale[1] },
|
45
|
+
rotation: value.rotation,
|
46
|
+
skew: value.skew,
|
47
|
+
skewAxis: value.skew_axis,
|
48
|
+
},
|
49
|
+
}));
|
50
|
+
}
|
51
|
+
setColor(key: string, color: SkColor) {
|
52
|
+
return this.ref.setColor(key, color);
|
53
|
+
}
|
54
|
+
setText(key: string, text: string, size: number) {
|
55
|
+
return this.ref.setText(key, text, size);
|
56
|
+
}
|
57
|
+
setOpacity(key: string, opacity: number) {
|
58
|
+
return this.ref.setOpacity(key, opacity);
|
59
|
+
}
|
60
|
+
setTransform(
|
61
|
+
key: string,
|
62
|
+
anchor: SkPoint,
|
63
|
+
position: SkPoint,
|
64
|
+
scale: SkPoint,
|
65
|
+
rotation: number,
|
66
|
+
skew: number,
|
67
|
+
skewAxis: number
|
68
|
+
) {
|
69
|
+
const a = Float32Array.of(anchor.x, anchor.y);
|
70
|
+
const p = Float32Array.of(position.x, position.y);
|
71
|
+
const s = Float32Array.of(scale.x, scale.y);
|
72
|
+
return this.ref.setTransform(key, a, p, s, rotation, skew, skewAxis);
|
73
|
+
}
|
74
|
+
|
75
|
+
getSlotInfo(): SlotInfo {
|
76
|
+
return this.ref.getSlotInfo();
|
77
|
+
}
|
78
|
+
setColorSlot(key: string, color: SkColor) {
|
79
|
+
return this.ref.setColorSlot(key, color);
|
80
|
+
}
|
81
|
+
setScalarSlot(key: string, scalar: number) {
|
82
|
+
return this.ref.setScalarSlot(key, scalar);
|
83
|
+
}
|
84
|
+
setVec2Slot(key: string, vec2: SkPoint) {
|
85
|
+
return this.ref.setVec2Slot(key, Float32Array.of(vec2.x, vec2.y));
|
86
|
+
}
|
87
|
+
setTextSlot(key: string, text: SlottableTextProperty): boolean {
|
88
|
+
const txt: CKSlottableTextProperty = {
|
89
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
90
|
+
// @ts-expect-error
|
91
|
+
typeface:
|
92
|
+
text.typeface && text.typeface instanceof JsiSkTypeface
|
93
|
+
? text.typeface.ref
|
94
|
+
: null,
|
95
|
+
text: text.text ?? "",
|
96
|
+
textSize: text.textSize ?? 0,
|
97
|
+
minTextSize: text.minTextSize ?? 0,
|
98
|
+
maxTextSize: text.maxTextSize ?? Number.MAX_VALUE,
|
99
|
+
strokeWidth: text.strokeWidth ?? 0,
|
100
|
+
lineHeight: text.lineHeight ?? 0,
|
101
|
+
lineShift: text.lineShift ?? 0,
|
102
|
+
ascent: text.ascent,
|
103
|
+
maxLines: text.maxLines,
|
104
|
+
// TODO: implement
|
105
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
106
|
+
//@ts-expect-error
|
107
|
+
horizAlign: this.CanvasKit.TextAlign.Left,
|
108
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
109
|
+
//@ts-expect-error
|
110
|
+
vertAlign: this.CanvasKit.VerticalTextAlign.Top,
|
111
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
112
|
+
//@ts-expect-error
|
113
|
+
strokeJoin: this.CanvasKit.StrokeJoin.Miter,
|
114
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
115
|
+
//@ts-expect-error
|
116
|
+
direction: this.CanvasKit.TextDirection.LTR,
|
117
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
118
|
+
// @ts-expect-error
|
119
|
+
linebreak: this.CanvasKit.LineBreakType.HardLineBreak,
|
120
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
121
|
+
// @ts-expect-error
|
122
|
+
resize: this.CanvasKit.ResizePolicy.None,
|
123
|
+
boundingBox: text.boundingBox
|
124
|
+
? this.CanvasKit.XYWHRect(
|
125
|
+
text.boundingBox.x,
|
126
|
+
text.boundingBox.y,
|
127
|
+
text.boundingBox.width,
|
128
|
+
text.boundingBox.height
|
129
|
+
)
|
130
|
+
: [0, 0, 0, 0],
|
131
|
+
fillColor: text.fillColor
|
132
|
+
? Color(text.fillColor)
|
133
|
+
: this.CanvasKit.TRANSPARENT,
|
134
|
+
strokeColor: text.strokeColor
|
135
|
+
? Color(text.strokeColor)
|
136
|
+
: this.CanvasKit.TRANSPARENT,
|
137
|
+
};
|
138
|
+
return this.ref.setTextSlot(key, txt);
|
139
|
+
}
|
140
|
+
setImageSlot(key: string, assetName: string) {
|
141
|
+
return this.ref.setImageSlot(key, assetName);
|
142
|
+
}
|
143
|
+
getColorSlot(key: string): SkColor | null {
|
144
|
+
const color = this.ref.getColorSlot(key);
|
145
|
+
return color;
|
146
|
+
}
|
147
|
+
getScalarSlot(key: string) {
|
148
|
+
return this.ref.getScalarSlot(key);
|
149
|
+
}
|
150
|
+
getVec2Slot(key: string): SkPoint | null {
|
151
|
+
const vec2 = this.ref.getVec2Slot(key);
|
152
|
+
if (!vec2) {
|
153
|
+
return null;
|
154
|
+
}
|
155
|
+
return { x: vec2[0], y: vec2[1] };
|
156
|
+
}
|
157
|
+
getTextSlot(key: string): SlottableTextProperty | null {
|
158
|
+
const result = this.ref.getTextSlot(key);
|
159
|
+
const textSlot: SlottableTextProperty = {};
|
160
|
+
if (result) {
|
161
|
+
if (result.typeface) {
|
162
|
+
textSlot.typeface = new JsiSkTypeface(this.CanvasKit, result.typeface);
|
163
|
+
}
|
164
|
+
if (result.text) {
|
165
|
+
textSlot.text = result.text;
|
166
|
+
}
|
167
|
+
if (result.textSize) {
|
168
|
+
textSlot.textSize = result.textSize;
|
169
|
+
}
|
170
|
+
if (result.minTextSize) {
|
171
|
+
textSlot.minTextSize = result.minTextSize;
|
172
|
+
}
|
173
|
+
if (result.maxTextSize) {
|
174
|
+
textSlot.maxTextSize = result.maxTextSize;
|
175
|
+
}
|
176
|
+
if (result.strokeWidth) {
|
177
|
+
textSlot.strokeWidth = result.strokeWidth;
|
178
|
+
}
|
179
|
+
if (result.lineHeight) {
|
180
|
+
textSlot.lineHeight = result.lineHeight;
|
181
|
+
}
|
182
|
+
if (result.lineShift) {
|
183
|
+
textSlot.lineShift = result.lineShift;
|
184
|
+
}
|
185
|
+
if (result.ascent) {
|
186
|
+
textSlot.ascent = result.ascent;
|
187
|
+
}
|
188
|
+
if (result.maxLines) {
|
189
|
+
textSlot.maxLines = result.maxLines;
|
190
|
+
}
|
191
|
+
// if (result.horizAlign) {
|
192
|
+
// textSlot.horizAlign = result.horizAlign;
|
193
|
+
// }
|
194
|
+
// if (result.vertAlign) {
|
195
|
+
// textSlot.vertAlign = result.vertAlign;
|
196
|
+
// }
|
197
|
+
// if (result.strokeJoin) {
|
198
|
+
// textSlot.strokeJoin = result.strokeJoin;
|
199
|
+
// }
|
200
|
+
// if (result.direction) {
|
201
|
+
// textSlot.direction = result.direction;
|
202
|
+
// }
|
203
|
+
// if (result.linebreak) {
|
204
|
+
// textSlot.linebreak = result.linebreak;
|
205
|
+
// }
|
206
|
+
// if (result.resize) {
|
207
|
+
// textSlot.resize = result.resize;
|
208
|
+
// }
|
209
|
+
// if (result.boundingBox) {
|
210
|
+
// textSlot.boundingBox = new JsiSkRect(
|
211
|
+
// this.CanvasKit,
|
212
|
+
// result.boundingBox
|
213
|
+
// );
|
214
|
+
// }
|
215
|
+
// if (result.fillColor) {
|
216
|
+
// textSlot.fillColor = Color(result.fillColor);
|
217
|
+
// }
|
218
|
+
// if (result.strokeColor) {
|
219
|
+
// textSlot.strokeColor = Color(result.strokeColor);
|
220
|
+
// }
|
221
|
+
}
|
222
|
+
return textSlot;
|
223
|
+
}
|
224
|
+
|
225
|
+
duration() {
|
226
|
+
return this.ref.duration();
|
227
|
+
}
|
228
|
+
fps() {
|
229
|
+
return this.ref.fps();
|
230
|
+
}
|
231
|
+
render(canvas: JsiSkCanvas, dstRect?: SkRect) {
|
232
|
+
const [width, height] = this.ref.size();
|
233
|
+
this.ref.render(
|
234
|
+
canvas.ref,
|
235
|
+
dstRect && dstRect instanceof JsiSkRect
|
236
|
+
? dstRect.ref
|
237
|
+
: Float32Array.of(0, 0, width, height)
|
238
|
+
);
|
239
|
+
}
|
240
|
+
seekFrame(frame: number, damageRect?: JsiSkRect) {
|
241
|
+
const result = this.ref.seekFrame(frame);
|
242
|
+
if (damageRect && damageRect instanceof JsiSkRect) {
|
243
|
+
damageRect.ref[0] = result[0];
|
244
|
+
damageRect.ref[1] = result[1];
|
245
|
+
damageRect.ref[2] = result[2];
|
246
|
+
damageRect.ref[3] = result[3];
|
247
|
+
}
|
248
|
+
}
|
249
|
+
size() {
|
250
|
+
const [width, height] = this.ref.size();
|
251
|
+
return { width, height };
|
252
|
+
}
|
253
|
+
version() {
|
254
|
+
return this.ref.version();
|
255
|
+
}
|
256
|
+
dispose() {
|
257
|
+
this.ref.delete();
|
258
|
+
}
|
259
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
+
|
3
|
+
import type { SkottieFactory } from "../types";
|
4
|
+
|
5
|
+
import { Host } from "./Host";
|
6
|
+
import { JsiSkottieAnimation } from "./JsiSkottieAnimation";
|
7
|
+
import type { JsiSkData } from "./JsiSkData";
|
8
|
+
|
9
|
+
export class JsiSkottieFactory extends Host implements SkottieFactory {
|
10
|
+
constructor(CanvasKit: CanvasKit) {
|
11
|
+
super(CanvasKit);
|
12
|
+
}
|
13
|
+
|
14
|
+
Make(json: string, assets?: Record<string, JsiSkData>) {
|
15
|
+
const rawAssets: { [key: string]: ArrayBuffer } = {};
|
16
|
+
for (const [key, value] of Object.entries(assets ?? {})) {
|
17
|
+
rawAssets[key] = value.ref;
|
18
|
+
}
|
19
|
+
const animation = this.CanvasKit.MakeManagedAnimation(json, rawAssets);
|
20
|
+
if (!animation) {
|
21
|
+
throw new Error("Failed to create SkottieAnimation");
|
22
|
+
}
|
23
|
+
return new JsiSkottieAnimation(this.CanvasKit, animation);
|
24
|
+
}
|
25
|
+
}
|