@shopify/react-native-skia 1.7.6 → 1.7.7
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/cpp/rnskia-android/OpenGLWindowContext.h +8 -1
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +4 -4
- package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +2 -2
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +13 -0
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaTextureView.java +24 -1
- package/cpp/rnskia/RNSkJsiViewApi.h +0 -3
- package/cpp/rnskia/RNSkView.h +6 -6
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +2 -2
- package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +2 -2
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Circle.d.ts +2 -3
- package/lib/commonjs/dom/nodes/datatypes/Circle.js +11 -6
- package/lib/commonjs/dom/nodes/datatypes/Circle.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Enum.js +1 -0
- package/lib/commonjs/dom/nodes/datatypes/Enum.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Fitting.js +1 -10
- package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Gradient.js +3 -2
- package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Path.js +4 -1
- package/lib/commonjs/dom/nodes/datatypes/Path.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Radius.js +1 -0
- package/lib/commonjs/dom/nodes/datatypes/Radius.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.d.ts +3 -1
- package/lib/commonjs/dom/nodes/datatypes/Rect.js +17 -7
- package/lib/commonjs/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/commonjs/dom/nodes/datatypes/Transform.d.ts +2 -1
- package/lib/commonjs/dom/nodes/datatypes/Transform.js +32 -1
- package/lib/commonjs/dom/nodes/datatypes/Transform.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Box.js +4 -5
- package/lib/commonjs/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/CircleNode.js +1 -1
- package/lib/commonjs/dom/nodes/drawings/CircleNode.js.map +1 -1
- package/lib/commonjs/dom/types/DeclarationContext.d.ts +4 -4
- package/lib/commonjs/dom/types/DeclarationContext.js +8 -2
- package/lib/commonjs/dom/types/DeclarationContext.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/commonjs/external/reanimated/renderHelpers.js +11 -6
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/renderer/HostConfig.js +8 -4
- package/lib/commonjs/renderer/HostConfig.js.map +1 -1
- package/lib/commonjs/renderer/__tests__/setup.d.ts +2 -3
- package/lib/commonjs/renderer/processors/Animations/Animations.d.ts +1 -2
- package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/commonjs/renderer/typeddash.js +5 -1
- package/lib/commonjs/renderer/typeddash.js.map +1 -1
- package/lib/commonjs/skia/__tests__/setup.d.ts +0 -3
- package/lib/commonjs/skia/types/Path/Path.js +5 -1
- package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
- package/lib/commonjs/skia/types/Shader/Shader.js +8 -6
- package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +19 -0
- package/lib/commonjs/sksg/Container.js +102 -0
- package/lib/commonjs/sksg/Container.js.map +1 -0
- package/lib/commonjs/sksg/DrawingContext.d.ts +16 -0
- package/lib/commonjs/sksg/DrawingContext.js +186 -0
- package/lib/commonjs/sksg/DrawingContext.js.map +1 -0
- package/lib/commonjs/sksg/HostConfig.d.ts +19 -0
- package/lib/commonjs/sksg/HostConfig.js +168 -0
- package/lib/commonjs/sksg/HostConfig.js.map +1 -0
- package/lib/commonjs/sksg/Reconciler.d.ts +17 -0
- package/lib/commonjs/sksg/Reconciler.js +54 -0
- package/lib/commonjs/sksg/Reconciler.js.map +1 -0
- package/lib/commonjs/sksg/__tests__/MockDeclaration.d.ts +57 -0
- package/lib/commonjs/sksg/nodes/Node.d.ts +7 -0
- package/lib/commonjs/sksg/nodes/Node.js +6 -0
- package/lib/commonjs/sksg/nodes/Node.js.map +1 -0
- package/lib/commonjs/sksg/nodes/colorFilters.d.ts +7 -0
- package/lib/commonjs/sksg/nodes/colorFilters.js +55 -0
- package/lib/commonjs/sksg/nodes/colorFilters.js.map +1 -0
- package/lib/commonjs/sksg/nodes/context.d.ts +3 -0
- package/lib/commonjs/sksg/nodes/context.js +448 -0
- package/lib/commonjs/sksg/nodes/context.js.map +1 -0
- package/lib/commonjs/sksg/nodes/drawings.d.ts +31 -0
- package/lib/commonjs/sksg/nodes/drawings.js +361 -0
- package/lib/commonjs/sksg/nodes/drawings.js.map +1 -0
- package/lib/commonjs/sksg/nodes/imageFilters.d.ts +14 -0
- package/lib/commonjs/sksg/nodes/imageFilters.js +135 -0
- package/lib/commonjs/sksg/nodes/imageFilters.js.map +1 -0
- package/lib/commonjs/sksg/nodes/index.d.ts +3 -0
- package/lib/commonjs/sksg/nodes/index.js +39 -0
- package/lib/commonjs/sksg/nodes/index.js.map +1 -0
- package/lib/commonjs/sksg/nodes/paint.d.ts +2 -0
- package/lib/commonjs/sksg/nodes/paint.js +80 -0
- package/lib/commonjs/sksg/nodes/paint.js.map +1 -0
- package/lib/commonjs/sksg/nodes/pathEffects.d.ts +8 -0
- package/lib/commonjs/sksg/nodes/pathEffects.js +84 -0
- package/lib/commonjs/sksg/nodes/pathEffects.js.map +1 -0
- package/lib/commonjs/sksg/nodes/shaders.d.ts +10 -0
- package/lib/commonjs/sksg/nodes/shaders.js +156 -0
- package/lib/commonjs/sksg/nodes/shaders.js.map +1 -0
- package/lib/commonjs/sksg/nodes/utils.d.ts +3 -0
- package/lib/commonjs/sksg/nodes/utils.js +25 -0
- package/lib/commonjs/sksg/nodes/utils.js.map +1 -0
- package/lib/commonjs/views/SkiaPictureView.js +0 -2
- package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
- package/lib/commonjs/views/types.d.ts +2 -2
- package/lib/commonjs/views/types.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Circle.d.ts +2 -3
- package/lib/module/dom/nodes/datatypes/Circle.js +12 -6
- package/lib/module/dom/nodes/datatypes/Circle.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Enum.js +2 -0
- package/lib/module/dom/nodes/datatypes/Enum.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Fitting.js +2 -10
- package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Gradient.js +4 -2
- package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Path.js +5 -1
- package/lib/module/dom/nodes/datatypes/Path.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Radius.js +2 -0
- package/lib/module/dom/nodes/datatypes/Radius.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Rect.d.ts +3 -1
- package/lib/module/dom/nodes/datatypes/Rect.js +14 -5
- package/lib/module/dom/nodes/datatypes/Rect.js.map +1 -1
- package/lib/module/dom/nodes/datatypes/Transform.d.ts +2 -1
- package/lib/module/dom/nodes/datatypes/Transform.js +31 -0
- package/lib/module/dom/nodes/datatypes/Transform.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Box.js +1 -2
- package/lib/module/dom/nodes/drawings/Box.js.map +1 -1
- package/lib/module/dom/nodes/drawings/CircleNode.js +1 -1
- package/lib/module/dom/nodes/drawings/CircleNode.js.map +1 -1
- package/lib/module/dom/types/DeclarationContext.d.ts +4 -4
- package/lib/module/dom/types/DeclarationContext.js +9 -2
- package/lib/module/dom/types/DeclarationContext.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/module/external/reanimated/renderHelpers.js +8 -4
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/renderer/HostConfig.js +8 -4
- package/lib/module/renderer/HostConfig.js.map +1 -1
- package/lib/module/renderer/__tests__/setup.d.ts +2 -3
- package/lib/module/renderer/processors/Animations/Animations.d.ts +1 -2
- package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
- package/lib/module/renderer/typeddash.js +5 -1
- package/lib/module/renderer/typeddash.js.map +1 -1
- package/lib/module/skia/__tests__/setup.d.ts +0 -3
- package/lib/module/skia/types/Path/Path.js +5 -1
- package/lib/module/skia/types/Path/Path.js.map +1 -1
- package/lib/module/skia/types/Shader/Shader.js +9 -6
- package/lib/module/skia/types/Shader/Shader.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +19 -0
- package/lib/module/sksg/Container.js +94 -0
- package/lib/module/sksg/Container.js.map +1 -0
- package/lib/module/sksg/DrawingContext.d.ts +16 -0
- package/lib/module/sksg/DrawingContext.js +180 -0
- package/lib/module/sksg/DrawingContext.js.map +1 -0
- package/lib/module/sksg/HostConfig.d.ts +19 -0
- package/lib/module/sksg/HostConfig.js +161 -0
- package/lib/module/sksg/HostConfig.js.map +1 -0
- package/lib/module/sksg/Reconciler.d.ts +17 -0
- package/lib/module/sksg/Reconciler.js +46 -0
- package/lib/module/sksg/Reconciler.js.map +1 -0
- package/lib/module/sksg/__tests__/MockDeclaration.d.ts +57 -0
- package/lib/module/sksg/nodes/Node.d.ts +7 -0
- package/lib/module/sksg/nodes/Node.js +2 -0
- package/lib/module/sksg/nodes/Node.js.map +1 -0
- package/lib/module/sksg/nodes/colorFilters.d.ts +7 -0
- package/lib/module/sksg/nodes/colorFilters.js +44 -0
- package/lib/module/sksg/nodes/colorFilters.js.map +1 -0
- package/lib/module/sksg/nodes/context.d.ts +3 -0
- package/lib/module/sksg/nodes/context.js +443 -0
- package/lib/module/sksg/nodes/context.js.map +1 -0
- package/lib/module/sksg/nodes/drawings.d.ts +31 -0
- package/lib/module/sksg/nodes/drawings.js +334 -0
- package/lib/module/sksg/nodes/drawings.js.map +1 -0
- package/lib/module/sksg/nodes/imageFilters.d.ts +14 -0
- package/lib/module/sksg/nodes/imageFilters.js +122 -0
- package/lib/module/sksg/nodes/imageFilters.js.map +1 -0
- package/lib/module/sksg/nodes/index.d.ts +3 -0
- package/lib/module/sksg/nodes/index.js +4 -0
- package/lib/module/sksg/nodes/index.js.map +1 -0
- package/lib/module/sksg/nodes/paint.d.ts +2 -0
- package/lib/module/sksg/nodes/paint.js +74 -0
- package/lib/module/sksg/nodes/paint.js.map +1 -0
- package/lib/module/sksg/nodes/pathEffects.d.ts +8 -0
- package/lib/module/sksg/nodes/pathEffects.js +72 -0
- package/lib/module/sksg/nodes/pathEffects.js.map +1 -0
- package/lib/module/sksg/nodes/shaders.d.ts +10 -0
- package/lib/module/sksg/nodes/shaders.js +142 -0
- package/lib/module/sksg/nodes/shaders.js.map +1 -0
- package/lib/module/sksg/nodes/utils.d.ts +3 -0
- package/lib/module/sksg/nodes/utils.js +18 -0
- package/lib/module/sksg/nodes/utils.js.map +1 -0
- package/lib/module/views/SkiaPictureView.js +0 -2
- package/lib/module/views/SkiaPictureView.js.map +1 -1
- package/lib/module/views/types.d.ts +2 -2
- package/lib/module/views/types.js.map +1 -1
- package/lib/typescript/lib/commonjs/dom/nodes/datatypes/Circle.d.ts +1 -1
- package/lib/typescript/lib/commonjs/dom/nodes/datatypes/Rect.d.ts +2 -0
- package/lib/typescript/lib/commonjs/dom/nodes/datatypes/Transform.d.ts +1 -0
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/typescript/lib/commonjs/renderer/HostConfig.d.ts +3 -1
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +16 -0
- package/lib/typescript/lib/commonjs/sksg/DrawingContext.d.ts +26 -0
- package/lib/typescript/lib/commonjs/sksg/HostConfig.d.ts +50 -0
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +16 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/Node.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/colorFilters.d.ts +7 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/context.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/drawings.d.ts +23 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/imageFilters.d.ts +10 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/paint.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/pathEffects.d.ts +8 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/shaders.d.ts +10 -0
- package/lib/typescript/lib/commonjs/sksg/nodes/utils.d.ts +3 -0
- package/lib/typescript/lib/module/dom/nodes/datatypes/Circle.d.ts +1 -1
- package/lib/typescript/lib/module/dom/nodes/datatypes/Rect.d.ts +2 -0
- package/lib/typescript/lib/module/dom/nodes/datatypes/Transform.d.ts +1 -0
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/typescript/lib/module/mock/index.d.ts +4 -1
- package/lib/typescript/lib/module/renderer/HostConfig.d.ts +3 -1
- package/lib/typescript/lib/module/sksg/Container.d.ts +15 -0
- package/lib/typescript/lib/module/sksg/DrawingContext.d.ts +26 -0
- package/lib/typescript/lib/module/sksg/HostConfig.d.ts +49 -0
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +15 -0
- package/lib/typescript/lib/module/sksg/nodes/colorFilters.d.ts +6 -0
- package/lib/typescript/lib/module/sksg/nodes/context.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/nodes/drawings.d.ts +22 -0
- package/lib/typescript/lib/module/sksg/nodes/imageFilters.d.ts +9 -0
- package/lib/typescript/lib/module/sksg/nodes/index.d.ts +3 -0
- package/lib/typescript/lib/module/sksg/nodes/paint.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/nodes/pathEffects.d.ts +7 -0
- package/lib/typescript/lib/module/sksg/nodes/shaders.d.ts +9 -0
- package/lib/typescript/lib/module/sksg/nodes/utils.d.ts +2 -0
- package/lib/typescript/src/dom/nodes/datatypes/Circle.d.ts +2 -3
- package/lib/typescript/src/dom/nodes/datatypes/Rect.d.ts +3 -1
- package/lib/typescript/src/dom/nodes/datatypes/Transform.d.ts +2 -1
- package/lib/typescript/src/dom/types/DeclarationContext.d.ts +4 -4
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +2 -0
- package/lib/typescript/src/renderer/__tests__/setup.d.ts +2 -3
- package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +1 -2
- package/lib/typescript/src/skia/__tests__/setup.d.ts +0 -3
- package/lib/typescript/src/sksg/Container.d.ts +19 -0
- package/lib/typescript/src/sksg/DrawingContext.d.ts +16 -0
- package/lib/typescript/src/sksg/HostConfig.d.ts +19 -0
- package/lib/typescript/src/sksg/Reconciler.d.ts +17 -0
- package/lib/typescript/src/sksg/__tests__/MockDeclaration.d.ts +57 -0
- package/lib/typescript/src/sksg/nodes/Node.d.ts +7 -0
- package/lib/typescript/src/sksg/nodes/colorFilters.d.ts +7 -0
- package/lib/typescript/src/sksg/nodes/context.d.ts +3 -0
- package/lib/typescript/src/sksg/nodes/drawings.d.ts +31 -0
- package/lib/typescript/src/sksg/nodes/imageFilters.d.ts +14 -0
- package/lib/typescript/src/sksg/nodes/index.d.ts +3 -0
- package/lib/typescript/src/sksg/nodes/paint.d.ts +2 -0
- package/lib/typescript/src/sksg/nodes/pathEffects.d.ts +8 -0
- package/lib/typescript/src/sksg/nodes/shaders.d.ts +10 -0
- package/lib/typescript/src/sksg/nodes/utils.d.ts +3 -0
- package/lib/typescript/src/views/types.d.ts +2 -2
- package/libs/{ios → apple}/libskia.xcframework/Info.plist +15 -0
- package/libs/{ios → apple}/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libskottie.xcframework/Info.plist +20 -5
- package/libs/{ios → apple}/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libskparagraph.xcframework/Info.plist +20 -5
- package/libs/{ios → apple}/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libsksg.xcframework/Info.plist +15 -0
- package/libs/{ios → apple}/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libskshaper.xcframework/Info.plist +20 -5
- package/libs/{ios → apple}/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libskunicode_core.xcframework/Info.plist +18 -3
- package/libs/{ios → apple}/libskunicode_core.xcframework/ios-arm64_arm64e/libskunicode_core.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libskunicode_libgrapheme.xcframework/Info.plist +15 -0
- package/libs/{ios → apple}/libskunicode_libgrapheme.xcframework/ios-arm64_arm64e/libskunicode_libgrapheme.a +0 -0
- package/libs/{ios → 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/{ios → apple}/libsvg.xcframework/Info.plist +15 -0
- package/libs/{ios → apple}/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/{ios → 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/package.json +3 -3
- package/react-native-skia.podspec +9 -9
- package/src/__tests__/setup.ts +1 -1
- package/src/__tests__/snapshots/sksg/breathe-0.png +0 -0
- package/src/__tests__/snapshots/sksg/breathe.png +0 -0
- package/src/__tests__/snapshots/sksg/simple.png +0 -0
- package/src/__tests__/snapshots/sksg/simple2.png +0 -0
- package/src/dom/nodes/JsiSkDOM.ts +2 -1
- package/src/dom/nodes/datatypes/Circle.ts +7 -5
- package/src/dom/nodes/datatypes/Enum.ts +2 -0
- package/src/dom/nodes/datatypes/Fitting.ts +2 -5
- package/src/dom/nodes/datatypes/Gradient.ts +4 -7
- package/src/dom/nodes/datatypes/Path.ts +5 -2
- package/src/dom/nodes/datatypes/Radius.ts +2 -0
- package/src/dom/nodes/datatypes/Rect.ts +40 -6
- package/src/dom/nodes/datatypes/Transform.ts +29 -1
- package/src/dom/nodes/drawings/Box.ts +1 -29
- package/src/dom/nodes/drawings/CircleNode.ts +1 -1
- package/src/dom/types/DeclarationContext.ts +12 -2
- package/src/external/reanimated/renderHelpers.ts +8 -4
- package/src/renderer/HostConfig.ts +10 -4
- package/src/renderer/__tests__/documentation/shapes/Box.spec.tsx +2 -2
- package/src/renderer/__tests__/setup.tsx +17 -15
- package/src/renderer/processors/Animations/Animations.ts +1 -5
- package/src/renderer/typeddash.ts +4 -2
- package/src/skia/__tests__/setup.ts +1 -51
- package/src/skia/types/Path/Path.ts +4 -2
- package/src/skia/types/Shader/Shader.ts +7 -4
- package/src/sksg/Container.ts +102 -0
- package/src/sksg/DrawingContext.ts +221 -0
- package/src/sksg/HostConfig.ts +287 -0
- package/src/sksg/Reconciler.ts +59 -0
- package/src/sksg/__tests__/Declarations.spec.tsx +235 -0
- package/src/sksg/__tests__/MockDeclaration.ts +140 -0
- package/src/sksg/__tests__/Simple.spec.tsx +148 -0
- package/src/sksg/nodes/Node.ts +8 -0
- package/src/sksg/nodes/colorFilters.ts +60 -0
- package/src/sksg/nodes/context.ts +489 -0
- package/src/sksg/nodes/drawings.ts +393 -0
- package/src/sksg/nodes/imageFilters.ts +183 -0
- package/src/sksg/nodes/index.ts +3 -0
- package/src/sksg/nodes/paint.ts +75 -0
- package/src/sksg/nodes/pathEffects.ts +95 -0
- package/src/sksg/nodes/shaders.ts +203 -0
- package/src/sksg/nodes/utils.ts +23 -0
- package/src/views/SkiaPictureView.tsx +0 -2
- package/src/views/types.ts +2 -2
- package/lib/commonjs/dom/__tests__/Shaders.spec.d.ts +0 -1
- package/lib/commonjs/renderer/__tests__/SkiaDOM.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/Compose.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/Demos.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/DrawingContext.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/Drawings.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/Group.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/Paint.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/RenderNodes.spec.d.ts +0 -1
- package/lib/module/dom/__tests__/Shaders.spec.d.ts +0 -1
- package/lib/module/renderer/__tests__/SkiaDOM.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/Compose.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/Demos.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/DrawingContext.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/Drawings.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/Group.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/Paint.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/RenderNodes.spec.d.ts +0 -1
- package/lib/typescript/src/dom/__tests__/Shaders.spec.d.ts +0 -1
- package/lib/typescript/src/renderer/__tests__/SkiaDOM.spec.d.ts +0 -1
- package/src/dom/__tests__/Compose.spec.tsx +0 -42
- package/src/dom/__tests__/Demos.spec.tsx +0 -145
- package/src/dom/__tests__/DrawingContext.spec.tsx +0 -99
- package/src/dom/__tests__/Drawings.spec.tsx +0 -95
- package/src/dom/__tests__/Group.spec.tsx +0 -132
- package/src/dom/__tests__/Paint.spec.tsx +0 -100
- package/src/dom/__tests__/RenderNodes.spec.tsx +0 -44
- package/src/dom/__tests__/Shaders.spec.tsx +0 -123
- package/src/renderer/__tests__/SkiaDOM.spec.tsx +0 -46
- /package/lib/commonjs/{dom/__tests__/Compose.spec.d.ts → sksg/__tests__/Declarations.spec.d.ts} +0 -0
- /package/lib/commonjs/{dom/__tests__/Demos.spec.d.ts → sksg/__tests__/Simple.spec.d.ts} +0 -0
- /package/lib/{commonjs/dom/__tests__/DrawingContext.spec.d.ts → module/sksg/__tests__/Declarations.spec.d.ts} +0 -0
- /package/lib/{commonjs/dom/__tests__/Drawings.spec.d.ts → module/sksg/__tests__/Simple.spec.d.ts} +0 -0
- /package/lib/{commonjs/dom/__tests__/Group.spec.d.ts → typescript/lib/module/sksg/nodes/Node.d.ts} +0 -0
- /package/lib/{commonjs/dom/__tests__/Paint.spec.d.ts → typescript/src/sksg/__tests__/Declarations.spec.d.ts} +0 -0
- /package/lib/{commonjs/dom/__tests__/RenderNodes.spec.d.ts → typescript/src/sksg/__tests__/Simple.spec.d.ts} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
"worklet";
|
|
2
|
+
|
|
1
3
|
import type { TransformProps } from "../../types";
|
|
2
|
-
import type { SkMatrix } from "../../../skia/types";
|
|
4
|
+
import type { Skia, SkMatrix } from "../../../skia/types";
|
|
3
5
|
import { processTransform } from "../../../skia/types";
|
|
4
6
|
|
|
5
7
|
export const processTransformProps = (m3: SkMatrix, props: TransformProps) => {
|
|
@@ -22,3 +24,29 @@ export const processTransformProps = (m3: SkMatrix, props: TransformProps) => {
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
};
|
|
27
|
+
|
|
28
|
+
export const processTransformProps2 = (Skia: Skia, props: TransformProps) => {
|
|
29
|
+
const { transform, origin, matrix } = props;
|
|
30
|
+
if (matrix) {
|
|
31
|
+
const m3 = Skia.Matrix();
|
|
32
|
+
if (origin) {
|
|
33
|
+
m3.translate(origin.x, origin.y);
|
|
34
|
+
m3.concat(matrix);
|
|
35
|
+
m3.translate(-origin.x, -origin.y);
|
|
36
|
+
} else {
|
|
37
|
+
m3.concat(matrix);
|
|
38
|
+
}
|
|
39
|
+
return m3;
|
|
40
|
+
} else if (transform) {
|
|
41
|
+
const m3 = Skia.Matrix();
|
|
42
|
+
if (origin) {
|
|
43
|
+
m3.translate(origin.x, origin.y);
|
|
44
|
+
}
|
|
45
|
+
processTransform(m3, transform);
|
|
46
|
+
if (origin) {
|
|
47
|
+
m3.translate(-origin.x, -origin.y);
|
|
48
|
+
}
|
|
49
|
+
return m3;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SkRRect, Skia } from "../../../skia/types";
|
|
2
1
|
import { BlurStyle, ClipOp, isRRect } from "../../../skia/types";
|
|
3
2
|
import type { DrawingContext } from "../../types";
|
|
4
3
|
import { NodeType } from "../../types";
|
|
@@ -7,34 +6,7 @@ import type { NodeContext } from "../Node";
|
|
|
7
6
|
import { JsiDeclarationNode } from "../Node";
|
|
8
7
|
import { JsiRenderNode } from "../RenderNode";
|
|
9
8
|
import type { DeclarationContext } from "../../types/DeclarationContext";
|
|
10
|
-
|
|
11
|
-
const inflate = (
|
|
12
|
-
Skia: Skia,
|
|
13
|
-
box: SkRRect,
|
|
14
|
-
dx: number,
|
|
15
|
-
dy: number,
|
|
16
|
-
tx = 0,
|
|
17
|
-
ty = 0
|
|
18
|
-
) =>
|
|
19
|
-
Skia.RRectXY(
|
|
20
|
-
Skia.XYWHRect(
|
|
21
|
-
box.rect.x - dx + tx,
|
|
22
|
-
box.rect.y - dy + ty,
|
|
23
|
-
box.rect.width + 2 * dx,
|
|
24
|
-
box.rect.height + 2 * dy
|
|
25
|
-
),
|
|
26
|
-
box.rx + dx,
|
|
27
|
-
box.ry + dy
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const deflate = (
|
|
31
|
-
Skia: Skia,
|
|
32
|
-
box: SkRRect,
|
|
33
|
-
dx: number,
|
|
34
|
-
dy: number,
|
|
35
|
-
tx = 0,
|
|
36
|
-
ty = 0
|
|
37
|
-
) => inflate(Skia, box, -dx, -dy, tx, ty);
|
|
9
|
+
import { deflate, inflate } from "../datatypes";
|
|
38
10
|
|
|
39
11
|
export class BoxShadowNode extends JsiDeclarationNode<BoxShadowProps> {
|
|
40
12
|
constructor(ctx: NodeContext, props: BoxShadowProps) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"worklet";
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
SkShader,
|
|
3
5
|
SkPaint,
|
|
@@ -25,8 +27,11 @@ export const composeDeclarations = <T>(filters: T[], composer: Composer<T>) => {
|
|
|
25
27
|
class Declaration<T> {
|
|
26
28
|
private decls: T[] = [];
|
|
27
29
|
private indexes = [0];
|
|
30
|
+
private composer?: Composer<T>;
|
|
28
31
|
|
|
29
|
-
constructor(
|
|
32
|
+
constructor(composer?: Composer<T>) {
|
|
33
|
+
this.composer = composer;
|
|
34
|
+
}
|
|
30
35
|
|
|
31
36
|
private get index() {
|
|
32
37
|
return this.indexes[this.indexes.length - 1];
|
|
@@ -53,6 +58,9 @@ class Declaration<T> {
|
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
popAllAsOne() {
|
|
61
|
+
if (this.decls.length === 0) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
56
64
|
if (!this.composer) {
|
|
57
65
|
throw new Error("No composer for this type of declaration");
|
|
58
66
|
}
|
|
@@ -62,6 +70,7 @@ class Declaration<T> {
|
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
export class DeclarationContext {
|
|
73
|
+
public Skia: Skia;
|
|
65
74
|
readonly paints: Declaration<SkPaint>;
|
|
66
75
|
readonly maskFilters: Declaration<SkMaskFilter>;
|
|
67
76
|
readonly shaders: Declaration<SkShader>;
|
|
@@ -69,7 +78,8 @@ export class DeclarationContext {
|
|
|
69
78
|
readonly imageFilters: Declaration<SkImageFilter>;
|
|
70
79
|
readonly colorFilters: Declaration<SkColorFilter>;
|
|
71
80
|
|
|
72
|
-
constructor(
|
|
81
|
+
constructor(Skia: Skia) {
|
|
82
|
+
this.Skia = Skia;
|
|
73
83
|
const peComp = this.Skia.PathEffect.MakeCompose.bind(this.Skia.PathEffect);
|
|
74
84
|
const ifComp = this.Skia.ImageFilter.MakeCompose.bind(
|
|
75
85
|
this.Skia.ImageFilter
|
|
@@ -6,13 +6,17 @@ import type { Node } from "../../dom/types";
|
|
|
6
6
|
|
|
7
7
|
import Rea from "./ReanimatedProxy";
|
|
8
8
|
|
|
9
|
-
let HAS_REANIMATED = false;
|
|
10
|
-
let HAS_REANIMATED_3 = false;
|
|
9
|
+
export let HAS_REANIMATED = false;
|
|
10
|
+
export let HAS_REANIMATED_3 = false;
|
|
11
11
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// This logic is convoluted but necessary
|
|
13
|
+
// In most systems, `require("react-native-reanimated")` throws an error, all is well.
|
|
14
|
+
// In webpack, in some configuration it will return an empty object.
|
|
15
|
+
// So it will not throw an error and we need to check the version to know if it's there.
|
|
14
16
|
const reanimatedVersion =
|
|
15
17
|
require("react-native-reanimated/package.json").version;
|
|
18
|
+
require("react-native-reanimated");
|
|
19
|
+
HAS_REANIMATED = !!reanimatedVersion;
|
|
16
20
|
if (
|
|
17
21
|
reanimatedVersion &&
|
|
18
22
|
(reanimatedVersion >= "3.0.0" || reanimatedVersion.includes("3.0.0-"))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*global NodeJS*/
|
|
2
|
-
import type { HostConfig } from "react-reconciler";
|
|
2
|
+
import type { Fiber, HostConfig } from "react-reconciler";
|
|
3
3
|
import { DefaultEventPriority } from "react-reconciler/constants";
|
|
4
4
|
|
|
5
5
|
import type { NodeType, Node } from "../dom/types";
|
|
@@ -78,7 +78,6 @@ export const skHostConfig: SkiaHostConfig = {
|
|
|
78
78
|
/**
|
|
79
79
|
* This function is used by the reconciler in order to calculate current time for prioritising work.
|
|
80
80
|
*/
|
|
81
|
-
now: Date.now,
|
|
82
81
|
supportsMutation: true,
|
|
83
82
|
isPrimaryRenderer: false,
|
|
84
83
|
supportsPersistence: false,
|
|
@@ -242,11 +241,18 @@ export const skHostConfig: SkiaHostConfig = {
|
|
|
242
241
|
insertBefore: (parent, child, before) => {
|
|
243
242
|
insertBefore(parent, child, before);
|
|
244
243
|
},
|
|
244
|
+
|
|
245
245
|
// see https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
247
|
-
// @ts-expect-error
|
|
248
246
|
getCurrentEventPriority: () => DefaultEventPriority,
|
|
249
247
|
beforeActiveInstanceBlur: () => {},
|
|
250
248
|
afterActiveInstanceBlur: () => {},
|
|
251
249
|
detachDeletedInstance: () => {},
|
|
250
|
+
|
|
251
|
+
getInstanceFromNode: function (_node): Fiber | null | undefined {
|
|
252
|
+
return null;
|
|
253
|
+
},
|
|
254
|
+
prepareScopeUpdate: function (_scopeInstance, _instance): void {},
|
|
255
|
+
getInstanceFromScope: function (_scopeInstance): Instance | null {
|
|
256
|
+
return null;
|
|
257
|
+
},
|
|
252
258
|
};
|
|
@@ -27,7 +27,7 @@ describe("Box", () => {
|
|
|
27
27
|
</Box>
|
|
28
28
|
</>
|
|
29
29
|
);
|
|
30
|
-
processResult(surface, docPath("box/shadows.png")
|
|
30
|
+
processResult(surface, docPath("box/shadows.png"));
|
|
31
31
|
});
|
|
32
32
|
it("should draw a box with red stroke", () => {
|
|
33
33
|
const size = width / 2;
|
|
@@ -41,6 +41,6 @@ describe("Box", () => {
|
|
|
41
41
|
/>
|
|
42
42
|
</>
|
|
43
43
|
);
|
|
44
|
-
processResult(surface, docPath("box/box-stroke.png")
|
|
44
|
+
processResult(surface, docPath("box/box-stroke.png"));
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -8,15 +8,13 @@ import type { Server, WebSocket } from "ws";
|
|
|
8
8
|
|
|
9
9
|
import type * as SkiaExports from "../../index";
|
|
10
10
|
import { JsiSkApi } from "../../skia/web/JsiSkia";
|
|
11
|
-
import type { Node } from "../../dom/nodes";
|
|
12
|
-
import { JsiSkDOM } from "../../dom/nodes";
|
|
13
11
|
import { Group } from "../components";
|
|
14
12
|
import type { SkImage, SkFont, Skia, SkCanvas } from "../../skia/types";
|
|
15
13
|
import { isPath } from "../../skia/types";
|
|
16
14
|
import { E2E } from "../../__tests__/setup";
|
|
17
|
-
import { SkiaRoot } from "../Reconciler";
|
|
18
|
-
import { JsiDrawingContext } from "../../dom/types/DrawingContext";
|
|
19
15
|
import { LoadSkiaWeb } from "../../web/LoadSkiaWeb";
|
|
16
|
+
import { SkiaSGRoot } from "../../sksg/Reconciler";
|
|
17
|
+
import type { Node } from "../../sksg/nodes";
|
|
20
18
|
|
|
21
19
|
import { SkiaObject } from "./e2e/setup";
|
|
22
20
|
|
|
@@ -172,11 +170,6 @@ export const importSkia = (): typeof SkiaExports => {
|
|
|
172
170
|
};
|
|
173
171
|
};
|
|
174
172
|
|
|
175
|
-
export const getSkDOM = () => {
|
|
176
|
-
const { Skia } = importSkia();
|
|
177
|
-
return new JsiSkDOM({ Skia }, false);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
173
|
export const PIXEL_RATIO = 3;
|
|
181
174
|
export const fontSize = 32 * PIXEL_RATIO;
|
|
182
175
|
export const width = 256 * PIXEL_RATIO;
|
|
@@ -197,21 +190,20 @@ export const mountCanvas = (element: ReactNode) => {
|
|
|
197
190
|
expect(ckSurface).toBeDefined();
|
|
198
191
|
const canvas = ckSurface.getCanvas();
|
|
199
192
|
|
|
200
|
-
const root = new
|
|
193
|
+
const root = new SkiaSGRoot(Skia);
|
|
201
194
|
root.render(element);
|
|
202
195
|
return {
|
|
203
196
|
surface: ckSurface,
|
|
204
197
|
root,
|
|
205
198
|
draw: () => {
|
|
206
|
-
|
|
207
|
-
root.dom.render(ctx);
|
|
199
|
+
root.drawOnCanvas(canvas);
|
|
208
200
|
},
|
|
209
201
|
};
|
|
210
202
|
};
|
|
211
203
|
|
|
212
204
|
export const serialize = (element: ReactNode) => {
|
|
213
205
|
const { root } = mountCanvas(element);
|
|
214
|
-
const serialized = serializeNode(root.
|
|
206
|
+
const serialized = serializeNode(root.sg);
|
|
215
207
|
return JSON.stringify(serialized);
|
|
216
208
|
};
|
|
217
209
|
|
|
@@ -228,6 +220,8 @@ interface SerializedNode {
|
|
|
228
220
|
const serializeSkOjects = (obj: any): any => {
|
|
229
221
|
if (typeof obj === "function") {
|
|
230
222
|
return { __typename__: "Function", source: `${obj.toString()}` };
|
|
223
|
+
} else if (obj instanceof Float32Array) {
|
|
224
|
+
return { __typename__: "Float32Array", value: Array.from(obj) };
|
|
231
225
|
} else if (Array.isArray(obj)) {
|
|
232
226
|
return obj.map((item) => serializeSkOjects(item));
|
|
233
227
|
} else if (obj && typeof obj === "object" && "__typename__" in obj) {
|
|
@@ -302,13 +296,21 @@ const serializeSkOjects = (obj: any): any => {
|
|
|
302
296
|
ty: obj.ty,
|
|
303
297
|
};
|
|
304
298
|
}
|
|
299
|
+
} else if (obj && typeof obj === "object") {
|
|
300
|
+
const result = Object.keys(obj).reduce((acc, key) => {
|
|
301
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
302
|
+
// @ts-ignore
|
|
303
|
+
acc[key] = serializeSkOjects(obj[key]);
|
|
304
|
+
return acc;
|
|
305
|
+
}, {});
|
|
306
|
+
return result;
|
|
305
307
|
}
|
|
306
308
|
return obj;
|
|
307
309
|
};
|
|
308
310
|
|
|
309
311
|
const serializeNode = (node: Node<any>): SerializedNode => {
|
|
310
312
|
const props: any = {};
|
|
311
|
-
const ogProps = node.
|
|
313
|
+
const ogProps = node.props;
|
|
312
314
|
if (ogProps) {
|
|
313
315
|
Object.keys(ogProps)
|
|
314
316
|
.filter((key) => key !== "children")
|
|
@@ -319,7 +321,7 @@ const serializeNode = (node: Node<any>): SerializedNode => {
|
|
|
319
321
|
return {
|
|
320
322
|
type: node.type,
|
|
321
323
|
props,
|
|
322
|
-
children: node.children
|
|
324
|
+
children: node.children.map((child) => serializeNode(child)),
|
|
323
325
|
};
|
|
324
326
|
};
|
|
325
327
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export type
|
|
2
|
-
value: T;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export type AnimatedProp<T> = T | SharedValueType<T>;
|
|
1
|
+
export type AnimatedProp<T> = T | { value: T };
|
|
6
2
|
|
|
7
3
|
export type AnimatedProps<T, O extends keyof T | never = never> = {
|
|
8
4
|
[K in keyof T]: K extends "children"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export const mapKeys = <T extends object>(obj: T) =>
|
|
2
|
-
|
|
1
|
+
export const mapKeys = <T extends object>(obj: T) => {
|
|
2
|
+
"worklet";
|
|
3
|
+
return Object.keys(obj) as (keyof T)[];
|
|
4
|
+
};
|
|
3
5
|
|
|
4
6
|
export const exhaustiveCheck = (a: never): never => {
|
|
5
7
|
"worklet";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { Node } from "../../dom/types";
|
|
2
|
-
import { mapKeys } from "../../renderer/typeddash";
|
|
3
1
|
import { LoadSkiaWeb } from "../../web/LoadSkiaWeb";
|
|
4
|
-
import {
|
|
2
|
+
import { Skia } from "../types";
|
|
5
3
|
import { JsiSkApi } from "../web";
|
|
6
4
|
|
|
7
5
|
let Skia: ReturnType<typeof JsiSkApi>;
|
|
@@ -27,51 +25,3 @@ export const setupSkia = (width = 256, height = 256) => {
|
|
|
27
25
|
CanvasKit: global.CanvasKit,
|
|
28
26
|
};
|
|
29
27
|
};
|
|
30
|
-
|
|
31
|
-
const asValue = (value: unknown) => {
|
|
32
|
-
if (value instanceof Float32Array) {
|
|
33
|
-
return Array.from(value)
|
|
34
|
-
.map((v) => Math.round(v * 100) / 100)
|
|
35
|
-
.join(", ");
|
|
36
|
-
} else if (isMatrix(value)) {
|
|
37
|
-
// TODO: https://github.com/Shopify/react-native-skia/issues/715
|
|
38
|
-
return "m3x3";
|
|
39
|
-
} else if (
|
|
40
|
-
typeof value === "object" &&
|
|
41
|
-
value !== null &&
|
|
42
|
-
"x" in value &&
|
|
43
|
-
"y" in value
|
|
44
|
-
) {
|
|
45
|
-
const v = value as { x: number; y: number };
|
|
46
|
-
return `{x:${v.x}, y:${v.y}}`;
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const printAsXML = (node: Node<unknown>) => {
|
|
52
|
-
console.log(asXML(node));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// Print nodes as XML tree
|
|
56
|
-
export const asXML = (node: Node<unknown>, indent = 0): string => {
|
|
57
|
-
// TODO: remove cast
|
|
58
|
-
const hasChildren = node.children().length > 0;
|
|
59
|
-
const props = node.getProps() as object;
|
|
60
|
-
const space = new Array(indent).fill(" ").join("");
|
|
61
|
-
const keys = mapKeys(props).filter((key) => props[key] !== undefined);
|
|
62
|
-
if (hasChildren) {
|
|
63
|
-
return `${space}<${node.type}${keys.length > 0 ? " " : ""}${keys
|
|
64
|
-
.map((name) => `${name}="${asValue(props[name])}"`)
|
|
65
|
-
.join(" ")}>
|
|
66
|
-
${node
|
|
67
|
-
.children()
|
|
68
|
-
|
|
69
|
-
.map((child) => asXML(child, indent + 2)).join(`
|
|
70
|
-
`)}
|
|
71
|
-
${space}</${node.type}>`;
|
|
72
|
-
} else {
|
|
73
|
-
return `${space}<${node.type} ${keys
|
|
74
|
-
.map((name) => `${name}="${asValue(props[name])}"`)
|
|
75
|
-
.join(" ")} />`;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
@@ -47,8 +47,10 @@ export enum PathVerb {
|
|
|
47
47
|
|
|
48
48
|
export type PathCommand = number[];
|
|
49
49
|
|
|
50
|
-
export const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath =>
|
|
51
|
-
|
|
50
|
+
export const isPath = (obj: SkJSIInstance<string> | null): obj is SkPath => {
|
|
51
|
+
"worklet";
|
|
52
|
+
return obj !== null && obj.__typename__ === "Path";
|
|
53
|
+
};
|
|
52
54
|
|
|
53
55
|
export interface SkPath extends SkJSIInstance<"Path"> {
|
|
54
56
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"worklet";
|
|
2
|
+
|
|
1
3
|
import type { SkJSIInstance } from "../JsiInstance";
|
|
2
4
|
import type { Vector } from "../Point";
|
|
3
5
|
import type { SkRuntimeEffect, SkRuntimeShaderBuilder } from "../RuntimeEffect";
|
|
@@ -18,12 +20,13 @@ export interface Uniforms {
|
|
|
18
20
|
[name: string]: Uniform;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const isVector = (obj: unknown): obj is Vector =>
|
|
23
|
+
const isVector = (obj: unknown): obj is Vector => {
|
|
22
24
|
// We have an issue to check property existence on JSI backed instances
|
|
23
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
(obj as any).x !== undefined && (obj as any).y !== undefined;
|
|
26
|
+
return (obj as any).x !== undefined && (obj as any).y !== undefined;
|
|
27
|
+
};
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
function processValue(values: number[], value: Uniform) {
|
|
27
30
|
if (typeof value === "number") {
|
|
28
31
|
values.push(value);
|
|
29
32
|
} else if (Array.isArray(value)) {
|
|
@@ -33,7 +36,7 @@ const processValue = (values: number[], value: Uniform) => {
|
|
|
33
36
|
} else if (value instanceof Float32Array) {
|
|
34
37
|
values.push(...value);
|
|
35
38
|
}
|
|
36
|
-
}
|
|
39
|
+
}
|
|
37
40
|
|
|
38
41
|
export const processUniforms = (
|
|
39
42
|
source: SkRuntimeEffect,
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
import Rea from "../external/reanimated/ReanimatedProxy";
|
|
4
|
+
import type { Skia, SkCanvas } from "../skia/types";
|
|
5
|
+
import {
|
|
6
|
+
HAS_REANIMATED,
|
|
7
|
+
HAS_REANIMATED_3,
|
|
8
|
+
} from "../external/reanimated/renderHelpers";
|
|
9
|
+
|
|
10
|
+
import { DrawingContext } from "./DrawingContext";
|
|
11
|
+
import type { Node } from "./nodes";
|
|
12
|
+
import { draw, isSharedValue } from "./nodes";
|
|
13
|
+
|
|
14
|
+
const drawOnscreen = (Skia: Skia, nativeId: number, root: Node[]) => {
|
|
15
|
+
"worklet";
|
|
16
|
+
const rec = Skia.PictureRecorder();
|
|
17
|
+
const canvas = rec.beginRecording();
|
|
18
|
+
// TODO: This is only support from 3.15 and above (check the exact version)
|
|
19
|
+
// This could be polyfilled in C++ if needed (or in JS via functions only?)
|
|
20
|
+
const ctx = new DrawingContext(Skia, canvas);
|
|
21
|
+
root.forEach((node) => {
|
|
22
|
+
draw(ctx, node);
|
|
23
|
+
});
|
|
24
|
+
const picture = rec.finishRecordingAsPicture();
|
|
25
|
+
SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class Container {
|
|
29
|
+
public _root: Node[] = [];
|
|
30
|
+
public unmounted = false;
|
|
31
|
+
|
|
32
|
+
private values = new Set<SharedValue<unknown>>();
|
|
33
|
+
private mapperId: number | null = null;
|
|
34
|
+
|
|
35
|
+
constructor(public Skia: Skia, private nativeId: number) {}
|
|
36
|
+
|
|
37
|
+
get root() {
|
|
38
|
+
return this._root;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set root(root: Node[]) {
|
|
42
|
+
const isOnscreen = this.nativeId !== -1;
|
|
43
|
+
if (HAS_REANIMATED && !HAS_REANIMATED_3) {
|
|
44
|
+
throw new Error("React Native Skia only supports Reanimated 3 and above");
|
|
45
|
+
}
|
|
46
|
+
if (isOnscreen) {
|
|
47
|
+
if (this.mapperId !== null) {
|
|
48
|
+
Rea.stopMapper(this.mapperId);
|
|
49
|
+
}
|
|
50
|
+
const { nativeId, Skia } = this;
|
|
51
|
+
this.mapperId = Rea.startMapper(() => {
|
|
52
|
+
"worklet";
|
|
53
|
+
drawOnscreen(Skia, nativeId, root);
|
|
54
|
+
}, Array.from(this.values));
|
|
55
|
+
}
|
|
56
|
+
this._root = root;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
clear() {
|
|
60
|
+
console.log("clear container");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
redraw() {
|
|
64
|
+
const isOnscreen = this.nativeId !== -1;
|
|
65
|
+
if (HAS_REANIMATED && !HAS_REANIMATED_3) {
|
|
66
|
+
throw new Error("React Native Skia only supports Reanimated 3 and above");
|
|
67
|
+
}
|
|
68
|
+
if (isOnscreen) {
|
|
69
|
+
const { nativeId, Skia, root } = this;
|
|
70
|
+
Rea.runOnUI(() => {
|
|
71
|
+
drawOnscreen(Skia, nativeId, root);
|
|
72
|
+
})();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getNativeId() {
|
|
77
|
+
return this.nativeId;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
unregisterValues(values: object) {
|
|
81
|
+
Object.values(values)
|
|
82
|
+
.filter(isSharedValue)
|
|
83
|
+
.forEach((value) => {
|
|
84
|
+
this.values.delete(value);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
registerValues(values: object) {
|
|
89
|
+
Object.values(values)
|
|
90
|
+
.filter(isSharedValue)
|
|
91
|
+
.forEach((value) => {
|
|
92
|
+
this.values.add(value);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
drawOnCanvas(canvas: SkCanvas) {
|
|
97
|
+
const ctx = new DrawingContext(this.Skia, canvas);
|
|
98
|
+
this.root.forEach((node) => {
|
|
99
|
+
draw(ctx, node);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|